@metamask-previews/eth-qr-keyring 2.0.1-7275dbc → 2.1.0-1fa477f

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,6 +7,29 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ### Changed
11
+
12
+ - Bump `@metamask/keyring-api` from `^23.1.0` to `^23.5.0` ([#562](https://github.com/MetaMask/accounts/pull/562), [#569](https://github.com/MetaMask/accounts/pull/569), [#583](https://github.com/MetaMask/accounts/pull/583), [#587](https://github.com/MetaMask/accounts/pull/587))
13
+ - Bump `@metamask/keyring-sdk` from `^2.1.1` to `^2.2.0` ([#562](https://github.com/MetaMask/accounts/pull/562))
14
+
15
+ ## [2.1.0]
16
+
17
+ ### Added
18
+
19
+ - Expose device-management pass-throughs on the V2 `QrKeyring` wrapper: `getName`, `getMode`, `getFirstPage`, `getNextPage`, `getPreviousPage`, `forgetDevice`. `forgetDevice` additionally clears the V2 account registry to keep it in sync with the inner keyring. ([#551](https://github.com/MetaMask/accounts/pull/551))
20
+
21
+ ### Changed
22
+
23
+ - Bump `@metamask/keyring-sdk` from `^2.0.2` to `^2.1.1` ([#544](https://github.com/MetaMask/accounts/pull/544), [#546](https://github.com/MetaMask/accounts/pull/546))
24
+ - Bump `@metamask/keyring-utils` from `^3.2.0` to `^3.3.1` ([#544](https://github.com/MetaMask/accounts/pull/544), [#546](https://github.com/MetaMask/accounts/pull/546))
25
+
26
+ ## [2.0.2]
27
+
28
+ ### Changed
29
+
30
+ - Bump `@metamask/keyring-api` from `^23.0.1` to `^23.1.0` ([#538](https://github.com/MetaMask/accounts/pull/538))
31
+ - Bump `@metamask/keyring-sdk` from `^2.0.1` to `^2.0.2` ([#538](https://github.com/MetaMask/accounts/pull/538))
32
+
10
33
  ## [2.0.1]
11
34
 
12
35
  ### Changed
@@ -23,7 +46,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
23
46
 
24
47
  ### Added
25
48
 
26
- - Add `QrKeyringV2` class implementing `KeyringV2` interface ([#411](https://github.com/MetaMask/accounts/pull/411)), ([#447](https://github.com/MetaMask/accounts/pull/447)), ([#451](https://github.com/MetaMask/accounts/pull/451)), ([#453](https://github.com/MetaMask/accounts/pull/453)), ([#478](https://github.com/MetaMask/accounts/pull/478)), ([#482](https://github.com/MetaMask/accounts/pull/482)), ([#487](https://github.com/MetaMask/accounts/pull/487)), ([#496](https://github.com/MetaMask/accounts/pull/496)), ([#509](https://github.com/MetaMask/accounts/pull/509))
49
+ - Add `QrKeyringV2` class implementing `KeyringV2` interface ([#411](https://github.com/MetaMask/accounts/pull/411), [#447](https://github.com/MetaMask/accounts/pull/447), [#451](https://github.com/MetaMask/accounts/pull/451), [#453](https://github.com/MetaMask/accounts/pull/453), [#478](https://github.com/MetaMask/accounts/pull/478), [#482](https://github.com/MetaMask/accounts/pull/482), [#487](https://github.com/MetaMask/accounts/pull/487), [#496](https://github.com/MetaMask/accounts/pull/496), [#509](https://github.com/MetaMask/accounts/pull/509))
27
50
  - Add new dependency `@metamask/keyring-api@22.0.0`.
28
51
  - Add new dependency `@metamask/keyring-sdk@1.2.0`.
29
52
  - Add new dependency `@metamask/account-api@1.0.1`.
@@ -58,7 +81,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
58
81
 
59
82
  - Initial release ([#60](https://github.com/MetaMask/accounts/pull/60))
60
83
 
61
- [Unreleased]: https://github.com/MetaMask/accounts/compare/@metamask/eth-qr-keyring@2.0.1...HEAD
84
+ [Unreleased]: https://github.com/MetaMask/accounts/compare/@metamask/eth-qr-keyring@2.1.0...HEAD
85
+ [2.1.0]: https://github.com/MetaMask/accounts/compare/@metamask/eth-qr-keyring@2.0.2...@metamask/eth-qr-keyring@2.1.0
86
+ [2.0.2]: https://github.com/MetaMask/accounts/compare/@metamask/eth-qr-keyring@2.0.1...@metamask/eth-qr-keyring@2.0.2
62
87
  [2.0.1]: https://github.com/MetaMask/accounts/compare/@metamask/eth-qr-keyring@2.0.0...@metamask/eth-qr-keyring@2.0.1
63
88
  [2.0.0]: https://github.com/MetaMask/accounts/compare/@metamask/eth-qr-keyring@1.1.0...@metamask/eth-qr-keyring@2.0.0
64
89
  [1.1.0]: https://github.com/MetaMask/accounts/compare/@metamask/eth-qr-keyring@1.0.0...@metamask/eth-qr-keyring@1.1.0
@@ -132,6 +132,54 @@ class QrKeyring extends v2_2.EthKeyringWrapper {
132
132
  this.registry.delete(accountId);
133
133
  });
134
134
  }
135
+ /**
136
+ * @returns The name of the paired device, or the keyring type if no device
137
+ * is paired.
138
+ */
139
+ getName() {
140
+ return this.inner.getName();
141
+ }
142
+ /**
143
+ * @returns The current device mode (HD or Account), or `undefined` if no
144
+ * device is paired.
145
+ */
146
+ getMode() {
147
+ return this.inner.getMode();
148
+ }
149
+ /**
150
+ * Fetch the first page of candidate addresses from the device.
151
+ *
152
+ * @returns The first page of addresses.
153
+ */
154
+ async getFirstPage() {
155
+ return this.inner.getFirstPage();
156
+ }
157
+ /**
158
+ * Fetch the next page of candidate addresses from the device.
159
+ *
160
+ * @returns The next page of addresses.
161
+ */
162
+ async getNextPage() {
163
+ return this.inner.getNextPage();
164
+ }
165
+ /**
166
+ * Fetch the previous page of candidate addresses from the device.
167
+ *
168
+ * @returns The previous page of addresses.
169
+ */
170
+ async getPreviousPage() {
171
+ return this.inner.getPreviousPage();
172
+ }
173
+ /**
174
+ * Clear the inner keyring's device-pairing state and accounts, and reset
175
+ * the V2 account registry to keep them in sync.
176
+ */
177
+ async forgetDevice() {
178
+ await this.withLock(async () => {
179
+ await this.inner.forgetDevice();
180
+ this.registry.clear();
181
+ });
182
+ }
135
183
  }
136
184
  exports.QrKeyring = QrKeyring;
137
185
  _QrKeyring_instances = new WeakSet(), _QrKeyring_getDeviceState =
@@ -1 +1 @@
1
- {"version":3,"file":"qr-keyring.cjs","sourceRoot":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AC,OAAO,EAAE,EAAE,CACV,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI;QAC3B,6CAA+B,CAAC,QAAQ;QAC1C,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,KAAK,WAAW,CACrD,CAAC;IAEF,IAAI,eAAe,EAAE,CAAC;QACpB,OAAO,CAAC,eAA+C,CAAC,CAAC;IAC3D,CAAC;IAED,4CAA4C;IAC5C,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC;IAC3C,MAAM,CAAC,UAAU,CAAC,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IAErD,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;IAClD,CAAC;IAED,MAAM,UAAU,GAAG,uBAAA,IAAI,4DAAqB,MAAzB,IAAI,EAAsB,UAAU,EAAE,WAAW,CAAC,CAAC;IACtE,OAAO,CAAC,UAAU,CAAC,CAAC;AACtB,CAAC","sourcesContent":["import type { Bip44Account } from '@metamask/account-api';\nimport {\n EthAccountType,\n EthMethod,\n EthScope,\n KeyringAccountEntropyTypeOption,\n} from '@metamask/keyring-api';\nimport type { KeyringAccount, EntropySourceId } from '@metamask/keyring-api';\nimport { KeyringType } from '@metamask/keyring-api/v2';\nimport type {\n CreateAccountOptions,\n KeyringCapabilities,\n Keyring,\n CreateAccountBip44DeriveIndexOptions,\n} from '@metamask/keyring-api/v2';\nimport { EthKeyringWrapper } from '@metamask/keyring-sdk/v2';\nimport type { AccountId } from '@metamask/keyring-utils';\nimport type { Hex } from '@metamask/utils';\n\nimport { DeviceMode } from '../device';\nimport type { QrKeyring as LegacyQrKeyring } from '../qr-keyring';\n\n/**\n * Methods supported by QR keyring EOA accounts.\n * QR keyrings support a subset of signing methods (no encryption, app keys, or EIP-7702).\n */\nconst QR_KEYRING_METHODS = [\n EthMethod.SignTransaction,\n EthMethod.PersonalSign,\n EthMethod.SignTypedDataV4,\n];\n\n/**\n * Capabilities for HD mode devices (index-based derivation supported).\n */\nconst HD_MODE_CAPABILITIES: KeyringCapabilities = {\n scopes: [EthScope.Eoa],\n bip44: {\n deriveIndex: true,\n },\n};\n\n/**\n * Capabilities for Account mode devices (custom account selection).\n */\nconst ACCOUNT_MODE_CAPABILITIES: KeyringCapabilities = {\n scopes: [EthScope.Eoa],\n custom: {\n createAccounts: true,\n },\n};\n\n/**\n * Custom options for creating accounts on Account mode QR devices.\n * Account mode devices provide pre-defined addresses that must be selected by index.\n */\nexport type QrAccountModeCreateOptions = {\n type: 'custom';\n /**\n * The entropy source ID (device fingerprint) to verify we're targeting the correct device.\n */\n entropySource: EntropySourceId;\n /**\n * The index of the pre-defined address to add from the device.\n * This refers to the position in the device's address list, not a BIP-44 derivation index.\n */\n addressIndex: number;\n};\n\n/**\n * Account creation options for QR keyring.\n * Excludes unsupported types (custom, private-key:import) and adds our specific QrAccountModeCreateOptions.\n */\nexport type QrKeyringCreateAccountOptions =\n | CreateAccountBip44DeriveIndexOptions\n | QrAccountModeCreateOptions;\n\n/**\n * Concrete {@link Keyring} adapter for {@link QrKeyring}.\n *\n * This wrapper exposes the accounts and signing capabilities of the legacy\n * QR keyring via the unified V2 interface.\n *\n * Account handling differs by device mode:\n * - **HD mode**: Accounts are derived by index with `groupIndex` values.\n * Supports `bip44:derive-index` for index-based derivation.\n * - **Account mode**: Accounts are treated as private key imports since the\n * device provides pre-defined addresses with arbitrary paths. Uses `custom`\n * account creation type to select addresses by their position in the device.\n */\nexport type QrKeyringOptions = {\n legacyKeyring: LegacyQrKeyring;\n entropySource: EntropySourceId;\n};\n\nexport class QrKeyring\n extends EthKeyringWrapper<LegacyQrKeyring>\n implements Keyring\n{\n readonly entropySource: EntropySourceId;\n\n constructor(options: QrKeyringOptions) {\n super({\n type: KeyringType.Qr,\n inner: options.legacyKeyring,\n // Default capabilities - overridden by getter below\n capabilities: HD_MODE_CAPABILITIES,\n });\n this.entropySource = options.entropySource;\n }\n\n /**\n * Get the capabilities of this keyring.\n *\n * Overrides the base class getter to return capabilities dynamically\n * based on the current device mode.\n *\n * @returns The keyring's capabilities.\n */\n override get capabilities(): KeyringCapabilities {\n return this.inner.getMode() === DeviceMode.ACCOUNT\n ? ACCOUNT_MODE_CAPABILITIES\n : HD_MODE_CAPABILITIES;\n }\n\n /**\n * Get the device state from the inner keyring.\n *\n * @returns The device state, or undefined if no device is paired.\n */\n async #getDeviceState(): Promise<\n | {\n mode: DeviceMode.HD;\n indexes: Record<Hex, number>;\n }\n | {\n mode: DeviceMode.ACCOUNT;\n indexes: Record<Hex, number>;\n paths: Record<Hex, string>;\n }\n | undefined\n > {\n const state = await this.inner.serialize();\n\n if (!state?.initialized) {\n return undefined;\n }\n\n if (state.keyringMode === DeviceMode.ACCOUNT) {\n return {\n mode: DeviceMode.ACCOUNT,\n indexes: state.indexes,\n paths: state.paths,\n };\n }\n\n return {\n mode: DeviceMode.HD,\n indexes: state.indexes,\n };\n }\n\n /**\n * Creates a Bip44Account for HD mode devices.\n *\n * @param address - The account address.\n * @param addressIndex - The account index in the derivation path.\n * @returns The created Bip44Account.\n */\n #createHdModeAccount(\n address: Hex,\n addressIndex: number,\n ): Bip44Account<KeyringAccount> {\n const id = this.registry.register(address);\n\n const derivationPath = this.inner.getPathFromAddress(address);\n\n if (!derivationPath) {\n throw new Error(\n `Cannot create account for address ${address}: derivation path not found in keyring.`,\n );\n }\n\n const account: Bip44Account<KeyringAccount> = {\n id,\n type: EthAccountType.Eoa,\n address,\n scopes: [...this.capabilities.scopes],\n methods: [...QR_KEYRING_METHODS],\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n id: this.entropySource,\n groupIndex: addressIndex,\n derivationPath,\n },\n },\n };\n\n this.registry.set(account);\n return account;\n }\n\n /**\n * Creates a KeyringAccount for Account mode devices.\n *\n * Account mode devices provide pre-defined addresses with arbitrary derivation\n * paths, so we treat them as private key imports rather than BIP-44 accounts.\n *\n * @param address - The account address.\n * @returns The created KeyringAccount.\n */\n #createAccountModeAccount(address: Hex): KeyringAccount {\n const id = this.registry.register(address);\n\n const account: KeyringAccount = {\n id,\n type: EthAccountType.Eoa,\n address,\n scopes: [...this.capabilities.scopes],\n methods: [...QR_KEYRING_METHODS],\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Custom,\n },\n },\n };\n\n this.registry.set(account);\n return account;\n }\n\n async getAccounts(): Promise<KeyringAccount[]> {\n const addresses = await this.inner.getAccounts();\n const deviceState = await this.#getDeviceState();\n\n if (!deviceState) {\n // No device paired yet, return empty\n return [];\n }\n\n const { mode, indexes } = deviceState;\n\n return addresses.map((address) => {\n // Check if we already have this account in the registry\n const existingId = this.registry.getAccountId(address);\n if (existingId) {\n const cached = this.registry.get(existingId);\n if (cached) {\n return cached;\n }\n }\n\n if (mode === DeviceMode.HD) {\n // HD mode: index must be in the map\n const addressIndex = indexes[address];\n if (addressIndex === undefined) {\n throw new Error(\n `Address ${address} not found in device indexes. This indicates an inconsistent keyring state.`,\n );\n }\n return this.#createHdModeAccount(address, addressIndex);\n }\n\n // Account mode: validate address exists in paths map\n const { paths } = deviceState;\n if (paths[address] === undefined) {\n throw new Error(\n `Address ${address} not found in device paths. This indicates an inconsistent keyring state.`,\n );\n }\n return this.#createAccountModeAccount(address);\n });\n }\n\n async createAccounts(\n options: QrKeyringCreateAccountOptions,\n ): Promise<KeyringAccount[]> {\n return this.withLock(async () => {\n const deviceState = await this.#getDeviceState();\n\n if (!deviceState) {\n throw new Error('No device paired. Cannot create accounts.');\n }\n\n // Validate entropy source for all account creation types\n if (options.entropySource !== this.entropySource) {\n throw new Error(\n `Entropy source mismatch: expected '${this.entropySource}', got '${options.entropySource}'`,\n );\n }\n\n // Handle Account mode with custom account creation\n if (deviceState.mode === DeviceMode.ACCOUNT) {\n if (options.type !== 'custom') {\n throw new Error(\n `Account mode devices only support 'custom' account creation type, got '${options.type}'. ` +\n `Use { type: 'custom', entropySource, addressIndex } to select a pre-defined address.`,\n );\n }\n return this.#createAccountModeAccounts(options, deviceState);\n }\n\n // HD mode: support derive-index\n return this.#createHdModeAccounts(options, deviceState);\n });\n }\n\n /**\n * Creates accounts for Account mode devices using custom options.\n *\n * @param options - The account creation options.\n * @param deviceState - The current device state.\n * @param deviceState.mode - The device mode (ACCOUNT).\n * @param deviceState.paths - Map of addresses to derivation paths.\n * @param deviceState.indexes - Map of addresses to their indexes.\n * @returns The created accounts.\n */\n async #createAccountModeAccounts(\n options: QrAccountModeCreateOptions,\n deviceState: {\n mode: DeviceMode.ACCOUNT;\n paths: Record<Hex, string>;\n indexes: Record<Hex, number>;\n },\n ): Promise<KeyringAccount[]> {\n const { addressIndex } = options;\n\n if (!Number.isInteger(addressIndex) || addressIndex < 0) {\n throw new Error(\n `Invalid addressIndex: ${String(\n addressIndex,\n )}. Must be a non-negative integer.`,\n );\n }\n\n // Get available addresses from paths\n const availableAddresses = Object.keys(deviceState.paths) as Hex[];\n if (addressIndex >= availableAddresses.length) {\n throw new Error(\n `Address index ${addressIndex} is out of bounds. Device has ${availableAddresses.length} pre-defined address(es).`,\n );\n }\n\n const address = availableAddresses[addressIndex];\n\n // Check if already exists\n const currentAccounts = await this.getAccounts();\n const existingAccount = currentAccounts.find(\n (account) => account.address.toLowerCase() === address?.toLowerCase(),\n );\n if (existingAccount) {\n return [existingAccount];\n }\n\n // Add the account via the inner keyring\n this.inner.setAccountToUnlock(addressIndex);\n const [newAddress] = await this.inner.addAccounts(1);\n\n if (!newAddress) {\n throw new Error('Failed to create new account');\n }\n\n const newAccount = this.#createAccountModeAccount(newAddress);\n return [newAccount];\n }\n\n /**\n * Creates accounts for HD mode devices using index-based derivation.\n *\n * @param options - The account creation options.\n * @param _deviceState - The current device state (reserved for future use).\n * @param _deviceState.indexes - Map of addresses to their indexes.\n * @returns The created accounts.\n */\n async #createHdModeAccounts(\n options: CreateAccountOptions,\n _deviceState: { indexes: Record<Hex, number> },\n ): Promise<Bip44Account<KeyringAccount>[]> {\n if (options.type !== 'bip44:derive-index') {\n throw new Error(\n `Unsupported account creation type for HD mode QrKeyring: ${String(\n options.type,\n )}. Supported type: 'bip44:derive-index'.`,\n );\n }\n\n if (!Number.isInteger(options.groupIndex) || options.groupIndex < 0) {\n throw new Error(\n `Invalid groupIndex: ${options.groupIndex}. Must be a non-negative integer.`,\n );\n }\n\n const targetIndex = options.groupIndex;\n\n // Check if an account at this index already exists\n const currentAccounts = await this.getAccounts();\n const existingAccount = currentAccounts.find(\n (account) =>\n account.options.entropy?.type ===\n KeyringAccountEntropyTypeOption.Mnemonic &&\n account.options.entropy.groupIndex === targetIndex,\n );\n\n if (existingAccount) {\n return [existingAccount as Bip44Account<KeyringAccount>];\n }\n\n // Derive the account at the specified index\n this.inner.setAccountToUnlock(targetIndex);\n const [newAddress] = await this.inner.addAccounts(1);\n\n if (!newAddress) {\n throw new Error('Failed to create new account');\n }\n\n const newAccount = this.#createHdModeAccount(newAddress, targetIndex);\n return [newAccount];\n }\n\n /**\n * Delete an account from the keyring.\n *\n * @param accountId - The account ID to delete.\n */\n async deleteAccount(accountId: AccountId): Promise<void> {\n await this.withLock(async () => {\n const { address } = await this.getAccount(accountId);\n const hexAddress = this.toHexAddress(address);\n\n // Remove from the legacy keyring\n this.inner.removeAccount(hexAddress);\n\n // Remove from the registry\n this.registry.delete(accountId);\n });\n }\n}\n"]}
1
+ {"version":3,"file":"qr-keyring.cjs","sourceRoot":"","sources":["../../src/v2/qr-keyring.ts"],"names":[],"mappings":";;;;;;;;;AACA,uDAK+B;AAE/B,iDAAuD;AAOvD,iDAA6D;AAI7D,0CAAuC;AAIvC;;;GAGG;AACH,MAAM,kBAAkB,GAAG;IACzB,uBAAS,CAAC,eAAe;IACzB,uBAAS,CAAC,YAAY;IACtB,uBAAS,CAAC,eAAe;CAC1B,CAAC;AAEF;;GAEG;AACH,MAAM,oBAAoB,GAAwB;IAChD,MAAM,EAAE,CAAC,sBAAQ,CAAC,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AC3C,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,OAAO,CAAC,UAAU,GAAG,CAAC,EAAE,CAAC;QACpE,MAAM,IAAI,KAAK,CACb,uBAAuB,OAAO,CAAC,UAAU,mCAAmC,CAC7E,CAAC;IACJ,CAAC;IAED,MAAM,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC;IAEvC,mDAAmD;IACnD,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC;IACjD,MAAM,eAAe,GAAG,eAAe,CAAC,IAAI,CAC1C,CAAC,OAAO,EAAE,EAAE,CACV,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI;QAC3B,6CAA+B,CAAC,QAAQ;QAC1C,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,KAAK,WAAW,CACrD,CAAC;IAEF,IAAI,eAAe,EAAE,CAAC;QACpB,OAAO,CAAC,eAA+C,CAAC,CAAC;IAC3D,CAAC;IAED,4CAA4C;IAC5C,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC;IAC3C,MAAM,CAAC,UAAU,CAAC,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IAErD,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;IAClD,CAAC;IAED,MAAM,UAAU,GAAG,uBAAA,IAAI,4DAAqB,MAAzB,IAAI,EAAsB,UAAU,EAAE,WAAW,CAAC,CAAC;IACtE,OAAO,CAAC,UAAU,CAAC,CAAC;AACtB,CAAC","sourcesContent":["import type { Bip44Account } from '@metamask/account-api';\nimport {\n EthAccountType,\n EthMethod,\n EthScope,\n KeyringAccountEntropyTypeOption,\n} from '@metamask/keyring-api';\nimport type { KeyringAccount, EntropySourceId } from '@metamask/keyring-api';\nimport { KeyringType } from '@metamask/keyring-api/v2';\nimport type {\n CreateAccountOptions,\n KeyringCapabilities,\n Keyring,\n CreateAccountBip44DeriveIndexOptions,\n} from '@metamask/keyring-api/v2';\nimport { EthKeyringWrapper } from '@metamask/keyring-sdk/v2';\nimport type { AccountId } from '@metamask/keyring-utils';\nimport type { Hex } from '@metamask/utils';\n\nimport { DeviceMode } from '../device';\nimport type { IndexedAddress } from '../device';\nimport type { QrKeyring as LegacyQrKeyring } from '../qr-keyring';\n\n/**\n * Methods supported by QR keyring EOA accounts.\n * QR keyrings support a subset of signing methods (no encryption, app keys, or EIP-7702).\n */\nconst QR_KEYRING_METHODS = [\n EthMethod.SignTransaction,\n EthMethod.PersonalSign,\n EthMethod.SignTypedDataV4,\n];\n\n/**\n * Capabilities for HD mode devices (index-based derivation supported).\n */\nconst HD_MODE_CAPABILITIES: KeyringCapabilities = {\n scopes: [EthScope.Eoa],\n bip44: {\n deriveIndex: true,\n },\n};\n\n/**\n * Capabilities for Account mode devices (custom account selection).\n */\nconst ACCOUNT_MODE_CAPABILITIES: KeyringCapabilities = {\n scopes: [EthScope.Eoa],\n custom: {\n createAccounts: true,\n },\n};\n\n/**\n * Custom options for creating accounts on Account mode QR devices.\n * Account mode devices provide pre-defined addresses that must be selected by index.\n */\nexport type QrAccountModeCreateOptions = {\n type: 'custom';\n /**\n * The entropy source ID (device fingerprint) to verify we're targeting the correct device.\n */\n entropySource: EntropySourceId;\n /**\n * The index of the pre-defined address to add from the device.\n * This refers to the position in the device's address list, not a BIP-44 derivation index.\n */\n addressIndex: number;\n};\n\n/**\n * Account creation options for QR keyring.\n * Excludes unsupported types (custom, private-key:import) and adds our specific QrAccountModeCreateOptions.\n */\nexport type QrKeyringCreateAccountOptions =\n | CreateAccountBip44DeriveIndexOptions\n | QrAccountModeCreateOptions;\n\n/**\n * Concrete {@link Keyring} adapter for {@link QrKeyring}.\n *\n * This wrapper exposes the accounts and signing capabilities of the legacy\n * QR keyring via the unified V2 interface.\n *\n * Account handling differs by device mode:\n * - **HD mode**: Accounts are derived by index with `groupIndex` values.\n * Supports `bip44:derive-index` for index-based derivation.\n * - **Account mode**: Accounts are treated as private key imports since the\n * device provides pre-defined addresses with arbitrary paths. Uses `custom`\n * account creation type to select addresses by their position in the device.\n */\nexport type QrKeyringOptions = {\n legacyKeyring: LegacyQrKeyring;\n entropySource: EntropySourceId;\n};\n\nexport class QrKeyring\n extends EthKeyringWrapper<LegacyQrKeyring>\n implements Keyring\n{\n readonly entropySource: EntropySourceId;\n\n constructor(options: QrKeyringOptions) {\n super({\n type: KeyringType.Qr,\n inner: options.legacyKeyring,\n // Default capabilities - overridden by getter below\n capabilities: HD_MODE_CAPABILITIES,\n });\n this.entropySource = options.entropySource;\n }\n\n /**\n * Get the capabilities of this keyring.\n *\n * Overrides the base class getter to return capabilities dynamically\n * based on the current device mode.\n *\n * @returns The keyring's capabilities.\n */\n override get capabilities(): KeyringCapabilities {\n return this.inner.getMode() === DeviceMode.ACCOUNT\n ? ACCOUNT_MODE_CAPABILITIES\n : HD_MODE_CAPABILITIES;\n }\n\n /**\n * Get the device state from the inner keyring.\n *\n * @returns The device state, or undefined if no device is paired.\n */\n async #getDeviceState(): Promise<\n | {\n mode: DeviceMode.HD;\n indexes: Record<Hex, number>;\n }\n | {\n mode: DeviceMode.ACCOUNT;\n indexes: Record<Hex, number>;\n paths: Record<Hex, string>;\n }\n | undefined\n > {\n const state = await this.inner.serialize();\n\n if (!state?.initialized) {\n return undefined;\n }\n\n if (state.keyringMode === DeviceMode.ACCOUNT) {\n return {\n mode: DeviceMode.ACCOUNT,\n indexes: state.indexes,\n paths: state.paths,\n };\n }\n\n return {\n mode: DeviceMode.HD,\n indexes: state.indexes,\n };\n }\n\n /**\n * Creates a Bip44Account for HD mode devices.\n *\n * @param address - The account address.\n * @param addressIndex - The account index in the derivation path.\n * @returns The created Bip44Account.\n */\n #createHdModeAccount(\n address: Hex,\n addressIndex: number,\n ): Bip44Account<KeyringAccount> {\n const id = this.registry.register(address);\n\n const derivationPath = this.inner.getPathFromAddress(address);\n\n if (!derivationPath) {\n throw new Error(\n `Cannot create account for address ${address}: derivation path not found in keyring.`,\n );\n }\n\n const account: Bip44Account<KeyringAccount> = {\n id,\n type: EthAccountType.Eoa,\n address,\n scopes: [...this.capabilities.scopes],\n methods: [...QR_KEYRING_METHODS],\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n id: this.entropySource,\n groupIndex: addressIndex,\n derivationPath,\n },\n },\n };\n\n this.registry.set(account);\n return account;\n }\n\n /**\n * Creates a KeyringAccount for Account mode devices.\n *\n * Account mode devices provide pre-defined addresses with arbitrary derivation\n * paths, so we treat them as private key imports rather than BIP-44 accounts.\n *\n * @param address - The account address.\n * @returns The created KeyringAccount.\n */\n #createAccountModeAccount(address: Hex): KeyringAccount {\n const id = this.registry.register(address);\n\n const account: KeyringAccount = {\n id,\n type: EthAccountType.Eoa,\n address,\n scopes: [...this.capabilities.scopes],\n methods: [...QR_KEYRING_METHODS],\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Custom,\n },\n },\n };\n\n this.registry.set(account);\n return account;\n }\n\n async getAccounts(): Promise<KeyringAccount[]> {\n const addresses = await this.inner.getAccounts();\n const deviceState = await this.#getDeviceState();\n\n if (!deviceState) {\n // No device paired yet, return empty\n return [];\n }\n\n const { mode, indexes } = deviceState;\n\n return addresses.map((address) => {\n // Check if we already have this account in the registry\n const existingId = this.registry.getAccountId(address);\n if (existingId) {\n const cached = this.registry.get(existingId);\n if (cached) {\n return cached;\n }\n }\n\n if (mode === DeviceMode.HD) {\n // HD mode: index must be in the map\n const addressIndex = indexes[address];\n if (addressIndex === undefined) {\n throw new Error(\n `Address ${address} not found in device indexes. This indicates an inconsistent keyring state.`,\n );\n }\n return this.#createHdModeAccount(address, addressIndex);\n }\n\n // Account mode: validate address exists in paths map\n const { paths } = deviceState;\n if (paths[address] === undefined) {\n throw new Error(\n `Address ${address} not found in device paths. This indicates an inconsistent keyring state.`,\n );\n }\n return this.#createAccountModeAccount(address);\n });\n }\n\n async createAccounts(\n options: QrKeyringCreateAccountOptions,\n ): Promise<KeyringAccount[]> {\n return this.withLock(async () => {\n const deviceState = await this.#getDeviceState();\n\n if (!deviceState) {\n throw new Error('No device paired. Cannot create accounts.');\n }\n\n // Validate entropy source for all account creation types\n if (options.entropySource !== this.entropySource) {\n throw new Error(\n `Entropy source mismatch: expected '${this.entropySource}', got '${options.entropySource}'`,\n );\n }\n\n // Handle Account mode with custom account creation\n if (deviceState.mode === DeviceMode.ACCOUNT) {\n if (options.type !== 'custom') {\n throw new Error(\n `Account mode devices only support 'custom' account creation type, got '${options.type}'. ` +\n `Use { type: 'custom', entropySource, addressIndex } to select a pre-defined address.`,\n );\n }\n return this.#createAccountModeAccounts(options, deviceState);\n }\n\n // HD mode: support derive-index\n return this.#createHdModeAccounts(options, deviceState);\n });\n }\n\n /**\n * Creates accounts for Account mode devices using custom options.\n *\n * @param options - The account creation options.\n * @param deviceState - The current device state.\n * @param deviceState.mode - The device mode (ACCOUNT).\n * @param deviceState.paths - Map of addresses to derivation paths.\n * @param deviceState.indexes - Map of addresses to their indexes.\n * @returns The created accounts.\n */\n async #createAccountModeAccounts(\n options: QrAccountModeCreateOptions,\n deviceState: {\n mode: DeviceMode.ACCOUNT;\n paths: Record<Hex, string>;\n indexes: Record<Hex, number>;\n },\n ): Promise<KeyringAccount[]> {\n const { addressIndex } = options;\n\n if (!Number.isInteger(addressIndex) || addressIndex < 0) {\n throw new Error(\n `Invalid addressIndex: ${String(\n addressIndex,\n )}. Must be a non-negative integer.`,\n );\n }\n\n // Get available addresses from paths\n const availableAddresses = Object.keys(deviceState.paths) as Hex[];\n if (addressIndex >= availableAddresses.length) {\n throw new Error(\n `Address index ${addressIndex} is out of bounds. Device has ${availableAddresses.length} pre-defined address(es).`,\n );\n }\n\n const address = availableAddresses[addressIndex];\n\n // Check if already exists\n const currentAccounts = await this.getAccounts();\n const existingAccount = currentAccounts.find(\n (account) => account.address.toLowerCase() === address?.toLowerCase(),\n );\n if (existingAccount) {\n return [existingAccount];\n }\n\n // Add the account via the inner keyring\n this.inner.setAccountToUnlock(addressIndex);\n const [newAddress] = await this.inner.addAccounts(1);\n\n if (!newAddress) {\n throw new Error('Failed to create new account');\n }\n\n const newAccount = this.#createAccountModeAccount(newAddress);\n return [newAccount];\n }\n\n /**\n * Creates accounts for HD mode devices using index-based derivation.\n *\n * @param options - The account creation options.\n * @param _deviceState - The current device state (reserved for future use).\n * @param _deviceState.indexes - Map of addresses to their indexes.\n * @returns The created accounts.\n */\n async #createHdModeAccounts(\n options: CreateAccountOptions,\n _deviceState: { indexes: Record<Hex, number> },\n ): Promise<Bip44Account<KeyringAccount>[]> {\n if (options.type !== 'bip44:derive-index') {\n throw new Error(\n `Unsupported account creation type for HD mode QrKeyring: ${String(\n options.type,\n )}. Supported type: 'bip44:derive-index'.`,\n );\n }\n\n if (!Number.isInteger(options.groupIndex) || options.groupIndex < 0) {\n throw new Error(\n `Invalid groupIndex: ${options.groupIndex}. Must be a non-negative integer.`,\n );\n }\n\n const targetIndex = options.groupIndex;\n\n // Check if an account at this index already exists\n const currentAccounts = await this.getAccounts();\n const existingAccount = currentAccounts.find(\n (account) =>\n account.options.entropy?.type ===\n KeyringAccountEntropyTypeOption.Mnemonic &&\n account.options.entropy.groupIndex === targetIndex,\n );\n\n if (existingAccount) {\n return [existingAccount as Bip44Account<KeyringAccount>];\n }\n\n // Derive the account at the specified index\n this.inner.setAccountToUnlock(targetIndex);\n const [newAddress] = await this.inner.addAccounts(1);\n\n if (!newAddress) {\n throw new Error('Failed to create new account');\n }\n\n const newAccount = this.#createHdModeAccount(newAddress, targetIndex);\n return [newAccount];\n }\n\n /**\n * Delete an account from the keyring.\n *\n * @param accountId - The account ID to delete.\n */\n async deleteAccount(accountId: AccountId): Promise<void> {\n await this.withLock(async () => {\n const { address } = await this.getAccount(accountId);\n const hexAddress = this.toHexAddress(address);\n\n // Remove from the legacy keyring\n this.inner.removeAccount(hexAddress);\n\n // Remove from the registry\n this.registry.delete(accountId);\n });\n }\n\n /**\n * @returns The name of the paired device, or the keyring type if no device\n * is paired.\n */\n getName(): string {\n return this.inner.getName();\n }\n\n /**\n * @returns The current device mode (HD or Account), or `undefined` if no\n * device is paired.\n */\n getMode(): DeviceMode | undefined {\n return this.inner.getMode();\n }\n\n /**\n * Fetch the first page of candidate addresses from the device.\n *\n * @returns The first page of addresses.\n */\n async getFirstPage(): Promise<IndexedAddress[]> {\n return this.inner.getFirstPage();\n }\n\n /**\n * Fetch the next page of candidate addresses from the device.\n *\n * @returns The next page of addresses.\n */\n async getNextPage(): Promise<IndexedAddress[]> {\n return this.inner.getNextPage();\n }\n\n /**\n * Fetch the previous page of candidate addresses from the device.\n *\n * @returns The previous page of addresses.\n */\n async getPreviousPage(): Promise<IndexedAddress[]> {\n return this.inner.getPreviousPage();\n }\n\n /**\n * Clear the inner keyring's device-pairing state and accounts, and reset\n * the V2 account registry to keep them in sync.\n */\n async forgetDevice(): Promise<void> {\n await this.withLock(async () => {\n await this.inner.forgetDevice();\n this.registry.clear();\n });\n }\n}\n"]}
@@ -2,6 +2,8 @@ import type { KeyringAccount, EntropySourceId } from "@metamask/keyring-api";
2
2
  import type { KeyringCapabilities, Keyring, CreateAccountBip44DeriveIndexOptions } from "@metamask/keyring-api/v2";
3
3
  import { EthKeyringWrapper } from "@metamask/keyring-sdk/v2";
4
4
  import type { AccountId } from "@metamask/keyring-utils";
5
+ import { DeviceMode } from "../device.cjs";
6
+ import type { IndexedAddress } from "../device.cjs";
5
7
  import type { QrKeyring as LegacyQrKeyring } from "../qr-keyring.cjs";
6
8
  /**
7
9
  * Custom options for creating accounts on Account mode QR devices.
@@ -62,5 +64,38 @@ export declare class QrKeyring extends EthKeyringWrapper<LegacyQrKeyring> implem
62
64
  * @param accountId - The account ID to delete.
63
65
  */
64
66
  deleteAccount(accountId: AccountId): Promise<void>;
67
+ /**
68
+ * @returns The name of the paired device, or the keyring type if no device
69
+ * is paired.
70
+ */
71
+ getName(): string;
72
+ /**
73
+ * @returns The current device mode (HD or Account), or `undefined` if no
74
+ * device is paired.
75
+ */
76
+ getMode(): DeviceMode | undefined;
77
+ /**
78
+ * Fetch the first page of candidate addresses from the device.
79
+ *
80
+ * @returns The first page of addresses.
81
+ */
82
+ getFirstPage(): Promise<IndexedAddress[]>;
83
+ /**
84
+ * Fetch the next page of candidate addresses from the device.
85
+ *
86
+ * @returns The next page of addresses.
87
+ */
88
+ getNextPage(): Promise<IndexedAddress[]>;
89
+ /**
90
+ * Fetch the previous page of candidate addresses from the device.
91
+ *
92
+ * @returns The previous page of addresses.
93
+ */
94
+ getPreviousPage(): Promise<IndexedAddress[]>;
95
+ /**
96
+ * Clear the inner keyring's device-pairing state and accounts, and reset
97
+ * the V2 account registry to keep them in sync.
98
+ */
99
+ forgetDevice(): Promise<void>;
65
100
  }
66
101
  //# sourceMappingURL=qr-keyring.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"qr-keyring.d.cts","sourceRoot":"","sources":["../../src/v2/qr-keyring.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,8BAA8B;AAE7E,OAAO,KAAK,EAEV,mBAAmB,EACnB,OAAO,EACP,oCAAoC,EACrC,iCAAiC;AAClC,OAAO,EAAE,iBAAiB,EAAE,iCAAiC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,gCAAgC;AAIzD,OAAO,KAAK,EAAE,SAAS,IAAI,eAAe,EAAE,0BAAsB;AAgClE;;;GAGG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACvC,IAAI,EAAE,QAAQ,CAAC;IACf;;OAEG;IACH,aAAa,EAAE,eAAe,CAAC;IAC/B;;;OAGG;IACH,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,6BAA6B,GACrC,oCAAoC,GACpC,0BAA0B,CAAC;AAE/B;;;;;;;;;;;;GAYG;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AYG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,aAAa,EAAE,eAAe,CAAC;IAC/B,aAAa,EAAE,eAAe,CAAC;CAChC,CAAC;AAEF,qBAAa,SACX,SAAQ,iBAAiB,CAAC,eAAe,CACzC,YAAW,OAAO;;IAElB,QAAQ,CAAC,aAAa,EAAE,eAAe,CAAC;gBAE5B,OAAO,EAAE,gBAAgB;IAUrC;;;;;;;OAOG;IACH,IAAa,YAAY,IAAI,mBAAmB,CAI/C;IA6GK,WAAW,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;IA2CxC,cAAc,CAClB,OAAO,EAAE,6BAA6B,GACrC,OAAO,CAAC,cAAc,EAAE,CAAC;IA+I5B;;;;OAIG;IACG,aAAa,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAaxD;;;OAGG;IACH,OAAO,IAAI,MAAM;IAIjB;;;OAGG;IACH,OAAO,IAAI,UAAU,GAAG,SAAS;IAIjC;;;;OAIG;IACG,YAAY,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;IAI/C;;;;OAIG;IACG,WAAW,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;IAI9C;;;;OAIG;IACG,eAAe,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;IAIlD;;;OAGG;IACG,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;CAMpC"}
@@ -2,6 +2,8 @@ import type { KeyringAccount, EntropySourceId } from "@metamask/keyring-api";
2
2
  import type { KeyringCapabilities, Keyring, CreateAccountBip44DeriveIndexOptions } from "@metamask/keyring-api/v2";
3
3
  import { EthKeyringWrapper } from "@metamask/keyring-sdk/v2";
4
4
  import type { AccountId } from "@metamask/keyring-utils";
5
+ import { DeviceMode } from "../device.mjs";
6
+ import type { IndexedAddress } from "../device.mjs";
5
7
  import type { QrKeyring as LegacyQrKeyring } from "../qr-keyring.mjs";
6
8
  /**
7
9
  * Custom options for creating accounts on Account mode QR devices.
@@ -62,5 +64,38 @@ export declare class QrKeyring extends EthKeyringWrapper<LegacyQrKeyring> implem
62
64
  * @param accountId - The account ID to delete.
63
65
  */
64
66
  deleteAccount(accountId: AccountId): Promise<void>;
67
+ /**
68
+ * @returns The name of the paired device, or the keyring type if no device
69
+ * is paired.
70
+ */
71
+ getName(): string;
72
+ /**
73
+ * @returns The current device mode (HD or Account), or `undefined` if no
74
+ * device is paired.
75
+ */
76
+ getMode(): DeviceMode | undefined;
77
+ /**
78
+ * Fetch the first page of candidate addresses from the device.
79
+ *
80
+ * @returns The first page of addresses.
81
+ */
82
+ getFirstPage(): Promise<IndexedAddress[]>;
83
+ /**
84
+ * Fetch the next page of candidate addresses from the device.
85
+ *
86
+ * @returns The next page of addresses.
87
+ */
88
+ getNextPage(): Promise<IndexedAddress[]>;
89
+ /**
90
+ * Fetch the previous page of candidate addresses from the device.
91
+ *
92
+ * @returns The previous page of addresses.
93
+ */
94
+ getPreviousPage(): Promise<IndexedAddress[]>;
95
+ /**
96
+ * Clear the inner keyring's device-pairing state and accounts, and reset
97
+ * the V2 account registry to keep them in sync.
98
+ */
99
+ forgetDevice(): Promise<void>;
65
100
  }
66
101
  //# sourceMappingURL=qr-keyring.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"qr-keyring.d.mts","sourceRoot":"","sources":["../../src/v2/qr-keyring.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,8BAA8B;AAE7E,OAAO,KAAK,EAEV,mBAAmB,EACnB,OAAO,EACP,oCAAoC,EACrC,iCAAiC;AAClC,OAAO,EAAE,iBAAiB,EAAE,iCAAiC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,gCAAgC;AAIzD,OAAO,KAAK,EAAE,SAAS,IAAI,eAAe,EAAE,0BAAsB;AAgClE;;;GAGG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACvC,IAAI,EAAE,QAAQ,CAAC;IACf;;OAEG;IACH,aAAa,EAAE,eAAe,C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Ae,CAAC;IAC/B;;;OAGG;IACH,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,6BAA6B,GACrC,oCAAoC,GACpC,0BAA0B,CAAC;AAE/B;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,aAAa,EAAE,eAAe,CAAC;IAC/B,aAAa,EAAE,eAAe,CAAC;CAChC,CAAC;AAEF,qBAAa,SACX,SAAQ,iBAAiB,CAAC,eAAe,CACzC,YAAW,OAAO;;IAElB,QAAQ,CAAC,aAAa,EAAE,eAAe,CAAC;gBAE5B,OAAO,EAAE,gBAAgB;IAUrC;;;;;;;OAOG;IACH,IAAa,YAAY,IAAI,mBAAmB,CAI/C;IA6GK,WAAW,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;IA2CxC,cAAc,CAClB,OAAO,EAAE,6BAA6B,GACrC,OAAO,CAAC,cAAc,EAAE,CAAC;IA+I5B;;;;OAIG;IACG,aAAa,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAaxD;;;OAGG;IACH,OAAO,IAAI,MAAM;IAIjB;;;OAGG;IACH,OAAO,IAAI,UAAU,GAAG,SAAS;IAIjC;;;;OAIG;IACG,YAAY,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;IAI/C;;;;OAIG;IACG,WAAW,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;IAI9C;;;;OAIG;IACG,eAAe,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;IAIlD;;;OAGG;IACG,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;CAMpC"}
@@ -129,6 +129,54 @@ export class QrKeyring extends EthKeyringWrapper {
129
129
  this.registry.delete(accountId);
130
130
  });
131
131
  }
132
+ /**
133
+ * @returns The name of the paired device, or the keyring type if no device
134
+ * is paired.
135
+ */
136
+ getName() {
137
+ return this.inner.getName();
138
+ }
139
+ /**
140
+ * @returns The current device mode (HD or Account), or `undefined` if no
141
+ * device is paired.
142
+ */
143
+ getMode() {
144
+ return this.inner.getMode();
145
+ }
146
+ /**
147
+ * Fetch the first page of candidate addresses from the device.
148
+ *
149
+ * @returns The first page of addresses.
150
+ */
151
+ async getFirstPage() {
152
+ return this.inner.getFirstPage();
153
+ }
154
+ /**
155
+ * Fetch the next page of candidate addresses from the device.
156
+ *
157
+ * @returns The next page of addresses.
158
+ */
159
+ async getNextPage() {
160
+ return this.inner.getNextPage();
161
+ }
162
+ /**
163
+ * Fetch the previous page of candidate addresses from the device.
164
+ *
165
+ * @returns The previous page of addresses.
166
+ */
167
+ async getPreviousPage() {
168
+ return this.inner.getPreviousPage();
169
+ }
170
+ /**
171
+ * Clear the inner keyring's device-pairing state and accounts, and reset
172
+ * the V2 account registry to keep them in sync.
173
+ */
174
+ async forgetDevice() {
175
+ await this.withLock(async () => {
176
+ await this.inner.forgetDevice();
177
+ this.registry.clear();
178
+ });
179
+ }
132
180
  }
133
181
  _QrKeyring_instances = new WeakSet(), _QrKeyring_getDeviceState =
134
182
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"qr-keyring.mjs","sourceRoot":"","sources":["../../src/v2/qr-keyring.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,EACL,cAAc,EACd,SAAS,EACT,QAAQ,EACR,+BAA+B,EAChC,8BAA8B;AAE/B,OAAO,EAAE,WAAW,EAAE,iCAAiC;AAOvD,OAAO,EAAE,iBAAiB,EAAE,iCAAiC;AAI7D,OAAO,EAAE,UAAU,EAAE,sBAAkB;AAGvC;;;GAGG;AACH,MAAM,kBAAkB,GAAG;IACzB,SAAS,CAAC,eAAe;IACzB,SAAS,CAAC,YAAY;IACtB,SAAS,CAAC,eAAe;CAC1B,CAAC;AAEF;;GAEG;AACH,MAAM,oBAAoB,GAAwB;IAChD,MAAM,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC;IACtB,KAAK,EAAE;QACL,WAAW,EAAE,IAAI;KAClB;CACF,CAAC;AAEF;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C,CAAC;IAErD,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;IAClD,CAAC;IAED,MAAM,UAAU,GAAG,uBAAA,IAAI,4DAAqB,MAAzB,IAAI,EAAsB,UAAU,EAAE,WAAW,CAAC,CAAC;IACtE,OAAO,CAAC,UAAU,CAAC,CAAC;AACtB,CAAC","sourcesContent":["import type { Bip44Account } from '@metamask/account-api';\nimport {\n EthAccountType,\n EthMethod,\n EthScope,\n KeyringAccountEntropyTypeOption,\n} from '@metamask/keyring-api';\nimport type { KeyringAccount, EntropySourceId } from '@metamask/keyring-api';\nimport { KeyringType } from '@metamask/keyring-api/v2';\nimport type {\n CreateAccountOptions,\n KeyringCapabilities,\n Keyring,\n CreateAccountBip44DeriveIndexOptions,\n} from '@metamask/keyring-api/v2';\nimport { EthKeyringWrapper } from '@metamask/keyring-sdk/v2';\nimport type { AccountId } from '@metamask/keyring-utils';\nimport type { Hex } from '@metamask/utils';\n\nimport { DeviceMode } from '../device';\nimport type { QrKeyring as LegacyQrKeyring } from '../qr-keyring';\n\n/**\n * Methods supported by QR keyring EOA accounts.\n * QR keyrings support a subset of signing methods (no encryption, app keys, or EIP-7702).\n */\nconst QR_KEYRING_METHODS = [\n EthMethod.SignTransaction,\n EthMethod.PersonalSign,\n EthMethod.SignTypedDataV4,\n];\n\n/**\n * Capabilities for HD mode devices (index-based derivation supported).\n */\nconst HD_MODE_CAPABILITIES: KeyringCapabilities = {\n scopes: [EthScope.Eoa],\n bip44: {\n deriveIndex: true,\n },\n};\n\n/**\n * Capabilities for Account mode devices (custom account selection).\n */\nconst ACCOUNT_MODE_CAPABILITIES: KeyringCapabilities = {\n scopes: [EthScope.Eoa],\n custom: {\n createAccounts: true,\n },\n};\n\n/**\n * Custom options for creating accounts on Account mode QR devices.\n * Account mode devices provide pre-defined addresses that must be selected by index.\n */\nexport type QrAccountModeCreateOptions = {\n type: 'custom';\n /**\n * The entropy source ID (device fingerprint) to verify we're targeting the correct device.\n */\n entropySource: EntropySourceId;\n /**\n * The index of the pre-defined address to add from the device.\n * This refers to the position in the device's address list, not a BIP-44 derivation index.\n */\n addressIndex: number;\n};\n\n/**\n * Account creation options for QR keyring.\n * Excludes unsupported types (custom, private-key:import) and adds our specific QrAccountModeCreateOptions.\n */\nexport type QrKeyringCreateAccountOptions =\n | CreateAccountBip44DeriveIndexOptions\n | QrAccountModeCreateOptions;\n\n/**\n * Concrete {@link Keyring} adapter for {@link QrKeyring}.\n *\n * This wrapper exposes the accounts and signing capabilities of the legacy\n * QR keyring via the unified V2 interface.\n *\n * Account handling differs by device mode:\n * - **HD mode**: Accounts are derived by index with `groupIndex` values.\n * Supports `bip44:derive-index` for index-based derivation.\n * - **Account mode**: Accounts are treated as private key imports since the\n * device provides pre-defined addresses with arbitrary paths. Uses `custom`\n * account creation type to select addresses by their position in the device.\n */\nexport type QrKeyringOptions = {\n legacyKeyring: LegacyQrKeyring;\n entropySource: EntropySourceId;\n};\n\nexport class QrKeyring\n extends EthKeyringWrapper<LegacyQrKeyring>\n implements Keyring\n{\n readonly entropySource: EntropySourceId;\n\n constructor(options: QrKeyringOptions) {\n super({\n type: KeyringType.Qr,\n inner: options.legacyKeyring,\n // Default capabilities - overridden by getter below\n capabilities: HD_MODE_CAPABILITIES,\n });\n this.entropySource = options.entropySource;\n }\n\n /**\n * Get the capabilities of this keyring.\n *\n * Overrides the base class getter to return capabilities dynamically\n * based on the current device mode.\n *\n * @returns The keyring's capabilities.\n */\n override get capabilities(): KeyringCapabilities {\n return this.inner.getMode() === DeviceMode.ACCOUNT\n ? ACCOUNT_MODE_CAPABILITIES\n : HD_MODE_CAPABILITIES;\n }\n\n /**\n * Get the device state from the inner keyring.\n *\n * @returns The device state, or undefined if no device is paired.\n */\n async #getDeviceState(): Promise<\n | {\n mode: DeviceMode.HD;\n indexes: Record<Hex, number>;\n }\n | {\n mode: DeviceMode.ACCOUNT;\n indexes: Record<Hex, number>;\n paths: Record<Hex, string>;\n }\n | undefined\n > {\n const state = await this.inner.serialize();\n\n if (!state?.initialized) {\n return undefined;\n }\n\n if (state.keyringMode === DeviceMode.ACCOUNT) {\n return {\n mode: DeviceMode.ACCOUNT,\n indexes: state.indexes,\n paths: state.paths,\n };\n }\n\n return {\n mode: DeviceMode.HD,\n indexes: state.indexes,\n };\n }\n\n /**\n * Creates a Bip44Account for HD mode devices.\n *\n * @param address - The account address.\n * @param addressIndex - The account index in the derivation path.\n * @returns The created Bip44Account.\n */\n #createHdModeAccount(\n address: Hex,\n addressIndex: number,\n ): Bip44Account<KeyringAccount> {\n const id = this.registry.register(address);\n\n const derivationPath = this.inner.getPathFromAddress(address);\n\n if (!derivationPath) {\n throw new Error(\n `Cannot create account for address ${address}: derivation path not found in keyring.`,\n );\n }\n\n const account: Bip44Account<KeyringAccount> = {\n id,\n type: EthAccountType.Eoa,\n address,\n scopes: [...this.capabilities.scopes],\n methods: [...QR_KEYRING_METHODS],\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n id: this.entropySource,\n groupIndex: addressIndex,\n derivationPath,\n },\n },\n };\n\n this.registry.set(account);\n return account;\n }\n\n /**\n * Creates a KeyringAccount for Account mode devices.\n *\n * Account mode devices provide pre-defined addresses with arbitrary derivation\n * paths, so we treat them as private key imports rather than BIP-44 accounts.\n *\n * @param address - The account address.\n * @returns The created KeyringAccount.\n */\n #createAccountModeAccount(address: Hex): KeyringAccount {\n const id = this.registry.register(address);\n\n const account: KeyringAccount = {\n id,\n type: EthAccountType.Eoa,\n address,\n scopes: [...this.capabilities.scopes],\n methods: [...QR_KEYRING_METHODS],\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Custom,\n },\n },\n };\n\n this.registry.set(account);\n return account;\n }\n\n async getAccounts(): Promise<KeyringAccount[]> {\n const addresses = await this.inner.getAccounts();\n const deviceState = await this.#getDeviceState();\n\n if (!deviceState) {\n // No device paired yet, return empty\n return [];\n }\n\n const { mode, indexes } = deviceState;\n\n return addresses.map((address) => {\n // Check if we already have this account in the registry\n const existingId = this.registry.getAccountId(address);\n if (existingId) {\n const cached = this.registry.get(existingId);\n if (cached) {\n return cached;\n }\n }\n\n if (mode === DeviceMode.HD) {\n // HD mode: index must be in the map\n const addressIndex = indexes[address];\n if (addressIndex === undefined) {\n throw new Error(\n `Address ${address} not found in device indexes. This indicates an inconsistent keyring state.`,\n );\n }\n return this.#createHdModeAccount(address, addressIndex);\n }\n\n // Account mode: validate address exists in paths map\n const { paths } = deviceState;\n if (paths[address] === undefined) {\n throw new Error(\n `Address ${address} not found in device paths. This indicates an inconsistent keyring state.`,\n );\n }\n return this.#createAccountModeAccount(address);\n });\n }\n\n async createAccounts(\n options: QrKeyringCreateAccountOptions,\n ): Promise<KeyringAccount[]> {\n return this.withLock(async () => {\n const deviceState = await this.#getDeviceState();\n\n if (!deviceState) {\n throw new Error('No device paired. Cannot create accounts.');\n }\n\n // Validate entropy source for all account creation types\n if (options.entropySource !== this.entropySource) {\n throw new Error(\n `Entropy source mismatch: expected '${this.entropySource}', got '${options.entropySource}'`,\n );\n }\n\n // Handle Account mode with custom account creation\n if (deviceState.mode === DeviceMode.ACCOUNT) {\n if (options.type !== 'custom') {\n throw new Error(\n `Account mode devices only support 'custom' account creation type, got '${options.type}'. ` +\n `Use { type: 'custom', entropySource, addressIndex } to select a pre-defined address.`,\n );\n }\n return this.#createAccountModeAccounts(options, deviceState);\n }\n\n // HD mode: support derive-index\n return this.#createHdModeAccounts(options, deviceState);\n });\n }\n\n /**\n * Creates accounts for Account mode devices using custom options.\n *\n * @param options - The account creation options.\n * @param deviceState - The current device state.\n * @param deviceState.mode - The device mode (ACCOUNT).\n * @param deviceState.paths - Map of addresses to derivation paths.\n * @param deviceState.indexes - Map of addresses to their indexes.\n * @returns The created accounts.\n */\n async #createAccountModeAccounts(\n options: QrAccountModeCreateOptions,\n deviceState: {\n mode: DeviceMode.ACCOUNT;\n paths: Record<Hex, string>;\n indexes: Record<Hex, number>;\n },\n ): Promise<KeyringAccount[]> {\n const { addressIndex } = options;\n\n if (!Number.isInteger(addressIndex) || addressIndex < 0) {\n throw new Error(\n `Invalid addressIndex: ${String(\n addressIndex,\n )}. Must be a non-negative integer.`,\n );\n }\n\n // Get available addresses from paths\n const availableAddresses = Object.keys(deviceState.paths) as Hex[];\n if (addressIndex >= availableAddresses.length) {\n throw new Error(\n `Address index ${addressIndex} is out of bounds. Device has ${availableAddresses.length} pre-defined address(es).`,\n );\n }\n\n const address = availableAddresses[addressIndex];\n\n // Check if already exists\n const currentAccounts = await this.getAccounts();\n const existingAccount = currentAccounts.find(\n (account) => account.address.toLowerCase() === address?.toLowerCase(),\n );\n if (existingAccount) {\n return [existingAccount];\n }\n\n // Add the account via the inner keyring\n this.inner.setAccountToUnlock(addressIndex);\n const [newAddress] = await this.inner.addAccounts(1);\n\n if (!newAddress) {\n throw new Error('Failed to create new account');\n }\n\n const newAccount = this.#createAccountModeAccount(newAddress);\n return [newAccount];\n }\n\n /**\n * Creates accounts for HD mode devices using index-based derivation.\n *\n * @param options - The account creation options.\n * @param _deviceState - The current device state (reserved for future use).\n * @param _deviceState.indexes - Map of addresses to their indexes.\n * @returns The created accounts.\n */\n async #createHdModeAccounts(\n options: CreateAccountOptions,\n _deviceState: { indexes: Record<Hex, number> },\n ): Promise<Bip44Account<KeyringAccount>[]> {\n if (options.type !== 'bip44:derive-index') {\n throw new Error(\n `Unsupported account creation type for HD mode QrKeyring: ${String(\n options.type,\n )}. Supported type: 'bip44:derive-index'.`,\n );\n }\n\n if (!Number.isInteger(options.groupIndex) || options.groupIndex < 0) {\n throw new Error(\n `Invalid groupIndex: ${options.groupIndex}. Must be a non-negative integer.`,\n );\n }\n\n const targetIndex = options.groupIndex;\n\n // Check if an account at this index already exists\n const currentAccounts = await this.getAccounts();\n const existingAccount = currentAccounts.find(\n (account) =>\n account.options.entropy?.type ===\n KeyringAccountEntropyTypeOption.Mnemonic &&\n account.options.entropy.groupIndex === targetIndex,\n );\n\n if (existingAccount) {\n return [existingAccount as Bip44Account<KeyringAccount>];\n }\n\n // Derive the account at the specified index\n this.inner.setAccountToUnlock(targetIndex);\n const [newAddress] = await this.inner.addAccounts(1);\n\n if (!newAddress) {\n throw new Error('Failed to create new account');\n }\n\n const newAccount = this.#createHdModeAccount(newAddress, targetIndex);\n return [newAccount];\n }\n\n /**\n * Delete an account from the keyring.\n *\n * @param accountId - The account ID to delete.\n */\n async deleteAccount(accountId: AccountId): Promise<void> {\n await this.withLock(async () => {\n const { address } = await this.getAccount(accountId);\n const hexAddress = this.toHexAddress(address);\n\n // Remove from the legacy keyring\n this.inner.removeAccount(hexAddress);\n\n // Remove from the registry\n this.registry.delete(accountId);\n });\n }\n}\n"]}
1
+ {"version":3,"file":"qr-keyring.mjs","sourceRoot":"","sources":["../../src/v2/qr-keyring.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,EACL,cAAc,EACd,SAAS,EACT,QAAQ,EACR,+BAA+B,EAChC,8BAA8B;AAE/B,OAAO,EAAE,WAAW,EAAE,iCAAiC;AAOvD,OAAO,EAAE,iBAAiB,EAAE,iCAAiC;AAI7D,OAAO,EAAE,UAAU,EAAE,sBAAkB;AAIvC;;;GAGG;AACH,MAAM,kBAAkB,GAAG;IACzB,SAAS,CAAC,eAAe;IACzB,SAAS,CAAC,YAAY;IACtB,SAAS,CAAC,eAAe;CAC1B,CAAC;AAEF;;GAEG;AACH,MAAM,oBAAoB,GAAwB;IAChD,MAAM,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC;IACtB,KAAK,EAAE;QACL,WAAW,EAAE,IAAI;KAClB;CACF,CAAC;AAEF;;GAEG;AACH,MAAM,yBAAyB,GAAwB;IACrD,MAAM,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC;IACtB,MAAM,EAAE;QACN,cAAc,EAAE,IAAI;KACrB;CACF,CAAC;AA6CF,MAAM,OAAO,SACX,SAAQ,iBAAkC;IAK1C,YAAY,OAAyB;QACnC,KAAK,CAA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AAM,IAAI,CAAC,WAAW,EAAE,CAAC;IACjD,MAAM,eAAe,GAAG,eAAe,CAAC,IAAI,CAC1C,CAAC,OAAO,EAAE,EAAE,CACV,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI;QAC3B,+BAA+B,CAAC,QAAQ;QAC1C,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,KAAK,WAAW,CACrD,CAAC;IAEF,IAAI,eAAe,EAAE,CAAC;QACpB,OAAO,CAAC,eAA+C,CAAC,CAAC;IAC3D,CAAC;IAED,4CAA4C;IAC5C,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC;IAC3C,MAAM,CAAC,UAAU,CAAC,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IAErD,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;IAClD,CAAC;IAED,MAAM,UAAU,GAAG,uBAAA,IAAI,4DAAqB,MAAzB,IAAI,EAAsB,UAAU,EAAE,WAAW,CAAC,CAAC;IACtE,OAAO,CAAC,UAAU,CAAC,CAAC;AACtB,CAAC","sourcesContent":["import type { Bip44Account } from '@metamask/account-api';\nimport {\n EthAccountType,\n EthMethod,\n EthScope,\n KeyringAccountEntropyTypeOption,\n} from '@metamask/keyring-api';\nimport type { KeyringAccount, EntropySourceId } from '@metamask/keyring-api';\nimport { KeyringType } from '@metamask/keyring-api/v2';\nimport type {\n CreateAccountOptions,\n KeyringCapabilities,\n Keyring,\n CreateAccountBip44DeriveIndexOptions,\n} from '@metamask/keyring-api/v2';\nimport { EthKeyringWrapper } from '@metamask/keyring-sdk/v2';\nimport type { AccountId } from '@metamask/keyring-utils';\nimport type { Hex } from '@metamask/utils';\n\nimport { DeviceMode } from '../device';\nimport type { IndexedAddress } from '../device';\nimport type { QrKeyring as LegacyQrKeyring } from '../qr-keyring';\n\n/**\n * Methods supported by QR keyring EOA accounts.\n * QR keyrings support a subset of signing methods (no encryption, app keys, or EIP-7702).\n */\nconst QR_KEYRING_METHODS = [\n EthMethod.SignTransaction,\n EthMethod.PersonalSign,\n EthMethod.SignTypedDataV4,\n];\n\n/**\n * Capabilities for HD mode devices (index-based derivation supported).\n */\nconst HD_MODE_CAPABILITIES: KeyringCapabilities = {\n scopes: [EthScope.Eoa],\n bip44: {\n deriveIndex: true,\n },\n};\n\n/**\n * Capabilities for Account mode devices (custom account selection).\n */\nconst ACCOUNT_MODE_CAPABILITIES: KeyringCapabilities = {\n scopes: [EthScope.Eoa],\n custom: {\n createAccounts: true,\n },\n};\n\n/**\n * Custom options for creating accounts on Account mode QR devices.\n * Account mode devices provide pre-defined addresses that must be selected by index.\n */\nexport type QrAccountModeCreateOptions = {\n type: 'custom';\n /**\n * The entropy source ID (device fingerprint) to verify we're targeting the correct device.\n */\n entropySource: EntropySourceId;\n /**\n * The index of the pre-defined address to add from the device.\n * This refers to the position in the device's address list, not a BIP-44 derivation index.\n */\n addressIndex: number;\n};\n\n/**\n * Account creation options for QR keyring.\n * Excludes unsupported types (custom, private-key:import) and adds our specific QrAccountModeCreateOptions.\n */\nexport type QrKeyringCreateAccountOptions =\n | CreateAccountBip44DeriveIndexOptions\n | QrAccountModeCreateOptions;\n\n/**\n * Concrete {@link Keyring} adapter for {@link QrKeyring}.\n *\n * This wrapper exposes the accounts and signing capabilities of the legacy\n * QR keyring via the unified V2 interface.\n *\n * Account handling differs by device mode:\n * - **HD mode**: Accounts are derived by index with `groupIndex` values.\n * Supports `bip44:derive-index` for index-based derivation.\n * - **Account mode**: Accounts are treated as private key imports since the\n * device provides pre-defined addresses with arbitrary paths. Uses `custom`\n * account creation type to select addresses by their position in the device.\n */\nexport type QrKeyringOptions = {\n legacyKeyring: LegacyQrKeyring;\n entropySource: EntropySourceId;\n};\n\nexport class QrKeyring\n extends EthKeyringWrapper<LegacyQrKeyring>\n implements Keyring\n{\n readonly entropySource: EntropySourceId;\n\n constructor(options: QrKeyringOptions) {\n super({\n type: KeyringType.Qr,\n inner: options.legacyKeyring,\n // Default capabilities - overridden by getter below\n capabilities: HD_MODE_CAPABILITIES,\n });\n this.entropySource = options.entropySource;\n }\n\n /**\n * Get the capabilities of this keyring.\n *\n * Overrides the base class getter to return capabilities dynamically\n * based on the current device mode.\n *\n * @returns The keyring's capabilities.\n */\n override get capabilities(): KeyringCapabilities {\n return this.inner.getMode() === DeviceMode.ACCOUNT\n ? ACCOUNT_MODE_CAPABILITIES\n : HD_MODE_CAPABILITIES;\n }\n\n /**\n * Get the device state from the inner keyring.\n *\n * @returns The device state, or undefined if no device is paired.\n */\n async #getDeviceState(): Promise<\n | {\n mode: DeviceMode.HD;\n indexes: Record<Hex, number>;\n }\n | {\n mode: DeviceMode.ACCOUNT;\n indexes: Record<Hex, number>;\n paths: Record<Hex, string>;\n }\n | undefined\n > {\n const state = await this.inner.serialize();\n\n if (!state?.initialized) {\n return undefined;\n }\n\n if (state.keyringMode === DeviceMode.ACCOUNT) {\n return {\n mode: DeviceMode.ACCOUNT,\n indexes: state.indexes,\n paths: state.paths,\n };\n }\n\n return {\n mode: DeviceMode.HD,\n indexes: state.indexes,\n };\n }\n\n /**\n * Creates a Bip44Account for HD mode devices.\n *\n * @param address - The account address.\n * @param addressIndex - The account index in the derivation path.\n * @returns The created Bip44Account.\n */\n #createHdModeAccount(\n address: Hex,\n addressIndex: number,\n ): Bip44Account<KeyringAccount> {\n const id = this.registry.register(address);\n\n const derivationPath = this.inner.getPathFromAddress(address);\n\n if (!derivationPath) {\n throw new Error(\n `Cannot create account for address ${address}: derivation path not found in keyring.`,\n );\n }\n\n const account: Bip44Account<KeyringAccount> = {\n id,\n type: EthAccountType.Eoa,\n address,\n scopes: [...this.capabilities.scopes],\n methods: [...QR_KEYRING_METHODS],\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n id: this.entropySource,\n groupIndex: addressIndex,\n derivationPath,\n },\n },\n };\n\n this.registry.set(account);\n return account;\n }\n\n /**\n * Creates a KeyringAccount for Account mode devices.\n *\n * Account mode devices provide pre-defined addresses with arbitrary derivation\n * paths, so we treat them as private key imports rather than BIP-44 accounts.\n *\n * @param address - The account address.\n * @returns The created KeyringAccount.\n */\n #createAccountModeAccount(address: Hex): KeyringAccount {\n const id = this.registry.register(address);\n\n const account: KeyringAccount = {\n id,\n type: EthAccountType.Eoa,\n address,\n scopes: [...this.capabilities.scopes],\n methods: [...QR_KEYRING_METHODS],\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Custom,\n },\n },\n };\n\n this.registry.set(account);\n return account;\n }\n\n async getAccounts(): Promise<KeyringAccount[]> {\n const addresses = await this.inner.getAccounts();\n const deviceState = await this.#getDeviceState();\n\n if (!deviceState) {\n // No device paired yet, return empty\n return [];\n }\n\n const { mode, indexes } = deviceState;\n\n return addresses.map((address) => {\n // Check if we already have this account in the registry\n const existingId = this.registry.getAccountId(address);\n if (existingId) {\n const cached = this.registry.get(existingId);\n if (cached) {\n return cached;\n }\n }\n\n if (mode === DeviceMode.HD) {\n // HD mode: index must be in the map\n const addressIndex = indexes[address];\n if (addressIndex === undefined) {\n throw new Error(\n `Address ${address} not found in device indexes. This indicates an inconsistent keyring state.`,\n );\n }\n return this.#createHdModeAccount(address, addressIndex);\n }\n\n // Account mode: validate address exists in paths map\n const { paths } = deviceState;\n if (paths[address] === undefined) {\n throw new Error(\n `Address ${address} not found in device paths. This indicates an inconsistent keyring state.`,\n );\n }\n return this.#createAccountModeAccount(address);\n });\n }\n\n async createAccounts(\n options: QrKeyringCreateAccountOptions,\n ): Promise<KeyringAccount[]> {\n return this.withLock(async () => {\n const deviceState = await this.#getDeviceState();\n\n if (!deviceState) {\n throw new Error('No device paired. Cannot create accounts.');\n }\n\n // Validate entropy source for all account creation types\n if (options.entropySource !== this.entropySource) {\n throw new Error(\n `Entropy source mismatch: expected '${this.entropySource}', got '${options.entropySource}'`,\n );\n }\n\n // Handle Account mode with custom account creation\n if (deviceState.mode === DeviceMode.ACCOUNT) {\n if (options.type !== 'custom') {\n throw new Error(\n `Account mode devices only support 'custom' account creation type, got '${options.type}'. ` +\n `Use { type: 'custom', entropySource, addressIndex } to select a pre-defined address.`,\n );\n }\n return this.#createAccountModeAccounts(options, deviceState);\n }\n\n // HD mode: support derive-index\n return this.#createHdModeAccounts(options, deviceState);\n });\n }\n\n /**\n * Creates accounts for Account mode devices using custom options.\n *\n * @param options - The account creation options.\n * @param deviceState - The current device state.\n * @param deviceState.mode - The device mode (ACCOUNT).\n * @param deviceState.paths - Map of addresses to derivation paths.\n * @param deviceState.indexes - Map of addresses to their indexes.\n * @returns The created accounts.\n */\n async #createAccountModeAccounts(\n options: QrAccountModeCreateOptions,\n deviceState: {\n mode: DeviceMode.ACCOUNT;\n paths: Record<Hex, string>;\n indexes: Record<Hex, number>;\n },\n ): Promise<KeyringAccount[]> {\n const { addressIndex } = options;\n\n if (!Number.isInteger(addressIndex) || addressIndex < 0) {\n throw new Error(\n `Invalid addressIndex: ${String(\n addressIndex,\n )}. Must be a non-negative integer.`,\n );\n }\n\n // Get available addresses from paths\n const availableAddresses = Object.keys(deviceState.paths) as Hex[];\n if (addressIndex >= availableAddresses.length) {\n throw new Error(\n `Address index ${addressIndex} is out of bounds. Device has ${availableAddresses.length} pre-defined address(es).`,\n );\n }\n\n const address = availableAddresses[addressIndex];\n\n // Check if already exists\n const currentAccounts = await this.getAccounts();\n const existingAccount = currentAccounts.find(\n (account) => account.address.toLowerCase() === address?.toLowerCase(),\n );\n if (existingAccount) {\n return [existingAccount];\n }\n\n // Add the account via the inner keyring\n this.inner.setAccountToUnlock(addressIndex);\n const [newAddress] = await this.inner.addAccounts(1);\n\n if (!newAddress) {\n throw new Error('Failed to create new account');\n }\n\n const newAccount = this.#createAccountModeAccount(newAddress);\n return [newAccount];\n }\n\n /**\n * Creates accounts for HD mode devices using index-based derivation.\n *\n * @param options - The account creation options.\n * @param _deviceState - The current device state (reserved for future use).\n * @param _deviceState.indexes - Map of addresses to their indexes.\n * @returns The created accounts.\n */\n async #createHdModeAccounts(\n options: CreateAccountOptions,\n _deviceState: { indexes: Record<Hex, number> },\n ): Promise<Bip44Account<KeyringAccount>[]> {\n if (options.type !== 'bip44:derive-index') {\n throw new Error(\n `Unsupported account creation type for HD mode QrKeyring: ${String(\n options.type,\n )}. Supported type: 'bip44:derive-index'.`,\n );\n }\n\n if (!Number.isInteger(options.groupIndex) || options.groupIndex < 0) {\n throw new Error(\n `Invalid groupIndex: ${options.groupIndex}. Must be a non-negative integer.`,\n );\n }\n\n const targetIndex = options.groupIndex;\n\n // Check if an account at this index already exists\n const currentAccounts = await this.getAccounts();\n const existingAccount = currentAccounts.find(\n (account) =>\n account.options.entropy?.type ===\n KeyringAccountEntropyTypeOption.Mnemonic &&\n account.options.entropy.groupIndex === targetIndex,\n );\n\n if (existingAccount) {\n return [existingAccount as Bip44Account<KeyringAccount>];\n }\n\n // Derive the account at the specified index\n this.inner.setAccountToUnlock(targetIndex);\n const [newAddress] = await this.inner.addAccounts(1);\n\n if (!newAddress) {\n throw new Error('Failed to create new account');\n }\n\n const newAccount = this.#createHdModeAccount(newAddress, targetIndex);\n return [newAccount];\n }\n\n /**\n * Delete an account from the keyring.\n *\n * @param accountId - The account ID to delete.\n */\n async deleteAccount(accountId: AccountId): Promise<void> {\n await this.withLock(async () => {\n const { address } = await this.getAccount(accountId);\n const hexAddress = this.toHexAddress(address);\n\n // Remove from the legacy keyring\n this.inner.removeAccount(hexAddress);\n\n // Remove from the registry\n this.registry.delete(accountId);\n });\n }\n\n /**\n * @returns The name of the paired device, or the keyring type if no device\n * is paired.\n */\n getName(): string {\n return this.inner.getName();\n }\n\n /**\n * @returns The current device mode (HD or Account), or `undefined` if no\n * device is paired.\n */\n getMode(): DeviceMode | undefined {\n return this.inner.getMode();\n }\n\n /**\n * Fetch the first page of candidate addresses from the device.\n *\n * @returns The first page of addresses.\n */\n async getFirstPage(): Promise<IndexedAddress[]> {\n return this.inner.getFirstPage();\n }\n\n /**\n * Fetch the next page of candidate addresses from the device.\n *\n * @returns The next page of addresses.\n */\n async getNextPage(): Promise<IndexedAddress[]> {\n return this.inner.getNextPage();\n }\n\n /**\n * Fetch the previous page of candidate addresses from the device.\n *\n * @returns The previous page of addresses.\n */\n async getPreviousPage(): Promise<IndexedAddress[]> {\n return this.inner.getPreviousPage();\n }\n\n /**\n * Clear the inner keyring's device-pairing state and accounts, and reset\n * the V2 account registry to keep them in sync.\n */\n async forgetDevice(): Promise<void> {\n await this.withLock(async () => {\n await this.inner.forgetDevice();\n this.registry.clear();\n });\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask-previews/eth-qr-keyring",
3
- "version": "2.0.1-7275dbc",
3
+ "version": "2.1.0-1fa477f",
4
4
  "description": "A simple standard interface for a series of Ethereum private keys",
5
5
  "keywords": [
6
6
  "ethereum",
@@ -75,9 +75,9 @@
75
75
  "@ethereumjs/util": "^9.1.0",
76
76
  "@keystonehq/bc-ur-registry-eth": "^0.19.1",
77
77
  "@metamask/eth-sig-util": "^8.2.0",
78
- "@metamask/keyring-api": "23.0.1",
79
- "@metamask/keyring-sdk": "2.0.1",
80
- "@metamask/keyring-utils": "3.2.0",
78
+ "@metamask/keyring-api": "23.5.0",
79
+ "@metamask/keyring-sdk": "2.2.0",
80
+ "@metamask/keyring-utils": "3.3.1",
81
81
  "@metamask/utils": "^11.11.0",
82
82
  "async-mutex": "^0.5.0",
83
83
  "hdkey": "^2.1.0",
@@ -87,7 +87,8 @@
87
87
  "@ethereumjs/common": "^4.4.0",
88
88
  "@keystonehq/metamask-airgapped-keyring": "^0.15.2",
89
89
  "@lavamoat/allow-scripts": "^3.2.1",
90
- "@metamask/account-api": "1.0.3",
90
+ "@lavamoat/preinstall-always-fail": "^2.1.0",
91
+ "@metamask/account-api": "1.1.0",
91
92
  "@metamask/auto-changelog": "^6.1.0",
92
93
  "@types/hdkey": "^2.0.1",
93
94
  "@types/jest": "^29.5.12",
@@ -98,7 +99,7 @@
98
99
  "ts-jest": "^29.0.5",
99
100
  "ts-node": "^10.9.2",
100
101
  "typedoc": "^0.25.13",
101
- "typescript": "~5.6.3"
102
+ "typescript": "~5.3.3"
102
103
  },
103
104
  "engines": {
104
105
  "node": "^18.18 || >=20"