@onekeyfe/hd-core 1.2.2-alpha.3 → 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.
- package/__tests__/open-wallet-session.test.ts +99 -23
- package/dist/api/OpenWalletSession.d.ts.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/index.js +9 -11
- package/dist/protocols/protocol-v2/walletSession.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/OpenWalletSession.ts +0 -3
- package/src/api/allnetwork/AllNetworkGetAddressBase.ts +2 -2
- package/src/core/index.ts +4 -2
- package/src/protocols/protocol-v2/walletSession.ts +10 -5
|
@@ -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])(
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
message: {
|
|
1974
|
-
|
|
1975
|
-
|
|
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
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
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
|
-
|
|
1987
|
-
method.device = createDevice({
|
|
2025
|
+
const device = createDevice({
|
|
1988
2026
|
typedCall,
|
|
1989
2027
|
promptPassphrase: jest.fn().mockResolvedValue({ passphrase: 'host hidden wallet' }),
|
|
1990
|
-
})
|
|
2028
|
+
});
|
|
1991
2029
|
|
|
1992
|
-
await expect(
|
|
1993
|
-
|
|
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
|
-
|
|
2044
|
+
DeviceSessionSeedDomain.SeedDomain_Cardano,
|
|
2002
2045
|
],
|
|
2003
2046
|
});
|
|
2004
|
-
|
|
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;
|
|
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"}
|
package/dist/core/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":";AACA,OAAO,YAAY,MAAM,QAAQ,CAAC;AAoClC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAsB1C,OAAO,eAAe,MAAM,2BAA2B,CAAC;AAYxD,OAAO,KAAK,EAAE,eAAe,EAAyB,MAAM,UAAU,CAAC;AACvE,OAAO,KAAK,EAAE,WAAW,EAAmD,MAAM,WAAW,CAAC;AAI9F,OAAO,KAAK,EACV,6BAA6B,EAG9B,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAWpD,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":";AACA,OAAO,YAAY,MAAM,QAAQ,CAAC;AAoClC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAsB1C,OAAO,eAAe,MAAM,2BAA2B,CAAC;AAYxD,OAAO,KAAK,EAAE,eAAe,EAAyB,MAAM,UAAU,CAAC;AACvE,OAAO,KAAK,EAAE,WAAW,EAAmD,MAAM,WAAW,CAAC;AAI9F,OAAO,KAAK,EACV,6BAA6B,EAG9B,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAWpD,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC;AA0E7D,eAAO,MAAM,OAAO,YAAmB,WAAW,WAAW,WAAW,iBAoFvE,CAAC;AAyqBF,wBAAgB,kCAAkC,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,WAWpF;AAED,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,WAW/E;AAED,wBAAgB,gCAAgC,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,WAQlF;AAED,wBAAgB,mCAAmC,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,WAMrF;AAkVD,eAAO,MAAM,MAAM,YAAa,WAAW,cAAc,MAAM,SAuG9D,CAAC;AAuGF,eAAO,MAAM,qBAAqB,gFAejC,CAAC;AAiLF,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,YAAY;IAC5C,OAAO,CAAC,cAAc,CAAoB;IAE1C,SAAgB,aAAa,EAAE,MAAM,CAAC;IAEtC,OAAO,CAAC,YAAY,CAAsB;IAE1C,OAAO,CAAC,cAAc,CAAC,CAAgB;IAGvC,OAAO,CAAC,sBAAsB,CAAoC;IAElE,OAAO,CAAC,iBAAiB,CAAoB;;IAS7C,OAAO,CAAC,cAAc;IA6BhB,aAAa,CAAC,OAAO,EAAE,WAAW;IAuExC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;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 ===
|
|
41798
|
-
? [
|
|
41799
|
-
: [
|
|
41797
|
+
const buildDeviceSessionSeedDomains = (deriveCardano) => deriveCardano === true
|
|
41798
|
+
? [
|
|
41800
41799
|
hdTransport.DeviceSessionSeedDomain.SeedDomain_Standard,
|
|
41801
|
-
|
|
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(
|
|
47719
|
+
? yield getProtocolV2WalletSession(this.device, Object.assign({}, (readCurrentAttachPinSession
|
|
47722
47720
|
? { readCurrentAttachPinSession: true }
|
|
47723
|
-
: { forceWalletSelection: true }))
|
|
47721
|
+
: { forceWalletSelection: true })))
|
|
47724
47722
|
: yield getPassphraseStateWithRefreshDeviceInfo(this.device, { initSession: true });
|
|
47725
47723
|
const refreshedState = isProtocolV2
|
|
47726
47724
|
? requireAuthoritativeProtocolV2WalletStatus(yield resolveProtocolV2DeviceStateAfterSession(session))
|
|
@@ -65634,8 +65632,8 @@ function resolveDeriveCardano(method) {
|
|
|
65634
65632
|
if (method.name.startsWith('cardano')) {
|
|
65635
65633
|
return true;
|
|
65636
65634
|
}
|
|
65637
|
-
if (
|
|
65638
|
-
return
|
|
65635
|
+
if (((_a = method.payload) === null || _a === void 0 ? void 0 : _a.deriveCardano) === true) {
|
|
65636
|
+
return true;
|
|
65639
65637
|
}
|
|
65640
65638
|
return undefined;
|
|
65641
65639
|
}
|
|
@@ -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;
|
|
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;AAgJD,wBAAsB,0BAA0B,CAC9C,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE;IACR,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAE/B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB,4BAA4B,CAAC,EAAE,OAAO,CAAC;IACvC,6BAA6B,CAAC,EAAE,OAAO,CAAC;IACxC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB,2BAA2B,CAAC,EAAE,OAAO,CAAC;IAEtC,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;;;;;;GAoRF;AAED,wBAAsB,8BAA8B,CAClD,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.
|
|
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.
|
|
29
|
-
"@onekeyfe/hd-transport": "1.2.2-alpha.
|
|
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": "
|
|
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,8 +393,8 @@ 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
|
-
//
|
|
397
|
-
//
|
|
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
398
|
const deriveCardano = method.name.startsWith('cardano') ? true : undefined;
|
|
399
399
|
const shouldResumeWalletSession = useEmptyPassphrase || !!this.payload.passphraseState;
|
|
400
400
|
if (this.device.isProtocolV2() && shouldResumeWalletSession) {
|
package/src/core/index.ts
CHANGED
|
@@ -105,8 +105,10 @@ function resolveDeriveCardano(method: BaseMethod): boolean | undefined {
|
|
|
105
105
|
if (method.name.startsWith('cardano')) {
|
|
106
106
|
return true;
|
|
107
107
|
}
|
|
108
|
-
|
|
109
|
-
|
|
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;
|
|
110
112
|
}
|
|
111
113
|
return undefined;
|
|
112
114
|
}
|
|
@@ -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 ===
|
|
68
|
-
? [
|
|
69
|
-
: [
|
|
72
|
+
deriveCardano === true
|
|
73
|
+
? [
|
|
70
74
|
DeviceSessionSeedDomain.SeedDomain_Standard,
|
|
71
|
-
|
|
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.
|