sealnet 1.1.2 → 1.2.0

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
@@ -20,8 +20,8 @@ and the SDK arrives as one global.
20
20
 
21
21
  ```html
22
22
  <script
23
- src="https://seal.net/sdk/v1.1.2/seal.js"
24
- integrity="sha384-UIrqgmFzwnFcAQT0JSG+L3exdN7uMFtWpHVJpks1Cx1gcFKtLxvSuOMrEKHVEh0O"
23
+ src="https://seal.net/sdk/v1.2.0/seal.js"
24
+ integrity="sha384-Z9JT8V6dg70AeS2wMJiHucnsDHMrpgKm0nl2x5I4qp6Rpm0IVAQe/z9eTKEKumRP"
25
25
  crossorigin="anonymous"
26
26
  ></script>
27
27
  <script>
@@ -170,6 +170,29 @@ answer.files[0].path // the value stays in the file
170
170
 
171
171
  A link addressed to your key opens with `open(link, { keyPair: keys })`.
172
172
 
173
+ ## Sending to a key, and your inbox
174
+
175
+ Your key's public half is your address. `secretKey` is the same value as
176
+ `SEAL_SEED` of the `seal` CLI and of `sealnet-mcp`, so one key gives one
177
+ address in every client. `send({ to })` addresses the link to
178
+ someone's address: it opens only with their key, and it lands in their inbox,
179
+ so nobody has to pass the link on.
180
+
181
+ ```typescript
182
+ const sent = await seal.send({ file, filename: 'report.pdf', ttl: '30m', to: theirAddress })
183
+ sent.delivered // true: it is in their inbox
184
+
185
+ const inbox = await seal.inbox({ keyPair: keys, wait: 60 }) // waits up to 60 s for something
186
+ for (const item of inbox.items) {
187
+ // item: { id, from (three emoji of the sender, or null), label, receivedAt, expiresAt }
188
+ const saved = await seal.open(item, { keyPair: keys, to: './downloads' })
189
+ await seal.dismiss(item, { keyPair: keys })
190
+ }
191
+ ```
192
+
193
+ The inbox is shown only to the holder of the key. Pass `seen: inbox.version`
194
+ to wait for the next change instead of the next item.
195
+
173
196
  ## Error handling
174
197
 
175
198
  ```typescript
@@ -1,4 +1,4 @@
1
- sealnet 1.1.2 — third-party notices
1
+ sealnet 1.2.0 — 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
@@ -2126,9 +2126,60 @@ var limits_default = {
2126
2126
  INTAKE_TTL_DEFAULT_SECONDS: 900,
2127
2127
  INTAKE_TTL_MAX_SECONDS: 86400,
2128
2128
  INTAKE_WAIT_MAX_SECONDS: 25,
2129
- PAYMENT_WAIT_MAX_SECONDS: 82800
2129
+ PAYMENT_WAIT_MAX_SECONDS: 82800,
2130
+ ADDRESS_PROOF_TTL_SECONDS: 300,
2131
+ INBOX_MAX_ITEMS: 200
2130
2132
  }
2131
2133
  };
2134
+ var seal_address_v1_default = {
2135
+ version: 1,
2136
+ $comment: "Address of a key: who a seal is for, without a URL (audit/SPEC-ADDRESS.md). Numbers live in limits.json, error codes in error_codes.json.",
2137
+ address: {
2138
+ key: "X25519 public key, 32 bytes",
2139
+ text: "base64url without padding, 43 characters",
2140
+ emoji: "fingerprint_emoji.json over sha256(key)[0..3], the same picture as intake",
2141
+ inbox_hash: "sha256(key), 32 bytes: the server finds an inbox by it"
2142
+ },
2143
+ seed: {
2144
+ env: "SEAL_SEED",
2145
+ text: "base64url without padding of the 32-byte X25519 secret, 43 characters",
2146
+ same_as: [
2147
+ "sealnet-mcp state.identity.x25519_secret_b64",
2148
+ "seal identity.v1.json x25519_secret_b64url",
2149
+ "sealnet (npm) KeyPair.secretKey",
2150
+ "sealnet (PyPI) keygen().secret_key"
2151
+ ]
2152
+ },
2153
+ scopes: {
2154
+ share_link: "seal_share",
2155
+ owner_copy: "seal_owner",
2156
+ address_proof: "seal_address_proof"
2157
+ },
2158
+ proof: {
2159
+ header_address: "X-Seal-Address",
2160
+ header_proof: "X-Seal-Proof",
2161
+ proof_text: "<ts>.<token>: ts is the decimal Unix second from the challenge, token base64url of 32 bytes",
2162
+ challenge: "sealed box of the 32-byte token to the address with scope (address_proof, decimal ts): ephemeral_pub(32) || nonce(12) || ciphertext(48), base64url, 123 characters",
2163
+ token: "opaque to clients: unwrap it and send it back"
2164
+ },
2165
+ items: {
2166
+ delivery: {
2167
+ id: "s.<seal_id>.<share_code>",
2168
+ is: "a share link addressed to this key; fragment = its key wrapped to the address (x25519:, targeted_x25519_v1, scope share_link)"
2169
+ }
2170
+ },
2171
+ request_kinds: ["secret", "file", "any"],
2172
+ vectors: [
2173
+ {
2174
+ comment: "generated once by backend_crypto.sealed_box.seal_key_for_recipient; every client must unwrap it",
2175
+ secret: "BwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwc",
2176
+ address: "E75P6uryBMf9M1j8nAByGIHRdCeBKCJ-xnTzf3_pe20",
2177
+ ts: 179e7,
2178
+ challenge: "4Oel-UMfgP_1dBhmf13yZiujhPDouCIQ6sSx1nY1qy-vyzFqDqb9jARbJ0e5A8vv4EDELDS5OPqBQMcsmDA-C_lXO95y_CVUyYtSu-1fltsy5ZihOFDp0T-C9Ro",
2179
+ token: "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8"
2180
+ }
2181
+ ]
2182
+ };
2132
2183
  var upload_default = {
2133
2184
  version: 1,
2134
2185
  upload: {
@@ -2460,13 +2511,24 @@ var SealApi = class _SealApi {
2460
2511
  });
2461
2512
  return { etag: resp.headers.get("ETag") };
2462
2513
  }
2463
- /** `POST /seal/{id}/share` — mint a share link, returns its code. */
2514
+ /**
2515
+ * `POST /seal/{id}/share` — mint a share link, returns its code. With an
2516
+ * address the link also lands in that key's inbox, in the same request.
2517
+ */
2464
2518
  async createShareLink(sealId, ownerToken, encryptedBlobB64, opts = {}) {
2519
+ const headers = _SealApi.ownerHeaders(ownerToken, true);
2520
+ const body = { encrypted_blob: encryptedBlobB64 };
2521
+ if ("to" in opts) {
2522
+ body.to = opts.to;
2523
+ body.fragment = opts.fragment;
2524
+ if (opts.label) body.label = opts.label;
2525
+ if (opts.sender) Object.assign(headers, proofHeaders(opts.sender));
2526
+ }
2465
2527
  const resp = await this.request(`/seal/${encode(sealId)}/share`, {
2466
2528
  what: `POST /seal/${sealId}/share`,
2467
2529
  method: "POST",
2468
- headers: _SealApi.ownerHeaders(ownerToken, true),
2469
- body: JSON.stringify({ encrypted_blob: encryptedBlobB64 }),
2530
+ headers,
2531
+ body: JSON.stringify(body),
2470
2532
  signal: opts.signal
2471
2533
  });
2472
2534
  const data = await resp.json();
@@ -2649,8 +2711,57 @@ var SealApi = class _SealApi {
2649
2711
  });
2650
2712
  return await resp.json();
2651
2713
  }
2714
+ // ---------------------------------------------------------------------------
2715
+ // Inbox (SPEC-ADDRESS F2): the share links addressed to a key
2716
+ // ---------------------------------------------------------------------------
2717
+ /** `POST /intake/proof` — a challenge sealed to `address`. */
2718
+ async requestAddressProof(address, opts = {}) {
2719
+ const resp = await this.request("/intake/proof", {
2720
+ what: "POST /intake/proof",
2721
+ method: "POST",
2722
+ headers: { "Content-Type": "application/json" },
2723
+ body: JSON.stringify({ address }),
2724
+ signal: opts.signal
2725
+ });
2726
+ return await resp.json();
2727
+ }
2728
+ /**
2729
+ * `GET /intake?to=` — every live item. `waitSeconds` holds the answer
2730
+ * while the inbox is empty, or, with `seen`, while its version is still
2731
+ * `seen`; one call waits at most `INTAKE_WAIT_MAX_SECONDS`, longer waits
2732
+ * are the caller's loop.
2733
+ */
2734
+ async listInbox(proof, opts = {}) {
2735
+ const params = new URLSearchParams({ to: proof.address });
2736
+ if (opts.waitSeconds) {
2737
+ params.set("wait", String(Math.min(opts.waitSeconds, limits_default.limits.INTAKE_WAIT_MAX_SECONDS)));
2738
+ }
2739
+ if (opts.seen) params.set("seen", opts.seen);
2740
+ const resp = await this.request(`/intake?${params.toString()}`, {
2741
+ what: "GET /intake",
2742
+ headers: proofHeaders(proof),
2743
+ signal: opts.signal
2744
+ });
2745
+ return await resp.json();
2746
+ }
2747
+ /** `DELETE /intake?to=&item=` — take one item out; the link keeps working. */
2748
+ async dismissInboxItem(itemId, proof, opts = {}) {
2749
+ const params = new URLSearchParams({ to: proof.address, item: itemId });
2750
+ await this.request(`/intake?${params.toString()}`, {
2751
+ what: "DELETE /intake",
2752
+ method: "DELETE",
2753
+ headers: proofHeaders(proof),
2754
+ signal: opts.signal
2755
+ });
2756
+ }
2652
2757
  };
2653
2758
  var NOT_READY_DEFAULT_RETRY_AFTER_S = 3;
2759
+ function proofHeaders(proof) {
2760
+ return {
2761
+ [seal_address_v1_default.proof.header_address]: proof.address,
2762
+ [seal_address_v1_default.proof.header_proof]: proof.proof
2763
+ };
2764
+ }
2654
2765
  function abortableSleep(ms, signal) {
2655
2766
  return new Promise((resolve2, reject) => {
2656
2767
  if (signal?.aborted) {
@@ -5209,10 +5320,29 @@ function parseUrlType(pathname) {
5209
5320
  var TARGETED_PREFIX_V1 = "x25519:";
5210
5321
  var TARGETED_PREFIX_V2_RESERVED = "x25519v2:";
5211
5322
  var SCOPE_TYPE = "seal_share";
5323
+ var ADDRESS_PROOF_SCOPE = "seal_address_proof";
5212
5324
  var X25519_KEY_BYTES = 32;
5213
5325
  var LINK_KEY_BYTES2 = 32;
5214
5326
  var PACKED_BYTES_V1 = 92;
5215
5327
  var B64URL = /^[A-Za-z0-9_-]+$/;
5328
+ function parseRecipientPubkey(raw) {
5329
+ const trimmed = raw.trim().replace(/=+$/, "");
5330
+ if (trimmed.length !== 43) {
5331
+ throw new Error(
5332
+ `expected 43-character urlsafe-base64-no-pad encoding of an X25519 public key (32 bytes), got ${trimmed.length} characters`
5333
+ );
5334
+ }
5335
+ if (!B64URL.test(trimmed)) {
5336
+ throw new Error(
5337
+ "not valid urlsafe-base64-no-pad: contains characters outside [A-Za-z0-9_-] (standard-base64 input is rejected \u2014 copy the exact string from `seal keygen` output)"
5338
+ );
5339
+ }
5340
+ const bytes = base64urlToBytes(trimmed);
5341
+ if (bytes.length !== X25519_KEY_BYTES) {
5342
+ throw new Error(`decoded to ${bytes.length} bytes, expected ${X25519_KEY_BYTES} (X25519 public key length)`);
5343
+ }
5344
+ return bytes;
5345
+ }
5216
5346
  async function generateRecipientKeyPair() {
5217
5347
  const wasm3 = await ensureWasm();
5218
5348
  const secretKey = wasm3.wasm_x25519_static_from_seed(crypto.getRandomValues(new Uint8Array(X25519_KEY_BYTES)));
@@ -5225,6 +5355,21 @@ async function recipientPublicKey(secretKey) {
5225
5355
  const wasm3 = await ensureWasm();
5226
5356
  return wasm3.wasm_x25519_public_from_secret(secretKey);
5227
5357
  }
5358
+ async function buildTargetedFragment(linkKey, recipientPub, sealId) {
5359
+ if (linkKey.length !== LINK_KEY_BYTES2) throw new Error(`linkKey length ${linkKey.length} \u2260 ${LINK_KEY_BYTES2}`);
5360
+ if (recipientPub.length !== X25519_KEY_BYTES) {
5361
+ throw new Error(`recipientPub length ${recipientPub.length} \u2260 ${X25519_KEY_BYTES}`);
5362
+ }
5363
+ if (sealId.length === 0) throw new Error("sealId must not be empty (AEAD binds to it via HKDF info)");
5364
+ const wasm3 = await ensureWasm();
5365
+ const packed = wasm3.wasm_sealbox_wrap(linkKey, recipientPub, SCOPE_TYPE, sealId);
5366
+ if (packed.length !== PACKED_BYTES_V1) {
5367
+ throw new Error(
5368
+ `wasm_sealbox_wrap returned ${packed.length} bytes \u2014 expected ${PACKED_BYTES_V1} for v1. GRANT_VERSION may have been bumped without minting a new "${TARGETED_PREFIX_V1}" prefix.`
5369
+ );
5370
+ }
5371
+ return `${TARGETED_PREFIX_V1}${bytesToBase64url(packed)}`;
5372
+ }
5228
5373
  var TargetedUnwrapError = class extends Error {
5229
5374
  constructor(kind, message, cause) {
5230
5375
  super(message);
@@ -5282,6 +5427,11 @@ async function unwrapTargetedFragment(fragment, recipientSecret, sealId) {
5282
5427
  }
5283
5428
  return linkKey;
5284
5429
  }
5430
+ async function proveAddress(secret, challenge, ts) {
5431
+ const wasm3 = await ensureWasm();
5432
+ const token = wasm3.wasm_sealbox_unwrap(base64urlToBytes(challenge), secret, ADDRESS_PROOF_SCOPE, String(ts));
5433
+ return `${ts}.${bytesToBase64url(token)}`;
5434
+ }
5285
5435
  var fingerprint_emoji_default = {
5286
5436
  version: 1,
5287
5437
  name: "FINGERPRINT_EMOJI",
@@ -5741,6 +5891,36 @@ async function waitForIntake(api, intakeId, opts = {}) {
5741
5891
  if (view.status === "fulfilled" && view.share_path) return view.share_path;
5742
5892
  }
5743
5893
  }
5894
+ var PROOF_MARGIN_MS = 3e4;
5895
+ var proofs = /* @__PURE__ */ new Map();
5896
+ async function addressProof(api, secret, opts = {}) {
5897
+ const address = bytesToBase64url(await recipientPublicKey(secret));
5898
+ const key = `${api.baseUrl} ${address}`;
5899
+ const kept = proofs.get(key);
5900
+ if (!opts.fresh && kept && kept.until > Date.now()) return kept.proof;
5901
+ const challenge = await api.requestAddressProof(address, opts);
5902
+ const proof = { address, proof: await proveAddress(secret, challenge.challenge, challenge.ts) };
5903
+ proofs.set(key, { proof, until: Date.parse(challenge.expires_at) - PROOF_MARGIN_MS });
5904
+ return proof;
5905
+ }
5906
+ async function withAddressProof(api, secret, signal, call) {
5907
+ const request = signal ? { signal } : {};
5908
+ try {
5909
+ return await call(await addressProof(api, secret, request));
5910
+ } catch (err) {
5911
+ if (!(err instanceof BackendError && err.appCode === "intake.proof_required")) throw err;
5912
+ return call(await addressProof(api, secret, { ...request, fresh: true }));
5913
+ }
5914
+ }
5915
+ async function readInbox(api, secret, opts = {}) {
5916
+ return withAddressProof(api, secret, opts.signal, (proof) => api.listInbox(proof, opts));
5917
+ }
5918
+ async function removeFromInbox(api, secret, itemId, opts = {}) {
5919
+ return withAddressProof(api, secret, opts.signal, (proof) => api.dismissInboxItem(itemId, proof, opts));
5920
+ }
5921
+ function inboxItemUrl(site, item) {
5922
+ return `${site.replace(/\/+$/, "")}${item.path}#${item.fragment}`;
5923
+ }
5744
5924
  async function describeFile(file, fileKeys) {
5745
5925
  const keyB64 = file.sha256_hex ? fileKeys[file.sha256_hex] : void 0;
5746
5926
  const base = { id: file.id, size: file.size, sha256Hex: file.sha256_hex };
@@ -5882,7 +6062,7 @@ function sealErrorFrom(err, fallbackMessage, details = null) {
5882
6062
  return new SealError(err.message, OPEN_CODES[err.code], status, { ...details, reason: err.code }, { cause: err });
5883
6063
  }
5884
6064
  if (err instanceof BackendError) {
5885
- const code = err.code === "not_found" || err.code === "revoked" ? "RESOURCE_NOT_FOUND" : err.code === "auth" ? "AUTH_INSUFFICIENT_SCOPE" : err.code === "rate_limited" ? "RATE_LIMITED" : err.code === "transient" ? "SERVICE_UNAVAILABLE" : "INTERNAL_ERROR";
6065
+ const code = err.appCode === "intake.proof_required" ? "AUTH_INVALID_KEY" : err.code === "not_found" || err.code === "revoked" ? "RESOURCE_NOT_FOUND" : err.code === "auth" ? "AUTH_INSUFFICIENT_SCOPE" : err.code === "rate_limited" ? "RATE_LIMITED" : err.code === "transient" ? "SERVICE_UNAVAILABLE" : "INTERNAL_ERROR";
5886
6066
  return new SealError(err.detail ?? fallbackMessage, code, err.status, details, { cause: err });
5887
6067
  }
5888
6068
  return new SealError(
@@ -5959,6 +6139,14 @@ var AnonymousSealsSendResource = class {
5959
6139
  if (options.tier && !options.onPaymentRequired) {
5960
6140
  throw new SealError("onPaymentRequired is required with tier", "VALIDATION_ERROR", 400);
5961
6141
  }
6142
+ let recipient;
6143
+ if (options.to !== void 0) {
6144
+ try {
6145
+ recipient = parseRecipientPubkey(options.to);
6146
+ } catch (err) {
6147
+ throw new SealError(`to: ${err instanceof Error ? err.message : String(err)}`, "VALIDATION_ERROR", 400);
6148
+ }
6149
+ }
5962
6150
  const desiredType = options.mimeType || options.file instanceof File && options.file.type || "application/octet-stream";
5963
6151
  let file;
5964
6152
  if (options.file instanceof File && options.file.name === options.filename && options.file.type === desiredType) {
@@ -6053,14 +6241,13 @@ var AnonymousSealsSendResource = class {
6053
6241
  const shareLinkKey = generateLinkKey();
6054
6242
  const shareLinkKeyB64 = bytesToBase64url(shareLinkKey);
6055
6243
  const shareBlob = await encryptShareBlob(fileKeysB64, shareLinkKey, blobMessage);
6244
+ const fragment = recipient ? await buildTargetedFragment(shareLinkKey, recipient, result.sealId) : null;
6056
6245
  let shareCode;
6057
6246
  try {
6058
- shareCode = await this.api.createShareLink(
6059
- result.sealId,
6060
- ownerTokenB64,
6061
- bytesToBase64url(shareBlob),
6062
- options.signal ? { signal: options.signal } : {}
6063
- );
6247
+ shareCode = await this.api.createShareLink(result.sealId, ownerTokenB64, bytesToBase64url(shareBlob), {
6248
+ ...options.signal ? { signal: options.signal } : {},
6249
+ ...recipient && fragment ? { to: bytesToBase64url(recipient), fragment, label: "sealnet" } : {}
6250
+ });
6064
6251
  } catch (err) {
6065
6252
  throw sealErrorFrom(
6066
6253
  err,
@@ -6068,7 +6255,8 @@ var AnonymousSealsSendResource = class {
6068
6255
  recovery(result.sealId)
6069
6256
  );
6070
6257
  }
6071
- const shareUrl = `${this.shareUrlBase}${buildShareUrl(result.sealId, shareCode, shareLinkKeyB64)}`;
6258
+ const sharePath = buildShareUrl(result.sealId, shareCode, shareLinkKeyB64);
6259
+ const shareUrl = `${this.shareUrlBase}${fragment ? sharePath.replace(/#.*$/, `#${fragment}`) : sharePath}`;
6072
6260
  const ownerUrl = `${this.shareUrlBase}${buildOwnerUrl(result.sealId, linkKeyB64)}`;
6073
6261
  const keyBase64 = bytesToBase64(result.encryptionKey);
6074
6262
  return {
@@ -6083,7 +6271,8 @@ var AnonymousSealsSendResource = class {
6083
6271
  // `now + ttl` as the seal's expiry states something we do not know.
6084
6272
  expiresAt: expiresAt ?? new Date(Date.now() + this.ttlToMs(options.ttl)).toISOString(),
6085
6273
  encryptionKey: keyBase64,
6086
- fileId: result.fileId
6274
+ fileId: result.fileId,
6275
+ delivered: fragment !== null
6087
6276
  };
6088
6277
  } catch (err) {
6089
6278
  if (err instanceof SealError) throw err;
@@ -6281,6 +6470,55 @@ async function keygen() {
6281
6470
  const { publicKey, secretKey } = await generateRecipientKeyPair();
6282
6471
  return { publicKey: bytesToBase64url(publicKey), secretKey: bytesToBase64url(secretKey) };
6283
6472
  }
6473
+ async function inboxOf(api, opts) {
6474
+ const secret = base64urlToBytes(opts.keyPair.secretKey);
6475
+ const deadline = Date.now() + (opts.wait ?? 0) * 1e3;
6476
+ try {
6477
+ for (; ; ) {
6478
+ const left = Math.ceil((deadline - Date.now()) / 1e3);
6479
+ const wire = await readInbox(api, secret, {
6480
+ ...left > 0 ? { waitSeconds: left } : {},
6481
+ ...opts.seen !== void 0 ? { seen: opts.seen } : {},
6482
+ ...opts.signal ? { signal: opts.signal } : {}
6483
+ });
6484
+ const due = opts.seen !== void 0 ? wire.version !== opts.seen : wire.items.length > 0;
6485
+ if (due || Date.now() >= deadline) {
6486
+ return {
6487
+ version: wire.version,
6488
+ items: wire.items.map((i) => ({
6489
+ id: i.id,
6490
+ from: i.sender === null ? null : keyEmoji(base64urlToBytes(i.sender)),
6491
+ label: i.label,
6492
+ receivedAt: i.at,
6493
+ expiresAt: i.expires_at
6494
+ }))
6495
+ };
6496
+ }
6497
+ }
6498
+ } catch (err) {
6499
+ throw sealErrorFrom(err, "Failed to read the inbox");
6500
+ }
6501
+ }
6502
+ async function inboxLink(api, site, item, opts) {
6503
+ let wire;
6504
+ try {
6505
+ wire = await readInbox(api, base64urlToBytes(opts.keyPair.secretKey), opts.signal ? { signal: opts.signal } : {});
6506
+ } catch (err) {
6507
+ throw sealErrorFrom(err, "Failed to read the inbox");
6508
+ }
6509
+ const row = wire.items.find((i) => i.id === item.id);
6510
+ if (!row) {
6511
+ throw new SealError(`${item.id} is not in the inbox: it was revoked, expired or removed`, "RESOURCE_NOT_FOUND", 404);
6512
+ }
6513
+ return inboxItemUrl(site, row);
6514
+ }
6515
+ async function dismissItem(api, item, opts) {
6516
+ try {
6517
+ await removeFromInbox(api, base64urlToBytes(opts.keyPair.secretKey), item.id, opts.signal ? { signal: opts.signal } : {});
6518
+ } catch (err) {
6519
+ throw sealErrorFrom(err, "Failed to remove the item");
6520
+ }
6521
+ }
6284
6522
 
6285
6523
  // src/index.ts
6286
6524
  var SealClient = class {
@@ -6303,10 +6541,31 @@ var SealClient = class {
6303
6541
  async send(options) {
6304
6542
  return this.seals.create(options);
6305
6543
  }
6306
- async open(url, options = {}) {
6544
+ async open(link, options = {}) {
6307
6545
  const { to, ...rest } = options;
6546
+ let url;
6547
+ if (typeof link === "string") {
6548
+ url = link;
6549
+ } else if (rest.keyPair) {
6550
+ url = await inboxLink(this.api, this.site, link, { keyPair: rest.keyPair, ...rest.signal ? { signal: rest.signal } : {} });
6551
+ } else {
6552
+ throw new SealError("An inbox item opens with the key it was sent to: pass `keyPair`", "VALIDATION_ERROR", 400);
6553
+ }
6308
6554
  return to !== void 0 ? saveLink(this.api, url, to, rest) : openLink(this.api, url, rest);
6309
6555
  }
6556
+ /**
6557
+ * What other agents or people sent to your key (your address,
6558
+ * `keyPair.publicKey`); `send({to})` puts a link there. `wait` seconds
6559
+ * holds the answer while the inbox is empty, or with `seen` (an earlier
6560
+ * `version`) until it changes.
6561
+ */
6562
+ async inbox(options) {
6563
+ return inboxOf(this.api, options);
6564
+ }
6565
+ /** Take an item out of your inbox; its link keeps working for whoever holds it. */
6566
+ async dismiss(item, options) {
6567
+ return dismissItem(this.api, item, options);
6568
+ }
6310
6569
  /**
6311
6570
  * Ask a person for a file or a secret without it passing through a chat:
6312
6571
  * show them `url` (or hand it to an MCP client as a URL-mode elicitation)
@@ -6332,7 +6591,7 @@ var SealClient = class {
6332
6591
  return this.seals.revoke(sealId, ownerToken, options);
6333
6592
  }
6334
6593
  };
6335
- var VERSION = "1.1.2";
6594
+ var VERSION = "1.2.0";
6336
6595
  // Annotate the CommonJS export names for ESM import in node:
6337
6596
  0 && (module.exports = {
6338
6597
  SealClient,
package/dist/index.d.cts CHANGED
@@ -34,6 +34,11 @@ interface CreateAnonymousSealOptions {
34
34
  maxOpens?: number;
35
35
  /** Restrict access to specific countries (ISO codes) */
36
36
  geoAllowlist?: string[];
37
+ /**
38
+ * The recipient's address (their `keygen().publicKey`): the link opens
39
+ * only with their key and also lands in their inbox (`inbox()`).
40
+ */
41
+ to?: string;
37
42
  /**
38
43
  * Over 1 GB: the tier the person pays for once by card (`5gb` $9 90 days,
39
44
  * `50gb` $29 180 days, `500gb` $99 365 days). Needs `ttl` 1d or 7d and
@@ -79,6 +84,8 @@ interface CreateAnonymousSealResult {
79
84
  encryptionKey: string;
80
85
  /** File ID */
81
86
  fileId: string;
87
+ /** The link is in the recipient's inbox (`to` was given). */
88
+ delivered: boolean;
82
89
  }
83
90
 
84
91
  /**
@@ -193,6 +200,28 @@ interface RequestResult {
193
200
  readonly emoji: string;
194
201
  readonly expiresAt: string;
195
202
  }
203
+ /** Something sent to your key: open it with `open(item, {keyPair})`. */
204
+ interface InboxItem {
205
+ readonly id: string;
206
+ /** Three emoji of the sender's address when it proved one. */
207
+ readonly from: string | null;
208
+ /** What the sender called itself, in the clear: never content. */
209
+ readonly label: string | null;
210
+ readonly receivedAt: string;
211
+ readonly expiresAt: string;
212
+ }
213
+ interface Inbox {
214
+ readonly items: readonly InboxItem[];
215
+ /** Pass as `seen` to wait for a change. */
216
+ readonly version: string;
217
+ }
218
+ interface InboxOptions {
219
+ readonly keyPair: Pick<KeyPair, 'secretKey'>;
220
+ /** Seconds to wait: while the inbox is empty, or with `seen` while it is still that version. */
221
+ readonly wait?: number;
222
+ readonly seen?: string;
223
+ readonly signal?: AbortSignal;
224
+ }
196
225
 
197
226
  /**
198
227
  * SEAL SDK
@@ -247,17 +276,26 @@ declare class SealClient {
247
276
  */
248
277
  send(options: SendOptions): Promise<SendResult>;
249
278
  /**
250
- * Open a link. With `to` (Node) every file is streamed into that directory
251
- * — 0600, named only after its ciphertext matched the digest registered at
252
- * upload. Without it each file is downloaded when you `read()` it, as a
253
- * stream that fails at its end if the ciphertext was changed. Either way
254
- * memory stays one segment whatever the size. `keyPair` opens a link
255
- * addressed to your key.
279
+ * Open a link, or an item of your inbox (with `keyPair`). With `to` (Node)
280
+ * every file is streamed into that directory — 0600, named only after its
281
+ * ciphertext matched the digest registered at upload. Without it each file
282
+ * is downloaded when you `read()` it, as a stream that fails at its end if
283
+ * the ciphertext was changed. Either way memory stays one segment whatever
284
+ * the size. `keyPair` opens a link addressed to your key.
256
285
  */
257
- open(url: string, options: OpenOptions & {
286
+ open(link: string | InboxItem, options: OpenOptions & {
258
287
  to: string;
259
288
  }): Promise<OpenedSeal<SavedSealFile>>;
260
- open(url: string, options?: OpenOptions): Promise<OpenedSeal<OpenedSealFile>>;
289
+ open(link: string | InboxItem, options?: OpenOptions): Promise<OpenedSeal<OpenedSealFile>>;
290
+ /**
291
+ * What other agents or people sent to your key (your address,
292
+ * `keyPair.publicKey`); `send({to})` puts a link there. `wait` seconds
293
+ * holds the answer while the inbox is empty, or with `seen` (an earlier
294
+ * `version`) until it changes.
295
+ */
296
+ inbox(options: InboxOptions): Promise<Inbox>;
297
+ /** Take an item out of your inbox; its link keeps working for whoever holds it. */
298
+ dismiss(item: InboxItem, options: Pick<InboxOptions, 'keyPair' | 'signal'>): Promise<void>;
261
299
  /**
262
300
  * Ask a person for a file or a secret without it passing through a chat:
263
301
  * show them `url` (or hand it to an MCP client as a URL-mode elicitation)
@@ -286,6 +324,6 @@ declare class SealClient {
286
324
  revokedAt: string | null;
287
325
  }>;
288
326
  }
289
- declare const VERSION = "1.1.2";
327
+ declare const VERSION = "1.2.0";
290
328
 
291
- export { type KeyPair, type OpenOptions, type OpenedSeal, type OpenedSealFile, type RequestOptions, type RequestResult, type SavedSealFile, SealClient, type SealClientOptions, SealError, type SealErrorCode, type SealErrorDetails, type SendOptions, type SendResult, type TTL, VERSION };
329
+ export { type Inbox, type InboxItem, type InboxOptions, type KeyPair, type OpenOptions, type OpenedSeal, type OpenedSealFile, type RequestOptions, type RequestResult, type SavedSealFile, SealClient, type SealClientOptions, SealError, type SealErrorCode, type SealErrorDetails, type SendOptions, type SendResult, type TTL, VERSION };
package/dist/index.d.ts CHANGED
@@ -34,6 +34,11 @@ interface CreateAnonymousSealOptions {
34
34
  maxOpens?: number;
35
35
  /** Restrict access to specific countries (ISO codes) */
36
36
  geoAllowlist?: string[];
37
+ /**
38
+ * The recipient's address (their `keygen().publicKey`): the link opens
39
+ * only with their key and also lands in their inbox (`inbox()`).
40
+ */
41
+ to?: string;
37
42
  /**
38
43
  * Over 1 GB: the tier the person pays for once by card (`5gb` $9 90 days,
39
44
  * `50gb` $29 180 days, `500gb` $99 365 days). Needs `ttl` 1d or 7d and
@@ -79,6 +84,8 @@ interface CreateAnonymousSealResult {
79
84
  encryptionKey: string;
80
85
  /** File ID */
81
86
  fileId: string;
87
+ /** The link is in the recipient's inbox (`to` was given). */
88
+ delivered: boolean;
82
89
  }
83
90
 
84
91
  /**
@@ -193,6 +200,28 @@ interface RequestResult {
193
200
  readonly emoji: string;
194
201
  readonly expiresAt: string;
195
202
  }
203
+ /** Something sent to your key: open it with `open(item, {keyPair})`. */
204
+ interface InboxItem {
205
+ readonly id: string;
206
+ /** Three emoji of the sender's address when it proved one. */
207
+ readonly from: string | null;
208
+ /** What the sender called itself, in the clear: never content. */
209
+ readonly label: string | null;
210
+ readonly receivedAt: string;
211
+ readonly expiresAt: string;
212
+ }
213
+ interface Inbox {
214
+ readonly items: readonly InboxItem[];
215
+ /** Pass as `seen` to wait for a change. */
216
+ readonly version: string;
217
+ }
218
+ interface InboxOptions {
219
+ readonly keyPair: Pick<KeyPair, 'secretKey'>;
220
+ /** Seconds to wait: while the inbox is empty, or with `seen` while it is still that version. */
221
+ readonly wait?: number;
222
+ readonly seen?: string;
223
+ readonly signal?: AbortSignal;
224
+ }
196
225
 
197
226
  /**
198
227
  * SEAL SDK
@@ -247,17 +276,26 @@ declare class SealClient {
247
276
  */
248
277
  send(options: SendOptions): Promise<SendResult>;
249
278
  /**
250
- * Open a link. With `to` (Node) every file is streamed into that directory
251
- * — 0600, named only after its ciphertext matched the digest registered at
252
- * upload. Without it each file is downloaded when you `read()` it, as a
253
- * stream that fails at its end if the ciphertext was changed. Either way
254
- * memory stays one segment whatever the size. `keyPair` opens a link
255
- * addressed to your key.
279
+ * Open a link, or an item of your inbox (with `keyPair`). With `to` (Node)
280
+ * every file is streamed into that directory — 0600, named only after its
281
+ * ciphertext matched the digest registered at upload. Without it each file
282
+ * is downloaded when you `read()` it, as a stream that fails at its end if
283
+ * the ciphertext was changed. Either way memory stays one segment whatever
284
+ * the size. `keyPair` opens a link addressed to your key.
256
285
  */
257
- open(url: string, options: OpenOptions & {
286
+ open(link: string | InboxItem, options: OpenOptions & {
258
287
  to: string;
259
288
  }): Promise<OpenedSeal<SavedSealFile>>;
260
- open(url: string, options?: OpenOptions): Promise<OpenedSeal<OpenedSealFile>>;
289
+ open(link: string | InboxItem, options?: OpenOptions): Promise<OpenedSeal<OpenedSealFile>>;
290
+ /**
291
+ * What other agents or people sent to your key (your address,
292
+ * `keyPair.publicKey`); `send({to})` puts a link there. `wait` seconds
293
+ * holds the answer while the inbox is empty, or with `seen` (an earlier
294
+ * `version`) until it changes.
295
+ */
296
+ inbox(options: InboxOptions): Promise<Inbox>;
297
+ /** Take an item out of your inbox; its link keeps working for whoever holds it. */
298
+ dismiss(item: InboxItem, options: Pick<InboxOptions, 'keyPair' | 'signal'>): Promise<void>;
261
299
  /**
262
300
  * Ask a person for a file or a secret without it passing through a chat:
263
301
  * show them `url` (or hand it to an MCP client as a URL-mode elicitation)
@@ -286,6 +324,6 @@ declare class SealClient {
286
324
  revokedAt: string | null;
287
325
  }>;
288
326
  }
289
- declare const VERSION = "1.1.2";
327
+ declare const VERSION = "1.2.0";
290
328
 
291
- export { type KeyPair, type OpenOptions, type OpenedSeal, type OpenedSealFile, type RequestOptions, type RequestResult, type SavedSealFile, SealClient, type SealClientOptions, SealError, type SealErrorCode, type SealErrorDetails, type SendOptions, type SendResult, type TTL, VERSION };
329
+ export { type Inbox, type InboxItem, type InboxOptions, type KeyPair, type OpenOptions, type OpenedSeal, type OpenedSealFile, type RequestOptions, type RequestResult, type SavedSealFile, SealClient, type SealClientOptions, SealError, type SealErrorCode, type SealErrorDetails, type SendOptions, type SendResult, type TTL, VERSION };