@telecrypt-io/storage 0.5.30 → 0.5.31
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.
|
@@ -132,7 +132,7 @@ function matrixRequestTimeout(options) {
|
|
|
132
132
|
const value = options?.timeoutMs ?? options?.localTimeoutMs ?? MATRIX_HTTP_TIMEOUT_MS;
|
|
133
133
|
if (!Number.isFinite(value) || value <= 0)
|
|
134
134
|
throw new Error("invalid Matrix request timeout");
|
|
135
|
-
return
|
|
135
|
+
return value;
|
|
136
136
|
}
|
|
137
137
|
function matrixRequestSignal(options) {
|
|
138
138
|
return options?.signal ?? options?.abortSignal;
|
package/dist/core/index.d.ts
CHANGED
package/dist/core/index.js
CHANGED
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
import { TeleCryptIOStorage } from "../TeleCryptIOStorage.js";
|
|
14
14
|
import type { DownloadedFile, FolderDetails, FolderInfo, FileDetails, FileInfo, VaultDetails, VaultInfo, DeleteResult, JoinResult, Member, RecoveryRestore, RecoverySetup, RenameResult, ShareResult, UnshareResult } from "./types.js";
|
|
15
15
|
export interface OperationOptions {
|
|
16
|
-
/** Cancels
|
|
16
|
+
/** Cancels waits and rate-limit backoff before the next mutation. */
|
|
17
17
|
signal?: AbortSignal;
|
|
18
|
-
/**
|
|
18
|
+
/** Optional wall-clock budget supplied by the caller. */
|
|
19
19
|
timeoutMs?: number;
|
|
20
20
|
}
|
|
21
21
|
export declare function createVault(storage: TeleCryptIOStorage, name: string, options?: OperationOptions): Promise<VaultInfo>;
|
package/dist/core/operations.js
CHANGED
|
@@ -31,13 +31,10 @@ const RATE_LIMIT_DEFAULT_DELAY_MS = 15_000;
|
|
|
31
31
|
// JavaScript timers cannot represent a longer delay reliably. The operation's
|
|
32
32
|
// own deadline remains the authority that stops retrying.
|
|
33
33
|
const MAX_TIMER_DELAY_MS = 2_147_483_647;
|
|
34
|
-
const MAX_DELETION_ROOMS = 4096;
|
|
35
|
-
const MAX_DELETION_DEPTH = 128;
|
|
36
|
-
const DEFAULT_MUTATION_TIMEOUT_MS = 5 * 60_000;
|
|
37
|
-
const MAX_MUTATION_TIMEOUT_MS = 15 * 60_000;
|
|
38
34
|
function createOperationDeadline(options) {
|
|
39
|
-
const timeoutMs = options?.timeoutMs
|
|
40
|
-
if (
|
|
35
|
+
const timeoutMs = options?.timeoutMs;
|
|
36
|
+
if (timeoutMs !== undefined &&
|
|
37
|
+
(!Number.isSafeInteger(timeoutMs) || timeoutMs <= 0 || timeoutMs > MAX_TIMER_DELAY_MS)) {
|
|
41
38
|
throw new StorageError("invalid operation timeout");
|
|
42
39
|
}
|
|
43
40
|
const controller = new AbortController();
|
|
@@ -45,11 +42,14 @@ function createOperationDeadline(options) {
|
|
|
45
42
|
options?.signal?.addEventListener("abort", onAbort, { once: true });
|
|
46
43
|
if (options?.signal?.aborted)
|
|
47
44
|
onAbort();
|
|
48
|
-
const timer =
|
|
45
|
+
const timer = timeoutMs === undefined
|
|
46
|
+
? undefined
|
|
47
|
+
: setTimeout(() => controller.abort(new Error("operation timed out")), timeoutMs);
|
|
49
48
|
return {
|
|
50
49
|
signal: controller.signal,
|
|
51
50
|
close: () => {
|
|
52
|
-
|
|
51
|
+
if (timer !== undefined)
|
|
52
|
+
clearTimeout(timer);
|
|
53
53
|
options?.signal?.removeEventListener("abort", onAbort);
|
|
54
54
|
},
|
|
55
55
|
};
|
|
@@ -308,20 +308,16 @@ function activeTreeDirectories(client, tree) {
|
|
|
308
308
|
return child;
|
|
309
309
|
});
|
|
310
310
|
}
|
|
311
|
-
function snapshotTreeSpaces(root,
|
|
311
|
+
function snapshotTreeSpaces(root, activeRelationClient) {
|
|
312
312
|
const spaces = [];
|
|
313
313
|
const seen = new Set();
|
|
314
|
-
const pending = [
|
|
314
|
+
const pending = [root];
|
|
315
315
|
while (pending.length > 0) {
|
|
316
|
-
const
|
|
317
|
-
if (!
|
|
316
|
+
const tree = pending.pop();
|
|
317
|
+
if (!tree)
|
|
318
318
|
continue;
|
|
319
|
-
const { tree, depth } = next;
|
|
320
319
|
if (seen.has(tree.id))
|
|
321
320
|
continue;
|
|
322
|
-
if (depth > MAX_DELETION_DEPTH || spaces.length >= MAX_DELETION_ROOMS) {
|
|
323
|
-
throw new StorageError(tooLargeMessage);
|
|
324
|
-
}
|
|
325
321
|
seen.add(tree.id);
|
|
326
322
|
spaces.push(tree);
|
|
327
323
|
let children;
|
|
@@ -335,11 +331,8 @@ function snapshotTreeSpaces(root, tooLargeMessage = "storage tree is too large",
|
|
|
335
331
|
throw error;
|
|
336
332
|
throw new StorageError("could not enumerate storage space descendants safely", { cause: error });
|
|
337
333
|
}
|
|
338
|
-
if (children.length > MAX_DELETION_ROOMS) {
|
|
339
|
-
throw new StorageError(tooLargeMessage);
|
|
340
|
-
}
|
|
341
334
|
for (const child of children)
|
|
342
|
-
pending.push(
|
|
335
|
+
pending.push(child);
|
|
343
336
|
}
|
|
344
337
|
return spaces;
|
|
345
338
|
}
|
|
@@ -1112,7 +1105,7 @@ async function deleteTree(storage, treeId, options) {
|
|
|
1112
1105
|
// part of this operation and must not block deletion merely because
|
|
1113
1106
|
// their membership is not joined.
|
|
1114
1107
|
await refreshDeletionRooms(storage, tree.id, operation.signal);
|
|
1115
|
-
const spaces = snapshotTreeSpaces(tree,
|
|
1108
|
+
const spaces = snapshotTreeSpaces(tree, client);
|
|
1116
1109
|
const activeSpaces = spaces.filter((space) => !removedRooms.has(space.id));
|
|
1117
1110
|
const ids = new Set(activeSpaces.map((space) => space.id));
|
|
1118
1111
|
if (!ids.has(tree.id)) {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
/** Shared name contract used by SDK inputs and remote projections. */
|
|
2
|
-
export declare const MAX_NAME_LENGTH = 512;
|
|
3
2
|
export declare function isValidName(value: unknown): value is string;
|
|
4
3
|
export declare function validateName(value: unknown, label: string): asserts value is string;
|
package/dist/core/validation.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
/** Shared name contract used by SDK inputs and remote projections. */
|
|
2
|
-
export const MAX_NAME_LENGTH = 512;
|
|
3
2
|
export function isValidName(value) {
|
|
4
3
|
return (typeof value === "string" &&
|
|
5
4
|
value.length > 0 &&
|
|
6
|
-
value.length <= MAX_NAME_LENGTH &&
|
|
7
5
|
!/[\u0000-\u001f\u007f]/.test(value));
|
|
8
6
|
}
|
|
9
7
|
export function validateName(value, label) {
|