@fkn/lib 0.4.9 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/account.cjs +1 -0
  2. package/account.d.ts +17 -0
  3. package/account.js +28 -0
  4. package/api-ByfayMm1.js +67 -0
  5. package/api-CDb2pv7C.cjs +1 -0
  6. package/background-Dk_vaVP1.cjs +1 -0
  7. package/{background-CTsVv_a0.js → background-TtzKw6g0.js} +5 -4
  8. package/chunk-B6C_zzib.cjs +1 -0
  9. package/chunk-CPXzm0be.js +11 -0
  10. package/cloud/dgram.cjs +1 -0
  11. package/cloud/dgram.d.ts +537 -0
  12. package/cloud/dgram.js +4 -0
  13. package/cloud/dns.cjs +1 -0
  14. package/cloud/dns.d.ts +12 -0
  15. package/cloud/dns.js +3 -0
  16. package/cloud/fs/promises.cjs +1 -0
  17. package/cloud/fs/promises.d.ts +45 -0
  18. package/cloud/fs/promises.js +8 -0
  19. package/cloud/fs.cjs +1 -0
  20. package/cloud/fs.d.ts +75 -0
  21. package/cloud/fs.js +20 -0
  22. package/cloud/http.cjs +1 -0
  23. package/cloud/http.d.ts +767 -0
  24. package/cloud/http.js +5 -0
  25. package/cloud/net.cjs +1 -0
  26. package/cloud/net.d.ts +606 -0
  27. package/cloud/net.js +4 -0
  28. package/cloud-BVnscun4.js +33 -0
  29. package/cloud-DTL2B5pW.cjs +1 -0
  30. package/cloud.cjs +1 -0
  31. package/cloud.d.ts +1048 -0
  32. package/cloud.js +12 -0
  33. package/desktop.cjs +1 -0
  34. package/desktop.d.ts +49 -0
  35. package/desktop.js +51 -0
  36. package/dgram-5YUb70O2.js +326 -0
  37. package/dgram-Cdi6Y7zJ.cjs +1 -0
  38. package/dgram.cjs +1 -0
  39. package/dgram.d.ts +537 -0
  40. package/dgram.js +4 -0
  41. package/dns.cjs +1 -0
  42. package/dns.d.ts +12 -0
  43. package/dns.js +6 -0
  44. package/extension-9Uv_0HdS.cjs +1 -0
  45. package/extension-Dgz0UTy0.js +245 -0
  46. package/extension.cjs +1 -0
  47. package/extension.d.ts +853 -0
  48. package/extension.js +5 -0
  49. package/fs/promises.cjs +1 -0
  50. package/fs/promises.d.ts +46 -0
  51. package/fs/promises.js +8 -0
  52. package/fs-B7JumDCn.js +78 -0
  53. package/fs-DrwvwtqC.cjs +1 -0
  54. package/fs.cjs +1 -0
  55. package/fs.d.ts +84 -0
  56. package/fs.js +5 -0
  57. package/http.cjs +9 -0
  58. package/http.d.ts +767 -0
  59. package/http.js +541 -0
  60. package/index.cjs +1 -9
  61. package/index.d.ts +197 -140
  62. package/index.js +27 -1879
  63. package/locator-Cf7M3QKN.cjs +53 -0
  64. package/{locator-Q5m8i40Z.js → locator-DxAsGV_o.js} +331 -337
  65. package/net-Bl6_W3bd.js +275 -0
  66. package/net-C5kWnI4C.cjs +1 -0
  67. package/net.cjs +1 -0
  68. package/net.d.ts +606 -0
  69. package/net.js +4 -0
  70. package/node-fs-Bd_UUx1m.js +361 -0
  71. package/node-fs-lrlD_zqB.cjs +1 -0
  72. package/opfs/promises.cjs +1 -0
  73. package/opfs/promises.d.ts +46 -0
  74. package/opfs/promises.js +6 -0
  75. package/opfs-BfcYLPGb.js +55 -0
  76. package/opfs-Dsi4FkJU.cjs +1 -0
  77. package/opfs.cjs +1 -0
  78. package/opfs.d.ts +83 -0
  79. package/opfs.js +35 -0
  80. package/package.json +91 -1
  81. package/proxy-A9UvWUaF.cjs +1 -0
  82. package/proxy-wiZN4eTR.js +14 -0
  83. package/storage-BadvHtv0.cjs +1 -0
  84. package/storage-z0q3iena.js +13 -0
  85. package/utils-BsNRWMfl.cjs +1 -0
  86. package/utils-CNydj3OT.js +52 -0
  87. package/background-BqRFQggD.cjs +0 -1
  88. package/locator-Cjl21Nkt.cjs +0 -53
@@ -0,0 +1,245 @@
1
+ import { n as e } from "./chunk-CPXzm0be.js";
2
+ import { d as t, f as n, i as r, l as i, m as a, p as o, r as s, t as c, u as l } from "./locator-DxAsGV_o.js";
3
+ import { t as u } from "./api-ByfayMm1.js";
4
+ import { n as d, t as f } from "./proxy-wiZN4eTR.js";
5
+ import { available as p, fetch as m } from "./desktop.js";
6
+ import { createTypedEventTarget as h, expose as g } from "osra";
7
+ //#region node_modules/@mfkn/web-extension/lib/utils/extension.js
8
+ var _ = "FKN_WEB_EXTENSION_MAIN_WORLD_CONTENT_SCRIPT_ENABLED_EVENT_KEY", v = "fknExtension", y = h();
9
+ typeof document < "u" && document.addEventListener(_, () => {
10
+ y.dispatchEvent(new CustomEvent("statuschange", { detail: { enabled: b() } }));
11
+ });
12
+ var b = () => typeof document > "u" ? !1 : document.documentElement.dataset[v] === "true", x = null, S = (e) => {
13
+ x = e;
14
+ }, C = 150, w = (e = 1e3) => new Promise((t, n) => {
15
+ if (b()) return t();
16
+ let r, i = (e) => {
17
+ clearTimeout(r), s.disconnect(), document.removeEventListener("readystatechange", c), e();
18
+ }, a = () => i(async () => {
19
+ if (x && (await x().catch(() => {}), b())) return t();
20
+ n(/* @__PURE__ */ Error("The FKN WebExtension is not installed, enabled or not exposed on this page."));
21
+ }), o = () => {
22
+ clearTimeout(r), r = setTimeout(() => b() ? i(t) : a(), C);
23
+ }, s = new MutationObserver(() => {
24
+ b() && i(t);
25
+ }), c = () => {
26
+ document.readyState === "complete" && !b() && o();
27
+ };
28
+ if (r = setTimeout(a, e), s.observe(document.documentElement, {
29
+ attributes: !0,
30
+ attributeFilter: ["data-fkn-extension"]
31
+ }), document.addEventListener("readystatechange", c), document.readyState === "complete") return o();
32
+ b() && i(t);
33
+ }), T, E = new Proxy({}, { get: (e, t) => async (...e) => {
34
+ await w(), T ??= g({}, {
35
+ transport: window,
36
+ revivableModules: i
37
+ });
38
+ let n = (await T)[t];
39
+ return n(...e);
40
+ } }), D = {
41
+ scope: "network.fetch",
42
+ category: "network",
43
+ severity: 0,
44
+ title: "Fetch data from other sites",
45
+ description: "Lets the app download public data from other websites directly, past the usual cross-origin limits."
46
+ }, O = {
47
+ scope: "network.fetchCredentialed",
48
+ category: "network",
49
+ severity: 3,
50
+ unsafe: !0,
51
+ title: "Fetch from other sites, signed in as you",
52
+ description: "Lets the app fetch other sites using your logged-in session cookies, so it can read data only you should see."
53
+ }, k = {
54
+ scope: "network.fetchLocal",
55
+ category: "network",
56
+ severity: 3,
57
+ unsafe: !0,
58
+ title: "Access devices on your local network",
59
+ description: "Lets the app reach devices and services on your home or work network, which websites normally cannot touch."
60
+ }, A = (e) => {
61
+ let t = e.match(/^(\d+)\.(\d+)\.\d+\.\d+$/);
62
+ if (!t) return !1;
63
+ let [n, r] = [Number(t[1]), Number(t[2])];
64
+ return n === 10 || n === 127 || n === 0 || n === 169 && r === 254 || n === 172 && r >= 16 && r <= 31 || n === 192 && r === 168;
65
+ }, j = (e) => {
66
+ let t;
67
+ try {
68
+ t = new URL(e);
69
+ } catch {
70
+ return !1;
71
+ }
72
+ let n = t.hostname.replace(/^\[|\]$/g, "").toLowerCase().replace(/\.$/, "");
73
+ return n === "localhost" || n.endsWith(".localhost") || n.endsWith(".local") || n.endsWith(".internal") || n.endsWith(".home.arpa") ? !0 : n.includes(":") ? n === "::" || n === "::1" || n.startsWith("fc") || n.startsWith("fd") || /^fe[89ab]/.test(n) || n.startsWith("::ffff:") : A(n);
74
+ }, M = ["fkn.app", "fkn.dev"], N = (e) => {
75
+ let t;
76
+ try {
77
+ t = new URL(e);
78
+ } catch {
79
+ return !1;
80
+ }
81
+ if (t.protocol === "chrome-extension:" || t.protocol === "moz-extension:") return !0;
82
+ let n = t.hostname;
83
+ return M.some((e) => n === e || n.endsWith(`.${e}`));
84
+ }, P = (e) => {
85
+ if (N(e)) throw Error("fetch: refusing to target the extension's own pages or FKN platform domains");
86
+ }, F = ["origin", "referer"], I = (e) => {
87
+ if (!e?.headers) return;
88
+ let t = new Headers(e.headers), n = F.map((e) => {
89
+ let n = t.get(e);
90
+ return n === null ? void 0 : [e, n];
91
+ }).filter((e) => e !== void 0);
92
+ return n.length ? n : void 0;
93
+ }, L = async (e, t) => {
94
+ let n = new Request(e, t);
95
+ P(n.url);
96
+ let r = n.body ? await n.arrayBuffer() : null;
97
+ return E.proxyFetch({
98
+ url: n.url,
99
+ method: n.method,
100
+ headers: [...n.headers],
101
+ body: r,
102
+ credentials: t?.credentials === "include" ? "include" : "omit",
103
+ redirect: n.redirect,
104
+ unsafeHeaders: I(t),
105
+ reason: t?.reason,
106
+ signal: t?.signal ?? void 0
107
+ });
108
+ }, R = {
109
+ scope: "network.readCookie",
110
+ category: "network",
111
+ severity: 3,
112
+ unsafe: !0,
113
+ title: "Read a site’s cookie",
114
+ description: "Lets the app read a named cookie from another site, which can include the login token only that site should see."
115
+ }, z = { get: (e) => E.getCookie(e) }, B = {
116
+ scope: "network.modifyRequestHeaders",
117
+ category: "network",
118
+ severity: 2,
119
+ unsafe: !0,
120
+ title: "Rewrite request headers to other sites",
121
+ description: "Lets the app set or remove headers (like Origin and Referer) on this page’s own requests to the listed sites."
122
+ }, V = (e) => E.setRequestHeaderRule(e), H = (e) => E.removeRequestHeaderRule({ ruleId: e });
123
+ (() => {
124
+ let e = {}, t = [...c.selectorModules, ...r.selectorModules];
125
+ for (let n of t) n.render && !(n.type in e) && (e[n.type] = n.render);
126
+ return e;
127
+ })();
128
+ //#endregion
129
+ //#region node_modules/@mfkn/web-extension/lib/lib/frame.js
130
+ var U = "FKN_WEB_EXTENSION_ATTACH_FRAME_EVENT_KEY", W = (e) => {
131
+ if (!e || e === "about:blank") return !1;
132
+ let t;
133
+ try {
134
+ t = new URL(e, location.href);
135
+ } catch {
136
+ return !1;
137
+ }
138
+ if (t.protocol === "chrome-extension:" || t.protocol === "moz-extension:") return !0;
139
+ if (t.protocol === "about:") return !1;
140
+ let n = t.hostname;
141
+ return n === "fkn.app" || n.endsWith(".fkn.app");
142
+ }, G = (e) => {
143
+ if (W(e)) throw Error("attachFrame: refusing to target the extension's own pages or fkn.app");
144
+ }, K = {
145
+ scope: "embed.iframe",
146
+ category: "embed",
147
+ severity: 0,
148
+ title: "Load another website inside this app",
149
+ description: "Lets the app embed external pages directly inside its own view."
150
+ }, q = {
151
+ scope: "embed.open",
152
+ category: "embed",
153
+ severity: 0,
154
+ title: "Open a website inside this app",
155
+ description: "Lets the app navigate to another site without leaving its window."
156
+ }, J = {
157
+ scope: "embed.evaluate",
158
+ category: "embed",
159
+ severity: 0,
160
+ title: "Run app code inside an embedded frame",
161
+ description: "Lets the app execute its own code inside a page it embedded, to read back a computed result."
162
+ }, Y = async ({ iframe: e, domains: t = [], syncCookies: n = !0, lockdown: r = !1 }) => {
163
+ let i = crypto.randomUUID();
164
+ if (G(e.src), await w(), !e.isConnected) throw Error("attachFrame: the iframe must be connected to the document before attaching");
165
+ e.dispatchEvent(new CustomEvent(U, { detail: i }));
166
+ let { executeLocator: a, ensureLocatorPermission: o, goto: c, evaluate: l } = await E.attachFrame({
167
+ marker: i,
168
+ domains: t,
169
+ syncCookies: n,
170
+ lockdown: r
171
+ }), u = s(a, o), d = (e, t = {}) => (G(e), c({
172
+ url: e,
173
+ ...t
174
+ })), f = ((e, t) => l(e, t)), p = () => e.src;
175
+ return {
176
+ ...u,
177
+ goto: d,
178
+ evaluate: f,
179
+ url: p
180
+ };
181
+ }, X = { request: (e) => E.requestPermissions(e.map((e) => ({
182
+ key: e.key,
183
+ scope: e.scope ?? "",
184
+ reason: e.reason
185
+ }))) }, Z = async (e) => {
186
+ if (typeof window > "u") return !1;
187
+ if (b()) return !0;
188
+ let t = await u, n = null, r = new Promise((e) => {
189
+ n = () => {
190
+ b() && e(!0);
191
+ }, y.addEventListener("statuschange", n);
192
+ }), i = t.installPrompt.show(e).then(() => !1), a = await Promise.race([r, i]);
193
+ return n && y.removeEventListener("statuschange", n), await t.installPrompt.hide().catch(() => {}), a;
194
+ }, Q = null;
195
+ S(() => (Q ||= Z().then(() => void 0).finally(() => {
196
+ Q = null;
197
+ }), Q));
198
+ //#endregion
199
+ //#region src/lib/auto.ts
200
+ var $ = () => typeof document < "u" && b(), ee = async (e, t) => {
201
+ if (d(e), t?.credentials === "include") {
202
+ if (typeof document > "u") throw Error("fetch with credentials needs the FKN extension, which only exists in window realms");
203
+ return L(e, t);
204
+ }
205
+ return $() ? L(e, {
206
+ ...t,
207
+ credentials: "omit"
208
+ }) : p() ? m(e, t) : f(e, t);
209
+ }, te = /* @__PURE__ */ e({
210
+ ATTACH_FRAME_EVENT_KEY: () => U,
211
+ assertAttachableFrameUrl: () => G,
212
+ assertFetchableUrl: () => P,
213
+ attachFrame: () => Y,
214
+ attachFramePermission: () => K,
215
+ available: () => $,
216
+ box: () => l,
217
+ cookies: () => z,
218
+ createVideoElementHandle: () => t,
219
+ evaluatePermission: () => J,
220
+ events: () => y,
221
+ extension: () => y,
222
+ fetch: () => L,
223
+ fetchCredentialedPermission: () => O,
224
+ fetchLocalPermission: () => k,
225
+ fetchPermission: () => D,
226
+ gotoPermission: () => q,
227
+ handleRevivableModules: () => i,
228
+ isBlockedFetchUrl: () => N,
229
+ isBlockedFrameUrl: () => W,
230
+ isExtensionExposed: () => b,
231
+ isLocalNetworkUrl: () => j,
232
+ isType: () => n,
233
+ modifyRequestHeadersPermission: () => B,
234
+ permissions: () => X,
235
+ promptInstall: () => Z,
236
+ readCookiePermission: () => R,
237
+ removeRequestHeaderRule: () => H,
238
+ revive: () => o,
239
+ setMissingExtensionHandler: () => S,
240
+ setRequestHeaderRule: () => V,
241
+ type: () => a,
242
+ waitForExtensionExposure: () => w
243
+ });
244
+ //#endregion
245
+ export { N as C, S as D, b as E, w as O, D as S, y as T, R as _, X as a, O as b, Y as c, q as d, W as f, z as g, V as h, Z as i, K as l, H as m, ee as n, U as o, B as p, $ as r, G as s, te as t, J as u, P as v, j as w, k as x, L as y };
package/extension.cjs ADDED
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./locator-Cf7M3QKN.cjs`),t=require(`./extension-9Uv_0HdS.cjs`);require(`./api-CDb2pv7C.cjs`),require(`./proxy-A9UvWUaF.cjs`),exports.ATTACH_FRAME_EVENT_KEY=t.o,exports.assertAttachableFrameUrl=t.s,exports.assertFetchableUrl=t.v,exports.attachFrame=t.c,exports.attachFramePermission=t.l,exports.available=t.r,exports.box=e.u,exports.cookies=t.g,exports.createVideoElementHandle=e.d,exports.evaluatePermission=t.u,exports.events=t.T,exports.extension=t.T,exports.fetch=t.y,exports.fetchCredentialedPermission=t.b,exports.fetchLocalPermission=t.x,exports.fetchPermission=t.S,exports.gotoPermission=t.d,exports.handleRevivableModules=e.l,exports.isBlockedFetchUrl=t.C,exports.isBlockedFrameUrl=t.f,exports.isExtensionExposed=t.E,exports.isLocalNetworkUrl=t.w,exports.isType=e.f,exports.modifyRequestHeadersPermission=t.p,exports.permissions=t.a,exports.promptInstall=t.i,exports.readCookiePermission=t._,exports.removeRequestHeaderRule=t.m,exports.revive=e.p,exports.setMissingExtensionHandler=t.D,exports.setRequestHeaderRule=t.h,exports.type=e.m,exports.waitForExtensionExposure=t.O;