@fkn/lib 0.9.40 → 0.9.42
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/account-generation-B-6Pn0b5.cjs +1 -0
- package/account-generation-XNWOvLea.js +28 -0
- package/account.cjs +1 -1
- package/account.d.ts +11 -0
- package/account.js +8 -20
- package/api--LOXTOpv.cjs +3 -0
- package/{api-Dp-2AT3u.js → api-DIgTslNb.js} +154 -114
- package/{api-BE5zPvFZ.d.ts → api-SwxtiYVU.d.ts} +38 -14
- package/api.cjs +1 -1
- package/api.d.ts +3 -3
- package/api.js +2 -2
- package/attach-policy.cjs +1 -1
- package/attach-policy.js +2 -2
- package/cloud/dns.d.ts +1 -1
- package/cloud/fetch.cjs +1 -1
- package/cloud/fetch.d.ts +1 -1
- package/cloud/fetch.js +1 -1
- package/cloud/fs/promises.d.ts +1 -1
- package/cloud/fs.cjs +1 -1
- package/cloud/fs.d.ts +4 -4
- package/cloud/fs.js +31 -24
- package/cloud/net.d.ts +1 -1
- package/cloud-868OlBKn.cjs +1 -0
- package/{cloud-5eldoFxK.d.ts → cloud-DUH-v10C.d.ts} +6 -4
- package/cloud-f3j4s8yZ.js +545 -0
- package/cloud.cjs +1 -1
- package/cloud.d.ts +4 -4
- package/cloud.js +2 -2
- package/{contract-Cvr_8gCL.d.ts → contract-CCxPKIC7.d.ts} +105 -13
- package/contract.d.ts +3 -2
- package/dgram.cjs +1 -1
- package/dgram.d.ts +2 -2
- package/dgram.js +1 -1
- package/dns.cjs +1 -1
- package/dns.d.ts +1 -1
- package/dns.js +1 -1
- package/extension-BOBuYwZc.js +92 -0
- package/extension-hoUs5yJ7.cjs +1 -0
- package/{extension-DMU-CwMw.d.ts → extension-yhwDSIiD.d.ts} +22 -3
- package/extension.cjs +1 -1
- package/extension.d.ts +3 -3
- package/extension.js +3 -3
- package/fs/promises.cjs +1 -1
- package/fs/promises.d.ts +1 -1
- package/fs/promises.js +1 -1
- package/fs-CVnmXRf7.js +513 -0
- package/{fs--NhtUyYa.d.ts → fs-D0MMRnHC.d.ts} +8 -4
- package/fs-p0bOOj5n.cjs +1 -0
- package/fs.cjs +1 -1
- package/fs.d.ts +4 -3
- package/fs.js +4 -2
- package/{hosts-9dYv63ud.cjs → hosts-GNBhZO3-.cjs} +1 -1
- package/{hosts-BzbzOhG8.js → hosts-t7CKGTRz.js} +4 -1
- package/http.d.ts +1 -1
- package/{index-D2CA-NX5.d.ts → index-BtFiGoVQ.d.ts} +465 -51
- package/{index-kuPqkS_-.d.ts → index-D2lvaQDs.d.ts} +28 -38
- package/index.cjs +1 -1
- package/index.d.ts +17 -17
- package/index.js +62 -59
- package/lib-CfdmsLoI.cjs +53 -0
- package/{lib-C4Eeg9eM.js → lib-DppqX10G.js} +470 -302
- package/{messages-C66ghz_A.d.ts → messages-CRcziTuC.d.ts} +17 -1
- package/messages.cjs +1 -1
- package/messages.d.ts +2 -2
- package/messages.js +2 -2
- package/{net-zThwNoA8.d.ts → net-DcLF-6E-.d.ts} +2 -2
- package/net.cjs +1 -1
- package/net.d.ts +1 -1
- package/net.js +1 -1
- package/{node-fs-BZy9bzKd.js → node-fs-CK2wWIYS.js} +140 -137
- package/node-fs-nfX7wisL.cjs +1 -0
- package/opfs.cjs +1 -1
- package/opfs.js +1 -1
- package/package.json +1 -1
- package/packages.cjs +1 -1
- package/packages.d.ts +1 -1
- package/packages.js +14 -14
- package/{proxy-Dc0gDOxz.d.ts → proxy-CE46SkyA.d.ts} +2 -2
- package/{proxy-DjoPtJH9.cjs → proxy-CFK-KiwE.cjs} +1 -1
- package/{proxy-DMTdQ4dN.js → proxy-Dixbk1WL.js} +1 -1
- package/rooms.cjs +1 -1
- package/rooms.d.ts +1 -1
- package/rooms.js +11 -11
- package/storage-BVr2Rb-d.d.ts +167 -0
- package/storage-D2cUJlVH.cjs +1 -0
- package/storage-Dn1gTLSZ.js +123 -0
- package/api-jOTOA-5n.cjs +0 -3
- package/cloud-BLv19j-W.js +0 -480
- package/cloud-D7aQY4GH.cjs +0 -1
- package/extension-B9v933cT.js +0 -89
- package/extension-D2zMdc2f.cjs +0 -1
- package/fs-CaQFRiIT.cjs +0 -1
- package/fs-D3IsGdnN.js +0 -360
- package/lib-BfAg9mHD.cjs +0 -53
- package/node-fs-BNTPsX5c.cjs +0 -1
- package/storage-BJd-mWHE.cjs +0 -1
- package/storage-DSvL-t80.js +0 -67
- package/storage-ZrY4Y4L5.d.ts +0 -88
package/packages.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
|
|
2
|
-
import {
|
|
2
|
+
import { c as t, l as n, o as r, u as i } from "./api-DIgTslNb.js";
|
|
3
3
|
import { r as a, t as o } from "./busy-B189uX--.js";
|
|
4
4
|
import { expose as s } from "osra";
|
|
5
5
|
//#region src/packages.ts
|
|
@@ -19,7 +19,7 @@ var c = /* @__PURE__ */ e({
|
|
|
19
19
|
uninstall: () => y
|
|
20
20
|
}), l = "fkn-packages-connection", u = 3e4, d = (e, t) => Object.assign(Error(t), { code: e }), f = async () => {
|
|
21
21
|
if (!n) throw d("unavailable", "packages: no FKN transport in this realm - use relayWorker to bridge workers");
|
|
22
|
-
return
|
|
22
|
+
return r;
|
|
23
23
|
}, p = (e, t, n) => s(e ?? {}, {
|
|
24
24
|
transport: t,
|
|
25
25
|
key: l,
|
|
@@ -154,30 +154,30 @@ var E = async (e, t) => {
|
|
|
154
154
|
w(s, e) || l(e).catch(() => {});
|
|
155
155
|
}
|
|
156
156
|
};
|
|
157
|
-
}, O = async (e, t = {}) => E(e, t.element), k = (async (e,
|
|
158
|
-
let
|
|
159
|
-
protocol:
|
|
160
|
-
...
|
|
157
|
+
}, O = async (e, t = {}) => E(e, t.element), k = (async (e, n = {}) => {
|
|
158
|
+
let r = await (await f()).packages.connect(e, {
|
|
159
|
+
protocol: n.protocol,
|
|
160
|
+
...n.path === void 0 ? {} : { path: n.path }
|
|
161
161
|
});
|
|
162
|
-
if ("error" in
|
|
163
|
-
let a = o("package connection"), s =
|
|
162
|
+
if ("error" in r) throw d(r.error, r.message);
|
|
163
|
+
let a = o("package connection"), s = t()?.epoch ?? 0, c = i((e, t) => {
|
|
164
164
|
t !== s && (a(), c());
|
|
165
165
|
});
|
|
166
|
-
Promise.resolve(
|
|
166
|
+
Promise.resolve(r.closed).then(() => {
|
|
167
167
|
a(), c();
|
|
168
168
|
}, () => {
|
|
169
169
|
a(), c();
|
|
170
170
|
});
|
|
171
|
-
let { port: l, closed: u } =
|
|
172
|
-
if (
|
|
171
|
+
let { port: l, closed: u } = r;
|
|
172
|
+
if (n.raw) return {
|
|
173
173
|
closed: u,
|
|
174
174
|
port: l
|
|
175
175
|
};
|
|
176
|
-
let p = await m(
|
|
177
|
-
signal:
|
|
176
|
+
let p = await m(n.payload, l, {
|
|
177
|
+
signal: n.signal,
|
|
178
178
|
closed: u
|
|
179
179
|
});
|
|
180
|
-
return
|
|
180
|
+
return n.signal && n.signal.addEventListener("abort", () => {
|
|
181
181
|
try {
|
|
182
182
|
l.postMessage({ type: "fkn-packages-disconnect" });
|
|
183
183
|
} catch {}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./api-
|
|
1
|
+
import { K as Resolvers } from "./contract-CCxPKIC7.js";
|
|
2
|
+
import "./api-SwxtiYVU.js";
|
|
3
3
|
//#region src/proxy.d.ts
|
|
4
4
|
type ProxyFetch = Resolvers['cloud']['fetch'];
|
|
5
5
|
type FetchParameters = Parameters<ProxyFetch>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require("./api
|
|
1
|
+
const e=require("./api--LOXTOpv.cjs"),t=require("./busy-Dv8wzE5M.cjs");var n=typeof FinalizationRegistry>`u`?void 0:new FinalizationRegistry(e=>e()),r=e=>{let r=e.body;if(!r)return e;let i=t.t(`streamed response`),a=r.getReader(),o=new ReadableStream({pull:async e=>{try{let{done:t,value:n}=await a.read();if(t){i(),e.close();return}e.enqueue(n)}catch(t){i(),e.error(t)}},cancel:async e=>{i(),await a.cancel(e).catch(()=>{})}}),s=new Response(o,{status:e.status,statusText:e.statusText,headers:e.headers});return n?.register(s,i),s},i=async e=>{if(e!=null)return typeof e==`string`||e instanceof ArrayBuffer||ArrayBuffer.isView(e)?e:new Request(`https://body.invalid/`,{method:`POST`,body:e,duplex:`half`}).arrayBuffer()},a=async e=>{if(e.method===`GET`||e.method===`HEAD`)return;let t=await e.clone().arrayBuffer();return t.byteLength?t:void 0},o=async(t,n)=>{if(e.p(t),typeof t==`object`&&t&&!(t instanceof URL)&&typeof t.url==`string`){let o=t,s={};o.headers.forEach((e,t)=>{s[t]=e});let c=await i(n?.body===void 0?await a(o):n.body);return e.o.then(e=>e.cloud.fetch(o.url,{...n,method:n?.method??o.method,headers:n?.headers??s,body:c})).then(r)}let o=t instanceof URL?t.href:t,s=await i(n?.body);return e.o.then(e=>e.cloud.fetch(o,n?.body===void 0?n:{...n,body:s})).then(r)};Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return o}});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { o as e, p as t } from "./api-DIgTslNb.js";
|
|
2
2
|
import { t as n } from "./busy-B189uX--.js";
|
|
3
3
|
//#region src/proxy.ts
|
|
4
4
|
var r = typeof FinalizationRegistry > "u" ? void 0 : new FinalizationRegistry((e) => e()), i = (e) => {
|
package/rooms.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./api
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./api--LOXTOpv.cjs"),n=require("./busy-Dv8wzE5M.cjs"),r=require("./contract.cjs");var i=e.t({available:()=>m,create:()=>g,join:()=>_,open:()=>h}),a={wrongKey:`rooms: wrong room key`,inviteNoKey:`rooms: the invite carries no key`,badName:`rooms: the name is not one a room can have`,badKeyOption:`rooms: the key is not 32 bytes base64url`,noSuchMember:`rooms: no such member`,noSuchMessage:`rooms: no such message`,roomFull:`rooms: the room is full`,tooManyConnections:`rooms: too many connections`,tooManyBlocks:`rooms: too many blocks`,tooManyClaims:`rooms: too many claims`,mailboxFull:`rooms: the mailbox is full`,outOfStorage:`rooms: the owner is out of storage`,outOfQuota:`rooms: out of daily bandwidth`,blocked:`rooms: you are blocked from this room`,cannotSend:`rooms: you cannot send here`,permissionDenied:`rooms: permission denied`,notOwner:`rooms: not the room owner`,ownerNotRemovable:`rooms: the owner cannot be removed`,ownerKeepsEvery:`rooms: the owner keeps every permission`,removeYourself:`rooms: you cannot remove yourself`,needsAccount:`rooms: claiming needs an account`,needsPremium:`rooms: claiming needs premium`,nameClaimed:`rooms: the name is claimed`,notClaimed:`rooms: the room is not claimed`,noMailbox:`rooms: the room keeps no messages`,badLimit:`rooms: the limit is out of range`,badDescription:`rooms: the description is not one a claim can carry`,notClaimer:`rooms: only the app that claimed the room can describe it`,notReleaser:`rooms: only the app that claimed the room can release it`,badTemporary:`rooms: the temporary duration is not one a claim can carry`,notTemporaryClaimer:`rooms: only the app that claimed the room can set when it expires`,temporaryUnavailable:`rooms: temporary claims are not available`,tooFast:`rooms: sending too fast`,tooLarge:`rooms: the message is too large`,unavailable:`rooms: rooms are unavailable`,notEnabled:`rooms: rooms are not available`,alreadyJoined:`rooms: already joined`,notJoined:`rooms: not joined`,malformed:`rooms: malformed frame`,ended:`rooms: the room has ended`},o=(e,t)=>Object.assign(Error(t),{code:e}),s=e=>e instanceof Error&&typeof e.code==`string`,c={send:!0,receive:!0,maxMessageBytes:262144},l=async()=>{if(!t.l)return;let e=(await t.s(`a room`).catch(()=>void 0))?.rooms;return typeof e?.open==`function`?e:void 0},u=()=>{throw o(`unavailable`,a.unavailable)},d=e=>e===`blocked`?`blocked`:e===`not-found`?`ended`:`unavailable`,f=e=>{if(e!==void 0&&e!==!1)return e===!0?r.ROOM_TEMPORARY_MS.default:typeof e!=`number`||!Number.isInteger(e)?null:e>=r.ROOM_TEMPORARY_MS.min&&e<=r.ROOM_TEMPORARY_MS.max?e:null},p=async e=>{let r=e.invite,i=e,l=0,u=e.self,p=e.owner,m=e.claimed,h=e.mailbox,g=await e.defaults().catch(()=>c),_=!1,v=new Set,y=new Set,b=n.t(`room`),x=()=>{},S=()=>{},C=new Promise(e=>{S=e}),w=e=>{let t=[...y];y.clear();for(let n of t)try{n(e)}catch{}},T=e=>{_||(_=!0,x(),v.clear(),b(),w(o(`closed`,a.ended)),S({reason:e}))},E=e=>{if(!_){e.type===`defaults`&&(g=e.defaults),e.type===`permissions`&&e.id===u.id&&(u={id:u.id,permissions:e.permissions,maxMessageBytes:e.maxMessageBytes}),e.type===`claim`&&(m=e.claimed,p=e.owner,m||(h=null));for(let t of[...v])try{t(e)}catch{}}},D=(e,t)=>{Promise.resolve(e.on(E)).catch(()=>{}),Promise.resolve(e.closed).then(e=>{t===l&&T(e.reason)},()=>{})},O=async(e,t)=>{if(typeof e?.join!=`function`)return T(`unavailable`);let n=await e.join(r).catch(()=>void 0);if(_||t!==l)return;if(!n)return T(`unavailable`);if(`error`in n)return T(d(n.error));if(n.self.id!==u.id)return Promise.resolve(n.leave()).catch(()=>{}),T(`unavailable`);i=n,u=n.self,p=n.owner,m=n.claimed,h=n.mailbox,D(n,t);let a=await n.defaults().catch(()=>void 0);a&&!_&&t===l&&(g=a)};x=t.u((e,t)=>{let n=l;l=t,!(_||n===0||n===t)&&(w(o(`unavailable`,a.unavailable)),O(e.rooms,t))}),D(e,l);let k=async e=>{if(_)throw o(`closed`,a.ended);let t=()=>{},n=new Promise((e,n)=>{t=n});y.add(t);try{return await Promise.race([Promise.resolve(e(i)),n])}catch(e){throw s(e)?e:o(`unavailable`,a.unavailable)}finally{y.delete(t)}},A=async e=>{let t=await k(e);if(`error`in t)throw o(t.error,t.message)},j=async e=>{let t=await k(e);if(typeof t==`object`&&t&&`error`in t)throw o(t.error,t.message);return t};return{id:e.id,name:e.name,key:e.key,invite:r,get self(){return u},get owner(){return p},get claimed(){return m},get mailbox(){return h},defaults:()=>g,members:()=>k(e=>e.members()),send:e=>A(t=>t.send(e)),edit:(e,t)=>A(n=>n.edit(e,t)),delete:(e,t)=>A(n=>n.delete(e,t)),backlog:(e,t)=>j(n=>n.backlog(e,t)),setDefault:(e,t)=>A(n=>n.setDefault(e,t)),limit:(e,t)=>A(n=>n.limit(e,t)),grant:(e,t)=>A(n=>n.grant(e,t)),revoke:(e,t)=>A(n=>n.revoke(e,t)),remove:e=>A(t=>t.remove(e)),block:e=>A(t=>t.block(e)),unblock:e=>A(t=>t.unblock(e)),claim:async e=>{let t=e?.description;if(t!==void 0&&typeof t!=`string`)throw o(`invalid`,a.badDescription);let n=f(e?.temporary);if(n===null)throw o(`invalid`,a.badTemporary);let r={...t===void 0?{}:{description:t},...n===void 0?{}:{temporary:n}};return Object.keys(r).length===0?A(e=>e.claim()):A(e=>{if(n!==void 0&&e.temporaryClaims!==!0)throw o(`unavailable`,a.temporaryUnavailable);return e.claim(r)})},release:()=>A(e=>e.release()),usage:async()=>{let e=await j(e=>e.usage());return h=e,e},on:async e=>_?()=>{}:(v.add(e),()=>{v.delete(e)}),leave:async()=>{await Promise.resolve(i.leave()).catch(()=>{}),T(`left`)},closed:C}},m=async()=>{let e=await l();return e?e.available().catch(()=>!1):!1},h=async(e,t)=>{if(typeof e!=`string`||e.length===0||e.length>72)throw o(`invalid`,a.badName);let n=await l();if(!n)throw o(`unavailable`,a.unavailable);let r=await n.open(e,t).catch(u);if(`error`in r)throw o(r.error,r.message);return p(r)},g=async e=>{let t=await l();if(!t)throw o(`unavailable`,a.unavailable);let n=await t.create(e).catch(u);if(`error`in n)throw o(n.error,n.message);return p(n)},_=async(e,t)=>{let n=typeof e==`string`?e.indexOf(`.`):-1;if(n<=0||n===e.length-1)throw o(`invalid`,a.inviteNoKey);let r=await l();if(!r)throw o(`unavailable`,a.unavailable);let i=await r.join(e,t).catch(u);if(`error`in i)throw o(i.error,i.message);return p(i)};exports.available=m,exports.create=g,exports.join=_,exports.open=h,Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return i}});
|
package/rooms.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { J as RoomClaimOptions, Q as RoomEvent, X as RoomDefaults, Y as RoomCreateOptions, Z as RoomEnd, at as RoomPermission, et as RoomJoinOptions, it as RoomOpenOptions, nt as RoomMember, ot as RoomPermissions, q as RoomBacklog, rt as RoomMessage, st as RoomsErrorCode, tt as RoomMailbox } from "./contract-CCxPKIC7.js";
|
|
2
2
|
declare namespace rooms_d_exports {
|
|
3
3
|
export { RoomClaimOptions as ClaimOptions, RoomCreateOptions as CreateOptions, RoomJoinOptions as JoinOptions, RoomOpenOptions as OpenOptions, Room, RoomBacklog, RoomDefaults, RoomEnd, RoomEvent, RoomMailbox, RoomMember, RoomMessage, RoomPermission, RoomPermissions, RoomsError, RoomsErrorCode, available, create, join, open };
|
|
4
4
|
}
|
package/rooms.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
|
|
2
|
-
import {
|
|
2
|
+
import { l as t, s as n, u as r } from "./api-DIgTslNb.js";
|
|
3
3
|
import { t as i } from "./busy-B189uX--.js";
|
|
4
4
|
import { ROOM_TEMPORARY_MS as a } from "./contract.js";
|
|
5
5
|
//#region src/rooms.ts
|
|
@@ -55,14 +55,14 @@ var o = /* @__PURE__ */ e({
|
|
|
55
55
|
maxMessageBytes: 262144
|
|
56
56
|
}, d = async () => {
|
|
57
57
|
if (!t) return;
|
|
58
|
-
let e = (await
|
|
58
|
+
let e = (await n("a room").catch(() => void 0))?.rooms;
|
|
59
59
|
return typeof e?.open == "function" ? e : void 0;
|
|
60
60
|
}, f = () => {
|
|
61
61
|
throw c("unavailable", s.unavailable);
|
|
62
62
|
}, p = (e) => e === "blocked" ? "blocked" : e === "not-found" ? "ended" : "unavailable", m = (e) => {
|
|
63
63
|
if (e !== void 0 && e !== !1) return e === !0 ? a.default : typeof e != "number" || !Number.isInteger(e) ? null : e >= a.min && e <= a.max ? e : null;
|
|
64
64
|
}, h = async (e) => {
|
|
65
|
-
let t = e.invite,
|
|
65
|
+
let t = e.invite, n = e, a = 0, o = e.self, d = e.owner, f = e.claimed, h = e.mailbox, g = await e.defaults().catch(() => u), _ = !1, v = /* @__PURE__ */ new Set(), y = /* @__PURE__ */ new Set(), b = i("room"), x = () => {}, S = () => {}, C = new Promise((e) => {
|
|
66
66
|
S = e;
|
|
67
67
|
}), w = (e) => {
|
|
68
68
|
let t = [...y];
|
|
@@ -87,29 +87,29 @@ var o = /* @__PURE__ */ e({
|
|
|
87
87
|
Promise.resolve(e.on(E)).catch(() => {}), Promise.resolve(e.closed).then((e) => {
|
|
88
88
|
t === a && T(e.reason);
|
|
89
89
|
}, () => {});
|
|
90
|
-
}, O = async (e,
|
|
90
|
+
}, O = async (e, r) => {
|
|
91
91
|
if (typeof e?.join != "function") return T("unavailable");
|
|
92
92
|
let i = await e.join(t).catch(() => void 0);
|
|
93
|
-
if (_ ||
|
|
93
|
+
if (_ || r !== a) return;
|
|
94
94
|
if (!i) return T("unavailable");
|
|
95
95
|
if ("error" in i) return T(p(i.error));
|
|
96
96
|
if (i.self.id !== o.id) return Promise.resolve(i.leave()).catch(() => {}), T("unavailable");
|
|
97
|
-
|
|
97
|
+
n = i, o = i.self, d = i.owner, f = i.claimed, h = i.mailbox, D(i, r);
|
|
98
98
|
let s = await i.defaults().catch(() => void 0);
|
|
99
|
-
s && !_ &&
|
|
99
|
+
s && !_ && r === a && (g = s);
|
|
100
100
|
};
|
|
101
|
-
x =
|
|
101
|
+
x = r((e, t) => {
|
|
102
102
|
let n = a;
|
|
103
103
|
a = t, !(_ || n === 0 || n === t) && (w(c("unavailable", s.unavailable)), O(e.rooms, t));
|
|
104
104
|
}), D(e, a);
|
|
105
105
|
let k = async (e) => {
|
|
106
106
|
if (_) throw c("closed", s.ended);
|
|
107
|
-
let t = () => {},
|
|
107
|
+
let t = () => {}, r = new Promise((e, n) => {
|
|
108
108
|
t = n;
|
|
109
109
|
});
|
|
110
110
|
y.add(t);
|
|
111
111
|
try {
|
|
112
|
-
return await Promise.race([Promise.resolve(e(
|
|
112
|
+
return await Promise.race([Promise.resolve(e(n)), r]);
|
|
113
113
|
} catch (e) {
|
|
114
114
|
throw l(e) ? e : c("unavailable", s.unavailable);
|
|
115
115
|
} finally {
|
|
@@ -176,7 +176,7 @@ var o = /* @__PURE__ */ e({
|
|
|
176
176
|
v.delete(e);
|
|
177
177
|
}),
|
|
178
178
|
leave: async () => {
|
|
179
|
-
await Promise.resolve(
|
|
179
|
+
await Promise.resolve(n.leave()).catch(() => {}), T("left");
|
|
180
180
|
},
|
|
181
181
|
closed: C
|
|
182
182
|
};
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
//#region src/fs/types.d.ts
|
|
2
|
+
type FileEntry$1 = {
|
|
3
|
+
path: string;
|
|
4
|
+
size: number;
|
|
5
|
+
contentType: string | null;
|
|
6
|
+
updatedAt: string | null;
|
|
7
|
+
};
|
|
8
|
+
type WriteData$1 = Blob | ArrayBuffer | Uint8Array | string;
|
|
9
|
+
/**
|
|
10
|
+
* Which account a cloud call belongs to. Library plumbing that app code never passes: an operation of
|
|
11
|
+
* several calls (a rename, a mount, a queue drain) captures one when it starts, so none of its calls
|
|
12
|
+
* can land in an account the realm switched to meanwhile.
|
|
13
|
+
*
|
|
14
|
+
* `{ generation }` is a ticket from `captureAccount()`: its calls carry that generation's pin. `{ pin }`
|
|
15
|
+
* is a pin a queued entry was stamped with, sent as is.
|
|
16
|
+
*/
|
|
17
|
+
type PinFrom = {
|
|
18
|
+
readonly generation: number;
|
|
19
|
+
} | {
|
|
20
|
+
readonly pin: string;
|
|
21
|
+
};
|
|
22
|
+
type PinOptions = {
|
|
23
|
+
pin?: PinFrom;
|
|
24
|
+
};
|
|
25
|
+
type FileSystem = {
|
|
26
|
+
available: () => Promise<boolean>;
|
|
27
|
+
list: (opts?: PinOptions) => Promise<FileEntry$1[]>;
|
|
28
|
+
readFile: (path: string, opts?: PinOptions) => Promise<Blob>;
|
|
29
|
+
writeFile: (path: string, data: WriteData$1, opts?: {
|
|
30
|
+
contentType?: string;
|
|
31
|
+
} & PinOptions) => Promise<void>;
|
|
32
|
+
remove: (path: string, opts?: PinOptions) => Promise<void>;
|
|
33
|
+
/** Captures the account generation this realm is on now; absent on a backing with no account. */
|
|
34
|
+
captureAccount?: () => PinFrom;
|
|
35
|
+
};
|
|
36
|
+
declare namespace storage_d_exports {
|
|
37
|
+
export { AccountTicket, CloudAvailability, EncryptionStatus, FileEntry, SealedRead, StorageAccountChangedError, StorageAccountPinUnsupportedError, StorageLockedError, StorageNotFoundError, StorageQuota, WriteData, availability, available, captureAccount, encryption, isAccountChanged, isInvalidPin, isNotFound, knownPin, list, pinFor, quota, readFile, readFileSealed, remove, unlock, writeFile };
|
|
38
|
+
}
|
|
39
|
+
type FileEntry = {
|
|
40
|
+
path: string;
|
|
41
|
+
size: number;
|
|
42
|
+
contentType: string | null;
|
|
43
|
+
updatedAt: string;
|
|
44
|
+
encryption: string | null;
|
|
45
|
+
};
|
|
46
|
+
type StorageQuota = {
|
|
47
|
+
usedBytes: number;
|
|
48
|
+
limitBytes: number;
|
|
49
|
+
remaining: number;
|
|
50
|
+
objects: number;
|
|
51
|
+
maxObjects: number;
|
|
52
|
+
};
|
|
53
|
+
type EncryptionStatus = {
|
|
54
|
+
unlocked: boolean;
|
|
55
|
+
enrolled: boolean;
|
|
56
|
+
keyEpoch: number | null;
|
|
57
|
+
};
|
|
58
|
+
type WriteData = Blob | ArrayBuffer | Uint8Array | string;
|
|
59
|
+
declare class StorageLockedError extends Error {
|
|
60
|
+
code: string;
|
|
61
|
+
constructor();
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* There is no object at this path. Test `err.code === STORAGE_NOT_FOUND`, never the message.
|
|
65
|
+
*
|
|
66
|
+
* Absence arrives from two places that word it completely differently: the api refusing to presign
|
|
67
|
+
* a path with no committed row says "Not found", and a presign that succeeded followed by an object
|
|
68
|
+
* fetch that 404s says "storage: read failed (404)". Neither is a fault, both mean the same thing,
|
|
69
|
+
* and matching either by hand means matching both. Ripple matched only the first, so a missing
|
|
70
|
+
* backup read as a transient failure, retried forever, and a library went un-backed-up for a day
|
|
71
|
+
* without a single error anywhere.
|
|
72
|
+
*
|
|
73
|
+
* The distinction matters more than it sounds. "There is nothing here" is safe to overwrite;
|
|
74
|
+
* "I could not tell you" is not, and a caller that confuses them either never writes a first
|
|
75
|
+
* backup or destroys a real one.
|
|
76
|
+
*/
|
|
77
|
+
declare class StorageNotFoundError extends Error {
|
|
78
|
+
code: string;
|
|
79
|
+
constructor(message?: string);
|
|
80
|
+
}
|
|
81
|
+
/** Whether an error from this module means the path is empty, as opposed to unreadable. */
|
|
82
|
+
declare const isNotFound: (error: unknown) => boolean;
|
|
83
|
+
/**
|
|
84
|
+
* The signed-in account is not the one this call belongs to, so the call was refused and nothing was
|
|
85
|
+
* read, written or removed. Test `err.code === STORAGE_ACCOUNT_CHANGED`, or `isAccountChanged(err)`.
|
|
86
|
+
*
|
|
87
|
+
* Every storage call (list, read, write, remove) carries a pin of the account this page was on when
|
|
88
|
+
* the call was made, captured synchronously in the call itself. So a call made before this page
|
|
89
|
+
* learned of an account switch never lands in the new account: FKN refuses it, or the library refuses
|
|
90
|
+
* it before sending. The library never retries it under the new account by itself.
|
|
91
|
+
*
|
|
92
|
+
* What stays the app's to check is work it started before the notification and resumes after it (an
|
|
93
|
+
* await between reading state and writing it back). Keep a counter that an `account.onChange` handler
|
|
94
|
+
* bumps and compare it synchronously right before the storage call: the pin is captured in that same
|
|
95
|
+
* synchronous step, so the check and the call are atomic.
|
|
96
|
+
*
|
|
97
|
+
* The notification also fires when the connection is renewed without a switch, so this can be thrown
|
|
98
|
+
* for a call that would have landed in the same account. Either way the answer is the same: re-read
|
|
99
|
+
* what the app is acting on, then call again.
|
|
100
|
+
*/
|
|
101
|
+
declare class StorageAccountChangedError extends Error {
|
|
102
|
+
code: string;
|
|
103
|
+
constructor(message?: string);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* The FKN broker this page reached is older than the account pin, so no storage call was sent: an
|
|
107
|
+
* unpinned call could land in an account the app did not mean. It goes away once fkn.app updates.
|
|
108
|
+
*/
|
|
109
|
+
declare class StorageAccountPinUnsupportedError extends Error {
|
|
110
|
+
code: string;
|
|
111
|
+
constructor(message?: string);
|
|
112
|
+
}
|
|
113
|
+
/** Whether an error from this module means the account changed under the call, which was not made. */
|
|
114
|
+
declare const isAccountChanged: (error: unknown) => boolean;
|
|
115
|
+
/** Whether the api could not read a pin at all (a queued entry's record damaged on the device). */
|
|
116
|
+
declare const isInvalidPin: (error: unknown) => boolean;
|
|
117
|
+
/** One account generation of this realm, captured when an operation started. */
|
|
118
|
+
type AccountTicket = {
|
|
119
|
+
readonly generation: number;
|
|
120
|
+
};
|
|
121
|
+
/** The account generation this realm is on now. Synchronous, so it is captured before any await. */
|
|
122
|
+
declare const captureAccount: () => AccountTicket;
|
|
123
|
+
/** The pin a ticket's generation carries, if it was already taken. */
|
|
124
|
+
declare const knownPin: (ticket: AccountTicket) => string | undefined;
|
|
125
|
+
/** The pin a ticket's generation carries, taking it if need be; refused once the generation has moved. */
|
|
126
|
+
declare const pinFor: (ticket: AccountTicket) => Promise<string>;
|
|
127
|
+
declare const available: () => Promise<boolean>;
|
|
128
|
+
type CloudAvailability = 'connected' | 'disconnected' | 'unknown';
|
|
129
|
+
/**
|
|
130
|
+
* Whether the cloud half is backed by an account, as three answers rather than two:
|
|
131
|
+
* 'disconnected' is an ANSWER (signed out, or the api refusing the stored token), 'unknown'
|
|
132
|
+
* means nobody could be asked, including a broker that never came up. Always settles within
|
|
133
|
+
* the probe deadline. A caller owing data to the cloud may drop that obligation only on
|
|
134
|
+
* 'disconnected'; treating 'unknown' the same silently loses the write.
|
|
135
|
+
*/
|
|
136
|
+
declare const availability: () => Promise<CloudAvailability>;
|
|
137
|
+
declare const list: (opts?: PinOptions) => Promise<FileEntry[]>;
|
|
138
|
+
declare const quota: () => Promise<StorageQuota>;
|
|
139
|
+
declare const readFile: (path: string, opts?: PinOptions) => Promise<Blob>;
|
|
140
|
+
/** The bytes of a cloud object and the seal time they carry, as an ISO string or null. */
|
|
141
|
+
type SealedRead = {
|
|
142
|
+
data: Uint8Array;
|
|
143
|
+
sealedAt: string | null;
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* A cloud read that also reports when the copy was sealed.
|
|
147
|
+
*
|
|
148
|
+
* `sealedAt` is an ISO string, or null when the envelope carries no such field (one written before
|
|
149
|
+
* the seal time existed) or when the data plane is older than this call. The value is
|
|
150
|
+
* AUTHENTICATED, so the server can neither forge nor alter it, and it is the WRITER's own claim
|
|
151
|
+
* about when it sealed, so on its own it does not prove this copy is the newest one: an older but
|
|
152
|
+
* perfectly authentic copy of the same path is still authentic. An app that needs that answer keeps
|
|
153
|
+
* a high-water mark per path and compares. Do not confuse it with the `updatedAt` on a listing,
|
|
154
|
+
* which is the server's hint and is fine for display and nothing else.
|
|
155
|
+
*
|
|
156
|
+
* The bytes and the stamp come from ONE read of ONE envelope, which is what makes the stamp
|
|
157
|
+
* describe the bytes returned beside it. `readFile` is unchanged and unaffected.
|
|
158
|
+
*/
|
|
159
|
+
declare const readFileSealed: (path: string, opts?: PinOptions) => Promise<SealedRead>;
|
|
160
|
+
declare const writeFile: (path: string, data: WriteData, opts?: {
|
|
161
|
+
contentType?: string;
|
|
162
|
+
} & PinOptions) => Promise<void>;
|
|
163
|
+
declare const remove: (path: string, opts?: PinOptions) => Promise<void>;
|
|
164
|
+
declare const encryption: () => Promise<EncryptionStatus>;
|
|
165
|
+
declare const unlock: () => Promise<boolean>;
|
|
166
|
+
//#endregion
|
|
167
|
+
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$1 as x, FileSystem as y };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./api--LOXTOpv.cjs"),n=require("./messages.cjs"),r=require("./account-generation-B-6Pn0b5.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}});
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
|
|
2
|
+
import { o as t } from "./api-DIgTslNb.js";
|
|
3
|
+
import { STORAGE_ACCOUNT_CHANGED as n, STORAGE_ACCOUNT_PIN_UNSUPPORTED as r, STORAGE_NOT_FOUND as i } from "./messages.js";
|
|
4
|
+
import { n as a, r as o, t as s } from "./account-generation-XNWOvLea.js";
|
|
5
|
+
//#region src/storage.ts
|
|
6
|
+
var c = /* @__PURE__ */ e({
|
|
7
|
+
StorageAccountChangedError: () => f,
|
|
8
|
+
StorageAccountPinUnsupportedError: () => p,
|
|
9
|
+
StorageLockedError: () => l,
|
|
10
|
+
StorageNotFoundError: () => u,
|
|
11
|
+
availability: () => N,
|
|
12
|
+
available: () => O,
|
|
13
|
+
captureAccount: () => _,
|
|
14
|
+
encryption: () => V,
|
|
15
|
+
isAccountChanged: () => m,
|
|
16
|
+
isInvalidPin: () => h,
|
|
17
|
+
isNotFound: () => d,
|
|
18
|
+
knownPin: () => C,
|
|
19
|
+
list: () => P,
|
|
20
|
+
pinFor: () => w,
|
|
21
|
+
quota: () => F,
|
|
22
|
+
readFile: () => I,
|
|
23
|
+
readFileSealed: () => R,
|
|
24
|
+
remove: () => B,
|
|
25
|
+
unlock: () => H,
|
|
26
|
+
writeFile: () => z
|
|
27
|
+
}), l = class extends Error {
|
|
28
|
+
code = "FKN_E2E_LOCKED";
|
|
29
|
+
constructor() {
|
|
30
|
+
super("storage locked: connect the app again to open encrypted data");
|
|
31
|
+
}
|
|
32
|
+
}, u = class extends Error {
|
|
33
|
+
code = i;
|
|
34
|
+
constructor(e = "storage: no object at that path") {
|
|
35
|
+
super(e);
|
|
36
|
+
}
|
|
37
|
+
}, d = (e) => e?.code === i, f = class extends Error {
|
|
38
|
+
code = n;
|
|
39
|
+
constructor(e = "storage: the signed-in account changed, so this call was not made") {
|
|
40
|
+
super(e);
|
|
41
|
+
}
|
|
42
|
+
}, p = class extends Error {
|
|
43
|
+
code = r;
|
|
44
|
+
constructor(e = "storage: the FKN broker cannot pin calls to an account yet, so nothing was sent") {
|
|
45
|
+
super(e);
|
|
46
|
+
}
|
|
47
|
+
}, m = (e) => e?.code === "FKN_ACCOUNT_CHANGED" || e instanceof Error && e.message.startsWith("fkn:account-changed"), h = (e) => e instanceof Error && e.message.startsWith("fkn:account-pin-invalid"), g = (e) => {
|
|
48
|
+
throw e instanceof Error && e.message.startsWith("fkn:e2e-locked") ? new l() : d(e) ? new u(e.message) : m(e) ? new f() : e instanceof Error && e.message.startsWith("fkn:account-pin-unsupported") ? new p() : e instanceof Error && (/^not found$/i.test(e.message) || /\(404\)$/.test(e.message)) ? new u(e.message) : e;
|
|
49
|
+
}, _ = () => (a(), { generation: s() }), v = /* @__PURE__ */ new Map(), y = null, b = (e) => typeof e?.accountPin == "function", x = (e, t) => {
|
|
50
|
+
let n = Promise.resolve(t.accountPin()).then((t) => {
|
|
51
|
+
if (typeof t != "string" || !t) throw Error("storage: the broker answered no account pin");
|
|
52
|
+
return s() === e && v.set(e, t), t;
|
|
53
|
+
});
|
|
54
|
+
return y = {
|
|
55
|
+
generation: e,
|
|
56
|
+
pin: n
|
|
57
|
+
}, n.catch(() => {
|
|
58
|
+
y?.pin === n && (y = null);
|
|
59
|
+
}), n;
|
|
60
|
+
}, S = async (e, t) => {
|
|
61
|
+
let n = v.get(e.generation);
|
|
62
|
+
if (n !== void 0) return n;
|
|
63
|
+
if (e.generation !== s()) throw new f();
|
|
64
|
+
let r = await (y?.generation === e.generation ? y.pin : x(e.generation, t)).catch(g);
|
|
65
|
+
if (e.generation !== s()) throw new f();
|
|
66
|
+
return r;
|
|
67
|
+
}, C = (e) => v.get(e.generation), w = async (e) => {
|
|
68
|
+
let n = (await t).cloud.fs;
|
|
69
|
+
if (!b(n)) throw new p();
|
|
70
|
+
return S(e, n);
|
|
71
|
+
}, T = (e) => {
|
|
72
|
+
for (let [t, n] of v) if (n === e) return t;
|
|
73
|
+
}, E = (e) => e?.pin ?? _(), D = async (e, n) => {
|
|
74
|
+
let r = (await t).cloud.fs;
|
|
75
|
+
if (!b(r)) throw new p();
|
|
76
|
+
let i = "pin" in e ? e.pin : await S(e, r);
|
|
77
|
+
if (!b(r)) throw new p();
|
|
78
|
+
return n(r, { accountPin: i }).catch((t) => {
|
|
79
|
+
if (m(t)) {
|
|
80
|
+
let t = "generation" in e ? e.generation : T(i);
|
|
81
|
+
t !== void 0 && o(t);
|
|
82
|
+
}
|
|
83
|
+
return g(t);
|
|
84
|
+
});
|
|
85
|
+
}, O = () => t.then((e) => e.cloud.fs.available()).catch(() => !1), k = 8e3, A = 1e3, j = !1, M = async () => {
|
|
86
|
+
let e = (await t).cloud.fs;
|
|
87
|
+
return typeof e.availability == "function" ? e.availability() : await e.available() ? "connected" : "disconnected";
|
|
88
|
+
}, N = async () => {
|
|
89
|
+
let e = j ? A : k, t = await new Promise((t) => {
|
|
90
|
+
let n = setTimeout(() => t("timeout"), e);
|
|
91
|
+
M().then((e) => {
|
|
92
|
+
clearTimeout(n), t(e);
|
|
93
|
+
}, () => {
|
|
94
|
+
clearTimeout(n), t("unknown");
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
return t === "timeout" ? (j = !0, "unknown") : (j = !1, t);
|
|
98
|
+
}, P = (e) => D(E(e), (e, t) => e.list(t)), F = () => t.then((e) => e.cloud.fs.quota()), I = async (e, t) => {
|
|
99
|
+
let n = await D(E(t), (t, n) => t.readFile(e, n));
|
|
100
|
+
return new Blob([n]);
|
|
101
|
+
}, L = (e) => {
|
|
102
|
+
if (e === null || !Number.isFinite(e)) return null;
|
|
103
|
+
let t = new Date(e);
|
|
104
|
+
return Number.isNaN(t.getTime()) ? null : t.toISOString();
|
|
105
|
+
}, R = async (e, t) => D(E(t), async (t, n) => {
|
|
106
|
+
let r = t;
|
|
107
|
+
if (typeof r.readFileSealed != "function") return {
|
|
108
|
+
data: await t.readFile(e, n),
|
|
109
|
+
sealedAt: null
|
|
110
|
+
};
|
|
111
|
+
let i = await r.readFileSealed(e, n);
|
|
112
|
+
return {
|
|
113
|
+
data: i.bytes,
|
|
114
|
+
sealedAt: L(i.sealedAt)
|
|
115
|
+
};
|
|
116
|
+
}), z = async (e, t, n) => {
|
|
117
|
+
let r = E(n), i = t instanceof Blob ? new Uint8Array(await t.arrayBuffer()) : t;
|
|
118
|
+
await D(r, (t, r) => t.writeFile(e, i, n?.contentType ?? null, r));
|
|
119
|
+
}, B = async (e, t) => {
|
|
120
|
+
await D(E(t), (t, n) => t.remove(e, n));
|
|
121
|
+
}, V = () => t.then((e) => e.cloud.fs.encryption()), H = () => t.then((e) => e.cloud.fs.unlock());
|
|
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 };
|
package/api-jOTOA-5n.cjs
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
let e=require("osra");var t=1e4,n=16,r=e=>{let t;try{t=e.contentWindow}catch{return!0}if(!t)return!0;try{let e=t.location.href;return e!==``&&e!==`about:blank`}catch{return!0}},i=(e,i=t)=>new Promise(t=>{if(r(e))return t();let a=()=>{clearInterval(o),clearTimeout(s),e.removeEventListener(`load`,a),t()},o=setInterval(()=>{r(e)&&a()},n),s=setTimeout(a,i);e.addEventListener(`load`,a)}),a=32,o=8,s=120,c=typeof CSS<`u`&&CSS.supports(`clip-path`,`path('M0 0H1V1H0Z')`),l=typeof CSS<`u`&&CSS.supports(`clip-path`,`polygon(nonzero, 0px 0px, 1px 0px, 1px 1px)`),u=e=>{let t=e.style;t.setProperty(`display`,`block`,`important`),t.setProperty(`position`,`fixed`,`important`),t.setProperty(`top`,`0`,`important`),t.setProperty(`left`,`0`,`important`),t.setProperty(`width`,`100%`,`important`),t.setProperty(`height`,`100%`,`important`),t.setProperty(`border`,`none`,`important`),t.setProperty(`padding`,`0`,`important`),t.setProperty(`box-sizing`,`border-box`,`important`),t.setProperty(`clip-path`,`inset(100%)`,`important`),t.setProperty(`background`,`transparent`),t.setProperty(`color-scheme`,`normal`),t.setProperty(`z-index`,`2147483647`),e.setAttribute(`title`,`FKN`)},d=({x:e,y:t,width:n,height:r,radius:i})=>{if(!i)return`M${e} ${t}h${n}v${r}h${-n}Z`;let a=Math.min(n,r)/2,[o,s,c,l]=i.map(e=>Math.max(0,Math.min(e,a)));return`M${e+o} ${t}h${n-o-s}a${s} ${s} 0 0 1 ${s} ${s}v${r-s-c}a${c} ${c} 0 0 1 ${-c} ${c}h${-(n-c-l)}a${l} ${l} 0 0 1 ${-l} ${-l}v${-(r-l-o)}a${o} ${o} 0 0 1 ${o} ${-o}Z`},f=()=>c&&l,p=({x:e,y:t,width:n,height:r})=>[[e,t],[e+n,t],[e+n,t+r],[e,t+r],[e,t]],ee=e=>{let t=e[0];if(!t)return[];let n=p(t)[0],r=[];return e.forEach((t,i)=>{r.push(...p(t)),i>0&&i<e.length-1&&r.push(n)}),r},m=e=>`polygon(nonzero, ${ee(e).map(([e,t])=>`${e}px ${t}px`).join(`, `)})`,h=({x:e,y:t,width:n,height:r,radius:i},a)=>{let o=`${t}px ${a.width-e-n}px ${a.height-t-r}px ${e}px`;return i?`inset(${o} round ${i.map(e=>`${e}px`).join(` `)})`:`inset(${o})`},g=(e,t,n)=>{if(t)return`none`;if(e.length===0)return`inset(100%)`;let r=e.length===1?e[0]:void 0;return r?h(r,n):l&&e.length<=5&&!e.some(e=>e.radius)?m(e):`path('${e.map(d).join(``)}')`},_=e=>{if(e.length<2)return null;let t=Math.min(...e.map(e=>e.x)),n=Math.min(...e.map(e=>e.y));return{x:t,y:n,width:Math.max(...e.map(e=>e.x+e.width))-t,height:Math.max(...e.map(e=>e.y+e.height))-n}},te=(e,t,n)=>t>=e.x&&t<e.x+e.width&&n>=e.y&&n<e.y+e.height,ne=16,v=(e,t,n)=>t===1?e*ne:t===2?e*n:e,re=(e,t,n)=>{let r=getComputedStyle(e);return n!==0&&/auto|scroll/.test(r.overflowY)&&e.scrollHeight>e.clientHeight?!0:t!==0&&/auto|scroll/.test(r.overflowX)&&e.scrollWidth>e.clientWidth},ie=(e,t,n)=>{for(let r=e;r;r=r.parentElement)if(re(r,t,n))return r;return document.scrollingElement},y=null,b=null,x=e=>({width:e.offsetWidth||window.innerWidth,height:e.offsetHeight||window.innerHeight}),S=e=>{if(!b||!y||!te(b,e.clientX,e.clientY))return;let t=document.elementFromPoint(e.clientX,e.clientY);if(!t||t===y)return;let n=v(e.deltaX,e.deltaMode,window.innerWidth),r=v(e.deltaY,e.deltaMode,window.innerHeight),i=ie(t,n,r);i&&(i.scrollBy({left:n,top:r,behavior:`instant`}),e.cancelable&&e.preventDefault())},ae=e=>{let t=b!==null;b=e,t!==(e!==null)&&(e?window.addEventListener(`wheel`,S,{capture:!0,passive:!1}):window.removeEventListener(`wheel`,S,{capture:!0}))},C=0,oe=e=>{if(e===C)return;C=e;let t=document.documentElement.style;e>0?(t.setProperty(`margin-top`,`${e}px`,`important`),t.setProperty(`--fkn-inset-top`,`${e}px`)):(t.removeProperty(`margin-top`),t.removeProperty(`--fkn-inset-top`))},w=(e,{modal:t,rects:n,inset:r},i)=>{if(oe(r),!c){let r=t||n.length>0;e.style.setProperty(`pointer-events`,r?`auto`:`none`,`important`),e.style.setProperty(`visibility`,r?`visible`:`hidden`,`important`);return}let a=g(n,t,i),o=a===`none`||CSS.supports(`clip-path`,a)?a:`inset(100%)`;e.style.setProperty(`clip-path`,o,`important`),ae(t||o!==a?null:_(n))},se=e=>{if(typeof e!=`object`||!e)return 0;let{top:t}=e;return typeof t!=`number`||!Number.isFinite(t)||t<=0?0:Math.min(Math.round(t),s)},ce=e=>{if(Array.isArray(e)&&e.length===4&&e.every(e=>typeof e==`number`&&Number.isFinite(e)&&e>=0))return e.some(e=>e>0)?e:void 0},le=(e,t)=>{if(typeof e!=`object`||!e)return null;let{x:n,y:r,width:i,height:a}=e;if(![n,r,i,a].every(e=>typeof e==`number`&&Number.isFinite(e)))return null;let o=t.width,s=t.height,c=Math.max(0,Math.min(Math.round(n),o)),l=Math.max(0,Math.min(Math.round(r),s)),u=Math.max(c,Math.min(Math.round(n+i),o)),d=Math.max(l,Math.min(Math.round(r+a),s)),f=ce(e.radius);return{x:c,y:l,width:u-c,height:d-l,...f?{radius:f}:{}}},T={"not-rendered":`this page is not painting it at all, so it or an ancestor is display:none, or the frame was moved out of the layout`,clipped:`it is clipped away or positioned outside the viewport`,"not-shown":`it is rendered but would not be seen, so either something is drawn over it, or it or an ancestor has opacity below 1, visibility:hidden, or a filter`},ue=e=>Array.isArray(e)?e.slice(0,o).flatMap(e=>{if(typeof e!=`object`||!e)return[];let{kind:t,cause:n,level:r}=e;return typeof t!=`string`||t.length>40||typeof n!=`string`||!(n in T)||r!==`full`&&r!==`liveness`?[]:[{kind:t,cause:n,level:r}]}):[],E=new Set,de=e=>{for(let{kind:t,cause:n,level:r}of e)E.has(t)||(E.add(t),console.error(`[FKN] The FKN ${JSON.stringify(t)} is not visible on this page: ${T[n]}. Nobody using this page can see or answer it.
|
|
2
|
-
@fkn/lib draws its UI inside <iframe title="FKN"> and sets display, position, top, left, width, height, border, padding, box-sizing, clip-path and z-index on that element. Leave those as they are, then check for an ancestor with opacity, visibility, display or a clipping transform, and for an element stacked above it.`+(r===`liveness`?`
|
|
3
|
-
This browser reports limited detail, so the cause above is a best guess.`:``)))},D=(e,t)=>{if(typeof e!=`object`||!e)return null;let n=e,r=(Array.isArray(n.rects)?n.rects.slice(0,a):[]).map(e=>le(e,t)).filter(e=>e!==null&&e.width>0&&e.height>0);return{modal:n.modal===!0,rects:r,hidden:ue(n.hidden),inset:se(n.inset)}},fe=()=>y!==null,O=null,k=null,A=()=>{if(!y||O===null)return;let e=x(y),t=D(O,e);t&&w(y,t,e)},j=e=>{typeof ResizeObserver<`u`&&(k??=new ResizeObserver(A),k.disconnect(),k.observe(e))},M=e=>{u(e),w(e,{modal:!1,rects:[],hidden:[],inset:0},x(e)),y=e,j(e)},N=e=>{if(!y)return;let t=x(y),n=D(e,t);n&&(O=e,w(y,n,t),de(n.hidden))},P=[`fkn.app`,`fkn.dev`,`sdbx.app`],F=e=>e.replace(/\.+$/,``),I=e=>{let t=F(e);return P.some(e=>t===e||t.endsWith(`.${e}`))},L=e=>{let t=typeof e==`string`?e:e instanceof URL?e.href:e.url,n;try{n=new URL(t)}catch{return}if(I(n.hostname))throw Error(`fetch refuses FKN platform domains (${n.hostname})`)},R=`autoplay.fullscreen.picture-in-picture.encrypted-media.screen-wake-lock.speaker-selection.captured-surface-control.camera.microphone.display-capture.geolocation.midi.usb.serial.hid.bluetooth.gamepad.keyboard-map.xr-spatial-tracking.accelerometer.gyroscope.magnetometer.ambient-light-sensor.compute-pressure.clipboard-read.clipboard-write.storage-access.window-management.local-fonts.idle-detection.web-share.sync-xhr.unload.payment.publickey-credentials-get.publickey-credentials-create.otp-credentials.identity-credentials-get.digital-credentials-get.local-network.local-network-access.loopback-network`.split(`.`),z=()=>{try{let e=globalThis.document?.featurePolicy?.features?.();return e===void 0?void 0:new Set(e)}catch{return}},B=(e=!0,t=z())=>[...R,...e?[`cross-origin-isolated`]:[]].filter(e=>t===void 0||t.has(e)).join(`; `),V=`https://fkn.app`,H=typeof globalThis<`u`&&globalThis.document?globalThis.document:void 0,U=typeof globalThis<`u`&&globalThis.crossOriginIsolated===!0,W=`${V}/api${U?`?coi=1`:``}`,pe=`fkn-api-port`,me=`fkn-api-port-ack`,he=2e3,ge=()=>{if(!H||typeof window>`u`||window.parent===window)return Promise.resolve(void 0);let e;try{e=window.parent}catch{return Promise.resolve(void 0)}let t=new MessageChannel;return new Promise(n=>{let r=e=>{if(clearTimeout(a),t.port1.removeEventListener(`message`,i),!e)try{t.port1.close()}catch{}n(e)},i=e=>{e.data?.type===me&&r(t.port1)},a=setTimeout(()=>r(void 0),he);t.port1.addEventListener(`message`,i),t.port1.start();try{e.postMessage({type:pe},V,[t.port2])}catch{r(void 0)}})},G,_e=()=>{if(G||!H)return G;let e=H.querySelector(`iframe[src="${W}"]`);if(e)G=e;else{let e=H.createElement(`iframe`);e.setAttribute(`allow`,B(U)),e.src=W,H.body.appendChild(e),G=e}return M(G),G},K=(async()=>{if(!H)return;let e=await ge();if(e)return{receive:e,emit:e};let t=_e();if(!t)return;await i(t);let n=t.contentWindow;return n?{receive:window,emit:n}:void 0})(),ve=e=>{let t,n=()=>{},r=new Promise(e=>{n=e}),i=new Set,a=new Set,o=0,s=0;(async()=>{for await(let r of e){let e=(t?.epoch??0)+1;t={remote:r,epoch:e},e===1&&n(r);let o=[...a];a.clear();let s=Error(`FKN: the broker was replaced while this call was pending; retry it`);for(let e of o)try{e(s)}catch{}for(let t of[...i])try{t(r,e)}catch{}}})().catch(()=>{});let c=async(e,n)=>{let i=t?.remote??await r;for(let t of e.slice(0,-1))i=i[t];let c=i[e[e.length-1]??``];o=Date.now(),s+=1;let l=()=>{},u=new Promise((e,t)=>{l=t});a.add(l);try{return await Promise.race([Promise.resolve(c.apply(i,n)),u])}finally{--s,a.delete(l),o=Date.now()}},l=new Map,u=e=>{let n=e.join(`\0`),r=l.get(n);if(r)return r;let i=new Proxy(function(){},{get:(n,r)=>{if(typeof r!=`string`||r===`then`)return;let i=t;if(i){let t=i.remote;for(let n of e)t=t?.[n];if(t?.[r]===void 0)return}return u([...e,r])},apply:(t,n,r)=>c(e,r)});return l.set(n,i),i};return{facade:u([]),first:r.then(()=>{}),current:()=>t,onEpoch:e=>{if(i.add(e),t)try{e(t.remote,t.epoch)}catch{}return()=>{i.delete(e)}},lastCall:()=>o,inFlight:()=>s}},ye=typeof window<`u`||typeof self<`u`,q=async()=>{if(typeof window<`u`)return K;if(typeof self<`u`)return{receive:self,emit:self}},J=ve({async*[Symbol.asyncIterator](){let t=await q();if(!t){await new Promise(()=>{});return}yield*(0,e.expose)({},{key:`fkn-api`,transport:t})}}),Y=J.first.then(()=>J.facade),X=8e3,be=1e3,Z=!1,Q=class extends Error{constructor(e,t){super(`@fkn/lib: no broker connection within ${t}ms, so ${e} could not be requested`),this.name=`BrokerUnreachableError`}},xe=e=>{let t=Z?be:X;return Promise.race([Y,new Promise((n,r)=>setTimeout(()=>{Z=!0,r(new Q(e,t))},t))])},$=J.onEpoch,Se=J.current,Ce=J.lastCall,we=J.inFlight;$(e=>{fe()&&e.overlay.setHost(N,{exactClips:f()}).catch(()=>{})}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return L}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return B}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return Ce}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return $}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return xe}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return we}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return Se}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return X}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return K}});
|