@open-e2ee/signal-protocol-sdk 9.4.0 → 10.0.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 (118) hide show
  1. package/ADAPTERS.md +1 -0
  2. package/CHANGELOG.md +229 -0
  3. package/README.md +1 -1
  4. package/SECURITY.md +4 -4
  5. package/client/README.md +29 -12
  6. package/dist/client/client.d.ts +75 -63
  7. package/dist/client/client.d.ts.map +1 -1
  8. package/dist/client/client.js +207 -179
  9. package/dist/client/client.js.map +1 -1
  10. package/dist/client/config.d.ts +18 -3
  11. package/dist/client/config.d.ts.map +1 -1
  12. package/dist/client/config.js.map +1 -1
  13. package/dist/client/constants.d.ts +2 -10
  14. package/dist/client/constants.d.ts.map +1 -1
  15. package/dist/client/constants.js +3 -12
  16. package/dist/client/constants.js.map +1 -1
  17. package/dist/client/content-adapter.d.ts +8 -0
  18. package/dist/client/content-adapter.d.ts.map +1 -1
  19. package/dist/client/content-adapter.js +4 -0
  20. package/dist/client/content-adapter.js.map +1 -1
  21. package/dist/client/delivery-status.d.ts +50 -0
  22. package/dist/client/delivery-status.d.ts.map +1 -0
  23. package/dist/client/delivery-status.js +121 -0
  24. package/dist/client/delivery-status.js.map +1 -0
  25. package/dist/client/event-hooks.d.ts +44 -10
  26. package/dist/client/event-hooks.d.ts.map +1 -1
  27. package/dist/client/event-hooks.js +26 -0
  28. package/dist/client/event-hooks.js.map +1 -1
  29. package/dist/client/hosted-anonymous-delivery.d.ts +2 -2
  30. package/dist/client/hosted-anonymous-delivery.d.ts.map +1 -1
  31. package/dist/client/hosted-anonymous-delivery.js +7 -4
  32. package/dist/client/hosted-anonymous-delivery.js.map +1 -1
  33. package/dist/client/hosted-mailbox-subscription.d.ts +39 -6
  34. package/dist/client/hosted-mailbox-subscription.d.ts.map +1 -1
  35. package/dist/client/hosted-mailbox-subscription.js +133 -26
  36. package/dist/client/hosted-mailbox-subscription.js.map +1 -1
  37. package/dist/client/hosted-push.d.ts +4 -3
  38. package/dist/client/hosted-push.d.ts.map +1 -1
  39. package/dist/client/hosted-push.js +18 -6
  40. package/dist/client/hosted-push.js.map +1 -1
  41. package/dist/client/hosted-transport.d.ts +26 -6
  42. package/dist/client/hosted-transport.d.ts.map +1 -1
  43. package/dist/client/hosted-transport.js +101 -14
  44. package/dist/client/hosted-transport.js.map +1 -1
  45. package/dist/client/index.d.ts +1 -1
  46. package/dist/client/index.d.ts.map +1 -1
  47. package/dist/client/index.js.map +1 -1
  48. package/dist/client/messages.d.ts +4 -2
  49. package/dist/client/messages.d.ts.map +1 -1
  50. package/dist/client/messages.js +32 -7
  51. package/dist/client/messages.js.map +1 -1
  52. package/dist/client/relay-acceptance.d.ts +8 -0
  53. package/dist/client/relay-acceptance.d.ts.map +1 -1
  54. package/dist/client/relay-acceptance.js +7 -0
  55. package/dist/client/relay-acceptance.js.map +1 -1
  56. package/dist/client/relay-receipt-intake.d.ts +70 -0
  57. package/dist/client/relay-receipt-intake.d.ts.map +1 -0
  58. package/dist/client/relay-receipt-intake.js +111 -0
  59. package/dist/client/relay-receipt-intake.js.map +1 -0
  60. package/dist/client/relay-receipt-join.d.ts +50 -0
  61. package/dist/client/relay-receipt-join.d.ts.map +1 -0
  62. package/dist/client/relay-receipt-join.js +106 -0
  63. package/dist/client/relay-receipt-join.js.map +1 -0
  64. package/dist/client/relay-subscription.d.ts +12 -0
  65. package/dist/client/relay-subscription.d.ts.map +1 -1
  66. package/dist/client/relay-subscription.js +246 -83
  67. package/dist/client/relay-subscription.js.map +1 -1
  68. package/dist/client/retry-family.d.ts +119 -0
  69. package/dist/client/retry-family.d.ts.map +1 -0
  70. package/dist/client/retry-family.js +170 -0
  71. package/dist/client/retry-family.js.map +1 -0
  72. package/dist/client/retry-request-envelope.d.ts +106 -0
  73. package/dist/client/retry-request-envelope.d.ts.map +1 -0
  74. package/dist/client/retry-request-envelope.js +245 -0
  75. package/dist/client/retry-request-envelope.js.map +1 -0
  76. package/dist/client/retry.d.ts +63 -22
  77. package/dist/client/retry.d.ts.map +1 -1
  78. package/dist/client/retry.js +234 -136
  79. package/dist/client/retry.js.map +1 -1
  80. package/dist/client/sealed-sender.d.ts +15 -3
  81. package/dist/client/sealed-sender.d.ts.map +1 -1
  82. package/dist/client/sealed-sender.js +22 -3
  83. package/dist/client/sealed-sender.js.map +1 -1
  84. package/dist/client/signal-service-cipher.d.ts +64 -1
  85. package/dist/client/signal-service-cipher.d.ts.map +1 -1
  86. package/dist/client/signal-service-cipher.js +212 -17
  87. package/dist/client/signal-service-cipher.js.map +1 -1
  88. package/dist/client/state.d.ts +7 -60
  89. package/dist/client/state.d.ts.map +1 -1
  90. package/dist/client/state.js +8 -86
  91. package/dist/client/state.js.map +1 -1
  92. package/dist/client/types.d.ts +11 -3
  93. package/dist/client/types.d.ts.map +1 -1
  94. package/dist/client/types.js.map +1 -1
  95. package/dist/index.d.ts +2 -2
  96. package/dist/index.d.ts.map +1 -1
  97. package/dist/index.js.map +1 -1
  98. package/dist/internal/protocol/sealed-sender/types.d.ts +1 -1
  99. package/dist/internal/protocol/sealed-sender/types.js +1 -1
  100. package/dist/local/store/received-content.d.ts +16 -2
  101. package/dist/local/store/received-content.d.ts.map +1 -1
  102. package/dist/local/store/received-content.js +18 -3
  103. package/dist/local/store/received-content.js.map +1 -1
  104. package/dist/local/store/reliability.d.ts +291 -2
  105. package/dist/local/store/reliability.d.ts.map +1 -1
  106. package/dist/local/store/reliability.js +451 -13
  107. package/dist/local/store/reliability.js.map +1 -1
  108. package/dist/remote/relay/index.d.ts +1 -1
  109. package/dist/remote/relay/index.d.ts.map +1 -1
  110. package/dist/remote/relay/index.js.map +1 -1
  111. package/dist/remote/relay/types.d.ts +34 -30
  112. package/dist/remote/relay/types.d.ts.map +1 -1
  113. package/dist/types/api.d.ts +43 -22
  114. package/dist/types/api.d.ts.map +1 -1
  115. package/docs/ASSURANCE.md +5 -5
  116. package/docs/DEVIATIONS.md +4 -5
  117. package/docs/INTERFACES.md +2 -0
  118. package/package.json +1 -1
@@ -8,10 +8,14 @@ import { EncryptionError, EncryptionErrorCode } from '../types/index.js';
8
8
  import { determineRetryReason, isRetryableDecryptionError } from './retry-utils.js';
9
9
  import { checkRetryRateLimit, RETRY_REQUEST_WINDOW_MS } from './retry.js';
10
10
  import { base64ToBytes } from '../internal/crypto/index.js';
11
- import { hasProcessedEnvelope, storeProcessedEnvelope, withProcessedEnvelopeLock, } from '../local/store/reliability.js';
12
- import { receivedContentId, pruneReceivedContent } from '../local/store/received-content.js';
11
+ import { getProcessedEnvelope, retryFamilyMember, storeProcessedEnvelope, } from '../local/store/reliability.js';
12
+ import { deliveredEnvelopeFingerprint, pruneReceivedContent, } from '../local/store/received-content.js';
13
13
  import { isImplicitContentType } from './constants.js';
14
14
  import { rethrowRelayWorkStopped } from './relay-work.js';
15
+ import { postRetryRequest, readRetryRequestEnvelope } from './retry-request-envelope.js';
16
+ import { receiveInRetryFamily } from './retry-family.js';
17
+ import { unsealedEnvelopeOf } from './sealed-sender.js';
18
+ import { relayReceiptJoinOf } from './relay-receipt-join.js';
15
19
  /** A batch flushes this long after its last arrival. */
16
20
  export const RECEIPT_BATCH_DELAY_MS = 3_000;
17
21
  /** A batch flushes no later than this long after its first arrival. */
@@ -63,6 +67,9 @@ async function markDeliveredSilently(relay, envelopeId, logger) {
63
67
  * │ → dataMessage: Content → onMessageDecrypted → ContentRouter │
64
68
  * │ → receiptMessage: Receipt → handleDeliveryReceipt │
65
69
  * │ → typingMessage: Typing → handleTypingIndicator │
70
+ * │ │
71
+ * │ A 'retry_request' envelope is not encrypted. It skips │
72
+ * │ decryption and goes to handleRetryRequest. │
66
73
  * └─────────────────────────────────────────────────────────────────┘
67
74
  * ```
68
75
  *
@@ -78,21 +85,23 @@ export async function handleRelayMessage(ctx, envelope, state, callbacks, config
78
85
  }
79
86
  /** Process content before either foreground or background transport acknowledges it. */
80
87
  export async function processRelayMessage(ctx, envelope, state, callbacks, config) {
81
- if (!envelope.id) {
82
- return handleRelayMessageLocked(ctx, envelope, state, callbacks, config);
83
- }
84
- return withProcessedEnvelopeLock(ctx.storage, envelope.id, () => handleRelayMessageLocked(ctx, envelope, state, callbacks, config));
88
+ return receiveInRetryFamily(ctx.storage, ctx.logger, envelope, (family) => handleRelayMessageLocked(ctx, envelope, family, state, callbacks, config));
85
89
  }
86
- async function handleRelayMessageLocked(ctx, envelope, state, callbacks, config) {
90
+ async function handleRelayMessageLocked(ctx, envelope, family, state, callbacks, config) {
87
91
  const receiveId = envelope.id
88
- ? await receivedContentId(ctx.userId, ctx.deviceId, envelope)
92
+ ? await deliveredEnvelopeFingerprint(ctx.userId, ctx.deviceId, envelope)
89
93
  : undefined;
90
94
  await pruneReceivedContent(ctx.storage);
91
- if (envelope.id &&
92
- (await hasProcessedEnvelope(ctx.storage, envelope.id, Date.now(), receiveId))) {
95
+ const processed = envelope.id ? await getProcessedEnvelope(ctx.storage, envelope.id) : null;
96
+ if (processed) {
93
97
  if (receiveId)
94
98
  await ctx.storage.deleteReceivedContent(receiveId);
95
- ctx.logger.debug('Acknowledging previously processed relay envelope', {
99
+ // After the Relay forgets a row, the same ID can carry a new encryption.
100
+ // The local device processed that ID, so it drops the new bytes too.
101
+ const identityChanged = receiveId !== undefined && receiveId !== processed.fingerprint;
102
+ ctx.logger.debug(identityChanged
103
+ ? 'Acknowledging a processed relay envelope ID with changed content'
104
+ : 'Acknowledging previously processed relay envelope', {
96
105
  category: 'E2EE',
97
106
  data: {
98
107
  envelopeId: envelope.id,
@@ -101,6 +110,20 @@ async function handleRelayMessageLocked(ctx, envelope, state, callbacks, config)
101
110
  });
102
111
  return true;
103
112
  }
113
+ if (envelope.messageType === 'retry_request') {
114
+ await handleRetryRequestEnvelope(ctx, envelope, callbacks);
115
+ if (envelope.id) {
116
+ await storeProcessedEnvelope(ctx.storage, envelope.id, Date.now(), receiveId);
117
+ }
118
+ return true;
119
+ }
120
+ if (!(await family.admit())) {
121
+ if (envelope.id)
122
+ await storeProcessedEnvelope(ctx.storage, envelope.id, Date.now(), receiveId);
123
+ if (receiveId)
124
+ await ctx.storage.deleteReceivedContent(receiveId);
125
+ return true;
126
+ }
104
127
  if (!ctx.hooks?.onMessageDecrypted) {
105
128
  throw new Error('Register onMessageDecrypted before receiving Relay messages');
106
129
  }
@@ -112,24 +135,91 @@ async function handleRelayMessageLocked(ctx, envelope, state, callbacks, config)
112
135
  }
113
136
  catch (error) {
114
137
  rethrowRelayWorkStopped(error);
115
- // ERROR: Handle decryption failure
116
- await handleDecryptionError(ctx, envelope, error, state, callbacks, config);
138
+ // A failure inside the seal names the unsealed sender, so the retry
139
+ // request goes to that device. The unsealed envelope keeps the ID. A
140
+ // member whose seal fails to open asks the device of its request.
141
+ const failed = family.withRequestedSender(unsealedEnvelopeOf(error) ?? envelope);
142
+ await handleDecryptionError(ctx, failed, error, state, callbacks, config, receiveId, family);
117
143
  return false;
118
144
  }
119
- await handleDecryptionSuccess(ctx, envelope, decryptedEnvelope, state, callbacks);
120
- if (envelope.id)
121
- await storeProcessedEnvelope(ctx.storage, envelope.id, Date.now(), receiveId);
145
+ // Route by decrypted content type, not the outer relay-envelope type.
146
+ const inspectedContent = ctx.contentAdapter.inspectContent(decryptedEnvelope.content);
147
+ // A null message carries no content, so the application never gets it
148
+ // and it fulfills nothing. It is acknowledged as a duplicate is.
149
+ if (inspectedContent.nullMessage) {
150
+ await family.consumeNull(receiveId);
151
+ }
152
+ else {
153
+ await handleDecryptionSuccess(ctx, envelope, decryptedEnvelope, inspectedContent, state, callbacks);
154
+ await family.fulfill();
155
+ if (envelope.id) {
156
+ await storeProcessedEnvelope(ctx.storage, envelope.id, Date.now(), receiveId);
157
+ }
158
+ }
122
159
  if (receiveId)
123
160
  await ctx.storage.deleteReceivedContent(receiveId);
124
161
  return true;
125
162
  }
163
+ /**
164
+ * Handle a `retry_request` envelope. The payload is not encrypted, so the
165
+ * envelope never reaches decryption.
166
+ *
167
+ * The function returns normally when the request is handled, refused or
168
+ * dropped, and the caller then acknowledges the envelope. It drops an
169
+ * envelope from an anonymous sender and an envelope that does not decode,
170
+ * with one warn line. An error from the handler propagates, so the envelope
171
+ * stays in the mailbox for the next pull.
172
+ */
173
+ async function handleRetryRequestEnvelope(ctx, envelope, callbacks) {
174
+ if (!envelope.senderUserId || !(envelope.senderDeviceId >= 1)) {
175
+ ctx.logger.warn('Dropping retry request without an identified sender', {
176
+ category: 'E2EE',
177
+ data: { envelopeId: envelope.id, behavior: 'RETRY_REQUEST_DROP' },
178
+ });
179
+ return;
180
+ }
181
+ const read = readRetryRequestEnvelope(envelope, { userId: ctx.userId, deviceId: ctx.deviceId });
182
+ if (!read.ok) {
183
+ ctx.logger.warn('Dropping malformed retry request', {
184
+ category: 'E2EE',
185
+ data: {
186
+ envelopeId: envelope.id,
187
+ sender: `${envelope.senderUserId}:${envelope.senderDeviceId}`,
188
+ cause: read.cause,
189
+ behavior: 'RETRY_REQUEST_DROP',
190
+ },
191
+ });
192
+ return;
193
+ }
194
+ // The requester names each request attempt
195
+ // `<retryId>:retry-request[:n]`. The Signal Protocol Relay delivers that
196
+ // name as the envelope ID. A relay that assigns its own envelope IDs
197
+ // delivers it as the client message ID. The sender keys one resend
198
+ // encryption by it and answers with its attempt number, so a redelivery
199
+ // of the same request replays the stored resend.
200
+ const requestEnvelopeId = envelope.clientMessageId ?? envelope.id;
201
+ const member = requestEnvelopeId ? retryFamilyMember(requestEnvelopeId) : undefined;
202
+ if (read.retry &&
203
+ (member?.kind !== 'retry-request' || member.retryId !== read.retry.retryId)) {
204
+ ctx.logger.warn('Dropping malformed retry request', {
205
+ category: 'E2EE',
206
+ data: {
207
+ envelopeId: envelope.id,
208
+ sender: `${envelope.senderUserId}:${envelope.senderDeviceId}`,
209
+ cause: 'envelope ID is not a request attempt of the retry ID',
210
+ behavior: 'RETRY_REQUEST_DROP',
211
+ },
212
+ });
213
+ return;
214
+ }
215
+ await callbacks.handleRetryRequest(read.request, read.retry && { ...read.retry, requestEnvelopeId: requestEnvelopeId });
216
+ }
126
217
  /**
127
218
  * Handle successful message decryption
128
219
  */
129
- async function handleDecryptionSuccess(ctx, envelope, decryptedEnvelope, state, callbacks) {
130
- // Route by decrypted content type, not the outer relay-envelope type.
131
- // Parse content to determine if it is a receipt, typing indicator, or data message.
132
- const inspectedContent = ctx.contentAdapter.inspectContent(decryptedEnvelope.content);
220
+ async function handleDecryptionSuccess(ctx, envelope, decryptedEnvelope, inspectedContent, state, callbacks) {
221
+ // The inspected content tells a receipt, a typing indicator and a data
222
+ // message apart.
133
223
  const { receipt, typing } = inspectedContent;
134
224
  const authenticatedEnvelope = {
135
225
  ...envelope,
@@ -165,12 +255,28 @@ async function handleDecryptionSuccess(ctx, envelope, decryptedEnvelope, state,
165
255
  await receive(decryptedEnvelope);
166
256
  // Batch delivery receipts before sending
167
257
  // Multi-device: sendDeliveryReceipt fans out to all sender's devices
168
- // 'auto' is the default, and it sends as 'always' does, for a sealed,
169
- // identified, or unknown arrival.
170
258
  const receipts = ctx.config.deliveryReceipts ?? 'auto';
171
259
  if (decryptedEnvelope.timestamp && ctx.relay && receipts !== 'off') {
172
260
  if (inspectedContent.shouldSendDeliveryReceipt) {
173
- accumulateDeliveryReceipt(state.receiptAccumulator, decryptedEnvelope.senderId, decryptedEnvelope.timestamp, callbacks.sendDeliveryReceipt, ctx.logger);
261
+ const { senderId, timestamp } = decryptedEnvelope;
262
+ const accumulate = () => accumulateDeliveryReceipt(state.receiptAccumulator, senderId, timestamp, callbacks.sendDeliveryReceipt, ctx.logger);
263
+ // 'auto' leaves the receipt of an identified or unknown arrival to
264
+ // the Relay when the reply to its acknowledgment lists it. A sealed
265
+ // arrival, an ephemeral one, and one through a relay without a
266
+ // receipt join always get the E2EE receipt.
267
+ const join = receipts === 'auto' ? relayReceiptJoinOf(ctx.relay) : undefined;
268
+ if (join !== undefined &&
269
+ envelope.id !== undefined &&
270
+ decryptedEnvelope.arrivedSealed !== true &&
271
+ envelope.deliveryClass !== 'ephemeral') {
272
+ join.await(envelope.id, (relayOwnsReceipt) => {
273
+ if (!relayOwnsReceipt)
274
+ accumulate();
275
+ });
276
+ }
277
+ else {
278
+ accumulate();
279
+ }
174
280
  }
175
281
  }
176
282
  }
@@ -248,8 +354,12 @@ function flushReceipts(acc, senderUserId, flush, logger) {
248
354
  * Classifies failures by ContentHint:
249
355
  * - IMPLICIT: silently discard (typing indicators, receipts, legacy messages)
250
356
  * - RESENDABLE: request retry from sender
357
+ *
358
+ * A failed resend or null message of a retry request asks again for its
359
+ * failed envelope, whatever its content hint: the failed envelope still has
360
+ * no content.
251
361
  */
252
- async function handleDecryptionError(ctx, envelope, error, state, callbacks, config) {
362
+ async function handleDecryptionError(ctx, envelope, error, state, callbacks, config, receiveId, family) {
253
363
  // A consumed ratchet key proves decryption, not application persistence.
254
364
  // Only the processed-envelope receipt above can authorize duplicate ACKs.
255
365
  if (error instanceof EncryptionError && error.code === EncryptionErrorCode.MESSAGE_DUPLICATE) {
@@ -264,6 +374,10 @@ async function handleDecryptionError(ctx, envelope, error, state, callbacks, con
264
374
  });
265
375
  return;
266
376
  }
377
+ if (family.member !== undefined && envelope.timestamp > 0) {
378
+ await sendRetryRequest(ctx, envelope, error, state, callbacks, config, receiveId, family);
379
+ return;
380
+ }
267
381
  // Early exit: Implicit messages (typing indicators, receipts) should be
268
382
  // silently discarded without ERROR-level logs. This prevents log spam
269
383
  // for expected failures on messages that will not be retried anyway.
@@ -333,13 +447,54 @@ async function handleDecryptionError(ctx, envelope, error, state, callbacks, con
333
447
  return;
334
448
  }
335
449
  // RESENDABLE behavior: request retry from sender
336
- await sendRetryRequest(ctx, envelope, error, state, callbacks, config);
450
+ await sendRetryRequest(ctx, envelope, error, state, callbacks, config, receiveId, family);
337
451
  }
338
452
  /**
339
- * Send retry request for failed message decryption
453
+ * Send a `retry_request` envelope to the device that sent a failed message.
454
+ *
455
+ * The checks run in this order: an identified sender that is not the local
456
+ * device, then the per-sender rate limit, which counts each post. A failed
457
+ * envelope that does not pass them gets no request, and the caller keeps it
458
+ * or acknowledges it as for any failed envelope. The request is stored
459
+ * under the failed envelope ID before its post, and a later failure of the
460
+ * same envelope posts the stored request again.
461
+ *
462
+ * A failed resend or null message asks again for its failed envelope
463
+ * through the retry family (`RetryFamilyReceive.requestRetry`).
340
464
  */
341
- async function sendRetryRequest(ctx, envelope, error, state, callbacks, config) {
465
+ async function sendRetryRequest(ctx, envelope, error, state, callbacks, config, receiveId, family) {
342
466
  try {
467
+ // An anonymous envelope names no device to ask. A member stays
468
+ // unacknowledged, so the content of its failed envelope is not lost.
469
+ if (!envelope.senderUserId || !(envelope.senderDeviceId >= 1)) {
470
+ ctx.logger.warn('No retry request for a failed envelope without an identified sender', {
471
+ category: 'E2EE',
472
+ data: {
473
+ envelopeId: envelope.id,
474
+ messageType: envelope.messageType,
475
+ behavior: 'RETRY_REQUEST_SKIP',
476
+ },
477
+ });
478
+ if (config.acknowledgeFailures !== false && family.member === undefined) {
479
+ await markDeliveredSilently(ctx.relay, envelope.id, ctx.logger);
480
+ }
481
+ return;
482
+ }
483
+ // A device never asks itself for a resend. Its resend would fail again.
484
+ if (envelope.senderUserId === ctx.userId && envelope.senderDeviceId === ctx.deviceId) {
485
+ ctx.logger.warn('No retry request for a failed envelope from the local device', {
486
+ category: 'E2EE',
487
+ data: {
488
+ envelopeId: envelope.id,
489
+ messageType: envelope.messageType,
490
+ behavior: 'RETRY_REQUEST_SKIP',
491
+ },
492
+ });
493
+ if (config.acknowledgeFailures !== false) {
494
+ await markDeliveredSilently(ctx.relay, envelope.id, ctx.logger);
495
+ }
496
+ return;
497
+ }
343
498
  // Convert envelope to SesameMessage format for retry request
344
499
  const failedMessage = {
345
500
  senderUserId: envelope.senderUserId,
@@ -347,77 +502,85 @@ async function sendRetryRequest(ctx, envelope, error, state, callbacks, config)
347
502
  recipientUserId: ctx.userId,
348
503
  recipientDeviceId: ctx.deviceId,
349
504
  sessionId: `${envelope.senderUserId}:${envelope.senderDeviceId}`,
350
- ciphertext: typeof envelope.ciphertext === 'string'
351
- ? base64ToBytes(envelope.ciphertext)
352
- : envelope.ciphertext,
505
+ // A seal that fails to open gives no ratchet key.
506
+ ciphertext: envelope.messageType === 'unidentified_sender'
507
+ ? new Uint8Array()
508
+ : typeof envelope.ciphertext === 'string'
509
+ ? base64ToBytes(envelope.ciphertext)
510
+ : envelope.ciphertext,
353
511
  isInitiating: envelope.messageType === 'prekey_bundle',
354
512
  initHeader: null,
355
513
  timestamp: envelope.timestamp,
356
514
  };
357
515
  const retryReason = determineRetryReason(error);
358
- // Receiver-side rate limiting
359
- if (!checkRetryRateLimit(state, envelope.senderUserId)) {
360
- ctx.logger.warn('Retry rate limit exceeded for sender', {
361
- category: 'E2EE',
362
- data: {
363
- senderId: envelope.senderUserId,
364
- windowMs: RETRY_REQUEST_WINDOW_MS,
365
- },
366
- });
367
- if (config.acknowledgeFailures !== false) {
368
- await markDeliveredSilently(ctx.relay, envelope.id, ctx.logger);
516
+ if (!ctx.relay)
517
+ throw new Error('Relay not configured - cannot send a retry request');
518
+ const relay = ctx.relay;
519
+ const posted = await family.requestRetry(receiveId, async (failed) => {
520
+ // Receiver-side rate limiting. A post of a stored request counts too.
521
+ if (!checkRetryRateLimit(state, envelope.senderUserId)) {
522
+ ctx.logger.warn('Retry rate limit exceeded for sender', {
523
+ category: 'E2EE',
524
+ data: {
525
+ senderId: envelope.senderUserId,
526
+ windowMs: RETRY_REQUEST_WINDOW_MS,
527
+ },
528
+ });
529
+ // A member stays unacknowledged, so its redelivery after the
530
+ // window asks again.
531
+ if (config.acknowledgeFailures !== false && family.member === undefined) {
532
+ await markDeliveredSilently(ctx.relay, envelope.id, ctx.logger);
533
+ }
534
+ return false;
369
535
  }
370
- return;
371
- }
372
- // Handle stale prekey indicators
373
- await handleStalePreKeyIndicator(ctx, envelope, error, state, callbacks, config);
374
- // Create retry request via SESAME manager
375
- const retryRequest = await ctx.sesameManager.createRetryRequest(failedMessage, retryReason);
376
- ctx.logger.info('Retry request created for failed message', {
377
- category: 'E2EE',
378
- data: {
379
- sender: `${envelope.senderUserId}:${envelope.senderDeviceId}`,
380
- timestamp: envelope.timestamp,
381
- reason: retryReason,
382
- localUserId: ctx.userId,
383
- localDeviceId: ctx.deviceId,
384
- },
385
- });
386
- // Send retry request via relay
387
- if (ctx.relay?.sendRetryRequest) {
388
- await ctx.relay.sendRetryRequest(retryRequest);
536
+ await postRetryRequest(ctx.storage, failed, async () => {
537
+ // Handle stale prekey indicators
538
+ await handleStalePreKeyIndicator(ctx, envelope, error, state, callbacks, config);
539
+ const retryRequest = await ctx.sesameManager.createRetryRequest(failedMessage, retryReason);
540
+ ctx.logger.info('Retry request created for failed message', {
541
+ category: 'E2EE',
542
+ data: {
543
+ sender: `${envelope.senderUserId}:${envelope.senderDeviceId}`,
544
+ timestamp: envelope.timestamp,
545
+ reason: retryReason,
546
+ localUserId: ctx.userId,
547
+ localDeviceId: ctx.deviceId,
548
+ },
549
+ });
550
+ return retryRequest;
551
+ }, { userId: ctx.userId, deviceId: ctx.deviceId }, (request) => relay.send(request));
389
552
  ctx.logger.info('Retry request sent to sender', {
390
553
  category: 'E2EE',
391
554
  data: {
392
555
  originalSender: `${envelope.senderUserId}:${envelope.senderDeviceId}`,
393
556
  timestamp: envelope.timestamp,
394
557
  reason: retryReason,
558
+ stored: failed.stored !== null,
395
559
  },
396
560
  });
397
- // Mark failed message as delivered so it does not reappear
398
- if (envelope.id && config.acknowledgeFailures !== false) {
399
- try {
400
- await ctx.relay.markDelivered(envelope.id);
401
- ctx.logger.debug('Marked failed message as delivered after retry request', {
402
- category: 'E2EE',
403
- data: { envelopeId: envelope.id },
404
- });
405
- }
406
- catch (markError) {
407
- ctx.logger.warn('Failed to mark message as delivered after retry', {
408
- category: 'E2EE',
409
- data: {
410
- envelopeId: envelope.id,
411
- error: markError.message,
412
- },
413
- });
414
- }
561
+ return true;
562
+ });
563
+ // An envelope with no post stays unacknowledged.
564
+ if (!posted)
565
+ return;
566
+ // Mark failed message as delivered so it does not reappear
567
+ if (envelope.id && config.acknowledgeFailures !== false) {
568
+ try {
569
+ await relay.markDelivered(envelope.id);
570
+ ctx.logger.debug('Marked failed message as delivered after retry request', {
571
+ category: 'E2EE',
572
+ data: { envelopeId: envelope.id },
573
+ });
574
+ }
575
+ catch (markError) {
576
+ ctx.logger.warn('Failed to mark message as delivered after retry', {
577
+ category: 'E2EE',
578
+ data: {
579
+ envelopeId: envelope.id,
580
+ error: markError.message,
581
+ },
582
+ });
415
583
  }
416
- }
417
- else {
418
- ctx.logger.debug('Relay does not support retry requests', {
419
- category: 'E2EE',
420
- });
421
584
  }
422
585
  }
423
586
  catch (retryError) {
@@ -1 +1 @@
1
- {"version":3,"file":"relay-subscription.js","sourceRoot":"","sources":["../../client/relay-subscription.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAe,MAAM,UAAU,CAAC;AAC7E,OAAO,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAC;AACjF,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAKvE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAC1F,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAgCvD,wDAAwD;AACxD,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,CAAC;AAC5C,uEAAuE;AACvE,MAAM,CAAC,MAAM,wBAAwB,GAAG,MAAM,CAAC;AAC/C,0DAA0D;AAC1D,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,CAAC;AACrC;;;GAGG;AACH,MAAM,CAAC,MAAM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AAK,CAAC,IAAI,KAAK,mBAAmB,CAAC,gBAAgB;gBACjD,CAAC,CAAC,kBAAkB;gBACpB,CAAC,CAAC,8BAA8B,CAAC;YAErC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,6DAA6D,EAAE;gBAC7E,QAAQ,EAAE,MAAM;gBAChB,IAAI,EAAE;oBACJ,MAAM;oBACN,WAAW,EAAE,QAAQ,CAAC,WAAW;iBAClC;aACF,CAAC,CAAC;YAEH,MAAM,SAAS,CAAC,mBAAmB,EAAE,CAAC;YACtC,KAAK,CAAC,sBAAsB,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAC5C,CAAC;QAAC,OAAO,aAAa,EAAE,CAAC;YACvB,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,iCAAiC,EAAE;gBACjD,QAAQ,EAAE,MAAM;gBAChB,IAAI,EAAE,EAAE,KAAK,EAAG,aAAuB,CAAC,OAAO,EAAE;aAClD,CAAC,CAAC;QACL,CAAC;IACH,CAAC;SAAM,CAAC;QACN,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,sDAAsD,EAAE;YACvE,QAAQ,EAAE,MAAM;YAChB,IAAI,EAAE,EAAE,uBAAuB,EAAE,qBAAqB,EAAE;SACzD,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
@@ -0,0 +1,119 @@
1
+ /**
2
+ * The retry family of a received envelope.
3
+ *
4
+ * A failed envelope, the request record that the requester keeps for it, and
5
+ * each resend or null message that answers that record form one retry
6
+ * family. The family index gives the failed envelope of a retry ID. Both
7
+ * receive paths, the relay subscription route and `processIncomingEnvelope`,
8
+ * receive each envelope through `receiveInRetryFamily`, so the application
9
+ * gets the content of one failed envelope at most once, from the envelope
10
+ * itself or from one family member.
11
+ */
12
+ import type { Logger } from '../logger.js';
13
+ import { withProcessedEnvelopeLock, type ResolvedRetryFamilyMember } from '../local/store/reliability.js';
14
+ import type { RetryRequestFailure } from './retry-request-envelope.js';
15
+ type RetryFamilyStore = Parameters<typeof withProcessedEnvelopeLock>[0];
16
+ /**
17
+ * One received envelope in the retry family of its failed envelope. The
18
+ * receive path calls `admit` before the decrypt, `fulfill` after a decrypt
19
+ * that succeeds, and `requestRetry` after a decrypt that fails.
20
+ */
21
+ export interface RetryFamilyReceive {
22
+ /**
23
+ * The resend or the null message that the envelope is, when the family
24
+ * index of the local device holds its retry ID. Undefined for any other
25
+ * envelope.
26
+ */
27
+ readonly member: ResolvedRetryFamilyMember | undefined;
28
+ /**
29
+ * Tell whether the envelope goes to the decrypt. False when the local
30
+ * device processed the envelope, or when the application already has the
31
+ * content of its failed envelope: the caller then acknowledges the
32
+ * envelope and drops it, with no decrypt and no retry request. This
33
+ * applies to the failed envelope and to each member. The check writes a
34
+ * debug log line for a dropped envelope. A member that goes to the decrypt
35
+ * marks the stored request attempt answered when the member has its
36
+ * attempt number.
37
+ */
38
+ admit(): Promise<boolean>;
39
+ /**
40
+ * Record a decrypt that succeeded. For a member, and for a failed
41
+ * envelope with a request record, one write marks the failed envelope
42
+ * processed and fulfilled. A redelivery of the failed envelope on either
43
+ * path is then dropped, and so is each later member. When the write
44
+ * fails, it writes one warning with the behavior
45
+ * RETRY_FULFILL_WRITE_FAILED and returns, so the caller continues as for
46
+ * any decrypted envelope. A redelivery of the failed envelope or of
47
+ * another member can then give the content again.
48
+ */
49
+ fulfill(): Promise<void>;
50
+ /**
51
+ * Record a decrypted null message, in place of `fulfill`. A null
52
+ * message carries no content, so the caller never gives it to the
53
+ * application. The null message is processed. For a member, the failed
54
+ * envelope is processed and not fulfilled: a redelivery of the failed
55
+ * envelope is dropped, the client asks for it no more, and a content
56
+ * resend that comes later is still admitted. When a processed write
57
+ * fails, it writes one warning with the behavior
58
+ * RETRY_NULL_WRITE_FAILED and returns, as `fulfill` does, so the caller
59
+ * still consumes the null message. A redelivery of the failed envelope
60
+ * can then give the content.
61
+ *
62
+ * @param fingerprint - The fingerprint of the received envelope.
63
+ */
64
+ consumeNull(fingerprint: string | undefined): Promise<void>;
65
+ /**
66
+ * Name the sender of a member whose seal fails to open. Such a member
67
+ * names no sender, and the request record that `admit` read names the
68
+ * device that the request went to. The result is that envelope with the
69
+ * sender of the record. Any other envelope, and a member with an
70
+ * identified sender or with no request record, is returned as it is.
71
+ */
72
+ withRequestedSender<E extends {
73
+ senderUserId: string;
74
+ senderDeviceId: number;
75
+ }>(envelope: E): E;
76
+ /**
77
+ * Ask the sender for a resend after a decrypt that failed. The request
78
+ * record is keyed by the failed envelope of the family. A member never
79
+ * starts a family of its own: it asks again for its failed envelope,
80
+ * under the retry ID of the record, and the fingerprint check of the
81
+ * failed envelope does not apply to it.
82
+ *
83
+ * @param fingerprint - The fingerprint of the received envelope.
84
+ * @param post - Posts the request for the given failure. It returns false
85
+ * when it posts nothing, for example under the rate limit.
86
+ * @returns True when `post` posted the request. After the post, a member
87
+ * is processed, so a redelivery of it on either path posts nothing. A
88
+ * failed post leaves it unprocessed. False with no post, and one warn
89
+ * line with the behavior RETRY_REQUEST_ENVELOPE_CHANGED, when the relay
90
+ * changed the failed envelope after its retry request.
91
+ */
92
+ requestRetry(fingerprint: string | undefined, post: (failed: RetryRequestFailure) => Promise<boolean>): Promise<boolean>;
93
+ }
94
+ /**
95
+ * Receive one envelope in the retry family of its failed envelope.
96
+ *
97
+ * A resend or a null message resolves to its failed envelope through the
98
+ * family index, by its SDK ID: the client message ID, or the envelope ID
99
+ * when the relay delivers no client message ID. A relay that assigns its
100
+ * own envelope IDs delivers the SDK ID as the client message ID. The
101
+ * receive then holds the processed-envelope lock of that failed envelope,
102
+ * so the fulfilled check, the decrypt and the fulfilled store of one
103
+ * family run one at a time on all paths. Any other envelope holds the lock
104
+ * of its own ID. An envelope with no ID holds no lock and has no family.
105
+ * The processed record and the acknowledgment use the delivered envelope
106
+ * ID.
107
+ *
108
+ * @param storage - The local store that keeps the retry records.
109
+ * @param logger - The client logger.
110
+ * @param envelope - The IDs of the received envelope: the delivered
111
+ * envelope ID, and the client message ID when the relay delivers one.
112
+ * @param receive - The receive path. It runs under the lock.
113
+ */
114
+ export declare function receiveInRetryFamily<T>(storage: RetryFamilyStore, logger: Required<Logger>, envelope: {
115
+ readonly id?: string;
116
+ readonly clientMessageId?: string;
117
+ }, receive: (family: RetryFamilyReceive) => Promise<T>): Promise<T>;
118
+ export {};
119
+ //# sourceMappingURL=retry-family.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retry-family.d.ts","sourceRoot":"","sources":["../../client/retry-family.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAOL,yBAAyB,EACzB,KAAK,yBAAyB,EAE/B,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAEpE,KAAK,gBAAgB,GAAG,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAAC,CAAC,CAAC,CAAC;AAExE;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;;OAIG;IACH,QAAQ,CAAC,MAAM,EAAE,yBAAyB,GAAG,SAAS,CAAC;IACvD;;;;;;;;;OASG;IACH,KAAK,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAC1B;;;;;;;;;OASG;IACH,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACzB;;;;;;;;;;;;;OAaG;IACH,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5D;;;;;;OAMG;IACH,mBAAmB,CAAC,CAAC,SAAS;QAAE,YAAY,EAAE,MAAM,CAAC;QAAC,cAAc,EAAE,MAAM,CAAA;KAAE,EAC5E,QAAQ,EAAE,CAAC,GACV,CAAC,CAAC;IACL;;;;;;;;;;;;;;;OAeG;IACH,YAAY,CACV,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,IAAI,EAAE,CAAC,MAAM,EAAE,mB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