@onekeyfe/hd-core 1.2.0-alpha.156 → 1.2.0-alpha.158
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__/device-state-events.test.ts +2 -2
- package/__tests__/device-state-mapper.test.ts +2 -11
- package/__tests__/device-utils.test.ts +0 -4
- package/__tests__/protocol-v2-resources.test.ts +2 -18
- package/__tests__/protocol-v2.test.ts +7 -7
- package/__tests__/search-devices.test.ts +3 -4
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/data-manager/TransportManager.d.ts.map +1 -1
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/deviceProfile/buildDeviceFeatures.d.ts.map +1 -1
- package/dist/index.js +71 -23
- package/dist/protocols/protocol-v2/resources.d.ts.map +1 -1
- package/dist/utils/deviceFeaturesCompat.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/FirmwareUpdateV4.ts +3 -7
- package/src/api/SearchDevices.ts +2 -2
- package/src/core/index.ts +97 -6
- package/src/data-manager/TransportManager.ts +3 -1
- package/src/device/Device.ts +1 -3
- package/src/device/DeviceStateMapper.ts +2 -2
- package/src/deviceProfile/buildDeviceFeatures.ts +2 -7
- package/src/protocols/protocol-v2/resources.ts +13 -3
- package/src/utils/deviceFeaturesCompat.ts +4 -9
|
@@ -88,9 +88,9 @@ describe('Device state events', () => {
|
|
|
88
88
|
expect(device.getCurrentDeviceType()).toBe(EDeviceType.Pro2);
|
|
89
89
|
expect(device.getCurrentDeviceId()).toBe('wallet-id');
|
|
90
90
|
expect(device.getCurrentSerialNo()).toBe('SERIAL-PRO2');
|
|
91
|
-
expect(device.getCurrentBleName()).toBe('
|
|
91
|
+
expect(device.getCurrentBleName()).toBe('Pro2 1234');
|
|
92
92
|
expect(device.getCurrentLabel()).toBeNull();
|
|
93
|
-
expect((device as any).getCurrentDisplayName()).toBe('
|
|
93
|
+
expect((device as any).getCurrentDisplayName()).toBe('Pro2 1234');
|
|
94
94
|
expect(device.getCurrentPassphraseProtection()).toBe(false);
|
|
95
95
|
expect(device.getCurrentFirmwareVersionString()).toBe('5.1.2');
|
|
96
96
|
expect(device.getCurrentBLEFirmwareVersionString()).toBe('0.0.0');
|
|
@@ -136,7 +136,7 @@ describe('DeviceStateMapper', () => {
|
|
|
136
136
|
expect(patch.identity).toMatchObject({
|
|
137
137
|
deviceType: EDeviceType.Pro2,
|
|
138
138
|
serialNo: 'SERIAL-1',
|
|
139
|
-
bleName: '
|
|
139
|
+
bleName: 'Pro2 1234',
|
|
140
140
|
});
|
|
141
141
|
expect(patch.versions).toMatchObject({
|
|
142
142
|
firmware: '5.0.0',
|
|
@@ -178,16 +178,7 @@ describe('DeviceStateMapper', () => {
|
|
|
178
178
|
coprocessor: { bt_adv_name: 'Pro2 22D8 - Fin' },
|
|
179
179
|
});
|
|
180
180
|
|
|
181
|
-
expect(patch.identity?.bleName).toBe('
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
test('canonicalizes a spaced Pro2 advertisement name from DeviceInfo', () => {
|
|
185
|
-
const patch = mapProtocolV2DeviceInfoToState({
|
|
186
|
-
hw: { Device_type: DeviceType.PRO2, serial_no: 'SERIAL-1' },
|
|
187
|
-
coprocessor: { bt_adv_name: 'Pro 2 0088 - Find My' },
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
expect(patch.identity?.bleName).toBe('Pro 2 0088');
|
|
181
|
+
expect(patch.identity?.bleName).toBe('Pro2 22D8');
|
|
191
182
|
});
|
|
192
183
|
|
|
193
184
|
test('maps the hardware model independently from Protocol V2', () => {
|
|
@@ -131,10 +131,6 @@ describe('device feature selectors', () => {
|
|
|
131
131
|
expect(getDeviceTypeByBleName('Pro2 A1B2')).toBe(EDeviceType.Pro2);
|
|
132
132
|
expect(getDeviceTypeByBleName('Pro2A1B2')).toBe(EDeviceType.Pro2);
|
|
133
133
|
expect(getDeviceTypeByBleName('OneKeyPro2A1B2')).toBe(EDeviceType.Pro2);
|
|
134
|
-
expect(getDeviceTypeByBleName('Pro 2 A1B2')).toBe(EDeviceType.Pro2);
|
|
135
|
-
expect(getDeviceTypeByBleName('Pro 2 0088')).toBe(EDeviceType.Pro2);
|
|
136
|
-
expect(getDeviceTypeByBleName('OneKey Pro 2 A1B2')).toBe(EDeviceType.Pro2);
|
|
137
|
-
expect(getDeviceTypeByBleName('Pro A1B2')).toBe(EDeviceType.Pro);
|
|
138
134
|
});
|
|
139
135
|
|
|
140
136
|
test.each([EDeviceType.Pro2, EDeviceType.Neo])(
|
|
@@ -116,30 +116,14 @@ describe('Pro2 resource configuration', () => {
|
|
|
116
116
|
});
|
|
117
117
|
});
|
|
118
118
|
|
|
119
|
-
test('
|
|
119
|
+
test('accepts the boot resource staging path and rejects paths outside resource roots', () => {
|
|
120
120
|
expect(
|
|
121
121
|
parseProtocolV2ResourcePackage(
|
|
122
122
|
createResourcePackage('vol0:/loaders/bootloader/boot_resource.okpkg.staging')
|
|
123
123
|
).devicePath
|
|
124
124
|
).toBe('vol0:/loaders/bootloader/boot_resource.okpkg.staging');
|
|
125
|
-
expect(
|
|
126
|
-
parseProtocolV2ResourcePackage(
|
|
127
|
-
createResourcePackage('vol0:/loaders/bootloader/params.okpkg.staging')
|
|
128
|
-
).devicePath
|
|
129
|
-
).toBe('vol0:/loaders/bootloader/params.okpkg.staging');
|
|
130
|
-
expect(
|
|
131
|
-
parseProtocolV2ResourcePackage(createResourcePackage('vol0:/loaders/rom/params.okpkg'))
|
|
132
|
-
.devicePath
|
|
133
|
-
).toBe('vol0:/loaders/rom/params.okpkg');
|
|
134
|
-
expect(
|
|
135
|
-
parseProtocolV2ResourcePackage(createResourcePackage('vol0:/unexpected/images.okpkg'))
|
|
136
|
-
.devicePath
|
|
137
|
-
).toBe('vol0:/unexpected/images.okpkg');
|
|
138
|
-
expect(() =>
|
|
139
|
-
parseProtocolV2ResourcePackage(createResourcePackage('vol0:/bundles/../images.okpkg'))
|
|
140
|
-
).toThrow('device path');
|
|
141
125
|
expect(() =>
|
|
142
|
-
parseProtocolV2ResourcePackage(createResourcePackage('vol0
|
|
126
|
+
parseProtocolV2ResourcePackage(createResourcePackage('vol0:/unexpected/images.okpkg'))
|
|
143
127
|
).toThrow('device path');
|
|
144
128
|
});
|
|
145
129
|
|
|
@@ -744,7 +744,7 @@ describe('Protocol V2 feature adapter', () => {
|
|
|
744
744
|
expect(features).toMatchObject({
|
|
745
745
|
deviceId: 'P2-DYNAMIC',
|
|
746
746
|
serialNo: 'P2-STATIC',
|
|
747
|
-
bleName: '
|
|
747
|
+
bleName: 'Pro2 STATIC',
|
|
748
748
|
initialized: true,
|
|
749
749
|
unlocked: true,
|
|
750
750
|
passphraseProtection: true,
|
|
@@ -865,7 +865,7 @@ describe('Protocol V2 feature adapter', () => {
|
|
|
865
865
|
expect(features.boardVersion).toBe('0.1.0');
|
|
866
866
|
expect(features.verify?.boardBuildId).toBe('rom-build');
|
|
867
867
|
expect(features.verify?.boardHash).toBe('0102ff');
|
|
868
|
-
expect(features.bleName).toBe('
|
|
868
|
+
expect(features.bleName).toBe('Pro2 BLE');
|
|
869
869
|
expect(features.bleVersion).toBe('4.5.6');
|
|
870
870
|
expect(features.verify?.bleHash).toBe('0c0d');
|
|
871
871
|
expect(features.se01Version).toBe('7.8.9');
|
|
@@ -2806,9 +2806,9 @@ describe('Protocol V2 feature adapter', () => {
|
|
|
2806
2806
|
|
|
2807
2807
|
expect(device.toMessageObject()).toMatchObject({
|
|
2808
2808
|
serialNo: 'PR9999999999',
|
|
2809
|
-
bleName: '
|
|
2810
|
-
name: '
|
|
2811
|
-
label: '
|
|
2809
|
+
bleName: 'Pro2 6136',
|
|
2810
|
+
name: 'Pro2 6136',
|
|
2811
|
+
label: 'Pro2 6136',
|
|
2812
2812
|
});
|
|
2813
2813
|
expect(device.features?.label).toBeNull();
|
|
2814
2814
|
});
|
|
@@ -2823,8 +2823,8 @@ describe('Protocol V2 feature adapter', () => {
|
|
|
2823
2823
|
|
|
2824
2824
|
expect(device.getCurrentDisplayName()).toBe('My Pro 2');
|
|
2825
2825
|
expect(device.toMessageObject()).toMatchObject({
|
|
2826
|
-
bleName: '
|
|
2827
|
-
name: '
|
|
2826
|
+
bleName: 'Pro2 6136',
|
|
2827
|
+
name: 'Pro2 6136',
|
|
2828
2828
|
label: 'My Pro 2',
|
|
2829
2829
|
});
|
|
2830
2830
|
});
|
|
@@ -151,10 +151,9 @@ describe('SearchDevices', () => {
|
|
|
151
151
|
);
|
|
152
152
|
|
|
153
153
|
test.each([
|
|
154
|
-
['Pro2 A1B2 - Find My', undefined, '
|
|
155
|
-
['Pro2 5E9D - Finde My', undefined, '
|
|
156
|
-
['Pro2 22D8FindMy', undefined, '
|
|
157
|
-
['Pro 2 A1B2 - Find My', undefined, 'Pro 2 A1B2'],
|
|
154
|
+
['Pro2 A1B2 - Find My', undefined, 'Pro2 A1B2'],
|
|
155
|
+
['Pro2 5E9D - Finde My', undefined, 'Pro2 5E9D'],
|
|
156
|
+
['Pro2 22D8FindMy', undefined, 'Pro2 22D8'],
|
|
158
157
|
[undefined, 'OneKey Pro 2 A1B2 - Find My', 'OneKey Pro 2 A1B2'],
|
|
159
158
|
])(
|
|
160
159
|
'BLE discovery normalizes the Find My display name from name=%s localName=%s',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FirmwareUpdateV4.d.ts","sourceRoot":"","sources":["../../src/api/FirmwareUpdateV4.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkD,MAAM,qBAAqB,CAAC;AA0BlG,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAqC/E,OAAO,KAAK,EAEV,sBAAsB,EAEvB,MAAM,6BAA6B,CAAC;AAyErC,wBAAgB,wCAAwC,CACtD,UAAU,EAAE,WAAW,GAAG,MAAM,GAAG,SAAS,EAC5C,MAAM,EAAE,sBAAsB,EAC9B,0BAA0B,UAAQ,QAiCnC;
|
|
1
|
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,OAAO,CAAC,0BAA0B;YAkBpB,mCAAmC;YAWnC,qCAAqC;YAmDrC,yBAAyB;YA8DzB,8BAA8B;IAU5C,OAAO,CAAC,kCAAkC;YAQ5B,cAAc;YAuCd,6BAA6B;YAW7B,0BAA0B;YAS1B,6BAA6B;YAwB7B,gBAAgB;IAiB9B,OAAO,CAAC,qBAAqB;CAM9B"}
|
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;AAmE7D,eAAO,MAAM,OAAO,YAAmB,WAAW,WAAW,WAAW,iBAoFvE,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,wBAAw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.ts","sourceRoot":"","sources":["../../src/data-manager/TransportManager.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,KAAK,EAAE,6BAA6B,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACvF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAgBzC,MAAM,CAAC,OAAO,OAAO,gBAAgB;IACnC,MAAM,CAAC,SAAS,EAAE,SAAS,CAAC;IAE5B,MAAM,CAAC,eAAe,EAAE,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAEnD,MAAM,CAAC,eAAe,EAAE,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAEnD,MAAM,CAAC,eAAe,UAAS;IAE/B,MAAM,CAAC,uBAAuB,EAAE,uBAAuB,CAAqB;IAE5E,MAAM,CAAC,MAAM,EAAE,6BAA6B,GAAG,IAAI,CAAQ;IAE3D,MAAM,CAAC,IAAI;WAOE,SAAS;
|
|
1
|
+
{"version":3,"file":"TransportManager.d.ts","sourceRoot":"","sources":["../../src/data-manager/TransportManager.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,KAAK,EAAE,6BAA6B,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACvF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAgBzC,MAAM,CAAC,OAAO,OAAO,gBAAgB;IACnC,MAAM,CAAC,SAAS,EAAE,SAAS,CAAC;IAE5B,MAAM,CAAC,eAAe,EAAE,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAEnD,MAAM,CAAC,eAAe,EAAE,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAEnD,MAAM,CAAC,eAAe,UAAS;IAE/B,MAAM,CAAC,uBAAuB,EAAE,uBAAuB,CAAqB;IAE5E,MAAM,CAAC,MAAM,EAAE,6BAA6B,GAAG,IAAI,CAAQ;IAE3D,MAAM,CAAC,IAAI;WAOE,SAAS;WAqDT,WAAW,CAAC,QAAQ,CAAC,EAAE,QAAQ;IAyB5C,MAAM,CAAC,YAAY,CAAC,oBAAoB,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,6BAA6B;IA6BrF,MAAM,CAAC,YAAY;mBAIE,2BAA2B;IAShD,MAAM,CAAC,kBAAkB;IAIzB,MAAM,CAAC,kBAAkB;IAIzB,MAAM,CAAC,0BAA0B;CAGlC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Device.d.ts","sourceRoot":"","sources":["../../src/device/Device.ts"],"names":[],"mappings":";AAAA,OAAO,YAAY,MAAM,QAAQ,CAAC;AAElC,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAmB,MAAM,wBAAwB,CAAC;AACjG,OAAO,EAEL,aAAa,
|
|
1
|
+
{"version":3,"file":"Device.d.ts","sourceRoot":"","sources":["../../src/device/Device.ts"],"names":[],"mappings":";AAAA,OAAO,YAAY,MAAM,QAAQ,CAAC;AAElC,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAmB,MAAM,wBAAwB,CAAC;AACjG,OAAO,EAEL,aAAa,EAQd,MAAM,qBAAqB,CAAC;AAU7B,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAalD,OAAO,EACL,KAAK,mBAAmB,EAExB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,EAE5B,KAAK,MAAM,IAAI,WAAW,EAC1B,iBAAiB,EACjB,KAAK,QAAQ,EACb,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC7B,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,MAAM,EAA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G3D,0BAA0B,CAC9B,eAAe,CAAC,EAAE,MAAM,EACxB,kBAAkB,CAAC,EAAE,OAAO,EAC5B,mBAAmB,CAAC,EAAE,OAAO,EAC7B,aAAa,CAAC,EAAE,OAAO;CAyD1B;AAED,eAAe,MAAM,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildDeviceFeatures.d.ts","sourceRoot":"","sources":["../../src/deviceProfile/buildDeviceFeatures.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"buildDeviceFeatures.d.ts","sourceRoot":"","sources":["../../src/deviceProfile/buildDeviceFeatures.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAEV,YAAY,EACZ,oBAAoB,EACrB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC/E,OAAO,KAAK,EAAsB,QAAQ,EAAE,MAAM,UAAU,CAAC;AA6C7D,eAAO,MAAM,8BAA8B,uBACrB,cAAc,aACvB,QAAQ,KAClB,QA+HF,CAAC;AASF,eAAO,MAAM,8BAA8B;;;;;MAUvC,QAsLH,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -419,8 +419,7 @@ const resolveDeviceBleName = (features) => {
|
|
|
419
419
|
if (!features)
|
|
420
420
|
return null;
|
|
421
421
|
const compatible = asCompatibleFeatures(features);
|
|
422
|
-
|
|
423
|
-
return bleName ? hdShared.canonicalizePro2BleAdvertisementName(bleName) : null;
|
|
422
|
+
return ((_a = firstNonEmptyString(compatible.bleName, compatible.onekey_ble_name, compatible.ble_name)) !== null && _a !== void 0 ? _a : null);
|
|
424
423
|
};
|
|
425
424
|
const resolveDeviceFirmwareVersion = (features) => {
|
|
426
425
|
var _a;
|
|
@@ -40717,14 +40716,21 @@ function parseProtocolV2Resources(value) {
|
|
|
40717
40716
|
},
|
|
40718
40717
|
};
|
|
40719
40718
|
}
|
|
40720
|
-
|
|
40721
|
-
|
|
40719
|
+
const PROTOCOL_V2_RESOURCE_DEVICE_ROOTS = ['vol0:/bundles/', 'vol0:/loaders/rom/'];
|
|
40720
|
+
function isAllowedResourceDevicePath(path) {
|
|
40721
|
+
if (path.includes('\\') ||
|
|
40722
40722
|
path.includes('//') ||
|
|
40723
40723
|
[...path].some(char => {
|
|
40724
40724
|
const code = char.charCodeAt(0);
|
|
40725
40725
|
return code <= 0x1f || code === 0x7f;
|
|
40726
40726
|
}) ||
|
|
40727
|
-
path.split('/').some(part => part === '.' || part === '..'))
|
|
40727
|
+
path.split('/').some(part => part === '.' || part === '..')) {
|
|
40728
|
+
return false;
|
|
40729
|
+
}
|
|
40730
|
+
if (path === PROTOCOL_V2_BOOT_RESOURCE_PACKAGE_STAGING_PATH) {
|
|
40731
|
+
return true;
|
|
40732
|
+
}
|
|
40733
|
+
return (path.endsWith('.okpkg') && PROTOCOL_V2_RESOURCE_DEVICE_ROOTS.some(root => path.startsWith(root)));
|
|
40728
40734
|
}
|
|
40729
40735
|
function readAscii(bytes, offset, length) {
|
|
40730
40736
|
return Array.from(bytes.slice(offset, offset + length))
|
|
@@ -40742,7 +40748,7 @@ function readResourceDevicePath(bytes) {
|
|
|
40742
40748
|
throw new Error('Invalid Pro2 RESOURCE package device path metadata');
|
|
40743
40749
|
}
|
|
40744
40750
|
const path = readAscii(pathBytes, 0, pathBytes.byteLength);
|
|
40745
|
-
if (!
|
|
40751
|
+
if (!isAllowedResourceDevicePath(path)) {
|
|
40746
40752
|
throw new Error(`Invalid Pro2 RESOURCE package device path: ${path}`);
|
|
40747
40753
|
}
|
|
40748
40754
|
return path;
|
|
@@ -43413,7 +43419,7 @@ class TransportManager {
|
|
|
43413
43419
|
yield this.transport.init(WebBleLogger, DevicePool.emitter);
|
|
43414
43420
|
}
|
|
43415
43421
|
else if (env === 'webusb' || env === 'desktop-webusb') {
|
|
43416
|
-
yield this.transport.init(WebUsbLogger);
|
|
43422
|
+
yield this.transport.init(WebUsbLogger, DevicePool.emitter);
|
|
43417
43423
|
}
|
|
43418
43424
|
else {
|
|
43419
43425
|
yield this.transport.init(HttpLogger);
|
|
@@ -44525,7 +44531,7 @@ const mapProtocolV2DeviceInfoToState = (info, mode = 'unknown') => {
|
|
|
44525
44531
|
vendor: 'onekey.so',
|
|
44526
44532
|
serialNo: (_b = info.hw) === null || _b === void 0 ? void 0 : _b.serial_no,
|
|
44527
44533
|
bleName: ((_c = info.coprocessor) === null || _c === void 0 ? void 0 : _c.bt_adv_name)
|
|
44528
|
-
? hdShared.
|
|
44534
|
+
? hdShared.normalizePro2FindMyAdvertisementName(info.coprocessor.bt_adv_name)
|
|
44529
44535
|
: undefined,
|
|
44530
44536
|
deviceId: loader ? null : undefined,
|
|
44531
44537
|
}),
|
|
@@ -45406,8 +45412,7 @@ class Device extends events.exports {
|
|
|
45406
45412
|
}
|
|
45407
45413
|
getCurrentBleName() {
|
|
45408
45414
|
var _a, _b;
|
|
45409
|
-
|
|
45410
|
-
return bleName ? hdShared.canonicalizePro2BleAdvertisementName(bleName) : null;
|
|
45415
|
+
return (_b = (_a = this.state) === null || _a === void 0 ? void 0 : _a.identity.bleName) !== null && _b !== void 0 ? _b : null;
|
|
45411
45416
|
}
|
|
45412
45417
|
getCurrentLabel() {
|
|
45413
45418
|
var _a, _b;
|
|
@@ -46918,7 +46923,7 @@ class SearchDevices extends BaseMethod {
|
|
|
46918
46923
|
if (!seenIds.has(lowerId)) {
|
|
46919
46924
|
seenIds.add(lowerId);
|
|
46920
46925
|
const rawBleName = (_e = (_d = device.name) !== null && _d !== void 0 ? _d : device.localName) !== null && _e !== void 0 ? _e : '';
|
|
46921
|
-
const bleName = hdShared.
|
|
46926
|
+
const bleName = hdShared.normalizePro2FindMyAdvertisementName(rawBleName);
|
|
46922
46927
|
devices.push(Object.assign(Object.assign({}, device), { connectId: device.id, serialNo: null, uuid: '', deviceId: null, name: bleName || device.name, deviceType: getDeviceTypeByBleName(bleName) }));
|
|
46923
46928
|
}
|
|
46924
46929
|
}
|
|
@@ -51901,12 +51906,8 @@ const PROTOCOL_V2_REMOTE_COMPONENT_TARGETS = {
|
|
|
51901
51906
|
},
|
|
51902
51907
|
};
|
|
51903
51908
|
const PROTOCOL_V2_FIRMWARE_STAGING_PATHS = new Set(Object.values(PROTOCOL_V2_REMOTE_COMPONENT_TARGETS).map(target => `${PROTOCOL_V2_FIRMWARE_STAGING_VOLUME}${target.fileName}`));
|
|
51904
|
-
const isProtocolV2BootResourcePackagePath = (devicePath) =>
|
|
51905
|
-
|
|
51906
|
-
return false;
|
|
51907
|
-
const normalized = devicePath.toLowerCase();
|
|
51908
|
-
return (normalized.startsWith('vol0:/loaders/bootloader/') && normalized.endsWith('.okpkg.staging'));
|
|
51909
|
-
};
|
|
51909
|
+
const isProtocolV2BootResourcePackagePath = (devicePath) => typeof devicePath === 'string' &&
|
|
51910
|
+
devicePath.toLowerCase() === PROTOCOL_V2_BOOT_RESOURCE_PACKAGE_STAGING_PATH;
|
|
51910
51911
|
const PROTOCOL_V2_UPDATE_TARGET_BY_TARGET_ID = new Map([
|
|
51911
51912
|
[ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_BOOTLOADER, 'boot'],
|
|
51912
51913
|
[ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_APPLICATION_P1, 'app_v1'],
|
|
@@ -65215,6 +65216,7 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
65215
65216
|
if ((_g = method.payload) === null || _g === void 0 ? void 0 : _g.onlyConnectBleDevice) {
|
|
65216
65217
|
preWarmCallbackTask === null || preWarmCallbackTask === void 0 ? void 0 : preWarmCallbackTask.resolve();
|
|
65217
65218
|
Log.debug('Call API - only connect ble device: ', device === null || device === void 0 ? void 0 : device.mainId);
|
|
65219
|
+
requestQueue.releaseTask(method.responseID);
|
|
65218
65220
|
return createResponseMessage(method.responseID, true, null);
|
|
65219
65221
|
}
|
|
65220
65222
|
Log.debug('Call API - setDevice: ', device.mainId);
|
|
@@ -65590,7 +65592,31 @@ function isMissingDetectedProtocolV2Error(method, error) {
|
|
|
65590
65592
|
typeof typedError.message === 'string' &&
|
|
65591
65593
|
typedError.message.includes('Device protocol has not been detected'));
|
|
65592
65594
|
}
|
|
65593
|
-
|
|
65595
|
+
const BLE_ACQUIRE_DEADLINE_MS = 60 * 1000;
|
|
65596
|
+
function raceBleAcquire(acquirePromise, abortSignal) {
|
|
65597
|
+
return new Promise((resolve, reject) => {
|
|
65598
|
+
let settled = false;
|
|
65599
|
+
const settle = (fn) => {
|
|
65600
|
+
if (settled)
|
|
65601
|
+
return;
|
|
65602
|
+
settled = true;
|
|
65603
|
+
clearTimeout(deadline);
|
|
65604
|
+
abortSignal === null || abortSignal === void 0 ? void 0 : abortSignal.removeEventListener('abort', onAbort);
|
|
65605
|
+
fn();
|
|
65606
|
+
};
|
|
65607
|
+
const onAbort = () => settle(() => reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallQueueActionCancelled)));
|
|
65608
|
+
const deadline = setTimeout(() => settle(() => reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BleTimeoutError, `BLE acquire exceeded ${BLE_ACQUIRE_DEADLINE_MS}ms deadline`))), BLE_ACQUIRE_DEADLINE_MS);
|
|
65609
|
+
acquirePromise.then(value => settle(() => resolve(value)), error => settle(() => reject(error)));
|
|
65610
|
+
if (abortSignal) {
|
|
65611
|
+
if (abortSignal.aborted) {
|
|
65612
|
+
onAbort();
|
|
65613
|
+
return;
|
|
65614
|
+
}
|
|
65615
|
+
abortSignal.addEventListener('abort', onAbort);
|
|
65616
|
+
}
|
|
65617
|
+
});
|
|
65618
|
+
}
|
|
65619
|
+
function connectDeviceForBle(method, device, abortSignal, retryCount = 0) {
|
|
65594
65620
|
var _a;
|
|
65595
65621
|
return __awaiter(this, void 0, void 0, function* () {
|
|
65596
65622
|
try {
|
|
@@ -65605,9 +65631,31 @@ function connectDeviceForBle(method, device, retryCount = 0) {
|
|
|
65605
65631
|
!device.commands ||
|
|
65606
65632
|
device.commands.disposed;
|
|
65607
65633
|
if (shouldAcquire) {
|
|
65608
|
-
|
|
65609
|
-
|
|
65610
|
-
|
|
65634
|
+
const useAcquireGuards = DataManager.getSettings('env') === 'desktop-web-ble';
|
|
65635
|
+
if (useAcquireGuards && (abortSignal === null || abortSignal === void 0 ? void 0 : abortSignal.aborted)) {
|
|
65636
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallQueueActionCancelled);
|
|
65637
|
+
}
|
|
65638
|
+
if (!useAcquireGuards) {
|
|
65639
|
+
yield device.acquire(method.payload.connectProtocol, {
|
|
65640
|
+
forceProtocolDetection: method.payload.forceProtocolDetection,
|
|
65641
|
+
});
|
|
65642
|
+
}
|
|
65643
|
+
else {
|
|
65644
|
+
try {
|
|
65645
|
+
yield raceBleAcquire(device.acquire(method.payload.connectProtocol, {
|
|
65646
|
+
forceProtocolDetection: method.payload.forceProtocolDetection,
|
|
65647
|
+
}), abortSignal);
|
|
65648
|
+
}
|
|
65649
|
+
catch (err) {
|
|
65650
|
+
if (err.errorCode === hdShared.HardwareErrorCode.BleTimeoutError &&
|
|
65651
|
+
device.mainId &&
|
|
65652
|
+
device.deviceConnector) {
|
|
65653
|
+
yield device.deviceConnector.disconnect(device.mainId).catch(() => undefined);
|
|
65654
|
+
device.markTransportDisconnected();
|
|
65655
|
+
}
|
|
65656
|
+
throw err;
|
|
65657
|
+
}
|
|
65658
|
+
}
|
|
65611
65659
|
}
|
|
65612
65660
|
if ((_a = method.payload) === null || _a === void 0 ? void 0 : _a.onlyConnectBleDevice) {
|
|
65613
65661
|
if (shouldAcquire) {
|
|
@@ -65638,7 +65686,7 @@ function connectDeviceForBle(method, device, retryCount = 0) {
|
|
|
65638
65686
|
const nextRetry = retryCount + 1;
|
|
65639
65687
|
Log.debug(`Bluetooth connection will retry, retry count: ${nextRetry}`);
|
|
65640
65688
|
yield wait(3000);
|
|
65641
|
-
yield connectDeviceForBle(method, device, nextRetry);
|
|
65689
|
+
yield connectDeviceForBle(method, device, abortSignal, nextRetry);
|
|
65642
65690
|
}
|
|
65643
65691
|
else {
|
|
65644
65692
|
throw err;
|
|
@@ -65723,7 +65771,7 @@ const ensureConnected = (_context, method, connectId, pollingId, abortSignal) =>
|
|
|
65723
65771
|
if (tryCount === 1) {
|
|
65724
65772
|
device.beginConnectionAttempt();
|
|
65725
65773
|
}
|
|
65726
|
-
yield connectDeviceForBle(method, device);
|
|
65774
|
+
yield connectDeviceForBle(method, device, abortSignal);
|
|
65727
65775
|
}
|
|
65728
65776
|
resolve(device);
|
|
65729
65777
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../../../src/protocols/protocol-v2/resources.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEvE,eAAO,MAAM,sCAAsC,iDACH,CAAC;AACjD,eAAO,MAAM,8CAA8C,QAAsD,CAAC;AAClH,eAAO,MAAM,mCAAmC,mCAAmC,CAAC;AACpF,eAAO,MAAM,wCAAwC,QAAS,CAAC;AAW/D,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,oBAAoB,GAAG,SAAS,CA8BzF;
|
|
1
|
+
{"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../../../src/protocols/protocol-v2/resources.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEvE,eAAO,MAAM,sCAAsC,iDACH,CAAC;AACjD,eAAO,MAAM,8CAA8C,QAAsD,CAAC;AAClH,eAAO,MAAM,mCAAmC,mCAAmC,CAAC;AACpF,eAAO,MAAM,wCAAwC,QAAS,CAAC;AAW/D,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,oBAAoB,GAAG,SAAS,CA8BzF;AAoDD,MAAM,MAAM,+BAA+B,GAAG;IAC5C,OAAO,EAAE,aAAa,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,wBAAgB,oCAAoC,CAClD,KAAK,EAAE,UAAU,EACjB,WAAW,EAAE,MAAM,GAClB,+BAA+B,CAyCjC;AAED,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,WAAW,GAAG,UAAU,GAC/B,+BAA+B,CAGjC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deviceFeaturesCompat.d.ts","sourceRoot":"","sources":["../../src/utils/deviceFeaturesCompat.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"deviceFeaturesCompat.d.ts","sourceRoot":"","sources":["../../src/utils/deviceFeaturesCompat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGjE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEtD,MAAM,MAAM,mBAAmB,GAAG,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;AAoB5D,eAAO,MAAM,qBAAqB,cAAe,mBAAmB,KAAG,MAWtE,CAAC;AAEF,eAAO,MAAM,2BAA2B,cAAe,mBAAmB,KAAG,OAI5E,CAAC;AAEF,eAAO,MAAM,iBAAiB,cAAe,mBAAmB,KAAG,WAqDlE,CAAC;AAEF,eAAO,MAAM,yBAAyB,cAAe,mBAAmB,KAAG,aAsB1E,CAAC;AAEF,eAAO,MAAM,oBAAoB,cAAe,mBAAmB,KAAG,MAAM,GAAG,IAM9E,CAAC;AAEF,eAAO,MAAM,4BAA4B,cAAe,mBAAmB,KAAG,MAAM,GAAG,IAgBtF,CAAC;AAEF,eAAO,MAAM,8BAA8B,cAAe,mBAAmB,KAAG,MAAM,GAAG,IAiBxF,CAAC;AAEF,eAAO,MAAM,yBAAyB,cAAe,mBAAmB,KAAG,MAAM,GAAG,IAUnF,CAAC;AAEF,eAAO,MAAM,+BAA+B,cAAe,mBAAmB,KAAG,MAAM,GAAG,IASzF,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.158",
|
|
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.158",
|
|
29
|
+
"@onekeyfe/hd-transport": "1.2.0-alpha.158",
|
|
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": "4eff5659b79164afa0c2d070833bec4f2a477f0b"
|
|
50
50
|
}
|
|
@@ -301,13 +301,9 @@ const PROTOCOL_V2_FIRMWARE_STAGING_PATHS = new Set(
|
|
|
301
301
|
)
|
|
302
302
|
);
|
|
303
303
|
|
|
304
|
-
const isProtocolV2BootResourcePackagePath = (devicePath: string) =>
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
return (
|
|
308
|
-
normalized.startsWith('vol0:/loaders/bootloader/') && normalized.endsWith('.okpkg.staging')
|
|
309
|
-
);
|
|
310
|
-
};
|
|
304
|
+
const isProtocolV2BootResourcePackagePath = (devicePath: string) =>
|
|
305
|
+
typeof devicePath === 'string' &&
|
|
306
|
+
devicePath.toLowerCase() === PROTOCOL_V2_BOOT_RESOURCE_PACKAGE_STAGING_PATH;
|
|
311
307
|
|
|
312
308
|
const PROTOCOL_V2_UPDATE_TARGET_BY_TARGET_ID = new Map<
|
|
313
309
|
number,
|
package/src/api/SearchDevices.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { normalizePro2FindMyAdvertisementName } from '@onekeyfe/hd-shared';
|
|
2
2
|
|
|
3
3
|
import { BaseMethod } from './BaseMethod';
|
|
4
4
|
import TransportManager from '../data-manager/TransportManager';
|
|
@@ -40,7 +40,7 @@ export default class SearchDevices extends BaseMethod {
|
|
|
40
40
|
seenIds.add(lowerId);
|
|
41
41
|
const rawBleName =
|
|
42
42
|
device.name ?? (device as unknown as { localName?: string }).localName ?? '';
|
|
43
|
-
const bleName =
|
|
43
|
+
const bleName = normalizePro2FindMyAdvertisementName(rawBleName);
|
|
44
44
|
devices.push({
|
|
45
45
|
...device,
|
|
46
46
|
connectId: device.id,
|
package/src/core/index.ts
CHANGED
|
@@ -415,6 +415,10 @@ const onCallDevice = async (
|
|
|
415
415
|
if (method.payload?.onlyConnectBleDevice) {
|
|
416
416
|
preWarmCallbackTask?.resolve();
|
|
417
417
|
Log.debug('Call API - only connect ble device: ', device?.mainId);
|
|
418
|
+
// This early return bypasses the normal-path releaseTask at the end of the
|
|
419
|
+
// call; without it the task leaks and haunts every later queue snapshot
|
|
420
|
+
// and cancel sweep (field log: a completed task lingered for 6 minutes).
|
|
421
|
+
requestQueue.releaseTask(method.responseID);
|
|
418
422
|
return createResponseMessage(method.responseID, true, null);
|
|
419
423
|
}
|
|
420
424
|
|
|
@@ -954,7 +958,60 @@ export function isMissingDetectedProtocolV2Error(method: BaseMethod, error: unkn
|
|
|
954
958
|
* If the Bluetooth connection times out, retry up to 6 times
|
|
955
959
|
* @param retryCount - Current retry count (default 0)
|
|
956
960
|
*/
|
|
957
|
-
|
|
961
|
+
// device.acquire awaits a transport reply with no deadline of its own; a
|
|
962
|
+
// transport that never settles (field case: Electron main lost an IPC reply,
|
|
963
|
+
// "reply was never sent" after 5 minutes) hangs the call forever and cancel()
|
|
964
|
+
// only takes effect at poll checkpoints. Race acquire against a deadline and
|
|
965
|
+
// the caller's abort signal so the hang is bounded and cancel is immediate.
|
|
966
|
+
const BLE_ACQUIRE_DEADLINE_MS = 60 * 1000;
|
|
967
|
+
|
|
968
|
+
function raceBleAcquire<T>(acquirePromise: Promise<T>, abortSignal?: AbortSignal): Promise<T> {
|
|
969
|
+
return new Promise<T>((resolve, reject) => {
|
|
970
|
+
let settled = false;
|
|
971
|
+
const settle = (fn: () => void) => {
|
|
972
|
+
if (settled) return;
|
|
973
|
+
settled = true;
|
|
974
|
+
clearTimeout(deadline);
|
|
975
|
+
abortSignal?.removeEventListener('abort', onAbort);
|
|
976
|
+
fn();
|
|
977
|
+
};
|
|
978
|
+
const onAbort = () =>
|
|
979
|
+
settle(() => reject(ERRORS.TypedError(HardwareErrorCode.CallQueueActionCancelled)));
|
|
980
|
+
const deadline = setTimeout(
|
|
981
|
+
() =>
|
|
982
|
+
settle(() =>
|
|
983
|
+
reject(
|
|
984
|
+
ERRORS.TypedError(
|
|
985
|
+
HardwareErrorCode.BleTimeoutError,
|
|
986
|
+
`BLE acquire exceeded ${BLE_ACQUIRE_DEADLINE_MS}ms deadline`
|
|
987
|
+
)
|
|
988
|
+
)
|
|
989
|
+
),
|
|
990
|
+
BLE_ACQUIRE_DEADLINE_MS
|
|
991
|
+
);
|
|
992
|
+
// Attach before any early return so a late settlement of acquirePromise
|
|
993
|
+
// is always consumed — an abort or deadline must never leave the acquire
|
|
994
|
+
// rejection unhandled.
|
|
995
|
+
acquirePromise.then(
|
|
996
|
+
value => settle(() => resolve(value)),
|
|
997
|
+
error => settle(() => reject(error))
|
|
998
|
+
);
|
|
999
|
+
if (abortSignal) {
|
|
1000
|
+
if (abortSignal.aborted) {
|
|
1001
|
+
onAbort();
|
|
1002
|
+
return;
|
|
1003
|
+
}
|
|
1004
|
+
abortSignal.addEventListener('abort', onAbort);
|
|
1005
|
+
}
|
|
1006
|
+
});
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
async function connectDeviceForBle(
|
|
1010
|
+
method: BaseMethod,
|
|
1011
|
+
device: Device,
|
|
1012
|
+
abortSignal?: AbortSignal,
|
|
1013
|
+
retryCount = 0
|
|
1014
|
+
) {
|
|
958
1015
|
try {
|
|
959
1016
|
if (device.wasInterruptedByUser()) {
|
|
960
1017
|
throw ERRORS.TypedError(HardwareErrorCode.DeviceInterruptedFromUser);
|
|
@@ -968,9 +1025,43 @@ async function connectDeviceForBle(method: BaseMethod, device: Device, retryCoun
|
|
|
968
1025
|
!device.commands ||
|
|
969
1026
|
device.commands.disposed;
|
|
970
1027
|
if (shouldAcquire) {
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
1028
|
+
// The deadline/abort guards are scoped to the desktop electron
|
|
1029
|
+
// transport: its IPC acquire is the only path with a proven
|
|
1030
|
+
// never-settling failure mode, while react-native/lowlevel acquire may
|
|
1031
|
+
// legitimately block on a user-driven system bonding prompt for longer
|
|
1032
|
+
// than any sane deadline. Other envs keep the plain acquire unchanged.
|
|
1033
|
+
const useAcquireGuards = DataManager.getSettings('env') === 'desktop-web-ble';
|
|
1034
|
+
// A cancel landing during the retry backoff must not start a new acquire.
|
|
1035
|
+
if (useAcquireGuards && abortSignal?.aborted) {
|
|
1036
|
+
throw ERRORS.TypedError(HardwareErrorCode.CallQueueActionCancelled);
|
|
1037
|
+
}
|
|
1038
|
+
if (!useAcquireGuards) {
|
|
1039
|
+
await device.acquire(method.payload.connectProtocol, {
|
|
1040
|
+
forceProtocolDetection: method.payload.forceProtocolDetection,
|
|
1041
|
+
});
|
|
1042
|
+
} else {
|
|
1043
|
+
try {
|
|
1044
|
+
await raceBleAcquire(
|
|
1045
|
+
device.acquire(method.payload.connectProtocol, {
|
|
1046
|
+
forceProtocolDetection: method.payload.forceProtocolDetection,
|
|
1047
|
+
}),
|
|
1048
|
+
abortSignal
|
|
1049
|
+
);
|
|
1050
|
+
} catch (err) {
|
|
1051
|
+
// A deadline hit means the transport is wedged mid-acquire; drop the
|
|
1052
|
+
// link before the retry so it cold-connects instead of stacking a
|
|
1053
|
+
// second connect onto the half-open one.
|
|
1054
|
+
if (
|
|
1055
|
+
err.errorCode === HardwareErrorCode.BleTimeoutError &&
|
|
1056
|
+
device.mainId &&
|
|
1057
|
+
device.deviceConnector
|
|
1058
|
+
) {
|
|
1059
|
+
await device.deviceConnector.disconnect(device.mainId).catch(() => undefined);
|
|
1060
|
+
device.markTransportDisconnected();
|
|
1061
|
+
}
|
|
1062
|
+
throw err;
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
974
1065
|
}
|
|
975
1066
|
if (method.payload?.onlyConnectBleDevice) {
|
|
976
1067
|
if (shouldAcquire) {
|
|
@@ -1010,7 +1101,7 @@ async function connectDeviceForBle(method: BaseMethod, device: Device, retryCoun
|
|
|
1010
1101
|
const nextRetry = retryCount + 1;
|
|
1011
1102
|
Log.debug(`Bluetooth connection will retry, retry count: ${nextRetry}`);
|
|
1012
1103
|
await wait(3000);
|
|
1013
|
-
await connectDeviceForBle(method, device, nextRetry);
|
|
1104
|
+
await connectDeviceForBle(method, device, abortSignal, nextRetry);
|
|
1014
1105
|
} else {
|
|
1015
1106
|
throw err;
|
|
1016
1107
|
}
|
|
@@ -1120,7 +1211,7 @@ const ensureConnected = async (
|
|
|
1120
1211
|
if (tryCount === 1) {
|
|
1121
1212
|
device.beginConnectionAttempt();
|
|
1122
1213
|
}
|
|
1123
|
-
await connectDeviceForBle(method, device);
|
|
1214
|
+
await connectDeviceForBle(method, device, abortSignal);
|
|
1124
1215
|
}
|
|
1125
1216
|
resolve(device);
|
|
1126
1217
|
return;
|
|
@@ -69,7 +69,9 @@ export default class TransportManager {
|
|
|
69
69
|
} else if (env === 'desktop-web-ble') {
|
|
70
70
|
await this.transport.init(WebBleLogger, DevicePool.emitter);
|
|
71
71
|
} else if (env === 'webusb' || env === 'desktop-webusb') {
|
|
72
|
-
|
|
72
|
+
// The emitter is what turns a navigator.usb 'disconnect' into a
|
|
73
|
+
// DEVICE.DISCONNECT; without it WebUSB never reports device removal.
|
|
74
|
+
await this.transport.init(WebUsbLogger, DevicePool.emitter);
|
|
73
75
|
} else {
|
|
74
76
|
await this.transport.init(HttpLogger);
|
|
75
77
|
}
|
package/src/device/Device.ts
CHANGED
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
ERROR_CODES_REQUIRE_RELEASE,
|
|
10
10
|
HardwareError,
|
|
11
11
|
HardwareErrorCode,
|
|
12
|
-
canonicalizePro2BleAdvertisementName,
|
|
13
12
|
createDeferred,
|
|
14
13
|
createDeviceNotSupportMethodError,
|
|
15
14
|
} from '@onekeyfe/hd-shared';
|
|
@@ -673,8 +672,7 @@ export class Device extends EventEmitter {
|
|
|
673
672
|
}
|
|
674
673
|
|
|
675
674
|
getCurrentBleName() {
|
|
676
|
-
|
|
677
|
-
return bleName ? canonicalizePro2BleAdvertisementName(bleName) : null;
|
|
675
|
+
return this.state?.identity.bleName ?? null;
|
|
678
676
|
}
|
|
679
677
|
|
|
680
678
|
getCurrentLabel() {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EFirmwareType,
|
|
1
|
+
import { EFirmwareType, normalizePro2FindMyAdvertisementName } from '@onekeyfe/hd-shared';
|
|
2
2
|
|
|
3
3
|
import { buildProtocolV1FeaturesPayload } from '../deviceProfile/buildDeviceFeatures';
|
|
4
4
|
import { resolveProtocolV2DeviceIdentity } from '../deviceProfile/protocolV2DeviceIdentity';
|
|
@@ -248,7 +248,7 @@ export const mapProtocolV2DeviceInfoToState = (
|
|
|
248
248
|
vendor: 'onekey.so',
|
|
249
249
|
serialNo: info.hw?.serial_no,
|
|
250
250
|
bleName: info.coprocessor?.bt_adv_name
|
|
251
|
-
?
|
|
251
|
+
? normalizePro2FindMyAdvertisementName(info.coprocessor.bt_adv_name)
|
|
252
252
|
: undefined,
|
|
253
253
|
deviceId: loader ? null : undefined,
|
|
254
254
|
}),
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
EDeviceType,
|
|
3
|
-
EFirmwareType,
|
|
4
|
-
canonicalizePro2BleAdvertisementName,
|
|
5
|
-
} from '@onekeyfe/hd-shared';
|
|
1
|
+
import { EDeviceType, EFirmwareType } from '@onekeyfe/hd-shared';
|
|
6
2
|
|
|
7
3
|
import {
|
|
8
4
|
resolveDeviceBleFirmwareVersion,
|
|
@@ -249,8 +245,7 @@ export const buildProtocolV2FeaturesPayload = ({
|
|
|
249
245
|
const deviceId = status?.device_id ?? cached?.deviceId ?? null;
|
|
250
246
|
const serialNo = firstValue(incomingSerialNo, cached?.serialNo) ?? '';
|
|
251
247
|
const label = cached?.label ?? null;
|
|
252
|
-
const
|
|
253
|
-
const bleName = rawBleName ? canonicalizePro2BleAdvertisementName(rawBleName) : rawBleName;
|
|
248
|
+
const bleName = firstValue(info?.coprocessor?.bt_adv_name, cached?.bleName);
|
|
254
249
|
const initialized = firstValue(status?.init_states, cached?.initialized) ?? null;
|
|
255
250
|
// passphrase_enabled from a locked Pro2 is not authoritative. Only DeviceStatus
|
|
256
251
|
// after PIN unlock can determine the final passphrase setting.
|
|
@@ -49,8 +49,10 @@ export function parseProtocolV2Resources(value: unknown): IProtocolV2Resources |
|
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
const PROTOCOL_V2_RESOURCE_DEVICE_ROOTS = ['vol0:/bundles/', 'vol0:/loaders/rom/'] as const;
|
|
53
|
+
|
|
54
|
+
function isAllowedResourceDevicePath(path: string): boolean {
|
|
55
|
+
if (
|
|
54
56
|
path.includes('\\') ||
|
|
55
57
|
path.includes('//') ||
|
|
56
58
|
[...path].some(char => {
|
|
@@ -58,6 +60,14 @@ function isSafeResourceDevicePath(path: string): boolean {
|
|
|
58
60
|
return code <= 0x1f || code === 0x7f;
|
|
59
61
|
}) ||
|
|
60
62
|
path.split('/').some(part => part === '.' || part === '..')
|
|
63
|
+
) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
if (path === PROTOCOL_V2_BOOT_RESOURCE_PACKAGE_STAGING_PATH) {
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
return (
|
|
70
|
+
path.endsWith('.okpkg') && PROTOCOL_V2_RESOURCE_DEVICE_ROOTS.some(root => path.startsWith(root))
|
|
61
71
|
);
|
|
62
72
|
}
|
|
63
73
|
|
|
@@ -83,7 +93,7 @@ function readResourceDevicePath(bytes: Uint8Array): string {
|
|
|
83
93
|
throw new Error('Invalid Pro2 RESOURCE package device path metadata');
|
|
84
94
|
}
|
|
85
95
|
const path = readAscii(pathBytes, 0, pathBytes.byteLength);
|
|
86
|
-
if (!
|
|
96
|
+
if (!isAllowedResourceDevicePath(path)) {
|
|
87
97
|
throw new Error(`Invalid Pro2 RESOURCE package device path: ${path}`);
|
|
88
98
|
}
|
|
89
99
|
return path;
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
EDeviceType,
|
|
3
|
-
EFirmwareType,
|
|
4
|
-
canonicalizePro2BleAdvertisementName,
|
|
5
|
-
} from '@onekeyfe/hd-shared';
|
|
1
|
+
import { EDeviceType, EFirmwareType } from '@onekeyfe/hd-shared';
|
|
6
2
|
import { Enum_Capability } from '@onekeyfe/hd-transport';
|
|
7
3
|
|
|
8
4
|
import type { PROTO } from '../constants';
|
|
@@ -129,10 +125,9 @@ export const resolveDeviceFirmwareType = (features?: DeviceFeaturesInput): EFirm
|
|
|
129
125
|
export const resolveDeviceBleName = (features?: DeviceFeaturesInput): string | null => {
|
|
130
126
|
if (!features) return null;
|
|
131
127
|
const compatible = asCompatibleFeatures(features);
|
|
132
|
-
|
|
133
|
-
firstNonEmptyString(compatible.bleName, compatible.onekey_ble_name, compatible.ble_name) ??
|
|
134
|
-
|
|
135
|
-
return bleName ? canonicalizePro2BleAdvertisementName(bleName) : null;
|
|
128
|
+
return (
|
|
129
|
+
firstNonEmptyString(compatible.bleName, compatible.onekey_ble_name, compatible.ble_name) ?? null
|
|
130
|
+
);
|
|
136
131
|
};
|
|
137
132
|
|
|
138
133
|
export const resolveDeviceFirmwareVersion = (features?: DeviceFeaturesInput): string | null => {
|