@fkn/lib 0.9.48 → 0.9.49

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 (49) hide show
  1. package/{storage-C6F9SnDM.js → account-storage-C31d68BN.js} +2 -2
  2. package/{storage-DmRIhg1P.cjs → account-storage-C6hcXjG0.cjs} +1 -1
  3. package/{storage-B_mXNAdB.d.ts → account-storage-DHl6bXdb.d.ts} +2 -2
  4. package/{api-Cpi-qz1j.d.ts → api-wnOQJEK6.d.ts} +34 -42
  5. package/api.d.ts +2 -2
  6. package/cloud/dns.d.ts +1 -1
  7. package/cloud/fetch.d.ts +1 -1
  8. package/cloud/fs/promises.d.ts +1 -1
  9. package/cloud/fs.cjs +1 -1
  10. package/cloud/fs.d.ts +3 -3
  11. package/cloud/fs.js +12 -12
  12. package/cloud/net.d.ts +1 -1
  13. package/{cloud-DK3DtdsU.d.ts → cloud-CWHjH89l.d.ts} +3 -3
  14. package/cloud.d.ts +4 -4
  15. package/{contract-XlEPwc7b.d.ts → contract-DGuGXxKd.d.ts} +119 -82
  16. package/contract.cjs +1 -1
  17. package/contract.d.ts +2 -2
  18. package/contract.js +69 -3
  19. package/dgram.d.ts +2 -2
  20. package/dns.d.ts +1 -1
  21. package/fs/promises.cjs +1 -1
  22. package/fs/promises.d.ts +1 -1
  23. package/fs/promises.js +1 -1
  24. package/{fs-lKZe5xIo.d.ts → fs-BZv2djbS.d.ts} +2 -2
  25. package/{fs-BY0Csn2V.js → fs-ClnOPmRF.js} +39 -39
  26. package/fs-zERmcLRS.cjs +1 -0
  27. package/fs.cjs +1 -1
  28. package/fs.d.ts +3 -3
  29. package/fs.js +2 -2
  30. package/http.d.ts +1 -1
  31. package/{index-D9x6A-Gx.d.ts → index-DawD_N1P.d.ts} +2 -2
  32. package/index.cjs +1 -1
  33. package/index.d.ts +5 -6
  34. package/index.js +39 -40
  35. package/{messages-d7pvCXPn.d.ts → messages-AdPfdoLV.d.ts} +1 -1
  36. package/messages.d.ts +1 -1
  37. package/{net-C2Yz0job.d.ts → net-C2sulnNU.d.ts} +2 -2
  38. package/net.d.ts +1 -1
  39. package/package.json +5 -5
  40. package/packages.d.ts +1 -1
  41. package/{proxy-BZ-YFeXe.d.ts → proxy-MVuD49E2.d.ts} +2 -2
  42. package/rooms.d.ts +1 -1
  43. package/storage.cjs +1 -0
  44. package/storage.d.ts +69 -0
  45. package/storage.js +137 -0
  46. package/fs-DnF1cQuE.cjs +0 -1
  47. package/links.cjs +0 -1
  48. package/links.d.ts +0 -65
  49. package/links.js +0 -187
@@ -2,7 +2,7 @@ import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
2
2
  import { o as t } from "./api-ySazPAwN.js";
3
3
  import { STORAGE_ACCOUNT_CHANGED as n, STORAGE_ACCOUNT_PIN_UNSUPPORTED as r, STORAGE_NOT_FOUND as i } from "./messages.js";
4
4
  import { n as a, r as o, t as s } from "./account-generation-hUekEHGW.js";
5
- //#region src/storage.ts
5
+ //#region src/account-storage.ts
6
6
  var c = /* @__PURE__ */ e({
7
7
  StorageAccountChangedError: () => f,
8
8
  StorageAccountPinUnsupportedError: () => p,
@@ -120,4 +120,4 @@ var c = /* @__PURE__ */ e({
120
120
  await D(E(t), (t, n) => t.remove(e, n));
121
121
  }, V = () => t.then((e) => e.cloud.fs.encryption()), H = () => t.then((e) => e.cloud.fs.unlock());
122
122
  //#endregion
123
- export { B as _, N as a, z as b, m as c, C as d, P as f, R as g, I as h, u as i, h as l, F as m, p as n, _ as o, w as p, l as r, V as s, f as t, d as u, c as v, H as y };
123
+ export { R as _, c as a, z as b, V as c, d, C as f, I as g, F as h, u as i, m as l, w as m, p as n, N as o, P as p, l as r, _ as s, f as t, h as u, B as v, H as y };
@@ -1 +1 @@
1
- const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./api-DMnVye0K.cjs"),n=require("./messages.cjs"),r=require("./account-generation-9VhfEDoW.cjs");var i=e.t({StorageAccountChangedError:()=>c,StorageAccountPinUnsupportedError:()=>l,StorageLockedError:()=>a,StorageNotFoundError:()=>o,availability:()=>k,available:()=>w,captureAccount:()=>p,encryption:()=>L,isAccountChanged:()=>u,isInvalidPin:()=>d,isNotFound:()=>s,knownPin:()=>y,list:()=>A,pinFor:()=>b,quota:()=>j,readFile:()=>M,readFileSealed:()=>P,remove:()=>I,unlock:()=>R,writeFile:()=>F}),a=class extends Error{code=`FKN_E2E_LOCKED`;constructor(){super(`storage locked: connect the app again to open encrypted data`)}},o=class extends Error{code=n.STORAGE_NOT_FOUND;constructor(e=`storage: no object at that path`){super(e)}},s=e=>e?.code===n.STORAGE_NOT_FOUND,c=class extends Error{code=n.STORAGE_ACCOUNT_CHANGED;constructor(e=`storage: the signed-in account changed, so this call was not made`){super(e)}},l=class extends Error{code=n.STORAGE_ACCOUNT_PIN_UNSUPPORTED;constructor(e=`storage: the FKN broker cannot pin calls to an account yet, so nothing was sent`){super(e)}},u=e=>e?.code===`FKN_ACCOUNT_CHANGED`||e instanceof Error&&e.message.startsWith(`fkn:account-changed`),d=e=>e instanceof Error&&e.message.startsWith(`fkn:account-pin-invalid`),f=e=>{throw e instanceof Error&&e.message.startsWith(`fkn:e2e-locked`)?new a:s(e)?new o(e.message):u(e)?new c:e instanceof Error&&e.message.startsWith(`fkn:account-pin-unsupported`)?new l:e instanceof Error&&(/^not found$/i.test(e.message)||/\(404\)$/.test(e.message))?new o(e.message):e},p=()=>(r.n(),{generation:r.t()}),m=new Map,h=null,g=e=>typeof e?.accountPin==`function`,_=(e,t)=>{let n=Promise.resolve(t.accountPin()).then(t=>{if(typeof t!=`string`||!t)throw Error(`storage: the broker answered no account pin`);return r.t()===e&&m.set(e,t),t});return h={generation:e,pin:n},n.catch(()=>{h?.pin===n&&(h=null)}),n},v=async(e,t)=>{let n=m.get(e.generation);if(n!==void 0)return n;if(e.generation!==r.t())throw new c;let i=await(h?.generation===e.generation?h.pin:_(e.generation,t)).catch(f);if(e.generation!==r.t())throw new c;return i},y=e=>m.get(e.generation),b=async e=>{let n=(await t.o).cloud.fs;if(!g(n))throw new l;return v(e,n)},x=e=>{for(let[t,n]of m)if(n===e)return t},S=e=>e?.pin??p(),C=async(e,n)=>{let i=(await t.o).cloud.fs;if(!g(i))throw new l;let a=`pin`in e?e.pin:await v(e,i);if(!g(i))throw new l;return n(i,{accountPin:a}).catch(t=>{if(u(t)){let t=`generation`in e?e.generation:x(a);t!==void 0&&r.r(t)}return f(t)})},w=()=>t.o.then(e=>e.cloud.fs.available()).catch(()=>!1),T=8e3,E=1e3,D=!1,O=async()=>{let e=(await t.o).cloud.fs;return typeof e.availability==`function`?e.availability():await e.available()?`connected`:`disconnected`},k=async()=>{let e=D?E:T,t=await new Promise(t=>{let n=setTimeout(()=>t(`timeout`),e);O().then(e=>{clearTimeout(n),t(e)},()=>{clearTimeout(n),t(`unknown`)})});return t===`timeout`?(D=!0,`unknown`):(D=!1,t)},A=e=>C(S(e),(e,t)=>e.list(t)),j=()=>t.o.then(e=>e.cloud.fs.quota()),M=async(e,t)=>{let n=await C(S(t),(t,n)=>t.readFile(e,n));return new Blob([n])},N=e=>{if(e===null||!Number.isFinite(e))return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t.toISOString()},P=async(e,t)=>C(S(t),async(t,n)=>{let r=t;if(typeof r.readFileSealed!=`function`)return{data:await t.readFile(e,n),sealedAt:null};let i=await r.readFileSealed(e,n);return{data:i.bytes,sealedAt:N(i.sealedAt)}}),F=async(e,t,n)=>{let r=S(n),i=t instanceof Blob?new Uint8Array(await t.arrayBuffer()):t;await C(r,(t,r)=>t.writeFile(e,i,n?.contentType??null,r))},I=async(e,t)=>{await C(S(t),(t,n)=>t.remove(e,n))},L=()=>t.o.then(e=>e.cloud.fs.encryption()),R=()=>t.o.then(e=>e.cloud.fs.unlock());Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return I}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,"b",{enumerable:!0,get:function(){return F}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return A}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return P}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return M}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return j}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return L}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return R}});
1
+ const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./api-DMnVye0K.cjs"),n=require("./messages.cjs"),r=require("./account-generation-9VhfEDoW.cjs");var i=e.t({StorageAccountChangedError:()=>c,StorageAccountPinUnsupportedError:()=>l,StorageLockedError:()=>a,StorageNotFoundError:()=>o,availability:()=>k,available:()=>w,captureAccount:()=>p,encryption:()=>L,isAccountChanged:()=>u,isInvalidPin:()=>d,isNotFound:()=>s,knownPin:()=>y,list:()=>A,pinFor:()=>b,quota:()=>j,readFile:()=>M,readFileSealed:()=>P,remove:()=>I,unlock:()=>R,writeFile:()=>F}),a=class extends Error{code=`FKN_E2E_LOCKED`;constructor(){super(`storage locked: connect the app again to open encrypted data`)}},o=class extends Error{code=n.STORAGE_NOT_FOUND;constructor(e=`storage: no object at that path`){super(e)}},s=e=>e?.code===n.STORAGE_NOT_FOUND,c=class extends Error{code=n.STORAGE_ACCOUNT_CHANGED;constructor(e=`storage: the signed-in account changed, so this call was not made`){super(e)}},l=class extends Error{code=n.STORAGE_ACCOUNT_PIN_UNSUPPORTED;constructor(e=`storage: the FKN broker cannot pin calls to an account yet, so nothing was sent`){super(e)}},u=e=>e?.code===`FKN_ACCOUNT_CHANGED`||e instanceof Error&&e.message.startsWith(`fkn:account-changed`),d=e=>e instanceof Error&&e.message.startsWith(`fkn:account-pin-invalid`),f=e=>{throw e instanceof Error&&e.message.startsWith(`fkn:e2e-locked`)?new a:s(e)?new o(e.message):u(e)?new c:e instanceof Error&&e.message.startsWith(`fkn:account-pin-unsupported`)?new l:e instanceof Error&&(/^not found$/i.test(e.message)||/\(404\)$/.test(e.message))?new o(e.message):e},p=()=>(r.n(),{generation:r.t()}),m=new Map,h=null,g=e=>typeof e?.accountPin==`function`,_=(e,t)=>{let n=Promise.resolve(t.accountPin()).then(t=>{if(typeof t!=`string`||!t)throw Error(`storage: the broker answered no account pin`);return r.t()===e&&m.set(e,t),t});return h={generation:e,pin:n},n.catch(()=>{h?.pin===n&&(h=null)}),n},v=async(e,t)=>{let n=m.get(e.generation);if(n!==void 0)return n;if(e.generation!==r.t())throw new c;let i=await(h?.generation===e.generation?h.pin:_(e.generation,t)).catch(f);if(e.generation!==r.t())throw new c;return i},y=e=>m.get(e.generation),b=async e=>{let n=(await t.o).cloud.fs;if(!g(n))throw new l;return v(e,n)},x=e=>{for(let[t,n]of m)if(n===e)return t},S=e=>e?.pin??p(),C=async(e,n)=>{let i=(await t.o).cloud.fs;if(!g(i))throw new l;let a=`pin`in e?e.pin:await v(e,i);if(!g(i))throw new l;return n(i,{accountPin:a}).catch(t=>{if(u(t)){let t=`generation`in e?e.generation:x(a);t!==void 0&&r.r(t)}return f(t)})},w=()=>t.o.then(e=>e.cloud.fs.available()).catch(()=>!1),T=8e3,E=1e3,D=!1,O=async()=>{let e=(await t.o).cloud.fs;return typeof e.availability==`function`?e.availability():await e.available()?`connected`:`disconnected`},k=async()=>{let e=D?E:T,t=await new Promise(t=>{let n=setTimeout(()=>t(`timeout`),e);O().then(e=>{clearTimeout(n),t(e)},()=>{clearTimeout(n),t(`unknown`)})});return t===`timeout`?(D=!0,`unknown`):(D=!1,t)},A=e=>C(S(e),(e,t)=>e.list(t)),j=()=>t.o.then(e=>e.cloud.fs.quota()),M=async(e,t)=>{let n=await C(S(t),(t,n)=>t.readFile(e,n));return new Blob([n])},N=e=>{if(e===null||!Number.isFinite(e))return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t.toISOString()},P=async(e,t)=>C(S(t),async(t,n)=>{let r=t;if(typeof r.readFileSealed!=`function`)return{data:await t.readFile(e,n),sealedAt:null};let i=await r.readFileSealed(e,n);return{data:i.bytes,sealedAt:N(i.sealedAt)}}),F=async(e,t,n)=>{let r=S(n),i=t instanceof Blob?new Uint8Array(await t.arrayBuffer()):t;await C(r,(t,r)=>t.writeFile(e,i,n?.contentType??null,r))},I=async(e,t)=>{await C(S(t),(t,n)=>t.remove(e,n))},L=()=>t.o.then(e=>e.cloud.fs.encryption()),R=()=>t.o.then(e=>e.cloud.fs.unlock());Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return P}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"b",{enumerable:!0,get:function(){return F}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return L}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return M}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return j}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return A}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return I}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return R}});
@@ -31,7 +31,7 @@ type FileSystem = {
31
31
  /** Captures the account generation this realm is on now; absent on a backing with no account. */
32
32
  captureAccount?: () => PinFrom;
33
33
  };
34
- declare namespace storage_d_exports {
34
+ declare namespace account_storage_d_exports {
35
35
  export { AccountTicket, CloudAvailability, EncryptionStatus, FileEntry, SealedRead, StorageAccountChangedError, StorageAccountPinUnsupportedError, StorageLockedError, StorageNotFoundError, StorageQuota, availability, available, captureAccount, encryption, isAccountChanged, isInvalidPin, isNotFound, knownPin, list, pinFor, quota, readFile, readFileSealed, remove, unlock, writeFile };
36
36
  }
37
37
  type FileEntry = {
@@ -149,4 +149,4 @@ declare const remove: (path: string, opts?: PinOptions) => Promise<void>;
149
149
  declare const encryption: () => Promise<EncryptionStatus>;
150
150
  declare const unlock: () => Promise<boolean>;
151
151
  //#endregion
152
- export { unlock as _, StorageAccountChangedError as a, PinOptions as b, StorageNotFoundError as c, captureAccount as d, encryption as f, storage_d_exports as g, quota as h, SealedRead as i, StorageQuota as l, isNotFound as m, EncryptionStatus as n, StorageAccountPinUnsupportedError as o, isAccountChanged as p, FileEntry as r, StorageLockedError as s, CloudAvailability as t, availability as u, FileEntry$1 as v, WriteData as x, FileSystem as y };
152
+ export { unlock as _, StorageAccountChangedError as a, PinOptions as b, StorageNotFoundError as c, availability as d, captureAccount as f, quota as g, isNotFound as h, SealedRead as i, StorageQuota as l, isAccountChanged as m, EncryptionStatus as n, StorageAccountPinUnsupportedError as o, encryption as p, FileEntry as r, StorageLockedError as s, CloudAvailability as t, account_storage_d_exports as u, FileEntry$1 as v, WriteData as x, FileSystem as y };
@@ -1,4 +1,4 @@
1
- import { D as IpFamily, F as LinksErrorCode, Ft as UdpDatagram, G as PackagesErrorCode, H as OverlayState, Ht as WriteData, It as UdpSocketOptions, J as Placement, M as LinkCreateWire, Nt as TcpSocketOptions, T as InstallOptions, U as PackageQuery, X as ProxyFetchInit, Z as ProxyFetchInput, a as AccountChange, b as FrameConsentAnswer, c as AdoptRequest, d as ConflictRequest, gt as RoomsErrorCode, jt as TcpSocketListenerOptions, l as AdoptState, lt as RoomJoinOptions, m as ConnectOptions, mt as RoomPermission, o as AccountPinOptions, p as ConnectAvailability, pt as RoomOpenOptions, q as PickOptions, rt as RoomClaimOptions, st as RoomEvent, tt as Resolvers, u as ConflictChoice, ut as RoomMailbox, x as FrameConsentRequest } from "./contract-XlEPwc7b.js";
1
+ import { D as IpFamily, Ft as UdpDatagram, H as ProxyFetchInput, Ht as WriteData, I as PackagesErrorCode, It as UdpSocketOptions, J as RoomClaimOptions, K as Resolvers, N as OverlayState, Nt as TcpSocketOptions, P as PackageQuery, Q as RoomEvent, R as PickOptions, T as InstallOptions, Tt as StoragePutWire, V as ProxyFetchInit, a as AccountChange, at as RoomPermission, b as FrameConsentAnswer, c as AdoptRequest, d as ConflictRequest, et as RoomJoinOptions, it as RoomOpenOptions, jt as TcpSocketListenerOptions, l as AdoptState, m as ConnectOptions, o as AccountPinOptions, p as ConnectAvailability, st as RoomsErrorCode, tt as RoomMailbox, u as ConflictChoice, x as FrameConsentRequest, xt as StorageErrorCode, z as Placement } from "./contract-DGuGXxKd.js";
2
2
  import { o as TcpSocketOption, x as UdpSocketOption } from "./wire-Fk5pJaoy.js";
3
3
  import { Remote } from "osra";
4
4
  //#region src/api-epochs.d.ts
@@ -26,7 +26,7 @@ declare const apiPromise: Promise<Api>;
26
26
  * so an unbridged worker parks every socket call with no `listening`, `error` or rejection, which
27
27
  * presents as a transport fault invisible from every counter.
28
28
  *
29
- * Once one deadline is missed, later calls wait only the retry deadline (as `storage.ts` does):
29
+ * Once one deadline is missed, later calls wait only the retry deadline (as `account-storage.ts` does):
30
30
  * `net.ts` listens with `bind('::').catch(() => bind('0.0.0.0'))` and would otherwise pay it twice.
31
31
  */
32
32
  declare const API_DEADLINE_MS = 8000;
@@ -707,54 +707,50 @@ declare const onApiEpoch: (listener: EpochListener<{
707
707
  message: string;
708
708
  }>;
709
709
  };
710
- links: {
710
+ storage: {
711
711
  available: () => Promise<boolean>;
712
- create: (data: Blob | ReadableStream<Uint8Array<ArrayBufferLike>>, options: LinkCreateWire) => Promise<{
713
- error: LinksErrorCode | 'aborted';
712
+ put: (data: Blob | ReadableStream<Uint8Array<ArrayBufferLike>>, options: StoragePutWire) => Promise<{
713
+ error: StorageErrorCode | 'aborted';
714
714
  message: string;
715
715
  } | {
716
- id: string;
716
+ url: string;
717
717
  size: number;
718
718
  status: 'uploading' | 'ready';
719
719
  created: number;
720
- expires: number | null;
721
- url: string;
722
- name: string;
723
- type: string;
720
+ key: string;
724
721
  }>;
725
- open: (url: string, options?: {
722
+ get: (url: string, key: string, options?: {
726
723
  signal?: AbortSignal;
727
724
  } | undefined) => Promise<{
728
- error: LinksErrorCode | 'aborted';
725
+ error: StorageErrorCode | 'aborted';
729
726
  message: string;
730
727
  } | {
731
- name: string;
732
- type: string;
733
728
  size: number;
734
- lastModified: number;
735
729
  read: (start: number, end: number) => Promise<ReadableStream<Uint8Array<ArrayBufferLike>> | {
736
- error: LinksErrorCode | 'aborted';
730
+ error: StorageErrorCode | 'aborted';
737
731
  message: string;
738
732
  }>;
739
733
  }>;
740
734
  list: (options: {
741
735
  accountPin: string;
736
+ limit?: number;
737
+ cursor?: string;
742
738
  }) => Promise<{
743
- error: LinksErrorCode | 'aborted';
739
+ error: StorageErrorCode | 'aborted';
744
740
  message: string;
745
741
  } | {
746
- links: {
747
- id: string;
742
+ objects: {
743
+ url: string;
748
744
  size: number;
749
745
  status: 'uploading' | 'ready';
750
746
  created: number;
751
- expires: number | null;
752
747
  }[];
748
+ cursor?: string;
753
749
  }>;
754
- revoke: (target: string, options: {
750
+ delete: (url: string, options: {
755
751
  accountPin: string;
756
752
  }) => Promise<{
757
- error: LinksErrorCode | 'aborted';
753
+ error: StorageErrorCode | 'aborted';
758
754
  message: string;
759
755
  } | {
760
756
  ok: true;
@@ -1498,54 +1494,50 @@ declare const currentApiEpoch: () => {
1498
1494
  message: string;
1499
1495
  }>;
1500
1496
  };
1501
- links: {
1497
+ storage: {
1502
1498
  available: () => Promise<boolean>;
1503
- create: (data: Blob | ReadableStream<Uint8Array<ArrayBufferLike>>, options: LinkCreateWire) => Promise<{
1504
- error: LinksErrorCode | 'aborted';
1499
+ put: (data: Blob | ReadableStream<Uint8Array<ArrayBufferLike>>, options: StoragePutWire) => Promise<{
1500
+ error: StorageErrorCode | 'aborted';
1505
1501
  message: string;
1506
1502
  } | {
1507
- id: string;
1503
+ url: string;
1508
1504
  size: number;
1509
1505
  status: 'uploading' | 'ready';
1510
1506
  created: number;
1511
- expires: number | null;
1512
- url: string;
1513
- name: string;
1514
- type: string;
1507
+ key: string;
1515
1508
  }>;
1516
- open: (url: string, options?: {
1509
+ get: (url: string, key: string, options?: {
1517
1510
  signal?: AbortSignal;
1518
1511
  } | undefined) => Promise<{
1519
- error: LinksErrorCode | 'aborted';
1512
+ error: StorageErrorCode | 'aborted';
1520
1513
  message: string;
1521
1514
  } | {
1522
- name: string;
1523
- type: string;
1524
1515
  size: number;
1525
- lastModified: number;
1526
1516
  read: (start: number, end: number) => Promise<ReadableStream<Uint8Array<ArrayBufferLike>> | {
1527
- error: LinksErrorCode | 'aborted';
1517
+ error: StorageErrorCode | 'aborted';
1528
1518
  message: string;
1529
1519
  }>;
1530
1520
  }>;
1531
1521
  list: (options: {
1532
1522
  accountPin: string;
1523
+ limit?: number;
1524
+ cursor?: string;
1533
1525
  }) => Promise<{
1534
- error: LinksErrorCode | 'aborted';
1526
+ error: StorageErrorCode | 'aborted';
1535
1527
  message: string;
1536
1528
  } | {
1537
- links: {
1538
- id: string;
1529
+ objects: {
1530
+ url: string;
1539
1531
  size: number;
1540
1532
  status: 'uploading' | 'ready';
1541
1533
  created: number;
1542
- expires: number | null;
1543
1534
  }[];
1535
+ cursor?: string;
1544
1536
  }>;
1545
- revoke: (target: string, options: {
1537
+ delete: (url: string, options: {
1546
1538
  accountPin: string;
1547
1539
  }) => Promise<{
1548
- error: LinksErrorCode | 'aborted';
1540
+ error: StorageErrorCode | 'aborted';
1549
1541
  message: string;
1550
1542
  } | {
1551
1543
  ok: true;
package/api.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { tt as Resolvers } from "./contract-XlEPwc7b.js";
2
- import { a as apiLastCall, c as currentApiEpoch, i as apiInFlight, l as hasTransport, n as BrokerUnreachableError, o as apiPromise, r as OwnChannelUnavailableError, s as apiWithin, t as API_DEADLINE_MS, u as onApiEpoch } from "./api-Cpi-qz1j.js";
1
+ import { K as Resolvers } from "./contract-DGuGXxKd.js";
2
+ import { a as apiLastCall, c as currentApiEpoch, i as apiInFlight, l as hasTransport, n as BrokerUnreachableError, o as apiPromise, r as OwnChannelUnavailableError, s as apiWithin, t as API_DEADLINE_MS, u as onApiEpoch } from "./api-wnOQJEK6.js";
3
3
  export { API_DEADLINE_MS, BrokerUnreachableError, OwnChannelUnavailableError, type Resolvers, apiInFlight, apiLastCall, apiPromise, apiWithin, currentApiEpoch, hasTransport, onApiEpoch };
package/cloud/dns.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { s as AddressLookupResult } from "../contract-XlEPwc7b.js";
1
+ import { s as AddressLookupResult } from "../contract-DGuGXxKd.js";
2
2
  import { lookup } from "../dns.js";
3
3
  export { type AddressLookupResult, lookup };
package/cloud/fetch.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { t as cloudFetch } from "../proxy-BZ-YFeXe.js";
1
+ import { t as cloudFetch } from "../proxy-MVuD49E2.js";
2
2
  export { cloudFetch as fetch };
@@ -1,5 +1,5 @@
1
1
  import { a as WriteData, i as Stats, n as MakeOptions, o as WriteOptions, r as ReadOptions } from "../../index-BQgZVQl7.js";
2
- import "../../fs-lKZe5xIo.js";
2
+ import "../../fs-BZv2djbS.js";
3
3
  //#region src/cloud/fs-promises.d.ts
4
4
  export declare const readFile: (path: import("node:fs").PathLike, options?: ReadOptions) => Promise<Buffer | string>, writeFile: (path: import("node:fs").PathLike, data: WriteData, options?: WriteOptions) => Promise<void>, unlink: (path: import("node:fs").PathLike) => Promise<void>, rename: (from: import("node:fs").PathLike, to: import("node:fs").PathLike) => Promise<void>, readdir: (path: import("node:fs").PathLike) => Promise<string[]>, mkdir: (_path?: import("node:fs").PathLike, _options?: MakeOptions) => Promise<void>, rm: (path: import("node:fs").PathLike, options?: {
5
5
  recursive?: boolean;
package/cloud/fs.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../rolldown-runtime-BIInC43l.cjs"),t=require("../node-fs-vsWuoMGa.cjs"),n=require("../messages.cjs"),r=require("../storage-DmRIhg1P.cjs");var i=e.t({STORAGE_ACCOUNT_CHANGED:()=>n.STORAGE_ACCOUNT_CHANGED,STORAGE_ACCOUNT_PIN_UNSUPPORTED:()=>n.STORAGE_ACCOUNT_PIN_UNSUPPORTED,STORAGE_NOT_FOUND:()=>n.STORAGE_NOT_FOUND,StorageAccountChangedError:()=>r.t,StorageAccountPinUnsupportedError:()=>r.n,StorageLockedError:()=>r.r,StorageNotFoundError:()=>r.i,availability:()=>r.a,available:()=>a,encryption:()=>r.s,isAccountChanged:()=>r.c,isNotFound:()=>r.u,list:()=>h,mkdir:()=>d,promises:()=>m,quota:()=>r.m,readFile:()=>o,readFileSealed:()=>g,readdir:()=>u,rename:()=>l,rm:()=>f,stat:()=>p,unlink:()=>c,unlock:()=>r.y,writeFile:()=>s}),{available:a,readFile:o,writeFile:s,unlink:c,rename:l,readdir:u,mkdir:d,rm:f,stat:p,promises:m}=t.t(r.v,{memfs:!1}),h=()=>r.f(),g=e=>r.g(e);exports.STORAGE_ACCOUNT_CHANGED=n.STORAGE_ACCOUNT_CHANGED,exports.STORAGE_ACCOUNT_PIN_UNSUPPORTED=n.STORAGE_ACCOUNT_PIN_UNSUPPORTED,exports.STORAGE_NOT_FOUND=n.STORAGE_NOT_FOUND,exports.StorageAccountChangedError=r.t,exports.StorageAccountPinUnsupportedError=r.n,exports.StorageLockedError=r.r,exports.StorageNotFoundError=r.i,exports.availability=r.a,exports.available=a,exports.encryption=r.s,exports.isAccountChanged=r.c,exports.isNotFound=r.u,exports.list=h,exports.mkdir=d,exports.promises=m,exports.quota=r.m,exports.readFile=o,exports.readFileSealed=g,exports.readdir=u,exports.rename=l,exports.rm=f,exports.stat=p,Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return i}}),exports.unlink=c,exports.unlock=r.y,exports.writeFile=s;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../rolldown-runtime-BIInC43l.cjs"),t=require("../node-fs-vsWuoMGa.cjs"),n=require("../messages.cjs"),r=require("../account-storage-C6hcXjG0.cjs");var i=e.t({STORAGE_ACCOUNT_CHANGED:()=>n.STORAGE_ACCOUNT_CHANGED,STORAGE_ACCOUNT_PIN_UNSUPPORTED:()=>n.STORAGE_ACCOUNT_PIN_UNSUPPORTED,STORAGE_NOT_FOUND:()=>n.STORAGE_NOT_FOUND,StorageAccountChangedError:()=>r.t,StorageAccountPinUnsupportedError:()=>r.n,StorageLockedError:()=>r.r,StorageNotFoundError:()=>r.i,availability:()=>r.o,available:()=>a,encryption:()=>r.c,isAccountChanged:()=>r.l,isNotFound:()=>r.d,list:()=>h,mkdir:()=>d,promises:()=>m,quota:()=>r.h,readFile:()=>o,readFileSealed:()=>g,readdir:()=>u,rename:()=>l,rm:()=>f,stat:()=>p,unlink:()=>c,unlock:()=>r.y,writeFile:()=>s}),{available:a,readFile:o,writeFile:s,unlink:c,rename:l,readdir:u,mkdir:d,rm:f,stat:p,promises:m}=t.t(r.a,{memfs:!1}),h=()=>r.p(),g=e=>r._(e);exports.STORAGE_ACCOUNT_CHANGED=n.STORAGE_ACCOUNT_CHANGED,exports.STORAGE_ACCOUNT_PIN_UNSUPPORTED=n.STORAGE_ACCOUNT_PIN_UNSUPPORTED,exports.STORAGE_NOT_FOUND=n.STORAGE_NOT_FOUND,exports.StorageAccountChangedError=r.t,exports.StorageAccountPinUnsupportedError=r.n,exports.StorageLockedError=r.r,exports.StorageNotFoundError=r.i,exports.availability=r.o,exports.available=a,exports.encryption=r.c,exports.isAccountChanged=r.l,exports.isNotFound=r.d,exports.list=h,exports.mkdir=d,exports.promises=m,exports.quota=r.h,exports.readFile=o,exports.readFileSealed=g,exports.readdir=u,exports.rename=l,exports.rm=f,exports.stat=p,Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return i}}),exports.unlink=c,exports.unlock=r.y,exports.writeFile=s;
package/cloud/fs.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { i as Stats } from "../index-BQgZVQl7.js";
2
- import { _ as unlock, a as StorageAccountChangedError, c as StorageNotFoundError, f as encryption, h as quota, i as SealedRead, l as StorageQuota, m as isNotFound, n as EncryptionStatus, o as StorageAccountPinUnsupportedError, p as isAccountChanged, r as FileEntry, s as StorageLockedError, t as CloudAvailability, u as availability } from "../storage-B_mXNAdB.js";
3
- import { c as STORAGE_ACCOUNT_CHANGED, l as STORAGE_ACCOUNT_PIN_UNSUPPORTED, u as STORAGE_NOT_FOUND } from "../messages-d7pvCXPn.js";
4
- import { a as promises, c as readdir, d as stat, f as unlink, i as mkdir, l as rename, o as readFile, p as writeFile, r as list, s as readFileSealed, t as available, u as rm } from "../fs-lKZe5xIo.js";
2
+ import { _ as unlock, a as StorageAccountChangedError, c as StorageNotFoundError, d as availability, g as quota, h as isNotFound, i as SealedRead, l as StorageQuota, m as isAccountChanged, n as EncryptionStatus, o as StorageAccountPinUnsupportedError, p as encryption, r as FileEntry, s as StorageLockedError, t as CloudAvailability } from "../account-storage-DHl6bXdb.js";
3
+ import { c as STORAGE_ACCOUNT_CHANGED, l as STORAGE_ACCOUNT_PIN_UNSUPPORTED, u as STORAGE_NOT_FOUND } from "../messages-AdPfdoLV.js";
4
+ import { a as promises, c as readdir, d as stat, f as unlink, i as mkdir, l as rename, o as readFile, p as writeFile, r as list, s as readFileSealed, t as available, u as rm } from "../fs-BZv2djbS.js";
5
5
  export { type CloudAvailability, type EncryptionStatus, type FileEntry, STORAGE_ACCOUNT_CHANGED, STORAGE_ACCOUNT_PIN_UNSUPPORTED, STORAGE_NOT_FOUND, type SealedRead, type Stats, StorageAccountChangedError, StorageAccountPinUnsupportedError, StorageLockedError, StorageNotFoundError, type StorageQuota, availability, available, encryption, isAccountChanged, isNotFound, list, mkdir, promises, quota, readFile, readFileSealed, readdir, rename, rm, stat, unlink, unlock, writeFile };
package/cloud/fs.js CHANGED
@@ -1,25 +1,25 @@
1
1
  import { t as e } from "../rolldown-runtime-Dy4uBu1J.js";
2
2
  import { t } from "../node-fs-DY2fO5zd.js";
3
3
  import { STORAGE_ACCOUNT_CHANGED as n, STORAGE_ACCOUNT_PIN_UNSUPPORTED as r, STORAGE_NOT_FOUND as i } from "../messages.js";
4
- import { a, c as o, f as s, g as c, i as l, m as u, n as d, r as f, s as p, t as m, u as h, v as g, y as _ } from "../storage-C6F9SnDM.js";
4
+ import { _ as a, a as o, c as s, d as c, h as l, i as u, l as d, n as f, o as p, p as m, r as h, t as g, y as _ } from "../account-storage-C31d68BN.js";
5
5
  //#region src/cloud/fs.ts
6
6
  var v = /* @__PURE__ */ e({
7
7
  STORAGE_ACCOUNT_CHANGED: () => n,
8
8
  STORAGE_ACCOUNT_PIN_UNSUPPORTED: () => r,
9
9
  STORAGE_NOT_FOUND: () => i,
10
- StorageAccountChangedError: () => m,
11
- StorageAccountPinUnsupportedError: () => d,
12
- StorageLockedError: () => f,
13
- StorageNotFoundError: () => l,
14
- availability: () => a,
10
+ StorageAccountChangedError: () => g,
11
+ StorageAccountPinUnsupportedError: () => f,
12
+ StorageLockedError: () => h,
13
+ StorageNotFoundError: () => u,
14
+ availability: () => p,
15
15
  available: () => y,
16
- encryption: () => p,
17
- isAccountChanged: () => o,
18
- isNotFound: () => h,
16
+ encryption: () => s,
17
+ isAccountChanged: () => d,
18
+ isNotFound: () => c,
19
19
  list: () => k,
20
20
  mkdir: () => T,
21
21
  promises: () => O,
22
- quota: () => u,
22
+ quota: () => l,
23
23
  readFile: () => b,
24
24
  readFileSealed: () => A,
25
25
  readdir: () => w,
@@ -29,6 +29,6 @@ var v = /* @__PURE__ */ e({
29
29
  unlink: () => S,
30
30
  unlock: () => _,
31
31
  writeFile: () => x
32
- }), { available: y, readFile: b, writeFile: x, unlink: S, rename: C, readdir: w, mkdir: T, rm: E, stat: D, promises: O } = t(g, { memfs: !1 }), k = () => s(), A = (e) => c(e);
32
+ }), { available: y, readFile: b, writeFile: x, unlink: S, rename: C, readdir: w, mkdir: T, rm: E, stat: D, promises: O } = t(o, { memfs: !1 }), k = () => m(), A = (e) => a(e);
33
33
  //#endregion
34
- export { n as STORAGE_ACCOUNT_CHANGED, r as STORAGE_ACCOUNT_PIN_UNSUPPORTED, i as STORAGE_NOT_FOUND, m as StorageAccountChangedError, d as StorageAccountPinUnsupportedError, f as StorageLockedError, l as StorageNotFoundError, a as availability, y as available, p as encryption, o as isAccountChanged, h as isNotFound, k as list, T as mkdir, O as promises, u as quota, b as readFile, A as readFileSealed, w as readdir, C as rename, E as rm, D as stat, v as t, S as unlink, _ as unlock, x as writeFile };
34
+ export { n as STORAGE_ACCOUNT_CHANGED, r as STORAGE_ACCOUNT_PIN_UNSUPPORTED, i as STORAGE_NOT_FOUND, g as StorageAccountChangedError, f as StorageAccountPinUnsupportedError, h as StorageLockedError, u as StorageNotFoundError, p as availability, y as available, s as encryption, d as isAccountChanged, c as isNotFound, k as list, T as mkdir, O as promises, l as quota, b as readFile, A as readFileSealed, w as readdir, C as rename, E as rm, D as stat, v as t, S as unlink, _ as unlock, x as writeFile };
package/cloud/net.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as createConnection, c as isIP, i as connect, l as isIPv4, n as Socket, o as createServer, r as _default, t as Server, u as isIPv6 } from "../net-C2Yz0job.js";
1
+ import { a as createConnection, c as isIP, i as connect, l as isIPv4, n as Socket, o as createServer, r as _default, t as Server, u as isIPv6 } from "../net-C2sulnNU.js";
2
2
  export { Server, Socket, _default, _default as default, connect, createConnection, createServer, isIP, isIPv4, isIPv6 };
@@ -1,8 +1,8 @@
1
1
  import { r as AttachFrameFunction } from "./index-DlBWSKwV.js";
2
- import { t as cloudFetch } from "./proxy-BZ-YFeXe.js";
2
+ import { t as cloudFetch } from "./proxy-MVuD49E2.js";
3
3
  import { t as dns_d_exports } from "./dns.js";
4
- import { n as fs_d_exports } from "./fs-lKZe5xIo.js";
5
- import { s as net_d_exports } from "./net-C2Yz0job.js";
4
+ import { n as fs_d_exports } from "./fs-BZv2djbS.js";
5
+ import { s as net_d_exports } from "./net-C2sulnNU.js";
6
6
  import { t as dgram_d_exports } from "./dgram.js";
7
7
  import { t as http_d_exports } from "./http.js";
8
8
  //#region src/cloud/frame.d.ts
package/cloud.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { t as cloudFetch } from "./proxy-BZ-YFeXe.js";
2
- import { a as attachFrame, i as quota, r as QuotaStatus, t as available } from "./cloud-DK3DtdsU.js";
1
+ import { t as cloudFetch } from "./proxy-MVuD49E2.js";
2
+ import { a as attachFrame, i as quota, r as QuotaStatus, t as available } from "./cloud-CWHjH89l.js";
3
3
  import { t as dns_d_exports } from "./dns.js";
4
- import { n as fs_d_exports } from "./fs-lKZe5xIo.js";
5
- import { s as net_d_exports } from "./net-C2Yz0job.js";
4
+ import { n as fs_d_exports } from "./fs-BZv2djbS.js";
5
+ import { s as net_d_exports } from "./net-C2sulnNU.js";
6
6
  import { t as dgram_d_exports } from "./dgram.js";
7
7
  import { t as http_d_exports } from "./http.js";
8
8
  export { type QuotaStatus, attachFrame, available, dgram_d_exports as dgram, dns_d_exports as dns, cloudFetch as fetch, fs_d_exports as fs, http_d_exports as http, net_d_exports as net, quota };
@@ -853,102 +853,137 @@ type RoomHandle = {
853
853
  /** settles once, when the room ends for this app. Never rejects. */
854
854
  closed: Promise<RoomEnd>;
855
855
  };
856
- /**
857
- * How far ahead a link's `expires` may be, in milliseconds: from 60,000 (1 minute) to 31,536,000,000
858
- * (365 days). Anything outside is refused `invalid`.
859
- */
860
- declare const LINK_EXPIRES_MS: {
861
- readonly min: 60000;
862
- readonly max: 31536000000;
863
- };
864
- /** What a links refusal is about. Branch on it, never on the message. */
865
- type LinksErrorCode = 'invalid' | 'not-found' | 'integrity' | 'denied' | 'quota' | 'too-many' | 'rate-limited' | 'account-changed' | 'unavailable';
856
+ /** What a storage refusal is about. Branch on it, never on the message. */
857
+ type StorageErrorCode = 'invalid' | 'not-found' | 'integrity' | 'denied' | 'quota' | 'too-many' | 'account-changed' | 'unavailable';
866
858
  /**
867
859
  * A refusal, as data, the `RoomsFail` shape. `aborted` is the app's own signal, which the library turns
868
- * back into the signal's reason rather than a `LinksError`.
860
+ * back into the signal's reason rather than a `StorageError`.
869
861
  */
870
- type LinksFail = {
871
- error: LinksErrorCode | 'aborted';
862
+ type StorageFail = {
863
+ error: StorageErrorCode | 'aborted';
872
864
  message: string;
873
865
  };
874
- /**
875
- * A link as `list` answers it: what the service holds, which names no file and opens nothing, since
876
- * the service never holds a link's key. Every time is epoch milliseconds.
877
- */
878
- type ListedLink = {
879
- /** for `revoke` and `list`; it opens nothing */
880
- id: string;
866
+ /** A stored object as `put` and `list` answer it. Every time is epoch milliseconds. */
867
+ type StoredObject = {
868
+ /** `https://cdn.fkn.app/<uuid>` in production: anyone holding it can download the sealed bytes, and nothing more */
869
+ url: string;
881
870
  /** the file's own bytes; the account's storage counts 28 bytes more per 1 MiB */
882
871
  size: number;
883
872
  /** `uploading` until every part has landed */
884
873
  status: 'uploading' | 'ready';
885
874
  created: number;
886
- /** null while the link lasts until it is revoked */
887
- expires: number | null;
888
875
  };
889
- /** A link as `create` answers it: the listed fields, and what only the app that made it holds. */
890
- type Link = ListedLink & {
891
- /** `https://fkn.app/file#<key>`: anyone holding it opens the file */
892
- url: string;
893
- name: string;
894
- type: string;
876
+ /** One page of `list`, newest first. `cursor` is present only while more objects remain. */
877
+ type StoredPage = {
878
+ objects: StoredObject[];
879
+ cursor?: string;
895
880
  };
896
881
  /** Progress of an upload, `ProgressEvent`'s two figures, in bytes of the file itself. */
897
- type LinkProgress = {
882
+ type StorageProgress = {
898
883
  loaded: number;
899
884
  total: number;
900
885
  };
901
- type LinkCreateOptions = {
902
- /** defaults to the File's own name, or '' for a Blob or a stream */
903
- name?: string;
904
- /** defaults to the Blob's own type */
905
- type?: string;
886
+ type StoragePutOptions = {
906
887
  /**
907
- * epoch milliseconds on this page's clock, from 60,000 to 31,536,000,000 ahead of now
908
- * (`LINK_EXPIRES_MS`), else `invalid`. The library turns it into a duration at the call, and the
909
- * service adds that duration to its own clock, so `Link.expires` is read back from the service.
910
- * Omitted, the link lasts until it is revoked.
888
+ * the key that opens the object, 32 bytes as canonical unpadded base64url (43 characters), minted
889
+ * when absent. It never reaches FKN's servers and never appears in the url: whoever holds the url
890
+ * and the key reads the object.
911
891
  */
912
- expires?: number;
892
+ key?: string;
913
893
  /** required for a ReadableStream: the bytes it will deliver, exactly */
914
894
  size?: number;
915
- /**
916
- * the link key, 32 bytes base64url, minted when absent, as a room key is. It is what the url carries
917
- * after the `#`, the service never sees it, and the account's own key has no part in it, so a key
918
- * reset leaves the link opening. One key names one link at a time: a key that already names one is
919
- * refused `invalid`.
920
- */
921
- key?: string;
922
895
  /** aborts the upload and releases the storage it reserved */
923
896
  signal?: AbortSignal;
924
897
  /** called as each part lands */
925
- onProgress?: (progress: LinkProgress) => void;
898
+ onProgress?: (progress: StorageProgress) => void;
926
899
  };
927
- /** What the library hands the broker for a create, resolved at the moment of the call. */
928
- type LinkCreateWire = {
929
- name?: string;
930
- type?: string;
931
- lastModified?: number;
932
- size?: number;
933
- /** milliseconds from now, from `LINK_EXPIRES_MS.min` to `.max`; absent for a link that lasts until revoked */
934
- expiresIn?: number;
935
- /** the app's own link key, as `LinkCreateOptions.key`; absent, the broker mints one */
936
- key?: string;
900
+ /** What the library hands the broker for a put, resolved at the moment of the call. */
901
+ type StoragePutWire = StoragePutOptions & {
937
902
  accountPin: string;
938
- signal?: AbortSignal;
939
- onProgress?: (progress: LinkProgress) => void;
940
903
  };
941
904
  /**
942
- * An opened link, held by the broker, which keeps its key and reads the file by range. `read` hands
943
- * over the bytes from `start` to `end` (exclusive), each 1 MiB record checked before it is handed over,
944
- * and errors the stream on the first that is not what the link sealed.
905
+ * An object the broker opened: its plaintext size, and its bytes from `start` to `end` (exclusive) by
906
+ * range, each 1 MiB record checked before it is handed over. The stream errors on the first record
907
+ * that does not open under the key.
945
908
  */
946
- type LinkHandle = {
947
- name: string;
948
- type: string;
909
+ type StoredHandle = {
949
910
  size: number;
950
- lastModified: number;
951
- read: (start: number, end: number) => Promise<LinksFail | ReadableStream<Uint8Array>>;
911
+ read: (start: number, end: number) => Promise<StorageFail | ReadableStream<Uint8Array>>;
912
+ };
913
+ /**
914
+ * Every storage refusal, worded once for the library and the broker. Branch on `code`, never on the
915
+ * message. `notFound` is one answer for an object that was never made, was deleted, or is still
916
+ * uploading.
917
+ */
918
+ declare const STORAGE_REFUSALS: {
919
+ readonly notAFile: {
920
+ readonly code: 'invalid';
921
+ readonly message: 'storage: the data is not a Blob or a ReadableStream';
922
+ };
923
+ readonly badSize: {
924
+ readonly code: 'invalid';
925
+ readonly message: 'storage: a stream needs the size it will deliver, a whole number of bytes';
926
+ };
927
+ readonly shortStream: {
928
+ readonly code: 'invalid';
929
+ readonly message: 'storage: the stream did not deliver the size it declared';
930
+ };
931
+ readonly tooLarge: {
932
+ readonly code: 'invalid';
933
+ readonly message: 'storage: the file is too large to store';
934
+ };
935
+ readonly badKey: {
936
+ readonly code: 'invalid';
937
+ readonly message: 'storage: the key is not 32 bytes base64url';
938
+ };
939
+ readonly badUrl: {
940
+ readonly code: 'invalid';
941
+ readonly message: 'storage: the url does not name a stored object';
942
+ };
943
+ readonly badLimit: {
944
+ readonly code: 'invalid';
945
+ readonly message: 'storage: the limit is out of range';
946
+ };
947
+ readonly badCursor: {
948
+ readonly code: 'invalid';
949
+ readonly message: 'storage: the cursor is not one list answered';
950
+ };
951
+ readonly notFound: {
952
+ readonly code: 'not-found';
953
+ readonly message: 'storage: no object at this url';
954
+ };
955
+ readonly integrity: {
956
+ readonly code: 'integrity';
957
+ readonly message: 'storage: the object does not match its key';
958
+ };
959
+ readonly needsAccount: {
960
+ readonly code: 'denied';
961
+ readonly message: 'storage: storing needs an account';
962
+ };
963
+ readonly notCreator: {
964
+ readonly code: 'denied';
965
+ readonly message: 'storage: only the app that stored the object can delete it';
966
+ };
967
+ readonly quota: {
968
+ readonly code: 'quota';
969
+ readonly message: 'storage: storage quota exceeded';
970
+ };
971
+ readonly tooMany: {
972
+ readonly code: 'too-many';
973
+ readonly message: 'storage: too many stored objects';
974
+ };
975
+ readonly tooManyThisHour: {
976
+ readonly code: 'too-many';
977
+ readonly message: 'storage: too many objects stored this hour, try again later';
978
+ };
979
+ readonly accountChanged: {
980
+ readonly code: 'account-changed';
981
+ readonly message: 'storage: the signed-in account changed';
982
+ };
983
+ readonly unavailable: {
984
+ readonly code: 'unavailable';
985
+ readonly message: 'storage: storage is unavailable';
986
+ };
952
987
  };
953
988
  type IpFamily = 'IPv4' | 'IPv6';
954
989
  /** Viewport rect plus optional corner radii, as the overlay host reports them. */
@@ -1184,26 +1219,28 @@ type Resolvers = {
1184
1219
  join: (invite: string, options?: RoomJoinOptions) => Promise<RoomsFail | RoomHandle>;
1185
1220
  };
1186
1221
  /**
1187
- * Links to sealed files. Making, listing and revoking act for the calling app under the account its
1188
- * pin was taken under; opening needs no account at all.
1222
+ * Objects sealed here under a key the app holds and served to anyone holding the url. `put`, `list`
1223
+ * and `delete` act for the calling app under the account its pin was taken under; `get` needs no
1224
+ * account at all. The data and the key cross to this frame and stay in the browser: the api hears
1225
+ * only sizes and ids, the store only sealed bytes.
1189
1226
  */
1190
- links: {
1191
- /** whether a link can be made here now: an account is connected and the broker serves links */
1227
+ storage: {
1228
+ /** whether put, list and delete can run here: storage is configured, the data plane serves it, and an account is connected under the caller */
1192
1229
  available: () => Promise<boolean>;
1193
- create: (data: Blob | ReadableStream<Uint8Array>, options: LinkCreateWire) => Promise<LinksFail | Link>;
1194
- open: (url: string, options?: {
1230
+ put: (data: Blob | ReadableStream<Uint8Array>, options: StoragePutWire) => Promise<StorageFail | (StoredObject & {
1231
+ key: string;
1232
+ })>;
1233
+ get: (url: string, key: string, options?: {
1195
1234
  signal?: AbortSignal;
1196
- }) => Promise<LinksFail | LinkHandle>;
1197
- /** the calling app's links, newest first, uploads in progress included */
1235
+ }) => Promise<StorageFail | StoredHandle>;
1198
1236
  list: (options: {
1199
1237
  accountPin: string;
1200
- }) => Promise<LinksFail | {
1201
- links: ListedLink[];
1202
- }>;
1203
- /** `target` is a link's url or its id; an upload in progress is aborted */
1204
- revoke: (target: string, options: {
1238
+ limit?: number;
1239
+ cursor?: string;
1240
+ }) => Promise<StorageFail | StoredPage>;
1241
+ delete: (url: string, options: {
1205
1242
  accountPin: string;
1206
- }) => Promise<LinksFail | {
1243
+ }) => Promise<StorageFail | {
1207
1244
  ok: true;
1208
1245
  }>;
1209
1246
  };
@@ -1229,4 +1266,4 @@ type Resolvers = {
1229
1266
  hideInstallPrompt: () => void;
1230
1267
  };
1231
1268
  //#endregion
1232
- export { ROOM_TEMPORARY_MS as $, Link as A, SurfaceRect as At, MountDescriptor as B, WINDOW_JAR_MODE_TIMEOUT_MS as Bt, FrameMessageRelay as C, SetOverlayHost as Ct, IpFamily as D, ShellJarUnreachable as Dt, InstalledPackage as E, ShellGotoOptions as Et, LinksErrorCode as F, UdpDatagram as Ft, PackagesErrorCode as G, OverlayState as H, WriteData as Ht, LinksFail as I, UdpSocketOptions as It, Placement as J, PackagesFail as K, ListedLink as L, UdpSocketResult as Lt, LinkCreateWire as M, TcpSocketListenerResult as Mt, LinkHandle as N, TcpSocketOptions as Nt, JAR_ANCHOR_MESSAGE as O, StorageEntry as Ot, LinkProgress as P, TcpSocketResult as Pt, Quota as Q, MiddleControl as R, WINDOW_HANDSHAKE_TIMEOUT_MS as Rt, FrameFetchScope as S, SHELL_JAR_UNREACHABLE as St, InstallOptions as T, ShellFrameMessage as Tt, PackageQuery as U, JarSeed as Ut, OverlayRect as V, WindowMiddleControl as Vt, PackageResult as W, JarSeedCookie as Wt, ProxyFetchInit as X, ProxyFetch as Y, ProxyFetchInput as Z, DnsLookup as _, RoomsFail as _t, AccountChange as a, RoomDefaults as at, FrameConsentAnswer as b, SHELL_FRAME_MESSAGE as bt, AdoptRequest as c, RoomHandle as ct, ConflictRequest as d, RoomMember as dt, Radii as et, ConflictSide as f, RoomMessage as ft, DisplayLevel as g, RoomsErrorCode as gt, DisplayCause as h, RoomPermissions as ht, Account as i, RoomCreateOptions as it, LinkCreateOptions as j, TcpSocketListenerOptions as jt, LINK_EXPIRES_MS as k, StorageQuota as kt, AdoptState as l, RoomJoinOptions as lt, ConnectOptions as m, RoomPermission as mt, ATTACH_WINDOW_KEY as n, RoomBacklog as nt, AccountPinOptions as o, RoomEnd as ot, ConnectAvailability as p, RoomOpenOptions as pt, PickOptions as q, ATTACH_WINDOW_MESSAGE as r, RoomClaimOptions as rt, AddressLookupResult as s, RoomEvent as st, ATTACH_FRAME_KEY as t, Resolvers as tt, ConflictChoice as u, RoomMailbox as ut, EncryptionState as v, SHELL_ATTACH_ERROR as vt, HiddenSurface as w, ShellControl as wt, FrameConsentRequest as x, SHELL_JAR_MESSAGE as xt, FRAME_MESSAGE as y, SHELL_CONTROL_KEY as yt, MiddleGotoOptions as z, WINDOW_HELLO_TIMEOUT_MS as zt };
1269
+ export { RoomHandle as $, MiddleGotoOptions as A, SurfaceRect as At, ProxyFetch as B, WINDOW_JAR_MODE_TIMEOUT_MS as Bt, FrameMessageRelay as C, StorageProgress as Ct, IpFamily as D, StoredHandle as Dt, InstalledPackage as E, StorageQuota as Et, PackageResult as F, UdpDatagram as Ft, Radii as G, ProxyFetchInput as H, WriteData as Ht, PackagesErrorCode as I, UdpSocketOptions as It, RoomClaimOptions as J, Resolvers as K, PackagesFail as L, UdpSocketResult as Lt, OverlayRect as M, TcpSocketListenerResult as Mt, OverlayState as N, TcpSocketOptions as Nt, JAR_ANCHOR_MESSAGE as O, StoredObject as Ot, PackageQuery as P, TcpSocketResult as Pt, RoomEvent as Q, PickOptions as R, WINDOW_HANDSHAKE_TIMEOUT_MS as Rt, FrameFetchScope as S, StorageFail as St, InstallOptions as T, StoragePutWire as Tt, Quota as U, JarSeed as Ut, ProxyFetchInit as V, WindowMiddleControl as Vt, ROOM_TEMPORARY_MS as W, JarSeedCookie as Wt, RoomDefaults as X, RoomCreateOptions as Y, RoomEnd as Z, DnsLookup as _, ShellFrameMessage as _t, AccountChange as a, RoomPermission as at, FrameConsentAnswer as b, StorageEntry as bt, AdoptRequest as c, RoomsFail as ct, ConflictRequest as d, SHELL_FRAME_MESSAGE as dt, RoomJoinOptions as et, ConflictSide as f, SHELL_JAR_MESSAGE as ft, DisplayLevel as g, ShellControl as gt, DisplayCause as h, SetOverlayHost as ht, Account as i, RoomOpenOptions as it, MountDescriptor as j, TcpSocketListenerOptions as jt, MiddleControl as k, StoredPage as kt, AdoptState as l, SHELL_ATTACH_ERROR as lt, ConnectOptions as m, STORAGE_REFUSALS as mt, ATTACH_WINDOW_KEY as n, RoomMember as nt, AccountPinOptions as o, RoomPermissions as ot, ConnectAvailability as p, SHELL_JAR_UNREACHABLE as pt, RoomBacklog as q, ATTACH_WINDOW_MESSAGE as r, RoomMessage as rt, AddressLookupResult as s, RoomsErrorCode as st, ATTACH_FRAME_KEY as t, RoomMailbox as tt, ConflictChoice as u, SHELL_CONTROL_KEY as ut, EncryptionState as v, ShellGotoOptions as vt, HiddenSurface as w, StoragePutOptions as wt, FrameConsentRequest as x, StorageErrorCode as xt, FRAME_MESSAGE as y, ShellJarUnreachable as yt, Placement as z, WINDOW_HELLO_TIMEOUT_MS as zt };