@open-e2ee/signal-protocol-sdk 10.1.0 → 11.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 (83) hide show
  1. package/CHANGELOG.md +98 -0
  2. package/README.md +1 -1
  3. package/SECURITY.md +2 -2
  4. package/client/README.md +14 -0
  5. package/dist/client/client.d.ts +9 -0
  6. package/dist/client/client.d.ts.map +1 -1
  7. package/dist/client/client.js +32 -0
  8. package/dist/client/client.js.map +1 -1
  9. package/dist/client/event-hooks.d.ts +36 -0
  10. package/dist/client/event-hooks.d.ts.map +1 -1
  11. package/dist/client/event-hooks.js +1 -0
  12. package/dist/client/event-hooks.js.map +1 -1
  13. package/dist/client/hosted-device-standing.d.ts +52 -0
  14. package/dist/client/hosted-device-standing.d.ts.map +1 -0
  15. package/dist/client/hosted-device-standing.js +74 -0
  16. package/dist/client/hosted-device-standing.js.map +1 -0
  17. package/dist/client/hosted-mailbox-subscription.d.ts +14 -1
  18. package/dist/client/hosted-mailbox-subscription.d.ts.map +1 -1
  19. package/dist/client/hosted-mailbox-subscription.js +201 -57
  20. package/dist/client/hosted-mailbox-subscription.js.map +1 -1
  21. package/dist/client/hosted-transport.d.ts.map +1 -1
  22. package/dist/client/hosted-transport.js +52 -14
  23. package/dist/client/hosted-transport.js.map +1 -1
  24. package/dist/client/hosted.d.ts +12 -1
  25. package/dist/client/hosted.d.ts.map +1 -1
  26. package/dist/client/hosted.js +112 -41
  27. package/dist/client/hosted.js.map +1 -1
  28. package/dist/client/index.d.ts +2 -2
  29. package/dist/client/index.d.ts.map +1 -1
  30. package/dist/client/index.js +1 -1
  31. package/dist/client/index.js.map +1 -1
  32. package/dist/client/messages.d.ts.map +1 -1
  33. package/dist/client/messages.js +10 -0
  34. package/dist/client/messages.js.map +1 -1
  35. package/dist/client/one-time-prekey-refill.d.ts +7 -0
  36. package/dist/client/one-time-prekey-refill.d.ts.map +1 -1
  37. package/dist/client/one-time-prekey-refill.js +5 -1
  38. package/dist/client/one-time-prekey-refill.js.map +1 -1
  39. package/dist/client/relay-acceptance.d.ts +17 -0
  40. package/dist/client/relay-acceptance.d.ts.map +1 -1
  41. package/dist/client/relay-acceptance.js +37 -0
  42. package/dist/client/relay-acceptance.js.map +1 -1
  43. package/dist/client/relay-subscription.d.ts.map +1 -1
  44. package/dist/client/relay-subscription.js +30 -30
  45. package/dist/client/relay-subscription.js.map +1 -1
  46. package/dist/client/retry-family.d.ts +11 -9
  47. package/dist/client/retry-family.d.ts.map +1 -1
  48. package/dist/client/retry-family.js +5 -5
  49. package/dist/client/retry-family.js.map +1 -1
  50. package/dist/client/retry-request-envelope.d.ts +40 -12
  51. package/dist/client/retry-request-envelope.d.ts.map +1 -1
  52. package/dist/client/retry-request-envelope.js +142 -54
  53. package/dist/client/retry-request-envelope.js.map +1 -1
  54. package/dist/client/retry-request-lifecycle.d.ts +101 -0
  55. package/dist/client/retry-request-lifecycle.d.ts.map +1 -0
  56. package/dist/client/retry-request-lifecycle.js +307 -0
  57. package/dist/client/retry-request-lifecycle.js.map +1 -0
  58. package/dist/client/retry.d.ts +6 -6
  59. package/dist/client/retry.d.ts.map +1 -1
  60. package/dist/client/retry.js +83 -38
  61. package/dist/client/retry.js.map +1 -1
  62. package/dist/client/signal-service-cipher.d.ts.map +1 -1
  63. package/dist/client/signal-service-cipher.js +5 -1
  64. package/dist/client/signal-service-cipher.js.map +1 -1
  65. package/dist/client/types.d.ts.map +1 -1
  66. package/dist/client/types.js.map +1 -1
  67. package/dist/index.d.ts +2 -2
  68. package/dist/index.d.ts.map +1 -1
  69. package/dist/index.js +1 -1
  70. package/dist/index.js.map +1 -1
  71. package/dist/local/store/reliability.d.ts +106 -8
  72. package/dist/local/store/reliability.d.ts.map +1 -1
  73. package/dist/local/store/reliability.js +165 -16
  74. package/dist/local/store/reliability.js.map +1 -1
  75. package/dist/remote/relay/types.d.ts +12 -3
  76. package/dist/remote/relay/types.d.ts.map +1 -1
  77. package/dist/utils/retry.d.ts +2 -0
  78. package/dist/utils/retry.d.ts.map +1 -1
  79. package/dist/utils/retry.js +7 -0
  80. package/dist/utils/retry.js.map +1 -1
  81. package/docs/ASSURANCE.md +5 -5
  82. package/docs/ERROR_HANDLING.md +70 -0
  83. package/package.json +1 -1
@@ -13,14 +13,16 @@
13
13
  * `:<n>` from attempt 2. The resend and the null message carry the attempt
14
14
  * number of the request that they answer. The failed envelope ID travels
15
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.
16
+ * The requester stores each request envelope before the post. After a post
17
+ * that fails with a retryable class, the retry request scheduler posts the
18
+ * stored envelope again, until the deadline of the record.
18
19
  */
19
20
  import { RetryReason } from '../internal/sesame/types.js';
20
21
  import { base64ToBytes, bytesToBase64, generateUuidV4, stringToBytes } from '../internal/crypto/index.js';
21
22
  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';
23
+ import { isRetryId, RELIABILITY_RECORD_TTL_MS, RETRY_REQUEST_DEADLINE_MS, retryAttemptClientMessageId, retryRequestClientMessageId, storeRetryRequest, updateRetryRequest, } from '../local/store/reliability.js';
24
+ import { classifyRetryRequestPostFailure, relayOperationRefusal, } from './relay-acceptance.js';
25
+ import { rethrowRelayWorkStopped } from './relay-work.js';
24
26
  /** The payload version that this client writes and reads. */
25
27
  const RETRY_REQUEST_PAYLOAD_VERSION = 1;
26
28
  /** The decoder refuses a longer `ciphertext` value before it decodes it. */
@@ -63,19 +65,22 @@ export async function retryRequestEnvelope(request, sender, failed) {
63
65
  : await generateUuidV4(),
64
66
  };
65
67
  }
68
+ /** The shortest wait before the next post of a stored attempt. */
69
+ const MIN_RETRY_REQUEST_BACKOFF_MS = 60_000;
70
+ /** The longest wait before the next post of a stored attempt. */
71
+ const MAX_RETRY_REQUEST_BACKOFF_MS = 60 * 60_000;
66
72
  /**
67
73
  * Post the retry request for one failed envelope.
68
74
  *
69
75
  * 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.
76
+ * new UUID, stores nothing, and throws when the post fails. Otherwise the
77
+ * request record owns the request. With no record, it creates attempt 1
78
+ * with a new retry ID and stores it before the post, due at once. A
79
+ * record that ended posts nothing. At the deadline of the record, the
80
+ * request ends as `expired-content` and posts nothing. When a member
81
+ * failed and the stored attempt is answered, it creates the next attempt
82
+ * under the same retry ID, with the same deadline, and posts it. Otherwise
83
+ * it posts the stored attempt, as `postStoredRetryRequest` does.
79
84
  *
80
85
  * @param store - The local store that keeps the request records.
81
86
  * @param failed - The failed envelope and its stored request.
@@ -88,54 +93,137 @@ export async function postRetryRequest(store, failed, createRequest, sender, sen
88
93
  const failedEnvelopeId = failed.id;
89
94
  if (failedEnvelopeId === undefined) {
90
95
  await send(await retryRequestEnvelope(await createRequest(), sender));
91
- return;
96
+ return 'posted';
92
97
  }
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, {
98
+ const attempts = retryRequestAttempts(store, createRequest, sender, send);
99
+ const { stored } = failed;
100
+ if (!stored) {
101
+ return attempts.postNew(await attempts.create({
104
102
  failedEnvelopeId,
105
- retryId,
106
- attempt,
107
- });
108
- await storeRetryRequest(store, {
109
- failedEnvelopeId,
110
- retryId,
111
- attempt,
112
- requestedAt: envelope.timestamp,
103
+ retryId: await generateUuidV4(),
104
+ attempt: 1,
113
105
  ...(failed.fingerprint !== undefined && { fingerprint: failed.fingerprint }),
106
+ }));
107
+ }
108
+ if (stored.terminal !== undefined || stored.envelope === undefined)
109
+ return 'terminal';
110
+ if (Date.now() >= stored.deadlineAt)
111
+ return attempts.expire(stored);
112
+ if (failed.member !== undefined && stored.answered) {
113
+ return attempts.postNew(await attempts.next(stored));
114
+ }
115
+ return attempts.postStored(stored);
116
+ }
117
+ /**
118
+ * Post the stored attempt of a retry request again, with its stored bytes
119
+ * and ID. When the Relay refuses it with OPERATION_EXPIRED, it creates the
120
+ * next attempt under the same retry ID, with the same deadline, replaces
121
+ * the record in one write, and posts it.
122
+ *
123
+ * Each post classifies its failure. A RETRY_CONFLICT answer completes the
124
+ * attempt, because the Relay holds an earlier encryption of it. A
125
+ * conclusive class stores the terminal state, with `emitted` false, and
126
+ * gives 'terminal'. A retryable class stores the class and the next
127
+ * attempt time, the age of the attempt from 1 minute to 1 hour from now,
128
+ * and gives 'pending'. A post that the Relay accepts clears both.
129
+ *
130
+ * @param store - The local store that keeps the request records.
131
+ * @param stored - The stored attempt. It has an envelope.
132
+ * @param createRequest - Creates the request of a new attempt.
133
+ * @param sender - The local identity, which sends the envelope.
134
+ * @param send - Posts one request envelope.
135
+ */
136
+ export async function postStoredRetryRequest(store, stored, createRequest, sender, send) {
137
+ return retryRequestAttempts(store, createRequest, sender, send).postStored(stored);
138
+ }
139
+ /** The attempt steps of one retry request. */
140
+ function retryRequestAttempts(store, createRequest, sender, send) {
141
+ const update = (record, changes) => updateRetryRequest(store, record.failedEnvelopeId, record.retryId, record.attempt, changes);
142
+ /**
143
+ * Create and store a new attempt. Attempt 1 sets the deadline. The
144
+ * attempt is due at its own time until its post settles, so the
145
+ * scheduler posts it again when a stop or a crash ends the post.
146
+ */
147
+ const create = async (attempt) => {
148
+ const request = await createRequest();
149
+ const envelope = await retryRequestEnvelope(request, sender, attempt);
150
+ const record = {
151
+ failedEnvelopeId: attempt.failedEnvelopeId,
152
+ retryId: attempt.retryId,
153
+ attempt: attempt.attempt,
154
+ requestedAt: envelope.timestamp,
155
+ ...(attempt.fingerprint !== undefined && { fingerprint: attempt.fingerprint }),
114
156
  answered: false,
157
+ deadlineAt: attempt.deadlineAt ??
158
+ Math.min(envelope.timestamp + RETRY_REQUEST_DEADLINE_MS, request.failedTimestamp + RELIABILITY_RECORD_TTL_MS),
159
+ nextAttemptAt: envelope.timestamp,
115
160
  envelope,
161
+ };
162
+ await storeRetryRequest(store, record);
163
+ return record;
164
+ };
165
+ /** Create the attempt after the stored one, with the same retry ID and deadline. */
166
+ const next = (stored) => create({
167
+ failedEnvelopeId: stored.failedEnvelopeId,
168
+ retryId: stored.retryId,
169
+ attempt: stored.attempt + 1,
170
+ fingerprint: stored.fingerprint,
171
+ deadlineAt: stored.deadlineAt,
172
+ });
173
+ const expire = async (stored) => {
174
+ await update(stored, {
175
+ terminal: { class: 'expired-content', at: Date.now(), emitted: false },
176
+ nextAttemptAt: undefined,
116
177
  });
117
- return envelope;
178
+ return 'terminal';
179
+ };
180
+ /**
181
+ * Post one attempt. `fresh` is true for an attempt that this call
182
+ * created: OPERATION_EXPIRED then means a clock outside the admission
183
+ * window, and counts as a transport outage.
184
+ */
185
+ const post = async (record, fresh) => {
186
+ try {
187
+ await send(record.envelope);
188
+ }
189
+ catch (error) {
190
+ rethrowRelayWorkStopped(error);
191
+ const refusal = relayOperationRefusal(error);
192
+ if (refusal === 'OPERATION_EXPIRED' && !fresh) {
193
+ // The Relay no longer admits or replays the stored operation. The
194
+ // new attempt replaces the record before its post.
195
+ return post(await next(record), true);
196
+ }
197
+ if (refusal !== 'RETRY_CONFLICT') {
198
+ const failure = refusal === 'OPERATION_EXPIRED'
199
+ ? { retry: 'transport-outage' }
200
+ : classifyRetryRequestPostFailure(error);
201
+ if ('terminal' in failure) {
202
+ await update(record, {
203
+ terminal: { class: failure.terminal, at: Date.now(), emitted: false },
204
+ nextAttemptAt: undefined,
205
+ lastFailureClass: undefined,
206
+ });
207
+ return 'terminal';
208
+ }
209
+ const now = Date.now();
210
+ const wait = Math.min(MAX_RETRY_REQUEST_BACKOFF_MS, Math.max(MIN_RETRY_REQUEST_BACKOFF_MS, now - record.requestedAt));
211
+ await update(record, { lastFailureClass: failure.retry, nextAttemptAt: now + wait });
212
+ return 'pending';
213
+ }
214
+ }
215
+ if (record.nextAttemptAt !== undefined || record.lastFailureClass !== undefined) {
216
+ await update(record, { nextAttemptAt: undefined, lastFailureClass: undefined });
217
+ }
218
+ return 'posted';
219
+ };
220
+ return {
221
+ create,
222
+ next,
223
+ expire,
224
+ postNew: (record) => post(record, true),
225
+ postStored: (stored) => post(stored, false),
118
226
  };
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
227
  }
140
228
  /**
141
229
  * Read a `retry_request` envelope that the local device received.
@@ -1 +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,2BA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,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"}
@@ -0,0 +1,101 @@
1
+ /**
2
+ * The lifecycle of a retry request on the requester device.
3
+ *
4
+ * The request record of a failed envelope owns its retry request from the
5
+ * first post to the answer or to a terminal state. A redelivery of the
6
+ * failed envelope posts nothing while the record exists. A post that fails
7
+ * with a retryable class is posted again by the scheduler at its next
8
+ * attempt time. A post that fails with a conclusive class, the deadline of
9
+ * the record, and an exhausted abuse allowance end the request. Each end
10
+ * calls the `onRetryTerminal` hook once.
11
+ */
12
+ import type { Logger } from '../logger.js';
13
+ import type { Envelope } from '../remote/relay/types.js';
14
+ import type { RetryRequest } from '../internal/sesame/types.js';
15
+ import { storeRetryRequest } from '../local/store/reliability.js';
16
+ import { type SignalProtocolClientHooks } from './event-hooks.js';
17
+ import type { RetryFamilyReceive } from './retry-family.js';
18
+ import { type RetryPostOutcome, type RetryRequestDevice } from './retry-request-envelope.js';
19
+ type RetryRequestStore = Parameters<typeof storeRetryRequest>[0];
20
+ /**
21
+ * What the retry request of one failed decrypt did.
22
+ *
23
+ * - `posted`, `pending`, `terminal`: as `postRetryRequest` gives them. A
24
+ * terminal request also called the hook.
25
+ * - `owned`: the record of the failed envelope owns the request, so a
26
+ * redelivery of the failed envelope posted nothing.
27
+ * - `deferred`: the rate limit refused a member, and the next attempt waits
28
+ * for the end of the limit window.
29
+ * - `skipped`: nothing was posted or stored.
30
+ */
31
+ export type RetryRequestOutcome = RetryPostOutcome | 'owned' | 'deferred' | 'skipped';
32
+ /**
33
+ * Tell whether the receive path acknowledges a failed envelope after its
34
+ * retry request. A failed envelope is acknowledged once a record owns its
35
+ * request. A member is acknowledged only when its request attempt is posted
36
+ * or ended, so a member that waits is delivered again.
37
+ */
38
+ export declare function acknowledgesRetryRequest(outcome: RetryRequestOutcome, member: boolean): boolean;
39
+ /** What the requester uses to ask for a resend after one failed decrypt. */
40
+ export interface RetryRequestSource {
41
+ readonly storage: RetryRequestStore;
42
+ readonly logger: Required<Logger>;
43
+ readonly hooks: SignalProtocolClientHooks | undefined;
44
+ /** The local identity, which sends the request envelope. */
45
+ readonly local: RetryRequestDevice;
46
+ /** The user ID of the failed sender, for the log line of a refusal. */
47
+ readonly senderUserId: string;
48
+ /** Spends one request of the rate limit of the sender. False when refused. */
49
+ allow(): boolean;
50
+ /** The rate limit window, for the log line and the cooldown of a member. */
51
+ readonly windowMs: number;
52
+ /** Posts one request envelope. Without it, nothing is posted. */
53
+ readonly send: ((envelope: Envelope) => Promise<unknown>) | undefined;
54
+ /** Creates the request of a new attempt. */
55
+ createRequest(): Promise<RetryRequest>;
56
+ /** Arms the scheduler for the next attempt time or the deadline of a record. */
57
+ readonly schedule: ((at: number) => void) | undefined;
58
+ }
59
+ /**
60
+ * Call the `onRetryTerminal` hook for the terminal state of a request
61
+ * record, once. It reads the record, calls the hook when the terminal state
62
+ * is not emitted, and then stores it as emitted. A RelayWorkStopped from the
63
+ * hook propagates and leaves the state not emitted, so the next scheduler
64
+ * pass or redelivery calls the hook again.
65
+ */
66
+ export declare function emitRetryTerminal(storage: RetryRequestStore, hooks: SignalProtocolClientHooks | undefined, failedEnvelopeId: string): Promise<void>;
67
+ /**
68
+ * Ask for a resend after a failed decrypt, through the retry family of the
69
+ * envelope.
70
+ *
71
+ * - A failed envelope with a record posts nothing and gives `owned`. It
72
+ * only calls the hook for a terminal state that is not emitted. The rate
73
+ * limit does not count it.
74
+ * - A failed envelope with no record spends one request of the rate limit.
75
+ * A refusal stores a record that ends as `abuse-allowance-exhausted`.
76
+ * - A member of a request that ended posts nothing and gives `terminal`.
77
+ * - A member whose stored attempt is answered, or that has no record,
78
+ * spends one request of the rate limit, unless an earlier refusal set a
79
+ * next attempt time that has not come. A refusal sets that time to the
80
+ * end of the limit window and gives `deferred`.
81
+ * - A member whose stored attempt is not answered posts it again, with no
82
+ * rate limit.
83
+ *
84
+ * After a post, a terminal outcome calls the hook, and any other outcome
85
+ * arms the scheduler for the record.
86
+ */
87
+ export declare function requestRetryInFamily(family: RetryFamilyReceive, fingerprint: string | undefined, source: RetryRequestSource): Promise<RetryRequestOutcome>;
88
+ /**
89
+ * The context of one scheduler pass: the hooks run through the relay work
90
+ * of the pass. Without `send`, the pass only calls the hook for terminal
91
+ * states.
92
+ */
93
+ export interface RetryRequestPass {
94
+ readonly storage: RetryRequestStore;
95
+ readonly logger: Required<Logger>;
96
+ readonly hooks: SignalProtocolClientHooks | undefined;
97
+ readonly local: RetryRequestDevice;
98
+ readonly send: ((envelope: Envelope) => Promise<unknown>) | undefined;
99
+ }
100
+ export {};
101
+ //# sourceMappingURL=retry-request-lifecycle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retry-request-lifecycle.d.ts","sourceRoot":"","sources":["../../client/retry-request-lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAIL,iBAAiB,EAIlB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAY,KAAK,yBAAyB,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,KAAK,EAAE,k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