@volter/tabnode 0.5.19 → 0.5.20

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.
@@ -19014,16 +19014,30 @@ nodePath.parse;
19014
19014
  nodePath.format;
19015
19015
  nodePath.toNamespacedPath;
19016
19016
  nodePath.matchesGlob;
19017
+ function loopback(host) {
19018
+ const bare = host.startsWith("[") && host.endsWith("]") ? host.slice(1, -1) : host;
19019
+ const name = bare.toLowerCase();
19020
+ return name === "" || name === "localhost" || name === "::1" || name.startsWith("127.");
19021
+ }
19017
19022
  function createTlsModule(require2) {
19018
19023
  const NetSocket = require2 ? require2("net").Socket : lazyExport("net", "Socket");
19019
- const Events = require2 ? require2("events").EventEmitter : EventEmitter;
19024
+ const netServer = () => (require2 ? require2("net") : nodeLibInternalRequire("net")).Server;
19020
19025
  class TLSSocket2 extends NetSocket {
19021
19026
  constructor(_socket, _options3) {
19022
19027
  super({ allowHalfOpen: false });
19023
19028
  __publicField(this, "authorized", false);
19024
19029
  __publicField(this, "encrypted", true);
19025
19030
  }
19026
- connect(..._args) {
19031
+ connect(...args) {
19032
+ const options = args[0];
19033
+ const host = String((options == null ? void 0 : options.host) ?? (options == null ? void 0 : options.hostname) ?? "localhost");
19034
+ if (options && typeof options === "object" && options.socket === void 0 && loopback(host)) {
19035
+ this.once("connect", () => {
19036
+ this.authorized = true;
19037
+ this.emit("secureConnect");
19038
+ });
19039
+ return NetSocket.prototype.connect.call(this, { port: options.port, host });
19040
+ }
19027
19041
  this.connecting = true;
19028
19042
  queueMicrotask(() => queueMicrotask(() => this.destroy(Object.assign(
19029
19043
  new Error("TLS transport is unavailable in this runtime; HTTPS requires an admitted HTTP transport."),
@@ -19046,34 +19060,53 @@ function createTlsModule(require2) {
19046
19060
  return false;
19047
19061
  }
19048
19062
  }
19049
- class Server2 extends Events {
19050
- constructor(_options3, _connectionListener) {
19051
- super();
19063
+ let chained = false;
19064
+ const Server2 = function TLSServer(options, secureConnectionListener) {
19065
+ if (!(this instanceof Server2)) return new Server2(options, secureConnectionListener);
19066
+ const NetServer = netServer();
19067
+ if (!chained) {
19068
+ Object.setPrototypeOf(Server2.prototype, NetServer.prototype);
19069
+ Object.setPrototypeOf(Server2, NetServer);
19070
+ chained = true;
19052
19071
  }
19053
- listen(..._args) {
19054
- return this;
19055
- }
19056
- close(_callback3) {
19057
- return this;
19058
- }
19059
- address() {
19060
- return null;
19072
+ if (typeof options === "function") {
19073
+ secureConnectionListener = options;
19074
+ options = {};
19061
19075
  }
19076
+ NetServer.call(this, options ?? {}, function secure(socket) {
19077
+ socket.encrypted = true;
19078
+ socket.authorized = false;
19079
+ this.emit("secureConnection", socket);
19080
+ });
19081
+ if (secureConnectionListener) this.on("secureConnection", secureConnectionListener);
19082
+ return this;
19083
+ };
19084
+ Object.assign(Server2.prototype, {
19085
+ addContext(_hostname, _context) {
19086
+ },
19062
19087
  getTicketKeys() {
19063
19088
  return (require2 ? require2("buffer").Buffer : Buffer).from("");
19064
- }
19089
+ },
19065
19090
  setTicketKeys(_keys) {
19066
- }
19091
+ },
19067
19092
  setSecureContext(_options3) {
19068
19093
  }
19094
+ });
19095
+ function createServer2(options, secureConnectionListener) {
19096
+ return new Server2(options, secureConnectionListener);
19069
19097
  }
19070
- function createServer2(_options3, _connectionListener) {
19071
- return new Server2(_options3, _connectionListener);
19072
- }
19073
- function connect2(_options3, _callback3) {
19098
+ function connect2(...args) {
19099
+ const options = {};
19100
+ let callback;
19101
+ for (const arg of args) {
19102
+ if (typeof arg === "function") callback = arg;
19103
+ else if (typeof arg === "number" || typeof arg === "string" && options.port === void 0 && /^\d+$/u.test(arg)) options.port = arg;
19104
+ else if (typeof arg === "string") options.host = arg;
19105
+ else if (arg && typeof arg === "object") Object.assign(options, arg);
19106
+ }
19074
19107
  const socket = new TLSSocket2();
19075
- if (_callback3) socket.once("secureConnect", _callback3);
19076
- return socket.connect();
19108
+ if (callback) socket.once("secureConnect", callback);
19109
+ return socket.connect(options);
19077
19110
  }
19078
19111
  const createSecureContext2 = (_options3) => ({});
19079
19112
  const getCiphers2 = () => ["TLS_AES_256_GCM_SHA384", "TLS_AES_128_GCM_SHA256"];
@@ -21103,10 +21136,17 @@ var implementation$1 = function bind2(that) {
21103
21136
  var implementation = implementation$1;
21104
21137
  var functionBind = Function.prototype.bind || implementation;
21105
21138
  var functionCall = Function.prototype.call;
21106
- var functionApply = Function.prototype.apply;
21139
+ var functionApply;
21140
+ var hasRequiredFunctionApply;
21141
+ function requireFunctionApply() {
21142
+ if (hasRequiredFunctionApply) return functionApply;
21143
+ hasRequiredFunctionApply = 1;
21144
+ functionApply = Function.prototype.apply;
21145
+ return functionApply;
21146
+ }
21107
21147
  var reflectApply = typeof Reflect !== "undefined" && Reflect && Reflect.apply;
21108
21148
  var bind$2 = functionBind;
21109
- var $apply$1 = functionApply;
21149
+ var $apply$1 = requireFunctionApply();
21110
21150
  var $call$2 = functionCall;
21111
21151
  var $reflectApply = reflectApply;
21112
21152
  var actualApply = $reflectApply || bind$2.call($call$2, $apply$1);
@@ -21226,7 +21266,7 @@ var hasSymbols = requireHasSymbols()();
21226
21266
  var getProto = requireGetProto();
21227
21267
  var $ObjectGPO = requireObject_getPrototypeOf();
21228
21268
  var $ReflectGPO = requireReflect_getPrototypeOf();
21229
- var $apply = functionApply;
21269
+ var $apply = requireFunctionApply();
21230
21270
  var $call = functionCall;
21231
21271
  var needsEval = {};
21232
21272
  var TypedArray = typeof Uint8Array === "undefined" || !getProto ? undefined$1 : getProto(Uint8Array);
@@ -21867,7 +21907,7 @@ function requireApplyBind() {
21867
21907
  if (hasRequiredApplyBind) return applyBind;
21868
21908
  hasRequiredApplyBind = 1;
21869
21909
  var bind3 = functionBind;
21870
- var $apply2 = functionApply;
21910
+ var $apply2 = requireFunctionApply();
21871
21911
  var actualApply$1 = actualApply;
21872
21912
  applyBind = function applyBind2() {
21873
21913
  return actualApply$1(bind3, $apply2, arguments);
package/dist/index.mjs CHANGED
@@ -19190,16 +19190,30 @@ const path = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty
19190
19190
  toNamespacedPath,
19191
19191
  win32
19192
19192
  }, Symbol.toStringTag, { value: "Module" }));
19193
+ function loopback(host2) {
19194
+ const bare = host2.startsWith("[") && host2.endsWith("]") ? host2.slice(1, -1) : host2;
19195
+ const name = bare.toLowerCase();
19196
+ return name === "" || name === "localhost" || name === "::1" || name.startsWith("127.");
19197
+ }
19193
19198
  function createTlsModule(require2) {
19194
19199
  const NetSocket = require2 ? require2("net").Socket : lazyExport("net", "Socket");
19195
- const Events = require2 ? require2("events").EventEmitter : EventEmitter;
19200
+ const netServer = () => (require2 ? require2("net") : nodeLibInternalRequire("net")).Server;
19196
19201
  class TLSSocket2 extends NetSocket {
19197
19202
  constructor(_socket, _options2) {
19198
19203
  super({ allowHalfOpen: false });
19199
19204
  __publicField(this, "authorized", false);
19200
19205
  __publicField(this, "encrypted", true);
19201
19206
  }
19202
- connect(..._args) {
19207
+ connect(...args) {
19208
+ const options = args[0];
19209
+ const host2 = String((options == null ? void 0 : options.host) ?? (options == null ? void 0 : options.hostname) ?? "localhost");
19210
+ if (options && typeof options === "object" && options.socket === void 0 && loopback(host2)) {
19211
+ this.once("connect", () => {
19212
+ this.authorized = true;
19213
+ this.emit("secureConnect");
19214
+ });
19215
+ return NetSocket.prototype.connect.call(this, { port: options.port, host: host2 });
19216
+ }
19203
19217
  this.connecting = true;
19204
19218
  queueMicrotask(() => queueMicrotask(() => this.destroy(Object.assign(
19205
19219
  new Error("TLS transport is unavailable in this runtime; HTTPS requires an admitted HTTP transport."),
@@ -19222,34 +19236,53 @@ function createTlsModule(require2) {
19222
19236
  return false;
19223
19237
  }
19224
19238
  }
19225
- class Server2 extends Events {
19226
- constructor(_options2, _connectionListener) {
19227
- super();
19239
+ let chained = false;
19240
+ const Server2 = function TLSServer(options, secureConnectionListener) {
19241
+ if (!(this instanceof Server2)) return new Server2(options, secureConnectionListener);
19242
+ const NetServer = netServer();
19243
+ if (!chained) {
19244
+ Object.setPrototypeOf(Server2.prototype, NetServer.prototype);
19245
+ Object.setPrototypeOf(Server2, NetServer);
19246
+ chained = true;
19228
19247
  }
19229
- listen(..._args) {
19230
- return this;
19231
- }
19232
- close(_callback3) {
19233
- return this;
19234
- }
19235
- address() {
19236
- return null;
19248
+ if (typeof options === "function") {
19249
+ secureConnectionListener = options;
19250
+ options = {};
19237
19251
  }
19252
+ NetServer.call(this, options ?? {}, function secure(socket) {
19253
+ socket.encrypted = true;
19254
+ socket.authorized = false;
19255
+ this.emit("secureConnection", socket);
19256
+ });
19257
+ if (secureConnectionListener) this.on("secureConnection", secureConnectionListener);
19258
+ return this;
19259
+ };
19260
+ Object.assign(Server2.prototype, {
19261
+ addContext(_hostname, _context) {
19262
+ },
19238
19263
  getTicketKeys() {
19239
19264
  return (require2 ? require2("buffer").Buffer : Buffer).from("");
19240
- }
19265
+ },
19241
19266
  setTicketKeys(_keys) {
19242
- }
19267
+ },
19243
19268
  setSecureContext(_options2) {
19244
19269
  }
19270
+ });
19271
+ function createServer2(options, secureConnectionListener) {
19272
+ return new Server2(options, secureConnectionListener);
19245
19273
  }
19246
- function createServer2(_options2, _connectionListener) {
19247
- return new Server2(_options2, _connectionListener);
19248
- }
19249
- function connect2(_options2, _callback3) {
19274
+ function connect2(...args) {
19275
+ const options = {};
19276
+ let callback;
19277
+ for (const arg of args) {
19278
+ if (typeof arg === "function") callback = arg;
19279
+ else if (typeof arg === "number" || typeof arg === "string" && options.port === void 0 && /^\d+$/u.test(arg)) options.port = arg;
19280
+ else if (typeof arg === "string") options.host = arg;
19281
+ else if (arg && typeof arg === "object") Object.assign(options, arg);
19282
+ }
19250
19283
  const socket = new TLSSocket2();
19251
- if (_callback3) socket.once("secureConnect", _callback3);
19252
- return socket.connect();
19284
+ if (callback) socket.once("secureConnect", callback);
19285
+ return socket.connect(options);
19253
19286
  }
19254
19287
  const createSecureContext2 = (_options2) => ({});
19255
19288
  const getCiphers2 = () => ["TLS_AES_256_GCM_SHA384", "TLS_AES_128_GCM_SHA256"];
@@ -21279,10 +21312,17 @@ var implementation$1 = function bind2(that) {
21279
21312
  var implementation = implementation$1;
21280
21313
  var functionBind = Function.prototype.bind || implementation;
21281
21314
  var functionCall = Function.prototype.call;
21282
- var functionApply = Function.prototype.apply;
21315
+ var functionApply;
21316
+ var hasRequiredFunctionApply;
21317
+ function requireFunctionApply() {
21318
+ if (hasRequiredFunctionApply) return functionApply;
21319
+ hasRequiredFunctionApply = 1;
21320
+ functionApply = Function.prototype.apply;
21321
+ return functionApply;
21322
+ }
21283
21323
  var reflectApply = typeof Reflect !== "undefined" && Reflect && Reflect.apply;
21284
21324
  var bind$2 = functionBind;
21285
- var $apply$1 = functionApply;
21325
+ var $apply$1 = requireFunctionApply();
21286
21326
  var $call$2 = functionCall;
21287
21327
  var $reflectApply = reflectApply;
21288
21328
  var actualApply = $reflectApply || bind$2.call($call$2, $apply$1);
@@ -21402,7 +21442,7 @@ var hasSymbols = requireHasSymbols()();
21402
21442
  var getProto = requireGetProto();
21403
21443
  var $ObjectGPO = requireObject_getPrototypeOf();
21404
21444
  var $ReflectGPO = requireReflect_getPrototypeOf();
21405
- var $apply = functionApply;
21445
+ var $apply = requireFunctionApply();
21406
21446
  var $call = functionCall;
21407
21447
  var needsEval = {};
21408
21448
  var TypedArray = typeof Uint8Array === "undefined" || !getProto ? undefined$1 : getProto(Uint8Array);
@@ -22043,7 +22083,7 @@ function requireApplyBind() {
22043
22083
  if (hasRequiredApplyBind) return applyBind;
22044
22084
  hasRequiredApplyBind = 1;
22045
22085
  var bind3 = functionBind;
22046
- var $apply2 = functionApply;
22086
+ var $apply2 = requireFunctionApply();
22047
22087
  var actualApply$1 = actualApply;
22048
22088
  applyBind = function applyBind2() {
22049
22089
  return actualApply$1(bind3, $apply2, arguments);
@@ -39787,7 +39827,7 @@ class WorkerRuntime {
39787
39827
  this.worker = new Worker(
39788
39828
  new URL(
39789
39829
  /* @vite-ignore */
39790
- "/assets/runtime-worker-ChOZScpd.js",
39830
+ "/assets/runtime-worker-IRKbkQwk.js",
39791
39831
  import.meta.url
39792
39832
  ),
39793
39833
  { type: "module" }
@@ -40016,7 +40056,8 @@ function installHttpClientTransport(factory, transportOptions = {}) {
40016
40056
  const connect2 = function(options, callback) {
40017
40057
  var _a2;
40018
40058
  const host2 = String(options.hostname ?? options.host ?? "localhost").toLowerCase();
40019
- if (protocol === "http:" && (local(host2) || options.socketPath) && !(local(host2) && !options.socketPath && ((_a2 = transportOptions.hostPorts) == null ? void 0 : _a2.call(transportOptions).has(Number(options.port ?? 80))))) {
40059
+ const hostPort = local(host2) && !options.socketPath && ((_a2 = transportOptions.hostPorts) == null ? void 0 : _a2.call(transportOptions).has(Number(options.port ?? (protocol === "https:" ? 443 : 80))));
40060
+ if (!hostPort && (protocol === "http:" && (local(host2) || options.socketPath) || protocol === "https:" && local(host2) && !options.socketPath)) {
40020
40061
  return original.call(this, options, callback);
40021
40062
  }
40022
40063
  try {
@@ -1,75 +1,43 @@
1
1
  /**
2
- * tls shim - TLS/SSL is not available in browser
3
- * No TLS transport is installed. A connection must fail asynchronously rather
4
- * than pretending to connect and leaving Node's HTTPS client waiting forever.
2
+ * tls: a tab's loopback carries no wire to protect. A TLS server listens on
3
+ * the engine's loopback as a net server does and hands its connections on as
4
+ * secure; a TLS connect to a loopback port pairs with that listener the same
5
+ * way. Bytes cross unencrypted because nothing lies between the two ends, and
6
+ * the browser holds TLS wherever there is a wire: a page reaches a guest
7
+ * server through the sandbox origin, and a request to another host goes out
8
+ * through the page's HTTP transport. A TLS connect to any other host fails
9
+ * asynchronously, rather than pretending to connect and leaving Node's HTTPS
10
+ * client waiting forever.
5
11
  */
6
- /** Native TLS refusal keeps the requesting graph's Socket identity. */
12
+ import type { Socket } from '../node-lib/net-module';
13
+ import type { EventEmitter } from '../node-lib/events-module';
14
+ /** A TLS server as Node's module exposes it: constructed with or without `new`. */
15
+ export interface TlsServer extends EventEmitter {
16
+ listen(...args: unknown[]): this;
17
+ close(callback?: (err?: Error) => void): this;
18
+ address(): {
19
+ port: number;
20
+ family: string;
21
+ address: string;
22
+ } | string | null;
23
+ addContext(hostname: string, context: unknown): void;
24
+ getTicketKeys(): Buffer;
25
+ setTicketKeys(keys: Buffer): void;
26
+ setSecureContext(options: unknown): void;
27
+ }
28
+ export interface TlsServerConstructor {
29
+ new (options?: unknown, secureConnectionListener?: (socket: Socket) => void): TlsServer;
30
+ (options?: unknown, secureConnectionListener?: (socket: Socket) => void): TlsServer;
31
+ readonly prototype: TlsServer;
32
+ }
33
+ /** Each graph's TLS keeps that graph's Socket and Server identity. */
7
34
  export declare function createTlsModule(require?: (name: string) => any): {
8
35
  TLSSocket: {
9
36
  new (_socket?: unknown, _options?: unknown): {
10
37
  [key: string]: unknown;
11
38
  authorized: boolean;
12
39
  encrypted: boolean;
13
- connect(..._args: unknown[]): /*elided*/ any;
14
- getPeerCertificate(_detailed?: boolean): object;
15
- getCipher(): {
16
- name: string;
17
- version: string;
18
- } | null;
19
- getProtocol(): string | null;
20
- setServername(_name: string): void;
21
- renegotiate(_options: unknown, _callback: (err: Error | null) => void): boolean;
22
- connecting: boolean;
23
- pending: boolean;
24
- readyState: string;
25
- bufferSize: number | undefined;
26
- bytesRead: number;
27
- bytesWritten: number | undefined;
28
- localAddress: string | undefined;
29
- localPort: number | undefined;
30
- localFamily: string | undefined;
31
- remoteAddress: string | undefined;
32
- remotePort: number | undefined;
33
- remoteFamily: string | undefined;
34
- timeout?: number;
35
- server: import("../node-lib/net-module").Server | null;
36
- _server: import("../node-lib/net-module").Server | null;
37
- _handle: import("../node-lib/binding/stream_wrap").LibuvStreamWrap | null;
38
- address(): import("../node-lib/net-module").AddressInfo | Record<string, never>;
39
- setTimeout(timeout: number, callback?: (() => void) | undefined): /*elided*/ any;
40
- setNoDelay(enable?: boolean): /*elided*/ any;
41
- setKeepAlive(enable?: boolean, initialDelay?: number): /*elided*/ any;
42
- resetAndDestroy(): /*elided*/ any;
43
- destroySoon(): void;
44
- ref(): /*elided*/ any;
45
- unref(): /*elided*/ any;
46
- cork(): void;
47
- uncork(): void;
48
- push(chunk: unknown, encoding?: string): boolean;
49
- read(size?: number): string | Uint8Array | null;
50
- pause(): /*elided*/ any;
51
- resume(): /*elided*/ any;
52
- destroy(error?: Error): /*elided*/ any;
53
- setEncoding(encoding: string): /*elided*/ any;
54
- pipe(destination: unknown, options?: unknown): unknown;
55
- on(event: string, listener: (...args: never[]) => void): /*elided*/ any;
56
- once(event: string, listener: (...args: never[]) => void): /*elided*/ any;
57
- emit(event: string, ...args: unknown[]): boolean;
58
- readable: boolean;
59
- readableEnded: boolean;
60
- destroyed: boolean;
61
- isTTY?: boolean;
62
- write(chunk: unknown, encoding?: unknown, callback?: unknown): boolean;
63
- end(chunk?: unknown, encoding?: unknown, callback?: unknown): /*elided*/ any;
64
- writable: boolean;
65
- };
66
- };
67
- Server: {
68
- new (_options?: unknown, _connectionListener?: (socket: {
69
- [key: string]: unknown;
70
- authorized: boolean;
71
- encrypted: boolean;
72
- connect(..._args: unknown[]): /*elided*/ any;
40
+ connect(...args: unknown[]): /*elided*/ any;
73
41
  getPeerCertificate(_detailed?: boolean): object;
74
42
  getCipher(): {
75
43
  name: string;
@@ -121,122 +89,15 @@ export declare function createTlsModule(require?: (name: string) => any): {
121
89
  write(chunk: unknown, encoding?: unknown, callback?: unknown): boolean;
122
90
  end(chunk?: unknown, encoding?: unknown, callback?: unknown): /*elided*/ any;
123
91
  writable: boolean;
124
- }) => void): {
125
- listen(..._args: unknown[]): /*elided*/ any;
126
- close(_callback?: (err?: Error) => void): /*elided*/ any;
127
- address(): {
128
- port: number;
129
- family: string;
130
- address: string;
131
- } | string | null;
132
- getTicketKeys(): Buffer;
133
- setTicketKeys(_keys: Buffer): void;
134
- setSecureContext(_options: unknown): void;
135
- addListener(event: string | symbol, listener: import("../node-lib/events-module").EventListener): /*elided*/ any;
136
- on(event: string | symbol, listener: import("../node-lib/events-module").EventListener): /*elided*/ any;
137
- once(event: string | symbol, listener: import("../node-lib/events-module").EventListener): /*elided*/ any;
138
- removeListener(event: string | symbol, listener: import("../node-lib/events-module").EventListener): /*elided*/ any;
139
- off(event: string | symbol, listener: import("../node-lib/events-module").EventListener): /*elided*/ any;
140
- removeAllListeners(event?: string | symbol): /*elided*/ any;
141
- setMaxListeners(n: number): /*elided*/ any;
142
- getMaxListeners(): number;
143
- listeners(event: string | symbol): Array<import("../node-lib/events-module").EventListener>;
144
- rawListeners(event: string | symbol): Array<import("../node-lib/events-module").EventListener>;
145
- emit(event: string | symbol, ...args: unknown[]): boolean;
146
- listenerCount(event: string | symbol, listener?: import("../node-lib/events-module").EventListener): number;
147
- prependListener(event: string | symbol, listener: import("../node-lib/events-module").EventListener): /*elided*/ any;
148
- prependOnceListener(event: string | symbol, listener: import("../node-lib/events-module").EventListener): /*elided*/ any;
149
- eventNames(): Array<string | symbol>;
150
92
  };
151
93
  };
152
- createServer: (_options?: unknown, _connectionListener?: (socket: {
153
- [key: string]: unknown;
154
- authorized: boolean;
155
- encrypted: boolean;
156
- connect(..._args: unknown[]): /*elided*/ any;
157
- getPeerCertificate(_detailed?: boolean): object;
158
- getCipher(): {
159
- name: string;
160
- version: string;
161
- } | null;
162
- getProtocol(): string | null;
163
- setServername(_name: string): void;
164
- renegotiate(_options: unknown, _callback: (err: Error | null) => void): boolean;
165
- connecting: boolean;
166
- pending: boolean;
167
- readyState: string;
168
- bufferSize: number | undefined;
169
- bytesRead: number;
170
- bytesWritten: number | undefined;
171
- localAddress: string | undefined;
172
- localPort: number | undefined;
173
- localFamily: string | undefined;
174
- remoteAddress: string | undefined;
175
- remotePort: number | undefined;
176
- remoteFamily: string | undefined;
177
- timeout?: number;
178
- server: import("../node-lib/net-module").Server | null;
179
- _server: import("../node-lib/net-module").Server | null;
180
- _handle: import("../node-lib/binding/stream_wrap").LibuvStreamWrap | null;
181
- address(): import("../node-lib/net-module").AddressInfo | Record<string, never>;
182
- setTimeout(timeout: number, callback?: (() => void) | undefined): /*elided*/ any;
183
- setNoDelay(enable?: boolean): /*elided*/ any;
184
- setKeepAlive(enable?: boolean, initialDelay?: number): /*elided*/ any;
185
- resetAndDestroy(): /*elided*/ any;
186
- destroySoon(): void;
187
- ref(): /*elided*/ any;
188
- unref(): /*elided*/ any;
189
- cork(): void;
190
- uncork(): void;
191
- push(chunk: unknown, encoding?: string): boolean;
192
- read(size?: number): string | Uint8Array | null;
193
- pause(): /*elided*/ any;
194
- resume(): /*elided*/ any;
195
- destroy(error?: Error): /*elided*/ any;
196
- setEncoding(encoding: string): /*elided*/ any;
197
- pipe(destination: unknown, options?: unknown): unknown;
198
- on(event: string, listener: (...args: never[]) => void): /*elided*/ any;
199
- once(event: string, listener: (...args: never[]) => void): /*elided*/ any;
200
- emit(event: string, ...args: unknown[]): boolean;
201
- readable: boolean;
202
- readableEnded: boolean;
203
- destroyed: boolean;
204
- isTTY?: boolean;
205
- write(chunk: unknown, encoding?: unknown, callback?: unknown): boolean;
206
- end(chunk?: unknown, encoding?: unknown, callback?: unknown): /*elided*/ any;
207
- writable: boolean;
208
- }) => void) => {
209
- listen(..._args: unknown[]): /*elided*/ any;
210
- close(_callback?: (err?: Error) => void): /*elided*/ any;
211
- address(): {
212
- port: number;
213
- family: string;
214
- address: string;
215
- } | string | null;
216
- getTicketKeys(): Buffer;
217
- setTicketKeys(_keys: Buffer): void;
218
- setSecureContext(_options: unknown): void;
219
- addListener(event: string | symbol, listener: import("../node-lib/events-module").EventListener): /*elided*/ any;
220
- on(event: string | symbol, listener: import("../node-lib/events-module").EventListener): /*elided*/ any;
221
- once(event: string | symbol, listener: import("../node-lib/events-module").EventListener): /*elided*/ any;
222
- removeListener(event: string | symbol, listener: import("../node-lib/events-module").EventListener): /*elided*/ any;
223
- off(event: string | symbol, listener: import("../node-lib/events-module").EventListener): /*elided*/ any;
224
- removeAllListeners(event?: string | symbol): /*elided*/ any;
225
- setMaxListeners(n: number): /*elided*/ any;
226
- getMaxListeners(): number;
227
- listeners(event: string | symbol): Array<import("../node-lib/events-module").EventListener>;
228
- rawListeners(event: string | symbol): Array<import("../node-lib/events-module").EventListener>;
229
- emit(event: string | symbol, ...args: unknown[]): boolean;
230
- listenerCount(event: string | symbol, listener?: import("../node-lib/events-module").EventListener): number;
231
- prependListener(event: string | symbol, listener: import("../node-lib/events-module").EventListener): /*elided*/ any;
232
- prependOnceListener(event: string | symbol, listener: import("../node-lib/events-module").EventListener): /*elided*/ any;
233
- eventNames(): Array<string | symbol>;
234
- };
235
- connect: (_options: unknown, _callback?: () => void) => {
94
+ Server: TlsServerConstructor;
95
+ createServer: (options?: unknown, secureConnectionListener?: (socket: Socket) => void) => TlsServer;
96
+ connect: (...args: unknown[]) => {
236
97
  [key: string]: unknown;
237
98
  authorized: boolean;
238
99
  encrypted: boolean;
239
- connect(..._args: unknown[]): /*elided*/ any;
100
+ connect(...args: unknown[]): /*elided*/ any;
240
101
  getPeerCertificate(_detailed?: boolean): object;
241
102
  getCipher(): {
242
103
  name: string;
@@ -303,7 +164,7 @@ declare const tls: {
303
164
  [key: string]: unknown;
304
165
  authorized: boolean;
305
166
  encrypted: boolean;
306
- connect(..._args: unknown[]): /*elided*/ any;
167
+ connect(...args: unknown[]): /*elided*/ any;
307
168
  getPeerCertificate(_detailed?: boolean): object;
308
169
  getCipher(): {
309
170
  name: string;
@@ -357,179 +218,13 @@ declare const tls: {
357
218
  writable: boolean;
358
219
  };
359
220
  };
360
- Server: {
361
- new (_options?: unknown, _connectionListener?: (socket: {
362
- [key: string]: unknown;
363
- authorized: boolean;
364
- encrypted: boolean;
365
- connect(..._args: unknown[]): /*elided*/ any;
366
- getPeerCertificate(_detailed?: boolean): object;
367
- getCipher(): {
368
- name: string;
369
- version: string;
370
- } | null;
371
- getProtocol(): string | null;
372
- setServername(_name: string): void;
373
- renegotiate(_options: unknown, _callback: (err: Error | null) => void): boolean;
374
- connecting: boolean;
375
- pending: boolean;
376
- readyState: string;
377
- bufferSize: number | undefined;
378
- bytesRead: number;
379
- bytesWritten: number | undefined;
380
- localAddress: string | undefined;
381
- localPort: number | undefined;
382
- localFamily: string | undefined;
383
- remoteAddress: string | undefined;
384
- remotePort: number | undefined;
385
- remoteFamily: string | undefined;
386
- timeout?: number;
387
- server: import("../node-lib/net-module").Server | null;
388
- _server: import("../node-lib/net-module").Server | null;
389
- _handle: import("../node-lib/binding/stream_wrap").LibuvStreamWrap | null;
390
- address(): import("../node-lib/net-module").AddressInfo | Record<string, never>;
391
- setTimeout(timeout: number, callback?: (() => void) | undefined): /*elided*/ any;
392
- setNoDelay(enable?: boolean): /*elided*/ any;
393
- setKeepAlive(enable?: boolean, initialDelay?: number): /*elided*/ any;
394
- resetAndDestroy(): /*elided*/ any;
395
- destroySoon(): void;
396
- ref(): /*elided*/ any;
397
- unref(): /*elided*/ any;
398
- cork(): void;
399
- uncork(): void;
400
- push(chunk: unknown, encoding?: string): boolean;
401
- read(size?: number): string | Uint8Array | null;
402
- pause(): /*elided*/ any;
403
- resume(): /*elided*/ any;
404
- destroy(error?: Error): /*elided*/ any;
405
- setEncoding(encoding: string): /*elided*/ any;
406
- pipe(destination: unknown, options?: unknown): unknown;
407
- on(event: string, listener: (...args: never[]) => void): /*elided*/ any;
408
- once(event: string, listener: (...args: never[]) => void): /*elided*/ any;
409
- emit(event: string, ...args: unknown[]): boolean;
410
- readable: boolean;
411
- readableEnded: boolean;
412
- destroyed: boolean;
413
- isTTY?: boolean;
414
- write(chunk: unknown, encoding?: unknown, callback?: unknown): boolean;
415
- end(chunk?: unknown, encoding?: unknown, callback?: unknown): /*elided*/ any;
416
- writable: boolean;
417
- }) => void): {
418
- listen(..._args: unknown[]): /*elided*/ any;
419
- close(_callback?: (err?: Error) => void): /*elided*/ any;
420
- address(): {
421
- port: number;
422
- family: string;
423
- address: string;
424
- } | string | null;
425
- getTicketKeys(): Buffer;
426
- setTicketKeys(_keys: Buffer): void;
427
- setSecureContext(_options: unknown): void;
428
- addListener(event: string | symbol, listener: import("../node-lib/events-module").EventListener): /*elided*/ any;
429
- on(event: string | symbol, listener: import("../node-lib/events-module").EventListener): /*elided*/ any;
430
- once(event: string | symbol, listener: import("../node-lib/events-module").EventListener): /*elided*/ any;
431
- removeListener(event: string | symbol, listener: import("../node-lib/events-module").EventListener): /*elided*/ any;
432
- off(event: string | symbol, listener: import("../node-lib/events-module").EventListener): /*elided*/ any;
433
- removeAllListeners(event?: string | symbol): /*elided*/ any;
434
- setMaxListeners(n: number): /*elided*/ any;
435
- getMaxListeners(): number;
436
- listeners(event: string | symbol): Array<import("../node-lib/events-module").EventListener>;
437
- rawListeners(event: string | symbol): Array<import("../node-lib/events-module").EventListener>;
438
- emit(event: string | symbol, ...args: unknown[]): boolean;
439
- listenerCount(event: string | symbol, listener?: import("../node-lib/events-module").EventListener): number;
440
- prependListener(event: string | symbol, listener: import("../node-lib/events-module").EventListener): /*elided*/ any;
441
- prependOnceListener(event: string | symbol, listener: import("../node-lib/events-module").EventListener): /*elided*/ any;
442
- eventNames(): Array<string | symbol>;
443
- };
444
- };
445
- createServer: (_options?: unknown, _connectionListener?: (socket: {
446
- [key: string]: unknown;
447
- authorized: boolean;
448
- encrypted: boolean;
449
- connect(..._args: unknown[]): /*elided*/ any;
450
- getPeerCertificate(_detailed?: boolean): object;
451
- getCipher(): {
452
- name: string;
453
- version: string;
454
- } | null;
455
- getProtocol(): string | null;
456
- setServername(_name: string): void;
457
- renegotiate(_options: unknown, _callback: (err: Error | null) => void): boolean;
458
- connecting: boolean;
459
- pending: boolean;
460
- readyState: string;
461
- bufferSize: number | undefined;
462
- bytesRead: number;
463
- bytesWritten: number | undefined;
464
- localAddress: string | undefined;
465
- localPort: number | undefined;
466
- localFamily: string | undefined;
467
- remoteAddress: string | undefined;
468
- remotePort: number | undefined;
469
- remoteFamily: string | undefined;
470
- timeout?: number;
471
- server: import("../node-lib/net-module").Server | null;
472
- _server: import("../node-lib/net-module").Server | null;
473
- _handle: import("../node-lib/binding/stream_wrap").LibuvStreamWrap | null;
474
- address(): import("../node-lib/net-module").AddressInfo | Record<string, never>;
475
- setTimeout(timeout: number, callback?: (() => void) | undefined): /*elided*/ any;
476
- setNoDelay(enable?: boolean): /*elided*/ any;
477
- setKeepAlive(enable?: boolean, initialDelay?: number): /*elided*/ any;
478
- resetAndDestroy(): /*elided*/ any;
479
- destroySoon(): void;
480
- ref(): /*elided*/ any;
481
- unref(): /*elided*/ any;
482
- cork(): void;
483
- uncork(): void;
484
- push(chunk: unknown, encoding?: string): boolean;
485
- read(size?: number): string | Uint8Array | null;
486
- pause(): /*elided*/ any;
487
- resume(): /*elided*/ any;
488
- destroy(error?: Error): /*elided*/ any;
489
- setEncoding(encoding: string): /*elided*/ any;
490
- pipe(destination: unknown, options?: unknown): unknown;
491
- on(event: string, listener: (...args: never[]) => void): /*elided*/ any;
492
- once(event: string, listener: (...args: never[]) => void): /*elided*/ any;
493
- emit(event: string, ...args: unknown[]): boolean;
494
- readable: boolean;
495
- readableEnded: boolean;
496
- destroyed: boolean;
497
- isTTY?: boolean;
498
- write(chunk: unknown, encoding?: unknown, callback?: unknown): boolean;
499
- end(chunk?: unknown, encoding?: unknown, callback?: unknown): /*elided*/ any;
500
- writable: boolean;
501
- }) => void) => {
502
- listen(..._args: unknown[]): /*elided*/ any;
503
- close(_callback?: (err?: Error) => void): /*elided*/ any;
504
- address(): {
505
- port: number;
506
- family: string;
507
- address: string;
508
- } | string | null;
509
- getTicketKeys(): Buffer;
510
- setTicketKeys(_keys: Buffer): void;
511
- setSecureContext(_options: unknown): void;
512
- addListener(event: string | symbol, listener: import("../node-lib/events-module").EventListener): /*elided*/ any;
513
- on(event: string | symbol, listener: import("../node-lib/events-module").EventListener): /*elided*/ any;
514
- once(event: string | symbol, listener: import("../node-lib/events-module").EventListener): /*elided*/ any;
515
- removeListener(event: string | symbol, listener: import("../node-lib/events-module").EventListener): /*elided*/ any;
516
- off(event: string | symbol, listener: import("../node-lib/events-module").EventListener): /*elided*/ any;
517
- removeAllListeners(event?: string | symbol): /*elided*/ any;
518
- setMaxListeners(n: number): /*elided*/ any;
519
- getMaxListeners(): number;
520
- listeners(event: string | symbol): Array<import("../node-lib/events-module").EventListener>;
521
- rawListeners(event: string | symbol): Array<import("../node-lib/events-module").EventListener>;
522
- emit(event: string | symbol, ...args: unknown[]): boolean;
523
- listenerCount(event: string | symbol, listener?: import("../node-lib/events-module").EventListener): number;
524
- prependListener(event: string | symbol, listener: import("../node-lib/events-module").EventListener): /*elided*/ any;
525
- prependOnceListener(event: string | symbol, listener: import("../node-lib/events-module").EventListener): /*elided*/ any;
526
- eventNames(): Array<string | symbol>;
527
- };
528
- connect: (_options: unknown, _callback?: () => void) => {
221
+ Server: TlsServerConstructor;
222
+ createServer: (options?: unknown, secureConnectionListener?: (socket: Socket) => void) => TlsServer;
223
+ connect: (...args: unknown[]) => {
529
224
  [key: string]: unknown;
530
225
  authorized: boolean;
531
226
  encrypted: boolean;
532
- connect(..._args: unknown[]): /*elided*/ any;
227
+ connect(...args: unknown[]): /*elided*/ any;
533
228
  getPeerCertificate(_detailed?: boolean): object;
534
229
  getCipher(): {
535
230
  name: string;
@@ -595,7 +290,7 @@ export declare const TLSSocket: {
595
290
  [key: string]: unknown;
596
291
  authorized: boolean;
597
292
  encrypted: boolean;
598
- connect(..._args: unknown[]): /*elided*/ any;
293
+ connect(...args: unknown[]): /*elided*/ any;
599
294
  getPeerCertificate(_detailed?: boolean): object;
600
295
  getCipher(): {
601
296
  name: string;
@@ -648,177 +343,11 @@ export declare const TLSSocket: {
648
343
  end(chunk?: unknown, encoding?: unknown, callback?: unknown): /*elided*/ any;
649
344
  writable: boolean;
650
345
  };
651
- }, Server: {
652
- new (_options?: unknown, _connectionListener?: (socket: {
653
- [key: string]: unknown;
654
- authorized: boolean;
655
- encrypted: boolean;
656
- connect(..._args: unknown[]): /*elided*/ any;
657
- getPeerCertificate(_detailed?: boolean): object;
658
- getCipher(): {
659
- name: string;
660
- version: string;
661
- } | null;
662
- getProtocol(): string | null;
663
- setServername(_name: string): void;
664
- renegotiate(_options: unknown, _callback: (err: Error | null) => void): boolean;
665
- connecting: boolean;
666
- pending: boolean;
667
- readyState: string;
668
- bufferSize: number | undefined;
669
- bytesRead: number;
670
- bytesWritten: number | undefined;
671
- localAddress: string | undefined;
672
- localPort: number | undefined;
673
- localFamily: string | undefined;
674
- remoteAddress: string | undefined;
675
- remotePort: number | undefined;
676
- remoteFamily: string | undefined;
677
- timeout?: number;
678
- server: import("../node-lib/net-module").Server | null;
679
- _server: import("../node-lib/net-module").Server | null;
680
- _handle: import("../node-lib/binding/stream_wrap").LibuvStreamWrap | null;
681
- address(): import("../node-lib/net-module").AddressInfo | Record<string, never>;
682
- setTimeout(timeout: number, callback?: (() => void) | undefined): /*elided*/ any;
683
- setNoDelay(enable?: boolean): /*elided*/ any;
684
- setKeepAlive(enable?: boolean, initialDelay?: number): /*elided*/ any;
685
- resetAndDestroy(): /*elided*/ any;
686
- destroySoon(): void;
687
- ref(): /*elided*/ any;
688
- unref(): /*elided*/ any;
689
- cork(): void;
690
- uncork(): void;
691
- push(chunk: unknown, encoding?: string): boolean;
692
- read(size?: number): string | Uint8Array | null;
693
- pause(): /*elided*/ any;
694
- resume(): /*elided*/ any;
695
- destroy(error?: Error): /*elided*/ any;
696
- setEncoding(encoding: string): /*elided*/ any;
697
- pipe(destination: unknown, options?: unknown): unknown;
698
- on(event: string, listener: (...args: never[]) => void): /*elided*/ any;
699
- once(event: string, listener: (...args: never[]) => void): /*elided*/ any;
700
- emit(event: string, ...args: unknown[]): boolean;
701
- readable: boolean;
702
- readableEnded: boolean;
703
- destroyed: boolean;
704
- isTTY?: boolean;
705
- write(chunk: unknown, encoding?: unknown, callback?: unknown): boolean;
706
- end(chunk?: unknown, encoding?: unknown, callback?: unknown): /*elided*/ any;
707
- writable: boolean;
708
- }) => void): {
709
- listen(..._args: unknown[]): /*elided*/ any;
710
- close(_callback?: (err?: Error) => void): /*elided*/ any;
711
- address(): {
712
- port: number;
713
- family: string;
714
- address: string;
715
- } | string | null;
716
- getTicketKeys(): Buffer;
717
- setTicketKeys(_keys: Buffer): void;
718
- setSecureContext(_options: unknown): void;
719
- addListener(event: string | symbol, listener: import("../node-lib/events-module").EventListener): /*elided*/ any;
720
- on(event: string | symbol, listener: import("../node-lib/events-module").EventListener): /*elided*/ any;
721
- once(event: string | symbol, listener: import("../node-lib/events-module").EventListener): /*elided*/ any;
722
- removeListener(event: string | symbol, listener: import("../node-lib/events-module").EventListener): /*elided*/ any;
723
- off(event: string | symbol, listener: import("../node-lib/events-module").EventListener): /*elided*/ any;
724
- removeAllListeners(event?: string | symbol): /*elided*/ any;
725
- setMaxListeners(n: number): /*elided*/ any;
726
- getMaxListeners(): number;
727
- listeners(event: string | symbol): Array<import("../node-lib/events-module").EventListener>;
728
- rawListeners(event: string | symbol): Array<import("../node-lib/events-module").EventListener>;
729
- emit(event: string | symbol, ...args: unknown[]): boolean;
730
- listenerCount(event: string | symbol, listener?: import("../node-lib/events-module").EventListener): number;
731
- prependListener(event: string | symbol, listener: import("../node-lib/events-module").EventListener): /*elided*/ any;
732
- prependOnceListener(event: string | symbol, listener: import("../node-lib/events-module").EventListener): /*elided*/ any;
733
- eventNames(): Array<string | symbol>;
734
- };
735
- }, createServer: (_options?: unknown, _connectionListener?: (socket: {
736
- [key: string]: unknown;
737
- authorized: boolean;
738
- encrypted: boolean;
739
- connect(..._args: unknown[]): /*elided*/ any;
740
- getPeerCertificate(_detailed?: boolean): object;
741
- getCipher(): {
742
- name: string;
743
- version: string;
744
- } | null;
745
- getProtocol(): string | null;
746
- setServername(_name: string): void;
747
- renegotiate(_options: unknown, _callback: (err: Error | null) => void): boolean;
748
- connecting: boolean;
749
- pending: boolean;
750
- readyState: string;
751
- bufferSize: number | undefined;
752
- bytesRead: number;
753
- bytesWritten: number | undefined;
754
- localAddress: string | undefined;
755
- localPort: number | undefined;
756
- localFamily: string | undefined;
757
- remoteAddress: string | undefined;
758
- remotePort: number | undefined;
759
- remoteFamily: string | undefined;
760
- timeout?: number;
761
- server: import("../node-lib/net-module").Server | null;
762
- _server: import("../node-lib/net-module").Server | null;
763
- _handle: import("../node-lib/binding/stream_wrap").LibuvStreamWrap | null;
764
- address(): import("../node-lib/net-module").AddressInfo | Record<string, never>;
765
- setTimeout(timeout: number, callback?: (() => void) | undefined): /*elided*/ any;
766
- setNoDelay(enable?: boolean): /*elided*/ any;
767
- setKeepAlive(enable?: boolean, initialDelay?: number): /*elided*/ any;
768
- resetAndDestroy(): /*elided*/ any;
769
- destroySoon(): void;
770
- ref(): /*elided*/ any;
771
- unref(): /*elided*/ any;
772
- cork(): void;
773
- uncork(): void;
774
- push(chunk: unknown, encoding?: string): boolean;
775
- read(size?: number): string | Uint8Array | null;
776
- pause(): /*elided*/ any;
777
- resume(): /*elided*/ any;
778
- destroy(error?: Error): /*elided*/ any;
779
- setEncoding(encoding: string): /*elided*/ any;
780
- pipe(destination: unknown, options?: unknown): unknown;
781
- on(event: string, listener: (...args: never[]) => void): /*elided*/ any;
782
- once(event: string, listener: (...args: never[]) => void): /*elided*/ any;
783
- emit(event: string, ...args: unknown[]): boolean;
784
- readable: boolean;
785
- readableEnded: boolean;
786
- destroyed: boolean;
787
- isTTY?: boolean;
788
- write(chunk: unknown, encoding?: unknown, callback?: unknown): boolean;
789
- end(chunk?: unknown, encoding?: unknown, callback?: unknown): /*elided*/ any;
790
- writable: boolean;
791
- }) => void) => {
792
- listen(..._args: unknown[]): /*elided*/ any;
793
- close(_callback?: (err?: Error) => void): /*elided*/ any;
794
- address(): {
795
- port: number;
796
- family: string;
797
- address: string;
798
- } | string | null;
799
- getTicketKeys(): Buffer;
800
- setTicketKeys(_keys: Buffer): void;
801
- setSecureContext(_options: unknown): void;
802
- addListener(event: string | symbol, listener: import("../node-lib/events-module").EventListener): /*elided*/ any;
803
- on(event: string | symbol, listener: import("../node-lib/events-module").EventListener): /*elided*/ any;
804
- once(event: string | symbol, listener: import("../node-lib/events-module").EventListener): /*elided*/ any;
805
- removeListener(event: string | symbol, listener: import("../node-lib/events-module").EventListener): /*elided*/ any;
806
- off(event: string | symbol, listener: import("../node-lib/events-module").EventListener): /*elided*/ any;
807
- removeAllListeners(event?: string | symbol): /*elided*/ any;
808
- setMaxListeners(n: number): /*elided*/ any;
809
- getMaxListeners(): number;
810
- listeners(event: string | symbol): Array<import("../node-lib/events-module").EventListener>;
811
- rawListeners(event: string | symbol): Array<import("../node-lib/events-module").EventListener>;
812
- emit(event: string | symbol, ...args: unknown[]): boolean;
813
- listenerCount(event: string | symbol, listener?: import("../node-lib/events-module").EventListener): number;
814
- prependListener(event: string | symbol, listener: import("../node-lib/events-module").EventListener): /*elided*/ any;
815
- prependOnceListener(event: string | symbol, listener: import("../node-lib/events-module").EventListener): /*elided*/ any;
816
- eventNames(): Array<string | symbol>;
817
- }, connect: (_options: unknown, _callback?: () => void) => {
346
+ }, Server: TlsServerConstructor, createServer: (options?: unknown, secureConnectionListener?: (socket: Socket) => void) => TlsServer, connect: (...args: unknown[]) => {
818
347
  [key: string]: unknown;
819
348
  authorized: boolean;
820
349
  encrypted: boolean;
821
- connect(..._args: unknown[]): /*elided*/ any;
350
+ connect(...args: unknown[]): /*elided*/ any;
822
351
  getPeerCertificate(_detailed?: boolean): object;
823
352
  getCipher(): {
824
353
  name: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volter/tabnode",
3
- "version": "0.5.19",
3
+ "version": "0.5.20",
4
4
  "description": "Node's own library, in a browser tab.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -2,7 +2,8 @@
2
2
  * Node's Agent connection seam over a host HTTP exchange. Both sides of the
3
3
  * internal connection use Node's unmodified HTTP library: it parses requests,
4
4
  * generates responses and owns ClientRequest/IncomingMessage and backpressure.
5
- * No TLS socket or network metadata is fabricated. The host admits the target
5
+ * No TLS socket or network metadata is fabricated for a remote host; a
6
+ * loopback port stays the engine's own network, plain or TLS. The host admits the target
6
7
  * and capabilities before sending, and returns one response without retries.
7
8
  */
8
9
  import { httpModule, httpsModule } from './node-lib/http-module';
@@ -54,9 +55,12 @@ export function installHttpClientTransport(factory: HttpClientTransportFactory,
54
55
  const original = prototype.createConnection;
55
56
  const connect = function(this: unknown, options: Record<string, any>, callback: (error: Error | null, socket?: unknown) => void): unknown {
56
57
  const host = String(options.hostname ?? options.host ?? 'localhost').toLowerCase();
57
- // Plain local HTTP is the engine's existing virtual network, except a port the host serves itself.
58
- if (protocol === 'http:' && (local(host) || options.socketPath)
59
- && !(local(host) && !options.socketPath && transportOptions.hostPorts?.().has(Number(options.port ?? 80)))) {
58
+ // Local HTTP, plain or TLS, is the engine's existing virtual network,
59
+ // except a port the host serves itself: a TLS connect to loopback pairs
60
+ // with the guest's listener, as `tls` does, with no wire to protect.
61
+ const hostPort = local(host) && !options.socketPath
62
+ && transportOptions.hostPorts?.().has(Number(options.port ?? (protocol === 'https:' ? 443 : 80)));
63
+ if (!hostPort && ((protocol === 'http:' && (local(host) || options.socketPath)) || (protocol === 'https:' && local(host) && !options.socketPath))) {
60
64
  return original.call(this, options, callback);
61
65
  }
62
66
  try {
package/src/shims/tls.ts CHANGED
@@ -1,21 +1,51 @@
1
1
  /**
2
- * tls shim - TLS/SSL is not available in browser
3
- * No TLS transport is installed. A connection must fail asynchronously rather
4
- * than pretending to connect and leaving Node's HTTPS client waiting forever.
2
+ * tls: a tab's loopback carries no wire to protect. A TLS server listens on
3
+ * the engine's loopback as a net server does and hands its connections on as
4
+ * secure; a TLS connect to a loopback port pairs with that listener the same
5
+ * way. Bytes cross unencrypted because nothing lies between the two ends, and
6
+ * the browser holds TLS wherever there is a wire: a page reaches a guest
7
+ * server through the sandbox origin, and a request to another host goes out
8
+ * through the page's HTTP transport. A TLS connect to any other host fails
9
+ * asynchronously, rather than pretending to connect and leaving Node's HTTPS
10
+ * client waiting forever.
5
11
  */
6
12
 
7
- import { EventEmitter } from '../node-lib/events-module';
8
13
  import { lazyExport } from '../node-lib/lazy';
14
+ import { nodeLibInternalRequire } from '../node-lib/load';
9
15
  import type { Socket } from '../node-lib/net-module';
16
+ import type { EventEmitter } from '../node-lib/events-module';
17
+
18
+ /** A TLS server as Node's module exposes it: constructed with or without `new`. */
19
+ export interface TlsServer extends EventEmitter {
20
+ listen(...args: unknown[]): this;
21
+ close(callback?: (err?: Error) => void): this;
22
+ address(): { port: number; family: string; address: string } | string | null;
23
+ addContext(hostname: string, context: unknown): void;
24
+ getTicketKeys(): Buffer;
25
+ setTicketKeys(keys: Buffer): void;
26
+ setSecureContext(options: unknown): void;
27
+ }
28
+ export interface TlsServerConstructor {
29
+ new (options?: unknown, secureConnectionListener?: (socket: Socket) => void): TlsServer;
30
+ (options?: unknown, secureConnectionListener?: (socket: Socket) => void): TlsServer;
31
+ readonly prototype: TlsServer;
32
+ }
33
+
34
+ /** The names a loopback connect reaches, as the engine's tcp_wrap answers them. */
35
+ function loopback(host: string): boolean {
36
+ const bare = host.startsWith('[') && host.endsWith(']') ? host.slice(1, -1) : host;
37
+ const name = bare.toLowerCase();
38
+ return name === '' || name === 'localhost' || name === '::1' || name.startsWith('127.');
39
+ }
10
40
 
11
41
  // Keep the ordinary stream lifecycle (error, close, destroy) from Node's own
12
42
  // Socket. Resolve it lazily, like the other builtin classes, to avoid a loader
13
43
  // cycle while the engine is being imported.
14
- /** Native TLS refusal keeps the requesting graph's Socket identity. */
44
+ /** Each graph's TLS keeps that graph's Socket and Server identity. */
15
45
  export function createTlsModule(require?: (name: string) => any) {
16
46
  const NetSocket = require ? require('net').Socket as new (options?: object) => Socket
17
47
  : lazyExport<new (options?: object) => Socket>('net', 'Socket');
18
- const Events = require ? require('events').EventEmitter as typeof EventEmitter : EventEmitter;
48
+ const netServer = (): any => (require ? require('net') : nodeLibInternalRequire('net') as any).Server;
19
49
 
20
50
  class TLSSocket extends NetSocket {
21
51
  authorized = false;
@@ -25,7 +55,19 @@ class TLSSocket extends NetSocket {
25
55
  super({ allowHalfOpen: false });
26
56
  }
27
57
 
28
- connect(..._args: unknown[]): this {
58
+ connect(...args: unknown[]): this {
59
+ const options = args[0] as { port?: unknown; host?: unknown; hostname?: unknown; socket?: unknown } | undefined;
60
+ const host = String(options?.host ?? options?.hostname ?? 'localhost');
61
+ if (options && typeof options === 'object' && options.socket === undefined && loopback(host)) {
62
+ // The peer is a listener of this engine, or nothing: a refused port
63
+ // fails as a net connect does.
64
+ this.once('connect', () => {
65
+ this.authorized = true;
66
+ this.emit('secureConnect');
67
+ });
68
+ return (NetSocket.prototype as unknown as { connect: (this: TLSSocket, options: object) => TLSSocket })
69
+ .connect.call(this, { port: options.port, host }) as this;
70
+ }
29
71
  this.connecting = true;
30
72
  // Never inherit a plain TCP connect while advertising an encrypted socket.
31
73
  // Agent assigns its socket on nextTick after connect returns, so failure
@@ -56,40 +98,57 @@ class TLSSocket extends NetSocket {
56
98
  }
57
99
  }
58
100
 
59
- class Server extends Events {
60
- constructor(_options?: unknown, _connectionListener?: (socket: TLSSocket) => void) {
61
- super();
62
- }
63
-
64
- listen(..._args: unknown[]): this {
65
- return this;
66
- }
67
-
68
- close(_callback?: (err?: Error) => void): this {
69
- return this;
101
+ // A function constructor, as Node's: its own `https.js` builds an https.Server
102
+ // by calling `tls.Server` on the instance, which a class refuses. It is a net
103
+ // server, chained to the graph's `net.Server` when the first one is built.
104
+ let chained = false;
105
+ const Server = function TLSServer(this: TlsServer, options?: unknown, secureConnectionListener?: (socket: Socket) => void): TlsServer {
106
+ if (!(this instanceof Server)) return new Server(options, secureConnectionListener);
107
+ const NetServer = netServer();
108
+ if (!chained) {
109
+ Object.setPrototypeOf(Server.prototype, NetServer.prototype);
110
+ Object.setPrototypeOf(Server, NetServer);
111
+ chained = true;
70
112
  }
71
-
72
- address(): { port: number; family: string; address: string } | string | null {
73
- return null;
113
+ if (typeof options === 'function') {
114
+ secureConnectionListener = options as (socket: Socket) => void;
115
+ options = {};
74
116
  }
75
-
76
- getTicketKeys(): Buffer {
117
+ NetServer.call(this, options ?? {}, function secure(this: TlsServer, socket: Socket & { encrypted?: boolean; authorized?: boolean }) {
118
+ socket.encrypted = true;
119
+ socket.authorized = false;
120
+ this.emit('secureConnection', socket);
121
+ });
122
+ if (secureConnectionListener) this.on('secureConnection', secureConnectionListener);
123
+ return this;
124
+ } as unknown as TlsServerConstructor;
125
+
126
+ Object.assign(Server.prototype, {
127
+ addContext(_hostname: string, _context: unknown) {},
128
+ getTicketKeys() {
77
129
  return (require ? require('buffer').Buffer : Buffer).from('');
78
- }
130
+ },
131
+ setTicketKeys(_keys: Buffer) {},
132
+ setSecureContext(_options: unknown) {},
133
+ });
79
134
 
80
- setTicketKeys(_keys: Buffer): void {}
81
-
82
- setSecureContext(_options: unknown): void {}
83
- }
84
-
85
- function createServer(_options?: unknown, _connectionListener?: (socket: TLSSocket) => void): Server {
86
- return new Server(_options, _connectionListener);
135
+ function createServer(options?: unknown, secureConnectionListener?: (socket: Socket) => void): TlsServer {
136
+ return new Server(options, secureConnectionListener);
87
137
  }
88
138
 
89
- function connect(_options: unknown, _callback?: () => void): TLSSocket {
139
+ // tls.connect(options[, callback]) and tls.connect(port[, host][, options][, callback]).
140
+ function connect(...args: unknown[]): TLSSocket {
141
+ const options: Record<string, unknown> = {};
142
+ let callback: (() => void) | undefined;
143
+ for (const arg of args) {
144
+ if (typeof arg === 'function') callback = arg as () => void;
145
+ else if (typeof arg === 'number' || (typeof arg === 'string' && options.port === undefined && /^\d+$/u.test(arg))) options.port = arg;
146
+ else if (typeof arg === 'string') options.host = arg;
147
+ else if (arg && typeof arg === 'object') Object.assign(options, arg);
148
+ }
90
149
  const socket = new TLSSocket();
91
- if (_callback) socket.once('secureConnect', _callback);
92
- return socket.connect();
150
+ if (callback) socket.once('secureConnect', callback);
151
+ return socket.connect(options);
93
152
  }
94
153
 
95
154
  const createSecureContext = (_options?: unknown) => ({});