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 CHANGED
@@ -25,8 +25,8 @@ and the SDK arrives as one global.
25
25
 
26
26
  ```html
27
27
  <script
28
- src="https://seal.net/sdk/v3.2.1/seal.js"
29
- integrity="sha384-ATE9Q23AuTZ5Nf4e30SSgMm7jyQZ1AE1VrjfTyQgKraiHeQZluYqEyyAnFc6Pilj"
28
+ src="https://seal.net/sdk/v3.2.4/seal.js"
29
+ integrity="sha384-AbbnJ+QkztV4sjZluK4d+Y5tkvrA2QHHeEzhg6eiJ+OgjLAQHFffGOWPvsdAEm8g"
30
30
  crossorigin="anonymous"
31
31
  ></script>
32
32
  <script>
@@ -1,4 +1,4 @@
1
- sealnet 3.2.1 — third-party notices
1
+ sealnet 3.2.4 — third-party notices
2
2
 
3
3
  The standalone browser build (dist/seal.global.js, also published at
4
4
  https://seal.net/sdk/v<version>/seal.js) bundles the software below.
package/dist/index.cjs CHANGED
@@ -38,7 +38,7 @@ __export(index_exports, {
38
38
  module.exports = __toCommonJS(index_exports);
39
39
 
40
40
  // <define:__SEAL_WASM__>
41
- var define_SEAL_WASM_default = { url: "https://seal.net/sdk/v3.2.1/seal_crypto.wasm", integrity: "sha384-shTJxj/f3gaTmjkHcR/wAxbvWNYCj4V/CY2RYpaWzTc02d58QB2ii6Lm1UMdh0T7" };
41
+ var define_SEAL_WASM_default = { url: "https://seal.net/sdk/v3.2.4/seal_crypto.wasm", integrity: "sha384-J9NTJFphVX/NdC0pcwJmhENoDqXMqj6caYtMhwzS4t9Bs+uIfpd4FuY2gX/Q4LFZ" };
42
42
 
43
43
  var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.tagName.toUpperCase() === "SCRIPT" ? document.currentScript.src : new URL("main.js", document.baseURI).href;
44
44
  var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
@@ -313,10 +313,10 @@ var WasmIdentity = class _WasmIdentity {
313
313
  * @param {string} at
314
314
  * @returns {Uint8Array}
315
315
  */
316
- signApproval(ask, decision, at) {
316
+ signApproval(ask2, decision, at) {
317
317
  try {
318
318
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
319
- const ptr0 = passStringToWasm0(ask, wasm.__wbindgen_export3, wasm.__wbindgen_export4);
319
+ const ptr0 = passStringToWasm0(ask2, wasm.__wbindgen_export3, wasm.__wbindgen_export4);
320
320
  const len0 = WASM_VECTOR_LEN;
321
321
  const ptr1 = passStringToWasm0(decision, wasm.__wbindgen_export3, wasm.__wbindgen_export4);
322
322
  const len1 = WASM_VECTOR_LEN;
@@ -470,12 +470,12 @@ if (Symbol.dispose) WasmIdentity.prototype[Symbol.dispose] = WasmIdentity.protot
470
470
  function init() {
471
471
  wasm.init();
472
472
  }
473
- function wasm_approval_message(ask, decision, at) {
473
+ function wasm_approval_message(ask2, decision, at) {
474
474
  let deferred5_0;
475
475
  let deferred5_1;
476
476
  try {
477
477
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
478
- const ptr0 = passStringToWasm0(ask, wasm.__wbindgen_export3, wasm.__wbindgen_export4);
478
+ const ptr0 = passStringToWasm0(ask2, wasm.__wbindgen_export3, wasm.__wbindgen_export4);
479
479
  const len0 = WASM_VECTOR_LEN;
480
480
  const ptr1 = passStringToWasm0(decision, wasm.__wbindgen_export3, wasm.__wbindgen_export4);
481
481
  const len1 = WASM_VECTOR_LEN;
@@ -1429,7 +1429,11 @@ var limits_default = {
1429
1429
  SENSOR_NOVELTY_WINDOW_DAYS: 30,
1430
1430
  SENSOR_HOLD_TTL_SECONDS: 86400,
1431
1431
  SENSOR_BASELINE_MIN_HOURS: 72,
1432
- SENSOR_GROWTH_BYTES_PER_DAY_DEFAULT: 107374182400
1432
+ SENSOR_GROWTH_BYTES_PER_DAY_DEFAULT: 107374182400,
1433
+ CLIENT_EVENT_STRING_MAX_CHARS: 512,
1434
+ CLIENT_EVENT_MAX_BYTES: 4096,
1435
+ CLIENT_EVENT_ID_MAX_CHARS: 64,
1436
+ CLIENT_EVENT_COUNT_MAX: 1e6
1433
1437
  }
1434
1438
  };
1435
1439
  var secrets_default = {
@@ -1467,7 +1471,7 @@ var secrets_default = {
1467
1471
  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"],
1468
1472
  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.",
1469
1473
  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).",
1470
- 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.",
1474
+ 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.",
1471
1475
  provision_commands: [
1472
1476
  { command: "wrangler secret put", host: "api.cloudflare.com" },
1473
1477
  { command: "gh secret set", host: "api.github.com" },
@@ -1621,6 +1625,7 @@ var secrets_default = {
1621
1625
  keywords: ["google", "api", "AIza"],
1622
1626
  hosts: ["*.googleapis.com"],
1623
1627
  place: "query:key",
1628
+ headers: ["x-goog-api-key"],
1624
1629
  class: "outbound",
1625
1630
  surrogate: { keep_prefix: "^AIza", alphabet: "base64url" },
1626
1631
  vectors: { hit: "AIzaSyAbCdEfGhIjKlMnOpQrStUvWxYz0123456", clean: "AIzaSyShort" }
@@ -2114,8 +2119,9 @@ var seal_address_default = {
2114
2119
  },
2115
2120
  approve: {
2116
2121
  mime: "application/vnd.seal.approve+json",
2117
- 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?}`,
2122
+ 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?}`,
2118
2123
  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.",
2124
+ 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.",
2119
2125
  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`)."
2120
2126
  },
2121
2127
  approve_answer: {
@@ -2219,10 +2225,27 @@ var READ_TIMEOUT_MS = 3e4;
2219
2225
  function retryable(status) {
2220
2226
  return status >= 500 || status === 408 || status === 429;
2221
2227
  }
2228
+ async function ask(url, init2, signal, fetchImpl) {
2229
+ const attempt = new AbortController();
2230
+ const follow = () => {
2231
+ attempt.abort(signal.reason);
2232
+ };
2233
+ if (signal.aborted) follow();
2234
+ else signal.addEventListener("abort", follow, { once: true });
2235
+ const timer = setTimeout(() => {
2236
+ attempt.abort(new Error(`storage did not answer in ${READ_TIMEOUT_MS} ms`));
2237
+ }, READ_TIMEOUT_MS);
2238
+ try {
2239
+ return await fetchImpl(url, { ...init2, signal: attempt.signal });
2240
+ } catch (err) {
2241
+ signal.removeEventListener("abort", follow);
2242
+ throw err;
2243
+ } finally {
2244
+ clearTimeout(timer);
2245
+ }
2246
+ }
2222
2247
  async function openCiphertext(url, offset, signal, fetchImpl = fetch) {
2223
- const init2 = { signal };
2224
- if (offset > 0) init2.headers = { Range: `bytes=${offset}-` };
2225
- const response = await fetchImpl(url, init2);
2248
+ const response = await ask(url, offset > 0 ? { headers: { Range: `bytes=${offset}-` } } : {}, signal, fetchImpl);
2226
2249
  if (offset > 0 && response.ok && response.status !== 206) {
2227
2250
  const err = new Error(`Storage ignored the resume range: ${response.status}`);
2228
2251
  err.terminal = true;
@@ -2323,7 +2346,7 @@ async function firstAnswer(url, signal, fetchImpl) {
2323
2346
  const stall = { since: null, attempt: 0 };
2324
2347
  let first;
2325
2348
  try {
2326
- first = await fetchImpl(url, { signal });
2349
+ first = await ask(url, {}, signal, fetchImpl);
2327
2350
  } catch (err) {
2328
2351
  if (signal.aborted) throw err;
2329
2352
  return reopenCiphertext(url, 0, signal, stall, err, () => void 0, fetchImpl);
@@ -2340,6 +2363,7 @@ async function reopenCiphertext(url, offset, signal, stall, cause, waiting, fetc
2340
2363
  if (Date.now() - stall.since >= MAX_STALL_MS) {
2341
2364
  const err = new Error(`Download stalled for ${MAX_STALL_MS / 1e3} s: ${lastError.message}`);
2342
2365
  err.swCode = "NETWORK";
2366
+ err.stalled = true;
2343
2367
  throw err;
2344
2368
  }
2345
2369
  const rung = RETRY_BACKOFF_MS[Math.min(stall.attempt, RETRY_BACKOFF_MS.length - 1)] ?? 0;
@@ -2774,7 +2798,7 @@ var PageVisit = class {
2774
2798
  function encode(segment) {
2775
2799
  return encodeURIComponent(segment);
2776
2800
  }
2777
- var IN_NODE = typeof process !== "undefined" && typeof process.versions?.node === "string";
2801
+ var READS_REDIRECTS = typeof process !== "undefined" && typeof process.versions?.node === "string" || typeof navigator !== "undefined" && navigator.userAgent === "Cloudflare-Workers";
2778
2802
  var SHARE_PROOF_HEADER = crypto_default.share_link.proof_header;
2779
2803
  async function shareProof(linkKey) {
2780
2804
  const text2 = new TextEncoder();
@@ -2991,7 +3015,7 @@ var SealApi = class _SealApi {
2991
3015
  what: `GET /seal/${sealId}/download?file_id=${target.fileId}`,
2992
3016
  headers,
2993
3017
  signal: opts.signal,
2994
- ...IN_NODE ? { redirect: "manual" } : {}
3018
+ ...READS_REDIRECTS ? { redirect: "manual" } : {}
2995
3019
  });
2996
3020
  const storage = resp.status >= 300 && resp.status < 400 ? resp.headers.get("location") : null;
2997
3021
  if (storage === null) return resp;
@@ -4176,6 +4200,7 @@ async function decryptMetadataField(encrypted, nonce, key2, field) {
4176
4200
  async function decryptFileMetadata(file, key2) {
4177
4201
  let name2 = ENCRYPTED_FILE_FALLBACK;
4178
4202
  let mime = ENCRYPTED_MIME_FALLBACK;
4203
+ let mimeRead = false;
4179
4204
  if (file.name_encrypted && file.name_nonce && file.name_nonce.length > 0) {
4180
4205
  try {
4181
4206
  name2 = await decryptMetadataField(file.name_encrypted, file.name_nonce, key2, "name");
@@ -4186,11 +4211,12 @@ async function decryptFileMetadata(file, key2) {
4186
4211
  if (file.mime_encrypted && file.mime_nonce && file.mime_nonce.length > 0) {
4187
4212
  try {
4188
4213
  mime = await decryptMetadataField(file.mime_encrypted, file.mime_nonce, key2, "mime");
4214
+ mimeRead = true;
4189
4215
  } catch {
4190
4216
  mime = ENCRYPTED_MIME_FALLBACK;
4191
4217
  }
4192
4218
  }
4193
- return { name: name2, mime };
4219
+ return { name: name2, mime, mimeRead };
4194
4220
  }
4195
4221
  async function importKeyForMetadata(keyBytes) {
4196
4222
  return crypto.subtle.importKey(
@@ -4206,7 +4232,7 @@ async function decryptFileMetadataWithBytes(file, keyBytes) {
4206
4232
  const key2 = await importKeyForMetadata(keyBytes);
4207
4233
  return decryptFileMetadata(file, key2);
4208
4234
  } catch {
4209
- return { name: ENCRYPTED_FILE_FALLBACK, mime: ENCRYPTED_MIME_FALLBACK };
4235
+ return { name: ENCRYPTED_FILE_FALLBACK, mime: ENCRYPTED_MIME_FALLBACK, mimeRead: false };
4210
4236
  }
4211
4237
  }
4212
4238
  var log2 = createLogger("upload");
@@ -5947,6 +5973,15 @@ async function waitForPayment(api, sealId, ownerToken, opts) {
5947
5973
  await abortableDelay(pause3, opts.signal);
5948
5974
  }
5949
5975
  }
5976
+ async function paymentWord(api, sealId, ownerToken, opts = {}) {
5977
+ let seal;
5978
+ try {
5979
+ seal = await api.getOwnerSeal(sealId, ownerToken, opts);
5980
+ } catch {
5981
+ return "unanswered";
5982
+ }
5983
+ return seal.tier && seal.tier !== "free" ? seal : "unpaid";
5984
+ }
5950
5985
  var TTL_OPTIONS = limits_default.limits.ttl_options;
5951
5986
  var countries_default = {
5952
5987
  version: 1,
@@ -6319,7 +6354,7 @@ function parseShareUrl(input) {
6319
6354
  try {
6320
6355
  parsed = parseUrlType(url.pathname.replace(/\/+$/, ""));
6321
6356
  } catch {
6322
- throw new ShareUrlError("url_invalid", `expected /s/<seal_id>[/<share_code>] path (got a path of ${url.pathname.length} characters)`);
6357
+ throw new ShareUrlError("url_invalid", `expected [/<lang>]/s/<seal_id>[/<share_code>] path (got a path of ${url.pathname.length} characters)`);
6323
6358
  }
6324
6359
  const fragment = url.hash.replace(/^#/, "").trim();
6325
6360
  const shareCode = parsed.shareCode ?? null;
@@ -6333,7 +6368,7 @@ function parseShareUrl(input) {
6333
6368
  return { sealId: parsed.sealId, shareCode, fragmentVariant: "key", fragment };
6334
6369
  }
6335
6370
  function parseUrlType(pathname) {
6336
- const match = pathname.match(/^\/s\/([A-Za-z0-9_-]{8})(?:\/([A-Za-z0-9_-]{4}))?$/);
6371
+ const match = pathname.match(/^(?:\/[a-z]{2})?\/s\/([A-Za-z0-9_-]{8})(?:\/([A-Za-z0-9_-]{4}))?$/);
6337
6372
  if (!match) throw new Error("Invalid seal URL format");
6338
6373
  const sealId = match[1];
6339
6374
  const shareCode = match[2];
@@ -6758,6 +6793,7 @@ function name(value) {
6758
6793
  return value;
6759
6794
  }
6760
6795
  var ends_reading = ["seal.revoked", "seal.expired", "seal.not_found", "seal.blocked", "geo.restricted", "client.outdated"];
6796
+ 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" };
6761
6797
  var SECRET_MIME = secrets_default.mime;
6762
6798
  var ranOut = (err) => err.appCode === "seal.expired";
6763
6799
  function clientOutdated(err) {
@@ -6774,7 +6810,12 @@ var OpenError = class extends Error {
6774
6810
  }
6775
6811
  };
6776
6812
  var SEAL_ENDS = new Set(ends_reading);
6813
+ var REASONS = /* @__PURE__ */ new Set(["taken", "rejected", "spent", "gone"]);
6814
+ var NOT_CAME = Object.fromEntries(
6815
+ Object.entries(not_came).filter((row) => REASONS.has(row[1]))
6816
+ );
6777
6817
  function refusalScope(err) {
6818
+ if (err?.stalled === true) return "seal";
6778
6819
  if (!(err instanceof BackendError)) return "file";
6779
6820
  if (err.status === 451 || err.status === 426 || err.appCode !== void 0 && SEAL_ENDS.has(err.appCode)) return "seal";
6780
6821
  if (err.status === 429 || err.status >= 500) return "transient";
@@ -6827,9 +6868,7 @@ async function openShareLink(api, url, opts = {}) {
6827
6868
  if (wire.gone === true) {
6828
6869
  throw new OpenError("seal_revoked", `seal ${parsed.sealId}: nothing in it is left to open; ask its sender to send it again`);
6829
6870
  }
6830
- const live = new Set(wire.files.filter((f) => !f.revoked_at).map((f) => f.id));
6831
- const offered = meta.files.filter((f) => live.has(f.id));
6832
- if (offered.length === 0) {
6871
+ if (meta.files.length === 0) {
6833
6872
  throw new OpenError(
6834
6873
  "seal_not_ready",
6835
6874
  `seal ${parsed.sealId} has no files available yet: the server verifies an upload before offering it. Retry in a few seconds.`
@@ -6887,7 +6926,7 @@ async function openShareLink(api, url, opts = {}) {
6887
6926
  err
6888
6927
  );
6889
6928
  }
6890
- const files = await Promise.all(offered.map((f) => describeFile(f, fileKeys, bindings)));
6929
+ const files = await Promise.all(meta.files.map((f) => describeFile(f, fileKeys, bindings)));
6891
6930
  return {
6892
6931
  sealId,
6893
6932
  shareCode,
@@ -7073,8 +7112,8 @@ async function describeFile(file, fileKeys, bindings) {
7073
7112
  if (key2.length !== KEY_BYTES2) {
7074
7113
  throw new OpenError("share_blob_corrupt", `share blob key for ${file.sha256_hex} is ${key2.length} bytes`);
7075
7114
  }
7076
- const { name: name2, mime } = await decryptFileMetadataWithBytes(file, key2);
7077
- const secret = bareMime(mime) === SECRET_MIME;
7115
+ const { name: name2, mime, mimeRead } = await decryptFileMetadataWithBytes(file, key2);
7116
+ const secret = !mimeRead || bareMime(mime) === SECRET_MIME;
7078
7117
  const binding = secret && file.sha256_hex ? bindings[file.sha256_hex] ?? null : null;
7079
7118
  return { ...base, name: name2, mime, secret, key: key2, binding };
7080
7119
  }
@@ -7346,7 +7385,11 @@ var limits_default2 = {
7346
7385
  SENSOR_NOVELTY_WINDOW_DAYS: 30,
7347
7386
  SENSOR_HOLD_TTL_SECONDS: 86400,
7348
7387
  SENSOR_BASELINE_MIN_HOURS: 72,
7349
- SENSOR_GROWTH_BYTES_PER_DAY_DEFAULT: 107374182400
7388
+ SENSOR_GROWTH_BYTES_PER_DAY_DEFAULT: 107374182400,
7389
+ CLIENT_EVENT_STRING_MAX_CHARS: 512,
7390
+ CLIENT_EVENT_MAX_BYTES: 4096,
7391
+ CLIENT_EVENT_ID_MAX_CHARS: 64,
7392
+ CLIENT_EVENT_COUNT_MAX: 1e6
7350
7393
  }
7351
7394
  };
7352
7395
 
@@ -7664,11 +7707,11 @@ var AnonymousSealsSendResource = class {
7664
7707
  const deadline = paymentDeadline(session instanceof UploadSession ? session.expiresAt : void 0);
7665
7708
  let paid = await waitForPayment(this.api, session.sealId, keys.ownerTokenB64, { deadline, ...signalOpt });
7666
7709
  if (!paid) {
7667
- const now = await this.api.getOwnerSeal(session.sealId, keys.ownerTokenB64, signalOpt).catch(() => void 0);
7668
- if (!now) {
7710
+ const now = await paymentWord(this.api, session.sealId, keys.ownerTokenB64, signalOpt);
7711
+ if (now === "unanswered") {
7669
7712
  throw new SealError("The seal may be paid and was kept, not revoked", "PAYMENT_REQUIRED", 402, recovery(session.sealId));
7670
7713
  }
7671
- if (now.tier && now.tier !== "free") paid = now;
7714
+ if (now !== "unpaid") paid = now;
7672
7715
  }
7673
7716
  if (!paid) {
7674
7717
  await this.api.revoke(session.sealId, keys.ownerTokenB64).catch(() => void 0);
@@ -7857,6 +7900,33 @@ function asFile(source2, name2, type) {
7857
7900
  return new File([bytes], name2, { type: mime });
7858
7901
  }
7859
7902
 
7903
+ async function folderIn(dir, parts) {
7904
+ const fs = await import(
7905
+ /* webpackIgnore: true */
7906
+ /* @vite-ignore */
7907
+ "fs/promises"
7908
+ );
7909
+ const path = await import(
7910
+ /* webpackIgnore: true */
7911
+ /* @vite-ignore */
7912
+ "path"
7913
+ );
7914
+ await fs.mkdir(dir, { recursive: true });
7915
+ let at = dir;
7916
+ for (const part of parts) {
7917
+ let made = null;
7918
+ for (let i = 0; i < 1e3 && made === null; i++) {
7919
+ const candidate = path.join(at, i === 0 ? part : `${part} (${i})`);
7920
+ await fs.mkdir(candidate).catch((err) => {
7921
+ if (err.code !== "EEXIST") throw err;
7922
+ });
7923
+ if ((await fs.lstat(candidate)).isDirectory()) made = candidate;
7924
+ }
7925
+ if (made === null) throw new Error(`no free name for the folder ${part} in ${at}`);
7926
+ at = made;
7927
+ }
7928
+ return at;
7929
+ }
7860
7930
  async function receiveToDisk(opened, dir, name2) {
7861
7931
  const fs = await import(
7862
7932
  /* webpackIgnore: true */
@@ -7984,7 +8054,7 @@ async function saveLink(api, url, dir, opts = {}, wrap = null) {
7984
8054
  const save = async (file) => {
7985
8055
  const parts = savePathOf(file.name);
7986
8056
  const name2 = parts.pop() ?? sanitizeFilename(file.name);
7987
- const into = parts.length > 0 ? [dir || ".", ...parts].join("/") : dir;
8057
+ const into = parts.length > 0 ? await folderIn(dir || ".", parts) : dir;
7988
8058
  const saved = await receiveToDisk(await read(file), into, name2);
7989
8059
  return { name: file.name, mime: file.mime, secret: file.secret, ...saved };
7990
8060
  };
@@ -8148,7 +8218,7 @@ async function dismissItem(api, item, opts) {
8148
8218
  }
8149
8219
 
8150
8220
  // src/index.ts
8151
- var [CLIENT_NAME = "", CLIENT_VERSION = ""] = "sealnet-js/3.2.1".split("/");
8221
+ var [CLIENT_NAME = "", CLIENT_VERSION = ""] = "sealnet-js/3.2.4".split("/");
8152
8222
  if (typeof globalThis.process?.versions?.node !== "string") {
8153
8223
  configureWasm(define_SEAL_WASM_default);
8154
8224
  }