@php-wasm/web 3.0.45 → 3.0.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -1,11 +1,12 @@
1
- import { LatestSupportedPHPVersion as O, FSHelpers as L, loadPHPRuntime as we, __private__dont__use as k } from "@php-wasm/universal";
2
- import { consumeAPI as Kt, exposeAPI as Dt } from "@php-wasm/universal";
3
- import { concatArrayBuffers as B, concatUint8Arrays as u, Semaphore as Le, joinPaths as ae, basename as ye } from "@php-wasm/util";
4
- import { logger as M } from "@php-wasm/logger";
5
- import { cloneRequest as $, teeRequest as me } from "@php-wasm/web-service-worker";
6
- import { createMemoizedFetch as ge } from "@wp-playground/common";
7
- import { journalFSEvents as Ie, normalizeFilesystemOperations as Ke } from "@php-wasm/fs-journal";
8
- async function De(i = O) {
1
+ import { LatestSupportedPHPVersion as j, FSHelpers as w, loadPHPRuntime as me, __private__dont__use as k } from "@php-wasm/universal";
2
+ import { consumeAPI as mt, exposeAPI as gt } from "@php-wasm/universal";
3
+ import { concatArrayBuffers as R, concatUint8Arrays as u, Semaphore as ge, joinPaths as ie, basename as Ie } from "@php-wasm/util";
4
+ import { logger as U } from "@php-wasm/logger";
5
+ import { fetchWithCorsProxy as Ke } from "@php-wasm/web-service-worker";
6
+ import { FirewallInterferenceError as Kt, fetchWithCorsProxy as Dt } from "@php-wasm/web-service-worker";
7
+ import { createMemoizedFetch as De } from "@wp-playground/common";
8
+ import { journalFSEvents as We, normalizeFilesystemOperations as be } from "@php-wasm/fs-journal";
9
+ async function Pe(i = j) {
9
10
  switch (i) {
10
11
  case "8.5":
11
12
  return (await import("@php-wasm/web-8-5")).getPHPLoaderModule();
@@ -27,10 +28,10 @@ async function De(i = O) {
27
28
  function f(i) {
28
29
  return Object.fromEntries(Object.entries(i).map(([e, t]) => [t, e]));
29
30
  }
30
- function D(i) {
31
+ function K(i) {
31
32
  return new Uint8Array([i >> 8 & 255, i & 255]);
32
33
  }
33
- function y(i) {
34
+ function L(i) {
34
35
  return new Uint8Array([
35
36
  i >> 16 & 255,
36
37
  i >> 8 & 255,
@@ -41,7 +42,7 @@ function V(i) {
41
42
  const e = new ArrayBuffer(8);
42
43
  return new DataView(e).setBigUint64(0, BigInt(i), !1), new Uint8Array(e);
43
44
  }
44
- class g {
45
+ class m {
45
46
  constructor(e) {
46
47
  this.offset = 0, this.buffer = e, this.view = new DataView(e);
47
48
  }
@@ -65,7 +66,7 @@ class g {
65
66
  return this.offset >= this.buffer.byteLength;
66
67
  }
67
68
  }
68
- class v {
69
+ class M {
69
70
  constructor(e) {
70
71
  this.offset = 0, this.buffer = new ArrayBuffer(e), this.uint8Array = new Uint8Array(this.buffer), this.view = new DataView(this.buffer);
71
72
  }
@@ -82,7 +83,7 @@ class v {
82
83
  this.uint8Array.set(e, this.offset), this.offset += e.length;
83
84
  }
84
85
  }
85
- const P = {
86
+ const D = {
86
87
  server_name: 0,
87
88
  max_fragment_length: 1,
88
89
  client_certificate_url: 2,
@@ -135,34 +136,35 @@ const P = {
135
136
  signature_algorithms_cert: 50,
136
137
  key_share: 51,
137
138
  transparency_info: 52,
138
- connection_id: 54
139
- }, We = f(P), _e = {
139
+ connection_id: 54,
140
+ renegotiation_info: 65281
141
+ }, Re = f(D), _e = {
140
142
  host_name: 0
141
- }, be = f(_e);
142
- class oe {
143
+ }, Be = f(_e);
144
+ class ae {
143
145
  static decodeFromClient(e) {
144
146
  const t = new DataView(e.buffer);
145
- let r = 0;
146
- const n = t.getUint16(r);
147
- r += 2;
147
+ let n = 0;
148
+ const r = t.getUint16(n);
149
+ n += 2;
148
150
  const s = [];
149
- for (; r < n + 2; ) {
150
- const a = e[r];
151
- r += 1;
152
- const _ = t.getUint16(r);
153
- r += 2;
154
- const S = e.slice(r, r + _);
155
- switch (r += _, a) {
151
+ for (; n < r + 2; ) {
152
+ const _ = e[n];
153
+ n += 1;
154
+ const a = t.getUint16(n);
155
+ n += 2;
156
+ const S = e.slice(n, n + a);
157
+ switch (n += a, _) {
156
158
  case _e.host_name:
157
159
  s.push({
158
- name_type: be[a],
160
+ name_type: Be[_],
159
161
  name: {
160
162
  host_name: new TextDecoder().decode(S)
161
163
  }
162
164
  });
163
165
  break;
164
166
  default:
165
- throw new Error(`Unsupported name type ${a}`);
167
+ throw new Error(`Unsupported name type ${_}`);
166
168
  }
167
169
  }
168
170
  return { server_name_list: s };
@@ -183,11 +185,80 @@ class oe {
183
185
  throw new Error(
184
186
  "Encoding non-empty lists for ClientHello is not supported yet. Only empty lists meant for ServerHello are supported today."
185
187
  );
186
- const t = new v(4);
187
- return t.writeUint16(P.server_name), t.writeUint16(0), t.uint8Array;
188
+ const t = new M(4);
189
+ return t.writeUint16(D.server_name), t.writeUint16(0), t.uint8Array;
188
190
  }
189
191
  }
190
- const ce = {
192
+ const oe = {
193
+ uncompressed: 0,
194
+ ansiX962_compressed_prime: 1,
195
+ ansiX962_compressed_char2: 2
196
+ }, z = f(oe);
197
+ class ce {
198
+ /**
199
+ * +--------------------------------------------------+
200
+ * | Payload Length [2B] |
201
+ * +--------------------------------------------------+
202
+ * | EC Point Formats Length [1B] |
203
+ * +--------------------------------------------------+
204
+ * | EC Point Format 1 [1B] |
205
+ * +--------------------------------------------------+
206
+ * | EC Point Format 2 [1B] |
207
+ * +--------------------------------------------------+
208
+ * | ... |
209
+ * +--------------------------------------------------+
210
+ * | EC Point Format n [1B] |
211
+ * +--------------------------------------------------+
212
+ */
213
+ static decodeFromClient(e) {
214
+ const t = new m(e.buffer), n = t.readUint8(), r = [];
215
+ for (let s = 0; s < n; s++) {
216
+ const _ = t.readUint8();
217
+ _ in z && r.push(z[_]);
218
+ }
219
+ return r;
220
+ }
221
+ /**
222
+ * Encode the ec_point_formats extension
223
+ *
224
+ * +--------------------------------------------------+
225
+ * | Extension Type (ec_point_formats) [2B] |
226
+ * | 0x00 0x0B |
227
+ * +--------------------------------------------------+
228
+ * | Body Length [2B] |
229
+ * +--------------------------------------------------+
230
+ * | EC Point Format Length [1B] |
231
+ * +--------------------------------------------------+
232
+ * | EC Point Format [1B] |
233
+ * +--------------------------------------------------+
234
+ */
235
+ static encodeForClient(e) {
236
+ const t = new M(6);
237
+ return t.writeUint16(D.ec_point_formats), t.writeUint16(2), t.writeUint8(1), t.writeUint8(oe[e]), t.uint8Array;
238
+ }
239
+ }
240
+ const Se = {
241
+ decodeFromClient(i) {
242
+ const e = i[0] ?? 0;
243
+ return {
244
+ renegotiatedConnection: i.slice(1, 1 + e)
245
+ };
246
+ },
247
+ /**
248
+ * For an initial connection (not a renegotiation), the server responds
249
+ * with an empty renegotiated_connection field.
250
+ */
251
+ encodeForClient() {
252
+ const i = D.renegotiation_info, e = new Uint8Array([0]);
253
+ return new Uint8Array([
254
+ i >> 8 & 255,
255
+ i & 255,
256
+ 0,
257
+ e.length,
258
+ ...e
259
+ ]);
260
+ }
261
+ }, Ce = {
191
262
  TLS1_CK_PSK_WITH_RC4_128_SHA: 138,
192
263
  TLS1_CK_PSK_WITH_3DES_EDE_CBC_SHA: 139,
193
264
  TLS1_CK_PSK_WITH_AES_128_CBC_SHA: 140,
@@ -390,14 +461,14 @@ const ce = {
390
461
  TLS1_CK_ECDHE_PSK_WITH_CHACHA20_POLY1305: 52396,
391
462
  TLS1_CK_DHE_PSK_WITH_CHACHA20_POLY1305: 52397,
392
463
  TLS1_CK_RSA_PSK_WITH_CHACHA20_POLY1305: 52398
393
- }, z = f(ce), Se = {
464
+ }, Y = f(Ce), Ae = {
394
465
  secp256r1: 23,
395
466
  secp384r1: 24,
396
467
  secp521r1: 25,
397
468
  x25519: 29,
398
469
  x448: 30
399
- }, Y = f(Se);
400
- class Pe {
470
+ }, Z = f(Ae);
471
+ class Ue {
401
472
  /**
402
473
  * +--------------------------------------------------+
403
474
  * | Payload Length [2B] |
@@ -414,14 +485,14 @@ class Pe {
414
485
  * +--------------------------------------------------+
415
486
  */
416
487
  static decodeFromClient(e) {
417
- const t = new g(e.buffer);
488
+ const t = new m(e.buffer);
418
489
  t.readUint16();
419
- const r = [];
490
+ const n = [];
420
491
  for (; !t.isFinished(); ) {
421
- const n = t.readUint16();
422
- n in Y && r.push(Y[n]);
492
+ const r = t.readUint16();
493
+ r in Z && n.push(Z[r]);
423
494
  }
424
- return r;
495
+ return n;
425
496
  }
426
497
  /**
427
498
  * +--------------------------------------------------+
@@ -434,64 +505,16 @@ class Pe {
434
505
  * +--------------------------------------------------+
435
506
  */
436
507
  static encodeForClient(e) {
437
- const t = new v(6);
438
- return t.writeUint16(P.supported_groups), t.writeUint16(2), t.writeUint16(Se[e]), t.uint8Array;
439
- }
440
- }
441
- const Ce = {
442
- uncompressed: 0,
443
- ansiX962_compressed_prime: 1,
444
- ansiX962_compressed_char2: 2
445
- }, X = f(Ce);
446
- class Re {
447
- /**
448
- * +--------------------------------------------------+
449
- * | Payload Length [2B] |
450
- * +--------------------------------------------------+
451
- * | EC Point Formats Length [1B] |
452
- * +--------------------------------------------------+
453
- * | EC Point Format 1 [1B] |
454
- * +--------------------------------------------------+
455
- * | EC Point Format 2 [1B] |
456
- * +--------------------------------------------------+
457
- * | ... |
458
- * +--------------------------------------------------+
459
- * | EC Point Format n [1B] |
460
- * +--------------------------------------------------+
461
- */
462
- static decodeFromClient(e) {
463
- const t = new g(e.buffer), r = t.readUint8(), n = [];
464
- for (let s = 0; s < r; s++) {
465
- const a = t.readUint8();
466
- a in X && n.push(X[a]);
467
- }
468
- return n;
469
- }
470
- /**
471
- * Encode the ec_point_formats extension
472
- *
473
- * +--------------------------------------------------+
474
- * | Extension Type (ec_point_formats) [2B] |
475
- * | 0x00 0x0B |
476
- * +--------------------------------------------------+
477
- * | Body Length [2B] |
478
- * +--------------------------------------------------+
479
- * | EC Point Format Length [1B] |
480
- * +--------------------------------------------------+
481
- * | EC Point Format [1B] |
482
- * +--------------------------------------------------+
483
- */
484
- static encodeForClient(e) {
485
- const t = new v(6);
486
- return t.writeUint16(P.ec_point_formats), t.writeUint16(2), t.writeUint8(1), t.writeUint8(Ce[e]), t.uint8Array;
508
+ const t = new M(6);
509
+ return t.writeUint16(D.supported_groups), t.writeUint16(2), t.writeUint16(Ae[e]), t.uint8Array;
487
510
  }
488
511
  }
489
- const j = {
512
+ const G = {
490
513
  anonymous: 0,
491
514
  rsa: 1,
492
515
  dsa: 2,
493
516
  ecdsa: 3
494
- }, Z = f(j), G = {
517
+ }, J = f(G), $ = {
495
518
  none: 0,
496
519
  md5: 1,
497
520
  sha1: 2,
@@ -499,8 +522,8 @@ const j = {
499
522
  sha256: 4,
500
523
  sha384: 5,
501
524
  sha512: 6
502
- }, J = f(G);
503
- class Be {
525
+ }, X = f($);
526
+ class Me {
504
527
  /**
505
528
  * Binary layout:
506
529
  *
@@ -517,23 +540,23 @@ class Be {
517
540
  * +------------------------------------+
518
541
  */
519
542
  static decodeFromClient(e) {
520
- const t = new g(e.buffer);
543
+ const t = new m(e.buffer);
521
544
  t.readUint16();
522
- const r = [];
545
+ const n = [];
523
546
  for (; !t.isFinished(); ) {
524
- const n = t.readUint8(), s = t.readUint8();
525
- if (Z[s]) {
526
- if (!J[n]) {
527
- M.warn(`Unknown hash algorithm: ${n}`);
547
+ const r = t.readUint8(), s = t.readUint8();
548
+ if (J[s]) {
549
+ if (!X[r]) {
550
+ U.warn(`Unknown hash algorithm: ${r}`);
528
551
  continue;
529
552
  }
530
- r.push({
531
- algorithm: Z[s],
532
- hash: J[n]
553
+ n.push({
554
+ algorithm: J[s],
555
+ hash: X[r]
533
556
  });
534
557
  }
535
558
  }
536
- return r;
559
+ return n;
537
560
  }
538
561
  /**
539
562
  * +--------------------------------------------------+
@@ -547,47 +570,48 @@ class Be {
547
570
  * +--------------------------------------------------+
548
571
  */
549
572
  static encodeforClient(e, t) {
550
- const r = new v(6);
551
- return r.writeUint16(P.signature_algorithms), r.writeUint16(2), r.writeUint8(G[e]), r.writeUint8(j[t]), r.uint8Array;
573
+ const n = new M(6);
574
+ return n.writeUint16(D.signature_algorithms), n.writeUint16(2), n.writeUint8($[e]), n.writeUint8(G[t]), n.uint8Array;
552
575
  }
553
576
  }
554
577
  const Q = {
555
- server_name: oe,
556
- signature_algorithms: Be,
557
- supported_groups: Pe,
558
- ec_point_formats: Re
578
+ server_name: ae,
579
+ signature_algorithms: Me,
580
+ supported_groups: Ue,
581
+ ec_point_formats: ce,
582
+ renegotiation_info: Se
559
583
  };
560
- function Ue(i) {
561
- const e = new g(i.buffer), t = [];
584
+ function ve(i) {
585
+ const e = new m(i.buffer), t = [];
562
586
  for (; !e.isFinished(); ) {
563
- const r = e.offset, n = e.readUint16(), s = We[n], a = e.readUint16(), _ = e.readUint8Array(a);
587
+ const n = e.offset, r = e.readUint16(), s = Re[r], _ = e.readUint16(), a = e.readUint8Array(_);
564
588
  if (!(s in Q))
565
589
  continue;
566
590
  const S = Q[s];
567
591
  t.push({
568
592
  type: s,
569
- data: S.decodeFromClient(_),
570
- raw: i.slice(r, r + 4 + a)
593
+ data: S.decodeFromClient(a),
594
+ raw: i.slice(n, n + 4 + _)
571
595
  });
572
596
  }
573
597
  return t;
574
598
  }
575
- async function q(i, e, t, r) {
576
- const n = B([e, t]), s = await crypto.subtle.importKey(
599
+ async function q(i, e, t, n) {
600
+ const r = R([e, t]), s = await crypto.subtle.importKey(
577
601
  "raw",
578
602
  i,
579
603
  { name: "HMAC", hash: { name: "SHA-256" } },
580
604
  !1,
581
605
  ["sign"]
582
606
  );
583
- let a = n;
584
- const _ = [];
585
- for (; B(_).byteLength < r; ) {
586
- a = await ee(s, a);
587
- const c = B([a, n]), h = await ee(s, c);
588
- _.push(h);
589
- }
590
- return B(_).slice(0, r);
607
+ let _ = r;
608
+ const a = [];
609
+ for (; R(a).byteLength < n; ) {
610
+ _ = await ee(s, _);
611
+ const c = R([_, r]), A = await ee(s, c);
612
+ a.push(A);
613
+ }
614
+ return R(a).slice(0, n);
591
615
  }
592
616
  async function ee(i, e) {
593
617
  return await crypto.subtle.sign(
@@ -596,12 +620,12 @@ async function ee(i, e) {
596
620
  e
597
621
  );
598
622
  }
599
- const Me = {
623
+ const xe = {
600
624
  Null: 0
601
- }, ve = {
625
+ }, he = {
602
626
  Warning: 1,
603
627
  Fatal: 2
604
- }, he = f(ve), xe = {
628
+ }, le = f(he), ue = {
605
629
  CloseNotify: 0,
606
630
  UnexpectedMessage: 10,
607
631
  BadRecordMac: 20,
@@ -627,12 +651,12 @@ const Me = {
627
651
  UserCanceled: 90,
628
652
  NoRenegotiation: 100,
629
653
  UnsupportedExtension: 110
630
- }, le = f(xe), C = {
654
+ }, He = f(ue), C = {
631
655
  ChangeCipherSpec: 20,
632
656
  Alert: 21,
633
657
  Handshake: 22,
634
658
  ApplicationData: 23
635
- }, E = {
659
+ }, d = {
636
660
  HelloRequest: 0,
637
661
  ClientHello: 1,
638
662
  ServerHello: 2,
@@ -653,9 +677,9 @@ const Me = {
653
677
  }, ke = {
654
678
  secp256r1: 23
655
679
  };
656
- class te extends Error {
680
+ class F extends Error {
657
681
  }
658
- const U = new Uint8Array([3, 3]), qe = crypto.subtle.generateKey(
682
+ const B = new Uint8Array([3, 3]), Fe = crypto.subtle.generateKey(
659
683
  {
660
684
  name: "ECDH",
661
685
  namedCurve: "P-256"
@@ -666,7 +690,7 @@ const U = new Uint8Array([3, 3]), qe = crypto.subtle.generateKey(
666
690
  ["deriveKey", "deriveBits"]
667
691
  // Key usage
668
692
  );
669
- class Fe {
693
+ class qe {
670
694
  constructor() {
671
695
  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 = {
672
696
  // We don't need to chunk the encrypted data.
@@ -739,41 +763,41 @@ class Fe {
739
763
  * https://datatracker.ietf.org/doc/html/rfc5246#section-7.4
740
764
  */
741
765
  async TLSHandshake(e, t) {
742
- const r = await this.readNextHandshakeMessage(
743
- E.ClientHello
766
+ const n = await this.readNextHandshakeMessage(
767
+ d.ClientHello
744
768
  );
745
- if (!r.body.cipher_suites.length)
769
+ if (!n.body.cipher_suites.length)
746
770
  throw new Error(
747
771
  "Client did not propose any supported cipher suites."
748
772
  );
749
- const n = crypto.getRandomValues(new Uint8Array(32));
773
+ const r = crypto.getRandomValues(new Uint8Array(32));
750
774
  await this.writeTLSRecord(
751
775
  C.Handshake,
752
- K.serverHello(
753
- r.body,
754
- n,
755
- Me.Null
776
+ I.serverHello(
777
+ n.body,
778
+ r,
779
+ xe.Null
756
780
  )
757
781
  ), await this.writeTLSRecord(
758
782
  C.Handshake,
759
- K.certificate(t)
783
+ I.certificate(t)
760
784
  );
761
- const s = await qe, a = r.body.random, _ = await K.ECDHEServerKeyExchange(
762
- a,
763
- n,
785
+ const s = await Fe, _ = n.body.random, a = await I.ECDHEServerKeyExchange(
786
+ _,
787
+ r,
764
788
  s,
765
789
  e
766
790
  );
767
- await this.writeTLSRecord(C.Handshake, _), await this.writeTLSRecord(
791
+ await this.writeTLSRecord(C.Handshake, a), await this.writeTLSRecord(
768
792
  C.Handshake,
769
- K.serverHelloDone()
793
+ I.serverHelloDone()
770
794
  );
771
795
  const S = await this.readNextHandshakeMessage(
772
- E.ClientKeyExchange
796
+ d.ClientKeyExchange
773
797
  );
774
798
  await this.readNextMessage(C.ChangeCipherSpec), this.sessionKeys = await this.deriveSessionKeys({
775
- clientRandom: a,
776
- serverRandom: n,
799
+ clientRandom: _,
800
+ serverRandom: r,
777
801
  serverPrivateKey: s.privateKey,
778
802
  clientPublicKey: await crypto.subtle.importKey(
779
803
  "raw",
@@ -782,12 +806,12 @@ class Fe {
782
806
  !1,
783
807
  []
784
808
  )
785
- }), await this.readNextHandshakeMessage(E.Finished), await this.writeTLSRecord(
809
+ }), await this.readNextHandshakeMessage(d.Finished), await this.writeTLSRecord(
786
810
  C.ChangeCipherSpec,
787
- K.changeCipherSpec()
811
+ I.changeCipherSpec()
788
812
  ), await this.writeTLSRecord(
789
813
  C.Handshake,
790
- await K.createFinishedMessage(
814
+ await I.createFinishedMessage(
791
815
  this.handshakeMessages,
792
816
  this.sessionKeys.masterSecret
793
817
  )
@@ -800,33 +824,33 @@ class Fe {
800
824
  async deriveSessionKeys({
801
825
  clientRandom: e,
802
826
  serverRandom: t,
803
- serverPrivateKey: r,
804
- clientPublicKey: n
827
+ serverPrivateKey: n,
828
+ clientPublicKey: r
805
829
  }) {
806
830
  const s = await crypto.subtle.deriveBits(
807
831
  {
808
832
  name: "ECDH",
809
- public: n
833
+ public: r
810
834
  },
811
- r,
835
+ n,
812
836
  256
813
837
  // Length of the derived secret (256 bits for P-256)
814
- ), a = new Uint8Array(
838
+ ), _ = new Uint8Array(
815
839
  await q(
816
840
  s,
817
841
  new TextEncoder().encode("master secret"),
818
842
  u([e, t]),
819
843
  48
820
844
  )
821
- ), _ = await q(
822
- a,
845
+ ), a = await q(
846
+ _,
823
847
  new TextEncoder().encode("key expansion"),
824
848
  u([t, e]),
825
849
  // Client key, server key, client IV, server IV
826
850
  40
827
- ), S = new g(_), c = S.readUint8Array(16), h = S.readUint8Array(16), l = S.readUint8Array(4), A = S.readUint8Array(4);
851
+ ), S = new m(a), c = S.readUint8Array(16), A = S.readUint8Array(16), h = S.readUint8Array(4), l = S.readUint8Array(4);
828
852
  return {
829
- masterSecret: a,
853
+ masterSecret: _,
830
854
  clientWriteKey: await crypto.subtle.importKey(
831
855
  "raw",
832
856
  c,
@@ -836,13 +860,13 @@ class Fe {
836
860
  ),
837
861
  serverWriteKey: await crypto.subtle.importKey(
838
862
  "raw",
839
- h,
863
+ A,
840
864
  { name: "AES-GCM" },
841
865
  !1,
842
866
  ["encrypt", "decrypt"]
843
867
  ),
844
- clientIV: l,
845
- serverIV: A
868
+ clientIV: h,
869
+ serverIV: l
846
870
  };
847
871
  }
848
872
  async readNextHandshakeMessage(e) {
@@ -852,41 +876,41 @@ class Fe {
852
876
  return t;
853
877
  }
854
878
  async readNextMessage(e) {
855
- let t, r = !1;
879
+ let t, n = !1;
856
880
  do
857
- t = await this.readNextTLSRecord(e), r = await this.accumulateUntilMessageIsComplete(
858
- t
859
- );
860
- while (r === !1);
861
- const n = T.TLSMessage(
881
+ t = await this.readNextTLSRecord(e), n = await this.accumulateUntilMessageIsComplete(t);
882
+ while (n === !1);
883
+ const r = T.TLSMessage(
862
884
  t.type,
863
- r
885
+ n
864
886
  );
865
- return t.type === C.Handshake && this.handshakeMessages.push(t.fragment), n;
887
+ return t.type === C.Handshake && this.handshakeMessages.push(t.fragment), r;
866
888
  }
867
889
  async readNextTLSRecord(e) {
868
890
  for (; ; ) {
869
- for (let _ = 0; _ < this.receivedTLSRecords.length; _++) {
870
- const S = this.receivedTLSRecords[_];
891
+ for (let a = 0; a < this.receivedTLSRecords.length; a++) {
892
+ const S = this.receivedTLSRecords[a];
871
893
  if (S.type === e)
872
- return this.receivedTLSRecords.splice(_, 1), S;
894
+ return this.receivedTLSRecords.splice(a, 1), S;
873
895
  }
874
- const t = await this.pollBytes(5), r = t[3] << 8 | t[4], n = t[0], s = await this.pollBytes(r), a = {
875
- type: n,
896
+ const t = await this.pollBytes(5), n = t[3] << 8 | t[4], r = t[0], s = await this.pollBytes(n), _ = {
897
+ type: r,
876
898
  version: {
877
899
  major: t[1],
878
900
  minor: t[2]
879
901
  },
880
- length: r,
881
- fragment: this.sessionKeys && n !== C.ChangeCipherSpec ? await this.decryptData(n, s) : s
902
+ length: n,
903
+ fragment: this.sessionKeys && r !== C.ChangeCipherSpec ? await this.decryptData(r, s) : s
882
904
  };
883
- if (a.type === C.Alert) {
884
- const _ = he[a.fragment[0]], S = le[a.fragment[1]];
885
- throw new Error(
886
- `TLS non-warning alert received: ${_} ${S}`
905
+ if (_.type === C.Alert) {
906
+ const a = _.fragment[0], S = _.fragment[1], c = le[a], A = He[S];
907
+ throw a === he.Warning && S === ue.CloseNotify ? new F(
908
+ "TLS connection closed by peer (CloseNotify)"
909
+ ) : new Error(
910
+ `TLS alert received: ${c} ${A}`
887
911
  );
888
912
  }
889
- this.receivedTLSRecords.push(a);
913
+ this.receivedTLSRecords.push(_);
890
914
  }
891
915
  }
892
916
  /**
@@ -895,12 +919,12 @@ class Fe {
895
919
  */
896
920
  async pollBytes(e) {
897
921
  for (; this.receivedBytesBuffer.length < e; ) {
898
- const { value: r, done: n } = await this.clientUpstreamReader.read();
899
- if (n)
900
- throw await this.close(), new te("TLS connection closed");
922
+ const { value: n, done: r } = await this.clientUpstreamReader.read();
923
+ if (r)
924
+ throw await this.close(), new F("TLS connection closed");
901
925
  if (this.receivedBytesBuffer = u([
902
926
  this.receivedBytesBuffer,
903
- r
927
+ n
904
928
  ]), this.receivedBytesBuffer.length >= e)
905
929
  break;
906
930
  await new Promise((s) => setTimeout(s, 100));
@@ -921,7 +945,7 @@ class Fe {
921
945
  this.serverUpstreamWriter.write(e.body);
922
946
  }
923
947
  } catch (e) {
924
- if (e instanceof te)
948
+ if (e instanceof F)
925
949
  return;
926
950
  throw e;
927
951
  }
@@ -931,16 +955,16 @@ class Fe {
931
955
  * the AES-GCM algorithm.
932
956
  */
933
957
  async decryptData(e, t) {
934
- const r = this.sessionKeys.clientIV, n = t.slice(0, 8), s = new Uint8Array([...r, ...n]), a = await crypto.subtle.decrypt(
958
+ const n = this.sessionKeys.clientIV, r = t.slice(0, 8), s = new Uint8Array([...n, ...r]), _ = await crypto.subtle.decrypt(
935
959
  {
936
960
  name: "AES-GCM",
937
961
  iv: s,
938
962
  additionalData: new Uint8Array([
939
963
  ...V(this.receivedRecordSequenceNumber),
940
964
  e,
941
- ...U,
965
+ ...B,
942
966
  // Payload length without IV and tag
943
- ...D(t.length - 8 - 16)
967
+ ...K(t.length - 8 - 16)
944
968
  ]),
945
969
  tagLength: 128
946
970
  },
@@ -948,7 +972,7 @@ class Fe {
948
972
  // Payload without the explicit IV
949
973
  t.slice(8)
950
974
  );
951
- return ++this.receivedRecordSequenceNumber, new Uint8Array(a);
975
+ return ++this.receivedRecordSequenceNumber, new Uint8Array(_);
952
976
  }
953
977
  async accumulateUntilMessageIsComplete(e) {
954
978
  this.partialTLSMessages[e.type] = u([
@@ -960,8 +984,8 @@ class Fe {
960
984
  case C.Handshake: {
961
985
  if (t.length < 4)
962
986
  return !1;
963
- const r = t[1] << 8 | t[2];
964
- if (t.length < 3 + r)
987
+ const n = t[1] << 8 | t[2];
988
+ if (t.length < 3 + n)
965
989
  return !1;
966
990
  break;
967
991
  }
@@ -987,35 +1011,35 @@ class Fe {
987
1011
  */
988
1012
  async writeTLSRecord(e, t) {
989
1013
  e === C.Handshake && this.handshakeMessages.push(t), this.sessionKeys && e !== C.ChangeCipherSpec && (t = await this.encryptData(e, t));
990
- const r = U, n = t.length, s = new Uint8Array(5);
991
- s[0] = e, s[1] = r[0], s[2] = r[1], s[3] = n >> 8 & 255, s[4] = n & 255;
992
- const a = u([s, t]);
993
- this.clientDownstreamWriter.write(a);
1014
+ const n = B, r = t.length, s = new Uint8Array(5);
1015
+ s[0] = e, s[1] = n[0], s[2] = n[1], s[3] = r >> 8 & 255, s[4] = r & 255;
1016
+ const _ = u([s, t]);
1017
+ this.clientDownstreamWriter.write(_);
994
1018
  }
995
1019
  /**
996
1020
  * Encrypts data in a TLS 1.2-compliant manner using
997
1021
  * the AES-GCM algorithm.
998
1022
  */
999
1023
  async encryptData(e, t) {
1000
- const r = this.sessionKeys.serverIV, n = crypto.getRandomValues(new Uint8Array(8)), s = new Uint8Array([...r, ...n]), a = new Uint8Array([
1024
+ const n = this.sessionKeys.serverIV, r = crypto.getRandomValues(new Uint8Array(8)), s = new Uint8Array([...n, ...r]), _ = new Uint8Array([
1001
1025
  ...V(this.sentRecordSequenceNumber),
1002
1026
  e,
1003
- ...U,
1027
+ ...B,
1004
1028
  // Payload length without IV and tag
1005
- ...D(t.length)
1006
- ]), _ = await crypto.subtle.encrypt(
1029
+ ...K(t.length)
1030
+ ]), a = await crypto.subtle.encrypt(
1007
1031
  {
1008
1032
  name: "AES-GCM",
1009
1033
  iv: s,
1010
- additionalData: a,
1034
+ additionalData: _,
1011
1035
  tagLength: 128
1012
1036
  },
1013
1037
  this.sessionKeys.serverWriteKey,
1014
1038
  t
1015
1039
  );
1016
1040
  return ++this.sentRecordSequenceNumber, u([
1017
- n,
1018
- new Uint8Array(_)
1041
+ r,
1042
+ new Uint8Array(a)
1019
1043
  ]);
1020
1044
  }
1021
1045
  }
@@ -1058,14 +1082,14 @@ class T {
1058
1082
  * https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#tls-parameters-4
1059
1083
  */
1060
1084
  static parseCipherSuites(e) {
1061
- const t = new g(e);
1085
+ const t = new m(e);
1062
1086
  t.readUint16();
1063
- const r = [];
1087
+ const n = [];
1064
1088
  for (; !t.isFinished(); ) {
1065
- const n = t.readUint16();
1066
- n in z && r.push(z[n]);
1089
+ const r = t.readUint16();
1090
+ r in Y && n.push(Y[r]);
1067
1091
  }
1068
- return r;
1092
+ return n;
1069
1093
  }
1070
1094
  static applicationData(e) {
1071
1095
  return {
@@ -1082,25 +1106,25 @@ class T {
1082
1106
  static alert(e) {
1083
1107
  return {
1084
1108
  type: C.Alert,
1085
- level: he[e[0]],
1086
- description: le[e[1]]
1109
+ level: le[e[0]],
1110
+ description: He[e[1]]
1087
1111
  };
1088
1112
  }
1089
1113
  static clientHandshake(e) {
1090
- const t = e[0], r = e[1] << 16 | e[2] << 8 | e[3], n = e.slice(4);
1114
+ const t = e[0], n = e[1] << 16 | e[2] << 8 | e[3], r = e.slice(4);
1091
1115
  let s;
1092
1116
  switch (t) {
1093
- case E.HelloRequest:
1117
+ case d.HelloRequest:
1094
1118
  s = T.clientHelloRequestPayload();
1095
1119
  break;
1096
- case E.ClientHello:
1097
- s = T.clientHelloPayload(n);
1120
+ case d.ClientHello:
1121
+ s = T.clientHelloPayload(r);
1098
1122
  break;
1099
- case E.ClientKeyExchange:
1100
- s = T.clientKeyExchangePayload(n);
1123
+ case d.ClientKeyExchange:
1124
+ s = T.clientKeyExchangePayload(r);
1101
1125
  break;
1102
- case E.Finished:
1103
- s = T.clientFinishedPayload(n);
1126
+ case d.Finished:
1127
+ s = T.clientFinishedPayload(r);
1104
1128
  break;
1105
1129
  default:
1106
1130
  throw new Error(`Invalid handshake type ${t}`);
@@ -1108,7 +1132,7 @@ class T {
1108
1132
  return {
1109
1133
  type: C.Handshake,
1110
1134
  msg_type: t,
1111
- length: r,
1135
+ length: n,
1112
1136
  body: s
1113
1137
  };
1114
1138
  }
@@ -1156,7 +1180,7 @@ class T {
1156
1180
  * +------+------+---------------------------+
1157
1181
  */
1158
1182
  static clientHelloPayload(e) {
1159
- const t = new g(e.buffer), r = {
1183
+ const t = new m(e.buffer), n = {
1160
1184
  client_version: t.readUint8Array(2),
1161
1185
  /**
1162
1186
  * Technically this consists of a GMT timestamp
@@ -1164,20 +1188,20 @@ class T {
1164
1188
  * parse this further.
1165
1189
  */
1166
1190
  random: t.readUint8Array(32)
1167
- }, n = t.readUint8();
1168
- r.session_id = t.readUint8Array(n);
1191
+ }, r = t.readUint8();
1192
+ n.session_id = t.readUint8Array(r);
1169
1193
  const s = t.readUint16();
1170
- r.cipher_suites = T.parseCipherSuites(
1194
+ n.cipher_suites = T.parseCipherSuites(
1171
1195
  t.readUint8Array(s).buffer
1172
1196
  );
1173
- const a = t.readUint8();
1174
- r.compression_methods = t.readUint8Array(
1175
- a
1197
+ const _ = t.readUint8();
1198
+ n.compression_methods = t.readUint8Array(
1199
+ _
1176
1200
  );
1177
- const _ = t.readUint16();
1178
- return r.extensions = Ue(
1179
- t.readUint8Array(_)
1180
- ), r;
1201
+ const a = t.readUint16();
1202
+ return n.extensions = ve(
1203
+ t.readUint8Array(a)
1204
+ ), n;
1181
1205
  }
1182
1206
  /**
1183
1207
  * Binary layout:
@@ -1208,19 +1232,19 @@ function Oe(i) {
1208
1232
  }
1209
1233
  });
1210
1234
  }
1211
- class K {
1235
+ class I {
1212
1236
  static certificate(e) {
1213
1237
  const t = [];
1214
1238
  for (const s of e)
1215
- t.push(y(s.byteLength)), t.push(new Uint8Array(s));
1216
- const r = u(t), n = new Uint8Array([
1217
- ...y(r.byteLength),
1218
- ...r
1239
+ t.push(L(s.byteLength)), t.push(new Uint8Array(s));
1240
+ const n = u(t), r = new Uint8Array([
1241
+ ...L(n.byteLength),
1242
+ ...n
1219
1243
  ]);
1220
1244
  return new Uint8Array([
1221
- E.Certificate,
1222
- ...y(n.length),
1223
- ...n
1245
+ d.Certificate,
1246
+ ...L(r.length),
1247
+ ...r
1224
1248
  ]);
1225
1249
  }
1226
1250
  /*
@@ -1256,38 +1280,38 @@ class K {
1256
1280
  * @param rsaPrivateKey - RSA private key for signing
1257
1281
  * @returns
1258
1282
  */
1259
- static async ECDHEServerKeyExchange(e, t, r, n) {
1283
+ static async ECDHEServerKeyExchange(e, t, n, r) {
1260
1284
  const s = new Uint8Array(
1261
- await crypto.subtle.exportKey("raw", r.publicKey)
1262
- ), a = new Uint8Array([
1285
+ await crypto.subtle.exportKey("raw", n.publicKey)
1286
+ ), _ = new Uint8Array([
1263
1287
  // Curve type (1 byte)
1264
1288
  Ne.NamedCurve,
1265
1289
  // Curve name (2 bytes)
1266
- ...D(ke.secp256r1),
1290
+ ...K(ke.secp256r1),
1267
1291
  // Public key length (1 byte)
1268
1292
  s.byteLength,
1269
1293
  // Public key (65 bytes, uncompressed format)
1270
1294
  ...s
1271
- ]), _ = await crypto.subtle.sign(
1295
+ ]), a = await crypto.subtle.sign(
1272
1296
  {
1273
1297
  name: "RSASSA-PKCS1-v1_5",
1274
1298
  hash: "SHA-256"
1275
1299
  },
1276
- n,
1277
- new Uint8Array([...e, ...t, ...a])
1278
- ), S = new Uint8Array(_), c = new Uint8Array([
1279
- G.sha256,
1280
- j.rsa
1281
- ]), h = new Uint8Array([
1282
- ...a,
1300
+ r,
1301
+ new Uint8Array([...e, ...t, ..._])
1302
+ ), S = new Uint8Array(a), c = new Uint8Array([
1303
+ $.sha256,
1304
+ G.rsa
1305
+ ]), A = new Uint8Array([
1306
+ ..._,
1283
1307
  ...c,
1284
- ...D(S.length),
1308
+ ...K(S.length),
1285
1309
  ...S
1286
1310
  ]);
1287
1311
  return new Uint8Array([
1288
- E.ServerKeyExchange,
1289
- ...y(h.length),
1290
- ...h
1312
+ d.ServerKeyExchange,
1313
+ ...L(A.length),
1314
+ ...A
1291
1315
  ]);
1292
1316
  }
1293
1317
  /**
@@ -1328,32 +1352,38 @@ class K {
1328
1352
  * | Other Extensions... |
1329
1353
  * +------------------------------------+
1330
1354
  */
1331
- static serverHello(e, t, r) {
1332
- const n = e.extensions.map((_) => {
1333
- switch (_.type) {
1355
+ static serverHello(e, t, n) {
1356
+ const r = e.extensions.map((a) => {
1357
+ switch (a.type) {
1334
1358
  case "server_name":
1335
- return oe.encodeForClient();
1359
+ return ae.encodeForClient();
1360
+ case "ec_point_formats":
1361
+ return ce.encodeForClient(
1362
+ "uncompressed"
1363
+ );
1364
+ case "renegotiation_info":
1365
+ return Se.encodeForClient();
1336
1366
  }
1337
- }).filter((_) => _ !== void 0), s = u(n), a = new Uint8Array([
1367
+ }).filter((a) => a !== void 0), s = u(r), _ = new Uint8Array([
1338
1368
  // Version field – 0x03, 0x03 means TLS 1.2
1339
- ...U,
1369
+ ...B,
1340
1370
  ...t,
1341
1371
  e.session_id.length,
1342
1372
  ...e.session_id,
1343
- ...D(ce.TLS1_CK_ECDHE_RSA_WITH_AES_128_GCM_SHA256),
1344
- r,
1373
+ ...K(Ce.TLS1_CK_ECDHE_RSA_WITH_AES_128_GCM_SHA256),
1374
+ n,
1345
1375
  // Extensions length (2 bytes)
1346
- ...D(s.length),
1376
+ ...K(s.length),
1347
1377
  ...s
1348
1378
  ]);
1349
1379
  return new Uint8Array([
1350
- E.ServerHello,
1351
- ...y(a.length),
1352
- ...a
1380
+ d.ServerHello,
1381
+ ...L(_.length),
1382
+ ..._
1353
1383
  ]);
1354
1384
  }
1355
1385
  static serverHelloDone() {
1356
- return new Uint8Array([E.ServerHelloDone, ...y(0)]);
1386
+ return new Uint8Array([d.ServerHelloDone, ...L(0)]);
1357
1387
  }
1358
1388
  /**
1359
1389
  * Server finished message.
@@ -1374,22 +1404,22 @@ class K {
1374
1404
  * the string "server finished".
1375
1405
  */
1376
1406
  static async createFinishedMessage(e, t) {
1377
- const r = await crypto.subtle.digest(
1407
+ const n = await crypto.subtle.digest(
1378
1408
  "SHA-256",
1379
1409
  u(e)
1380
- ), n = new Uint8Array(
1410
+ ), r = new Uint8Array(
1381
1411
  await q(
1382
1412
  t,
1383
1413
  new TextEncoder().encode("server finished"),
1384
- r,
1414
+ n,
1385
1415
  // verify_data length. TLS 1.2 specifies 12 bytes for verify_data
1386
1416
  12
1387
1417
  )
1388
1418
  );
1389
1419
  return new Uint8Array([
1390
- E.Finished,
1391
- ...y(n.length),
1392
- ...n
1420
+ d.Finished,
1421
+ ...L(r.length),
1422
+ ...r
1393
1423
  ]);
1394
1424
  }
1395
1425
  static changeCipherSpec() {
@@ -1399,24 +1429,24 @@ class K {
1399
1429
  function je(i, e) {
1400
1430
  return Ge.generateCertificate(i, e);
1401
1431
  }
1402
- function Tt(i) {
1432
+ function Ht(i) {
1403
1433
  return `-----BEGIN CERTIFICATE-----
1404
- ${ue(
1405
- Ae(i.buffer)
1434
+ ${Ee(
1435
+ de(i.buffer)
1406
1436
  )}
1407
1437
  -----END CERTIFICATE-----`;
1408
1438
  }
1409
- async function ft(i) {
1439
+ async function dt(i) {
1410
1440
  const e = await crypto.subtle.exportKey("pkcs8", i);
1411
1441
  return `-----BEGIN PRIVATE KEY-----
1412
- ${ue(
1413
- Ae(e)
1442
+ ${Ee(
1443
+ de(e)
1414
1444
  )}
1415
1445
  -----END PRIVATE KEY-----`;
1416
1446
  }
1417
1447
  class Ge {
1418
1448
  static async generateCertificate(e, t) {
1419
- const r = await crypto.subtle.generateKey(
1449
+ const n = await crypto.subtle.generateKey(
1420
1450
  {
1421
1451
  name: "RSASSA-PKCS1-v1_5",
1422
1452
  hash: "SHA-256",
@@ -1426,22 +1456,22 @@ class Ge {
1426
1456
  !0,
1427
1457
  // extractable
1428
1458
  ["sign", "verify"]
1429
- ), n = await this.signingRequest(
1459
+ ), r = await this.signingRequest(
1430
1460
  e,
1431
- r.publicKey
1461
+ n.publicKey
1432
1462
  ), s = await this.sign(
1433
- n,
1434
- (t == null ? void 0 : t.privateKey) ?? r.privateKey
1463
+ r,
1464
+ (t == null ? void 0 : t.privateKey) ?? n.privateKey
1435
1465
  );
1436
1466
  return {
1437
- keyPair: r,
1467
+ keyPair: n,
1438
1468
  certificate: s,
1439
- tbsCertificate: n,
1469
+ tbsCertificate: r,
1440
1470
  tbsDescription: e
1441
1471
  };
1442
1472
  }
1443
1473
  static async sign(e, t) {
1444
- const r = await crypto.subtle.sign(
1474
+ const n = await crypto.subtle.sign(
1445
1475
  {
1446
1476
  name: "RSASSA-PKCS1-v1_5",
1447
1477
  hash: "SHA-256"
@@ -1452,12 +1482,12 @@ class Ge {
1452
1482
  return o.sequence([
1453
1483
  new Uint8Array(e.buffer),
1454
1484
  this.signatureAlgorithm("sha256WithRSAEncryption"),
1455
- o.bitString(new Uint8Array(r))
1485
+ o.bitString(new Uint8Array(n))
1456
1486
  ]);
1457
1487
  }
1458
1488
  static async signingRequest(e, t) {
1459
- const r = [];
1460
- return e.keyUsage && r.push(this.keyUsage(e.keyUsage)), e.extKeyUsage && r.push(this.extKeyUsage(e.extKeyUsage)), e.subjectAltNames && r.push(this.subjectAltName(e.subjectAltNames)), e.nsCertType && r.push(this.nsCertType(e.nsCertType)), e.basicConstraints && r.push(
1489
+ const n = [];
1490
+ return e.keyUsage && n.push(this.keyUsage(e.keyUsage)), e.extKeyUsage && n.push(this.extKeyUsage(e.extKeyUsage)), e.subjectAltNames && n.push(this.subjectAltName(e.subjectAltNames)), e.nsCertType && n.push(this.nsCertType(e.nsCertType)), e.basicConstraints && n.push(
1461
1491
  this.basicConstraints(e.basicConstraints)
1462
1492
  ), o.sequence([
1463
1493
  this.version(e.version),
@@ -1467,7 +1497,7 @@ class Ge {
1467
1497
  this.validity(e.validity),
1468
1498
  this.distinguishedName(e.subject),
1469
1499
  await this.subjectPublicKeyInfo(t),
1470
- this.extensions(r)
1500
+ this.extensions(n)
1471
1501
  ]);
1472
1502
  }
1473
1503
  static version(e = 2) {
@@ -1481,7 +1511,7 @@ class Ge {
1481
1511
  }
1482
1512
  static signatureAlgorithm(e = "sha256WithRSAEncryption") {
1483
1513
  return o.sequence([
1484
- o.objectIdentifier(w(e)),
1514
+ o.objectIdentifier(p(e)),
1485
1515
  o.null()
1486
1516
  ]);
1487
1517
  }
@@ -1493,16 +1523,16 @@ class Ge {
1493
1523
  }
1494
1524
  static distinguishedName(e) {
1495
1525
  const t = [];
1496
- for (const [r, n] of Object.entries(e)) {
1526
+ for (const [n, r] of Object.entries(e)) {
1497
1527
  const s = [
1498
- o.objectIdentifier(w(r))
1528
+ o.objectIdentifier(p(n))
1499
1529
  ];
1500
- switch (r) {
1530
+ switch (n) {
1501
1531
  case "countryName":
1502
- s.push(o.printableString(n));
1532
+ s.push(o.printableString(r));
1503
1533
  break;
1504
1534
  default:
1505
- s.push(o.utf8String(n));
1535
+ s.push(o.utf8String(r));
1506
1536
  }
1507
1537
  t.push(o.set([o.sequence(s)]));
1508
1538
  }
@@ -1511,13 +1541,13 @@ class Ge {
1511
1541
  static validity(e) {
1512
1542
  return o.sequence([
1513
1543
  o.ASN1(
1514
- d.UTCTime,
1544
+ H.UTCTime,
1515
1545
  new TextEncoder().encode(
1516
1546
  ne((e == null ? void 0 : e.notBefore) ?? /* @__PURE__ */ new Date())
1517
1547
  )
1518
1548
  ),
1519
1549
  o.ASN1(
1520
- d.UTCTime,
1550
+ H.UTCTime,
1521
1551
  new TextEncoder().encode(
1522
1552
  ne(
1523
1553
  (e == null ? void 0 : e.notAfter) ?? Ve(/* @__PURE__ */ new Date(), 10)
@@ -1530,18 +1560,18 @@ class Ge {
1530
1560
  ca: e = !0,
1531
1561
  pathLenConstraint: t = void 0
1532
1562
  }) {
1533
- const r = [o.boolean(e)];
1534
- return t !== void 0 && r.push(
1563
+ const n = [o.boolean(e)];
1564
+ return t !== void 0 && n.push(
1535
1565
  o.integer(new Uint8Array([t]))
1536
1566
  ), o.sequence([
1537
- o.objectIdentifier(w("basicConstraints")),
1538
- o.octetString(o.sequence(r))
1567
+ o.objectIdentifier(p("basicConstraints")),
1568
+ o.octetString(o.sequence(n))
1539
1569
  ]);
1540
1570
  }
1541
1571
  static keyUsage(e) {
1542
1572
  const t = new Uint8Array([0]);
1543
1573
  return e != null && e.digitalSignature && (t[0] |= 1), e != null && e.nonRepudiation && (t[0] |= 2), e != null && e.keyEncipherment && (t[0] |= 4), e != null && e.dataEncipherment && (t[0] |= 8), e != null && e.keyAgreement && (t[0] |= 16), e != null && e.keyCertSign && (t[0] |= 32), e != null && e.cRLSign && (t[0] |= 64), e != null && e.encipherOnly && (t[0] |= 128), e != null && e.decipherOnly && (t[0] |= 64), o.sequence([
1544
- o.objectIdentifier(w("keyUsage")),
1574
+ o.objectIdentifier(p("keyUsage")),
1545
1575
  o.boolean(!0),
1546
1576
  // Critical
1547
1577
  o.octetString(o.bitString(t))
@@ -1549,13 +1579,13 @@ class Ge {
1549
1579
  }
1550
1580
  static extKeyUsage(e = {}) {
1551
1581
  return o.sequence([
1552
- o.objectIdentifier(w("extKeyUsage")),
1582
+ o.objectIdentifier(p("extKeyUsage")),
1553
1583
  o.boolean(!0),
1554
1584
  // Critical
1555
1585
  o.octetString(
1556
1586
  o.sequence(
1557
- Object.entries(e).map(([t, r]) => r ? o.objectIdentifier(
1558
- w(t)
1587
+ Object.entries(e).map(([t, n]) => n ? o.objectIdentifier(
1588
+ p(t)
1559
1589
  ) : o.null())
1560
1590
  )
1561
1591
  )
@@ -1564,25 +1594,25 @@ class Ge {
1564
1594
  static nsCertType(e) {
1565
1595
  const t = new Uint8Array([0]);
1566
1596
  return e.client && (t[0] |= 1), e.server && (t[0] |= 2), e.email && (t[0] |= 4), e.objsign && (t[0] |= 8), e.sslCA && (t[0] |= 16), e.emailCA && (t[0] |= 32), e.objCA && (t[0] |= 64), o.sequence([
1567
- o.objectIdentifier(w("nsCertType")),
1597
+ o.objectIdentifier(p("nsCertType")),
1568
1598
  o.octetString(t)
1569
1599
  ]);
1570
1600
  }
1571
1601
  static subjectAltName(e) {
1572
- var s, a;
1573
- const t = ((s = e.dnsNames) == null ? void 0 : s.map((_) => {
1574
- const S = o.ia5String(_);
1602
+ var s, _;
1603
+ const t = ((s = e.dnsNames) == null ? void 0 : s.map((a) => {
1604
+ const S = o.ia5String(a);
1575
1605
  return o.contextSpecific(2, S);
1576
- })) || [], r = ((a = e.ipAddresses) == null ? void 0 : a.map((_) => {
1577
- const S = o.ia5String(_);
1606
+ })) || [], n = ((_ = e.ipAddresses) == null ? void 0 : _.map((a) => {
1607
+ const S = o.ia5String(a);
1578
1608
  return o.contextSpecific(7, S);
1579
- })) || [], n = o.octetString(
1580
- o.sequence([...t, ...r])
1609
+ })) || [], r = o.octetString(
1610
+ o.sequence([...t, ...n])
1581
1611
  );
1582
1612
  return o.sequence([
1583
- o.objectIdentifier(w("subjectAltName")),
1613
+ o.objectIdentifier(p("subjectAltName")),
1584
1614
  o.boolean(!0),
1585
- n
1615
+ r
1586
1616
  ]);
1587
1617
  }
1588
1618
  }
@@ -1696,13 +1726,13 @@ const $e = {
1696
1726
  "1.3.6.1.5.5.7.3.4": "emailProtection",
1697
1727
  "1.3.6.1.5.5.7.3.8": "timeStamping"
1698
1728
  };
1699
- function w(i) {
1729
+ function p(i) {
1700
1730
  for (const [e, t] of Object.entries($e))
1701
1731
  if (t === i)
1702
1732
  return e;
1703
1733
  throw new Error(`OID not found for name: ${i}`);
1704
1734
  }
1705
- const re = 32, d = {
1735
+ const te = 32, H = {
1706
1736
  Boolean: 1,
1707
1737
  Integer: 2,
1708
1738
  BitString: 3,
@@ -1710,8 +1740,8 @@ const re = 32, d = {
1710
1740
  Null: 5,
1711
1741
  OID: 6,
1712
1742
  Utf8String: 12,
1713
- Sequence: 16 | re,
1714
- Set: 17 | re,
1743
+ Sequence: 16 | te,
1744
+ Set: 17 | te,
1715
1745
  PrintableString: 19,
1716
1746
  IA5String: 22,
1717
1747
  UTCTime: 23
@@ -1723,91 +1753,91 @@ class o {
1723
1753
  return new Uint8Array([e]);
1724
1754
  {
1725
1755
  let t = e;
1726
- const r = [];
1756
+ const n = [];
1727
1757
  for (; t > 0; )
1728
- r.unshift(t & 255), t >>= 8;
1729
- const n = r.length, s = new Uint8Array(1 + n);
1730
- s[0] = 128 | n;
1731
- for (let a = 0; a < n; a++)
1732
- s[a + 1] = r[a];
1758
+ n.unshift(t & 255), t >>= 8;
1759
+ const r = n.length, s = new Uint8Array(1 + r);
1760
+ s[0] = 128 | r;
1761
+ for (let _ = 0; _ < r; _++)
1762
+ s[_ + 1] = n[_];
1733
1763
  return s;
1734
1764
  }
1735
1765
  }
1736
1766
  static ASN1(e, t) {
1737
- const r = o.length_(t.length), n = new Uint8Array(1 + r.length + t.length);
1738
- return n[0] = e, n.set(r, 1), n.set(t, 1 + r.length), n;
1767
+ const n = o.length_(t.length), r = new Uint8Array(1 + n.length + t.length);
1768
+ return r[0] = e, r.set(n, 1), r.set(t, 1 + n.length), r;
1739
1769
  }
1740
1770
  static integer(e) {
1741
1771
  if (e[0] > 127) {
1742
1772
  const t = new Uint8Array(e.length + 1);
1743
1773
  t[0] = 0, t.set(e, 1), e = t;
1744
1774
  }
1745
- return o.ASN1(d.Integer, e);
1775
+ return o.ASN1(H.Integer, e);
1746
1776
  }
1747
1777
  static bitString(e) {
1748
- const t = new Uint8Array([0]), r = new Uint8Array(t.length + e.length);
1749
- return r.set(t), r.set(e, t.length), o.ASN1(d.BitString, r);
1778
+ const t = new Uint8Array([0]), n = new Uint8Array(t.length + e.length);
1779
+ return n.set(t), n.set(e, t.length), o.ASN1(H.BitString, n);
1750
1780
  }
1751
1781
  static octetString(e) {
1752
- return o.ASN1(d.OctetString, e);
1782
+ return o.ASN1(H.OctetString, e);
1753
1783
  }
1754
1784
  static null() {
1755
- return o.ASN1(d.Null, new Uint8Array(0));
1785
+ return o.ASN1(H.Null, new Uint8Array(0));
1756
1786
  }
1757
1787
  static objectIdentifier(e) {
1758
- const t = e.split(".").map(Number), n = [t[0] * 40 + t[1]];
1788
+ const t = e.split(".").map(Number), r = [t[0] * 40 + t[1]];
1759
1789
  for (let s = 2; s < t.length; s++) {
1760
- let a = t[s];
1761
- const _ = [];
1790
+ let _ = t[s];
1791
+ const a = [];
1762
1792
  do
1763
- _.unshift(a & 127), a >>= 7;
1764
- while (a > 0);
1765
- for (let S = 0; S < _.length - 1; S++)
1766
- _[S] |= 128;
1767
- n.push(..._);
1793
+ a.unshift(_ & 127), _ >>= 7;
1794
+ while (_ > 0);
1795
+ for (let S = 0; S < a.length - 1; S++)
1796
+ a[S] |= 128;
1797
+ r.push(...a);
1768
1798
  }
1769
- return o.ASN1(d.OID, new Uint8Array(n));
1799
+ return o.ASN1(H.OID, new Uint8Array(r));
1770
1800
  }
1771
1801
  static utf8String(e) {
1772
1802
  const t = new TextEncoder().encode(e);
1773
- return o.ASN1(d.Utf8String, t);
1803
+ return o.ASN1(H.Utf8String, t);
1774
1804
  }
1775
1805
  static printableString(e) {
1776
1806
  const t = new TextEncoder().encode(e);
1777
- return o.ASN1(d.PrintableString, t);
1807
+ return o.ASN1(H.PrintableString, t);
1778
1808
  }
1779
1809
  static sequence(e) {
1780
- return o.ASN1(d.Sequence, u(e));
1810
+ return o.ASN1(H.Sequence, u(e));
1781
1811
  }
1782
1812
  static set(e) {
1783
- return o.ASN1(d.Set, u(e));
1813
+ return o.ASN1(H.Set, u(e));
1784
1814
  }
1785
1815
  static ia5String(e) {
1786
1816
  const t = new TextEncoder().encode(e);
1787
- return o.ASN1(d.IA5String, t);
1817
+ return o.ASN1(H.IA5String, t);
1788
1818
  }
1789
- static contextSpecific(e, t, r = !1) {
1790
- const n = (r ? 160 : 128) | e;
1791
- return o.ASN1(n, t);
1819
+ static contextSpecific(e, t, n = !1) {
1820
+ const r = (n ? 160 : 128) | e;
1821
+ return o.ASN1(r, t);
1792
1822
  }
1793
1823
  static boolean(e) {
1794
1824
  return o.ASN1(
1795
- d.Boolean,
1825
+ H.Boolean,
1796
1826
  new Uint8Array([e ? 255 : 0])
1797
1827
  );
1798
1828
  }
1799
1829
  }
1800
- function Ae(i) {
1830
+ function de(i) {
1801
1831
  return btoa(String.fromCodePoint(...new Uint8Array(i)));
1802
1832
  }
1803
- function ue(i) {
1833
+ function Ee(i) {
1804
1834
  var e;
1805
1835
  return ((e = i.match(/.{1,64}/g)) == null ? void 0 : e.join(`
1806
1836
  `)) || i;
1807
1837
  }
1808
1838
  function ne(i) {
1809
- const e = i.getUTCFullYear().toString().substr(2), t = b(i.getUTCMonth() + 1), r = b(i.getUTCDate()), n = b(i.getUTCHours()), s = b(i.getUTCMinutes()), a = b(i.getUTCSeconds());
1810
- return `${e}${t}${r}${n}${s}${a}Z`;
1839
+ const e = i.getUTCFullYear().toString().substr(2), t = b(i.getUTCMonth() + 1), n = b(i.getUTCDate()), r = b(i.getUTCHours()), s = b(i.getUTCMinutes()), _ = b(i.getUTCSeconds());
1840
+ return `${e}${t}${n}${r}${s}${_}Z`;
1811
1841
  }
1812
1842
  function b(i) {
1813
1843
  return i.toString().padStart(2, "0");
@@ -1816,85 +1846,46 @@ function Ve(i, e) {
1816
1846
  const t = new Date(i);
1817
1847
  return t.setUTCFullYear(t.getUTCFullYear() + e), t;
1818
1848
  }
1819
- class ze extends Error {
1820
- constructor(e, t, r) {
1821
- super(
1822
- `Could not fetch ${e} – your network appears to be blocking this request (HTTP ${t}). This often happens on school, university, or corporate networks. Try switching to a different network or using a VPN.`
1823
- ), this.name = "FirewallInterferenceError", this.url = e, this.status = t, this.statusText = r;
1824
- }
1825
- }
1826
- const Ye = "X-Playground-Cors-Proxy";
1827
- async function Xe(i, e, t, r) {
1828
- var c;
1829
- let n = typeof i == "string" ? new Request(i, e) : i;
1830
- const s = r ? new URL(r) : null;
1831
- let a = s ? new URL(n.url, s) : new URL(n.url);
1832
- if (a.protocol === "http:") {
1833
- a.protocol = "https:";
1834
- const h = a.toString();
1835
- n = await $(n, { url: h }), a = new URL(h);
1836
- }
1837
- if (!t)
1838
- return await fetch(n);
1839
- if (s && a.protocol === s.protocol && a.hostname === s.hostname && a.port === s.port && a.pathname.startsWith(s.pathname))
1840
- return await fetch(n);
1841
- const [_, S] = await me(n);
1842
- try {
1843
- return await fetch(_);
1844
- } catch {
1845
- const l = ((c = new Headers(S.headers).get("x-cors-proxy-allowed-request-headers")) == null ? void 0 : c.split(",")) || [], A = l.includes("authorization") || l.includes("cookie"), H = await $(S, {
1846
- url: `${t}${n.url}`,
1847
- ...A && { credentials: "include" }
1848
- }), p = await fetch(H, e);
1849
- if (!p.headers.has(Ye))
1850
- throw new ze(
1851
- n.url,
1852
- p.status,
1853
- p.statusText
1854
- );
1855
- return p;
1856
- }
1857
- }
1858
- class Ze extends TransformStream {
1849
+ class ze extends TransformStream {
1859
1850
  constructor() {
1860
- let e = new Uint8Array(0), t = "SCAN_CHUNK_SIZE", r = 0;
1851
+ let e = new Uint8Array(0), t = "SCAN_CHUNK_SIZE", n = 0;
1861
1852
  super({
1862
- transform(n, s) {
1863
- for (e = u([e, n]); e.length > 0; )
1853
+ transform(r, s) {
1854
+ for (e = u([e, r]); e.length > 0; )
1864
1855
  if (t === "SCAN_CHUNK_SIZE") {
1865
1856
  if (e.length < 3)
1866
1857
  return;
1867
- let a = 0;
1868
- for (; a < e.length; ) {
1869
- const c = e[a];
1858
+ let _ = 0;
1859
+ for (; _ < e.length; ) {
1860
+ const c = e[_];
1870
1861
  if (!(c >= 48 && c <= 57 || // 0-9
1871
1862
  c >= 97 && c <= 102 || // a-f
1872
1863
  c >= 65 && c <= 70)) break;
1873
- a++;
1864
+ _++;
1874
1865
  }
1875
- if (a === 0)
1866
+ if (_ === 0)
1876
1867
  throw new Error("Invalid chunk size format");
1877
- if (e.length < a + 2)
1868
+ if (e.length < _ + 2)
1878
1869
  return;
1879
- if (e[a] !== 13 || // \r
1880
- e[a + 1] !== 10)
1870
+ if (e[_] !== 13 || // \r
1871
+ e[_ + 1] !== 10)
1881
1872
  throw new Error(
1882
1873
  "Invalid chunk size format. Expected CRLF after chunk size"
1883
1874
  );
1884
- const _ = new TextDecoder().decode(
1885
- e.slice(0, a)
1886
- ), S = parseInt(_, 16);
1887
- if (e = e.slice(a + 2), S === 0) {
1875
+ const a = new TextDecoder().decode(
1876
+ e.slice(0, _)
1877
+ ), S = parseInt(a, 16);
1878
+ if (e = e.slice(_ + 2), S === 0) {
1888
1879
  t = "SCAN_FINAL_CHUNK", s.terminate();
1889
1880
  return;
1890
1881
  }
1891
- r = S, t = "SCAN_CHUNK_DATA";
1882
+ n = S, t = "SCAN_CHUNK_DATA";
1892
1883
  } else if (t === "SCAN_CHUNK_DATA") {
1893
- const a = Math.min(
1894
- r,
1884
+ const _ = Math.min(
1885
+ n,
1895
1886
  e.length
1896
- ), _ = e.slice(0, a);
1897
- e = e.slice(a), r -= a, s.enqueue(_), r === 0 && (t = "SCAN_CHUNK_TRAILER");
1887
+ ), a = e.slice(0, _);
1888
+ e = e.slice(_), n -= _, s.enqueue(a), n === 0 && (t = "SCAN_CHUNK_TRAILER");
1898
1889
  } else if (t === "SCAN_CHUNK_TRAILER") {
1899
1890
  if (e.length < 2)
1900
1891
  return;
@@ -1908,17 +1899,17 @@ class Ze extends TransformStream {
1908
1899
  });
1909
1900
  }
1910
1901
  }
1911
- const Je = (i, e) => ({
1902
+ const Ye = (i, e) => ({
1912
1903
  ...i,
1913
1904
  websocket: {
1914
- url: (t, r, n) => `ws://playground.internal/?${new URLSearchParams({
1915
- host: r,
1916
- port: n
1905
+ url: (t, n, r) => `ws://playground.internal/?${new URLSearchParams({
1906
+ host: n,
1907
+ port: r
1917
1908
  }).toString()}`,
1918
1909
  subprotocol: "binary",
1919
- decorator: () => class extends Qe {
1920
- constructor(t, r) {
1921
- super(t, r, {
1910
+ decorator: () => class extends Ze {
1911
+ constructor(t, n) {
1912
+ super(t, n, {
1922
1913
  CAroot: e.CAroot,
1923
1914
  corsProxyUrl: e.corsProxyUrl
1924
1915
  });
@@ -1926,18 +1917,18 @@ const Je = (i, e) => ({
1926
1917
  }
1927
1918
  }
1928
1919
  });
1929
- class Qe {
1920
+ class Ze {
1930
1921
  constructor(e, t, {
1931
- CAroot: r,
1932
- corsProxyUrl: n,
1922
+ CAroot: n,
1923
+ corsProxyUrl: r,
1933
1924
  outputType: s = "messages"
1934
1925
  } = {}) {
1935
1926
  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;
1936
- const a = new URL(e);
1937
- this.host = a.searchParams.get("host"), this.port = parseInt(a.searchParams.get("port"), 10), this.binaryType = "arraybuffer", this.corsProxyUrl = n, this.CAroot = r, s === "messages" && this.clientDownstream.readable.pipeTo(
1927
+ const _ = new URL(e);
1928
+ this.host = _.searchParams.get("host"), this.port = parseInt(_.searchParams.get("port"), 10), this.binaryType = "arraybuffer", this.corsProxyUrl = r, this.CAroot = n, s === "messages" && this.clientDownstream.readable.pipeTo(
1938
1929
  new WritableStream({
1939
- write: (_) => {
1940
- this.emit("message", { data: _ });
1930
+ write: (a) => {
1931
+ this.emit("message", { data: a });
1941
1932
  },
1942
1933
  abort: () => {
1943
1934
  this.emit("error", new Error("ECONNREFUSED")), this.close();
@@ -1953,10 +1944,10 @@ class Qe {
1953
1944
  this.addEventListener(e, t);
1954
1945
  }
1955
1946
  once(e, t) {
1956
- const r = (n) => {
1957
- t(n), this.removeEventListener(e, r);
1947
+ const n = (r) => {
1948
+ t(r), this.removeEventListener(e, n);
1958
1949
  };
1959
- this.addEventListener(e, r);
1950
+ this.addEventListener(e, n);
1960
1951
  }
1961
1952
  addEventListener(e, t) {
1962
1953
  this.listeners.has(e) || this.listeners.set(e, /* @__PURE__ */ new Set()), this.listeners.get(e).add(t);
@@ -1965,15 +1956,15 @@ class Qe {
1965
1956
  this.removeEventListener(e, t);
1966
1957
  }
1967
1958
  removeEventListener(e, t) {
1968
- const r = this.listeners.get(e);
1969
- r && r.delete(t);
1959
+ const n = this.listeners.get(e);
1960
+ n && n.delete(t);
1970
1961
  }
1971
1962
  emit(e, t = {}) {
1972
1963
  e === "message" ? this.onmessage(t) : e === "close" ? this.onclose(t) : e === "error" ? this.onerror(t) : e === "open" && this.onopen(t);
1973
- const r = this.listeners.get(e);
1974
- if (r)
1975
- for (const n of r)
1976
- n(t);
1964
+ const n = this.listeners.get(e);
1965
+ if (n)
1966
+ for (const r of n)
1967
+ r(t);
1977
1968
  }
1978
1969
  // Default event handlers that can be overridden by the user
1979
1970
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -1997,7 +1988,7 @@ class Qe {
1997
1988
  switch (this.bufferedBytesFromClient = u([
1998
1989
  this.bufferedBytesFromClient,
1999
1990
  new Uint8Array(e)
2000
- ]), tt(this.port, this.bufferedBytesFromClient)) {
1991
+ ]), Xe(this.port, this.bufferedBytesFromClient)) {
2001
1992
  case !1:
2002
1993
  return;
2003
1994
  case "other":
@@ -2026,34 +2017,34 @@ class Qe {
2026
2017
  issuer: this.CAroot.tbsDescription.subject
2027
2018
  },
2028
2019
  this.CAroot.keyPair
2029
- ), t = new Fe();
2020
+ ), t = new qe();
2030
2021
  this.clientUpstream.readable.pipeTo(t.clientEnd.upstream.writable).catch(() => {
2031
2022
  }), t.clientEnd.downstream.readable.pipeTo(this.clientDownstream.writable).catch(() => {
2032
2023
  }), await t.TLSHandshake(e.keyPair.privateKey, [
2033
2024
  e.certificate,
2034
2025
  this.CAroot.certificate
2035
2026
  ]);
2036
- const r = await m.parseHttpRequest(
2027
+ const n = await y.parseHttpRequest(
2037
2028
  t.serverEnd.upstream.readable,
2038
2029
  this.host,
2039
2030
  "https"
2040
2031
  );
2041
2032
  try {
2042
- await m.fetchRawResponseBytes(
2043
- r,
2033
+ await y.fetchRawResponseBytes(
2034
+ n,
2044
2035
  this.corsProxyUrl
2045
2036
  ).pipeTo(t.serverEnd.downstream.writable);
2046
2037
  } catch {
2047
2038
  }
2048
2039
  }
2049
2040
  async fetchOverHTTP() {
2050
- const e = await m.parseHttpRequest(
2041
+ const e = await y.parseHttpRequest(
2051
2042
  this.clientUpstream.readable,
2052
2043
  this.host,
2053
2044
  "http"
2054
2045
  );
2055
2046
  try {
2056
- await m.fetchRawResponseBytes(
2047
+ await y.fetchRawResponseBytes(
2057
2048
  e,
2058
2049
  this.corsProxyUrl
2059
2050
  ).pipeTo(this.clientDownstream.writable);
@@ -2064,7 +2055,7 @@ class Qe {
2064
2055
  this.emit("message", { data: new Uint8Array(0) }), this.readyState = this.CLOSING, this.emit("close"), this.readyState = this.CLOSED;
2065
2056
  }
2066
2057
  }
2067
- const et = [
2058
+ const Je = [
2068
2059
  "GET",
2069
2060
  "POST",
2070
2061
  "HEAD",
@@ -2074,62 +2065,62 @@ const et = [
2074
2065
  "PUT",
2075
2066
  "TRACE"
2076
2067
  ];
2077
- function tt(i, e) {
2068
+ function Xe(i, e) {
2078
2069
  if (e.length < 8)
2079
2070
  return !1;
2080
2071
  if (i === 443 && e[0] === C.Handshake && // TLS versions between 1.0 and 1.2
2081
2072
  e[1] === 3 && e[2] >= 1 && e[2] <= 3)
2082
2073
  return "tls";
2083
- const r = new TextDecoder("latin1", {
2074
+ const n = new TextDecoder("latin1", {
2084
2075
  fatal: !0
2085
2076
  }).decode(e);
2086
- return et.some(
2087
- (s) => r.startsWith(s + " ")
2077
+ return Je.some(
2078
+ (s) => n.startsWith(s + " ")
2088
2079
  ) ? "http" : "other";
2089
2080
  }
2090
- class m {
2081
+ class y {
2091
2082
  /**
2092
2083
  * Streams a HTTP response including the status line and headers.
2093
2084
  */
2094
2085
  static fetchRawResponseBytes(e, t) {
2095
2086
  return new ReadableStream({
2096
- async start(r) {
2097
- var _;
2098
- let n;
2087
+ async start(n) {
2088
+ var a;
2089
+ let r;
2099
2090
  try {
2100
- n = await Xe(
2091
+ r = await Ke(
2101
2092
  e,
2102
2093
  void 0,
2103
2094
  t
2104
2095
  );
2105
2096
  } catch (S) {
2106
- r.enqueue(
2097
+ n.enqueue(
2107
2098
  new TextEncoder().encode(
2108
2099
  `HTTP/1.1 400 Bad Request\r
2109
2100
  Content-Length: 0\r
2110
2101
  \r
2111
2102
  `
2112
2103
  )
2113
- ), r.error(S);
2104
+ ), n.error(S);
2114
2105
  return;
2115
2106
  }
2116
- r.enqueue(m.headersAsBytes(n));
2117
- const s = (_ = n.body) == null ? void 0 : _.getReader();
2107
+ n.enqueue(y.headersAsBytes(r));
2108
+ const s = (a = r.body) == null ? void 0 : a.getReader();
2118
2109
  if (!s) {
2119
- r.close();
2110
+ n.close();
2120
2111
  return;
2121
2112
  }
2122
- const a = new TextEncoder();
2113
+ const _ = new TextEncoder();
2123
2114
  for (; ; ) {
2124
2115
  const { done: S, value: c } = await s.read();
2125
- if (c && (r.enqueue(
2126
- a.encode(`${c.length.toString(16)}\r
2116
+ if (c && (n.enqueue(
2117
+ _.encode(`${c.length.toString(16)}\r
2127
2118
  `)
2128
- ), r.enqueue(c), r.enqueue(a.encode(`\r
2119
+ ), n.enqueue(c), n.enqueue(_.encode(`\r
2129
2120
  `))), S) {
2130
- r.enqueue(a.encode(`0\r
2121
+ n.enqueue(_.encode(`0\r
2131
2122
  \r
2132
- `)), r.close();
2123
+ `)), n.close();
2133
2124
  return;
2134
2125
  }
2135
2126
  }
@@ -2137,14 +2128,14 @@ Content-Length: 0\r
2137
2128
  });
2138
2129
  }
2139
2130
  static headersAsBytes(e) {
2140
- const t = `HTTP/1.1 ${e.status} ${e.statusText}`, r = {};
2141
- e.headers.forEach((a, _) => {
2142
- r[_.toLowerCase()] = a;
2143
- }), delete r["content-length"], r["transfer-encoding"] = "chunked";
2144
- const n = [];
2145
- for (const [a, _] of Object.entries(r))
2146
- n.push(`${a}: ${_}`);
2147
- const s = [t, ...n].join(`\r
2131
+ const t = `HTTP/1.1 ${e.status} ${e.statusText}`, n = {};
2132
+ e.headers.forEach((_, a) => {
2133
+ n[a.toLowerCase()] = _;
2134
+ }), delete n["content-length"], n["transfer-encoding"] = "chunked";
2135
+ const r = [];
2136
+ for (const [_, a] of Object.entries(n))
2137
+ r.push(`${_}: ${a}`);
2138
+ const s = [t, ...r].join(`\r
2148
2139
  `) + `\r
2149
2140
  \r
2150
2141
  `;
@@ -2154,57 +2145,57 @@ Content-Length: 0\r
2154
2145
  * Parses a raw, streamed HTTP request into a Request object
2155
2146
  * with known headers and a readable body stream.
2156
2147
  */
2157
- static async parseHttpRequest(e, t, r) {
2158
- let n = new Uint8Array(0), s = !1, a = -1;
2159
- const _ = e.getReader();
2160
- for (; a === -1; ) {
2161
- const { done: x, value: R } = await _.read();
2148
+ static async parseHttpRequest(e, t, n) {
2149
+ let r = new Uint8Array(0), s = !1, _ = -1;
2150
+ const a = e.getReader();
2151
+ for (; _ === -1; ) {
2152
+ const { done: x, value: P } = await a.read();
2162
2153
  if (x) {
2163
2154
  s = !0;
2164
2155
  break;
2165
2156
  }
2166
- n = u([n, R]), a = rt(
2167
- n,
2157
+ r = u([r, P]), _ = Qe(
2158
+ r,
2168
2159
  new Uint8Array([13, 10, 13, 10])
2169
2160
  );
2170
2161
  }
2171
- _.releaseLock();
2172
- const S = n.slice(0, a), c = m.parseRequestHeaders(S), h = c.headers.get("Transfer-Encoding") !== null ? "chunked" : "content-length", l = c.headers.get("Content-Length") !== null ? parseInt(c.headers.get("Content-Length"), 10) : void 0, A = n.slice(
2173
- a + 4
2162
+ a.releaseLock();
2163
+ const S = r.slice(0, _), c = y.parseRequestHeaders(S), A = c.headers.get("Transfer-Encoding") !== null ? "chunked" : "content-length", h = c.headers.get("Content-Length") !== null ? parseInt(c.headers.get("Content-Length"), 10) : void 0, l = r.slice(
2164
+ _ + 4
2174
2165
  /* Skip \r\n\r\n */
2175
2166
  );
2176
- let H;
2167
+ let E;
2177
2168
  if (c.method !== "GET") {
2178
2169
  const x = e.getReader();
2179
- let R = A.length, N = A.slice(-6);
2180
- const Ee = new TextEncoder().encode(`0\r
2170
+ let P = l.length, N = l.slice(-6);
2171
+ const pe = new TextEncoder().encode(`0\r
2181
2172
  \r
2182
2173
  `);
2183
- H = new ReadableStream({
2174
+ E = new ReadableStream({
2184
2175
  async start(W) {
2185
- A.length > 0 && W.enqueue(A), s && W.close();
2176
+ l.length > 0 && W.enqueue(l), s && W.close();
2186
2177
  },
2187
2178
  async pull(W) {
2188
- const { done: Te, value: I } = await x.read();
2189
- if (R += (I == null ? void 0 : I.length) || 0, I && (W.enqueue(I), N = u([
2179
+ const { done: we, value: g } = await x.read();
2180
+ if (P += (g == null ? void 0 : g.length) || 0, g && (W.enqueue(g), N = u([
2190
2181
  N,
2191
- I || new Uint8Array()
2192
- ]).slice(-5)), Te || h === "content-length" && l !== void 0 && R >= l || h === "chunked" && N.every(
2193
- (fe, pe) => fe === Ee[pe]
2182
+ g || new Uint8Array()
2183
+ ]).slice(-5)), we || A === "content-length" && h !== void 0 && P >= h || A === "chunked" && N.every(
2184
+ (Le, ye) => Le === pe[ye]
2194
2185
  )) {
2195
2186
  W.close();
2196
2187
  return;
2197
2188
  }
2198
2189
  }
2199
- }), h === "chunked" && (H = H.pipeThrough(
2200
- new Ze()
2190
+ }), A === "chunked" && (E = E.pipeThrough(
2191
+ new ze()
2201
2192
  ));
2202
2193
  }
2203
- const p = c.headers.get("Host") ?? t, de = new URL(c.path, r + "://" + p);
2204
- return new Request(de.toString(), {
2194
+ const v = c.headers.get("Host") ?? t, fe = new URL(c.path, n + "://" + v);
2195
+ return new Request(fe.toString(), {
2205
2196
  method: c.method,
2206
2197
  headers: c.headers,
2207
- body: H,
2198
+ body: E,
2208
2199
  // In Node.js, duplex: 'half' is required when
2209
2200
  // the body stream is provided.
2210
2201
  // @ts-expect-error
@@ -2212,33 +2203,33 @@ Content-Length: 0\r
2212
2203
  });
2213
2204
  }
2214
2205
  static parseRequestHeaders(e) {
2215
- const t = new TextDecoder().decode(e), r = t.split(`
2216
- `)[0], [n, s] = r.split(" "), a = new Headers();
2217
- for (const _ of t.split(`\r
2206
+ const t = new TextDecoder().decode(e), n = t.split(`
2207
+ `)[0], [r, s] = n.split(" "), _ = new Headers();
2208
+ for (const a of t.split(`\r
2218
2209
  `).slice(1)) {
2219
- if (_ === "")
2210
+ if (a === "")
2220
2211
  break;
2221
- const [S, c] = _.split(": ");
2222
- a.set(S, c);
2212
+ const [S, c] = a.split(": ");
2213
+ _.set(S, c);
2223
2214
  }
2224
- return { method: n, path: s, headers: a };
2215
+ return { method: r, path: s, headers: _ };
2225
2216
  }
2226
2217
  }
2227
- function rt(i, e) {
2228
- const t = i.length, r = e.length, n = t - r;
2229
- for (let s = 0; s <= n; s++) {
2230
- let a = !0;
2231
- for (let _ = 0; _ < r; _++)
2232
- if (i[s + _] !== e[_]) {
2233
- a = !1;
2218
+ function Qe(i, e) {
2219
+ const t = i.length, n = e.length, r = t - n;
2220
+ for (let s = 0; s <= r; s++) {
2221
+ let _ = !0;
2222
+ for (let a = 0; a < n; a++)
2223
+ if (i[s + a] !== e[a]) {
2224
+ _ = !1;
2234
2225
  break;
2235
2226
  }
2236
- if (a)
2227
+ if (_)
2237
2228
  return s;
2238
2229
  }
2239
2230
  return -1;
2240
2231
  }
2241
- async function nt(i = O) {
2232
+ async function et(i = j) {
2242
2233
  switch (i) {
2243
2234
  case "8.5":
2244
2235
  return (await import("@php-wasm/web-8-5")).getIntlExtensionPath();
@@ -2257,10 +2248,10 @@ async function nt(i = O) {
2257
2248
  }
2258
2249
  throw new Error(`Unsupported PHP version ${i}`);
2259
2250
  }
2260
- async function st(i = O, e) {
2261
- const t = ge(fetch), r = "intl.so", n = "icu.dat", s = await nt(i), a = (await import("./shared/icu.dat")).default, [_, S] = await Promise.all([
2251
+ async function tt(i = j, e) {
2252
+ const t = De(fetch), n = "intl.so", r = "icu.dat", s = await et(i), _ = (await import("./shared/icu.dat")).default, [a, S] = await Promise.all([
2262
2253
  t(s).then((c) => c.arrayBuffer()),
2263
- t(a).then((c) => c.arrayBuffer())
2254
+ t(_).then((c) => c.arrayBuffer())
2264
2255
  ]);
2265
2256
  return {
2266
2257
  ...e,
@@ -2270,27 +2261,27 @@ async function st(i = O, e) {
2270
2261
  ICU_DATA: "/internal/shared"
2271
2262
  },
2272
2263
  onRuntimeInitialized: (c) => {
2273
- e.onRuntimeInitialized && e.onRuntimeInitialized(c), L.fileExists(
2264
+ e.onRuntimeInitialized && e.onRuntimeInitialized(c), w.fileExists(
2274
2265
  c.FS,
2275
2266
  "/internal/shared/extensions"
2276
- ) || c.FS.mkdirTree("/internal/shared/extensions"), L.fileExists(
2267
+ ) || c.FS.mkdirTree("/internal/shared/extensions"), w.fileExists(
2277
2268
  c.FS,
2278
- `/internal/shared/extensions/${r}`
2269
+ `/internal/shared/extensions/${n}`
2279
2270
  ) || c.FS.writeFile(
2280
- `/internal/shared/extensions/${r}`,
2281
- new Uint8Array(_)
2282
- ), L.fileExists(
2271
+ `/internal/shared/extensions/${n}`,
2272
+ new Uint8Array(a)
2273
+ ), w.fileExists(
2283
2274
  c.FS,
2284
2275
  "/internal/shared/extensions/intl.ini"
2285
2276
  ) || c.FS.writeFile(
2286
2277
  "/internal/shared/extensions/intl.ini",
2287
2278
  [
2288
- `extension=/internal/shared/extensions/${r}`
2279
+ `extension=/internal/shared/extensions/${n}`
2289
2280
  ].join(`
2290
2281
  `)
2291
- ), L.fileExists(
2282
+ ), w.fileExists(
2292
2283
  c.FS,
2293
- `${c.ENV.ICU_DATA}/${n}`
2284
+ `${c.ENV.ICU_DATA}/${r}`
2294
2285
  ) || (c.FS.mkdirTree(c.ENV.ICU_DATA), c.FS.writeFile(
2295
2286
  `${c.ENV.ICU_DATA}/icudt74l.dat`,
2296
2287
  new Uint8Array(S)
@@ -2298,7 +2289,7 @@ async function st(i = O, e) {
2298
2289
  }
2299
2290
  };
2300
2291
  }
2301
- const it = () => ({
2292
+ const nt = () => ({
2302
2293
  websocket: {
2303
2294
  decorator: (i) => class extends i {
2304
2295
  constructor() {
@@ -2313,162 +2304,162 @@ const it = () => ({
2313
2304
  }
2314
2305
  }
2315
2306
  });
2316
- async function wt(i, e = {}) {
2307
+ async function Tt(i, e = {}) {
2317
2308
  var s;
2318
- "setImmediate" in globalThis || (globalThis.setImmediate = (a) => setTimeout(a, 0));
2309
+ "setImmediate" in globalThis || (globalThis.setImmediate = (_) => setTimeout(_, 0));
2319
2310
  let t = {
2320
- ...it(),
2311
+ ...nt(),
2321
2312
  ...e.emscriptenOptions || {}
2322
2313
  };
2323
- e.tcpOverFetch && (t = Je(
2314
+ e.tcpOverFetch && (t = Ye(
2324
2315
  t,
2325
2316
  e.tcpOverFetch
2326
- )), e.withIntl && (t = st(i, t));
2327
- const [r, n] = await Promise.all([
2328
- De(i),
2317
+ )), e.withIntl && (t = tt(i, t));
2318
+ const [n, r] = await Promise.all([
2319
+ Pe(i),
2329
2320
  t
2330
2321
  ]);
2331
- return (s = e.onPhpLoaderModuleLoaded) == null || s.call(e, r), await we(r, n);
2322
+ return (s = e.onPhpLoaderModuleLoaded) == null || s.call(e, n), await me(n, r);
2332
2323
  }
2333
- function Lt(i, e) {
2324
+ function ft(i, e) {
2334
2325
  window.addEventListener("message", (t) => {
2335
2326
  t.source === i.contentWindow && (e && t.origin !== e || typeof t.data != "object" || t.data.type !== "relay" || window.parent.postMessage(t.data, "*"));
2336
2327
  }), window.addEventListener("message", (t) => {
2337
- var r;
2338
- t.source === window.parent && (typeof t.data != "object" || t.data.type !== "relay" || (r = i == null ? void 0 : i.contentWindow) == null || r.postMessage(t.data));
2328
+ var n;
2329
+ t.source === window.parent && (typeof t.data != "object" || t.data.type !== "relay" || (n = i == null ? void 0 : i.contentWindow) == null || n.postMessage(t.data));
2339
2330
  });
2340
2331
  }
2341
- async function yt(i) {
2332
+ async function pt(i) {
2342
2333
  const e = new Worker(i, { type: "module" });
2343
- return new Promise((t, r) => {
2334
+ return new Promise((t, n) => {
2344
2335
  e.onerror = (s) => {
2345
- const a = new Error(
2336
+ const _ = new Error(
2346
2337
  `WebWorker failed to load at ${i}. ${s.message ? `Original error: ${s.message}` : ""}`
2347
2338
  );
2348
- a.filename = s.filename, r(a);
2339
+ _.filename = s.filename, n(_);
2349
2340
  };
2350
- function n(s) {
2351
- s.data === "worker-script-started" && (t(e), e.removeEventListener("message", n));
2341
+ function r(s) {
2342
+ s.data === "worker-script-started" && (t(e), e.removeEventListener("message", r));
2352
2343
  }
2353
- e.addEventListener("message", n);
2344
+ e.addEventListener("message", r);
2354
2345
  });
2355
2346
  }
2356
- function mt(i, e = { initialSync: {} }) {
2347
+ function wt(i, e = { initialSync: {} }) {
2357
2348
  return e = {
2358
2349
  ...e,
2359
2350
  initialSync: {
2360
2351
  ...e.initialSync,
2361
2352
  direction: e.initialSync.direction ?? "opfs-to-memfs"
2362
2353
  }
2363
- }, async function(t, r, n) {
2364
- return e.initialSync.direction === "opfs-to-memfs" ? (L.fileExists(r, n) && L.rmdir(r, n), L.mkdir(r, n), await at(r, i, n)) : await He(
2365
- r,
2366
- i,
2354
+ }, async function(t, n, r) {
2355
+ return e.initialSync.direction === "opfs-to-memfs" ? (w.fileExists(n, r) && w.rmdir(n, r), w.mkdir(n, r), await rt(n, i, r)) : await Te(
2367
2356
  n,
2357
+ i,
2358
+ r,
2368
2359
  e.initialSync.onProgress
2369
- ), ot(t, i, n);
2360
+ ), it(t, i, r);
2370
2361
  };
2371
2362
  }
2372
- async function at(i, e, t) {
2373
- L.mkdir(i, t);
2374
- const r = new Le({
2363
+ async function rt(i, e, t) {
2364
+ w.mkdir(i, t);
2365
+ const n = new ge({
2375
2366
  concurrency: 40
2376
- }), n = [], s = [
2367
+ }), r = [], s = [
2377
2368
  [e, t]
2378
2369
  ];
2379
2370
  for (; s.length > 0; ) {
2380
- const [a, _] = s.pop();
2381
- for await (const S of a.values()) {
2382
- const c = r.run(async () => {
2383
- const h = ae(
2384
- _,
2371
+ const [_, a] = s.pop();
2372
+ for await (const S of _.values()) {
2373
+ const c = n.run(async () => {
2374
+ const A = ie(
2375
+ a,
2385
2376
  S.name
2386
2377
  );
2387
2378
  if (S.kind === "directory") {
2388
2379
  try {
2389
- i.mkdir(h);
2390
- } catch (l) {
2391
- if ((l == null ? void 0 : l.errno) !== 20)
2392
- throw M.error(l), l;
2380
+ i.mkdir(A);
2381
+ } catch (h) {
2382
+ if ((h == null ? void 0 : h.errno) !== 20)
2383
+ throw U.error(h), h;
2393
2384
  }
2394
- s.push([S, h]);
2385
+ s.push([S, A]);
2395
2386
  } else if (S.kind === "file") {
2396
- const l = await S.getFile(), A = new Uint8Array(await l.arrayBuffer());
2387
+ const h = await S.getFile(), l = new Uint8Array(await h.arrayBuffer());
2397
2388
  i.createDataFile(
2398
- _,
2389
+ a,
2399
2390
  S.name,
2400
- A,
2391
+ l,
2401
2392
  !0,
2402
2393
  !0,
2403
2394
  !0
2404
2395
  );
2405
2396
  }
2406
- n.splice(n.indexOf(c), 1);
2397
+ r.splice(r.indexOf(c), 1);
2407
2398
  });
2408
- n.push(c);
2399
+ r.push(c);
2409
2400
  }
2410
- for (; s.length === 0 && n.length > 0; )
2411
- await Promise.any(n);
2401
+ for (; s.length === 0 && r.length > 0; )
2402
+ await Promise.any(r);
2412
2403
  }
2413
2404
  }
2414
- async function He(i, e, t, r) {
2405
+ async function Te(i, e, t, n) {
2415
2406
  i.mkdirTree(t);
2416
- const n = [];
2417
- async function s(h, l) {
2407
+ const r = [];
2408
+ async function s(A, h) {
2418
2409
  await Promise.all(
2419
- i.readdir(h).filter(
2420
- (A) => A !== "." && A !== ".."
2421
- ).map(async (A) => {
2422
- const H = ae(h, A);
2423
- if (!_t(i, H)) {
2424
- n.push([l, H, A]);
2410
+ i.readdir(A).filter(
2411
+ (l) => l !== "." && l !== ".."
2412
+ ).map(async (l) => {
2413
+ const E = ie(A, l);
2414
+ if (!st(i, E)) {
2415
+ r.push([h, E, l]);
2425
2416
  return;
2426
2417
  }
2427
- const p = await l.getDirectoryHandle(A, {
2418
+ const v = await h.getDirectoryHandle(l, {
2428
2419
  create: !0
2429
2420
  });
2430
- return await s(H, p);
2421
+ return await s(E, v);
2431
2422
  })
2432
2423
  );
2433
2424
  }
2434
2425
  await s(t, e);
2435
- let a = 0;
2436
- const _ = r && Ct(r, 100), S = 100, c = /* @__PURE__ */ new Set();
2426
+ let _ = 0;
2427
+ const a = n && ot(n, 100), S = 100, c = /* @__PURE__ */ new Set();
2437
2428
  try {
2438
- for (const [h, l, A] of n) {
2439
- const H = F(
2440
- h,
2429
+ for (const [A, h, l] of r) {
2430
+ const E = O(
2441
2431
  A,
2432
+ l,
2442
2433
  i,
2443
- l
2434
+ h
2444
2435
  ).then(() => {
2445
- a++, c.delete(H), _ == null || _({
2446
- files: a,
2447
- total: n.length
2436
+ _++, c.delete(E), a == null || a({
2437
+ files: _,
2438
+ total: r.length
2448
2439
  });
2449
2440
  });
2450
- c.add(H), c.size >= S && (await Promise.race(c), _ == null || _({
2451
- files: a,
2452
- total: n.length
2441
+ c.add(E), c.size >= S && (await Promise.race(c), a == null || a({
2442
+ files: _,
2443
+ total: r.length
2453
2444
  }));
2454
2445
  }
2455
2446
  } finally {
2456
2447
  await Promise.allSettled(c);
2457
2448
  }
2458
2449
  }
2459
- function _t(i, e) {
2450
+ function st(i, e) {
2460
2451
  return i.isDir(i.lookupPath(e, { follow: !0 }).node.mode);
2461
2452
  }
2462
- async function F(i, e, t, r) {
2463
- let n;
2453
+ async function O(i, e, t, n) {
2454
+ let r;
2464
2455
  try {
2465
- n = t.readFile(r, {
2456
+ r = t.readFile(n, {
2466
2457
  encoding: "binary"
2467
2458
  });
2468
2459
  } catch {
2469
2460
  return;
2470
2461
  }
2471
- const s = await i.getFileHandle(e, { create: !0 }), a = s.createWritable !== void 0 ? (
2462
+ const s = await i.getFileHandle(e, { create: !0 }), _ = s.createWritable !== void 0 ? (
2472
2463
  // Google Chrome, Firefox, probably more browsers
2473
2464
  await s.createWritable()
2474
2465
  ) : (
@@ -2476,145 +2467,145 @@ async function F(i, e, t, r) {
2476
2467
  await s.createSyncAccessHandle()
2477
2468
  );
2478
2469
  try {
2479
- await a.truncate(0), await a.write(n);
2470
+ await _.truncate(0), await _.write(r);
2480
2471
  } finally {
2481
- await a.close();
2472
+ await _.close();
2482
2473
  }
2483
2474
  }
2484
- function ot(i, e, t) {
2485
- const r = [], n = Ie(i, t, (_) => {
2486
- r.push(_);
2487
- }), s = new ct(i, e, t);
2488
- async function a() {
2489
- if (r.length === 0)
2475
+ function it(i, e, t) {
2476
+ const n = [], r = We(i, t, (a) => {
2477
+ n.push(a);
2478
+ }), s = new _t(i, e, t);
2479
+ async function _() {
2480
+ if (n.length === 0)
2490
2481
  return;
2491
- const _ = await i.semaphore.acquire(), S = [...r];
2492
- r.splice(0, S.length);
2493
- const c = Ke(S);
2482
+ const a = await i.semaphore.acquire(), S = [...n];
2483
+ n.splice(0, S.length);
2484
+ const c = be(S);
2494
2485
  try {
2495
- for (const h of c)
2496
- await s.processEntry(h);
2486
+ for (const A of c)
2487
+ await s.processEntry(A);
2497
2488
  } finally {
2498
- _();
2489
+ a();
2499
2490
  }
2500
2491
  }
2501
- return i.addEventListener("request.end", a), i.addEventListener("filesystem.write", a), function() {
2502
- n(), i.removeEventListener("request.end", a), i.removeEventListener("filesystem.write", a);
2492
+ return i.addEventListener("request.end", _), i.addEventListener("filesystem.write", _), function() {
2493
+ r(), i.removeEventListener("request.end", _), i.removeEventListener("filesystem.write", _);
2503
2494
  };
2504
2495
  }
2505
- class ct {
2506
- constructor(e, t, r) {
2507
- this.php = e, this.opfs = t, this.memfsRoot = se(r);
2496
+ class _t {
2497
+ constructor(e, t, n) {
2498
+ this.php = e, this.opfs = t, this.memfsRoot = re(n);
2508
2499
  }
2509
2500
  toOpfsPath(e) {
2510
- return se(e.substring(this.memfsRoot.length));
2501
+ return re(e.substring(this.memfsRoot.length));
2511
2502
  }
2512
2503
  async processEntry(e) {
2513
2504
  if (!e.path.startsWith(this.memfsRoot) || e.path === this.memfsRoot)
2514
2505
  return;
2515
- const t = this.toOpfsPath(e.path), r = await ie(this.opfs, t), n = St(t);
2516
- if (n)
2506
+ const t = this.toOpfsPath(e.path), n = await se(this.opfs, t), r = at(t);
2507
+ if (r)
2517
2508
  try {
2518
2509
  if (e.operation === "DELETE")
2519
2510
  try {
2520
- await r.removeEntry(n, {
2511
+ await n.removeEntry(r, {
2521
2512
  recursive: !0
2522
2513
  });
2523
2514
  } catch {
2524
2515
  }
2525
2516
  else if (e.operation === "CREATE")
2526
- e.nodeType === "directory" ? await r.getDirectoryHandle(n, {
2517
+ e.nodeType === "directory" ? await n.getDirectoryHandle(r, {
2527
2518
  create: !0
2528
- }) : await r.getFileHandle(n, {
2519
+ }) : await n.getFileHandle(r, {
2529
2520
  create: !0
2530
2521
  });
2531
2522
  else if (e.operation === "WRITE")
2532
- await F(
2533
- r,
2523
+ await O(
2534
2524
  n,
2525
+ r,
2535
2526
  this.php[k].FS,
2536
2527
  e.path
2537
2528
  );
2538
2529
  else if (e.operation === "RENAME" && e.toPath.startsWith(this.memfsRoot)) {
2539
- const s = this.toOpfsPath(e.toPath), a = await ie(
2530
+ const s = this.toOpfsPath(e.toPath), _ = await se(
2540
2531
  this.opfs,
2541
2532
  s
2542
2533
  );
2543
2534
  if (e.nodeType === "directory") {
2544
- const _ = await a.getDirectoryHandle(
2545
- n,
2535
+ const a = await _.getDirectoryHandle(
2536
+ r,
2546
2537
  {
2547
2538
  create: !0
2548
2539
  }
2549
2540
  );
2550
- await He(
2541
+ await Te(
2551
2542
  this.php[k].FS,
2552
- _,
2543
+ a,
2553
2544
  e.toPath
2554
- ), await r.removeEntry(n, {
2545
+ ), await n.removeEntry(r, {
2555
2546
  recursive: !0
2556
2547
  });
2557
2548
  } else {
2558
2549
  try {
2559
- await r.removeEntry(n);
2550
+ await n.removeEntry(r);
2560
2551
  } catch {
2561
2552
  }
2562
- await F(
2563
- a,
2564
- ye(s),
2553
+ await O(
2554
+ _,
2555
+ Ie(s),
2565
2556
  this.php[k].FS,
2566
2557
  e.toPath
2567
2558
  );
2568
2559
  }
2569
2560
  }
2570
2561
  } catch (s) {
2571
- throw M.log({ entry: e, name: n }), M.error(s), s;
2562
+ throw U.log({ entry: e, name: r }), U.error(s), s;
2572
2563
  }
2573
2564
  }
2574
2565
  }
2575
- function se(i) {
2566
+ function re(i) {
2576
2567
  return i.replace(/\/$/, "").replace(/\/\/+/g, "/");
2577
2568
  }
2578
- function St(i) {
2569
+ function at(i) {
2579
2570
  return i.substring(i.lastIndexOf("/") + 1);
2580
2571
  }
2581
- async function ie(i, e) {
2572
+ async function se(i, e) {
2582
2573
  const t = e.replace(/^\/+|\/+$/g, "").replace(/\/+/, "/");
2583
2574
  if (!t)
2584
2575
  return i;
2585
- const r = t.split("/");
2586
- let n = i;
2587
- for (let s = 0; s < r.length - 1; s++) {
2588
- const a = r[s];
2589
- n = await n.getDirectoryHandle(a, { create: !0 });
2576
+ const n = t.split("/");
2577
+ let r = i;
2578
+ for (let s = 0; s < n.length - 1; s++) {
2579
+ const _ = n[s];
2580
+ r = await r.getDirectoryHandle(_, { create: !0 });
2590
2581
  }
2591
- return n;
2582
+ return r;
2592
2583
  }
2593
- function Ct(i, e) {
2594
- let t = 0, r, n;
2595
- return function(...a) {
2596
- n = a;
2597
- const _ = Date.now() - t;
2598
- if (r === void 0) {
2599
- const S = Math.max(0, e - _);
2600
- r = setTimeout(() => {
2601
- r = void 0, t = Date.now(), i(...n);
2584
+ function ot(i, e) {
2585
+ let t = 0, n, r;
2586
+ return function(..._) {
2587
+ r = _;
2588
+ const a = Date.now() - t;
2589
+ if (n === void 0) {
2590
+ const S = Math.max(0, e - a);
2591
+ n = setTimeout(() => {
2592
+ n = void 0, t = Date.now(), i(...r);
2602
2593
  }, S);
2603
2594
  }
2604
2595
  };
2605
2596
  }
2606
2597
  export {
2607
- ze as FirewallInterferenceError,
2608
- Tt as certificateToPEM,
2609
- Kt as consumeAPI,
2610
- mt as createDirectoryHandleMountHandler,
2611
- Dt as exposeAPI,
2612
- Xe as fetchWithCorsProxy,
2598
+ Kt as FirewallInterferenceError,
2599
+ Ht as certificateToPEM,
2600
+ mt as consumeAPI,
2601
+ wt as createDirectoryHandleMountHandler,
2602
+ gt as exposeAPI,
2603
+ Dt as fetchWithCorsProxy,
2613
2604
  je as generateCertificate,
2614
- De as getPHPLoaderModule,
2615
- wt as loadWebRuntime,
2616
- ft as privateKeyToPEM,
2617
- Lt as setupPostMessageRelay,
2618
- yt as spawnPHPWorkerThread
2605
+ Pe as getPHPLoaderModule,
2606
+ Tt as loadWebRuntime,
2607
+ dt as privateKeyToPEM,
2608
+ ft as setupPostMessageRelay,
2609
+ pt as spawnPHPWorkerThread
2619
2610
  };
2620
2611
  //# sourceMappingURL=index.js.map