@open-e2ee/signal-protocol-sdk 9.3.0 → 9.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/ADAPTERS.md +1 -0
  2. package/CHANGELOG.md +269 -0
  3. package/README.md +1 -1
  4. package/SECURITY.md +2 -2
  5. package/client/README.md +11 -14
  6. package/dist/client/client.d.ts +134 -64
  7. package/dist/client/client.d.ts.map +1 -1
  8. package/dist/client/client.js +333 -179
  9. package/dist/client/client.js.map +1 -1
  10. package/dist/client/config.d.ts +4 -7
  11. package/dist/client/config.d.ts.map +1 -1
  12. package/dist/client/config.js.map +1 -1
  13. package/dist/client/content-adapter.d.ts +8 -0
  14. package/dist/client/content-adapter.d.ts.map +1 -1
  15. package/dist/client/content-adapter.js +4 -0
  16. package/dist/client/content-adapter.js.map +1 -1
  17. package/dist/client/event-hooks.d.ts +1 -1
  18. package/dist/client/group-outbox.d.ts +2 -4
  19. package/dist/client/group-outbox.d.ts.map +1 -1
  20. package/dist/client/group-outbox.js +7 -1
  21. package/dist/client/group-outbox.js.map +1 -1
  22. package/dist/client/hosted-anonymous-delivery.d.ts +1 -1
  23. package/dist/client/hosted-anonymous-delivery.d.ts.map +1 -1
  24. package/dist/client/hosted-anonymous-delivery.js +5 -14
  25. package/dist/client/hosted-anonymous-delivery.js.map +1 -1
  26. package/dist/client/hosted-mailbox-subscription.d.ts.map +1 -1
  27. package/dist/client/hosted-mailbox-subscription.js +136 -15
  28. package/dist/client/hosted-mailbox-subscription.js.map +1 -1
  29. package/dist/client/hosted-transport.d.ts +2 -2
  30. package/dist/client/hosted-transport.d.ts.map +1 -1
  31. package/dist/client/hosted-transport.js +20 -5
  32. package/dist/client/hosted-transport.js.map +1 -1
  33. package/dist/client/messages.d.ts.map +1 -1
  34. package/dist/client/messages.js +12 -2
  35. package/dist/client/messages.js.map +1 -1
  36. package/dist/client/relay-acceptance.d.ts +29 -0
  37. package/dist/client/relay-acceptance.d.ts.map +1 -0
  38. package/dist/client/relay-acceptance.js +29 -0
  39. package/dist/client/relay-acceptance.js.map +1 -0
  40. package/dist/client/relay-subscription.d.ts +43 -1
  41. package/dist/client/relay-subscription.d.ts.map +1 -1
  42. package/dist/client/relay-subscription.js +278 -100
  43. package/dist/client/relay-subscription.js.map +1 -1
  44. package/dist/client/relay-work.d.ts +7 -6
  45. package/dist/client/relay-work.d.ts.map +1 -1
  46. package/dist/client/relay-work.js +34 -9
  47. package/dist/client/relay-work.js.map +1 -1
  48. package/dist/client/retry-family.d.ts +119 -0
  49. package/dist/client/retry-family.d.ts.map +1 -0
  50. package/dist/client/retry-family.js +170 -0
  51. package/dist/client/retry-family.js.map +1 -0
  52. package/dist/client/retry-request-envelope.d.ts +106 -0
  53. package/dist/client/retry-request-envelope.d.ts.map +1 -0
  54. package/dist/client/retry-request-envelope.js +245 -0
  55. package/dist/client/retry-request-envelope.js.map +1 -0
  56. package/dist/client/retry.d.ts +66 -24
  57. package/dist/client/retry.d.ts.map +1 -1
  58. package/dist/client/retry.js +239 -139
  59. package/dist/client/retry.js.map +1 -1
  60. package/dist/client/sealed-sender.d.ts +15 -3
  61. package/dist/client/sealed-sender.d.ts.map +1 -1
  62. package/dist/client/sealed-sender.js +22 -3
  63. package/dist/client/sealed-sender.js.map +1 -1
  64. package/dist/client/signal-service-cipher.d.ts +52 -0
  65. package/dist/client/signal-service-cipher.d.ts.map +1 -1
  66. package/dist/client/signal-service-cipher.js +185 -15
  67. package/dist/client/signal-service-cipher.js.map +1 -1
  68. package/dist/client/state.d.ts +12 -64
  69. package/dist/client/state.d.ts.map +1 -1
  70. package/dist/client/state.js +22 -98
  71. package/dist/client/state.js.map +1 -1
  72. package/dist/client/types.d.ts +28 -2
  73. package/dist/client/types.d.ts.map +1 -1
  74. package/dist/client/types.js.map +1 -1
  75. package/dist/internal/protocol/sealed-sender/types.d.ts +1 -1
  76. package/dist/internal/protocol/sealed-sender/types.js +1 -1
  77. package/dist/local/store/received-content.d.ts +16 -2
  78. package/dist/local/store/received-content.d.ts.map +1 -1
  79. package/dist/local/store/received-content.js +18 -3
  80. package/dist/local/store/received-content.js.map +1 -1
  81. package/dist/local/store/reliability.d.ts +260 -2
  82. package/dist/local/store/reliability.d.ts.map +1 -1
  83. package/dist/local/store/reliability.js +390 -12
  84. package/dist/local/store/reliability.js.map +1 -1
  85. package/dist/remote/relay/types.d.ts +31 -31
  86. package/dist/remote/relay/types.d.ts.map +1 -1
  87. package/dist/types/api.d.ts +74 -26
  88. package/dist/types/api.d.ts.map +1 -1
  89. package/docs/ASSURANCE.md +5 -5
  90. package/docs/DEVIATIONS.md +4 -5
  91. package/docs/INTERFACES.md +2 -0
  92. package/package.json +1 -1
@@ -1,13 +1,40 @@
1
1
  import { createKeyedLocks, withKeyedLock } from '../../utils/keyed-lock.js';
2
2
  const OUTBOX_PREFIX = 'reliability:exact-ciphertext-outbox:v2';
3
3
  const INCOMING_PREFIX = 'reliability:processed-envelopes:v2';
4
+ const RETRY_REQUESTED_PREFIX = 'reliability:retry-requested:v1';
5
+ const RETRY_RESEND_PREFIX = 'reliability:retry-resend:v1';
6
+ const RETRY_FAMILY_PREFIX = 'reliability:retry-family:v1';
4
7
  const DAY_MS = 24 * 60 * 60 * 1_000;
5
8
  export const RELIABILITY_RECORD_TTL_MS = 30 * DAY_MS;
9
+ /**
10
+ * The lifetime of the retry-request and retry-family records of the
11
+ * requester, and of a fulfilled processed-envelope record. Two bounds set
12
+ * it. A sender refuses a retry request for a message older than
13
+ * `RELIABILITY_RECORD_TTL_MS`, so its last resend post comes at most that
14
+ * long after the failure. The Relay keeps a post for at most
15
+ * `RELIABILITY_RECORD_TTL_MS`, so a resend can arrive up to twice that
16
+ * time after the failure.
17
+ */
18
+ export const RETRY_REQUESTER_RECORD_TTL_MS = 2 * RELIABILITY_RECORD_TTL_MS;
6
19
  const mutationTails = new WeakMap();
7
20
  const outgoingIntentLocks = createKeyedLocks();
8
21
  const incomingEnvelopeLocks = createKeyedLocks();
22
+ const LEDGER_PREFIXES = {
23
+ outbox: OUTBOX_PREFIX,
24
+ incoming: INCOMING_PREFIX,
25
+ 'retry-requested': RETRY_REQUESTED_PREFIX,
26
+ 'retry-family': RETRY_FAMILY_PREFIX,
27
+ 'retry-resend': RETRY_RESEND_PREFIX,
28
+ };
29
+ const LEDGER_TTL_MS = {
30
+ outbox: RELIABILITY_RECORD_TTL_MS,
31
+ incoming: RELIABILITY_RECORD_TTL_MS,
32
+ 'retry-requested': RETRY_REQUESTER_RECORD_TTL_MS,
33
+ 'retry-family': RETRY_REQUESTER_RECORD_TTL_MS,
34
+ 'retry-resend': RELIABILITY_RECORD_TTL_MS,
35
+ };
9
36
  function prefix(kind) {
10
- return kind === 'outbox' ? OUTBOX_PREFIX : INCOMING_PREFIX;
37
+ return LEDGER_PREFIXES[kind];
11
38
  }
12
39
  function recordKey(kind, id) {
13
40
  return `${prefix(kind)}:record:${encodeURIComponent(id)}`;
@@ -44,7 +71,7 @@ export async function withProcessedEnvelopeLock(store, envelopeId, operation) {
44
71
  }
45
72
  async function pruneExpiredBuckets(store, kind, now) {
46
73
  const days = parseJson(await store.getMetadata(manifestKey(kind)), []);
47
- const firstRetainedDay = dayFor(now - RELIABILITY_RECORD_TTL_MS);
74
+ const firstRetainedDay = dayFor(now - LEDGER_TTL_MS[kind]);
48
75
  const retained = [];
49
76
  for (const day of days) {
50
77
  if (day >= firstRetainedDay) {
@@ -72,6 +99,19 @@ async function indexRecord(store, kind, id, timestamp, retainedDays) {
72
99
  }
73
100
  await store.setMetadata(manifestKey(kind), JSON.stringify(retainedDays));
74
101
  }
102
+ /** Remove one record ID from the bucket of its day, and the empty bucket from the manifest. */
103
+ async function unindexRecord(store, kind, id, timestamp) {
104
+ const day = dayFor(timestamp);
105
+ const dayKey = bucketKey(kind, day);
106
+ const ids = parseJson(await store.getMetadata(dayKey), []).filter((candidate) => candidate !== id);
107
+ if (ids.length > 0) {
108
+ await store.setMetadata(dayKey, JSON.stringify(ids));
109
+ return;
110
+ }
111
+ await store.deleteMetadata(dayKey);
112
+ const days = parseJson(await store.getMetadata(manifestKey(kind)), []);
113
+ await store.setMetadata(manifestKey(kind), JSON.stringify(days.filter((retainedDay) => retainedDay !== day)));
114
+ }
75
115
  function sameIntent(a, b) {
76
116
  const sameLogicalIntent = a.clientMessageId === b.clientMessageId &&
77
117
  a.kind === b.kind &&
@@ -230,23 +270,361 @@ export async function completeOutgoingMessageIntent(store, clientMessageId, resu
230
270
  await store.setMetadata(key, JSON.stringify(existing));
231
271
  });
232
272
  }
233
- export async function hasProcessedEnvelope(store, envelopeId, now = Date.now(), fingerprint) {
273
+ /** The lifetime of one processed-envelope record. */
274
+ function processedEnvelopeTtl(record) {
275
+ return record.fulfilled ? RETRY_REQUESTER_RECORD_TTL_MS : RELIABILITY_RECORD_TTL_MS;
276
+ }
277
+ /**
278
+ * The time that the incoming ledger indexes one record at. The ledger
279
+ * prunes a day after `RELIABILITY_RECORD_TTL_MS`, so a fulfilled record
280
+ * goes to a later day and lives for `RETRY_REQUESTER_RECORD_TTL_MS`.
281
+ */
282
+ function processedEnvelopeIndexTime(record) {
283
+ return record.processedAt + processedEnvelopeTtl(record) - RELIABILITY_RECORD_TTL_MS;
284
+ }
285
+ async function readProcessedEnvelope(store, envelopeId) {
234
286
  const value = await store.getMetadata(recordKey('incoming', envelopeId));
235
287
  if (value === null)
236
- return false;
237
- const { processedAt, fingerprint: storedFingerprint } = JSON.parse(value);
238
- if (!Number.isFinite(processedAt))
288
+ return null;
289
+ const { processedAt, fingerprint, fulfilled } = JSON.parse(value);
290
+ if (!Number.isFinite(processedAt) ||
291
+ (fingerprint !== undefined && typeof fingerprint !== 'string') ||
292
+ (fulfilled !== undefined && fulfilled !== true)) {
239
293
  throw new Error('Corrupt processed-envelope record');
240
- if (fingerprint !== undefined && fingerprint !== storedFingerprint) {
241
- throw new Error('Relay envelope identity changed after processing');
242
294
  }
243
- return processedAt >= now - RELIABILITY_RECORD_TTL_MS;
295
+ return {
296
+ processedAt,
297
+ ...(fingerprint !== undefined && { fingerprint }),
298
+ ...(fulfilled === true && { fulfilled }),
299
+ };
244
300
  }
245
- export async function storeProcessedEnvelope(store, envelopeId, processedAt = Date.now(), fingerprint) {
301
+ /**
302
+ * Get the processed-envelope record of one envelope ID. A record older
303
+ * than `RELIABILITY_RECORD_TTL_MS` does not count. A fulfilled record
304
+ * counts for `RETRY_REQUESTER_RECORD_TTL_MS`.
305
+ */
306
+ export async function getProcessedEnvelope(store, envelopeId, now = Date.now()) {
307
+ const record = await readProcessedEnvelope(store, envelopeId);
308
+ if (record === null)
309
+ return null;
310
+ if (record.processedAt < now - processedEnvelopeTtl(record))
311
+ return null;
312
+ return record;
313
+ }
314
+ /**
315
+ * Tell whether the local device processed one envelope ID. A record counts
316
+ * for the lifetime that `getProcessedEnvelope` applies.
317
+ */
318
+ export async function hasProcessedEnvelope(store, envelopeId, now = Date.now()) {
319
+ return (await getProcessedEnvelope(store, envelopeId, now)) !== null;
320
+ }
321
+ /**
322
+ * Record that the local device processed one envelope ID. The write keeps
323
+ * the fingerprint and the fulfilled flag of a record that counts, so a
324
+ * later store for the same ID never clears them.
325
+ *
326
+ * @param fulfilled - True when the application got the content of this
327
+ * failed envelope. The processed fact and the fulfilled fact are then
328
+ * one write.
329
+ */
330
+ export async function storeProcessedEnvelope(store, envelopeId, processedAt = Date.now(), fingerprint, fulfilled) {
246
331
  await serializeMutation(store, async () => {
332
+ const existing = await readProcessedEnvelope(store, envelopeId);
333
+ const current = existing && existing.processedAt >= processedAt - processedEnvelopeTtl(existing)
334
+ ? existing
335
+ : null;
336
+ const keptFingerprint = fingerprint ?? current?.fingerprint;
337
+ const record = {
338
+ processedAt,
339
+ ...(keptFingerprint !== undefined && { fingerprint: keptFingerprint }),
340
+ ...((fulfilled || current?.fulfilled) && { fulfilled: true }),
341
+ };
342
+ const indexTime = processedEnvelopeIndexTime(record);
247
343
  const retainedDays = await pruneExpiredBuckets(store, 'incoming', processedAt);
248
- await store.setMetadata(recordKey('incoming', envelopeId), JSON.stringify({ processedAt, fingerprint }));
249
- await indexRecord(store, 'incoming', envelopeId, processedAt, retainedDays);
344
+ await store.setMetadata(recordKey('incoming', envelopeId), JSON.stringify(record));
345
+ await indexRecord(store, 'incoming', envelopeId, indexTime, retainedDays);
346
+ // The bucket of the earlier record would prune the new record early.
347
+ if (existing) {
348
+ const existingIndexTime = processedEnvelopeIndexTime(existing);
349
+ if (dayFor(existingIndexTime) !== dayFor(indexTime)) {
350
+ await unindexRecord(store, 'incoming', envelopeId, existingIndexTime);
351
+ }
352
+ }
353
+ });
354
+ }
355
+ /**
356
+ * The relay gave a failed envelope ID again with other content after the
357
+ * local device stored a retry request for that ID.
358
+ */
359
+ export class RetryRequestedEnvelopeChangedError extends Error {
360
+ constructor() {
361
+ super('Relay envelope identity changed after the retry request');
362
+ this.name = 'RetryRequestedEnvelopeChangedError';
363
+ }
364
+ }
365
+ /**
366
+ * The retry ID shape: a UUID in lowercase hex. The requester makes one
367
+ * retry ID for each retry request record, and every wire ID of that retry
368
+ * family derives from it.
369
+ */
370
+ const RETRY_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/u;
371
+ /** Tell whether a value has the shape of a retry ID. */
372
+ export function isRetryId(value) {
373
+ return typeof value === 'string' && RETRY_ID.test(value);
374
+ }
375
+ /**
376
+ * The client message ID of the retry request with one retry ID. The first
377
+ * attempt of that request posts under this ID.
378
+ */
379
+ export function retryRequestClientMessageId(retryId) {
380
+ return `${retryId}:retry-request`;
381
+ }
382
+ /**
383
+ * The resend ID of the content resend for one retry ID. The first attempt of
384
+ * that resend posts under this ID.
385
+ */
386
+ export function retryResendClientMessageId(retryId) {
387
+ return `${retryId}:resend`;
388
+ }
389
+ /**
390
+ * The resend ID of the null message for one retry ID. It is not the content
391
+ * resend ID, so a null message never posts content bytes.
392
+ */
393
+ export function retryNullMessageClientMessageId(retryId) {
394
+ return `${retryId}:null`;
395
+ }
396
+ /**
397
+ * The client message ID of one attempt of a retry request or a retry resend.
398
+ * Attempt 1 posts under the given ID, and attempt `n` posts under
399
+ * `<id>:<n>`. A resend takes the attempt number of the request that it
400
+ * answers. A new encryption for the same request attempt posts the same
401
+ * ID, and the processed ledger of the requester and the RETRY_CONFLICT
402
+ * answer of the Relay cover the new bytes.
403
+ */
404
+ export function retryAttemptClientMessageId(id, attempt) {
405
+ if (!Number.isSafeInteger(attempt) || attempt < 1) {
406
+ throw new Error('A retry attempt is a positive integer');
407
+ }
408
+ return attempt === 1 ? id : `${id}:${attempt}`;
409
+ }
410
+ const RETRY_FAMILY_ENVELOPE_ID = /^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}):(retry-request|resend|null)(?::([2-9]|[1-9][0-9]+))?$/u;
411
+ /**
412
+ * The retry ID, the kind and the attempt number of an envelope whose ID has
413
+ * the shape of a retry attempt: `<retryId>:retry-request[:n]`,
414
+ * `<retryId>:resend[:n]` or `<retryId>:null[:n]`, with `n` from 2. An ID
415
+ * with no `n` is attempt 1. Undefined for any other ID. Only the family
416
+ * index of the requester tells which failed envelope a retry ID names.
417
+ */
418
+ export function retryFamilyMember(envelopeId) {
419
+ const match = RETRY_FAMILY_ENVELOPE_ID.exec(envelopeId);
420
+ if (!match)
421
+ return undefined;
422
+ return {
423
+ retryId: match[1],
424
+ kind: match[2],
425
+ attempt: match[3] === undefined ? 1 : Number(match[3]),
426
+ };
427
+ }
428
+ /**
429
+ * The attempt number of the retry request that a resend or a null message
430
+ * answers, from the request envelope ID. The answer carries this number,
431
+ * so the requester can tell which of its attempts the answer is for.
432
+ * Throws when the ID is not a retry request of the retry ID: the requester
433
+ * makes each request envelope ID, so the sender never answers another ID.
434
+ */
435
+ export function retryRequestAttempt(target) {
436
+ const member = retryFamilyMember(target.requestEnvelopeId);
437
+ if (member?.kind !== 'retry-request' || member.retryId !== target.retryId) {
438
+ throw new Error('A retry resend answers a retry request of its retry ID');
439
+ }
440
+ return member.attempt;
441
+ }
442
+ /**
443
+ * Get the failed envelope ID that the family index gives for one retry ID.
444
+ * A record older than `RETRY_REQUESTER_RECORD_TTL_MS` does not count.
445
+ */
446
+ export async function getRetryFamily(store, retryId, now = Date.now()) {
447
+ const value = await store.getMetadata(recordKey('retry-family', retryId));
448
+ if (value === null)
449
+ return null;
450
+ const { failedEnvelopeId, indexedAt } = JSON.parse(value);
451
+ if (!Number.isFinite(indexedAt) || typeof failedEnvelopeId !== 'string') {
452
+ throw new Error('Corrupt retry-family record');
453
+ }
454
+ if (indexedAt < now - RETRY_REQUESTER_RECORD_TTL_MS)
455
+ return null;
456
+ return failedEnvelopeId;
457
+ }
458
+ /**
459
+ * Resolve an envelope ID to the request record that it answers. An ID that
460
+ * has the shape of a resend or a null message is a family member only when
461
+ * the family index of the local device holds its retry ID. Any other ID
462
+ * gives undefined, and the envelope is an ordinary envelope.
463
+ *
464
+ * The sender of a member is not bound to the target of the request. The
465
+ * retry ID is a random UUID that only the requester, the Relay and the
466
+ * requested sender see, so another sender cannot name it.
467
+ */
468
+ export async function resolveRetryFamilyMember(store, envelopeId, now = Date.now()) {
469
+ const member = retryFamilyMember(envelopeId);
470
+ if (!member || member.kind === 'retry-request')
471
+ return undefined;
472
+ const failedEnvelopeId = await getRetryFamily(store, member.retryId, now);
473
+ if (failedEnvelopeId === null)
474
+ return undefined;
475
+ return { retryId: member.retryId, failedEnvelopeId, kind: member.kind, attempt: member.attempt };
476
+ }
477
+ /**
478
+ * Get the stored retry request for one failed envelope. A record older than
479
+ * `RETRY_REQUESTER_RECORD_TTL_MS` does not count.
480
+ *
481
+ * @throws RetryRequestedEnvelopeChangedError When the stored fingerprint is
482
+ * not the given fingerprint.
483
+ */
484
+ export async function getRetryRequest(store, failedEnvelopeId, now = Date.now(), fingerprint) {
485
+ const record = parseJson(await store.getMetadata(recordKey('retry-requested', failedEnvelopeId)), null);
486
+ if (!record)
487
+ return null;
488
+ if (!Number.isFinite(record.requestedAt) ||
489
+ record.failedEnvelopeId !== failedEnvelopeId ||
490
+ !isRetryId(record.retryId) ||
491
+ !Number.isSafeInteger(record.attempt) ||
492
+ record.attempt < 1 ||
493
+ typeof record.answered !== 'boolean') {
494
+ throw new Error('Corrupt retry-request record');
495
+ }
496
+ if (record.requestedAt < now - RETRY_REQUESTER_RECORD_TTL_MS)
497
+ return null;
498
+ if (fingerprint !== undefined && fingerprint !== record.fingerprint) {
499
+ throw new RetryRequestedEnvelopeChangedError();
500
+ }
501
+ return cloneReliabilityValue(record);
502
+ }
503
+ /**
504
+ * Mark the stored attempt of a retry request answered when a resend or a
505
+ * null message of its retry ID and its attempt number arrives. A member of
506
+ * another attempt number answers nothing. An expired record, a record of
507
+ * another retry ID and an answered attempt stay as they are.
508
+ *
509
+ * @param store - The local store that keeps the request records.
510
+ * @param failedEnvelopeId - The failed envelope of the family.
511
+ * @param retryId - The retry ID of the arriving envelope.
512
+ * @param attempt - The attempt number of the arriving envelope ID.
513
+ * @param now - The current time.
514
+ */
515
+ export async function markRetryRequestAnswered(store, failedEnvelopeId, retryId, attempt, now = Date.now()) {
516
+ await serializeMutation(store, async () => {
517
+ const record = await getRetryRequest(store, failedEnvelopeId, now);
518
+ if (!record ||
519
+ record.retryId !== retryId ||
520
+ record.answered ||
521
+ record.attempt !== attempt) {
522
+ return;
523
+ }
524
+ // The attempt keeps its time, so its bucket index stays.
525
+ await store.setMetadata(recordKey('retry-requested', failedEnvelopeId), JSON.stringify({ ...record, answered: true }));
526
+ });
527
+ }
528
+ /**
529
+ * Record the request envelope of a retry request before its post, and the
530
+ * family index entry from its retry ID to the failed envelope ID. One
531
+ * mutation writes both. The two writes are serialized, not atomic, and the
532
+ * index write comes first. Only a failure between the two writes leaves an
533
+ * index entry with no request record, so the case is practically
534
+ * unreachable. A member of that retry ID then still resolves to the
535
+ * failed envelope. Its decrypt stores the failed envelope processed, and
536
+ * its decrypt failure creates attempt 1 under a new retry ID. A record
537
+ * that a member creates has no fingerprint, so a later failure of the
538
+ * failed envelope with a fingerprint reads as a changed envelope and posts
539
+ * nothing. A later attempt replaces the earlier one in one write, so the
540
+ * record holds an attempt at each point.
541
+ */
542
+ export async function storeRetryRequest(store, request) {
543
+ await serializeMutation(store, async () => {
544
+ await indexRetryFamily(store, request);
545
+ const key = recordKey('retry-requested', request.failedEnvelopeId);
546
+ const replaced = parseJson(await store.getMetadata(key), null);
547
+ const retainedDays = await pruneExpiredBuckets(store, 'retry-requested', request.requestedAt);
548
+ await store.setMetadata(key, JSON.stringify(request));
549
+ await indexRecord(store, 'retry-requested', request.failedEnvelopeId, request.requestedAt, retainedDays);
550
+ // The bucket of the replaced attempt would prune the new attempt early.
551
+ if (replaced && dayFor(replaced.requestedAt) !== dayFor(request.requestedAt)) {
552
+ await unindexRecord(store, 'retry-requested', request.failedEnvelopeId, replaced.requestedAt);
553
+ }
554
+ });
555
+ }
556
+ /**
557
+ * Write the family index entry of a request attempt. Each attempt writes it
558
+ * again with its own time, so the entry lives as long as the request record.
559
+ */
560
+ async function indexRetryFamily(store, request) {
561
+ const key = recordKey('retry-family', request.retryId);
562
+ const replaced = parseJson(await store.getMetadata(key), null);
563
+ const retainedDays = await pruneExpiredBuckets(store, 'retry-family', request.requestedAt);
564
+ await store.setMetadata(key, JSON.stringify({ failedEnvelopeId: request.failedEnvelopeId, indexedAt: request.requestedAt }));
565
+ await indexRecord(store, 'retry-family', request.retryId, request.requestedAt, retainedDays);
566
+ if (replaced && dayFor(replaced.indexedAt) !== dayFor(request.requestedAt)) {
567
+ await unindexRecord(store, 'retry-family', request.retryId, replaced.indexedAt);
568
+ }
569
+ }
570
+ /**
571
+ * A direct send gives each device of the recipient the same message ID, so
572
+ * one failed envelope ID can come from more than one device.
573
+ */
574
+ function retryResendRecordId(recipientUserId, recipientDeviceId, failedEnvelopeId) {
575
+ return JSON.stringify([recipientUserId, recipientDeviceId, failedEnvelopeId]);
576
+ }
577
+ /**
578
+ * Get the stored answer to one device for one failed envelope. A record
579
+ * older than `RELIABILITY_RECORD_TTL_MS` does not count.
580
+ */
581
+ export async function getRetryResend(store, recipientUserId, recipientDeviceId, failedEnvelopeId, now = Date.now()) {
582
+ const record = parseJson(await store.getMetadata(recordKey('retry-resend', retryResendRecordId(recipientUserId, recipientDeviceId, failedEnvelopeId))), null);
583
+ if (!record)
584
+ return null;
585
+ if (!Number.isFinite(record.operationEpochMilliseconds) ||
586
+ record.failedEnvelopeId !== failedEnvelopeId ||
587
+ !isRetryId(record.retryId) ||
588
+ typeof record.requestEnvelopeId !== 'string' ||
589
+ (record.kind !== 'resend' && record.kind !== 'null') ||
590
+ record.message?.recipientUserId !== recipientUserId ||
591
+ record.message.recipientDeviceId !== recipientDeviceId ||
592
+ !answersItsRequestAttempt(record)) {
593
+ throw new Error('Corrupt retry-resend record');
594
+ }
595
+ if (record.operationEpochMilliseconds < now - RELIABILITY_RECORD_TTL_MS)
596
+ return null;
597
+ return cloneReliabilityValue(record);
598
+ }
599
+ /** True when the record carries the attempt number of its request. */
600
+ function answersItsRequestAttempt(record) {
601
+ const member = retryFamilyMember(record.requestEnvelopeId);
602
+ return (member?.kind === 'retry-request' &&
603
+ member.retryId === record.retryId &&
604
+ member.attempt === record.attempt);
605
+ }
606
+ /**
607
+ * Record the encrypted bytes of a retry resend before their post. A later
608
+ * encryption replaces the earlier one in one write, so the record holds an
609
+ * encryption at each point. Throws, and writes nothing, when the attempt
610
+ * is not the attempt number of the request envelope.
611
+ */
612
+ export async function storeRetryResend(store, resend) {
613
+ if (resend.attempt !== retryRequestAttempt(resend)) {
614
+ throw new Error('A retry resend carries the attempt number of its request');
615
+ }
616
+ await serializeMutation(store, async () => {
617
+ const id = retryResendRecordId(resend.message.recipientUserId, resend.message.recipientDeviceId, resend.failedEnvelopeId);
618
+ const key = recordKey('retry-resend', id);
619
+ const replaced = parseJson(await store.getMetadata(key), null);
620
+ const retainedDays = await pruneExpiredBuckets(store, 'retry-resend', resend.operationEpochMilliseconds);
621
+ await store.setMetadata(key, JSON.stringify(resend));
622
+ await indexRecord(store, 'retry-resend', id, resend.operationEpochMilliseconds, retainedDays);
623
+ // The bucket of the replaced epoch would prune the new attempt early.
624
+ if (replaced &&
625
+ dayFor(replaced.operationEpochMilliseconds) !== dayFor(resend.operationEpochMilliseconds)) {
626
+ await unindexRecord(store, 'retry-resend', id, replaced.operationEpochMilliseconds);
627
+ }
250
628
  });
251
629
  }
252
630
  //# sourceMappingURL=reliability.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"reliability.js","sourceRoot":"","sources":["../../../local/store/reliability.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEzE,MAAM,aAAa,GAAG,wCAAwC,CAAC;AAC/D,MAAM,eAAe,GAAG,oCAAoC,CAAC;AAC7D,MAAM,MAAM,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,KAAK,CAAC;AAEpC,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,GAAG,MAAM,CAAC;AA6DrD,MAAM,aAAa,GAAG,IAAI,OAAO,EAAyB,CAAC;AAC3D,MAAM,mBAAmB,GAAG,gBAAgB,EAAE,CAAC;AAC/C,MAAM,qBAAqB,GAAG,gBAAgB,EAAE,CAAC;AAEjD,SAAS,MAAM,CAAC,IAAgB;IAC9B,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,eAAe,CAAC;AAC7D,CAAC;AAED,SAAS,SAAS,CAAC,IAAgB,EAAE,EAAU;IAC7C,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,kBAAkB,CAAC,EAAE,CAAC,EAAE,CAAC;AAC5D,CAAC;AAED,SAAS,SAAS,CAAC,IAAgB,EAAE,GAAW;IAC9C,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;AACzC,CAAC;AAED,SAAS,WAAW,CAA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C,gBAAgB,CACxB,CAAC;QACF,MAAM,GAAG,GAAG,SAAS,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC;QAC1C,MAAM,QAAQ,GAAG,SAAS,CAA2B,MAAM,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC;QACzF,MAAM,YAAY,GAAG,MAAM,mBAAmB,CAC5C,KAAK,EACL,cAAc,EACd,MAAM,CAAC,0BAA0B,CAClC,CAAC;QACF,MAAM,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;QACrD,MAAM,WAAW,CAAC,KAAK,EAAE,cAAc,EAAE,EAAE,EAAE,MAAM,CAAC,0BAA0B,EAAE,YAAY,CAAC,CAAC;QAC9F,sEAAsE;QACtE,IACE,QAAQ;YACR,MAAM,CAAC,QAAQ,CAAC,0BAA0B,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,0BAA0B,CAAC,EACzF,CAAC;YACD,MAAM,aAAa,CAAC,KAAK,EAAE,cAAc,EAAE,EAAE,EAAE,QAAQ,CAAC,0BAA0B,CAAC,CAAC;QACtF,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -244,13 +244,20 @@ export interface SignalProtocolRelayServer extends ProvisioningService, KeyRotat
244
244
  *
245
245
  * @param userId - Current user ID
246
246
  * @param deviceId - This device's ID (1-5)
247
- * @param onEnvelope - Callback for each incoming envelope
247
+ * @param onEnvelope - Callback for each incoming envelope. A relay that waits
248
+ * for the returned promise acknowledges or accepts the envelope itself only
249
+ * when it resolves. A rejected promise that did not acknowledge a durable
250
+ * envelope with `markDelivered` leaves it in the mailbox, and the hosted
251
+ * transport gives it to this callback again on the next recovery pull or
252
+ * socket replay. The hosted transport continues with the next envelope at
253
+ * once and does not keep the order across a rejected envelope. It holds
254
+ * back no envelope, durable or ephemeral.
248
255
  * @param options - Optional batching callbacks for notification coalescing
249
256
  * @param options.onBatchStart - Called when first message in a batch arrives
250
257
  * @param options.onBatchEnd - Called when batch is complete (idle detected)
251
258
  * @returns Unsubscribe function
252
259
  */
253
- subscribe(userId: string, deviceId: number, onEnvelope: (envelope: Envelope) => void, options?: {
260
+ subscribe(userId: string, deviceId: number, onEnvelope: (envelope: Envelope) => void | Promise<void>, options?: {
254
261
  onBatchStart?: () => void;
255
262
  onBatchEnd?: () => void;
256
263
  }): Unsubscribe;
@@ -505,10 +512,13 @@ export interface SignalProtocolRelayServer extends ProvisioningService, KeyRotat
505
512
  * @param timestamp - Client timestamp for message identification
506
513
  * @param deliveryClass - Exact persistence and wake behavior
507
514
  * @param recipientUserIds - Original user IDs in same order as binary recipients
515
+ * @param clientMessageId - The operation ID of the send
516
+ * @param operationEpochMilliseconds - The operation epoch that the relay
517
+ * admits the post by. Without it, the relay uses `timestamp`
508
518
  * @returns Message ID, server timestamp, and list of unknown recipient UUIDs
509
519
  *
510
520
  */
511
- sendMultiRecipientUnidentified?(sentMessageBase64: string, auth: SealedSenderAuth, timestamp: number, deliveryClass: DeliveryClass, recipientUserIds?: string[], clientMessageId?: string): Promise<{
521
+ sendMultiRecipientUnidentified?(sentMessageBase64: string, auth: SealedSenderAuth, timestamp: number, deliveryClass: DeliveryClass, recipientUserIds?: string[], clientMessageId?: string, operationEpochMilliseconds?: number): Promise<{
512
522
  messageId: string;
513
523
  serverTimestamp: number;
514
524
  uuids404: string[];
@@ -530,32 +540,6 @@ export interface SignalProtocolRelayServer extends ProvisioningService, KeyRotat
530
540
  */
531
541
  expiresAt?: number;
532
542
  }>;
533
- /**
534
- * Send retry request to the original sender.
535
- *
536
- * The recipient calls this when decryption fails. The retry request stays
537
- * unencrypted (per SESAME spec) and contains only the message ID
538
- * and reason. Transport is TLS-secured.
539
- *
540
- * @param request - Retry request with sender/requester info and failed sequence number
541
- */
542
- sendRetryRequest?(request: RetryRequest): Promise<void>;
543
- /**
544
- * Subscribe to incoming retry requests for this device.
545
- *
546
- * Called by sender to listen for retry requests from recipients.
547
- * When a retry request arrives, the sender should:
548
- * 1. Look up the MessageRecord by sequence number
549
- * 2. Fetch the requester's current prekey bundle
550
- * 3. Establish a new session (X3DH/PQXDH)
551
- * 4. Re-encrypt and send the original message
552
- *
553
- * @param userId - Current user ID (the original sender)
554
- * @param deviceId - This device's ID
555
- * @param handler - Callback for each incoming retry request
556
- * @returns Unsubscribe function
557
- */
558
- subscribeRetryRequests?(userId: string, deviceId: number, handler: (request: RetryRequest) => Promise<void>): Unsubscribe;
559
543
  }
560
544
  /** Unsubscribe function returned by subscribe() */
561
545
  export type Unsubscribe = () => void;
@@ -643,6 +627,9 @@ export interface Envelope {
643
627
  * - sender_key: Group message encrypted with sender keys
644
628
  * - server_delivery_receipt: Server-generated delivery receipts
645
629
  * - unidentified_sender: Sealed sender protocol messages
630
+ * - retry_request: A request that the original sender device resend a
631
+ * message that the requester could not decrypt. The payload is not
632
+ * encrypted. The envelope sender is the requester.
646
633
  *
647
634
  * `sender_key` tells the receiver to decrypt the payload as a framed
648
635
  * SenderKeyMessage rather than as a pairwise ratchet message. It names no
@@ -651,10 +638,14 @@ export interface Envelope {
651
638
  * therefore learns that an envelope is group traffic, which its fan-out
652
639
  * pattern already implies, but not which group.
653
640
  */
654
- messageType: 'ciphertext' | 'prekey_bundle' | 'sender_key' | 'server_delivery_receipt' | 'unidentified_sender';
641
+ messageType: 'ciphertext' | 'prekey_bundle' | 'sender_key' | 'server_delivery_receipt' | 'unidentified_sender' | 'retry_request';
655
642
  /** Exact persistence and wake behavior for this encrypted envelope. */
656
643
  deliveryClass: DeliveryClass;
657
- /** Server-assigned envelope ID (set by server) */
644
+ /**
645
+ * Server-assigned envelope ID (set by server). A relay gives an envelope
646
+ * one `id` and keeps it on every redelivery of that envelope. The
647
+ * at-most-once rule of the client depends on it.
648
+ */
658
649
  id?: string;
659
650
  /** Server timestamp (set by server) */
660
651
  serverTimestamp?: number;
@@ -677,8 +668,17 @@ export interface Envelope {
677
668
  * namespace. Two sealed senders reusing the same value would silently
678
669
  * collapse into one stored message. The second sender would receive the
679
670
  * first message's receipt.
671
+ *
672
+ * A relay that assigns its own `id` delivers this value with the
673
+ * envelope. A retry request names its attempt here.
680
674
  */
681
675
  clientMessageId?: string;
676
+ /**
677
+ * The operation epoch that the relay admits the post by. Without it, the
678
+ * relay uses `timestamp`. A retry resend keeps the original `timestamp`, so
679
+ * it posts the time of its first attempt here.
680
+ */
681
+ operationEpochMilliseconds?: number;
682
682
  /**
683
683
  * Recipient's registration ID from the prekey bundle.
684
684
  * For PreKeyMessages only. Server validates this matches recipient's current registration.