@onekeyfe/hd-core 1.2.2-alpha.2 → 1.2.2-alpha.4

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.
@@ -95,7 +95,7 @@ describe('AllNetworkGetAddressBase tracing', () => {
95
95
  'hidden-state',
96
96
  false,
97
97
  undefined,
98
- false,
98
+ undefined,
99
99
  undefined
100
100
  );
101
101
  expect(calls).toEqual(['resume-hidden-session', 'run-chain-method']);
@@ -264,7 +264,7 @@ describe('AllNetworkGetAddressBase tracing', () => {
264
264
  undefined,
265
265
  true,
266
266
  undefined,
267
- false,
267
+ undefined,
268
268
  true
269
269
  );
270
270
  expect(calls).toEqual(['resume-standard-session', 'run-chain-method']);
@@ -1964,43 +1964,119 @@ describe('openWalletSession', () => {
1964
1964
  expect(deviceWalletSessionStore.get('device-1', 'hidden-state')).toBe('new-session');
1965
1965
  });
1966
1966
 
1967
- test.each([false, true])('keeps deriveCardano API compatibility: %s', async deriveCardano => {
1968
- const typedCall = jest
1969
- .fn()
1970
- .mockResolvedValueOnce({ message: { version: 2 } })
1971
- .mockResolvedValueOnce({ message: {} })
1972
- .mockResolvedValueOnce({
1973
- message: {
1974
- btc_test_address: 'hidden-state',
1975
- session_id: 'new-session',
1967
+ test.each([false, true])(
1968
+ 'openWalletSession does not thread CommonParams.deriveCardano: %s',
1969
+ async deriveCardano => {
1970
+ const typedCall = jest
1971
+ .fn()
1972
+ .mockResolvedValueOnce({ message: { version: 2 } })
1973
+ .mockResolvedValueOnce({ message: {} })
1974
+ .mockResolvedValueOnce({
1975
+ message: {
1976
+ btc_test_address: 'hidden-state',
1977
+ session_id: 'new-session',
1978
+ },
1979
+ });
1980
+ const method = new OpenWalletSession({
1981
+ payload: {
1982
+ method: 'openWalletSession',
1983
+ connectId: 'connect-id',
1984
+ mode: 'select-hidden',
1985
+ deriveCardano,
1976
1986
  },
1977
1987
  });
1978
- const method = new OpenWalletSession({
1979
- payload: {
1980
- method: 'openWalletSession',
1981
- connectId: 'connect-id',
1982
- mode: 'select-hidden',
1983
- deriveCardano,
1984
- },
1988
+ method.init();
1989
+ method.device = createDevice({
1990
+ typedCall,
1991
+ promptPassphrase: jest.fn().mockResolvedValue({ passphrase: 'host hidden wallet' }),
1992
+ }) as any;
1993
+
1994
+ await expect(method.run()).resolves.toMatchObject({
1995
+ walletType: 'hidden',
1996
+ passphraseState: 'hidden-state',
1997
+ });
1998
+ expect(typedCall).toHaveBeenCalledWith('DeviceSessionAskPassphrase', 'Success', {
1999
+ passphrase: 'host hidden wallet',
2000
+ on_device: false,
2001
+ seed_domains: [],
2002
+ });
2003
+ expect(typedCall).toHaveBeenCalledWith('DeviceSessionGet', 'DeviceSession', {});
2004
+ }
2005
+ );
2006
+
2007
+ test('requests Cardano seed domains when a V2 session rebuild has Cardano intent', async () => {
2008
+ const typedCall = jest.fn((request: string) => {
2009
+ if (request === 'ProtocolInfoRequest') {
2010
+ return { message: { version: 2 } };
2011
+ }
2012
+ if (request === 'DeviceSessionAskPassphrase') {
2013
+ return { message: {} };
2014
+ }
2015
+ if (request === 'DeviceSessionGet') {
2016
+ return {
2017
+ message: {
2018
+ btc_test_address: 'hidden-state',
2019
+ session_id: 'new-session',
2020
+ },
2021
+ };
2022
+ }
2023
+ throw new Error(`Unexpected request: ${request}`);
1985
2024
  });
1986
- method.init();
1987
- method.device = createDevice({
2025
+ const device = createDevice({
1988
2026
  typedCall,
1989
2027
  promptPassphrase: jest.fn().mockResolvedValue({ passphrase: 'host hidden wallet' }),
1990
- }) as any;
2028
+ });
1991
2029
 
1992
- await expect(method.run()).resolves.toMatchObject({
1993
- walletType: 'hidden',
2030
+ await expect(
2031
+ getProtocolV2WalletSession(device as any, {
2032
+ forceWalletSelection: true,
2033
+ deriveCardano: true,
2034
+ })
2035
+ ).resolves.toMatchObject({
1994
2036
  passphraseState: 'hidden-state',
2037
+ newSession: 'new-session',
1995
2038
  });
1996
2039
  expect(typedCall).toHaveBeenCalledWith('DeviceSessionAskPassphrase', 'Success', {
1997
2040
  passphrase: 'host hidden wallet',
1998
2041
  on_device: false,
1999
2042
  seed_domains: [
2000
2043
  DeviceSessionSeedDomain.SeedDomain_Standard,
2001
- ...(deriveCardano ? [DeviceSessionSeedDomain.SeedDomain_Cardano] : []),
2044
+ DeviceSessionSeedDomain.SeedDomain_Cardano,
2002
2045
  ],
2003
2046
  });
2004
- expect(typedCall).toHaveBeenCalledWith('DeviceSessionGet', 'DeviceSession', {});
2047
+ });
2048
+
2049
+ test('does not freeze a V2 session to Standard-only when deriveCardano is false', async () => {
2050
+ const typedCall = jest.fn((request: string) => {
2051
+ if (request === 'ProtocolInfoRequest') {
2052
+ return { message: { version: 2 } };
2053
+ }
2054
+ if (request === 'DeviceSessionAskPassphrase') {
2055
+ return { message: {} };
2056
+ }
2057
+ if (request === 'DeviceSessionGet') {
2058
+ return {
2059
+ message: {
2060
+ btc_test_address: 'hidden-state',
2061
+ session_id: 'new-session',
2062
+ },
2063
+ };
2064
+ }
2065
+ throw new Error(`Unexpected request: ${request}`);
2066
+ });
2067
+ const device = createDevice({
2068
+ typedCall,
2069
+ promptPassphrase: jest.fn().mockResolvedValue({ passphrase: 'host hidden wallet' }),
2070
+ });
2071
+
2072
+ await getProtocolV2WalletSession(device as any, {
2073
+ forceWalletSelection: true,
2074
+ deriveCardano: false,
2075
+ });
2076
+ expect(typedCall).toHaveBeenCalledWith('DeviceSessionAskPassphrase', 'Success', {
2077
+ passphrase: 'host hidden wallet',
2078
+ on_device: false,
2079
+ seed_domains: [],
2080
+ });
2005
2081
  });
2006
2082
  });
@@ -1 +1 @@
1
- {"version":3,"file":"OpenWalletSession.d.ts","sourceRoot":"","sources":["../../src/api/OpenWalletSession.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAI1C,OAAO,KAAK,EACV,uBAAuB,EACvB,wBAAwB,EACzB,MAAM,gCAAgC,CAAC;AAwExC,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,UAAU,CAAC,uBAAuB,CAAC;IAChF,qBAAqB;IAIrB,IAAI;IAYE,GAAG,IAAI,OAAO,CAAC,wBAAwB,CAAC;CAmM/C"}
1
+ {"version":3,"file":"OpenWalletSession.d.ts","sourceRoot":"","sources":["../../src/api/OpenWalletSession.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAI1C,OAAO,KAAK,EACV,uBAAuB,EACvB,wBAAwB,EACzB,MAAM,gCAAgC,CAAC;AAwExC,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,UAAU,CAAC,uBAAuB,CAAC;IAChF,qBAAqB;IAIrB,IAAI;IAYE,GAAG,IAAI,OAAO,CAAC,wBAAwB,CAAC;CAgM/C"}
@@ -1 +1 @@
1
- {"version":3,"file":"AllNetworkGetAddressBase.d.ts","sourceRoot":"","sources":["../../../src/api/allnetwork/AllNetworkGetAddressBase.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAe3C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,EACV,iBAAiB,EACjB,uBAAuB,EACvB,oBAAoB,EACpB,QAAQ,EACT,MAAM,sCAAsC,CAAC;AAI9C,MAAM,MAAM,aAAa,GAAG;IAC1B,UAAU,EAAE,MAAM,OAAO,CAAC;IAC1B,SAAS,CAAC,EAAE,CAAC,UAAU,EAAE,uBAAuB,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,KAAK,GAAG,CAAC;IAClG,kBAAkB,CAAC,EAAE,CAAC,MAAM,OAAO,CAAC,EAAE,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,CAAC,CAAC;AAEzF,MAAM,MAAM,gBAAgB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AAC;YAOV,gBAAgB;CAiC/B;AAED,eAAO,MAAM,QAAQ,YAIpB,CAAC;AAEF,eAAO,MAAM,aAAa,uBAYzB,CAAC;AAMF,eAAO,MAAM,IAAI,aACL,eAAe,aACd,GAAG,WACL,6BAA6B,8BAiBvC,CAAC;AAEF,eAAO,MAAM,eAAe;SAKrB,eAAe,CAAC,KAAK,CAAC;eAChB,GAAG;;UASf,CAAC"}
package/dist/index.js CHANGED
@@ -41794,12 +41794,12 @@ const negotiateEventlessWalletSession = (device) => __awaiter(void 0, void 0, vo
41794
41794
  yield device.ensureProtocolV2RuntimeContext();
41795
41795
  });
41796
41796
  const getDeviceSession = (device, request) => __awaiter(void 0, void 0, void 0, function* () { return device.commands.typedCall('DeviceSessionGet', 'DeviceSession', request); });
41797
- const buildDeviceSessionSeedDomains = (deriveCardano) => deriveCardano === undefined
41798
- ? []
41799
- : [
41797
+ const buildDeviceSessionSeedDomains = (deriveCardano) => deriveCardano === true
41798
+ ? [
41800
41799
  hdTransport.DeviceSessionSeedDomain.SeedDomain_Standard,
41801
- ...(deriveCardano ? [hdTransport.DeviceSessionSeedDomain.SeedDomain_Cardano] : []),
41802
- ];
41800
+ hdTransport.DeviceSessionSeedDomain.SeedDomain_Cardano,
41801
+ ]
41802
+ : [];
41803
41803
  const buildDeviceSessionGetRequest = ({ sessionId, expectedPassphraseState, } = {}) => (Object.assign(Object.assign({}, (sessionId ? { session_id: sessionId } : {})), (expectedPassphraseState ? { btc_test_address: expectedPassphraseState } : {})));
41804
41804
  const askDevicePassphrase = (device, requestPayload, deriveCardano, onStatusRefreshed) => __awaiter(void 0, void 0, void 0, function* () {
41805
41805
  yield device.commands.typedCall('DeviceSessionAskPassphrase', 'Success', Object.assign(Object.assign({}, requestPayload), { seed_domains: buildDeviceSessionSeedDomains(deriveCardano) }));
@@ -47641,7 +47641,6 @@ class OpenWalletSession extends BaseMethod {
47641
47641
  const session = isProtocolV2
47642
47642
  ? yield getProtocolV2WalletSession(this.device, {
47643
47643
  onlyMainPin: true,
47644
- deriveCardano: this.payload.deriveCardano,
47645
47644
  selectMainWalletBeforeRestore: !hasAuthoritativeProtocolV2WalletStatus(state) ||
47646
47645
  state.status.unlockedAttachPin === true,
47647
47646
  mainPinSelected: (_b = this.protocolV2UnlockContext) === null || _b === void 0 ? void 0 : _b.preflightMainPinSelected,
@@ -47698,7 +47697,6 @@ class OpenWalletSession extends BaseMethod {
47698
47697
  const session = isProtocolV2
47699
47698
  ? yield getProtocolV2WalletSession(this.device, {
47700
47699
  expectedPassphraseState: this.params.passphraseState,
47701
- deriveCardano: this.payload.deriveCardano,
47702
47700
  })
47703
47701
  : yield getPassphraseStateWithRefreshDeviceInfo(this.device, {
47704
47702
  expectPassphraseState: this.params.passphraseState,
@@ -47718,9 +47716,9 @@ class OpenWalletSession extends BaseMethod {
47718
47716
  }
47719
47717
  const readCurrentAttachPinSession = isProtocolV2 && walletStatus.status.unlockedAttachPin === true;
47720
47718
  const session = isProtocolV2
47721
- ? yield getProtocolV2WalletSession(this.device, Object.assign(Object.assign({}, (readCurrentAttachPinSession
47719
+ ? yield getProtocolV2WalletSession(this.device, Object.assign({}, (readCurrentAttachPinSession
47722
47720
  ? { readCurrentAttachPinSession: true }
47723
- : { forceWalletSelection: true })), { deriveCardano: this.payload.deriveCardano }))
47721
+ : { forceWalletSelection: true })))
47724
47722
  : yield getPassphraseStateWithRefreshDeviceInfo(this.device, { initSession: true });
47725
47723
  const refreshedState = isProtocolV2
47726
47724
  ? requireAuthoritativeProtocolV2WalletStatus(yield resolveProtocolV2DeviceStateAfterSession(session))
@@ -55875,7 +55873,7 @@ class AllNetworkGetAddressBase extends BaseMethod {
55875
55873
  }
55876
55874
  }
55877
55875
  const useEmptyPassphrase = this.payload.useEmptyPassphrase === true;
55878
- const deriveCardano = method.name.startsWith('cardano');
55876
+ const deriveCardano = method.name.startsWith('cardano') ? true : undefined;
55879
55877
  const shouldResumeWalletSession = useEmptyPassphrase || !!this.payload.passphraseState;
55880
55878
  if (this.device.isProtocolV2() && shouldResumeWalletSession) {
55881
55879
  const passphraseStateSafety = yield this.device.checkPassphraseStateSafety(this.payload.passphraseState, useEmptyPassphrase, this.payload.skipPassphraseCheck, deriveCardano, (_d = this.protocolV2UnlockContext) === null || _d === void 0 ? void 0 : _d.preflightMainPinSelected);
@@ -65623,7 +65621,7 @@ const PRE_INITIALIZE_TTL_MS = 60 * 1000;
65623
65621
  const PRE_PENDING_CALL_TIMEOUT_MS = 15 * 1000;
65624
65622
  const preWarmInflight = new Map();
65625
65623
  const preWarmDoneAt = new Map();
65626
- function hasDeriveCardano(method) {
65624
+ function resolveDeriveCardano(method) {
65627
65625
  var _a;
65628
65626
  if (method.name.startsWith('allNetworkGetAddress') &&
65629
65627
  method.payload &&
@@ -65631,13 +65629,19 @@ function hasDeriveCardano(method) {
65631
65629
  method.payload.bundle.some(net => net && net.network === 'ada')) {
65632
65630
  return true;
65633
65631
  }
65634
- return method.name.startsWith('cardano') || ((_a = method.payload) === null || _a === void 0 ? void 0 : _a.deriveCardano);
65632
+ if (method.name.startsWith('cardano')) {
65633
+ return true;
65634
+ }
65635
+ if (((_a = method.payload) === null || _a === void 0 ? void 0 : _a.deriveCardano) === true) {
65636
+ return true;
65637
+ }
65638
+ return undefined;
65635
65639
  }
65636
65640
  const parseInitOptions = (method) => ({
65637
65641
  initSession: method === null || method === void 0 ? void 0 : method.payload.initSession,
65638
65642
  passphraseState: (method === null || method === void 0 ? void 0 : method.payload.useEmptyPassphrase) ? undefined : method === null || method === void 0 ? void 0 : method.payload.passphraseState,
65639
65643
  deviceId: method === null || method === void 0 ? void 0 : method.payload.deviceId,
65640
- deriveCardano: method && hasDeriveCardano(method),
65644
+ deriveCardano: method ? resolveDeriveCardano(method) : undefined,
65641
65645
  connectProtocol: method === null || method === void 0 ? void 0 : method.payload.connectProtocol,
65642
65646
  forceProtocolDetection: method === null || method === void 0 ? void 0 : method.payload.forceProtocolDetection,
65643
65647
  protocolV2DeviceInfoTimeoutMs: method === null || method === void 0 ? void 0 : method.payload.protocolV2DeviceInfoTimeoutMs,
@@ -65996,7 +66000,7 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
65996
66000
  require: support.require,
65997
66001
  });
65998
66002
  }
65999
- const passphraseStateSafety = yield device.checkPassphraseStateSafety((_o = method.payload) === null || _o === void 0 ? void 0 : _o.passphraseState, (_p = method.payload) === null || _p === void 0 ? void 0 : _p.useEmptyPassphrase, (_q = method.payload) === null || _q === void 0 ? void 0 : _q.skipPassphraseCheck, hasDeriveCardano(method), (_r = method.protocolV2UnlockContext) === null || _r === void 0 ? void 0 : _r.preflightMainPinSelected);
66003
+ const passphraseStateSafety = yield device.checkPassphraseStateSafety((_o = method.payload) === null || _o === void 0 ? void 0 : _o.passphraseState, (_p = method.payload) === null || _p === void 0 ? void 0 : _p.useEmptyPassphrase, (_q = method.payload) === null || _q === void 0 ? void 0 : _q.skipPassphraseCheck, resolveDeriveCardano(method), (_r = method.protocolV2UnlockContext) === null || _r === void 0 ? void 0 : _r.preflightMainPinSelected);
66000
66004
  checkPassphraseEnableState(method, device.features);
66001
66005
  if (!passphraseStateSafety) {
66002
66006
  DevicePool.clearDeviceCache(method.payload.connectId);
@@ -1 +1 @@
1
- {"version":3,"file":"walletSession.d.ts","sourceRoot":"","sources":["../../../src/protocols/protocol-v2/walletSession.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAuBlD,wBAAsB,6BAA6B,CAAC,MAAM,EAAE,MAAM,0DAGjE;AAED,wBAAsB,6BAA6B,CAAC,MAAM,EAAE,MAAM,qCAGjE;AAED,wBAAsB,qCAAqC,CAAC,MAAM,EAAE,MAAM,oBAgBzE;AA2ID,wBAAsB,0BAA0B,CAC9C,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE;IACR,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAE/B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,uBAA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ClD,MAAM,EAAE,MAAM,EACd,uBAAuB,EAAE,MAAM,EAC/B,aAAa,CAAC,EAAE,OAAO;;;;;;GAOxB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hd-core",
3
- "version": "1.2.2-alpha.2",
3
+ "version": "1.2.2-alpha.4",
4
4
  "description": "Core processes and APIs for communicating with OneKey hardware devices.",
5
5
  "author": "OneKey",
6
6
  "homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
@@ -25,8 +25,8 @@
25
25
  "url": "https://github.com/OneKeyHQ/hardware-js-sdk/issues"
26
26
  },
27
27
  "dependencies": {
28
- "@onekeyfe/hd-shared": "1.2.2-alpha.2",
29
- "@onekeyfe/hd-transport": "1.2.2-alpha.2",
28
+ "@onekeyfe/hd-shared": "1.2.2-alpha.4",
29
+ "@onekeyfe/hd-transport": "1.2.2-alpha.4",
30
30
  "axios": "1.15.2",
31
31
  "bignumber.js": "^9.0.2",
32
32
  "buffer": "^6.0.3",
@@ -46,5 +46,5 @@
46
46
  "@types/w3c-web-usb": "^1.0.10",
47
47
  "@types/web-bluetooth": "^0.0.21"
48
48
  },
49
- "gitHead": "fc914d0361028f1012ca764e53f996b9893b40f9"
49
+ "gitHead": "53bee9cdd24c8a4d124ca5067fa78756f287d391"
50
50
  }
@@ -160,7 +160,6 @@ export default class OpenWalletSession extends BaseMethod<OpenWalletSessionParam
160
160
  const session = isProtocolV2
161
161
  ? await getProtocolV2WalletSession(this.device, {
162
162
  onlyMainPin: true,
163
- deriveCardano: this.payload.deriveCardano,
164
163
  selectMainWalletBeforeRestore:
165
164
  !hasAuthoritativeProtocolV2WalletStatus(state) ||
166
165
  state.status.unlockedAttachPin === true,
@@ -225,7 +224,6 @@ export default class OpenWalletSession extends BaseMethod<OpenWalletSessionParam
225
224
  const session = isProtocolV2
226
225
  ? await getProtocolV2WalletSession(this.device, {
227
226
  expectedPassphraseState: this.params.passphraseState,
228
- deriveCardano: this.payload.deriveCardano,
229
227
  })
230
228
  : await getPassphraseStateWithRefreshDeviceInfo(this.device, {
231
229
  expectPassphraseState: this.params.passphraseState,
@@ -257,7 +255,6 @@ export default class OpenWalletSession extends BaseMethod<OpenWalletSessionParam
257
255
  ...(readCurrentAttachPinSession
258
256
  ? { readCurrentAttachPinSession: true }
259
257
  : { forceWalletSelection: true }),
260
- deriveCardano: this.payload.deriveCardano,
261
258
  })
262
259
  : await getPassphraseStateWithRefreshDeviceInfo(this.device, { initSession: true });
263
260
  const refreshedState = isProtocolV2
@@ -393,7 +393,9 @@ export default abstract class AllNetworkGetAddressBase extends BaseMethod<
393
393
  // the root fingerprint, so each nested chain method must resume the
394
394
  // requested standard or hidden wallet before sending its device command.
395
395
  const useEmptyPassphrase = this.payload.useEmptyPassphrase === true;
396
- const deriveCardano = method.name.startsWith('cardano');
396
+ // Nested Cardano methods opt in to [Standard, Cardano] if Ask rebuilds.
397
+ // Other chains omit the flag so V2 keeps firmware's default domains.
398
+ const deriveCardano = method.name.startsWith('cardano') ? true : undefined;
397
399
  const shouldResumeWalletSession = useEmptyPassphrase || !!this.payload.passphraseState;
398
400
  if (this.device.isProtocolV2() && shouldResumeWalletSession) {
399
401
  const passphraseStateSafety = await this.device.checkPassphraseStateSafety(
package/src/core/index.ts CHANGED
@@ -92,7 +92,7 @@ const preWarmDoneAt = new Map<string, number>();
92
92
 
93
93
  export type CoreContext = ReturnType<Core['getCoreContext']>;
94
94
 
95
- function hasDeriveCardano(method: BaseMethod): boolean {
95
+ function resolveDeriveCardano(method: BaseMethod): boolean | undefined {
96
96
  if (
97
97
  method.name.startsWith('allNetworkGetAddress') &&
98
98
  method.payload &&
@@ -102,15 +102,22 @@ function hasDeriveCardano(method: BaseMethod): boolean {
102
102
  ) {
103
103
  return true;
104
104
  }
105
-
106
- return method.name.startsWith('cardano') || method.payload?.deriveCardano;
105
+ if (method.name.startsWith('cardano')) {
106
+ return true;
107
+ }
108
+ // V1 Initialize only acts on a true opt-in. V2 AskPassphrase must not treat
109
+ // false as Standard-only, so never forward an explicit false.
110
+ if (method.payload?.deriveCardano === true) {
111
+ return true;
112
+ }
113
+ return undefined;
107
114
  }
108
115
 
109
116
  const parseInitOptions = (method?: BaseMethod): InitOptions => ({
110
117
  initSession: method?.payload.initSession,
111
118
  passphraseState: method?.payload.useEmptyPassphrase ? undefined : method?.payload.passphraseState,
112
119
  deviceId: method?.payload.deviceId,
113
- deriveCardano: method && hasDeriveCardano(method),
120
+ deriveCardano: method ? resolveDeriveCardano(method) : undefined,
114
121
  connectProtocol: method?.payload.connectProtocol,
115
122
  forceProtocolDetection: method?.payload.forceProtocolDetection,
116
123
  protocolV2DeviceInfoTimeoutMs: method?.payload.protocolV2DeviceInfoTimeoutMs,
@@ -651,7 +658,7 @@ const onCallDevice = async (
651
658
  method.payload?.passphraseState,
652
659
  method.payload?.useEmptyPassphrase,
653
660
  method.payload?.skipPassphraseCheck,
654
- hasDeriveCardano(method),
661
+ resolveDeriveCardano(method),
655
662
  method.protocolV2UnlockContext?.preflightMainPinSelected
656
663
  );
657
664
 
@@ -63,13 +63,18 @@ const negotiateEventlessWalletSession = async (device: Device) => {
63
63
  const getDeviceSession = async (device: Device, request: DeviceSessionGet) =>
64
64
  device.commands.typedCall('DeviceSessionGet', 'DeviceSession', request);
65
65
 
66
+ // V1 `deriveCardano` is a per-Initialize opt-in: false/omit skips Cardano this
67
+ // round trip and a later Initialize can still add it. V2 seed domains are set
68
+ // only on AskPassphrase and cannot be upgraded by Get, so false must not freeze
69
+ // the session to Standard-only. true requests [Standard, Cardano]; anything
70
+ // else leaves seed_domains empty and firmware keeps its default (all domains).
66
71
  const buildDeviceSessionSeedDomains = (deriveCardano?: boolean): DeviceSessionSeedDomain[] =>
67
- deriveCardano === undefined
68
- ? []
69
- : [
72
+ deriveCardano === true
73
+ ? [
70
74
  DeviceSessionSeedDomain.SeedDomain_Standard,
71
- ...(deriveCardano ? [DeviceSessionSeedDomain.SeedDomain_Cardano] : []),
72
- ];
75
+ DeviceSessionSeedDomain.SeedDomain_Cardano,
76
+ ]
77
+ : [];
73
78
 
74
79
  // Seed domains are applied when creating a passphrase session, not when reading/resuming one.
75
80
  // Current firmware rejects unknown DeviceSessionGet fields, including leftover seed_domains.