@ping-app/ping-openmls-sdk 0.10.2 → 0.10.4
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/README.md +13 -10
- package/dist/index.cjs +1401 -266
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +999 -145
- package/dist/index.d.ts +999 -145
- package/dist/index.js +1360 -263
- package/dist/index.js.map +1 -1
- package/dist/notification-preview.cjs +1 -3
- package/dist/notification-preview.cjs.map +1 -1
- package/dist/notification-preview.d.cts +1 -8
- package/dist/notification-preview.d.ts +1 -8
- package/dist/notification-preview.js +1 -3
- package/dist/notification-preview.js.map +1 -1
- package/dist/storage/indexeddb.cjs +4 -3
- package/dist/storage/indexeddb.cjs.map +1 -1
- package/dist/storage/indexeddb.d.cts +1 -1
- package/dist/storage/indexeddb.d.ts +1 -1
- package/dist/storage/indexeddb.js +4 -3
- package/dist/storage/indexeddb.js.map +1 -1
- package/dist/transport/websocket.d.cts +1 -1
- package/dist/transport/websocket.d.ts +1 -1
- package/dist/{types-gAmJFSC-.d.cts → types-omhvRjtq.d.cts} +343 -45
- package/dist/{types-gAmJFSC-.d.ts → types-omhvRjtq.d.ts} +343 -45
- package/dist/worker.cjs +686 -69
- package/dist/worker.cjs.map +1 -1
- package/dist/worker.js +716 -80
- package/dist/worker.js.map +1 -1
- package/package.json +1 -1
- package/wasm/package.json +1 -1
- package/wasm/ping_wasm.d.ts +539 -112
- package/wasm/ping_wasm.js +1387 -322
- package/wasm/ping_wasm_bg.wasm +0 -0
- package/wasm/ping_wasm_bg.wasm.d.ts +74 -21
package/dist/index.cjs
CHANGED
|
@@ -30,15 +30,29 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var src_exports = {};
|
|
32
32
|
__export(src_exports, {
|
|
33
|
+
AccountSetup: () => AccountSetup,
|
|
34
|
+
AccountSetupClosedError: () => AccountSetupClosedError,
|
|
33
35
|
BATCH_PARTIAL_PREFIX: () => BATCH_PARTIAL_PREFIX,
|
|
34
36
|
CONTENT_TYPE_CBOR: () => CONTENT_TYPE_CBOR,
|
|
35
37
|
CONTENT_TYPE_CBOR_LEGACY_V1: () => CONTENT_TYPE_CBOR_LEGACY_V1,
|
|
36
38
|
CONTENT_TYPE_JSON: () => CONTENT_TYPE_JSON,
|
|
37
39
|
CONTENT_TYPE_JSON_LEGACY_V1: () => CONTENT_TYPE_JSON_LEGACY_V1,
|
|
40
|
+
DEVICE_GROUP_BEHIND_PREFIX: () => DEVICE_GROUP_BEHIND_PREFIX,
|
|
41
|
+
DeviceGroupBehindError: () => DeviceGroupBehindError,
|
|
38
42
|
EphemeralWorkerError: () => EphemeralWorkerError,
|
|
43
|
+
HISTORY_REFUSED_PREFIX: () => HISTORY_REFUSED_PREFIX,
|
|
39
44
|
HPKE_PQ_ENC_BYTES: () => HPKE_PQ_ENC_BYTES,
|
|
40
45
|
HPKE_PQ_PUBLIC_KEY_BYTES: () => HPKE_PQ_PUBLIC_KEY_BYTES,
|
|
46
|
+
HistoryRefusedError: () => HistoryRefusedError,
|
|
41
47
|
IndexedDbStorage: () => IndexedDbStorage,
|
|
48
|
+
JOURNAL_FULL_PREFIX: () => JOURNAL_FULL_PREFIX,
|
|
49
|
+
JournalFullError: () => JournalFullError,
|
|
50
|
+
LINK_ADD_REFUSED_PREFIX: () => LINK_ADD_REFUSED_PREFIX,
|
|
51
|
+
LINK_CHAIN_TOO_DEEP_PREFIX: () => LINK_CHAIN_TOO_DEEP_PREFIX,
|
|
52
|
+
LINK_COMMITMENT_MISMATCH_PREFIX: () => LINK_COMMITMENT_MISMATCH_PREFIX,
|
|
53
|
+
LinkAddRefusedError: () => LinkAddRefusedError,
|
|
54
|
+
LinkChainTooDeepError: () => LinkChainTooDeepError,
|
|
55
|
+
LinkCommitmentMismatchError: () => LinkCommitmentMismatchError,
|
|
42
56
|
MAX_PREVIEW_PREREQUISITES: () => MAX_PREVIEW_PREREQUISITES,
|
|
43
57
|
MessagingClient: () => MessagingClient,
|
|
44
58
|
MessagingClientClosedError: () => MessagingClientClosedError,
|
|
@@ -47,15 +61,38 @@ __export(src_exports, {
|
|
|
47
61
|
PING_WIRE_CONTRACT_HEADER: () => PING_WIRE_CONTRACT_HEADER,
|
|
48
62
|
PING_WIRE_CONTRACT_HEADER_VALUE: () => PING_WIRE_CONTRACT_HEADER_VALUE,
|
|
49
63
|
PING_WIRE_CONTRACT_VERSION: () => PING_WIRE_CONTRACT_VERSION,
|
|
64
|
+
READ_ONLY_PREFIX: () => READ_ONLY_PREFIX,
|
|
65
|
+
ReadOnlyError: () => ReadOnlyError,
|
|
50
66
|
SENDER_MISMATCH_PREFIX: () => SENDER_MISMATCH_PREFIX,
|
|
67
|
+
STALE_GENERATION_PREFIX: () => STALE_GENERATION_PREFIX,
|
|
68
|
+
STORE_MOVED_PREFIX: () => STORE_MOVED_PREFIX,
|
|
51
69
|
SenderMismatchError: () => SenderMismatchError,
|
|
70
|
+
StaleGenerationError: () => StaleGenerationError,
|
|
71
|
+
StoreMovedError: () => StoreMovedError,
|
|
52
72
|
ValidationError: () => ValidationError,
|
|
73
|
+
WELCOME_MISLABELED_PREFIX: () => WELCOME_MISLABELED_PREFIX,
|
|
74
|
+
WELCOME_WAITS_PREFIX: () => WELCOME_WAITS_PREFIX,
|
|
53
75
|
WIRE_VERSION_MIN_ACCEPTED: () => WIRE_VERSION_MIN_ACCEPTED,
|
|
54
76
|
WebSocketTransport: () => WebSocketTransport,
|
|
77
|
+
WelcomeMislabeledError: () => WelcomeMislabeledError,
|
|
78
|
+
WelcomeWaitsError: () => WelcomeWaitsError,
|
|
79
|
+
accountRefusalCode: () => accountRefusalCode,
|
|
80
|
+
backupPhraseCheckFromWire: () => backupPhraseCheckFromWire,
|
|
55
81
|
describeTransportError: () => describeTransportError,
|
|
56
82
|
emulateSendBatch: () => emulateSendBatch,
|
|
83
|
+
isDeviceGroupBehindError: () => isDeviceGroupBehindError,
|
|
84
|
+
isHistoryRefusedError: () => isHistoryRefusedError,
|
|
85
|
+
isJournalFullError: () => isJournalFullError,
|
|
86
|
+
isLinkAddRefusedError: () => isLinkAddRefusedError,
|
|
87
|
+
isLinkChainTooDeepError: () => isLinkChainTooDeepError,
|
|
88
|
+
isLinkCommitmentMismatchError: () => isLinkCommitmentMismatchError,
|
|
57
89
|
isNotPermittedError: () => isNotPermittedError,
|
|
90
|
+
isReadOnlyError: () => isReadOnlyError,
|
|
58
91
|
isSenderMismatchError: () => isSenderMismatchError,
|
|
92
|
+
isStaleGenerationError: () => isStaleGenerationError,
|
|
93
|
+
isStoreMovedError: () => isStoreMovedError,
|
|
94
|
+
isWelcomeMislabeledError: () => isWelcomeMislabeledError,
|
|
95
|
+
isWelcomeWaitsError: () => isWelcomeWaitsError,
|
|
59
96
|
negotiates: () => negotiates,
|
|
60
97
|
notPermittedRule: () => notPermittedRule,
|
|
61
98
|
openNotificationPreview: () => openNotificationPreview,
|
|
@@ -268,7 +305,8 @@ function logHeadToWire(h) {
|
|
|
268
305
|
return {
|
|
269
306
|
conversation_id: h.conversationId,
|
|
270
307
|
head_server_seq: h.headServerSeq,
|
|
271
|
-
head_epoch: h.headEpoch
|
|
308
|
+
head_epoch: h.headEpoch,
|
|
309
|
+
...h.sealedGroupInfoWanted === true ? { sealed_group_info_wanted: true } : {}
|
|
272
310
|
};
|
|
273
311
|
}
|
|
274
312
|
function logGapFromWire(g) {
|
|
@@ -314,13 +352,45 @@ function bufferOverflowFromWire(o) {
|
|
|
314
352
|
dropped: o.dropped
|
|
315
353
|
};
|
|
316
354
|
}
|
|
355
|
+
function selfAdmissionFromWire(a) {
|
|
356
|
+
return {
|
|
357
|
+
conversationId: a.conversation_id,
|
|
358
|
+
identity: a.identity,
|
|
359
|
+
deviceId: a.device_id,
|
|
360
|
+
replacedOwnLeaf: a.replaced_own_leaf,
|
|
361
|
+
ownAccount: a.own_account,
|
|
362
|
+
epoch: a.epoch
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
function logHoleFromWire(h) {
|
|
366
|
+
return {
|
|
367
|
+
conversationId: h.conversation_id,
|
|
368
|
+
fromServerSeq: h.from_server_seq,
|
|
369
|
+
toServerSeq: h.to_server_seq,
|
|
370
|
+
reason: variant(h.reason),
|
|
371
|
+
contentHashes: h.content_hashes.map((c) => Uint8Array.from(c)),
|
|
372
|
+
kept: h.kept
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
function logAckFromWire(a) {
|
|
376
|
+
return { conversationId: a.conversation_id, serverSeq: a.server_seq };
|
|
377
|
+
}
|
|
378
|
+
function journalFullAtFromWire(j) {
|
|
379
|
+
return { conversationId: j.conversation_id, serverSeq: j.server_seq, rows: j.rows };
|
|
380
|
+
}
|
|
317
381
|
function outcomesFromWire(r) {
|
|
318
382
|
return {
|
|
319
383
|
removed: (r.removed ?? []).map(conversationRemovalFromWire),
|
|
320
384
|
welcomeFailures: (r.welcome_failures ?? []).map(welcomeFailureFromWire),
|
|
321
385
|
stranded: (r.stranded ?? []).map(strandedConversationFromWire),
|
|
322
386
|
proposalsPending: r.proposals_pending ?? [],
|
|
323
|
-
overflow: (r.overflow ?? []).map(bufferOverflowFromWire)
|
|
387
|
+
overflow: (r.overflow ?? []).map(bufferOverflowFromWire),
|
|
388
|
+
selfAdmissions: (r.self_admissions ?? []).map(selfAdmissionFromWire),
|
|
389
|
+
// Absent from an older wasm: nothing recorded, nothing safe to acknowledge.
|
|
390
|
+
holes: (r.holes ?? []).map(logHoleFromWire),
|
|
391
|
+
acks: (r.acks ?? []).map(logAckFromWire),
|
|
392
|
+
// Absent from an older wasm, which never stopped for the journal.
|
|
393
|
+
journalFull: (r.journal_full ?? []).map(journalFullAtFromWire)
|
|
324
394
|
};
|
|
325
395
|
}
|
|
326
396
|
function applyBatchResultFromWire(r) {
|
|
@@ -333,7 +403,10 @@ function applyBatchResultFromWire(r) {
|
|
|
333
403
|
gaps: r.gaps.map(logGapFromWire),
|
|
334
404
|
joined: r.joined,
|
|
335
405
|
updated: r.updated.map(conversationUpdateFromWire),
|
|
336
|
-
...outcomesFromWire(r)
|
|
406
|
+
...outcomesFromWire(r),
|
|
407
|
+
// Present only when the SDK says it: said once, with the batch at which
|
|
408
|
+
// the anchor record was seen to change.
|
|
409
|
+
...r.state_backup_owed === true ? { stateBackupOwed: true } : {}
|
|
337
410
|
};
|
|
338
411
|
}
|
|
339
412
|
function syncStepResultFromWire(r) {
|
|
@@ -369,6 +442,7 @@ function commitInDoubtFromWire(c) {
|
|
|
369
442
|
var DB_NAME = "ping-sdk";
|
|
370
443
|
var DB_VERSION = 1;
|
|
371
444
|
var STORE = "kv";
|
|
445
|
+
var DURABLE = { durability: "strict" };
|
|
372
446
|
function open() {
|
|
373
447
|
return new Promise((resolve, reject) => {
|
|
374
448
|
const req = indexedDB.open(DB_NAME, DB_VERSION);
|
|
@@ -400,7 +474,7 @@ var IndexedDbStorage = class {
|
|
|
400
474
|
async put(namespace, key, value) {
|
|
401
475
|
const db = await this.dbPromise;
|
|
402
476
|
return new Promise((resolve, reject) => {
|
|
403
|
-
const tx = db.transaction(STORE, "readwrite");
|
|
477
|
+
const tx = db.transaction(STORE, "readwrite", DURABLE);
|
|
404
478
|
tx.objectStore(STORE).put({ ns: namespace, key, value });
|
|
405
479
|
tx.oncomplete = () => resolve();
|
|
406
480
|
tx.onerror = () => reject(tx.error);
|
|
@@ -409,7 +483,7 @@ var IndexedDbStorage = class {
|
|
|
409
483
|
async del(namespace, key) {
|
|
410
484
|
const db = await this.dbPromise;
|
|
411
485
|
return new Promise((resolve, reject) => {
|
|
412
|
-
const tx = db.transaction(STORE, "readwrite");
|
|
486
|
+
const tx = db.transaction(STORE, "readwrite", DURABLE);
|
|
413
487
|
tx.objectStore(STORE).delete([namespace, key]);
|
|
414
488
|
tx.oncomplete = () => resolve();
|
|
415
489
|
tx.onerror = () => reject(tx.error);
|
|
@@ -425,7 +499,7 @@ var IndexedDbStorage = class {
|
|
|
425
499
|
if (puts.length === 0 && deletes.length === 0) return;
|
|
426
500
|
const db = await this.dbPromise;
|
|
427
501
|
return new Promise((resolve, reject) => {
|
|
428
|
-
const tx = db.transaction(STORE, "readwrite");
|
|
502
|
+
const tx = db.transaction(STORE, "readwrite", DURABLE);
|
|
429
503
|
let settled = false;
|
|
430
504
|
const fail = (e) => {
|
|
431
505
|
if (settled) return;
|
|
@@ -658,6 +732,434 @@ function btoaUrl(b) {
|
|
|
658
732
|
return btoa(s).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
659
733
|
}
|
|
660
734
|
|
|
735
|
+
// src/account-setup.ts
|
|
736
|
+
var import_meta = {};
|
|
737
|
+
function phraseBytes(phrase) {
|
|
738
|
+
return new TextEncoder().encode(phrase);
|
|
739
|
+
}
|
|
740
|
+
function rotationAnswerFields(answer) {
|
|
741
|
+
return {
|
|
742
|
+
status: answer.status,
|
|
743
|
+
error: answer.error ?? null,
|
|
744
|
+
generation: answer.generation ?? null,
|
|
745
|
+
statement: answer.statement ?? null
|
|
746
|
+
};
|
|
747
|
+
}
|
|
748
|
+
function accountRefusalCode(error) {
|
|
749
|
+
const text = error instanceof Error ? error.message : String(error);
|
|
750
|
+
const at = text.indexOf("account refused: ");
|
|
751
|
+
return at < 0 ? null : text.slice(at + "account refused: ".length).trim();
|
|
752
|
+
}
|
|
753
|
+
var AccountSetupClosedError = class extends Error {
|
|
754
|
+
constructor() {
|
|
755
|
+
super("AccountSetup is closed");
|
|
756
|
+
this.name = "AccountSetupClosedError";
|
|
757
|
+
}
|
|
758
|
+
};
|
|
759
|
+
var AccountSetup = class _AccountSetup {
|
|
760
|
+
worker;
|
|
761
|
+
storage;
|
|
762
|
+
now;
|
|
763
|
+
pending = /* @__PURE__ */ new Map();
|
|
764
|
+
nextId = 1;
|
|
765
|
+
closed = false;
|
|
766
|
+
constructor(cfg, worker) {
|
|
767
|
+
this.worker = worker;
|
|
768
|
+
this.storage = cfg.accountNamespace !== void 0 && cfg.accountNamespace.length > 0 ? scopeStorage(cfg.storage, cfg.accountNamespace) : cfg.storage;
|
|
769
|
+
this.now = cfg.now ?? (() => Date.now());
|
|
770
|
+
this.worker.onmessage = (ev) => void this.handleWorker(ev.data);
|
|
771
|
+
this.worker.onerror = () => this.fail(new AccountSetupClosedError());
|
|
772
|
+
}
|
|
773
|
+
/** Start the SDK's set-up Worker over the device's own store. */
|
|
774
|
+
static open(cfg) {
|
|
775
|
+
const worker = new Worker(new URL("./worker.js", import_meta.url), { type: "module" });
|
|
776
|
+
return new _AccountSetup(cfg, worker);
|
|
777
|
+
}
|
|
778
|
+
/**
|
|
779
|
+
* Set a NEW account up on this browser after "Not now" (rule R34 b): the
|
|
780
|
+
* pending root first, then the device record. `identityState` is the
|
|
781
|
+
* sign-in body's `identity_state` field as the server sent it; only
|
|
782
|
+
* `"none_pinned"` lets the call run (ruling V102). `persistentStorage` is the
|
|
783
|
+
* browser's answer to `navigator.storage.persist()`, which the host asked
|
|
784
|
+
* for before this call (ruling ID39).
|
|
785
|
+
*/
|
|
786
|
+
createAccount(args) {
|
|
787
|
+
return this.call({
|
|
788
|
+
kind: "createAccount",
|
|
789
|
+
id: this.nextId++,
|
|
790
|
+
slot: args.slot,
|
|
791
|
+
identityState: args.identityState,
|
|
792
|
+
persistentStorage: args.persistentStorage,
|
|
793
|
+
nowMs: this.now(),
|
|
794
|
+
storageFeatures: storageFeaturesOf(this.storage)
|
|
795
|
+
});
|
|
796
|
+
}
|
|
797
|
+
/** Whether the slot holds the pending root this device expects (rule R32).
|
|
798
|
+
* No prompt, no read of the seed. */
|
|
799
|
+
pendingStatus(slot) {
|
|
800
|
+
return this.call({
|
|
801
|
+
kind: "pendingStatus",
|
|
802
|
+
id: this.nextId++,
|
|
803
|
+
slot,
|
|
804
|
+
storageFeatures: storageFeaturesOf(this.storage)
|
|
805
|
+
});
|
|
806
|
+
}
|
|
807
|
+
/** The first backup of a PENDING account. `accountId` is the account's
|
|
808
|
+
* 16-byte id at the auth layer. */
|
|
809
|
+
makeBackup(args) {
|
|
810
|
+
return this.call({
|
|
811
|
+
kind: "makeBackup",
|
|
812
|
+
id: this.nextId++,
|
|
813
|
+
slot: args.slot,
|
|
814
|
+
phrase: phraseBytes(args.phrase),
|
|
815
|
+
accountId: args.accountId,
|
|
816
|
+
hostState: args.hostState,
|
|
817
|
+
nowMs: this.now(),
|
|
818
|
+
storageFeatures: storageFeaturesOf(this.storage)
|
|
819
|
+
});
|
|
820
|
+
}
|
|
821
|
+
/** Rule R10 (b): the root part READ BACK from where it was stored opens to
|
|
822
|
+
* this account. Answers the fingerprint `endPending` asks for. */
|
|
823
|
+
async proveBackup(args) {
|
|
824
|
+
const proof = await this.call({
|
|
825
|
+
kind: "proveBackup",
|
|
826
|
+
id: this.nextId++,
|
|
827
|
+
readBackRootPart: args.readBackRootPart,
|
|
828
|
+
phrase: phraseBytes(args.phrase),
|
|
829
|
+
storageFeatures: storageFeaturesOf(this.storage)
|
|
830
|
+
});
|
|
831
|
+
return proof.fingerprint;
|
|
832
|
+
}
|
|
833
|
+
/** End PENDING: delete the pending item, only against the proof on record. */
|
|
834
|
+
async endPending(args) {
|
|
835
|
+
await this.call({
|
|
836
|
+
kind: "endPending",
|
|
837
|
+
id: this.nextId++,
|
|
838
|
+
slot: args.slot,
|
|
839
|
+
fingerprint: args.fingerprint,
|
|
840
|
+
storageFeatures: storageFeaturesOf(this.storage)
|
|
841
|
+
});
|
|
842
|
+
}
|
|
843
|
+
// ---- The restore as a rotation (the account identity contract, sections
|
|
844
|
+
// 3.9, 3.13, 13.1). None of these needs a client or a session: the backup
|
|
845
|
+
// is opened and the whole `rotation` object is built before the device
|
|
846
|
+
// exists at the server. No call takes or returns a root. ----
|
|
847
|
+
/** Step 3 of a restore: the root part opens with the phrase to the PINNED
|
|
848
|
+
* root; `hostState` is there when the root part's secret opens the state
|
|
849
|
+
* part. Writes nothing. */
|
|
850
|
+
openBackupForRestore(args) {
|
|
851
|
+
return this.call({
|
|
852
|
+
kind: "openBackupForRestore",
|
|
853
|
+
id: this.nextId++,
|
|
854
|
+
rootPart: args.rootPart,
|
|
855
|
+
phrase: phraseBytes(args.phrase),
|
|
856
|
+
statePart: args.statePart,
|
|
857
|
+
pinnedRootPublicKey: args.pinnedRootPublicKey
|
|
858
|
+
});
|
|
859
|
+
}
|
|
860
|
+
/**
|
|
861
|
+
* M1, take the account over: the next generation (the pinned one plus one,
|
|
862
|
+
* or a refusal), a NEW device key, the new generation secret, the device's
|
|
863
|
+
* credential, the statement, its wrap, the new backup parts, and the
|
|
864
|
+
* rotation record. `oldStatePart` gives its anchors only; `hostState` is
|
|
865
|
+
* the NEW host state with the NEW sign-in key companion. Called again with
|
|
866
|
+
* the same rotation id it answers the same request and the same device key.
|
|
867
|
+
*/
|
|
868
|
+
restoreTakeOver(args) {
|
|
869
|
+
return this.call({
|
|
870
|
+
kind: "restoreTakeOver",
|
|
871
|
+
id: this.nextId++,
|
|
872
|
+
rootPart: args.rootPart,
|
|
873
|
+
phrase: phraseBytes(args.phrase),
|
|
874
|
+
start: args.start,
|
|
875
|
+
oldStatePart: args.oldStatePart,
|
|
876
|
+
accountId: args.accountId,
|
|
877
|
+
hostState: args.hostState,
|
|
878
|
+
nowMs: this.now(),
|
|
879
|
+
storageFeatures: storageFeaturesOf(this.storage)
|
|
880
|
+
});
|
|
881
|
+
}
|
|
882
|
+
/** "Take your account back": the take-over with the pending root of the
|
|
883
|
+
* slot. The pending item is read, never written and never deleted.
|
|
884
|
+
* `oldStatePart` is the account's state part as the escrow served it
|
|
885
|
+
* (it gives its anchors only); `undefined` only when none was served.
|
|
886
|
+
* ON AN EMPTY STORE EVERY JOIN IS UNCHECKED: never empty the SDK's
|
|
887
|
+
* store on the service's word while the slot holds a pending item
|
|
888
|
+
* (ruling V538). */
|
|
889
|
+
takeAccountBack(args) {
|
|
890
|
+
return this.call({
|
|
891
|
+
kind: "takeAccountBack",
|
|
892
|
+
id: this.nextId++,
|
|
893
|
+
slot: args.slot,
|
|
894
|
+
start: args.start,
|
|
895
|
+
oldStatePart: args.oldStatePart,
|
|
896
|
+
accountId: args.accountId,
|
|
897
|
+
hostState: args.hostState,
|
|
898
|
+
nowMs: this.now(),
|
|
899
|
+
storageFeatures: storageFeaturesOf(this.storage)
|
|
900
|
+
});
|
|
901
|
+
}
|
|
902
|
+
/** At every start: the rotation this device built and has not finished, or
|
|
903
|
+
* `null`. While its phase is `"built"` the host sends the identical
|
|
904
|
+
* request again. */
|
|
905
|
+
resumeRotation() {
|
|
906
|
+
return this.call({
|
|
907
|
+
kind: "resumeRotation",
|
|
908
|
+
id: this.nextId++,
|
|
909
|
+
storageFeatures: storageFeaturesOf(this.storage)
|
|
910
|
+
});
|
|
911
|
+
}
|
|
912
|
+
/** `resumeRotation` WITH THE HOST'S CLOCK (ruling V461; `nowMs`, by default
|
|
913
|
+
* this client's own): the call an app makes at every start. A take-over
|
|
914
|
+
* the server never answered loses the sealing seed it kept once 30 days
|
|
915
|
+
* have passed since its record was made; the record itself stays. */
|
|
916
|
+
resumeRotationAt(nowMs = this.now()) {
|
|
917
|
+
return this.call({
|
|
918
|
+
kind: "resumeRotation",
|
|
919
|
+
id: this.nextId++,
|
|
920
|
+
nowMs,
|
|
921
|
+
storageFeatures: storageFeaturesOf(this.storage)
|
|
922
|
+
});
|
|
923
|
+
}
|
|
924
|
+
/** The server's answer to the request of record `recordId`, AS RECEIVED
|
|
925
|
+
* and judged inside the SDK (ruling V161): the device adopts, or discards
|
|
926
|
+
* the record only against a DIFFERENT pinned statement the root signed
|
|
927
|
+
* (`"lost"`); a final refusal of the server (`"refused"`, `400
|
|
928
|
+
* rotation_invalid` included) keeps the record until `abandonRotation`; any
|
|
929
|
+
* other answer is `"undecided"` and changes nothing. */
|
|
930
|
+
completeRotation(recordId, answer) {
|
|
931
|
+
return this.call({
|
|
932
|
+
kind: "completeRotation",
|
|
933
|
+
id: this.nextId++,
|
|
934
|
+
recordId,
|
|
935
|
+
answer: rotationAnswerFields(answer),
|
|
936
|
+
storageFeatures: storageFeaturesOf(this.storage)
|
|
937
|
+
});
|
|
938
|
+
}
|
|
939
|
+
/** Move an adopted rotation forward. */
|
|
940
|
+
async setRotationPhase(recordId, phase) {
|
|
941
|
+
await this.call({
|
|
942
|
+
kind: "setRotationPhase",
|
|
943
|
+
id: this.nextId++,
|
|
944
|
+
recordId,
|
|
945
|
+
phase,
|
|
946
|
+
storageFeatures: storageFeaturesOf(this.storage)
|
|
947
|
+
});
|
|
948
|
+
}
|
|
949
|
+
/** Step 6: delete the record of an adopted rotation. */
|
|
950
|
+
async finishRotation(recordId) {
|
|
951
|
+
await this.call({
|
|
952
|
+
kind: "finishRotation",
|
|
953
|
+
id: this.nextId++,
|
|
954
|
+
recordId,
|
|
955
|
+
storageFeatures: storageFeaturesOf(this.storage)
|
|
956
|
+
});
|
|
957
|
+
}
|
|
958
|
+
/** Ruling V212: ABANDON a rotation that was never adopted. Its record is
|
|
959
|
+
* deleted, so that another rotation can start. THE PERSON'S CHOICE (after
|
|
960
|
+
* `"refused"`, or to supply the phrase after `"root_part_required"`): the
|
|
961
|
+
* SDK never calls it. ONLY a record the server answered with one of
|
|
962
|
+
* those two is deleted (ruling V227): a record the server never answered
|
|
963
|
+
* is refused (`rotation-refused`) and its request is sent again, because
|
|
964
|
+
* the server may have applied it and the record then holds the only copy
|
|
965
|
+
* of the new device's key. An adopted rotation is refused
|
|
966
|
+
* (`rotation-refused`); it ends by `finishRotation`. */
|
|
967
|
+
async abandonRotation(recordId) {
|
|
968
|
+
await this.call({
|
|
969
|
+
kind: "abandonRotation",
|
|
970
|
+
id: this.nextId++,
|
|
971
|
+
recordId,
|
|
972
|
+
storageFeatures: storageFeaturesOf(this.storage)
|
|
973
|
+
});
|
|
974
|
+
}
|
|
975
|
+
/** Ruling V232: whether this store holds a rotation record and whether the
|
|
976
|
+
* server refused it for good, so a screen can offer "start over" after a
|
|
977
|
+
* restart without sending the request once more. One local read: no secret,
|
|
978
|
+
* no id, no request. The refusal it reports is the server's unauthenticated
|
|
979
|
+
* word; this read decides nothing. */
|
|
980
|
+
rotationRecordState() {
|
|
981
|
+
return this.call({
|
|
982
|
+
kind: "rotationRecordState",
|
|
983
|
+
id: this.nextId++,
|
|
984
|
+
storageFeatures: storageFeaturesOf(this.storage)
|
|
985
|
+
});
|
|
986
|
+
}
|
|
987
|
+
/** M2, join beside the devices that stay: no rotation; a depth 0 credential
|
|
988
|
+
* at the pinned generation. `restore-join-not-current`: offer M1 or a link. */
|
|
989
|
+
restoreJoin(args) {
|
|
990
|
+
return this.call({
|
|
991
|
+
kind: "restoreJoin",
|
|
992
|
+
id: this.nextId++,
|
|
993
|
+
rootPart: args.rootPart,
|
|
994
|
+
phrase: phraseBytes(args.phrase),
|
|
995
|
+
statePart: args.statePart,
|
|
996
|
+
start: args.start,
|
|
997
|
+
nowMs: this.now(),
|
|
998
|
+
storageFeatures: storageFeaturesOf(this.storage)
|
|
999
|
+
});
|
|
1000
|
+
}
|
|
1001
|
+
/** Open the account's state part with the generation secret this device
|
|
1002
|
+
* holds, and keep its anchors. No phrase, no root.
|
|
1003
|
+
* It is also the ONE look a linked device owes before it writes a state
|
|
1004
|
+
* part: until this ran once, `refreshStateBackup` and a rotation that keeps
|
|
1005
|
+
* the device's key reject with the code `state-part-look-owed`. Pass an
|
|
1006
|
+
* EMPTY part when the service serves none; whatever this answers, the look
|
|
1007
|
+
* is made. */
|
|
1008
|
+
openStateBackup(statePart) {
|
|
1009
|
+
return this.call({
|
|
1010
|
+
kind: "openStateBackup",
|
|
1011
|
+
id: this.nextId++,
|
|
1012
|
+
statePart,
|
|
1013
|
+
storageFeatures: storageFeaturesOf(this.storage)
|
|
1014
|
+
});
|
|
1015
|
+
}
|
|
1016
|
+
/** Write the account's state part anew under the generation secret this
|
|
1017
|
+
* device holds. */
|
|
1018
|
+
refreshStateBackup(args) {
|
|
1019
|
+
return this.call({
|
|
1020
|
+
kind: "refreshStateBackup",
|
|
1021
|
+
id: this.nextId++,
|
|
1022
|
+
accountId: args.accountId,
|
|
1023
|
+
hostState: args.hostState,
|
|
1024
|
+
nowMs: this.now(),
|
|
1025
|
+
storageFeatures: storageFeaturesOf(this.storage)
|
|
1026
|
+
});
|
|
1027
|
+
}
|
|
1028
|
+
/**
|
|
1029
|
+
* Begin a set-up session whose root is in memory only (rule R34 a): for the
|
|
1030
|
+
* person who makes the backup during set-up. One session per object; it
|
|
1031
|
+
* lives in the Worker until `sessionFinish`, `sessionKeepAsPending` or
|
|
1032
|
+
* `close`.
|
|
1033
|
+
*/
|
|
1034
|
+
async beginInMemory(identityState) {
|
|
1035
|
+
await this.call({
|
|
1036
|
+
kind: "beginAccountSetupInMemory",
|
|
1037
|
+
id: this.nextId++,
|
|
1038
|
+
identityState,
|
|
1039
|
+
nowMs: this.now()
|
|
1040
|
+
});
|
|
1041
|
+
}
|
|
1042
|
+
/** The session's backup. */
|
|
1043
|
+
sessionMakeBackup(args) {
|
|
1044
|
+
return this.call({
|
|
1045
|
+
kind: "setupSessionMakeBackup",
|
|
1046
|
+
id: this.nextId++,
|
|
1047
|
+
phrase: phraseBytes(args.phrase),
|
|
1048
|
+
accountId: args.accountId,
|
|
1049
|
+
hostState: args.hostState,
|
|
1050
|
+
nowMs: this.now()
|
|
1051
|
+
});
|
|
1052
|
+
}
|
|
1053
|
+
/** Rule R10 (b) for the session. Answers the fingerprint. */
|
|
1054
|
+
async sessionProveBackup(args) {
|
|
1055
|
+
const proof = await this.call({
|
|
1056
|
+
kind: "setupSessionProveBackup",
|
|
1057
|
+
id: this.nextId++,
|
|
1058
|
+
readBackRootPart: args.readBackRootPart,
|
|
1059
|
+
phrase: phraseBytes(args.phrase)
|
|
1060
|
+
});
|
|
1061
|
+
return proof.fingerprint;
|
|
1062
|
+
}
|
|
1063
|
+
/** End the session after the proof: the device record is written, the root
|
|
1064
|
+
* is wiped. Only then does the host upload KeyPackages. */
|
|
1065
|
+
sessionFinish() {
|
|
1066
|
+
return this.call({
|
|
1067
|
+
kind: "setupSessionFinish",
|
|
1068
|
+
id: this.nextId++,
|
|
1069
|
+
storageFeatures: storageFeaturesOf(this.storage)
|
|
1070
|
+
});
|
|
1071
|
+
}
|
|
1072
|
+
/** "Not now" after the session began (ruling ID42): THIS session's root
|
|
1073
|
+
* becomes the pending item, then the device record is written. */
|
|
1074
|
+
sessionKeepAsPending(args) {
|
|
1075
|
+
return this.call({
|
|
1076
|
+
kind: "setupSessionKeepAsPending",
|
|
1077
|
+
id: this.nextId++,
|
|
1078
|
+
slot: args.slot,
|
|
1079
|
+
persistentStorage: args.persistentStorage,
|
|
1080
|
+
storageFeatures: storageFeaturesOf(this.storage)
|
|
1081
|
+
});
|
|
1082
|
+
}
|
|
1083
|
+
/** Stop the Worker. A session still open there is wiped with it. */
|
|
1084
|
+
close() {
|
|
1085
|
+
if (this.closed) return;
|
|
1086
|
+
this.closed = true;
|
|
1087
|
+
try {
|
|
1088
|
+
this.worker.postMessage({ kind: "endAccountSetupSession", id: this.nextId++ });
|
|
1089
|
+
} catch {
|
|
1090
|
+
}
|
|
1091
|
+
this.worker.onmessage = null;
|
|
1092
|
+
this.worker.onerror = null;
|
|
1093
|
+
this.worker.terminate();
|
|
1094
|
+
this.fail(new AccountSetupClosedError());
|
|
1095
|
+
}
|
|
1096
|
+
fail(error) {
|
|
1097
|
+
const waiting = [...this.pending.values()];
|
|
1098
|
+
this.pending.clear();
|
|
1099
|
+
for (const slot of waiting) slot.reject(error);
|
|
1100
|
+
}
|
|
1101
|
+
/** Post a request. A recovery phrase in it crossed as bytes (ruling
|
|
1102
|
+
* V253): this side's copy is zeroed when the call has answered, whatever
|
|
1103
|
+
* it answered; the Worker zeroes its own. */
|
|
1104
|
+
call(req) {
|
|
1105
|
+
const phrase = req.phrase;
|
|
1106
|
+
const answered = this.post(req);
|
|
1107
|
+
return phrase instanceof Uint8Array ? answered.finally(() => {
|
|
1108
|
+
phrase.fill(0);
|
|
1109
|
+
}) : answered;
|
|
1110
|
+
}
|
|
1111
|
+
post(req) {
|
|
1112
|
+
if (this.closed) return Promise.reject(new AccountSetupClosedError());
|
|
1113
|
+
return new Promise((resolve, reject) => {
|
|
1114
|
+
this.pending.set(req.id, { resolve, reject });
|
|
1115
|
+
try {
|
|
1116
|
+
this.worker.postMessage(req);
|
|
1117
|
+
} catch (e) {
|
|
1118
|
+
this.pending.delete(req.id);
|
|
1119
|
+
reject(e);
|
|
1120
|
+
}
|
|
1121
|
+
});
|
|
1122
|
+
}
|
|
1123
|
+
async handleWorker(msg) {
|
|
1124
|
+
switch (msg.kind) {
|
|
1125
|
+
case "result": {
|
|
1126
|
+
const slot = this.pending.get(msg.id);
|
|
1127
|
+
if (!slot) return;
|
|
1128
|
+
this.pending.delete(msg.id);
|
|
1129
|
+
if (msg.ok) slot.resolve(msg.value);
|
|
1130
|
+
else slot.reject(new Error(msg.error));
|
|
1131
|
+
return;
|
|
1132
|
+
}
|
|
1133
|
+
case "storage.call": {
|
|
1134
|
+
try {
|
|
1135
|
+
const method = this.storage[msg.method];
|
|
1136
|
+
if (typeof method !== "function") {
|
|
1137
|
+
throw new Error(`storage.${String(msg.method)} is not implemented by the host storage`);
|
|
1138
|
+
}
|
|
1139
|
+
const value = await method.apply(this.storage, msg.args);
|
|
1140
|
+
if (!this.closed) this.worker.postMessage({ kind: "storage.reply", id: msg.id, ok: true, value });
|
|
1141
|
+
} catch (e) {
|
|
1142
|
+
if (!this.closed) {
|
|
1143
|
+
this.worker.postMessage({ kind: "storage.reply", id: msg.id, ok: false, error: String(e) });
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1146
|
+
return;
|
|
1147
|
+
}
|
|
1148
|
+
case "transport.call": {
|
|
1149
|
+
this.worker.postMessage({
|
|
1150
|
+
kind: "transport.reply",
|
|
1151
|
+
id: msg.id,
|
|
1152
|
+
ok: false,
|
|
1153
|
+
error: "account set-up has no transport"
|
|
1154
|
+
});
|
|
1155
|
+
return;
|
|
1156
|
+
}
|
|
1157
|
+
default:
|
|
1158
|
+
return;
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
};
|
|
1162
|
+
|
|
661
1163
|
// src/wasm-memory.ts
|
|
662
1164
|
var RESERVE_MIB_TARGETS = [192, 128, 64, 32];
|
|
663
1165
|
var WASM_PAGE_BYTES = 64 * 1024;
|
|
@@ -685,9 +1187,7 @@ async function openNotificationPreview(opts) {
|
|
|
685
1187
|
opts.wasmModuleOrPath === void 0 ? void 0 : { module_or_path: opts.wasmModuleOrPath }
|
|
686
1188
|
);
|
|
687
1189
|
reserveLinearMemory(out.memory);
|
|
688
|
-
const client = await wasm.PingClient.
|
|
689
|
-
opts.identityExport,
|
|
690
|
-
// Label is unused on the read-only path (no LocalDevice is ever minted).
|
|
1190
|
+
const client = await wasm.PingClient.openReadOnlyFromDeviceRecord(
|
|
691
1191
|
"notification-preview",
|
|
692
1192
|
storage,
|
|
693
1193
|
silentTransport(),
|
|
@@ -753,7 +1253,7 @@ function silentTransport() {
|
|
|
753
1253
|
}
|
|
754
1254
|
|
|
755
1255
|
// src/index.ts
|
|
756
|
-
var
|
|
1256
|
+
var import_meta2 = {};
|
|
757
1257
|
var MessagingClient = class _MessagingClient {
|
|
758
1258
|
worker;
|
|
759
1259
|
nextId = 1;
|
|
@@ -813,56 +1313,6 @@ var MessagingClient = class _MessagingClient {
|
|
|
813
1313
|
this.worker.onmessage = (ev) => this.handleWorker(ev.data);
|
|
814
1314
|
this.worker.onerror = () => this.failPending(new MessagingClientClosedError("worker-error"));
|
|
815
1315
|
}
|
|
816
|
-
/** Generate a fresh identity. The returned bytes are a secret — store them encrypted. */
|
|
817
|
-
static async generateIdentity() {
|
|
818
|
-
return _MessagingClient.ephemeralWorkerCall({
|
|
819
|
-
kind: "generateIdentity",
|
|
820
|
-
id: 1
|
|
821
|
-
});
|
|
822
|
-
}
|
|
823
|
-
/**
|
|
824
|
-
* HPKE-seal a `LinkingTicket` for delivery to a new device ([CR-3]).
|
|
825
|
-
*
|
|
826
|
-
* Returns CBOR-encoded bytes safe to relay through an untrusted inbox. The new device's
|
|
827
|
-
* X25519 public key (`newDevicePub`) is exchanged out-of-band — typically as part of a
|
|
828
|
-
* QR-encoded handshake on the linking screen. Pure function; runs in an ephemeral
|
|
829
|
-
* worker so no live `MessagingClient` is required on the sender side.
|
|
830
|
-
*
|
|
831
|
-
* Suite: `DHKEM(X25519, HKDF-SHA256), HKDF-SHA256, AES-128-GCM` (matches MLS).
|
|
832
|
-
*/
|
|
833
|
-
static async sealLinkingTicket(ticket, newDevicePub) {
|
|
834
|
-
if (newDevicePub.length !== 32) {
|
|
835
|
-
throw new Error("sealLinkingTicket: newDevicePub must be 32 bytes");
|
|
836
|
-
}
|
|
837
|
-
return _MessagingClient.ephemeralWorkerCall({
|
|
838
|
-
kind: "sealLinkingTicket",
|
|
839
|
-
id: 1,
|
|
840
|
-
ticket,
|
|
841
|
-
newDevicePub
|
|
842
|
-
});
|
|
843
|
-
}
|
|
844
|
-
/**
|
|
845
|
-
* HPKE-open a sealed `LinkingTicket` on the new device ([CR-3]).
|
|
846
|
-
*
|
|
847
|
-
* The receiving device hasn't booted a `MessagingClient` yet — it only has its X25519
|
|
848
|
-
* ephemeral keypair. This static method runs the open in an ephemeral worker, returning
|
|
849
|
-
* the cleartext ticket which the host then feeds to `init()` + `consumeLinkingTicket()`.
|
|
850
|
-
*
|
|
851
|
-
* On failure the error message is deliberately generic (no discriminator between "wrong
|
|
852
|
-
* key" vs "tampered ciphertext") so a probing attacker can't tell the new device's key
|
|
853
|
-
* was the issue.
|
|
854
|
-
*/
|
|
855
|
-
static async openLinkingTicket(sealed, newDevicePriv) {
|
|
856
|
-
if (newDevicePriv.length !== 32) {
|
|
857
|
-
throw new Error("openLinkingTicket: newDevicePriv must be 32 bytes");
|
|
858
|
-
}
|
|
859
|
-
return _MessagingClient.ephemeralWorkerCall({
|
|
860
|
-
kind: "openLinkingTicket",
|
|
861
|
-
id: 1,
|
|
862
|
-
sealed,
|
|
863
|
-
newDevicePriv
|
|
864
|
-
});
|
|
865
|
-
}
|
|
866
1316
|
/**
|
|
867
1317
|
* Generic HPKE-Base seal of arbitrary bytes to `recipientPub` (32-byte X25519)
|
|
868
1318
|
* under a caller-supplied `info`. One shared HPKE implementation so app layers
|
|
@@ -962,39 +1412,6 @@ var MessagingClient = class _MessagingClient {
|
|
|
962
1412
|
// forms stay for app inboxes created with a 32-byte key before the roll. A
|
|
963
1413
|
// classical private key and an X-Wing seed are both 32 bytes but are NOT
|
|
964
1414
|
// interchangeable: the host knows which family a stored key belongs to.
|
|
965
|
-
/**
|
|
966
|
-
* HPKE-seal a `LinkingTicket` under the new device's X-Wing public key
|
|
967
|
-
* ([CR-3], post-quantum). CBOR `{v: 2, enc, ct}` under `ping/link/v2`; the
|
|
968
|
-
* classical {@link openLinkingTicket} refuses it and {@link openLinkingTicketPq}
|
|
969
|
-
* refuses a `v: 1` blob, so there is no downgrade in either direction.
|
|
970
|
-
*/
|
|
971
|
-
static async sealLinkingTicketPq(ticket, newDevicePub) {
|
|
972
|
-
if (newDevicePub.length !== HPKE_PQ_PUBLIC_KEY_BYTES) {
|
|
973
|
-
throw new Error(`sealLinkingTicketPq: newDevicePub must be ${HPKE_PQ_PUBLIC_KEY_BYTES} bytes`);
|
|
974
|
-
}
|
|
975
|
-
return _MessagingClient.ephemeralWorkerCall({
|
|
976
|
-
kind: "sealLinkingTicketPq",
|
|
977
|
-
id: 1,
|
|
978
|
-
ticket,
|
|
979
|
-
newDevicePub
|
|
980
|
-
});
|
|
981
|
-
}
|
|
982
|
-
/**
|
|
983
|
-
* HPKE-open a sealed `v: 2` ticket with the new device's 32-byte X-Wing seed
|
|
984
|
-
* ([CR-3], post-quantum). The error is deliberately generic, like
|
|
985
|
-
* {@link openLinkingTicket}.
|
|
986
|
-
*/
|
|
987
|
-
static async openLinkingTicketPq(sealed, newDevicePriv) {
|
|
988
|
-
if (newDevicePriv.length !== 32) {
|
|
989
|
-
throw new Error("openLinkingTicketPq: newDevicePriv must be 32 bytes");
|
|
990
|
-
}
|
|
991
|
-
return _MessagingClient.ephemeralWorkerCall({
|
|
992
|
-
kind: "openLinkingTicketPq",
|
|
993
|
-
id: 1,
|
|
994
|
-
sealed,
|
|
995
|
-
newDevicePriv
|
|
996
|
-
});
|
|
997
|
-
}
|
|
998
1415
|
/** Post-quantum {@link hpkeSeal}: CBOR-wrapped (`v: 2`), `recipientPub` is 1216 bytes. */
|
|
999
1416
|
static async hpkeSealPq(plaintext, recipientPub, info) {
|
|
1000
1417
|
if (recipientPub.length !== HPKE_PQ_PUBLIC_KEY_BYTES) {
|
|
@@ -1158,52 +1575,112 @@ var MessagingClient = class _MessagingClient {
|
|
|
1158
1575
|
}
|
|
1159
1576
|
return { deviceId: both.slice(0, 32), signature: both.slice(32) };
|
|
1160
1577
|
}
|
|
1578
|
+
// ---- The link handshake commitment (2026-11-25) ----
|
|
1579
|
+
//
|
|
1580
|
+
// REMOVED 2026-11-28 (ruling V576): `openLinkingTicket`, `openLinkingTicketPq`,
|
|
1581
|
+
// `sealLinkingTicketFor`, `buildLinkingTicketFor`, `consumeLinkingTicket` and the type
|
|
1582
|
+
// `LinkingTicket`. A ticket of version 1 or 2 carries a binding an ACCOUNT KEY signs;
|
|
1583
|
+
// the only ticket is version 3 (`buildLinkingTicketV3For`, `completeDeviceLink`).
|
|
1584
|
+
// REMOVED 2026-11-25 (ruling ID15): `sealLinkingTicket`, `sealLinkingTicketPq`,
|
|
1585
|
+
// `signDeviceLinkApproval` (a raw key) and `buildLinkingTicket(deviceId,
|
|
1586
|
+
// keyPackage)`. Every call below takes the handshake payload the relay returned
|
|
1587
|
+
// together with what THIS device was shown (`expected`) and verifies inside the
|
|
1588
|
+
// call, so nothing can be approved for, built for or sealed to a handshake that
|
|
1589
|
+
// was not verified. `hpkeSeal*` refuse the infos `ping/link/*` and
|
|
1590
|
+
// `ping/link-auth/*`. Host notes: docs-site/api.md, "Device link commitment".
|
|
1591
|
+
/**
|
|
1592
|
+
* The commitment of a handshake payload: what a NEW device shows for the exact
|
|
1593
|
+
* bytes it publishes ({@link MessagingClient.linkHandshakePayload}). `qrText` is
|
|
1594
|
+
* `{"v":3,"h":"<base64url(commitment)>"}`; `code` is the 20 characters the relay
|
|
1595
|
+
* indexes; `codeDisplay` is the same in five groups of four.
|
|
1596
|
+
*/
|
|
1597
|
+
static async linkCommitment(payload) {
|
|
1598
|
+
const parts = await _MessagingClient.ephemeralWorkerCall({
|
|
1599
|
+
kind: "linkCommitment",
|
|
1600
|
+
id: 1,
|
|
1601
|
+
payload
|
|
1602
|
+
});
|
|
1603
|
+
return { commitment: parts[0], qrText: parts[1], code: parts[2], codeDisplay: parts[3] };
|
|
1604
|
+
}
|
|
1161
1605
|
/**
|
|
1162
|
-
*
|
|
1163
|
-
*
|
|
1164
|
-
*
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
*
|
|
1175
|
-
*
|
|
1176
|
-
* {@link
|
|
1177
|
-
*
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1606
|
+
* THE normaliser of a typed link code. Hand it what the person typed; send the
|
|
1607
|
+
* relay, and pass to the calls below, only the 20 characters it returns. No host
|
|
1608
|
+
* normalises a code itself. Rejects anything that is not a code.
|
|
1609
|
+
*/
|
|
1610
|
+
static async normalizeLinkCode(typed) {
|
|
1611
|
+
return _MessagingClient.ephemeralWorkerCall({ kind: "normalizeLinkCode", id: 1, typed });
|
|
1612
|
+
}
|
|
1613
|
+
/** The 32 bytes of a QR text `{"v":3,"h":"..."}`. Rejects any other shape. */
|
|
1614
|
+
static async linkQrCommitment(qrText) {
|
|
1615
|
+
return _MessagingClient.ephemeralWorkerCall({ kind: "linkQrCommitment", id: 1, qrText });
|
|
1616
|
+
}
|
|
1617
|
+
/**
|
|
1618
|
+
* Verify the handshake payload a relay returned against what this device was
|
|
1619
|
+
* shown. Call it BEFORE anything else is done with the handshake. Rejects with
|
|
1620
|
+
* {@link LinkCommitmentMismatchError} when the payload is not the committed one:
|
|
1621
|
+
* send nothing, open no approval session, ask the person to try again.
|
|
1622
|
+
*/
|
|
1623
|
+
static async verifyLinkHandshake(payload, expected) {
|
|
1624
|
+
const all = await _MessagingClient.ephemeralWorkerCall({
|
|
1625
|
+
kind: "verifyLinkHandshake",
|
|
1626
|
+
id: 1,
|
|
1627
|
+
payload,
|
|
1628
|
+
...linkExpectedFields(expected)
|
|
1629
|
+
});
|
|
1630
|
+
if (all.length !== 97) {
|
|
1631
|
+
throw new Error("verifyLinkHandshake: expected 97 bytes");
|
|
1632
|
+
}
|
|
1633
|
+
return {
|
|
1634
|
+
deviceId: all.slice(0, 32),
|
|
1635
|
+
deviceSigningPubkey: all.slice(32, 64),
|
|
1636
|
+
commitment: all.slice(64, 96),
|
|
1637
|
+
verifiedByQr: all[96] === 1
|
|
1638
|
+
};
|
|
1639
|
+
}
|
|
1640
|
+
/**
|
|
1641
|
+
* HPKE-seal the device-linking auth envelope (`ping/link-auth/v2`) to the
|
|
1642
|
+
* X-Wing key of the handshake `payload`, verified inside the call.
|
|
1181
1643
|
*/
|
|
1182
|
-
static async
|
|
1183
|
-
|
|
1644
|
+
static async sealLinkAuthFor(plaintext, payload, expected) {
|
|
1645
|
+
return _MessagingClient.ephemeralWorkerCall({
|
|
1646
|
+
kind: "sealLinkAuthFor",
|
|
1647
|
+
id: 1,
|
|
1648
|
+
plaintext,
|
|
1649
|
+
payload,
|
|
1650
|
+
...linkExpectedFields(expected)
|
|
1651
|
+
});
|
|
1652
|
+
}
|
|
1653
|
+
/**
|
|
1654
|
+
* Link verification v2, on the EXISTING device: approve the new device of the
|
|
1655
|
+
* handshake `payload`, verified inside the call, on one server link session with
|
|
1656
|
+
* this device's signing key. The signed bytes are those of
|
|
1657
|
+
* docs/DEVICE_LINK_V2_VECTORS.md; the key that is approved is the handshake's
|
|
1658
|
+
* device signing key and cannot be passed separately. `audience` as for
|
|
1659
|
+
* {@link signDeviceReauth}. Runs in an ephemeral worker.
|
|
1660
|
+
*/
|
|
1661
|
+
static async signDeviceLinkApprovalFor(params) {
|
|
1662
|
+
const { deviceSigningSecretKey, approvalSessionId, accountId, payload, expected, audience } = params;
|
|
1184
1663
|
if (deviceSigningSecretKey.length !== 32) {
|
|
1185
|
-
throw new Error("
|
|
1664
|
+
throw new Error("signDeviceLinkApprovalFor: deviceSigningSecretKey must be 32 bytes");
|
|
1186
1665
|
}
|
|
1187
1666
|
if (approvalSessionId.length !== 16) {
|
|
1188
|
-
throw new Error("
|
|
1667
|
+
throw new Error("signDeviceLinkApprovalFor: approvalSessionId must be 16 bytes");
|
|
1189
1668
|
}
|
|
1190
1669
|
if (accountId.length !== 16) {
|
|
1191
|
-
throw new Error("
|
|
1192
|
-
}
|
|
1193
|
-
if (newDevicePubkey.length !== 32) {
|
|
1194
|
-
throw new Error("signDeviceLinkApproval: newDevicePubkey must be 32 bytes");
|
|
1670
|
+
throw new Error("signDeviceLinkApprovalFor: accountId must be 16 bytes");
|
|
1195
1671
|
}
|
|
1196
1672
|
const all = await _MessagingClient.ephemeralWorkerCall({
|
|
1197
|
-
kind: "
|
|
1673
|
+
kind: "signDeviceLinkApprovalFor",
|
|
1198
1674
|
id: 1,
|
|
1199
1675
|
deviceSigningSecretKey,
|
|
1200
1676
|
approvalSessionId,
|
|
1201
1677
|
accountId,
|
|
1202
|
-
|
|
1678
|
+
payload,
|
|
1679
|
+
...linkExpectedFields(expected),
|
|
1203
1680
|
audience
|
|
1204
1681
|
});
|
|
1205
1682
|
if (all.length !== 128) {
|
|
1206
|
-
throw new Error("
|
|
1683
|
+
throw new Error("signDeviceLinkApprovalFor: expected 128 bytes");
|
|
1207
1684
|
}
|
|
1208
1685
|
return {
|
|
1209
1686
|
approverDeviceId: all.slice(0, 32),
|
|
@@ -1254,12 +1731,12 @@ var MessagingClient = class _MessagingClient {
|
|
|
1254
1731
|
// result, on a worker `error` (the script failed to load or import, or threw at top
|
|
1255
1732
|
// level), on a `messageerror` (a reply that could not be deserialised), and when the
|
|
1256
1733
|
// worker cannot be created or the request cannot be posted. Only `onmessage` used to be
|
|
1257
|
-
// wired, so a worker that failed to load left
|
|
1734
|
+
// wired, so a worker that failed to load left a static call pending forever and
|
|
1258
1735
|
// the worker alive.
|
|
1259
1736
|
static ephemeralWorkerCall(req) {
|
|
1260
1737
|
let w;
|
|
1261
1738
|
try {
|
|
1262
|
-
w = new Worker(new URL("./worker.js",
|
|
1739
|
+
w = new Worker(new URL("./worker.js", import_meta2.url), { type: "module" });
|
|
1263
1740
|
} catch {
|
|
1264
1741
|
return Promise.reject(new EphemeralWorkerError("spawn"));
|
|
1265
1742
|
}
|
|
@@ -1289,30 +1766,99 @@ var MessagingClient = class _MessagingClient {
|
|
|
1289
1766
|
}
|
|
1290
1767
|
});
|
|
1291
1768
|
}
|
|
1292
|
-
|
|
1293
|
-
|
|
1769
|
+
/**
|
|
1770
|
+
* Start the client FROM THE DEVICE RECORD: the ONE start of a client (after
|
|
1771
|
+
* `AccountSetup`, a link or a restore wrote the record into `cfg.storage`).
|
|
1772
|
+
* The client holds no account key: every leaf and KeyPackage it builds
|
|
1773
|
+
* carries the one credential the device holds (`heldCredential()`). No call
|
|
1774
|
+
* starts a client from an account identity and none hands one out (the
|
|
1775
|
+
* start from an identity export, `generateIdentity` and `exportIdentity`
|
|
1776
|
+
* left every binding on 2026-11-28). Rejects when the
|
|
1777
|
+
* store holds no device record, or when `cfg.deviceSigningSecretKey` is not
|
|
1778
|
+
* the record's own device key.
|
|
1779
|
+
*/
|
|
1780
|
+
static async initFromDeviceRecord(cfg) {
|
|
1781
|
+
return (await _MessagingClient.start(cfg, "record")).client;
|
|
1782
|
+
}
|
|
1783
|
+
/**
|
|
1784
|
+
* Begin a link on a NEW device, in one call: the SDK draws the device key
|
|
1785
|
+
* (no field of `cfg` is a key), records "link begun" in `cfg.storage`,
|
|
1786
|
+
* starts the staging client and builds the handshake payload. A repeat
|
|
1787
|
+
* after a reload answers the SAME key and the SAME handshake. Rejects with
|
|
1788
|
+
* `account refused: account-already-set-up` over a store that already holds
|
|
1789
|
+
* a device.
|
|
1790
|
+
*/
|
|
1791
|
+
static async beginDeviceLink(cfg) {
|
|
1792
|
+
const { client, answer } = await _MessagingClient.start(cfg, "link");
|
|
1793
|
+
const begun = answer;
|
|
1794
|
+
return { client, ...begun };
|
|
1795
|
+
}
|
|
1796
|
+
/**
|
|
1797
|
+
* HPKE-seal a version 3 ticket to the X-Wing key of the handshake `payload`,
|
|
1798
|
+
* verified inside the call (`ping/link/v2`). Rejects a ticket that was built
|
|
1799
|
+
* for another device than the handshake's.
|
|
1800
|
+
*/
|
|
1801
|
+
static async sealLinkingTicketV3For(ticket, payload, expected) {
|
|
1802
|
+
return _MessagingClient.ephemeralWorkerCall({
|
|
1803
|
+
kind: "sealLinkingTicketV3For",
|
|
1804
|
+
id: 1,
|
|
1805
|
+
ticket,
|
|
1806
|
+
payload,
|
|
1807
|
+
...linkExpectedFields(expected)
|
|
1808
|
+
});
|
|
1809
|
+
}
|
|
1810
|
+
/**
|
|
1811
|
+
* HPKE-open a sealed version 3 ticket with the new device's X-Wing seed.
|
|
1812
|
+
* NOT yet verified: `completeDeviceLink` runs every check.
|
|
1813
|
+
*/
|
|
1814
|
+
static async openLinkingTicketV3(sealed, newDevicePriv) {
|
|
1815
|
+
return _MessagingClient.ephemeralWorkerCall({
|
|
1816
|
+
kind: "openLinkingTicketV3",
|
|
1817
|
+
id: 1,
|
|
1818
|
+
sealed,
|
|
1819
|
+
newDevicePriv
|
|
1820
|
+
});
|
|
1821
|
+
}
|
|
1822
|
+
static async start(cfg, mode) {
|
|
1823
|
+
const worker = new Worker(new URL("./worker.js", import_meta2.url), { type: "module" });
|
|
1294
1824
|
const client = new _MessagingClient(cfg, worker);
|
|
1295
1825
|
const transportFeatures = {
|
|
1296
1826
|
fetchLogSince: typeof cfg.transport.fetchLogSince === "function",
|
|
1297
|
-
fetchLogHeads: typeof cfg.transport.fetchLogHeads === "function"
|
|
1827
|
+
fetchLogHeads: typeof cfg.transport.fetchLogHeads === "function",
|
|
1828
|
+
sendExternalCommit: typeof cfg.transport.sendExternalCommit === "function",
|
|
1829
|
+
fetchSelfAdmissionStates: typeof cfg.transport.fetchSelfAdmissionStates === "function",
|
|
1830
|
+
fetchSealedGroupInfos: typeof cfg.transport.fetchSealedGroupInfos === "function",
|
|
1831
|
+
sendExternalCommits: typeof cfg.transport.sendExternalCommits === "function",
|
|
1832
|
+
fetchSealingStatements: typeof cfg.transport.fetchSealingStatements === "function",
|
|
1833
|
+
publishSealedGroupInfo: typeof cfg.transport.publishSealedGroupInfo === "function"
|
|
1298
1834
|
};
|
|
1299
1835
|
const storageFeatures = storageFeaturesOf(client.storage);
|
|
1300
|
-
|
|
1301
|
-
kind: "init",
|
|
1836
|
+
const first = {
|
|
1302
1837
|
id: client.nextId++,
|
|
1303
|
-
identityExport: cfg.identityExport,
|
|
1304
1838
|
deviceLabel: cfg.deviceLabel,
|
|
1305
1839
|
nowMs: client.now(),
|
|
1306
1840
|
...cfg.deviceSigningSecretKey ? { deviceSigningSecretKey: cfg.deviceSigningSecretKey } : {},
|
|
1307
1841
|
...cfg.expectedOwners ? { expectedOwners: cfg.expectedOwners } : {},
|
|
1842
|
+
// Handed on as given: the Worker counts only the value `true`.
|
|
1843
|
+
...cfg.tabClient !== void 0 ? { tabClient: cfg.tabClient } : {},
|
|
1308
1844
|
transportFeatures,
|
|
1309
1845
|
storageFeatures
|
|
1310
|
-
}
|
|
1846
|
+
};
|
|
1847
|
+
const answer = await client.call(
|
|
1848
|
+
mode === "link" ? {
|
|
1849
|
+
kind: "beginDeviceLink",
|
|
1850
|
+
id: first.id,
|
|
1851
|
+
deviceLabel: first.deviceLabel,
|
|
1852
|
+
nowMs: first.nowMs,
|
|
1853
|
+
transportFeatures,
|
|
1854
|
+
storageFeatures
|
|
1855
|
+
} : { kind: "initFromDeviceRecord", ...first }
|
|
1856
|
+
);
|
|
1311
1857
|
client.ownDeviceId = await client.deviceId();
|
|
1312
1858
|
client.subscription = cfg.transport.subscribe(
|
|
1313
1859
|
(frame) => client.dispatchIncoming(frame)
|
|
1314
1860
|
);
|
|
1315
|
-
return client;
|
|
1861
|
+
return { client, answer };
|
|
1316
1862
|
}
|
|
1317
1863
|
/**
|
|
1318
1864
|
* Internal: route an inbound envelope to the right handler, IN ARRIVAL ORDER
|
|
@@ -1442,49 +1988,20 @@ var MessagingClient = class _MessagingClient {
|
|
|
1442
1988
|
async userId() {
|
|
1443
1989
|
return await this.call({ kind: "userId", id: this.nextId++ });
|
|
1444
1990
|
}
|
|
1445
|
-
/**
|
|
1446
|
-
* Export the account identity seed (CBOR-wrapped Ed25519, **SECRET**).
|
|
1447
|
-
* Transfer to a newly-linked device over the sealed linking channel so all of
|
|
1448
|
-
* an account's devices share one `userId` — the basis for cross-device
|
|
1449
|
-
* self-attribution (`IncomingMessage.sender_user_id === userId()`). Never log
|
|
1450
|
-
* or persist in cleartext.
|
|
1451
|
-
*/
|
|
1452
|
-
async exportIdentity() {
|
|
1453
|
-
return await this.call({ kind: "exportIdentity", id: this.nextId++ });
|
|
1454
|
-
}
|
|
1455
|
-
/**
|
|
1456
|
-
* RETIRED (2026-11-03): always rejects (`Invalid`) and changes nothing.
|
|
1457
|
-
*
|
|
1458
|
-
* It moved every conversation's own leaf to a new account identity with a
|
|
1459
|
-
* credential-changing Commit, the way out of `409 mls_identity_conflict`.
|
|
1460
|
-
* Every Ping client now refuses a Commit that changes a member's leaf
|
|
1461
|
-
* credential (a hostile linked device could otherwise move its leaf to a
|
|
1462
|
-
* peer's identity and escape the account's removal), so a rotation would
|
|
1463
|
-
* strand every conversation it touched. The way out of an identity conflict
|
|
1464
|
-
* is to link this device again, or sign out and in. Kept so no caller
|
|
1465
|
-
* breaks. See `docs/MULTIDEVICE.md` "Identity rotation".
|
|
1466
|
-
*
|
|
1467
|
-
* @deprecated Retired: always rejects. Link this device again instead.
|
|
1468
|
-
*/
|
|
1469
|
-
async rotateIdentity(newIdentityExport, nowMs = this.now()) {
|
|
1470
|
-
return await this.call({
|
|
1471
|
-
kind: "rotateIdentity",
|
|
1472
|
-
id: this.nextId++,
|
|
1473
|
-
newIdentityExport,
|
|
1474
|
-
nowMs
|
|
1475
|
-
});
|
|
1476
|
-
}
|
|
1477
|
-
/**
|
|
1478
|
-
* RETIRED with [[rotateIdentity]]: always rejects (`Invalid`).
|
|
1479
|
-
*
|
|
1480
|
-
* @deprecated Retired: always rejects.
|
|
1481
|
-
*/
|
|
1482
|
-
async rotateIdentityRetry(conv, nowMs = this.now()) {
|
|
1483
|
-
await this.call({ kind: "rotateIdentityRetry", id: this.nextId++, conv, nowMs });
|
|
1484
|
-
}
|
|
1485
1991
|
async deviceId() {
|
|
1486
1992
|
return await this.call({ kind: "deviceId", id: this.nextId++ });
|
|
1487
1993
|
}
|
|
1994
|
+
/** The credential this device HOLDS for itself (version 2), which every
|
|
1995
|
+
* leaf and KeyPackage it builds carries. A public value. Never absent
|
|
1996
|
+
* (2026-11-28): every client starts from a device record. Rejects with
|
|
1997
|
+
* `NoDeviceRecord` on a read-only client, which holds no credential. */
|
|
1998
|
+
async heldCredential() {
|
|
1999
|
+
return await this.call({ kind: "heldCredential", id: this.nextId++ });
|
|
2000
|
+
}
|
|
2001
|
+
/** The generation of the held credential. Rejects as `heldCredential` does. */
|
|
2002
|
+
async heldGeneration() {
|
|
2003
|
+
return await this.call({ kind: "heldGeneration", id: this.nextId++ });
|
|
2004
|
+
}
|
|
1488
2005
|
/**
|
|
1489
2006
|
* Release every file lock the MLS store holds so the host process can be
|
|
1490
2007
|
* suspended. Resolves `true` when the locks are genuinely gone.
|
|
@@ -1876,6 +2393,91 @@ var MessagingClient = class _MessagingClient {
|
|
|
1876
2393
|
// See docs/SYNC_PROTOCOL.md "Sequenced log sync". The subscribe path feeds
|
|
1877
2394
|
// these itself for a transport that hands over sequenced frames; they are
|
|
1878
2395
|
// public for hosts that drive their own socket.
|
|
2396
|
+
/**
|
|
2397
|
+
* SELF-ADMISSION: enter `conversationId` by this device's own act, from
|
|
2398
|
+
* what the delivery service returned for it (the sealed GroupInfo and
|
|
2399
|
+
* this account's wrap). Every refusal is a VALUE (`kind: "refused"`);
|
|
2400
|
+
* while the SDK is built without self-admission the answer is `refusal:
|
|
2401
|
+
* "notCompiled"` and nothing was touched. The client reads the anchor
|
|
2402
|
+
* record its device holds by itself, before the join. Rejects only for an
|
|
2403
|
+
* id of the wrong length.
|
|
2404
|
+
*
|
|
2405
|
+
* THE MESSAGES OF A JOIN. `joined` carries `replayed`: messages of this
|
|
2406
|
+
* conversation that waited for the join. Show them, save them and
|
|
2407
|
+
* confirm them (`confirmApplied`) exactly as the messages of a batch
|
|
2408
|
+
* (also for every `joined` entry of `selfAdmitMany`). This client
|
|
2409
|
+
* DELIVERS them to its observers by itself (source `live`), as it
|
|
2410
|
+
* delivers the messages of `processSequencedBatch`; Swift and Kotlin
|
|
2411
|
+
* return them, as they return a batch's messages.
|
|
2412
|
+
*/
|
|
2413
|
+
async selfAdmit(conversationId, fetched) {
|
|
2414
|
+
const result = await this.call({
|
|
2415
|
+
kind: "selfAdmit",
|
|
2416
|
+
id: this.nextId++,
|
|
2417
|
+
conv: conversationId,
|
|
2418
|
+
fetched: {
|
|
2419
|
+
blob: fetched.blob,
|
|
2420
|
+
wrap: fetched.wrap,
|
|
2421
|
+
wrapCount: fetched.wrapCount,
|
|
2422
|
+
...fetched.currentEpoch === void 0 ? {} : { currentEpoch: fetched.currentEpoch }
|
|
2423
|
+
},
|
|
2424
|
+
nowMs: this.now()
|
|
2425
|
+
});
|
|
2426
|
+
if (result.kind === "joined") {
|
|
2427
|
+
holeOfJoin(result);
|
|
2428
|
+
this.fanout.deliverBatch(result.replayed, { source: "live" });
|
|
2429
|
+
}
|
|
2430
|
+
return result;
|
|
2431
|
+
}
|
|
2432
|
+
/**
|
|
2433
|
+
* Enter MANY conversations with few requests (the transport's
|
|
2434
|
+
* `fetchSelfAdmissionStates`, `fetchSealedGroupInfos` and
|
|
2435
|
+
* `sendExternalCommits`): `first` (the conversation on screen) goes to
|
|
2436
|
+
* the head, then the order given, each once. One entry per conversation,
|
|
2437
|
+
* each judged and answered alone. A conversation this device holds and is
|
|
2438
|
+
* not stranded in answers `alreadyHeld` with no request. Nothing is
|
|
2439
|
+
* polled: call again when the account event of a publication arrives.
|
|
2440
|
+
*/
|
|
2441
|
+
async selfAdmitMany(conversations, opts = {}) {
|
|
2442
|
+
const entries = await this.call({
|
|
2443
|
+
kind: "selfAdmitMany",
|
|
2444
|
+
id: this.nextId++,
|
|
2445
|
+
...opts.first === void 0 ? {} : { first: opts.first },
|
|
2446
|
+
conversations,
|
|
2447
|
+
nowMs: this.now()
|
|
2448
|
+
});
|
|
2449
|
+
for (const entry of entries) {
|
|
2450
|
+
if (entry.result.kind === "joined") {
|
|
2451
|
+
holeOfJoin(entry.result);
|
|
2452
|
+
this.fanout.deliverBatch(entry.result.replayed, { source: "live" });
|
|
2453
|
+
}
|
|
2454
|
+
}
|
|
2455
|
+
return entries;
|
|
2456
|
+
}
|
|
2457
|
+
/**
|
|
2458
|
+
* THE ONE CALL A HOST REMEMBERS FOR THE ANCHOR RECORD: write the account's
|
|
2459
|
+
* state part from the RUNNING client. The record of who may sign a
|
|
2460
|
+
* GroupInfo a restoring device enters by is rebuilt from this client's
|
|
2461
|
+
* own conversations first (at every call; the SDK also rebuilds it
|
|
2462
|
+
* by itself during `processSequencedBatch` and at every rotation), and
|
|
2463
|
+
* the part carries it. The host stores the part where it stores every
|
|
2464
|
+
* state part. (`AccountSetup.refreshStateBackup` takes a store and
|
|
2465
|
+
* carries the record as it was last built.)
|
|
2466
|
+
*
|
|
2467
|
+
* A LINKED device owes ONE look first: until `AccountSetup.openStateBackup`
|
|
2468
|
+
* ran once on it, this rejects with the code `state-part-look-owed` (so does
|
|
2469
|
+
* a rotation that keeps the device's key). Pass an EMPTY part there when the
|
|
2470
|
+
* service serves none; whatever it answers, the look is made.
|
|
2471
|
+
*/
|
|
2472
|
+
async refreshStateBackup(args) {
|
|
2473
|
+
return await this.call({
|
|
2474
|
+
kind: "clientRefreshStateBackup",
|
|
2475
|
+
id: this.nextId++,
|
|
2476
|
+
accountId: args.accountId,
|
|
2477
|
+
hostState: args.hostState,
|
|
2478
|
+
nowMs: this.now()
|
|
2479
|
+
});
|
|
2480
|
+
}
|
|
1879
2481
|
/**
|
|
1880
2482
|
* Apply a batch of live frames, each with its server log position, and
|
|
1881
2483
|
* checkpoint once per touched conversation. Per conversation: the next
|
|
@@ -1963,6 +2565,30 @@ var MessagingClient = class _MessagingClient {
|
|
|
1963
2565
|
serverSeq
|
|
1964
2566
|
});
|
|
1965
2567
|
}
|
|
2568
|
+
/**
|
|
2569
|
+
* The holes of one conversation's log on this device, lowest position
|
|
2570
|
+
* first: every position at or below the stored position that was not
|
|
2571
|
+
* applied, with the reason and the content hashes the envelopes named.
|
|
2572
|
+
* `kept: true` entries are rows the SDK still holds and retries by itself.
|
|
2573
|
+
*/
|
|
2574
|
+
async logHoles(id) {
|
|
2575
|
+
const raw = await this.call({ kind: "logHoles", id: this.nextId++, conv: id });
|
|
2576
|
+
return raw.map(logHoleFromWire);
|
|
2577
|
+
}
|
|
2578
|
+
/**
|
|
2579
|
+
* The host filled `fromServerSeq..toServerSeq` (inclusive) of a
|
|
2580
|
+
* conversation from elsewhere (the account's other device): take the range
|
|
2581
|
+
* out of the recorded holes. Resolves `true` when a recorded hole changed.
|
|
2582
|
+
*/
|
|
2583
|
+
async resolveLogHole(id, fromServerSeq, toServerSeq) {
|
|
2584
|
+
return await this.call({
|
|
2585
|
+
kind: "resolveLogHole",
|
|
2586
|
+
id: this.nextId++,
|
|
2587
|
+
conv: id,
|
|
2588
|
+
fromServerSeq,
|
|
2589
|
+
toServerSeq
|
|
2590
|
+
});
|
|
2591
|
+
}
|
|
1966
2592
|
/**
|
|
1967
2593
|
* Conversations the server's heads show this device is behind on: not
|
|
1968
2594
|
* anchored yet, a head above the applied position, or frames held in the
|
|
@@ -2043,28 +2669,17 @@ var MessagingClient = class _MessagingClient {
|
|
|
2043
2669
|
await this.call({ kind: "confirmApplied", id: this.nextId++, journalIds });
|
|
2044
2670
|
}
|
|
2045
2671
|
/**
|
|
2046
|
-
*
|
|
2047
|
-
*
|
|
2048
|
-
*
|
|
2049
|
-
*
|
|
2050
|
-
* Pass `[]` to suppress catchup data — the new device will see an empty conversation
|
|
2051
|
-
* list until normal sync runs.
|
|
2052
|
-
*
|
|
2053
|
-
* Caller is responsible for HPKE-sealing the returned ticket via
|
|
2054
|
-
* `MessagingClient.sealLinkingTicket` before transmitting (CR-3).
|
|
2055
|
-
*
|
|
2056
|
-
* Rejects (`Invalid`), before anything is sent, a KeyPackage that claims the
|
|
2057
|
-
* identity of another account this client knows: a new device links under an
|
|
2058
|
-
* identity of its own, or the account's.
|
|
2672
|
+
* The version 3 handshake payload this NEW device publishes: its own signing key,
|
|
2673
|
+
* the id derived from it, `hpkePublicKey` (X-Wing, 1216 bytes) and a KeyPackage it
|
|
2674
|
+
* just made. Show {@link MessagingClient.linkCommitment} of exactly these bytes and
|
|
2675
|
+
* publish exactly these bytes; nobody re-serialises them.
|
|
2059
2676
|
*/
|
|
2060
|
-
async
|
|
2677
|
+
async linkHandshakePayload(hpkePublicKey, keyPackage) {
|
|
2061
2678
|
return await this.call({
|
|
2062
|
-
kind: "
|
|
2679
|
+
kind: "linkHandshakePayload",
|
|
2063
2680
|
id: this.nextId++,
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
lastAppEvents,
|
|
2067
|
-
nowMs: this.now()
|
|
2681
|
+
hpkePublicKey,
|
|
2682
|
+
keyPackage
|
|
2068
2683
|
});
|
|
2069
2684
|
}
|
|
2070
2685
|
/**
|
|
@@ -2085,18 +2700,201 @@ var MessagingClient = class _MessagingClient {
|
|
|
2085
2700
|
snapshotBytes
|
|
2086
2701
|
});
|
|
2087
2702
|
}
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2703
|
+
/**
|
|
2704
|
+
* The linking ticket, version 3, for the handshake `payload`, verified
|
|
2705
|
+
* inside the call: for a client started from a device record. The new
|
|
2706
|
+
* device's credential is signed by THIS device's key. Rejects when this
|
|
2707
|
+
* device's own chain is at its limit (show the "link from another device"
|
|
2708
|
+
* copy) or it holds no device record. Seal it with
|
|
2709
|
+
* {@link MessagingClient.sealLinkingTicketV3For} and the SAME payload and
|
|
2710
|
+
* `expected`.
|
|
2711
|
+
*/
|
|
2712
|
+
async buildLinkingTicketV3For(payload, expected, lastAppEvents = []) {
|
|
2713
|
+
return await this.call({
|
|
2714
|
+
kind: "buildLinkingTicketV3For",
|
|
2715
|
+
id: this.nextId++,
|
|
2716
|
+
payload,
|
|
2717
|
+
...linkExpectedFields(expected),
|
|
2718
|
+
lastAppEvents,
|
|
2719
|
+
nowMs: this.now()
|
|
2720
|
+
});
|
|
2721
|
+
}
|
|
2722
|
+
/**
|
|
2723
|
+
* The generation and its secret for the link-auth envelope, version 6:
|
|
2724
|
+
* answered only for a handshake whose version 3 ticket this client built
|
|
2725
|
+
* since it started.
|
|
2726
|
+
*/
|
|
2727
|
+
async linkGenerationFor(payload, expected) {
|
|
2728
|
+
return await this.call({
|
|
2729
|
+
kind: "linkGenerationFor",
|
|
2730
|
+
id: this.nextId++,
|
|
2731
|
+
payload,
|
|
2732
|
+
...linkExpectedFields(expected)
|
|
2733
|
+
});
|
|
2734
|
+
}
|
|
2735
|
+
/**
|
|
2736
|
+
* Complete the link on the NEW device, on the staging client of
|
|
2737
|
+
* {@link MessagingClient.beginDeviceLink}: every check of the ticket and of
|
|
2738
|
+
* the envelope's two values, then the DeviceGroup, then the device record.
|
|
2739
|
+
* Rejects with `account refused: link-refused` when anything does not fit:
|
|
2740
|
+
* nothing was kept. Afterwards close this client and start
|
|
2741
|
+
* {@link MessagingClient.initFromDeviceRecord} on the same store.
|
|
2742
|
+
*/
|
|
2743
|
+
async completeDeviceLink(ticket, generation, generationSecret) {
|
|
2744
|
+
return await this.call({
|
|
2745
|
+
kind: "completeDeviceLink",
|
|
2091
2746
|
id: this.nextId++,
|
|
2092
2747
|
ticket,
|
|
2748
|
+
generation,
|
|
2749
|
+
generationSecret,
|
|
2750
|
+
nowMs: this.now(),
|
|
2751
|
+
storageFeatures: storageFeaturesOf(this.storage)
|
|
2752
|
+
});
|
|
2753
|
+
}
|
|
2754
|
+
/**
|
|
2755
|
+
* Create the DeviceGroup anew after a take-over (the account identity
|
|
2756
|
+
* contract, 3.13, "The DeviceGroup reset"): drops what this device holds
|
|
2757
|
+
* under the DeviceGroup's id, then creates the group alone. Call it ONLY
|
|
2758
|
+
* after the server answered the DeviceGroup reset with `200` or with the
|
|
2759
|
+
* reason `already_reset`. There is no call that joins a DeviceGroup from
|
|
2760
|
+
* outside.
|
|
2761
|
+
*/
|
|
2762
|
+
async recreateDeviceGroup() {
|
|
2763
|
+
await this.call({ kind: "recreateDeviceGroup", id: this.nextId++, nowMs: this.now() });
|
|
2764
|
+
}
|
|
2765
|
+
/**
|
|
2766
|
+
* Step 0 of a rotation (removing a device, Secure my account): the next
|
|
2767
|
+
* generation is the pinned one plus one, proven by the root's own
|
|
2768
|
+
* statement, or the call rejects (`account refused:
|
|
2769
|
+
* pinned-generation-unproven`, `generation-ahead`). A listed device is
|
|
2770
|
+
* offered only when its signed delivery key verifies under a leaf of THIS
|
|
2771
|
+
* device's own DeviceGroup. Signs nothing.
|
|
2772
|
+
*/
|
|
2773
|
+
async planRotation(start, devices, rootPartGeneration = 0) {
|
|
2774
|
+
return await this.call({
|
|
2775
|
+
kind: "planRotation",
|
|
2776
|
+
id: this.nextId++,
|
|
2777
|
+
start,
|
|
2778
|
+
devices,
|
|
2779
|
+
rootPartGeneration
|
|
2780
|
+
});
|
|
2781
|
+
}
|
|
2782
|
+
/**
|
|
2783
|
+
* Step 1 of a rotation, THE BUILD, with the pending item of `slot` as the
|
|
2784
|
+
* root's source (an account with no backup yet). It runs in this client's
|
|
2785
|
+
* Worker, which opens the root itself for the length of the call (rulings
|
|
2786
|
+
* V136 and V244): nothing of the root reaches this realm or any other
|
|
2787
|
+
* Worker, in the answer or in a refusal. Only the tab's own client builds
|
|
2788
|
+
* (`ClientConfig.tabClient`); any other answers `account refused:
|
|
2789
|
+
* background-worker`. `kept` is every device that stays, this one
|
|
2790
|
+
* included. The answer is the request for the server (public values and
|
|
2791
|
+
* ciphertext) with the record's id, or `keptSetRefused` naming the one
|
|
2792
|
+
* device that cannot be kept: a value, final for that kept set. The
|
|
2793
|
+
* request carries no root part. No request is made by this call.
|
|
2794
|
+
*/
|
|
2795
|
+
async rotateGenerationWithPending(args) {
|
|
2796
|
+
return await this.call({
|
|
2797
|
+
kind: "rotateGenerationWithPending",
|
|
2798
|
+
id: this.nextId++,
|
|
2799
|
+
slot: args.slot,
|
|
2800
|
+
start: args.start,
|
|
2801
|
+
devices: args.devices,
|
|
2802
|
+
kept: args.kept,
|
|
2803
|
+
reason: args.reason,
|
|
2804
|
+
accountId: args.accountId,
|
|
2805
|
+
hostState: args.hostState,
|
|
2806
|
+
nowMs: this.now()
|
|
2807
|
+
});
|
|
2808
|
+
}
|
|
2809
|
+
/**
|
|
2810
|
+
* Step 1 of a rotation, THE BUILD, with the backup as the root's source:
|
|
2811
|
+
* the root part as the server holds it and the CURRENT recovery phrase,
|
|
2812
|
+
* and `newPhrase` when the person asked for a new one. As
|
|
2813
|
+
* {@link rotateGenerationWithPending}: the root part is opened inside this
|
|
2814
|
+
* client's Worker for the length of the call. The phrases cross to the
|
|
2815
|
+
* Worker as bytes; the Worker zeroes its copy when the call has answered
|
|
2816
|
+
* and this call zeroes the copy it made. The strings themselves are the
|
|
2817
|
+
* host's: drop them. A phrase that does not open the root part answers
|
|
2818
|
+
* `account refused: backup-authentication` and nothing of the cause.
|
|
2819
|
+
*/
|
|
2820
|
+
async rotateGenerationWithBackup(args) {
|
|
2821
|
+
const encoder = new TextEncoder();
|
|
2822
|
+
const phrase = encoder.encode(args.phrase);
|
|
2823
|
+
const newPhrase = args.newPhrase === void 0 ? void 0 : encoder.encode(args.newPhrase);
|
|
2824
|
+
try {
|
|
2825
|
+
return await this.call({
|
|
2826
|
+
kind: "rotateGenerationWithBackup",
|
|
2827
|
+
id: this.nextId++,
|
|
2828
|
+
rootPart: args.rootPart,
|
|
2829
|
+
phrase,
|
|
2830
|
+
...newPhrase ? { newPhrase } : {},
|
|
2831
|
+
start: args.start,
|
|
2832
|
+
devices: args.devices,
|
|
2833
|
+
kept: args.kept,
|
|
2834
|
+
reason: args.reason,
|
|
2835
|
+
accountId: args.accountId,
|
|
2836
|
+
hostState: args.hostState,
|
|
2837
|
+
nowMs: this.now()
|
|
2838
|
+
});
|
|
2839
|
+
} finally {
|
|
2840
|
+
phrase.fill(0);
|
|
2841
|
+
newPhrase?.fill(0);
|
|
2842
|
+
}
|
|
2843
|
+
}
|
|
2844
|
+
/**
|
|
2845
|
+
* Step 3 of a rotation this device built, on the running client: the
|
|
2846
|
+
* server's answer AS RECEIVED, judged inside the SDK (ruling V161; no
|
|
2847
|
+
* value says "applied"). When the device adopts, this client runs on the
|
|
2848
|
+
* new record from that moment. `"undecided"`: nothing changed, the record
|
|
2849
|
+
* stays.
|
|
2850
|
+
*/
|
|
2851
|
+
async completeRotation(recordId, answer) {
|
|
2852
|
+
return await this.call({
|
|
2853
|
+
kind: "completeRotationOnClient",
|
|
2854
|
+
id: this.nextId++,
|
|
2855
|
+
recordId,
|
|
2856
|
+
answer: rotationAnswerFields(answer)
|
|
2857
|
+
});
|
|
2858
|
+
}
|
|
2859
|
+
/**
|
|
2860
|
+
* Step 7 of a rotation, on every other kept device: this device's mailbox
|
|
2861
|
+
* row (`GET /v1/devices/self/credential`). The credential must be this
|
|
2862
|
+
* device's and the root's own; the wrap must open with this device's
|
|
2863
|
+
* delivery key and match the root's statement. On any refusal the device
|
|
2864
|
+
* stays on its generation. From the adoption on, this device's next Commit
|
|
2865
|
+
* in each conversation carries its new credential.
|
|
2866
|
+
*/
|
|
2867
|
+
async adoptGeneration(row) {
|
|
2868
|
+
return await this.call({
|
|
2869
|
+
kind: "adoptGeneration",
|
|
2870
|
+
id: this.nextId++,
|
|
2871
|
+
generation: row.generation,
|
|
2872
|
+
credential: row.credential,
|
|
2873
|
+
gsWrap: row.gsWrap,
|
|
2874
|
+
statement: row.statement,
|
|
2093
2875
|
nowMs: this.now()
|
|
2094
2876
|
});
|
|
2095
2877
|
}
|
|
2096
2878
|
// ------------------------ Recovery (account backup) ------------------------
|
|
2097
2879
|
// All static + stateless: they run on an ephemeral worker, so the recovery screen can
|
|
2098
|
-
// call them before any client is initialised.
|
|
2099
|
-
//
|
|
2880
|
+
// call them before any client is initialised. `encryptBackup` and `decryptBackup`
|
|
2881
|
+
// (the version 1 blob) took and returned the account identity and left every
|
|
2882
|
+
// binding on 2026-11-28: a backup is made, proven and opened by `AccountSetup`
|
|
2883
|
+
// and the restore calls, which hand no root to a host.
|
|
2884
|
+
/**
|
|
2885
|
+
* The one switch of self-admission as the wasm module of this package was
|
|
2886
|
+
* COMPILED (a constant of the SDK's source: the same value in every artifact
|
|
2887
|
+
* built from one commit). Read-only. `false`: the module refuses every
|
|
2888
|
+
* external Commit, lists no capability marker and sends nothing of the
|
|
2889
|
+
* feature. A host that ships more than one artifact asserts at start that
|
|
2890
|
+
* they agree.
|
|
2891
|
+
*/
|
|
2892
|
+
static async selfAdmissionCompiled() {
|
|
2893
|
+
return _MessagingClient.ephemeralWorkerCall({
|
|
2894
|
+
kind: "selfAdmissionCompiled",
|
|
2895
|
+
id: 1
|
|
2896
|
+
});
|
|
2897
|
+
}
|
|
2100
2898
|
/** Generate a fresh 12-word BIP39 mnemonic, returned as its canonical phrase string. */
|
|
2101
2899
|
static async generateMnemonicPhrase() {
|
|
2102
2900
|
return _MessagingClient.ephemeralWorkerCall({
|
|
@@ -2105,7 +2903,7 @@ var MessagingClient = class _MessagingClient {
|
|
|
2105
2903
|
});
|
|
2106
2904
|
}
|
|
2107
2905
|
/** Validate + canonicalise a user-entered phrase (BIP39 wordlist + checksum). Rejects
|
|
2108
|
-
* malformed input.
|
|
2906
|
+
* malformed input. */
|
|
2109
2907
|
static async normalizeMnemonicPhrase(phrase) {
|
|
2110
2908
|
return _MessagingClient.ephemeralWorkerCall({
|
|
2111
2909
|
kind: "normalizeMnemonicPhrase",
|
|
@@ -2113,87 +2911,168 @@ var MessagingClient = class _MessagingClient {
|
|
|
2113
2911
|
phrase
|
|
2114
2912
|
});
|
|
2115
2913
|
}
|
|
2116
|
-
/**
|
|
2117
|
-
*
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2914
|
+
/**
|
|
2915
|
+
* Whether `mnemonicPhrase` opens `blob` (a recovery backup as the server returned
|
|
2916
|
+
* it), with THREE answers to switch on:
|
|
2917
|
+
*
|
|
2918
|
+
* - `{ outcome: "opens" }`;
|
|
2919
|
+
* - `{ outcome: "authenticationFailed" }`: PROOF. The backup's own authentication
|
|
2920
|
+
* check failed under the key derived from the phrase, so the phrase does not open
|
|
2921
|
+
* these exact bytes (wrong words, or bytes that are not what the words sealed: an
|
|
2922
|
+
* AEAD cannot tell a changed or shortened ciphertext from wrong words, so hand in
|
|
2923
|
+
* the complete bytes). The only answer on which to delete a stored phrase;
|
|
2924
|
+
* - `{ outcome: "couldNotCheck", reason }`: DOUBT. A phrase that is not a phrase, a
|
|
2925
|
+
* version or a format this build cannot read, a payload it cannot decode, a
|
|
2926
|
+
* failure inside the SDK. Delete nothing, claim nothing, ask again later.
|
|
2927
|
+
*
|
|
2928
|
+
* This call NEVER rejects: a wasm trap, an out-of-memory failure and a one-shot
|
|
2929
|
+
* worker that could not be created or did not answer are `couldNotCheck` with
|
|
2930
|
+
* `reason: "internal"`. It resolves nothing of the backup: the decrypted identity
|
|
2931
|
+
* is wiped inside the SDK. One Argon2id derivation, on a one-shot worker.
|
|
2932
|
+
*/
|
|
2933
|
+
static async checkBackupPhrase(blob, mnemonicPhrase) {
|
|
2934
|
+
try {
|
|
2935
|
+
return backupPhraseCheckFromWire(
|
|
2936
|
+
await _MessagingClient.ephemeralWorkerCall({
|
|
2937
|
+
kind: "checkBackupPhrase",
|
|
2938
|
+
id: 1,
|
|
2939
|
+
blob,
|
|
2940
|
+
mnemonicPhrase
|
|
2941
|
+
})
|
|
2942
|
+
);
|
|
2943
|
+
} catch {
|
|
2944
|
+
return { outcome: "couldNotCheck", reason: "internal" };
|
|
2945
|
+
}
|
|
2129
2946
|
}
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2947
|
+
// ------------------------ Peer-assisted history transfer ------------------------
|
|
2948
|
+
// History, version 3 (2026-11-25, rulings V88 to V92). A bundle is signed by
|
|
2949
|
+
// this DEVICE's key and sealed only to a key the SDK verified itself: the
|
|
2950
|
+
// signed delivery key of a device that is a verified leaf of this device's own
|
|
2951
|
+
// tree, or the key of a link handshake verified against what the person was
|
|
2952
|
+
// shown. No call takes a recipient key, so a server that answers a key request
|
|
2953
|
+
// with a key of its own gets nothing. The raw-key, seed-signed forms
|
|
2954
|
+
// (sealHistoryBundle, openHistoryBundle and their Pq twins) are REMOVED.
|
|
2955
|
+
/** The counter the next {@link publishHistoryDeliveryKey} with this floor will
|
|
2956
|
+
* sign. A host that keeps the device key outside the SDK's store writes this
|
|
2957
|
+
* number beside that key BEFORE the publish, and passes what it kept as
|
|
2958
|
+
* `counterFloor` from then on (0 when it keeps none). Never a server's number. */
|
|
2959
|
+
async historyDeliveryKeyNextCounter(counterFloor = 0) {
|
|
2960
|
+
return await this.call({
|
|
2961
|
+
kind: "historyDeliveryKeyNextCounter",
|
|
2962
|
+
id: this.nextId++,
|
|
2963
|
+
counterFloor
|
|
2138
2964
|
});
|
|
2139
2965
|
}
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
* 32B) is this account's identity key. Returns the blob to POST to /v1/history-transfers. */
|
|
2148
|
-
static async sealHistoryBundle(bundle, recipientPub, senderIdentitySecret) {
|
|
2149
|
-
return _MessagingClient.ephemeralWorkerCall({
|
|
2150
|
-
kind: "sealHistoryBundle",
|
|
2151
|
-
id: 1,
|
|
2152
|
-
bundle,
|
|
2153
|
-
recipientPub,
|
|
2154
|
-
senderIdentitySecret
|
|
2966
|
+
/** This device's signed history delivery key: post it at every start. The key
|
|
2967
|
+
* pair is made once, inside the SDK; the device signs only the key it holds. */
|
|
2968
|
+
async publishHistoryDeliveryKey(counterFloor = 0) {
|
|
2969
|
+
return await this.call({
|
|
2970
|
+
kind: "publishHistoryDeliveryKey",
|
|
2971
|
+
id: this.nextId++,
|
|
2972
|
+
counterFloor
|
|
2155
2973
|
});
|
|
2156
2974
|
}
|
|
2157
|
-
/**
|
|
2158
|
-
*
|
|
2159
|
-
*
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2975
|
+
/** The server refused the publication (`409 delivery_key_counter_behind`) and
|
|
2976
|
+
* answered with the statement IT holds. Taken only when that statement
|
|
2977
|
+
* verifies strictly under THIS device's own key and is not older than this
|
|
2978
|
+
* device's own; resolves with the statement to publish once more. Anything
|
|
2979
|
+
* else rejects ({@link NotPermittedError}) and nothing is signed. */
|
|
2980
|
+
async adoptHistoryDeliveryKeyCounter(stored) {
|
|
2981
|
+
return await this.call({
|
|
2982
|
+
kind: "adoptHistoryDeliveryKeyCounter",
|
|
2983
|
+
id: this.nextId++,
|
|
2984
|
+
stored
|
|
2167
2985
|
});
|
|
2168
2986
|
}
|
|
2169
2987
|
/**
|
|
2170
|
-
*
|
|
2171
|
-
*
|
|
2172
|
-
* the
|
|
2988
|
+
* Verify `recipient` (the statement a server returned for the device the bundle
|
|
2989
|
+
* names) in this device's own tree, then sign the bundle with the device key and
|
|
2990
|
+
* seal it to that key. `ownAccount` is what the host believes (true: a device of
|
|
2991
|
+
* this account, looked up in the DeviceGroup; false: another account's device,
|
|
2992
|
+
* looked up in the tree of the bundle's conversation). It decides nothing: the
|
|
2993
|
+
* SDK takes the path the recipient's verified identity gives and rejects
|
|
2994
|
+
* ({@link NotPermittedError}) when the host said the other one.
|
|
2173
2995
|
*/
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
return _MessagingClient.ephemeralWorkerCall({
|
|
2179
|
-
kind: "sealHistoryBundlePq",
|
|
2180
|
-
id: 1,
|
|
2996
|
+
async sealHistoryBundleV3(bundle, recipient, ownAccount) {
|
|
2997
|
+
return await this.call({
|
|
2998
|
+
kind: "sealHistoryBundleV3",
|
|
2999
|
+
id: this.nextId++,
|
|
2181
3000
|
bundle,
|
|
2182
|
-
|
|
2183
|
-
|
|
3001
|
+
recipient,
|
|
3002
|
+
ownAccount
|
|
2184
3003
|
});
|
|
2185
3004
|
}
|
|
2186
|
-
/**
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
return
|
|
2192
|
-
kind: "
|
|
2193
|
-
id:
|
|
3005
|
+
/** The link's own transfer. The handshake `payload` is verified inside the call
|
|
3006
|
+
* against what this device was shown, and the bundle is sealed to the verified
|
|
3007
|
+
* handshake's key: no key can be passed. Rejects with
|
|
3008
|
+
* {@link LinkCommitmentMismatchError} when the payload is not the committed one. */
|
|
3009
|
+
async sealLinkHistoryBundle(bundle, payload, expected) {
|
|
3010
|
+
return await this.call({
|
|
3011
|
+
kind: "sealLinkHistoryBundle",
|
|
3012
|
+
id: this.nextId++,
|
|
3013
|
+
bundle,
|
|
3014
|
+
payload,
|
|
3015
|
+
...linkExpectedFields(expected)
|
|
3016
|
+
});
|
|
3017
|
+
}
|
|
3018
|
+
/** Open a transfer sealed to this device's published delivery key. `ownAccount`
|
|
3019
|
+
* as in {@link sealHistoryBundleV3}, and as there only a reason to refuse. A
|
|
3020
|
+
* bundle whose import the host CONFIRMED ({@link confirmHistoryImport}) is never
|
|
3021
|
+
* returned again: the transfer then rejects with {@link HistoryRefusedError}
|
|
3022
|
+
* `replayed`, and the host drops it. Until the confirmation the same transfer
|
|
3023
|
+
* opens again (the host's import is idempotent by event id). */
|
|
3024
|
+
async openHistoryBundleV3(sealed, ownAccount) {
|
|
3025
|
+
return await this.call({
|
|
3026
|
+
kind: "openHistoryBundleV3",
|
|
3027
|
+
id: this.nextId++,
|
|
2194
3028
|
sealed,
|
|
2195
|
-
|
|
2196
|
-
|
|
3029
|
+
ownAccount
|
|
3030
|
+
});
|
|
3031
|
+
}
|
|
3032
|
+
/** The NEW device opens its link's own transfer, sealed to the X-Wing key of the
|
|
3033
|
+
* handshake it published; `recipientPriv` is that key's 32-byte seed. */
|
|
3034
|
+
async openLinkHistoryBundle(sealed, recipientPriv) {
|
|
3035
|
+
return await this.call({
|
|
3036
|
+
kind: "openLinkHistoryBundle",
|
|
3037
|
+
id: this.nextId++,
|
|
3038
|
+
sealed,
|
|
3039
|
+
recipientPriv
|
|
3040
|
+
});
|
|
3041
|
+
}
|
|
3042
|
+
/** Ruling V177: call AFTER the host's own store holds the events of a bundle an
|
|
3043
|
+
* open returned, with that result's `import_id`. From then on the same bundle
|
|
3044
|
+
* (sealed afresh or not, from any sender) is refused as a replay. `true` when
|
|
3045
|
+
* this call recorded it, `false` when it was recorded before. The id may be
|
|
3046
|
+
* kept and confirmed after a restart. A local write; no request. */
|
|
3047
|
+
async confirmHistoryImport(importId) {
|
|
3048
|
+
return await this.call({
|
|
3049
|
+
kind: "confirmHistoryImport",
|
|
3050
|
+
id: this.nextId++,
|
|
3051
|
+
importId
|
|
3052
|
+
});
|
|
3053
|
+
}
|
|
3054
|
+
/** Whether this device's trust record names `deviceId` for history. */
|
|
3055
|
+
async historyTrust(deviceId) {
|
|
3056
|
+
return await this.call({
|
|
3057
|
+
kind: "historyTrust",
|
|
3058
|
+
id: this.nextId++,
|
|
3059
|
+
deviceId
|
|
3060
|
+
});
|
|
3061
|
+
}
|
|
3062
|
+
/** Record that this device shipped history to `deviceId`, once the server
|
|
3063
|
+
* accepted the transfer and never before. */
|
|
3064
|
+
async recordHistoryShipped(deviceId) {
|
|
3065
|
+
await this.call({ kind: "recordHistoryShipped", id: this.nextId++, deviceId });
|
|
3066
|
+
}
|
|
3067
|
+
/** For a device of this account: ship history by itself, only after the person
|
|
3068
|
+
* confirms on this device, or not at all. Ask it for every entry of the
|
|
3069
|
+
* admission ledger and before the "send your chats" prompt; a link's own
|
|
3070
|
+
* transfer does not ask. */
|
|
3071
|
+
async historyShipDecision(deviceId) {
|
|
3072
|
+
return await this.call({
|
|
3073
|
+
kind: "historyShipDecision",
|
|
3074
|
+
id: this.nextId++,
|
|
3075
|
+
deviceId
|
|
2197
3076
|
});
|
|
2198
3077
|
}
|
|
2199
3078
|
/**
|
|
@@ -2330,6 +3209,32 @@ var MessagingClient = class _MessagingClient {
|
|
|
2330
3209
|
nowMs
|
|
2331
3210
|
});
|
|
2332
3211
|
}
|
|
3212
|
+
/**
|
|
3213
|
+
* THE ONE TAP AFTER A RESTORE BESIDE DEVICES THAT STAY (ruling V123). Call it on
|
|
3214
|
+
* a KEPT device when the person confirmed, on that device, the device `deviceId`
|
|
3215
|
+
* that restored with the recovery phrase and waits for its DeviceGroup.
|
|
3216
|
+
* `keyPackage` is a KeyPackage of that device, as the host fetched it. Nothing
|
|
3217
|
+
* the server says is believed: the KeyPackage must be the named device's, and its
|
|
3218
|
+
* credential must verify for THIS device's own account root, be signed by the
|
|
3219
|
+
* root itself (a linked device enters by its ticket) and stand at the generation
|
|
3220
|
+
* this device holds; anything else rejects (`NotPermitted`; `StaleGeneration`
|
|
3221
|
+
* when this device is behind its account). Then the DeviceGroup's ordinary Add,
|
|
3222
|
+
* sent with its Welcome and merged only when the delivery service accepted. As
|
|
3223
|
+
* every Commit there it rejects with `DeviceGroupBehind` while this device is
|
|
3224
|
+
* behind or may not commit yet after a rotation (catch up, or run the sweep, and
|
|
3225
|
+
* call again), and with `WelcomeUndelivered` when the Add is in and the Welcome is
|
|
3226
|
+
* not (call again). The waiting device calls nothing: the Welcome reaches it by
|
|
3227
|
+
* the transport. MLS only.
|
|
3228
|
+
*/
|
|
3229
|
+
async addRestoredDevice(deviceId, keyPackage, nowMs = this.now()) {
|
|
3230
|
+
await this.call({
|
|
3231
|
+
kind: "addRestoredDevice",
|
|
3232
|
+
id: this.nextId++,
|
|
3233
|
+
deviceId,
|
|
3234
|
+
keyPackage,
|
|
3235
|
+
nowMs
|
|
3236
|
+
});
|
|
3237
|
+
}
|
|
2333
3238
|
/**
|
|
2334
3239
|
* Export a portable MLS state snapshot for one conversation ([CR-7]).
|
|
2335
3240
|
*
|
|
@@ -2630,6 +3535,29 @@ var MessagingClient = class _MessagingClient {
|
|
|
2630
3535
|
const heads = await this.transport.fetchLogHeads();
|
|
2631
3536
|
return heads === null || heads === void 0 ? null : heads.map(logHeadToWire);
|
|
2632
3537
|
}
|
|
3538
|
+
if (method === "send" || method === "sendBatch") {
|
|
3539
|
+
try {
|
|
3540
|
+
return await t[method]?.(...args);
|
|
3541
|
+
} catch (e) {
|
|
3542
|
+
if (e?.staleGeneration === true) {
|
|
3543
|
+
throw new Error(TRANSPORT_STALE_GENERATION);
|
|
3544
|
+
}
|
|
3545
|
+
throw e;
|
|
3546
|
+
}
|
|
3547
|
+
}
|
|
3548
|
+
if (method === "sendExternalCommit" || method === "sendExternalCommits" || method === "publishSealedGroupInfo") {
|
|
3549
|
+
try {
|
|
3550
|
+
return await t[method]?.(...args) ?? null;
|
|
3551
|
+
} catch (e) {
|
|
3552
|
+
if (e?.epochOccupied === true) {
|
|
3553
|
+
throw new Error(EXTERNAL_COMMIT_EPOCH_OCCUPIED);
|
|
3554
|
+
}
|
|
3555
|
+
if (e?.staleGeneration === true) {
|
|
3556
|
+
throw new Error(TRANSPORT_STALE_GENERATION);
|
|
3557
|
+
}
|
|
3558
|
+
throw e;
|
|
3559
|
+
}
|
|
3560
|
+
}
|
|
2633
3561
|
return await t[method]?.(...args);
|
|
2634
3562
|
}
|
|
2635
3563
|
async handleWorker(msg) {
|
|
@@ -2702,6 +3630,20 @@ var MessagingClient = class _MessagingClient {
|
|
|
2702
3630
|
}
|
|
2703
3631
|
}
|
|
2704
3632
|
};
|
|
3633
|
+
var BACKUP_CHECK_FAILURES = [
|
|
3634
|
+
"invalidPhrase",
|
|
3635
|
+
"unsupportedVersion",
|
|
3636
|
+
"malformed",
|
|
3637
|
+
"undecodable",
|
|
3638
|
+
"internal"
|
|
3639
|
+
];
|
|
3640
|
+
function backupPhraseCheckFromWire(raw) {
|
|
3641
|
+
const rec = raw !== null && typeof raw === "object" ? raw : {};
|
|
3642
|
+
if (rec.outcome === "opens") return { outcome: "opens" };
|
|
3643
|
+
if (rec.outcome === "authenticationFailed") return { outcome: "authenticationFailed" };
|
|
3644
|
+
const reason = rec.outcome === "couldNotCheck" ? BACKUP_CHECK_FAILURES.find((known) => known === rec.reason) : void 0;
|
|
3645
|
+
return { outcome: "couldNotCheck", reason: reason ?? "internal" };
|
|
3646
|
+
}
|
|
2705
3647
|
var EphemeralWorkerError = class extends Error {
|
|
2706
3648
|
reason;
|
|
2707
3649
|
constructor(reason) {
|
|
@@ -2749,11 +3691,162 @@ function isSenderMismatchError(e) {
|
|
|
2749
3691
|
const text = typeof e === "string" ? e : e !== null && typeof e === "object" && typeof e.message === "string" ? e.message : null;
|
|
2750
3692
|
return text !== null && text.startsWith(SENDER_MISMATCH_PREFIX);
|
|
2751
3693
|
}
|
|
3694
|
+
var STORE_MOVED_PREFIX = "store moved: ";
|
|
3695
|
+
var StoreMovedError = class extends Error {
|
|
3696
|
+
constructor(message) {
|
|
3697
|
+
super(message);
|
|
3698
|
+
this.name = "StoreMovedError";
|
|
3699
|
+
}
|
|
3700
|
+
};
|
|
3701
|
+
function isStoreMovedError(e) {
|
|
3702
|
+
const text = typeof e === "string" ? e : e !== null && typeof e === "object" && typeof e.message === "string" ? e.message : null;
|
|
3703
|
+
return text !== null && text.startsWith(STORE_MOVED_PREFIX);
|
|
3704
|
+
}
|
|
3705
|
+
var READ_ONLY_PREFIX = "read-only client: ";
|
|
3706
|
+
var ReadOnlyError = class extends Error {
|
|
3707
|
+
constructor(message) {
|
|
3708
|
+
super(message);
|
|
3709
|
+
this.name = "ReadOnlyError";
|
|
3710
|
+
}
|
|
3711
|
+
};
|
|
3712
|
+
function isReadOnlyError(e) {
|
|
3713
|
+
const text = typeof e === "string" ? e : e !== null && typeof e === "object" && typeof e.message === "string" ? e.message : null;
|
|
3714
|
+
return text !== null && text.startsWith(READ_ONLY_PREFIX);
|
|
3715
|
+
}
|
|
3716
|
+
function linkExpectedFields(expected) {
|
|
3717
|
+
return "code" in expected ? { expectedCode: expected.code } : { expectedQr: expected.qrCommitment };
|
|
3718
|
+
}
|
|
3719
|
+
var LINK_COMMITMENT_MISMATCH_PREFIX = "link commitment mismatch: ";
|
|
3720
|
+
var LinkCommitmentMismatchError = class extends Error {
|
|
3721
|
+
constructor(message) {
|
|
3722
|
+
super(message);
|
|
3723
|
+
this.name = "LinkCommitmentMismatchError";
|
|
3724
|
+
}
|
|
3725
|
+
};
|
|
3726
|
+
function isLinkCommitmentMismatchError(e) {
|
|
3727
|
+
if (e instanceof LinkCommitmentMismatchError) return true;
|
|
3728
|
+
const text = e instanceof Error ? e.message : typeof e === "string" ? e : null;
|
|
3729
|
+
return text !== null && text.startsWith(LINK_COMMITMENT_MISMATCH_PREFIX);
|
|
3730
|
+
}
|
|
3731
|
+
var WELCOME_MISLABELED_PREFIX = "welcome mislabeled: ";
|
|
3732
|
+
var WelcomeMislabeledError = class extends Error {
|
|
3733
|
+
constructor(message) {
|
|
3734
|
+
super(message);
|
|
3735
|
+
this.name = "WelcomeMislabeledError";
|
|
3736
|
+
}
|
|
3737
|
+
};
|
|
3738
|
+
function isWelcomeMislabeledError(e) {
|
|
3739
|
+
const text = typeof e === "string" ? e : e !== null && typeof e === "object" && typeof e.message === "string" ? e.message : null;
|
|
3740
|
+
return text !== null && text.startsWith(WELCOME_MISLABELED_PREFIX);
|
|
3741
|
+
}
|
|
3742
|
+
var STALE_GENERATION_PREFIX = "stale generation: ";
|
|
3743
|
+
var StaleGenerationError = class extends Error {
|
|
3744
|
+
constructor(message) {
|
|
3745
|
+
super(message);
|
|
3746
|
+
this.name = "StaleGenerationError";
|
|
3747
|
+
}
|
|
3748
|
+
};
|
|
3749
|
+
function isStaleGenerationError(e) {
|
|
3750
|
+
const text = typeof e === "string" ? e : e !== null && typeof e === "object" && typeof e.message === "string" ? e.message : null;
|
|
3751
|
+
return text !== null && text.startsWith(STALE_GENERATION_PREFIX);
|
|
3752
|
+
}
|
|
3753
|
+
var DEVICE_GROUP_BEHIND_PREFIX = "device group behind: ";
|
|
3754
|
+
var DeviceGroupBehindError = class extends Error {
|
|
3755
|
+
constructor(message) {
|
|
3756
|
+
super(message);
|
|
3757
|
+
this.name = "DeviceGroupBehindError";
|
|
3758
|
+
}
|
|
3759
|
+
};
|
|
3760
|
+
function isDeviceGroupBehindError(e) {
|
|
3761
|
+
const text = typeof e === "string" ? e : e !== null && typeof e === "object" && typeof e.message === "string" ? e.message : null;
|
|
3762
|
+
return text !== null && text.startsWith(DEVICE_GROUP_BEHIND_PREFIX);
|
|
3763
|
+
}
|
|
3764
|
+
var LINK_CHAIN_TOO_DEEP_PREFIX = "link chain too deep: ";
|
|
3765
|
+
var LinkChainTooDeepError = class extends Error {
|
|
3766
|
+
constructor(message) {
|
|
3767
|
+
super(message);
|
|
3768
|
+
this.name = "LinkChainTooDeepError";
|
|
3769
|
+
}
|
|
3770
|
+
};
|
|
3771
|
+
var LINK_ADD_REFUSED_PREFIX = "link add refused: ";
|
|
3772
|
+
var LinkAddRefusedError = class extends Error {
|
|
3773
|
+
constructor(message) {
|
|
3774
|
+
super(message);
|
|
3775
|
+
this.name = "LinkAddRefusedError";
|
|
3776
|
+
}
|
|
3777
|
+
};
|
|
3778
|
+
var WELCOME_WAITS_PREFIX = "welcome waits: ";
|
|
3779
|
+
var WelcomeWaitsError = class extends Error {
|
|
3780
|
+
constructor(message) {
|
|
3781
|
+
super(message);
|
|
3782
|
+
this.name = "WelcomeWaitsError";
|
|
3783
|
+
}
|
|
3784
|
+
};
|
|
3785
|
+
function startsWithPrefix(e, prefix) {
|
|
3786
|
+
const text = typeof e === "string" ? e : e !== null && typeof e === "object" && typeof e.message === "string" ? e.message : null;
|
|
3787
|
+
return text !== null && text.startsWith(prefix);
|
|
3788
|
+
}
|
|
3789
|
+
function isLinkChainTooDeepError(e) {
|
|
3790
|
+
return startsWithPrefix(e, LINK_CHAIN_TOO_DEEP_PREFIX);
|
|
3791
|
+
}
|
|
3792
|
+
function isLinkAddRefusedError(e) {
|
|
3793
|
+
return startsWithPrefix(e, LINK_ADD_REFUSED_PREFIX);
|
|
3794
|
+
}
|
|
3795
|
+
function isWelcomeWaitsError(e) {
|
|
3796
|
+
return startsWithPrefix(e, WELCOME_WAITS_PREFIX);
|
|
3797
|
+
}
|
|
3798
|
+
var HISTORY_REFUSED_PREFIX = "history refused: ";
|
|
3799
|
+
var HistoryRefusedError = class extends Error {
|
|
3800
|
+
reason;
|
|
3801
|
+
constructor(message) {
|
|
3802
|
+
super(message);
|
|
3803
|
+
this.name = "HistoryRefusedError";
|
|
3804
|
+
const reason = message.slice(HISTORY_REFUSED_PREFIX.length);
|
|
3805
|
+
this.reason = HISTORY_REFUSAL_REASONS.includes(reason) ? reason : "unknown";
|
|
3806
|
+
}
|
|
3807
|
+
};
|
|
3808
|
+
var HISTORY_REFUSAL_REASONS = [
|
|
3809
|
+
"recipient",
|
|
3810
|
+
"sender",
|
|
3811
|
+
"signature",
|
|
3812
|
+
"recipient-key",
|
|
3813
|
+
"too-large",
|
|
3814
|
+
"replayed"
|
|
3815
|
+
];
|
|
3816
|
+
function isHistoryRefusedError(e) {
|
|
3817
|
+
if (e instanceof HistoryRefusedError) return true;
|
|
3818
|
+
const text = typeof e === "string" ? e : e !== null && typeof e === "object" && typeof e.message === "string" ? e.message : null;
|
|
3819
|
+
return text !== null && text.startsWith(HISTORY_REFUSED_PREFIX);
|
|
3820
|
+
}
|
|
3821
|
+
var JOURNAL_FULL_PREFIX = "journal full: ";
|
|
3822
|
+
var JournalFullError = class extends Error {
|
|
3823
|
+
constructor(message) {
|
|
3824
|
+
super(message);
|
|
3825
|
+
this.name = "JournalFullError";
|
|
3826
|
+
}
|
|
3827
|
+
};
|
|
3828
|
+
function isJournalFullError(e) {
|
|
3829
|
+
const text = typeof e === "string" ? e : e !== null && typeof e === "object" && typeof e.message === "string" ? e.message : null;
|
|
3830
|
+
return text !== null && text.startsWith(JOURNAL_FULL_PREFIX);
|
|
3831
|
+
}
|
|
2752
3832
|
function errorFromWorker(text) {
|
|
2753
3833
|
if (text.startsWith(NOT_PERMITTED_PREFIX)) return new NotPermittedError(text);
|
|
2754
3834
|
if (text.startsWith(SENDER_MISMATCH_PREFIX)) return new SenderMismatchError(text);
|
|
3835
|
+
if (text.startsWith(STORE_MOVED_PREFIX)) return new StoreMovedError(text);
|
|
3836
|
+
if (text.startsWith(READ_ONLY_PREFIX)) return new ReadOnlyError(text);
|
|
3837
|
+
if (text.startsWith(WELCOME_MISLABELED_PREFIX)) return new WelcomeMislabeledError(text);
|
|
3838
|
+
if (text.startsWith(LINK_COMMITMENT_MISMATCH_PREFIX)) return new LinkCommitmentMismatchError(text);
|
|
3839
|
+
if (text.startsWith(STALE_GENERATION_PREFIX)) return new StaleGenerationError(text);
|
|
3840
|
+
if (text.startsWith(DEVICE_GROUP_BEHIND_PREFIX)) return new DeviceGroupBehindError(text);
|
|
3841
|
+
if (text.startsWith(JOURNAL_FULL_PREFIX)) return new JournalFullError(text);
|
|
3842
|
+
if (text.startsWith(LINK_CHAIN_TOO_DEEP_PREFIX)) return new LinkChainTooDeepError(text);
|
|
3843
|
+
if (text.startsWith(LINK_ADD_REFUSED_PREFIX)) return new LinkAddRefusedError(text);
|
|
3844
|
+
if (text.startsWith(WELCOME_WAITS_PREFIX)) return new WelcomeWaitsError(text);
|
|
3845
|
+
if (text.startsWith(HISTORY_REFUSED_PREFIX)) return new HistoryRefusedError(text);
|
|
2755
3846
|
return new Error(text);
|
|
2756
3847
|
}
|
|
3848
|
+
var EXTERNAL_COMMIT_EPOCH_OCCUPIED = "external commit: epoch occupied";
|
|
3849
|
+
var TRANSPORT_STALE_GENERATION = "transport: stale generation";
|
|
2757
3850
|
async function emulateSendBatch(transport, envelopes) {
|
|
2758
3851
|
let delivered = 0;
|
|
2759
3852
|
for (const envelope of envelopes) {
|
|
@@ -2796,17 +3889,36 @@ function sameBytesU8(a, b) {
|
|
|
2796
3889
|
for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return false;
|
|
2797
3890
|
return true;
|
|
2798
3891
|
}
|
|
3892
|
+
function holeOfJoin(result) {
|
|
3893
|
+
if (result.beforeReturn !== void 0 && result.beforeReturn !== null) {
|
|
3894
|
+
result.beforeReturn = logHoleFromWire(result.beforeReturn);
|
|
3895
|
+
}
|
|
3896
|
+
}
|
|
2799
3897
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2800
3898
|
0 && (module.exports = {
|
|
3899
|
+
AccountSetup,
|
|
3900
|
+
AccountSetupClosedError,
|
|
2801
3901
|
BATCH_PARTIAL_PREFIX,
|
|
2802
3902
|
CONTENT_TYPE_CBOR,
|
|
2803
3903
|
CONTENT_TYPE_CBOR_LEGACY_V1,
|
|
2804
3904
|
CONTENT_TYPE_JSON,
|
|
2805
3905
|
CONTENT_TYPE_JSON_LEGACY_V1,
|
|
3906
|
+
DEVICE_GROUP_BEHIND_PREFIX,
|
|
3907
|
+
DeviceGroupBehindError,
|
|
2806
3908
|
EphemeralWorkerError,
|
|
3909
|
+
HISTORY_REFUSED_PREFIX,
|
|
2807
3910
|
HPKE_PQ_ENC_BYTES,
|
|
2808
3911
|
HPKE_PQ_PUBLIC_KEY_BYTES,
|
|
3912
|
+
HistoryRefusedError,
|
|
2809
3913
|
IndexedDbStorage,
|
|
3914
|
+
JOURNAL_FULL_PREFIX,
|
|
3915
|
+
JournalFullError,
|
|
3916
|
+
LINK_ADD_REFUSED_PREFIX,
|
|
3917
|
+
LINK_CHAIN_TOO_DEEP_PREFIX,
|
|
3918
|
+
LINK_COMMITMENT_MISMATCH_PREFIX,
|
|
3919
|
+
LinkAddRefusedError,
|
|
3920
|
+
LinkChainTooDeepError,
|
|
3921
|
+
LinkCommitmentMismatchError,
|
|
2810
3922
|
MAX_PREVIEW_PREREQUISITES,
|
|
2811
3923
|
MessagingClient,
|
|
2812
3924
|
MessagingClientClosedError,
|
|
@@ -2815,15 +3927,38 @@ function sameBytesU8(a, b) {
|
|
|
2815
3927
|
PING_WIRE_CONTRACT_HEADER,
|
|
2816
3928
|
PING_WIRE_CONTRACT_HEADER_VALUE,
|
|
2817
3929
|
PING_WIRE_CONTRACT_VERSION,
|
|
3930
|
+
READ_ONLY_PREFIX,
|
|
3931
|
+
ReadOnlyError,
|
|
2818
3932
|
SENDER_MISMATCH_PREFIX,
|
|
3933
|
+
STALE_GENERATION_PREFIX,
|
|
3934
|
+
STORE_MOVED_PREFIX,
|
|
2819
3935
|
SenderMismatchError,
|
|
3936
|
+
StaleGenerationError,
|
|
3937
|
+
StoreMovedError,
|
|
2820
3938
|
ValidationError,
|
|
3939
|
+
WELCOME_MISLABELED_PREFIX,
|
|
3940
|
+
WELCOME_WAITS_PREFIX,
|
|
2821
3941
|
WIRE_VERSION_MIN_ACCEPTED,
|
|
2822
3942
|
WebSocketTransport,
|
|
3943
|
+
WelcomeMislabeledError,
|
|
3944
|
+
WelcomeWaitsError,
|
|
3945
|
+
accountRefusalCode,
|
|
3946
|
+
backupPhraseCheckFromWire,
|
|
2823
3947
|
describeTransportError,
|
|
2824
3948
|
emulateSendBatch,
|
|
3949
|
+
isDeviceGroupBehindError,
|
|
3950
|
+
isHistoryRefusedError,
|
|
3951
|
+
isJournalFullError,
|
|
3952
|
+
isLinkAddRefusedError,
|
|
3953
|
+
isLinkChainTooDeepError,
|
|
3954
|
+
isLinkCommitmentMismatchError,
|
|
2825
3955
|
isNotPermittedError,
|
|
3956
|
+
isReadOnlyError,
|
|
2826
3957
|
isSenderMismatchError,
|
|
3958
|
+
isStaleGenerationError,
|
|
3959
|
+
isStoreMovedError,
|
|
3960
|
+
isWelcomeMislabeledError,
|
|
3961
|
+
isWelcomeWaitsError,
|
|
2827
3962
|
negotiates,
|
|
2828
3963
|
notPermittedRule,
|
|
2829
3964
|
openNotificationPreview,
|