@volter/tabnode 0.5.2 → 0.5.3

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.
@@ -17595,10 +17595,17 @@ var implementation$1 = function bind2(that) {
17595
17595
  var implementation = implementation$1;
17596
17596
  var functionBind = Function.prototype.bind || implementation;
17597
17597
  var functionCall = Function.prototype.call;
17598
- var functionApply = Function.prototype.apply;
17598
+ var functionApply;
17599
+ var hasRequiredFunctionApply;
17600
+ function requireFunctionApply() {
17601
+ if (hasRequiredFunctionApply) return functionApply;
17602
+ hasRequiredFunctionApply = 1;
17603
+ functionApply = Function.prototype.apply;
17604
+ return functionApply;
17605
+ }
17599
17606
  var reflectApply = typeof Reflect !== "undefined" && Reflect && Reflect.apply;
17600
17607
  var bind$2 = functionBind;
17601
- var $apply$1 = functionApply;
17608
+ var $apply$1 = requireFunctionApply();
17602
17609
  var $call$2 = functionCall;
17603
17610
  var $reflectApply = reflectApply;
17604
17611
  var actualApply = $reflectApply || bind$2.call($call$2, $apply$1);
@@ -17718,7 +17725,7 @@ var hasSymbols = requireHasSymbols()();
17718
17725
  var getProto = requireGetProto();
17719
17726
  var $ObjectGPO = requireObject_getPrototypeOf();
17720
17727
  var $ReflectGPO = requireReflect_getPrototypeOf();
17721
- var $apply = functionApply;
17728
+ var $apply = requireFunctionApply();
17722
17729
  var $call = functionCall;
17723
17730
  var needsEval = {};
17724
17731
  var TypedArray = typeof Uint8Array === "undefined" || !getProto ? undefined$1 : getProto(Uint8Array);
@@ -18359,7 +18366,7 @@ function requireApplyBind() {
18359
18366
  if (hasRequiredApplyBind) return applyBind;
18360
18367
  hasRequiredApplyBind = 1;
18361
18368
  var bind3 = functionBind;
18362
- var $apply2 = functionApply;
18369
+ var $apply2 = requireFunctionApply();
18363
18370
  var actualApply$1 = actualApply;
18364
18371
  applyBind = function applyBind2() {
18365
18372
  return actualApply$1(bind3, $apply2, arguments);
package/dist/index.mjs CHANGED
@@ -17762,10 +17762,17 @@ var implementation$1 = function bind2(that) {
17762
17762
  var implementation = implementation$1;
17763
17763
  var functionBind = Function.prototype.bind || implementation;
17764
17764
  var functionCall = Function.prototype.call;
17765
- var functionApply = Function.prototype.apply;
17765
+ var functionApply;
17766
+ var hasRequiredFunctionApply;
17767
+ function requireFunctionApply() {
17768
+ if (hasRequiredFunctionApply) return functionApply;
17769
+ hasRequiredFunctionApply = 1;
17770
+ functionApply = Function.prototype.apply;
17771
+ return functionApply;
17772
+ }
17766
17773
  var reflectApply = typeof Reflect !== "undefined" && Reflect && Reflect.apply;
17767
17774
  var bind$2 = functionBind;
17768
- var $apply$1 = functionApply;
17775
+ var $apply$1 = requireFunctionApply();
17769
17776
  var $call$2 = functionCall;
17770
17777
  var $reflectApply = reflectApply;
17771
17778
  var actualApply = $reflectApply || bind$2.call($call$2, $apply$1);
@@ -17885,7 +17892,7 @@ var hasSymbols = requireHasSymbols()();
17885
17892
  var getProto = requireGetProto();
17886
17893
  var $ObjectGPO = requireObject_getPrototypeOf();
17887
17894
  var $ReflectGPO = requireReflect_getPrototypeOf();
17888
- var $apply = functionApply;
17895
+ var $apply = requireFunctionApply();
17889
17896
  var $call = functionCall;
17890
17897
  var needsEval = {};
17891
17898
  var TypedArray = typeof Uint8Array === "undefined" || !getProto ? undefined$1 : getProto(Uint8Array);
@@ -18526,7 +18533,7 @@ function requireApplyBind() {
18526
18533
  if (hasRequiredApplyBind) return applyBind;
18527
18534
  hasRequiredApplyBind = 1;
18528
18535
  var bind3 = functionBind;
18529
- var $apply2 = functionApply;
18536
+ var $apply2 = requireFunctionApply();
18530
18537
  var actualApply$1 = actualApply;
18531
18538
  applyBind = function applyBind2() {
18532
18539
  return actualApply$1(bind3, $apply2, arguments);
@@ -35548,7 +35555,7 @@ class WorkerRuntime {
35548
35555
  this.worker = new Worker(
35549
35556
  new URL(
35550
35557
  /* @vite-ignore */
35551
- "/assets/runtime-worker-CqG62h2U.js",
35558
+ "/assets/runtime-worker-CfmZOVKz.js",
35552
35559
  import.meta.url
35553
35560
  ),
35554
35561
  { type: "module" }
@@ -37408,11 +37415,15 @@ function __substrateListenForUpgrades(bridge) {
37408
37415
  const key = uint8ToBase64(crypto.getRandomValues(new Uint8Array(16)));
37409
37416
  const protocols = Array.isArray(data2.protocols) ? data2.protocols : [];
37410
37417
  void __upgradeOverLoopback(port, "GET", url2.pathname + url2.search, {
37411
- Host: url2.host,
37418
+ // Host is the authority the client addressed, as an HTTP request's is
37419
+ Host: typeof data2.host === "string" && /^(?:\[[0-9a-f:.]+\]|[a-z0-9.-]+)(?::[0-9]{1,5})?$/iu.test(data2.host) ? data2.host : url2.host,
37412
37420
  Upgrade: "websocket",
37413
37421
  "Sec-WebSocket-Version": "13",
37414
37422
  "Sec-WebSocket-Key": key,
37415
- ...protocols.length ? { "Sec-WebSocket-Protocol": protocols.join(", ") } : {}
37423
+ ...protocols.length ? { "Sec-WebSocket-Protocol": protocols.join(", ") } : {},
37424
+ // A browser sends Origin on every WebSocket handshake, and a server's
37425
+ // check of it is how it refuses sockets from pages it did not serve.
37426
+ ...typeof data2.origin === "string" && /^https?:\/\/[^/]+$/u.test(data2.origin) ? { Origin: data2.origin } : {}
37416
37427
  }).then((result) => {
37417
37428
  if (result.statusCode !== 101 || !result.socket) {
37418
37429
  channel.postMessage({ type: "close", targetClient: data2.clientId, code: 1006, reason: "upgrade refused" });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volter/tabnode",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
4
4
  "description": "Node's own library, in a browser tab.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -123,6 +123,10 @@ interface UpgradeSignal {
123
123
  protocols?: string[];
124
124
  /** `"none"` asks for a byte pipe; anything else, or nothing, is a WebSocket. */
125
125
  framing?: "websocket" | "none";
126
+ /** The origin of the page that opened the socket, which a browser sends on every handshake. */
127
+ origin?: string;
128
+ /** The authority the client addressed, its handshake's Host; the engine's own URL names the port. */
129
+ host?: string;
126
130
  payload?: string | ArrayBuffer;
127
131
  code?: number;
128
132
  reason?: string;
@@ -348,11 +352,15 @@ function __substrateListenForUpgrades(bridge: ServerBridge): BroadcastChannel |
348
352
  // with the socket, which is what the real `ws` takes over. What comes
349
353
  // back here is the client's end of that same connection.
350
354
  void __upgradeOverLoopback(port, "GET", url2.pathname + url2.search, {
351
- Host: url2.host,
355
+ // Host is the authority the client addressed, as an HTTP request's is
356
+ Host: typeof data2.host === "string" && /^(?:\[[0-9a-f:.]+\]|[a-z0-9.-]+)(?::[0-9]{1,5})?$/iu.test(data2.host) ? data2.host : url2.host,
352
357
  Upgrade: "websocket",
353
358
  "Sec-WebSocket-Version": "13",
354
359
  "Sec-WebSocket-Key": key,
355
360
  ...(protocols.length ? { "Sec-WebSocket-Protocol": protocols.join(", ") } : {}),
361
+ // A browser sends Origin on every WebSocket handshake, and a server's
362
+ // check of it is how it refuses sockets from pages it did not serve.
363
+ ...(typeof data2.origin === "string" && /^https?:\/\/[^/]+$/u.test(data2.origin) ? { Origin: data2.origin } : {}),
356
364
  }).then((result) => {
357
365
  if (result.statusCode !== 101 || !result.socket) {
358
366
  channel.postMessage({ type: "close", targetClient: data2.clientId, code: 1006, reason: "upgrade refused" });