@ping-app/ping-openmls-sdk 0.9.2 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +68 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +51 -4
- package/dist/index.d.ts +51 -4
- package/dist/index.js +68 -8
- package/dist/index.js.map +1 -1
- package/dist/worker.cjs +208 -53
- package/dist/worker.cjs.map +1 -1
- package/dist/worker.js +208 -53
- package/dist/worker.js.map +1 -1
- package/package.json +1 -1
- package/wasm/package.json +1 -1
- package/wasm/ping_wasm.d.ts +21 -2
- package/wasm/ping_wasm.js +56 -20
- package/wasm/ping_wasm_bg.wasm +0 -0
- package/wasm/ping_wasm_bg.wasm.d.ts +3 -2
package/dist/index.d.cts
CHANGED
|
@@ -174,8 +174,15 @@ interface Conversation {
|
|
|
174
174
|
* group-name capability shipped, else the SDK throws. */
|
|
175
175
|
setConversationName(name: string | null): Promise<void>;
|
|
176
176
|
/**
|
|
177
|
-
* The conversation's MLS GroupContext name
|
|
178
|
-
* has
|
|
177
|
+
* The conversation's MLS GroupContext name as the group holds it now, or
|
|
178
|
+
* `undefined` when the group has none or the client holds no metadata for
|
|
179
|
+
* the conversation (it is not held, or nothing has reported it yet: read it
|
|
180
|
+
* with `readConversationMeta(id)`).
|
|
181
|
+
*
|
|
182
|
+
* Never the name from before a change. The client's copy of a conversation's
|
|
183
|
+
* metadata is replaced before any `onConversationUpdated` listener is told
|
|
184
|
+
* the conversation changed, and before this device's own call that changed
|
|
185
|
+
* it resolves (see `MessagingClient.readConversationMeta`).
|
|
179
186
|
*
|
|
180
187
|
* This accessor was MISSING, and hosts reasonably assumed it existed:
|
|
181
188
|
* `getConversation(id).name` read `undefined` on every call, so any host logic
|
|
@@ -186,9 +193,13 @@ interface Conversation {
|
|
|
186
193
|
* one-field convenience that hosts were already reaching for.
|
|
187
194
|
*/
|
|
188
195
|
readonly name?: string | undefined;
|
|
189
|
-
/** The conversation's current MLS epoch, or `undefined` when the
|
|
190
|
-
*
|
|
196
|
+
/** The conversation's current MLS epoch, or `undefined` when the client
|
|
197
|
+
* holds no metadata for the conversation. Never an epoch from before a
|
|
198
|
+
* change the host was already told about. */
|
|
191
199
|
readonly epoch?: number | undefined;
|
|
200
|
+
/** The whole record, as fresh as `name`. Throws when the client holds no
|
|
201
|
+
* metadata for the conversation: `readConversationMeta(id)` answers `null`
|
|
202
|
+
* instead, and tells "not held" from "not read yet". */
|
|
192
203
|
meta(): ConversationMeta;
|
|
193
204
|
}
|
|
194
205
|
declare class MessagingClient {
|
|
@@ -202,6 +213,19 @@ declare class MessagingClient {
|
|
|
202
213
|
private readonly fanout;
|
|
203
214
|
private conversationHandlers;
|
|
204
215
|
private subscription;
|
|
216
|
+
/**
|
|
217
|
+
* This client's copy of each conversation's metadata, keyed by lowercase-hex
|
|
218
|
+
* conversation id: what a conversation handle's `name`, `epoch` and `meta()`
|
|
219
|
+
* answer from.
|
|
220
|
+
*
|
|
221
|
+
* It is never older than what the host has been told. The worker attaches a
|
|
222
|
+
* conversation's metadata to every change it reports, and {@link handleWorker}
|
|
223
|
+
* stores it before it calls a listener or settles a call; an entry whose
|
|
224
|
+
* conversation changed with no metadata attached is dropped, never kept.
|
|
225
|
+
* Bounded by the conversations the client holds: an entry goes when its
|
|
226
|
+
* conversation is left, dropped or removed, and `listConversations()`
|
|
227
|
+
* replaces the whole map.
|
|
228
|
+
*/
|
|
205
229
|
private metaCache;
|
|
206
230
|
/**
|
|
207
231
|
* Per-conversation batching of sequenced live frames: the first frame goes
|
|
@@ -550,6 +574,25 @@ declare class MessagingClient {
|
|
|
550
574
|
*/
|
|
551
575
|
getConversation(id: ConversationId): Conversation;
|
|
552
576
|
listConversations(): Promise<ConversationMeta[]>;
|
|
577
|
+
/**
|
|
578
|
+
* ONE conversation's metadata as the group holds it now: the same record as
|
|
579
|
+
* its element of {@link listConversations}, without listing the others.
|
|
580
|
+
* Resolves `null` when this client does not hold the conversation (unknown,
|
|
581
|
+
* dropped, removed, or left). A pure read of local state: nothing is
|
|
582
|
+
* fetched. Rejects for an id that is not 16 bytes.
|
|
583
|
+
*
|
|
584
|
+
* It also brings the conversation handle's `name`, `epoch` and `meta()` to
|
|
585
|
+
* the answer, though they do not need it to be fresh: the client replaces
|
|
586
|
+
* its copy of a conversation's metadata
|
|
587
|
+
* - before any {@link onConversationUpdated} listener is told the
|
|
588
|
+
* conversation changed (a Commit from another member, a join, a page of
|
|
589
|
+
* a catch-up), and
|
|
590
|
+
* - before this device's own call that changed it resolves (a rename, a
|
|
591
|
+
* roles or membership change, a creation, a leave).
|
|
592
|
+
* Use this read for a conversation nothing has reported yet in this
|
|
593
|
+
* session, or to learn that a conversation is no longer held.
|
|
594
|
+
*/
|
|
595
|
+
readConversationMeta(id: Uint8Array): Promise<ConversationMeta | null>;
|
|
553
596
|
/**
|
|
554
597
|
* Conversations detected as STRANDED during catch-up — a Commit was missed
|
|
555
598
|
* and the group can no longer advance from local state, so new messages stop
|
|
@@ -1083,6 +1126,10 @@ declare class MessagingClient {
|
|
|
1083
1126
|
/** Reject every pending call with `error` and forget them. */
|
|
1084
1127
|
private failPending;
|
|
1085
1128
|
private conversationProxy;
|
|
1129
|
+
/** Replace this client's copy of one conversation's metadata with what the
|
|
1130
|
+
* worker read; no metadata means the copy is dropped, so the handle answers
|
|
1131
|
+
* "not held" instead of what the group held before. */
|
|
1132
|
+
private storeMeta;
|
|
1086
1133
|
private call;
|
|
1087
1134
|
/** Dispatch a worker-side transport proxy call onto the host transport.
|
|
1088
1135
|
* `sendBatch` is the one method the worker proxy always declares but a
|
package/dist/index.d.ts
CHANGED
|
@@ -174,8 +174,15 @@ interface Conversation {
|
|
|
174
174
|
* group-name capability shipped, else the SDK throws. */
|
|
175
175
|
setConversationName(name: string | null): Promise<void>;
|
|
176
176
|
/**
|
|
177
|
-
* The conversation's MLS GroupContext name
|
|
178
|
-
* has
|
|
177
|
+
* The conversation's MLS GroupContext name as the group holds it now, or
|
|
178
|
+
* `undefined` when the group has none or the client holds no metadata for
|
|
179
|
+
* the conversation (it is not held, or nothing has reported it yet: read it
|
|
180
|
+
* with `readConversationMeta(id)`).
|
|
181
|
+
*
|
|
182
|
+
* Never the name from before a change. The client's copy of a conversation's
|
|
183
|
+
* metadata is replaced before any `onConversationUpdated` listener is told
|
|
184
|
+
* the conversation changed, and before this device's own call that changed
|
|
185
|
+
* it resolves (see `MessagingClient.readConversationMeta`).
|
|
179
186
|
*
|
|
180
187
|
* This accessor was MISSING, and hosts reasonably assumed it existed:
|
|
181
188
|
* `getConversation(id).name` read `undefined` on every call, so any host logic
|
|
@@ -186,9 +193,13 @@ interface Conversation {
|
|
|
186
193
|
* one-field convenience that hosts were already reaching for.
|
|
187
194
|
*/
|
|
188
195
|
readonly name?: string | undefined;
|
|
189
|
-
/** The conversation's current MLS epoch, or `undefined` when the
|
|
190
|
-
*
|
|
196
|
+
/** The conversation's current MLS epoch, or `undefined` when the client
|
|
197
|
+
* holds no metadata for the conversation. Never an epoch from before a
|
|
198
|
+
* change the host was already told about. */
|
|
191
199
|
readonly epoch?: number | undefined;
|
|
200
|
+
/** The whole record, as fresh as `name`. Throws when the client holds no
|
|
201
|
+
* metadata for the conversation: `readConversationMeta(id)` answers `null`
|
|
202
|
+
* instead, and tells "not held" from "not read yet". */
|
|
192
203
|
meta(): ConversationMeta;
|
|
193
204
|
}
|
|
194
205
|
declare class MessagingClient {
|
|
@@ -202,6 +213,19 @@ declare class MessagingClient {
|
|
|
202
213
|
private readonly fanout;
|
|
203
214
|
private conversationHandlers;
|
|
204
215
|
private subscription;
|
|
216
|
+
/**
|
|
217
|
+
* This client's copy of each conversation's metadata, keyed by lowercase-hex
|
|
218
|
+
* conversation id: what a conversation handle's `name`, `epoch` and `meta()`
|
|
219
|
+
* answer from.
|
|
220
|
+
*
|
|
221
|
+
* It is never older than what the host has been told. The worker attaches a
|
|
222
|
+
* conversation's metadata to every change it reports, and {@link handleWorker}
|
|
223
|
+
* stores it before it calls a listener or settles a call; an entry whose
|
|
224
|
+
* conversation changed with no metadata attached is dropped, never kept.
|
|
225
|
+
* Bounded by the conversations the client holds: an entry goes when its
|
|
226
|
+
* conversation is left, dropped or removed, and `listConversations()`
|
|
227
|
+
* replaces the whole map.
|
|
228
|
+
*/
|
|
205
229
|
private metaCache;
|
|
206
230
|
/**
|
|
207
231
|
* Per-conversation batching of sequenced live frames: the first frame goes
|
|
@@ -550,6 +574,25 @@ declare class MessagingClient {
|
|
|
550
574
|
*/
|
|
551
575
|
getConversation(id: ConversationId): Conversation;
|
|
552
576
|
listConversations(): Promise<ConversationMeta[]>;
|
|
577
|
+
/**
|
|
578
|
+
* ONE conversation's metadata as the group holds it now: the same record as
|
|
579
|
+
* its element of {@link listConversations}, without listing the others.
|
|
580
|
+
* Resolves `null` when this client does not hold the conversation (unknown,
|
|
581
|
+
* dropped, removed, or left). A pure read of local state: nothing is
|
|
582
|
+
* fetched. Rejects for an id that is not 16 bytes.
|
|
583
|
+
*
|
|
584
|
+
* It also brings the conversation handle's `name`, `epoch` and `meta()` to
|
|
585
|
+
* the answer, though they do not need it to be fresh: the client replaces
|
|
586
|
+
* its copy of a conversation's metadata
|
|
587
|
+
* - before any {@link onConversationUpdated} listener is told the
|
|
588
|
+
* conversation changed (a Commit from another member, a join, a page of
|
|
589
|
+
* a catch-up), and
|
|
590
|
+
* - before this device's own call that changed it resolves (a rename, a
|
|
591
|
+
* roles or membership change, a creation, a leave).
|
|
592
|
+
* Use this read for a conversation nothing has reported yet in this
|
|
593
|
+
* session, or to learn that a conversation is no longer held.
|
|
594
|
+
*/
|
|
595
|
+
readConversationMeta(id: Uint8Array): Promise<ConversationMeta | null>;
|
|
553
596
|
/**
|
|
554
597
|
* Conversations detected as STRANDED during catch-up — a Commit was missed
|
|
555
598
|
* and the group can no longer advance from local state, so new messages stop
|
|
@@ -1083,6 +1126,10 @@ declare class MessagingClient {
|
|
|
1083
1126
|
/** Reject every pending call with `error` and forget them. */
|
|
1084
1127
|
private failPending;
|
|
1085
1128
|
private conversationProxy;
|
|
1129
|
+
/** Replace this client's copy of one conversation's metadata with what the
|
|
1130
|
+
* worker read; no metadata means the copy is dropped, so the handle answers
|
|
1131
|
+
* "not held" instead of what the group held before. */
|
|
1132
|
+
private storeMeta;
|
|
1086
1133
|
private call;
|
|
1087
1134
|
/** Dispatch a worker-side transport proxy call onto the host transport.
|
|
1088
1135
|
* `sendBatch` is the one method the worker proxy always declares but a
|
package/dist/index.js
CHANGED
|
@@ -677,6 +677,19 @@ var MessagingClient = class _MessagingClient {
|
|
|
677
677
|
fanout = new MessageFanout();
|
|
678
678
|
conversationHandlers = /* @__PURE__ */ new Set();
|
|
679
679
|
subscription = null;
|
|
680
|
+
/**
|
|
681
|
+
* This client's copy of each conversation's metadata, keyed by lowercase-hex
|
|
682
|
+
* conversation id: what a conversation handle's `name`, `epoch` and `meta()`
|
|
683
|
+
* answer from.
|
|
684
|
+
*
|
|
685
|
+
* It is never older than what the host has been told. The worker attaches a
|
|
686
|
+
* conversation's metadata to every change it reports, and {@link handleWorker}
|
|
687
|
+
* stores it before it calls a listener or settles a call; an entry whose
|
|
688
|
+
* conversation changed with no metadata attached is dropped, never kept.
|
|
689
|
+
* Bounded by the conversations the client holds: an entry goes when its
|
|
690
|
+
* conversation is left, dropped or removed, and `listConversations()`
|
|
691
|
+
* replaces the whole map.
|
|
692
|
+
*/
|
|
680
693
|
metaCache = /* @__PURE__ */ new Map();
|
|
681
694
|
/**
|
|
682
695
|
* Per-conversation batching of sequenced live frames: the first frame goes
|
|
@@ -1464,6 +1477,33 @@ var MessagingClient = class _MessagingClient {
|
|
|
1464
1477
|
for (const m of metas) this.metaCache.set(hex(m.id), m);
|
|
1465
1478
|
return metas;
|
|
1466
1479
|
}
|
|
1480
|
+
/**
|
|
1481
|
+
* ONE conversation's metadata as the group holds it now: the same record as
|
|
1482
|
+
* its element of {@link listConversations}, without listing the others.
|
|
1483
|
+
* Resolves `null` when this client does not hold the conversation (unknown,
|
|
1484
|
+
* dropped, removed, or left). A pure read of local state: nothing is
|
|
1485
|
+
* fetched. Rejects for an id that is not 16 bytes.
|
|
1486
|
+
*
|
|
1487
|
+
* It also brings the conversation handle's `name`, `epoch` and `meta()` to
|
|
1488
|
+
* the answer, though they do not need it to be fresh: the client replaces
|
|
1489
|
+
* its copy of a conversation's metadata
|
|
1490
|
+
* - before any {@link onConversationUpdated} listener is told the
|
|
1491
|
+
* conversation changed (a Commit from another member, a join, a page of
|
|
1492
|
+
* a catch-up), and
|
|
1493
|
+
* - before this device's own call that changed it resolves (a rename, a
|
|
1494
|
+
* roles or membership change, a creation, a leave).
|
|
1495
|
+
* Use this read for a conversation nothing has reported yet in this
|
|
1496
|
+
* session, or to learn that a conversation is no longer held.
|
|
1497
|
+
*/
|
|
1498
|
+
async readConversationMeta(id) {
|
|
1499
|
+
const meta = await this.call({
|
|
1500
|
+
kind: "conversationMeta",
|
|
1501
|
+
id: this.nextId++,
|
|
1502
|
+
conv: id
|
|
1503
|
+
});
|
|
1504
|
+
this.storeMeta(id, meta);
|
|
1505
|
+
return meta ?? null;
|
|
1506
|
+
}
|
|
1467
1507
|
/**
|
|
1468
1508
|
* Conversations detected as STRANDED during catch-up — a Commit was missed
|
|
1469
1509
|
* and the group can no longer advance from local state, so new messages stop
|
|
@@ -2316,12 +2356,14 @@ var MessagingClient = class _MessagingClient {
|
|
|
2316
2356
|
return {
|
|
2317
2357
|
id,
|
|
2318
2358
|
async send(plaintext) {
|
|
2359
|
+
const heldEpoch = self.metaCache.get(hex(id))?.epoch;
|
|
2319
2360
|
return await self.call({
|
|
2320
2361
|
kind: "send",
|
|
2321
2362
|
id: self.nextId++,
|
|
2322
2363
|
conv: id,
|
|
2323
2364
|
plaintext,
|
|
2324
|
-
nowMs: self.now()
|
|
2365
|
+
nowMs: self.now(),
|
|
2366
|
+
...heldEpoch !== void 0 ? { heldEpoch } : {}
|
|
2325
2367
|
});
|
|
2326
2368
|
},
|
|
2327
2369
|
async addMembers(entries) {
|
|
@@ -2399,8 +2441,8 @@ var MessagingClient = class _MessagingClient {
|
|
|
2399
2441
|
});
|
|
2400
2442
|
},
|
|
2401
2443
|
/**
|
|
2402
|
-
* The conversation's MLS GroupContext name
|
|
2403
|
-
*
|
|
2444
|
+
* The conversation's MLS GroupContext name as the group holds it now, or
|
|
2445
|
+
* `undefined` when it has none or the client holds no metadata for it.
|
|
2404
2446
|
*
|
|
2405
2447
|
* This accessor did not exist, and hosts reasonably assumed it did:
|
|
2406
2448
|
* `getConversation(id).name` read `undefined` on every call, which
|
|
@@ -2409,24 +2451,36 @@ var MessagingClient = class _MessagingClient {
|
|
|
2409
2451
|
* absent, so a group would materialise unnamed until a best-effort
|
|
2410
2452
|
* broadcast happened to arrive.
|
|
2411
2453
|
*
|
|
2412
|
-
* A getter rather than a snapshot, so it reflects the
|
|
2413
|
-
*
|
|
2454
|
+
* A getter rather than a snapshot, so it reflects the client's copy at
|
|
2455
|
+
* read time. That copy used to be refilled by `listConversations()`
|
|
2456
|
+
* only, and this answered the name from BEFORE a rename until the host
|
|
2457
|
+
* listed again; it is now replaced with every change the worker reports
|
|
2458
|
+
* (see `metaCache`).
|
|
2414
2459
|
*/
|
|
2415
2460
|
get name() {
|
|
2416
2461
|
return self.metaCache.get(hex(id))?.name ?? void 0;
|
|
2417
2462
|
},
|
|
2418
|
-
/** The conversation's current MLS epoch, or `undefined` when the
|
|
2419
|
-
*
|
|
2463
|
+
/** The conversation's current MLS epoch, or `undefined` when the client
|
|
2464
|
+
* holds no metadata for it. */
|
|
2420
2465
|
get epoch() {
|
|
2421
2466
|
return self.metaCache.get(hex(id))?.epoch;
|
|
2422
2467
|
},
|
|
2423
2468
|
meta() {
|
|
2424
2469
|
const cached = self.metaCache.get(hex(id));
|
|
2425
|
-
if (!cached)
|
|
2470
|
+
if (!cached) {
|
|
2471
|
+
throw new Error("conversation meta not loaded; call readConversationMeta(id) or listConversations() first");
|
|
2472
|
+
}
|
|
2426
2473
|
return cached;
|
|
2427
2474
|
}
|
|
2428
2475
|
};
|
|
2429
2476
|
}
|
|
2477
|
+
/** Replace this client's copy of one conversation's metadata with what the
|
|
2478
|
+
* worker read; no metadata means the copy is dropped, so the handle answers
|
|
2479
|
+
* "not held" instead of what the group held before. */
|
|
2480
|
+
storeMeta(id, meta) {
|
|
2481
|
+
if (meta === null || meta === void 0) this.metaCache.delete(hex(id));
|
|
2482
|
+
else this.metaCache.set(hex(id), meta);
|
|
2483
|
+
}
|
|
2430
2484
|
call(req) {
|
|
2431
2485
|
if (this.closed) return Promise.reject(new MessagingClientClosedError("closed"));
|
|
2432
2486
|
return new Promise((resolve, reject) => {
|
|
@@ -2480,6 +2534,7 @@ var MessagingClient = class _MessagingClient {
|
|
|
2480
2534
|
return;
|
|
2481
2535
|
}
|
|
2482
2536
|
case "event.conversation": {
|
|
2537
|
+
this.storeMeta(msg.id, msg.meta);
|
|
2483
2538
|
for (const h of this.conversationHandlers) {
|
|
2484
2539
|
try {
|
|
2485
2540
|
h(msg.id, msg.epoch, msg.sender);
|
|
@@ -2491,6 +2546,11 @@ var MessagingClient = class _MessagingClient {
|
|
|
2491
2546
|
}
|
|
2492
2547
|
return;
|
|
2493
2548
|
}
|
|
2549
|
+
case "cache.conversations": {
|
|
2550
|
+
for (const meta of msg.held) this.storeMeta(meta.id, meta);
|
|
2551
|
+
for (const id of msg.dropped) this.storeMeta(id, null);
|
|
2552
|
+
return;
|
|
2553
|
+
}
|
|
2494
2554
|
case "storage.call": {
|
|
2495
2555
|
try {
|
|
2496
2556
|
const method = this.storage[msg.method];
|