@fkn/lib 0.9.63 → 0.9.65

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 (169) hide show
  1. package/README.md +34 -0
  2. package/account-Bm7uIcQo.d.ts +39 -0
  3. package/account-Uh0-1Cbp.js +22 -0
  4. package/{account-generation-B0cJrpDx.cjs → account-generation-ACCBzaI-.cjs} +1 -1
  5. package/{account-generation-u31dhamM.js → account-generation-BKHNe-jL.js} +2 -3
  6. package/account-m2iCmNui.cjs +1 -0
  7. package/{account-storage-ZkzqZp3A.js → account-storage-BmCVutNL.js} +4 -5
  8. package/{account-storage-Co9IvkPr.d.ts → account-storage-UmSfF63A.d.ts} +1 -66
  9. package/{account-storage-BnohkyMJ.cjs → account-storage-dYWDpqsr.cjs} +1 -1
  10. package/account.cjs +1 -1
  11. package/account.d.ts +3 -40
  12. package/account.js +1 -23
  13. package/{api-xh6lzApn.d.ts → api-0Yp9uZcV.d.ts} +3 -7
  14. package/{api-Di2Ff3jS.js → api-DRglK7ft.js} +115 -156
  15. package/api-DrvhPN56.cjs +3 -0
  16. package/api.cjs +1 -1
  17. package/api.d.ts +2 -2
  18. package/api.js +1 -2
  19. package/attach-policy.d.ts +0 -4
  20. package/attach-policy.js +2 -3
  21. package/broker-frame-CF4-yXtj.cjs +9 -0
  22. package/broker-frame-vjSpBa8d.js +51 -0
  23. package/broker-frame.cjs +1 -0
  24. package/broker-frame.d.ts +12 -0
  25. package/broker-frame.js +1 -0
  26. package/{busy-DsMWrSzc.js → busy-C1JPjoZ_.js} +1 -2
  27. package/cloud/dgram.cjs +1 -1
  28. package/cloud/dgram.d.ts +1 -1
  29. package/cloud/dgram.js +1 -2
  30. package/cloud/dns.cjs +1 -1
  31. package/cloud/dns.d.ts +2 -2
  32. package/cloud/dns.js +1 -2
  33. package/cloud/fetch.cjs +1 -1
  34. package/cloud/fetch.d.ts +1 -1
  35. package/cloud/fetch.js +1 -2
  36. package/cloud/fs/promises.cjs +1 -1
  37. package/cloud/fs/promises.d.ts +3 -5
  38. package/cloud/fs/promises.js +2 -3
  39. package/cloud/fs.cjs +1 -1
  40. package/cloud/fs.d.ts +4 -4
  41. package/cloud/fs.js +4 -34
  42. package/cloud/http.cjs +1 -1
  43. package/cloud/http.d.ts +1 -1
  44. package/cloud/http.js +1 -2
  45. package/cloud/net.cjs +1 -1
  46. package/cloud/net.d.ts +1 -1
  47. package/cloud/net.js +3 -3
  48. package/{cloud-CI7FFRMC.d.ts → cloud-BoH54gaM.d.ts} +7 -11
  49. package/{cloud-C6rG_aod.js → cloud-C7StNncS.js} +17 -17
  50. package/cloud-TN0eDUy3.cjs +1 -0
  51. package/cloud.cjs +1 -1
  52. package/cloud.d.ts +7 -7
  53. package/cloud.js +7 -7
  54. package/connect-button-2FmOM8ai.d.ts +2 -0
  55. package/{connect-button-DtsN3X1J.js → connect-button-C1wKkIhh.js} +1 -2
  56. package/{contract-BGMJVvTg.d.ts → contract-0rua6Wsh.d.ts} +11 -6
  57. package/contract.d.ts +3 -3
  58. package/contract.js +1 -2
  59. package/desktop-DOubT4ES.d.ts +57 -0
  60. package/desktop-vXKU4wEK.cjs +1 -0
  61. package/desktop-xTT7ciGX.js +50 -0
  62. package/desktop.cjs +1 -1
  63. package/desktop.d.ts +2 -58
  64. package/desktop.js +1 -51
  65. package/dgram-BBbLokVF.js +397 -0
  66. package/dgram-BYk-QDHW.d.ts +118 -0
  67. package/dgram-D9ljiUFh.cjs +1 -0
  68. package/dgram.cjs +1 -1
  69. package/dgram.d.ts +2 -119
  70. package/dgram.js +1 -410
  71. package/dns-2v96zoEh.cjs +1 -0
  72. package/dns-DyB4K2oE.d.ts +9 -0
  73. package/dns-o8DLFjP1.js +5 -0
  74. package/dns.cjs +1 -1
  75. package/dns.d.ts +3 -10
  76. package/dns.js +1 -6
  77. package/extension-BXBjpypy.cjs +1 -0
  78. package/{extension-C3_aJX7C.js → extension-D5UMnEmQ.js} +11 -12
  79. package/{extension-C1bcizcn.d.ts → extension-D98KM8W7.d.ts} +1 -27
  80. package/extension.cjs +1 -1
  81. package/extension.d.ts +2 -2
  82. package/extension.js +2 -2
  83. package/fs/promises.cjs +1 -1
  84. package/fs/promises.d.ts +2 -4
  85. package/fs/promises.js +2 -3
  86. package/fs--MLHvMW-.cjs +1 -0
  87. package/fs-BX_ghRy0.cjs +1 -0
  88. package/fs-BnWXGRik.js +33 -0
  89. package/{fs-DCJAYoYy.d.ts → fs-ChOYC6VD.d.ts} +3 -4
  90. package/{fs-DgdN2HPt.js → fs-Cw7CcUhx.js} +17 -41
  91. package/fs.cjs +1 -1
  92. package/fs.d.ts +4 -4
  93. package/fs.js +2 -2
  94. package/{hosts-t7CKGTRz.js → hosts-HUfgMimI.js} +1 -2
  95. package/http-BE3UBktN.cjs +9 -0
  96. package/http-CDhG4bUc.d.ts +187 -0
  97. package/http-DIDjdm08.js +523 -0
  98. package/http.cjs +1 -9
  99. package/http.d.ts +2 -188
  100. package/http.js +1 -542
  101. package/index-CUWTpQKP.d.ts +87 -0
  102. package/{index-BQgZVQl7.d.ts → index-CcVwh9yz.d.ts} +0 -2
  103. package/{index-C5DdoMGo.d.ts → index-Cu5EcdK0.d.ts} +0 -59
  104. package/{index-57lTXnoe.d.ts → index-D6GPJ4Ow.d.ts} +29 -26
  105. package/index.cjs +1 -1
  106. package/index.d.ts +17 -25
  107. package/index.js +22 -27
  108. package/lib-Bs-g5jyp.cjs +53 -0
  109. package/{lib-BrsqpUkv.js → lib-CtJaID_y.js} +7 -31
  110. package/{messages-AdPfdoLV.d.ts → messages-B9dOXntM.d.ts} +0 -2
  111. package/messages.d.ts +1 -1
  112. package/messages.js +1 -2
  113. package/net-COkJw8lV.js +286 -0
  114. package/net-Dk2kqtgE.cjs +1 -0
  115. package/{net-BpyIeQ8r.d.ts → net-mVAYXs8e.d.ts} +5 -7
  116. package/net.cjs +1 -1
  117. package/net.d.ts +1 -1
  118. package/net.js +3 -323
  119. package/{node-fs-DY2fO5zd.js → node-fs-B4pY08Kc.js} +3 -10
  120. package/node-fs-DN0ejGTL.cjs +1 -0
  121. package/opfs/promises.cjs +1 -1
  122. package/opfs/promises.d.ts +2 -4
  123. package/opfs/promises.js +2 -3
  124. package/{opfs-D0goLAQW.js → opfs-CzCfVam3.js} +2 -3
  125. package/opfs-D3pYzYRc.js +35 -0
  126. package/opfs-DuXvTgIl.cjs +1 -0
  127. package/opfs.cjs +1 -1
  128. package/opfs.d.ts +3 -88
  129. package/opfs.js +1 -36
  130. package/package.json +6 -1
  131. package/packages-BEadIy_h.d.ts +155 -0
  132. package/packages-Cws_rcgf.js +346 -0
  133. package/packages-DT8vPB5_.cjs +1 -0
  134. package/packages.cjs +1 -1
  135. package/packages.d.ts +3 -156
  136. package/packages.js +1 -347
  137. package/{proxy-tsVhjcl-.js → proxy-BBAQxJmP.js} +13 -13
  138. package/{proxy-Dz60YyYy.d.ts → proxy-BP40IXYD.d.ts} +2 -4
  139. package/proxy-DVgGp6A8.cjs +1 -0
  140. package/react.cjs +1 -1
  141. package/react.d.ts +16 -4
  142. package/react.js +96 -7
  143. package/{relay-choice-BGwXRC5d.js → relay-choice-Bb3oP2gw.js} +1 -2
  144. package/{relay-choice-5yUPI-tJ.d.ts → relay-choice-DOUttUnL.d.ts} +2 -4
  145. package/{rolldown-runtime-Dy4uBu1J.js → rolldown-runtime-CGnMp29N.js} +1 -2
  146. package/rooms-C6mbannC.d.ts +227 -0
  147. package/rooms-DHFS9cwA.cjs +1 -0
  148. package/rooms-DP5stTEr.js +300 -0
  149. package/rooms.cjs +1 -1
  150. package/rooms.d.ts +3 -228
  151. package/rooms.js +1 -301
  152. package/storage-BCjYihUO.cjs +1 -0
  153. package/storage-BhfImh_2.js +136 -0
  154. package/storage-DpCLksAa.d.ts +68 -0
  155. package/storage.cjs +1 -1
  156. package/storage.d.ts +3 -69
  157. package/storage.js +1 -137
  158. package/{utils-Cyq8uJiy.js → utils-DtWP-E9x.js} +1 -2
  159. package/{wire-Fk5pJaoy.d.ts → wire-DhmLnYEU.d.ts} +0 -2
  160. package/wire.d.ts +1 -1
  161. package/wire.js +1 -2
  162. package/api-BSk3dc_X.cjs +0 -3
  163. package/cloud-BoiHKoRZ.cjs +0 -1
  164. package/connect-button-Cp0NS95-.d.ts +0 -4
  165. package/extension-Crv4aUAm.cjs +0 -1
  166. package/fs-CjQTj3FA.cjs +0 -1
  167. package/lib-C_X3WR4G.cjs +0 -53
  168. package/node-fs-vsWuoMGa.cjs +0 -1
  169. package/proxy-BA92hkId.cjs +0 -1
package/dgram.d.ts CHANGED
@@ -1,119 +1,2 @@
1
- import { D as RelayChoice } from "./index-C5DdoMGo.js";
2
- import { Gt as UdpSocketResult, X as Resolvers } from "./contract-BGMJVvTg.js";
3
- import { x as UdpSocketOption } from "./wire-Fk5pJaoy.js";
4
- import "./api-xh6lzApn.js";
5
- import { t as RelayOption } from "./relay-choice-5yUPI-tJ.js";
6
- import { Buffer } from "buffer";
7
- import { AddressInfo } from "net";
8
- import { BindOptions, RemoteInfo, Socket as Socket$2, SocketOptions, SocketType } from "dgram";
9
- import { EventEmitter } from "events";
10
- declare namespace dgram_d_exports {
11
- export { Socket, createSocket, _default as default };
12
- }
13
- type WebVpnUdpSocket = Resolvers['cloud']['webvpn']['udpSocket'];
14
- interface EventEmitterOptions {
15
- /**
16
- * Enables automatic capturing of promise rejection.
17
- */
18
- captureRejections?: boolean | undefined;
19
- }
20
- export declare class Socket extends EventEmitter implements Socket$2 {
21
- _type: 'udp4' | 'udp6';
22
- _localAddress?: {
23
- address: string;
24
- family: string;
25
- port: number;
26
- };
27
- _remoteAddress?: {
28
- address: string;
29
- family: string;
30
- port: number;
31
- };
32
- _connectedLocally?: boolean;
33
- _connectGeneration: number;
34
- _destroyed: boolean;
35
- _busyRelease?: () => void;
36
- _webVPNUdpSocketPromise?: Promise<Awaited<ReturnType<WebVpnUdpSocket>> | undefined>;
37
- _dataPort?: MessagePort;
38
- _socketId?: number;
39
- _sendQueue: Uint8Array[];
40
- _sendQueueBytes: number;
41
- _sendFlushScheduled: boolean;
42
- _peerTailCache: Map<string, Uint8Array<ArrayBufferLike>>;
43
- _relayChoice?: RelayChoice;
44
- /** the relay serving this socket once it is bound, read through `relayOf` */
45
- _relay?: string;
46
- constructor(options: SocketOptions & EventEmitterOptions & RelayOption & {
47
- connection?: ReturnType<WebVpnUdpSocket>;
48
- });
49
- _lastRecvBufferSize: number;
50
- _lastSendBufferSize: number;
51
- _lastTtl: number;
52
- _lastMulticastTtl: number;
53
- _lastMulticastLoopback: boolean;
54
- _setUdpOption(option: UdpSocketOption): void;
55
- _dataPortAcks: boolean;
56
- _dataPortConsumedBytes: number;
57
- _dataPortAckedBytes: number;
58
- _ackDataPortBatch(batchBytes: number): void;
59
- _onTransportClosed(reason?: string): void;
60
- _onDataPortBatch(buffer: ArrayBuffer): void;
61
- _peerTail(address: string | undefined, port: number | undefined): Uint8Array;
62
- _portSend(message: Uint8Array, address: string | undefined, port: number | undefined): void;
63
- addMembership(multicastAddress: string, multicastInterface?: string | undefined): void;
64
- address(): AddressInfo;
65
- bind(port?: number | undefined, address?: string | undefined, callback?: (() => void) | undefined): this;
66
- bind(port?: number | undefined, callback?: (() => void) | undefined): this;
67
- bind(callback?: (() => void) | undefined): this;
68
- bind(options: BindOptions, callback?: (() => void) | undefined): this;
69
- /**
70
- * Wires the socket up from a connection already in hand and reports it as bound; also the seam a
71
- * test uses to reach a refused bind without mocking the resolver. `endpoints` publishes the local
72
- * address synchronously, as net.ts does: `address()` throws EBADF until the connection resolves,
73
- * while Node fills an address in before reporting a socket bound.
74
- */
75
- __webvpn_udp_socket_init__(connection: ReturnType<WebVpnUdpSocket>, endpoints?: Awaited<ReturnType<WebVpnUdpSocket>>): Promise<UdpSocketResult | undefined>;
76
- close(callback?: (() => void) | undefined): this;
77
- connect(port: number, address?: string, callback?: () => void): void;
78
- connect(port: number, callback: () => void): void;
79
- disconnect(): void;
80
- dropMembership(multicastAddress: string, multicastInterface?: string | undefined): void;
81
- getRecvBufferSize(): number;
82
- getSendBufferSize(): number;
83
- /** Queue measurements are not exposed by the browser transport. Always returns 0. */
84
- getSendQueueSize(): number;
85
- /** Queue measurements are not exposed by the browser transport. Always returns 0. */
86
- getSendQueueCount(): number;
87
- /** No-op in a browser, which has no Node process-liveness handle. */
88
- ref(): this;
89
- remoteAddress(): AddressInfo;
90
- send(msg: string | readonly any[] | Uint8Array, port?: number | undefined, address?: string | undefined, callback?: ((error: Error | null, bytes: number) => void) | undefined): void;
91
- send(msg: string | readonly any[] | Uint8Array, port?: number | undefined, callback?: ((error: Error | null, bytes: number) => void) | undefined): void;
92
- send(msg: string | readonly any[] | Uint8Array, callback?: ((error: Error | null, bytes: number) => void) | undefined): void;
93
- send(msg: string | Uint8Array, offset: number, length: number, port?: number | undefined, address?: string | undefined, callback?: ((error: Error | null, bytes: number) => void) | undefined): void;
94
- send(msg: string | Uint8Array, offset: number, length: number, port?: number | undefined, callback?: ((error: Error | null, bytes: number) => void) | undefined): void;
95
- send(msg: string | Uint8Array, offset: number, length: number, callback?: ((error: Error | null, bytes: number) => void) | undefined): void;
96
- send(msg: unknown, offset?: unknown, length?: unknown, port?: unknown, address?: unknown, callback?: unknown): void;
97
- setBroadcast(flag: boolean): void;
98
- /** No-op. The browser transport does not expose an interface index or address. */
99
- setMulticastInterface(multicastInterface: string): void;
100
- setMulticastLoopback(flag: boolean): boolean;
101
- setMulticastTTL(ttl: number): number;
102
- setRecvBufferSize(size: number): void;
103
- setSendBufferSize(size: number): void;
104
- setTTL(ttl: number): number;
105
- /** No-op in a browser, which has no Node process-liveness handle. */
106
- unref(): this;
107
- /** Not implemented by the browser transport. This method currently does nothing. */
108
- addSourceSpecificMembership(sourceAddress: string, groupAddress: string, multicastInterface?: string | undefined): void;
109
- /** Not implemented by the browser transport. This method currently does nothing. */
110
- dropSourceSpecificMembership(sourceAddress: string, groupAddress: string, multicastInterface?: string | undefined): void;
111
- [Symbol.asyncDispose](): Promise<void>;
112
- }
113
- export declare const createSocket: (options: SocketType | (SocketOptions & RelayOption), callback?: (msg: Buffer, rinfo: RemoteInfo) => void) => Socket;
114
- declare const _default: {
115
- Socket: typeof Socket;
116
- createSocket: typeof createSocket;
117
- };
118
- //#endregion
119
- export { _default as default, dgram_d_exports as t };
1
+ import { n as _default, r as createSocket, t as Socket } from "./dgram-BYk-QDHW.js";
2
+ export { Socket, createSocket, _default as default };
package/dgram.js CHANGED
@@ -1,410 +1 @@
1
- import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
2
- import { s as t } from "./api-Di2Ff3jS.js";
3
- import { t as n } from "./busy-DsMWrSzc.js";
4
- import { t as r } from "./relay-choice-BGwXRC5d.js";
5
- import { a as i, i as a, s as o } from "./utils-Cyq8uJiy.js";
6
- import { UDP_PORT_ACK_TYPE as s } from "./wire.js";
7
- import { Buffer as c } from "buffer";
8
- import { EventEmitter as l } from "events";
9
- import { Address4 as u, Address6 as d } from "ip-address";
10
- //#region src/webvpn/dgram.ts
11
- var f = /* @__PURE__ */ e({
12
- Socket: () => p,
13
- createSocket: () => y,
14
- default: () => b
15
- }), p = class extends l {
16
- _type;
17
- _localAddress;
18
- _remoteAddress;
19
- _connectedLocally;
20
- _connectGeneration = 0;
21
- _destroyed = !1;
22
- _busyRelease;
23
- _webVPNUdpSocketPromise;
24
- _dataPort;
25
- _socketId;
26
- _sendQueue = [];
27
- _sendQueueBytes = 0;
28
- _sendFlushScheduled = !1;
29
- _peerTailCache = /* @__PURE__ */ new Map();
30
- _relayChoice;
31
- _relay;
32
- constructor(e) {
33
- if (super(e), !e) throw Error("Missing options");
34
- this._type = e.type, this._relayChoice = e.relay, e.connection && this.__webvpn_udp_socket_init__(e.connection);
35
- }
36
- _lastRecvBufferSize = 0;
37
- _lastSendBufferSize = 0;
38
- _lastTtl = 64;
39
- _lastMulticastTtl = 1;
40
- _lastMulticastLoopback = !0;
41
- _setUdpOption(e) {
42
- if (!this._webVPNUdpSocketPromise) {
43
- this.emit("error", /* @__PURE__ */ Error("Cannot set socket option before bind"));
44
- return;
45
- }
46
- this._webVPNUdpSocketPromise.then(async (t) => {
47
- if (t) try {
48
- await t.setOption(e);
49
- } catch (e) {
50
- this.emit("error", e);
51
- }
52
- });
53
- }
54
- _dataPortAcks = !1;
55
- _dataPortConsumedBytes = 0;
56
- _dataPortAckedBytes = 0;
57
- _ackDataPortBatch(e) {
58
- if (!this._dataPortAcks || !this._dataPort || (this._dataPortConsumedBytes += e, this._dataPortAckedBytes !== 0 && this._dataPortConsumedBytes - this._dataPortAckedBytes < 524288)) return;
59
- this._dataPortAckedBytes = this._dataPortConsumedBytes;
60
- let t = {
61
- type: s,
62
- consumedBytes: this._dataPortConsumedBytes
63
- };
64
- this._dataPort.postMessage(t);
65
- }
66
- _onTransportClosed(e) {
67
- this._destroyed || (this._destroyed = !0, this._busyRelease?.(), this._dataPort?.close(), this._dataPort = void 0, this.listenerCount("error") > 0 && this.emit("error", Error(e || "WebVPN session closed")), this.emit("close"));
68
- }
69
- _onDataPortBatch(e) {
70
- let t = new DataView(e), n = !1, r, i = 0;
71
- for (; i + 4 <= e.byteLength;) {
72
- let a = t.getUint32(i);
73
- i += 4;
74
- let o = i + a;
75
- if (o > e.byteLength) break;
76
- let s = i + 4, l = t.getUint8(s);
77
- s += 1;
78
- let u, d, f;
79
- if (l === 2) {
80
- if (!this._remoteAddress) {
81
- i = o;
82
- continue;
83
- }
84
- u = this._remoteAddress.address, d = this._remoteAddress.family, f = this._remoteAddress.port;
85
- } else {
86
- let n = new Uint8Array(e, s, l === 0 ? 4 : 16);
87
- l === 0 ? (d = "IPv4", u = `${n[0]}.${n[1]}.${n[2]}.${n[3]}`) : (d = "IPv6", u = _(n)), s += n.byteLength, f = t.getUint16(s), s += 2;
88
- }
89
- let p = t.getUint32(s);
90
- s += 4;
91
- try {
92
- this.emit("message", c.from(e.slice(s, s + p)), {
93
- address: u,
94
- family: d,
95
- port: f,
96
- size: p
97
- });
98
- } catch (e) {
99
- n || (n = !0, r = e);
100
- }
101
- i = o;
102
- }
103
- if (n) throw r;
104
- }
105
- _peerTail(e, t) {
106
- if (e === void 0 || t === void 0) return m;
107
- let n = `${e}|${t}`, r = this._peerTailCache.get(n);
108
- if (r) return r;
109
- let i = u.isValid(e) ? g(e) : v(e), a = new Uint8Array(1 + i.byteLength + 2);
110
- return a[0] = i.byteLength === 4 ? 0 : 1, a.set(i, 1), new DataView(a.buffer).setUint16(1 + i.byteLength, t), this._peerTailCache.size >= 4096 && this._peerTailCache.clear(), this._peerTailCache.set(n, a), a;
111
- }
112
- _portSend(e, t, n) {
113
- let r = this._peerTail(t, n), i = new Uint8Array(8 + r.byteLength + 4 + e.byteLength), a = new DataView(i.buffer);
114
- a.setUint32(0, i.byteLength - 4), a.setUint32(4, this._socketId), i.set(r, 8), a.setUint32(8 + r.byteLength, e.byteLength), i.set(e, 12 + r.byteLength), this._sendQueue.push(i), this._sendQueueBytes += i.byteLength, !this._sendFlushScheduled && (this._sendFlushScheduled = !0, queueMicrotask(() => {
115
- this._sendFlushScheduled = !1;
116
- let e = this._sendQueue, t = this._sendQueueBytes;
117
- if (this._sendQueue = [], this._sendQueueBytes = 0, !e.length || !this._dataPort) return;
118
- let n = new Uint8Array(t), r = 0;
119
- for (let t of e) n.set(t, r), r += t.byteLength;
120
- this._dataPort.postMessage(n.buffer, [n.buffer]);
121
- }));
122
- }
123
- addMembership(e, t) {
124
- if (u.isValid(e)) {
125
- let n = g(e), r = t && u.isValid(t) ? g(t) : new Uint8Array([
126
- 0,
127
- 0,
128
- 0,
129
- 0
130
- ]);
131
- this._setUdpOption({
132
- type: 5,
133
- group: n,
134
- interface: r
135
- });
136
- } else if (d.isValid(e)) {
137
- let t = v(e);
138
- this._setUdpOption({
139
- type: 7,
140
- group: t,
141
- ifIndex: 0
142
- });
143
- } else this.emit("error", /* @__PURE__ */ Error(`Invalid multicast address: ${e}`));
144
- }
145
- address() {
146
- if (!this._localAddress) throw Error("EBADF");
147
- return this._localAddress;
148
- }
149
- bind(...e) {
150
- let n = a(...e), i = this._type === "udp6" ? "::" : "0.0.0.0", o = this._relayChoice, s = this.__webvpn_udp_socket_init__(t("a udp socket").then((e) => (o !== void 0 && r(e, "dgram.createSocket"), e.cloud.webvpn.udpSocket({
151
- type: this._type,
152
- address: n.address ?? i,
153
- port: n.port,
154
- dataPort: !0,
155
- relay: o
156
- }))));
157
- return n.callback && s.then((e) => {
158
- e && n.callback.call(this);
159
- }), this;
160
- }
161
- __webvpn_udp_socket_init__(e, t) {
162
- return t && (this._localAddress = {
163
- address: t.localAddress,
164
- family: t.localFamily,
165
- port: t.localPort
166
- }), this._busyRelease ??= n("udp socket"), this._webVPNUdpSocketPromise = e.then((e) => {
167
- if (e.dataPort) this._socketId = e.socketId, this._dataPort = e.dataPort, this._dataPortAcks = e.dataPortAcks === !0, this._dataPort.onmessage = (e) => {
168
- try {
169
- this._onDataPortBatch(e.data);
170
- } finally {
171
- this._ackDataPortBatch(e.data.byteLength);
172
- }
173
- };
174
- else {
175
- let t = e.dataReadableStream.getReader();
176
- (async () => {
177
- for (;;) {
178
- let { value: e, done: n } = await t.read();
179
- if (n) return;
180
- this.emit("message", c.from(e.data), {
181
- address: e.address,
182
- family: e.family,
183
- port: e.port,
184
- size: e.size
185
- });
186
- }
187
- })().catch((e) => this._onTransportClosed(e instanceof Error ? e.message : void 0));
188
- }
189
- return e.closed?.then((e) => this._onTransportClosed(e?.reason)).catch(() => {}), this._relay = e.relay, this._localAddress = {
190
- address: e.localAddress,
191
- family: e.localFamily,
192
- port: e.localPort
193
- }, e;
194
- }).catch((e) => {
195
- this.emit("error", e);
196
- }), this._webVPNUdpSocketPromise.then((e) => {
197
- if (!e) {
198
- this._busyRelease?.();
199
- return;
200
- }
201
- this.emit("listening");
202
- }), this._webVPNUdpSocketPromise;
203
- }
204
- close(e) {
205
- if (!this._webVPNUdpSocketPromise) throw Error("Socket not bound");
206
- return this._webVPNUdpSocketPromise.then(async (t) => {
207
- if (!t) throw Error("Socket not bound");
208
- let n = this._destroyed;
209
- this._destroyed = !0, this._busyRelease?.(), this._dataPort?.close(), this._dataPort = void 0;
210
- try {
211
- await t.close();
212
- } finally {
213
- try {
214
- e && e();
215
- } finally {
216
- n || this.emit("close");
217
- }
218
- }
219
- }).catch(() => {}), this;
220
- }
221
- connect(...e) {
222
- if (!this._webVPNUdpSocketPromise) throw Error("Socket not bound");
223
- this._webVPNUdpSocketPromise.then(async (t) => {
224
- if (!t) throw Error("Socket not bound");
225
- let n = e[0], r = this._type === "udp6" ? "::1" : "127.0.0.1", i = typeof e[1] == "string" ? e[1] : r, a = typeof e.at(-1) == "function" ? e.at(-1) : void 0, o = await t.connect({
226
- remotePort: n,
227
- remoteAddress: i
228
- });
229
- this._connectedLocally = o?.local === !0, this._remoteAddress = o?.address ? {
230
- address: o.address,
231
- family: o.family,
232
- port: o.port
233
- } : {
234
- address: i,
235
- family: this._type === "udp6" ? "IPv6" : "IPv4",
236
- port: n
237
- }, this._connectGeneration += 1, a && a();
238
- }).catch((e) => {
239
- this.emit("error", e);
240
- });
241
- }
242
- disconnect() {
243
- if (!this._webVPNUdpSocketPromise) throw Error("Socket not bound");
244
- if (!this._remoteAddress) throw Error("ERR_SOCKET_DGRAM_NOT_CONNECTED");
245
- let e = this._remoteAddress, t = this._connectedLocally, n = this._connectGeneration;
246
- this._remoteAddress = void 0, this._connectedLocally = void 0, this._webVPNUdpSocketPromise.then((e) => e?.disconnect?.()).catch((r) => {
247
- this._connectGeneration === n && (this._remoteAddress = e, this._connectedLocally = t), this.emit("error", r);
248
- });
249
- }
250
- dropMembership(e, t) {
251
- if (u.isValid(e)) {
252
- let n = g(e), r = t && u.isValid(t) ? g(t) : new Uint8Array([
253
- 0,
254
- 0,
255
- 0,
256
- 0
257
- ]);
258
- this._setUdpOption({
259
- type: 6,
260
- group: n,
261
- interface: r
262
- });
263
- } else if (d.isValid(e)) {
264
- let t = v(e);
265
- this._setUdpOption({
266
- type: 8,
267
- group: t,
268
- ifIndex: 0
269
- });
270
- } else this.emit("error", /* @__PURE__ */ Error(`Invalid multicast address: ${e}`));
271
- }
272
- getRecvBufferSize() {
273
- return this._lastRecvBufferSize;
274
- }
275
- getSendBufferSize() {
276
- return this._lastSendBufferSize;
277
- }
278
- getSendQueueSize() {
279
- return 0;
280
- }
281
- getSendQueueCount() {
282
- return 0;
283
- }
284
- ref() {
285
- return this;
286
- }
287
- remoteAddress() {
288
- if (!this._remoteAddress) throw Error("ERR_SOCKET_DGRAM_NOT_CONNECTED");
289
- return {
290
- address: this._remoteAddress.address,
291
- family: this._remoteAddress.family,
292
- port: this._remoteAddress.port
293
- };
294
- }
295
- send(...e) {
296
- this._webVPNUdpSocketPromise || this.bind();
297
- let t = i(...e), n = h(t.message), r = n;
298
- if (t.hasRange) {
299
- let { offset: e, length: i } = t;
300
- if (!Number.isInteger(e) || e < 0 || e > n.byteLength) throw Object.assign(/* @__PURE__ */ RangeError("\"offset\" is outside of buffer bounds"), { code: "ERR_BUFFER_OUT_OF_BOUNDS" });
301
- if (!Number.isInteger(i) || i < 0 || i > n.byteLength - e) throw Object.assign(/* @__PURE__ */ RangeError("\"length\" is outside of buffer bounds"), { code: "ERR_BUFFER_OUT_OF_BOUNDS" });
302
- r = n.subarray(e, e + i);
303
- }
304
- let a = this._type === "udp6" ? "::1" : "127.0.0.1";
305
- if (!this._webVPNUdpSocketPromise) throw Error("Socket not bound");
306
- this._webVPNUdpSocketPromise.then((e) => {
307
- if (!e) throw Error("Socket not bound");
308
- let n = t.callback, i = t.address ?? a, o = this._remoteAddress !== void 0 && t.address === void 0;
309
- if (this._dataPort && (o || u.isValid(i) || d.isValid(i))) {
310
- this._portSend(r, o ? void 0 : i, o ? void 0 : t.port), n?.call(this, null, r.byteLength);
311
- return;
312
- }
313
- e.send({
314
- port: t.port,
315
- address: i,
316
- message: r.byteOffset === 0 && r.byteLength === r.buffer.byteLength ? r.buffer : r.buffer.slice(r.byteOffset, r.byteOffset + r.byteLength)
317
- }).then(() => n?.call(this, null, r.byteLength), (e) => n ? n.call(this, e, 0) : this.emit("error", e));
318
- });
319
- }
320
- setBroadcast(e) {
321
- this._setUdpOption({
322
- type: 0,
323
- value: e
324
- });
325
- }
326
- setMulticastInterface(e) {}
327
- setMulticastLoopback(e) {
328
- return this._setUdpOption({
329
- type: 3,
330
- value: e
331
- }), this._setUdpOption({
332
- type: 4,
333
- value: e
334
- }), this._lastMulticastLoopback = e, e;
335
- }
336
- setMulticastTTL(e) {
337
- return this._setUdpOption({
338
- type: 2,
339
- value: e
340
- }), this._lastMulticastTtl = e, e;
341
- }
342
- setRecvBufferSize(e) {
343
- this._setUdpOption({
344
- type: 10,
345
- value: e
346
- }), this._lastRecvBufferSize = e;
347
- }
348
- setSendBufferSize(e) {
349
- this._setUdpOption({
350
- type: 9,
351
- value: e
352
- }), this._lastSendBufferSize = e;
353
- }
354
- setTTL(e) {
355
- return this._setUdpOption({
356
- type: 1,
357
- value: e
358
- }), this._lastTtl = e, e;
359
- }
360
- unref() {
361
- return this;
362
- }
363
- addSourceSpecificMembership(e, t, n) {}
364
- dropSourceSpecificMembership(e, t, n) {}
365
- async [Symbol.asyncDispose]() {
366
- await new Promise((e) => {
367
- this.close(e);
368
- });
369
- }
370
- }, m = new Uint8Array([2]), h = (e) => {
371
- if (typeof e == "string") return o.encode(e);
372
- if (e instanceof Uint8Array) return e;
373
- if (ArrayBuffer.isView(e)) return new Uint8Array(e.buffer, e.byteOffset, e.byteLength);
374
- if (Array.isArray(e)) {
375
- let t = e.map(h), n = new Uint8Array(t.reduce((e, t) => e + t.byteLength, 0)), r = 0;
376
- for (let e of t) n.set(e, r), r += e.byteLength;
377
- return n;
378
- }
379
- return new Uint8Array(e);
380
- }, g = (e) => {
381
- let t = e.split(".").map((e) => parseInt(e, 10));
382
- if (t.length !== 4 || t.some((e) => Number.isNaN(e) || e < 0 || e > 255)) throw Error(`Invalid IPv4 address: ${e}`);
383
- return new Uint8Array(t);
384
- }, _ = (e) => {
385
- let t = [];
386
- for (let n = 0; n < 16; n += 2) t.push(e[n] << 8 | e[n + 1]);
387
- let n = -1, r = 1;
388
- for (let e = 0; e < 8;) {
389
- if (t[e] !== 0) {
390
- e++;
391
- continue;
392
- }
393
- let i = e;
394
- for (; i < 8 && t[i] === 0;) i++;
395
- i - e > r && (n = e, r = i - e), e = i;
396
- }
397
- return n === -1 ? t.map((e) => e.toString(16)).join(":") : `${t.slice(0, n).map((e) => e.toString(16)).join(":")}::${t.slice(n + r).map((e) => e.toString(16)).join(":")}`;
398
- }, v = (e) => {
399
- let t = new d(e).getBitsBase16(0, 128).match(/.{2}/g);
400
- if (!t || t.length !== 16) throw Error(`Invalid IPv6 address: ${e}`);
401
- return new Uint8Array(t.map((e) => parseInt(e, 16)));
402
- }, y = (e, t) => {
403
- let n = new p(typeof e == "string" ? { type: e } : e);
404
- return t && n.on("message", t), n;
405
- }, b = {
406
- Socket: p,
407
- createSocket: y
408
- };
409
- //#endregion
410
- export { p as Socket, y as createSocket, b as default, f as t };
1
+ export { t as Socket, n as createSocket, r as default } from "./dgram-BBbLokVF.js";
@@ -0,0 +1 @@
1
+ const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./api-DrvhPN56.cjs");var n=e.t({lookup:()=>r}),r=(e,n)=>t.o.then(t=>t.cloud.dns.lookup(e,n));Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return n}});
@@ -0,0 +1,9 @@
1
+ import { s as AddressLookupResult } from "./contract-0rua6Wsh.js";
2
+ declare namespace dns_d_exports {
3
+ export { AddressLookupResult, lookup };
4
+ }
5
+ declare const lookup: <T extends boolean = false>(hostname: string, options?: {
6
+ all?: T;
7
+ family?: 0 | 4 | 6;
8
+ }) => Promise<T extends true ? AddressLookupResult[] : AddressLookupResult | undefined>;
9
+ export { lookup as n, dns_d_exports as t };
@@ -0,0 +1,5 @@
1
+ import { t as e } from "./rolldown-runtime-CGnMp29N.js";
2
+ import { o as t } from "./api-DRglK7ft.js";
3
+ // src/dns.ts
4
+ var n = /* @__PURE__ */ e({ lookup: () => r }), r = (e, n) => t.then((t) => t.cloud.dns.lookup(e, n));
5
+ export { r as n, n as t };
package/dns.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./api-BSk3dc_X.cjs");var n=e.t({lookup:()=>r}),r=(e,n)=>t.o.then(t=>t.cloud.dns.lookup(e,n));exports.lookup=r,Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return n}});
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./dns-2v96zoEh.cjs");exports.lookup=e.n;
package/dns.d.ts CHANGED
@@ -1,10 +1,3 @@
1
- import { s as AddressLookupResult } from "./contract-BGMJVvTg.js";
2
- declare namespace dns_d_exports {
3
- export { AddressLookupResult, lookup };
4
- }
5
- export declare const lookup: <T extends boolean = false>(hostname: string, options?: {
6
- all?: T;
7
- family?: 0 | 4 | 6;
8
- }) => Promise<T extends true ? AddressLookupResult[] : AddressLookupResult | undefined>;
9
- //#endregion
10
- export { type AddressLookupResult, dns_d_exports as t };
1
+ import { s as AddressLookupResult } from "./contract-0rua6Wsh.js";
2
+ import { n as lookup } from "./dns-DyB4K2oE.js";
3
+ export { type AddressLookupResult, lookup };
package/dns.js CHANGED
@@ -1,6 +1 @@
1
- import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
2
- import { o as t } from "./api-Di2Ff3jS.js";
3
- //#region src/dns.ts
4
- var n = /* @__PURE__ */ e({ lookup: () => r }), r = (e, n) => t.then((t) => t.cloud.dns.lookup(e, n));
5
- //#endregion
6
- export { r as lookup, n as t };
1
+ export { n as lookup } from "./dns-o8DLFjP1.js";
@@ -0,0 +1 @@
1
+ const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./lib-Bs-g5jyp.cjs"),n=require("./broker-frame-CF4-yXtj.cjs"),r=require("./api-DrvhPN56.cjs"),i=require("./contract.cjs"),a=require("./proxy-DVgGp6A8.cjs"),o=require("./desktop-vXKU4wEK.cjs");var s=`BackgroundStoppedError`,c=e=>t.d(e)&&e.name===`BackgroundStoppedError`,l=async e=>{if(t.Z(`promptInstall`,e),typeof window>`u`)return!1;if(t.rt())return!0;let n=await r.o,i=null,a=new Promise(e=>{i=()=>{t.rt()&&e(!0)},t.nt.addEventListener(`statuschange`,i)}),o=n.installPrompt.show(e).then(()=>!1),s=await Promise.race([a,o]);return i&&t.nt.removeEventListener(`statuschange`,i),await n.installPrompt.hide().catch(()=>{}),s},u=null;t.at(()=>(u||=l().then(()=>void 0).finally(()=>{u=null}),u));var d=e=>{try{e.headers.delete(i.RELAY_HEADER)}catch{}return e},f=()=>typeof document<`u`&&t.rt(),p=async(e,r)=>{if(n.r(e),t.Z(`fetch`,r?.reason),r?.credentials===`include`){if(typeof document>`u`)throw Error(`fetch with credentials needs the FKN extension, which only exists in window realms`);return t.W(e,r).then(d)}return f()?t.W(e,{...r,credentials:`omit`}).then(d):o.t()?o.a(e,r):a.t(e,r)},m=e.t({ATTACH_FRAME_EVENT_KEY:()=>t.i,BACKGROUND_STOPPED:()=>s,CATEGORIES:()=>t.w,EXTENSION_ABI:()=>5,ExtensionOperationUnsupportedError:()=>t.ct,ExtensionOutdatedError:()=>t.lt,FORGEABLE_HEADERS:()=>t.Q,FrameWindowBlockedError:()=>t.g,FrameWindowRefusedError:()=>t._,LOCATOR_DENIED:()=>t.A,LOCATOR_ERROR:()=>t.F,LOCATOR_INVALID:()=>t.L,LOCATOR_UNSUPPORTED:()=>t.D,MAX_REASON_LENGTH:()=>100,PERMISSION_DENIED:()=>t.t,REQUIRED_EXTENSION_ABI:()=>0,TimeoutError:()=>t.E,assertAttachableFrameUrl:()=>t.x,assertFetchableUrl:()=>t.U,assertForgeableHeaders:()=>t.$,assertLockdownApplicable:()=>t.S,assertOneCookieIdentity:()=>t.et,attachFrame:()=>t.a,attachFramePermission:()=>t.v,available:()=>f,box:()=>t.pt,cookies:()=>t.V,createFrame:()=>t.y,createVideoElementHandle:()=>t.mt,events:()=>t.nt,extension:()=>t.nt,fetch:()=>t.W,fetchCredentialedPermission:()=>t.G,fetchLocalPermission:()=>t.K,fetchPermission:()=>t.q,gotoPermission:()=>t.b,handleRevivableModules:()=>t.ft,hasForgedCookie:()=>t.tt,isBackgroundStopped:()=>c,isBlockedFetchUrl:()=>t.J,isBlockedFrameUrl:()=>t.C,isExtensionExposed:()=>t.rt,isLocalNetworkUrl:()=>t.Y,isLocatorDenied:()=>t.I,isLocatorInvalid:()=>t.M,isLocatorUnsupported:()=>t.O,isPermissionDenied:()=>t.n,isTerminalError:()=>t.P,isType:()=>t.ht,modifyRequestHeadersPermission:()=>t.R,permissions:()=>t.r,promptInstall:()=>l,readCookiePermission:()=>t.H,readExtensionHandshake:()=>t.it,removeRequestHeaderRule:()=>t.z,revive:()=>t.gt,setMissingExtensionHandler:()=>t.at,setRequestHeaderRule:()=>t.B,supportsOperation:()=>t.dt,type:()=>t._t,waitForExtensionExposure:()=>t.ot});Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return m}});
@@ -1,14 +1,15 @@
1
- import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
2
- import { $ as t, A as n, B as r, C as i, D as a, E as o, F as s, G as c, H as l, I as u, J as ee, K as te, L as ne, M as re, O as ie, P as ae, Q as oe, R as d, S as f, U as p, V as m, W as h, Y as g, Z as _, _ as v, _t as y, a as b, at as x, b as S, ct as C, d as w, dt as T, et as E, ft as D, g as O, gt as k, ht as A, i as j, it as M, lt as N, mt as P, n as se, nt as F, ot as I, pt as L, q as R, r as z, rt as B, t as V, tt as H, v as U, w as W, x as G, y as K, z as ce } from "./lib-BrsqpUkv.js";
3
- import { o as le, p as ue } from "./api-Di2Ff3jS.js";
1
+ import { t as e } from "./rolldown-runtime-CGnMp29N.js";
2
+ import { $ as t, A as n, B as r, C as i, D as a, E as o, F as s, G as c, H as l, I as u, J as ee, K as te, L as ne, M as re, O as ie, P as ae, Q as oe, R as d, S as f, U as p, V as m, W as h, Y as g, Z as _, _ as v, _t as y, a as b, at as x, b as S, ct as C, d as w, dt as T, et as E, ft as D, g as O, gt as k, ht as A, i as j, it as M, lt as N, mt as P, n as se, nt as F, ot as I, pt as L, q as R, r as z, rt as B, t as V, tt as H, v as U, w as W, x as G, y as K, z as ce } from "./lib-CtJaID_y.js";
3
+ import { r as le } from "./broker-frame-vjSpBa8d.js";
4
+ import { o as ue } from "./api-DRglK7ft.js";
4
5
  import { RELAY_HEADER as de } from "./contract.js";
5
- import { t as fe } from "./proxy-tsVhjcl-.js";
6
- import { available as q, fetch as pe } from "./desktop.js";
7
- //#region ../web-extension/lib/utils/background-stopped.js
6
+ import { t as fe } from "./proxy-BBAQxJmP.js";
7
+ import { a as q, t as pe } from "./desktop-xTT7ciGX.js";
8
+ // ../web-extension/lib/utils/background-stopped.js
8
9
  var J = "BackgroundStoppedError", Y = (e) => w(e) && e.name === "BackgroundStoppedError", X = async (e) => {
9
10
  if (_("promptInstall", e), typeof window > "u") return !1;
10
11
  if (B()) return !0;
11
- let t = await le, n = null, r = new Promise((e) => {
12
+ let t = await ue, n = null, r = new Promise((e) => {
12
13
  n = () => {
13
14
  B() && e(!0);
14
15
  }, F.addEventListener("statuschange", n);
@@ -18,22 +19,21 @@ var J = "BackgroundStoppedError", Y = (e) => w(e) && e.name === "BackgroundStopp
18
19
  x(() => (Z ||= X().then(() => void 0).finally(() => {
19
20
  Z = null;
20
21
  }), Z));
21
- //#endregion
22
- //#region src/auto.ts
22
+ // src/auto.ts
23
23
  var Q = (e) => {
24
24
  try {
25
25
  e.headers.delete(de);
26
26
  } catch {}
27
27
  return e;
28
28
  }, $ = () => typeof document < "u" && B(), me = async (e, t) => {
29
- if (ue(e), _("fetch", t?.reason), t?.credentials === "include") {
29
+ if (le(e), _("fetch", t?.reason), t?.credentials === "include") {
30
30
  if (typeof document > "u") throw Error("fetch with credentials needs the FKN extension, which only exists in window realms");
31
31
  return h(e, t).then(Q);
32
32
  }
33
33
  return $() ? h(e, {
34
34
  ...t,
35
35
  credentials: "omit"
36
- }).then(Q) : q() ? pe(e, t) : fe(e, t);
36
+ }).then(Q) : pe() ? q(e, t) : fe(e, t);
37
37
  }, he = /* @__PURE__ */ e({
38
38
  ATTACH_FRAME_EVENT_KEY: () => j,
39
39
  BACKGROUND_STOPPED: () => J,
@@ -97,5 +97,4 @@ var Q = (e) => {
97
97
  type: () => y,
98
98
  waitForExtensionExposure: () => I
99
99
  });
100
- //#endregion
101
100
  export { J as a, X as i, me as n, Y as o, $ as r, he as t };