@elaraai/e3-cloud-files 1.1.19 → 1.1.21
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/README.md +79 -14
- package/dist/src/authoring.d.ts +88 -19
- package/dist/src/authoring.d.ts.map +1 -1
- package/dist/src/authoring.js +94 -25
- package/dist/src/authoring.js.map +1 -1
- package/dist/src/check/index.d.ts +1 -1
- package/dist/src/check/index.d.ts.map +1 -1
- package/dist/src/check/index.js +1 -1
- package/dist/src/check/index.js.map +1 -1
- package/dist/src/check.d.ts +7 -9
- package/dist/src/check.d.ts.map +1 -1
- package/dist/src/check.js +12 -11
- package/dist/src/check.js.map +1 -1
- package/dist/src/compat.d.ts +255 -3
- package/dist/src/compat.d.ts.map +1 -1
- package/dist/src/compat.js +60 -10
- package/dist/src/compat.js.map +1 -1
- package/dist/src/index.d.ts +2 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/s3/index.d.ts.map +1 -1
- package/dist/src/s3/index.js +12 -0
- package/dist/src/s3/index.js.map +1 -1
- package/dist/src/sync/engine.d.ts +122 -10
- package/dist/src/sync/engine.d.ts.map +1 -1
- package/dist/src/sync/engine.js +337 -78
- package/dist/src/sync/engine.js.map +1 -1
- package/dist/src/sync/index.d.ts +3 -2
- package/dist/src/sync/index.d.ts.map +1 -1
- package/dist/src/sync/index.js +3 -2
- package/dist/src/sync/index.js.map +1 -1
- package/dist/src/sync/memory.d.ts +78 -0
- package/dist/src/sync/memory.d.ts.map +1 -1
- package/dist/src/sync/memory.js +206 -1
- package/dist/src/sync/memory.js.map +1 -1
- package/dist/src/sync/push.d.ts +15 -2
- package/dist/src/sync/push.d.ts.map +1 -1
- package/dist/src/sync/push.js +19 -6
- package/dist/src/sync/push.js.map +1 -1
- package/dist/src/sync/sealed.d.ts +251 -0
- package/dist/src/sync/sealed.d.ts.map +1 -0
- package/dist/src/sync/sealed.js +573 -0
- package/dist/src/sync/sealed.js.map +1 -0
- package/dist/test/orders.examples.d.ts +1 -1
- package/dist/test/orders.examples.d.ts.map +1 -1
- package/dist/test/typed.examples.d.ts +2 -2
- package/dist/test/typed.examples.d.ts.map +1 -1
- package/package.json +6 -6
|
@@ -0,0 +1,573 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Licensed under BSL 1.1. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Sealed files: what an encrypted deliveries area holds, told apart from
|
|
7
|
+
* plaintext with no OpenPGP library.
|
|
8
|
+
*
|
|
9
|
+
* A deliveries area the deployment makes takes OpenPGP messages alone, each
|
|
10
|
+
* encrypted to the deliveries key, and the sync's round decrypts ("unseals")
|
|
11
|
+
* each before any byte of it is used. The reader that decrypts lives with the
|
|
12
|
+
* platform (`@elaraai/e3-aws`), so no published package carries the library;
|
|
13
|
+
* what is here is the part every reader shares:
|
|
14
|
+
*
|
|
15
|
+
* - {@link isOpenPgpMessage}: whether a file's first bytes begin an OpenPGP
|
|
16
|
+
* message, armored or binary;
|
|
17
|
+
* - {@link plaintextOnlyReader}: a reader that refuses such a file, for a
|
|
18
|
+
* place that only a deployment could decrypt (a local repository's
|
|
19
|
+
* stand-in folder, a developer reading an external bucket);
|
|
20
|
+
* - {@link UnsealStore}: where a decrypted file too large to hold in memory
|
|
21
|
+
* is staged, and found again by a later round;
|
|
22
|
+
* - {@link unsealingReader}: the reader every sealed area is read through,
|
|
23
|
+
* over an {@link Unsealer} that decrypts (the platform's OpenPGP one, or
|
|
24
|
+
* the toy one in memory a test seals with): it sniffs a file before
|
|
25
|
+
* downloading it, bounds its plaintext, holds it in memory up to
|
|
26
|
+
* {@link SEALED_IN_MEMORY_BYTES} or stages it whole, and lets no byte of
|
|
27
|
+
* it be read before the decryption ended cleanly;
|
|
28
|
+
* - the fixed words of each refusal ({@link SEALED_REFUSALS}).
|
|
29
|
+
*
|
|
30
|
+
* @packageDocumentation
|
|
31
|
+
*/
|
|
32
|
+
import { createHash } from 'node:crypto';
|
|
33
|
+
import { variant } from '@elaraai/east';
|
|
34
|
+
import { FilesUnreadableError } from './engine.js';
|
|
35
|
+
/** How many of a file's first bytes {@link isOpenPgpMessage} looks at. */
|
|
36
|
+
export const OPENPGP_SNIFF_BYTES = 64;
|
|
37
|
+
/** An armored message's first line. */
|
|
38
|
+
const ARMOR = '-----BEGIN PGP MESSAGE-----';
|
|
39
|
+
/** The packet tags an encrypted message begins with: a public-key (1) or a symmetric-key (3) encrypted session key. */
|
|
40
|
+
const SESSION_KEY_TAGS = new Set([1, 3]);
|
|
41
|
+
/** A marker packet's tag (10): RFC 9580 lets a message begin with one, which a reader ignores. */
|
|
42
|
+
const MARKER_TAG = 10;
|
|
43
|
+
/** UTF-8's byte-order mark, which a Windows tool may write before an armored message. */
|
|
44
|
+
const BOM = [0xef, 0xbb, 0xbf];
|
|
45
|
+
/**
|
|
46
|
+
* A binary packet's header at a byte: its tag and where its body starts and
|
|
47
|
+
* ends, or null where the bytes hold no header (or one whose length is not
|
|
48
|
+
* among the bytes given).
|
|
49
|
+
*/
|
|
50
|
+
function packetAt(head, at) {
|
|
51
|
+
const first = head[at];
|
|
52
|
+
if (first === undefined || (first & 0x80) === 0)
|
|
53
|
+
return null;
|
|
54
|
+
if ((first & 0x40) !== 0) {
|
|
55
|
+
// New format: a one-, two- or five-byte length
|
|
56
|
+
const tag = first & 0x3f;
|
|
57
|
+
const l0 = head[at + 1];
|
|
58
|
+
if (l0 === undefined)
|
|
59
|
+
return { tag, end: Infinity };
|
|
60
|
+
if (l0 < 192)
|
|
61
|
+
return { tag, end: at + 2 + l0 };
|
|
62
|
+
if (l0 < 224)
|
|
63
|
+
return head[at + 2] === undefined ? { tag, end: Infinity } : { tag, end: at + 3 + ((l0 - 192) << 8) + head[at + 2] + 192 };
|
|
64
|
+
return { tag, end: Infinity };
|
|
65
|
+
}
|
|
66
|
+
// Old format: 10TTTTLL, the length in 1, 2 or 4 bytes (or indeterminate)
|
|
67
|
+
const tag = (first >> 2) & 0x0f;
|
|
68
|
+
const lengthType = first & 0x03;
|
|
69
|
+
if (lengthType === 0)
|
|
70
|
+
return head[at + 1] === undefined ? { tag, end: Infinity } : { tag, end: at + 2 + head[at + 1] };
|
|
71
|
+
if (lengthType === 1)
|
|
72
|
+
return head[at + 2] === undefined ? { tag, end: Infinity } : { tag, end: at + 3 + ((head[at + 1] << 8) | head[at + 2]) };
|
|
73
|
+
return { tag, end: Infinity };
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Whether a file's first bytes begin an OpenPGP message that is encrypted:
|
|
77
|
+
* an armored `-----BEGIN PGP MESSAGE-----` (after a UTF-8 byte-order mark
|
|
78
|
+
* and blank space, either optional), or a binary first packet of tag 1 (a
|
|
79
|
+
* public-key encrypted session key) or 3 (a symmetric-key one), in the old
|
|
80
|
+
* or the new packet format, after a marker packet if one leads. Plaintext,
|
|
81
|
+
* CSV, JSON and beast2 are none.
|
|
82
|
+
*
|
|
83
|
+
* @param head - The file's first bytes: {@link OPENPGP_SNIFF_BYTES} suffice
|
|
84
|
+
* @returns Whether it is an encrypted OpenPGP message
|
|
85
|
+
*/
|
|
86
|
+
export function isOpenPgpMessage(head) {
|
|
87
|
+
if (head.length === 0)
|
|
88
|
+
return false;
|
|
89
|
+
const bom = head[0] === BOM[0] && head[1] === BOM[1] && head[2] === BOM[2];
|
|
90
|
+
// A binary packet header: its top bit set; a leading marker packet skipped
|
|
91
|
+
let packet = bom ? null : packetAt(head, 0);
|
|
92
|
+
if (packet !== null) {
|
|
93
|
+
if (packet.tag === MARKER_TAG) {
|
|
94
|
+
if (!Number.isFinite(packet.end))
|
|
95
|
+
return false;
|
|
96
|
+
packet = packetAt(head, packet.end);
|
|
97
|
+
if (packet === null)
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
return SESSION_KEY_TAGS.has(packet.tag);
|
|
101
|
+
}
|
|
102
|
+
// Armored: ASCII, after a byte-order mark and blank space
|
|
103
|
+
let at = bom ? BOM.length : 0;
|
|
104
|
+
while (at < head.length && (head[at] === 0x20 || head[at] === 0x09 || head[at] === 0x0a || head[at] === 0x0d))
|
|
105
|
+
at += 1;
|
|
106
|
+
if (head.length - at < ARMOR.length)
|
|
107
|
+
return false;
|
|
108
|
+
for (let i = 0; i < ARMOR.length; i++)
|
|
109
|
+
if (head[at + i] !== ARMOR.charCodeAt(i))
|
|
110
|
+
return false;
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
/** The refusal of an encrypted file where only the deployment decrypts it. */
|
|
114
|
+
export const ENCRYPTED_HERE_REFUSAL = 'is encrypted: only the deployment decrypts it';
|
|
115
|
+
/**
|
|
116
|
+
* A reader that refuses an encrypted file ({@link isOpenPgpMessage}) as
|
|
117
|
+
* unreadable ({@link ENCRYPTED_HERE_REFUSAL}), and reads every other file as
|
|
118
|
+
* the inner reader does: a local repository's stand-in folder for the
|
|
119
|
+
* deliveries, which a push fills with plaintext, and an external bucket a
|
|
120
|
+
* developer reads with their own credentials. A file's first bytes are read
|
|
121
|
+
* once, by a ranged read, before any other of its bytes.
|
|
122
|
+
*
|
|
123
|
+
* @param inner - The reader of the place
|
|
124
|
+
* @returns The reader
|
|
125
|
+
*/
|
|
126
|
+
export function plaintextOnlyReader(inner) {
|
|
127
|
+
/** Each file's verdict, by key and ETag: read once */
|
|
128
|
+
const verdicts = new Map();
|
|
129
|
+
const encrypted = (object) => {
|
|
130
|
+
const key = `${object.key}\u0000${object.etag}`;
|
|
131
|
+
let verdict = verdicts.get(key);
|
|
132
|
+
if (verdict === undefined) {
|
|
133
|
+
verdict = object.size === 0 ? Promise.resolve(false) : inner.readRange(object, 0, Math.min(object.size, OPENPGP_SNIFF_BYTES)).then(isOpenPgpMessage);
|
|
134
|
+
verdicts.set(key, verdict);
|
|
135
|
+
}
|
|
136
|
+
return verdict;
|
|
137
|
+
};
|
|
138
|
+
const plaintext = async (object) => {
|
|
139
|
+
if (await encrypted(object))
|
|
140
|
+
throw new FilesUnreadableError(object.key, ENCRYPTED_HERE_REFUSAL);
|
|
141
|
+
};
|
|
142
|
+
return {
|
|
143
|
+
list: (prefix, options) => inner.list(prefix, options),
|
|
144
|
+
stat: (key) => inner.stat(key),
|
|
145
|
+
async read(object) {
|
|
146
|
+
await plaintext(object);
|
|
147
|
+
return inner.read(object);
|
|
148
|
+
},
|
|
149
|
+
async readRange(object, start, end) {
|
|
150
|
+
await plaintext(object);
|
|
151
|
+
return inner.readRange(object, start, end);
|
|
152
|
+
},
|
|
153
|
+
async open(object, options) {
|
|
154
|
+
await plaintext(object);
|
|
155
|
+
return inner.open(object, options);
|
|
156
|
+
},
|
|
157
|
+
...(inner.origin !== undefined && { origin: (object) => inner.origin(object) }),
|
|
158
|
+
...(inner.folders !== undefined && { folders: (prefix) => inner.folders(prefix) }),
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
/** No record: a file no round has tried and not finished. */
|
|
162
|
+
export const NO_UNSEAL_ATTEMPTS = { count: 0, refusedAt: null };
|
|
163
|
+
/**
|
|
164
|
+
* An {@link UnsealStore} that keeps nothing: a file "staged" in it is read to
|
|
165
|
+
* its end and counted, each chunk let go as it passes, and nothing is
|
|
166
|
+
* written anywhere. It finds nothing staged and records no attempt. A probe's
|
|
167
|
+
* store: the sync's own unseal, its every check and limit, run on a file
|
|
168
|
+
* whose plaintext is wanted for its size alone. Reading a file it answered
|
|
169
|
+
* is refused, for it holds none of it.
|
|
170
|
+
*
|
|
171
|
+
* @returns The store
|
|
172
|
+
*/
|
|
173
|
+
export function countingUnsealStore() {
|
|
174
|
+
const nothing = (object) => {
|
|
175
|
+
throw new FilesUnreadableError(object.key, 'is counted, not kept: a probe holds none of its plaintext');
|
|
176
|
+
};
|
|
177
|
+
const kept = {
|
|
178
|
+
list: () => [],
|
|
179
|
+
stat: () => Promise.resolve(null),
|
|
180
|
+
read: (object) => Promise.resolve().then(() => nothing(object)),
|
|
181
|
+
readRange: (object) => Promise.resolve().then(() => nothing(object)),
|
|
182
|
+
open: (object) => Promise.resolve().then(() => nothing(object)),
|
|
183
|
+
};
|
|
184
|
+
return {
|
|
185
|
+
find: () => Promise.resolve(null),
|
|
186
|
+
async write(_key, chunks, signal) {
|
|
187
|
+
let size = 0;
|
|
188
|
+
for await (const chunk of chunks) {
|
|
189
|
+
if (signal?.aborted === true)
|
|
190
|
+
return { aborted: true };
|
|
191
|
+
size += chunk.length;
|
|
192
|
+
}
|
|
193
|
+
return { size, reader: kept };
|
|
194
|
+
},
|
|
195
|
+
remove: () => Promise.resolve(),
|
|
196
|
+
// A probe tries the file whatever a sync recorded of it: no record is read or written here
|
|
197
|
+
attempts: () => Promise.resolve(NO_UNSEAL_ATTEMPTS),
|
|
198
|
+
attempted: () => Promise.resolve(),
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
/** The most recipients (session keys, to keys or passphrases) a sealed file's message may name: a client encrypts to one key, perhaps its own beside it. */
|
|
202
|
+
export const SEALED_MAX_RECIPIENTS = 8;
|
|
203
|
+
/**
|
|
204
|
+
* The fixed words a sealed file is refused with: nothing a library says is
|
|
205
|
+
* passed on. Each but `notDecrypted` is decided from what the message shows
|
|
206
|
+
* before any private key is used; every failure at or after the private-key
|
|
207
|
+
* step is `notDecrypted` alone, so a sender learns nothing from which.
|
|
208
|
+
*/
|
|
209
|
+
export const SEALED_REFUSALS = {
|
|
210
|
+
notEncrypted: 'is not encrypted: deliveries take only OpenPGP messages to the deliveries key',
|
|
211
|
+
passphrase: 'is encrypted with a passphrase, not to the deliveries key',
|
|
212
|
+
notIntegrityProtected: 'is not integrity-protected: turn on the tool\'s integrity check',
|
|
213
|
+
/** The one refusal of every failure at or after the private-key step */
|
|
214
|
+
notDecrypted: 'did not decrypt whole: it is truncated, altered or malformed, or its cipher is not AES',
|
|
215
|
+
unreadable: 'is not an OpenPGP message deliveries can read',
|
|
216
|
+
ocb: 'is encrypted in LibrePGP\'s OCB form (packet 20), which deliveries do not take: encrypt with OpenPGP\'s integrity protection (SEIPD)',
|
|
217
|
+
noKey: 'deliveries have no decryption key yet: an administrator makes it',
|
|
218
|
+
stalled: 'was not decrypted within two rounds: deliveries take a file that decrypts within one; send it smaller, or split it',
|
|
219
|
+
/** Encrypted to other keys: their IDs, and the current deliveries key's */
|
|
220
|
+
otherKeys: (theirs, ours) => `is encrypted to key(s) ${theirs.join(', ') || 'none named'}, not to the deliveries key (${ours.join(', ')})`,
|
|
221
|
+
/** Encrypted only to a key retired before the file was last written: the current key's fingerprint */
|
|
222
|
+
retired: (fingerprint) => `is encrypted only to a retired deliveries key and was written after it was retired: encrypt to the current key (fingerprint ${fingerprint})`,
|
|
223
|
+
/** More recipients than {@link SEALED_MAX_RECIPIENTS} */
|
|
224
|
+
recipients: (count) => `names ${count} recipients: deliveries take a message to at most ${SEALED_MAX_RECIPIENTS}; encrypt to the deliveries key alone`,
|
|
225
|
+
/** A session cipher other than AES, by its name, where the message names it before any key is used */
|
|
226
|
+
cipher: (name) => `uses a cipher deliveries do not take (${name})`,
|
|
227
|
+
};
|
|
228
|
+
/**
|
|
229
|
+
* Thrown by an {@link Unsealer} when the sealed file's own bytes could not
|
|
230
|
+
* be read from storage: no refusal, for the file is not at fault. It stops
|
|
231
|
+
* the sync, whose round is tried again, and names no key or value.
|
|
232
|
+
*/
|
|
233
|
+
export class SealedSourceUnavailable extends Error {
|
|
234
|
+
constructor(cause) {
|
|
235
|
+
super(`a delivered file could not be read from storage (${cause instanceof Error ? cause.name : 'error'}): unavailable; the round is tried again`);
|
|
236
|
+
this.name = 'SealedSourceUnavailable';
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
/** Thrown inside an unseal that its signal stopped: the reader answers `yielded`. */
|
|
240
|
+
export class SealedStopped extends Error {
|
|
241
|
+
constructor() {
|
|
242
|
+
super('stopped at the round\'s signal');
|
|
243
|
+
this.name = 'SealedStopped';
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
/** Thrown by an {@link Unsealer} for a file it refuses: the sync refuses the file with the reason, and goes on. */
|
|
247
|
+
export class UnsealRefusal extends Error {
|
|
248
|
+
reason;
|
|
249
|
+
constructor(reason) {
|
|
250
|
+
super(reason.type === 'unreadable' ? reason.value : reason.type);
|
|
251
|
+
this.name = 'UnsealRefusal';
|
|
252
|
+
this.reason = reason;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
/** A refusal as {@link UnsealRefusal}'s `unreadable` words. */
|
|
256
|
+
export function unsealRefused(words) {
|
|
257
|
+
return new UnsealRefusal(variant('unreadable', words));
|
|
258
|
+
}
|
|
259
|
+
/** A sealed file's plaintext held in memory up to this: 64 MiB; larger, staged whole in the {@link UnsealStore}. */
|
|
260
|
+
export const SEALED_IN_MEMORY_BYTES = 64 * 1024 * 1024;
|
|
261
|
+
/** A sealed file at least this large is looked for in the store before it is decrypted: a smaller one is decrypted again (1 MiB). */
|
|
262
|
+
export const SEALED_FIND_MIN_BYTES = 1024 * 1024;
|
|
263
|
+
/** How many rounds may give one file a fair try and not finish it before it is refused ({@link SEALED_REFUSALS}.stalled). */
|
|
264
|
+
export const SEALED_MAX_ATTEMPTS = 2;
|
|
265
|
+
/**
|
|
266
|
+
* How long a refusal for stalling lasts: two days from when it was made,
|
|
267
|
+
* never moved by a later refusal. After it the file is tried again from
|
|
268
|
+
* nothing, so the rule costs a legitimate file two days at most. A file
|
|
269
|
+
* encrypted again (new bytes, so a new ETag) is a new file at once.
|
|
270
|
+
*/
|
|
271
|
+
export const SEALED_STALL_REFUSAL_MS = 2 * 24 * 60 * 60_000;
|
|
272
|
+
/**
|
|
273
|
+
* The most sealed bytes a file may hold for a plaintext of at most
|
|
274
|
+
* `maxBytes`: an armored message is about 4/3 of its binary form, line ends
|
|
275
|
+
* included under 1.4, and its packets add less than a mebibyte. A file
|
|
276
|
+
* larger is refused `too_large` before any of it is read.
|
|
277
|
+
*
|
|
278
|
+
* @param maxBytes - The most plaintext the file may hold
|
|
279
|
+
* @returns The most sealed bytes it may hold
|
|
280
|
+
*/
|
|
281
|
+
export function sealedMaxBytes(maxBytes) {
|
|
282
|
+
return Math.ceil(maxBytes * 1.4) + 1024 * 1024;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* The most plaintext a sealed reader holds in memory at once, over every
|
|
286
|
+
* file it has unsealed and the sync has not yet released, and every file
|
|
287
|
+
* being decrypted: 256 MiB. A file that would take it past this is staged in
|
|
288
|
+
* the store instead, as one past {@link SEALED_IN_MEMORY_BYTES} is.
|
|
289
|
+
*/
|
|
290
|
+
export const SEALED_HELD_BYTES = 256 * 1024 * 1024;
|
|
291
|
+
/** Chunks of bytes held in memory, from a byte on. */
|
|
292
|
+
function chunksOf(bytes, start = 0) {
|
|
293
|
+
return {
|
|
294
|
+
[Symbol.asyncIterator]() {
|
|
295
|
+
let at = start;
|
|
296
|
+
return {
|
|
297
|
+
next: () => {
|
|
298
|
+
if (at >= bytes.length)
|
|
299
|
+
return Promise.resolve({ value: undefined, done: true });
|
|
300
|
+
const chunk = bytes.subarray(at, Math.min(at + 1024 * 1024, bytes.length));
|
|
301
|
+
at += chunk.length;
|
|
302
|
+
return Promise.resolve({ value: chunk, done: false });
|
|
303
|
+
},
|
|
304
|
+
};
|
|
305
|
+
},
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
/** Chunks joined. */
|
|
309
|
+
function joined(chunks, length) {
|
|
310
|
+
const bytes = new Uint8Array(length);
|
|
311
|
+
let at = 0;
|
|
312
|
+
for (const chunk of chunks) {
|
|
313
|
+
bytes.set(chunk, at);
|
|
314
|
+
at += chunk.length;
|
|
315
|
+
}
|
|
316
|
+
return bytes;
|
|
317
|
+
}
|
|
318
|
+
/** Thrown inside a count that passed its limit. */
|
|
319
|
+
class OverLimit extends Error {
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* The reader of a sealed area: `list` and `stat` are the inner reader's;
|
|
323
|
+
* `unseal` opens a file; `read`, `readRange` and `open` give only a file
|
|
324
|
+
* `unseal` answered, as its plaintext, until the sync `release`s it, and
|
|
325
|
+
* refuse any other as unreadable.
|
|
326
|
+
*
|
|
327
|
+
* `unseal`, for a file listed with its key and ETag:
|
|
328
|
+
* 1. sniffs its first {@link OPENPGP_SNIFF_BYTES} by a ranged read: a file
|
|
329
|
+
* that is not an encrypted OpenPGP message is refused
|
|
330
|
+
* ({@link SEALED_REFUSALS}.notEncrypted) and never downloaded;
|
|
331
|
+
* 2. finds its plaintext staged by an earlier round, for a file of at least
|
|
332
|
+
* {@link SEALED_FIND_MIN_BYTES} (a typed intake resumed);
|
|
333
|
+
* 3. else decrypts it as a stream, counting the plaintext: past `maxBytes`
|
|
334
|
+
* it stops and is refused `too_large` (its size given as one past the
|
|
335
|
+
* limit: the rest is never decompressed). Held in memory while the file
|
|
336
|
+
* is within the in-memory bytes and everything held stays within the held
|
|
337
|
+
* bytes; past either, staged whole in the store, completed only when the
|
|
338
|
+
* decryption ended cleanly and aborted otherwise.
|
|
339
|
+
*
|
|
340
|
+
* What it holds in memory is therefore at most the held bytes, plus the
|
|
341
|
+
* chunk each decryption under way has in hand: never what a round has read
|
|
342
|
+
* and the sync has released.
|
|
343
|
+
*
|
|
344
|
+
* A file that may take long to decrypt (sealed at least
|
|
345
|
+
* {@link SEALED_FIND_MIN_BYTES}, or whose plaintext may pass
|
|
346
|
+
* {@link SEALED_IN_MEMORY_BYTES}) has a record in the store
|
|
347
|
+
* ({@link UnsealAttempts}), written before its decryption begins and cleared
|
|
348
|
+
* once it ends, so a process that died while it ran is counted. A stop at the
|
|
349
|
+
* round's signal counts only when the file's own unseal ran for at least
|
|
350
|
+
* half of the round (`roundMs`): a file cut off because it started late is
|
|
351
|
+
* not counted, its record put back as it was, and the next round, which
|
|
352
|
+
* resumes where this one stopped, tries it again. A file two rounds gave a
|
|
353
|
+
* fair try and neither finished is refused `stalled` from the third, so the
|
|
354
|
+
* files after it are not held up by it for ever; the refusal lasts
|
|
355
|
+
* {@link SEALED_STALL_REFUSAL_MS} from when it was made, is never renewed,
|
|
356
|
+
* and then the file is tried again from nothing.
|
|
357
|
+
*
|
|
358
|
+
* The staged key is the SHA-256 of the location, key and ETag. `close`
|
|
359
|
+
* removes every file this reader staged, but those it is told to keep (a
|
|
360
|
+
* typed intake left under way, which the next round resumes); the store's
|
|
361
|
+
* own expiry takes any left.
|
|
362
|
+
*
|
|
363
|
+
* @param inner - The area's reader, of sealed bytes
|
|
364
|
+
* @param unsealer - What decrypts
|
|
365
|
+
* @param store - Where large plaintext is staged
|
|
366
|
+
* @param options - The area's location, and how much is held in memory
|
|
367
|
+
* @returns The reader
|
|
368
|
+
*/
|
|
369
|
+
export function unsealingReader(inner, unsealer, store, options) {
|
|
370
|
+
const inMemory = options.inMemoryBytes ?? SEALED_IN_MEMORY_BYTES;
|
|
371
|
+
const budget = options.heldBytes ?? SEALED_HELD_BYTES;
|
|
372
|
+
const now = options.now ?? Date.now;
|
|
373
|
+
const held = new Map();
|
|
374
|
+
const staged = new Set();
|
|
375
|
+
/** The bytes held in memory: every held file's, and every decryption's under way */
|
|
376
|
+
let holding = 0;
|
|
377
|
+
const idOf = (object) => `${object.key}\u0000${object.etag}`;
|
|
378
|
+
const sealKeyOf = (object) => createHash('sha256').update(`${options.location}\u0000${object.key}\u0000${object.etag}`).digest('hex');
|
|
379
|
+
const plaintextOf = (object) => {
|
|
380
|
+
const found = held.get(idOf(object));
|
|
381
|
+
if (found === undefined)
|
|
382
|
+
throw new FilesUnreadableError(object.key, 'is sealed: it is read only once unsealed');
|
|
383
|
+
return found;
|
|
384
|
+
};
|
|
385
|
+
const release = (object) => {
|
|
386
|
+
const id = idOf(object);
|
|
387
|
+
const kept = held.get(id);
|
|
388
|
+
if (kept === undefined)
|
|
389
|
+
return;
|
|
390
|
+
held.delete(id);
|
|
391
|
+
if ('bytes' in kept)
|
|
392
|
+
holding -= kept.bytes.length;
|
|
393
|
+
};
|
|
394
|
+
const answer = (object, size, kept) => {
|
|
395
|
+
release(object);
|
|
396
|
+
held.set(idOf(object), kept);
|
|
397
|
+
return { object: { key: object.key, etag: object.etag, modified: object.modified, size } };
|
|
398
|
+
};
|
|
399
|
+
const refusedWith = (err) => {
|
|
400
|
+
if (err instanceof UnsealRefusal)
|
|
401
|
+
return { refused: err.reason };
|
|
402
|
+
if (err instanceof FilesUnreadableError)
|
|
403
|
+
return { refused: variant('unreadable', err.reason) };
|
|
404
|
+
throw err;
|
|
405
|
+
};
|
|
406
|
+
/** A file decrypted, counted, held or staged: its answer; a refusal as one; anything else thrown. */
|
|
407
|
+
const decrypted = async (object, sealKey, maxBytes, signal, aborted, opened) => {
|
|
408
|
+
let plain;
|
|
409
|
+
const chunks = [];
|
|
410
|
+
let size = 0;
|
|
411
|
+
/** This file's bytes counted in what the reader holds, while they are held */
|
|
412
|
+
let mine = 0;
|
|
413
|
+
const counted = (chunk) => {
|
|
414
|
+
if (aborted())
|
|
415
|
+
throw new SealedStopped();
|
|
416
|
+
size += chunk.length;
|
|
417
|
+
if (size > maxBytes)
|
|
418
|
+
throw new OverLimit();
|
|
419
|
+
return chunk;
|
|
420
|
+
};
|
|
421
|
+
try {
|
|
422
|
+
plain = unsealer.plaintext(object, await inner.open(object), signal, opened)[Symbol.asyncIterator]();
|
|
423
|
+
for (;;) {
|
|
424
|
+
const next = await plain.next();
|
|
425
|
+
if (next.done === true) {
|
|
426
|
+
const bytes = joined(chunks, size);
|
|
427
|
+
chunks.length = 0;
|
|
428
|
+
// Counted as the file held from here: its count moves to the held file
|
|
429
|
+
holding -= mine;
|
|
430
|
+
mine = 0;
|
|
431
|
+
const answered = answer(object, size, { bytes });
|
|
432
|
+
holding += bytes.length;
|
|
433
|
+
return answered;
|
|
434
|
+
}
|
|
435
|
+
chunks.push(counted(next.value));
|
|
436
|
+
holding += next.value.length;
|
|
437
|
+
mine += next.value.length;
|
|
438
|
+
if (size > inMemory || holding > budget)
|
|
439
|
+
break;
|
|
440
|
+
}
|
|
441
|
+
// Past what one file, or every file, may hold in memory: staged whole, the chunks so far first
|
|
442
|
+
holding -= mine;
|
|
443
|
+
mine = 0;
|
|
444
|
+
const from = plain;
|
|
445
|
+
const rest = {
|
|
446
|
+
async *[Symbol.asyncIterator]() {
|
|
447
|
+
for (const chunk of chunks.splice(0))
|
|
448
|
+
yield chunk;
|
|
449
|
+
for (;;) {
|
|
450
|
+
const next = await from.next();
|
|
451
|
+
if (next.done === true)
|
|
452
|
+
return;
|
|
453
|
+
yield counted(next.value);
|
|
454
|
+
}
|
|
455
|
+
},
|
|
456
|
+
};
|
|
457
|
+
staged.add(sealKey);
|
|
458
|
+
const written = await store.write(sealKey, rest, signal);
|
|
459
|
+
if ('aborted' in written)
|
|
460
|
+
return { yielded: true };
|
|
461
|
+
return answer(object, written.size, { staged: sealKey, reader: written.reader });
|
|
462
|
+
}
|
|
463
|
+
catch (err) {
|
|
464
|
+
holding -= mine;
|
|
465
|
+
mine = 0;
|
|
466
|
+
chunks.length = 0;
|
|
467
|
+
await plain?.return?.();
|
|
468
|
+
if (err instanceof OverLimit)
|
|
469
|
+
return { refused: variant('too_large', { size: BigInt(maxBytes) + 1n, limit: BigInt(maxBytes) }) };
|
|
470
|
+
if (err instanceof SealedStopped || (aborted() && !(err instanceof UnsealRefusal) && !(err instanceof SealedSourceUnavailable)))
|
|
471
|
+
return { yielded: true };
|
|
472
|
+
return refusedWith(err);
|
|
473
|
+
}
|
|
474
|
+
};
|
|
475
|
+
return {
|
|
476
|
+
list: (prefix, listOptions) => inner.list(prefix, listOptions),
|
|
477
|
+
stat: (key) => inner.stat(key),
|
|
478
|
+
...(inner.folders !== undefined && { folders: (prefix) => inner.folders(prefix) }),
|
|
479
|
+
async unseal(object, { maxBytes, signal, roundMs, opened }) {
|
|
480
|
+
release(object);
|
|
481
|
+
// Asked again after each await: the signal may fire at any
|
|
482
|
+
const aborted = () => signal?.aborted === true;
|
|
483
|
+
if (aborted())
|
|
484
|
+
return { yielded: true };
|
|
485
|
+
let sealKey;
|
|
486
|
+
try {
|
|
487
|
+
// 1. Sniffed before any other byte is read
|
|
488
|
+
const head = object.size === 0 ? new Uint8Array(0) : await inner.readRange(object, 0, Math.min(object.size, OPENPGP_SNIFF_BYTES));
|
|
489
|
+
if (!isOpenPgpMessage(head))
|
|
490
|
+
return { refused: variant('unreadable', SEALED_REFUSALS.notEncrypted) };
|
|
491
|
+
// 2. Larger sealed than any plaintext within the limit could be: refused unread
|
|
492
|
+
if (object.size > sealedMaxBytes(maxBytes))
|
|
493
|
+
return { refused: variant('too_large', { size: BigInt(object.size), limit: BigInt(maxBytes) }) };
|
|
494
|
+
// 3. Staged by an earlier round
|
|
495
|
+
sealKey = sealKeyOf(object);
|
|
496
|
+
if (object.size >= SEALED_FIND_MIN_BYTES) {
|
|
497
|
+
const found = await store.find(sealKey);
|
|
498
|
+
if (found !== null) {
|
|
499
|
+
if (found.size > maxBytes)
|
|
500
|
+
return { refused: variant('too_large', { size: BigInt(found.size), limit: BigInt(maxBytes) }) };
|
|
501
|
+
staged.add(sealKey);
|
|
502
|
+
return answer(object, found.size, { staged: sealKey, reader: found.reader });
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
catch (err) {
|
|
507
|
+
return refusedWith(err);
|
|
508
|
+
}
|
|
509
|
+
// 4. A file that may take long to decrypt (a large one, or one whose plaintext may be large) is
|
|
510
|
+
// recorded as begun before it is, and the record cleared once it ends: a file two rounds gave a
|
|
511
|
+
// fair try and neither finished is refused for a while, so the files after it are not held up by it
|
|
512
|
+
const tracked = maxBytes > SEALED_IN_MEMORY_BYTES || object.size >= SEALED_FIND_MIN_BYTES;
|
|
513
|
+
let before = NO_UNSEAL_ATTEMPTS;
|
|
514
|
+
if (tracked) {
|
|
515
|
+
before = await store.attempts(sealKey);
|
|
516
|
+
if (before.refusedAt !== null && now() - before.refusedAt < SEALED_STALL_REFUSAL_MS) {
|
|
517
|
+
// Refused still: the record is not written, so its end never moves
|
|
518
|
+
return { refused: variant('unreadable', SEALED_REFUSALS.stalled) };
|
|
519
|
+
}
|
|
520
|
+
// A refusal whose time is over: the file is tried again from nothing
|
|
521
|
+
if (before.refusedAt !== null)
|
|
522
|
+
before = NO_UNSEAL_ATTEMPTS;
|
|
523
|
+
if (before.count >= SEALED_MAX_ATTEMPTS) {
|
|
524
|
+
// Two fair tries, neither finished: refused from now, for SEALED_STALL_REFUSAL_MS
|
|
525
|
+
await store.attempted(sealKey, { count: before.count, refusedAt: now() });
|
|
526
|
+
return { refused: variant('unreadable', SEALED_REFUSALS.stalled) };
|
|
527
|
+
}
|
|
528
|
+
await store.attempted(sealKey, { count: before.count + 1, refusedAt: null });
|
|
529
|
+
}
|
|
530
|
+
const began = now();
|
|
531
|
+
let outcome;
|
|
532
|
+
try {
|
|
533
|
+
outcome = await decrypted(object, sealKey, maxBytes, signal, aborted, opened);
|
|
534
|
+
}
|
|
535
|
+
catch (err) {
|
|
536
|
+
if (tracked)
|
|
537
|
+
await store.attempted(sealKey, NO_UNSEAL_ATTEMPTS).catch(() => undefined);
|
|
538
|
+
throw err;
|
|
539
|
+
}
|
|
540
|
+
if (tracked) {
|
|
541
|
+
if (!('yielded' in outcome))
|
|
542
|
+
await store.attempted(sealKey, NO_UNSEAL_ATTEMPTS);
|
|
543
|
+
// Stopped by the round's signal: counted only after a fair try, else the record as it was
|
|
544
|
+
else if (roundMs === undefined || now() - began < roundMs / 2)
|
|
545
|
+
await store.attempted(sealKey, before);
|
|
546
|
+
}
|
|
547
|
+
return outcome;
|
|
548
|
+
},
|
|
549
|
+
async read(object) {
|
|
550
|
+
const kept = plaintextOf(object);
|
|
551
|
+
return 'bytes' in kept ? kept.bytes : kept.reader.read(object);
|
|
552
|
+
},
|
|
553
|
+
async readRange(object, start, end) {
|
|
554
|
+
const kept = plaintextOf(object);
|
|
555
|
+
return 'bytes' in kept ? kept.bytes.subarray(start, end) : kept.reader.readRange(object, start, end);
|
|
556
|
+
},
|
|
557
|
+
async open(object, openOptions) {
|
|
558
|
+
const kept = plaintextOf(object);
|
|
559
|
+
return 'bytes' in kept ? chunksOf(kept.bytes, openOptions?.start ?? 0) : kept.reader.open(object, openOptions);
|
|
560
|
+
},
|
|
561
|
+
release,
|
|
562
|
+
holding: () => ({ files: held.size, bytes: holding }),
|
|
563
|
+
async close(keep = []) {
|
|
564
|
+
const keeping = new Set(keep.map(sealKeyOf));
|
|
565
|
+
held.clear();
|
|
566
|
+
holding = 0;
|
|
567
|
+
const removing = [...staged].filter((key) => !keeping.has(key));
|
|
568
|
+
staged.clear();
|
|
569
|
+
await Promise.all(removing.map((key) => store.remove(key)));
|
|
570
|
+
},
|
|
571
|
+
};
|
|
572
|
+
}
|
|
573
|
+
//# sourceMappingURL=sealed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sealed.js","sourceRoot":"","sources":["../../../src/sync/sealed.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,oBAAoB,EAA0G,MAAM,aAAa,CAAC;AAE3J,0EAA0E;AAC1E,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAEtC,uCAAuC;AACvC,MAAM,KAAK,GAAG,6BAA6B,CAAC;AAE5C,uHAAuH;AACvH,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAEzC,kGAAkG;AAClG,MAAM,UAAU,GAAG,EAAE,CAAC;AAEtB,yFAAyF;AACzF,MAAM,GAAG,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAU,CAAC;AAExC;;;;GAIG;AACH,SAAS,QAAQ,CAAC,IAAgB,EAAE,EAAU;IAC5C,MAAM,KAAK,GAAG,IAAI,CAAC,EAAE,CAA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,KAAK,EAAE,CAAC;YACf,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAC9D,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
import { ArrayType, BlobType, FloatType, IntegerType, StringType, StructType } from '@elaraai/east';
|
|
16
16
|
import { type FilesManifest } from '../src/index.js';
|
|
17
17
|
/** Where the partners' files are: each workspace binds it to a bucket and prefix. */
|
|
18
|
-
export declare const upload: import("../src/authoring.js").FilesSource
|
|
18
|
+
export declare const upload: import("../src/authoring.js").FilesSource<"upload">;
|
|
19
19
|
/** One file: today's exchange rates. */
|
|
20
20
|
export declare const rates: import("@elaraai/e3").DatasetDef<BlobType, [import("@elaraai/east").variant<"field", "inputs">, import("@elaraai/east").variant<"field", "rates">]>;
|
|
21
21
|
/** The newest stock snapshot: the snapshots are named by their date, so the greatest key is the latest. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orders.examples.d.ts","sourceRoot":"","sources":["../../test/orders.examples.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;GASG;AAEH,OAAO,EAAQ,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAiB,MAAM,eAAe,CAAC;AAEzH,OAAO,EAA4C,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAM/F,qFAAqF;AACrF,eAAO,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"orders.examples.d.ts","sourceRoot":"","sources":["../../test/orders.examples.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;GASG;AAEH,OAAO,EAAQ,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAiB,MAAM,eAAe,CAAC;AAEzH,OAAO,EAA4C,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAM/F,qFAAqF;AACrF,eAAO,MAAM,MAAM,qDAAyB,CAAC;AAE7C,wCAAwC;AACxC,eAAO,MAAM,KAAK,qJAA8C,CAAC;AACjE,2GAA2G;AAC3G,eAAO,MAAM,KAAK,qJAAkE,CAAC;AACrF,2CAA2C;AAC3C,eAAO,MAAM,MAAM,oMAAoE,CAAC;AACxF,oEAAoE;AACpE,eAAO,MAAM,UAAU;;;;mHAA0E,CAAC;AAElG,4CAA4C;AAC5C,QAAA,MAAM,QAAQ,EAAE,aAAwC,CAAC;AACzD,eAAe,QAAQ,CAAC;AAIxB,eAAO,MAAM,IAAI;;;EAAwD,CAAC;AAC1E,eAAO,MAAM,SAAS;;;EAAoD,CAAC;AAC3E,eAAO,MAAM,KAAK;;;;;EAA2F,CAAC;AAE9G,qCAAqC;AACrC,eAAO,MAAM,WAAW;;;IACuB,CAAC;AAEhD,eAAO,MAAM,WAAW;;;IAC4B,CAAC;AAErD,oDAAoD;AACpD,eAAO,MAAM,YAAY;;;;;IAMvB,CAAC;AAEH,8DAA8D;AAC9D,eAAO,MAAM,UAAU;;;;kBAA4E,CAAC;AAEpG,eAAO,MAAM,SAAS;;;qKAAkE,CAAC;AACzF,eAAO,MAAM,WAAW;;;uKAAoE,CAAC;AAC7F,eAAO,MAAM,SAAS;;;;;qKAAoE,CAAC;AAC3F,eAAO,MAAM,cAAc,mNAA4E,CAAC;AAExG,eAAO,MAAM,aAAa,2DAAmF,CAAC;AAQ9G,gFAAgF;AAChF,eAAO,MAAM,WAAW,EAAE,WAAW,CAAC,MAAM,EAAE,UAAU,CAUtD,CAAC"}
|
|
@@ -18,7 +18,7 @@ export declare const Price: StructType<{
|
|
|
18
18
|
}>;
|
|
19
19
|
export declare const PriceBook: DictType<StringType, FloatType>;
|
|
20
20
|
/** Where the partners' files are: each workspace binds it to a bucket and prefix. */
|
|
21
|
-
export declare const upload: import("../src/authoring.js").FilesSource
|
|
21
|
+
export declare const upload: import("../src/authoring.js").FilesSource<"upload">;
|
|
22
22
|
/** The price list, as the beast2 value it holds: an input of `Array<Price>`. */
|
|
23
23
|
export declare const prices: import("@elaraai/e3").DatasetDef<ArrayType<StructType<{
|
|
24
24
|
readonly sku: StringType;
|
|
@@ -102,7 +102,7 @@ export declare const CustomerBookV2: DictType<StringType, StructType<{
|
|
|
102
102
|
* under `--schema reset` it unassigns it, pending again until the new
|
|
103
103
|
* version's file is its first state.
|
|
104
104
|
*/
|
|
105
|
-
export declare const uploadV2: import("../src/authoring.js").FilesSource
|
|
105
|
+
export declare const uploadV2: import("../src/authoring.js").FilesSource<"upload">;
|
|
106
106
|
export declare const customersV2: import("@elaraai/e3").RecordDef<DictType<StringType, StructType<{
|
|
107
107
|
readonly name: StringType;
|
|
108
108
|
readonly tier: IntegerType;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typed.examples.d.ts","sourceRoot":"","sources":["../../test/typed.examples.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;GAOG;AAEH,OAAO,EAAQ,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAmB,MAAM,eAAe,CAAC;AAE3H,OAAO,EAAS,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAM5D,eAAO,MAAM,KAAK;;;EAAoD,CAAC;AACvE,eAAO,MAAM,SAAS,iCAAkC,CAAC;AAEzD,qFAAqF;AACrF,eAAO,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"typed.examples.d.ts","sourceRoot":"","sources":["../../test/typed.examples.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;GAOG;AAEH,OAAO,EAAQ,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAmB,MAAM,eAAe,CAAC;AAE3H,OAAO,EAAS,KAAK,aAAa,EAAE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