sealnet 3.2.1 → 3.2.4
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 +2 -2
- package/THIRD-PARTY-NOTICES.txt +1 -1
- package/dist/index.cjs +100 -30
- package/dist/index.js +100 -30
- package/dist/seal.global.js +3 -3
- package/dist/seal.global.js.sha384 +1 -1
- package/dist/seal_crypto.wasm +0 -0
- package/dist/seal_crypto.wasm.sha384 +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// <define:__SEAL_WASM__>
|
|
2
|
-
var define_SEAL_WASM_default = { url: "https://seal.net/sdk/v3.2.
|
|
2
|
+
var define_SEAL_WASM_default = { url: "https://seal.net/sdk/v3.2.4/seal_crypto.wasm", integrity: "sha384-J9NTJFphVX/NdC0pcwJmhENoDqXMqj6caYtMhwzS4t9Bs+uIfpd4FuY2gX/Q4LFZ" };
|
|
3
3
|
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
5
5
|
var __export = (target, all) => {
|
|
@@ -271,10 +271,10 @@ var WasmIdentity = class _WasmIdentity {
|
|
|
271
271
|
* @param {string} at
|
|
272
272
|
* @returns {Uint8Array}
|
|
273
273
|
*/
|
|
274
|
-
signApproval(
|
|
274
|
+
signApproval(ask2, decision, at) {
|
|
275
275
|
try {
|
|
276
276
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
277
|
-
const ptr0 = passStringToWasm0(
|
|
277
|
+
const ptr0 = passStringToWasm0(ask2, wasm.__wbindgen_export3, wasm.__wbindgen_export4);
|
|
278
278
|
const len0 = WASM_VECTOR_LEN;
|
|
279
279
|
const ptr1 = passStringToWasm0(decision, wasm.__wbindgen_export3, wasm.__wbindgen_export4);
|
|
280
280
|
const len1 = WASM_VECTOR_LEN;
|
|
@@ -428,12 +428,12 @@ if (Symbol.dispose) WasmIdentity.prototype[Symbol.dispose] = WasmIdentity.protot
|
|
|
428
428
|
function init() {
|
|
429
429
|
wasm.init();
|
|
430
430
|
}
|
|
431
|
-
function wasm_approval_message(
|
|
431
|
+
function wasm_approval_message(ask2, decision, at) {
|
|
432
432
|
let deferred5_0;
|
|
433
433
|
let deferred5_1;
|
|
434
434
|
try {
|
|
435
435
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
436
|
-
const ptr0 = passStringToWasm0(
|
|
436
|
+
const ptr0 = passStringToWasm0(ask2, wasm.__wbindgen_export3, wasm.__wbindgen_export4);
|
|
437
437
|
const len0 = WASM_VECTOR_LEN;
|
|
438
438
|
const ptr1 = passStringToWasm0(decision, wasm.__wbindgen_export3, wasm.__wbindgen_export4);
|
|
439
439
|
const len1 = WASM_VECTOR_LEN;
|
|
@@ -1387,7 +1387,11 @@ var limits_default = {
|
|
|
1387
1387
|
SENSOR_NOVELTY_WINDOW_DAYS: 30,
|
|
1388
1388
|
SENSOR_HOLD_TTL_SECONDS: 86400,
|
|
1389
1389
|
SENSOR_BASELINE_MIN_HOURS: 72,
|
|
1390
|
-
SENSOR_GROWTH_BYTES_PER_DAY_DEFAULT: 107374182400
|
|
1390
|
+
SENSOR_GROWTH_BYTES_PER_DAY_DEFAULT: 107374182400,
|
|
1391
|
+
CLIENT_EVENT_STRING_MAX_CHARS: 512,
|
|
1392
|
+
CLIENT_EVENT_MAX_BYTES: 4096,
|
|
1393
|
+
CLIENT_EVENT_ID_MAX_CHARS: 64,
|
|
1394
|
+
CLIENT_EVENT_COUNT_MAX: 1e6
|
|
1391
1395
|
}
|
|
1392
1396
|
};
|
|
1393
1397
|
var secrets_default = {
|
|
@@ -1425,7 +1429,7 @@ var secrets_default = {
|
|
|
1425
1429
|
shared_host_suffixes: ["s3.amazonaws.com", "cloudfront.net", "azurewebsites.net", "appspot.com", "firebaseapp.com", "web.app", "github.io", "githubusercontent.com", "gitlab.io", "herokuapp.com", "pages.dev", "workers.dev", "vercel.app", "netlify.app", "onrender.com", "fly.dev", "blogspot.com", "ngrok.io", "ngrok-free.app", "glitch.me", "surge.sh"],
|
|
1426
1430
|
shared_host_note: "Names under which each customer has a name of its own (the private part of the public suffix list): a host there is one service with the label before it, as `x.co.uk` is \u2014 AUDIT K162: by its last two labels every github.io page was one service.",
|
|
1427
1431
|
wildcard_note: "A proposed `*.<name>` binds a key unless <name> is a public suffix: one label (`*.com`), or two where the second is a two-letter country top level and the first is one of wildcard_public_second_level (`*.co.uk` would be a root for every .co.uk host; `*.me.com` is a name of its own); a bare name needs two labels (SPEC agent egress \xA74.2, review of phase 1).",
|
|
1428
|
-
guard_note: "What the guard does with a key of an entry (SPEC agent egress \xA74.1, read by `seal-client-core::guard`). `hosts`: where the key is a way in, the default binding a person confirms or narrows; `*.` is one label. `place`: where the guard puts the value \u2014 `bearer` (Authorization: Bearer), `header:<name>`, `query:<param>`, `basic_user`, `basic_pass`, `userinfo`, `url` (the secret is the request address itself, a webhook). `class`: `outbound` \u2014 a key a program enters a service with, the proxy puts it in; `inprocess` \u2014 a key a program works with itself (a webhook signing secret, a database password of a driver that uses no proxy, a private key, an assignment the pattern matches with its name): the program gets the value, by the person's word on the page. `surrogate`: the form of the stand-in the agent sees \u2014 `keep_prefix` (kept as it is), `alphabet` (`base62`, `base64url`, `hex`, `digits`, `base32`, `classes` \u2014 each character keeps its class and punctuation stays), `length` (a number, else the value's), `checksum` (`github_crc32`: the last six characters are the CRC32 of the body, base62), `parts` (`password`: of a connection URI only the password changes). An entry without `surrogate` is treated by classes. `provision_commands`: commands that write a key as data into a service's own store; a surrogate in their arguments or stdin is refused unless the binding's `provision` names the host (\xA75.4, \xA76.4). Data, not code: a service is added with one entry.",
|
|
1432
|
+
guard_note: "What the guard does with a key of an entry (SPEC agent egress \xA74.1, read by `seal-client-core::guard`). `hosts`: where the key is a way in, the default binding a person confirms or narrows; `*.` is one label. `place`: where the guard puts the value \u2014 `bearer` (Authorization: Bearer), `header:<name>`, `query:<param>`, `basic_user`, `basic_pass`, `userinfo`, `url` (the secret is the request address itself, a webhook). In the headers the value goes into `Authorization` (any scheme), the place's own `header:<name>`, and `headers`: the headers the service takes the key in beside its place (Google's SDKs send an API key as `x-goog-api-key`); a stand-in in any other header refuses the request (`off_place`). `class`: `outbound` \u2014 a key a program enters a service with, the proxy puts it in; `inprocess` \u2014 a key a program works with itself (a webhook signing secret, a database password of a driver that uses no proxy, a private key, an assignment the pattern matches with its name): the program gets the value, by the person's word on the page. `surrogate`: the form of the stand-in the agent sees \u2014 `keep_prefix` (kept as it is), `alphabet` (`base62`, `base64url`, `hex`, `digits`, `base32`, `classes` \u2014 each character keeps its class and punctuation stays), `length` (a number, else the value's), `checksum` (`github_crc32`: the last six characters are the CRC32 of the body, base62), `parts` (`password`: of a connection URI only the password changes). An entry without `surrogate` is treated by classes. `provision_commands`: commands that write a key as data into a service's own store; a surrogate in their arguments or stdin is refused unless the binding's `provision` names the host (\xA75.4, \xA76.4). Data, not code: a service is added with one entry.",
|
|
1429
1433
|
provision_commands: [
|
|
1430
1434
|
{ command: "wrangler secret put", host: "api.cloudflare.com" },
|
|
1431
1435
|
{ command: "gh secret set", host: "api.github.com" },
|
|
@@ -1579,6 +1583,7 @@ var secrets_default = {
|
|
|
1579
1583
|
keywords: ["google", "api", "AIza"],
|
|
1580
1584
|
hosts: ["*.googleapis.com"],
|
|
1581
1585
|
place: "query:key",
|
|
1586
|
+
headers: ["x-goog-api-key"],
|
|
1582
1587
|
class: "outbound",
|
|
1583
1588
|
surrogate: { keep_prefix: "^AIza", alphabet: "base64url" },
|
|
1584
1589
|
vectors: { hit: "AIzaSyAbCdEfGhIjKlMnOpQrStUvWxYz0123456", clean: "AIzaSyShort" }
|
|
@@ -2072,8 +2077,9 @@ var seal_address_default = {
|
|
|
2072
2077
|
},
|
|
2073
2078
|
approve: {
|
|
2074
2079
|
mime: "application/vnd.seal.approve+json",
|
|
2075
|
-
json: `{"v":2,"ask":"<16 random bytes, base64url>","secret_id":"<k_\u2026>","secret":"<STRIPE_KEY>","guard":"<the guard's address, 43>","host":"api.stripe.com","method":"POST","path":"/v1/refunds?expand=charge","at":"<ISO 8601>","until":"<ISO 8601>","body_bytes":24,"body":"charge=ch_1&amount=50000"?,"body_sha256":"<SHA-256 hex of the whole body>"?,"body_more":true?}`,
|
|
2080
|
+
json: `{"v":2,"ask":"<16 random bytes, base64url>","secret_id":"<k_\u2026>","secret":"<STRIPE_KEY>","guard":"<the guard's address, 43>","from":"<the borrower's address, 43>"?,"host":"api.stripe.com","method":"POST","path":"/v1/refunds?expand=charge","at":"<ISO 8601>","until":"<ISO 8601>","body_bytes":24,"body":"charge=ch_1&amount=50000"?,"body_sha256":"<SHA-256 hex of the whole body>"?,"body_more":true?}`,
|
|
2076
2081
|
body: "What the call carries (AUDIT K152): `path` is the path with its query; `body_bytes` the bytes of the body the guard read; `body` its first `limits.json::APPROVE_BODY_SHOWN_BYTES` bytes when they are text, cut where a character ends, absent for an empty or a binary body; `body_sha256` the digest of the whole body, absent for an empty one and for one that streams on past what the guard reads whole, which `body_more` says. An agent's request holds surrogates, never a value. A reader takes a question without these fields (a guard before them) and shows what it has.",
|
|
2082
|
+
from: "Whose call it is, when the key is lent as use (\xA77.2, \xA77.3: the owner sees who asks): the address the key is lent to, whose guard dialled the owner's gateway. Absent in a question of a call of the owner's own programs, and from a guard before the field.",
|
|
2077
2083
|
is: "A guard's question to a key's owner (SPEC agent egress \xA77.3, \u04214): a call the binding marks `approve: owner` waits for this answer. Sent as a seal addressed to the owner (30 minutes, one open), its share blob marked `payload: approve`; the inbox shows it as a card with Allow and Deny and pushes. Unanswered within `limits.json::APPROVE_WAIT_SECONDS` the call is refused (403 `approve`)."
|
|
2078
2084
|
},
|
|
2079
2085
|
approve_answer: {
|
|
@@ -2177,10 +2183,27 @@ var READ_TIMEOUT_MS = 3e4;
|
|
|
2177
2183
|
function retryable(status) {
|
|
2178
2184
|
return status >= 500 || status === 408 || status === 429;
|
|
2179
2185
|
}
|
|
2186
|
+
async function ask(url, init2, signal, fetchImpl) {
|
|
2187
|
+
const attempt = new AbortController();
|
|
2188
|
+
const follow = () => {
|
|
2189
|
+
attempt.abort(signal.reason);
|
|
2190
|
+
};
|
|
2191
|
+
if (signal.aborted) follow();
|
|
2192
|
+
else signal.addEventListener("abort", follow, { once: true });
|
|
2193
|
+
const timer = setTimeout(() => {
|
|
2194
|
+
attempt.abort(new Error(`storage did not answer in ${READ_TIMEOUT_MS} ms`));
|
|
2195
|
+
}, READ_TIMEOUT_MS);
|
|
2196
|
+
try {
|
|
2197
|
+
return await fetchImpl(url, { ...init2, signal: attempt.signal });
|
|
2198
|
+
} catch (err) {
|
|
2199
|
+
signal.removeEventListener("abort", follow);
|
|
2200
|
+
throw err;
|
|
2201
|
+
} finally {
|
|
2202
|
+
clearTimeout(timer);
|
|
2203
|
+
}
|
|
2204
|
+
}
|
|
2180
2205
|
async function openCiphertext(url, offset, signal, fetchImpl = fetch) {
|
|
2181
|
-
const
|
|
2182
|
-
if (offset > 0) init2.headers = { Range: `bytes=${offset}-` };
|
|
2183
|
-
const response = await fetchImpl(url, init2);
|
|
2206
|
+
const response = await ask(url, offset > 0 ? { headers: { Range: `bytes=${offset}-` } } : {}, signal, fetchImpl);
|
|
2184
2207
|
if (offset > 0 && response.ok && response.status !== 206) {
|
|
2185
2208
|
const err = new Error(`Storage ignored the resume range: ${response.status}`);
|
|
2186
2209
|
err.terminal = true;
|
|
@@ -2281,7 +2304,7 @@ async function firstAnswer(url, signal, fetchImpl) {
|
|
|
2281
2304
|
const stall = { since: null, attempt: 0 };
|
|
2282
2305
|
let first;
|
|
2283
2306
|
try {
|
|
2284
|
-
first = await
|
|
2307
|
+
first = await ask(url, {}, signal, fetchImpl);
|
|
2285
2308
|
} catch (err) {
|
|
2286
2309
|
if (signal.aborted) throw err;
|
|
2287
2310
|
return reopenCiphertext(url, 0, signal, stall, err, () => void 0, fetchImpl);
|
|
@@ -2298,6 +2321,7 @@ async function reopenCiphertext(url, offset, signal, stall, cause, waiting, fetc
|
|
|
2298
2321
|
if (Date.now() - stall.since >= MAX_STALL_MS) {
|
|
2299
2322
|
const err = new Error(`Download stalled for ${MAX_STALL_MS / 1e3} s: ${lastError.message}`);
|
|
2300
2323
|
err.swCode = "NETWORK";
|
|
2324
|
+
err.stalled = true;
|
|
2301
2325
|
throw err;
|
|
2302
2326
|
}
|
|
2303
2327
|
const rung = RETRY_BACKOFF_MS[Math.min(stall.attempt, RETRY_BACKOFF_MS.length - 1)] ?? 0;
|
|
@@ -2732,7 +2756,7 @@ var PageVisit = class {
|
|
|
2732
2756
|
function encode(segment) {
|
|
2733
2757
|
return encodeURIComponent(segment);
|
|
2734
2758
|
}
|
|
2735
|
-
var
|
|
2759
|
+
var READS_REDIRECTS = typeof process !== "undefined" && typeof process.versions?.node === "string" || typeof navigator !== "undefined" && navigator.userAgent === "Cloudflare-Workers";
|
|
2736
2760
|
var SHARE_PROOF_HEADER = crypto_default.share_link.proof_header;
|
|
2737
2761
|
async function shareProof(linkKey) {
|
|
2738
2762
|
const text2 = new TextEncoder();
|
|
@@ -2949,7 +2973,7 @@ var SealApi = class _SealApi {
|
|
|
2949
2973
|
what: `GET /seal/${sealId}/download?file_id=${target.fileId}`,
|
|
2950
2974
|
headers,
|
|
2951
2975
|
signal: opts.signal,
|
|
2952
|
-
...
|
|
2976
|
+
...READS_REDIRECTS ? { redirect: "manual" } : {}
|
|
2953
2977
|
});
|
|
2954
2978
|
const storage = resp.status >= 300 && resp.status < 400 ? resp.headers.get("location") : null;
|
|
2955
2979
|
if (storage === null) return resp;
|
|
@@ -4134,6 +4158,7 @@ async function decryptMetadataField(encrypted, nonce, key2, field) {
|
|
|
4134
4158
|
async function decryptFileMetadata(file, key2) {
|
|
4135
4159
|
let name2 = ENCRYPTED_FILE_FALLBACK;
|
|
4136
4160
|
let mime = ENCRYPTED_MIME_FALLBACK;
|
|
4161
|
+
let mimeRead = false;
|
|
4137
4162
|
if (file.name_encrypted && file.name_nonce && file.name_nonce.length > 0) {
|
|
4138
4163
|
try {
|
|
4139
4164
|
name2 = await decryptMetadataField(file.name_encrypted, file.name_nonce, key2, "name");
|
|
@@ -4144,11 +4169,12 @@ async function decryptFileMetadata(file, key2) {
|
|
|
4144
4169
|
if (file.mime_encrypted && file.mime_nonce && file.mime_nonce.length > 0) {
|
|
4145
4170
|
try {
|
|
4146
4171
|
mime = await decryptMetadataField(file.mime_encrypted, file.mime_nonce, key2, "mime");
|
|
4172
|
+
mimeRead = true;
|
|
4147
4173
|
} catch {
|
|
4148
4174
|
mime = ENCRYPTED_MIME_FALLBACK;
|
|
4149
4175
|
}
|
|
4150
4176
|
}
|
|
4151
|
-
return { name: name2, mime };
|
|
4177
|
+
return { name: name2, mime, mimeRead };
|
|
4152
4178
|
}
|
|
4153
4179
|
async function importKeyForMetadata(keyBytes) {
|
|
4154
4180
|
return crypto.subtle.importKey(
|
|
@@ -4164,7 +4190,7 @@ async function decryptFileMetadataWithBytes(file, keyBytes) {
|
|
|
4164
4190
|
const key2 = await importKeyForMetadata(keyBytes);
|
|
4165
4191
|
return decryptFileMetadata(file, key2);
|
|
4166
4192
|
} catch {
|
|
4167
|
-
return { name: ENCRYPTED_FILE_FALLBACK, mime: ENCRYPTED_MIME_FALLBACK };
|
|
4193
|
+
return { name: ENCRYPTED_FILE_FALLBACK, mime: ENCRYPTED_MIME_FALLBACK, mimeRead: false };
|
|
4168
4194
|
}
|
|
4169
4195
|
}
|
|
4170
4196
|
var log2 = createLogger("upload");
|
|
@@ -5905,6 +5931,15 @@ async function waitForPayment(api, sealId, ownerToken, opts) {
|
|
|
5905
5931
|
await abortableDelay(pause3, opts.signal);
|
|
5906
5932
|
}
|
|
5907
5933
|
}
|
|
5934
|
+
async function paymentWord(api, sealId, ownerToken, opts = {}) {
|
|
5935
|
+
let seal;
|
|
5936
|
+
try {
|
|
5937
|
+
seal = await api.getOwnerSeal(sealId, ownerToken, opts);
|
|
5938
|
+
} catch {
|
|
5939
|
+
return "unanswered";
|
|
5940
|
+
}
|
|
5941
|
+
return seal.tier && seal.tier !== "free" ? seal : "unpaid";
|
|
5942
|
+
}
|
|
5908
5943
|
var TTL_OPTIONS = limits_default.limits.ttl_options;
|
|
5909
5944
|
var countries_default = {
|
|
5910
5945
|
version: 1,
|
|
@@ -6277,7 +6312,7 @@ function parseShareUrl(input) {
|
|
|
6277
6312
|
try {
|
|
6278
6313
|
parsed = parseUrlType(url.pathname.replace(/\/+$/, ""));
|
|
6279
6314
|
} catch {
|
|
6280
|
-
throw new ShareUrlError("url_invalid", `expected /s/<seal_id>[/<share_code>] path (got a path of ${url.pathname.length} characters)`);
|
|
6315
|
+
throw new ShareUrlError("url_invalid", `expected [/<lang>]/s/<seal_id>[/<share_code>] path (got a path of ${url.pathname.length} characters)`);
|
|
6281
6316
|
}
|
|
6282
6317
|
const fragment = url.hash.replace(/^#/, "").trim();
|
|
6283
6318
|
const shareCode = parsed.shareCode ?? null;
|
|
@@ -6291,7 +6326,7 @@ function parseShareUrl(input) {
|
|
|
6291
6326
|
return { sealId: parsed.sealId, shareCode, fragmentVariant: "key", fragment };
|
|
6292
6327
|
}
|
|
6293
6328
|
function parseUrlType(pathname) {
|
|
6294
|
-
const match = pathname.match(
|
|
6329
|
+
const match = pathname.match(/^(?:\/[a-z]{2})?\/s\/([A-Za-z0-9_-]{8})(?:\/([A-Za-z0-9_-]{4}))?$/);
|
|
6295
6330
|
if (!match) throw new Error("Invalid seal URL format");
|
|
6296
6331
|
const sealId = match[1];
|
|
6297
6332
|
const shareCode = match[2];
|
|
@@ -6716,6 +6751,7 @@ function name(value) {
|
|
|
6716
6751
|
return value;
|
|
6717
6752
|
}
|
|
6718
6753
|
var ends_reading = ["seal.revoked", "seal.expired", "seal.not_found", "seal.blocked", "geo.restricted", "client.outdated"];
|
|
6754
|
+
var not_came = { "file.revoked": "taken", "file.verification_failed": "rejected", "single_use.exhausted": "spent", "seal.revoked": "gone", "seal.expired": "gone", "seal.not_found": "gone", "seal.blocked": "gone" };
|
|
6719
6755
|
var SECRET_MIME = secrets_default.mime;
|
|
6720
6756
|
var ranOut = (err) => err.appCode === "seal.expired";
|
|
6721
6757
|
function clientOutdated(err) {
|
|
@@ -6732,7 +6768,12 @@ var OpenError = class extends Error {
|
|
|
6732
6768
|
}
|
|
6733
6769
|
};
|
|
6734
6770
|
var SEAL_ENDS = new Set(ends_reading);
|
|
6771
|
+
var REASONS = /* @__PURE__ */ new Set(["taken", "rejected", "spent", "gone"]);
|
|
6772
|
+
var NOT_CAME = Object.fromEntries(
|
|
6773
|
+
Object.entries(not_came).filter((row) => REASONS.has(row[1]))
|
|
6774
|
+
);
|
|
6735
6775
|
function refusalScope(err) {
|
|
6776
|
+
if (err?.stalled === true) return "seal";
|
|
6736
6777
|
if (!(err instanceof BackendError)) return "file";
|
|
6737
6778
|
if (err.status === 451 || err.status === 426 || err.appCode !== void 0 && SEAL_ENDS.has(err.appCode)) return "seal";
|
|
6738
6779
|
if (err.status === 429 || err.status >= 500) return "transient";
|
|
@@ -6785,9 +6826,7 @@ async function openShareLink(api, url, opts = {}) {
|
|
|
6785
6826
|
if (wire.gone === true) {
|
|
6786
6827
|
throw new OpenError("seal_revoked", `seal ${parsed.sealId}: nothing in it is left to open; ask its sender to send it again`);
|
|
6787
6828
|
}
|
|
6788
|
-
|
|
6789
|
-
const offered = meta.files.filter((f) => live.has(f.id));
|
|
6790
|
-
if (offered.length === 0) {
|
|
6829
|
+
if (meta.files.length === 0) {
|
|
6791
6830
|
throw new OpenError(
|
|
6792
6831
|
"seal_not_ready",
|
|
6793
6832
|
`seal ${parsed.sealId} has no files available yet: the server verifies an upload before offering it. Retry in a few seconds.`
|
|
@@ -6845,7 +6884,7 @@ async function openShareLink(api, url, opts = {}) {
|
|
|
6845
6884
|
err
|
|
6846
6885
|
);
|
|
6847
6886
|
}
|
|
6848
|
-
const files = await Promise.all(
|
|
6887
|
+
const files = await Promise.all(meta.files.map((f) => describeFile(f, fileKeys, bindings)));
|
|
6849
6888
|
return {
|
|
6850
6889
|
sealId,
|
|
6851
6890
|
shareCode,
|
|
@@ -7031,8 +7070,8 @@ async function describeFile(file, fileKeys, bindings) {
|
|
|
7031
7070
|
if (key2.length !== KEY_BYTES2) {
|
|
7032
7071
|
throw new OpenError("share_blob_corrupt", `share blob key for ${file.sha256_hex} is ${key2.length} bytes`);
|
|
7033
7072
|
}
|
|
7034
|
-
const { name: name2, mime } = await decryptFileMetadataWithBytes(file, key2);
|
|
7035
|
-
const secret = bareMime(mime) === SECRET_MIME;
|
|
7073
|
+
const { name: name2, mime, mimeRead } = await decryptFileMetadataWithBytes(file, key2);
|
|
7074
|
+
const secret = !mimeRead || bareMime(mime) === SECRET_MIME;
|
|
7036
7075
|
const binding = secret && file.sha256_hex ? bindings[file.sha256_hex] ?? null : null;
|
|
7037
7076
|
return { ...base, name: name2, mime, secret, key: key2, binding };
|
|
7038
7077
|
}
|
|
@@ -7304,7 +7343,11 @@ var limits_default2 = {
|
|
|
7304
7343
|
SENSOR_NOVELTY_WINDOW_DAYS: 30,
|
|
7305
7344
|
SENSOR_HOLD_TTL_SECONDS: 86400,
|
|
7306
7345
|
SENSOR_BASELINE_MIN_HOURS: 72,
|
|
7307
|
-
SENSOR_GROWTH_BYTES_PER_DAY_DEFAULT: 107374182400
|
|
7346
|
+
SENSOR_GROWTH_BYTES_PER_DAY_DEFAULT: 107374182400,
|
|
7347
|
+
CLIENT_EVENT_STRING_MAX_CHARS: 512,
|
|
7348
|
+
CLIENT_EVENT_MAX_BYTES: 4096,
|
|
7349
|
+
CLIENT_EVENT_ID_MAX_CHARS: 64,
|
|
7350
|
+
CLIENT_EVENT_COUNT_MAX: 1e6
|
|
7308
7351
|
}
|
|
7309
7352
|
};
|
|
7310
7353
|
|
|
@@ -7622,11 +7665,11 @@ var AnonymousSealsSendResource = class {
|
|
|
7622
7665
|
const deadline = paymentDeadline(session instanceof UploadSession ? session.expiresAt : void 0);
|
|
7623
7666
|
let paid = await waitForPayment(this.api, session.sealId, keys.ownerTokenB64, { deadline, ...signalOpt });
|
|
7624
7667
|
if (!paid) {
|
|
7625
|
-
const now = await this.api
|
|
7626
|
-
if (
|
|
7668
|
+
const now = await paymentWord(this.api, session.sealId, keys.ownerTokenB64, signalOpt);
|
|
7669
|
+
if (now === "unanswered") {
|
|
7627
7670
|
throw new SealError("The seal may be paid and was kept, not revoked", "PAYMENT_REQUIRED", 402, recovery(session.sealId));
|
|
7628
7671
|
}
|
|
7629
|
-
if (now
|
|
7672
|
+
if (now !== "unpaid") paid = now;
|
|
7630
7673
|
}
|
|
7631
7674
|
if (!paid) {
|
|
7632
7675
|
await this.api.revoke(session.sealId, keys.ownerTokenB64).catch(() => void 0);
|
|
@@ -7815,6 +7858,33 @@ function asFile(source2, name2, type) {
|
|
|
7815
7858
|
return new File([bytes], name2, { type: mime });
|
|
7816
7859
|
}
|
|
7817
7860
|
|
|
7861
|
+
async function folderIn(dir, parts) {
|
|
7862
|
+
const fs = await import(
|
|
7863
|
+
/* webpackIgnore: true */
|
|
7864
|
+
/* @vite-ignore */
|
|
7865
|
+
"fs/promises"
|
|
7866
|
+
);
|
|
7867
|
+
const path = await import(
|
|
7868
|
+
/* webpackIgnore: true */
|
|
7869
|
+
/* @vite-ignore */
|
|
7870
|
+
"path"
|
|
7871
|
+
);
|
|
7872
|
+
await fs.mkdir(dir, { recursive: true });
|
|
7873
|
+
let at = dir;
|
|
7874
|
+
for (const part of parts) {
|
|
7875
|
+
let made = null;
|
|
7876
|
+
for (let i = 0; i < 1e3 && made === null; i++) {
|
|
7877
|
+
const candidate = path.join(at, i === 0 ? part : `${part} (${i})`);
|
|
7878
|
+
await fs.mkdir(candidate).catch((err) => {
|
|
7879
|
+
if (err.code !== "EEXIST") throw err;
|
|
7880
|
+
});
|
|
7881
|
+
if ((await fs.lstat(candidate)).isDirectory()) made = candidate;
|
|
7882
|
+
}
|
|
7883
|
+
if (made === null) throw new Error(`no free name for the folder ${part} in ${at}`);
|
|
7884
|
+
at = made;
|
|
7885
|
+
}
|
|
7886
|
+
return at;
|
|
7887
|
+
}
|
|
7818
7888
|
async function receiveToDisk(opened, dir, name2) {
|
|
7819
7889
|
const fs = await import(
|
|
7820
7890
|
/* webpackIgnore: true */
|
|
@@ -7942,7 +8012,7 @@ async function saveLink(api, url, dir, opts = {}, wrap = null) {
|
|
|
7942
8012
|
const save = async (file) => {
|
|
7943
8013
|
const parts = savePathOf(file.name);
|
|
7944
8014
|
const name2 = parts.pop() ?? sanitizeFilename(file.name);
|
|
7945
|
-
const into = parts.length > 0 ?
|
|
8015
|
+
const into = parts.length > 0 ? await folderIn(dir || ".", parts) : dir;
|
|
7946
8016
|
const saved = await receiveToDisk(await read(file), into, name2);
|
|
7947
8017
|
return { name: file.name, mime: file.mime, secret: file.secret, ...saved };
|
|
7948
8018
|
};
|
|
@@ -8106,7 +8176,7 @@ async function dismissItem(api, item, opts) {
|
|
|
8106
8176
|
}
|
|
8107
8177
|
|
|
8108
8178
|
// src/index.ts
|
|
8109
|
-
var [CLIENT_NAME = "", CLIENT_VERSION = ""] = "sealnet-js/3.2.
|
|
8179
|
+
var [CLIENT_NAME = "", CLIENT_VERSION = ""] = "sealnet-js/3.2.4".split("/");
|
|
8110
8180
|
if (typeof globalThis.process?.versions?.node !== "string") {
|
|
8111
8181
|
configureWasm(define_SEAL_WASM_default);
|
|
8112
8182
|
}
|