@php-wasm/web 3.1.34 → 3.1.35

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,13 +1,13 @@
1
- import { LatestSupportedPHPVersion as oe, withResolvedPHPExtensions as Ie, resolvePHPExtension as Y, isLegacyPHPVersion as Ke, createLegacyPhpIniPreRunStep as De, loadPHPRuntime as We, FSHelpers as M, __private__dont__use as O } from "@php-wasm/universal";
2
- import { consumeAPI as Ut, exposeAPI as vt } from "@php-wasm/universal";
3
- import { concatArrayBuffers as v, concatUint8Arrays as H, Semaphore as Pe, joinPaths as ce, basename as be } from "@php-wasm/util";
4
- import { logger as B } from "@php-wasm/logger";
5
- import { fetchWithCorsProxy as Re } from "@php-wasm/web-service-worker";
6
- import { FirewallInterferenceError as xt, fetchWithCorsProxy as Nt } from "@php-wasm/web-service-worker";
7
- import { createMemoizedFetch as Be } from "@wp-playground/common";
8
- import { jspi as Ue } from "wasm-feature-detect";
9
- import { journalFSEvents as ve, normalizeFilesystemOperations as Me } from "@php-wasm/fs-journal";
10
- async function xe(i = oe) {
1
+ import { LatestSupportedPHPVersion as Se, withResolvedPHPExtensions as We, resolvePHPExtension as Y, isLegacyPHPVersion as Pe, createLegacyPhpIniPreRunStep as be, loadPHPRuntime as Re, FSHelpers as M, __private__dont__use as O } from "@php-wasm/universal";
2
+ import { consumeAPI as xt, exposeAPI as Nt } from "@php-wasm/universal";
3
+ import { concatArrayBuffers as v, concatUint8Arrays as H, Semaphore as Be, joinPaths as le, basename as Ue } from "@php-wasm/util";
4
+ import { logger as g } from "@php-wasm/logger";
5
+ import { fetchWithCorsProxy as ve } from "@php-wasm/web-service-worker";
6
+ import { FirewallInterferenceError as qt, fetchWithCorsProxy as Ft } from "@php-wasm/web-service-worker";
7
+ import { createMemoizedFetch as Me } from "@wp-playground/common";
8
+ import { jspi as xe } from "wasm-feature-detect";
9
+ import { journalFSEvents as Ne, normalizeFilesystemOperations as ke } from "@php-wasm/fs-journal";
10
+ async function qe(i = Se) {
11
11
  switch (i) {
12
12
  case "8.5":
13
13
  return (await import("@php-wasm/web-8-5")).getPHPLoaderModule();
@@ -28,13 +28,13 @@ async function xe(i = oe) {
28
28
  }
29
29
  throw new Error(`Unsupported PHP version ${i}`);
30
30
  }
31
- function p(i) {
31
+ function w(i) {
32
32
  return Object.fromEntries(Object.entries(i).map(([e, t]) => [t, e]));
33
33
  }
34
- function D(i) {
34
+ function W(i) {
35
35
  return new Uint8Array([i >> 8 & 255, i & 255]);
36
36
  }
37
- function m(i) {
37
+ function L(i) {
38
38
  return new Uint8Array([
39
39
  i >> 16 & 255,
40
40
  i >> 8 & 255,
@@ -45,7 +45,7 @@ function Z(i) {
45
45
  const e = new ArrayBuffer(8);
46
46
  return new DataView(e).setBigUint64(0, BigInt(i), !1), new Uint8Array(e);
47
47
  }
48
- class g {
48
+ class I {
49
49
  constructor(e) {
50
50
  this.offset = 0, this.buffer = e, this.view = new DataView(e);
51
51
  }
@@ -86,7 +86,7 @@ class N {
86
86
  this.uint8Array.set(e, this.offset), this.offset += e.length;
87
87
  }
88
88
  }
89
- const W = {
89
+ const P = {
90
90
  server_name: 0,
91
91
  max_fragment_length: 1,
92
92
  client_certificate_url: 2,
@@ -141,10 +141,10 @@ const W = {
141
141
  transparency_info: 52,
142
142
  connection_id: 54,
143
143
  renegotiation_info: 65281
144
- }, Ne = p(W), Se = {
144
+ }, Fe = w(P), Ce = {
145
145
  host_name: 0
146
- }, ke = p(Se);
147
- class Ce {
146
+ }, Oe = w(Ce);
147
+ class he {
148
148
  static decodeFromClient(e) {
149
149
  const t = new DataView(e.buffer);
150
150
  let n = 0;
@@ -156,13 +156,13 @@ class Ce {
156
156
  n += 1;
157
157
  const _ = t.getUint16(n);
158
158
  n += 2;
159
- const c = e.slice(n, n + _);
159
+ const o = e.slice(n, n + _);
160
160
  switch (n += _, a) {
161
- case Se.host_name:
161
+ case Ce.host_name:
162
162
  s.push({
163
- name_type: ke[a],
163
+ name_type: Oe[a],
164
164
  name: {
165
- host_name: new TextDecoder().decode(c)
165
+ host_name: new TextDecoder().decode(o)
166
166
  }
167
167
  });
168
168
  break;
@@ -189,15 +189,15 @@ class Ce {
189
189
  "Encoding non-empty lists for ClientHello is not supported yet. Only empty lists meant for ServerHello are supported today."
190
190
  );
191
191
  const t = new N(4);
192
- return t.writeUint16(W.server_name), t.writeUint16(0), t.uint8Array;
192
+ return t.writeUint16(P.server_name), t.writeUint16(0), t.uint8Array;
193
193
  }
194
194
  }
195
- const le = {
195
+ const ue = {
196
196
  uncompressed: 0,
197
197
  ansiX962_compressed_prime: 1,
198
198
  ansiX962_compressed_char2: 2
199
- }, J = p(le);
200
- class he {
199
+ }, J = w(ue);
200
+ class Ae {
201
201
  /**
202
202
  * +--------------------------------------------------+
203
203
  * | Payload Length [2B] |
@@ -214,7 +214,7 @@ class he {
214
214
  * +--------------------------------------------------+
215
215
  */
216
216
  static decodeFromClient(e) {
217
- const t = new g(e.buffer), n = t.readUint8(), r = [];
217
+ const t = new I(e.buffer), n = t.readUint8(), r = [];
218
218
  for (let s = 0; s < n; s++) {
219
219
  const a = t.readUint8();
220
220
  a in J && r.push(J[a]);
@@ -237,10 +237,10 @@ class he {
237
237
  */
238
238
  static encodeForClient(e) {
239
239
  const t = new N(6);
240
- return t.writeUint16(W.ec_point_formats), t.writeUint16(2), t.writeUint8(1), t.writeUint8(le[e]), t.uint8Array;
240
+ return t.writeUint16(P.ec_point_formats), t.writeUint16(2), t.writeUint8(1), t.writeUint8(ue[e]), t.uint8Array;
241
241
  }
242
242
  }
243
- const Ae = {
243
+ const He = {
244
244
  decodeFromClient(i) {
245
245
  const e = i[0] ?? 0;
246
246
  return {
@@ -252,7 +252,7 @@ const Ae = {
252
252
  * with an empty renegotiated_connection field.
253
253
  */
254
254
  encodeForClient() {
255
- const i = W.renegotiation_info, e = new Uint8Array([0]);
255
+ const i = P.renegotiation_info, e = new Uint8Array([0]);
256
256
  return new Uint8Array([
257
257
  i >> 8 & 255,
258
258
  i & 255,
@@ -261,7 +261,7 @@ const Ae = {
261
261
  ...e
262
262
  ]);
263
263
  }
264
- }, ue = {
264
+ }, de = {
265
265
  TLS1_CK_PSK_WITH_RC4_128_SHA: 138,
266
266
  TLS1_CK_PSK_WITH_3DES_EDE_CBC_SHA: 139,
267
267
  TLS1_CK_PSK_WITH_AES_128_CBC_SHA: 140,
@@ -464,14 +464,14 @@ const Ae = {
464
464
  TLS1_CK_ECDHE_PSK_WITH_CHACHA20_POLY1305: 52396,
465
465
  TLS1_CK_DHE_PSK_WITH_CHACHA20_POLY1305: 52397,
466
466
  TLS1_CK_RSA_PSK_WITH_CHACHA20_POLY1305: 52398
467
- }, X = p(ue), He = {
467
+ }, X = w(de), fe = {
468
468
  secp256r1: 23,
469
469
  secp384r1: 24,
470
470
  secp521r1: 25,
471
471
  x25519: 29,
472
472
  x448: 30
473
- }, Q = p(He);
474
- class qe {
473
+ }, Q = w(fe);
474
+ class je {
475
475
  /**
476
476
  * +--------------------------------------------------+
477
477
  * | Payload Length [2B] |
@@ -488,7 +488,7 @@ class qe {
488
488
  * +--------------------------------------------------+
489
489
  */
490
490
  static decodeFromClient(e) {
491
- const t = new g(e.buffer);
491
+ const t = new I(e.buffer);
492
492
  t.readUint16();
493
493
  const n = [];
494
494
  for (; !t.isFinished(); ) {
@@ -509,7 +509,7 @@ class qe {
509
509
  */
510
510
  static encodeForClient(e) {
511
511
  const t = new N(6);
512
- return t.writeUint16(W.supported_groups), t.writeUint16(2), t.writeUint16(He[e]), t.uint8Array;
512
+ return t.writeUint16(P.supported_groups), t.writeUint16(2), t.writeUint16(fe[e]), t.uint8Array;
513
513
  }
514
514
  }
515
515
  const V = {
@@ -517,7 +517,7 @@ const V = {
517
517
  rsa: 1,
518
518
  dsa: 2,
519
519
  ecdsa: 3
520
- }, ee = p(V), z = {
520
+ }, ee = w(V), z = {
521
521
  none: 0,
522
522
  md5: 1,
523
523
  sha1: 2,
@@ -525,8 +525,8 @@ const V = {
525
525
  sha256: 4,
526
526
  sha384: 5,
527
527
  sha512: 6
528
- }, te = p(z);
529
- class Fe {
528
+ }, te = w(z);
529
+ class Ge {
530
530
  /**
531
531
  * Binary layout:
532
532
  *
@@ -543,14 +543,14 @@ class Fe {
543
543
  * +------------------------------------+
544
544
  */
545
545
  static decodeFromClient(e) {
546
- const t = new g(e.buffer);
546
+ const t = new I(e.buffer);
547
547
  t.readUint16();
548
548
  const n = [];
549
549
  for (; !t.isFinished(); ) {
550
550
  const r = t.readUint8(), s = t.readUint8();
551
551
  if (ee[s]) {
552
552
  if (!te[r]) {
553
- B.warn(`Unknown hash algorithm: ${r}`);
553
+ g.warn(`Unknown hash algorithm: ${r}`);
554
554
  continue;
555
555
  }
556
556
  n.push({
@@ -574,26 +574,26 @@ class Fe {
574
574
  */
575
575
  static encodeforClient(e, t) {
576
576
  const n = new N(6);
577
- return n.writeUint16(W.signature_algorithms), n.writeUint16(2), n.writeUint8(z[e]), n.writeUint8(V[t]), n.uint8Array;
577
+ return n.writeUint16(P.signature_algorithms), n.writeUint16(2), n.writeUint8(z[e]), n.writeUint8(V[t]), n.uint8Array;
578
578
  }
579
579
  }
580
580
  const ne = {
581
- server_name: Ce,
582
- signature_algorithms: Fe,
583
- supported_groups: qe,
584
- ec_point_formats: he,
585
- renegotiation_info: Ae
581
+ server_name: he,
582
+ signature_algorithms: Ge,
583
+ supported_groups: je,
584
+ ec_point_formats: Ae,
585
+ renegotiation_info: He
586
586
  };
587
- function Oe(i) {
588
- const e = new g(i.buffer), t = [];
587
+ function $e(i) {
588
+ const e = new I(i.buffer), t = [];
589
589
  for (; !e.isFinished(); ) {
590
- const n = e.offset, r = e.readUint16(), s = Ne[r], a = e.readUint16(), _ = e.readUint8Array(a);
590
+ const n = e.offset, r = e.readUint16(), s = Fe[r], a = e.readUint16(), _ = e.readUint8Array(a);
591
591
  if (!(s in ne))
592
592
  continue;
593
- const c = ne[s];
593
+ const o = ne[s];
594
594
  t.push({
595
595
  type: s,
596
- data: c.decodeFromClient(_),
596
+ data: o.decodeFromClient(_),
597
597
  raw: i.slice(n, n + 4 + a)
598
598
  });
599
599
  }
@@ -611,8 +611,8 @@ async function G(i, e, t, n) {
611
611
  const _ = [];
612
612
  for (; v(_).byteLength < n; ) {
613
613
  a = await re(s, a);
614
- const S = v([a, r]), C = await re(s, S);
615
- _.push(C);
614
+ const S = v([a, r]), l = await re(s, S);
615
+ _.push(l);
616
616
  }
617
617
  return v(_).slice(0, n);
618
618
  }
@@ -623,12 +623,12 @@ async function re(i, e) {
623
623
  e
624
624
  );
625
625
  }
626
- const je = {
626
+ const Ve = {
627
627
  Null: 0
628
- }, de = {
628
+ }, Ee = {
629
629
  Warning: 1,
630
630
  Fatal: 2
631
- }, fe = p(de), Ee = {
631
+ }, Te = w(Ee), pe = {
632
632
  CloseNotify: 0,
633
633
  UnexpectedMessage: 10,
634
634
  BadRecordMac: 20,
@@ -654,12 +654,12 @@ const je = {
654
654
  UserCanceled: 90,
655
655
  NoRenegotiation: 100,
656
656
  UnsupportedExtension: 110
657
- }, Te = p(Ee), l = {
657
+ }, we = w(pe), h = {
658
658
  ChangeCipherSpec: 20,
659
659
  Alert: 21,
660
660
  Handshake: 22,
661
661
  ApplicationData: 23
662
- }, f = {
662
+ }, E = {
663
663
  HelloRequest: 0,
664
664
  ClientHello: 1,
665
665
  ServerHello: 2,
@@ -668,7 +668,7 @@ const je = {
668
668
  ServerHelloDone: 14,
669
669
  ClientKeyExchange: 16,
670
670
  Finished: 20
671
- }, Ge = {
671
+ }, ze = {
672
672
  /**
673
673
  * Indicates that a named curve is used. This option
674
674
  * SHOULD be used when applicable.
@@ -677,12 +677,12 @@ const je = {
677
677
  /**
678
678
  * Values 248 through 255 are reserved for private use.
679
679
  */
680
- }, $e = {
680
+ }, Ye = {
681
681
  secp256r1: 23
682
682
  };
683
683
  class j extends Error {
684
684
  }
685
- const x = new Uint8Array([3, 3]), Ve = crypto.subtle.generateKey(
685
+ const x = new Uint8Array([3, 3]), Ze = crypto.subtle.generateKey(
686
686
  {
687
687
  name: "ECDH",
688
688
  namedCurve: "P-256"
@@ -693,7 +693,7 @@ const x = new Uint8Array([3, 3]), Ve = crypto.subtle.generateKey(
693
693
  ["deriveKey", "deriveBits"]
694
694
  // Key usage
695
695
  );
696
- class ze {
696
+ class Je {
697
697
  constructor() {
698
698
  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 = {
699
699
  // We don't need to chunk the encrypted data.
@@ -710,14 +710,14 @@ class ze {
710
710
  * This will spread some messages across multiple records,
711
711
  * but TLS supports it so that's fine.
712
712
  */
713
- downstream: Ye(this.MAX_CHUNK_SIZE)
713
+ downstream: Xe(this.MAX_CHUNK_SIZE)
714
714
  }, this.serverUpstreamWriter = this.serverEnd.upstream.writable.getWriter();
715
715
  const e = this;
716
716
  this.serverEnd.downstream.readable.pipeTo(
717
717
  new WritableStream({
718
718
  async write(t) {
719
719
  await e.writeTLSRecord(
720
- l.ApplicationData,
720
+ h.ApplicationData,
721
721
  t
722
722
  );
723
723
  },
@@ -767,7 +767,7 @@ class ze {
767
767
  */
768
768
  async TLSHandshake(e, t) {
769
769
  const n = await this.readNextHandshakeMessage(
770
- f.ClientHello
770
+ E.ClientHello
771
771
  );
772
772
  if (!n.body.cipher_suites.length)
773
773
  throw new Error(
@@ -775,46 +775,46 @@ class ze {
775
775
  );
776
776
  const r = crypto.getRandomValues(new Uint8Array(32));
777
777
  await this.writeTLSRecord(
778
- l.Handshake,
779
- K.serverHello(
778
+ h.Handshake,
779
+ D.serverHello(
780
780
  n.body,
781
781
  r,
782
- je.Null
782
+ Ve.Null
783
783
  )
784
784
  ), await this.writeTLSRecord(
785
- l.Handshake,
786
- K.certificate(t)
785
+ h.Handshake,
786
+ D.certificate(t)
787
787
  );
788
- const s = await Ve, a = n.body.random, _ = await K.ECDHEServerKeyExchange(
788
+ const s = await Ze, a = n.body.random, _ = await D.ECDHEServerKeyExchange(
789
789
  a,
790
790
  r,
791
791
  s,
792
792
  e
793
793
  );
794
- await this.writeTLSRecord(l.Handshake, _), await this.writeTLSRecord(
795
- l.Handshake,
796
- K.serverHelloDone()
794
+ await this.writeTLSRecord(h.Handshake, _), await this.writeTLSRecord(
795
+ h.Handshake,
796
+ D.serverHelloDone()
797
797
  );
798
- const c = await this.readNextHandshakeMessage(
799
- f.ClientKeyExchange
798
+ const o = await this.readNextHandshakeMessage(
799
+ E.ClientKeyExchange
800
800
  );
801
- await this.readNextMessage(l.ChangeCipherSpec), this.sessionKeys = await this.deriveSessionKeys({
801
+ await this.readNextMessage(h.ChangeCipherSpec), this.sessionKeys = await this.deriveSessionKeys({
802
802
  clientRandom: a,
803
803
  serverRandom: r,
804
804
  serverPrivateKey: s.privateKey,
805
805
  clientPublicKey: await crypto.subtle.importKey(
806
806
  "raw",
807
- c.body.exchange_keys,
807
+ o.body.exchange_keys,
808
808
  { name: "ECDH", namedCurve: "P-256" },
809
809
  !1,
810
810
  []
811
811
  )
812
- }), await this.readNextHandshakeMessage(f.Finished), await this.writeTLSRecord(
813
- l.ChangeCipherSpec,
814
- K.changeCipherSpec()
812
+ }), await this.readNextHandshakeMessage(E.Finished), await this.writeTLSRecord(
813
+ h.ChangeCipherSpec,
814
+ D.changeCipherSpec()
815
815
  ), await this.writeTLSRecord(
816
- l.Handshake,
817
- await K.createFinishedMessage(
816
+ h.Handshake,
817
+ await D.createFinishedMessage(
818
818
  this.handshakeMessages,
819
819
  this.sessionKeys.masterSecret
820
820
  )
@@ -851,7 +851,7 @@ class ze {
851
851
  H([t, e]),
852
852
  // Client key, server key, client IV, server IV
853
853
  40
854
- ), c = new g(_), S = c.readUint8Array(16), C = c.readUint8Array(16), h = c.readUint8Array(4), A = c.readUint8Array(4);
854
+ ), o = new I(_), S = o.readUint8Array(16), l = o.readUint8Array(16), C = o.readUint8Array(4), A = o.readUint8Array(4);
855
855
  return {
856
856
  masterSecret: a,
857
857
  clientWriteKey: await crypto.subtle.importKey(
@@ -863,17 +863,17 @@ class ze {
863
863
  ),
864
864
  serverWriteKey: await crypto.subtle.importKey(
865
865
  "raw",
866
- C,
866
+ l,
867
867
  { name: "AES-GCM" },
868
868
  !1,
869
869
  ["encrypt", "decrypt"]
870
870
  ),
871
- clientIV: h,
871
+ clientIV: C,
872
872
  serverIV: A
873
873
  };
874
874
  }
875
875
  async readNextHandshakeMessage(e) {
876
- const t = await this.readNextMessage(l.Handshake);
876
+ const t = await this.readNextMessage(h.Handshake);
877
877
  if (t.msg_type !== e)
878
878
  throw new Error(`Expected ${e} message`);
879
879
  return t;
@@ -883,18 +883,18 @@ class ze {
883
883
  do
884
884
  t = await this.readNextTLSRecord(e), n = await this.accumulateUntilMessageIsComplete(t);
885
885
  while (n === !1);
886
- const r = E.TLSMessage(
886
+ const r = T.TLSMessage(
887
887
  t.type,
888
888
  n
889
889
  );
890
- return t.type === l.Handshake && this.handshakeMessages.push(t.fragment), r;
890
+ return t.type === h.Handshake && this.handshakeMessages.push(t.fragment), r;
891
891
  }
892
892
  async readNextTLSRecord(e) {
893
893
  for (; ; ) {
894
894
  for (let _ = 0; _ < this.receivedTLSRecords.length; _++) {
895
- const c = this.receivedTLSRecords[_];
896
- if (c.type === e)
897
- return this.receivedTLSRecords.splice(_, 1), c;
895
+ const o = this.receivedTLSRecords[_];
896
+ if (o.type === e)
897
+ return this.receivedTLSRecords.splice(_, 1), o;
898
898
  }
899
899
  const t = await this.pollBytes(5), n = t[3] << 8 | t[4], r = t[0], s = await this.pollBytes(n), a = {
900
900
  type: r,
@@ -903,14 +903,14 @@ class ze {
903
903
  minor: t[2]
904
904
  },
905
905
  length: n,
906
- fragment: this.sessionKeys && r !== l.ChangeCipherSpec ? await this.decryptData(r, s) : s
906
+ fragment: this.sessionKeys && r !== h.ChangeCipherSpec ? await this.decryptData(r, s) : s
907
907
  };
908
- if (a.type === l.Alert) {
909
- const _ = a.fragment[0], c = a.fragment[1], S = fe[_], C = Te[c];
910
- throw _ === de.Warning && c === Ee.CloseNotify ? new j(
908
+ if (a.type === h.Alert) {
909
+ const _ = a.fragment[0], o = a.fragment[1], S = Te[_], l = we[o];
910
+ throw _ === Ee.Warning && o === pe.CloseNotify ? new j(
911
911
  "TLS connection closed by peer (CloseNotify)"
912
912
  ) : new Error(
913
- `TLS alert received: ${S} ${C}`
913
+ `TLS alert received: ${S} ${l}`
914
914
  );
915
915
  }
916
916
  this.receivedTLSRecords.push(a);
@@ -943,7 +943,7 @@ class ze {
943
943
  try {
944
944
  for (; ; ) {
945
945
  const e = await this.readNextMessage(
946
- l.ApplicationData
946
+ h.ApplicationData
947
947
  );
948
948
  this.serverUpstreamWriter.write(e.body);
949
949
  }
@@ -967,7 +967,7 @@ class ze {
967
967
  e,
968
968
  ...x,
969
969
  // Payload length without IV and tag
970
- ...D(t.length - 8 - 16)
970
+ ...W(t.length - 8 - 16)
971
971
  ]),
972
972
  tagLength: 128
973
973
  },
@@ -984,7 +984,7 @@ class ze {
984
984
  ]);
985
985
  const t = this.partialTLSMessages[e.type];
986
986
  switch (e.type) {
987
- case l.Handshake: {
987
+ case h.Handshake: {
988
988
  if (t.length < 4)
989
989
  return !1;
990
990
  const n = t[1] << 8 | t[2];
@@ -992,13 +992,13 @@ class ze {
992
992
  return !1;
993
993
  break;
994
994
  }
995
- case l.Alert: {
995
+ case h.Alert: {
996
996
  if (t.length < 2)
997
997
  return !1;
998
998
  break;
999
999
  }
1000
- case l.ChangeCipherSpec:
1001
- case l.ApplicationData:
1000
+ case h.ChangeCipherSpec:
1001
+ case h.ApplicationData:
1002
1002
  break;
1003
1003
  default:
1004
1004
  throw new Error(`TLS: Unsupported record type ${e.type}`);
@@ -1013,7 +1013,7 @@ class ze {
1013
1013
  * only kicks in after the handshake is complete.
1014
1014
  */
1015
1015
  async writeTLSRecord(e, t) {
1016
- e === l.Handshake && this.handshakeMessages.push(t), this.sessionKeys && e !== l.ChangeCipherSpec && (t = await this.encryptData(e, t));
1016
+ e === h.Handshake && this.handshakeMessages.push(t), this.sessionKeys && e !== h.ChangeCipherSpec && (t = await this.encryptData(e, t));
1017
1017
  const n = x, r = t.length, s = new Uint8Array(5);
1018
1018
  s[0] = e, s[1] = n[0], s[2] = n[1], s[3] = r >> 8 & 255, s[4] = r & 255;
1019
1019
  const a = H([s, t]);
@@ -1029,7 +1029,7 @@ class ze {
1029
1029
  e,
1030
1030
  ...x,
1031
1031
  // Payload length without IV and tag
1032
- ...D(t.length)
1032
+ ...W(t.length)
1033
1033
  ]), _ = await crypto.subtle.encrypt(
1034
1034
  {
1035
1035
  name: "AES-GCM",
@@ -1046,17 +1046,17 @@ class ze {
1046
1046
  ]);
1047
1047
  }
1048
1048
  }
1049
- class E {
1049
+ class T {
1050
1050
  static TLSMessage(e, t) {
1051
1051
  switch (e) {
1052
- case l.Handshake:
1053
- return E.clientHandshake(t);
1054
- case l.Alert:
1055
- return E.alert(t);
1056
- case l.ChangeCipherSpec:
1057
- return E.changeCipherSpec();
1058
- case l.ApplicationData:
1059
- return E.applicationData(t);
1052
+ case h.Handshake:
1053
+ return T.clientHandshake(t);
1054
+ case h.Alert:
1055
+ return T.alert(t);
1056
+ case h.ChangeCipherSpec:
1057
+ return T.changeCipherSpec();
1058
+ case h.ApplicationData:
1059
+ return T.applicationData(t);
1060
1060
  default:
1061
1061
  throw new Error(`TLS: Unsupported TLS record type ${e}`);
1062
1062
  }
@@ -1085,7 +1085,7 @@ class E {
1085
1085
  * https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#tls-parameters-4
1086
1086
  */
1087
1087
  static parseCipherSuites(e) {
1088
- const t = new g(e);
1088
+ const t = new I(e);
1089
1089
  t.readUint16();
1090
1090
  const n = [];
1091
1091
  for (; !t.isFinished(); ) {
@@ -1096,44 +1096,44 @@ class E {
1096
1096
  }
1097
1097
  static applicationData(e) {
1098
1098
  return {
1099
- type: l.ApplicationData,
1099
+ type: h.ApplicationData,
1100
1100
  body: e
1101
1101
  };
1102
1102
  }
1103
1103
  static changeCipherSpec() {
1104
1104
  return {
1105
- type: l.ChangeCipherSpec,
1105
+ type: h.ChangeCipherSpec,
1106
1106
  body: new Uint8Array()
1107
1107
  };
1108
1108
  }
1109
1109
  static alert(e) {
1110
1110
  return {
1111
- type: l.Alert,
1112
- level: fe[e[0]],
1113
- description: Te[e[1]]
1111
+ type: h.Alert,
1112
+ level: Te[e[0]],
1113
+ description: we[e[1]]
1114
1114
  };
1115
1115
  }
1116
1116
  static clientHandshake(e) {
1117
1117
  const t = e[0], n = e[1] << 16 | e[2] << 8 | e[3], r = e.slice(4);
1118
1118
  let s;
1119
1119
  switch (t) {
1120
- case f.HelloRequest:
1121
- s = E.clientHelloRequestPayload();
1120
+ case E.HelloRequest:
1121
+ s = T.clientHelloRequestPayload();
1122
1122
  break;
1123
- case f.ClientHello:
1124
- s = E.clientHelloPayload(r);
1123
+ case E.ClientHello:
1124
+ s = T.clientHelloPayload(r);
1125
1125
  break;
1126
- case f.ClientKeyExchange:
1127
- s = E.clientKeyExchangePayload(r);
1126
+ case E.ClientKeyExchange:
1127
+ s = T.clientKeyExchangePayload(r);
1128
1128
  break;
1129
- case f.Finished:
1130
- s = E.clientFinishedPayload(r);
1129
+ case E.Finished:
1130
+ s = T.clientFinishedPayload(r);
1131
1131
  break;
1132
1132
  default:
1133
1133
  throw new Error(`Invalid handshake type ${t}`);
1134
1134
  }
1135
1135
  return {
1136
- type: l.Handshake,
1136
+ type: h.Handshake,
1137
1137
  msg_type: t,
1138
1138
  length: n,
1139
1139
  body: s
@@ -1183,7 +1183,7 @@ class E {
1183
1183
  * +------+------+---------------------------+
1184
1184
  */
1185
1185
  static clientHelloPayload(e) {
1186
- const t = new g(e.buffer), n = {
1186
+ const t = new I(e.buffer), n = {
1187
1187
  client_version: t.readUint8Array(2),
1188
1188
  /**
1189
1189
  * Technically this consists of a GMT timestamp
@@ -1194,7 +1194,7 @@ class E {
1194
1194
  }, r = t.readUint8();
1195
1195
  n.session_id = t.readUint8Array(r);
1196
1196
  const s = t.readUint16();
1197
- n.cipher_suites = E.parseCipherSuites(
1197
+ n.cipher_suites = T.parseCipherSuites(
1198
1198
  t.readUint8Array(s).buffer
1199
1199
  );
1200
1200
  const a = t.readUint8();
@@ -1202,7 +1202,7 @@ class E {
1202
1202
  a
1203
1203
  );
1204
1204
  const _ = t.readUint16();
1205
- return n.extensions = Oe(
1205
+ return n.extensions = $e(
1206
1206
  t.readUint8Array(_)
1207
1207
  ), n;
1208
1208
  }
@@ -1227,7 +1227,7 @@ class E {
1227
1227
  };
1228
1228
  }
1229
1229
  }
1230
- function Ye(i) {
1230
+ function Xe(i) {
1231
1231
  return new TransformStream({
1232
1232
  transform(e, t) {
1233
1233
  for (; e.length > 0; )
@@ -1235,18 +1235,18 @@ function Ye(i) {
1235
1235
  }
1236
1236
  });
1237
1237
  }
1238
- class K {
1238
+ class D {
1239
1239
  static certificate(e) {
1240
1240
  const t = [];
1241
1241
  for (const s of e)
1242
- t.push(m(s.byteLength)), t.push(new Uint8Array(s));
1242
+ t.push(L(s.byteLength)), t.push(new Uint8Array(s));
1243
1243
  const n = H(t), r = new Uint8Array([
1244
- ...m(n.byteLength),
1244
+ ...L(n.byteLength),
1245
1245
  ...n
1246
1246
  ]);
1247
1247
  return new Uint8Array([
1248
- f.Certificate,
1249
- ...m(r.length),
1248
+ E.Certificate,
1249
+ ...L(r.length),
1250
1250
  ...r
1251
1251
  ]);
1252
1252
  }
@@ -1288,9 +1288,9 @@ class K {
1288
1288
  await crypto.subtle.exportKey("raw", n.publicKey)
1289
1289
  ), a = new Uint8Array([
1290
1290
  // Curve type (1 byte)
1291
- Ge.NamedCurve,
1291
+ ze.NamedCurve,
1292
1292
  // Curve name (2 bytes)
1293
- ...D($e.secp256r1),
1293
+ ...W(Ye.secp256r1),
1294
1294
  // Public key length (1 byte)
1295
1295
  s.byteLength,
1296
1296
  // Public key (65 bytes, uncompressed format)
@@ -1302,19 +1302,19 @@ class K {
1302
1302
  },
1303
1303
  r,
1304
1304
  new Uint8Array([...e, ...t, ...a])
1305
- ), c = new Uint8Array(_), S = new Uint8Array([
1305
+ ), o = new Uint8Array(_), S = new Uint8Array([
1306
1306
  z.sha256,
1307
1307
  V.rsa
1308
- ]), C = new Uint8Array([
1308
+ ]), l = new Uint8Array([
1309
1309
  ...a,
1310
1310
  ...S,
1311
- ...D(c.length),
1312
- ...c
1311
+ ...W(o.length),
1312
+ ...o
1313
1313
  ]);
1314
1314
  return new Uint8Array([
1315
- f.ServerKeyExchange,
1316
- ...m(C.length),
1317
- ...C
1315
+ E.ServerKeyExchange,
1316
+ ...L(l.length),
1317
+ ...l
1318
1318
  ]);
1319
1319
  }
1320
1320
  /**
@@ -1359,13 +1359,13 @@ class K {
1359
1359
  const r = e.extensions.map((_) => {
1360
1360
  switch (_.type) {
1361
1361
  case "server_name":
1362
- return Ce.encodeForClient();
1362
+ return he.encodeForClient();
1363
1363
  case "ec_point_formats":
1364
- return he.encodeForClient(
1364
+ return Ae.encodeForClient(
1365
1365
  "uncompressed"
1366
1366
  );
1367
1367
  case "renegotiation_info":
1368
- return Ae.encodeForClient();
1368
+ return He.encodeForClient();
1369
1369
  }
1370
1370
  }).filter((_) => _ !== void 0), s = H(r), a = new Uint8Array([
1371
1371
  // Version field – 0x03, 0x03 means TLS 1.2
@@ -1373,20 +1373,20 @@ class K {
1373
1373
  ...t,
1374
1374
  e.session_id.length,
1375
1375
  ...e.session_id,
1376
- ...D(ue.TLS1_CK_ECDHE_RSA_WITH_AES_128_GCM_SHA256),
1376
+ ...W(de.TLS1_CK_ECDHE_RSA_WITH_AES_128_GCM_SHA256),
1377
1377
  n,
1378
1378
  // Extensions length (2 bytes)
1379
- ...D(s.length),
1379
+ ...W(s.length),
1380
1380
  ...s
1381
1381
  ]);
1382
1382
  return new Uint8Array([
1383
- f.ServerHello,
1384
- ...m(a.length),
1383
+ E.ServerHello,
1384
+ ...L(a.length),
1385
1385
  ...a
1386
1386
  ]);
1387
1387
  }
1388
1388
  static serverHelloDone() {
1389
- return new Uint8Array([f.ServerHelloDone, ...m(0)]);
1389
+ return new Uint8Array([E.ServerHelloDone, ...L(0)]);
1390
1390
  }
1391
1391
  /**
1392
1392
  * Server finished message.
@@ -1420,8 +1420,8 @@ class K {
1420
1420
  )
1421
1421
  );
1422
1422
  return new Uint8Array([
1423
- f.Finished,
1424
- ...m(r.length),
1423
+ E.Finished,
1424
+ ...L(r.length),
1425
1425
  ...r
1426
1426
  ]);
1427
1427
  }
@@ -1429,25 +1429,25 @@ class K {
1429
1429
  return new Uint8Array([1]);
1430
1430
  }
1431
1431
  }
1432
- function Ze(i, e) {
1433
- return Je.generateCertificate(i, e);
1432
+ function Qe(i, e) {
1433
+ return et.generateCertificate(i, e);
1434
1434
  }
1435
- function gt(i) {
1435
+ function Dt(i) {
1436
1436
  return `-----BEGIN CERTIFICATE-----
1437
- ${we(
1438
- pe(i.buffer)
1437
+ ${me(
1438
+ ye(i.buffer)
1439
1439
  )}
1440
1440
  -----END CERTIFICATE-----`;
1441
1441
  }
1442
- async function It(i) {
1442
+ async function Wt(i) {
1443
1443
  const e = await crypto.subtle.exportKey("pkcs8", i);
1444
1444
  return `-----BEGIN PRIVATE KEY-----
1445
- ${we(
1446
- pe(e)
1445
+ ${me(
1446
+ ye(e)
1447
1447
  )}
1448
1448
  -----END PRIVATE KEY-----`;
1449
1449
  }
1450
- class Je {
1450
+ class et {
1451
1451
  static async generateCertificate(e, t) {
1452
1452
  const n = await crypto.subtle.generateKey(
1453
1453
  {
@@ -1482,17 +1482,17 @@ class Je {
1482
1482
  t,
1483
1483
  e.buffer
1484
1484
  );
1485
- return o.sequence([
1485
+ return c.sequence([
1486
1486
  new Uint8Array(e.buffer),
1487
1487
  this.signatureAlgorithm("sha256WithRSAEncryption"),
1488
- o.bitString(new Uint8Array(n))
1488
+ c.bitString(new Uint8Array(n))
1489
1489
  ]);
1490
1490
  }
1491
1491
  static async signingRequest(e, t) {
1492
1492
  const n = [];
1493
1493
  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(
1494
1494
  this.basicConstraints(e.basicConstraints)
1495
- ), o.sequence([
1495
+ ), c.sequence([
1496
1496
  this.version(e.version),
1497
1497
  this.serialNumber(e.serialNumber),
1498
1498
  this.signatureAlgorithm(e.signatureAlgorithm),
@@ -1504,56 +1504,56 @@ class Je {
1504
1504
  ]);
1505
1505
  }
1506
1506
  static version(e = 2) {
1507
- return o.ASN1(
1507
+ return c.ASN1(
1508
1508
  160,
1509
- o.integer(new Uint8Array([e]))
1509
+ c.integer(new Uint8Array([e]))
1510
1510
  );
1511
1511
  }
1512
1512
  static serialNumber(e = crypto.getRandomValues(new Uint8Array(4))) {
1513
- return o.integer(e);
1513
+ return c.integer(e);
1514
1514
  }
1515
1515
  static signatureAlgorithm(e = "sha256WithRSAEncryption") {
1516
- return o.sequence([
1517
- o.objectIdentifier(w(e)),
1518
- o.null()
1516
+ return c.sequence([
1517
+ c.objectIdentifier(y(e)),
1518
+ c.null()
1519
1519
  ]);
1520
1520
  }
1521
1521
  static async subjectPublicKeyInfo(e) {
1522
1522
  return new Uint8Array(await crypto.subtle.exportKey("spki", e));
1523
1523
  }
1524
1524
  static extensions(e) {
1525
- return o.ASN1(163, o.sequence(e));
1525
+ return c.ASN1(163, c.sequence(e));
1526
1526
  }
1527
1527
  static distinguishedName(e) {
1528
1528
  const t = [];
1529
1529
  for (const [n, r] of Object.entries(e)) {
1530
1530
  const s = [
1531
- o.objectIdentifier(w(n))
1531
+ c.objectIdentifier(y(n))
1532
1532
  ];
1533
1533
  switch (n) {
1534
1534
  case "countryName":
1535
- s.push(o.printableString(r));
1535
+ s.push(c.printableString(r));
1536
1536
  break;
1537
1537
  default:
1538
- s.push(o.utf8String(r));
1538
+ s.push(c.utf8String(r));
1539
1539
  }
1540
- t.push(o.set([o.sequence(s)]));
1540
+ t.push(c.set([c.sequence(s)]));
1541
1541
  }
1542
- return o.sequence(t);
1542
+ return c.sequence(t);
1543
1543
  }
1544
1544
  static validity(e) {
1545
- return o.sequence([
1546
- o.ASN1(
1547
- d.UTCTime,
1545
+ return c.sequence([
1546
+ c.ASN1(
1547
+ f.UTCTime,
1548
1548
  new TextEncoder().encode(
1549
1549
  ie((e == null ? void 0 : e.notBefore) ?? /* @__PURE__ */ new Date())
1550
1550
  )
1551
1551
  ),
1552
- o.ASN1(
1553
- d.UTCTime,
1552
+ c.ASN1(
1553
+ f.UTCTime,
1554
1554
  new TextEncoder().encode(
1555
1555
  ie(
1556
- (e == null ? void 0 : e.notAfter) ?? Qe(/* @__PURE__ */ new Date(), 10)
1556
+ (e == null ? void 0 : e.notAfter) ?? nt(/* @__PURE__ */ new Date(), 10)
1557
1557
  )
1558
1558
  )
1559
1559
  )
@@ -1563,63 +1563,63 @@ class Je {
1563
1563
  ca: e = !0,
1564
1564
  pathLenConstraint: t = void 0
1565
1565
  }) {
1566
- const n = [o.boolean(e)];
1566
+ const n = [c.boolean(e)];
1567
1567
  return t !== void 0 && n.push(
1568
- o.integer(new Uint8Array([t]))
1569
- ), o.sequence([
1570
- o.objectIdentifier(w("basicConstraints")),
1571
- o.octetString(o.sequence(n))
1568
+ c.integer(new Uint8Array([t]))
1569
+ ), c.sequence([
1570
+ c.objectIdentifier(y("basicConstraints")),
1571
+ c.octetString(c.sequence(n))
1572
1572
  ]);
1573
1573
  }
1574
1574
  static keyUsage(e) {
1575
1575
  const t = new Uint8Array([0]);
1576
- 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([
1577
- o.objectIdentifier(w("keyUsage")),
1578
- o.boolean(!0),
1576
+ 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), c.sequence([
1577
+ c.objectIdentifier(y("keyUsage")),
1578
+ c.boolean(!0),
1579
1579
  // Critical
1580
- o.octetString(o.bitString(t))
1580
+ c.octetString(c.bitString(t))
1581
1581
  ]);
1582
1582
  }
1583
1583
  static extKeyUsage(e = {}) {
1584
- return o.sequence([
1585
- o.objectIdentifier(w("extKeyUsage")),
1586
- o.boolean(!0),
1584
+ return c.sequence([
1585
+ c.objectIdentifier(y("extKeyUsage")),
1586
+ c.boolean(!0),
1587
1587
  // Critical
1588
- o.octetString(
1589
- o.sequence(
1590
- Object.entries(e).map(([t, n]) => n ? o.objectIdentifier(
1591
- w(t)
1592
- ) : o.null())
1588
+ c.octetString(
1589
+ c.sequence(
1590
+ Object.entries(e).map(([t, n]) => n ? c.objectIdentifier(
1591
+ y(t)
1592
+ ) : c.null())
1593
1593
  )
1594
1594
  )
1595
1595
  ]);
1596
1596
  }
1597
1597
  static nsCertType(e) {
1598
1598
  const t = new Uint8Array([0]);
1599
- 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([
1600
- o.objectIdentifier(w("nsCertType")),
1601
- o.octetString(t)
1599
+ 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), c.sequence([
1600
+ c.objectIdentifier(y("nsCertType")),
1601
+ c.octetString(t)
1602
1602
  ]);
1603
1603
  }
1604
1604
  static subjectAltName(e) {
1605
1605
  var s, a;
1606
1606
  const t = ((s = e.dnsNames) == null ? void 0 : s.map((_) => {
1607
- const c = o.ia5String(_);
1608
- return o.contextSpecific(2, c);
1607
+ const o = c.ia5String(_);
1608
+ return c.contextSpecific(2, o);
1609
1609
  })) || [], n = ((a = e.ipAddresses) == null ? void 0 : a.map((_) => {
1610
- const c = o.ia5String(_);
1611
- return o.contextSpecific(7, c);
1612
- })) || [], r = o.octetString(
1613
- o.sequence([...t, ...n])
1610
+ const o = c.ia5String(_);
1611
+ return c.contextSpecific(7, o);
1612
+ })) || [], r = c.octetString(
1613
+ c.sequence([...t, ...n])
1614
1614
  );
1615
- return o.sequence([
1616
- o.objectIdentifier(w("subjectAltName")),
1617
- o.boolean(!0),
1615
+ return c.sequence([
1616
+ c.objectIdentifier(y("subjectAltName")),
1617
+ c.boolean(!0),
1618
1618
  r
1619
1619
  ]);
1620
1620
  }
1621
1621
  }
1622
- const Xe = {
1622
+ const tt = {
1623
1623
  // Algorithm OIDs
1624
1624
  "1.2.840.113549.1.1.1": "rsaEncryption",
1625
1625
  "1.2.840.113549.1.1.4": "md5WithRSAEncryption",
@@ -1729,13 +1729,13 @@ const Xe = {
1729
1729
  "1.3.6.1.5.5.7.3.4": "emailProtection",
1730
1730
  "1.3.6.1.5.5.7.3.8": "timeStamping"
1731
1731
  };
1732
- function w(i) {
1733
- for (const [e, t] of Object.entries(Xe))
1732
+ function y(i) {
1733
+ for (const [e, t] of Object.entries(tt))
1734
1734
  if (t === i)
1735
1735
  return e;
1736
1736
  throw new Error(`OID not found for name: ${i}`);
1737
1737
  }
1738
- const se = 32, d = {
1738
+ const se = 32, f = {
1739
1739
  Boolean: 1,
1740
1740
  Integer: 2,
1741
1741
  BitString: 3,
@@ -1749,7 +1749,7 @@ const se = 32, d = {
1749
1749
  IA5String: 22,
1750
1750
  UTCTime: 23
1751
1751
  };
1752
- class o {
1752
+ class c {
1753
1753
  // Helper functions for ASN.1 DER encoding
1754
1754
  static length_(e) {
1755
1755
  if (e < 128)
@@ -1767,7 +1767,7 @@ class o {
1767
1767
  }
1768
1768
  }
1769
1769
  static ASN1(e, t) {
1770
- const n = o.length_(t.length), r = new Uint8Array(1 + n.length + t.length);
1770
+ const n = c.length_(t.length), r = new Uint8Array(1 + n.length + t.length);
1771
1771
  return r[0] = e, r.set(n, 1), r.set(t, 1 + n.length), r;
1772
1772
  }
1773
1773
  static integer(e) {
@@ -1778,17 +1778,17 @@ class o {
1778
1778
  const n = new Uint8Array(e.length + 1);
1779
1779
  n[0] = 0, n.set(e, 1), e = n;
1780
1780
  }
1781
- return o.ASN1(d.Integer, e);
1781
+ return c.ASN1(f.Integer, e);
1782
1782
  }
1783
1783
  static bitString(e) {
1784
1784
  const t = new Uint8Array([0]), n = new Uint8Array(t.length + e.length);
1785
- return n.set(t), n.set(e, t.length), o.ASN1(d.BitString, n);
1785
+ return n.set(t), n.set(e, t.length), c.ASN1(f.BitString, n);
1786
1786
  }
1787
1787
  static octetString(e) {
1788
- return o.ASN1(d.OctetString, e);
1788
+ return c.ASN1(f.OctetString, e);
1789
1789
  }
1790
1790
  static null() {
1791
- return o.ASN1(d.Null, new Uint8Array(0));
1791
+ return c.ASN1(f.Null, new Uint8Array(0));
1792
1792
  }
1793
1793
  static objectIdentifier(e) {
1794
1794
  const t = e.split(".").map(Number), r = [t[0] * 40 + t[1]];
@@ -1798,61 +1798,61 @@ class o {
1798
1798
  do
1799
1799
  _.unshift(a & 127), a >>= 7;
1800
1800
  while (a > 0);
1801
- for (let c = 0; c < _.length - 1; c++)
1802
- _[c] |= 128;
1801
+ for (let o = 0; o < _.length - 1; o++)
1802
+ _[o] |= 128;
1803
1803
  r.push(..._);
1804
1804
  }
1805
- return o.ASN1(d.OID, new Uint8Array(r));
1805
+ return c.ASN1(f.OID, new Uint8Array(r));
1806
1806
  }
1807
1807
  static utf8String(e) {
1808
1808
  const t = new TextEncoder().encode(e);
1809
- return o.ASN1(d.Utf8String, t);
1809
+ return c.ASN1(f.Utf8String, t);
1810
1810
  }
1811
1811
  static printableString(e) {
1812
1812
  const t = new TextEncoder().encode(e);
1813
- return o.ASN1(d.PrintableString, t);
1813
+ return c.ASN1(f.PrintableString, t);
1814
1814
  }
1815
1815
  static sequence(e) {
1816
- return o.ASN1(d.Sequence, H(e));
1816
+ return c.ASN1(f.Sequence, H(e));
1817
1817
  }
1818
1818
  static set(e) {
1819
- return o.ASN1(d.Set, H(e));
1819
+ return c.ASN1(f.Set, H(e));
1820
1820
  }
1821
1821
  static ia5String(e) {
1822
1822
  const t = new TextEncoder().encode(e);
1823
- return o.ASN1(d.IA5String, t);
1823
+ return c.ASN1(f.IA5String, t);
1824
1824
  }
1825
1825
  static contextSpecific(e, t, n = !1) {
1826
1826
  const r = (n ? 160 : 128) | e;
1827
- return o.ASN1(r, t);
1827
+ return c.ASN1(r, t);
1828
1828
  }
1829
1829
  static boolean(e) {
1830
- return o.ASN1(
1831
- d.Boolean,
1830
+ return c.ASN1(
1831
+ f.Boolean,
1832
1832
  new Uint8Array([e ? 255 : 0])
1833
1833
  );
1834
1834
  }
1835
1835
  }
1836
- function pe(i) {
1836
+ function ye(i) {
1837
1837
  return btoa(String.fromCodePoint(...new Uint8Array(i)));
1838
1838
  }
1839
- function we(i) {
1839
+ function me(i) {
1840
1840
  var e;
1841
1841
  return ((e = i.match(/.{1,64}/g)) == null ? void 0 : e.join(`
1842
1842
  `)) || i;
1843
1843
  }
1844
1844
  function ie(i) {
1845
- const e = i.getUTCFullYear().toString().substr(2), t = R(i.getUTCMonth() + 1), n = R(i.getUTCDate()), r = R(i.getUTCHours()), s = R(i.getUTCMinutes()), a = R(i.getUTCSeconds());
1845
+ const e = i.getUTCFullYear().toString().substr(2), t = U(i.getUTCMonth() + 1), n = U(i.getUTCDate()), r = U(i.getUTCHours()), s = U(i.getUTCMinutes()), a = U(i.getUTCSeconds());
1846
1846
  return `${e}${t}${n}${r}${s}${a}Z`;
1847
1847
  }
1848
- function R(i) {
1848
+ function U(i) {
1849
1849
  return i.toString().padStart(2, "0");
1850
1850
  }
1851
- function Qe(i, e) {
1851
+ function nt(i, e) {
1852
1852
  const t = new Date(i);
1853
1853
  return t.setUTCFullYear(t.getUTCFullYear() + e), t;
1854
1854
  }
1855
- class et extends TransformStream {
1855
+ class rt extends TransformStream {
1856
1856
  constructor() {
1857
1857
  let e = new Uint8Array(0), t = "SCAN_CHUNK_SIZE", n = 0;
1858
1858
  super({
@@ -1880,12 +1880,12 @@ class et extends TransformStream {
1880
1880
  );
1881
1881
  const _ = new TextDecoder().decode(
1882
1882
  e.slice(0, a)
1883
- ), c = parseInt(_, 16);
1884
- if (e = e.slice(a + 2), c === 0) {
1883
+ ), o = parseInt(_, 16);
1884
+ if (e = e.slice(a + 2), o === 0) {
1885
1885
  t = "SCAN_FINAL_CHUNK", s.terminate();
1886
1886
  return;
1887
1887
  }
1888
- n = c, t = "SCAN_CHUNK_DATA";
1888
+ n = o, t = "SCAN_CHUNK_DATA";
1889
1889
  } else if (t === "SCAN_CHUNK_DATA") {
1890
1890
  const a = Math.min(
1891
1891
  n,
@@ -1905,7 +1905,7 @@ class et extends TransformStream {
1905
1905
  });
1906
1906
  }
1907
1907
  }
1908
- const tt = (i, e) => ({
1908
+ const st = (i, e) => ({
1909
1909
  ...i,
1910
1910
  websocket: {
1911
1911
  url: (t, n, r) => `ws://playground.internal/?${new URLSearchParams({
@@ -1913,7 +1913,7 @@ const tt = (i, e) => ({
1913
1913
  port: r
1914
1914
  }).toString()}`,
1915
1915
  subprotocol: "binary",
1916
- decorator: () => class extends nt {
1916
+ decorator: () => class extends it {
1917
1917
  constructor(t, n) {
1918
1918
  super(t, n, {
1919
1919
  CAroot: e.CAroot,
@@ -1923,7 +1923,7 @@ const tt = (i, e) => ({
1923
1923
  }
1924
1924
  }
1925
1925
  });
1926
- class nt {
1926
+ class it {
1927
1927
  constructor(e, t, {
1928
1928
  CAroot: n,
1929
1929
  corsProxyUrl: r,
@@ -1994,7 +1994,7 @@ class nt {
1994
1994
  switch (this.bufferedBytesFromClient = H([
1995
1995
  this.bufferedBytesFromClient,
1996
1996
  new Uint8Array(e)
1997
- ]), st(this.port, this.bufferedBytesFromClient)) {
1997
+ ]), _t(this.port, this.bufferedBytesFromClient)) {
1998
1998
  case !1:
1999
1999
  return;
2000
2000
  case "other":
@@ -2013,7 +2013,7 @@ class nt {
2013
2013
  throw new Error(
2014
2014
  "TLS protocol is only supported when the TCPOverFetchWebsocket is instantiated with a CAroot"
2015
2015
  );
2016
- const e = await Ze(
2016
+ const e = await Qe(
2017
2017
  {
2018
2018
  subject: {
2019
2019
  commonName: this.host,
@@ -2023,14 +2023,14 @@ class nt {
2023
2023
  issuer: this.CAroot.tbsDescription.subject
2024
2024
  },
2025
2025
  this.CAroot.keyPair
2026
- ), t = new ze();
2026
+ ), t = new Je();
2027
2027
  this.clientUpstream.readable.pipeTo(t.clientEnd.upstream.writable).catch(() => {
2028
2028
  }), t.clientEnd.downstream.readable.pipeTo(this.clientDownstream.writable).catch(() => {
2029
2029
  }), await t.TLSHandshake(e.keyPair.privateKey, [
2030
2030
  e.certificate,
2031
2031
  this.CAroot.certificate
2032
2032
  ]);
2033
- const { request: n, expectsContinue: r } = await L.parseHttpRequest(
2033
+ const { request: n, expectsContinue: r } = await p.parseHttpRequest(
2034
2034
  t.serverEnd.upstream.readable,
2035
2035
  this.host,
2036
2036
  "https"
@@ -2044,7 +2044,7 @@ class nt {
2044
2044
  ), s.releaseLock();
2045
2045
  }
2046
2046
  try {
2047
- await L.fetchRawResponseBytes(
2047
+ await p.fetchRawResponseBytes(
2048
2048
  n,
2049
2049
  this.corsProxyUrl
2050
2050
  ).pipeTo(t.serverEnd.downstream.writable);
@@ -2052,7 +2052,7 @@ class nt {
2052
2052
  }
2053
2053
  }
2054
2054
  async fetchOverHTTP() {
2055
- const { request: e, expectsContinue: t } = await L.parseHttpRequest(
2055
+ const { request: e, expectsContinue: t } = await p.parseHttpRequest(
2056
2056
  this.clientUpstream.readable,
2057
2057
  this.host,
2058
2058
  "http"
@@ -2066,7 +2066,7 @@ class nt {
2066
2066
  ), n.releaseLock();
2067
2067
  }
2068
2068
  try {
2069
- await L.fetchRawResponseBytes(
2069
+ await p.fetchRawResponseBytes(
2070
2070
  e,
2071
2071
  this.corsProxyUrl
2072
2072
  ).pipeTo(this.clientDownstream.writable);
@@ -2077,7 +2077,7 @@ class nt {
2077
2077
  this.emit("message", { data: new Uint8Array(0) }), this.readyState = this.CLOSING, this.emit("close"), this.readyState = this.CLOSED;
2078
2078
  }
2079
2079
  }
2080
- const rt = [
2080
+ const at = [
2081
2081
  "GET",
2082
2082
  "POST",
2083
2083
  "HEAD",
@@ -2087,20 +2087,20 @@ const rt = [
2087
2087
  "PUT",
2088
2088
  "TRACE"
2089
2089
  ];
2090
- function st(i, e) {
2090
+ function _t(i, e) {
2091
2091
  if (e.length < 8)
2092
2092
  return !1;
2093
- if (i === 443 && e[0] === l.Handshake && // TLS versions between 1.0 and 1.2
2093
+ if (i === 443 && e[0] === h.Handshake && // TLS versions between 1.0 and 1.2
2094
2094
  e[1] === 3 && e[2] >= 1 && e[2] <= 3)
2095
2095
  return "tls";
2096
2096
  const n = new TextDecoder("latin1", {
2097
2097
  fatal: !0
2098
2098
  }).decode(e);
2099
- return rt.some(
2099
+ return at.some(
2100
2100
  (s) => n.startsWith(s + " ")
2101
2101
  ) ? "http" : "other";
2102
2102
  }
2103
- class L {
2103
+ class p {
2104
2104
  /**
2105
2105
  * Streams a HTTP response including the status line and headers.
2106
2106
  */
@@ -2110,12 +2110,12 @@ class L {
2110
2110
  var _;
2111
2111
  let r;
2112
2112
  try {
2113
- r = await Re(
2113
+ r = await ve(
2114
2114
  e,
2115
2115
  void 0,
2116
2116
  t
2117
2117
  );
2118
- } catch (c) {
2118
+ } catch (o) {
2119
2119
  n.enqueue(
2120
2120
  new TextEncoder().encode(
2121
2121
  `HTTP/1.1 400 Bad Request\r
@@ -2123,10 +2123,10 @@ Content-Length: 0\r
2123
2123
  \r
2124
2124
  `
2125
2125
  )
2126
- ), n.error(c);
2126
+ ), n.error(o);
2127
2127
  return;
2128
2128
  }
2129
- n.enqueue(L.headersAsBytes(r));
2129
+ n.enqueue(p.headersAsBytes(r));
2130
2130
  const s = (_ = r.body) == null ? void 0 : _.getReader();
2131
2131
  if (!s) {
2132
2132
  n.close();
@@ -2134,12 +2134,12 @@ Content-Length: 0\r
2134
2134
  }
2135
2135
  const a = new TextEncoder();
2136
2136
  for (; ; ) {
2137
- const { done: c, value: S } = await s.read();
2137
+ const { done: o, value: S } = await s.read();
2138
2138
  if (S && (n.enqueue(
2139
2139
  a.encode(`${S.length.toString(16)}\r
2140
2140
  `)
2141
2141
  ), n.enqueue(S), n.enqueue(a.encode(`\r
2142
- `))), c) {
2142
+ `))), o) {
2143
2143
  n.enqueue(a.encode(`0\r
2144
2144
  \r
2145
2145
  `)), n.close();
@@ -2171,81 +2171,105 @@ Content-Length: 0\r
2171
2171
  let r = new Uint8Array(0), s = !1, a = -1;
2172
2172
  const _ = e.getReader();
2173
2173
  for (; a === -1; ) {
2174
- const { done: k, value: P } = await _.read();
2174
+ const { done: k, value: R } = await _.read();
2175
2175
  if (k) {
2176
2176
  s = !0;
2177
2177
  break;
2178
2178
  }
2179
- r = H([r, P]), a = it(
2179
+ r = H([r, R]), a = ot(
2180
2180
  r,
2181
2181
  new Uint8Array([13, 10, 13, 10])
2182
2182
  );
2183
2183
  }
2184
2184
  _.releaseLock();
2185
- const c = r.slice(0, a), S = L.parseRequestHeaders(c), C = S.headers.get("Transfer-Encoding") !== null ? "chunked" : "content-length", h = S.headers.get("Content-Length") !== null ? parseInt(S.headers.get("Content-Length"), 10) : void 0, A = r.slice(
2185
+ const o = r.slice(0, a), S = p.parseRequestHeaders(o), l = p.expectsContinue(
2186
+ S.headers
2187
+ ), C = S.headers.get("Transfer-Encoding") !== null ? "chunked" : "content-length", A = S.headers.get("Content-Length") !== null ? parseInt(S.headers.get("Content-Length"), 10) : void 0, u = r.slice(
2186
2188
  a + 4
2187
2189
  /* Skip \r\n\r\n */
2188
2190
  );
2189
- let u;
2190
- if (S.method !== "GET") {
2191
+ let d;
2192
+ if (S.method !== "GET" && S.method !== "HEAD") {
2191
2193
  const k = e.getReader();
2192
- let P = A.length, q = A.slice(-6);
2193
- const me = new TextEncoder().encode(`0\r
2194
+ let R = u.length, q = u.slice(-6);
2195
+ const Ie = new TextEncoder().encode(`0\r
2194
2196
  \r
2195
2197
  `);
2196
- u = new ReadableStream({
2197
- async start(b) {
2198
- A.length > 0 && b.enqueue(A);
2199
- const F = C === "content-length" && h !== void 0 && P >= h;
2200
- (s || F) && b.close();
2198
+ d = new ReadableStream({
2199
+ async start(B) {
2200
+ u.length > 0 && B.enqueue(u);
2201
+ const F = C === "content-length" && A !== void 0 && R >= A;
2202
+ (s || F) && B.close();
2201
2203
  },
2202
- async pull(b) {
2203
- const { done: F, value: I } = await k.read();
2204
- if (P += (I == null ? void 0 : I.length) || 0, I && (b.enqueue(I), q = H([
2204
+ async pull(B) {
2205
+ const { done: F, value: K } = await k.read();
2206
+ if (R += (K == null ? void 0 : K.length) || 0, K && (B.enqueue(K), q = H([
2205
2207
  q,
2206
- I || new Uint8Array()
2207
- ]).slice(-5)), F || C === "content-length" && h !== void 0 && P >= h || C === "chunked" && q.every(
2208
- (Le, ge) => Le === me[ge]
2208
+ K || new Uint8Array()
2209
+ ]).slice(-5)), F || C === "content-length" && A !== void 0 && R >= A || C === "chunked" && q.every(
2210
+ (Ke, De) => Ke === Ie[De]
2209
2211
  )) {
2210
- b.close();
2212
+ B.close();
2211
2213
  return;
2212
2214
  }
2213
2215
  }
2214
- }), C === "chunked" && (u = u.pipeThrough(
2215
- new et()
2216
+ }), C === "chunked" && (d = d.pipeThrough(
2217
+ new rt()
2216
2218
  ));
2217
2219
  }
2218
- const T = S.headers.get("Host") ?? t, y = new URL(S.path, n + "://" + T);
2220
+ const m = S.headers.get("Host") ?? t, b = new URL(S.path, n + "://" + m), ge = p.normalizeRequestHeadersForFetch(
2221
+ S.headers
2222
+ );
2219
2223
  return {
2220
- request: new Request(y.toString(), {
2224
+ request: new Request(b.toString(), {
2221
2225
  method: S.method,
2222
- headers: S.headers,
2223
- body: u,
2226
+ headers: ge,
2227
+ body: d,
2224
2228
  // @ts-expect-error duplex is required for streaming request bodies
2225
- duplex: u ? "half" : void 0
2229
+ duplex: d ? "half" : void 0
2226
2230
  }),
2227
- expectsContinue: S.expectsContinue
2231
+ expectsContinue: l
2228
2232
  };
2229
2233
  }
2230
2234
  static parseRequestHeaders(e) {
2231
- var c;
2232
2235
  const t = new TextDecoder().decode(e), n = t.split(`
2233
2236
  `)[0], [r, s] = n.split(" "), a = new Headers();
2234
- for (const S of t.split(`\r
2237
+ for (const _ of t.split(`\r
2235
2238
  `).slice(1)) {
2236
- if (S === "")
2239
+ if (_ === "")
2237
2240
  break;
2238
- const C = S.indexOf(":");
2239
- if (C === -1)
2241
+ const o = _.indexOf(":");
2242
+ if (o === -1)
2240
2243
  continue;
2241
- const h = S.slice(0, C).trim(), A = S.slice(C + 1).trimStart();
2242
- h !== "" && a.set(h, A);
2244
+ const S = _.slice(0, o).trim(), l = _.slice(o + 1).trimStart();
2245
+ S !== "" && a.set(S, l);
2243
2246
  }
2244
- const _ = ((c = a.get("Expect")) == null ? void 0 : c.toLowerCase()) === "100-continue";
2245
- return a.delete("Expect"), { method: r, path: s, headers: a, expectsContinue: _ };
2247
+ return { method: r, path: s, headers: a };
2248
+ }
2249
+ static expectsContinue(e) {
2250
+ var t;
2251
+ return ((t = e.get("Expect")) == null ? void 0 : t.toLowerCase()) === "100-continue";
2252
+ }
2253
+ static normalizeRequestHeadersForFetch(e) {
2254
+ const t = new Headers(e);
2255
+ for (const n of [
2256
+ "Connection",
2257
+ "Content-Length",
2258
+ "Expect",
2259
+ "Host",
2260
+ "Keep-Alive",
2261
+ "Proxy-Authenticate",
2262
+ "Proxy-Authorization",
2263
+ "TE",
2264
+ "Trailer",
2265
+ "Transfer-Encoding",
2266
+ "Upgrade"
2267
+ ])
2268
+ t.delete(n);
2269
+ return t;
2246
2270
  }
2247
2271
  }
2248
- function it(i, e) {
2272
+ function ot(i, e) {
2249
2273
  const t = i.length, n = e.length, r = t - n;
2250
2274
  for (let s = 0; s <= r; s++) {
2251
2275
  let a = !0;
@@ -2259,7 +2283,7 @@ function it(i, e) {
2259
2283
  }
2260
2284
  return -1;
2261
2285
  }
2262
- async function at(i = oe) {
2286
+ async function ct(i = Se) {
2263
2287
  switch (i) {
2264
2288
  case "8.5":
2265
2289
  return (await import("@php-wasm/web-8-5")).getIntlExtensionPath();
@@ -2278,17 +2302,17 @@ async function at(i = oe) {
2278
2302
  }
2279
2303
  throw new Error(`Unsupported PHP version ${i}`);
2280
2304
  }
2281
- async function _t(i, e, t, n = []) {
2305
+ async function St(i, e, t, n = []) {
2282
2306
  if (!n.length)
2283
2307
  return t;
2284
2308
  const r = await Promise.all(
2285
2309
  n.map(
2286
- (s) => ot(i, e, s)
2310
+ (s) => lt(i, e, s)
2287
2311
  )
2288
2312
  );
2289
- return Ie(t, r);
2313
+ return We(t, r);
2290
2314
  }
2291
- async function ot(i, e, t) {
2315
+ async function lt(i, e, t) {
2292
2316
  if (typeof t == "object" && "source" in t) {
2293
2317
  if (e === "asyncify")
2294
2318
  throw new Error(
@@ -2302,14 +2326,14 @@ async function ot(i, e, t) {
2302
2326
  const n = typeof t == "string" ? t : t.name;
2303
2327
  if (n !== "intl")
2304
2328
  throw new Error(`Unknown bundled PHP web extension: ${String(n)}.`);
2305
- const r = Be(fetch), s = await at(i), a = (await import("../intl/shared/icu.dat")).default, [_, c] = await Promise.all(
2329
+ const r = Me(fetch), s = await ct(i), a = (await import("../intl/shared/icu.dat")).default, [_, o] = await Promise.all(
2306
2330
  [s, a].map(async (S) => {
2307
- const C = await r(S);
2308
- if (!C.ok)
2331
+ const l = await r(S);
2332
+ if (!l.ok)
2309
2333
  throw new Error(
2310
- `Failed to fetch bundled PHP web extension asset: ${C.url || S} (${C.status} ${C.statusText}).`
2334
+ `Failed to fetch bundled PHP web extension asset: ${l.url || S} (${l.status} ${l.statusText}).`
2311
2335
  );
2312
- return await C.arrayBuffer();
2336
+ return await l.arrayBuffer();
2313
2337
  })
2314
2338
  );
2315
2339
  return await Y({
@@ -2325,12 +2349,12 @@ async function ot(i, e, t) {
2325
2349
  extraFiles: {
2326
2350
  files: {
2327
2351
  // The Intl extension looks for the hard-coded ICU data name.
2328
- "/internal/shared/icudt74l.dat": new Uint8Array(c)
2352
+ "/internal/shared/icudt74l.dat": new Uint8Array(o)
2329
2353
  }
2330
2354
  }
2331
2355
  });
2332
2356
  }
2333
- const ct = () => ({
2357
+ const Ct = () => ({
2334
2358
  websocket: {
2335
2359
  decorator: (i) => class extends i {
2336
2360
  constructor() {
@@ -2345,47 +2369,47 @@ const ct = () => ({
2345
2369
  }
2346
2370
  }
2347
2371
  });
2348
- async function Dt(i, e = {}) {
2349
- var c;
2372
+ async function bt(i, e = {}) {
2373
+ var o;
2350
2374
  "setImmediate" in globalThis || (globalThis.setImmediate = (S) => setTimeout(S, 0));
2351
- const t = await Ue() ? "jspi" : "asyncify";
2375
+ const t = await xe() ? "jspi" : "asyncify";
2352
2376
  let n = {
2353
- ...ct(),
2377
+ ...Ct(),
2354
2378
  ...e.emscriptenOptions || {},
2355
2379
  phpWasmAsyncMode: t
2356
2380
  };
2357
- e.tcpOverFetch && (n = tt(
2381
+ e.tcpOverFetch && (n = st(
2358
2382
  n,
2359
2383
  e.tcpOverFetch
2360
2384
  ));
2361
- const r = Ke(i), s = [...e.extensions ?? []];
2362
- if (e.withIntl && !St(s, "intl") && s.push("intl"), r) {
2363
- const S = await n, C = S.preRun || [];
2385
+ const r = Pe(i), s = [...e.extensions ?? []];
2386
+ if (e.withIntl && !ht(s, "intl") && s.push("intl"), r) {
2387
+ const S = await n, l = S.preRun || [];
2364
2388
  n = {
2365
2389
  ...S,
2366
- preRun: [...C, De()]
2390
+ preRun: [...l, be()]
2367
2391
  };
2368
2392
  }
2369
2393
  if (r && s.length)
2370
2394
  throw new Error(
2371
2395
  `Extensions are not available for legacy PHP ${i}.`
2372
2396
  );
2373
- r || (n = _t(
2397
+ r || (n = St(
2374
2398
  i,
2375
2399
  t,
2376
2400
  await n,
2377
2401
  s
2378
2402
  ));
2379
2403
  const [a, _] = await Promise.all([
2380
- xe(i),
2404
+ qe(i),
2381
2405
  n
2382
2406
  ]);
2383
- return (c = e.onPhpLoaderModuleLoaded) == null || c.call(e, a), await We(a, _);
2407
+ return (o = e.onPhpLoaderModuleLoaded) == null || o.call(e, a), await Re(a, _);
2384
2408
  }
2385
- function St(i, e) {
2409
+ function ht(i, e) {
2386
2410
  return i.some((t) => typeof t == "string" ? t === e : !("source" in t) && t.name === e);
2387
2411
  }
2388
- function Wt(i, e) {
2412
+ function Rt(i, e) {
2389
2413
  window.addEventListener("message", (t) => {
2390
2414
  t.source === i.contentWindow && (e && t.origin !== e || typeof t.data != "object" || t.data.type !== "relay" || window.parent.postMessage(t.data, "*"));
2391
2415
  }), window.addEventListener("message", (t) => {
@@ -2393,7 +2417,7 @@ function Wt(i, e) {
2393
2417
  t.source === window.parent && (typeof t.data != "object" || t.data.type !== "relay" || (n = i == null ? void 0 : i.contentWindow) == null || n.postMessage(t.data));
2394
2418
  });
2395
2419
  }
2396
- async function Pt(i) {
2420
+ async function Bt(i) {
2397
2421
  const e = new Worker(i, { type: "module" });
2398
2422
  return new Promise((t, n) => {
2399
2423
  e.onerror = (s) => {
@@ -2408,8 +2432,8 @@ async function Pt(i) {
2408
2432
  e.addEventListener("message", r);
2409
2433
  });
2410
2434
  }
2411
- const Ct = 1e3;
2412
- function bt(i, e = { initialSync: {} }) {
2435
+ const ut = 1e3;
2436
+ function Ut(i, e = { initialSync: {} }) {
2413
2437
  return e = {
2414
2438
  ...e,
2415
2439
  initialSync: {
@@ -2417,45 +2441,72 @@ function bt(i, e = { initialSync: {} }) {
2417
2441
  direction: e.initialSync.direction ?? "opfs-to-memfs"
2418
2442
  }
2419
2443
  }, async function(t, n, r) {
2420
- var a;
2421
- e.initialSync.direction === "opfs-to-memfs" ? (M.fileExists(n, r) && M.rmdir(n, r), M.mkdir(n, r), await lt(n, i, r)) : await ye(
2422
- n,
2423
- i,
2424
- r,
2425
- e.initialSync.onProgress
2426
- );
2427
- const s = At(t, i, r);
2428
- return (a = e.onMount) == null || a.call(e, s), s.unmount;
2444
+ var s, a, _, o;
2445
+ if (e.initialSync.direction === "opfs-to-memfs") {
2446
+ M.fileExists(n, r) && M.rmdir(n, r), M.mkdir(n, r), await At(n, i, r);
2447
+ const S = ae(t, i, r);
2448
+ return (s = e.onMount) == null || s.call(e, S), S.unmount;
2449
+ } else {
2450
+ const S = ae(t, i, r);
2451
+ (a = e.onMount) == null || a.call(e, S);
2452
+ let l;
2453
+ try {
2454
+ await Le(
2455
+ n,
2456
+ i,
2457
+ r,
2458
+ async (C) => {
2459
+ var A, u;
2460
+ l = {
2461
+ ...C,
2462
+ phase: "copying"
2463
+ }, await ((u = (A = e.initialSync).onProgress) == null ? void 0 : u.call(A, l));
2464
+ }
2465
+ ), await ((o = (_ = e.initialSync).onProgress) == null ? void 0 : o.call(_, {
2466
+ files: (l == null ? void 0 : l.files) ?? 0,
2467
+ total: (l == null ? void 0 : l.total) ?? 0,
2468
+ phase: "flushing"
2469
+ })), S.flush().catch((C) => {
2470
+ g.error("OPFS flush failed after initial sync", {
2471
+ error: C,
2472
+ vfsMountPoint: r
2473
+ });
2474
+ });
2475
+ } catch (C) {
2476
+ throw await S.unmount(), C;
2477
+ }
2478
+ return S.unmount;
2479
+ }
2429
2480
  };
2430
2481
  }
2431
- async function lt(i, e, t) {
2482
+ async function At(i, e, t) {
2432
2483
  M.mkdir(i, t);
2433
- const n = new Pe({
2484
+ const n = new Be({
2434
2485
  concurrency: 40
2435
2486
  }), r = [], s = [
2436
2487
  [e, t]
2437
2488
  ];
2438
2489
  for (; s.length > 0; ) {
2439
2490
  const [a, _] = s.pop();
2440
- for await (const c of a.values()) {
2491
+ for await (const o of a.values()) {
2441
2492
  const S = n.run(async () => {
2442
- const C = ce(
2493
+ const l = le(
2443
2494
  _,
2444
- c.name
2495
+ o.name
2445
2496
  );
2446
- if (c.kind === "directory") {
2497
+ if (o.kind === "directory") {
2447
2498
  try {
2448
- i.mkdir(C);
2449
- } catch (h) {
2450
- if ((h == null ? void 0 : h.errno) !== 20)
2451
- throw B.error(h), h;
2499
+ i.mkdir(l);
2500
+ } catch (C) {
2501
+ if ((C == null ? void 0 : C.errno) !== 20)
2502
+ throw g.error(C), C;
2452
2503
  }
2453
- s.push([c, C]);
2454
- } else if (c.kind === "file") {
2455
- const h = await c.getFile(), A = new Uint8Array(await h.arrayBuffer());
2504
+ s.push([o, l]);
2505
+ } else if (o.kind === "file") {
2506
+ const C = await o.getFile(), A = new Uint8Array(await C.arrayBuffer());
2456
2507
  i.createDataFile(
2457
2508
  _,
2458
- c.name,
2509
+ o.name,
2459
2510
  A,
2460
2511
  !0,
2461
2512
  !0,
@@ -2470,43 +2521,47 @@ async function lt(i, e, t) {
2470
2521
  await Promise.any(r);
2471
2522
  }
2472
2523
  }
2473
- async function ye(i, e, t, n) {
2524
+ async function Le(i, e, t, n) {
2474
2525
  i.mkdirTree(t);
2475
2526
  const r = [];
2476
- async function s(C, h) {
2527
+ async function s(l, C) {
2477
2528
  await Promise.all(
2478
- i.readdir(C).filter(
2529
+ i.readdir(l).filter(
2479
2530
  (A) => A !== "." && A !== ".."
2480
2531
  ).map(async (A) => {
2481
- const u = ce(C, A);
2482
- if (!ht(i, u)) {
2483
- r.push([h, u, A]);
2532
+ const u = le(l, A);
2533
+ if (!Ht(i, u)) {
2534
+ r.push([C, u, A]);
2484
2535
  return;
2485
2536
  }
2486
- const T = await h.getDirectoryHandle(A, {
2537
+ const d = await C.getDirectoryHandle(A, {
2487
2538
  create: !0
2488
2539
  });
2489
- return await s(u, T);
2540
+ return await s(u, d);
2490
2541
  })
2491
2542
  );
2492
2543
  }
2493
2544
  await s(t, e);
2494
2545
  let a = 0;
2495
- const _ = n && dt(n, 100), c = 100, S = /* @__PURE__ */ new Set();
2546
+ await (n == null ? void 0 : n({
2547
+ files: a,
2548
+ total: r.length
2549
+ }));
2550
+ const _ = n && Et(n, 100), o = 100, S = /* @__PURE__ */ new Set();
2496
2551
  try {
2497
- for (const [C, h, A] of r) {
2552
+ for (const [l, C, A] of r) {
2498
2553
  const u = $(
2499
- C,
2554
+ l,
2500
2555
  A,
2501
2556
  i,
2502
- h
2557
+ C
2503
2558
  ).then(() => {
2504
2559
  a++, S.delete(u), _ == null || _({
2505
2560
  files: a,
2506
2561
  total: r.length
2507
2562
  });
2508
2563
  });
2509
- S.add(u), S.size >= c && (await Promise.race(S), _ == null || _({
2564
+ S.add(u), S.size >= o && (await Promise.race(S), _ == null || _({
2510
2565
  files: a,
2511
2566
  total: r.length
2512
2567
  }));
@@ -2514,8 +2569,12 @@ async function ye(i, e, t, n) {
2514
2569
  } finally {
2515
2570
  await Promise.allSettled(S);
2516
2571
  }
2572
+ _ == null || _.cancel(), await (n == null ? void 0 : n({
2573
+ files: r.length,
2574
+ total: r.length
2575
+ }));
2517
2576
  }
2518
- function ht(i, e) {
2577
+ function Ht(i, e) {
2519
2578
  return i.isDir(i.lookupPath(e, { follow: !0 }).node.mode);
2520
2579
  }
2521
2580
  async function $(i, e, t, n) {
@@ -2540,35 +2599,35 @@ async function $(i, e, t, n) {
2540
2599
  await a.close();
2541
2600
  }
2542
2601
  }
2543
- function At(i, e, t, n = {}) {
2544
- const r = [], s = ve(i, t, (u) => {
2602
+ function ae(i, e, t, n = {}) {
2603
+ const r = [], s = Ne(i, t, (u) => {
2545
2604
  r.push(u);
2546
- }), a = new ut(i, e, t);
2605
+ }), a = new dt(i, e, t);
2547
2606
  let _;
2548
- function c() {
2549
- return _ === void 0 && (_ = h().finally(() => {
2607
+ function o() {
2608
+ return _ === void 0 && (_ = C().finally(() => {
2550
2609
  _ = void 0;
2551
2610
  })), _;
2552
2611
  }
2553
2612
  async function S() {
2554
2613
  try {
2555
- await c();
2614
+ await o();
2556
2615
  } finally {
2557
- s(), i.removeEventListener("request.end", C), i.removeEventListener("filesystem.write", C);
2616
+ s(), i.removeEventListener("request.end", l), i.removeEventListener("filesystem.write", l);
2558
2617
  }
2559
2618
  }
2560
- function C() {
2561
- c().catch((u) => {
2562
- B.error(u);
2619
+ function l() {
2620
+ o().catch((u) => {
2621
+ g.error(u);
2563
2622
  });
2564
2623
  }
2565
- async function h() {
2566
- const u = n.maxFlushPasses ?? Ct;
2567
- for (let T = 0; r.length > 0; T++) {
2568
- if (T >= u) {
2569
- const y = r.length, U = y === 1 ? `${y} journal entry remains` : `${y} journal entries remain`;
2624
+ async function C() {
2625
+ const u = n.maxFlushPasses ?? ut;
2626
+ for (let d = 0; r.length > 0; d++) {
2627
+ if (d >= u) {
2628
+ const m = r.length, b = m === 1 ? `${m} journal entry remains` : `${m} journal entries remain`;
2570
2629
  throw new Error(
2571
- `OPFS flush for "${t}" did not settle after ${u} journal batches; ${U}. This can happen when filesystem writes are continuously enqueued while flushing.`
2630
+ `OPFS flush for "${t}" did not settle after ${u} journal batches; ${b}. This can happen when filesystem writes are continuously enqueued while flushing.`
2572
2631
  );
2573
2632
  }
2574
2633
  await A();
@@ -2577,32 +2636,32 @@ function At(i, e, t, n = {}) {
2577
2636
  async function A() {
2578
2637
  if (r.length === 0)
2579
2638
  return;
2580
- const u = await i.semaphore.acquire(), T = [...r];
2581
- r.splice(0, T.length);
2582
- const y = Me(T);
2639
+ const u = await i.semaphore.acquire(), d = [...r];
2640
+ r.splice(0, d.length);
2641
+ const m = ke(d);
2583
2642
  try {
2584
- for (const U of y)
2585
- await a.processEntry(U);
2643
+ for (const b of m)
2644
+ await a.processEntry(b);
2586
2645
  } finally {
2587
2646
  u();
2588
2647
  }
2589
2648
  }
2590
- return i.addEventListener("request.end", C), i.addEventListener("filesystem.write", C), {
2591
- flush: c,
2649
+ return i.addEventListener("request.end", l), i.addEventListener("filesystem.write", l), {
2650
+ flush: o,
2592
2651
  unmount: S
2593
2652
  };
2594
2653
  }
2595
- class ut {
2654
+ class dt {
2596
2655
  constructor(e, t, n) {
2597
- this.php = e, this.opfs = t, this.memfsRoot = ae(n);
2656
+ this.php = e, this.opfs = t, this.memfsRoot = _e(n);
2598
2657
  }
2599
2658
  toOpfsPath(e) {
2600
- return ae(e.substring(this.memfsRoot.length));
2659
+ return _e(e.substring(this.memfsRoot.length));
2601
2660
  }
2602
2661
  async processEntry(e) {
2603
2662
  if (!e.path.startsWith(this.memfsRoot) || e.path === this.memfsRoot)
2604
2663
  return;
2605
- const t = this.toOpfsPath(e.path), n = await _e(this.opfs, t), r = Ht(t);
2664
+ const t = this.toOpfsPath(e.path), n = await oe(this.opfs, t), r = ft(t);
2606
2665
  if (r)
2607
2666
  try {
2608
2667
  if (e.operation === "DELETE")
@@ -2626,7 +2685,7 @@ class ut {
2626
2685
  e.path
2627
2686
  );
2628
2687
  else if (e.operation === "RENAME" && e.toPath.startsWith(this.memfsRoot)) {
2629
- const s = this.toOpfsPath(e.toPath), a = await _e(
2688
+ const s = this.toOpfsPath(e.toPath), a = await oe(
2630
2689
  this.opfs,
2631
2690
  s
2632
2691
  );
@@ -2637,7 +2696,7 @@ class ut {
2637
2696
  create: !0
2638
2697
  }
2639
2698
  );
2640
- await ye(
2699
+ await Le(
2641
2700
  this.php[O].FS,
2642
2701
  _,
2643
2702
  e.toPath
@@ -2651,24 +2710,24 @@ class ut {
2651
2710
  }
2652
2711
  await $(
2653
2712
  a,
2654
- be(s),
2713
+ Ue(s),
2655
2714
  this.php[O].FS,
2656
2715
  e.toPath
2657
2716
  );
2658
2717
  }
2659
2718
  }
2660
2719
  } catch (s) {
2661
- throw B.log({ entry: e, name: r }), B.error(s), s;
2720
+ throw g.log({ entry: e, name: r }), g.error(s), s;
2662
2721
  }
2663
2722
  }
2664
2723
  }
2665
- function ae(i) {
2724
+ function _e(i) {
2666
2725
  return i.replace(/\/$/, "").replace(/\/\/+/g, "/");
2667
2726
  }
2668
- function Ht(i) {
2727
+ function ft(i) {
2669
2728
  return i.substring(i.lastIndexOf("/") + 1);
2670
2729
  }
2671
- async function _e(i, e) {
2730
+ async function oe(i, e) {
2672
2731
  const t = e.replace(/^\/+|\/+$/g, "").replace(/\/+/, "/");
2673
2732
  if (!t)
2674
2733
  return i;
@@ -2680,31 +2739,46 @@ async function _e(i, e) {
2680
2739
  }
2681
2740
  return r;
2682
2741
  }
2683
- function dt(i, e) {
2742
+ function Et(i, e) {
2684
2743
  let t = 0, n, r;
2685
- return function(...a) {
2686
- r = a;
2687
- const _ = Date.now() - t;
2744
+ const s = function(..._) {
2745
+ r = _;
2746
+ const o = Date.now() - t;
2688
2747
  if (n === void 0) {
2689
- const c = Math.max(0, e - _);
2748
+ const S = Math.max(0, e - o);
2690
2749
  n = setTimeout(() => {
2691
- n = void 0, t = Date.now(), i(...r);
2692
- }, c);
2750
+ n = void 0, t = Date.now();
2751
+ const l = r;
2752
+ r = void 0;
2753
+ try {
2754
+ Promise.resolve(i(...l)).catch(
2755
+ ce
2756
+ );
2757
+ } catch (C) {
2758
+ ce(C);
2759
+ }
2760
+ }, S);
2693
2761
  }
2694
2762
  };
2763
+ return s.cancel = () => {
2764
+ n !== void 0 && clearTimeout(n), n = void 0, r = void 0;
2765
+ }, s;
2766
+ }
2767
+ function ce(i) {
2768
+ g.error("Throttled progress callback failed", { error: i });
2695
2769
  }
2696
2770
  export {
2697
- xt as FirewallInterferenceError,
2698
- gt as certificateToPEM,
2699
- Ut as consumeAPI,
2700
- bt as createDirectoryHandleMountHandler,
2701
- vt as exposeAPI,
2702
- Nt as fetchWithCorsProxy,
2703
- Ze as generateCertificate,
2704
- xe as getPHPLoaderModule,
2705
- Dt as loadWebRuntime,
2706
- It as privateKeyToPEM,
2707
- Wt as setupPostMessageRelay,
2708
- Pt as spawnPHPWorkerThread
2771
+ qt as FirewallInterferenceError,
2772
+ Dt as certificateToPEM,
2773
+ xt as consumeAPI,
2774
+ Ut as createDirectoryHandleMountHandler,
2775
+ Nt as exposeAPI,
2776
+ Ft as fetchWithCorsProxy,
2777
+ Qe as generateCertificate,
2778
+ qe as getPHPLoaderModule,
2779
+ bt as loadWebRuntime,
2780
+ Wt as privateKeyToPEM,
2781
+ Rt as setupPostMessageRelay,
2782
+ Bt as spawnPHPWorkerThread
2709
2783
  };
2710
2784
  //# sourceMappingURL=index.js.map