@metamask-previews/cryptography 0.0.0-preview-ff2ab0583 → 0.0.0-preview-a2f6118d2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +0 -6
- package/dist/index.d.ts +7 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -2
- package/dist/index.js.map +1 -1
- package/package.json +6 -7
- package/dist/hmac.d.ts +0 -35
- package/dist/hmac.d.ts.map +0 -1
- package/dist/hmac.js +0 -60
- package/dist/hmac.js.map +0 -1
- package/dist/sha.d.ts +0 -22
- package/dist/sha.d.ts.map +0 -1
- package/dist/sha.js +0 -28
- package/dist/sha.js.map +0 -1
- package/dist/types.d.ts +0 -2
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,10 +7,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
-
### Added
|
|
11
|
-
|
|
12
|
-
- Initial release ([#10282](https://github.com/MetaMask/core/pull/10282), [#10431](https://github.com/MetaMask/core/pull/10431))
|
|
13
|
-
- Add `sha256`, `sha384`, and `sha512` functions for computing SHA digests
|
|
14
|
-
- Add `hmacSha256`, `hmacSha384`, and `hmacSha512` functions for computing HMAC digests
|
|
15
|
-
|
|
16
10
|
[Unreleased]: https://github.com/MetaMask/core/
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Example function that returns a greeting for the given name.
|
|
3
|
+
*
|
|
4
|
+
* @param name - The name to greet.
|
|
5
|
+
* @returns The greeting.
|
|
6
|
+
*/
|
|
7
|
+
export default function greeter(name: string): string;
|
|
4
8
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEpD"}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Example function that returns a greeting for the given name.
|
|
3
|
+
*
|
|
4
|
+
* @param name - The name to greet.
|
|
5
|
+
* @returns The greeting.
|
|
6
|
+
*/
|
|
7
|
+
export default function greeter(name) {
|
|
8
|
+
return `Hello, ${name}!`;
|
|
9
|
+
}
|
|
3
10
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,IAAY;IAC1C,OAAO,UAAU,IAAI,GAAG,CAAC;AAC3B,CAAC","sourcesContent":["/**\n * Example function that returns a greeting for the given name.\n *\n * @param name - The name to greet.\n * @returns The greeting.\n */\nexport default function greeter(name: string): string {\n return `Hello, ${name}!`;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask-previews/cryptography",
|
|
3
|
-
"version": "0.0.0-preview-
|
|
3
|
+
"version": "0.0.0-preview-a2f6118d2",
|
|
4
4
|
"description": "Provides optimized versions of commonly used cryptography functions for MetaMask clients",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Ethereum",
|
|
@@ -50,15 +50,14 @@
|
|
|
50
50
|
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@metamask/auto-changelog": "^6.
|
|
54
|
-
"@metamask/utils": "^12.0.0",
|
|
53
|
+
"@metamask/auto-changelog": "^6.1.0",
|
|
55
54
|
"@types/jest": "^30.0.0",
|
|
56
55
|
"@typescript/native": "npm:typescript@^7.0.2",
|
|
57
|
-
"deepmerge": "^4.
|
|
56
|
+
"deepmerge": "^4.2.2",
|
|
58
57
|
"jest": "^30.4.2",
|
|
59
|
-
"rimraf": "^
|
|
60
|
-
"ts-jest": "^29.4.
|
|
61
|
-
"tsx": "^4.
|
|
58
|
+
"rimraf": "^5.0.5",
|
|
59
|
+
"ts-jest": "^29.4.11",
|
|
60
|
+
"tsx": "^4.20.5",
|
|
62
61
|
"typedoc": "^0.25.13",
|
|
63
62
|
"typedoc-plugin-missing-exports": "^2.0.0",
|
|
64
63
|
"typescript": "npm:@typescript/typescript6@^6.0.2"
|
package/dist/hmac.d.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
export type HmacOptions = {
|
|
2
|
-
/**
|
|
3
|
-
* Skip the minimum key length check. Using a key shorter than the hash
|
|
4
|
-
* output length reduces the effective security strength of HMAC (RFC 2104).
|
|
5
|
-
*/
|
|
6
|
-
unsafeKeyLength?: boolean;
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* Compute the HMAC-SHA-256 of the given data using the given key.
|
|
10
|
-
*
|
|
11
|
-
* @param key - The key to use.
|
|
12
|
-
* @param data - The data to hash.
|
|
13
|
-
* @param options - Additional configuration options.
|
|
14
|
-
* @returns The HMAC-SHA-256 of the data.
|
|
15
|
-
*/
|
|
16
|
-
export declare function hmacSha256(key: BufferSource, data: BufferSource, options?: HmacOptions): Promise<Uint8Array>;
|
|
17
|
-
/**
|
|
18
|
-
* Compute the HMAC-SHA-384 of the given data using the given key.
|
|
19
|
-
*
|
|
20
|
-
* @param key - The key to use.
|
|
21
|
-
* @param data - The data to hash.
|
|
22
|
-
* @param options - Additional configuration options.
|
|
23
|
-
* @returns The HMAC-SHA-384 of the data.
|
|
24
|
-
*/
|
|
25
|
-
export declare function hmacSha384(key: BufferSource, data: BufferSource, options?: HmacOptions): Promise<Uint8Array>;
|
|
26
|
-
/**
|
|
27
|
-
* Compute the HMAC-SHA-512 of the given data using the given key.
|
|
28
|
-
*
|
|
29
|
-
* @param key - The key to use.
|
|
30
|
-
* @param data - The data to hash.
|
|
31
|
-
* @param options - Additional configuration options.
|
|
32
|
-
* @returns The HMAC-SHA-512 of the data.
|
|
33
|
-
*/
|
|
34
|
-
export declare function hmacSha512(key: BufferSource, data: BufferSource, options?: HmacOptions): Promise<Uint8Array>;
|
|
35
|
-
//# sourceMappingURL=hmac.d.ts.map
|
package/dist/hmac.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hmac.d.ts","sourceRoot":"","sources":["../src/hmac.ts"],"names":[],"mappings":"AASA,MAAM,MAAM,WAAW,GAAG;IACxB;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAsB,UAAU,CAC9B,GAAG,EAAE,YAAY,EACjB,IAAI,EAAE,YAAY,EAClB,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,UAAU,CAAC,CAErB;AAED;;;;;;;GAOG;AACH,wBAAsB,UAAU,CAC9B,GAAG,EAAE,YAAY,EACjB,IAAI,EAAE,YAAY,EAClB,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,UAAU,CAAC,CAErB;AAED;;;;;;;GAOG;AACH,wBAAsB,UAAU,CAC9B,GAAG,EAAE,YAAY,EACjB,IAAI,EAAE,YAAY,EAClB,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,UAAU,CAAC,CAErB"}
|
package/dist/hmac.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
// https://datatracker.ietf.org/doc/html/rfc2104#section-3
|
|
2
|
-
const MIN_KEY_LENGTH = {
|
|
3
|
-
'SHA-256': 32,
|
|
4
|
-
'SHA-384': 48,
|
|
5
|
-
'SHA-512': 64,
|
|
6
|
-
};
|
|
7
|
-
/**
|
|
8
|
-
* Compute the HMAC-SHA-256 of the given data using the given key.
|
|
9
|
-
*
|
|
10
|
-
* @param key - The key to use.
|
|
11
|
-
* @param data - The data to hash.
|
|
12
|
-
* @param options - Additional configuration options.
|
|
13
|
-
* @returns The HMAC-SHA-256 of the data.
|
|
14
|
-
*/
|
|
15
|
-
export async function hmacSha256(key, data, options) {
|
|
16
|
-
return hmac(key, 'SHA-256', data, options);
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Compute the HMAC-SHA-384 of the given data using the given key.
|
|
20
|
-
*
|
|
21
|
-
* @param key - The key to use.
|
|
22
|
-
* @param data - The data to hash.
|
|
23
|
-
* @param options - Additional configuration options.
|
|
24
|
-
* @returns The HMAC-SHA-384 of the data.
|
|
25
|
-
*/
|
|
26
|
-
export async function hmacSha384(key, data, options) {
|
|
27
|
-
return hmac(key, 'SHA-384', data, options);
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Compute the HMAC-SHA-512 of the given data using the given key.
|
|
31
|
-
*
|
|
32
|
-
* @param key - The key to use.
|
|
33
|
-
* @param data - The data to hash.
|
|
34
|
-
* @param options - Additional configuration options.
|
|
35
|
-
* @returns The HMAC-SHA-512 of the data.
|
|
36
|
-
*/
|
|
37
|
-
export async function hmacSha512(key, data, options) {
|
|
38
|
-
return hmac(key, 'SHA-512', data, options);
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Compute the HMAC-SHA of the given data using the given key.
|
|
42
|
-
*
|
|
43
|
-
* @param key - The key to use.
|
|
44
|
-
* @param hash - The hash to use.
|
|
45
|
-
* @param data - The data to hash.
|
|
46
|
-
* @param options - Additional configuration options..
|
|
47
|
-
* @returns The HMAC-SHA of the data.
|
|
48
|
-
*/
|
|
49
|
-
async function hmac(key, hash, data, options = {}) {
|
|
50
|
-
if (key.byteLength === 0) {
|
|
51
|
-
throw new Error(`Unsafe key length: Key must not be zero bytes for HMAC-${hash}.`);
|
|
52
|
-
}
|
|
53
|
-
if (!options.unsafeKeyLength && key.byteLength < MIN_KEY_LENGTH[hash]) {
|
|
54
|
-
throw new Error(`Unsafe key length: Key must be at least ${MIN_KEY_LENGTH[hash]} bytes for HMAC-${hash}. To bypass this check, set the \`unsafeKeyLength\` option to \`true\`.`);
|
|
55
|
-
}
|
|
56
|
-
const subtleKey = await globalThis.crypto.subtle.importKey('raw', key, { name: 'HMAC', hash }, false, ['sign']);
|
|
57
|
-
const result = await globalThis.crypto.subtle.sign('HMAC', subtleKey, data);
|
|
58
|
-
return new Uint8Array(result);
|
|
59
|
-
}
|
|
60
|
-
//# sourceMappingURL=hmac.js.map
|
package/dist/hmac.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hmac.js","sourceRoot":"","sources":["../src/hmac.ts"],"names":[],"mappings":"AAEA,0DAA0D;AAC1D,MAAM,cAAc,GAAiC;IACnD,SAAS,EAAE,EAAE;IACb,SAAS,EAAE,EAAE;IACb,SAAS,EAAE,EAAE;CACd,CAAC;AAUF;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,GAAiB,EACjB,IAAkB,EAClB,OAAqB;IAErB,OAAO,IAAI,CAAC,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;AAC7C,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,GAAiB,EACjB,IAAkB,EAClB,OAAqB;IAErB,OAAO,IAAI,CAAC,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;AAC7C,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,GAAiB,EACjB,IAAkB,EAClB,OAAqB;IAErB,OAAO,IAAI,CAAC,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;AAC7C,CAAC;AAED;;;;;;;;GAQG;AACH,KAAK,UAAU,IAAI,CACjB,GAAiB,EACjB,IAAkB,EAClB,IAAkB,EAClB,OAAO,GAAgB,EAAE;IAEzB,IAAI,GAAG,CAAC,UAAU,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CACb,0DAA0D,IAAI,GAAG,CAClE,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,OAAO,CAAC,eAAe,IAAI,GAAG,CAAC,UAAU,GAAG,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC;QACtE,MAAM,IAAI,KAAK,CACb,2CAA2C,cAAc,CAAC,IAAI,CAAC,mBAAmB,IAAI,yEAAyE,CAChK,CAAC;IACJ,CAAC;IAED,MAAM,SAAS,GAAG,MAAM,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CACxD,KAAK,EACL,GAAG,EACH,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,EACtB,KAAK,EACL,CAAC,MAAM,CAAC,CACT,CAAC;IAEF,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;IAC5E,OAAO,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;AAChC,CAAC","sourcesContent":["import type { HashFunction } from './types.js';\n\n// https://datatracker.ietf.org/doc/html/rfc2104#section-3\nconst MIN_KEY_LENGTH: Record<HashFunction, number> = {\n 'SHA-256': 32,\n 'SHA-384': 48,\n 'SHA-512': 64,\n};\n\nexport type HmacOptions = {\n /**\n * Skip the minimum key length check. Using a key shorter than the hash\n * output length reduces the effective security strength of HMAC (RFC 2104).\n */\n unsafeKeyLength?: boolean;\n};\n\n/**\n * Compute the HMAC-SHA-256 of the given data using the given key.\n *\n * @param key - The key to use.\n * @param data - The data to hash.\n * @param options - Additional configuration options.\n * @returns The HMAC-SHA-256 of the data.\n */\nexport async function hmacSha256(\n key: BufferSource,\n data: BufferSource,\n options?: HmacOptions,\n): Promise<Uint8Array> {\n return hmac(key, 'SHA-256', data, options);\n}\n\n/**\n * Compute the HMAC-SHA-384 of the given data using the given key.\n *\n * @param key - The key to use.\n * @param data - The data to hash.\n * @param options - Additional configuration options.\n * @returns The HMAC-SHA-384 of the data.\n */\nexport async function hmacSha384(\n key: BufferSource,\n data: BufferSource,\n options?: HmacOptions,\n): Promise<Uint8Array> {\n return hmac(key, 'SHA-384', data, options);\n}\n\n/**\n * Compute the HMAC-SHA-512 of the given data using the given key.\n *\n * @param key - The key to use.\n * @param data - The data to hash.\n * @param options - Additional configuration options.\n * @returns The HMAC-SHA-512 of the data.\n */\nexport async function hmacSha512(\n key: BufferSource,\n data: BufferSource,\n options?: HmacOptions,\n): Promise<Uint8Array> {\n return hmac(key, 'SHA-512', data, options);\n}\n\n/**\n * Compute the HMAC-SHA of the given data using the given key.\n *\n * @param key - The key to use.\n * @param hash - The hash to use.\n * @param data - The data to hash.\n * @param options - Additional configuration options..\n * @returns The HMAC-SHA of the data.\n */\nasync function hmac(\n key: BufferSource,\n hash: HashFunction,\n data: BufferSource,\n options: HmacOptions = {},\n): Promise<Uint8Array> {\n if (key.byteLength === 0) {\n throw new Error(\n `Unsafe key length: Key must not be zero bytes for HMAC-${hash}.`,\n );\n }\n\n if (!options.unsafeKeyLength && key.byteLength < MIN_KEY_LENGTH[hash]) {\n throw new Error(\n `Unsafe key length: Key must be at least ${MIN_KEY_LENGTH[hash]} bytes for HMAC-${hash}. To bypass this check, set the \\`unsafeKeyLength\\` option to \\`true\\`.`,\n );\n }\n\n const subtleKey = await globalThis.crypto.subtle.importKey(\n 'raw',\n key,\n { name: 'HMAC', hash },\n false,\n ['sign'],\n );\n\n const result = await globalThis.crypto.subtle.sign('HMAC', subtleKey, data);\n return new Uint8Array(result);\n}\n"]}
|
package/dist/sha.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Compute a SHA-256 digest for a given byte array.
|
|
3
|
-
*
|
|
4
|
-
* @param bytes - A byte array.
|
|
5
|
-
* @returns The SHA-256 hash as a byte array.
|
|
6
|
-
*/
|
|
7
|
-
export declare function sha256(bytes: BufferSource): Promise<Uint8Array>;
|
|
8
|
-
/**
|
|
9
|
-
* Compute a SHA-384 digest for a given byte array.
|
|
10
|
-
*
|
|
11
|
-
* @param bytes - A byte array.
|
|
12
|
-
* @returns The SHA-384 hash as a byte array.
|
|
13
|
-
*/
|
|
14
|
-
export declare function sha384(bytes: BufferSource): Promise<Uint8Array>;
|
|
15
|
-
/**
|
|
16
|
-
* Compute a SHA-512 digest for a given byte array.
|
|
17
|
-
*
|
|
18
|
-
* @param bytes - A byte array.
|
|
19
|
-
* @returns The SHA-512 hash as a byte array.
|
|
20
|
-
*/
|
|
21
|
-
export declare function sha512(bytes: BufferSource): Promise<Uint8Array>;
|
|
22
|
-
//# sourceMappingURL=sha.d.ts.map
|
package/dist/sha.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sha.d.ts","sourceRoot":"","sources":["../src/sha.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAsB,MAAM,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,UAAU,CAAC,CAIrE;AAED;;;;;GAKG;AACH,wBAAsB,MAAM,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,UAAU,CAAC,CAIrE;AAED;;;;;GAKG;AACH,wBAAsB,MAAM,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,UAAU,CAAC,CAIrE"}
|
package/dist/sha.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Compute a SHA-256 digest for a given byte array.
|
|
3
|
-
*
|
|
4
|
-
* @param bytes - A byte array.
|
|
5
|
-
* @returns The SHA-256 hash as a byte array.
|
|
6
|
-
*/
|
|
7
|
-
export async function sha256(bytes) {
|
|
8
|
-
return new Uint8Array(await globalThis.crypto.subtle.digest('SHA-256', bytes));
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Compute a SHA-384 digest for a given byte array.
|
|
12
|
-
*
|
|
13
|
-
* @param bytes - A byte array.
|
|
14
|
-
* @returns The SHA-384 hash as a byte array.
|
|
15
|
-
*/
|
|
16
|
-
export async function sha384(bytes) {
|
|
17
|
-
return new Uint8Array(await globalThis.crypto.subtle.digest('SHA-384', bytes));
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Compute a SHA-512 digest for a given byte array.
|
|
21
|
-
*
|
|
22
|
-
* @param bytes - A byte array.
|
|
23
|
-
* @returns The SHA-512 hash as a byte array.
|
|
24
|
-
*/
|
|
25
|
-
export async function sha512(bytes) {
|
|
26
|
-
return new Uint8Array(await globalThis.crypto.subtle.digest('SHA-512', bytes));
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=sha.js.map
|
package/dist/sha.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sha.js","sourceRoot":"","sources":["../src/sha.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,KAAmB;IAC9C,OAAO,IAAI,UAAU,CACnB,MAAM,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,CACxD,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,KAAmB;IAC9C,OAAO,IAAI,UAAU,CACnB,MAAM,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,CACxD,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,KAAmB;IAC9C,OAAO,IAAI,UAAU,CACnB,MAAM,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,CACxD,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Compute a SHA-256 digest for a given byte array.\n *\n * @param bytes - A byte array.\n * @returns The SHA-256 hash as a byte array.\n */\nexport async function sha256(bytes: BufferSource): Promise<Uint8Array> {\n return new Uint8Array(\n await globalThis.crypto.subtle.digest('SHA-256', bytes),\n );\n}\n\n/**\n * Compute a SHA-384 digest for a given byte array.\n *\n * @param bytes - A byte array.\n * @returns The SHA-384 hash as a byte array.\n */\nexport async function sha384(bytes: BufferSource): Promise<Uint8Array> {\n return new Uint8Array(\n await globalThis.crypto.subtle.digest('SHA-384', bytes),\n );\n}\n\n/**\n * Compute a SHA-512 digest for a given byte array.\n *\n * @param bytes - A byte array.\n * @returns The SHA-512 hash as a byte array.\n */\nexport async function sha512(bytes: BufferSource): Promise<Uint8Array> {\n return new Uint8Array(\n await globalThis.crypto.subtle.digest('SHA-512', bytes),\n );\n}\n"]}
|
package/dist/types.d.ts
DELETED
package/dist/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC"}
|
package/dist/types.js
DELETED
package/dist/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["export type HashFunction = 'SHA-256' | 'SHA-384' | 'SHA-512';\n"]}
|