@onekeyfe/hd-core 1.2.0-alpha.102 → 1.2.0-alpha.103

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.
Files changed (33) hide show
  1. package/__tests__/base64Data.test.ts +70 -0
  2. package/__tests__/deviceUploadNft.test.ts +33 -4
  3. package/__tests__/protocol-v2.test.ts +75 -16
  4. package/__tests__/resourceBase64Boundary.test.ts +48 -0
  5. package/dist/api/UploadPortfolio.d.ts +1 -1
  6. package/dist/api/UploadPortfolio.d.ts.map +1 -1
  7. package/dist/api/helpers/base64Data.d.ts +16 -0
  8. package/dist/api/helpers/base64Data.d.ts.map +1 -0
  9. package/dist/api/protocol-v2/DeviceUploadNft.d.ts +2 -3
  10. package/dist/api/protocol-v2/DeviceUploadNft.d.ts.map +1 -1
  11. package/dist/api/protocol-v2/DeviceUploadWallpaper.d.ts +2 -3
  12. package/dist/api/protocol-v2/DeviceUploadWallpaper.d.ts.map +1 -1
  13. package/dist/api/utils.d.ts.map +1 -1
  14. package/dist/index.d.ts +4 -12
  15. package/dist/index.js +154 -157
  16. package/dist/topLevelInject.d.ts.map +1 -1
  17. package/dist/types/api/protocolV2.d.ts +1 -1
  18. package/dist/types/api/protocolV2.d.ts.map +1 -1
  19. package/dist/utils/pro2Nft.d.ts +7 -0
  20. package/dist/utils/pro2Nft.d.ts.map +1 -1
  21. package/package.json +6 -4
  22. package/src/api/UploadPortfolio.ts +9 -2
  23. package/src/api/helpers/base64Data.ts +85 -0
  24. package/src/api/protocol-v2/DeviceUploadNft.ts +56 -8
  25. package/src/api/protocol-v2/DeviceUploadWallpaper.ts +37 -18
  26. package/src/api/utils.ts +2 -5
  27. package/src/topLevelInject.ts +2 -4
  28. package/src/types/api/protocolV2.ts +1 -1
  29. package/src/utils/pro2Nft.ts +31 -8
  30. package/__tests__/bridgeBinaryPayload.test.ts +0 -173
  31. package/dist/utils/bridgeBinaryPayload.d.ts +0 -3
  32. package/dist/utils/bridgeBinaryPayload.d.ts.map +0 -1
  33. package/src/utils/bridgeBinaryPayload.ts +0 -137
@@ -0,0 +1,70 @@
1
+ import { Buffer } from 'buffer';
2
+
3
+ import { encode as encodeJpeg } from 'jpeg-js';
4
+
5
+ import { decodeCanonicalBase64, decodeJpegBase64ToRgba } from '../src/api/helpers/base64Data';
6
+
7
+ const createJpegBase64 = (width: number, height: number) => {
8
+ const rgba = new Uint8Array(width * height * 4).fill(0xff);
9
+ return encodeJpeg({ width, height, data: rgba }, 80).data.toString('base64');
10
+ };
11
+
12
+ describe('Base64 resource data', () => {
13
+ test('decodes canonical Base64 to a detached Uint8Array', () => {
14
+ const decoded = decodeCanonicalBase64({
15
+ value: 'AQID',
16
+ parameterName: 'packageBase64',
17
+ maxBytes: 3,
18
+ });
19
+
20
+ expect(decoded).toBeInstanceOf(Uint8Array);
21
+ expect(Array.from(decoded)).toEqual([1, 2, 3]);
22
+ });
23
+
24
+ test.each(['', 'not-base64', 'AB==', 'data:image/jpeg;base64,AQID'])(
25
+ 'rejects non-canonical Base64 input %p',
26
+ value => {
27
+ expect(() =>
28
+ decodeCanonicalBase64({ value, parameterName: 'data', maxBytes: 1024 })
29
+ ).toThrow();
30
+ }
31
+ );
32
+
33
+ test('rejects oversized Base64 before decoding', () => {
34
+ const value = Buffer.alloc(64 * 1024 + 17).toString('base64');
35
+ expect(() =>
36
+ decodeCanonicalBase64({ value, parameterName: 'data', maxBytes: 64 * 1024 })
37
+ ).toThrow('maximum supported size');
38
+ });
39
+
40
+ test('decodes and validates a JPEG with the expected dimensions', () => {
41
+ const decoded = decodeJpegBase64ToRgba({
42
+ jpegBase64: createJpegBase64(2, 1),
43
+ parameterName: 'jpegBase64',
44
+ expectedWidth: 2,
45
+ expectedHeight: 1,
46
+ });
47
+
48
+ expect(decoded).toMatchObject({ width: 2, height: 1 });
49
+ expect(decoded.data).toHaveLength(8);
50
+ });
51
+
52
+ test('rejects non-JPEG bytes and unexpected dimensions', () => {
53
+ expect(() =>
54
+ decodeJpegBase64ToRgba({
55
+ jpegBase64: 'AQID',
56
+ parameterName: 'jpegBase64',
57
+ expectedWidth: 2,
58
+ expectedHeight: 1,
59
+ })
60
+ ).toThrow('JPEG image');
61
+ expect(() =>
62
+ decodeJpegBase64ToRgba({
63
+ jpegBase64: createJpegBase64(2, 1),
64
+ parameterName: 'jpegBase64',
65
+ expectedWidth: 1,
66
+ expectedHeight: 1,
67
+ })
68
+ ).toThrow('1x1');
69
+ });
70
+ });
@@ -1,4 +1,5 @@
1
1
  import { HardwareErrorCode } from '@onekeyfe/hd-shared';
2
+ import { encode as encodeJpeg } from 'jpeg-js';
2
3
 
3
4
  import DeviceUploadNft from '../src/api/protocol-v2/DeviceUploadNft';
4
5
 
@@ -13,6 +14,19 @@ const createRgba = (width: number, height: number) => {
13
14
  return data;
14
15
  };
15
16
 
17
+ const jpegBase64Cache = new Map<string, string>();
18
+
19
+ const createJpegBase64 = (width: number, height: number) => {
20
+ const key = `${width}x${height}`;
21
+ const cached = jpegBase64Cache.get(key);
22
+ if (cached) return cached;
23
+ const value = encodeJpeg({ width, height, data: createRgba(width, height) }, 80).data.toString(
24
+ 'base64'
25
+ );
26
+ jpegBase64Cache.set(key, value);
27
+ return value;
28
+ };
29
+
16
30
  const createMethod = ({
17
31
  typedCall,
18
32
  supportedMessages = [60802, 60805, 60808, 61500],
@@ -26,8 +40,8 @@ const createMethod = ({
26
40
  id: 1,
27
41
  payload: {
28
42
  method: 'deviceUploadNft',
29
- image: { width: 540, height: 540, rgba: createRgba(540, 540) },
30
- thumbnail: { width: 263, height: 263, rgba: createRgba(263, 263) },
43
+ imageJpegBase64: createJpegBase64(540, 540),
44
+ thumbnailJpegBase64: createJpegBase64(263, 263),
31
45
  title: 'CryptoPunk #3100',
32
46
  subtitle: 'CryptoPunks',
33
47
  timestampMs: 1_760_000_000_000,
@@ -86,8 +100,8 @@ describe('DeviceUploadNft', () => {
86
100
  id: 1,
87
101
  payload: {
88
102
  method: 'deviceUploadNft',
89
- image: { width: 540, height: 540, rgba: createRgba(540, 540) },
90
- thumbnail: { width: 263, height: 263, rgba: createRgba(263, 263) },
103
+ imageJpegBase64: createJpegBase64(540, 540),
104
+ thumbnailJpegBase64: createJpegBase64(263, 263),
91
105
  title: 'CryptoPunk #3100',
92
106
  subtitle: 'CryptoPunks',
93
107
  timestampMs: 1_760_000_000_000,
@@ -102,6 +116,21 @@ describe('DeviceUploadNft', () => {
102
116
  });
103
117
  });
104
118
 
119
+ test('rejects invalid image Base64 before device communication', () => {
120
+ const method = new DeviceUploadNft({
121
+ id: 1,
122
+ payload: {
123
+ method: 'deviceUploadNft',
124
+ imageJpegBase64: 'not-base64',
125
+ thumbnailJpegBase64: createJpegBase64(263, 263),
126
+ title: 'NFT',
127
+ subtitle: '',
128
+ },
129
+ });
130
+
131
+ expect(() => method.init()).toThrow('canonical Base64');
132
+ });
133
+
105
134
  test('uploads the triplet in order without creating the firmware-owned directory', async () => {
106
135
  const typedCall = jest.fn((request: string, _response: string, params: any) => {
107
136
  if (request === 'FilesystemPathInfoQuery') {
@@ -1,7 +1,10 @@
1
+ import { Buffer } from 'buffer';
2
+
1
3
  import { EFirmwareType, ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
2
4
  import { sha256 } from '@noble/hashes/sha256';
3
5
  import { bytesToHex } from '@noble/hashes/utils';
4
6
  import JSZip from 'jszip';
7
+ import { encode as encodeJpeg } from 'jpeg-js';
5
8
  import {
6
9
  DeviceRebootType,
7
10
  DeviceSessionPinType,
@@ -123,6 +126,18 @@ jest.mock('../src/data/config', () => ({
123
126
  DEFAULT_DOMAIN: 'https://jssdk.onekey.so/1.0.0/',
124
127
  }));
125
128
 
129
+ const jpegBase64Cache = new Map<string, string>();
130
+
131
+ const createJpegBase64 = (width: number, height: number) => {
132
+ const key = `${width}x${height}`;
133
+ const cached = jpegBase64Cache.get(key);
134
+ if (cached) return cached;
135
+ const rgba = new Uint8Array(width * height * 4).fill(0xff);
136
+ const value = encodeJpeg({ width, height, data: rgba }, 80).data.toString('base64');
137
+ jpegBase64Cache.set(key, value);
138
+ return value;
139
+ };
140
+
126
141
  const createProtocolV2OkppBinary = ({
127
142
  version = [1, 2, 3],
128
143
  payloadHashByte = 0x11,
@@ -160,8 +175,18 @@ const createWalletSessionTypedCall = (
160
175
  });
161
176
 
162
177
  describe('DeviceUploadWallpaper', () => {
178
+ const wallpaperProtocolInfo = {
179
+ version: 2,
180
+ supported_messages: [60412, 60805, 60809],
181
+ };
182
+
183
+ const stubWallpaperDevice = <T extends Record<string, any>>(device: T) =>
184
+ stubDevice({
185
+ ...device,
186
+ ensureProtocolV2RuntimeContext: jest.fn().mockResolvedValue(wallpaperProtocolInfo),
187
+ });
188
+
163
189
  test('encodes, uploads and applies a Pro2 wallpaper', async () => {
164
- const rgba = new Uint8Array(604 * 1024 * 4).fill(255);
165
190
  const typedCall = jest.fn().mockImplementation((request, _response, params) => {
166
191
  if (request === 'FilesystemDirMake') return { message: { message: 'directory ready' } };
167
192
  if (request === 'FilesystemFileWrite') {
@@ -175,9 +200,12 @@ describe('DeviceUploadWallpaper', () => {
175
200
  });
176
201
  const method = new DeviceUploadWallpaper({
177
202
  id: 1,
178
- payload: { method: 'deviceUploadWallpaper', width: 604, height: 1024, rgba },
203
+ payload: {
204
+ method: 'deviceUploadWallpaper',
205
+ jpegBase64: createJpegBase64(604, 1024),
206
+ },
179
207
  });
180
- (method as any).device = stubDevice({ commands: { typedCall } });
208
+ (method as any).device = stubWallpaperDevice({ commands: { typedCall } });
181
209
  method.postMessage = jest.fn();
182
210
 
183
211
  method.init();
@@ -225,12 +253,10 @@ describe('DeviceUploadWallpaper', () => {
225
253
  id: 1,
226
254
  payload: {
227
255
  method: 'deviceUploadWallpaper',
228
- width: 604,
229
- height: 1024,
230
- rgba: new Uint8Array(604 * 1024 * 4),
256
+ jpegBase64: createJpegBase64(604, 1024),
231
257
  },
232
258
  });
233
- (method as any).device = stubDevice({ commands: { typedCall } });
259
+ (method as any).device = stubWallpaperDevice({ commands: { typedCall } });
234
260
  method.init();
235
261
 
236
262
  await expect(method.run()).rejects.toThrow('write failed');
@@ -242,15 +268,37 @@ describe('DeviceUploadWallpaper', () => {
242
268
  id: 1,
243
269
  payload: {
244
270
  method: 'deviceUploadWallpaper',
245
- width: 604,
246
- height: 1024,
247
- rgba: new Uint8Array(604 * 1024 * 4),
271
+ jpegBase64: createJpegBase64(604, 1024),
248
272
  fileName: '../wallpaper.bin',
249
273
  },
250
274
  });
251
275
 
252
276
  expect(() => method.init()).toThrow('fileName');
253
277
  });
278
+
279
+ test('rejects unsupported firmware before creating or writing files', async () => {
280
+ const typedCall = jest.fn();
281
+ const method = new DeviceUploadWallpaper({
282
+ id: 1,
283
+ payload: {
284
+ method: 'deviceUploadWallpaper',
285
+ jpegBase64: createJpegBase64(604, 1024),
286
+ },
287
+ });
288
+ (method as any).device = stubDevice({
289
+ commands: { typedCall },
290
+ ensureProtocolV2RuntimeContext: jest.fn().mockResolvedValue({
291
+ version: 2,
292
+ supported_messages: [60805, 60809],
293
+ }),
294
+ });
295
+ method.init();
296
+
297
+ await expect(method.run()).rejects.toMatchObject({
298
+ errorCode: HardwareErrorCode.DeviceNotSupportMethod,
299
+ });
300
+ expect(typedCall).not.toHaveBeenCalled();
301
+ });
254
302
  });
255
303
 
256
304
  describe('UploadPortfolio', () => {
@@ -266,7 +314,6 @@ describe('UploadPortfolio', () => {
266
314
  });
267
315
 
268
316
  test('writes and applies the portfolio while the device is locked without unlocking', async () => {
269
- const packageBytes = new Uint8Array([1, 2, 3]);
270
317
  const typedCall = jest
271
318
  .fn()
272
319
  .mockResolvedValueOnce({ message: { processed_byte: 3 } })
@@ -282,7 +329,7 @@ describe('UploadPortfolio', () => {
282
329
  id: 1,
283
330
  payload: {
284
331
  method: 'uploadPortfolio',
285
- packageBytes,
332
+ packageBase64: 'AQID',
286
333
  },
287
334
  });
288
335
  (method as any).device = device;
@@ -314,7 +361,7 @@ describe('UploadPortfolio', () => {
314
361
  id: 1,
315
362
  payload: {
316
363
  method: 'uploadPortfolio',
317
- packageBytes,
364
+ packageBase64: 'AQID',
318
365
  },
319
366
  });
320
367
  (method as any).device = stubPortfolioDevice({ commands: { typedCall } });
@@ -362,7 +409,7 @@ describe('UploadPortfolio', () => {
362
409
  id: 1,
363
410
  payload: {
364
411
  method: 'uploadPortfolio',
365
- packageBytes: new Uint8Array([1]),
412
+ packageBase64: 'AQ==',
366
413
  },
367
414
  });
368
415
  (method as any).device = stubPortfolioDevice({ commands: { typedCall } });
@@ -384,7 +431,7 @@ describe('UploadPortfolio', () => {
384
431
  id: 1,
385
432
  payload: {
386
433
  method: 'uploadPortfolio',
387
- packageBytes,
434
+ packageBase64: Buffer.from(packageBytes).toString('base64'),
388
435
  },
389
436
  });
390
437
  method.abortSignal = abortController.signal;
@@ -405,7 +452,7 @@ describe('UploadPortfolio', () => {
405
452
  id: 1,
406
453
  payload: {
407
454
  method: 'uploadPortfolio',
408
- packageBytes: new Uint8Array([1]),
455
+ packageBase64: 'AQ==',
409
456
  },
410
457
  });
411
458
  (method as any).device = stubDevice({
@@ -423,6 +470,18 @@ describe('UploadPortfolio', () => {
423
470
  });
424
471
  expect(typedCall).not.toHaveBeenCalled();
425
472
  });
473
+
474
+ test('rejects non-canonical Base64 before device communication', () => {
475
+ const method = new UploadPortfolio({
476
+ id: 1,
477
+ payload: {
478
+ method: 'uploadPortfolio',
479
+ packageBase64: 'data:application/octet-stream;base64,AQID',
480
+ },
481
+ });
482
+
483
+ expect(() => method.init()).toThrow('canonical Base64');
484
+ });
426
485
  });
427
486
 
428
487
  const descriptor = {
@@ -0,0 +1,48 @@
1
+ import { HardwareTopLevelSdk } from '../src';
2
+ import { findMethod } from '../src/api/utils';
3
+
4
+ import type { LowLevelCoreApi } from '../src';
5
+
6
+ jest.mock('../src/data/config', () => ({
7
+ DEFAULT_DOMAIN: 'https://example.com/',
8
+ getSDKVersion: () => '0.0.0-test',
9
+ }));
10
+
11
+ const crossJsonOnlyBridge = (value: unknown): unknown => JSON.parse(JSON.stringify(value));
12
+
13
+ describe('Base64 resource boundary', () => {
14
+ test('keeps Portfolio, wallpaper and NFT payloads JSON-safe across TopLevel and LowLevel', async () => {
15
+ const restoredPayloads: Array<Record<string, any>> = [];
16
+ const lowLevelApi = {
17
+ call: jest.fn(params => {
18
+ const method = findMethod({ id: 1, payload: crossJsonOnlyBridge(params) } as any);
19
+ restoredPayloads.push(method.payload);
20
+ return Promise.resolve({ success: true, payload: {} });
21
+ }),
22
+ init: jest.fn(() => Promise.resolve(true)),
23
+ } as unknown as LowLevelCoreApi;
24
+ const sdk = HardwareTopLevelSdk();
25
+ await sdk.init({}, lowLevelApi);
26
+
27
+ await sdk.uploadPortfolio('connect-id', { packageBase64: 'AQID' });
28
+ await sdk.deviceUploadWallpaper('connect-id', { jpegBase64: '/9j/' });
29
+ await sdk.deviceUploadNft('connect-id', {
30
+ imageJpegBase64: '/9j/',
31
+ thumbnailJpegBase64: '/9j/',
32
+ title: 'NFT',
33
+ subtitle: '',
34
+ });
35
+
36
+ expect(restoredPayloads.map(payload => payload.method)).toEqual([
37
+ 'uploadPortfolio',
38
+ 'deviceUploadWallpaper',
39
+ 'deviceUploadNft',
40
+ ]);
41
+ expect(restoredPayloads[0].packageBase64).toBe('AQID');
42
+ expect(restoredPayloads[1].jpegBase64).toBe('/9j/');
43
+ expect(restoredPayloads[2]).toMatchObject({
44
+ imageJpegBase64: '/9j/',
45
+ thumbnailJpegBase64: '/9j/',
46
+ });
47
+ });
48
+ });
@@ -1,6 +1,6 @@
1
1
  import FileWrite from './FileWrite';
2
2
  export type UploadPortfolioParams = {
3
- packageBytes: ArrayBuffer | Uint8Array | Blob;
3
+ packageBase64: string;
4
4
  timeoutMs?: number | string;
5
5
  };
6
6
  export default class UploadPortfolio extends FileWrite {
@@ -1 +1 @@
1
- {"version":3,"file":"UploadPortfolio.d.ts","sourceRoot":"","sources":["../../src/api/UploadPortfolio.ts"],"names":[],"mappings":"AAGA,OAAO,SAAS,MAAM,aAAa,CAAC;AAEpC,MAAM,MAAM,qBAAqB,GAAG;IAClC,YAAY,EAAE,WAAW,GAAG,UAAU,GAAG,IAAI,CAAC;IAC9C,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAC7B,CAAC;AAOF,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,SAAS;IACpD,IAAI;IAmBE,GAAG;;;;;;;;CAsBV"}
1
+ {"version":3,"file":"UploadPortfolio.d.ts","sourceRoot":"","sources":["../../src/api/UploadPortfolio.ts"],"names":[],"mappings":"AAIA,OAAO,SAAS,MAAM,aAAa,CAAC;AAEpC,MAAM,MAAM,qBAAqB,GAAG;IAClC,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAC7B,CAAC;AAQF,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,SAAS;IACpD,IAAI;IAwBE,GAAG;;;;;;;;CAsBV"}
@@ -0,0 +1,16 @@
1
+ export declare function decodeCanonicalBase64({ value, parameterName, maxBytes, }: {
2
+ value: unknown;
3
+ parameterName: string;
4
+ maxBytes: number;
5
+ }): Uint8Array;
6
+ export declare function decodeJpegBase64ToRgba({ jpegBase64, parameterName, expectedWidth, expectedHeight, }: {
7
+ jpegBase64: unknown;
8
+ parameterName: string;
9
+ expectedWidth: number;
10
+ expectedHeight: number;
11
+ }): {
12
+ width: number;
13
+ height: number;
14
+ data: Uint8Array;
15
+ };
16
+ //# sourceMappingURL=base64Data.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base64Data.d.ts","sourceRoot":"","sources":["../../../src/api/helpers/base64Data.ts"],"names":[],"mappings":"AAUA,wBAAgB,qBAAqB,CAAC,EACpC,KAAK,EACL,aAAa,EACb,QAAQ,GACT,EAAE;IACD,KAAK,EAAE,OAAO,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,UAAU,CAmBb;AAED,wBAAgB,sBAAsB,CAAC,EACrC,UAAU,EACV,aAAa,EACb,aAAa,EACb,cAAc,GACf,EAAE;IACD,UAAU,EAAE,OAAO,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;CACxB,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,UAAU,CAAA;CAAE,CAmCtD"}
@@ -1,8 +1,7 @@
1
- import { type Pro2NftImage } from '../../utils/pro2Nft';
2
1
  import { BaseMethod } from '../BaseMethod';
3
2
  export type DeviceUploadNftParams = {
4
- image: Pro2NftImage;
5
- thumbnail: Pro2NftImage;
3
+ imageJpegBase64: string;
4
+ thumbnailJpegBase64: string;
6
5
  title: string;
7
6
  subtitle: string;
8
7
  timestampMs?: number;
@@ -1 +1 @@
1
- {"version":3,"file":"DeviceUploadNft.d.ts","sourceRoot":"","sources":["../../../src/api/protocol-v2/DeviceUploadNft.ts"],"names":[],"mappings":"AAIA,OAAO,EASL,KAAK,YAAY,EAGlB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAI3C,MAAM,MAAM,qBAAqB,GAAG;IAClC,KAAK,EAAE,YAAY,CAAC;IACpB,SAAS,EAAE,YAAY,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,IAAI,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAOF,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,UAAU,CAAC,qBAAqB,CAAC;IAC5E,OAAO,CAAC,MAAM,CAAC,CAAgB;IAE/B,qBAAqB;IAIrB,IAAI;YAkCU,kBAAkB;YAiBlB,qBAAqB;YAwBrB,SAAS;IASjB,GAAG,IAAI,OAAO,CAAC,uBAAuB,CAAC;CA0D9C"}
1
+ {"version":3,"file":"DeviceUploadNft.d.ts","sourceRoot":"","sources":["../../../src/api/protocol-v2/DeviceUploadNft.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAK3C,MAAM,MAAM,qBAAqB,GAAG;IAClC,eAAe,EAAE,MAAM,CAAC;IACxB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,IAAI,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAOF,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,UAAU,CAAC,qBAAqB,CAAC;IAC5E,OAAO,CAAC,MAAM,CAAC,CAAgB;IAE/B,qBAAqB;IAIrB,IAAI;YA6EU,kBAAkB;YAiBlB,qBAAqB;YAwBrB,SAAS;IASjB,GAAG,IAAI,OAAO,CAAC,uBAAuB,CAAC;CA0D9C"}
@@ -1,9 +1,7 @@
1
1
  import { BaseMethod } from '../BaseMethod';
2
2
  import { type Pro2WallpaperColorFormat } from '../../utils/pro2Wallpaper';
3
3
  export type DeviceUploadWallpaperParams = {
4
- width: number;
5
- height: number;
6
- rgba: Uint8Array | ArrayBuffer;
4
+ jpegBase64: string;
7
5
  fileName?: string;
8
6
  chunkSize?: number;
9
7
  };
@@ -20,6 +18,7 @@ export default class DeviceUploadWallpaper extends BaseMethod<DeviceUploadWallpa
20
18
  private uploaded;
21
19
  private path;
22
20
  init(): void;
21
+ private assertCapabilities;
23
22
  private ensureDirectory;
24
23
  private upload;
25
24
  run(): Promise<DeviceUploadWallpaperResponse>;
@@ -1 +1 @@
1
- {"version":3,"file":"DeviceUploadWallpaper.d.ts","sourceRoot":"","sources":["../../../src/api/protocol-v2/DeviceUploadWallpaper.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAI3C,OAAO,EAGL,KAAK,wBAAwB,EAE9B,MAAM,2BAA2B,CAAC;AAEnC,MAAM,MAAM,2BAA2B,GAAG;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,UAAU,GAAG,WAAW,CAAC;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,wBAAwB,CAAC;IACtC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAeF,MAAM,CAAC,OAAO,OAAO,qBAAsB,SAAQ,UAAU,CAAC,2BAA2B,CAAC;IACxF,qBAAqB;IAIrB,OAAO,CAAC,OAAO,CAAC,CAA8D;IAE9E,OAAO,CAAC,cAAc,CAAS;IAE/B,OAAO,CAAC,QAAQ,CAAS;IAEzB,OAAO,CAAC,IAAI,CAAM;IAElB,IAAI;YA0BU,eAAe;YAaf,MAAM;IAwBd,GAAG,IAAI,OAAO,CAAC,6BAA6B,CAAC;CAepD"}
1
+ {"version":3,"file":"DeviceUploadWallpaper.d.ts","sourceRoot":"","sources":["../../../src/api/protocol-v2/DeviceUploadWallpaper.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAM3C,OAAO,EAGL,KAAK,wBAAwB,EAE9B,MAAM,2BAA2B,CAAC;AAEnC,MAAM,MAAM,2BAA2B,GAAG;IACxC,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,wBAAwB,CAAC;IACtC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAkBF,MAAM,CAAC,OAAO,OAAO,qBAAsB,SAAQ,UAAU,CAAC,2BAA2B,CAAC;IACxF,qBAAqB;IAIrB,OAAO,CAAC,OAAO,CAAC,CAA8D;IAE9E,OAAO,CAAC,cAAc,CAAS;IAE/B,OAAO,CAAC,QAAQ,CAAS;IAEzB,OAAO,CAAC,IAAI,CAAM;IAElB,IAAI;YAwBU,kBAAkB;YAgBlB,eAAe;YAaf,MAAM;IAwBd,GAAG,IAAI,OAAO,CAAC,6BAA6B,CAAC;CAgBpD"}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/api/utils.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAM3D,wBAAgB,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG;IAAE,EAAE,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,UAAU,CAAC,GAAG,CAAC,CAiBxF;AAOD,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,SAAS,YAAY,EAAE,CAczB"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/api/utils.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAM3D,wBAAgB,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG;IAAE,EAAE,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,UAAU,CAAC,GAAG,CAAC,CAexF;AAOD,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,SAAS,YAAY,EAAE,CAczB"}
package/dist/index.d.ts CHANGED
@@ -1137,9 +1137,7 @@ declare function encodePro2Wallpaper(options: {
1137
1137
  };
1138
1138
 
1139
1139
  type DeviceUploadWallpaperParams = {
1140
- width: number;
1141
- height: number;
1142
- rgba: Uint8Array | ArrayBuffer;
1140
+ jpegBase64: string;
1143
1141
  fileName?: string;
1144
1142
  chunkSize?: number;
1145
1143
  };
@@ -1150,15 +1148,9 @@ type DeviceUploadWallpaperResponse = {
1150
1148
  message?: string;
1151
1149
  };
1152
1150
 
1153
- type Pro2NftImage = {
1154
- width: number;
1155
- height: number;
1156
- rgba: Uint8Array | ArrayBuffer;
1157
- };
1158
-
1159
1151
  type DeviceUploadNftParams = {
1160
- image: Pro2NftImage;
1161
- thumbnail: Pro2NftImage;
1152
+ imageJpegBase64: string;
1153
+ thumbnailJpegBase64: string;
1162
1154
  title: string;
1163
1155
  subtitle: string;
1164
1156
  timestampMs?: number;
@@ -1195,7 +1187,7 @@ declare function deviceGetOnboardingStatus(connectId: string, params?: CommonPar
1195
1187
  declare function deviceUploadWallpaper(connectId: string, params: CommonParams & DeviceUploadWallpaperParams): Response<DeviceUploadWallpaperResponse>;
1196
1188
  declare function deviceUploadNft(connectId: string, params: CommonParams & DeviceUploadNftParams): Response<DeviceUploadNftResponse>;
1197
1189
  declare function uploadPortfolio(connectId: string, params: {
1198
- packageBytes: ArrayBuffer | Uint8Array | Blob;
1190
+ packageBase64: string;
1199
1191
  timeoutMs?: number | string;
1200
1192
  }): Response<FileInfo & {
1201
1193
  portfolioUpdated: true;