@metamask-previews/cryptography 0.0.0-preview-db287901b → 0.0.0-preview-d3f9964be

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 CHANGED
@@ -7,4 +7,8 @@ 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))
13
+
10
14
  [Unreleased]: https://github.com/MetaMask/core/
package/dist/index.d.ts CHANGED
@@ -1,8 +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: string): string;
1
+ export * from './sha.js';
8
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
package/dist/index.js CHANGED
@@ -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
- }
1
+ export * from './sha.js';
10
2
  //# 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;;;;;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"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC","sourcesContent":["export * from './sha.js';\n"]}
package/dist/sha.d.ts ADDED
@@ -0,0 +1,22 @@
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
@@ -0,0 +1 @@
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 ADDED
@@ -0,0 +1,28 @@
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
@@ -0,0 +1 @@
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask-previews/cryptography",
3
- "version": "0.0.0-preview-db287901b",
3
+ "version": "0.0.0-preview-d3f9964be",
4
4
  "description": "Provides optimized versions of commonly used cryptography functions for MetaMask clients",
5
5
  "keywords": [
6
6
  "Ethereum",
@@ -51,6 +51,7 @@
51
51
  },
52
52
  "devDependencies": {
53
53
  "@metamask/auto-changelog": "^6.1.0",
54
+ "@metamask/utils": "^12.0.0",
54
55
  "@types/jest": "^30.0.0",
55
56
  "@typescript/native": "npm:typescript@^7.0.2",
56
57
  "deepmerge": "^4.2.2",