@onekeyfe/hd-core 1.2.0-alpha.28 → 1.2.0-alpha.29
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 +1 -7
- package/dist/api/OpenWalletSession.d.ts.map +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.js +11 -4
- package/dist/types/api/openWalletSession.d.ts +0 -1
- package/dist/types/api/openWalletSession.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/OpenWalletSession.ts +1 -10
- package/src/types/api/openWalletSession.ts +0 -2
|
@@ -184,7 +184,6 @@ describe('openWalletSession', () => {
|
|
|
184
184
|
walletType: 'standard',
|
|
185
185
|
deviceId: 'device-1',
|
|
186
186
|
passphraseState: null,
|
|
187
|
-
sessionId: 'main-wallet-session',
|
|
188
187
|
resumed: false,
|
|
189
188
|
});
|
|
190
189
|
expect(method.payload.useEmptyPassphrase).toBe(true);
|
|
@@ -261,7 +260,6 @@ describe('openWalletSession', () => {
|
|
|
261
260
|
walletType: 'hidden',
|
|
262
261
|
deviceId: 'device-1',
|
|
263
262
|
passphraseState: 'hidden-state-after-unlock',
|
|
264
|
-
sessionId: 'hidden-session-after-unlock',
|
|
265
263
|
resumed: false,
|
|
266
264
|
});
|
|
267
265
|
expect(device.unlockDevice).toHaveBeenCalledWith(DeviceSessionPinType.Main);
|
|
@@ -295,7 +293,6 @@ describe('openWalletSession', () => {
|
|
|
295
293
|
walletType: 'hidden',
|
|
296
294
|
deviceId: 'device-1',
|
|
297
295
|
passphraseState: 'new-hidden-state',
|
|
298
|
-
sessionId: 'new-hidden-session',
|
|
299
296
|
resumed: false,
|
|
300
297
|
});
|
|
301
298
|
expect(typedCall).toHaveBeenCalledWith('ProtocolInfoRequest', 'ProtocolInfo', {
|
|
@@ -369,7 +366,6 @@ describe('openWalletSession', () => {
|
|
|
369
366
|
walletType: 'hidden',
|
|
370
367
|
deviceId: 'device-1',
|
|
371
368
|
passphraseState: 'hidden-state',
|
|
372
|
-
sessionId: 'renewed-session',
|
|
373
369
|
resumed: true,
|
|
374
370
|
});
|
|
375
371
|
expect(typedCall).toHaveBeenCalledWith('DeviceSessionGet', 'DeviceSession', {
|
|
@@ -567,7 +563,7 @@ describe('openWalletSession', () => {
|
|
|
567
563
|
expect(device.clearInternalState).toHaveBeenCalled();
|
|
568
564
|
});
|
|
569
565
|
|
|
570
|
-
test('selects a hidden wallet
|
|
566
|
+
test('selects a hidden wallet without exposing the internal device session', async () => {
|
|
571
567
|
const typedCall = jest
|
|
572
568
|
.fn()
|
|
573
569
|
.mockResolvedValueOnce({ message: { version: 2 } })
|
|
@@ -592,7 +588,6 @@ describe('openWalletSession', () => {
|
|
|
592
588
|
walletType: 'hidden',
|
|
593
589
|
deviceId: 'device-1',
|
|
594
590
|
passphraseState: 'hidden-state',
|
|
595
|
-
sessionId: 'hidden-session',
|
|
596
591
|
resumed: false,
|
|
597
592
|
});
|
|
598
593
|
expect(typedCall).toHaveBeenCalledWith('DeviceSessionAskPassphrase', 'Success', {});
|
|
@@ -759,7 +754,6 @@ describe('openWalletSession', () => {
|
|
|
759
754
|
walletType: 'hidden',
|
|
760
755
|
deviceId: 'device-1',
|
|
761
756
|
passphraseState: 'hidden-state',
|
|
762
|
-
sessionId: 'renewed-session',
|
|
763
757
|
resumed: true,
|
|
764
758
|
});
|
|
765
759
|
expect(typedCall).toHaveBeenCalledWith('DeviceSessionGet', 'DeviceSession', {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenWalletSession.d.ts","sourceRoot":"","sources":["../../src/api/OpenWalletSession.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C,OAAO,KAAK,EACV,uBAAuB,EACvB,wBAAwB,EACzB,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"OpenWalletSession.d.ts","sourceRoot":"","sources":["../../src/api/OpenWalletSession.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C,OAAO,KAAK,EACV,uBAAuB,EACvB,wBAAwB,EACzB,MAAM,gCAAgC,CAAC;AA+DxC,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,UAAU,CAAC,uBAAuB,CAAC;IAChF,qBAAqB;IAIrB,IAAI;IAOE,GAAG,IAAI,OAAO,CAAC,wBAAwB,CAAC;CAmH/C"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1423,8 +1423,6 @@ type OpenWalletSessionPayloadBase = {
|
|
|
1423
1423
|
protocol: 'V1' | 'V2';
|
|
1424
1424
|
deviceId: string;
|
|
1425
1425
|
resumed: boolean;
|
|
1426
|
-
/** Forwarded only when the firmware response contains a wallet session id. */
|
|
1427
|
-
sessionId?: string;
|
|
1428
1426
|
};
|
|
1429
1427
|
type OpenWalletSessionPayload = OpenWalletSessionPayloadBase & ({
|
|
1430
1428
|
walletType: 'standard';
|
package/dist/index.js
CHANGED
|
@@ -45853,12 +45853,13 @@ const wasResumed = (session) => !!session &&
|
|
|
45853
45853
|
typeof session === 'object' &&
|
|
45854
45854
|
'resumed' in session &&
|
|
45855
45855
|
session.resumed === true;
|
|
45856
|
-
const forwardSessionId = (session) => session.newSession ? { sessionId: session.newSession } : {};
|
|
45857
45856
|
const requireHiddenWalletResponse = (session) => {
|
|
45858
45857
|
if (!session.passphraseState) {
|
|
45859
45858
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceInitializeFailed, 'Hidden wallet response is missing passphraseState');
|
|
45860
45859
|
}
|
|
45861
|
-
return
|
|
45860
|
+
return {
|
|
45861
|
+
passphraseState: session.passphraseState,
|
|
45862
|
+
};
|
|
45862
45863
|
};
|
|
45863
45864
|
const normalizeParams = (payload) => {
|
|
45864
45865
|
if (payload.mode === undefined) {
|
|
@@ -45930,7 +45931,13 @@ class OpenWalletSession extends BaseMethod {
|
|
|
45930
45931
|
this.device.clearInternalState();
|
|
45931
45932
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceCheckUnlockTypeError);
|
|
45932
45933
|
}
|
|
45933
|
-
return
|
|
45934
|
+
return {
|
|
45935
|
+
protocol,
|
|
45936
|
+
walletType: 'standard',
|
|
45937
|
+
deviceId,
|
|
45938
|
+
passphraseState: null,
|
|
45939
|
+
resumed: wasResumed(session),
|
|
45940
|
+
};
|
|
45934
45941
|
}
|
|
45935
45942
|
if (this.params.mode === 'resume-hidden') {
|
|
45936
45943
|
if (isProtocolV2) {
|
|
@@ -45982,7 +45989,7 @@ class OpenWalletSession extends BaseMethod {
|
|
|
45982
45989
|
resumed: wasResumed(session),
|
|
45983
45990
|
};
|
|
45984
45991
|
return this.device.getCurrentPassphraseProtection() === false
|
|
45985
|
-
? Object.assign(Object.assign(
|
|
45992
|
+
? Object.assign(Object.assign({}, responseBase), { walletType: 'standard', passphraseState: null }) : Object.assign(Object.assign(Object.assign({}, responseBase), { walletType: 'hidden' }), requireHiddenWalletResponse(session));
|
|
45986
45993
|
});
|
|
45987
45994
|
}
|
|
45988
45995
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openWalletSession.d.ts","sourceRoot":"","sources":["../../../src/types/api/openWalletSession.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAExD,MAAM,MAAM,uBAAuB,GAC/B;IACE,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,CAAC,EAAE,KAAK,CAAC;IACjB,eAAe,CAAC,EAAE,KAAK,CAAC;CACzB,GACD;IACE,IAAI,EAAE,eAAe,CAAC;IACtB,QAAQ,CAAC,EAAE,KAAK,CAAC;IACjB,eAAe,CAAC,EAAE,KAAK,CAAC;CACzB,GACD;IACE,IAAI,EAAE,eAAe,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAEN,KAAK,4BAA4B,GAAG;IAClC,QAAQ,EAAE,IAAI,GAAG,IAAI,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"openWalletSession.d.ts","sourceRoot":"","sources":["../../../src/types/api/openWalletSession.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAExD,MAAM,MAAM,uBAAuB,GAC/B;IACE,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,CAAC,EAAE,KAAK,CAAC;IACjB,eAAe,CAAC,EAAE,KAAK,CAAC;CACzB,GACD;IACE,IAAI,EAAE,eAAe,CAAC;IACtB,QAAQ,CAAC,EAAE,KAAK,CAAC;IACjB,eAAe,CAAC,EAAE,KAAK,CAAC;CACzB,GACD;IACE,IAAI,EAAE,eAAe,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAEN,KAAK,4BAA4B,GAAG;IAClC,QAAQ,EAAE,IAAI,GAAG,IAAI,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG,4BAA4B,GACjE,CACI;IACE,UAAU,EAAE,UAAU,CAAC;IACvB,eAAe,EAAE,IAAI,CAAC;CACvB,GACD;IACE,UAAU,EAAE,QAAQ,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;CACzB,CACJ,CAAC;AAMJ,MAAM,CAAC,OAAO,UAAU,iBAAiB,CACvC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,YAAY,GAAG,uBAAuB,GAC7C,QAAQ,CAAC,wBAAwB,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-core",
|
|
3
|
-
"version": "1.2.0-alpha.
|
|
3
|
+
"version": "1.2.0-alpha.29",
|
|
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.0-alpha.
|
|
29
|
-
"@onekeyfe/hd-transport": "1.2.0-alpha.
|
|
28
|
+
"@onekeyfe/hd-shared": "1.2.0-alpha.29",
|
|
29
|
+
"@onekeyfe/hd-transport": "1.2.0-alpha.29",
|
|
30
30
|
"axios": "1.15.2",
|
|
31
31
|
"bignumber.js": "^9.0.2",
|
|
32
32
|
"bytebuffer": "^5.0.1",
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"@types/w3c-web-usb": "^1.0.10",
|
|
45
45
|
"@types/web-bluetooth": "^0.0.21"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "4a4019e439cc472f89fd15ab47e84ef0ed43166a"
|
|
48
48
|
}
|
|
@@ -27,13 +27,7 @@ const wasResumed = (session: unknown) =>
|
|
|
27
27
|
'resumed' in session &&
|
|
28
28
|
(session as { resumed?: unknown }).resumed === true;
|
|
29
29
|
|
|
30
|
-
const
|
|
31
|
-
session.newSession ? { sessionId: session.newSession } : {};
|
|
32
|
-
|
|
33
|
-
const requireHiddenWalletResponse = (session: {
|
|
34
|
-
passphraseState?: string;
|
|
35
|
-
newSession?: string;
|
|
36
|
-
}) => {
|
|
30
|
+
const requireHiddenWalletResponse = (session: { passphraseState?: string }) => {
|
|
37
31
|
if (!session.passphraseState) {
|
|
38
32
|
throw ERRORS.TypedError(
|
|
39
33
|
HardwareErrorCode.DeviceInitializeFailed,
|
|
@@ -42,7 +36,6 @@ const requireHiddenWalletResponse = (session: {
|
|
|
42
36
|
}
|
|
43
37
|
return {
|
|
44
38
|
passphraseState: session.passphraseState,
|
|
45
|
-
...forwardSessionId(session),
|
|
46
39
|
};
|
|
47
40
|
};
|
|
48
41
|
|
|
@@ -132,7 +125,6 @@ export default class OpenWalletSession extends BaseMethod<OpenWalletSessionParam
|
|
|
132
125
|
walletType: 'standard',
|
|
133
126
|
deviceId,
|
|
134
127
|
passphraseState: null,
|
|
135
|
-
...forwardSessionId(session),
|
|
136
128
|
resumed: wasResumed(session),
|
|
137
129
|
};
|
|
138
130
|
}
|
|
@@ -200,7 +192,6 @@ export default class OpenWalletSession extends BaseMethod<OpenWalletSessionParam
|
|
|
200
192
|
...responseBase,
|
|
201
193
|
walletType: 'standard',
|
|
202
194
|
passphraseState: null,
|
|
203
|
-
...forwardSessionId(session),
|
|
204
195
|
}
|
|
205
196
|
: {
|
|
206
197
|
...responseBase,
|
|
@@ -21,8 +21,6 @@ type OpenWalletSessionPayloadBase = {
|
|
|
21
21
|
protocol: 'V1' | 'V2';
|
|
22
22
|
deviceId: string;
|
|
23
23
|
resumed: boolean;
|
|
24
|
-
/** Forwarded only when the firmware response contains a wallet session id. */
|
|
25
|
-
sessionId?: string;
|
|
26
24
|
};
|
|
27
25
|
|
|
28
26
|
export type OpenWalletSessionPayload = OpenWalletSessionPayloadBase &
|