@bota.dev/web-app-sdk 2.0.0-beta.0

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 (54) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +517 -0
  3. package/dist/capabilities.d.ts +8 -0
  4. package/dist/capabilities.js +21 -0
  5. package/dist/client.d.ts +39 -0
  6. package/dist/client.js +153 -0
  7. package/dist/controlManager.d.ts +38 -0
  8. package/dist/controlManager.js +344 -0
  9. package/dist/core.d.ts +698 -0
  10. package/dist/core.js +13 -0
  11. package/dist/deviceManager.d.ts +52 -0
  12. package/dist/deviceManager.js +491 -0
  13. package/dist/encryptedUploadV2Host.d.ts +239 -0
  14. package/dist/encryptedUploadV2Host.js +2136 -0
  15. package/dist/errors.d.ts +24 -0
  16. package/dist/errors.js +230 -0
  17. package/dist/gatt.d.ts +39 -0
  18. package/dist/gatt.js +57 -0
  19. package/dist/generated/bota_device_sdk_core.d.ts +202 -0
  20. package/dist/generated/bota_device_sdk_core.js +1025 -0
  21. package/dist/generated/bota_device_sdk_core_bg.wasm +0 -0
  22. package/dist/index.d.ts +13 -0
  23. package/dist/index.js +2 -0
  24. package/dist/indexedDbWorkflowStore.d.ts +52 -0
  25. package/dist/indexedDbWorkflowStore.js +763 -0
  26. package/dist/logManager.d.ts +24 -0
  27. package/dist/logManager.js +205 -0
  28. package/dist/models.d.ts +217 -0
  29. package/dist/models.js +1 -0
  30. package/dist/opfsBlobStore.d.ts +12 -0
  31. package/dist/opfsBlobStore.js +250 -0
  32. package/dist/otaManager.d.ts +49 -0
  33. package/dist/otaManager.js +951 -0
  34. package/dist/providerCancellation.d.ts +2 -0
  35. package/dist/providerCancellation.js +23 -0
  36. package/dist/providers.d.ts +138 -0
  37. package/dist/providers.js +1 -0
  38. package/dist/provisioningManager.d.ts +48 -0
  39. package/dist/provisioningManager.js +753 -0
  40. package/dist/recordingManager.d.ts +53 -0
  41. package/dist/recordingManager.js +1397 -0
  42. package/dist/storage.d.ts +103 -0
  43. package/dist/storage.js +60 -0
  44. package/dist/transport.d.ts +33 -0
  45. package/dist/transport.js +8 -0
  46. package/dist/wasmCore.d.ts +3 -0
  47. package/dist/wasmCore.js +1651 -0
  48. package/dist/webBluetoothTransport.d.ts +23 -0
  49. package/dist/webBluetoothTransport.js +369 -0
  50. package/dist/wifiManager.d.ts +54 -0
  51. package/dist/wifiManager.js +528 -0
  52. package/dist/workflowRuntime.d.ts +115 -0
  53. package/dist/workflowRuntime.js +1508 -0
  54. package/package.json +46 -0
package/dist/core.d.ts ADDED
@@ -0,0 +1,698 @@
1
+ import type { DeviceStatus, EncryptedUploadV2Capabilities } from './models.ts';
2
+ export type CoreOperation = 'validate' | 'decode' | 'encode' | 'discover' | 'connect' | 'reconnect' | 'provision' | 'transfer_recording' | 'upload' | 'update_firmware' | 'read_device_logs' | 'factory_reset' | 'unknown';
3
+ export interface CoreConnectionInput {
4
+ expectedSerialNumber: string;
5
+ peripheralId: string;
6
+ name: string | null;
7
+ cancellationId: Uint8Array;
8
+ }
9
+ export interface CoreReconnectHint {
10
+ storedPeripheralId: string | null;
11
+ advertisedAddress: string | null;
12
+ storedName: string | null;
13
+ scanTimeoutMs: bigint;
14
+ connectionTimeoutMs: bigint;
15
+ }
16
+ export interface CoreReconnectInput {
17
+ expectedSerialNumber: string;
18
+ hint: CoreReconnectHint;
19
+ cancellationId: Uint8Array;
20
+ }
21
+ export interface CoreProvisioningInput {
22
+ serialNumber: string;
23
+ materialId: string;
24
+ cancellationId: Uint8Array;
25
+ }
26
+ export interface CoreRecordingTransferInput {
27
+ serialNumber: string;
28
+ recordingUuid: string;
29
+ sinkId: string;
30
+ totalUnits: bigint;
31
+ cancellationId: Uint8Array;
32
+ }
33
+ export interface CoreEncryptedUploadV2Input {
34
+ serialNumber: string;
35
+ recordingUuid: string;
36
+ recordingGeneration: number;
37
+ storageFormat: number;
38
+ uploadSessionId: string;
39
+ ownerRevision: number;
40
+ transportSessionId: bigint;
41
+ materialId: string;
42
+ sinkId: string;
43
+ policy: 'legacy_allowed' | 'v2_preferred' | 'v2_required';
44
+ capabilities: EncryptedUploadV2Capabilities;
45
+ windowPackets: number;
46
+ dataPayloadBytes: number;
47
+ ciphertextLength: bigint;
48
+ ciphertextSha256: Uint8Array;
49
+ cancellationId: Uint8Array;
50
+ }
51
+ export interface CoreFirmwareUpdateInput {
52
+ serialNumber: string;
53
+ version: string;
54
+ sizeBytes: number;
55
+ crc32: number;
56
+ downloadId: bigint;
57
+ reconnectHint: CoreReconnectHint;
58
+ cancellationId: Uint8Array;
59
+ }
60
+ export interface CoreDeviceLogsInput {
61
+ serialNumber: string;
62
+ cancellationId: Uint8Array;
63
+ }
64
+ export interface CoreDeviceCandidate {
65
+ peripheralId: string;
66
+ name: string | null;
67
+ advertisedAddress: string | null;
68
+ rssi: number;
69
+ }
70
+ export type CoreWorkflowKind = 'discovery' | 'connection' | 'provisioning' | 'recording_transfer' | 'recording_upload' | 'firmware_update' | 'device_logs' | 'factory_reset';
71
+ export type CoreCheckpointPhase = 'pending' | 'connecting' | 'transferring' | 'uploading' | 'verifying' | 'reconnecting' | 'awaiting_receipt';
72
+ export interface CoreWorkflowCheckpoint {
73
+ workflow: CoreWorkflowKind;
74
+ operation: CoreOperation;
75
+ serialNumber: string;
76
+ recordingUuid: Uint8Array | null;
77
+ phase: CoreCheckpointPhase;
78
+ completedUnits: bigint;
79
+ retryCount: number;
80
+ lastSequence: number | null;
81
+ firmwareVersion: string | null;
82
+ }
83
+ export interface CoreEncryptedUploadV2Checkpoint {
84
+ serialNumber: string;
85
+ recordingUuid: Uint8Array;
86
+ recordingGeneration: number;
87
+ uploadSessionId: Uint8Array;
88
+ ownerRevision: number;
89
+ transportSessionId: bigint;
90
+ checkpointRevision: number;
91
+ nextCiphertextOffset: bigint;
92
+ prefixSha256: Uint8Array;
93
+ windowPackets: number;
94
+ dataPayloadBytes: number;
95
+ }
96
+ export interface CoreEncryptedUploadV2Evidence {
97
+ ciphertextLength: bigint;
98
+ ciphertextSha256: Uint8Array;
99
+ manifestLength: number;
100
+ manifestSha256: Uint8Array;
101
+ blockCount: number;
102
+ }
103
+ export type CoreNotification = {
104
+ kind: 'started';
105
+ operation: CoreOperation;
106
+ } | {
107
+ kind: 'connection_established';
108
+ serialNumber: string;
109
+ candidate: CoreDeviceCandidate;
110
+ mode: 'manual' | 'reconnect';
111
+ } | {
112
+ kind: 'progress';
113
+ operation: CoreOperation;
114
+ completedUnits: bigint;
115
+ totalUnits: bigint;
116
+ } | {
117
+ kind: 'retrying';
118
+ operation: CoreOperation;
119
+ attempt: number;
120
+ } | {
121
+ kind: 'firmware_progress';
122
+ phase: 'downloading' | 'awaiting_device' | 'transferring' | 'verifying' | 'rebooting' | 'reconnecting' | 'complete';
123
+ completedBytes: bigint;
124
+ totalBytes: bigint;
125
+ } | {
126
+ kind: 'device_log';
127
+ message: string;
128
+ isBacklog: boolean;
129
+ } | {
130
+ kind: 'recording_transfer_completed';
131
+ encrypted: boolean;
132
+ sha256: Uint8Array | null;
133
+ } | {
134
+ kind: 'encrypted_upload_v2_staged';
135
+ uploadSessionId: Uint8Array;
136
+ ownerRevision: number;
137
+ ciphertextLength: bigint;
138
+ ciphertextSha256: Uint8Array;
139
+ manifestLength: number;
140
+ manifestSha256: Uint8Array;
141
+ } | {
142
+ kind: 'completed';
143
+ operation: CoreOperation;
144
+ } | {
145
+ kind: 'cancelled';
146
+ operation: CoreOperation;
147
+ } | {
148
+ kind: 'failed';
149
+ error: unknown;
150
+ };
151
+ export type CoreEffect = {
152
+ kind: 'notify';
153
+ notification: CoreNotification;
154
+ } | {
155
+ kind: 'ble_start_scan';
156
+ allowDuplicates: boolean;
157
+ } | {
158
+ kind: 'ble_stop_scan';
159
+ } | {
160
+ kind: 'ble_connect';
161
+ peripheralId: string;
162
+ } | {
163
+ kind: 'ble_discover_services';
164
+ peripheralId: string;
165
+ } | {
166
+ kind: 'ble_disconnect';
167
+ peripheralId: string;
168
+ } | {
169
+ kind: 'ble_read';
170
+ serviceUuid: string;
171
+ characteristicUuid: string;
172
+ } | {
173
+ kind: 'ble_write';
174
+ serviceUuid: string;
175
+ characteristicUuid: string;
176
+ payload: Uint8Array;
177
+ withResponse: boolean;
178
+ } | {
179
+ kind: 'ble_subscribe';
180
+ serviceUuid: string;
181
+ characteristicUuid: string;
182
+ } | {
183
+ kind: 'ble_unsubscribe';
184
+ serviceUuid: string;
185
+ characteristicUuid: string;
186
+ } | {
187
+ kind: 'timer_schedule';
188
+ timerId: bigint;
189
+ delayMs: bigint;
190
+ } | {
191
+ kind: 'timer_cancel';
192
+ timerId: bigint;
193
+ } | {
194
+ kind: 'persistence_load_checkpoint';
195
+ } | {
196
+ kind: 'persistence_save_checkpoint';
197
+ checkpoint: CoreWorkflowCheckpoint;
198
+ } | {
199
+ kind: 'persistence_delete_checkpoint';
200
+ } | {
201
+ kind: 'persistence_save_connection_identity';
202
+ serialNumber: string;
203
+ candidate: CoreDeviceCandidate;
204
+ } | {
205
+ kind: 'host_material_prepare_provisioning';
206
+ materialId: string;
207
+ serialNumber: string;
208
+ nonce: Uint8Array;
209
+ devicePublicKey: Uint8Array;
210
+ } | {
211
+ kind: 'recording_sink_truncate';
212
+ sinkId: string;
213
+ completedUnits: bigint;
214
+ } | {
215
+ kind: 'recording_sink_append';
216
+ sinkId: string;
217
+ sequence: number;
218
+ payload: Uint8Array;
219
+ } | {
220
+ kind: 'recording_sink_finalize';
221
+ sinkId: string;
222
+ expectedCrc32: number | null;
223
+ } | {
224
+ kind: 'recording_sink_discard';
225
+ sinkId: string;
226
+ } | {
227
+ kind: 'network_download';
228
+ downloadId: bigint;
229
+ } | {
230
+ kind: 'progress';
231
+ completedUnits: bigint;
232
+ totalUnits: bigint;
233
+ } | {
234
+ kind: 'firmware_blob_read_chunk';
235
+ downloadId: bigint;
236
+ offset: bigint;
237
+ maxLength: number;
238
+ } | {
239
+ kind: 'encrypted_upload_v2_load_checkpoint';
240
+ serialNumber: string;
241
+ recordingUuid: Uint8Array;
242
+ recordingGeneration: number;
243
+ uploadSessionId: Uint8Array;
244
+ ownerRevision: number;
245
+ } | {
246
+ kind: 'encrypted_upload_v2_delete_checkpoint';
247
+ uploadSessionId: Uint8Array;
248
+ } | {
249
+ kind: 'encrypted_upload_v2_truncate_sink';
250
+ sinkId: string;
251
+ nextCiphertextOffset: bigint;
252
+ } | {
253
+ kind: 'encrypted_upload_v2_prepare_session';
254
+ materialId: string;
255
+ } | {
256
+ kind: 'encrypted_upload_v2_start_transfer';
257
+ serialNumber: string;
258
+ recordingUuid: Uint8Array;
259
+ recordingGeneration: number;
260
+ storageFormat: number;
261
+ uploadSessionId: Uint8Array;
262
+ ownerRevision: number;
263
+ transportSessionId: bigint;
264
+ materialId: string;
265
+ sinkId: string;
266
+ policy: CoreEncryptedUploadV2Input['policy'];
267
+ capabilities: EncryptedUploadV2Capabilities;
268
+ windowPackets: number;
269
+ dataPayloadBytes: number;
270
+ ciphertextLength: bigint;
271
+ ciphertextSha256: Uint8Array;
272
+ checkpoint: CoreEncryptedUploadV2Checkpoint | null;
273
+ authorizationSha256: Uint8Array;
274
+ } | {
275
+ kind: 'encrypted_upload_v2_repair_window';
276
+ missingSequences: number[];
277
+ } | {
278
+ kind: 'encrypted_upload_v2_save_checkpoint';
279
+ checkpoint: CoreEncryptedUploadV2Checkpoint;
280
+ } | {
281
+ kind: 'encrypted_upload_v2_acknowledge_window';
282
+ checkpoint: CoreEncryptedUploadV2Checkpoint;
283
+ } | {
284
+ kind: 'encrypted_upload_v2_stage_artifacts';
285
+ sinkId: string;
286
+ materialId: string;
287
+ evidence: CoreEncryptedUploadV2Evidence;
288
+ } | {
289
+ kind: 'encrypted_upload_v2_await_completion_receipt';
290
+ materialId: string;
291
+ evidence: CoreEncryptedUploadV2Evidence;
292
+ } | {
293
+ kind: 'encrypted_upload_v2_confirm_with_receipt';
294
+ materialId: string;
295
+ receiptSha256: Uint8Array;
296
+ } | {
297
+ kind: 'encrypted_upload_v2_abort';
298
+ materialId: string;
299
+ };
300
+ export interface CoreEffectEnvelope {
301
+ requestId: bigint;
302
+ operation: CoreOperation;
303
+ cancellationId: Uint8Array;
304
+ effect: CoreEffect;
305
+ }
306
+ interface CoreRequest {
307
+ requestId: bigint;
308
+ }
309
+ export type CoreHostEvent = (CoreRequest & {
310
+ kind: 'ble_scan_result';
311
+ candidate: CoreDeviceCandidate;
312
+ }) | (CoreRequest & {
313
+ kind: 'ble_scan_stopped';
314
+ }) | (CoreRequest & {
315
+ kind: 'ble_connected';
316
+ peripheralId: string;
317
+ }) | (CoreRequest & {
318
+ kind: 'ble_services_discovered';
319
+ peripheralId: string;
320
+ }) | (CoreRequest & {
321
+ kind: 'ble_subscribed';
322
+ characteristicUuid: string;
323
+ }) | (CoreRequest & {
324
+ kind: 'ble_disconnected';
325
+ peripheralId: string;
326
+ reasonCode: number | null;
327
+ }) | (CoreRequest & {
328
+ kind: 'ble_read_completed';
329
+ value: Uint8Array;
330
+ }) | (CoreRequest & {
331
+ kind: 'ble_write_completed';
332
+ }) | (CoreRequest & {
333
+ kind: 'ble_notification';
334
+ characteristicUuid: string;
335
+ value: Uint8Array;
336
+ }) | (CoreRequest & {
337
+ kind: 'ble_failed';
338
+ platformCode: number | null;
339
+ }) | (CoreRequest & {
340
+ kind: 'timer_fired';
341
+ timerId: bigint;
342
+ }) | (CoreRequest & {
343
+ kind: 'checkpoint_loaded';
344
+ checkpoint: CoreWorkflowCheckpoint | null;
345
+ }) | (CoreRequest & {
346
+ kind: 'checkpoint_saved';
347
+ }) | (CoreRequest & {
348
+ kind: 'connection_identity_saved';
349
+ }) | (CoreRequest & {
350
+ kind: 'persistence_failed';
351
+ platformCode: bigint | null;
352
+ }) | (CoreRequest & {
353
+ kind: 'provisioning_material_prepared';
354
+ apiEndpoint: Uint8Array;
355
+ deviceToken: Uint8Array;
356
+ mtu: number;
357
+ }) | (CoreRequest & {
358
+ kind: 'host_material_failed';
359
+ platformCode: bigint | null;
360
+ }) | (CoreRequest & {
361
+ kind: 'recording_sink_truncated';
362
+ }) | (CoreRequest & {
363
+ kind: 'recording_sink_append_completed';
364
+ durableUnits: bigint;
365
+ }) | (CoreRequest & {
366
+ kind: 'recording_sink_finalized';
367
+ durableUnits: bigint;
368
+ }) | (CoreRequest & {
369
+ kind: 'recording_sink_integrity_failed';
370
+ }) | (CoreRequest & {
371
+ kind: 'recording_sink_failed';
372
+ platformCode: bigint | null;
373
+ }) | (CoreRequest & {
374
+ kind: 'firmware_chunk_read';
375
+ downloadId: bigint;
376
+ offset: bigint;
377
+ bytes: Uint8Array;
378
+ }) | (CoreRequest & {
379
+ kind: 'firmware_blob_failed';
380
+ platformCode: bigint | null;
381
+ }) | (CoreRequest & {
382
+ kind: 'network_download_progress';
383
+ downloadId: bigint;
384
+ completedBytes: bigint;
385
+ totalBytes: bigint | null;
386
+ }) | (CoreRequest & {
387
+ kind: 'network_download_completed';
388
+ downloadId: bigint;
389
+ crc32: number;
390
+ }) | (CoreRequest & {
391
+ kind: 'network_failed';
392
+ transferId: bigint;
393
+ statusCode: number | null;
394
+ }) | (CoreRequest & {
395
+ kind: 'encrypted_upload_v2_checkpoint_loaded';
396
+ checkpoint: CoreEncryptedUploadV2Checkpoint | null;
397
+ }) | (CoreRequest & {
398
+ kind: 'encrypted_upload_v2_sink_truncated';
399
+ }) | (CoreRequest & {
400
+ kind: 'encrypted_upload_v2_session_prepared';
401
+ authorizationSha256: Uint8Array;
402
+ }) | (CoreRequest & {
403
+ kind: 'encrypted_upload_v2_transfer_started';
404
+ }) | (CoreRequest & {
405
+ kind: 'encrypted_upload_v2_resume_rejected';
406
+ }) | (CoreRequest & {
407
+ kind: 'encrypted_upload_v2_window_staged';
408
+ checkpoint: CoreEncryptedUploadV2Checkpoint;
409
+ missingSequences: number[];
410
+ }) | (CoreRequest & {
411
+ kind: 'encrypted_upload_v2_checkpoint_saved';
412
+ }) | (CoreRequest & {
413
+ kind: 'encrypted_upload_v2_window_acknowledged';
414
+ checkpoint: CoreEncryptedUploadV2Checkpoint;
415
+ }) | (CoreRequest & {
416
+ kind: 'encrypted_upload_v2_transfer_completed';
417
+ evidence: CoreEncryptedUploadV2Evidence;
418
+ }) | (CoreRequest & {
419
+ kind: 'encrypted_upload_v2_artifacts_staged';
420
+ }) | (CoreRequest & {
421
+ kind: 'encrypted_upload_v2_completion_receipt_accepted';
422
+ receiptSha256: Uint8Array;
423
+ }) | (CoreRequest & {
424
+ kind: 'encrypted_upload_v2_recording_confirmed';
425
+ }) | (CoreRequest & {
426
+ kind: 'encrypted_upload_v2_mixed_profile';
427
+ }) | (CoreRequest & {
428
+ kind: 'encrypted_upload_v2_failed';
429
+ error: unknown;
430
+ });
431
+ export type CoreWorkflowStatus = {
432
+ kind: 'idle';
433
+ } | {
434
+ kind: 'running';
435
+ operation: CoreOperation;
436
+ cancellationId: Uint8Array;
437
+ } | {
438
+ kind: 'completed';
439
+ operation: CoreOperation;
440
+ } | {
441
+ kind: 'cancelled';
442
+ operation: CoreOperation;
443
+ } | {
444
+ kind: 'failed';
445
+ error: unknown;
446
+ };
447
+ export interface CoreDeviceRecording {
448
+ uuid: string;
449
+ startedAtTimestampSeconds: number;
450
+ durationMilliseconds: bigint;
451
+ fileSizeBytes: bigint;
452
+ codec: 'pcm_16k' | 'pcm_8k' | 'opus_16k' | 'opus_8k' | 'unknown';
453
+ codecRaw?: number;
454
+ encrypted: boolean;
455
+ }
456
+ export type CoreConnectionType = 'wifi' | 'ble' | 'cellular' | 'unknown';
457
+ export interface CoreConnectionSettings {
458
+ enabledConnections: {
459
+ wifi: boolean;
460
+ cellular: boolean;
461
+ };
462
+ heartbeatEnabledConnections: {
463
+ wifi: boolean;
464
+ cellular: boolean;
465
+ };
466
+ uploadNetworkPreference: CoreConnectionType[];
467
+ powerManagement: {
468
+ cellularIdleTimeoutSeconds: number;
469
+ wifiIdleTimeoutSeconds: number;
470
+ };
471
+ streamingEnabled: boolean;
472
+ streamingFlushIntervalSeconds: number;
473
+ }
474
+ export interface CoreDecodedConnectionSettings extends CoreConnectionSettings {
475
+ supportedVersion: boolean;
476
+ }
477
+ export type CoreDeviceModel = 'pin' | 'pin_4g' | 'note';
478
+ export interface CoreOperationResult {
479
+ success: boolean;
480
+ error?: string;
481
+ errorRaw?: number;
482
+ }
483
+ export interface CoreWiFiStatusInfo {
484
+ status: 'idle' | 'connecting' | 'connected' | 'failed' | 'disconnected' | 'unknown';
485
+ statusRaw: number;
486
+ signalStrength?: number;
487
+ ssid?: string;
488
+ lastError?: string;
489
+ }
490
+ export interface CoreWiFiScanNetwork {
491
+ ssid: string;
492
+ quality: number;
493
+ isCurrent: boolean;
494
+ isOpen: boolean;
495
+ }
496
+ export type CoreWiFiScanUpdate = {
497
+ kind: 'pending';
498
+ statusRaw: number;
499
+ } | {
500
+ kind: 'done';
501
+ networks: CoreWiFiScanNetwork[];
502
+ currentSsid: string | null;
503
+ };
504
+ interface CoreEncryptedUploadV2Common {
505
+ flags: number;
506
+ transportSessionId: bigint;
507
+ }
508
+ interface CoreEncryptedUploadV2ResumeFrame extends CoreEncryptedUploadV2Common {
509
+ uploadSessionUuid: string;
510
+ recordingUuid: string;
511
+ recordingGeneration: number;
512
+ checkpointRevision: number;
513
+ nextCiphertextOffset: bigint;
514
+ prefixSha256: Uint8Array;
515
+ windowPackets: number;
516
+ dataPayloadBytes: number;
517
+ }
518
+ export type CoreEncryptedUploadV2TransferFrame = (CoreEncryptedUploadV2Common & {
519
+ kind: 'list';
520
+ }) | (CoreEncryptedUploadV2Common & {
521
+ kind: 'recording_entry';
522
+ recordingUuid: string;
523
+ recordingGeneration: number;
524
+ storageFormat: number;
525
+ completionState: number;
526
+ startedAt: bigint;
527
+ durationSeconds: number;
528
+ plaintextLength: bigint;
529
+ ciphertextLength: bigint;
530
+ ciphertextSha256: Uint8Array;
531
+ }) | (CoreEncryptedUploadV2Common & {
532
+ kind: 'recording_list_end';
533
+ count: number;
534
+ listRevision: number;
535
+ listSha256: Uint8Array;
536
+ }) | (CoreEncryptedUploadV2Common & {
537
+ kind: 'start';
538
+ uploadSessionUuid: string;
539
+ recordingUuid: string;
540
+ recordingGeneration: number;
541
+ authorizationSha256: Uint8Array;
542
+ checkpointRevision: number;
543
+ nextCiphertextOffset: bigint;
544
+ prefixSha256: Uint8Array;
545
+ windowPackets: number;
546
+ dataPayloadBytes: number;
547
+ }) | (CoreEncryptedUploadV2Common & {
548
+ kind: 'start_ack';
549
+ uploadSessionUuid: string;
550
+ recordingUuid: string;
551
+ recordingGeneration: number;
552
+ ciphertextLength: bigint;
553
+ ciphertextSha256: Uint8Array;
554
+ windowPackets: number;
555
+ dataPayloadBytes: number;
556
+ checkpointIntervalBlocks: number;
557
+ checkpointRevision: number;
558
+ nextCiphertextOffset: bigint;
559
+ prefixSha256: Uint8Array;
560
+ }) | (CoreEncryptedUploadV2Common & {
561
+ kind: 'data';
562
+ sequence: number;
563
+ offset: bigint;
564
+ data: Uint8Array;
565
+ }) | (CoreEncryptedUploadV2Common & {
566
+ kind: 'window_end';
567
+ windowIndex: number;
568
+ firstSequence: number;
569
+ lastSequence: number;
570
+ nextCiphertextOffset: bigint;
571
+ prefixSha256: Uint8Array;
572
+ checkpointRevision: number;
573
+ }) | (CoreEncryptedUploadV2Common & {
574
+ kind: 'window_ack';
575
+ windowIndex: number;
576
+ highestContiguousSequence: number;
577
+ nextCiphertextOffset: bigint;
578
+ prefixSha256: Uint8Array;
579
+ checkpointRevision: number;
580
+ missingSequences: number[];
581
+ }) | (CoreEncryptedUploadV2Common & {
582
+ kind: 'manifest_chunk';
583
+ totalManifestLength: number;
584
+ chunkOffset: number;
585
+ manifestSha256: Uint8Array;
586
+ chunk: Uint8Array;
587
+ }) | (CoreEncryptedUploadV2Common & {
588
+ kind: 'eof';
589
+ finalSequence: number;
590
+ blockCount: number;
591
+ ciphertextLength: bigint;
592
+ ciphertextSha256: Uint8Array;
593
+ manifestSha256: Uint8Array;
594
+ }) | (CoreEncryptedUploadV2ResumeFrame & {
595
+ kind: 'resume_request';
596
+ }) | (CoreEncryptedUploadV2ResumeFrame & {
597
+ kind: 'resume_accept';
598
+ }) | (CoreEncryptedUploadV2Common & {
599
+ kind: 'resume_reject';
600
+ reason: number;
601
+ checkpointRevision: number;
602
+ nextCiphertextOffset: bigint;
603
+ prefixSha256: Uint8Array;
604
+ }) | (CoreEncryptedUploadV2Common & {
605
+ kind: 'confirm';
606
+ uploadSessionUuid: string;
607
+ recordingUuid: string;
608
+ recordingGeneration: number;
609
+ ownerRevision: number;
610
+ receiptSha256: Uint8Array;
611
+ }) | (CoreEncryptedUploadV2Common & {
612
+ kind: 'abort';
613
+ reason: number;
614
+ }) | (CoreEncryptedUploadV2Common & {
615
+ kind: 'error';
616
+ result: number;
617
+ failedMessageType: number;
618
+ checkpointRevision: number;
619
+ });
620
+ export type CoreEncryptedUploadV2OutboundTransferFrame = Extract<CoreEncryptedUploadV2TransferFrame, {
621
+ kind: 'list' | 'start' | 'window_ack' | 'resume_request' | 'confirm' | 'abort';
622
+ }>;
623
+ export interface CoreEncryptedUploadV2Status {
624
+ phase: number;
625
+ result: number;
626
+ transportSessionId: bigint;
627
+ durableCiphertextBytes: bigint;
628
+ progressPercent: number;
629
+ transportProfile: number;
630
+ }
631
+ export type CoreEncryptedUploadV2SignedBlobFrame = {
632
+ kind: 'begin';
633
+ blobKind: 'authorization' | 'receipt';
634
+ writeId: number;
635
+ totalLength: number;
636
+ sha256: Uint8Array;
637
+ } | {
638
+ kind: 'data';
639
+ blobKind: 'authorization' | 'receipt';
640
+ writeId: number;
641
+ offset: number;
642
+ data: Uint8Array;
643
+ } | {
644
+ kind: 'commit' | 'abort';
645
+ blobKind: 'authorization' | 'receipt';
646
+ writeId: number;
647
+ };
648
+ export interface CoreEncryptedUploadV2SignedBlobResult {
649
+ blobKind: 'authorization' | 'receipt';
650
+ writeId: number;
651
+ result: number;
652
+ }
653
+ export interface CoreIntegrityHasher {
654
+ update(bytes: Uint8Array): void;
655
+ length(): bigint;
656
+ crc32(): number;
657
+ sha256Snapshot(): Uint8Array;
658
+ }
659
+ export interface CoreBridge {
660
+ startExactConnection(input: CoreConnectionInput): CoreEffectEnvelope[];
661
+ startReconnect(input: CoreReconnectInput): CoreEffectEnvelope[];
662
+ startProvisioning(input: CoreProvisioningInput): CoreEffectEnvelope[];
663
+ startRecordingTransfer(input: CoreRecordingTransferInput): CoreEffectEnvelope[];
664
+ startEncryptedUploadV2(input: CoreEncryptedUploadV2Input): CoreEffectEnvelope[];
665
+ startFirmwareUpdate(input: CoreFirmwareUpdateInput): CoreEffectEnvelope[];
666
+ startDeviceLogs(input: CoreDeviceLogsInput): CoreEffectEnvelope[];
667
+ cancel(cancellationId: Uint8Array): CoreEffectEnvelope[];
668
+ dispatch(event: CoreHostEvent): CoreEffectEnvelope[];
669
+ status(): CoreWorkflowStatus;
670
+ decodeDeviceStatus(bytes: Uint8Array): DeviceStatus;
671
+ decodeEncryptedUploadV2Capabilities(bytes: Uint8Array): EncryptedUploadV2Capabilities;
672
+ supportsEncryptedUploadV2Batch(capabilities: EncryptedUploadV2Capabilities): boolean;
673
+ validateEncryptedUploadV2Profile(capabilities: EncryptedUploadV2Capabilities, recordingGeneration: number, storageFormat: number): void;
674
+ decodeRecordingList(bytes: Uint8Array): CoreDeviceRecording[];
675
+ encodeRecordingListCommand(): Uint8Array;
676
+ encodeRecordingConfirm(recordingUuid: string): Uint8Array;
677
+ encodeDeprovisionCommand(): Uint8Array;
678
+ decodeDeprovisionResult(bytes: Uint8Array): CoreOperationResult;
679
+ decodeConnectionSettings(bytes: Uint8Array): CoreDecodedConnectionSettings;
680
+ encodeConnectionSettings(settings: CoreConnectionSettings, model: CoreDeviceModel): Uint8Array;
681
+ encodeWiFiGrant(grant: string, capacity: number): Uint8Array;
682
+ encodeWiFiCredentials(ssid: string, password: string): Uint8Array;
683
+ encodeWiFiScanCommand(): Uint8Array;
684
+ decodeWiFiConfigResult(bytes: Uint8Array): CoreOperationResult;
685
+ decodeWiFiStatus(bytes: Uint8Array): CoreWiFiStatusInfo;
686
+ decodeWiFiScanUpdate(bytes: Uint8Array): CoreWiFiScanUpdate;
687
+ encodeRecordingControlCommand(action: 'start' | 'stop'): Uint8Array;
688
+ decodeRecordingControlResult(bytes: Uint8Array): CoreOperationResult;
689
+ decodeEncryptedUploadV2Transfer(bytes: Uint8Array): CoreEncryptedUploadV2TransferFrame;
690
+ encodeEncryptedUploadV2Transfer(frame: CoreEncryptedUploadV2OutboundTransferFrame): Uint8Array;
691
+ decodeEncryptedUploadV2Status(bytes: Uint8Array): CoreEncryptedUploadV2Status;
692
+ encodeEncryptedUploadV2SignedBlob(frame: CoreEncryptedUploadV2SignedBlobFrame): Uint8Array;
693
+ decodeEncryptedUploadV2SignedBlobResult(bytes: Uint8Array): CoreEncryptedUploadV2SignedBlobResult;
694
+ createIntegrityHasher(): CoreIntegrityHasher;
695
+ }
696
+ export type CoreLoader = () => Promise<CoreBridge>;
697
+ export declare function createCoreLoader(importer: CoreLoader): CoreLoader;
698
+ export {};
package/dist/core.js ADDED
@@ -0,0 +1,13 @@
1
+ import { normalizeCoreError } from "./errors.js";
2
+ export function createCoreLoader(importer) {
3
+ let pending = null;
4
+ return async () => {
5
+ if (!pending) {
6
+ pending = importer().catch((error) => {
7
+ pending = null;
8
+ throw normalizeCoreError(error, 'initialize');
9
+ });
10
+ }
11
+ return pending;
12
+ };
13
+ }