@open-e2ee/signal-protocol-sdk 13.4.0 → 13.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +423 -0
- package/README.md +4 -8
- package/SECURITY.md +2 -2
- package/TROUBLESHOOTING.md +55 -27
- package/dist/client/binary-send.d.ts +28 -0
- package/dist/client/binary-send.d.ts.map +1 -0
- package/dist/client/binary-send.js +26 -0
- package/dist/client/binary-send.js.map +1 -0
- package/dist/client/client.d.ts +46 -6
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/client.js +181 -66
- package/dist/client/client.js.map +1 -1
- package/dist/client/content-adapter.d.ts +18 -0
- package/dist/client/content-adapter.d.ts.map +1 -1
- package/dist/client/content-adapter.js.map +1 -1
- package/dist/client/device-set-reconciliation.d.ts +23 -8
- package/dist/client/device-set-reconciliation.d.ts.map +1 -1
- package/dist/client/device-set-reconciliation.js +25 -11
- package/dist/client/device-set-reconciliation.js.map +1 -1
- package/dist/client/event-hooks.d.ts +88 -8
- package/dist/client/event-hooks.d.ts.map +1 -1
- package/dist/client/event-hooks.js +1 -0
- package/dist/client/event-hooks.js.map +1 -1
- package/dist/client/group-outbox.d.ts +45 -10
- package/dist/client/group-outbox.d.ts.map +1 -1
- package/dist/client/group-outbox.js +246 -154
- package/dist/client/group-outbox.js.map +1 -1
- package/dist/client/group-receive-authorization.d.ts +10 -1
- package/dist/client/group-receive-authorization.d.ts.map +1 -1
- package/dist/client/group-receive-authorization.js.map +1 -1
- package/dist/client/hosted-anonymous-delivery.d.ts +18 -1
- package/dist/client/hosted-anonymous-delivery.d.ts.map +1 -1
- package/dist/client/hosted-anonymous-delivery.js +84 -12
- package/dist/client/hosted-anonymous-delivery.js.map +1 -1
- package/dist/client/hosted-connection.js +1 -1
- package/dist/client/hosted-connection.js.map +1 -1
- package/dist/client/hosted-group-authority.d.ts +6 -2
- package/dist/client/hosted-group-authority.d.ts.map +1 -1
- package/dist/client/hosted-group-authority.js +11 -7
- package/dist/client/hosted-group-authority.js.map +1 -1
- package/dist/client/hosted-groups.d.ts +5 -1
- package/dist/client/hosted-groups.d.ts.map +1 -1
- package/dist/client/hosted-groups.js +8 -4
- package/dist/client/hosted-groups.js.map +1 -1
- package/dist/client/hosted-http-error.d.ts +5 -1
- package/dist/client/hosted-http-error.d.ts.map +1 -1
- package/dist/client/hosted-http-error.js +5 -1
- package/dist/client/hosted-http-error.js.map +1 -1
- package/dist/client/hosted-mailbox-subscription.d.ts +2 -0
- package/dist/client/hosted-mailbox-subscription.d.ts.map +1 -1
- package/dist/client/hosted-mailbox-subscription.js +5 -5
- package/dist/client/hosted-mailbox-subscription.js.map +1 -1
- package/dist/client/hosted-transport.d.ts +11 -1
- package/dist/client/hosted-transport.d.ts.map +1 -1
- package/dist/client/hosted-transport.js +75 -30
- package/dist/client/hosted-transport.js.map +1 -1
- package/dist/client/hosted.d.ts.map +1 -1
- package/dist/client/hosted.js +1 -1
- package/dist/client/hosted.js.map +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js.map +1 -1
- package/dist/client/receive-queue.d.ts +5 -2
- package/dist/client/receive-queue.d.ts.map +1 -1
- package/dist/client/receive-queue.js +55 -18
- package/dist/client/receive-queue.js.map +1 -1
- package/dist/client/relay-acceptance.d.ts +49 -6
- package/dist/client/relay-acceptance.d.ts.map +1 -1
- package/dist/client/relay-acceptance.js +49 -3
- package/dist/client/relay-acceptance.js.map +1 -1
- package/dist/client/relay-protocol.d.ts +37 -7
- package/dist/client/relay-protocol.d.ts.map +1 -1
- package/dist/client/relay-protocol.js +53 -10
- package/dist/client/relay-protocol.js.map +1 -1
- package/dist/client/retry-family.d.ts +3 -3
- package/dist/client/retry-family.js +1 -1
- package/dist/client/retry-family.js.map +1 -1
- package/dist/client/retry-request-envelope.d.ts +18 -8
- package/dist/client/retry-request-envelope.d.ts.map +1 -1
- package/dist/client/retry-request-envelope.js +57 -29
- package/dist/client/retry-request-envelope.js.map +1 -1
- package/dist/client/retry-request-lifecycle.d.ts +24 -11
- package/dist/client/retry-request-lifecycle.d.ts.map +1 -1
- package/dist/client/retry-request-lifecycle.js +46 -20
- package/dist/client/retry-request-lifecycle.js.map +1 -1
- package/dist/client/retry-terminal-recovery.d.ts +11 -8
- package/dist/client/retry-terminal-recovery.d.ts.map +1 -1
- package/dist/client/retry-terminal-recovery.js +18 -12
- package/dist/client/retry-terminal-recovery.js.map +1 -1
- package/dist/client/retry.d.ts +8 -7
- package/dist/client/retry.d.ts.map +1 -1
- package/dist/client/retry.js +30 -22
- package/dist/client/retry.js.map +1 -1
- package/dist/client/send-deadline.d.ts +308 -0
- package/dist/client/send-deadline.d.ts.map +1 -0
- package/dist/client/send-deadline.js +914 -0
- package/dist/client/send-deadline.js.map +1 -0
- package/dist/client/send-intent-driver.d.ts +116 -0
- package/dist/client/send-intent-driver.d.ts.map +1 -0
- package/dist/client/send-intent-driver.js +373 -0
- package/dist/client/send-intent-driver.js.map +1 -0
- package/dist/client/signal-service-cipher.d.ts +257 -27
- package/dist/client/signal-service-cipher.d.ts.map +1 -1
- package/dist/client/signal-service-cipher.js +1274 -283
- package/dist/client/signal-service-cipher.js.map +1 -1
- package/dist/client/types.d.ts +48 -5
- package/dist/client/types.d.ts.map +1 -1
- package/dist/client/types.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/local/store/conformance/cases/metadata.d.ts +3 -2
- package/dist/local/store/conformance/cases/metadata.d.ts.map +1 -1
- package/dist/local/store/conformance/cases/metadata.js +153 -2
- package/dist/local/store/conformance/cases/metadata.js.map +1 -1
- package/dist/local/store/key-value/adapter.d.ts +2 -1
- package/dist/local/store/key-value/adapter.d.ts.map +1 -1
- package/dist/local/store/key-value/adapter.js +9 -0
- package/dist/local/store/key-value/adapter.js.map +1 -1
- package/dist/local/store/memory/adapter.d.ts +2 -1
- package/dist/local/store/memory/adapter.d.ts.map +1 -1
- package/dist/local/store/memory/adapter.js +4 -0
- package/dist/local/store/memory/adapter.js.map +1 -1
- package/dist/local/store/metadata-keys.d.ts +13 -0
- package/dist/local/store/metadata-keys.d.ts.map +1 -0
- package/dist/local/store/metadata-keys.js +20 -0
- package/dist/local/store/metadata-keys.js.map +1 -0
- package/dist/local/store/receive-work.d.ts.map +1 -1
- package/dist/local/store/receive-work.js +12 -1
- package/dist/local/store/receive-work.js.map +1 -1
- package/dist/local/store/reliability.d.ts +482 -33
- package/dist/local/store/reliability.d.ts.map +1 -1
- package/dist/local/store/reliability.js +690 -48
- package/dist/local/store/reliability.js.map +1 -1
- package/dist/local/store/sqlite/key-storage/index.d.ts +2 -1
- package/dist/local/store/sqlite/key-storage/index.d.ts.map +1 -1
- package/dist/local/store/sqlite/key-storage/index.js +3 -0
- package/dist/local/store/sqlite/key-storage/index.js.map +1 -1
- package/dist/local/store/sqlite/key-storage/metadata.d.ts +9 -0
- package/dist/local/store/sqlite/key-storage/metadata.d.ts.map +1 -1
- package/dist/local/store/sqlite/key-storage/metadata.js +12 -0
- package/dist/local/store/sqlite/key-storage/metadata.js.map +1 -1
- package/dist/local/store/sqlite/store.d.ts +2 -1
- package/dist/local/store/sqlite/store.d.ts.map +1 -1
- package/dist/local/store/sqlite/store.js +3 -0
- package/dist/local/store/sqlite/store.js.map +1 -1
- package/dist/local/store/web/adapter.d.ts +8 -1
- package/dist/local/store/web/adapter.d.ts.map +1 -1
- package/dist/local/store/web/adapter.js +18 -0
- package/dist/local/store/web/adapter.js.map +1 -1
- package/dist/remote/relay/request-admission.d.ts +49 -0
- package/dist/remote/relay/request-admission.d.ts.map +1 -0
- package/dist/remote/relay/request-admission.js +74 -0
- package/dist/remote/relay/request-admission.js.map +1 -0
- package/dist/types/api.d.ts +77 -0
- package/dist/types/api.d.ts.map +1 -1
- package/dist/types/errors.d.ts +144 -1
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/errors.js +146 -1
- package/dist/types/errors.js.map +1 -1
- package/docs/ASSURANCE.md +31 -15
- package/docs/DEVIATIONS.md +34 -4
- package/docs/ERROR_HANDLING.md +134 -7
- package/docs/GETTING_STARTED.md +30 -23
- package/docs/PROTOCOL_POLICY.md +31 -20
- package/groups/README.md +1 -1
- package/hooks/README.md +6 -3
- package/local/store/react-native/README.md +9 -10
- package/local/store/web/README.md +1 -1
- package/package.json +1 -1
- package/safety/README.md +48 -11
|
@@ -2,6 +2,11 @@ import type { Envelope } from '../../remote/relay/types.js';
|
|
|
2
2
|
import type { SignalProtocolLocalStore } from '../../types/index.js';
|
|
3
3
|
import type { ContentHint } from '../../types/messages.js';
|
|
4
4
|
export declare const RELIABILITY_RECORD_TTL_MS: number;
|
|
5
|
+
/**
|
|
6
|
+
* The posting window of an outgoing intent. No request of the intent starts
|
|
7
|
+
* at or after `outgoingMessageDeadlineAt`.
|
|
8
|
+
*/
|
|
9
|
+
export declare const OUTGOING_POSTING_WINDOW_MS: number;
|
|
5
10
|
/**
|
|
6
11
|
* The lifetime of the retry-request and retry-family records of the
|
|
7
12
|
* requester, and of a fulfilled processed-envelope record. Two bounds set
|
|
@@ -19,6 +24,12 @@ export declare const RETRY_REQUESTER_RECORD_TTL_MS: number;
|
|
|
19
24
|
* at this time ends as `expired-content`.
|
|
20
25
|
*/
|
|
21
26
|
export declare const RETRY_REQUEST_DEADLINE_MS: number;
|
|
27
|
+
/**
|
|
28
|
+
* The posting window of a retry request: 24 hours from the first failure,
|
|
29
|
+
* `receivedAt`. No post of the request starts at or after
|
|
30
|
+
* `retryRequestPostingDeadlineAt`.
|
|
31
|
+
*/
|
|
32
|
+
export declare const RETRY_REQUEST_POSTING_WINDOW_MS: number;
|
|
22
33
|
export interface StoredOutgoingDeviceMessage {
|
|
23
34
|
recipientUserId: string;
|
|
24
35
|
recipientDeviceId: number;
|
|
@@ -60,6 +71,17 @@ export interface StoredOutgoingMessageIntent {
|
|
|
60
71
|
unidentifiedAccessKey: string;
|
|
61
72
|
};
|
|
62
73
|
contentHint?: ContentHint;
|
|
74
|
+
/**
|
|
75
|
+
* The attachment of a binary send. `message` is the exact serialized
|
|
76
|
+
* attachment message that the intent encrypts, and `fileDigest` is the
|
|
77
|
+
* base64 SHA-256 digest of the source file. A repeat of the send with the
|
|
78
|
+
* same file sends `message` again and uploads nothing. The record keeps it
|
|
79
|
+
* for its life, also after completion.
|
|
80
|
+
*/
|
|
81
|
+
binaryAttachment?: {
|
|
82
|
+
fileDigest: string;
|
|
83
|
+
message: string;
|
|
84
|
+
};
|
|
63
85
|
preMessages?: StoredOutgoingDeviceMessage[];
|
|
64
86
|
deviceMessages: StoredOutgoingDeviceMessage[];
|
|
65
87
|
syncMessages: StoredOutgoingDeviceMessage[];
|
|
@@ -88,18 +110,73 @@ export interface StoredOutgoingMessageIntent {
|
|
|
88
110
|
* bundle at the last repair of the phase. They have no message in the
|
|
89
111
|
* intent. A replay starts a session with each of them before its first
|
|
90
112
|
* post, so a device that uploaded a bundle after the repair gets the
|
|
91
|
-
* message. A
|
|
113
|
+
* message. A terminal end keeps them, and no later replay posts to them.
|
|
92
114
|
*/
|
|
93
115
|
deviceSetBundleMissing?: {
|
|
94
116
|
recipient?: OutgoingGroupDevice[];
|
|
95
117
|
sync?: OutgoingGroupDevice[];
|
|
96
118
|
};
|
|
97
119
|
/**
|
|
98
|
-
*
|
|
99
|
-
* keeps its sync messages, and a replay
|
|
100
|
-
*
|
|
120
|
+
* On a declared intent, the recipient phase completed and the sync phase
|
|
121
|
+
* did not. The intent keeps its sync messages, and a replay before
|
|
122
|
+
* `deadlineAt` posts only them. At or after `deadlineAt`, a replay posts
|
|
123
|
+
* nothing and returns the stored result with `syncPending`. With no sync
|
|
124
|
+
* messages, the read of the own device list failed, and a replay reads it
|
|
125
|
+
* again. When that read finds no other own device, the replay completes the
|
|
126
|
+
* sync phase with no post and returns the result without `syncPending`.
|
|
127
|
+
*
|
|
128
|
+
* On an undeclared intent, the posting deadline stopped the sync posts. A
|
|
129
|
+
* replay returns the stored result with `syncPending` and posts nothing.
|
|
101
130
|
*/
|
|
102
131
|
syncPending?: true;
|
|
132
|
+
/**
|
|
133
|
+
* The posting deadline: the earlier of `createdAt` and `clientTimestamp`,
|
|
134
|
+
* plus `OUTGOING_POSTING_WINDOW_MS`. The first write stores it. An intent
|
|
135
|
+
* that an earlier SDK stored gets it at its next mutation write, from the
|
|
136
|
+
* same terms. No request of the intent starts at or after it.
|
|
137
|
+
*/
|
|
138
|
+
deadlineAt?: number;
|
|
139
|
+
/**
|
|
140
|
+
* The end of an open intent at its posting deadline. Its absence means
|
|
141
|
+
* that the intent is open. `result` takes precedence over it.
|
|
142
|
+
*/
|
|
143
|
+
outcome?: 'failed' | 'acceptance-unknown';
|
|
144
|
+
/**
|
|
145
|
+
* The SDK send driver ended or completed this intent and has not yet
|
|
146
|
+
* reported the end through `onSendOutcome`. The end write or the completion
|
|
147
|
+
* write sets it. The driver clears it before it calls the hook, so a crash
|
|
148
|
+
* before the clear reports the end at the next start. An application send
|
|
149
|
+
* never sets it: its end is reported in memory.
|
|
150
|
+
*/
|
|
151
|
+
outcomeReportPending?: true;
|
|
152
|
+
/** The time at which the driver cleared `outcomeReportPending`. */
|
|
153
|
+
outcomeReportedAt?: number;
|
|
154
|
+
/**
|
|
155
|
+
* The SDK made this send for itself, as a sender key distribution. Its
|
|
156
|
+
* end never reaches `onSendOutcome`, from an application call or from the
|
|
157
|
+
* driver, so no end write sets `outcomeReportPending` on it.
|
|
158
|
+
*/
|
|
159
|
+
internal?: true;
|
|
160
|
+
/**
|
|
161
|
+
* The progress of each destination device, keyed by
|
|
162
|
+
* `outgoingDestinationProgressKey`. A send writes the entry of a device
|
|
163
|
+
* before each request and after each answer, and the end write merges the
|
|
164
|
+
* class of each recipient device. The completion keeps it.
|
|
165
|
+
*/
|
|
166
|
+
destinationProgress?: Record<string, StoredDestinationProgress>;
|
|
167
|
+
/**
|
|
168
|
+
* The intent wrote the progress of each destination before each of its
|
|
169
|
+
* requests, from its first write. Without it, an earlier SDK can have
|
|
170
|
+
* posted a destination with no progress written, so a new entry starts
|
|
171
|
+
* uncertain.
|
|
172
|
+
*/
|
|
173
|
+
progressFromStart?: true;
|
|
174
|
+
/**
|
|
175
|
+
* The manual resends of an ended intent, in the order of their start. An
|
|
176
|
+
* intent with no resend has no field, and `outgoingManualResends` reads it
|
|
177
|
+
* as an empty list.
|
|
178
|
+
*/
|
|
179
|
+
manualResends?: StoredManualResend[];
|
|
103
180
|
result?: {
|
|
104
181
|
clientMessageId: string;
|
|
105
182
|
messageId: string;
|
|
@@ -111,6 +188,105 @@ export interface StoredOutgoingMessageIntent {
|
|
|
111
188
|
groupId?: string;
|
|
112
189
|
};
|
|
113
190
|
}
|
|
191
|
+
/**
|
|
192
|
+
* One manual resend of an ended intent. It is a new operation: its posts
|
|
193
|
+
* carry `manualMessageId` and its own operation epoch, and its posting
|
|
194
|
+
* deadline is its own. The content of each message keeps the client
|
|
195
|
+
* timestamp of the intent. The intent keeps its own epoch, `deadlineAt` and
|
|
196
|
+
* `outcome`.
|
|
197
|
+
*/
|
|
198
|
+
export interface StoredManualResend {
|
|
199
|
+
/** The client message ID of each post of the resend: `<clientMessageId>:manual:N`, N from 1. */
|
|
200
|
+
manualMessageId: string;
|
|
201
|
+
/** The time of the first write of the resend. One clock read gives it and the epoch. */
|
|
202
|
+
createdAt: number;
|
|
203
|
+
/** The operation epoch of each post of the resend. */
|
|
204
|
+
operationEpochMilliseconds: number;
|
|
205
|
+
/** The posting deadline of the resend: `createdAt` plus `OUTGOING_POSTING_WINDOW_MS`. */
|
|
206
|
+
deadlineAt: number;
|
|
207
|
+
/** The encrypted message of each destination device, which each post of the resend sends again. */
|
|
208
|
+
messages: StoredManualResendMessage[];
|
|
209
|
+
/** The progress of each destination of the resend, keyed by `outgoingDestinationProgressKey`. */
|
|
210
|
+
destinationProgress?: Record<string, StoredDestinationProgress>;
|
|
211
|
+
/** The Relay result, when the Relay accepted each destination of the resend. */
|
|
212
|
+
result?: StoredOutgoingMessageIntent['result'];
|
|
213
|
+
/** The end of the resend at its posting deadline. `result` takes precedence over it. */
|
|
214
|
+
outcome?: NonNullable<StoredOutgoingMessageIntent['outcome']>;
|
|
215
|
+
/** The time of the end write of the resend, which also gives its report. */
|
|
216
|
+
outcomeReportedAt?: number;
|
|
217
|
+
}
|
|
218
|
+
/** The encrypted message of one destination device of a manual resend. */
|
|
219
|
+
export interface StoredManualResendMessage {
|
|
220
|
+
transportMode: StoredOutgoingMessageIntent['transportMode'];
|
|
221
|
+
/**
|
|
222
|
+
* The sealed authorization of the post. A group endorsement is stored by
|
|
223
|
+
* its group, and the endorsement of the device's account resolves again
|
|
224
|
+
* at each post.
|
|
225
|
+
*/
|
|
226
|
+
sealedSenderAuth?: {
|
|
227
|
+
type: 'accessKey';
|
|
228
|
+
unidentifiedAccessKey: string;
|
|
229
|
+
} | {
|
|
230
|
+
type: 'groupSendToken';
|
|
231
|
+
groupId: string;
|
|
232
|
+
};
|
|
233
|
+
contentHint?: ContentHint;
|
|
234
|
+
message: StoredOutgoingDeviceMessage;
|
|
235
|
+
}
|
|
236
|
+
/** The progress of one destination device of an outgoing intent. */
|
|
237
|
+
export interface StoredDestinationProgress {
|
|
238
|
+
phase: 'recipient' | 'sync';
|
|
239
|
+
userId: string;
|
|
240
|
+
deviceId: number;
|
|
241
|
+
/** The client message ID that the posts to this device carry. */
|
|
242
|
+
postMessageId: string;
|
|
243
|
+
state: 'pending' | 'posted' | 'accepted' | 'refused' | 'unknown';
|
|
244
|
+
/** The number of requests that started for this device. */
|
|
245
|
+
requests: number;
|
|
246
|
+
/**
|
|
247
|
+
* A request for this device can have reached the Relay with no answer
|
|
248
|
+
* that proves its outcome. Once set, it stays set.
|
|
249
|
+
*/
|
|
250
|
+
uncertain?: true;
|
|
251
|
+
/**
|
|
252
|
+
* A repair replaced the message of this device after a stale
|
|
253
|
+
* registration: a stale-device repair, or a device-set repair that
|
|
254
|
+
* removed this device. The Relay can hold the replaced message under the
|
|
255
|
+
* message ID, sealed to the old session, so a `RETRY_CONFLICT` answer to
|
|
256
|
+
* the repost does not prove acceptance. A repair that only adds a missing
|
|
257
|
+
* device sets `repairedFor` and not this mark: the Relay stores nothing
|
|
258
|
+
* under the message ID for a device-set refusal, so a `RETRY_CONFLICT`
|
|
259
|
+
* answer for an added device names a copy that another writer posted
|
|
260
|
+
* while the device was registered. No released SDK version wrote
|
|
261
|
+
* `repaired` or `repairedFor` (13.3.0 is the last release), so no
|
|
262
|
+
* migration reads an earlier meaning.
|
|
263
|
+
*/
|
|
264
|
+
repaired?: true;
|
|
265
|
+
/**
|
|
266
|
+
* The recovery that the last repair of this device ran, and the client
|
|
267
|
+
* message ID of the message that it stored. Each repair sets it, with or
|
|
268
|
+
* without `repaired`. An entry that has `repaired` without this field
|
|
269
|
+
* counts each refusal as a refusal of its repair.
|
|
270
|
+
*/
|
|
271
|
+
repairedFor?: {
|
|
272
|
+
recovery: 'stale-device' | 'device-set';
|
|
273
|
+
postMessageId: string;
|
|
274
|
+
};
|
|
275
|
+
/**
|
|
276
|
+
* The Relay code of the last answer when that answer is a refusal, or the
|
|
277
|
+
* kind of a refusal with no Relay code: `device-set`, `sealed-sender-auth`
|
|
278
|
+
* or `device-rejection`. A later request or a later answer of another
|
|
279
|
+
* class clears it.
|
|
280
|
+
*/
|
|
281
|
+
refusalCode?: string;
|
|
282
|
+
/** The recovery for the refusal ran, and the Relay refused the repost too. */
|
|
283
|
+
repairSpent?: true;
|
|
284
|
+
generation?: number;
|
|
285
|
+
messageId?: string;
|
|
286
|
+
enqueuedAt?: number;
|
|
287
|
+
expiresAt?: number;
|
|
288
|
+
duplicate?: true;
|
|
289
|
+
}
|
|
114
290
|
/** The terminal record of a declared send phase that ended without reconciliation. */
|
|
115
291
|
export interface StoredDeviceSetUnresolved {
|
|
116
292
|
phase: 'recipient' | 'sync';
|
|
@@ -126,8 +302,35 @@ export interface StoredDeviceSetUnresolved {
|
|
|
126
302
|
}[];
|
|
127
303
|
};
|
|
128
304
|
}
|
|
129
|
-
type ReliabilityMetadataStore = Pick<SignalProtocolLocalStore, 'getMetadata' | 'setMetadata' | 'deleteMetadata'
|
|
130
|
-
|
|
305
|
+
type ReliabilityMetadataStore = Pick<SignalProtocolLocalStore, 'getMetadata' | 'setMetadata' | 'deleteMetadata'> & Partial<Pick<SignalProtocolLocalStore, 'listMetadataKeys'>>;
|
|
306
|
+
/**
|
|
307
|
+
* The end of one send call, as the end write or the completion write of its
|
|
308
|
+
* intent records it. The send call that holds the intent lock gives it.
|
|
309
|
+
*/
|
|
310
|
+
export interface OutgoingIntentEndReport {
|
|
311
|
+
/** The SDK send driver made the call. Its end write then sets `outcomeReportPending`. */
|
|
312
|
+
readonly driven: boolean;
|
|
313
|
+
/**
|
|
314
|
+
* The SDK made the send for itself. A new intent of the call stores
|
|
315
|
+
* `internal`, and its end is never reported.
|
|
316
|
+
*/
|
|
317
|
+
readonly internal?: true;
|
|
318
|
+
/**
|
|
319
|
+
* The intent as the call ended or completed it. Only a write that ends an
|
|
320
|
+
* open intent sets it: a replay of an ended or completed intent does not.
|
|
321
|
+
*/
|
|
322
|
+
ended?: StoredOutgoingMessageIntent;
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Run `operation` under the lock of one outgoing intent. When
|
|
326
|
+
* `navigator.locks.request` exists and the store sets `storeIdentity`, the
|
|
327
|
+
* lock is the Web Lock `open-e2ee:outbox:<store identity>:<clientMessageId>`,
|
|
328
|
+
* so the tabs, workers and threads of one origin that share the store share
|
|
329
|
+
* it. Otherwise it is an in-process lock keyed by the store object. The lock
|
|
330
|
+
* is not reentrant. With `report`, an end write or a completion write of the
|
|
331
|
+
* intent during `operation` records the end in it.
|
|
332
|
+
*/
|
|
333
|
+
export declare function withOutgoingMessageIntentLock<T>(store: ReliabilityMetadataStore, clientMessageId: string, operation: () => Promise<T>, report?: OutgoingIntentEndReport): Promise<T>;
|
|
131
334
|
export declare function withProcessedEnvelopeLock<T>(store: ReliabilityMetadataStore, envelopeId: string, operation: () => Promise<T>): Promise<T>;
|
|
132
335
|
/** One device of a group intent: an account and one of its devices. */
|
|
133
336
|
export interface OutgoingGroupDevice {
|
|
@@ -153,6 +356,11 @@ export interface OutgoingGroupDeviceSetChange {
|
|
|
153
356
|
* appended to its list. A new message for a device that still has a message
|
|
154
357
|
* in the same list must be equal to it, and is not appended again. The same
|
|
155
358
|
* write replaces or removes the shared body when the change names one.
|
|
359
|
+
*
|
|
360
|
+
* A device whose pre-message or device message the change appends after it
|
|
361
|
+
* removed that device gets `repaired` and `repairedFor` on its progress
|
|
362
|
+
* entry. The write creates the entry when none exists. A device that the
|
|
363
|
+
* change appends without a removal gets no mark.
|
|
156
364
|
*/
|
|
157
365
|
export declare function reconcileOutgoingGroupDeviceSet(store: ReliabilityMetadataStore, clientMessageId: string, change: OutgoingGroupDeviceSetChange): Promise<StoredOutgoingMessageIntent>;
|
|
158
366
|
/** A repair of the device set of one phase of a declared send. */
|
|
@@ -179,22 +387,31 @@ export interface OutgoingDeviceSetRepair {
|
|
|
179
387
|
/**
|
|
180
388
|
* Commit the repair of a declared send phase and its restart count in one
|
|
181
389
|
* write. Each removed device first loses all of its messages. Then each new
|
|
182
|
-
* message is appended to its list
|
|
183
|
-
*
|
|
390
|
+
* message is appended to its list, and the progress entry of its device
|
|
391
|
+
* gets `repairedFor`. The entry of a device that the repair also removed
|
|
392
|
+
* gets `repaired`, because the repair replaced its message. The entry of an
|
|
393
|
+
* added device does not. A completed intent takes a repair only of its
|
|
394
|
+
* pending sync phase, and a terminal intent takes none.
|
|
395
|
+
*
|
|
396
|
+
* @returns The stored intent, with the progress entry of each appended device
|
|
184
397
|
*/
|
|
185
398
|
export declare function repairOutgoingDeviceSet(store: ReliabilityMetadataStore, clientMessageId: string, repair: OutgoingDeviceSetRepair): Promise<StoredOutgoingMessageIntent>;
|
|
186
399
|
/**
|
|
187
400
|
* Record that a phase of a declared send ended without reconciliation. The
|
|
188
|
-
* restart counts stay.
|
|
189
|
-
*
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
*
|
|
194
|
-
*
|
|
195
|
-
*
|
|
401
|
+
* restart counts stay. A recipient-phase end stores the send outcome. A
|
|
402
|
+
* later `send()` with the same `clientMessageId` then throws the stored-end
|
|
403
|
+
* class and posts nothing. A sync-phase end keeps the result, and a later
|
|
404
|
+
* `send()` posts the sync phase again. `resendMessage` posts a new
|
|
405
|
+
* operation.
|
|
406
|
+
*
|
|
407
|
+
* `end` is the class of the recipient phase at the end: its outcome and the
|
|
408
|
+
* progress of each recipient destination, which replaces the stored entry
|
|
409
|
+
* under its key. Only a recipient-phase end of an open intent writes it.
|
|
196
410
|
*/
|
|
197
|
-
export declare function
|
|
411
|
+
export declare function markOutgoingDeviceSetUnresolved(store: ReliabilityMetadataStore, clientMessageId: string, unresolved: StoredDeviceSetUnresolved, end?: {
|
|
412
|
+
outcome: NonNullable<StoredOutgoingMessageIntent['outcome']>;
|
|
413
|
+
destinationProgress: Record<string, StoredDestinationProgress>;
|
|
414
|
+
}): Promise<StoredOutgoingMessageIntent>;
|
|
198
415
|
/**
|
|
199
416
|
* Complete the pending sync phase of a completed intent: remove its sync
|
|
200
417
|
* messages, its restart counts, and its terminal record.
|
|
@@ -207,6 +424,99 @@ export declare function completeOutgoingSyncPhase(store: ReliabilityMetadataStor
|
|
|
207
424
|
export declare function outgoingMessageIntentResult(intent: StoredOutgoingMessageIntent): (NonNullable<StoredOutgoingMessageIntent['result']> & {
|
|
208
425
|
syncPending?: true;
|
|
209
426
|
}) | undefined;
|
|
427
|
+
/**
|
|
428
|
+
* The posting deadline of an intent: the stored `deadlineAt`, else the
|
|
429
|
+
* earlier of `createdAt` and `clientTimestamp`, plus
|
|
430
|
+
* `OUTGOING_POSTING_WINDOW_MS`. An intent that an earlier SDK stored has no
|
|
431
|
+
* `deadlineAt`, and it gets the same value from its stored times.
|
|
432
|
+
*/
|
|
433
|
+
export declare function outgoingMessageDeadlineAt(intent: Pick<StoredOutgoingMessageIntent, 'createdAt' | 'clientTimestamp' | 'deadlineAt'>): number;
|
|
434
|
+
/** The `destinationProgress` key of one device of one post. */
|
|
435
|
+
export declare function outgoingDestinationProgressKey(postMessageId: string, device: OutgoingGroupDevice): string;
|
|
436
|
+
/** One request or one answer of one destination, as a progress write stores it. */
|
|
437
|
+
export type OutgoingDestinationProgressUpdate = Pick<StoredDestinationProgress, 'phase' | 'userId' | 'deviceId' | 'postMessageId'> & ({
|
|
438
|
+
readonly request: true;
|
|
439
|
+
} | ({
|
|
440
|
+
readonly answer: 'accepted' | 'refused' | 'pending' | 'unknown';
|
|
441
|
+
readonly repairSpent?: true;
|
|
442
|
+
} & Pick<StoredDestinationProgress, 'refusalCode' | 'messageId' | 'enqueuedAt' | 'expiresAt' | 'duplicate'>));
|
|
443
|
+
/**
|
|
444
|
+
* Record one request or one answer of one destination of an open intent,
|
|
445
|
+
* and merge it into the entry under `key`.
|
|
446
|
+
*
|
|
447
|
+
* - Before each request, the entry becomes `posted` and its `requests` count
|
|
448
|
+
* grows by one. When the entry is already `posted`, an earlier request
|
|
449
|
+
* has no answer, so the entry becomes uncertain.
|
|
450
|
+
* - After an answer, the entry takes the class of the answer. An uncertain
|
|
451
|
+
* answer sets `uncertain`. A refusal stores its code. A refusal that
|
|
452
|
+
* refuses the repair of the entry (`refusesRepair`) stores `repairSpent`.
|
|
453
|
+
* An `accepted` entry stays accepted.
|
|
454
|
+
* - The refusal code belongs to the last answer, so a later request or a
|
|
455
|
+
* later answer that is not a refusal clears it. `repairSpent` stays: the
|
|
456
|
+
* refusal spent the repair, and a later answer does not give it back.
|
|
457
|
+
*
|
|
458
|
+
* The `uncertain` flag is never cleared. A completed or ended intent takes
|
|
459
|
+
* no write, except a sync entry of a completed intent with `syncPending`.
|
|
460
|
+
* The caller holds the intent lock, so this takes only the store mutation
|
|
461
|
+
* order.
|
|
462
|
+
*
|
|
463
|
+
* @returns The stored entry, or undefined when nothing was written
|
|
464
|
+
*/
|
|
465
|
+
export declare function recordOutgoingDestinationProgress(store: ReliabilityMetadataStore, clientMessageId: string, key: string, update: OutgoingDestinationProgressUpdate): Promise<StoredDestinationProgress | undefined>;
|
|
466
|
+
/**
|
|
467
|
+
* The manual resends of an intent. An intent that an earlier SDK stored, or
|
|
468
|
+
* that has no resend, has no `manualResends` field and reads as an empty
|
|
469
|
+
* list.
|
|
470
|
+
*/
|
|
471
|
+
export declare function outgoingManualResends(intent: Pick<StoredOutgoingMessageIntent, 'manualResends'>): StoredManualResend[];
|
|
472
|
+
/**
|
|
473
|
+
* The time that the retention of an intent counts from: its `createdAt`, or
|
|
474
|
+
* the `createdAt` of its latest manual resend. The ledger indexes the intent
|
|
475
|
+
* at this time, so a manual resend keeps the intent, and its listing, for
|
|
476
|
+
* `RELIABILITY_RECORD_TTL_MS` after the resend. That is past the posting
|
|
477
|
+
* deadline of the resend.
|
|
478
|
+
*/
|
|
479
|
+
export declare function outgoingIntentRetainedFrom(intent: Pick<StoredOutgoingMessageIntent, 'createdAt' | 'manualResends'>): number;
|
|
480
|
+
/** True when a manual resend has neither a result nor an outcome. */
|
|
481
|
+
export declare function isOpenManualResend(resend: StoredManualResend): boolean;
|
|
482
|
+
/**
|
|
483
|
+
* The client message ID of manual resend number `n` of an intent, from 1.
|
|
484
|
+
*/
|
|
485
|
+
export declare function manualResendMessageId(clientMessageId: string, n: number): string;
|
|
486
|
+
/**
|
|
487
|
+
* Store a new manual resend on an ended intent. The caller holds the intent
|
|
488
|
+
* lock. Only an intent with `outcome` and no `result` takes one, and only
|
|
489
|
+
* when no earlier resend of it is open. The intent keeps its own fields. The
|
|
490
|
+
* ledger indexes the intent again at the `createdAt` of the resend, as
|
|
491
|
+
* `outgoingIntentRetainedFrom` gives it. The new bucket is written before
|
|
492
|
+
* the intent leaves its old bucket, so a stop leaves it in a bucket, and a
|
|
493
|
+
* prune of the old bucket keeps an intent that the resend retains.
|
|
494
|
+
*/
|
|
495
|
+
export declare function addOutgoingManualResend(store: ReliabilityMetadataStore, clientMessageId: string, resend: StoredManualResend, now?: number): Promise<StoredOutgoingMessageIntent>;
|
|
496
|
+
/**
|
|
497
|
+
* Record one request or one answer of one destination of an open manual
|
|
498
|
+
* resend, by the rules of `recordOutgoingDestinationProgress`. The resend
|
|
499
|
+
* writes progress before each of its requests from its first write, so a
|
|
500
|
+
* new entry starts with no uncertain request. An ended resend takes no
|
|
501
|
+
* write.
|
|
502
|
+
*
|
|
503
|
+
* @returns The stored entry, or undefined when nothing was written
|
|
504
|
+
*/
|
|
505
|
+
export declare function recordOutgoingManualResendProgress(store: ReliabilityMetadataStore, clientMessageId: string, manualMessageId: string, key: string, update: OutgoingDestinationProgressUpdate): Promise<StoredDestinationProgress | undefined>;
|
|
506
|
+
/**
|
|
507
|
+
* End an open manual resend: with its Relay result when the Relay accepted
|
|
508
|
+
* each of its destinations, else with its outcome. One write stores the end
|
|
509
|
+
* and `outcomeReportedAt`, so the end is reported at most once. Each entry
|
|
510
|
+
* of `destinationProgress` replaces the stored entry under its key.
|
|
511
|
+
*
|
|
512
|
+
* @returns The ended resend, or undefined when it had already ended
|
|
513
|
+
*/
|
|
514
|
+
export declare function endOutgoingManualResend(store: ReliabilityMetadataStore, clientMessageId: string, manualMessageId: string, end: {
|
|
515
|
+
result: NonNullable<StoredOutgoingMessageIntent['result']>;
|
|
516
|
+
} | {
|
|
517
|
+
outcome: NonNullable<StoredOutgoingMessageIntent['outcome']>;
|
|
518
|
+
destinationProgress: Record<string, StoredDestinationProgress>;
|
|
519
|
+
}, at?: number): Promise<StoredManualResend | undefined>;
|
|
210
520
|
/**
|
|
211
521
|
* Remove the pre-messages that the relay accepted or that the send dropped
|
|
212
522
|
* from a group intent, so a replay posts only the pre-messages that the relay
|
|
@@ -217,7 +527,11 @@ export declare function confirmOutgoingPreMessages(store: ReliabilityMetadataSto
|
|
|
217
527
|
/**
|
|
218
528
|
* Replace stored pre-messages of a group intent in one write. Each
|
|
219
529
|
* replacement keeps the target and the timestamp of the pre-message that it
|
|
220
|
-
* replaces, and the stored pre-message must still equal the expected one.
|
|
530
|
+
* replaces, and the stored pre-message must still equal the expected one. A
|
|
531
|
+
* replacement under a new client message ID is a repair: its progress entry
|
|
532
|
+
* gets `repaired`, and the write creates the entry when none exists. A
|
|
533
|
+
* replacement under the same ID, such as the sealed form of the stored
|
|
534
|
+
* pre-message, gets no mark.
|
|
221
535
|
*/
|
|
222
536
|
export declare function replaceOutgoingGroupPreMessages(store: ReliabilityMetadataStore, clientMessageId: string, replacements: readonly {
|
|
223
537
|
expected: StoredOutgoingDeviceMessage;
|
|
@@ -237,6 +551,12 @@ export declare function reconcileOutgoingDirectDeviceMessages(store: Reliability
|
|
|
237
551
|
* change only while its sync phase is pending.
|
|
238
552
|
*/
|
|
239
553
|
export declare function reconcileOutgoingSyncMessages(store: ReliabilityMetadataStore, clientMessageId: string, removedDeviceIds: readonly number[], additions: readonly StoredOutgoingDeviceMessage[]): Promise<StoredOutgoingMessageIntent>;
|
|
554
|
+
/**
|
|
555
|
+
* Replace the stored message of one device of an open direct intent after a
|
|
556
|
+
* session repair. The progress entry of the device gets the repair mark.
|
|
557
|
+
*
|
|
558
|
+
* @returns The stored intent, with the progress entry of the device
|
|
559
|
+
*/
|
|
240
560
|
export declare function replaceOutgoingDirectDeviceMessage(store: ReliabilityMetadataStore, clientMessageId: string, expected: StoredOutgoingDeviceMessage, replacement: StoredOutgoingDeviceMessage): Promise<StoredOutgoingMessageIntent>;
|
|
241
561
|
export declare function getOutgoingMessageIntent(store: ReliabilityMetadataStore, clientMessageId: string, now?: number): Promise<StoredOutgoingMessageIntent | null>;
|
|
242
562
|
export declare function storeOutgoingMessageIntent(store: ReliabilityMetadataStore, intent: StoredOutgoingMessageIntent, now?: number): Promise<void>;
|
|
@@ -246,6 +566,55 @@ export declare function storeOutgoingMessageIntent(store: ReliabilityMetadataSto
|
|
|
246
566
|
* recipient.
|
|
247
567
|
*/
|
|
248
568
|
export declare function getSentClientMessageIds(store: ReliabilityMetadataStore, clientTimestamp: number): Promise<string[]>;
|
|
569
|
+
/**
|
|
570
|
+
* The key of one received message: its sender device, its content timestamp
|
|
571
|
+
* and the digest of its content. A manual resend of a sender has a new
|
|
572
|
+
* envelope ID and keeps the content timestamp and the content, so the key
|
|
573
|
+
* finds a copy that the envelope ID does not. The digest keeps two messages
|
|
574
|
+
* that one sender device sent in the same millisecond apart. The record of
|
|
575
|
+
* a key expires after `RETRY_REQUESTER_RECORD_TTL_MS`: a sender posts its
|
|
576
|
+
* last manual resend at most `RELIABILITY_RECORD_TTL_MS` after the intent,
|
|
577
|
+
* and the Relay keeps a post for at most `RELIABILITY_RECORD_TTL_MS`.
|
|
578
|
+
*/
|
|
579
|
+
export interface ReceivedMessageKey {
|
|
580
|
+
readonly senderUserId: string;
|
|
581
|
+
/**
|
|
582
|
+
* The device ID of the sender.
|
|
583
|
+
*
|
|
584
|
+
* @deprecated The next major SDK version removes the sender device from
|
|
585
|
+
* the key. A key then holds only the sender user and the timestamp, so
|
|
586
|
+
* the recipient also drops a later message from another device of the
|
|
587
|
+
* sender with the same timestamp. A custom store that checks or stores
|
|
588
|
+
* `ReceiveWorkRecord.received` must accept a key with no
|
|
589
|
+
* `senderDeviceId`.
|
|
590
|
+
*/
|
|
591
|
+
readonly senderDeviceId: number;
|
|
592
|
+
/** The content timestamp of the message. */
|
|
593
|
+
readonly timestamp: number;
|
|
594
|
+
/**
|
|
595
|
+
* The base64 SHA-256 of the UTF-8 bytes of the content that the
|
|
596
|
+
* application gets, with no group context in it.
|
|
597
|
+
*
|
|
598
|
+
* @deprecated The next major SDK version removes the digest from the key.
|
|
599
|
+
* In SDK 13.x, two different messages of one sender device with one
|
|
600
|
+
* timestamp both deliver. In the next major SDK version, the recipient
|
|
601
|
+
* keeps the first such message and drops a later one with no notice. A
|
|
602
|
+
* custom store that checks or stores `ReceiveWorkRecord.received` must
|
|
603
|
+
* accept a key with no `contentDigest`.
|
|
604
|
+
*/
|
|
605
|
+
readonly contentDigest: string;
|
|
606
|
+
}
|
|
607
|
+
/**
|
|
608
|
+
* True when the local device processed a message with this key. The record
|
|
609
|
+
* expires after `RETRY_REQUESTER_RECORD_TTL_MS`.
|
|
610
|
+
*/
|
|
611
|
+
export declare function hasReceivedTimestamp(store: ReliabilityMetadataStore, key: ReceivedMessageKey): Promise<boolean>;
|
|
612
|
+
/**
|
|
613
|
+
* Record that the local device processed a message with this key. The
|
|
614
|
+
* record expires after `RETRY_REQUESTER_RECORD_TTL_MS`. A receive that completes
|
|
615
|
+
* its record writes the key with `completeReceiveRecord` instead.
|
|
616
|
+
*/
|
|
617
|
+
export declare function recordReceivedTimestamp(store: ReliabilityMetadataStore, key: ReceivedMessageKey, now?: number): Promise<void>;
|
|
249
618
|
/** A source that tells that a recipient device has a message. */
|
|
250
619
|
export type StoredDeliverySource = 'relay' | 'e2ee';
|
|
251
620
|
/** The delivery of one message to one recipient device. */
|
|
@@ -278,11 +647,52 @@ export declare function updateDeliveryStatus<T>(store: ReliabilityMetadataStore,
|
|
|
278
647
|
* the recipient phase completed and the sync phase did not: the intent keeps
|
|
279
648
|
* its sync messages and the restart count of its sync phase, so a replay
|
|
280
649
|
* posts only the sync messages. With `syncPending` and no sync messages, the
|
|
281
|
-
* read of the own device list failed, and a replay reads it.
|
|
650
|
+
* read of the own device list failed, and a replay reads it. The intent
|
|
651
|
+
* keeps `destinationProgress`.
|
|
282
652
|
*/
|
|
283
653
|
export declare function completeOutgoingMessageIntent(store: ReliabilityMetadataStore, clientMessageId: string, result: NonNullable<StoredOutgoingMessageIntent['result']>, options?: {
|
|
284
654
|
syncPending?: boolean;
|
|
285
655
|
}): Promise<void>;
|
|
656
|
+
/**
|
|
657
|
+
* End an open intent at its posting deadline. It keeps the device messages
|
|
658
|
+
* and every other field, and it stores the posting deadline. Each entry of
|
|
659
|
+
* `destinationProgress` replaces the stored entry under its key, and each
|
|
660
|
+
* other stored entry stays. A completed
|
|
661
|
+
* intent keeps its `result`, which takes precedence, and this writes nothing.
|
|
662
|
+
* An intent that ended with another outcome is refused.
|
|
663
|
+
*/
|
|
664
|
+
export declare function endOutgoingMessageIntent(store: ReliabilityMetadataStore, clientMessageId: string, end: {
|
|
665
|
+
outcome: NonNullable<StoredOutgoingMessageIntent['outcome']>;
|
|
666
|
+
destinationProgress: Record<string, StoredDestinationProgress>;
|
|
667
|
+
}): Promise<void>;
|
|
668
|
+
/**
|
|
669
|
+
* The outgoing intents that the SDK send driver acts on, or undefined when
|
|
670
|
+
* the store does not implement `listMetadataKeys`. It returns each intent
|
|
671
|
+
* whose `outgoingIntentRetainedFrom` is not older than
|
|
672
|
+
* `RELIABILITY_RECORD_TTL_MS` and that is open (no
|
|
673
|
+
* `result` and no `outcome`), holds `outcomeReportPending`, or holds a
|
|
674
|
+
* manual resend with no `result` and no `outcome` of its own.
|
|
675
|
+
*/
|
|
676
|
+
export declare function listOpenOutgoingIntents(store: ReliabilityMetadataStore, now?: number): Promise<StoredOutgoingMessageIntent[] | undefined>;
|
|
677
|
+
/**
|
|
678
|
+
* Clear `outcomeReportPending` on an intent and record the time of the
|
|
679
|
+
* report. The SDK send driver calls it before it calls `onSendOutcome`, and
|
|
680
|
+
* calls the hook only when it returns true. It reads the record again under
|
|
681
|
+
* the intent lock, so of two drivers on one store, only one clears the mark.
|
|
682
|
+
* It returns false, and writes nothing, for an intent without the field.
|
|
683
|
+
*/
|
|
684
|
+
export declare function markOutgoingIntentReported(store: ReliabilityMetadataStore, clientMessageId: string, at?: number): Promise<boolean>;
|
|
685
|
+
/**
|
|
686
|
+
* Store the posting deadline on each open outgoing intent that an earlier
|
|
687
|
+
* SDK stored without one. The deadline comes from the stored times, as
|
|
688
|
+
* `outgoingMessageDeadlineAt` computes it, so the moved deadline is the one
|
|
689
|
+
* that the intent already had. It writes no report field, so the SDK send
|
|
690
|
+
* driver reports no end that an earlier SDK wrote. With a store that does
|
|
691
|
+
* not implement `listMetadataKeys`, or with no open intent without a
|
|
692
|
+
* deadline, it writes nothing. Such an intent then gets its deadline at its
|
|
693
|
+
* next mutation write.
|
|
694
|
+
*/
|
|
695
|
+
export declare function migrateOutgoingIntentRecords(store: ReliabilityMetadataStore, now?: number): Promise<void>;
|
|
286
696
|
/** The record of one envelope ID that the local device processed. */
|
|
287
697
|
export interface ProcessedEnvelope {
|
|
288
698
|
/** The time of the processing. The record expires from this time. */
|
|
@@ -318,6 +728,12 @@ export interface ProcessedEnvelopeWrite {
|
|
|
318
728
|
completed?: true;
|
|
319
729
|
outcome?: ProcessedEnvelopeOutcome;
|
|
320
730
|
}
|
|
731
|
+
/** The record of one received message, written with the completion of its receive. */
|
|
732
|
+
export interface ReceivedTimestampWrite {
|
|
733
|
+
receivedMessage: ReceivedMessageKey;
|
|
734
|
+
}
|
|
735
|
+
/** One write of a receive completion. */
|
|
736
|
+
export type ReceiveCompletionWrite = ProcessedEnvelopeWrite | ReceivedTimestampWrite;
|
|
321
737
|
/**
|
|
322
738
|
* Get the processed-envelope record of one envelope ID. A record older
|
|
323
739
|
* than `RELIABILITY_RECORD_TTL_MS` does not count. A fulfilled record
|
|
@@ -347,14 +763,14 @@ export declare function storeProcessedEnvelope(store: ReliabilityMetadataStore,
|
|
|
347
763
|
export declare function writeProcessedEnvelopes(store: ReliabilityMetadataStore, writes: readonly ProcessedEnvelopeWrite[], processedAt?: number): Promise<void>;
|
|
348
764
|
/**
|
|
349
765
|
* Complete one receive record: delete it and write its processed-envelope
|
|
350
|
-
* records
|
|
351
|
-
* the store, so the ledger index and the
|
|
352
|
-
* not at all.
|
|
766
|
+
* records and the record of its received message in one atomic store write.
|
|
767
|
+
* The writes run against a buffer over the store, so the ledger index and the
|
|
768
|
+
* records commit with the delete or not at all.
|
|
353
769
|
*
|
|
354
770
|
* @returns False, with nothing written, when the stored revision of the
|
|
355
771
|
* receive record is not `expectedRevision`.
|
|
356
772
|
*/
|
|
357
|
-
export declare function completeReceiveRecord(store: ReliabilityMetadataStore & Pick<SignalProtocolLocalStore, 'completeReceiveWork'>, workId: string, expectedRevision: number, writes: readonly
|
|
773
|
+
export declare function completeReceiveRecord(store: ReliabilityMetadataStore & Pick<SignalProtocolLocalStore, 'completeReceiveWork'>, workId: string, expectedRevision: number, writes: readonly ReceiveCompletionWrite[], processedAt?: number): Promise<boolean>;
|
|
358
774
|
/**
|
|
359
775
|
* The relay gave a failed envelope ID again with other content after the
|
|
360
776
|
* local device stored a retry request for that ID.
|
|
@@ -383,9 +799,9 @@ export declare function retryNullMessageClientMessageId(retryId: string): string
|
|
|
383
799
|
* The client message ID of one attempt of a retry request or a retry resend.
|
|
384
800
|
* Attempt 1 posts under the given ID, and attempt `n` posts under
|
|
385
801
|
* `<id>:<n>`. A resend takes the attempt number of the request that it
|
|
386
|
-
* answers.
|
|
387
|
-
*
|
|
388
|
-
*
|
|
802
|
+
* answers. Each attempt ID gets one encryption. When the Relay refuses the
|
|
803
|
+
* stored bytes of an attempt with OPERATION_EXPIRED, the attempt is marked
|
|
804
|
+
* acceptance-unknown, and nothing more posts under its ID.
|
|
389
805
|
*/
|
|
390
806
|
export declare function retryAttemptClientMessageId(id: string, attempt: number): string;
|
|
391
807
|
/**
|
|
@@ -536,6 +952,16 @@ export interface StoredRetryRequest {
|
|
|
536
952
|
* its stored attempt is answered.
|
|
537
953
|
*/
|
|
538
954
|
deadlineAt: number;
|
|
955
|
+
/**
|
|
956
|
+
* The end of the posts: the first failure, `receivedAt`, plus
|
|
957
|
+
* `RETRY_REQUEST_POSTING_WINDOW_MS`. Each later attempt keeps it. No post
|
|
958
|
+
* starts at or after it. A request whose stored attempt is due at this
|
|
959
|
+
* time ends as `posting-deadline`. A request whose attempt the Relay
|
|
960
|
+
* accepted posts nothing more and waits for its deadline. A record that
|
|
961
|
+
* an earlier SDK stored has none, and `retryRequestPostingDeadlineAt`
|
|
962
|
+
* derives it.
|
|
963
|
+
*/
|
|
964
|
+
postingDeadlineAt?: number;
|
|
539
965
|
/**
|
|
540
966
|
* The earliest time of the next post of the stored attempt. A new attempt
|
|
541
967
|
* stores its own time, so an attempt whose post a stop or a crash ended
|
|
@@ -555,12 +981,22 @@ export interface StoredRetryRequest {
|
|
|
555
981
|
*/
|
|
556
982
|
envelope?: Envelope;
|
|
557
983
|
/**
|
|
558
|
-
* The session reset of an `expired-content` end.
|
|
559
|
-
* it ends, so a replay does not do a step again.
|
|
560
|
-
* terminal class is `expired-content`
|
|
984
|
+
* The session reset of an `expired-content` or `posting-deadline` end.
|
|
985
|
+
* Each step is stored when it ends, so a replay does not do a step again.
|
|
986
|
+
* Only a record whose terminal class is `expired-content` or
|
|
987
|
+
* `posting-deadline` has it.
|
|
561
988
|
*/
|
|
562
989
|
recovery?: RetryTerminalRecovery;
|
|
563
990
|
}
|
|
991
|
+
/**
|
|
992
|
+
* The posting deadline of a retry request: the stored `postingDeadlineAt`.
|
|
993
|
+
* A record that an earlier SDK stored has none. Its deadline is then the
|
|
994
|
+
* first failure, `receivedAt`, else the time of the stored attempt, plus
|
|
995
|
+
* `RETRY_REQUEST_POSTING_WINDOW_MS`, and at most `deadlineAt`. An earlier
|
|
996
|
+
* SDK can store a `deadlineAt` one day after the first failure, so
|
|
997
|
+
* `deadlineAt` does not give the time of the first failure.
|
|
998
|
+
*/
|
|
999
|
+
export declare function retryRequestPostingDeadlineAt(record: Pick<StoredRetryRequest, 'deadlineAt' | 'postingDeadlineAt' | 'receivedAt' | 'requestedAt'>): number;
|
|
564
1000
|
/**
|
|
565
1001
|
* The conclusive end of a retry request or a retry resend.
|
|
566
1002
|
*
|
|
@@ -570,7 +1006,11 @@ export interface StoredRetryRequest {
|
|
|
570
1006
|
* sender of the resend cannot start a new session.
|
|
571
1007
|
* - `revoked-authority`: the Relay revoked the authority of the post.
|
|
572
1008
|
* - `expired-content`: the content of the request did not come before its
|
|
573
|
-
* deadline.
|
|
1009
|
+
* deadline. The next major SDK version renames this class to
|
|
1010
|
+
* `request-expired`.
|
|
1011
|
+
* - `posting-deadline`: a post of the request was due at or after its
|
|
1012
|
+
* posting deadline, or the Relay refused a post with OPERATION_EXPIRED;
|
|
1013
|
+
* the session resets.
|
|
574
1014
|
* - `attempts-exhausted`: the resend that answered the fifth attempt of the
|
|
575
1015
|
* request, `MAX_RETRY_RESPONSES_PER_MESSAGE`, also failed. The sender
|
|
576
1016
|
* answers no later attempt.
|
|
@@ -580,7 +1020,7 @@ export interface StoredRetryRequest {
|
|
|
580
1020
|
* of the content, or the sender has no source of current group membership.
|
|
581
1021
|
* The sender sends no content. Only the answer of a sender ends with it.
|
|
582
1022
|
*/
|
|
583
|
-
export type RetryTerminalClass = 'missing-sender' | 'missing-prekey' | 'revoked-authority' | 'expired-content' | 'attempts-exhausted' | 'deletion' | 'abuse-allowance-exhausted' | 'membership-refused';
|
|
1023
|
+
export type RetryTerminalClass = 'missing-sender' | 'missing-prekey' | 'revoked-authority' | 'expired-content' | 'posting-deadline' | 'attempts-exhausted' | 'deletion' | 'abuse-allowance-exhausted' | 'membership-refused';
|
|
584
1024
|
/**
|
|
585
1025
|
* The class of a retry request post that failed and can succeed later.
|
|
586
1026
|
* `transport-outage`: the post did not reach the Relay, its answer is
|
|
@@ -598,7 +1038,7 @@ export interface RetryTerminal {
|
|
|
598
1038
|
}
|
|
599
1039
|
/**
|
|
600
1040
|
* The session reset that the requester did after a request ended as
|
|
601
|
-
* `expired-content`.
|
|
1041
|
+
* `expired-content` or `posting-deadline`.
|
|
602
1042
|
*/
|
|
603
1043
|
export interface RetryTerminalRecovery {
|
|
604
1044
|
/** The user of the device that sent the failed envelope. */
|
|
@@ -710,7 +1150,9 @@ export interface RetryResendTarget {
|
|
|
710
1150
|
* record key is the device that gets the answer and the failed envelope
|
|
711
1151
|
* ID. The record holds the last encryption: a later post for the same
|
|
712
1152
|
* request attempt and kind sends these bytes with this operation epoch
|
|
713
|
-
* again, so the Relay sees one operation.
|
|
1153
|
+
* again, so the Relay sees one operation. The record also holds the
|
|
1154
|
+
* acceptance-unknown mark of that attempt, after which nothing more posts
|
|
1155
|
+
* under its ID.
|
|
714
1156
|
*/
|
|
715
1157
|
export interface StoredRetryResend extends RetryResendTarget {
|
|
716
1158
|
/**
|
|
@@ -736,6 +1178,13 @@ export interface StoredRetryResend extends RetryResendTarget {
|
|
|
736
1178
|
};
|
|
737
1179
|
contentHint?: ContentHint;
|
|
738
1180
|
message: StoredOutgoingDeviceMessage;
|
|
1181
|
+
/**
|
|
1182
|
+
* Set when the Relay refused the stored bytes with OPERATION_EXPIRED. The
|
|
1183
|
+
* Relay acceptance of the attempt is unknown, so nothing more posts under
|
|
1184
|
+
* its ID, and no new encryption replaces it. A record without the field
|
|
1185
|
+
* is not marked.
|
|
1186
|
+
*/
|
|
1187
|
+
acceptanceUnknown?: true;
|
|
739
1188
|
/** A stored encryption has no terminal state. */
|
|
740
1189
|
terminal?: undefined;
|
|
741
1190
|
}
|