@onekeyfe/hd-transport 1.2.8-alpha.11 → 1.2.8-alpha.110

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.
@@ -1,5 +1,3 @@
1
- const { execFileSync } = require('child_process');
2
-
3
1
  const {
4
2
  createMessageFromName,
5
3
  createMessageFromType,
@@ -66,71 +64,6 @@ const json = {
66
64
  };
67
65
 
68
66
  describe('messages', () => {
69
- test('built-in schemas encode and decode with string code generation disabled', () => {
70
- const script = `
71
- const assert = require('assert');
72
- const babel = require('@babel/core');
73
- require.extensions['.ts'] = (mod, filename) => {
74
- const { code } = babel.transformFileSync(filename, { rootMode: 'upward' });
75
- mod._compile(code, filename);
76
- };
77
- const { parseConfigure } = require('./src/serialization/protobuf/messages.ts');
78
- const { encode } = require('./src/serialization/protobuf/encode.ts');
79
- const { decode } = require('./src/serialization/protobuf/decode.ts');
80
- const { ProtocolV2 } = require('./src/protocols/index.ts');
81
- const { encodeProtobufFrame } = require('./src/protocols/v2/encode.ts');
82
- const v1 = require('../core/src/data/messages/messages.json');
83
- const legacyV1 = require('../core/src/data/messages/messages_legacy_v1.json');
84
- const v2 = require('./messages-protocol-v2.json');
85
- for (const schema of [v1, legacyV1, v2]) {
86
- for (const input of [schema, JSON.stringify(schema)]) {
87
- const root = parseConfigure(input);
88
- const ping = root.lookupType('Ping');
89
- const encoded = encode(ping, { message: 'csp' });
90
- assert.strictEqual(encoded.toString('hex'), '0a03637370');
91
- assert.strictEqual(decode(ping, encoded).message, 'csp');
92
- assert.strictEqual(ping.verify(ping.fromObject({ message: 'csp' })), null);
93
- assert.strictEqual(ping.toObject(ping.create({ message: 'csp' })).message, 'csp');
94
- encode(root.lookupType('Initialize'), {});
95
- const amount = root.lookupType('StellarBumpSequenceOp');
96
- const amountBytes = encode(amount, { bump_to: '18446744073709551615' });
97
- assert.strictEqual(amountBytes.toString('hex'), '10ffffffffffffffffff01');
98
- assert.deepStrictEqual(decode(amount, amountBytes), {
99
- source_account: null, bump_to: '18446744073709551615'
100
- });
101
- const request = root.lookupType('TxRequest');
102
- assert.deepStrictEqual(decode(request, encode(request, {
103
- request_type: 'TXINPUT', details: { request_index: 7, tx_hash: 'abcd' }
104
- })), {
105
- request_type: 'TXINPUT', serialized: null,
106
- details: { request_index: 7, tx_hash: 'abcd', extra_data_len: null, extra_data_offset: null }
107
- });
108
- const reordered = { ...schema, nested: Object.fromEntries(Object.entries(schema.nested).reverse()) };
109
- const otherPing = parseConfigure(reordered).lookupType('Ping');
110
- assert.notStrictEqual(ping.ctor, otherPing.ctor);
111
- assert.strictEqual(ping.decode(encoded.toBuffer()).$type, ping);
112
- assert.strictEqual(decode(otherPing, encoded).message, 'csp');
113
- }
114
- }
115
- const schemas = { protocolV1: parseConfigure(v1), protocolV2: parseConfigure(v2) };
116
- const frame = ProtocolV2.encodeFrame(schemas, 'ProtocolInfoRequest', { eventless_wallet_session: true });
117
- assert.strictEqual(ProtocolV2.decodeFrame(schemas, frame).message.eventless_wallet_session, true);
118
- const legacyFrame = encodeProtobufFrame(
119
- v2.nested.MessageType.values.MessageType_ProtocolInfo,
120
- Uint8Array.from([0x08, 0x02, 0x10, 0x01])
121
- );
122
- assert.deepStrictEqual(ProtocolV2.decodeFrame(schemas, legacyFrame).message, {
123
- version: 2, build_fingerprint: '', supported_messages: [1], protobuf_definition: null
124
- });
125
- `;
126
-
127
- execFileSync(process.execPath, ['--disallow-code-generation-from-strings', '-e', script], {
128
- cwd: `${__dirname}/..`,
129
- env: { ...process.env, BABEL_DISABLE_CACHE: '1' },
130
- stdio: 'pipe',
131
- });
132
- });
133
-
134
67
  test('V1 GetPassphraseState matches the current firmware schema', () => {
135
68
  const { fields } = v1Messages.nested.GetPassphraseState;
136
69
 
package/dist/index.d.ts CHANGED
@@ -323,6 +323,12 @@ type OneKeyDeviceInfoWithSession = OneKeyUsbDeviceInfo & {
323
323
  type OneKeyMobileDeviceInfo = {
324
324
  id: string;
325
325
  name: string | null;
326
+ /**
327
+ * Color letter of the serial number ('A'-'Z') from the Pro2 / Neo BLE advertisement,
328
+ * possibly seen in an earlier scan. Set by the React Native and Electron BLE
329
+ * transports; absent when unknown.
330
+ */
331
+ bleColorCode?: string;
326
332
  };
327
333
  type OneKeyDeviceInfoBase = {
328
334
  commType: OneKeyDeviceCommType;