@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
@@ -0,0 +1,245 @@
1
+ /**
2
+ * Wire form of a retry request.
3
+ *
4
+ * A retry request travels as an identified mailbox envelope with
5
+ * `messageType: 'retry_request'`. The envelope sender is the requester: the
6
+ * relay stamps it, so the payload never carries it. The `ciphertext` field
7
+ * holds canonical base64 of a small UTF-8 JSON payload. The payload is not
8
+ * encrypted. It holds only what the requester knows about the failed message.
9
+ *
10
+ * The requester keeps one request record for each failed envelope. The record
11
+ * holds a random retry ID, and every wire ID of the request family derives from
12
+ * it: `<retryId>:retry-request`, `<retryId>:resend` and `<retryId>:null`, with
13
+ * `:<n>` from attempt 2. The resend and the null message carry the attempt
14
+ * number of the request that they answer. The failed envelope ID travels
15
+ * only in the payload.
16
+ * The requester stores each request envelope before the post, and posts the
17
+ * stored envelope again on a later decrypt failure of the same envelope.
18
+ */
19
+ import { RetryReason } from '../internal/sesame/types.js';
20
+ import { base64ToBytes, bytesToBase64, generateUuidV4, stringToBytes } from '../internal/crypto/index.js';
21
+ import { utf8Decode } from '../internal/platform/index.js';
22
+ import { isRetryId, retryAttemptClientMessageId, retryRequestClientMessageId, storeRetryRequest, } from '../local/store/reliability.js';
23
+ import { relayOperationRefusal } from './relay-acceptance.js';
24
+ /** The payload version that this client writes and reads. */
25
+ const RETRY_REQUEST_PAYLOAD_VERSION = 1;
26
+ /** The decoder refuses a longer `ciphertext` value before it decodes it. */
27
+ export const MAX_RETRY_REQUEST_CIPHERTEXT_LENGTH = 2_048;
28
+ /** The Relay refuses a longer message ID, so a failed envelope ID is 1 to this many characters. */
29
+ const MAX_FAILED_ENVELOPE_ID_LENGTH = 128;
30
+ /** The decoded ratchet key is 1 to this many bytes. */
31
+ const MAX_RATCHET_KEY_BYTES = 64;
32
+ const RETRY_REASONS = new Set(Object.values(RetryReason));
33
+ /**
34
+ * Make the envelope that asks the original sender device for a resend.
35
+ *
36
+ * @param request - The retry request. Its original sender is the target.
37
+ * @param sender - The local identity, which sends the envelope.
38
+ * @param failed - The ID of the failed envelope, the retry ID of its request
39
+ * record and the attempt number. The client message ID derives from the
40
+ * retry ID and the attempt. Without them, it is a new UUID.
41
+ */
42
+ export async function retryRequestEnvelope(request, sender, failed) {
43
+ const payload = {
44
+ v: RETRY_REQUEST_PAYLOAD_VERSION,
45
+ failedTimestamp: request.failedTimestamp,
46
+ deviceId: request.originalSenderDeviceId,
47
+ reason: request.reason,
48
+ timestamp: request.timestamp,
49
+ ...(request.ratchetKey === undefined ? {} : { ratchetKey: request.ratchetKey }),
50
+ ...(failed && { failedEnvelopeId: failed.failedEnvelopeId, retryId: failed.retryId }),
51
+ };
52
+ return {
53
+ targetUserId: request.originalSenderUserId,
54
+ targetDeviceId: request.originalSenderDeviceId,
55
+ senderUserId: sender.userId,
56
+ senderDeviceId: sender.deviceId,
57
+ ciphertext: bytesToBase64(stringToBytes(JSON.stringify(payload))),
58
+ messageType: 'retry_request',
59
+ deliveryClass: 'background-sync',
60
+ timestamp: Date.now(),
61
+ clientMessageId: failed
62
+ ? retryAttemptClientMessageId(retryRequestClientMessageId(failed.retryId), failed.attempt)
63
+ : await generateUuidV4(),
64
+ };
65
+ }
66
+ /**
67
+ * Post the retry request for one failed envelope.
68
+ *
69
+ * Without a failed envelope ID, it creates a request and posts it under a
70
+ * new UUID, and stores nothing. With a stored attempt, it posts the stored
71
+ * envelope again. Otherwise it creates attempt 1 with a new retry ID and
72
+ * stores it before the post. Each later attempt keeps the retry ID. When
73
+ * the Relay refuses a stored attempt with OPERATION_EXPIRED, or when a
74
+ * member failed and the stored attempt is answered, it creates the next
75
+ * attempt, replaces the record in one write, and posts it. Each new
76
+ * attempt is not answered. A RETRY_CONFLICT answer to any post completes
77
+ * the attempt, because the Relay holds an earlier encryption of this
78
+ * attempt.
79
+ *
80
+ * @param store - The local store that keeps the request records.
81
+ * @param failed - The failed envelope and its stored request.
82
+ * @param createRequest - Creates the request of a new attempt. Only a new
83
+ * attempt calls it.
84
+ * @param sender - The local identity, which sends the envelope.
85
+ * @param send - Posts one request envelope.
86
+ */
87
+ export async function postRetryRequest(store, failed, createRequest, sender, send) {
88
+ const failedEnvelopeId = failed.id;
89
+ if (failedEnvelopeId === undefined) {
90
+ await send(await retryRequestEnvelope(await createRequest(), sender));
91
+ return;
92
+ }
93
+ const post = async (envelope) => {
94
+ try {
95
+ await send(envelope);
96
+ }
97
+ catch (error) {
98
+ if (relayOperationRefusal(error) !== 'RETRY_CONFLICT')
99
+ throw error;
100
+ }
101
+ };
102
+ const create = async (attempt, retryId) => {
103
+ const envelope = await retryRequestEnvelope(await createRequest(), sender, {
104
+ failedEnvelopeId,
105
+ retryId,
106
+ attempt,
107
+ });
108
+ await storeRetryRequest(store, {
109
+ failedEnvelopeId,
110
+ retryId,
111
+ attempt,
112
+ requestedAt: envelope.timestamp,
113
+ ...(failed.fingerprint !== undefined && { fingerprint: failed.fingerprint }),
114
+ answered: false,
115
+ envelope,
116
+ });
117
+ return envelope;
118
+ };
119
+ if (!failed.stored) {
120
+ await post(await create(1, await generateUuidV4()));
121
+ return;
122
+ }
123
+ const { attempt, retryId } = failed.stored;
124
+ if (failed.member !== undefined && failed.stored.answered) {
125
+ await post(await create(attempt + 1, retryId));
126
+ return;
127
+ }
128
+ try {
129
+ await post(failed.stored.envelope);
130
+ return;
131
+ }
132
+ catch (error) {
133
+ if (relayOperationRefusal(error) !== 'OPERATION_EXPIRED')
134
+ throw error;
135
+ }
136
+ // The Relay no longer admits or replays the stored operation. The new
137
+ // attempt replaces the record before its post.
138
+ await post(await create(attempt + 1, retryId));
139
+ }
140
+ /**
141
+ * Read a `retry_request` envelope that the local device received.
142
+ *
143
+ * The requester is the envelope sender. The original sender is the local
144
+ * identity. The other fields come from the payload. A `Uint8Array`
145
+ * ciphertext is read as its base64 form. The function ignores
146
+ * every payload key that it does not read, a requester key included. It does
147
+ * not check the envelope sender: the caller does that first.
148
+ *
149
+ * @param envelope - The received envelope.
150
+ * @param local - The local identity.
151
+ * @returns The retry request, or the cause of the refusal. The cause never
152
+ * holds payload bytes.
153
+ */
154
+ export function readRetryRequestEnvelope(envelope, local) {
155
+ // A relay can deliver raw bytes. The checks apply to their base64 form.
156
+ const ciphertext = typeof envelope.ciphertext === 'string'
157
+ ? envelope.ciphertext
158
+ : bytesToBase64(envelope.ciphertext);
159
+ if (ciphertext.length > MAX_RETRY_REQUEST_CIPHERTEXT_LENGTH) {
160
+ return { ok: false, cause: 'payload is too long' };
161
+ }
162
+ const bytes = canonicalBase64Bytes(ciphertext);
163
+ if (bytes === undefined) {
164
+ return { ok: false, cause: 'payload is not canonical base64' };
165
+ }
166
+ let value;
167
+ try {
168
+ value = JSON.parse(utf8Decode(bytes, { fatal: true }));
169
+ }
170
+ catch {
171
+ return { ok: false, cause: 'payload is not JSON' };
172
+ }
173
+ if (typeof value !== 'object' || value === null || Array.isArray(value)) {
174
+ return { ok: false, cause: 'payload is not a JSON object' };
175
+ }
176
+ const payload = value;
177
+ if (payload.v !== RETRY_REQUEST_PAYLOAD_VERSION) {
178
+ return { ok: false, cause: 'payload version is not supported' };
179
+ }
180
+ const { failedTimestamp, deviceId, reason, timestamp, ratchetKey, failedEnvelopeId, retryId } = payload;
181
+ if (!Number.isSafeInteger(failedTimestamp) || failedTimestamp <= 0) {
182
+ return { ok: false, cause: 'failedTimestamp is not valid' };
183
+ }
184
+ if (!Number.isSafeInteger(deviceId) || deviceId < 1) {
185
+ return { ok: false, cause: 'deviceId is not valid' };
186
+ }
187
+ if (typeof reason !== 'string' || !RETRY_REASONS.has(reason)) {
188
+ return { ok: false, cause: 'reason is not known' };
189
+ }
190
+ if (!Number.isSafeInteger(timestamp)) {
191
+ return { ok: false, cause: 'timestamp is not valid' };
192
+ }
193
+ if (ratchetKey !== undefined) {
194
+ const ratchetKeyBytes = typeof ratchetKey === 'string' ? canonicalBase64Bytes(ratchetKey) : undefined;
195
+ if (ratchetKeyBytes === undefined ||
196
+ ratchetKeyBytes.length < 1 ||
197
+ ratchetKeyBytes.length > MAX_RATCHET_KEY_BYTES) {
198
+ return { ok: false, cause: 'ratchetKey is not valid' };
199
+ }
200
+ }
201
+ if (failedEnvelopeId !== undefined &&
202
+ (typeof failedEnvelopeId !== 'string' ||
203
+ failedEnvelopeId.length < 1 ||
204
+ failedEnvelopeId.length > MAX_FAILED_ENVELOPE_ID_LENGTH)) {
205
+ return { ok: false, cause: 'failedEnvelopeId is not valid' };
206
+ }
207
+ if (retryId !== undefined && !isRetryId(retryId)) {
208
+ return { ok: false, cause: 'retryId is not valid' };
209
+ }
210
+ // The sender derives the resend IDs from the retry ID and keys its record by
211
+ // the failed envelope ID, so a payload carries both or neither.
212
+ if ((failedEnvelopeId === undefined) !== (retryId === undefined)) {
213
+ return { ok: false, cause: 'failedEnvelopeId and retryId are not both present' };
214
+ }
215
+ if (deviceId !== local.deviceId) {
216
+ return { ok: false, cause: 'deviceId is not the local device' };
217
+ }
218
+ return {
219
+ ok: true,
220
+ request: {
221
+ requesterUserId: envelope.senderUserId,
222
+ requesterDeviceId: envelope.senderDeviceId,
223
+ originalSenderUserId: local.userId,
224
+ originalSenderDeviceId: local.deviceId,
225
+ failedTimestamp: failedTimestamp,
226
+ timestamp: timestamp,
227
+ reason: reason,
228
+ ...(ratchetKey === undefined ? {} : { ratchetKey: ratchetKey }),
229
+ },
230
+ ...(retryId === undefined
231
+ ? {}
232
+ : { retry: { failedEnvelopeId: failedEnvelopeId, retryId: retryId } }),
233
+ };
234
+ }
235
+ /** Decode canonical base64, or return undefined. */
236
+ function canonicalBase64Bytes(value) {
237
+ try {
238
+ const bytes = base64ToBytes(value);
239
+ return bytesToBase64(bytes) === value ? bytes : undefined;
240
+ }
241
+ catch {
242
+ return undefined;
243
+ }
244
+ }
245
+ //# sourceMappingURL=retry-request-envelope.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retry-request-envelope.js","sourceRoot":"","sources":["../../client/retry-request-envelope.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,EAAE,WAAW,EAAqB,MAAM,0BAA0B,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACjG,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,OAAO,EACL,SAAS,EACT,2BAA2B,EAC3B,2BAA2B,EAC3B,iBAAiB,GAGlB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,6DAA6D;AAC7D,MAAM,6BAA6B,GAAG,CAAC,CAAC;AAExC,4EAA4E;AAC5E,MAAM,CAAC,MAAM,mCAAmC,GAAG,KAAK,CAAC;AAEzD,mGAAmG;AACnG,MAAM,6BAA6B,GAAG,GAAG,CAAC;AAE1C,uDAAuD;AACvD,MAAM,qBAAqB,GAAG,EAAE,CAAC;AAEjC,MAAM,aAAa,GAAwB,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC;AA6C/E;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,OAAqB,EACrB,MAA0B,EAC1B,MAA8C;IAE9C,MAAM,OAAO,GAAwB;QACnC,CAAC,EAAE,6BAA6B;QAChC,eAAe,E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Y;YACtC,iBAAiB,EAAE,QAAQ,CAAC,cAAc;YAC1C,oBAAoB,EAAE,KAAK,CAAC,MAAM;YAClC,sBAAsB,EAAE,KAAK,CAAC,QAAQ;YACtC,eAAe,EAAE,eAAyB;YAC1C,SAAS,EAAE,SAAmB;YAC9B,MAAM,EAAE,MAAqB;YAC7B,GAAG,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,UAAoB,EAAE,CAAC;SAC1E;QACD,GAAG,CAAC,OAAO,KAAK,SAAS;YACvB,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,gBAAgB,EAAE,gBAA0B,EAAE,OAAO,EAAE,OAAiB,EAAE,EAAE,CAAC;KAC7F,CAAC;AACJ,CAAC;AAED,oDAAoD;AACpD,SAAS,oBAAoB,CAAC,KAAa;IACzC,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,aAAa,CAAC,KAAe,CAAC,CAAC;QAC7C,OAAO,aAAa,CAAC,KAAK,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;IAC5D,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
@@ -7,18 +7,16 @@
7
7
  import type { PreKeyBundle } from '../keys/index.js';
8
8
  import { ContentHint } from '../types/messages.js';
9
9
  import { ProtocolAddress } from '../types/address.js';
10
- import type { SignalProtocolClientContext, IncomingEnvelope, ProcessEnvelopeOptions, SendResult, DataMessageInput } from './types.js';
10
+ import type { RetryFamilyReceive } from './retry-family.js';
11
+ import type { SignalProtocolClientContext, IncomingEnvelope, ProcessEnvelopeOptions } from './types.js';
11
12
  import { type SesameManager, type RetryRequest } from '../internal/sesame/types.js';
13
+ import { type RetryResendTarget } from '../local/store/reliability.js';
12
14
  /**
13
- * State for retry deduplication (passed by client, mutated in place)
15
+ * Retry response state (passed by client, mutated in place)
14
16
  */
15
17
  export {};
16
- export interface RetryDedupState {
17
- /** Tracks recent retry requests: key = `${sessionId}:${timestamp}`, value = request time */
18
- recentRetryRequests: Map<string, number>;
19
- /** Timestamp of last cleanup */
20
- lastRetryCleanupTime: number;
21
- /** Tracks retry response counts per message: key = dedupKey, value = response count */
18
+ export interface RetryResponseState {
19
+ /** Retry responses per message: key = `${sessionId}:${failedTimestamp}`, value = response count */
22
20
  retryResponseCounts: Map<string, number>;
23
21
  }
24
22
  /**
@@ -27,6 +25,11 @@ export interface RetryDedupState {
27
25
  export interface RetryContext extends SignalProtocolClientContext {
28
26
  sesameManager: SesameManager;
29
27
  }
28
+ /**
29
+ * The request attempt that a retry request envelope is: the failed envelope,
30
+ * the retry ID of its request record and the ID of the request envelope.
31
+ */
32
+ export type RetryRequestAttempt = Omit<RetryResendTarget, 'kind'>;
30
33
  /**
31
34
  * Callbacks for operations that need to delegate back to SignalProtocolClient
32
35
  */
@@ -35,11 +38,25 @@ export interface RetryCallbacks {
35
38
  archiveSession: (address: ProtocolAddress) => Promise<void>;
36
39
  /** Establish a new session with prekey bundle */
37
40
  establishSession: (address: ProtocolAddress, bundle: PreKeyBundle) => Promise<void>;
38
- /** Send a message to a recipient */
39
- send: (recipientId: string, content: DataMessageInput | string | Uint8Array, options?: {
40
- timestamp?: number;
41
+ /**
42
+ * Encrypt content for one device of a user and post it to that device
43
+ * only. The send makes no sent-sync transcript. With a retry target, the
44
+ * sender keeps one resend record for the device and the failed envelope.
45
+ * A call for the request attempt and the kind of that record posts its
46
+ * stored bytes again under their own ID. A call for another request
47
+ * attempt or kind encrypts again, and the resend takes the attempt
48
+ * number of the request. A new encryption for the same request attempt,
49
+ * as after the Relay refuses the stored bytes as expired, posts the same
50
+ * ID: the processed ledger of the requester and the RETRY_CONFLICT
51
+ * answer of the Relay cover the new bytes. Null content posts only a
52
+ * stored attempt. It returns false only when null content has no stored
53
+ * attempt to post.
54
+ */
55
+ resend: (userId: string, deviceId: number, content: string | null, options: {
56
+ timestamp: number;
41
57
  contentHint?: ContentHint;
42
- }) => Promise<SendResult>;
58
+ retry?: RetryResendTarget;
59
+ }) => Promise<boolean>;
43
60
  /** Generate replacement prekeys and upload their public material. */
44
61
  forcePreKeyRotation: () => Promise<void>;
45
62
  }
@@ -49,10 +66,6 @@ export interface RetryCallbacks {
49
66
  export interface RetryConfig {
50
67
  /** Debounce interval for forced prekey rotations in ms */
51
68
  keyRotationDebounceMs: number;
52
- /** Deduplication window for retry requests in ms */
53
- retryDedupWindowMs: number;
54
- /** Cleanup interval for retry dedup entries in ms */
55
- retryCleanupIntervalMs: number;
56
69
  }
57
70
  export declare const MAX_RETRY_REQUESTS_PER_SENDER = 10;
58
71
  export declare const RETRY_REQUEST_WINDOW_MS: number;
@@ -78,7 +91,6 @@ export interface RetryRateLimitState {
78
91
  export declare function checkRetryRateLimit(rateLimitState: RetryRateLimitState, senderId: string, now?: number): boolean;
79
92
  /**
80
93
  * Default configuration values
81
- * Imports common values from state.ts to avoid duplication
82
94
  */
83
95
  export declare const DEFAULT_RETRY_CONFIG: RetryConfig;
84
96
  /**
@@ -88,8 +100,17 @@ export declare function getSessionKey(userId: string, deviceId: number): string;
88
100
  /**
89
101
  * Send retry request for failed decryption (internal)
90
102
  *
91
- * Uses relay if available, otherwise falls back to options callback.
103
+ * Sends a `retry_request` envelope to the failed sender device through the
104
+ * relay. Without a relay, it gives the envelope to the options callback.
92
105
  * Handles IMPLICIT content type discarding, rate limiting, and stale prekey rotation.
106
+ * An envelope without an identified sender, or from the local device, gets
107
+ * one warn line and no request. The request is stored under the failed
108
+ * envelope ID before its post, and a later failure of the same envelope posts
109
+ * the stored request again. The rate limit counts each post. A failed resend
110
+ * or null message asks again for its failed envelope through the retry
111
+ * family, whatever its content hint. A member that fails with an error that
112
+ * is not retryable posts nothing here, and its redelivery on the pull path
113
+ * asks again.
93
114
  *
94
115
  * @param ctx - Retry context with dependencies
95
116
  * @param envelope - The failed message envelope
@@ -97,25 +118,46 @@ export declare function getSessionKey(userId: string, deviceId: number): string;
97
118
  * @param rateLimitState - State for rate limiting (mutated in place)
98
119
  * @param callbacks - Callbacks for operations needing SignalProtocolClient
99
120
  * @param config - Configuration constants
121
+ * @param family - The retry family of the envelope
122
+ * @param fingerprint - The fingerprint of the envelope as the Relay delivered
123
+ * it, before any unseal. The stored request binds to it.
100
124
  * @param options - Optional transport callbacks (for background without relay)
101
125
  */
102
- export declare function sendRetryRequestInternal(ctx: RetryContext, envelope: IncomingEnvelope, error: Error, rateLimitState: RetryRateLimitState, callbacks: Pick<RetryCallbacks, 'forcePreKeyRotation'>, config: RetryConfig, options?: ProcessEnvelopeOptions): Promise<void>;
126
+ export declare function sendRetryRequestInternal(ctx: RetryContext, envelope: IncomingEnvelope, error: Error, rateLimitState: RetryRateLimitState, callbacks: Pick<RetryCallbacks, 'forcePreKeyRotation'>, config: RetryConfig, family: RetryFamilyReceive, fingerprint: string | undefined, options?: ProcessEnvelopeOptions): Promise<void>;
103
127
  /**
104
128
  * Handle incoming retry request and resend the original message
105
129
  *
106
130
  * Per SESAME spec §4.1, this method:
107
- * 1. Looks up the MessageRecord for the failed sequence number
131
+ * 1. Looks up the MessageRecord for the failed sequence number. When the
132
+ * sender already stored a resend or a null message for this request
133
+ * envelope, it posts the stored bytes again and does no session work
108
134
  * 2. Verifies the requester is the intended recipient
109
135
  * 3. Checks retry limits and TTL
110
136
  * 4. Creates new session if orphaned, or uses existing different session
111
- * 5. Re-encrypts and sends the original message
112
- * 6. Deletes the old MessageRecord
137
+ * 5. Re-encrypts and sends the original message, which replaces the old
138
+ * MessageRecord with the record of the new encryption. Only a delivery
139
+ * receipt from the device or the TTL deletes that record.
140
+ *
141
+ * It refuses a request for a message sent more than
142
+ * `RELIABILITY_RECORD_TTL_MS` ago, before it reads a stored resend. The
143
+ * Relay can keep the last resend post for that time again, and the
144
+ * requester keeps its retry records for both periods.
145
+ *
146
+ * It returns normally when it resends the message or refuses the request.
147
+ * It throws every other error, so the caller keeps the request envelope and
148
+ * a later pull gives it again.
113
149
  *
114
150
  * @param ctx - Retry context with dependencies
115
151
  * @param retryRequest - The retry request from the recipient
116
- * @param dedupState - State for deduplication (mutated in place)
152
+ * @param responseState - Retry response counts (mutated in place)
117
153
  * @param callbacks - Callbacks for SignalProtocolClient operations
118
154
  * @param config - Configuration constants
155
+ * @param retry - The ID of the envelope that the requester could not
156
+ * decrypt and the retry ID of its request record, from the request, and
157
+ * the ID of the request envelope. Each request attempt gets one
158
+ * encryption. The content resend has the ID `<retryId>:resend`, and the
159
+ * null message has the ID `<retryId>:null`. Attempt n of either adds
160
+ * `:<n>` from attempt 2.
119
161
  */
120
- export declare function handleRetryRequestAndResend(ctx: RetryContext, retryRequest: RetryRequest, dedupState: RetryDedupState, callbacks: RetryCallbacks, config: RetryConfig): Promise<void>;
162
+ export declare function handleRetryRequestAndResend(ctx: RetryContext, retryRequest: RetryRequest, responseState: RetryResponseState, callbacks: RetryCallbacks, config: RetryConfig, retry?: RetryRequestAttempt): Promise<void>;
121
163
  //# sourceMappingURL=retry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../../client/retry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAGnD,OAAO,KAAK,EACV,2BAA2B,EAC3B,gBAAgB,EAChB,sBAAsB,EACtB,UAAU,EACV,gBAAgB,EACjB,MAAM,SAAS,CAAC;AACjB,OAAO,EAEL,KAAK,aAAa,EAElB,KAAK,YAAY,EAClB,MAAM,0BAA0B,CAAC;AAUlC;;GAEG;AACH,OAAO,EAAE,CAAC;AACV,MAAM,WAAW,eAAe;IAC9B,4FAA4F;IAC5F,mBAAmB,EAAE,GAAG,CAAC,MAAM,EA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