@onekeyfe/hd-core 1.2.0-alpha.40 → 1.2.0-alpha.41
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__/AllNetworkGetAddressBase.tracing.test.ts +0 -78
- package/__tests__/DeviceEventRegistration.test.ts +0 -6
- package/__tests__/connectSettings.test.ts +47 -5
- package/__tests__/firmware-update/check-all-firmware-release.test.ts +175 -0
- package/__tests__/firmware-update/firmware-artifact-source.test.ts +119 -0
- package/__tests__/firmware-update/firmware-host-binding.test.ts +70 -0
- package/__tests__/firmware-update/firmware-preparation-error.test.ts +27 -0
- package/__tests__/firmware-update/firmware-update-capabilities.test.ts +13 -0
- package/__tests__/firmware-update/firmware-update-plan.test.ts +593 -0
- package/__tests__/firmware-update/firmware-update-prepared-plan.test.ts +213 -0
- package/__tests__/firmware-update/firmware-update-v2-download-before-boot.test.ts +59 -31
- package/__tests__/firmware-update/firmware-update-v3-reconnect.test.ts +58 -0
- package/__tests__/firmware-update/firmware-upload-source.test.ts +70 -0
- package/__tests__/get-device-state.test.ts +12 -132
- package/__tests__/homescreen.test.ts +1 -41
- package/__tests__/logBlockEvent.test.ts +1 -1
- package/__tests__/open-wallet-session.test.ts +18 -259
- package/__tests__/protocol-v2-unlock-policy.test.ts +35 -86
- package/__tests__/protocol-v2.test.ts +632 -333
- package/__tests__/public-pro2-api-boundary.test.ts +0 -1
- package/dist/api/BaseMethod.d.ts +1 -3
- package/dist/api/BaseMethod.d.ts.map +1 -1
- package/dist/api/CheckAllFirmwareRelease.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV2.d.ts +11 -0
- package/dist/api/FirmwareUpdateV2.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV3.d.ts +7 -3
- package/dist/api/FirmwareUpdateV3.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV4.d.ts +22 -5
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
- package/dist/api/GetPassphraseState.d.ts.map +1 -1
- package/dist/api/OpenWalletSession.d.ts.map +1 -1
- package/dist/api/allnetwork/AllNetworkGetAddressBase.d.ts.map +1 -1
- package/dist/api/device/DeviceUpdateBootloader.d.ts +5 -1
- package/dist/api/device/DeviceUpdateBootloader.d.ts.map +1 -1
- package/dist/api/firmware/FirmwareArtifactSource.d.ts +25 -0
- package/dist/api/firmware/FirmwareArtifactSource.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareHostBinding.d.ts +6 -0
- package/dist/api/firmware/FirmwareHostBinding.d.ts.map +1 -0
- package/dist/api/firmware/FirmwarePreparationError.d.ts +3 -0
- package/dist/api/firmware/FirmwarePreparationError.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts +8 -0
- package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts.map +1 -1
- package/dist/api/firmware/FirmwareUpdateCapabilities.d.ts +3 -0
- package/dist/api/firmware/FirmwareUpdateCapabilities.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareUpdatePlan.d.ts +25 -0
- package/dist/api/firmware/FirmwareUpdatePlan.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts +30 -0
- package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts.map +1 -0
- package/dist/api/firmware/getBinary.d.ts +7 -0
- package/dist/api/firmware/getBinary.d.ts.map +1 -1
- package/dist/api/firmware/progressThrottle.d.ts +3 -0
- package/dist/api/firmware/progressThrottle.d.ts.map +1 -0
- package/dist/api/firmware/updateBootloader.d.ts +2 -0
- package/dist/api/firmware/updateBootloader.d.ts.map +1 -1
- package/dist/api/firmware/uploadFirmware.d.ts +9 -1
- package/dist/api/firmware/uploadFirmware.d.ts.map +1 -1
- package/dist/api/helpers/protocolV2FileWrite.d.ts +0 -2
- package/dist/api/helpers/protocolV2FileWrite.d.ts.map +1 -1
- package/dist/api/index.d.ts +0 -1
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/protocol-v2/ProtocolInfoRequest.d.ts.map +1 -1
- package/dist/api/stellar/StellarSignTransaction.d.ts +1 -1
- package/dist/core/deviceEventRegistration.d.ts +0 -2
- package/dist/core/deviceEventRegistration.d.ts.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/data-manager/DataManager.d.ts +1 -0
- package/dist/data-manager/DataManager.d.ts.map +1 -1
- package/dist/data-manager/connectSettings.d.ts.map +1 -1
- package/dist/device/Device.d.ts +4 -22
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/events/device.d.ts +0 -4
- package/dist/events/device.d.ts.map +1 -1
- package/dist/events/logBlockEvent.d.ts.map +1 -1
- package/dist/events/ui-request.d.ts +2 -27
- package/dist/events/ui-request.d.ts.map +1 -1
- package/dist/index.d.ts +181 -88
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3162 -1614
- package/dist/inject.d.ts.map +1 -1
- package/dist/lowLevelInject.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/features.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/lockedError.d.ts +2 -0
- package/dist/protocols/protocol-v2/lockedError.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/uiInteraction.d.ts +3 -3
- package/dist/protocols/protocol-v2/uiInteraction.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/unlockPolicy.d.ts +3 -1
- package/dist/protocols/protocol-v2/unlockPolicy.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/unlockRetry.d.ts +10 -0
- package/dist/protocols/protocol-v2/unlockRetry.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/walletSession.d.ts +1 -4
- package/dist/protocols/protocol-v2/walletSession.d.ts.map +1 -1
- package/dist/topLevelInject.d.ts.map +1 -1
- package/dist/types/api/checkAllFirmwareRelease.d.ts +4 -0
- package/dist/types/api/checkAllFirmwareRelease.d.ts.map +1 -1
- package/dist/types/api/deviceUpdateBootloader.d.ts +6 -0
- package/dist/types/api/deviceUpdateBootloader.d.ts.map +1 -1
- package/dist/types/api/export.d.ts +4 -1
- package/dist/types/api/export.d.ts.map +1 -1
- package/dist/types/api/firmwareUpdate.d.ts +69 -0
- package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
- package/dist/types/api/firmwareUpdateCapabilities.d.ts +9 -0
- package/dist/types/api/firmwareUpdateCapabilities.d.ts.map +1 -0
- package/dist/types/api/firmwareUpdatePlan.d.ts +28 -0
- package/dist/types/api/firmwareUpdatePlan.d.ts.map +1 -0
- package/dist/types/api/firmwareUpdatePreparedPlan.d.ts +42 -0
- package/dist/types/api/firmwareUpdatePreparedPlan.d.ts.map +1 -0
- package/dist/types/api/index.d.ts +10 -3
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/protocolV2.d.ts +0 -3
- package/dist/types/api/protocolV2.d.ts.map +1 -1
- package/dist/types/settings.d.ts +13 -0
- package/dist/types/settings.d.ts.map +1 -1
- package/dist/utils/deviceFeaturesUtils.d.ts +0 -2
- package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
- package/dist/utils/homescreen.d.ts +0 -4
- package/dist/utils/homescreen.d.ts.map +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/patch.d.ts +1 -1
- package/dist/utils/patch.d.ts.map +1 -1
- package/dist/utils/pro2Wallpaper.d.ts +0 -10
- package/dist/utils/pro2Wallpaper.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/BaseMethod.ts +10 -8
- package/src/api/CheckAllFirmwareRelease.ts +51 -6
- package/src/api/FirmwareUpdateV2.ts +298 -120
- package/src/api/FirmwareUpdateV3.ts +263 -57
- package/src/api/FirmwareUpdateV4.ts +748 -281
- package/src/api/GetPassphraseState.ts +1 -7
- package/src/api/OpenWalletSession.ts +17 -54
- package/src/api/allnetwork/AllNetworkGetAddressBase.ts +11 -32
- package/src/api/device/DeviceUnlock.ts +1 -1
- package/src/api/device/DeviceUpdateBootloader.ts +122 -6
- package/src/api/firmware/FirmwareArtifactSource.ts +278 -0
- package/src/api/firmware/FirmwareHostBinding.ts +100 -0
- package/src/api/firmware/FirmwarePreparationError.ts +12 -0
- package/src/api/firmware/FirmwareUpdateBaseMethod.ts +57 -0
- package/src/api/firmware/FirmwareUpdateCapabilities.ts +9 -0
- package/src/api/firmware/FirmwareUpdatePlan.ts +745 -0
- package/src/api/firmware/FirmwareUpdatePreparedPlan.ts +392 -0
- package/src/api/firmware/progressThrottle.ts +44 -0
- package/src/api/firmware/updateBootloader.ts +19 -4
- package/src/api/firmware/uploadFirmware.ts +140 -22
- package/src/api/helpers/protocolV2FileWrite.ts +4 -11
- package/src/api/index.ts +0 -1
- package/src/api/protocol-v2/ProtocolInfoRequest.ts +1 -3
- package/src/core/deviceEventRegistration.ts +0 -4
- package/src/core/index.ts +75 -118
- package/src/data/messages/messages-protocol-v2.json +0 -10
- package/src/data-manager/DataManager.ts +33 -33
- package/src/data-manager/connectSettings.ts +11 -0
- package/src/device/Device.ts +21 -193
- package/src/events/device.ts +0 -4
- package/src/events/logBlockEvent.ts +0 -1
- package/src/events/ui-request.ts +2 -32
- package/src/index.ts +5 -0
- package/src/inject.ts +22 -3
- package/src/lowLevelInject.ts +5 -1
- package/src/protocols/protocol-v2/features.ts +2 -9
- package/src/protocols/protocol-v2/lockedError.ts +10 -0
- package/src/protocols/protocol-v2/uiInteraction.ts +5 -31
- package/src/protocols/protocol-v2/unlockPolicy.ts +105 -1
- package/src/protocols/protocol-v2/unlockRetry.ts +109 -0
- package/src/protocols/protocol-v2/walletSession.ts +18 -93
- package/src/topLevelInject.ts +5 -1
- package/src/types/api/checkAllFirmwareRelease.ts +4 -0
- package/src/types/api/deviceUpdateBootloader.ts +6 -0
- package/src/types/api/export.ts +18 -0
- package/src/types/api/firmwareUpdate.ts +76 -0
- package/src/types/api/firmwareUpdateCapabilities.ts +9 -0
- package/src/types/api/firmwareUpdatePlan.ts +38 -0
- package/src/types/api/firmwareUpdatePreparedPlan.ts +53 -0
- package/src/types/api/index.ts +14 -2
- package/src/types/api/protocolV2.ts +0 -13
- package/src/types/settings.ts +13 -0
- package/src/utils/deviceFeaturesUtils.ts +0 -4
- package/src/utils/homescreen.ts +6 -32
- package/src/utils/index.ts +1 -6
- package/src/utils/pro2Wallpaper.ts +8 -35
- package/__tests__/deviceUploadNft.test.ts +0 -187
- package/__tests__/pro2Nft.test.ts +0 -108
- package/__tests__/protocol-v2-ui-lifecycle.test.ts +0 -56
- package/__tests__/uiProgressThrottle.test.ts +0 -74
- package/dist/api/protocol-v2/DeviceUploadNft.d.ts +0 -30
- package/dist/api/protocol-v2/DeviceUploadNft.d.ts.map +0 -1
- package/dist/protocols/protocol-v2/unlockPolicyRunner.d.ts +0 -22
- package/dist/protocols/protocol-v2/unlockPolicyRunner.d.ts.map +0 -1
- package/dist/utils/pro2Nft.d.ts +0 -29
- package/dist/utils/pro2Nft.d.ts.map +0 -1
- package/dist/utils/uiProgressThrottle.d.ts +0 -3
- package/dist/utils/uiProgressThrottle.d.ts.map +0 -1
- package/src/api/protocol-v2/DeviceUploadNft.ts +0 -166
- package/src/protocols/protocol-v2/unlockPolicyRunner.ts +0 -117
- package/src/utils/pro2Nft.ts +0 -91
- package/src/utils/uiProgressThrottle.ts +0 -63
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
import DeviceUploadNft from '../src/api/protocol-v2/DeviceUploadNft';
|
|
2
|
-
|
|
3
|
-
jest.mock('../src/data/config', () => ({
|
|
4
|
-
getSDKVersion: jest.fn(() => '1.0.0'),
|
|
5
|
-
DEFAULT_DOMAIN: 'https://jssdk.onekey.so/1.0.0/',
|
|
6
|
-
}));
|
|
7
|
-
|
|
8
|
-
const createRgba = (width: number, height: number) => {
|
|
9
|
-
const data = new Uint8Array(width * height * 4);
|
|
10
|
-
for (let index = 3; index < data.length; index += 4) data[index] = 0xff;
|
|
11
|
-
return data;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const createMethod = ({
|
|
15
|
-
typedCall,
|
|
16
|
-
supportedMessages = [60805, 61500],
|
|
17
|
-
useFullBundle = false,
|
|
18
|
-
}: {
|
|
19
|
-
typedCall: jest.Mock;
|
|
20
|
-
supportedMessages?: number[];
|
|
21
|
-
useFullBundle?: boolean;
|
|
22
|
-
}) => {
|
|
23
|
-
const method = new DeviceUploadNft({
|
|
24
|
-
id: 1,
|
|
25
|
-
payload: {
|
|
26
|
-
method: 'deviceUploadNft',
|
|
27
|
-
image: { width: 540, height: 540, rgba: createRgba(540, 540) },
|
|
28
|
-
thumbnail: { width: 263, height: 263, rgba: createRgba(263, 263) },
|
|
29
|
-
title: 'CryptoPunk #3100',
|
|
30
|
-
subtitle: 'CryptoPunks',
|
|
31
|
-
timestampMs: 1_760_000_000_000,
|
|
32
|
-
chunkSize: 2048,
|
|
33
|
-
paceMs: 0,
|
|
34
|
-
},
|
|
35
|
-
});
|
|
36
|
-
(method as any).device = {
|
|
37
|
-
commands: { typedCall },
|
|
38
|
-
ensureProtocolV2RuntimeContext: jest.fn(() =>
|
|
39
|
-
Promise.resolve({
|
|
40
|
-
version: 2,
|
|
41
|
-
build_fingerprint: 'application__1.0.0__test__DEV__DEBUG',
|
|
42
|
-
supported_messages: supportedMessages,
|
|
43
|
-
})
|
|
44
|
-
),
|
|
45
|
-
getCurrentFirmwareType: jest.fn(),
|
|
46
|
-
};
|
|
47
|
-
method.postMessage = jest.fn();
|
|
48
|
-
|
|
49
|
-
if (useFullBundle) {
|
|
50
|
-
method.init();
|
|
51
|
-
} else {
|
|
52
|
-
(method as any).params = { chunkSize: 2048, paceMs: 0, timeoutMs: 15_000 };
|
|
53
|
-
(method as any).bundle = {
|
|
54
|
-
basename: 'nft-deadbeef-1760000000000',
|
|
55
|
-
image: new Uint8Array([1]),
|
|
56
|
-
thumbnail: new Uint8Array([2]),
|
|
57
|
-
metadata: new TextEncoder().encode('{"title":"NFT","subtitle":""}'),
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return method;
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
const fileWriteSuccess = (params: { file: { offset: number; data: Uint8Array } }) => ({
|
|
65
|
-
message: {
|
|
66
|
-
processed_byte: params.file.offset + params.file.data.byteLength,
|
|
67
|
-
},
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
describe('DeviceUploadNft', () => {
|
|
71
|
-
test('uploads the triplet in order without creating the firmware-owned directory', async () => {
|
|
72
|
-
const typedCall = jest.fn((request: string, _response: string, params: any) => {
|
|
73
|
-
if (request === 'FilesystemFileWrite') return fileWriteSuccess(params);
|
|
74
|
-
if (request === 'NftUpdate') return { message: { message: 'NFT updated' } };
|
|
75
|
-
throw new Error(`Unexpected request: ${request}`);
|
|
76
|
-
});
|
|
77
|
-
const method = createMethod({ typedCall, useFullBundle: true });
|
|
78
|
-
|
|
79
|
-
const result = await method.run();
|
|
80
|
-
|
|
81
|
-
const requests = typedCall.mock.calls.map(call => call[0]);
|
|
82
|
-
expect(requests[0]).toBe('FilesystemFileWrite');
|
|
83
|
-
expect(requests).not.toContain('FilesystemDirMake');
|
|
84
|
-
expect(requests.at(-1)).toBe('NftUpdate');
|
|
85
|
-
const fileWrites = typedCall.mock.calls.filter(call => call[0] === 'FilesystemFileWrite');
|
|
86
|
-
const paths = fileWrites.map(call => call[2].file.path as string);
|
|
87
|
-
const imagePath = paths[0];
|
|
88
|
-
const thumbnailStart = paths.findIndex(path => path.endsWith('_m.bin'));
|
|
89
|
-
const metadataStart = paths.findIndex(path => path.endsWith('.json'));
|
|
90
|
-
expect(imagePath).toMatch(/^vol1:\/nft\/nft-[a-f0-9]{8}-1760000000000\.bin$/);
|
|
91
|
-
expect(thumbnailStart).toBeGreaterThan(0);
|
|
92
|
-
expect(metadataStart).toBeGreaterThan(thumbnailStart);
|
|
93
|
-
expect(new Set(paths.slice(0, thumbnailStart))).toEqual(new Set([imagePath]));
|
|
94
|
-
expect(new Set(paths.slice(thumbnailStart, metadataStart))).toEqual(
|
|
95
|
-
new Set([result.thumbnailPath])
|
|
96
|
-
);
|
|
97
|
-
expect(typedCall).toHaveBeenLastCalledWith(
|
|
98
|
-
'NftUpdate',
|
|
99
|
-
'Success',
|
|
100
|
-
{ file_name_no_ext: result.basename },
|
|
101
|
-
{ timeoutMs: 15_000 }
|
|
102
|
-
);
|
|
103
|
-
expect(result).toMatchObject({
|
|
104
|
-
nftUpdated: true,
|
|
105
|
-
message: 'NFT updated',
|
|
106
|
-
totalSize: 583_212 + 138_876 + 53,
|
|
107
|
-
});
|
|
108
|
-
expect(method.postMessage).toHaveBeenLastCalledWith({
|
|
109
|
-
event: 'UI_EVENT',
|
|
110
|
-
type: 'ui-device_progress',
|
|
111
|
-
payload: expect.objectContaining({
|
|
112
|
-
progress: 100,
|
|
113
|
-
transferredBytes: result.totalSize,
|
|
114
|
-
totalBytes: result.totalSize,
|
|
115
|
-
}),
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
test('retries one timed-out NftUpdate with the same basename', async () => {
|
|
120
|
-
const timeout = Object.assign(new Error('Protocol V2 response timeout'), {
|
|
121
|
-
code: 'response-timeout',
|
|
122
|
-
});
|
|
123
|
-
let updateCalls = 0;
|
|
124
|
-
const typedCall = jest.fn((request: string, _response: string, params: any) => {
|
|
125
|
-
if (request === 'FilesystemFileWrite') return fileWriteSuccess(params);
|
|
126
|
-
if (request === 'NftUpdate') {
|
|
127
|
-
updateCalls += 1;
|
|
128
|
-
if (updateCalls === 1) throw timeout;
|
|
129
|
-
return { message: { message: 'NFT updated' } };
|
|
130
|
-
}
|
|
131
|
-
throw new Error(`Unexpected request: ${request}`);
|
|
132
|
-
});
|
|
133
|
-
const method = createMethod({ typedCall });
|
|
134
|
-
|
|
135
|
-
await expect(method.run()).resolves.toMatchObject({ nftUpdated: true });
|
|
136
|
-
|
|
137
|
-
const updateRequests = typedCall.mock.calls.filter(call => call[0] === 'NftUpdate');
|
|
138
|
-
expect(updateRequests).toHaveLength(2);
|
|
139
|
-
expect(updateRequests[1]).toEqual(updateRequests[0]);
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
test('does not retry a non-timeout NftUpdate failure', async () => {
|
|
143
|
-
const typedCall = jest.fn((request: string, _response: string, params: any) => {
|
|
144
|
-
if (request === 'FilesystemFileWrite') return fileWriteSuccess(params);
|
|
145
|
-
if (request === 'NftUpdate') throw new Error('Invalid NFT metadata');
|
|
146
|
-
throw new Error(`Unexpected request: ${request}`);
|
|
147
|
-
});
|
|
148
|
-
const method = createMethod({ typedCall });
|
|
149
|
-
|
|
150
|
-
await expect(method.run()).rejects.toThrow('Invalid NFT metadata');
|
|
151
|
-
expect(typedCall.mock.calls.filter(call => call[0] === 'NftUpdate')).toHaveLength(1);
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
test('propagates a second NftUpdate timeout after one retry', async () => {
|
|
155
|
-
const timeout = Object.assign(new Error('Protocol V2 response timeout'), {
|
|
156
|
-
code: 'response-timeout',
|
|
157
|
-
});
|
|
158
|
-
const typedCall = jest.fn((request: string, _response: string, params: any) => {
|
|
159
|
-
if (request === 'FilesystemFileWrite') return fileWriteSuccess(params);
|
|
160
|
-
if (request === 'NftUpdate') throw timeout;
|
|
161
|
-
throw new Error(`Unexpected request: ${request}`);
|
|
162
|
-
});
|
|
163
|
-
const method = createMethod({ typedCall });
|
|
164
|
-
|
|
165
|
-
await expect(method.run()).rejects.toBe(timeout);
|
|
166
|
-
expect(typedCall.mock.calls.filter(call => call[0] === 'NftUpdate')).toHaveLength(2);
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
test('does not publish when a file write fails', async () => {
|
|
170
|
-
const typedCall = jest.fn((request: string) => {
|
|
171
|
-
if (request === 'FilesystemFileWrite') throw new Error('Filesystem full');
|
|
172
|
-
throw new Error(`Unexpected request: ${request}`);
|
|
173
|
-
});
|
|
174
|
-
const method = createMethod({ typedCall });
|
|
175
|
-
|
|
176
|
-
await expect(method.run()).rejects.toThrow('Filesystem full');
|
|
177
|
-
expect(typedCall.mock.calls.some(call => call[0] === 'NftUpdate')).toBe(false);
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
test('rejects unsupported firmware before writing files', async () => {
|
|
181
|
-
const typedCall = jest.fn();
|
|
182
|
-
const method = createMethod({ typedCall, supportedMessages: [60805] });
|
|
183
|
-
|
|
184
|
-
await expect(method.run()).rejects.toBeDefined();
|
|
185
|
-
expect(typedCall).not.toHaveBeenCalled();
|
|
186
|
-
});
|
|
187
|
-
});
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { blake2s } from '@noble/hashes/blake2s';
|
|
2
|
-
import { bytesToHex } from '@noble/hashes/utils';
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
PRO2_NFT_IMAGE_HEIGHT,
|
|
6
|
-
PRO2_NFT_IMAGE_WIDTH,
|
|
7
|
-
PRO2_NFT_THUMBNAIL_HEIGHT,
|
|
8
|
-
PRO2_NFT_THUMBNAIL_WIDTH,
|
|
9
|
-
buildPro2NftBundle,
|
|
10
|
-
} from '../src/utils/pro2Nft';
|
|
11
|
-
|
|
12
|
-
const rgba = (width: number, height: number, alpha = 0xff) => {
|
|
13
|
-
const data = new Uint8Array(width * height * 4);
|
|
14
|
-
for (let index = 3; index < data.length; index += 4) data[index] = alpha;
|
|
15
|
-
return data;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
describe('buildPro2NftBundle', () => {
|
|
19
|
-
test('builds the exact Pro2 RGB565 triplet and basename', () => {
|
|
20
|
-
const bundle = buildPro2NftBundle({
|
|
21
|
-
image: {
|
|
22
|
-
width: PRO2_NFT_IMAGE_WIDTH,
|
|
23
|
-
height: PRO2_NFT_IMAGE_HEIGHT,
|
|
24
|
-
rgba: rgba(PRO2_NFT_IMAGE_WIDTH, PRO2_NFT_IMAGE_HEIGHT),
|
|
25
|
-
},
|
|
26
|
-
thumbnail: {
|
|
27
|
-
width: PRO2_NFT_THUMBNAIL_WIDTH,
|
|
28
|
-
height: PRO2_NFT_THUMBNAIL_HEIGHT,
|
|
29
|
-
rgba: rgba(PRO2_NFT_THUMBNAIL_WIDTH, PRO2_NFT_THUMBNAIL_HEIGHT),
|
|
30
|
-
},
|
|
31
|
-
title: 'CryptoPunk #3100',
|
|
32
|
-
subtitle: 'CryptoPunks',
|
|
33
|
-
timestampMs: 1_760_000_000_000,
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
expect(bundle.image.byteLength).toBe(583_212);
|
|
37
|
-
expect(bundle.thumbnail.byteLength).toBe(138_876);
|
|
38
|
-
expect(Array.from(bundle.image.slice(0, 12))).toEqual([
|
|
39
|
-
0x19, 0x12, 0, 0, 28, 2, 28, 2, 56, 4, 0, 0,
|
|
40
|
-
]);
|
|
41
|
-
expect(Array.from(bundle.thumbnail.slice(0, 12))).toEqual([
|
|
42
|
-
0x19, 0x12, 0, 0, 7, 1, 7, 1, 16, 2, 0, 0,
|
|
43
|
-
]);
|
|
44
|
-
expect(new TextDecoder().decode(bundle.metadata)).toBe(
|
|
45
|
-
'{"title":"CryptoPunk #3100","subtitle":"CryptoPunks"}'
|
|
46
|
-
);
|
|
47
|
-
expect(bytesToHex(blake2s(bundle.image))).toBe(
|
|
48
|
-
'af4b5f8fe216cfd0ef4a9162a42b5c66a73466f2491066f66f756c4e28cc869e'
|
|
49
|
-
);
|
|
50
|
-
expect(bytesToHex(blake2s(bundle.thumbnail))).toBe(
|
|
51
|
-
'44591afae1163cc14651d77644501c6a110f96506889b825cab0351ff4de857d'
|
|
52
|
-
);
|
|
53
|
-
expect(bytesToHex(blake2s(bundle.metadata))).toBe(
|
|
54
|
-
'e30d4dc2cddd441c9f1438c783e05a623ccf76f2f6219d4281769dda1b3635b5'
|
|
55
|
-
);
|
|
56
|
-
expect(bundle.basename).toBe('nft-af4b5f8f-1760000000000');
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
test('composites transparent pixels onto black without an alpha plane', () => {
|
|
60
|
-
const image = rgba(PRO2_NFT_IMAGE_WIDTH, PRO2_NFT_IMAGE_HEIGHT);
|
|
61
|
-
image.set([255, 255, 255, 0], 0);
|
|
62
|
-
const bundle = buildPro2NftBundle({
|
|
63
|
-
image: { width: PRO2_NFT_IMAGE_WIDTH, height: PRO2_NFT_IMAGE_HEIGHT, rgba: image },
|
|
64
|
-
thumbnail: {
|
|
65
|
-
width: PRO2_NFT_THUMBNAIL_WIDTH,
|
|
66
|
-
height: PRO2_NFT_THUMBNAIL_HEIGHT,
|
|
67
|
-
rgba: rgba(PRO2_NFT_THUMBNAIL_WIDTH, PRO2_NFT_THUMBNAIL_HEIGHT, 0),
|
|
68
|
-
},
|
|
69
|
-
title: 'NFT',
|
|
70
|
-
subtitle: '',
|
|
71
|
-
timestampMs: 1,
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
expect(bundle.image[1]).toBe(0x12);
|
|
75
|
-
expect(Array.from(bundle.image.slice(12, 14))).toEqual([0, 0]);
|
|
76
|
-
expect(bundle.thumbnail.byteLength).toBe(138_876);
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
test('rejects invalid dimensions and metadata byte lengths', () => {
|
|
80
|
-
const validThumbnail = {
|
|
81
|
-
width: PRO2_NFT_THUMBNAIL_WIDTH,
|
|
82
|
-
height: PRO2_NFT_THUMBNAIL_HEIGHT,
|
|
83
|
-
rgba: rgba(PRO2_NFT_THUMBNAIL_WIDTH, PRO2_NFT_THUMBNAIL_HEIGHT),
|
|
84
|
-
};
|
|
85
|
-
expect(() =>
|
|
86
|
-
buildPro2NftBundle({
|
|
87
|
-
image: { width: 1, height: 1, rgba: new Uint8Array(4) },
|
|
88
|
-
thumbnail: validThumbnail,
|
|
89
|
-
title: 'NFT',
|
|
90
|
-
subtitle: '',
|
|
91
|
-
timestampMs: 1,
|
|
92
|
-
})
|
|
93
|
-
).toThrow('540x540');
|
|
94
|
-
expect(() =>
|
|
95
|
-
buildPro2NftBundle({
|
|
96
|
-
image: {
|
|
97
|
-
width: PRO2_NFT_IMAGE_WIDTH,
|
|
98
|
-
height: PRO2_NFT_IMAGE_HEIGHT,
|
|
99
|
-
rgba: rgba(PRO2_NFT_IMAGE_WIDTH, PRO2_NFT_IMAGE_HEIGHT),
|
|
100
|
-
},
|
|
101
|
-
thumbnail: validThumbnail,
|
|
102
|
-
title: 'a'.repeat(64),
|
|
103
|
-
subtitle: '',
|
|
104
|
-
timestampMs: 1,
|
|
105
|
-
})
|
|
106
|
-
).toThrow('1 to 63');
|
|
107
|
-
});
|
|
108
|
-
});
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { DeviceSessionPinType } from '@onekeyfe/hd-transport';
|
|
2
|
-
|
|
3
|
-
import { DEVICE } from '../src/events';
|
|
4
|
-
import { Device } from '../src/device/Device';
|
|
5
|
-
|
|
6
|
-
jest.mock('../src/data/config', () => ({
|
|
7
|
-
getSDKVersion: jest.fn(() => '1.0.0-test'),
|
|
8
|
-
DEFAULT_DOMAIN: 'https://example.com/',
|
|
9
|
-
}));
|
|
10
|
-
|
|
11
|
-
describe('Protocol V2 UI interaction lifecycle', () => {
|
|
12
|
-
test('emits a matching PIN phase completion after DeviceSessionAskPin succeeds', async () => {
|
|
13
|
-
const device = new Device({ id: 'connect-1' } as any);
|
|
14
|
-
device.isProtocolV2 = jest.fn(() => true);
|
|
15
|
-
device.updateProtocolV2Status = jest.fn(() => undefined as any);
|
|
16
|
-
device.commands = {
|
|
17
|
-
typedCall: jest.fn().mockResolvedValue({
|
|
18
|
-
message: { unlocked: true },
|
|
19
|
-
}),
|
|
20
|
-
} as any;
|
|
21
|
-
device.beginProtocolV2UiInteraction();
|
|
22
|
-
|
|
23
|
-
const starts: unknown[] = [];
|
|
24
|
-
const completions: unknown[] = [];
|
|
25
|
-
device.on(DEVICE.PIN_ON_DEVICE, (...args) => starts.push(args));
|
|
26
|
-
device.on(DEVICE.PIN_ON_DEVICE_COMPLETE, (...args) => completions.push(args));
|
|
27
|
-
|
|
28
|
-
await device.unlockDevice(DeviceSessionPinType.Main, {
|
|
29
|
-
source: 'unlock-coordinator',
|
|
30
|
-
reason: 'device-locked',
|
|
31
|
-
deviceOnly: true,
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
const startMetadata = (starts[0] as unknown[])[2] as Record<string, unknown>;
|
|
35
|
-
const completionMetadata = (completions[0] as unknown[])[1] as Record<string, unknown>;
|
|
36
|
-
expect(startMetadata.interaction).toMatchObject({
|
|
37
|
-
phase: 'pin',
|
|
38
|
-
transition: 'start',
|
|
39
|
-
protocol: 'V2',
|
|
40
|
-
});
|
|
41
|
-
expect(completionMetadata).toMatchObject({
|
|
42
|
-
interactionId: (startMetadata.interaction as { interactionId: string }).interactionId,
|
|
43
|
-
phaseId: (startMetadata.interaction as { phaseId: string }).phaseId,
|
|
44
|
-
phase: 'pin',
|
|
45
|
-
transition: 'complete',
|
|
46
|
-
outcome: 'succeeded',
|
|
47
|
-
protocol: 'V2',
|
|
48
|
-
});
|
|
49
|
-
expect(completionMetadata.sequence).toBeGreaterThan(
|
|
50
|
-
(startMetadata.interaction as { sequence: number }).sequence
|
|
51
|
-
);
|
|
52
|
-
expect(completionMetadata.phaseId).toBe(
|
|
53
|
-
(startMetadata.interaction as { phaseId: string }).phaseId
|
|
54
|
-
);
|
|
55
|
-
});
|
|
56
|
-
});
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { createUiMessage } from '../src/events';
|
|
2
|
-
import { UI_REQUEST } from '../src/events/ui-request';
|
|
3
|
-
import { createUiProgressMessageFilter } from '../src/utils/uiProgressThrottle';
|
|
4
|
-
|
|
5
|
-
import type { KnownDevice } from '../src/types';
|
|
6
|
-
|
|
7
|
-
describe('createUiProgressMessageFilter', () => {
|
|
8
|
-
let currentTime: number;
|
|
9
|
-
let shouldPostMessage: ReturnType<typeof createUiProgressMessageFilter>;
|
|
10
|
-
|
|
11
|
-
beforeEach(() => {
|
|
12
|
-
currentTime = 1_000;
|
|
13
|
-
shouldPostMessage = createUiProgressMessageFilter(250, () => currentTime);
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
const firmwareProgress = (
|
|
17
|
-
progress: number,
|
|
18
|
-
progressType: 'transferData' | 'installingFirmware' = 'transferData'
|
|
19
|
-
) =>
|
|
20
|
-
createUiMessage(UI_REQUEST.FIRMWARE_PROGRESS, {
|
|
21
|
-
device: {} as KnownDevice,
|
|
22
|
-
progress,
|
|
23
|
-
progressType,
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
test('limits firmware progress to one event per interval', () => {
|
|
27
|
-
expect(shouldPostMessage(firmwareProgress(1))).toBe(true);
|
|
28
|
-
|
|
29
|
-
currentTime += 100;
|
|
30
|
-
expect(shouldPostMessage(firmwareProgress(1))).toBe(false);
|
|
31
|
-
|
|
32
|
-
currentTime += 150;
|
|
33
|
-
expect(shouldPostMessage(firmwareProgress(1))).toBe(true);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
test('limits transfer and install progress independently', () => {
|
|
37
|
-
expect(shouldPostMessage(firmwareProgress(1, 'transferData'))).toBe(true);
|
|
38
|
-
expect(shouldPostMessage(firmwareProgress(1, 'installingFirmware'))).toBe(true);
|
|
39
|
-
|
|
40
|
-
currentTime += 10;
|
|
41
|
-
expect(shouldPostMessage(firmwareProgress(2, 'transferData'))).toBe(false);
|
|
42
|
-
expect(shouldPostMessage(firmwareProgress(2, 'installingFirmware'))).toBe(false);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
test('emits phase boundaries immediately and suppresses duplicate boundaries', () => {
|
|
46
|
-
expect(shouldPostMessage(firmwareProgress(0))).toBe(true);
|
|
47
|
-
expect(shouldPostMessage(firmwareProgress(0))).toBe(false);
|
|
48
|
-
|
|
49
|
-
currentTime += 10;
|
|
50
|
-
expect(shouldPostMessage(firmwareProgress(50))).toBe(false);
|
|
51
|
-
expect(shouldPostMessage(firmwareProgress(100))).toBe(true);
|
|
52
|
-
expect(shouldPostMessage(firmwareProgress(100))).toBe(false);
|
|
53
|
-
|
|
54
|
-
expect(shouldPostMessage(firmwareProgress(0))).toBe(true);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
test('treats decreasing progress as a new phase', () => {
|
|
58
|
-
expect(shouldPostMessage(firmwareProgress(80))).toBe(true);
|
|
59
|
-
|
|
60
|
-
currentTime += 10;
|
|
61
|
-
expect(shouldPostMessage(firmwareProgress(20))).toBe(true);
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
test('also limits device progress and leaves other UI events unchanged', () => {
|
|
65
|
-
const deviceProgress = (progress: number) =>
|
|
66
|
-
createUiMessage(UI_REQUEST.DEVICE_PROGRESS, { progress });
|
|
67
|
-
|
|
68
|
-
expect(shouldPostMessage(deviceProgress(1))).toBe(true);
|
|
69
|
-
currentTime += 10;
|
|
70
|
-
expect(shouldPostMessage(deviceProgress(2))).toBe(false);
|
|
71
|
-
|
|
72
|
-
expect(shouldPostMessage(createUiMessage(UI_REQUEST.CLOSE_UI_WINDOW))).toBe(true);
|
|
73
|
-
});
|
|
74
|
-
});
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { type Pro2NftImage } from '../../utils/pro2Nft';
|
|
2
|
-
import { BaseMethod } from '../BaseMethod';
|
|
3
|
-
export type DeviceUploadNftParams = {
|
|
4
|
-
image: Pro2NftImage;
|
|
5
|
-
thumbnail: Pro2NftImage;
|
|
6
|
-
title: string;
|
|
7
|
-
subtitle: string;
|
|
8
|
-
timestampMs?: number;
|
|
9
|
-
chunkSize?: number;
|
|
10
|
-
paceMs?: number;
|
|
11
|
-
timeoutMs?: number;
|
|
12
|
-
};
|
|
13
|
-
export type DeviceUploadNftResponse = {
|
|
14
|
-
basename: string;
|
|
15
|
-
imagePath: string;
|
|
16
|
-
thumbnailPath: string;
|
|
17
|
-
metadataPath: string;
|
|
18
|
-
totalSize: number;
|
|
19
|
-
nftUpdated: true;
|
|
20
|
-
message?: string;
|
|
21
|
-
};
|
|
22
|
-
export default class DeviceUploadNft extends BaseMethod<DeviceUploadNftParams> {
|
|
23
|
-
private bundle?;
|
|
24
|
-
getSupportedProtocols(): readonly ["V2"];
|
|
25
|
-
init(): void;
|
|
26
|
-
private assertCapabilities;
|
|
27
|
-
private updateNft;
|
|
28
|
-
run(): Promise<DeviceUploadNftResponse>;
|
|
29
|
-
}
|
|
30
|
-
//# sourceMappingURL=DeviceUploadNft.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DeviceUploadNft.d.ts","sourceRoot":"","sources":["../../../src/api/protocol-v2/DeviceUploadNft.ts"],"names":[],"mappings":"AAIA,OAAO,EAQL,KAAK,YAAY,EAElB,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;AAKF,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,UAAU,CAAC,qBAAqB,CAAC;IAC5E,OAAO,CAAC,MAAM,CAAC,CAAgB;IAE/B,qBAAqB;IAIrB,IAAI;YAkCU,kBAAkB;YAYlB,SAAS;IAcjB,GAAG,IAAI,OAAO,CAAC,uBAAuB,CAAC;CAuD9C"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { BaseMethod } from '../../api/BaseMethod';
|
|
2
|
-
import type { Device } from '../../device/Device';
|
|
3
|
-
import type { ProtocolV2UiInteractionCoordinator } from './uiInteraction';
|
|
4
|
-
export type ProtocolV2UnlockContext = {
|
|
5
|
-
preflightCompleted: boolean;
|
|
6
|
-
};
|
|
7
|
-
export declare const createProtocolV2UnlockContext: () => ProtocolV2UnlockContext;
|
|
8
|
-
type RunnableMethod = Pick<BaseMethod, 'run' | 'unlockPolicy' | 'useDevicePassphraseState' | 'protocolV2UiInteraction' | 'protocolV2UiMode' | 'params' | 'payload'> & {
|
|
9
|
-
name?: string;
|
|
10
|
-
protocolV2UnlockContext?: ProtocolV2UnlockContext;
|
|
11
|
-
};
|
|
12
|
-
type UiInteractionCoordinator = Pick<ProtocolV2UiInteractionCoordinator, 'enterMethodInteraction' | 'enterUnlockInteraction'>;
|
|
13
|
-
type RunMethodWithUnlockPolicyOptions<T> = {
|
|
14
|
-
context?: ProtocolV2UnlockContext;
|
|
15
|
-
uiCoordinator?: UiInteractionCoordinator;
|
|
16
|
-
afterStatusBeforeUnlock?: () => void | Promise<void>;
|
|
17
|
-
prepare?: () => Promise<void>;
|
|
18
|
-
run?: () => Promise<T>;
|
|
19
|
-
};
|
|
20
|
-
export declare function runMethodWithUnlockPolicy<T = unknown>(method: RunnableMethod, device: Device, options?: RunMethodWithUnlockPolicyOptions<T>): Promise<T>;
|
|
21
|
-
export {};
|
|
22
|
-
//# sourceMappingURL=unlockPolicyRunner.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unlockPolicyRunner.d.ts","sourceRoot":"","sources":["../../../src/protocols/protocol-v2/unlockPolicyRunner.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAElD,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,iBAAiB,CAAC;AAI1E,MAAM,MAAM,uBAAuB,GAAG;IACpC,kBAAkB,EAAE,OAAO,CAAC;CAC7B,CAAC;AAEF,eAAO,MAAM,6BAA6B,QAAO,uBAE/C,CAAC;AAEH,KAAK,cAAc,GAAG,IAAI,CACxB,UAAU,EACR,KAAK,GACL,cAAc,GACd,0BAA0B,GAC1B,yBAAyB,GACzB,kBAAkB,GAClB,QAAQ,GACR,SAAS,CACZ,GAAG;IACF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uBAAuB,CAAC,EAAE,uBAAuB,CAAC;CACnD,CAAC;AAEF,KAAK,wBAAwB,GAAG,IAAI,CAClC,kCAAkC,EAClC,wBAAwB,GAAG,wBAAwB,CACpD,CAAC;AAEF,KAAK,gCAAgC,CAAC,CAAC,IAAI;IACzC,OAAO,CAAC,EAAE,uBAAuB,CAAC;IAClC,aAAa,CAAC,EAAE,wBAAwB,CAAC;IACzC,uBAAuB,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrD,OAAO,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,GAAG,CAAC,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,CAAC;CACxB,CAAC;AAEF,wBAAsB,yBAAyB,CAAC,CAAC,GAAG,OAAO,EACzD,MAAM,EAAE,cAAc,EACtB,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,gCAAgC,CAAC,CAAC,CAAM,GAChD,OAAO,CAAC,CAAC,CAAC,CAgEZ"}
|
package/dist/utils/pro2Nft.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export declare const PRO2_NFT_IMAGE_WIDTH = 540;
|
|
2
|
-
export declare const PRO2_NFT_IMAGE_HEIGHT = 540;
|
|
3
|
-
export declare const PRO2_NFT_THUMBNAIL_WIDTH = 263;
|
|
4
|
-
export declare const PRO2_NFT_THUMBNAIL_HEIGHT = 263;
|
|
5
|
-
export declare const PRO2_NFT_DIRECTORY = "vol1:/nft";
|
|
6
|
-
export declare const PRO2_NFT_DEFAULT_CHUNK_SIZE = 512;
|
|
7
|
-
export declare const PRO2_NFT_DEFAULT_PACE_MS = 20;
|
|
8
|
-
export declare const PRO2_NFT_DEFAULT_TIMEOUT_MS = 15000;
|
|
9
|
-
export declare const PRO2_NFT_MIN_CHUNK_SIZE = 64;
|
|
10
|
-
export declare const PRO2_NFT_MAX_CHUNK_SIZE = 2048;
|
|
11
|
-
export type Pro2NftImage = {
|
|
12
|
-
width: number;
|
|
13
|
-
height: number;
|
|
14
|
-
rgba: Uint8Array | ArrayBuffer;
|
|
15
|
-
};
|
|
16
|
-
export type Pro2NftBundle = {
|
|
17
|
-
basename: string;
|
|
18
|
-
image: Uint8Array;
|
|
19
|
-
thumbnail: Uint8Array;
|
|
20
|
-
metadata: Uint8Array;
|
|
21
|
-
};
|
|
22
|
-
export declare function buildPro2NftBundle(options: {
|
|
23
|
-
image: Pro2NftImage;
|
|
24
|
-
thumbnail: Pro2NftImage;
|
|
25
|
-
title: string;
|
|
26
|
-
subtitle: string;
|
|
27
|
-
timestampMs: number;
|
|
28
|
-
}): Pro2NftBundle;
|
|
29
|
-
//# sourceMappingURL=pro2Nft.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pro2Nft.d.ts","sourceRoot":"","sources":["../../src/utils/pro2Nft.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,oBAAoB,MAAM,CAAC;AACxC,eAAO,MAAM,qBAAqB,MAAM,CAAC;AACzC,eAAO,MAAM,wBAAwB,MAAM,CAAC;AAC5C,eAAO,MAAM,yBAAyB,MAAM,CAAC;AAC7C,eAAO,MAAM,kBAAkB,cAAc,CAAC;AAC9C,eAAO,MAAM,2BAA2B,MAAM,CAAC;AAC/C,eAAO,MAAM,wBAAwB,KAAK,CAAC;AAC3C,eAAO,MAAM,2BAA2B,QAAS,CAAC;AAClD,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAC1C,eAAO,MAAM,uBAAuB,OAAO,CAAC;AAE5C,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,UAAU,GAAG,WAAW,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,UAAU,CAAC;IAClB,SAAS,EAAE,UAAU,CAAC;IACtB,QAAQ,EAAE,UAAU,CAAC;CACtB,CAAC;AAsBF,wBAAgB,kBAAkB,CAAC,OAAO,EAAE;IAC1C,KAAK,EAAE,YAAY,CAAC;IACpB,SAAS,EAAE,YAAY,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;CACrB,GAAG,aAAa,CAkChB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"uiProgressThrottle.d.ts","sourceRoot":"","sources":["../../src/utils/uiProgressThrottle.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAiB7C,eAAO,MAAM,6BAA6B,yDAMvB,WAAW,YAqC7B,CAAC"}
|