@teepin/sdk 0.2.0 → 0.3.0-rc.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.
Files changed (134) hide show
  1. package/README.md +181 -396
  2. package/dist/cjs/client.js +42 -4
  3. package/dist/cjs/client.js.map +1 -1
  4. package/dist/cjs/direct/bytes.js +50 -0
  5. package/dist/cjs/direct/bytes.js.map +1 -0
  6. package/dist/cjs/direct/common.js +167 -0
  7. package/dist/cjs/direct/common.js.map +1 -0
  8. package/dist/cjs/direct/downloads-plan.js +127 -0
  9. package/dist/cjs/direct/downloads-plan.js.map +1 -0
  10. package/dist/cjs/direct/engine.js +405 -0
  11. package/dist/cjs/direct/engine.js.map +1 -0
  12. package/dist/cjs/direct/formats.js +44 -0
  13. package/dist/cjs/direct/formats.js.map +1 -0
  14. package/dist/cjs/direct/hpke.js +275 -0
  15. package/dist/cjs/direct/hpke.js.map +1 -0
  16. package/dist/cjs/direct/journal.js +80 -0
  17. package/dist/cjs/direct/journal.js.map +1 -0
  18. package/dist/cjs/direct/large.js +850 -0
  19. package/dist/cjs/direct/large.js.map +1 -0
  20. package/dist/cjs/direct/reads.js +1314 -0
  21. package/dist/cjs/direct/reads.js.map +1 -0
  22. package/dist/cjs/direct/sha256.js +122 -0
  23. package/dist/cjs/direct/sha256.js.map +1 -0
  24. package/dist/cjs/direct/tws1.js +480 -0
  25. package/dist/cjs/direct/tws1.js.map +1 -0
  26. package/dist/cjs/direct/uploads.js +1706 -0
  27. package/dist/cjs/direct/uploads.js.map +1 -0
  28. package/dist/cjs/errors.js +70 -13
  29. package/dist/cjs/errors.js.map +1 -1
  30. package/dist/cjs/index.js +5 -1
  31. package/dist/cjs/index.js.map +1 -1
  32. package/dist/cjs/links.js +195 -0
  33. package/dist/cjs/links.js.map +1 -0
  34. package/dist/cjs/node/downloads.js +835 -0
  35. package/dist/cjs/node/downloads.js.map +1 -0
  36. package/dist/cjs/node/journal.js +841 -0
  37. package/dist/cjs/node/journal.js.map +1 -0
  38. package/dist/cjs/node/uploads.js +219 -0
  39. package/dist/cjs/node/uploads.js.map +1 -0
  40. package/dist/cjs/node.js +26 -39
  41. package/dist/cjs/node.js.map +1 -1
  42. package/dist/cjs/storage.js +214 -184
  43. package/dist/cjs/storage.js.map +1 -1
  44. package/dist/cjs/transfer.js +18 -351
  45. package/dist/cjs/transfer.js.map +1 -1
  46. package/dist/esm/client.js +42 -4
  47. package/dist/esm/client.js.map +1 -1
  48. package/dist/esm/direct/bytes.js +42 -0
  49. package/dist/esm/direct/bytes.js.map +1 -0
  50. package/dist/esm/direct/common.js +155 -0
  51. package/dist/esm/direct/common.js.map +1 -0
  52. package/dist/esm/direct/downloads-plan.js +117 -0
  53. package/dist/esm/direct/downloads-plan.js.map +1 -0
  54. package/dist/esm/direct/engine.js +385 -0
  55. package/dist/esm/direct/engine.js.map +1 -0
  56. package/dist/esm/direct/formats.js +40 -0
  57. package/dist/esm/direct/formats.js.map +1 -0
  58. package/dist/esm/direct/hpke.js +262 -0
  59. package/dist/esm/direct/hpke.js.map +1 -0
  60. package/dist/esm/direct/journal.js +75 -0
  61. package/dist/esm/direct/journal.js.map +1 -0
  62. package/dist/esm/direct/large.js +816 -0
  63. package/dist/esm/direct/large.js.map +1 -0
  64. package/dist/esm/direct/reads.js +1275 -0
  65. package/dist/esm/direct/reads.js.map +1 -0
  66. package/dist/esm/direct/sha256.js +118 -0
  67. package/dist/esm/direct/sha256.js.map +1 -0
  68. package/dist/esm/direct/tws1.js +460 -0
  69. package/dist/esm/direct/tws1.js.map +1 -0
  70. package/dist/esm/direct/uploads.js +1660 -0
  71. package/dist/esm/direct/uploads.js.map +1 -0
  72. package/dist/esm/errors.js +64 -11
  73. package/dist/esm/errors.js.map +1 -1
  74. package/dist/esm/index.js +1 -0
  75. package/dist/esm/index.js.map +1 -1
  76. package/dist/esm/links.js +189 -0
  77. package/dist/esm/links.js.map +1 -0
  78. package/dist/esm/node/downloads.js +829 -0
  79. package/dist/esm/node/downloads.js.map +1 -0
  80. package/dist/esm/node/journal.js +824 -0
  81. package/dist/esm/node/journal.js.map +1 -0
  82. package/dist/esm/node/uploads.js +187 -0
  83. package/dist/esm/node/uploads.js.map +1 -0
  84. package/dist/esm/node.js +17 -14
  85. package/dist/esm/node.js.map +1 -1
  86. package/dist/esm/storage.js +214 -184
  87. package/dist/esm/storage.js.map +1 -1
  88. package/dist/esm/transfer.js +19 -349
  89. package/dist/esm/transfer.js.map +1 -1
  90. package/dist/types/client.d.ts +45 -4
  91. package/dist/types/client.d.ts.map +1 -1
  92. package/dist/types/direct/bytes.d.ts +11 -0
  93. package/dist/types/direct/bytes.d.ts.map +1 -0
  94. package/dist/types/direct/common.d.ts +47 -0
  95. package/dist/types/direct/common.d.ts.map +1 -0
  96. package/dist/types/direct/downloads-plan.d.ts +75 -0
  97. package/dist/types/direct/downloads-plan.d.ts.map +1 -0
  98. package/dist/types/direct/engine.d.ts +191 -0
  99. package/dist/types/direct/engine.d.ts.map +1 -0
  100. package/dist/types/direct/formats.d.ts +9 -0
  101. package/dist/types/direct/formats.d.ts.map +1 -0
  102. package/dist/types/direct/hpke.d.ts +55 -0
  103. package/dist/types/direct/hpke.d.ts.map +1 -0
  104. package/dist/types/direct/journal.d.ts +55 -0
  105. package/dist/types/direct/journal.d.ts.map +1 -0
  106. package/dist/types/direct/large.d.ts +170 -0
  107. package/dist/types/direct/large.d.ts.map +1 -0
  108. package/dist/types/direct/reads.d.ts +306 -0
  109. package/dist/types/direct/reads.d.ts.map +1 -0
  110. package/dist/types/direct/sha256.d.ts +16 -0
  111. package/dist/types/direct/sha256.d.ts.map +1 -0
  112. package/dist/types/direct/tws1.d.ts +157 -0
  113. package/dist/types/direct/tws1.d.ts.map +1 -0
  114. package/dist/types/direct/uploads.d.ts +461 -0
  115. package/dist/types/direct/uploads.d.ts.map +1 -0
  116. package/dist/types/errors.d.ts +47 -8
  117. package/dist/types/errors.d.ts.map +1 -1
  118. package/dist/types/index.d.ts +1 -0
  119. package/dist/types/index.d.ts.map +1 -1
  120. package/dist/types/links.d.ts +86 -0
  121. package/dist/types/links.d.ts.map +1 -0
  122. package/dist/types/node/downloads.d.ts +73 -0
  123. package/dist/types/node/downloads.d.ts.map +1 -0
  124. package/dist/types/node/journal.d.ts +162 -0
  125. package/dist/types/node/journal.d.ts.map +1 -0
  126. package/dist/types/node/uploads.d.ts +86 -0
  127. package/dist/types/node/uploads.d.ts.map +1 -0
  128. package/dist/types/node.d.ts +4 -2
  129. package/dist/types/node.d.ts.map +1 -1
  130. package/dist/types/storage.d.ts +107 -64
  131. package/dist/types/storage.d.ts.map +1 -1
  132. package/dist/types/transfer.d.ts +14 -23
  133. package/dist/types/transfer.d.ts.map +1 -1
  134. package/package.json +8 -5
@@ -0,0 +1,75 @@
1
+ import { TeepinError } from '../errors.js';
2
+ import type { StorageObject } from '../storage.js';
3
+ /** A download is written into its target's path with this added, and renamed into place only when whole. */
4
+ export declare const PART_SUFFIX = ".teepin-part";
5
+ /**
6
+ * saved; skipped (the file there already has the object's size and SHA-256, or the key is a folder marker); failed
7
+ * (final: not found, replaced while read, damaged, a key that isn't a safe path); or pending (stopped by a passing
8
+ * error, kept in the run's journal with its part file, so running the download again goes on from its written pieces).
9
+ */
10
+ export type DownloadStatus = 'saved' | 'skipped' | 'failed' | 'pending';
11
+ /** One object's result from downloadFiles or downloadPrefix. One object's failure never fails another. */
12
+ export interface DownloadResult {
13
+ /** The object's key. */
14
+ key: string;
15
+ /** Where it was written (or would have been). */
16
+ path: string;
17
+ status: DownloadStatus;
18
+ /** The object, for saved and skipped (not for a folder marker). */
19
+ object?: StorageObject;
20
+ /** Why it failed or is pending. */
21
+ error?: unknown;
22
+ /** It went on from pieces an earlier run had written. */
23
+ resumed: boolean;
24
+ }
25
+ /** A key that can't be written under the destination: not a safe path, a link leading out, or another key's file. */
26
+ export declare class UnsafePathError extends TeepinError {
27
+ constructor(message: string);
28
+ }
29
+ /**
30
+ * Why one part of a key's path can't be a file name ("" when it can). On Windows also: its forbidden characters, a
31
+ * device name with or without an extension, and a trailing dot or space, which Windows drops, so the file would land
32
+ * under another name than the key's.
33
+ */
34
+ export declare function partProblem(part: string, windows: boolean): string;
35
+ /** A key's path split into its parts, each checked by partProblem: UnsafePathError for the first that can't be a name. */
36
+ export declare function keyParts(rel: string, windows: boolean): string[];
37
+ /** A path as names that ignore case see it (NFC, then upper and lower case, so a sharp s and "SS" are one), or as it is. */
38
+ export declare function fold(path: string, insensitive: boolean): string;
39
+ /** One key of a plan: where it goes and, when that's decided before anything is signed, its result. */
40
+ export interface PlanEntry {
41
+ key: string;
42
+ path: string;
43
+ /** A folder marker (skipped) or a key that isn't a safe path (failed); undefined for a key to download. */
44
+ result?: DownloadResult;
45
+ }
46
+ export interface Plan {
47
+ /** In the order the keys came, one per key (the same key twice is one). */
48
+ entries: PlanEntry[];
49
+ /** Keys that would land on a file an earlier key does: failed, after the rest. */
50
+ collisions: DownloadResult[];
51
+ }
52
+ /** What a plan needs from the file system. */
53
+ export interface PlanPaths {
54
+ /** Whether Windows' rules on names apply. */
55
+ windows: boolean;
56
+ /** Whether names under the destination ignore case. */
57
+ insensitive: boolean;
58
+ /** The target of a key whose parts are names: UnsafePathError when it isn't under the destination (a link leads out). */
59
+ target(parts: string[], rel: string): Promise<string>;
60
+ /** Where a key that isn't downloaded is said to go (only shown in its result). */
61
+ shown(rel: string): string;
62
+ }
63
+ /**
64
+ * (key, relative path) pairs to the plan: folder markers skipped, keys that aren't safe paths failed, and a key whose
65
+ * file another key already takes failed.
66
+ */
67
+ export declare function plan(pairs: Iterable<readonly [string, string]>, paths: PlanPaths): Promise<Plan>;
68
+ /** Errors that stop a whole run: what's left stays pending, to run again (a revoked key, no credit). */
69
+ export declare function stopsRun(err: unknown): boolean;
70
+ /**
71
+ * An error after which an object's download is kept, to go on with later: one that stops the run, the network, a busy
72
+ * or failing service, or the local disk (full, say: any failed system call).
73
+ */
74
+ export declare function passing(err: unknown): boolean;
75
+ //# sourceMapp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B;AAED,MAAM,WAAW,IAAI;IACnB,2EAA2E;IAC3E,OAAO,EAAE,SAAS,EAAE,CAAC;IACrB,kFAAkF;IAClF,UAAU,EAAE,cAAc,EAAE,CAAC;CAC9B;AAED,8CAA8C;AAC9C,MAAM,WAAW,SAAS;IACxB,6CAA6C;IAC7C,OAAO,EAAE,OAAO,CAAC;IACjB,uDAAuD;IACvD,WAAW,EAAE,OAAO,CAAC;IACrB,yHAAyH;IACzH,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACtD,kFAAkF;IAClF,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CAC5B;AAED;;;GAGG;AACH,wBAAsB,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAgCtG;AAED,wGAAwG;AACxG,wBAAgB,QAAQ,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAE9C;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAI7C"}
@@ -0,0 +1,191 @@
1
+ import { TooLargeError } from '../errors.js';
2
+ /** A pack is closed at about this many bytes as stored (section 12.4): one of the storage network's efficient writes. */
3
+ export declare const PACK_TARGET_BYTES: number;
4
+ /** The most objects in one pack (the control plane's cap). */
5
+ export declare const PACK_MAX_OBJECTS = 1000;
6
+ /** Objects up to this size go into packs; larger ones are uploaded in parts. */
7
+ export declare const PACK_OBJECT_LIMIT: number;
8
+ /** Packs and parts in flight: where the adaptive limit starts, and its ceiling. */
9
+ export declare const START_CONCURRENCY = 4;
10
+ export declare const MAX_CONCURRENCY = 32;
11
+ export declare const CONCURRENCY_ENV = "TEEPIN_UPLOAD_CONCURRENCY";
12
+ /** How long an upload waits for an unavailable storage network or control plane, in ms (section 17.4). */
13
+ export declare const DEFAULT_UPLOAD_WAIT_MS = 600000;
14
+ export declare const UPLOAD_WAIT_ENV = "TEEPIN_UPLOAD_WAIT";
15
+ /** A signature closer than this to its expiry is renewed before use, in ms. */
16
+ export declare const SIGN_MARGIN_MS = 60000;
17
+ /** How often a commit that answers "verifying" is asked again before the pack is sent again (section 19.13). */
18
+ export declare const COMMIT_VERIFY_TRIES = 4;
19
+ /** Times a pack's files are reserved again (conflict, bad bytes) before they fail. */
20
+ export declare const MAX_REBUILDS = 3;
21
+ /**
22
+ * A large object's parts (section 21.2): 16 MiB of plaintext by default, at least 5 MiB, a multiple of TWS1's 64 KiB
23
+ * segment, and at most 3,000 of them; each at most 5 GiB as stored.
24
+ */
25
+ export declare const DEFAULT_PART_BYTES: number;
26
+ export declare const MIN_PART_BYTES: number;
27
+ export declare const MAX_DIRECT_PARTS = 3000;
28
+ export declare const MAX_PART_STORED: number;
29
+ /** A stream's part size when neither its size nor a part size is given: about 187 GiB at most, in 3,000 parts. */
30
+ export declare const STREAM_PART_BYTES: number;
31
+ /**
32
+ * A stream's parts in flight unless the caller says: each holds its ciphertext in memory, so with the reader's parts a
33
+ * stream holds at most about (STREAM_CONCURRENCY + 3) x its part size.
34
+ */
35
+ export declare const STREAM_CONCURRENCY = 4;
36
+ /** The part-size rules directPartSize and streamPartSize apply: an upload engine keeps its own copy (tests shrink it). */
37
+ export interface PartRules {
38
+ /** A part's plaintext bytes unless asked for (DEFAULT_PART_BYTES). */
39
+ defaultBytes: number;
40
+ /** The fewest plaintext bytes a part may hold (MIN_PART_BYTES). */
41
+ minBytes: number;
42
+ /** The most parts an object may have (MAX_DIRECT_PARTS). */
43
+ maxParts: number;
44
+ /** A stream's part size with no hint (STREAM_PART_BYTES). */
45
+ streamBytes: number;
46
+ }
47
+ export declare const PART_RULES: Readonly<PartRules>;
48
+ /**
49
+ * Slow links (section 22.7): one request to the storage network should take at most about this long (ms) at the
50
+ * measured speed. Packs, and the parts of uploads created from then on, shrink to fit it.
51
+ */
52
+ export declare const REQUEST_MS = 240000;
53
+ /** A pack's target never shrinks below one TWS1 segment (a pack still always holds at least one object). */
54
+ export declare const PACK_MIN_TARGET: number;
55
+ /** A PUT smaller than this isn't measured: its time is mostly the round trip, not the link. */
56
+ export declare const SPEED_SAMPLE_BYTES: number;
57
+ /** How far each measured PUT moves the estimate (an exponential moving average of bytes and of time). */
58
+ export declare const SPEED_WEIGHT = 0.3;
59
+ /** A measured speed, for the part-size rule: bytes per second, and how long (ms) one request may take. */
60
+ export interface LinkSpeed {
61
+ bytesPerSecond: number;
62
+ ms: number;
63
+ }
64
+ /**
65
+ * The upload speed to the storage network, measured from completed PUTs (section 22.7): a moving estimate per client,
66
+ * of bytes over time, so a long transfer counts for more than a short one. Failed PUTs, and ones under
67
+ * minBytes, aren't measured. Until a PUT is measured, requestBytes is undefined and today's sizes hold. set (tests)
68
+ * fixes the speed; ms is the per-request budget.
69
+ */
70
+ export declare class SpeedMeter {
71
+ ms: number;
72
+ /** The smallest PUT measured (SPEED_SAMPLE_BYTES; tests lower it). */
73
+ minBytes: number;
74
+ private bytes;
75
+ private time;
76
+ private fixed?;
77
+ /** A PUT of nbytes that succeeded in elapsedMs. */
78
+ observe(nbytes: number, elapsedMs: number): void;
79
+ private sample;
80
+ /**
81
+ * A PUT of nbytes that timed out on its own timer after elapsedMs, with no answer: evidence of a slow link (section
82
+ * 22.7). Taken as an upper bound, weighted like a completed PUT: at most nbytes over elapsedMs, and never above the
83
+ * speed measured so far, so it can only lower the estimate. nbytes is the request's size: fetch doesn't say how much
84
+ * of it was written.
85
+ */
86
+ observeTimeout(nbytes: number, elapsedMs: number): void;
87
+ /** Fixes the measured speed in bytes per second (tests); undefined goes back to measuring. */
88
+ set(bytesPerSecond: number | undefined): void;
89
+ /** Bytes per second, or undefined before anything is measured. */
90
+ get bytesPerSecond(): number | undefined;
91
+ /** The speed and budget for the part-size rule, or undefined before anything is measured. */
92
+ get link(): LinkSpeed | undefined;
93
+ /** The most bytes one request carries within ms at the measured speed; undefined before anything is measured. */
94
+ requestBytes(): number | undefined;
95
+ }
96
+ /** A pack's target size: target (9 MiB), or less when requestBytes (the measured speed's budget) is smaller, never below floor. */
97
+ export declare function packTarget(requestBytes: number | undefined, target?: number, floor?: number): number;
98
+ /**
99
+ * The largest object that goes into a pack; a larger one goes in parts. limit (16 MiB), or on a slow link (section 22.7)
100
+ * the bytes one request carries at the measured speed (requestBytes), but never under minPart: an object a pack request
101
+ * couldn't carry in time goes in parts, which the part rule sizes for the link.
102
+ */
103
+ export declare function packObjectLimit(requestBytes: number | undefined, limit?: number, minPart?: number): number;
104
+ export declare function formatSpeed(bytesPerSecond: number): string;
105
+ /**
106
+ * TooLargeError with reason connection_speed: name (size bytes, 0 for a stream of unknown size) can't be sent at the
107
+ * measured speed. partCap is the largest part the speed allows.
108
+ */
109
+ export declare function tooSlow(name: string, size: number, speed: LinkSpeed, partCap: number, rules?: Readonly<PartRules>): TooLargeError;
110
+ /**
111
+ * The part size for a large object of size bytes when want (0 for the default) is asked for: at least MIN_PART_BYTES,
112
+ * rounded up to whole segments, doubled until the parts fit in MAX_DIRECT_PARTS.
113
+ *
114
+ * A slow link (section 22.7): with speed measured (undefined before anything is), a part carries at most speed.ms of
115
+ * it, rounded down to whole segments. When that cap is under the smallest part, or the parts can't fit in the most
116
+ * parts under it, TooLargeError with reason connection_speed, before anything is created or sent.
117
+ */
118
+ export declare function directPartSize(size: number, want?: number, rules?: Readonly<PartRules>, speed?: LinkSpeed, name?: string): number;
119
+ /**
120
+ * The part size for a stream whose size isn't known (section 22.1, E2 b). It fixes the largest stream: MAX_DIRECT_PARTS
121
+ * of it. expectedSize, a hint, chooses it as for a known size; with neither hint nor want, STREAM_PART_BYTES. A
122
+ * measured speed caps it as for a known size.
123
+ */
124
+ export declare function streamPartSize(expectedSize?: number, want?: number, rules?: Readonly<PartRules>, speed?: LinkSpeed, name?: string): number;
125
+ /** A positive number from the environment (Node only; browsers have none), else def. */
126
+ export declare function envNumber(name: string, def: number): number;
127
+ /** A pack's size: each object's needle and TWS1 bytes. */
128
+ export declare function packedSize(sizes: readonly number[]): number;
129
+ /**
130
+ * Packs for items, in order: each closes when the next item would take it past target bytes or maxObjects objects,
131
+ * and never holds one key twice (a second write to a key waits for the next pack, and writes to one key keep their
132
+ * order). An item bigger than target gets a pack of its own.
133
+ */
134
+ export declare function planPacks<T>(items: readonly T[], sizeOf: (it: T) => number, keyOf: (it: T) => string, target?: number, maxObjects?: number): T[][];
135
+ /**
136
+ * The first of planPacks's packs, and the items left for later ones: a planner that packs as it goes, so each pack
137
+ * takes the target the speed measured by then allows (section 22.7).
138
+ */
139
+ export declare function nextPack<T>(items: readonly T[], sizeOf: (it: T) => number, keyOf: (it: T) => string, target?: number, maxObjects?: number): [pack: T[], rest: T[]];
140
+ /** A slot's outcome when it is released: ok, throttled (or a timeout), or failed. */
141
+ export type Outcome = 'ok' | 'throttled' | 'failed';
142
+ /**
143
+ * How many packs or parts may be in flight (section 17.8): starts at 4, adds about one per round of successes, halves
144
+ * on a throttle or a timeout, and never passes its ceiling.
145
+ *
146
+ * priority is set while putObject calls wait for a slot: a run's acquire() then waits too, so a freed slot goes to them
147
+ * (tryAcquire) before the run's next pack, and a long run never makes a putObject wait for its end.
148
+ */
149
+ export declare class AdaptiveLimit {
150
+ readonly ceiling: number;
151
+ limit: number;
152
+ inFlight: number;
153
+ priority: boolean;
154
+ private waiters;
155
+ constructor(start?: number, ceiling?: number);
156
+ private free;
157
+ /** A slot now, if one is free (putObject's dispatch, which priority doesn't hold back). */
158
+ tryAcquire(): boolean;
159
+ /** Waits for a slot that putObject's callers aren't waiting for. An abort ends the wait with the signal's reason. */
160
+ acquire(signal?: AbortSignal): Promise<void>;
161
+ setPriority(on: boolean): void;
162
+ release(outcome?: Outcome): void;
163
+ private wakeAll;
164
+ }
165
+ /** A token bucket that caps retries at about a tenth of requests, plus a burst, so an incident doesn't become a retry storm (section 17.6). */
166
+ export declare class RetryBudget {
167
+ readonly ratio: number;
168
+ readonly burst: number;
169
+ tokens: number;
170
+ constructor(ratio?: number, burst?: number);
171
+ onRequest(): void;
172
+ tryRetry(): boolean;
173
+ }
174
+ /**
175
+ * The wait in ms before the next round when storage or the control plane is unavailable: from 5 s, doubling to 5
176
+ * minutes, with jitter; a server's Retry-After when it sent one (section 17.6).
177
+ */
178
+ export declare function waitDelayMs(round: number, retryAfterMs?: number): number;
179
+ /**
180
+ * sent: the bytes are there (200), or an earlier attempt put them there (412). resign: the signature was refused
181
+ * (expired, or another value): sign again. bad: refused as not the bytes signed (400 BadDigest). busy: wait and try
182
+ * again (429, 5xx). unsent: never sent, safe to send again at once. unknown: sent, but no answer came: commit first
183
+ * (section 17.1, rule 5). refused: anything else, a bug or an unsupported request, never retried in a loop.
184
+ */
185
+ export type StorageOutcome = 'sent' | 'resign' | 'bad' | 'busy' | 'unsent' | 'unknown' | 'refused';
186
+ /** What a PUT to the storage network ended in (undefined: success). */
187
+ export declare function storageOutcome(err: unknown): StorageOutcome;
188
+ export declare function isThrottle(err: unknown): boolean;
189
+ /** A control-plane failure worth waiting out: the network, a busy or failing server (the client has already retried it). */
190
+ export declare function isPassing(err: unknown): boolean;
191
+ //# sourceMappingURL=engine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../../src/direct/engine.ts"],"names":[],"mappings":"AAQA,OAAO,EAA0C,aAAa,EAAE,MAAM,cAAc,CAAC;AAGrF,yHAAyH;AACzH,eAAO,MAAM,iBAAiB,QAAc,CAAC;AAC7C,8DAA8D;AAC9D,eAAO,MAAM,gBAAgB,OAAO,CAAC;AACrC,gFAAgF;AAChF,eAAO,MAAM,iBAAiB,QAAe,CAAC;AAC9C,mFAAmF;AACnF,eAAO,MAAM,iBAAiB,IAAI,CAAC;AACnC,eAAO,MAAM,eAAe,KAAK,CAAC;AAClC,eAAO,MAAM,eAAe,8BAA8B,CAAC;AAC3D,0GAA0G;AAC1G,eA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AKhE,OAAO,CAAC,IAAI;IAIZ,2FAA2F;IAC3F,UAAU,IAAI,OAAO;IAMrB,qHAAqH;IAC/G,OAAO,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAsBlD,WAAW,CAAC,EAAE,EAAE,OAAO,GAAG,IAAI;IAM9B,OAAO,CAAC,OAAO,GAAE,OAAc,GAAG,IAAI;IAOtC,OAAO,CAAC,OAAO;CAKhB;AAED,+IAA+I;AAC/I,qBAAa,WAAW;IAIpB,QAAQ,CAAC,KAAK;IACd,QAAQ,CAAC,KAAK;IAJhB,MAAM,EAAE,MAAM,CAAC;gBAGJ,KAAK,SAAM,EACX,KAAK,SAAK;IAKrB,SAAS,IAAI,IAAI;IAIjB,QAAQ,IAAI,OAAO;CAKpB;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAIxE;AAID;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,CAAC;AAEnG,uEAAuE;AACvE,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,GAAG,cAAc,CAW3D;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAEhD;AAED,4HAA4H;AAC5H,wBAAgB,SAAS,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAG/C"}
@@ -0,0 +1,9 @@
1
+ export declare const FORMAT_TWS1 = "tws1";
2
+ export declare const FORMAT_SERVER = "teepin-v1";
3
+ export declare const FORMAT_PLAIN = "plain";
4
+ export declare const FORMATS: readonly string[];
5
+ export declare const SOURCE_STORAGE = "storage";
6
+ export declare const SOURCE_API = "api";
7
+ /** A teepin-v1 object's plaintext, after its tag is checked; DataIntegrityError if it doesn't authenticate. */
8
+ export declare function openServerV1(key: Uint8Array, stored: Uint8Array, associatedData: Uint8Array): Promise<Uint8Array>;
9
+ //# sourceMappingURL=formats.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formats.d.ts","sourceRoot":"","sources":["../../../src/direct/formats.ts"],"names":[],"mappings":"AAmBA,eAAO,MAAM,WAAW,SAAS,CAAC;AAClC,eAAO,MAAM,aAAa,cAAc,CAAC;AACzC,eAAO,MAAM,YAAY,UAAU,CAAC;AACpC,eAAO,MAAM,OAAO,EAAE,SAAS,MAAM,EAA+C,CAAC;AAErF,eAAO,MAAM,cAAc,YAAY,CAAC;AACxC,eAAO,MAAM,UAAU,QAAQ,CAAC;AAKhC,+GAA+G;AAC/G,wBAAsB,YAAY,CAAC,GAAG,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,cAAc,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAUvH"}
@@ -0,0 +1,55 @@
1
+ import { TeepinError } from '../errors.js';
2
+ /** The suite's name, as the control plane reports it with an account key. */
3
+ export declare const SUITE = "x25519-hkdfsha256-aes128gcm";
4
+ export declare const KEM_ID = 32;
5
+ export declare const KDF_ID = 1;
6
+ export declare const AEAD_ID = 1;
7
+ export declare const PUBLIC_KEY_SIZE = 32;
8
+ export declare const PRIVATE_KEY_SIZE = 32;
9
+ export declare const ENC_SIZE = 32;
10
+ export declare const DATA_KEY_SIZE = 32;
11
+ export declare const WRAPPED_KEY_SIZE: number;
12
+ /** A wrapped key that does not open for this account and object. */
13
+ export declare class UnwrapError extends TeepinError {
14
+ constructor(message: string, options?: {
15
+ cause?: unknown;
16
+ });
17
+ }
18
+ /** info for an object's wrapped key: the label, then the account's and the object's 16-byte ids. */
19
+ export declare function keyInfo(accountId: Uint8Array, objectId: Uint8Array): Uint8Array;
20
+ /**
21
+ * A raw 32-byte X25519 private key as a non-extractable WebCrypto key, for deriveBits. WebCrypto has no raw import
22
+ * for private keys, so it goes in as PKCS #8.
23
+ */
24
+ export declare function importPrivateKey(privateKey: Uint8Array): Promise<CryptoKey>;
25
+ /** The raw public key that belongs to a raw 32-byte private key. */
26
+ export declare function publicKeyOf(privateKey: Uint8Array): Promise<Uint8Array>;
27
+ /** One seal's ephemeral key pair: the WebCrypto private key and the raw public key, which becomes enc. */
28
+ export interface EphemeralKey {
29
+ privateKey: CryptoKey;
30
+ publicKey: Uint8Array;
31
+ }
32
+ /** A single-shot base-mode seal to publicKey: enc | ciphertext, under a fresh ephemeral key. */
33
+ export declare function seal(publicKey: Uint8Array, info: Uint8Array, plaintext: Uint8Array, aad?: Uint8Array): Promise<Uint8Array>;
34
+ /**
35
+ * seal under a given ephemeral key: only the RFC's own vectors need it. An ephemeral key used twice with one
36
+ * recipient gives the same AES-GCM key and nonce twice, which gives away both plaintexts' XOR. So the SDK only ever
37
+ * calls seal, which makes a fresh one each time, and a test checks that nothing under src calls sealWith. It takes
38
+ * the key per call, never from shared state another module could change.
39
+ */
40
+ export declare function sealWith(ephemeral: EphemeralKey, publicKey: Uint8Array, info: Uint8Array, plaintext: Uint8Array, aad?: Uint8Array): Promise<Uint8Array>;
41
+ /**
42
+ * Opens the seq-th message of a base-mode context set up by enc. A single-shot seal is message 0. UnwrapError if it
43
+ * doesn't open.
44
+ */
45
+ export declare function openSealed(privateKey: Uint8Array, enc: Uint8Array, info: Uint8Array, ciphertext: Uint8Array, aad?: Uint8Array, seq?: number): Promise<Uint8Array>;
46
+ /** A new X25519 key pair, raw 32 bytes each: for tests and the fake API. */
47
+ export declare function generateKeyPair(): Promise<{
48
+ privateKey: Uint8Array;
49
+ publicKey: Uint8Array;
50
+ }>;
51
+ /** An object's data key, wrapped to its account's public key: 80 bytes. */
52
+ export declare function wrapKey(publicKey: Uint8Array, accountId: Uint8Array, objectId: Uint8Array, dataKey: Uint8Array): Promise<Uint8Array>;
53
+ /** The data key inside wrapped, which must have been wrapped for this account and object; UnwrapError otherwise. */
54
+ export declare function unwrapKey(privateKey: Uint8Array, accountId: Uint8Array, objectId: Uint8Array, w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AAE,UAAkB,GAAG,OAAO,CAAC,UAAU,CAAC,CAEvI;AAED;;;;;GAKG;AACH,wBAAsB,QAAQ,CAC5B,SAAS,EAAE,YAAY,EACvB,SAAS,EAAE,UAAU,EACrB,IAAI,EAAE,UAAU,EAChB,SAAS,EAAE,UAAU,EACrB,GAAG,GAAE,UAAkB,GACtB,OAAO,CAAC,UAAU,CAAC,CAUrB;AAED;;;GAGG;AACH,wBAAsB,UAAU,CAC9B,UAAU,EAAE,UAAU,EACtB,GAAG,EAAE,UAAU,EACf,IAAI,EAAE,UAAU,EAChB,UAAU,EAAE,UAAU,EACtB,GAAG,GAAE,UAAkB,EACvB,GAAG,SAAI,GACN,OAAO,CAAC,UAAU,CAAC,CAarB;AAED,4EAA4E;AAC5E,wBAAsB,eAAe,IAAI,OAAO,CAAC;IAAE,UAAU,EAAE,UAAU,CAAC;IAAC,SAAS,EAAE,UAAU,CAAA;CAAE,CAAC,CAalG;AAID,2EAA2E;AAC3E,wBAAsB,OAAO,CAAC,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAK1I;AAED,oHAAoH;AACpH,wBAAsB,SAAS,CAAC,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAQ7I"}
@@ -0,0 +1,55 @@
1
+ /** What a journal holds: a run's own row, and its files, packs and large uploads (and their parts). */
2
+ export type Table = 'run' | 'files' | 'packs' | 'uploads' | 'parts';
3
+ /** One row: plain JSON values, so a file journal can write it as it is. */
4
+ export type Row = Record<string, unknown>;
5
+ /** One write in a batch: a row put (replacing any row with its id), or removed. */
6
+ export type Entry = {
7
+ table: Table;
8
+ id: string;
9
+ row: Row;
10
+ } | {
11
+ table: Table;
12
+ id: string;
13
+ remove: true;
14
+ };
15
+ /** A run's journal. Writes resolve once they are durable; a batch is written whole or not at all. */
16
+ export interface Journal {
17
+ /** Whether the journal survives the process (a resumable run). */
18
+ readonly durable: boolean;
19
+ /** Puts row (replacing any row with its id), durably. */
20
+ put(table: Table, id: string, row: Row): Promise<void>;
21
+ /** Writes entries together: after a crash, all of them are there or none. */
22
+ write(entries: readonly Entry[]): Promise<void>;
23
+ /** A row by id, as last put. */
24
+ get(table: Table, id: string): Row | undefined;
25
+ /** Every row of a table, in the order their ids were first put. */
26
+ rows(table: Table): Row[];
27
+ /** A fresh id for a row of table, unique in this journal (the files of a run are numbered in order). */
28
+ nextId(table: Table): string;
29
+ close(): Promise<void>;
30
+ }
31
+ /** Rows as a journal keeps them in memory: the shared core of every journal. */
32
+ export declare class Rows {
33
+ private readonly tables;
34
+ private readonly counters;
35
+ apply(entry: Entry): void;
36
+ get(table: Table, id: string): Row | undefined;
37
+ rows(table: Table): Row[];
38
+ nextId(table: Table): string;
39
+ /** Every row, as entries: what a file journal writes when it compacts. */
40
+ entries(): Entry[];
41
+ }
42
+ /** A run journaled in memory: not resumable after the process ends (browsers, and journal: false). */
43
+ export declare class MemoryJournal implements Journal {
44
+ readonly durable = false;
45
+ private readonly data;
46
+ private closed;
47
+ put(table: Table, id: string, row: Row): Promise<void>;
48
+ write(entries: readonly Entry[]): Promise<void>;
49
+ get(table: Table, id: string): Row | undefined;
50
+ rows(table: Table): Row[];
51
+ nextId(table: Table): string;
52
+ close(): Promise<void>;
53
+ private check;
54
+ }
55
+ //# sourceMappingURL=journal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"journal.d.ts","sourceRoot":"","sources":["../../../src/direct/journal.ts"],"names":[],"mappings":"AAQA,uGAAuG;AACvG,MAAM,MAAM,KAAK,GAAG,KAAK,GAAG,OAAO,GAAG,OAAO,GAAG,SAAS,GAAG,OAAO,CAAC;AAEpE,2EAA2E;AAC3E,MAAM,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE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,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM;IAM5B,0EAA0E;IAC1E,OAAO,IAAI,KAAK,EAAE;CAKnB;AAED,sGAAsG;AACtG,qBAAa,aAAc,YAAW,OAAO;IAC3C,QAAQ,CAAC,OAAO,SAAS;IACzB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAc;IACnC,OAAO,CAAC,MAAM,CAAS;IAEjB,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAKtD,KAAK,CAAC,OAAO,EAAE,SAAS,KAAK,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAKrD,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,GAAG,GAAG,GAAG,SAAS;IAI9C,IAAI,CAAC,KAAK,EAAE,KAAK,GAAG,GAAG,EAAE;IAIzB,MAAM,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM;IAItB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B,OAAO,CAAC,KAAK;CAGd"}
@@ -0,0 +1,170 @@
1
+ import type { StorageObject } from '../storage.js';
2
+ import { type Json, type Progress, type Waits } from './common.js';
3
+ import { type LinkSpeed } from './engine.js';
4
+ import * as tws1 from './tws1.js';
5
+ import type { DirectUploads, RunStore } from './uploads.js';
6
+ /** Data that can be read at any offset: what a large upload sends parts from. */
7
+ export interface PartSource {
8
+ size: number;
9
+ readAt(offset: number, length: number): Promise<Uint8Array>;
10
+ /** In one pass, the whole SHA-256 and each part's, where the source has a faster way than the default. */
11
+ hashParts?(partSize: number): Promise<{
12
+ whole: string;
13
+ parts: Map<number, string>;
14
+ }>;
15
+ }
16
+ /** A stream read a piece at a time: up to max bytes (fewer is fine), empty at its end. */
17
+ export interface StreamSource {
18
+ pull(max: number, signal?: AbortSignal): Promise<Uint8Array>;
19
+ /** Lets go of the source, cancelling it if it wasn't read to its end. */
20
+ release(reason?: unknown): Promise<void>;
21
+ }
22
+ /** The upload can't go on: start again under a new create, with a fresh key. */
23
+ export declare class Restart extends Error {
24
+ constructor(why: string);
25
+ }
26
+ export interface LargeOptions {
27
+ contentType?: string;
28
+ metadata?: Record<string, string>;
29
+ ifNoneMatch?: boolean;
30
+ ifMatch?: string;
31
+ partSize: number;
32
+ /** The run's store, when it has one (its journal, and its directory for the data key). */
33
+ store?: RunStore;
34
+ fileId?: string;
35
+ path?: string;
36
+ partHashes?: Map<number, string>;
37
+ }
38
+ /** One large upload's state, journaled when it has a store. The methods tests replace are save and savePart. */
39
+ export declare class Large implements Waits {
40
+ readonly bucket: string;
41
+ readonly key: string;
42
+ readonly size: number;
43
+ readonly sha256: string;
44
+ readonly readAt: (offset: number, length: number) => Promise<Uint8Array>;
45
+ id: string;
46
+ idem: string;
47
+ uploadId: string;
48
+ state: 'new' | 'sending' | 'completing' | 'completed' | 'failed';
49
+ dek?: Uint8Array;
50
+ header: Uint8Array;
51
+ stream?: tws1.Stream;
52
+ wrapped: string;
53
+ keyVersion: number;
54
+ /** Part number → its plaintext's SHA-256 (D1 a), taken in the same pass as the whole object's. */
55
+ plain: Map<number, string>;
56
+ resumed: boolean;
57
+ restarts: number;
58
+ waited: number;
59
+ throttled: boolean;
60
+ lastError: string;
61
+ readonly contentType: string;
62
+ readonly metadata: Record<string, string>;
63
+ readonly ifNoneMatch: boolean;
64
+ readonly ifMatch: string;
65
+ readonly partSize: number;
66
+ readonly partCount: number;
67
+ readonly store?: RunStore;
68
+ readonly fileId?: string;
69
+ readonly path?: string;
70
+ /** Whether the data key's file is written (and so must be deleted). */
71
+ private keyOnDisk;
72
+ constructor(bucket: string, key: string, size: number, sha256: string, readAt: (offset: number, length: number) => Promise<Uint8Array>, opts: LargeOptions);
73
+ /** Whether its journal survives the process (a resumable upload). */
74
+ get durable(): boolean;
75
+ private row;
76
+ private partRow;
77
+ /** The upload's state, journaled (with its data key first, on disk, while it has one). */
78
+ save(): Promise<void>;
79
+ savePart(number: number, plain: string, md5?: string, sha256?: string, state?: string): Promise<void>;
80
+ /** D1 (a): every part's hash before any byte leaves; then the data key, header and wrap, before any part is signed. */
81
+ saveCreated(): Promise<void>;
82
+ private saveKey;
83
+ /** Zeroes the data key and deletes its file (E3: promptly). */
84
+ forgetKey(): Promise<void>;
85
+ /** An upload a crashed run left in its journal. */
86
+ static fromRow(row: Json, readAt: (offset: number, length: number) => Promise<Uint8Array>, opts: Omit<LargeOptions, 'partSize' | 'partHashes'>): Promise<Large>;
87
+ /** A new create and a fresh key. The source's part hashes stay: they still catch a file that changed. */
88
+ reset(): Promise<void>;
89
+ }
90
+ /**
91
+ * A stream's upload: created without its size, its last part declared at its sign, and its size and SHA-256 brought by
92
+ * complete. Held in memory only: nothing could read the stream again to resume it.
93
+ */
94
+ export declare class StreamUpload implements Waits {
95
+ readonly bucket: string;
96
+ readonly key: string;
97
+ readonly partSize: number;
98
+ readonly idem: string;
99
+ uploadId: string;
100
+ stream?: tws1.OpenStream;
101
+ wrapped: string;
102
+ keyVersion: number;
103
+ readonly path?: string;
104
+ /** The measured speed when it shrank the part size (section 22.7), else undefined. */
105
+ slow?: LinkSpeed;
106
+ waited: number;
107
+ throttled: boolean;
108
+ lastError: string;
109
+ readonly contentType: string;
110
+ readonly metadata: Record<string, string>;
111
+ readonly ifNoneMatch: boolean;
112
+ readonly ifMatch: string;
113
+ constructor(bucket: string, key: string, partSize: number, opts?: {
114
+ contentType?: string;
115
+ metadata?: Record<string, string>;
116
+ ifNoneMatch?: boolean;
117
+ ifMatch?: string;
118
+ });
119
+ }
120
+ type Upload = Large | StreamUpload;
121
+ /** Large uploads and streams for one DirectUploads. The methods tests replace are sendSealed and completeStream. */
122
+ export declare class Parts {
123
+ readonly up: DirectUploads;
124
+ constructor(up: DirectUploads);
125
+ /**
126
+ * Takes a large upload to its object. A final failure cancels it; an error after which it may resume (storage
127
+ * unavailable, a revoked key) keeps it, in its journal, when it has one on disk. An abort leaves a journaled upload
128
+ * for resumeUploads, and cancels one in memory, which nothing could resume.
129
+ */
130
+ run(u: Large, prog?: Progress, signal?: AbortSignal): Promise<StorageObject>;
131
+ /** Cancels the upload at the storage network: one call, best effort, never the control plane's rounds of waiting. */
132
+ abort(u: Upload, stopping?: boolean): Promise<void>;
133
+ private attempt;
134
+ private create;
135
+ private sendParts;
136
+ /**
137
+ * Part n's plaintext, read and hashed: journaled before its first byte leaves (D1 a), and the same as journaled on
138
+ * every later read (D1 b).
139
+ */
140
+ checkSource(u: Large, n: number): Promise<Uint8Array>;
141
+ private sign;
142
+ private sendPart;
143
+ /** Signs part n and sends it until storage holds it as signed; recheck reads the source again when storage holds other bytes. Replaced in tests. */
144
+ sendSealed(u: Upload, n: number, sealed: Uint8Array, md5: string, sha: string, extra: Json | undefined, recheck: (() => Promise<unknown>) | undefined, signal?: AbortSignal): Promise<void>;
145
+ private complete;
146
+ /**
147
+ * Uploads everything source yields, sealing and sending up to concurrency parts at once. Any failure, or an abort,
148
+ * cancels the upload (one call): a stream can't be read again.
149
+ */
150
+ runStream(s: StreamUpload, source: StreamSource, concurrency: number, prog?: Progress, signal?: AbortSignal): Promise<StorageObject>;
151
+ private streamAttempt;
152
+ private createStream;
153
+ /** Completes a stream's upload with the size and SHA-256 read. Replaced in tests. */
154
+ completeStream(s: StreamUpload, size: number, sha256: string, signal?: AbortSignal): Promise<StorageObject>;
155
+ }
156
+ /** Whether body is a stream (a ReadableStream or an async iterable) rather than data that can be read at any offset. */
157
+ export declare function isStreamBody(body: unknown): body is ReadableStream<Uint8Array> | AsyncIterable<Uint8Array>;
158
+ /** A ReadableStream or an async iterable, read a piece at a time: no piece is copied before it is taken. */
159
+ export declare function streamSource(body: ReadableStream<Uint8Array> | AsyncIterable<Uint8Array>): StreamSource;
160
+ /**
161
+ * head (what was read first, to choose the way), then the rest of inner. head is handed on and dropped as soon as its
162
+ * bytes are taken, not held for the upload.
163
+ */
164
+ export declare function prefixed(head: Uint8Array, inner: StreamSource): StreamSource & {
165
+ readonly holding: boolean;
166
+ };
167
+ /** Up to n bytes from source, into one buffer (shorter only at the source's end). */
168
+ export declare function readUpTo(source: StreamSource, n: number, signal?: AbortSignal): Promise<Uint8Array>;
169
+ export {};
170
+ //# sourceMappingURL=large.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"large.d.ts","sourceRoot":"","sources":["../../../src/direct/large.ts"],"names":[],"mappings":"AAyCA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,OAAO,EAAqE,KAAK,IAAI,EAAE,KAAK,QAAQ,EAAE,KAAK,KAAK,EAAE,MAAM,aAAa,CAAC;AACtI,OAAO,EAAyC,KAAK,SAAS,EAAgB,MAAM,aAAa,CAAC;AAElG,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAQ5D,iFAAiF;AACjF,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAC5D,0GAA0G;IAC1G,SAAS,CAAC,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,CAAC,CAAC;CACtF;AAED,0FAA0F;AAC1F,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAC7D,yEAAyE;IACzE,OAAO,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1C;AAED,gFAAgF;AAChF,qBAAa,OAAQ,SAAQ,KAAK;gBACpB,GAAG,E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