@metamask/keyring-sdk 1.0.0 → 1.1.0

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,11 +7,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.1.0]
11
+
12
+ ### Added
13
+
14
+ - Add `encodeMnemonic` ([#495](https://github.com/MetaMask/accounts/pull/495))
15
+
16
+ ### Changed
17
+
18
+ - Bump `@metamask/utils` from `^11.1.0` to `^11.10.0` ([#489](https://github.com/MetaMask/accounts/pull/489))
19
+
10
20
  ## [1.0.0]
11
21
 
12
22
  ### Added
13
23
 
14
24
  - Initial release, extracted from `@metamask/keyring-api` ([#478](https://github.com/MetaMask/accounts/pull/478)), ([#482](https://github.com/MetaMask/accounts/pull/482))
15
25
 
16
- [Unreleased]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-sdk@1.0.0...HEAD
26
+ [Unreleased]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-sdk@1.1.0...HEAD
27
+ [1.1.0]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-sdk@1.0.0...@metamask/keyring-sdk@1.1.0
17
28
  [1.0.0]: https://github.com/MetaMask/accounts/releases/tag/@metamask/keyring-sdk@1.0.0
package/dist/index.cjs CHANGED
@@ -16,5 +16,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./keyring-wrapper.cjs"), exports);
18
18
  __exportStar(require("./keyring-account-registry.cjs"), exports);
19
+ __exportStar(require("./mnemonic.cjs"), exports);
19
20
  __exportStar(require("./eth/index.cjs"), exports);
20
21
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAkC;AAClC,iEAA2C;AAC3C,kDAAsB","sourcesContent":["export * from './keyring-wrapper';\nexport * from './keyring-account-registry';\nexport * from './eth';\n"]}
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAkC;AAClC,iEAA2C;AAC3C,iDAA2B;AAC3B,kDAAsB","sourcesContent":["export * from './keyring-wrapper';\nexport * from './keyring-account-registry';\nexport * from './mnemonic';\nexport * from './eth';\n"]}
package/dist/index.d.cts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./keyring-wrapper.cjs";
2
2
  export * from "./keyring-account-registry.cjs";
3
+ export * from "./mnemonic.cjs";
3
4
  export * from "./eth/index.cjs";
4
5
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,sCAAkC;AAClC,+CAA2C;AAC3C,gCAAsB"}
1
+ {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,sCAAkC;AAClC,+CAA2C;AAC3C,+BAA2B;AAC3B,gCAAsB"}
package/dist/index.d.mts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./keyring-wrapper.mjs";
2
2
  export * from "./keyring-account-registry.mjs";
3
+ export * from "./mnemonic.mjs";
3
4
  export * from "./eth/index.mjs";
4
5
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,sCAAkC;AAClC,+CAA2C;AAC3C,gCAAsB"}
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,sCAAkC;AAClC,+CAA2C;AAC3C,+BAA2B;AAC3B,gCAAsB"}
package/dist/index.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./keyring-wrapper.mjs";
2
2
  export * from "./keyring-account-registry.mjs";
3
+ export * from "./mnemonic.mjs";
3
4
  export * from "./eth/index.mjs";
4
5
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,sCAAkC;AAClC,+CAA2C;AAC3C,gCAAsB","sourcesContent":["export * from './keyring-wrapper';\nexport * from './keyring-account-registry';\nexport * from './eth';\n"]}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,sCAAkC;AAClC,+CAA2C;AAC3C,+BAA2B;AAC3B,gCAAsB","sourcesContent":["export * from './keyring-wrapper';\nexport * from './keyring-account-registry';\nexport * from './mnemonic';\nexport * from './eth';\n"]}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.encodeMnemonic = encodeMnemonic;
4
+ const english_1 = require("@metamask/scure-bip39/dist/wordlists/english.js");
5
+ /**
6
+ * Encodes a mnemonic as an array of bytes (UTF-8).
7
+ *
8
+ * @param mnemonicIndicesBytes - An array of bytes (16-bit unsigned integers) representing the indices of the words in the mnemonic.
9
+ * @returns An array of bytes (UTF-8) representing the mnemonic.
10
+ */
11
+ function encodeMnemonic(mnemonicIndicesBytes) {
12
+ const mnemonicIndices = Array.from(
13
+ // Create a new `Uint8Array` to ensure we have a proper view on the buffer
14
+ // without having to worry about `byteOffset` and `byteLength` of
15
+ // the inner buffer.
16
+ new Uint16Array(new Uint8Array(mnemonicIndicesBytes).buffer));
17
+ const mnemonic = mnemonicIndices.map((i) => english_1.wordlist[i]).join(' ');
18
+ return Array.from(new TextEncoder().encode(mnemonic));
19
+ }
20
+ //# sourceMappingURL=mnemonic.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mnemonic.cjs","sourceRoot":"","sources":["../src/mnemonic.ts"],"names":[],"mappings":";;AAQA,wCASC;AAjBD,6EAAwE;AAExE;;;;;GAKG;AACH,SAAgB,cAAc,CAAC,oBAAgC;IAC7D,MAAM,eAAe,GAAG,KAAK,CAAC,IAAI;IAChC,0EAA0E;IAC1E,iEAAiE;IACjE,oBAAoB;IACpB,IAAI,WAAW,CAAC,IAAI,UAAU,CAAC,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAC7D,CAAC;IACF,MAAM,QAAQ,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,kBAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACnE,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;AACxD,CAAC","sourcesContent":["import { wordlist } from '@metamask/scure-bip39/dist/wordlists/english';\n\n/**\n * Encodes a mnemonic as an array of bytes (UTF-8).\n *\n * @param mnemonicIndicesBytes - An array of bytes (16-bit unsigned integers) representing the indices of the words in the mnemonic.\n * @returns An array of bytes (UTF-8) representing the mnemonic.\n */\nexport function encodeMnemonic(mnemonicIndicesBytes: Uint8Array): number[] {\n const mnemonicIndices = Array.from(\n // Create a new `Uint8Array` to ensure we have a proper view on the buffer\n // without having to worry about `byteOffset` and `byteLength` of\n // the inner buffer.\n new Uint16Array(new Uint8Array(mnemonicIndicesBytes).buffer),\n );\n const mnemonic = mnemonicIndices.map((i) => wordlist[i]).join(' ');\n return Array.from(new TextEncoder().encode(mnemonic));\n}\n"]}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Encodes a mnemonic as an array of bytes (UTF-8).
3
+ *
4
+ * @param mnemonicIndicesBytes - An array of bytes (16-bit unsigned integers) representing the indices of the words in the mnemonic.
5
+ * @returns An array of bytes (UTF-8) representing the mnemonic.
6
+ */
7
+ export declare function encodeMnemonic(mnemonicIndicesBytes: Uint8Array): number[];
8
+ //# sourceMappingURL=mnemonic.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mnemonic.d.cts","sourceRoot":"","sources":["../src/mnemonic.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,oBAAoB,EAAE,UAAU,GAAG,MAAM,EAAE,CASzE"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Encodes a mnemonic as an array of bytes (UTF-8).
3
+ *
4
+ * @param mnemonicIndicesBytes - An array of bytes (16-bit unsigned integers) representing the indices of the words in the mnemonic.
5
+ * @returns An array of bytes (UTF-8) representing the mnemonic.
6
+ */
7
+ export declare function encodeMnemonic(mnemonicIndicesBytes: Uint8Array): number[];
8
+ //# sourceMappingURL=mnemonic.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mnemonic.d.mts","sourceRoot":"","sources":["../src/mnemonic.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,oBAAoB,EAAE,UAAU,GAAG,MAAM,EAAE,CASzE"}
@@ -0,0 +1,17 @@
1
+ import { wordlist } from "@metamask/scure-bip39/dist/wordlists/english.js";
2
+ /**
3
+ * Encodes a mnemonic as an array of bytes (UTF-8).
4
+ *
5
+ * @param mnemonicIndicesBytes - An array of bytes (16-bit unsigned integers) representing the indices of the words in the mnemonic.
6
+ * @returns An array of bytes (UTF-8) representing the mnemonic.
7
+ */
8
+ export function encodeMnemonic(mnemonicIndicesBytes) {
9
+ const mnemonicIndices = Array.from(
10
+ // Create a new `Uint8Array` to ensure we have a proper view on the buffer
11
+ // without having to worry about `byteOffset` and `byteLength` of
12
+ // the inner buffer.
13
+ new Uint16Array(new Uint8Array(mnemonicIndicesBytes).buffer));
14
+ const mnemonic = mnemonicIndices.map((i) => wordlist[i]).join(' ');
15
+ return Array.from(new TextEncoder().encode(mnemonic));
16
+ }
17
+ //# sourceMappingURL=mnemonic.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mnemonic.mjs","sourceRoot":"","sources":["../src/mnemonic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,wDAAqD;AAExE;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,oBAAgC;IAC7D,MAAM,eAAe,GAAG,KAAK,CAAC,IAAI;IAChC,0EAA0E;IAC1E,iEAAiE;IACjE,oBAAoB;IACpB,IAAI,WAAW,CAAC,IAAI,UAAU,CAAC,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAC7D,CAAC;IACF,MAAM,QAAQ,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACnE,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;AACxD,CAAC","sourcesContent":["import { wordlist } from '@metamask/scure-bip39/dist/wordlists/english';\n\n/**\n * Encodes a mnemonic as an array of bytes (UTF-8).\n *\n * @param mnemonicIndicesBytes - An array of bytes (16-bit unsigned integers) representing the indices of the words in the mnemonic.\n * @returns An array of bytes (UTF-8) representing the mnemonic.\n */\nexport function encodeMnemonic(mnemonicIndicesBytes: Uint8Array): number[] {\n const mnemonicIndices = Array.from(\n // Create a new `Uint8Array` to ensure we have a proper view on the buffer\n // without having to worry about `byteOffset` and `byteLength` of\n // the inner buffer.\n new Uint16Array(new Uint8Array(mnemonicIndicesBytes).buffer),\n );\n const mnemonic = mnemonicIndices.map((i) => wordlist[i]).join(' ');\n return Array.from(new TextEncoder().encode(mnemonic));\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask/keyring-sdk",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "MetaMask Keyring SDK",
5
5
  "keywords": [
6
6
  "metamask",
@@ -49,8 +49,9 @@
49
49
  "@metamask/eth-sig-util": "^8.2.0",
50
50
  "@metamask/keyring-api": "^22.0.0",
51
51
  "@metamask/keyring-utils": "^3.2.0",
52
+ "@metamask/scure-bip39": "^2.1.1",
52
53
  "@metamask/superstruct": "^3.1.0",
53
- "@metamask/utils": "^11.1.0",
54
+ "@metamask/utils": "^11.10.0",
54
55
  "async-mutex": "^0.5.0",
55
56
  "uuid": "^9.0.1"
56
57
  },