@fkn/lib 0.9.42 → 0.9.44
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/{api-SwxtiYVU.d.ts → api-CFkZVr53.d.ts} +61 -30
- package/api.d.ts +2 -2
- package/attach-policy.d.ts +11 -15
- package/cloud/dns.d.ts +1 -1
- package/cloud/fetch.d.ts +1 -1
- package/cloud/fs/promises.d.ts +1 -1
- package/cloud/fs.d.ts +3 -3
- package/cloud/net.d.ts +1 -1
- package/cloud-Bx64HSkQ.cjs +1 -0
- package/cloud-D-vDUzzx.js +552 -0
- package/{cloud-DUH-v10C.d.ts → cloud-DyOQPyUB.d.ts} +4 -4
- package/cloud.cjs +1 -1
- package/cloud.d.ts +4 -4
- package/cloud.js +1 -1
- package/{contract-CCxPKIC7.d.ts → contract-6Xfd_qel.d.ts} +173 -22
- package/contract.d.ts +4 -4
- package/dgram.d.ts +7 -14
- package/dns.d.ts +1 -1
- package/{extension-yhwDSIiD.d.ts → extension-BlEtNAYc.d.ts} +36 -37
- package/extension-CzZn0bY2.js +94 -0
- package/extension-DvFf7uoG.cjs +1 -0
- package/extension.cjs +1 -1
- package/extension.d.ts +3 -3
- package/extension.js +3 -3
- package/fs/promises.d.ts +1 -1
- package/{fs-D0MMRnHC.d.ts → fs-KA1Mgisv.d.ts} +2 -2
- package/fs.d.ts +3 -3
- package/http.d.ts +1 -1
- package/{index-BtFiGoVQ.d.ts → index-BOInGaEl.d.ts} +103 -62
- package/{index-D2lvaQDs.d.ts → index-DKr9L2RI.d.ts} +6 -11
- package/index.cjs +1 -1
- package/index.d.ts +36 -39
- package/index.js +55 -55
- package/{lib-DppqX10G.js → lib-C3UwxjVs.js} +560 -474
- package/lib-fqQfEPk6.cjs +53 -0
- package/messages-d7pvCXPn.d.ts +34 -0
- package/messages.d.ts +1 -1
- package/{net-DcLF-6E-.d.ts → net-CmMZgV2a.d.ts} +3 -19
- package/net.d.ts +1 -1
- package/package.json +1 -1
- package/packages.d.ts +1 -1
- package/{proxy-CE46SkyA.d.ts → proxy-dOOmiMl4.d.ts} +2 -2
- package/rooms.cjs +1 -1
- package/rooms.d.ts +94 -15
- package/rooms.js +118 -90
- package/{storage-BVr2Rb-d.d.ts → storage-BLBsmkmp.d.ts} +14 -28
- package/{wire-Gbo-D74t.d.ts → wire-BwA4JjZH.d.ts} +6 -12
- package/wire.d.ts +1 -1
- package/cloud-868OlBKn.cjs +0 -1
- package/cloud-f3j4s8yZ.js +0 -545
- package/extension-BOBuYwZc.js +0 -92
- package/extension-hoUs5yJ7.cjs +0 -1
- package/lib-CfdmsLoI.cjs +0 -53
- package/messages-CRcziTuC.d.ts +0 -46
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { o as
|
|
2
|
-
import {
|
|
1
|
+
import { D as IpFamily, Dt as UdpSocketOptions, Et as UdpDatagram, H as ProxyFetchInput, I as PackagesErrorCode, J as RoomClaimOptions, K as Resolvers, N as OverlayState, Nt as WriteData, P as PackageQuery, Q as RoomEvent, R as PickOptions, St as TcpSocketListenerOptions, T as InstallOptions, V as ProxyFetchInit, a as AccountChange, at as RoomPermission, b as FrameConsentAnswer, c as AdoptRequest, d as ConflictRequest, et as RoomJoinOptions, it as RoomOpenOptions, l as AdoptState, m as ConnectOptions, o as AccountPinOptions, p as ConnectAvailability, st as RoomsErrorCode, tt as RoomMailbox, u as ConflictChoice, wt as TcpSocketOptions, x as FrameConsentRequest, z as Placement } from "./contract-6Xfd_qel.js";
|
|
2
|
+
import { o as TcpSocketOption, v as UdpSocketOption } from "./wire-BwA4JjZH.js";
|
|
3
3
|
import { Remote } from "osra";
|
|
4
4
|
//#region src/api-epochs.d.ts
|
|
5
5
|
type EpochListener<T> = (remote: T, epoch: number) => void;
|
|
@@ -8,10 +8,9 @@ type EpochListener<T> = (remote: T, epoch: number) => void;
|
|
|
8
8
|
declare const hasTransport: boolean;
|
|
9
9
|
type Api = Remote<Resolvers>;
|
|
10
10
|
/**
|
|
11
|
-
* The broker api. Settles when the first connection exists
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* error instead of hanging.
|
|
11
|
+
* The broker api. Settles when the first connection exists and resolves with a stable facade that
|
|
12
|
+
* always routes to the NEWEST connection, so holding the resolved value across a broker replacement
|
|
13
|
+
* is safe. A call in flight at the moment of replacement rejects with a named error instead of hanging.
|
|
15
14
|
*
|
|
16
15
|
* A window realm that relays its channel to a worker (`relayWorker`) moves its own calls to a channel
|
|
17
16
|
* of their own, never back to the relayed one. There it also settles once the realm relays, a call in
|
|
@@ -21,23 +20,14 @@ type Api = Remote<Resolvers>;
|
|
|
21
20
|
*/
|
|
22
21
|
declare const apiPromise: Promise<Api>;
|
|
23
22
|
/**
|
|
24
|
-
*
|
|
23
|
+
* The deadline of `apiWithin`, for call sites that own a socket, a timer or a UI and must not park.
|
|
24
|
+
* `apiPromise` NEVER REJECTS: a broker frame that never bridges leaves it pending for the realm's
|
|
25
|
+
* life. In a worker the transport `{receive: self, emit: self}` is inert until the page bridges it,
|
|
26
|
+
* so an unbridged worker parks every socket call with no `listening`, `error` or rejection, which
|
|
27
|
+
* presents as a transport fault invisible from every counter.
|
|
25
28
|
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* is correct wherever hanging is the honest answer, and wrong wherever the caller owns a socket, a
|
|
29
|
-
* timer or a UI that has to say something.
|
|
30
|
-
*
|
|
31
|
-
* That distinction is not academic. In a WORKER realm the osra transport is `{receive: self,
|
|
32
|
-
* emit: self}`, which is inert until the page bridges it, so an unbridged worker parks every socket
|
|
33
|
-
* call here with no `listening`, no `error` and no rejection. The engine then reports a listener
|
|
34
|
-
* that neither succeeded nor failed, its reopen counters stay at 0 because reopen only runs from an
|
|
35
|
-
* `error` or `close` that never arrives, and the relay is never contacted at all. That state cost a
|
|
36
|
-
* long diagnosis: it presents as a transport fault and is invisible from every counter.
|
|
37
|
-
*
|
|
38
|
-
* The latch mirrors `storage.ts`: once the broker has missed one deadline, later calls stop paying
|
|
39
|
-
* the full wait. `net.ts` needs it especially, because its listen path is `bind('::').catch(() =>
|
|
40
|
-
* bind('0.0.0.0'))`, so an unbounded-then-rejecting version would charge the deadline twice.
|
|
29
|
+
* Once one deadline is missed, later calls wait only the retry deadline (as `storage.ts` does):
|
|
30
|
+
* `net.ts` listens with `bind('::').catch(() => bind('0.0.0.0'))` and would otherwise pay it twice.
|
|
41
31
|
*/
|
|
42
32
|
declare const API_DEADLINE_MS = 8000;
|
|
43
33
|
declare class BrokerUnreachableError extends Error {
|
|
@@ -45,15 +35,14 @@ declare class BrokerUnreachableError extends Error {
|
|
|
45
35
|
}
|
|
46
36
|
/**
|
|
47
37
|
* A page's own call, refused because the page relays its FKN channel to a worker (`relayWorker`) and
|
|
48
|
-
* the broker
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
38
|
+
* the broker never answered on the page's own channel within the deadline: a broker document from
|
|
39
|
+
* before that channel, as fkn.app's service worker can still serve from its cache. The page's own
|
|
40
|
+
* calls never fall back to the relayed channel, so this is the answer until a reload reaches a newer
|
|
41
|
+
* broker. The relayed worker's calls are unaffected.
|
|
52
42
|
*
|
|
53
|
-
* What the page registered on the relayed channel went with it
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
* once with `console.error` when the deadline passes, whether or not the page calls.
|
|
43
|
+
* What the page registered on the relayed channel went with it: FKN's UI over this page is no longer
|
|
44
|
+
* placed and account changes are no longer heard. So the realm also logs this error once with
|
|
45
|
+
* `console.error` when the deadline passes, whether or not the page calls.
|
|
57
46
|
*/
|
|
58
47
|
declare class OwnChannelUnavailableError extends Error {
|
|
59
48
|
constructor();
|
|
@@ -322,6 +311,7 @@ declare const onApiEpoch: (listener: EpochListener<{
|
|
|
322
311
|
claimed: boolean;
|
|
323
312
|
mailbox: RoomMailbox | null;
|
|
324
313
|
temporaryClaims?: true;
|
|
314
|
+
mailboxSwitch?: true;
|
|
325
315
|
defaults: () => Promise<{
|
|
326
316
|
readonly send: boolean;
|
|
327
317
|
readonly receive: boolean;
|
|
@@ -410,6 +400,12 @@ declare const onApiEpoch: (listener: EpochListener<{
|
|
|
410
400
|
} | {
|
|
411
401
|
ok: true;
|
|
412
402
|
}>;
|
|
403
|
+
setMailbox: (on: boolean) => Promise<{
|
|
404
|
+
error: RoomsErrorCode;
|
|
405
|
+
message: string;
|
|
406
|
+
} | {
|
|
407
|
+
ok: true;
|
|
408
|
+
}>;
|
|
413
409
|
release: () => Promise<{
|
|
414
410
|
error: RoomsErrorCode;
|
|
415
411
|
message: string;
|
|
@@ -453,6 +449,7 @@ declare const onApiEpoch: (listener: EpochListener<{
|
|
|
453
449
|
claimed: boolean;
|
|
454
450
|
mailbox: RoomMailbox | null;
|
|
455
451
|
temporaryClaims?: true;
|
|
452
|
+
mailboxSwitch?: true;
|
|
456
453
|
defaults: () => Promise<{
|
|
457
454
|
readonly send: boolean;
|
|
458
455
|
readonly receive: boolean;
|
|
@@ -541,6 +538,12 @@ declare const onApiEpoch: (listener: EpochListener<{
|
|
|
541
538
|
} | {
|
|
542
539
|
ok: true;
|
|
543
540
|
}>;
|
|
541
|
+
setMailbox: (on: boolean) => Promise<{
|
|
542
|
+
error: RoomsErrorCode;
|
|
543
|
+
message: string;
|
|
544
|
+
} | {
|
|
545
|
+
ok: true;
|
|
546
|
+
}>;
|
|
544
547
|
release: () => Promise<{
|
|
545
548
|
error: RoomsErrorCode;
|
|
546
549
|
message: string;
|
|
@@ -584,6 +587,7 @@ declare const onApiEpoch: (listener: EpochListener<{
|
|
|
584
587
|
claimed: boolean;
|
|
585
588
|
mailbox: RoomMailbox | null;
|
|
586
589
|
temporaryClaims?: true;
|
|
590
|
+
mailboxSwitch?: true;
|
|
587
591
|
defaults: () => Promise<{
|
|
588
592
|
readonly send: boolean;
|
|
589
593
|
readonly receive: boolean;
|
|
@@ -672,6 +676,12 @@ declare const onApiEpoch: (listener: EpochListener<{
|
|
|
672
676
|
} | {
|
|
673
677
|
ok: true;
|
|
674
678
|
}>;
|
|
679
|
+
setMailbox: (on: boolean) => Promise<{
|
|
680
|
+
error: RoomsErrorCode;
|
|
681
|
+
message: string;
|
|
682
|
+
} | {
|
|
683
|
+
ok: true;
|
|
684
|
+
}>;
|
|
675
685
|
release: () => Promise<{
|
|
676
686
|
error: RoomsErrorCode;
|
|
677
687
|
message: string;
|
|
@@ -1039,6 +1049,7 @@ declare const currentApiEpoch: () => {
|
|
|
1039
1049
|
claimed: boolean;
|
|
1040
1050
|
mailbox: RoomMailbox | null;
|
|
1041
1051
|
temporaryClaims?: true;
|
|
1052
|
+
mailboxSwitch?: true;
|
|
1042
1053
|
defaults: () => Promise<{
|
|
1043
1054
|
readonly send: boolean;
|
|
1044
1055
|
readonly receive: boolean;
|
|
@@ -1127,6 +1138,12 @@ declare const currentApiEpoch: () => {
|
|
|
1127
1138
|
} | {
|
|
1128
1139
|
ok: true;
|
|
1129
1140
|
}>;
|
|
1141
|
+
setMailbox: (on: boolean) => Promise<{
|
|
1142
|
+
error: RoomsErrorCode;
|
|
1143
|
+
message: string;
|
|
1144
|
+
} | {
|
|
1145
|
+
ok: true;
|
|
1146
|
+
}>;
|
|
1130
1147
|
release: () => Promise<{
|
|
1131
1148
|
error: RoomsErrorCode;
|
|
1132
1149
|
message: string;
|
|
@@ -1170,6 +1187,7 @@ declare const currentApiEpoch: () => {
|
|
|
1170
1187
|
claimed: boolean;
|
|
1171
1188
|
mailbox: RoomMailbox | null;
|
|
1172
1189
|
temporaryClaims?: true;
|
|
1190
|
+
mailboxSwitch?: true;
|
|
1173
1191
|
defaults: () => Promise<{
|
|
1174
1192
|
readonly send: boolean;
|
|
1175
1193
|
readonly receive: boolean;
|
|
@@ -1258,6 +1276,12 @@ declare const currentApiEpoch: () => {
|
|
|
1258
1276
|
} | {
|
|
1259
1277
|
ok: true;
|
|
1260
1278
|
}>;
|
|
1279
|
+
setMailbox: (on: boolean) => Promise<{
|
|
1280
|
+
error: RoomsErrorCode;
|
|
1281
|
+
message: string;
|
|
1282
|
+
} | {
|
|
1283
|
+
ok: true;
|
|
1284
|
+
}>;
|
|
1261
1285
|
release: () => Promise<{
|
|
1262
1286
|
error: RoomsErrorCode;
|
|
1263
1287
|
message: string;
|
|
@@ -1301,6 +1325,7 @@ declare const currentApiEpoch: () => {
|
|
|
1301
1325
|
claimed: boolean;
|
|
1302
1326
|
mailbox: RoomMailbox | null;
|
|
1303
1327
|
temporaryClaims?: true;
|
|
1328
|
+
mailboxSwitch?: true;
|
|
1304
1329
|
defaults: () => Promise<{
|
|
1305
1330
|
readonly send: boolean;
|
|
1306
1331
|
readonly receive: boolean;
|
|
@@ -1389,6 +1414,12 @@ declare const currentApiEpoch: () => {
|
|
|
1389
1414
|
} | {
|
|
1390
1415
|
ok: true;
|
|
1391
1416
|
}>;
|
|
1417
|
+
setMailbox: (on: boolean) => Promise<{
|
|
1418
|
+
error: RoomsErrorCode;
|
|
1419
|
+
message: string;
|
|
1420
|
+
} | {
|
|
1421
|
+
ok: true;
|
|
1422
|
+
}>;
|
|
1392
1423
|
release: () => Promise<{
|
|
1393
1424
|
error: RoomsErrorCode;
|
|
1394
1425
|
message: string;
|
package/api.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { K as Resolvers } from "./contract-
|
|
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-
|
|
1
|
+
import { K as Resolvers } from "./contract-6Xfd_qel.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-CFkZVr53.js";
|
|
3
3
|
export { API_DEADLINE_MS, BrokerUnreachableError, OwnChannelUnavailableError, type Resolvers, apiInFlight, apiLastCall, apiPromise, apiWithin, currentApiEpoch, hasTransport, onApiEpoch };
|
package/attach-policy.d.ts
CHANGED
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
/** What `normalizeHosts` keeps beyond a bare hostname. */
|
|
3
3
|
type NormalizeHostsOptions = {
|
|
4
4
|
/**
|
|
5
|
-
* Keep a bracketed IPv6 literal, in the canonical form `URL.hostname` reports
|
|
6
|
-
*
|
|
7
|
-
* callers pass it, so the cloud's declared hosts (`normalizeDeclaredHosts`) stay what they were.
|
|
5
|
+
* Keep a bracketed IPv6 literal, in the canonical form `URL.hostname` reports (what a document or
|
|
6
|
+
* fetch is compared against). Off by default; only the extension's own callers pass it.
|
|
8
7
|
*/
|
|
9
8
|
ipv6?: boolean;
|
|
10
9
|
};
|
|
@@ -18,12 +17,11 @@ declare const normalizeHosts: (raw: readonly string[], { ipv6 }?: NormalizeHosts
|
|
|
18
17
|
//#endregion
|
|
19
18
|
//#region src/attach-policy.d.ts
|
|
20
19
|
/**
|
|
21
|
-
* The pure half of the middle page's frame.fetch gate:
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* library's copy of the same checks.
|
|
20
|
+
* The pure half of the middle page's frame.fetch gate: what can be decided from the attachment's own
|
|
21
|
+
* facts, with no broker and no UI. The middle page enforces it on EVERY fetch call, because any app
|
|
22
|
+
* can drive the 'fkn-attach-frame' channel directly and skip the library's copy of the checks.
|
|
25
23
|
*
|
|
26
|
-
* Refusals
|
|
24
|
+
* Refusals must surface under a TERMINAL locator error name (callers map them through
|
|
27
25
|
* `locatorDeniedError`), or the shared dispatch loop retries them to its 30 second deadline and
|
|
28
26
|
* reports a timeout that names neither the operation nor the reason.
|
|
29
27
|
*/
|
|
@@ -44,13 +42,11 @@ export type FrameFetchVerdict = {
|
|
|
44
42
|
promptHosts: string[];
|
|
45
43
|
};
|
|
46
44
|
/**
|
|
47
|
-
* How a fetch url is read.
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
* an application on an older library is refused nothing it was not refused before; the library's
|
|
53
|
-
* own gate passes `'fetchTarget'`.
|
|
45
|
+
* How a fetch url is read. `'no-base'` is `new URL(url)`, which accepts the base-dependent forms
|
|
46
|
+
* `https:h/x` and `http:h/x` as if they named `h`. `'fetchTarget'` is the shared classifier, which
|
|
47
|
+
* calls those relative and refuses them. The middle page keeps `'no-base'` until the contract deploy,
|
|
48
|
+
* so an application on an older library is refused nothing new; the library's own gate passes
|
|
49
|
+
* `'fetchTarget'`.
|
|
54
50
|
*/
|
|
55
51
|
export type FrameFetchClassifier = 'no-base' | 'fetchTarget';
|
|
56
52
|
export declare const frameFetchVerdict: (policy: FrameFetchPolicy, url: unknown, { classifier }?: {
|
package/cloud/dns.d.ts
CHANGED
package/cloud/fetch.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as cloudFetch } from "../proxy-
|
|
1
|
+
import { t as cloudFetch } from "../proxy-dOOmiMl4.js";
|
|
2
2
|
export { cloudFetch as fetch };
|
package/cloud/fs/promises.d.ts
CHANGED
|
@@ -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-
|
|
2
|
+
import "../../fs-KA1Mgisv.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.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-
|
|
3
|
-
import { c as STORAGE_ACCOUNT_CHANGED, l as STORAGE_ACCOUNT_PIN_UNSUPPORTED, u as STORAGE_NOT_FOUND } from "../messages-
|
|
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-
|
|
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-BLBsmkmp.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-KA1Mgisv.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/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-
|
|
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-CmMZgV2a.js";
|
|
2
2
|
export { Server, Socket, _default, _default as default, connect, createConnection, createServer, isIP, isIPv4, isIPv6 };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./lib-fqQfEPk6.cjs"),n=require("./hosts-GNBhZO3-.cjs"),r=require("./api--LOXTOpv.cjs"),i=require("./busy-Dv8wzE5M.cjs"),a=require("./proxy-CFK-KiwE.cjs"),o=require("./attach-policy.cjs"),s=require("./contract.cjs"),c=require("./dns.cjs"),l=require("./cloud/fs.cjs"),u=require("./net.cjs"),d=require("./dgram.cjs"),f=require("./http.cjs");let p=require("osra");var m=async()=>{let e=()=>r.s(`frame consent`);try{let t=await e();return{request:typeof t.frameConsent.request==`function`?t.frameConsent.request:void 0,ensure:t.frameConsent.ensure}}catch(t){if(!(t instanceof r.n))throw t;return{request:void 0,ensure:t=>e().then(e=>e.frameConsent.ensure(t))}}},h=`frame: this frame no longer holds the document the app attached it to`,g=!1,_=()=>{g||(g=!0,console.warn(`[fkn-frame] this FKN broker is too old to ask for permission categories, so nothing was asked for upfront and each capability is asked for as it is first used. Reloading the page picks up the current broker.`))},v=e=>[...e].flatMap(e=>{try{return[new URL(e).hostname]}catch{return[]}}),y=(e,t,n)=>n===null?`frame.${e}: the user did not grant ${t} here`:`frame.${e}: the user did not grant ${t} on ${n}`,b=e=>{let{assertLive:r,attach:i,consent:a,current:s,declaredHosts:c,documentHost:l,freshBlank:u,session:d,approvedOrigins:f}=e,p=new Set,m=()=>{try{return new URL(s()).hostname}catch{return``}},g=async()=>l?await l():m(),b=()=>n.t([...c,...v(f)]),x=async(e,t)=>(await e([t]))[0]??!1;return{gate:async({operation:e,args:s,phase:l})=>{r();let _=n.m(e,s);if(_===null)return;let v=t.h(_);if(v===void 0||v===`auto`)return;if(e===`fetch`){let e=o.frameFetchVerdict({session:d,declaredHosts:c,approvedOrigins:f},l===`ensure`?void 0:s[0],{classifier:`fetchTarget`});if(l===`ensure`&&!d)throw t.O(e.kind===`refuse`?e.reason:``,`fetch`);if(l!==`ensure`&&e.kind===`refuse`)throw t.O(e.reason,`fetch`);let{request:r,ensure:i}=await a();if(!r){if(e.kind===`refuse`)throw t.O(e.reason,`fetch`);if(!await i({scope:n.c(s[0],s[1]).scope,hosts:e.promptHosts}))throw t.O(`frame.fetch: the user did not grant this`,`fetch`);return}let u=e.kind===`consent`?e.targetHost:await g(),p=n.t([u,...c]);if(!p.length)throw t.O(`frame: navigate the frame before fetch`,`fetch`);if(await x(r,{category:`network`,hosts:p})===!1)throw t.O(y(`fetch`,`network`,u||null),`fetch`);return}let S=await g();if(!S)throw t.O(`frame: navigate the frame before ${e}`,e);if(!b().includes(S))throw t.O(h,e);let C=t.m(_);if(C===void 0||C===`evaluation`&&S===m()&&await u?.()||v===`critical`&&p.has(`${_} ${S}`))return;let{request:w}=await a();if(!w)return;let T=n.t([S,...c]),E=await x(w,v===`critical`?{key:_,hosts:T,attach:i}:{category:C,hosts:T});if(E===!1)throw t.O(y(e,C,null),e);if(E===`once`&&l!==`ensure`)for(let e of T)p.add(`${_} ${e}`)},requestCategories:async e=>{r(),t.f(`frame.requestPermissions`,e);let o=await g(),s=n.t(o?[o,...c]:c);if(!s.length)throw TypeError(`frame.requestPermissions: navigate the frame or declare domains first`);let l=e.map(e=>{let n=e.key;return n===void 0?{named:void 0,critical:!1,category:e.category}:{named:n,critical:t.h(n)===`critical`,category:t.p(n)}}),u=({named:e,critical:t,category:n},r)=>({category:n,...t?{key:e}:{},hosts:s,allow:r}),{request:d}=await a();if(!d)return _(),l.map(e=>u(e,!1));let f=await d(l.map(({named:e,critical:t,category:n})=>t?{key:e,hosts:s,attach:i}:{category:n,hosts:s}));return l.map((e,t)=>u(e,f[t]!==void 0&&f[t]!==!1))},boundary:b}},x=e=>e,S=5e3,C=new Set([]),w=()=>`https://fkn.app`,T=e=>e===`persistent`?``:`incognito-${crypto.randomUUID()}`,E=(e,n,r)=>{let i,a=new Promise((e,a)=>{i=setTimeout(()=>a(typeof r==`string`?new t.T(r):r()),n)});return Promise.race([e,a]).finally(()=>clearTimeout(i))},D=e=>Object.assign(Error(e),{name:t.E}),O=`frame.postMessage: this FKN page predates frame messaging; reload the app to load the current one`,k=`frame.addScriptTag: this render proxy predates addScriptTag; reload the app`,A=`frame.addScriptTag: no answer within ${t.l}ms; the script may or may not have run`,j=`frame.clearCookies: this FKN page predates clearCookies; reload the app to load the current one`,M=`frame.clearCookies: this attachment reaches no site yet; attach a url, goto one, or declare it in domains`,N=3e4,P=`attachFrame: this FKN page predates storageState; reload the app to load the current one`,F=2e4,I=async(e,n)=>{if(typeof e.seed!=`function`)throw t.M(P,`storageState`,`cloud`);try{await E(e.seed(n),F,`attachFrame: the render proxy did not take the storageState seed`)}catch(e){throw t.D(e)?t.M(P,`storageState`,`cloud`):e}},L=`frame.clearCookies: the render proxy did not answer within ${N}ms; the cookies may or may not be gone, and calling it again is safe`,ee=e=>t.D(e)&&e.message===t.A(`addScriptTag`).message,R=!1,te=()=>{R||(R=!0,console.warn(`[fkn-frame] this FKN page predates frame messaging, so the page's messages and documents are never reported. Reloading the app loads the current one.`))},z=({from:e,origin:t,attach:n,signal:r})=>i=>{let a=r=>{if(r.source===null||r.source!==e()||r.origin!==t)return;let a=r.data;typeof a==`object`&&a&&a.type===`fkn-frame-message`&&a.attach===n&&typeof a.origin==`string`&&(a.kind===`message`?i({type:`message`,data:a.data,origin:a.origin,ports:r.ports}):a.kind===`document`&&i({type:`document`,origin:a.origin}))};return window.addEventListener(`message`,a,{signal:r}),()=>window.removeEventListener(`message`,a)},ne=e=>{if(typeof e!=`function`)return()=>Promise.resolve(e);let t=null;return()=>t??=e().catch(e=>{throw t=null,e})},B=({control:e,target:n,blank:r=!1,session:i,declaredHosts:a,approvedOrigins:o,attach:s,assertLive:c,guard:l,consent:u,onNavigated:d,relay:f})=>{let p=n,m=r&&i!==``,g=async()=>{if(!m)return!1;let t=typeof e.blank==`function`?await l(()=>e.blank()):``;return(typeof t!=`string`||t.split(`#`)[0]!==n.split(`#`)[0])&&(m=!1),m},_=Promise.resolve(),{gate:v,requestCategories:y,boundary:x}=b({session:i,declaredHosts:a,approvedOrigins:o,attach:s,assertLive:c,documentHost:typeof e.documentHost==`function`?()=>l(()=>e.documentHost()):void 0,current:()=>p,consent:ne(u),freshBlank:g});return t.y({backend:`cloud`,executor:{execute:(n,r,i)=>C.has(r)?Promise.reject(t.A(r,`cloud`)):(c(),l(()=>e.executeLocator(n,r,i))),highlight:async()=>{}},gate:v,requestPermissions:y,evaluate:async(n,r)=>(c(),await v({parts:[],operation:`evaluate`,args:[n,r],phase:`execute`}),E(l(()=>e.executeLocator([],`evaluate`,[n,r])),t.l,t.u)),addScriptTag:async(n,r)=>{c();let i=[n,r];await v({parts:[],operation:`addScriptTag`,args:i,phase:`execute`});try{await E(l(()=>e.executeLocator([],`addScriptTag`,i)),t.l,A)}catch(e){throw ee(e)?t.M(k,`addScriptTag`,`cloud`):e}},clearCookies:async n=>{if(c(),typeof e.clearCookies!=`function`)throw t.M(j,`clearCookies`,`cloud`);if(x().length===0)throw t.O(M,`clearCookies`);await E(l(()=>e.clearCookies(n)),N,L)},postMessage:(n,r,i)=>{if(c(),typeof e.messaging!=`function`)throw t.M(O,`postMessage`,`cloud`);if(r!==`*`&&!x().includes(new URL(r).hostname))throw t.O(h,`postMessage`);let{port1:a,port2:o}=new MessageChannel;a.postMessage({data:n,transfer:i},i);let s=[o,r],u=_.then(async()=>(await v({parts:[],operation:`postMessage`,args:s,phase:`execute`}),{answer:l(()=>e.executeLocator([],`postMessage`,s))}));return _=u.catch(()=>{}),u.then(async({answer:e})=>{await e})},listen:t=>(typeof e.messaging!=`function`&&te(),f(t)),goto:async(n,{timeout:r,...i}={})=>{let a=new URL(n,location.href).href;c(),m=!1;let s=(()=>{try{return new URL(a).origin}catch{return``}})(),u=s!==``&&!o.has(s);u&&o.add(s);try{await E(l(()=>e.goto(a,r===void 0?i:{...i,timeoutMs:r})),(r??3e4)+S,`cloud.attachFrame: the render proxy did not answer goto; the frame may have been detached or its page reloaded`)}catch(e){throw u&&o.delete(s),t.c(e)}p=a,d()},url:()=>p})},re=250,ie=500,ae=65e3,oe=2e3,se=2e3,ce=2,le=2e3,ue=2e3,V=({origin:e,target:t,session:n,domains:r,attach:i})=>{let a=new URL(`/attach-window`,e);return a.searchParams.set(`attach`,i),t&&a.searchParams.set(`url`,t),n&&a.searchParams.set(`session`,n),r.length&&a.searchParams.set(`domains`,r.join(`,`)),a.href},H=(e,t)=>{let n=document.createElement(`iframe`),r=new URL(`/attach-jar`,e);return r.searchParams.set(`attach`,t),n.src=r.href,n.tabIndex=-1,n.setAttribute(`aria-hidden`,`true`),n.setAttribute(`style`,`display:none`),(document.body??document.documentElement).appendChild(n),n},de=(e,t)=>{let n=new MutationObserver(()=>{e.isConnected||t.aborted||(n.disconnect(),console.warn(`cloud.attachFrame: the window's jar anchor was removed from this page, so a sign-in in the window no longer reaches this app's cookie jar`))});e.parentNode&&n.observe(e.parentNode,{childList:!0}),n.observe(document.documentElement,{childList:!0}),t.addEventListener(`abort`,()=>n.disconnect(),{once:!0})},U=()=>D(`cloud.attachFrame: the attached window closed, reloaded or left the page FKN attached; attach a fresh window`),W=()=>D(`cloud.attachFrame: the attached window stopped answering; attach a fresh window`),fe=()=>D(`cloud.attachFrame: the window went away before it connected; attach a fresh window`),pe=()=>D(`cloud.attachFrame: the window closed before it connected. Either the user closed it, or this page's Cross-Origin-Opener-Policy cut its link to the window`),me=async(e,r,a)=>{if(typeof window>`u`)throw Error(`cloud.attachFrame needs a window realm`);let{domains:o=[],permissions:c}=e,{url:l,width:u,height:d}=t.s(e.window);if(window.origin===`null`)throw new t._(`opaque-opener`);let f=w(),m=crypto.randomUUID(),h=T(r),g=n.t(o),_=new Set;l&&_.add(new URL(l).origin);let v=r===`persistent`?H(f,m):null,y=window.open(V({origin:f,target:a===void 0?l:``,session:h,domains:g,attach:m}),`_blank`,`popup,width=${u},height=${d}`);if(!y)throw v?.remove(),new t.g;let b=new AbortController,S=!1,C=null,D=(e,t=!1)=>{if(C===null){C=e,b.abort(t?W():U());try{y.closed||y.postMessage({type:s.ATTACH_WINDOW_MESSAGE.detach,attach:m,...t?{unanswered:t}:{}},f)}catch{}v&&setTimeout(()=>v.remove(),ue)}};v&&de(v,b.signal);let O=new Promise((e,t)=>{b.signal.addEventListener(`abort`,()=>t(b.signal.reason),{once:!0})});O.catch(()=>{});let k=O.then(()=>{},()=>{}),A=()=>{if(b.signal.aborted)throw b.signal.reason},j=e=>b.signal.aborted?Promise.reject(b.signal.reason):Promise.race([e(),O]),M=e=>e.source===y&&e.origin===f;window.addEventListener(`message`,e=>{if(!M(e))return;let n=e.data;typeof n==`object`&&n&&n.attach===m&&(n.type===s.ATTACH_WINDOW_MESSAGE.refused?D(new t._(n.reason)):n.type===s.ATTACH_WINDOW_MESSAGE.gone&&D(S?U():fe()))},{signal:b.signal}),window.addEventListener(`pagehide`,()=>D(U()),{signal:b.signal});let N=()=>{try{y.postMessage({type:s.ATTACH_WINDOW_MESSAGE.hello,attach:m},f)}catch{}};N();let P=setInterval(N,re),F=setInterval(()=>{y.closed&&D(S?U():pe())},ie);b.signal.addEventListener(`abort`,()=>{clearInterval(P),clearInterval(F)},{once:!0});let L=async e=>{try{return await Promise.race([e,O])}catch(e){throw C??e}};try{let e=await L(E((0,p.expose)({},{key:s.ATTACH_WINDOW_KEY,transport:{emit:(e,t)=>y.postMessage(e,f,t??[]),receive:e=>{let t=t=>{M(t)&&e(t.data,{source:t.source,origin:t.origin})};return window.addEventListener(`message`,t),()=>window.removeEventListener(`message`,t)}},unregisterSignal:b.signal,revivableModules:x(t.lt)}),s.WINDOW_HANDSHAKE_TIMEOUT_MS,`cloud.attachFrame: timed out connecting to the window`));S=!0,clearInterval(P);let n=0,r=setInterval(()=>{E(j(()=>e.ping()),se,`ping`).then(()=>{n=0},()=>{b.signal.aborted||(document.visibilityState===`hidden`?n=0:++n>=ce&&D(W(),!0))})},oe);b.signal.addEventListener(`abort`,()=>clearInterval(r),{once:!0}),await L(E(e.ready(),ae,`cloud.attachFrame: the window never became ready`)),a!==void 0&&await L(I(e,a));let o=i.t(`attached frame`);b.signal.aborted?o():b.signal.addEventListener(`abort`,o,{once:!0});let u=B({control:e,target:l,session:h,declaredHosts:g,approvedOrigins:_,attach:m,assertLive:A,guard:j,consent:{request:t=>j(()=>e.requestConsent(t)),ensure:t=>j(()=>e.requestConsent([t])).then(([e])=>e!==void 0&&e!==!1)},onNavigated:()=>{},relay:z({from:()=>y,origin:f,attach:m,signal:b.signal})}),d=null,v=Object.assign(u,{close:()=>d??=(async()=>{b.signal.aborted||await E(Promise.allSettled([j(()=>e.flushCookies()),j(()=>e.sweepStorage())]),le,`close`).catch(()=>{});try{y.close()}catch{}D(U())})(),closed:k});return a!==void 0&&l&&await L(v.goto(l)),c?.length&&await L(v.requestPermissions(c)),v}catch(e){let n=C??e;if(!(n instanceof t._))try{y.close()}catch{}throw D(n),n}},he=2e4,G=65e3,K=e=>!e||e===`about:blank`,ge=`cloud.attachFrame: this FKN page predates blank pages; reload the app to load the current one`,_e=`cloud.attachFrame: cookies: 'native' needs the FKN browser extension; the cloud render proxy has no browser cookies`,q=e=>e.split(`#`)[0]??``,J=({iframe:e,lockdown:n,cookies:r,blank:i})=>{if(i===void 0)return``;if(typeof i!=`object`||!i)throw TypeError(`attachFrame: blank must be an object { url }`);let a=Object.keys(i).find(e=>e!==`url`);if(a!==void 0)throw TypeError(`attachFrame: blank takes { url }, not "${a}"`);let{url:o}=i,s=(()=>{try{return typeof o==`string`?new URL(o):null}catch{return null}})();if(!s||s.protocol!==`http:`&&s.protocol!==`https:`)throw TypeError(`attachFrame: blank.url must be an absolute http or https url, not "${String(o)}"`);let c=e.getAttribute(`src`)??``;if(!K(c))throw TypeError(`attachFrame: blank needs an iframe with no src; this one has "${c}"`);if(n)throw TypeError(`attachFrame: blank does not combine with lockdown`);if(r===`native`)throw TypeError(`attachFrame: blank runs on the cloud render proxy, which has no browser cookies; pass cookies: 'persistent' or 'ephemeral'`);if(t.x(s.href),!Te())throw Error(`attachFrame: a blank page is served by the cloud render proxy, which this build does not configure`);return s.href},ve=({target:e,blank:t,session:n,domains:r,attach:i})=>{let a=new URL(`/attach-frame`,w());return t?a.searchParams.set(`blank`,t):e&&a.searchParams.set(`url`,e),n&&a.searchParams.set(`session`,n),r.length&&a.searchParams.set(`domains`,r.join(`,`)),a.searchParams.set(`attach`,i),a.href},ye=(e,t)=>{let n=()=>{a(),t()},r=e.parentNode,i=new MutationObserver(()=>{(!e.isConnected||e.parentNode!==r)&&(a(),t())}),a=()=>{window.removeEventListener(`pagehide`,n),i.disconnect()};window.addEventListener(`pagehide`,n,{once:!0}),r&&i.observe(r,{childList:!0}),e.isConnected||(a(),t())},be=()=>D(`cloud.attachFrame: the attached iframe left the document or was reloaded; attach a fresh iframe`),xe=(e,t)=>{let n=[...e.split(`;`),...t.split(`;`)].map(e=>e.trim()).filter(Boolean);return[...new Set(n)].join(`; `)},Se=[300,1200,4e3],Y=e=>{let t=()=>{if(!e.isConnected)return;let t=e.style.height,n=e.getBoundingClientRect();n.height&&(e.style.height=`${n.height-1}px`,setTimeout(()=>{e.style.height=t},50))};t();for(let e of Se)setTimeout(t,e)},Ce=e=>{let t=e.getAttribute(`sandbox`);if(t===null)return;let n=new Set(t.toLowerCase().split(/\s+/).filter(Boolean)),r=[`allow-scripts`,`allow-same-origin`].filter(e=>!n.has(e));if(r.length)throw Error(`cloud.attachFrame: the iframe's sandbox attribute must include ${r.join(` and `)} for the render proxy to load`)},X=async(e,n)=>{let r=typeof e.blank==`function`?await E(e.blank(),G,`cloud.attachFrame: the render proxy never became ready`):``;if(typeof r!=`string`||q(r)!==q(n))throw t.M(ge,`blank`,`cloud`)},we=async(e,a,o)=>{let c=J(e),{iframe:l,domains:u=[],permissions:d}=e;if(typeof window>`u`)throw Error(`cloud.attachFrame needs a window realm`);if(!l.isConnected)throw Error(`cloud.attachFrame: the iframe must be connected to the document before attaching`);Ce(l);let f=l.getAttribute(`src`)??``,h=(()=>{if(K(f))return null;try{return new URL(l.src||f,location.href)}catch{throw Error(`cloud.attachFrame: the iframe src is not a valid URL: ${f}`)}})();if(h){let e=new URL(`/attach-frame`,w());if(h.origin===e.origin&&h.pathname===e.pathname)throw Error(`cloud.attachFrame: this iframe is already attached; navigate with the Frame returned by that attach or use a fresh iframe`)}let g=h?.href??``;g&&t.x(g);let _=o===void 0?g:``,v=T(a),y=n.t(u),b=new Set;try{b.add(new URL(c||g).origin)}catch{}let S=new AbortController,C=l.referrerPolicy,D=l.allow,O=crypto.randomUUID();if(l.referrerPolicy=`origin`,l.allow=xe(r.m(),l.allow),l.src=ve({target:_,blank:c,session:v,domains:y,attach:O}),!l.contentWindow)throw Error(`cloud.attachFrame: the iframe window is not available`);try{let e=await E((0,p.expose)({},{key:s.ATTACH_FRAME_KEY,origin:w(),transport:{receive:window,emit:l.contentWindow},unregisterSignal:S.signal,revivableModules:x(t.lt)}),he,`cloud.attachFrame: timed out connecting to the render proxy page`);await E(e.ready(),G,`cloud.attachFrame: the render proxy never became ready`),c&&await X(e,c),o!==void 0&&await I(e,o),(g||c)&&Y(l),ye(l,()=>S.abort());let n=i.t(`attached frame`);S.signal.aborted?n():S.signal.addEventListener(`abort`,n,{once:!0});let r=l.contentWindow,a=B({control:e,target:c||g,blank:c!==``,session:v,declaredHosts:y,approvedOrigins:b,attach:O,assertLive:()=>{if(S.signal.aborted||!l.isConnected||l.contentWindow!==r)throw S.abort(),be()},guard:e=>e(),consent:m,onNavigated:()=>Y(l),relay:z({from:()=>r,origin:w(),attach:O,signal:S.signal})});return o!==void 0&&g&&await a.goto(g),d?.length&&await a.requestPermissions(d),a}catch(e){throw S.abort(),l.referrerPolicy=C,l.allow=D,l.src=_||`about:blank`,e}},Z=(async e=>{let{kind:n,cookies:r,storageState:i}=t.o(e);if(r===`native`)throw TypeError(_e);return n===`window`?me(e,r,i):we(e,r,i)}),Te=()=>typeof window<`u`&&!0,Q=async()=>{let e=await r.o.then(e=>e.cloud.quota());return{premium:e.premium,overQuota:e.overQuota,throttled:e.overQuota&&!e.premium,usedBytes:e.usedBytes,limitBytes:e.limitBytes,remainingBytes:e.remaining,bytesPerSecond:e.bytesPerSecond,bitsPerSecond:e.bytesPerSecond*8}},Ee=e.t({attachFrame:()=>Z,available:()=>$,dgram:()=>d.t,dns:()=>c.t,fetch:()=>a.t,fs:()=>l.t,http:()=>f.t,net:()=>u.t,quota:()=>Q}),$=()=>r.l;Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return J}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return $}});
|