@php-wasm/web 1.0.29 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/index.cjs +21 -0
  2. package/index.cjs.map +1 -0
  3. package/index.js +666 -631
  4. package/index.js.map +1 -1
  5. package/lib/chunked-decoder.d.ts +8 -0
  6. package/lib/directory-handle-mount.d.ts +1 -1
  7. package/lib/get-php-loader-module.d.ts +1 -1
  8. package/lib/load-runtime.d.ts +4 -3
  9. package/lib/tcp-over-fetch-websocket.d.ts +32 -4
  10. package/lib/tls/1_2/types.d.ts +19 -17
  11. package/lib/tls/extensions/parse-extensions.d.ts +8 -4
  12. package/lib/tls/utils.d.ts +1 -1
  13. package/lib/with-icu-data.d.ts +2 -0
  14. package/package.json +28 -14
  15. package/php/asyncify/7_0_33/php_7_0.wasm +0 -0
  16. package/php/asyncify/7_1_30/php_7_1.wasm +0 -0
  17. package/php/asyncify/7_2_34/php_7_2.wasm +0 -0
  18. package/php/asyncify/7_3_33/php_7_3.wasm +0 -0
  19. package/php/asyncify/7_4_33/php_7_4.wasm +0 -0
  20. package/php/asyncify/8_0_30/php_8_0.wasm +0 -0
  21. package/php/asyncify/8_1_23/php_8_1.wasm +0 -0
  22. package/php/asyncify/8_2_10/php_8_2.wasm +0 -0
  23. package/php/asyncify/8_3_0/php_8_3.wasm +0 -0
  24. package/php/asyncify/8_4_0/php_8_4.wasm +0 -0
  25. package/php/asyncify/php_7_0.js +13 -39
  26. package/php/asyncify/php_7_1.js +13 -39
  27. package/php/asyncify/php_7_2.js +13 -39
  28. package/php/asyncify/php_7_3.js +13 -39
  29. package/php/asyncify/php_7_4.js +13 -39
  30. package/php/asyncify/php_8_0.js +13 -39
  31. package/php/asyncify/php_8_1.js +13 -39
  32. package/php/asyncify/php_8_2.js +13 -39
  33. package/php/asyncify/php_8_3.js +13 -39
  34. package/php/asyncify/php_8_4.js +13 -39
  35. package/php/jspi/7_0_33/php_7_0.wasm +0 -0
  36. package/php/jspi/7_1_30/php_7_1.wasm +0 -0
  37. package/php/jspi/7_2_34/php_7_2.wasm +0 -0
  38. package/php/jspi/7_3_33/php_7_3.wasm +0 -0
  39. package/php/jspi/7_4_33/php_7_4.wasm +0 -0
  40. package/php/jspi/8_0_30/php_8_0.wasm +0 -0
  41. package/php/jspi/8_1_23/php_8_1.wasm +0 -0
  42. package/php/jspi/8_2_10/php_8_2.wasm +0 -0
  43. package/php/jspi/8_3_0/php_8_3.wasm +0 -0
  44. package/php/jspi/8_4_0/php_8_4.wasm +0 -0
  45. package/php/jspi/php_7_0.js +13 -39
  46. package/php/jspi/php_7_1.js +13 -39
  47. package/php/jspi/php_7_2.js +13 -39
  48. package/php/jspi/php_7_3.js +13 -39
  49. package/php/jspi/php_7_4.js +13 -39
  50. package/php/jspi/php_8_0.js +13 -39
  51. package/php/jspi/php_8_1.js +13 -39
  52. package/php/jspi/php_8_2.js +13 -39
  53. package/php/jspi/php_8_3.js +13 -39
  54. package/php/jspi/php_8_4.js +13 -39
  55. package/shared/icudt74l.dat +0 -0
  56. package/shared/icudt74l.js +2 -0
package/index.js CHANGED
@@ -1,48 +1,48 @@
1
- import { PHPResponse as we, LatestSupportedPHPVersion as Le, loadPHPRuntime as me, FSHelpers as B, __private__dont__use as k } from "@php-wasm/universal";
1
+ import { PHPResponse as Le, LatestSupportedPHPVersion as me, FSHelpers as R, loadPHPRuntime as ge, __private__dont__use as q } from "@php-wasm/universal";
2
2
  import * as E from "comlink";
3
- import { jspi as ye } from "wasm-feature-detect";
4
- import { logger as R } from "@php-wasm/logger";
5
- import { cloneRequest as ge } from "@php-wasm/web-service-worker";
6
- import { Semaphore as Ke, joinPaths as se } from "@php-wasm/util";
7
- import { journalFSEvents as Ie } from "@php-wasm/fs-journal";
8
- function ct(n, e = void 0) {
9
- ie();
10
- const t = n instanceof Worker ? n : E.windowEndpoint(n, e), r = E.wrap(t), s = x(r);
11
- return new Proxy(s, {
12
- get: (i, _) => _ === "isConnected" ? async () => {
3
+ import { jspi as Ke } from "wasm-feature-detect";
4
+ import { logger as v } from "@php-wasm/logger";
5
+ import { teeRequest as Ie, cloneRequest as De } from "@php-wasm/web-service-worker";
6
+ import { Semaphore as We, joinPaths as oe, basename as Re } from "@php-wasm/util";
7
+ import { journalFSEvents as be } from "@php-wasm/fs-journal";
8
+ function pt(s, e = void 0) {
9
+ ce();
10
+ const t = s instanceof Worker ? s : E.windowEndpoint(s, e), r = E.wrap(t), n = j(r);
11
+ return new Proxy(n, {
12
+ get: (i, a) => a === "isConnected" ? async () => {
13
13
  for (; ; )
14
14
  try {
15
- await De(r.isConnected(), 200);
15
+ await Pe(r.isConnected(), 200);
16
16
  break;
17
17
  } catch {
18
18
  }
19
- } : r[_]
19
+ } : r[a]
20
20
  });
21
21
  }
22
- async function De(n, e) {
22
+ async function Pe(s, e) {
23
23
  return new Promise((t, r) => {
24
- setTimeout(r, e), n.then(t);
24
+ setTimeout(r, e), s.then(t);
25
25
  });
26
26
  }
27
- function St(n, e) {
28
- ie();
27
+ function wt(s, e) {
28
+ ce();
29
29
  const t = Promise.resolve();
30
- let r, s;
30
+ let r, n;
31
31
  const i = new Promise((c, S) => {
32
- r = c, s = S;
33
- }), _ = x(n), a = new Proxy(_, {
32
+ r = c, n = S;
33
+ }), a = j(s), _ = new Proxy(a, {
34
34
  get: (c, S) => S === "isConnected" ? () => t : S === "isReady" ? () => i : S in c ? c[S] : e == null ? void 0 : e[S]
35
35
  });
36
36
  return E.expose(
37
- a,
37
+ _,
38
38
  typeof window < "u" ? E.windowEndpoint(self.parent) : void 0
39
- ), [r, s, a];
39
+ ), [r, n, _];
40
40
  }
41
- let F = !1;
42
- function ie() {
43
- if (F)
41
+ let V = !1;
42
+ function ce() {
43
+ if (V)
44
44
  return;
45
- F = !0, E.transferHandlers.set("EVENT", {
45
+ V = !0, E.transferHandlers.set("EVENT", {
46
46
  canHandle: (t) => t instanceof CustomEvent,
47
47
  serialize: (t) => [
48
48
  {
@@ -52,10 +52,12 @@ function ie() {
52
52
  ],
53
53
  deserialize: (t) => t
54
54
  }), E.transferHandlers.set("FUNCTION", {
55
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
55
56
  canHandle: (t) => typeof t == "function",
57
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
56
58
  serialize(t) {
57
- const { port1: r, port2: s } = new MessageChannel();
58
- return E.expose(t, r), [s, [s]];
59
+ const { port1: r, port2: n } = new MessageChannel();
60
+ return E.expose(t, r), [n, [n]];
59
61
  },
60
62
  deserialize(t) {
61
63
  return t.start(), E.wrap(t);
@@ -66,23 +68,23 @@ function ie() {
66
68
  return [t.toRawData(), []];
67
69
  },
68
70
  deserialize(t) {
69
- return we.fromRawData(t);
71
+ return Le.fromRawData(t);
70
72
  }
71
73
  });
72
- const n = E.transferHandlers.get("throw"), e = n == null ? void 0 : n.serialize;
73
- n.serialize = ({ value: t }) => {
74
+ const s = E.transferHandlers.get("throw"), e = s == null ? void 0 : s.serialize;
75
+ s.serialize = ({ value: t }) => {
74
76
  const r = e({ value: t });
75
77
  return t.response && (r[0].value.response = t.response), t.source && (r[0].value.source = t.source), r;
76
78
  };
77
79
  }
78
- function x(n) {
79
- return new Proxy(n, {
80
+ function j(s) {
81
+ return new Proxy(s, {
80
82
  get(e, t) {
81
83
  switch (typeof e[t]) {
82
84
  case "function":
83
85
  return (...r) => e[t](...r);
84
86
  case "object":
85
- return e[t] === null ? e[t] : x(e[t]);
87
+ return e[t] === null ? e[t] : j(e[t]);
86
88
  case "undefined":
87
89
  case "number":
88
90
  case "string":
@@ -93,9 +95,9 @@ function x(n) {
93
95
  }
94
96
  });
95
97
  }
96
- async function We(n = Le) {
97
- if (await ye())
98
- switch (n) {
98
+ async function Be(s = me) {
99
+ if (await Ke())
100
+ switch (s) {
99
101
  case "8.4":
100
102
  return await import("./php/jspi/php_8_4.js");
101
103
  case "8.3":
@@ -112,13 +114,9 @@ async function We(n = Le) {
112
114
  return await import("./php/jspi/php_7_3.js");
113
115
  case "7.2":
114
116
  return await import("./php/jspi/php_7_2.js");
115
- case "7.1":
116
- return await import("./php/jspi/php_7_1.js");
117
- case "7.0":
118
- return await import("./php/jspi/php_7_0.js");
119
117
  }
120
118
  else
121
- switch (n) {
119
+ switch (s) {
122
120
  case "8.4":
123
121
  return await import("./php/asyncify/php_8_4.js");
124
122
  case "8.3":
@@ -135,45 +133,41 @@ async function We(n = Le) {
135
133
  return await import("./php/asyncify/php_7_3.js");
136
134
  case "7.2":
137
135
  return await import("./php/asyncify/php_7_2.js");
138
- case "7.1":
139
- return await import("./php/asyncify/php_7_1.js");
140
- case "7.0":
141
- return await import("./php/asyncify/php_7_0.js");
142
136
  }
143
- throw new Error(`Unsupported PHP version ${n}`);
137
+ throw new Error(`Unsupported PHP version ${s}`);
144
138
  }
145
- function p(n) {
146
- return Object.fromEntries(Object.entries(n).map(([e, t]) => [t, e]));
139
+ function p(s) {
140
+ return Object.fromEntries(Object.entries(s).map(([e, t]) => [t, e]));
147
141
  }
148
- function h(n) {
142
+ function u(s) {
149
143
  let e = 0;
150
- n.forEach((s) => e += s.length);
144
+ s.forEach((n) => e += n.length);
151
145
  const t = new Uint8Array(e);
152
146
  let r = 0;
153
- return n.forEach((s) => {
154
- t.set(s, r), r += s.length;
147
+ return s.forEach((n) => {
148
+ t.set(n, r), r += n.length;
155
149
  }), t;
156
150
  }
157
- function P(n) {
158
- return h(n.map((e) => new Uint8Array(e))).buffer;
151
+ function B(s) {
152
+ return u(s.map((e) => new Uint8Array(e))).buffer;
159
153
  }
160
- function I(n) {
161
- return new Uint8Array([n >> 8 & 255, n & 255]);
154
+ function I(s) {
155
+ return new Uint8Array([s >> 8 & 255, s & 255]);
162
156
  }
163
- function m(n) {
157
+ function y(s) {
164
158
  return new Uint8Array([
165
- n >> 16 & 255,
166
- n >> 8 & 255,
167
- n & 255
159
+ s >> 16 & 255,
160
+ s >> 8 & 255,
161
+ s & 255
168
162
  ]);
169
163
  }
170
- function G(n) {
164
+ function Y(s) {
171
165
  const e = new ArrayBuffer(8);
172
- return new DataView(e).setBigUint64(0, BigInt(n), !1), new Uint8Array(e);
166
+ return new DataView(e).setBigUint64(0, BigInt(s), !1), new Uint8Array(e);
173
167
  }
174
- class g {
168
+ class m {
175
169
  constructor(e) {
176
- this.buffer = e, this.offset = 0, this.view = new DataView(e);
170
+ this.offset = 0, this.buffer = e, this.view = new DataView(e);
177
171
  }
178
172
  readUint8() {
179
173
  const e = this.view.getUint8(this.offset);
@@ -195,7 +189,7 @@ class g {
195
189
  return this.offset >= this.buffer.byteLength;
196
190
  }
197
191
  }
198
- class v {
192
+ class M {
199
193
  constructor(e) {
200
194
  this.offset = 0, this.buffer = new ArrayBuffer(e), this.uint8Array = new Uint8Array(this.buffer), this.view = new DataView(this.buffer);
201
195
  }
@@ -266,33 +260,33 @@ const b = {
266
260
  key_share: 51,
267
261
  transparency_info: 52,
268
262
  connection_id: 54
269
- }, Re = p(b), _e = {
263
+ }, Ue = p(b), Se = {
270
264
  host_name: 0
271
- }, be = p(_e);
272
- class ae {
265
+ }, ve = p(Se);
266
+ class Ce {
273
267
  static decodeFromClient(e) {
274
268
  const t = new DataView(e.buffer);
275
269
  let r = 0;
276
- const s = t.getUint16(r);
270
+ const n = t.getUint16(r);
277
271
  r += 2;
278
272
  const i = [];
279
- for (; r < s + 2; ) {
280
- const _ = e[r];
273
+ for (; r < n + 2; ) {
274
+ const a = e[r];
281
275
  r += 1;
282
- const a = t.getUint16(r);
276
+ const _ = t.getUint16(r);
283
277
  r += 2;
284
- const c = e.slice(r, r + a);
285
- switch (r += a, _) {
286
- case _e.host_name:
278
+ const c = e.slice(r, r + _);
279
+ switch (r += _, a) {
280
+ case Se.host_name:
287
281
  i.push({
288
- name_type: be[_],
282
+ name_type: ve[a],
289
283
  name: {
290
284
  host_name: new TextDecoder().decode(c)
291
285
  }
292
286
  });
293
287
  break;
294
288
  default:
295
- throw new Error(`Unsupported name type ${_}`);
289
+ throw new Error(`Unsupported name type ${a}`);
296
290
  }
297
291
  }
298
292
  return { server_name_list: i };
@@ -313,11 +307,11 @@ class ae {
313
307
  throw new Error(
314
308
  "Encoding non-empty lists for ClientHello is not supported yet. Only empty lists meant for ServerHello are supported today."
315
309
  );
316
- const t = new v(4);
310
+ const t = new M(4);
317
311
  return t.writeUint16(b.server_name), t.writeUint16(0), t.uint8Array;
318
312
  }
319
313
  }
320
- const oe = {
314
+ const he = {
321
315
  TLS1_CK_PSK_WITH_RC4_128_SHA: 138,
322
316
  TLS1_CK_PSK_WITH_3DES_EDE_CBC_SHA: 139,
323
317
  TLS1_CK_PSK_WITH_AES_128_CBC_SHA: 140,
@@ -520,14 +514,14 @@ const oe = {
520
514
  TLS1_CK_ECDHE_PSK_WITH_CHACHA20_POLY1305: 52396,
521
515
  TLS1_CK_DHE_PSK_WITH_CHACHA20_POLY1305: 52397,
522
516
  TLS1_CK_RSA_PSK_WITH_CHACHA20_POLY1305: 52398
523
- }, j = p(oe), ce = {
517
+ }, Z = p(he), le = {
524
518
  secp256r1: 23,
525
519
  secp384r1: 24,
526
520
  secp521r1: 25,
527
521
  x25519: 29,
528
522
  x448: 30
529
- }, $ = p(ce);
530
- class Se {
523
+ }, J = p(le);
524
+ class Me {
531
525
  /**
532
526
  * +--------------------------------------------------+
533
527
  * | Payload Length [2B] |
@@ -544,12 +538,12 @@ class Se {
544
538
  * +--------------------------------------------------+
545
539
  */
546
540
  static decodeFromClient(e) {
547
- const t = new g(e.buffer);
541
+ const t = new m(e.buffer);
548
542
  t.readUint16();
549
543
  const r = [];
550
544
  for (; !t.isFinished(); ) {
551
- const s = t.readUint16();
552
- s in $ && r.push($[s]);
545
+ const n = t.readUint16();
546
+ n in J && r.push(J[n]);
553
547
  }
554
548
  return r;
555
549
  }
@@ -564,16 +558,16 @@ class Se {
564
558
  * +--------------------------------------------------+
565
559
  */
566
560
  static encodeForClient(e) {
567
- const t = new v(6);
568
- return t.writeUint16(b.supported_groups), t.writeUint16(2), t.writeUint16(ce[e]), t.uint8Array;
561
+ const t = new M(6);
562
+ return t.writeUint16(b.supported_groups), t.writeUint16(2), t.writeUint16(le[e]), t.uint8Array;
569
563
  }
570
564
  }
571
- const Ce = {
565
+ const Ae = {
572
566
  uncompressed: 0,
573
567
  ansiX962_compressed_prime: 1,
574
568
  ansiX962_compressed_char2: 2
575
- }, V = p(Ce);
576
- class le {
569
+ }, X = p(Ae);
570
+ class Ne {
577
571
  /**
578
572
  * +--------------------------------------------------+
579
573
  * | Payload Length [2B] |
@@ -590,12 +584,12 @@ class le {
590
584
  * +--------------------------------------------------+
591
585
  */
592
586
  static decodeFromClient(e) {
593
- const t = new g(e.buffer), r = t.readUint8(), s = [];
587
+ const t = new m(e.buffer), r = t.readUint8(), n = [];
594
588
  for (let i = 0; i < r; i++) {
595
- const _ = t.readUint8();
596
- _ in V && s.push(V[_]);
589
+ const a = t.readUint8();
590
+ a in X && n.push(X[a]);
597
591
  }
598
- return s;
592
+ return n;
599
593
  }
600
594
  /**
601
595
  * Encode the ec_point_formats extension
@@ -612,16 +606,16 @@ class le {
612
606
  * +--------------------------------------------------+
613
607
  */
614
608
  static encodeForClient(e) {
615
- const t = new v(6);
616
- return t.writeUint16(b.ec_point_formats), t.writeUint16(2), t.writeUint8(1), t.writeUint8(Ce[e]), t.uint8Array;
609
+ const t = new M(6);
610
+ return t.writeUint16(b.ec_point_formats), t.writeUint16(2), t.writeUint8(1), t.writeUint8(Ae[e]), t.uint8Array;
617
611
  }
618
612
  }
619
- const N = {
613
+ const G = {
620
614
  anonymous: 0,
621
615
  rsa: 1,
622
616
  dsa: 2,
623
617
  ecdsa: 3
624
- }, z = p(N), O = {
618
+ }, Q = p(G), $ = {
625
619
  none: 0,
626
620
  md5: 1,
627
621
  sha1: 2,
@@ -629,8 +623,8 @@ const N = {
629
623
  sha256: 4,
630
624
  sha384: 5,
631
625
  sha512: 6
632
- }, Y = p(O);
633
- class Ae {
626
+ }, ee = p($);
627
+ class xe {
634
628
  /**
635
629
  * Binary layout:
636
630
  *
@@ -647,23 +641,21 @@ class Ae {
647
641
  * +------------------------------------+
648
642
  */
649
643
  static decodeFromClient(e) {
650
- const t = new g(e.buffer);
644
+ const t = new m(e.buffer);
651
645
  t.readUint16();
652
646
  const r = [];
653
647
  for (; !t.isFinished(); ) {
654
- const s = t.readUint8(), i = t.readUint8();
655
- if (!z[i]) {
656
- R.warn(`Unknown signature algorithm: ${i}`);
657
- continue;
658
- }
659
- if (!Y[s]) {
660
- R.warn(`Unknown hash algorithm: ${s}`);
661
- continue;
648
+ const n = t.readUint8(), i = t.readUint8();
649
+ if (Q[i]) {
650
+ if (!ee[n]) {
651
+ v.warn(`Unknown hash algorithm: ${n}`);
652
+ continue;
653
+ }
654
+ r.push({
655
+ algorithm: Q[i],
656
+ hash: ee[n]
657
+ });
662
658
  }
663
- r.push({
664
- algorithm: z[i],
665
- hash: Y[s]
666
- });
667
659
  }
668
660
  return r;
669
661
  }
@@ -679,60 +671,61 @@ class Ae {
679
671
  * +--------------------------------------------------+
680
672
  */
681
673
  static encodeforClient(e, t) {
682
- const r = new v(6);
683
- return r.writeUint16(b.signature_algorithms), r.writeUint16(2), r.writeUint8(O[e]), r.writeUint8(N[t]), r.uint8Array;
674
+ const r = new M(6);
675
+ return r.writeUint16(b.signature_algorithms), r.writeUint16(2), r.writeUint8($[e]), r.writeUint8(G[t]), r.uint8Array;
684
676
  }
685
677
  }
686
- const J = {
687
- server_name: ae,
688
- signature_algorithms: Ae,
689
- supported_groups: Se,
690
- ec_point_formats: le
678
+ const te = {
679
+ server_name: Ce,
680
+ signature_algorithms: xe,
681
+ supported_groups: Me,
682
+ ec_point_formats: Ne
691
683
  };
692
- function Pe(n) {
693
- const e = new g(n.buffer), t = [];
684
+ function ke(s) {
685
+ const e = new m(s.buffer), t = [];
694
686
  for (; !e.isFinished(); ) {
695
- const r = e.offset, s = e.readUint16(), i = Re[s], _ = e.readUint16(), a = e.readUint8Array(_);
696
- if (!(i in J))
687
+ const r = e.offset, n = e.readUint16(), i = Ue[n], a = e.readUint16(), _ = e.readUint8Array(a);
688
+ if (!(i in te))
697
689
  continue;
698
- const c = J[i];
690
+ const c = te[i];
699
691
  t.push({
700
692
  type: i,
701
- data: c.decodeFromClient(a),
702
- raw: n.slice(r, r + 4 + _)
693
+ data: c.decodeFromClient(_),
694
+ raw: s.slice(r, r + 4 + a)
703
695
  });
704
696
  }
705
697
  return t;
706
698
  }
707
- async function M(n, e, t, r) {
708
- const s = P([e, t]), i = await crypto.subtle.importKey(
699
+ async function O(s, e, t, r) {
700
+ const n = B([e, t]), i = await crypto.subtle.importKey(
709
701
  "raw",
710
- n,
702
+ s,
711
703
  { name: "HMAC", hash: { name: "SHA-256" } },
712
704
  !1,
713
705
  ["sign"]
714
706
  );
715
- let _ = s;
716
- const a = [];
717
- for (; P(a).byteLength < r; ) {
718
- _ = await X(i, _);
719
- const S = P([_, s]), l = await X(i, S);
720
- a.push(l);
721
- }
722
- return P(a).slice(0, r);
707
+ let a = n;
708
+ const _ = [];
709
+ for (; B(_).byteLength < r; ) {
710
+ a = await re(i, a);
711
+ const S = B([a, n]), h = await re(i, S);
712
+ _.push(h);
713
+ }
714
+ return B(_).slice(0, r);
723
715
  }
724
- async function X(n, e) {
716
+ async function re(s, e) {
725
717
  return await crypto.subtle.sign(
726
718
  { name: "HMAC", hash: "SHA-256" },
727
- n,
719
+ s,
728
720
  e
729
721
  );
730
722
  }
731
- var ue = /* @__PURE__ */ ((n) => (n[n.Null = 0] = "Null", n[n.Deflate = 1] = "Deflate", n))(ue || {});
732
- const Be = {
723
+ const qe = {
724
+ Null: 0
725
+ }, Oe = {
733
726
  Warning: 1,
734
727
  Fatal: 2
735
- }, he = p(Be), Ue = {
728
+ }, ue = p(Oe), Fe = {
736
729
  CloseNotify: 0,
737
730
  UnexpectedMessage: 10,
738
731
  BadRecordMac: 20,
@@ -758,26 +751,21 @@ const Be = {
758
751
  UserCanceled: 90,
759
752
  NoRenegotiation: 100,
760
753
  UnsupportedExtension: 110
761
- }, He = p(Ue), C = {
754
+ }, He = p(Fe), C = {
762
755
  ChangeCipherSpec: 20,
763
756
  Alert: 21,
764
757
  Handshake: 22,
765
758
  ApplicationData: 23
766
- };
767
- var d = /* @__PURE__ */ ((n) => (n[n.HelloRequest = 0] = "HelloRequest", n[n.ClientHello = 1] = "ClientHello", n[n.ServerHello = 2] = "ServerHello", n[n.Certificate = 11] = "Certificate", n[n.ServerKeyExchange = 12] = "ServerKeyExchange", n[n.CertificateRequest = 13] = "CertificateRequest", n[n.ServerHelloDone = 14] = "ServerHelloDone", n[n.CertificateVerify = 15] = "CertificateVerify", n[n.ClientKeyExchange = 16] = "ClientKeyExchange", n[n.Finished = 20] = "Finished", n))(d || {});
768
- const ve = {
769
- /**
770
- * Indicates the elliptic curve domain parameters are
771
- * conveyed verbosely, and the underlying finite field is a prime
772
- * field.
773
- */
774
- ExplicitPrime: 1,
775
- /**
776
- * Indicates the elliptic curve domain parameters are
777
- * conveyed verbosely, and the underlying finite field is a
778
- * characteristic-2 field.
779
- */
780
- ExplicitChar2: 2,
759
+ }, d = {
760
+ HelloRequest: 0,
761
+ ClientHello: 1,
762
+ ServerHello: 2,
763
+ Certificate: 11,
764
+ ServerKeyExchange: 12,
765
+ ServerHelloDone: 14,
766
+ ClientKeyExchange: 16,
767
+ Finished: 20
768
+ }, je = {
781
769
  /**
782
770
  * Indicates that a named curve is used. This option
783
771
  * SHOULD be used when applicable.
@@ -786,29 +774,12 @@ const ve = {
786
774
  /**
787
775
  * Values 248 through 255 are reserved for private use.
788
776
  */
789
- }, Me = {
790
- sect163k1: 1,
791
- sect163r1: 2,
792
- sect163r2: 3,
793
- sect193r1: 4,
794
- sect193r2: 5,
795
- sect233k1: 6,
796
- sect233r1: 7,
797
- sect239k1: 8,
798
- sect283k1: 9,
799
- sect283r1: 10,
800
- sect409k1: 11,
801
- sect409r1: 12,
802
- secp256k1: 22,
803
- secp256r1: 23,
804
- secp384r1: 24,
805
- secp521r1: 25,
806
- arbitrary_explicit_prime_curves: 65281,
807
- arbitrary_explicit_char2_curves: 65282
777
+ }, Ge = {
778
+ secp256r1: 23
808
779
  };
809
- class Z extends Error {
780
+ class ne extends Error {
810
781
  }
811
- const U = new Uint8Array([3, 3]), xe = crypto.subtle.generateKey(
782
+ const U = new Uint8Array([3, 3]), $e = crypto.subtle.generateKey(
812
783
  {
813
784
  name: "ECDH",
814
785
  namedCurve: "P-256"
@@ -819,7 +790,7 @@ const U = new Uint8Array([3, 3]), xe = crypto.subtle.generateKey(
819
790
  ["deriveKey", "deriveBits"]
820
791
  // Key usage
821
792
  );
822
- class Ne {
793
+ class ze {
823
794
  constructor() {
824
795
  this.receivedRecordSequenceNumber = 0, this.sentRecordSequenceNumber = 0, this.closed = !1, this.receivedBytesBuffer = new Uint8Array(), this.receivedTLSRecords = [], this.partialTLSMessages = {}, this.handshakeMessages = [], this.MAX_CHUNK_SIZE = 1024 * 16, this.clientEnd = {
825
796
  // We don't need to chunk the encrypted data.
@@ -836,7 +807,7 @@ class Ne {
836
807
  * This will spread some messages across multiple records,
837
808
  * but TLS supports it so that's fine.
838
809
  */
839
- downstream: Oe(this.MAX_CHUNK_SIZE)
810
+ downstream: Ve(this.MAX_CHUNK_SIZE)
840
811
  }, this.serverUpstreamWriter = this.serverEnd.upstream.writable.getWriter();
841
812
  const e = this;
842
813
  this.serverEnd.downstream.readable.pipeTo(
@@ -899,25 +870,25 @@ class Ne {
899
870
  throw new Error(
900
871
  "Client did not propose any supported cipher suites."
901
872
  );
902
- const s = crypto.getRandomValues(new Uint8Array(32));
873
+ const n = crypto.getRandomValues(new Uint8Array(32));
903
874
  await this.writeTLSRecord(
904
875
  C.Handshake,
905
876
  K.serverHello(
906
877
  r.body,
907
- s,
908
- ue.Null
878
+ n,
879
+ qe.Null
909
880
  )
910
881
  ), await this.writeTLSRecord(
911
882
  C.Handshake,
912
883
  K.certificate(t)
913
884
  );
914
- const i = await xe, _ = r.body.random, a = await K.ECDHEServerKeyExchange(
915
- _,
916
- s,
885
+ const i = await $e, a = r.body.random, _ = await K.ECDHEServerKeyExchange(
886
+ a,
887
+ n,
917
888
  i,
918
889
  e
919
890
  );
920
- await this.writeTLSRecord(C.Handshake, a), await this.writeTLSRecord(
891
+ await this.writeTLSRecord(C.Handshake, _), await this.writeTLSRecord(
921
892
  C.Handshake,
922
893
  K.serverHelloDone()
923
894
  );
@@ -925,8 +896,8 @@ class Ne {
925
896
  d.ClientKeyExchange
926
897
  );
927
898
  await this.readNextMessage(C.ChangeCipherSpec), this.sessionKeys = await this.deriveSessionKeys({
928
- clientRandom: _,
929
- serverRandom: s,
899
+ clientRandom: a,
900
+ serverRandom: n,
930
901
  serverPrivateKey: i.privateKey,
931
902
  clientPublicKey: await crypto.subtle.importKey(
932
903
  "raw",
@@ -954,32 +925,32 @@ class Ne {
954
925
  clientRandom: e,
955
926
  serverRandom: t,
956
927
  serverPrivateKey: r,
957
- clientPublicKey: s
928
+ clientPublicKey: n
958
929
  }) {
959
930
  const i = await crypto.subtle.deriveBits(
960
931
  {
961
932
  name: "ECDH",
962
- public: s
933
+ public: n
963
934
  },
964
935
  r,
965
936
  256
966
937
  // Length of the derived secret (256 bits for P-256)
967
- ), _ = new Uint8Array(
968
- await M(
938
+ ), a = new Uint8Array(
939
+ await O(
969
940
  i,
970
941
  new TextEncoder().encode("master secret"),
971
- h([e, t]),
942
+ u([e, t]),
972
943
  48
973
944
  )
974
- ), a = await M(
975
- _,
945
+ ), _ = await O(
946
+ a,
976
947
  new TextEncoder().encode("key expansion"),
977
- h([t, e]),
948
+ u([t, e]),
978
949
  // Client key, server key, client IV, server IV
979
- 16 + 16 + 4 + 4
980
- ), c = new g(a), S = c.readUint8Array(16), l = c.readUint8Array(16), A = c.readUint8Array(4), u = c.readUint8Array(4);
950
+ 40
951
+ ), c = new m(_), S = c.readUint8Array(16), h = c.readUint8Array(16), l = c.readUint8Array(4), A = c.readUint8Array(4);
981
952
  return {
982
- masterSecret: _,
953
+ masterSecret: a,
983
954
  clientWriteKey: await crypto.subtle.importKey(
984
955
  "raw",
985
956
  S,
@@ -989,13 +960,13 @@ class Ne {
989
960
  ),
990
961
  serverWriteKey: await crypto.subtle.importKey(
991
962
  "raw",
992
- l,
963
+ h,
993
964
  { name: "AES-GCM" },
994
965
  !1,
995
966
  ["encrypt", "decrypt"]
996
967
  ),
997
- clientIV: A,
998
- serverIV: u
968
+ clientIV: l,
969
+ serverIV: A
999
970
  };
1000
971
  }
1001
972
  async readNextHandshakeMessage(e) {
@@ -1011,35 +982,35 @@ class Ne {
1011
982
  t
1012
983
  );
1013
984
  while (r === !1);
1014
- const s = f.TLSMessage(
985
+ const n = T.TLSMessage(
1015
986
  t.type,
1016
987
  r
1017
988
  );
1018
- return t.type === C.Handshake && this.handshakeMessages.push(t.fragment), s;
989
+ return t.type === C.Handshake && this.handshakeMessages.push(t.fragment), n;
1019
990
  }
1020
991
  async readNextTLSRecord(e) {
1021
992
  for (; ; ) {
1022
- for (let a = 0; a < this.receivedTLSRecords.length; a++) {
1023
- const c = this.receivedTLSRecords[a];
993
+ for (let _ = 0; _ < this.receivedTLSRecords.length; _++) {
994
+ const c = this.receivedTLSRecords[_];
1024
995
  if (c.type === e)
1025
- return this.receivedTLSRecords.splice(a, 1), c;
996
+ return this.receivedTLSRecords.splice(_, 1), c;
1026
997
  }
1027
- const t = await this.pollBytes(5), r = t[3] << 8 | t[4], s = t[0], i = await this.pollBytes(r), _ = {
1028
- type: s,
998
+ const t = await this.pollBytes(5), r = t[3] << 8 | t[4], n = t[0], i = await this.pollBytes(r), a = {
999
+ type: n,
1029
1000
  version: {
1030
1001
  major: t[1],
1031
1002
  minor: t[2]
1032
1003
  },
1033
1004
  length: r,
1034
- fragment: this.sessionKeys && s !== C.ChangeCipherSpec ? await this.decryptData(s, i) : i
1005
+ fragment: this.sessionKeys && n !== C.ChangeCipherSpec ? await this.decryptData(n, i) : i
1035
1006
  };
1036
- if (_.type === C.Alert) {
1037
- const a = he[_.fragment[0]], c = He[_.fragment[1]];
1007
+ if (a.type === C.Alert) {
1008
+ const _ = ue[a.fragment[0]], c = He[a.fragment[1]];
1038
1009
  throw new Error(
1039
- `TLS non-warning alert received: ${a} ${c}`
1010
+ `TLS non-warning alert received: ${_} ${c}`
1040
1011
  );
1041
1012
  }
1042
- this.receivedTLSRecords.push(_);
1013
+ this.receivedTLSRecords.push(a);
1043
1014
  }
1044
1015
  }
1045
1016
  /**
@@ -1048,10 +1019,10 @@ class Ne {
1048
1019
  */
1049
1020
  async pollBytes(e) {
1050
1021
  for (; this.receivedBytesBuffer.length < e; ) {
1051
- const { value: r, done: s } = await this.clientUpstreamReader.read();
1052
- if (s)
1053
- throw await this.close(), new Z("TLS connection closed");
1054
- if (this.receivedBytesBuffer = h([
1022
+ const { value: r, done: n } = await this.clientUpstreamReader.read();
1023
+ if (n)
1024
+ throw await this.close(), new ne("TLS connection closed");
1025
+ if (this.receivedBytesBuffer = u([
1055
1026
  this.receivedBytesBuffer,
1056
1027
  r
1057
1028
  ]), this.receivedBytesBuffer.length >= e)
@@ -1074,7 +1045,7 @@ class Ne {
1074
1045
  this.serverUpstreamWriter.write(e.body);
1075
1046
  }
1076
1047
  } catch (e) {
1077
- if (e instanceof Z)
1048
+ if (e instanceof ne)
1078
1049
  return;
1079
1050
  throw e;
1080
1051
  }
@@ -1084,12 +1055,12 @@ class Ne {
1084
1055
  * the AES-GCM algorithm.
1085
1056
  */
1086
1057
  async decryptData(e, t) {
1087
- const r = this.sessionKeys.clientIV, s = t.slice(0, 8), i = new Uint8Array([...r, ...s]), _ = await crypto.subtle.decrypt(
1058
+ const r = this.sessionKeys.clientIV, n = t.slice(0, 8), i = new Uint8Array([...r, ...n]), a = await crypto.subtle.decrypt(
1088
1059
  {
1089
1060
  name: "AES-GCM",
1090
1061
  iv: i,
1091
1062
  additionalData: new Uint8Array([
1092
- ...G(this.receivedRecordSequenceNumber),
1063
+ ...Y(this.receivedRecordSequenceNumber),
1093
1064
  e,
1094
1065
  ...U,
1095
1066
  // Payload length without IV and tag
@@ -1101,10 +1072,10 @@ class Ne {
1101
1072
  // Payload without the explicit IV
1102
1073
  t.slice(8)
1103
1074
  );
1104
- return ++this.receivedRecordSequenceNumber, new Uint8Array(_);
1075
+ return ++this.receivedRecordSequenceNumber, new Uint8Array(a);
1105
1076
  }
1106
1077
  async accumulateUntilMessageIsComplete(e) {
1107
- this.partialTLSMessages[e.type] = h([
1078
+ this.partialTLSMessages[e.type] = u([
1108
1079
  this.partialTLSMessages[e.type] || new Uint8Array(),
1109
1080
  e.fragment
1110
1081
  ]);
@@ -1140,49 +1111,49 @@ class Ne {
1140
1111
  */
1141
1112
  async writeTLSRecord(e, t) {
1142
1113
  e === C.Handshake && this.handshakeMessages.push(t), this.sessionKeys && e !== C.ChangeCipherSpec && (t = await this.encryptData(e, t));
1143
- const r = U, s = t.length, i = new Uint8Array(5);
1144
- i[0] = e, i[1] = r[0], i[2] = r[1], i[3] = s >> 8 & 255, i[4] = s & 255;
1145
- const _ = h([i, t]);
1146
- this.clientDownstreamWriter.write(_);
1114
+ const r = U, n = t.length, i = new Uint8Array(5);
1115
+ i[0] = e, i[1] = r[0], i[2] = r[1], i[3] = n >> 8 & 255, i[4] = n & 255;
1116
+ const a = u([i, t]);
1117
+ this.clientDownstreamWriter.write(a);
1147
1118
  }
1148
1119
  /**
1149
1120
  * Encrypts data in a TLS 1.2-compliant manner using
1150
1121
  * the AES-GCM algorithm.
1151
1122
  */
1152
1123
  async encryptData(e, t) {
1153
- const r = this.sessionKeys.serverIV, s = crypto.getRandomValues(new Uint8Array(8)), i = new Uint8Array([...r, ...s]), _ = new Uint8Array([
1154
- ...G(this.sentRecordSequenceNumber),
1124
+ const r = this.sessionKeys.serverIV, n = crypto.getRandomValues(new Uint8Array(8)), i = new Uint8Array([...r, ...n]), a = new Uint8Array([
1125
+ ...Y(this.sentRecordSequenceNumber),
1155
1126
  e,
1156
1127
  ...U,
1157
1128
  // Payload length without IV and tag
1158
1129
  ...I(t.length)
1159
- ]), a = await crypto.subtle.encrypt(
1130
+ ]), _ = await crypto.subtle.encrypt(
1160
1131
  {
1161
1132
  name: "AES-GCM",
1162
1133
  iv: i,
1163
- additionalData: _,
1134
+ additionalData: a,
1164
1135
  tagLength: 128
1165
1136
  },
1166
1137
  this.sessionKeys.serverWriteKey,
1167
1138
  t
1168
1139
  );
1169
- return ++this.sentRecordSequenceNumber, h([
1170
- s,
1171
- new Uint8Array(a)
1140
+ return ++this.sentRecordSequenceNumber, u([
1141
+ n,
1142
+ new Uint8Array(_)
1172
1143
  ]);
1173
1144
  }
1174
1145
  }
1175
- class f {
1146
+ class T {
1176
1147
  static TLSMessage(e, t) {
1177
1148
  switch (e) {
1178
1149
  case C.Handshake:
1179
- return f.clientHandshake(t);
1150
+ return T.clientHandshake(t);
1180
1151
  case C.Alert:
1181
- return f.alert(t);
1152
+ return T.alert(t);
1182
1153
  case C.ChangeCipherSpec:
1183
- return f.changeCipherSpec();
1154
+ return T.changeCipherSpec();
1184
1155
  case C.ApplicationData:
1185
- return f.applicationData(t);
1156
+ return T.applicationData(t);
1186
1157
  default:
1187
1158
  throw new Error(`TLS: Unsupported TLS record type ${e}`);
1188
1159
  }
@@ -1211,12 +1182,12 @@ class f {
1211
1182
  * https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#tls-parameters-4
1212
1183
  */
1213
1184
  static parseCipherSuites(e) {
1214
- const t = new g(e);
1185
+ const t = new m(e);
1215
1186
  t.readUint16();
1216
1187
  const r = [];
1217
1188
  for (; !t.isFinished(); ) {
1218
- const s = t.readUint16();
1219
- s in j && r.push(j[s]);
1189
+ const n = t.readUint16();
1190
+ n in Z && r.push(Z[n]);
1220
1191
  }
1221
1192
  return r;
1222
1193
  }
@@ -1235,25 +1206,25 @@ class f {
1235
1206
  static alert(e) {
1236
1207
  return {
1237
1208
  type: C.Alert,
1238
- level: he[e[0]],
1209
+ level: ue[e[0]],
1239
1210
  description: He[e[1]]
1240
1211
  };
1241
1212
  }
1242
1213
  static clientHandshake(e) {
1243
- const t = e[0], r = e[1] << 16 | e[2] << 8 | e[3], s = e.slice(4);
1214
+ const t = e[0], r = e[1] << 16 | e[2] << 8 | e[3], n = e.slice(4);
1244
1215
  let i;
1245
1216
  switch (t) {
1246
1217
  case d.HelloRequest:
1247
- i = f.clientHelloRequestPayload();
1218
+ i = T.clientHelloRequestPayload();
1248
1219
  break;
1249
1220
  case d.ClientHello:
1250
- i = f.clientHelloPayload(s);
1221
+ i = T.clientHelloPayload(n);
1251
1222
  break;
1252
1223
  case d.ClientKeyExchange:
1253
- i = f.clientKeyExchangePayload(s);
1224
+ i = T.clientKeyExchangePayload(n);
1254
1225
  break;
1255
1226
  case d.Finished:
1256
- i = f.clientFinishedPayload(s);
1227
+ i = T.clientFinishedPayload(n);
1257
1228
  break;
1258
1229
  default:
1259
1230
  throw new Error(`Invalid handshake type ${t}`);
@@ -1309,7 +1280,7 @@ class f {
1309
1280
  * +------+------+---------------------------+
1310
1281
  */
1311
1282
  static clientHelloPayload(e) {
1312
- const t = new g(e.buffer), r = {
1283
+ const t = new m(e.buffer), r = {
1313
1284
  client_version: t.readUint8Array(2),
1314
1285
  /**
1315
1286
  * Technically this consists of a GMT timestamp
@@ -1317,19 +1288,19 @@ class f {
1317
1288
  * parse this further.
1318
1289
  */
1319
1290
  random: t.readUint8Array(32)
1320
- }, s = t.readUint8();
1321
- r.session_id = t.readUint8Array(s);
1291
+ }, n = t.readUint8();
1292
+ r.session_id = t.readUint8Array(n);
1322
1293
  const i = t.readUint16();
1323
- r.cipher_suites = f.parseCipherSuites(
1294
+ r.cipher_suites = T.parseCipherSuites(
1324
1295
  t.readUint8Array(i).buffer
1325
1296
  );
1326
- const _ = t.readUint8();
1297
+ const a = t.readUint8();
1327
1298
  r.compression_methods = t.readUint8Array(
1328
- _
1299
+ a
1329
1300
  );
1330
- const a = t.readUint16();
1331
- return r.extensions = Pe(
1332
- t.readUint8Array(a)
1301
+ const _ = t.readUint16();
1302
+ return r.extensions = ke(
1303
+ t.readUint8Array(_)
1333
1304
  ), r;
1334
1305
  }
1335
1306
  /**
@@ -1353,11 +1324,11 @@ class f {
1353
1324
  };
1354
1325
  }
1355
1326
  }
1356
- function Oe(n) {
1327
+ function Ve(s) {
1357
1328
  return new TransformStream({
1358
1329
  transform(e, t) {
1359
1330
  for (; e.length > 0; )
1360
- t.enqueue(e.slice(0, n)), e = e.slice(n);
1331
+ t.enqueue(e.slice(0, s)), e = e.slice(s);
1361
1332
  }
1362
1333
  });
1363
1334
  }
@@ -1365,15 +1336,15 @@ class K {
1365
1336
  static certificate(e) {
1366
1337
  const t = [];
1367
1338
  for (const i of e)
1368
- t.push(m(i.byteLength)), t.push(new Uint8Array(i));
1369
- const r = h(t), s = new Uint8Array([
1370
- ...m(r.byteLength),
1339
+ t.push(y(i.byteLength)), t.push(new Uint8Array(i));
1340
+ const r = u(t), n = new Uint8Array([
1341
+ ...y(r.byteLength),
1371
1342
  ...r
1372
1343
  ]);
1373
1344
  return new Uint8Array([
1374
1345
  d.Certificate,
1375
- ...m(s.length),
1376
- ...s
1346
+ ...y(n.length),
1347
+ ...n
1377
1348
  ]);
1378
1349
  }
1379
1350
  /*
@@ -1409,38 +1380,38 @@ class K {
1409
1380
  * @param rsaPrivateKey - RSA private key for signing
1410
1381
  * @returns
1411
1382
  */
1412
- static async ECDHEServerKeyExchange(e, t, r, s) {
1383
+ static async ECDHEServerKeyExchange(e, t, r, n) {
1413
1384
  const i = new Uint8Array(
1414
1385
  await crypto.subtle.exportKey("raw", r.publicKey)
1415
- ), _ = new Uint8Array([
1386
+ ), a = new Uint8Array([
1416
1387
  // Curve type (1 byte)
1417
- ve.NamedCurve,
1388
+ je.NamedCurve,
1418
1389
  // Curve name (2 bytes)
1419
- ...I(Me.secp256r1),
1390
+ ...I(Ge.secp256r1),
1420
1391
  // Public key length (1 byte)
1421
1392
  i.byteLength,
1422
1393
  // Public key (65 bytes, uncompressed format)
1423
1394
  ...i
1424
- ]), a = await crypto.subtle.sign(
1395
+ ]), _ = await crypto.subtle.sign(
1425
1396
  {
1426
1397
  name: "RSASSA-PKCS1-v1_5",
1427
1398
  hash: "SHA-256"
1428
1399
  },
1429
- s,
1430
- new Uint8Array([...e, ...t, ..._])
1431
- ), c = new Uint8Array(a), S = new Uint8Array([
1432
- O.sha256,
1433
- N.rsa
1434
- ]), l = new Uint8Array([
1435
- ..._,
1400
+ n,
1401
+ new Uint8Array([...e, ...t, ...a])
1402
+ ), c = new Uint8Array(_), S = new Uint8Array([
1403
+ $.sha256,
1404
+ G.rsa
1405
+ ]), h = new Uint8Array([
1406
+ ...a,
1436
1407
  ...S,
1437
1408
  ...I(c.length),
1438
1409
  ...c
1439
1410
  ]);
1440
1411
  return new Uint8Array([
1441
1412
  d.ServerKeyExchange,
1442
- ...m(l.length),
1443
- ...l
1413
+ ...y(h.length),
1414
+ ...h
1444
1415
  ]);
1445
1416
  }
1446
1417
  /**
@@ -1482,31 +1453,18 @@ class K {
1482
1453
  * +------------------------------------+
1483
1454
  */
1484
1455
  static serverHello(e, t, r) {
1485
- const s = e.extensions.map((a) => {
1486
- switch (a.type) {
1456
+ const n = e.extensions.map((_) => {
1457
+ switch (_.type) {
1487
1458
  case "server_name":
1488
- return ae.encodeForClient();
1489
- case "supported_groups":
1490
- return Se.encodeForClient(
1491
- "secp256r1"
1492
- );
1493
- case "ec_point_formats":
1494
- return le.encodeForClient(
1495
- "uncompressed"
1496
- );
1497
- case "signature_algorithms":
1498
- return Ae.encodeforClient(
1499
- "sha256",
1500
- "rsa"
1501
- );
1459
+ return Ce.encodeForClient();
1502
1460
  }
1503
- }).filter((a) => a !== void 0), i = h(s), _ = new Uint8Array([
1461
+ }).filter((_) => _ !== void 0), i = u(n), a = new Uint8Array([
1504
1462
  // Version field – 0x03, 0x03 means TLS 1.2
1505
1463
  ...U,
1506
1464
  ...t,
1507
1465
  e.session_id.length,
1508
1466
  ...e.session_id,
1509
- ...I(oe.TLS1_CK_ECDHE_RSA_WITH_AES_128_GCM_SHA256),
1467
+ ...I(he.TLS1_CK_ECDHE_RSA_WITH_AES_128_GCM_SHA256),
1510
1468
  r,
1511
1469
  // Extensions length (2 bytes)
1512
1470
  ...I(i.length),
@@ -1514,12 +1472,12 @@ class K {
1514
1472
  ]);
1515
1473
  return new Uint8Array([
1516
1474
  d.ServerHello,
1517
- ...m(_.length),
1518
- ..._
1475
+ ...y(a.length),
1476
+ ...a
1519
1477
  ]);
1520
1478
  }
1521
1479
  static serverHelloDone() {
1522
- return new Uint8Array([d.ServerHelloDone, ...m(0)]);
1480
+ return new Uint8Array([d.ServerHelloDone, ...y(0)]);
1523
1481
  }
1524
1482
  /**
1525
1483
  * Server finished message.
@@ -1542,9 +1500,9 @@ class K {
1542
1500
  static async createFinishedMessage(e, t) {
1543
1501
  const r = await crypto.subtle.digest(
1544
1502
  "SHA-256",
1545
- h(e)
1546
- ), s = new Uint8Array(
1547
- await M(
1503
+ u(e)
1504
+ ), n = new Uint8Array(
1505
+ await O(
1548
1506
  t,
1549
1507
  new TextEncoder().encode("server finished"),
1550
1508
  r,
@@ -1554,33 +1512,33 @@ class K {
1554
1512
  );
1555
1513
  return new Uint8Array([
1556
1514
  d.Finished,
1557
- ...m(s.length),
1558
- ...s
1515
+ ...y(n.length),
1516
+ ...n
1559
1517
  ]);
1560
1518
  }
1561
1519
  static changeCipherSpec() {
1562
1520
  return new Uint8Array([1]);
1563
1521
  }
1564
1522
  }
1565
- function qe(n, e) {
1566
- return ke.generateCertificate(n, e);
1523
+ function Ye(s, e) {
1524
+ return Ze.generateCertificate(s, e);
1567
1525
  }
1568
- function Ct(n) {
1526
+ function yt(s) {
1569
1527
  return `-----BEGIN CERTIFICATE-----
1570
1528
  ${fe(
1571
- de(n.buffer)
1529
+ de(s.buffer)
1572
1530
  )}
1573
1531
  -----END CERTIFICATE-----`;
1574
1532
  }
1575
- async function lt(n) {
1576
- const e = await crypto.subtle.exportKey("pkcs8", n);
1533
+ async function Lt(s) {
1534
+ const e = await crypto.subtle.exportKey("pkcs8", s);
1577
1535
  return `-----BEGIN PRIVATE KEY-----
1578
1536
  ${fe(
1579
1537
  de(e)
1580
1538
  )}
1581
1539
  -----END PRIVATE KEY-----`;
1582
1540
  }
1583
- class ke {
1541
+ class Ze {
1584
1542
  static async generateCertificate(e, t) {
1585
1543
  const r = await crypto.subtle.generateKey(
1586
1544
  {
@@ -1592,17 +1550,17 @@ class ke {
1592
1550
  !0,
1593
1551
  // extractable
1594
1552
  ["sign", "verify"]
1595
- ), s = await this.signingRequest(
1553
+ ), n = await this.signingRequest(
1596
1554
  e,
1597
1555
  r.publicKey
1598
1556
  ), i = await this.sign(
1599
- s,
1557
+ n,
1600
1558
  (t == null ? void 0 : t.privateKey) ?? r.privateKey
1601
1559
  );
1602
1560
  return {
1603
1561
  keyPair: r,
1604
1562
  certificate: i,
1605
- tbsCertificate: s,
1563
+ tbsCertificate: n,
1606
1564
  tbsDescription: e
1607
1565
  };
1608
1566
  }
@@ -1659,16 +1617,16 @@ class ke {
1659
1617
  }
1660
1618
  static distinguishedName(e) {
1661
1619
  const t = [];
1662
- for (const [r, s] of Object.entries(e)) {
1620
+ for (const [r, n] of Object.entries(e)) {
1663
1621
  const i = [
1664
1622
  o.objectIdentifier(w(r))
1665
1623
  ];
1666
1624
  switch (r) {
1667
1625
  case "countryName":
1668
- i.push(o.printableString(s));
1626
+ i.push(o.printableString(n));
1669
1627
  break;
1670
1628
  default:
1671
- i.push(o.utf8String(s));
1629
+ i.push(o.utf8String(n));
1672
1630
  }
1673
1631
  t.push(o.set([o.sequence(i)]));
1674
1632
  }
@@ -1679,14 +1637,14 @@ class ke {
1679
1637
  o.ASN1(
1680
1638
  H.UTCTime,
1681
1639
  new TextEncoder().encode(
1682
- ee((e == null ? void 0 : e.notBefore) ?? /* @__PURE__ */ new Date())
1640
+ ie((e == null ? void 0 : e.notBefore) ?? /* @__PURE__ */ new Date())
1683
1641
  )
1684
1642
  ),
1685
1643
  o.ASN1(
1686
1644
  H.UTCTime,
1687
1645
  new TextEncoder().encode(
1688
- ee(
1689
- (e == null ? void 0 : e.notAfter) ?? Ge(/* @__PURE__ */ new Date(), 10)
1646
+ ie(
1647
+ (e == null ? void 0 : e.notAfter) ?? Xe(/* @__PURE__ */ new Date(), 10)
1690
1648
  )
1691
1649
  )
1692
1650
  )
@@ -1735,24 +1693,24 @@ class ke {
1735
1693
  ]);
1736
1694
  }
1737
1695
  static subjectAltName(e) {
1738
- var i, _;
1739
- const t = ((i = e.dnsNames) == null ? void 0 : i.map((a) => {
1740
- const c = o.ia5String(a);
1696
+ var i, a;
1697
+ const t = ((i = e.dnsNames) == null ? void 0 : i.map((_) => {
1698
+ const c = o.ia5String(_);
1741
1699
  return o.contextSpecific(2, c);
1742
- })) || [], r = ((_ = e.ipAddresses) == null ? void 0 : _.map((a) => {
1743
- const c = o.ia5String(a);
1700
+ })) || [], r = ((a = e.ipAddresses) == null ? void 0 : a.map((_) => {
1701
+ const c = o.ia5String(_);
1744
1702
  return o.contextSpecific(7, c);
1745
- })) || [], s = o.octetString(
1703
+ })) || [], n = o.octetString(
1746
1704
  o.sequence([...t, ...r])
1747
1705
  );
1748
1706
  return o.sequence([
1749
1707
  o.objectIdentifier(w("subjectAltName")),
1750
1708
  o.boolean(!0),
1751
- s
1709
+ n
1752
1710
  ]);
1753
1711
  }
1754
1712
  }
1755
- const Fe = {
1713
+ const Je = {
1756
1714
  // Algorithm OIDs
1757
1715
  "1.2.840.113549.1.1.1": "rsaEncryption",
1758
1716
  "1.2.840.113549.1.1.4": "md5WithRSAEncryption",
@@ -1862,45 +1820,25 @@ const Fe = {
1862
1820
  "1.3.6.1.5.5.7.3.4": "emailProtection",
1863
1821
  "1.3.6.1.5.5.7.3.8": "timeStamping"
1864
1822
  };
1865
- function w(n) {
1866
- for (const [e, t] of Object.entries(Fe))
1867
- if (t === n)
1823
+ function w(s) {
1824
+ for (const [e, t] of Object.entries(Je))
1825
+ if (t === s)
1868
1826
  return e;
1869
- throw new Error(`OID not found for name: ${n}`);
1827
+ throw new Error(`OID not found for name: ${s}`);
1870
1828
  }
1871
- const Q = 32, H = {
1872
- EOC: 0,
1829
+ const se = 32, H = {
1873
1830
  Boolean: 1,
1874
1831
  Integer: 2,
1875
1832
  BitString: 3,
1876
1833
  OctetString: 4,
1877
1834
  Null: 5,
1878
1835
  OID: 6,
1879
- ObjectDescriptor: 7,
1880
- External: 8,
1881
- Real: 9,
1882
- // float
1883
- Enumeration: 10,
1884
- PDV: 11,
1885
1836
  Utf8String: 12,
1886
- RelativeOID: 13,
1887
- Sequence: 16 | Q,
1888
- Set: 17 | Q,
1889
- NumericString: 18,
1837
+ Sequence: 16 | se,
1838
+ Set: 17 | se,
1890
1839
  PrintableString: 19,
1891
- T61String: 20,
1892
- VideotexString: 21,
1893
1840
  IA5String: 22,
1894
- UTCTime: 23,
1895
- GeneralizedTime: 24,
1896
- GraphicString: 25,
1897
- VisibleString: 26,
1898
- GeneralString: 28,
1899
- UniversalString: 29,
1900
- CharacterString: 30,
1901
- BMPString: 31,
1902
- Constructor: 32,
1903
- Context: 128
1841
+ UTCTime: 23
1904
1842
  };
1905
1843
  class o {
1906
1844
  // Helper functions for ASN.1 DER encoding
@@ -1912,16 +1850,16 @@ class o {
1912
1850
  const r = [];
1913
1851
  for (; t > 0; )
1914
1852
  r.unshift(t & 255), t >>= 8;
1915
- const s = r.length, i = new Uint8Array(1 + s);
1916
- i[0] = 128 | s;
1917
- for (let _ = 0; _ < s; _++)
1918
- i[_ + 1] = r[_];
1853
+ const n = r.length, i = new Uint8Array(1 + n);
1854
+ i[0] = 128 | n;
1855
+ for (let a = 0; a < n; a++)
1856
+ i[a + 1] = r[a];
1919
1857
  return i;
1920
1858
  }
1921
1859
  }
1922
1860
  static ASN1(e, t) {
1923
- const r = o.length_(t.length), s = new Uint8Array(1 + r.length + t.length);
1924
- return s[0] = e, s.set(r, 1), s.set(t, 1 + r.length), s;
1861
+ const r = o.length_(t.length), n = new Uint8Array(1 + r.length + t.length);
1862
+ return n[0] = e, n.set(r, 1), n.set(t, 1 + r.length), n;
1925
1863
  }
1926
1864
  static integer(e) {
1927
1865
  if (e[0] > 127) {
@@ -1941,18 +1879,18 @@ class o {
1941
1879
  return o.ASN1(H.Null, new Uint8Array(0));
1942
1880
  }
1943
1881
  static objectIdentifier(e) {
1944
- const t = e.split(".").map(Number), s = [t[0] * 40 + t[1]];
1882
+ const t = e.split(".").map(Number), n = [t[0] * 40 + t[1]];
1945
1883
  for (let i = 2; i < t.length; i++) {
1946
- let _ = t[i];
1947
- const a = [];
1884
+ let a = t[i];
1885
+ const _ = [];
1948
1886
  do
1949
- a.unshift(_ & 127), _ >>= 7;
1950
- while (_ > 0);
1951
- for (let c = 0; c < a.length - 1; c++)
1952
- a[c] |= 128;
1953
- s.push(...a);
1887
+ _.unshift(a & 127), a >>= 7;
1888
+ while (a > 0);
1889
+ for (let c = 0; c < _.length - 1; c++)
1890
+ _[c] |= 128;
1891
+ n.push(..._);
1954
1892
  }
1955
- return o.ASN1(H.OID, new Uint8Array(s));
1893
+ return o.ASN1(H.OID, new Uint8Array(n));
1956
1894
  }
1957
1895
  static utf8String(e) {
1958
1896
  const t = new TextEncoder().encode(e);
@@ -1963,18 +1901,18 @@ class o {
1963
1901
  return o.ASN1(H.PrintableString, t);
1964
1902
  }
1965
1903
  static sequence(e) {
1966
- return o.ASN1(H.Sequence, h(e));
1904
+ return o.ASN1(H.Sequence, u(e));
1967
1905
  }
1968
1906
  static set(e) {
1969
- return o.ASN1(H.Set, h(e));
1907
+ return o.ASN1(H.Set, u(e));
1970
1908
  }
1971
1909
  static ia5String(e) {
1972
1910
  const t = new TextEncoder().encode(e);
1973
1911
  return o.ASN1(H.IA5String, t);
1974
1912
  }
1975
1913
  static contextSpecific(e, t, r = !1) {
1976
- const s = (r ? 160 : 128) | e;
1977
- return o.ASN1(s, t);
1914
+ const n = (r ? 160 : 128) | e;
1915
+ return o.ASN1(n, t);
1978
1916
  }
1979
1917
  static boolean(e) {
1980
1918
  return o.ASN1(
@@ -1983,73 +1921,124 @@ class o {
1983
1921
  );
1984
1922
  }
1985
1923
  }
1986
- function de(n) {
1987
- return btoa(String.fromCodePoint(...new Uint8Array(n)));
1924
+ function de(s) {
1925
+ return btoa(String.fromCodePoint(...new Uint8Array(s)));
1988
1926
  }
1989
- function fe(n) {
1927
+ function fe(s) {
1990
1928
  var e;
1991
- return ((e = n.match(/.{1,64}/g)) == null ? void 0 : e.join(`
1992
- `)) || n;
1929
+ return ((e = s.match(/.{1,64}/g)) == null ? void 0 : e.join(`
1930
+ `)) || s;
1993
1931
  }
1994
- function ee(n) {
1995
- const e = n.getUTCFullYear().toString().substr(2), t = W(n.getUTCMonth() + 1), r = W(n.getUTCDate()), s = W(n.getUTCHours()), i = W(n.getUTCMinutes()), _ = W(n.getUTCSeconds());
1996
- return `${e}${t}${r}${s}${i}${_}Z`;
1932
+ function ie(s) {
1933
+ const e = s.getUTCFullYear().toString().substr(2), t = W(s.getUTCMonth() + 1), r = W(s.getUTCDate()), n = W(s.getUTCHours()), i = W(s.getUTCMinutes()), a = W(s.getUTCSeconds());
1934
+ return `${e}${t}${r}${n}${i}${a}Z`;
1997
1935
  }
1998
- function W(n) {
1999
- return n.toString().padStart(2, "0");
1936
+ function W(s) {
1937
+ return s.toString().padStart(2, "0");
2000
1938
  }
2001
- function Ge(n, e) {
2002
- const t = new Date(n);
1939
+ function Xe(s, e) {
1940
+ const t = new Date(s);
2003
1941
  return t.setUTCFullYear(t.getUTCFullYear() + e), t;
2004
1942
  }
2005
- async function je(n, e, t) {
2006
- const r = fetch(n, e);
1943
+ async function Qe(s, e, t) {
1944
+ var a;
1945
+ const r = typeof s == "string" ? new Request(s, e) : s;
2007
1946
  if (!t)
2008
- return r;
1947
+ return await fetch(r);
1948
+ const [n, i] = await Ie(r);
2009
1949
  try {
2010
- return await r;
1950
+ return await fetch(n);
2011
1951
  } catch {
2012
- let s;
2013
- if (typeof n == "string" || n instanceof URL)
2014
- s = `${t}${n}`;
2015
- else if (n instanceof Request)
2016
- s = await ge(n, {
2017
- url: `${t}${n.url}`
2018
- });
2019
- else
2020
- throw new Error("Invalid input type for fetch");
2021
- return fetch(s, e);
1952
+ const c = ((a = new Headers(i.headers).get("x-cors-proxy-allowed-request-headers")) == null ? void 0 : a.split(",")) || [], S = c.includes("authorization") || c.includes("cookie"), h = await De(i, {
1953
+ url: `${t}${r.url}`,
1954
+ ...S && { credentials: "include" }
1955
+ });
1956
+ return await fetch(h, e);
2022
1957
  }
2023
1958
  }
2024
- const $e = (n) => ({
1959
+ class et extends TransformStream {
1960
+ constructor() {
1961
+ let e = new Uint8Array(0), t = "SCAN_CHUNK_SIZE", r = 0;
1962
+ super({
1963
+ transform(n, i) {
1964
+ for (e = u([e, n]); e.length > 0; )
1965
+ if (t === "SCAN_CHUNK_SIZE") {
1966
+ if (e.length < 3)
1967
+ return;
1968
+ let a = 0;
1969
+ for (; a < e.length; ) {
1970
+ const S = e[a];
1971
+ if (!(S >= 48 && S <= 57 || // 0-9
1972
+ S >= 97 && S <= 102 || // a-f
1973
+ S >= 65 && S <= 70)) break;
1974
+ a++;
1975
+ }
1976
+ if (a === 0)
1977
+ throw new Error("Invalid chunk size format");
1978
+ if (e.length < a + 2)
1979
+ return;
1980
+ if (e[a] !== 13 || // \r
1981
+ e[a + 1] !== 10)
1982
+ throw new Error(
1983
+ "Invalid chunk size format. Expected CRLF after chunk size"
1984
+ );
1985
+ const _ = new TextDecoder().decode(
1986
+ e.slice(0, a)
1987
+ ), c = parseInt(_, 16);
1988
+ if (e = e.slice(a + 2), c === 0) {
1989
+ t = "SCAN_FINAL_CHUNK", i.terminate();
1990
+ return;
1991
+ }
1992
+ r = c, t = "SCAN_CHUNK_DATA";
1993
+ } else if (t === "SCAN_CHUNK_DATA") {
1994
+ const a = Math.min(
1995
+ r,
1996
+ e.length
1997
+ ), _ = e.slice(0, a);
1998
+ e = e.slice(a), r -= a, i.enqueue(_), r === 0 && (t = "SCAN_CHUNK_TRAILER");
1999
+ } else if (t === "SCAN_CHUNK_TRAILER") {
2000
+ if (e.length < 2)
2001
+ return;
2002
+ if (e[0] !== 13 || e[1] !== 10)
2003
+ throw new Error(
2004
+ "Invalid chunk trailer format. Expected CRLF after chunk data"
2005
+ );
2006
+ e = e.slice(2), t = "SCAN_CHUNK_SIZE";
2007
+ }
2008
+ }
2009
+ });
2010
+ }
2011
+ }
2012
+ const tt = (s, e) => ({
2013
+ ...s,
2025
2014
  websocket: {
2026
- url: (e, t, r) => `ws://playground.internal/?${new URLSearchParams({
2027
- host: t,
2028
- port: r
2015
+ url: (t, r, n) => `ws://playground.internal/?${new URLSearchParams({
2016
+ host: r,
2017
+ port: n
2029
2018
  }).toString()}`,
2030
2019
  subprotocol: "binary",
2031
- decorator: () => class extends Ve {
2032
- constructor(e, t) {
2033
- super(e, t, {
2034
- CAroot: n.CAroot,
2035
- corsProxyUrl: n.corsProxyUrl
2020
+ decorator: () => class extends rt {
2021
+ constructor(t, r) {
2022
+ super(t, r, {
2023
+ CAroot: e.CAroot,
2024
+ corsProxyUrl: e.corsProxyUrl
2036
2025
  });
2037
2026
  }
2038
2027
  }
2039
2028
  }
2040
2029
  });
2041
- class Ve {
2030
+ class rt {
2042
2031
  constructor(e, t, {
2043
2032
  CAroot: r,
2044
- corsProxyUrl: s,
2033
+ corsProxyUrl: n,
2045
2034
  outputType: i = "messages"
2046
2035
  } = {}) {
2047
- this.url = e, this.options = t, this.CONNECTING = 0, this.OPEN = 1, this.CLOSING = 2, this.CLOSED = 3, this.readyState = this.CONNECTING, this.binaryType = "blob", this.bufferedAmount = 0, this.extensions = "", this.protocol = "ws", this.host = "", this.port = 0, this.listeners = /* @__PURE__ */ new Map(), this.clientUpstream = new TransformStream(), this.clientUpstreamWriter = this.clientUpstream.writable.getWriter(), this.clientDownstream = new TransformStream(), this.fetchInitiated = !1, this.bufferedBytesFromClient = new Uint8Array(0);
2048
- const _ = new URL(e);
2049
- this.host = _.searchParams.get("host"), this.port = parseInt(_.searchParams.get("port"), 10), this.binaryType = "arraybuffer", this.corsProxyUrl = s, this.CAroot = r, i === "messages" && this.clientDownstream.readable.pipeTo(
2036
+ this.CONNECTING = 0, this.OPEN = 1, this.CLOSING = 2, this.CLOSED = 3, this.readyState = this.CONNECTING, this.binaryType = "blob", this.bufferedAmount = 0, this.extensions = "", this.protocol = "ws", this.host = "", this.port = 0, this.listeners = /* @__PURE__ */ new Map(), this.clientUpstream = new TransformStream(), this.clientUpstreamWriter = this.clientUpstream.writable.getWriter(), this.clientDownstream = new TransformStream(), this.fetchInitiated = !1, this.bufferedBytesFromClient = new Uint8Array(0), this.url = e, this.options = t;
2037
+ const a = new URL(e);
2038
+ this.host = a.searchParams.get("host"), this.port = parseInt(a.searchParams.get("port"), 10), this.binaryType = "arraybuffer", this.corsProxyUrl = n, this.CAroot = r, i === "messages" && this.clientDownstream.readable.pipeTo(
2050
2039
  new WritableStream({
2051
- write: (a) => {
2052
- this.emit("message", { data: a });
2040
+ write: (_) => {
2041
+ this.emit("message", { data: _ });
2053
2042
  },
2054
2043
  abort: () => {
2055
2044
  this.emit("error", new Error("ECONNREFUSED")), this.close();
@@ -2065,8 +2054,8 @@ class Ve {
2065
2054
  this.addEventListener(e, t);
2066
2055
  }
2067
2056
  once(e, t) {
2068
- const r = (s) => {
2069
- t(s), this.removeEventListener(e, r);
2057
+ const r = (n) => {
2058
+ t(n), this.removeEventListener(e, r);
2070
2059
  };
2071
2060
  this.addEventListener(e, r);
2072
2061
  }
@@ -2084,8 +2073,8 @@ class Ve {
2084
2073
  e === "message" ? this.onmessage(t) : e === "close" ? this.onclose(t) : e === "error" ? this.onerror(t) : e === "open" && this.onopen(t);
2085
2074
  const r = this.listeners.get(e);
2086
2075
  if (r)
2087
- for (const s of r)
2088
- s(t);
2076
+ for (const n of r)
2077
+ n(t);
2089
2078
  }
2090
2079
  // Default event handlers that can be overridden by the user
2091
2080
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -2106,10 +2095,10 @@ class Ve {
2106
2095
  */
2107
2096
  send(e) {
2108
2097
  if (!(this.readyState === this.CLOSING || this.readyState === this.CLOSED) && (this.clientUpstreamWriter.write(new Uint8Array(e)), !this.fetchInitiated))
2109
- switch (this.bufferedBytesFromClient = h([
2098
+ switch (this.bufferedBytesFromClient = u([
2110
2099
  this.bufferedBytesFromClient,
2111
2100
  new Uint8Array(e)
2112
- ]), Ye(this.port, this.bufferedBytesFromClient)) {
2101
+ ]), st(this.port, this.bufferedBytesFromClient)) {
2113
2102
  case !1:
2114
2103
  return;
2115
2104
  case "other":
@@ -2128,7 +2117,7 @@ class Ve {
2128
2117
  throw new Error(
2129
2118
  "TLS protocol is only supported when the TCPOverFetchWebsocket is instantiated with a CAroot"
2130
2119
  );
2131
- const e = await qe(
2120
+ const e = await Ye(
2132
2121
  {
2133
2122
  subject: {
2134
2123
  commonName: this.host,
@@ -2138,20 +2127,20 @@ class Ve {
2138
2127
  issuer: this.CAroot.tbsDescription.subject
2139
2128
  },
2140
2129
  this.CAroot.keyPair
2141
- ), t = new Ne();
2130
+ ), t = new ze();
2142
2131
  this.clientUpstream.readable.pipeTo(t.clientEnd.upstream.writable).catch(() => {
2143
2132
  }), t.clientEnd.downstream.readable.pipeTo(this.clientDownstream.writable).catch(() => {
2144
2133
  }), await t.TLSHandshake(e.keyPair.privateKey, [
2145
2134
  e.certificate,
2146
2135
  this.CAroot.certificate
2147
2136
  ]);
2148
- const r = await y.parseHttpRequest(
2137
+ const r = await L.parseHttpRequest(
2149
2138
  t.serverEnd.upstream.readable,
2150
2139
  this.host,
2151
2140
  "https"
2152
2141
  );
2153
2142
  try {
2154
- await y.fetchRawResponseBytes(
2143
+ await L.fetchRawResponseBytes(
2155
2144
  r,
2156
2145
  this.corsProxyUrl
2157
2146
  ).pipeTo(t.serverEnd.downstream.writable);
@@ -2159,13 +2148,13 @@ class Ve {
2159
2148
  }
2160
2149
  }
2161
2150
  async fetchOverHTTP() {
2162
- const e = await y.parseHttpRequest(
2151
+ const e = await L.parseHttpRequest(
2163
2152
  this.clientUpstream.readable,
2164
2153
  this.host,
2165
2154
  "http"
2166
2155
  );
2167
2156
  try {
2168
- await y.fetchRawResponseBytes(
2157
+ await L.fetchRawResponseBytes(
2169
2158
  e,
2170
2159
  this.corsProxyUrl
2171
2160
  ).pipeTo(this.clientDownstream.writable);
@@ -2176,7 +2165,7 @@ class Ve {
2176
2165
  this.emit("message", { data: new Uint8Array(0) }), this.readyState = this.CLOSING, this.emit("close"), this.readyState = this.CLOSED;
2177
2166
  }
2178
2167
  }
2179
- const ze = [
2168
+ const nt = [
2180
2169
  "GET",
2181
2170
  "POST",
2182
2171
  "HEAD",
@@ -2186,30 +2175,30 @@ const ze = [
2186
2175
  "PUT",
2187
2176
  "TRACE"
2188
2177
  ];
2189
- function Ye(n, e) {
2178
+ function st(s, e) {
2190
2179
  if (e.length < 8)
2191
2180
  return !1;
2192
- if (n === 443 && e[0] === C.Handshake && // TLS versions between 1.0 and 1.2
2181
+ if (s === 443 && e[0] === C.Handshake && // TLS versions between 1.0 and 1.2
2193
2182
  e[1] === 3 && e[2] >= 1 && e[2] <= 3)
2194
2183
  return "tls";
2195
2184
  const r = new TextDecoder("latin1", {
2196
2185
  fatal: !0
2197
2186
  }).decode(e);
2198
- return ze.some(
2187
+ return nt.some(
2199
2188
  (i) => r.startsWith(i + " ")
2200
2189
  ) ? "http" : "other";
2201
2190
  }
2202
- class y {
2191
+ class L {
2203
2192
  /**
2204
2193
  * Streams a HTTP response including the status line and headers.
2205
2194
  */
2206
2195
  static fetchRawResponseBytes(e, t) {
2207
2196
  return new ReadableStream({
2208
2197
  async start(r) {
2209
- var a;
2210
- let s;
2198
+ var _;
2199
+ let n;
2211
2200
  try {
2212
- s = await je(
2201
+ n = await Qe(
2213
2202
  e,
2214
2203
  void 0,
2215
2204
  t
@@ -2225,21 +2214,21 @@ Content-Length: 0\r
2225
2214
  ), r.error(c);
2226
2215
  return;
2227
2216
  }
2228
- r.enqueue(y.headersAsBytes(s));
2229
- const i = (a = s.body) == null ? void 0 : a.getReader();
2217
+ r.enqueue(L.headersAsBytes(n));
2218
+ const i = (_ = n.body) == null ? void 0 : _.getReader();
2230
2219
  if (!i) {
2231
2220
  r.close();
2232
2221
  return;
2233
2222
  }
2234
- const _ = new TextEncoder();
2223
+ const a = new TextEncoder();
2235
2224
  for (; ; ) {
2236
2225
  const { done: c, value: S } = await i.read();
2237
2226
  if (S && (r.enqueue(
2238
- _.encode(`${S.length.toString(16)}\r
2227
+ a.encode(`${S.length.toString(16)}\r
2239
2228
  `)
2240
- ), r.enqueue(S), r.enqueue(_.encode(`\r
2229
+ ), r.enqueue(S), r.enqueue(a.encode(`\r
2241
2230
  `))), c) {
2242
- r.enqueue(_.encode(`0\r
2231
+ r.enqueue(a.encode(`0\r
2243
2232
  \r
2244
2233
  `)), r.close();
2245
2234
  return;
@@ -2250,13 +2239,13 @@ Content-Length: 0\r
2250
2239
  }
2251
2240
  static headersAsBytes(e) {
2252
2241
  const t = `HTTP/1.1 ${e.status} ${e.statusText}`, r = {};
2253
- e.headers.forEach((_, a) => {
2254
- r[a.toLowerCase()] = _;
2242
+ e.headers.forEach((a, _) => {
2243
+ r[_.toLowerCase()] = a;
2255
2244
  }), delete r["content-length"], r["transfer-encoding"] = "chunked";
2256
- const s = [];
2257
- for (const [_, a] of Object.entries(r))
2258
- s.push(`${_}: ${a}`);
2259
- const i = [t, ...s].join(`\r
2245
+ const n = [];
2246
+ for (const [a, _] of Object.entries(r))
2247
+ n.push(`${a}: ${_}`);
2248
+ const i = [t, ...n].join(`\r
2260
2249
  `) + `\r
2261
2250
  \r
2262
2251
  `;
@@ -2267,45 +2256,56 @@ Content-Length: 0\r
2267
2256
  * with known headers and a readable body stream.
2268
2257
  */
2269
2258
  static async parseHttpRequest(e, t, r) {
2270
- let s = new Uint8Array(0), i = !1, _ = -1;
2271
- const a = e.getReader();
2272
- for (; _ === -1; ) {
2273
- const { done: D, value: L } = await a.read();
2274
- if (D) {
2259
+ let n = new Uint8Array(0), i = !1, a = -1;
2260
+ const _ = e.getReader();
2261
+ for (; a === -1; ) {
2262
+ const { done: x, value: P } = await _.read();
2263
+ if (x) {
2275
2264
  i = !0;
2276
2265
  break;
2277
2266
  }
2278
- s = h([s, L]), _ = Je(
2279
- s,
2267
+ n = u([n, P]), a = it(
2268
+ n,
2280
2269
  new Uint8Array([13, 10, 13, 10])
2281
2270
  );
2282
2271
  }
2283
- a.releaseLock();
2284
- const c = s.slice(0, _), S = y.parseRequestHeaders(c), l = s.slice(
2285
- _ + 4
2272
+ _.releaseLock();
2273
+ const c = n.slice(0, a), S = L.parseRequestHeaders(c), h = S.headers.get("Transfer-Encoding") !== null ? "chunked" : "content-length", l = S.headers.get("Content-Length") !== null ? parseInt(S.headers.get("Content-Length"), 10) : void 0, A = n.slice(
2274
+ a + 4
2286
2275
  /* Skip \r\n\r\n */
2287
2276
  );
2288
- let A;
2277
+ let f;
2289
2278
  if (S.method !== "GET") {
2290
- const D = e.getReader();
2291
- A = new ReadableStream({
2292
- async start(L) {
2293
- l.length > 0 && L.enqueue(l), i && L.close();
2279
+ const x = e.getReader();
2280
+ let P = A.length, k = A.slice(-6);
2281
+ const Ee = new TextEncoder().encode(`0\r
2282
+ \r
2283
+ `);
2284
+ f = new ReadableStream({
2285
+ async start(D) {
2286
+ A.length > 0 && D.enqueue(A), i && D.close();
2294
2287
  },
2295
- async pull(L) {
2296
- const { done: pe, value: q } = await D.read();
2297
- if (q && L.enqueue(q), pe) {
2298
- L.close();
2288
+ async pull(D) {
2289
+ const { done: pe, value: g } = await x.read();
2290
+ if (P += (g == null ? void 0 : g.length) || 0, g && (D.enqueue(g), k = u([
2291
+ k,
2292
+ g || new Uint8Array()
2293
+ ]).slice(-5)), pe || h === "content-length" && l !== void 0 && P >= l || h === "chunked" && k.every(
2294
+ (we, ye) => we === Ee[ye]
2295
+ )) {
2296
+ D.close();
2299
2297
  return;
2300
2298
  }
2301
2299
  }
2302
- });
2300
+ }), h === "chunked" && (f = f.pipeThrough(
2301
+ new et()
2302
+ ));
2303
2303
  }
2304
- const u = S.headers.get("Host") ?? t, T = new URL(S.path, r + "://" + u);
2305
- return T.pathname = S.path, new Request(T.toString(), {
2304
+ const N = S.headers.get("Host") ?? t, z = new URL(S.path, r + "://" + N);
2305
+ return z.pathname = S.path, new Request(z.toString(), {
2306
2306
  method: S.method,
2307
2307
  headers: S.headers,
2308
- body: A,
2308
+ body: f,
2309
2309
  // In Node.js, duplex: 'half' is required when
2310
2310
  // the body stream is provided.
2311
2311
  // @ts-expect-error
@@ -2314,34 +2314,53 @@ Content-Length: 0\r
2314
2314
  }
2315
2315
  static parseRequestHeaders(e) {
2316
2316
  const t = new TextDecoder().decode(e), r = t.split(`
2317
- `)[0], [s, i] = r.split(" "), _ = new Headers();
2318
- for (const a of t.split(`\r
2317
+ `)[0], [n, i] = r.split(" "), a = new Headers();
2318
+ for (const _ of t.split(`\r
2319
2319
  `).slice(1)) {
2320
- if (a === "")
2320
+ if (_ === "")
2321
2321
  break;
2322
- const [c, S] = a.split(": ");
2323
- _.set(c, S);
2322
+ const [c, S] = _.split(": ");
2323
+ a.set(c, S);
2324
2324
  }
2325
- return { method: s, path: i, headers: _ };
2325
+ return { method: n, path: i, headers: a };
2326
2326
  }
2327
2327
  }
2328
- function Je(n, e) {
2329
- const t = n.length, r = e.length, s = t - r;
2330
- for (let i = 0; i <= s; i++) {
2331
- let _ = !0;
2332
- for (let a = 0; a < r; a++)
2333
- if (n[i + a] !== e[a]) {
2334
- _ = !1;
2328
+ function it(s, e) {
2329
+ const t = s.length, r = e.length, n = t - r;
2330
+ for (let i = 0; i <= n; i++) {
2331
+ let a = !0;
2332
+ for (let _ = 0; _ < r; _++)
2333
+ if (s[i + _] !== e[_]) {
2334
+ a = !1;
2335
2335
  break;
2336
2336
  }
2337
- if (_)
2337
+ if (a)
2338
2338
  return i;
2339
2339
  }
2340
2340
  return -1;
2341
2341
  }
2342
- const Xe = () => ({
2342
+ async function at(s) {
2343
+ const e = "icudt74l.dat", t = (await import("./shared/icudt74l.js")).dataFilename, r = await (await fetch(t)).arrayBuffer();
2344
+ return {
2345
+ ...s,
2346
+ ENV: {
2347
+ ...s.ENV,
2348
+ ICU_DATA: "/internal/shared"
2349
+ },
2350
+ onRuntimeInitialized: (n) => {
2351
+ s.onRuntimeInitialized && s.onRuntimeInitialized(n), R.fileExists(
2352
+ n.FS,
2353
+ `${n.ENV.ICU_DATA}/${e}`
2354
+ ) || (n.FS.mkdirTree(n.ENV.ICU_DATA), n.FS.writeFile(
2355
+ `${n.ENV.ICU_DATA}/${e}`,
2356
+ new Uint8Array(r)
2357
+ ));
2358
+ }
2359
+ };
2360
+ }
2361
+ const _t = () => ({
2343
2362
  websocket: {
2344
- decorator: (n) => class extends n {
2363
+ decorator: (s) => class extends s {
2345
2364
  constructor() {
2346
2365
  try {
2347
2366
  super();
@@ -2354,155 +2373,161 @@ const Xe = () => ({
2354
2373
  }
2355
2374
  }
2356
2375
  });
2357
- async function ut(n, e = {}) {
2358
- var s;
2359
- const t = await We(n);
2360
- (s = e.onPhpLoaderModuleLoaded) == null || s.call(e, t);
2361
- const r = e.tcpOverFetch ? $e(e.tcpOverFetch) : Xe();
2362
- return await me(t, {
2363
- ...e.emscriptenOptions || {},
2364
- ...r
2365
- });
2376
+ async function gt(s, e = {}) {
2377
+ var i;
2378
+ let t = {
2379
+ ..._t(),
2380
+ ...e.emscriptenOptions || {}
2381
+ };
2382
+ e.tcpOverFetch && (t = tt(
2383
+ t,
2384
+ e.tcpOverFetch
2385
+ )), e.withICU && (t = at(t));
2386
+ const [r, n] = await Promise.all([
2387
+ Be(s),
2388
+ t
2389
+ ]);
2390
+ return (i = e.onPhpLoaderModuleLoaded) == null || i.call(e, r), await ge(r, n);
2366
2391
  }
2367
- function ht(n, e) {
2392
+ function Kt(s, e) {
2368
2393
  window.addEventListener("message", (t) => {
2369
- t.source === n.contentWindow && (e && t.origin !== e || typeof t.data != "object" || t.data.type !== "relay" || window.parent.postMessage(t.data, "*"));
2394
+ t.source === s.contentWindow && (e && t.origin !== e || typeof t.data != "object" || t.data.type !== "relay" || window.parent.postMessage(t.data, "*"));
2370
2395
  }), window.addEventListener("message", (t) => {
2371
2396
  var r;
2372
- t.source === window.parent && (typeof t.data != "object" || t.data.type !== "relay" || (r = n == null ? void 0 : n.contentWindow) == null || r.postMessage(t.data));
2397
+ t.source === window.parent && (typeof t.data != "object" || t.data.type !== "relay" || (r = s == null ? void 0 : s.contentWindow) == null || r.postMessage(t.data));
2373
2398
  });
2374
2399
  }
2375
- async function Ht(n) {
2376
- const e = new Worker(n, { type: "module" });
2400
+ async function It(s) {
2401
+ const e = new Worker(s, { type: "module" });
2377
2402
  return new Promise((t, r) => {
2378
2403
  e.onerror = (i) => {
2379
- const _ = new Error(
2380
- `WebWorker failed to load at ${n}. ${i.message ? `Original error: ${i.message}` : ""}`
2404
+ const a = new Error(
2405
+ `WebWorker failed to load at ${s}. ${i.message ? `Original error: ${i.message}` : ""}`
2381
2406
  );
2382
- _.filename = i.filename, r(_);
2407
+ a.filename = i.filename, r(a);
2383
2408
  };
2384
- function s(i) {
2385
- i.data === "worker-script-started" && (t(e), e.removeEventListener("message", s));
2409
+ function n(i) {
2410
+ i.data === "worker-script-started" && (t(e), e.removeEventListener("message", n));
2386
2411
  }
2387
- e.addEventListener("message", s);
2412
+ e.addEventListener("message", n);
2388
2413
  });
2389
2414
  }
2390
- function dt(n, e = { initialSync: {} }) {
2415
+ function Dt(s, e = { initialSync: {} }) {
2391
2416
  return e = {
2392
2417
  ...e,
2393
2418
  initialSync: {
2394
2419
  ...e.initialSync,
2395
2420
  direction: e.initialSync.direction ?? "opfs-to-memfs"
2396
2421
  }
2397
- }, async function(t, r, s) {
2398
- return e.initialSync.direction === "opfs-to-memfs" ? (B.fileExists(r, s) && B.rmdir(r, s), B.mkdir(r, s), await Ze(r, n, s)) : await Ee(
2422
+ }, async function(t, r, n) {
2423
+ return e.initialSync.direction === "opfs-to-memfs" ? (R.fileExists(r, n) && R.rmdir(r, n), R.mkdir(r, n), await ot(r, s, n)) : await Te(
2399
2424
  r,
2400
- n,
2401
2425
  s,
2426
+ n,
2402
2427
  e.initialSync.onProgress
2403
- ), et(t, n, s);
2428
+ ), St(t, s, n);
2404
2429
  };
2405
2430
  }
2406
- async function Ze(n, e, t) {
2407
- B.mkdir(n, t);
2408
- const r = new Ke({
2431
+ async function ot(s, e, t) {
2432
+ R.mkdir(s, t);
2433
+ const r = new We({
2409
2434
  concurrency: 40
2410
- }), s = [], i = [
2435
+ }), n = [], i = [
2411
2436
  [e, t]
2412
2437
  ];
2413
2438
  for (; i.length > 0; ) {
2414
- const [_, a] = i.pop();
2415
- for await (const c of _.values()) {
2439
+ const [a, _] = i.pop();
2440
+ for await (const c of a.values()) {
2416
2441
  const S = r.run(async () => {
2417
- const l = se(
2418
- a,
2442
+ const h = oe(
2443
+ _,
2419
2444
  c.name
2420
2445
  );
2421
2446
  if (c.kind === "directory") {
2422
2447
  try {
2423
- n.mkdir(l);
2424
- } catch (A) {
2425
- if ((A == null ? void 0 : A.errno) !== 20)
2426
- throw R.error(A), A;
2448
+ s.mkdir(h);
2449
+ } catch (l) {
2450
+ if ((l == null ? void 0 : l.errno) !== 20)
2451
+ throw v.error(l), l;
2427
2452
  }
2428
- i.push([c, l]);
2453
+ i.push([c, h]);
2429
2454
  } else if (c.kind === "file") {
2430
- const A = await c.getFile(), u = new Uint8Array(await A.arrayBuffer());
2431
- n.createDataFile(
2432
- a,
2455
+ const l = await c.getFile(), A = new Uint8Array(await l.arrayBuffer());
2456
+ s.createDataFile(
2457
+ _,
2433
2458
  c.name,
2434
- u,
2459
+ A,
2435
2460
  !0,
2436
2461
  !0,
2437
2462
  !0
2438
2463
  );
2439
2464
  }
2440
- s.splice(s.indexOf(S), 1);
2465
+ n.splice(n.indexOf(S), 1);
2441
2466
  });
2442
- s.push(S);
2467
+ n.push(S);
2443
2468
  }
2444
- for (; i.length === 0 && s.length > 0; )
2445
- await Promise.any(s);
2469
+ for (; i.length === 0 && n.length > 0; )
2470
+ await Promise.any(n);
2446
2471
  }
2447
2472
  }
2448
- async function Ee(n, e, t, r) {
2449
- n.mkdirTree(t);
2450
- const s = [];
2451
- async function i(l, A) {
2473
+ async function Te(s, e, t, r) {
2474
+ s.mkdirTree(t);
2475
+ const n = [];
2476
+ async function i(h, l) {
2452
2477
  await Promise.all(
2453
- n.readdir(l).filter(
2454
- (u) => u !== "." && u !== ".."
2455
- ).map(async (u) => {
2456
- const T = se(l, u);
2457
- if (!Qe(n, T)) {
2458
- s.push([A, T, u]);
2478
+ s.readdir(h).filter(
2479
+ (A) => A !== "." && A !== ".."
2480
+ ).map(async (A) => {
2481
+ const f = oe(h, A);
2482
+ if (!ct(s, f)) {
2483
+ n.push([l, f, A]);
2459
2484
  return;
2460
2485
  }
2461
- const D = await A.getDirectoryHandle(u, {
2486
+ const N = await l.getDirectoryHandle(A, {
2462
2487
  create: !0
2463
2488
  });
2464
- return await i(T, D);
2489
+ return await i(f, N);
2465
2490
  })
2466
2491
  );
2467
2492
  }
2468
2493
  await i(t, e);
2469
- let _ = 0;
2470
- const a = r && rt(r, 100), c = 100, S = /* @__PURE__ */ new Set();
2494
+ let a = 0;
2495
+ const _ = r && lt(r, 100), c = 100, S = /* @__PURE__ */ new Set();
2471
2496
  try {
2472
- for (const [l, A, u] of s) {
2473
- const T = Te(
2474
- l,
2475
- u,
2476
- n,
2477
- A
2497
+ for (const [h, l, A] of n) {
2498
+ const f = F(
2499
+ h,
2500
+ A,
2501
+ s,
2502
+ l
2478
2503
  ).then(() => {
2479
- _++, S.delete(T), a == null || a({
2480
- files: _,
2481
- total: s.length
2504
+ a++, S.delete(f), _ == null || _({
2505
+ files: a,
2506
+ total: n.length
2482
2507
  });
2483
2508
  });
2484
- S.add(T), S.size >= c && (await Promise.race(S), a == null || a({
2485
- files: _,
2486
- total: s.length
2509
+ S.add(f), S.size >= c && (await Promise.race(S), _ == null || _({
2510
+ files: a,
2511
+ total: n.length
2487
2512
  }));
2488
2513
  }
2489
2514
  } finally {
2490
2515
  await Promise.allSettled(S);
2491
2516
  }
2492
2517
  }
2493
- function Qe(n, e) {
2494
- return n.isDir(n.lookupPath(e, { follow: !0 }).node.mode);
2518
+ function ct(s, e) {
2519
+ return s.isDir(s.lookupPath(e, { follow: !0 }).node.mode);
2495
2520
  }
2496
- async function Te(n, e, t, r) {
2497
- let s;
2521
+ async function F(s, e, t, r) {
2522
+ let n;
2498
2523
  try {
2499
- s = t.readFile(r, {
2524
+ n = t.readFile(r, {
2500
2525
  encoding: "binary"
2501
2526
  });
2502
2527
  } catch {
2503
2528
  return;
2504
2529
  }
2505
- const i = await n.getFileHandle(e, { create: !0 }), _ = i.createWritable !== void 0 ? (
2530
+ const i = await s.getFileHandle(e, { create: !0 }), a = i.createWritable !== void 0 ? (
2506
2531
  // Google Chrome, Firefox, probably more browsers
2507
2532
  await i.createWritable()
2508
2533
  ) : (
@@ -2510,130 +2535,140 @@ async function Te(n, e, t, r) {
2510
2535
  await i.createSyncAccessHandle()
2511
2536
  );
2512
2537
  try {
2513
- await _.truncate(0), await _.write(s);
2538
+ await a.truncate(0), await a.write(n);
2514
2539
  } finally {
2515
- await _.close();
2540
+ await a.close();
2516
2541
  }
2517
2542
  }
2518
- function et(n, e, t) {
2519
- const r = [], s = Ie(n, t, (a) => {
2520
- r.push(a);
2521
- }), i = new tt(n, e, t);
2522
- async function _() {
2523
- const a = await n.semaphore.acquire();
2543
+ function St(s, e, t) {
2544
+ const r = [], n = be(s, t, (_) => {
2545
+ r.push(_);
2546
+ }), i = new Ct(s, e, t);
2547
+ async function a() {
2548
+ const _ = await s.semaphore.acquire();
2524
2549
  try {
2525
2550
  for (; r.length; )
2526
2551
  await i.processEntry(r.shift());
2527
2552
  } finally {
2528
- a();
2553
+ _();
2529
2554
  }
2530
2555
  }
2531
- return n.addEventListener("request.end", _), function() {
2532
- s(), n.removeEventListener("request.end", _);
2556
+ return s.addEventListener("request.end", a), function() {
2557
+ n(), s.removeEventListener("request.end", a);
2533
2558
  };
2534
2559
  }
2535
- class tt {
2560
+ class Ct {
2536
2561
  constructor(e, t, r) {
2537
- this.php = e, this.opfs = t, this.memfsRoot = te(r);
2562
+ this.php = e, this.opfs = t, this.memfsRoot = ae(r);
2538
2563
  }
2539
2564
  toOpfsPath(e) {
2540
- return te(e.substring(this.memfsRoot.length));
2565
+ return ae(e.substring(this.memfsRoot.length));
2541
2566
  }
2542
2567
  async processEntry(e) {
2543
2568
  if (!e.path.startsWith(this.memfsRoot) || e.path === this.memfsRoot)
2544
2569
  return;
2545
- const t = this.toOpfsPath(e.path), r = await ne(this.opfs, t), s = re(t);
2546
- if (s)
2570
+ const t = this.toOpfsPath(e.path), r = await _e(this.opfs, t), n = ht(t);
2571
+ if (n)
2547
2572
  try {
2548
2573
  if (e.operation === "DELETE")
2549
2574
  try {
2550
- await r.removeEntry(s, {
2575
+ await r.removeEntry(n, {
2551
2576
  recursive: !0
2552
2577
  });
2553
2578
  } catch {
2554
2579
  }
2555
2580
  else if (e.operation === "CREATE")
2556
- e.nodeType === "directory" ? await r.getDirectoryHandle(s, {
2581
+ e.nodeType === "directory" ? await r.getDirectoryHandle(n, {
2557
2582
  create: !0
2558
- }) : await r.getFileHandle(s, {
2583
+ }) : await r.getFileHandle(n, {
2559
2584
  create: !0
2560
2585
  });
2561
2586
  else if (e.operation === "WRITE")
2562
- await Te(
2587
+ await F(
2563
2588
  r,
2564
- s,
2565
- this.php[k].FS,
2589
+ n,
2590
+ this.php[q].FS,
2566
2591
  e.path
2567
2592
  );
2568
2593
  else if (e.operation === "RENAME" && e.toPath.startsWith(this.memfsRoot)) {
2569
- const i = this.toOpfsPath(e.toPath), _ = await ne(
2594
+ const i = this.toOpfsPath(e.toPath), a = await _e(
2570
2595
  this.opfs,
2571
2596
  i
2572
- ), a = re(i);
2597
+ );
2573
2598
  if (e.nodeType === "directory") {
2574
- const c = await _.getDirectoryHandle(
2575
- s,
2599
+ const _ = await a.getDirectoryHandle(
2600
+ n,
2576
2601
  {
2577
2602
  create: !0
2578
2603
  }
2579
2604
  );
2580
- await Ee(
2581
- this.php[k].FS,
2582
- c,
2605
+ await Te(
2606
+ this.php[q].FS,
2607
+ _,
2583
2608
  e.toPath
2584
- ), await r.removeEntry(s, {
2609
+ ), await r.removeEntry(n, {
2585
2610
  recursive: !0
2586
2611
  });
2587
- } else
2588
- (await r.getFileHandle(s)).move(_, a);
2612
+ } else {
2613
+ try {
2614
+ await r.removeEntry(n);
2615
+ } catch {
2616
+ }
2617
+ await F(
2618
+ a,
2619
+ Re(i),
2620
+ this.php[q].FS,
2621
+ e.toPath
2622
+ );
2623
+ }
2589
2624
  }
2590
2625
  } catch (i) {
2591
- throw R.log({ entry: e, name: s }), R.error(i), i;
2626
+ throw v.log({ entry: e, name: n }), v.error(i), i;
2592
2627
  }
2593
2628
  }
2594
2629
  }
2595
- function te(n) {
2596
- return n.replace(/\/$/, "").replace(/\/\/+/g, "/");
2630
+ function ae(s) {
2631
+ return s.replace(/\/$/, "").replace(/\/\/+/g, "/");
2597
2632
  }
2598
- function re(n) {
2599
- return n.substring(n.lastIndexOf("/") + 1);
2633
+ function ht(s) {
2634
+ return s.substring(s.lastIndexOf("/") + 1);
2600
2635
  }
2601
- async function ne(n, e) {
2636
+ async function _e(s, e) {
2602
2637
  const t = e.replace(/^\/+|\/+$/g, "").replace(/\/+/, "/");
2603
2638
  if (!t)
2604
- return n;
2639
+ return s;
2605
2640
  const r = t.split("/");
2606
- let s = n;
2641
+ let n = s;
2607
2642
  for (let i = 0; i < r.length - 1; i++) {
2608
- const _ = r[i];
2609
- s = await s.getDirectoryHandle(_, { create: !0 });
2643
+ const a = r[i];
2644
+ n = await n.getDirectoryHandle(a, { create: !0 });
2610
2645
  }
2611
- return s;
2646
+ return n;
2612
2647
  }
2613
- function rt(n, e) {
2614
- let t = 0, r, s;
2615
- return function(..._) {
2616
- s = _;
2617
- const a = Date.now() - t;
2648
+ function lt(s, e) {
2649
+ let t = 0, r, n;
2650
+ return function(...a) {
2651
+ n = a;
2652
+ const _ = Date.now() - t;
2618
2653
  if (r === void 0) {
2619
- const c = Math.max(0, e - a);
2654
+ const c = Math.max(0, e - _);
2620
2655
  r = setTimeout(() => {
2621
- r = void 0, t = Date.now(), n(...s);
2656
+ r = void 0, t = Date.now(), s(...n);
2622
2657
  }, c);
2623
2658
  }
2624
2659
  };
2625
2660
  }
2626
2661
  export {
2627
- Ct as certificateToPEM,
2628
- ct as consumeAPI,
2629
- dt as createDirectoryHandleMountHandler,
2630
- St as exposeAPI,
2631
- je as fetchWithCorsProxy,
2632
- qe as generateCertificate,
2633
- We as getPHPLoaderModule,
2634
- ut as loadWebRuntime,
2635
- lt as privateKeyToPEM,
2636
- ht as setupPostMessageRelay,
2637
- Ht as spawnPHPWorkerThread
2662
+ yt as certificateToPEM,
2663
+ pt as consumeAPI,
2664
+ Dt as createDirectoryHandleMountHandler,
2665
+ wt as exposeAPI,
2666
+ Qe as fetchWithCorsProxy,
2667
+ Ye as generateCertificate,
2668
+ Be as getPHPLoaderModule,
2669
+ gt as loadWebRuntime,
2670
+ Lt as privateKeyToPEM,
2671
+ Kt as setupPostMessageRelay,
2672
+ It as spawnPHPWorkerThread
2638
2673
  };
2639
2674
  //# sourceMappingURL=index.js.map