@onekeyfe/hd-transport-lowlevel 1.2.0-alpha.26 → 1.2.0-alpha.28
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__/protocol-v2.test.js +20 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -3
- package/package.json +4 -4
- package/src/index.ts +15 -3
|
@@ -122,6 +122,26 @@ const splitFrame = (frame, index) => [
|
|
|
122
122
|
];
|
|
123
123
|
|
|
124
124
|
describe('LowlevelTransport protocol framing', () => {
|
|
125
|
+
test('keeps active links when the Protocol V2 schema is configured repeatedly', () => {
|
|
126
|
+
const lowlevel = new LowlevelTransport();
|
|
127
|
+
const invalidateAllLinks = jest.fn().mockResolvedValue(undefined);
|
|
128
|
+
lowlevel.protocolV2Links.invalidateAllLinks = invalidateAllLinks;
|
|
129
|
+
|
|
130
|
+
lowlevel.configureProtocolV2(protocolV2Schema);
|
|
131
|
+
lowlevel.configureProtocolV2(protocolV2Schema);
|
|
132
|
+
|
|
133
|
+
expect(invalidateAllLinks).not.toHaveBeenCalled();
|
|
134
|
+
|
|
135
|
+
lowlevel.configureProtocolV2({
|
|
136
|
+
nested: {
|
|
137
|
+
...protocolV2Schema.nested,
|
|
138
|
+
ExtraMessage: { fields: {} },
|
|
139
|
+
},
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
expect(invalidateAllLinks).toHaveBeenCalledWith('Protocol V2 schema reconfigured');
|
|
143
|
+
});
|
|
144
|
+
|
|
125
145
|
test('keeps Protocol V1 raw notification chunks compatible', async () => {
|
|
126
146
|
const responseChunks = ProtocolV1.encodeTransportPackets(schemas.protocolV1, 'Success', {
|
|
127
147
|
message: 'ok',
|
package/dist/index.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ declare class LowlevelTransport {
|
|
|
29
29
|
private protocolV2Generations;
|
|
30
30
|
private connectedDevices;
|
|
31
31
|
private protocolV2Links;
|
|
32
|
+
private protocolV2SchemaConfiguration;
|
|
32
33
|
getProtocolType(path: string): ProtocolType | undefined;
|
|
33
34
|
init(logger: any, emitter: EventEmitter, plugin: LowlevelTransportSharedPlugin): void;
|
|
34
35
|
configure(signedData: any): void;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,SAWN,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,YAAY,MAAM,QAAQ,CAAC;AACvC,OAAO,KAAK,EACV,cAAc,EACd,6BAA6B,EAC7B,YAAY,EACZ,oBAAoB,EACrB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAUpD,wBAAgB,+BAA+B,CAAC,EAC9C,OAAO,EACP,iBAAiB,EACjB,GAAG,EACH,YAAY,GACb,EAAE;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,EAAE,MAAM,CAAC;CACtB,WAMA;AAED,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM;;cAEpD;AAcD,MAAM,CAAC,OAAO,OAAO,iBAAiB;IACpC,SAAS,EAAE,UAAU,CAAC,OAAO,SAAS,CAAC,cAAc,CAAC,GAAG,SAAS,CAAC;IAEnE,WAAW,EAAE,UAAU,CAAC,OAAO,SAAS,CAAC,cAAc,CAAC,GAAG,SAAS,CAAC;IAErE,UAAU,UAAS;IAEnB,GAAG,CAAC,EAAE,GAAG,CAAC;IAEV,OAAO,CAAC,EAAE,YAAY,CAAC;IAEvB,MAAM,EAAE,6BAA6B,CAAuC;IAE5E,OAAO,CAAC,cAAc,CAAwC;IAE9D,OAAO,CAAC,mBAAmB,CAAwC;IAEnE,OAAO,CAAC,oBAAoB,CAAoD;IAEhF,OAAO,CAAC,q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AC,cAAc,CAAwC;IAE9D,OAAO,CAAC,mBAAmB,CAAwC;IAEnE,OAAO,CAAC,oBAAoB,CAAoD;IAEhF,OAAO,CAAC,qBAAqB,CAAkC;IAE/D,OAAO,CAAC,gBAAgB,CAA0B;IAElD,OAAO,CAAC,eAAe,CA6BpB;IAEH,OAAO,CAAC,6BAA6B,CAAqB;IAE1D,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;IAIvD,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,6BAA6B;IAO9E,SAAS,CAAC,UAAU,EAAE,GAAG;IAMzB,mBAAmB,CAAC,UAAU,EAAE,GAAG;IAiBnC,MAAM;IAIA,SAAS;IAWT,OAAO,CAAC,KAAK,EAAE,oBAAoB;;;;IA6BnC,OAAO,CAAC,IAAI,EAAE,MAAM;IAgBpB,IAAI,CACR,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,CAAC,EAAE,oBAAoB;YAsBlB,cAAc;IA6E5B,OAAO,CAAC,0BAA0B;IAOlC,OAAO,CAAC,2BAA2B;IAOnC,OAAO,CAAC,4BAA4B;IAOpC,OAAO,CAAC,kBAAkB;YAMZ,cAAc;YAsDd,yBAAyB;YAiCzB,eAAe;YAgBf,eAAe;YA6Bf,UAAU;YAUV,qBAAqB;YAmBrB,mBAAmB;YAqBnB,oBAAoB;YAOpB,cAAc;IAwB5B,OAAO,CAAC,uBAAuB;IAkC/B,OAAO,CAAC,2BAA2B;IAMnC,MAAM;CAGP"}
|
package/dist/index.js
CHANGED
|
@@ -117,10 +117,18 @@ class LowlevelTransport {
|
|
|
117
117
|
this._messages = messages;
|
|
118
118
|
}
|
|
119
119
|
configureProtocolV2(signedData) {
|
|
120
|
+
const configuration = typeof signedData === 'string' ? signedData : JSON.stringify(signedData);
|
|
121
|
+
if (this.protocolV2SchemaConfiguration === configuration) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
const isReconfiguration = this.protocolV2SchemaConfiguration !== undefined;
|
|
120
125
|
this._messagesV2 = parseConfigure(signedData);
|
|
121
|
-
this.
|
|
122
|
-
|
|
123
|
-
|
|
126
|
+
this.protocolV2SchemaConfiguration = configuration;
|
|
127
|
+
if (isReconfiguration) {
|
|
128
|
+
this.protocolV2Links
|
|
129
|
+
.invalidateAllLinks('Protocol V2 schema reconfigured')
|
|
130
|
+
.catch(error => { var _a; return (_a = this.Log) === null || _a === void 0 ? void 0 : _a.debug('Protocol V2 schema link cleanup failed:', error); });
|
|
131
|
+
}
|
|
124
132
|
}
|
|
125
133
|
listen() {
|
|
126
134
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-transport-lowlevel",
|
|
3
|
-
"version": "1.2.0-alpha.
|
|
3
|
+
"version": "1.2.0-alpha.28",
|
|
4
4
|
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"lint:fix": "eslint . --fix"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@onekeyfe/hd-shared": "1.2.0-alpha.
|
|
24
|
-
"@onekeyfe/hd-transport": "1.2.0-alpha.
|
|
23
|
+
"@onekeyfe/hd-shared": "1.2.0-alpha.28",
|
|
24
|
+
"@onekeyfe/hd-transport": "1.2.0-alpha.28"
|
|
25
25
|
},
|
|
26
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "b7c7f9f53c4d745f127d03e0b173e8b759bf8e15"
|
|
27
27
|
}
|
package/src/index.ts
CHANGED
|
@@ -117,6 +117,8 @@ export default class LowlevelTransport {
|
|
|
117
117
|
},
|
|
118
118
|
});
|
|
119
119
|
|
|
120
|
+
private protocolV2SchemaConfiguration: string | undefined;
|
|
121
|
+
|
|
120
122
|
getProtocolType(path: string): ProtocolType | undefined {
|
|
121
123
|
return this.deviceProtocol.get(path);
|
|
122
124
|
}
|
|
@@ -135,10 +137,20 @@ export default class LowlevelTransport {
|
|
|
135
137
|
}
|
|
136
138
|
|
|
137
139
|
configureProtocolV2(signedData: any) {
|
|
140
|
+
const configuration = typeof signedData === 'string' ? signedData : JSON.stringify(signedData);
|
|
141
|
+
if (this.protocolV2SchemaConfiguration === configuration) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const isReconfiguration = this.protocolV2SchemaConfiguration !== undefined;
|
|
138
146
|
this._messagesV2 = parseConfigure(signedData);
|
|
139
|
-
this.
|
|
140
|
-
|
|
141
|
-
|
|
147
|
+
this.protocolV2SchemaConfiguration = configuration;
|
|
148
|
+
|
|
149
|
+
if (isReconfiguration) {
|
|
150
|
+
this.protocolV2Links
|
|
151
|
+
.invalidateAllLinks('Protocol V2 schema reconfigured')
|
|
152
|
+
.catch(error => this.Log?.debug('Protocol V2 schema link cleanup failed:', error));
|
|
153
|
+
}
|
|
142
154
|
}
|
|
143
155
|
|
|
144
156
|
listen() {
|