-
-
Notifications
You must be signed in to change notification settings - Fork 324
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
42 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
import crypto, { ensureSecureContext } from './webcrypto.js' | ||
import type { DigestFunction } from '../interfaces.d' | ||
|
||
export default async ( | ||
digest: 'sha256' | 'sha384' | 'sha512', | ||
const digest: DigestFunction = async ( | ||
algorithm: 'sha256' | 'sha384' | 'sha512', | ||
data: Uint8Array, | ||
): Promise<Uint8Array> => { | ||
ensureSecureContext() | ||
const subtleDigest = `SHA-${digest.substr(-3)}` | ||
const subtleDigest = `SHA-${algorithm.substr(-3)}` | ||
return new Uint8Array(await crypto.subtle.digest(subtleDigest, data)) | ||
} | ||
export default digest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import type { AsyncOrSync } from '../types.i.d' | ||
declare const _default: (digest: string, data: Uint8Array) => AsyncOrSync<Uint8Array> | ||
export default _default | ||
import type { DigestFunction } from './interfaces.d' | ||
declare const digest: DigestFunction | ||
export default digest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
declare const _default: (url: URL, timeout: number) => Promise<any> | ||
export default _default | ||
import type { FetchFunction } from './interfaces.d' | ||
declare const fetch: FetchFunction | ||
export default fetch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import type { KeyLike, JWK } from '../types.d' | ||
declare const _default: (jwk: JWK) => Promise<KeyLike> | ||
export default _default | ||
import type { JWKParseFunction } from './interfaces.d' | ||
declare const parse: JWKParseFunction | ||
export default parse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
import { createHash } from 'crypto' | ||
import type { DigestFunction } from '../interfaces.d' | ||
|
||
export default (digest: 'sha256' | 'sha384' | 'sha512', data: Uint8Array): Uint8Array => { | ||
return createHash(digest).update(data).digest() | ||
const digest: DigestFunction = ( | ||
algorithm: 'sha256' | 'sha384' | 'sha512', | ||
data: Uint8Array, | ||
): Uint8Array => { | ||
return createHash(algorithm).update(data).digest() | ||
} | ||
export default digest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters