@onekeyfe/hd-core 0.2.32 → 0.2.34
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/dist/api/FirmwareUpdateV2.d.ts.map +1 -1
- package/dist/api/firmware/getBinary.d.ts +1 -0
- package/dist/api/firmware/getBinary.d.ts.map +1 -1
- package/dist/api/firmware/updateBootloader.d.ts.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/data-manager/DataManager.d.ts +2 -1
- package/dist/data-manager/DataManager.d.ts.map +1 -1
- package/dist/device/DeviceConnector.d.ts +1 -1
- package/dist/device/DeviceConnector.d.ts.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +112 -101
- package/dist/types/params.d.ts +0 -1
- package/dist/types/params.d.ts.map +1 -1
- package/dist/types/settings.d.ts +1 -0
- package/dist/types/settings.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/FirmwareUpdateV2.ts +5 -1
- package/src/api/firmware/updateBootloader.ts +5 -1
- package/src/core/index.ts +7 -16
- package/src/data-manager/DataManager.ts +12 -0
- package/src/device/DeviceConnector.ts +2 -2
- package/src/types/params.ts +0 -4
- package/src/types/settings.ts +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FirmwareUpdateV2.d.ts","sourceRoot":"","sources":["../../src/api/FirmwareUpdateV2.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAIT,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAO1C,OAAO,KAAK,EAAe,QAAQ,EAAE,MAAM,UAAU,CAAC;AAItD,aAAK,MAAM,GAAG;IACZ,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,UAAU,EAAE,UAAU,GAAG,KAAK,CAAC;IAC/B,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,CAAC;AAIF,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,UAAU,CAAC,MAAM,CAAC;IAC9D,YAAY,EAAE,QAAQ,CAAC,GAAG,CAAC,GAAG,IAAI,CAAQ;IAE1C,IAAI;IAsCJ,cAAc,YAAa,MAAM,UAS/B;IAEF,uBAAuB,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS;
|
|
1
|
+
{"version":3,"file":"FirmwareUpdateV2.d.ts","sourceRoot":"","sources":["../../src/api/FirmwareUpdateV2.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAIT,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAO1C,OAAO,KAAK,EAAe,QAAQ,EAAE,MAAM,UAAU,CAAC;AAItD,aAAK,MAAM,GAAG;IACZ,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,UAAU,EAAE,UAAU,GAAG,KAAK,CAAC;IAC/B,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,CAAC;AAIF,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,UAAU,CAAC,MAAM,CAAC;IAC9D,YAAY,EAAE,QAAQ,CAAC,GAAG,CAAC,GAAG,IAAI,CAAQ;IAE1C,IAAI;IAsCJ,cAAc,YAAa,MAAM,UAS/B;IAEF,uBAAuB,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS;IAsDrD,qBAAqB,CAAC,QAAQ,EAAE,QAAQ;IAUxC,uBAAuB,CAAC,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM;IAc9D,gCAAgC,CAAC,QAAQ,CAAC,EAAE,QAAQ;IAwB9C,GAAG;CAiGV"}
|
|
@@ -14,6 +14,7 @@ export declare const getBinary: ({ features, updateType, version }: GetBinaryPro
|
|
|
14
14
|
fullResource?: string | undefined;
|
|
15
15
|
fullResourceRange?: string[] | undefined;
|
|
16
16
|
bootloaderResource?: string | undefined;
|
|
17
|
+
bootloaderVersion?: import("../../types").IVersionArray | undefined;
|
|
17
18
|
fingerprint: string;
|
|
18
19
|
version: import("../../types").IVersionArray;
|
|
19
20
|
changelog: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getBinary.d.ts","sourceRoot":"","sources":["../../../src/api/firmware/getBinary.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAMvC,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,QAAQ,CAAC;IACnB,UAAU,EAAE,UAAU,GAAG,KAAK,CAAC;CAChC;AAED,UAAU,cAAe,SAAQ,YAAY;IAC3C,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,eAAO,MAAM,SAAS,sCAA6C,cAAc
|
|
1
|
+
{"version":3,"file":"getBinary.d.ts","sourceRoot":"","sources":["../../../src/api/firmware/getBinary.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAMvC,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,QAAQ,CAAC;IACnB,UAAU,EAAE,UAAU,GAAG,KAAK,CAAC;CAChC;AAED,UAAU,cAAe,SAAQ,YAAY;IAC3C,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,eAAO,MAAM,SAAS,sCAA6C,cAAc;;;;;;;;;;;;;;;EA2BhF,CAAC;AAEF,eAAO,MAAM,oBAAoB,QAAe,MAAM;;EAWrD,CAAC;AAEF,eAAO,MAAM,OAAO,6BAA8B,YAAY,2DAO7D,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updateBootloader.d.ts","sourceRoot":"","sources":["../../../src/api/firmware/updateBootloader.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"updateBootloader.d.ts","sourceRoot":"","sources":["../../../src/api/firmware/updateBootloader.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAQvC,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,QAAQ,WAgBrD"}
|
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;AAqBlC,OAAO,EACL,WAAW,EAYZ,MAAM,WAAW,CAAC;AAEnB,OAAO,KAAK,EAAE,eAAe,EAAe,MAAM,UAAU,CAAC;AAE7D,OAAO,eAAe,MAAM,2BAA2B,CAAC;AA4BxD,eAAO,MAAM,OAAO,YAAmB,WAAW,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":";AACA,OAAO,YAAY,MAAM,QAAQ,CAAC;AAqBlC,OAAO,EACL,WAAW,EAYZ,MAAM,WAAW,CAAC;AAEnB,OAAO,KAAK,EAAE,eAAe,EAAe,MAAM,UAAU,CAAC;AAE7D,OAAO,eAAe,MAAM,2BAA2B,CAAC;AA4BxD,eAAO,MAAM,OAAO,YAAmB,WAAW,iBA+PjD,CAAC;AAqMF,eAAO,MAAM,MAAM,0CAkBlB,CAAC;AA8IF,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,YAAY;IACtC,aAAa,CAAC,OAAO,EAAE,WAAW;IA8CxC,OAAO;CAGR;AAED,eAAO,MAAM,QAAQ,YAGpB,CAAC;AAEF,eAAO,MAAM,aAAa,uBAIzB,CAAC;AAMF,eAAO,MAAM,IAAI,aAAoB,eAAe,aAAa,GAAG,8BAmBnE,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ConnectSettings, DeviceTypeMap, AssetsMap, Features, IDeviceFirmwareStatus, IDeviceBLEFirmwareStatus, ITransportStatus } from '../types';
|
|
1
|
+
import type { ConnectSettings, DeviceTypeMap, AssetsMap, Features, IDeviceFirmwareStatus, IDeviceBLEFirmwareStatus, ITransportStatus, IVersionArray } from '../types';
|
|
2
2
|
export default class DataManager {
|
|
3
3
|
static deviceMap: DeviceTypeMap;
|
|
4
4
|
static assets: AssetsMap | null;
|
|
@@ -10,6 +10,7 @@ export default class DataManager {
|
|
|
10
10
|
static getSysResourcesLatestRelease: (features: Features, forcedUpdateRes?: boolean | undefined) => string | undefined;
|
|
11
11
|
static getSysFullResource: (features: Features) => string | undefined;
|
|
12
12
|
static getBootloaderResource: (features: Features) => string | undefined;
|
|
13
|
+
static getBootloaderTargetVersion: (features: Features) => IVersionArray | undefined;
|
|
13
14
|
static getFirmwareChangelog: (features: Features) => {
|
|
14
15
|
"zh-CN": string;
|
|
15
16
|
"en-US": string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataManager.d.ts","sourceRoot":"","sources":["../../src/data-manager/DataManager.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EACV,eAAe,EACf,aAAa,EACb,SAAS,EAET,QAAQ,EACR,qBAAqB,EACrB,wBAAwB,EACxB,gBAAgB,
|
|
1
|
+
{"version":3,"file":"DataManager.d.ts","sourceRoot":"","sources":["../../src/data-manager/DataManager.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EACV,eAAe,EACf,aAAa,EACb,SAAS,EAET,QAAQ,EACR,qBAAqB,EACrB,wBAAwB,EACxB,gBAAgB,EAChB,aAAa,EACd,MAAM,UAAU,CAAC;AAKlB,MAAM,CAAC,OAAO,OAAO,WAAW;IAC9B,MAAM,CAAC,SAAS,EAAE,aAAa,CAiB7B;IAEF,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAAQ;IAEvC,MAAM,CAAC,QAAQ,EAAE,eAAe,CAAC;IAEjC,MAAM,CAAC,QAAQ,EAAE;QAAE,OAAO,EAAE,IAAI,CAAA;KAAE,CAEhC;IAEF,MAAM,CAAC,iBAAiB,aAAc,QAAQ,KAAG,qBAAqB,CAepE;IAMF,MAAM,CAAC,4BAA4B,aAAc,QAAQ,+DAgBvD;IAMF,MAAM,CAAC,kBAAkB,aAAc,QAAQ,wBAU7C;IAEF,MAAM,CAAC,qBAAqB,aAAc,QAAQ,wBAShD;IAEF,MAAM,CAAC,0BAA0B,aAAc,QAAQ,KAAG,aAAa,GAAG,SAAS,CASjF;IAEF,MAAM,CAAC,oBAAoB,aAAc,QAAQ;;;QAe/C;IAEF,MAAM,CAAC,wBAAwB,aAAc,QAAQ,yDAgBnD;IAEF,MAAM,CAAC,oBAAoB,aAAc,QAAQ,KAAG,wBAAwB,CAY1E;IAEF,MAAM,CAAC,uBAAuB,aAAc,QAAQ;;;QAWlD;IAEF,MAAM,CAAC,2BAA2B,aAAc,QAAQ,4DAItD;IAEF,MAAM,CAAC,kBAAkB,iBAAkB,MAAM,KAAG,gBAAgB,CAKlE;WAEW,IAAI,CAAC,QAAQ,EAAE,eAAe;IAwB3C,MAAM,CAAC,mBAAmB;IAI1B,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,SAAS,GAAG,eAAe;IAEpD,MAAM,CAAC,WAAW,CAAC,CAAC,SAAS,MAAM,eAAe,EAAE,GAAG,EAAE,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC;CAShF"}
|
|
@@ -10,7 +10,7 @@ export default class DeviceConnector {
|
|
|
10
10
|
enumerate(): Promise<DeviceDescriptorDiff | undefined>;
|
|
11
11
|
listen(): Promise<void>;
|
|
12
12
|
stop(): void;
|
|
13
|
-
acquire(path: string, session?: string | null): Promise<string | undefined>;
|
|
13
|
+
acquire(path: string, session?: string | null, forceCleanRunPromise?: boolean): Promise<string | undefined>;
|
|
14
14
|
release(session: string, onclose: boolean): Promise<void>;
|
|
15
15
|
_reportDevicesChange(): void;
|
|
16
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeviceConnector.d.ts","sourceRoot":"","sources":["../../src/device/DeviceConnector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,gBAAgB,IAAI,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAIzF,OAAO,EAAc,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAMhE,MAAM,CAAC,OAAO,OAAO,eAAe;IAClC,SAAS,EAAE,SAAS,CAAC;IAErB,eAAe,SAAK;IAEpB,OAAO,EAAE,gBAAgB,EAAE,GAAG,IAAI,CAAQ;IAE1C,QAAQ,EAAE,gBAAgB,EAAE,CAAM;IAElC,SAAS,UAAS;;IAQZ,SAAS;IAWT,MAAM;IAiCZ,IAAI;IAIE,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI;
|
|
1
|
+
{"version":3,"file":"DeviceConnector.d.ts","sourceRoot":"","sources":["../../src/device/DeviceConnector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,gBAAgB,IAAI,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAIzF,OAAO,EAAc,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAMhE,MAAM,CAAC,OAAO,OAAO,eAAe;IAClC,SAAS,EAAE,SAAS,CAAC;IAErB,eAAe,SAAK;IAEpB,OAAO,EAAE,gBAAgB,EAAE,GAAG,IAAI,CAAQ;IAE1C,QAAQ,EAAE,gBAAgB,EAAE,CAAM;IAElC,SAAS,UAAS;;IAQZ,SAAS;IAWT,MAAM;IAiCZ,IAAI;IAIE,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,EAAE,oBAAoB,CAAC,EAAE,OAAO;IAiB7E,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;IAS/C,oBAAoB;CAGrB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -10,7 +10,6 @@ interface CommonParams {
|
|
|
10
10
|
pollIntervalTime?: number;
|
|
11
11
|
timeout?: number;
|
|
12
12
|
passphraseState?: string;
|
|
13
|
-
useEmptyPassphrase?: boolean;
|
|
14
13
|
initSession?: boolean;
|
|
15
14
|
}
|
|
16
15
|
declare type Params<T> = CommonParams & T & {
|
|
@@ -150,6 +149,7 @@ declare type IFirmwareReleaseInfo = {
|
|
|
150
149
|
fullResource?: string;
|
|
151
150
|
fullResourceRange?: string[];
|
|
152
151
|
bootloaderResource?: string;
|
|
152
|
+
bootloaderVersion?: IVersionArray;
|
|
153
153
|
fingerprint: string;
|
|
154
154
|
version: IVersionArray;
|
|
155
155
|
changelog: {
|
|
@@ -1918,7 +1918,7 @@ declare class DeviceConnector {
|
|
|
1918
1918
|
enumerate(): Promise<DeviceDescriptorDiff | undefined>;
|
|
1919
1919
|
listen(): Promise<void>;
|
|
1920
1920
|
stop(): void;
|
|
1921
|
-
acquire(path: string, session?: string | null): Promise<string | undefined>;
|
|
1921
|
+
acquire(path: string, session?: string | null, forceCleanRunPromise?: boolean): Promise<string | undefined>;
|
|
1922
1922
|
release(session: string, onclose: boolean): Promise<void>;
|
|
1923
1923
|
_reportDevicesChange(): void;
|
|
1924
1924
|
}
|
|
@@ -2141,6 +2141,7 @@ declare class DataManager {
|
|
|
2141
2141
|
static getSysResourcesLatestRelease: (features: Features, forcedUpdateRes?: boolean | undefined) => string | undefined;
|
|
2142
2142
|
static getSysFullResource: (features: Features) => string | undefined;
|
|
2143
2143
|
static getBootloaderResource: (features: Features) => string | undefined;
|
|
2144
|
+
static getBootloaderTargetVersion: (features: Features) => IVersionArray | undefined;
|
|
2144
2145
|
static getFirmwareChangelog: (features: Features) => {
|
|
2145
2146
|
"zh-CN": string;
|
|
2146
2147
|
"en-US": string;
|
package/dist/index.js
CHANGED
|
@@ -10741,15 +10741,106 @@ function patchFeatures(response) {
|
|
|
10741
10741
|
return response;
|
|
10742
10742
|
}
|
|
10743
10743
|
|
|
10744
|
+
const pkg = require('../package.json');
|
|
10745
|
+
const getSDKVersion = () => pkg.version;
|
|
10746
|
+
const DEFAULT_DOMAIN = `https://jssdk.onekey.so/${getSDKVersion()}/`;
|
|
10747
|
+
|
|
10748
|
+
const DEFAULT_PRIORITY = 2;
|
|
10749
|
+
const initialSettings = {
|
|
10750
|
+
configSrc: './data/config.json',
|
|
10751
|
+
version: '',
|
|
10752
|
+
debug: false,
|
|
10753
|
+
priority: DEFAULT_PRIORITY,
|
|
10754
|
+
trustedHost: false,
|
|
10755
|
+
connectSrc: DEFAULT_DOMAIN,
|
|
10756
|
+
iframeSrc: `${DEFAULT_DOMAIN}iframe.html`,
|
|
10757
|
+
parentOrigin: typeof window !== 'undefined' && window.location ? window.location.origin : '',
|
|
10758
|
+
supportedBrowser: typeof navigator !== 'undefined' ? !/Trident|MSIE|Edge/.test(navigator.userAgent) : true,
|
|
10759
|
+
env: 'web',
|
|
10760
|
+
lazyLoad: false,
|
|
10761
|
+
timestamp: new Date().getTime(),
|
|
10762
|
+
};
|
|
10763
|
+
const getEnv = () => {
|
|
10764
|
+
if (typeof chrome !== 'undefined' &&
|
|
10765
|
+
chrome.runtime &&
|
|
10766
|
+
typeof chrome.runtime.onConnect !== 'undefined') {
|
|
10767
|
+
return 'webextension';
|
|
10768
|
+
}
|
|
10769
|
+
if (typeof navigator !== 'undefined') {
|
|
10770
|
+
if (typeof navigator.product === 'string' &&
|
|
10771
|
+
navigator.product.toLowerCase() === 'reactnative') {
|
|
10772
|
+
return 'react-native';
|
|
10773
|
+
}
|
|
10774
|
+
const userAgent = navigator.userAgent.toLowerCase();
|
|
10775
|
+
if (userAgent.indexOf(' electron/') > -1) {
|
|
10776
|
+
return 'electron';
|
|
10777
|
+
}
|
|
10778
|
+
}
|
|
10779
|
+
return 'web';
|
|
10780
|
+
};
|
|
10781
|
+
const corsValidator = (url) => {
|
|
10782
|
+
if (typeof url !== 'string')
|
|
10783
|
+
return;
|
|
10784
|
+
if (url.match(/^https:\/\/([A-Za-z0-9\-_]+\.)*onekey\.so\//))
|
|
10785
|
+
return url;
|
|
10786
|
+
if (url.match(/^https?:\/\/localhost:[58][0-9]{3}\//))
|
|
10787
|
+
return url;
|
|
10788
|
+
return url;
|
|
10789
|
+
};
|
|
10790
|
+
const parseConnectSettings = (input = {}) => {
|
|
10791
|
+
const settings = Object.assign({}, initialSettings);
|
|
10792
|
+
if (Object.prototype.hasOwnProperty.call(input, 'debug')) {
|
|
10793
|
+
settings.debug = input.debug;
|
|
10794
|
+
}
|
|
10795
|
+
if (input.isFrame) {
|
|
10796
|
+
settings.parentOrigin = input.parentOrigin;
|
|
10797
|
+
}
|
|
10798
|
+
if (typeof input.connectSrc === 'string') {
|
|
10799
|
+
settings.connectSrc = input.connectSrc;
|
|
10800
|
+
}
|
|
10801
|
+
let globalSrc;
|
|
10802
|
+
if (typeof window !== 'undefined') {
|
|
10803
|
+
globalSrc = window.ONEKEY_CONNECT_SRC;
|
|
10804
|
+
}
|
|
10805
|
+
else if (typeof global !== 'undefined') {
|
|
10806
|
+
globalSrc = global.ONEKEY_CONNECT_SRC;
|
|
10807
|
+
}
|
|
10808
|
+
if (typeof globalSrc === 'string') {
|
|
10809
|
+
settings.connectSrc = corsValidator(globalSrc);
|
|
10810
|
+
settings.debug = true;
|
|
10811
|
+
}
|
|
10812
|
+
const src = settings.connectSrc || DEFAULT_DOMAIN;
|
|
10813
|
+
settings.iframeSrc = `${src}iframe.html`;
|
|
10814
|
+
if (input.transportReconnect) {
|
|
10815
|
+
settings.transportReconnect = input.transportReconnect;
|
|
10816
|
+
}
|
|
10817
|
+
if (input.lazyLoad) {
|
|
10818
|
+
settings.lazyLoad = input.lazyLoad;
|
|
10819
|
+
}
|
|
10820
|
+
if (typeof input.env === 'string') {
|
|
10821
|
+
settings.env = input.env;
|
|
10822
|
+
}
|
|
10823
|
+
else {
|
|
10824
|
+
settings.env = getEnv();
|
|
10825
|
+
}
|
|
10826
|
+
if (input.timestamp) {
|
|
10827
|
+
settings.timestamp = input.timestamp;
|
|
10828
|
+
}
|
|
10829
|
+
return settings;
|
|
10830
|
+
};
|
|
10831
|
+
|
|
10744
10832
|
function checkNeedUpdateBoot(features) {
|
|
10745
10833
|
const deviceType = getDeviceType(features);
|
|
10746
10834
|
if (deviceType !== 'touch')
|
|
10747
10835
|
return false;
|
|
10748
10836
|
const currentVersion = getDeviceFirmwareVersion(features).join('.');
|
|
10749
10837
|
const bootloaderVersion = getDeviceBootloaderVersion(features).join('.');
|
|
10838
|
+
const targetBootloaderVersion = DataManager.getBootloaderTargetVersion(features);
|
|
10839
|
+
if (!targetBootloaderVersion)
|
|
10840
|
+
return false;
|
|
10750
10841
|
return (semver__default["default"].gte(currentVersion, '3.2.0') &&
|
|
10751
10842
|
semver__default["default"].gte(currentVersion, '4.1.0') &&
|
|
10752
|
-
semver__default["default"].lte(bootloaderVersion, '
|
|
10843
|
+
semver__default["default"].lte(bootloaderVersion, targetBootloaderVersion.join('.')));
|
|
10753
10844
|
}
|
|
10754
10845
|
|
|
10755
10846
|
const LOG_EVENT = 'LOG_EVENT';
|
|
@@ -11275,6 +11366,16 @@ DataManager.getBootloaderResource = (features) => {
|
|
|
11275
11366
|
const targetDeviceConfig = targetDeviceConfigList.filter(item => !!item.bootloaderResource);
|
|
11276
11367
|
return (_d = findLatestRelease(targetDeviceConfig)) === null || _d === void 0 ? void 0 : _d.bootloaderResource;
|
|
11277
11368
|
};
|
|
11369
|
+
DataManager.getBootloaderTargetVersion = (features) => {
|
|
11370
|
+
var _b, _c, _d, _e;
|
|
11371
|
+
const deviceType = getDeviceType(features);
|
|
11372
|
+
if (deviceType !== 'pro' && deviceType !== 'touch')
|
|
11373
|
+
return undefined;
|
|
11374
|
+
const firmwareUpdateField = getFirmwareUpdateField(features, 'firmware');
|
|
11375
|
+
const targetDeviceConfigList = (_c = (_b = _a.deviceMap[deviceType]) === null || _b === void 0 ? void 0 : _b[firmwareUpdateField]) !== null && _c !== void 0 ? _c : [];
|
|
11376
|
+
const targetDeviceConfig = targetDeviceConfigList.filter(item => !!item.bootloaderResource);
|
|
11377
|
+
return (_e = (_d = targetDeviceConfig === null || targetDeviceConfig === void 0 ? void 0 : targetDeviceConfig[0]) === null || _d === void 0 ? void 0 : _d.bootloaderVersion) !== null && _e !== void 0 ? _e : undefined;
|
|
11378
|
+
};
|
|
11278
11379
|
DataManager.getFirmwareChangelog = (features) => {
|
|
11279
11380
|
var _b, _c;
|
|
11280
11381
|
const deviceType = getDeviceType(features);
|
|
@@ -11946,94 +12047,6 @@ const UI_REQUEST = {
|
|
|
11946
12047
|
FIRMWARE_TIP: 'ui-firmware-tip',
|
|
11947
12048
|
};
|
|
11948
12049
|
|
|
11949
|
-
const pkg = require('../package.json');
|
|
11950
|
-
const getSDKVersion = () => pkg.version;
|
|
11951
|
-
const DEFAULT_DOMAIN = `https://jssdk.onekey.so/${getSDKVersion()}/`;
|
|
11952
|
-
|
|
11953
|
-
const DEFAULT_PRIORITY = 2;
|
|
11954
|
-
const initialSettings = {
|
|
11955
|
-
configSrc: './data/config.json',
|
|
11956
|
-
version: '',
|
|
11957
|
-
debug: false,
|
|
11958
|
-
priority: DEFAULT_PRIORITY,
|
|
11959
|
-
trustedHost: false,
|
|
11960
|
-
connectSrc: DEFAULT_DOMAIN,
|
|
11961
|
-
iframeSrc: `${DEFAULT_DOMAIN}iframe.html`,
|
|
11962
|
-
parentOrigin: typeof window !== 'undefined' && window.location ? window.location.origin : '',
|
|
11963
|
-
supportedBrowser: typeof navigator !== 'undefined' ? !/Trident|MSIE|Edge/.test(navigator.userAgent) : true,
|
|
11964
|
-
env: 'web',
|
|
11965
|
-
lazyLoad: false,
|
|
11966
|
-
timestamp: new Date().getTime(),
|
|
11967
|
-
};
|
|
11968
|
-
const getEnv = () => {
|
|
11969
|
-
if (typeof chrome !== 'undefined' &&
|
|
11970
|
-
chrome.runtime &&
|
|
11971
|
-
typeof chrome.runtime.onConnect !== 'undefined') {
|
|
11972
|
-
return 'webextension';
|
|
11973
|
-
}
|
|
11974
|
-
if (typeof navigator !== 'undefined') {
|
|
11975
|
-
if (typeof navigator.product === 'string' &&
|
|
11976
|
-
navigator.product.toLowerCase() === 'reactnative') {
|
|
11977
|
-
return 'react-native';
|
|
11978
|
-
}
|
|
11979
|
-
const userAgent = navigator.userAgent.toLowerCase();
|
|
11980
|
-
if (userAgent.indexOf(' electron/') > -1) {
|
|
11981
|
-
return 'electron';
|
|
11982
|
-
}
|
|
11983
|
-
}
|
|
11984
|
-
return 'web';
|
|
11985
|
-
};
|
|
11986
|
-
const corsValidator = (url) => {
|
|
11987
|
-
if (typeof url !== 'string')
|
|
11988
|
-
return;
|
|
11989
|
-
if (url.match(/^https:\/\/([A-Za-z0-9\-_]+\.)*onekey\.so\//))
|
|
11990
|
-
return url;
|
|
11991
|
-
if (url.match(/^https?:\/\/localhost:[58][0-9]{3}\//))
|
|
11992
|
-
return url;
|
|
11993
|
-
return url;
|
|
11994
|
-
};
|
|
11995
|
-
const parseConnectSettings = (input = {}) => {
|
|
11996
|
-
const settings = Object.assign({}, initialSettings);
|
|
11997
|
-
if (Object.prototype.hasOwnProperty.call(input, 'debug')) {
|
|
11998
|
-
settings.debug = input.debug;
|
|
11999
|
-
}
|
|
12000
|
-
if (input.isFrame) {
|
|
12001
|
-
settings.parentOrigin = input.parentOrigin;
|
|
12002
|
-
}
|
|
12003
|
-
if (typeof input.connectSrc === 'string') {
|
|
12004
|
-
settings.connectSrc = input.connectSrc;
|
|
12005
|
-
}
|
|
12006
|
-
let globalSrc;
|
|
12007
|
-
if (typeof window !== 'undefined') {
|
|
12008
|
-
globalSrc = window.ONEKEY_CONNECT_SRC;
|
|
12009
|
-
}
|
|
12010
|
-
else if (typeof global !== 'undefined') {
|
|
12011
|
-
globalSrc = global.ONEKEY_CONNECT_SRC;
|
|
12012
|
-
}
|
|
12013
|
-
if (typeof globalSrc === 'string') {
|
|
12014
|
-
settings.connectSrc = corsValidator(globalSrc);
|
|
12015
|
-
settings.debug = true;
|
|
12016
|
-
}
|
|
12017
|
-
const src = settings.connectSrc || DEFAULT_DOMAIN;
|
|
12018
|
-
settings.iframeSrc = `${src}iframe.html`;
|
|
12019
|
-
if (input.transportReconnect) {
|
|
12020
|
-
settings.transportReconnect = input.transportReconnect;
|
|
12021
|
-
}
|
|
12022
|
-
if (input.lazyLoad) {
|
|
12023
|
-
settings.lazyLoad = input.lazyLoad;
|
|
12024
|
-
}
|
|
12025
|
-
if (typeof input.env === 'string') {
|
|
12026
|
-
settings.env = input.env;
|
|
12027
|
-
}
|
|
12028
|
-
else {
|
|
12029
|
-
settings.env = getEnv();
|
|
12030
|
-
}
|
|
12031
|
-
if (input.timestamp) {
|
|
12032
|
-
settings.timestamp = input.timestamp;
|
|
12033
|
-
}
|
|
12034
|
-
return settings;
|
|
12035
|
-
};
|
|
12036
|
-
|
|
12037
12050
|
const parseRunOptions = (options) => {
|
|
12038
12051
|
if (!options)
|
|
12039
12052
|
options = {};
|
|
@@ -13599,7 +13612,7 @@ class FirmwareUpdateV2 extends BaseMethod {
|
|
|
13599
13612
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
13600
13613
|
if (isBleReconnect) {
|
|
13601
13614
|
try {
|
|
13602
|
-
yield ((_a = this.device.deviceConnector) === null || _a === void 0 ? void 0 : _a.acquire(this.device.originalDescriptor.id));
|
|
13615
|
+
yield ((_a = this.device.deviceConnector) === null || _a === void 0 ? void 0 : _a.acquire(this.device.originalDescriptor.id, null, true));
|
|
13603
13616
|
yield this.device.initialize();
|
|
13604
13617
|
if ((_b = this.device.features) === null || _b === void 0 ? void 0 : _b.bootloader_mode) {
|
|
13605
13618
|
clearInterval(intervalTimer);
|
|
@@ -18305,14 +18318,14 @@ class DeviceConnector {
|
|
|
18305
18318
|
stop() {
|
|
18306
18319
|
this.listening = false;
|
|
18307
18320
|
}
|
|
18308
|
-
acquire(path, session) {
|
|
18321
|
+
acquire(path, session, forceCleanRunPromise) {
|
|
18309
18322
|
return __awaiter(this, void 0, void 0, function* () {
|
|
18310
18323
|
Log$1.debug('acquire', path, session);
|
|
18311
18324
|
const env = DataManager.getSettings('env');
|
|
18312
18325
|
try {
|
|
18313
18326
|
let res;
|
|
18314
18327
|
if (env === 'react-native') {
|
|
18315
|
-
res = yield this.transport.acquire({ uuid: path });
|
|
18328
|
+
res = yield this.transport.acquire({ uuid: path, forceCleanRunPromise });
|
|
18316
18329
|
}
|
|
18317
18330
|
else {
|
|
18318
18331
|
res = yield this.transport.acquire({ path, previous: session !== null && session !== void 0 ? session : null });
|
|
@@ -18413,7 +18426,7 @@ const callAPI = (message) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
18413
18426
|
(_a = method.setDevice) === null || _a === void 0 ? void 0 : _a.call(method, device);
|
|
18414
18427
|
device.on(DEVICE.PIN, onDevicePinHandler);
|
|
18415
18428
|
device.on(DEVICE.BUTTON, onDeviceButtonHandler);
|
|
18416
|
-
device.on(DEVICE.PASSPHRASE,
|
|
18429
|
+
device.on(DEVICE.PASSPHRASE, onDevicePassphraseHandler);
|
|
18417
18430
|
device.on(DEVICE.PASSPHRASE_ON_DEVICE, onEnterPassphraseOnDeviceHandler);
|
|
18418
18431
|
device.on(DEVICE.FEATURES, onDeviceFeaturesHandler);
|
|
18419
18432
|
try {
|
|
@@ -18717,9 +18730,7 @@ const cancel = (connectId) => {
|
|
|
18717
18730
|
const checkPassphraseSafety = (method, features) => {
|
|
18718
18731
|
if (!method.useDevicePassphraseState)
|
|
18719
18732
|
return;
|
|
18720
|
-
if ((features === null || features === void 0 ? void 0 : features.passphrase_protection) === true &&
|
|
18721
|
-
(method.payload.passphraseState == null || method.payload.passphraseState === '') &&
|
|
18722
|
-
!method.payload.useEmptyPassphrase) {
|
|
18733
|
+
if ((features === null || features === void 0 ? void 0 : features.passphrase_protection) === true && !method.payload.passphraseState) {
|
|
18723
18734
|
DevicePool.clearDeviceCache(method.payload.connectId);
|
|
18724
18735
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceOpenedPassphrase);
|
|
18725
18736
|
}
|
|
@@ -18733,7 +18744,11 @@ const cleanup = () => {
|
|
|
18733
18744
|
Log.debug('Cleanup...');
|
|
18734
18745
|
};
|
|
18735
18746
|
const removeDeviceListener = (device) => {
|
|
18736
|
-
device.
|
|
18747
|
+
device.removeListener(DEVICE.PIN, onDevicePinHandler);
|
|
18748
|
+
device.removeListener(DEVICE.BUTTON, onDeviceButtonHandler);
|
|
18749
|
+
device.removeListener(DEVICE.PASSPHRASE, onDevicePassphraseHandler);
|
|
18750
|
+
device.removeListener(DEVICE.PASSPHRASE_ON_DEVICE, onEnterPassphraseOnDeviceHandler);
|
|
18751
|
+
device.removeListener(DEVICE.FEATURES, onDeviceFeaturesHandler);
|
|
18737
18752
|
DevicePool.emitter.removeListener(DEVICE.CONNECT, onDeviceConnectHandler);
|
|
18738
18753
|
};
|
|
18739
18754
|
const closePopup = () => {
|
|
@@ -18789,10 +18804,6 @@ const onDevicePassphraseHandler = (...[device, callback]) => __awaiter(void 0, v
|
|
|
18789
18804
|
cache: save,
|
|
18790
18805
|
});
|
|
18791
18806
|
});
|
|
18792
|
-
const onEmptyPassphraseHandler = (...[_, callback]) => {
|
|
18793
|
-
Log.debug('onEmptyPassphraseHandler');
|
|
18794
|
-
callback({ passphrase: '' });
|
|
18795
|
-
};
|
|
18796
18807
|
const onEnterPassphraseOnDeviceHandler = (...[device]) => {
|
|
18797
18808
|
postMessage(createUiMessage(UI_REQUEST$1.REQUEST_PASSPHRASE_ON_DEVICE, {
|
|
18798
18809
|
device: device.toMessageObject(),
|
package/dist/types/params.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"params.d.ts","sourceRoot":"","sources":["../../src/types/params.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,WAAW,CAAC,EAAE,OAAO,CAAC;IAItB,UAAU,CAAC,EAAE,MAAM,CAAC;IAIpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAI1B,OAAO,CAAC,EAAE,MAAM,CAAC;IAIjB,eAAe,CAAC,EAAE,MAAM,CAAC;IAIzB,
|
|
1
|
+
{"version":3,"file":"params.d.ts","sourceRoot":"","sources":["../../src/types/params.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,WAAW,CAAC,EAAE,OAAO,CAAC;IAItB,UAAU,CAAC,EAAE,MAAM,CAAC;IAIpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAI1B,OAAO,CAAC,EAAE,MAAM,CAAC;IAIjB,eAAe,CAAC,EAAE,MAAM,CAAC;IAIzB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,oBAAY,MAAM,CAAC,CAAC,IAAI,YAAY,GAAG,CAAC,GAAG;IAAE,MAAM,CAAC,EAAE,SAAS,CAAA;CAAE,CAAC;AAElE,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,KAAK,CAAC;IACf,OAAO,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;CACpD;AAED,MAAM,WAAW,OAAO,CAAC,CAAC;IACxB,OAAO,EAAE,IAAI,CAAC;IACd,OAAO,EAAE,CAAC,CAAC;CACZ;AAED,oBAAY,QAAQ,CAAC,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC"}
|
package/dist/types/settings.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../src/types/settings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,oBAAY,eAAe,GAAG;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB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,CAAC;QACvB,UAAU,EAAE,MAAM,CAAC;QACnB,UAAU,EAAE,MAAM,CAAC;QACnB,UAAU,EAAE,MAAM,CAAC;QACnB,UAAU,EAAE,MAAM,CAAC;QACnB,GAAG,EAAE,MAAM,CAAC;QACZ,GAAG,EAAE,MAAM,CAAC;QACZ,YAAY,EAAE,MAAM,CAAC;QACrB,SAAS,EAAE;aACR,CAAC,IAAI,OAAO,GAAG,MAAM;SACvB,CAAC;KACH,CAAC;CACH,CAAC;AAEF,oBAAY,oBAAoB,GAAG;IACjC,MAAM,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAC;CAC7B,GAAG,aAAa,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-core",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.34",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"author": "OneKey",
|
|
6
6
|
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"url": "https://github.com/OneKeyHQ/hardware-js-sdk/issues"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@onekeyfe/hd-shared": "^0.2.
|
|
28
|
-
"@onekeyfe/hd-transport": "^0.2.
|
|
27
|
+
"@onekeyfe/hd-shared": "^0.2.34",
|
|
28
|
+
"@onekeyfe/hd-transport": "^0.2.34",
|
|
29
29
|
"axios": "^0.27.2",
|
|
30
30
|
"bignumber.js": "^9.0.2",
|
|
31
31
|
"jszip": "^3.10.1",
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"@types/semver": "^7.3.9",
|
|
43
43
|
"ripple-keypairs": "^1.1.4"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "938bb02e6417dd94caaea4719933a33575705add"
|
|
46
46
|
}
|
|
@@ -91,7 +91,11 @@ export default class FirmwareUpdateV2 extends BaseMethod<Params> {
|
|
|
91
91
|
async () => {
|
|
92
92
|
if (isBleReconnect) {
|
|
93
93
|
try {
|
|
94
|
-
await this.device.deviceConnector?.acquire(
|
|
94
|
+
await this.device.deviceConnector?.acquire(
|
|
95
|
+
this.device.originalDescriptor.id,
|
|
96
|
+
null,
|
|
97
|
+
true
|
|
98
|
+
);
|
|
95
99
|
await this.device.initialize();
|
|
96
100
|
if (this.device.features?.bootloader_mode) {
|
|
97
101
|
clearInterval(intervalTimer);
|
|
@@ -5,18 +5,22 @@ import {
|
|
|
5
5
|
getDeviceBootloaderVersion,
|
|
6
6
|
getDeviceFirmwareVersion,
|
|
7
7
|
} from '../../utils/deviceFeaturesUtils';
|
|
8
|
+
import { DataManager } from '../../data-manager';
|
|
8
9
|
|
|
9
10
|
export function checkNeedUpdateBoot(features: Features) {
|
|
10
11
|
const deviceType = getDeviceType(features);
|
|
11
12
|
if (deviceType !== 'touch') return false;
|
|
12
13
|
const currentVersion = getDeviceFirmwareVersion(features).join('.');
|
|
13
14
|
const bootloaderVersion = getDeviceBootloaderVersion(features).join('.');
|
|
15
|
+
const targetBootloaderVersion = DataManager.getBootloaderTargetVersion(features);
|
|
16
|
+
if (!targetBootloaderVersion) return false;
|
|
17
|
+
|
|
14
18
|
return (
|
|
15
19
|
// support ResourceUpdate version 3.2.0
|
|
16
20
|
semver.gte(currentVersion, '3.2.0') &&
|
|
17
21
|
// support update bootloader version 4.1.0
|
|
18
22
|
semver.gte(currentVersion, '4.1.0') &&
|
|
19
23
|
// target bootloader version
|
|
20
|
-
semver.lte(bootloaderVersion, '
|
|
24
|
+
semver.lte(bootloaderVersion, targetBootloaderVersion.join('.'))
|
|
21
25
|
);
|
|
22
26
|
}
|
package/src/core/index.ts
CHANGED
|
@@ -133,10 +133,7 @@ export const callAPI = async (message: CoreMessage) => {
|
|
|
133
133
|
|
|
134
134
|
device.on(DEVICE.PIN, onDevicePinHandler);
|
|
135
135
|
device.on(DEVICE.BUTTON, onDeviceButtonHandler);
|
|
136
|
-
device.on(
|
|
137
|
-
DEVICE.PASSPHRASE,
|
|
138
|
-
message.payload.useEmptyPassphrase ? onEmptyPassphraseHandler : onDevicePassphraseHandler
|
|
139
|
-
);
|
|
136
|
+
device.on(DEVICE.PASSPHRASE, onDevicePassphraseHandler);
|
|
140
137
|
device.on(DEVICE.PASSPHRASE_ON_DEVICE, onEnterPassphraseOnDeviceHandler);
|
|
141
138
|
device.on(DEVICE.FEATURES, onDeviceFeaturesHandler);
|
|
142
139
|
|
|
@@ -543,11 +540,7 @@ export const cancel = (connectId?: string) => {
|
|
|
543
540
|
const checkPassphraseSafety = (method: BaseMethod, features?: Features) => {
|
|
544
541
|
if (!method.useDevicePassphraseState) return;
|
|
545
542
|
|
|
546
|
-
if (
|
|
547
|
-
features?.passphrase_protection === true &&
|
|
548
|
-
(method.payload.passphraseState == null || method.payload.passphraseState === '') &&
|
|
549
|
-
!method.payload.useEmptyPassphrase
|
|
550
|
-
) {
|
|
543
|
+
if (features?.passphrase_protection === true && !method.payload.passphraseState) {
|
|
551
544
|
DevicePool.clearDeviceCache(method.payload.connectId);
|
|
552
545
|
throw ERRORS.TypedError(HardwareErrorCode.DeviceOpenedPassphrase);
|
|
553
546
|
}
|
|
@@ -564,7 +557,11 @@ const cleanup = () => {
|
|
|
564
557
|
};
|
|
565
558
|
|
|
566
559
|
const removeDeviceListener = (device: Device) => {
|
|
567
|
-
device.
|
|
560
|
+
device.removeListener(DEVICE.PIN, onDevicePinHandler);
|
|
561
|
+
device.removeListener(DEVICE.BUTTON, onDeviceButtonHandler);
|
|
562
|
+
device.removeListener(DEVICE.PASSPHRASE, onDevicePassphraseHandler);
|
|
563
|
+
device.removeListener(DEVICE.PASSPHRASE_ON_DEVICE, onEnterPassphraseOnDeviceHandler);
|
|
564
|
+
device.removeListener(DEVICE.FEATURES, onDeviceFeaturesHandler);
|
|
568
565
|
DevicePool.emitter.removeListener(DEVICE.CONNECT, onDeviceConnectHandler);
|
|
569
566
|
// DevicePool.emitter.removeListener(DEVICE.DISCONNECT, onDeviceDisconnectHandler);
|
|
570
567
|
};
|
|
@@ -644,12 +641,6 @@ const onDevicePassphraseHandler = async (...[device, callback]: DeviceEvents['pa
|
|
|
644
641
|
});
|
|
645
642
|
};
|
|
646
643
|
|
|
647
|
-
const onEmptyPassphraseHandler = (...[_, callback]: DeviceEvents['passphrase']) => {
|
|
648
|
-
Log.debug('onEmptyPassphraseHandler');
|
|
649
|
-
// send as PassphrasePromptResponse
|
|
650
|
-
callback({ passphrase: '' });
|
|
651
|
-
};
|
|
652
|
-
|
|
653
644
|
const onEnterPassphraseOnDeviceHandler = (
|
|
654
645
|
...[device]: [...DeviceEvents['passphrase_on_device']]
|
|
655
646
|
) => {
|
|
@@ -18,6 +18,7 @@ import type {
|
|
|
18
18
|
IDeviceFirmwareStatus,
|
|
19
19
|
IDeviceBLEFirmwareStatus,
|
|
20
20
|
ITransportStatus,
|
|
21
|
+
IVersionArray,
|
|
21
22
|
} from '../types';
|
|
22
23
|
import { getReleaseChangelog, getReleaseStatus, findLatestRelease } from '../utils/release';
|
|
23
24
|
|
|
@@ -117,6 +118,17 @@ export default class DataManager {
|
|
|
117
118
|
return findLatestRelease(targetDeviceConfig)?.bootloaderResource;
|
|
118
119
|
};
|
|
119
120
|
|
|
121
|
+
static getBootloaderTargetVersion = (features: Features): IVersionArray | undefined => {
|
|
122
|
+
const deviceType = getDeviceType(features);
|
|
123
|
+
|
|
124
|
+
if (deviceType !== 'pro' && deviceType !== 'touch') return undefined;
|
|
125
|
+
const firmwareUpdateField = getFirmwareUpdateField(features, 'firmware') as FirmwareField;
|
|
126
|
+
const targetDeviceConfigList = this.deviceMap[deviceType]?.[firmwareUpdateField] ?? [];
|
|
127
|
+
const targetDeviceConfig = targetDeviceConfigList.filter(item => !!item.bootloaderResource);
|
|
128
|
+
|
|
129
|
+
return targetDeviceConfig?.[0]?.bootloaderVersion ?? undefined;
|
|
130
|
+
};
|
|
131
|
+
|
|
120
132
|
static getFirmwareChangelog = (features: Features) => {
|
|
121
133
|
const deviceType = getDeviceType(features);
|
|
122
134
|
const deviceFirmwareVersion = getDeviceFirmwareVersion(features);
|
|
@@ -73,13 +73,13 @@ export default class DeviceConnector {
|
|
|
73
73
|
this.listening = false;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
async acquire(path: string, session?: string | null) {
|
|
76
|
+
async acquire(path: string, session?: string | null, forceCleanRunPromise?: boolean) {
|
|
77
77
|
Log.debug('acquire', path, session);
|
|
78
78
|
const env = DataManager.getSettings('env');
|
|
79
79
|
try {
|
|
80
80
|
let res;
|
|
81
81
|
if (env === 'react-native') {
|
|
82
|
-
res = await this.transport.acquire({ uuid: path });
|
|
82
|
+
res = await this.transport.acquire({ uuid: path, forceCleanRunPromise });
|
|
83
83
|
} else {
|
|
84
84
|
res = await this.transport.acquire({ path, previous: session ?? null });
|
|
85
85
|
}
|
package/src/types/params.ts
CHANGED
package/src/types/settings.ts
CHANGED