@php-wasm/web 3.0.22 → 3.0.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/README.md +1 -1
  2. package/index.cjs +14 -13
  3. package/index.cjs.map +1 -1
  4. package/index.js +535 -489
  5. package/index.js.map +1 -1
  6. package/lib/extensions/intl/get-intl-extension-module.d.ts +11 -0
  7. package/lib/extensions/intl/with-intl.d.ts +2 -0
  8. package/lib/firewall-interference-error.d.ts +13 -0
  9. package/lib/get-php-loader-module.d.ts +6 -1
  10. package/lib/index.d.ts +1 -0
  11. package/lib/load-runtime.d.ts +1 -1
  12. package/lib/test-utils/generate-certificate.d.ts +6 -0
  13. package/package.json +20 -9
  14. package/{php/asyncify/8_4_14/php_8_4.wasm → shared/icu.dat} +0 -0
  15. package/test/playwright/globals.d.ts +1 -0
  16. package/test/playwright/reporter.d.ts +6 -0
  17. package/lib/with-icu-data.d.ts +0 -2
  18. package/php/asyncify/7_0_33/php_7_0.wasm +0 -0
  19. package/php/asyncify/7_1_30/php_7_1.wasm +0 -0
  20. package/php/asyncify/7_2_34/php_7_2.wasm +0 -0
  21. package/php/asyncify/7_3_33/php_7_3.wasm +0 -0
  22. package/php/asyncify/7_4_33/php_7_4.wasm +0 -0
  23. package/php/asyncify/8_0_30/php_8_0.wasm +0 -0
  24. package/php/asyncify/8_1_33/php_8_1.wasm +0 -0
  25. package/php/asyncify/8_2_29/php_8_2.wasm +0 -0
  26. package/php/asyncify/8_3_27/php_8_3.wasm +0 -0
  27. package/php/asyncify/php_7_0.js +0 -79
  28. package/php/asyncify/php_7_1.js +0 -79
  29. package/php/asyncify/php_7_2.js +0 -112
  30. package/php/asyncify/php_7_3.js +0 -112
  31. package/php/asyncify/php_7_4.js +0 -112
  32. package/php/asyncify/php_8_0.js +0 -112
  33. package/php/asyncify/php_8_1.js +0 -112
  34. package/php/asyncify/php_8_2.js +0 -112
  35. package/php/asyncify/php_8_3.js +0 -112
  36. package/php/asyncify/php_8_4.js +0 -112
  37. package/php/jspi/7_0_33/php_7_0.wasm +0 -0
  38. package/php/jspi/7_1_30/php_7_1.wasm +0 -0
  39. package/php/jspi/7_2_34/php_7_2.wasm +0 -0
  40. package/php/jspi/7_3_33/php_7_3.wasm +0 -0
  41. package/php/jspi/7_4_33/php_7_4.wasm +0 -0
  42. package/php/jspi/8_0_30/php_8_0.wasm +0 -0
  43. package/php/jspi/8_1_33/php_8_1.wasm +0 -0
  44. package/php/jspi/8_2_29/php_8_2.wasm +0 -0
  45. package/php/jspi/8_3_27/php_8_3.wasm +0 -0
  46. package/php/jspi/8_4_14/php_8_4.wasm +0 -0
  47. package/php/jspi/php_7_0.js +0 -79
  48. package/php/jspi/php_7_1.js +0 -79
  49. package/php/jspi/php_7_2.js +0 -112
  50. package/php/jspi/php_7_3.js +0 -112
  51. package/php/jspi/php_7_4.js +0 -112
  52. package/php/jspi/php_8_0.js +0 -112
  53. package/php/jspi/php_8_1.js +0 -112
  54. package/php/jspi/php_8_2.js +0 -112
  55. package/php/jspi/php_8_3.js +0 -112
  56. package/php/jspi/php_8_4.js +0 -112
package/index.js CHANGED
@@ -1,69 +1,51 @@
1
- import { LatestSupportedPHPVersion as fe, FSHelpers as W, loadPHPRuntime as pe, __private__dont__use as k } from "@php-wasm/universal";
2
- import { consumeAPI as mt, exposeAPI as gt } from "@php-wasm/universal";
3
- import { jspi as we } from "wasm-feature-detect";
4
- import { concatArrayBuffers as B, concatUint8Arrays as u, Semaphore as Le, joinPaths as se, basename as ye } from "@php-wasm/util";
5
- import { logger as U } from "@php-wasm/logger";
6
- import { teeRequest as me, cloneRequest as ge } from "@php-wasm/web-service-worker";
7
- import { journalFSEvents as Ke, normalizeFilesystemOperations as Ie } from "@php-wasm/fs-journal";
8
- async function De(i = fe) {
9
- if (await we())
10
- switch (i) {
11
- case "8.4":
12
- return await import("./php/jspi/php_8_4.js");
13
- case "8.3":
14
- return await import("./php/jspi/php_8_3.js");
15
- case "8.2":
16
- return await import("./php/jspi/php_8_2.js");
17
- case "8.1":
18
- return await import("./php/jspi/php_8_1.js");
19
- case "8.0":
20
- return await import("./php/jspi/php_8_0.js");
21
- case "7.4":
22
- return await import("./php/jspi/php_7_4.js");
23
- case "7.3":
24
- return await import("./php/jspi/php_7_3.js");
25
- case "7.2":
26
- return await import("./php/jspi/php_7_2.js");
27
- }
28
- else
29
- switch (i) {
30
- case "8.4":
31
- return await import("./php/asyncify/php_8_4.js");
32
- case "8.3":
33
- return await import("./php/asyncify/php_8_3.js");
34
- case "8.2":
35
- return await import("./php/asyncify/php_8_2.js");
36
- case "8.1":
37
- return await import("./php/asyncify/php_8_1.js");
38
- case "8.0":
39
- return await import("./php/asyncify/php_8_0.js");
40
- case "7.4":
41
- return await import("./php/asyncify/php_7_4.js");
42
- case "7.3":
43
- return await import("./php/asyncify/php_7_3.js");
44
- case "7.2":
45
- return await import("./php/asyncify/php_7_2.js");
46
- }
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) {
9
+ switch (i) {
10
+ case "8.5":
11
+ return (await import("@php-wasm/web-8-5")).getPHPLoaderModule();
12
+ case "8.4":
13
+ return (await import("@php-wasm/web-8-4")).getPHPLoaderModule();
14
+ case "8.3":
15
+ return (await import("@php-wasm/web-8-3")).getPHPLoaderModule();
16
+ case "8.2":
17
+ return (await import("@php-wasm/web-8-2")).getPHPLoaderModule();
18
+ case "8.1":
19
+ return (await import("@php-wasm/web-8-1")).getPHPLoaderModule();
20
+ case "8.0":
21
+ return (await import("@php-wasm/web-8-0")).getPHPLoaderModule();
22
+ case "7.4":
23
+ return (await import("@php-wasm/web-7-4")).getPHPLoaderModule();
24
+ case "7.3":
25
+ return (await import("@php-wasm/web-7-3")).getPHPLoaderModule();
26
+ case "7.2":
27
+ return (await import("@php-wasm/web-7-2")).getPHPLoaderModule();
28
+ }
47
29
  throw new Error(`Unsupported PHP version ${i}`);
48
30
  }
49
31
  function f(i) {
50
32
  return Object.fromEntries(Object.entries(i).map(([e, t]) => [t, e]));
51
33
  }
52
- function K(i) {
34
+ function D(i) {
53
35
  return new Uint8Array([i >> 8 & 255, i & 255]);
54
36
  }
55
- function w(i) {
37
+ function y(i) {
56
38
  return new Uint8Array([
57
39
  i >> 16 & 255,
58
40
  i >> 8 & 255,
59
41
  i & 255
60
42
  ]);
61
43
  }
62
- function G(i) {
44
+ function V(i) {
63
45
  const e = new ArrayBuffer(8);
64
46
  return new DataView(e).setBigUint64(0, BigInt(i), !1), new Uint8Array(e);
65
47
  }
66
- class y {
48
+ class g {
67
49
  constructor(e) {
68
50
  this.offset = 0, this.buffer = e, this.view = new DataView(e);
69
51
  }
@@ -158,10 +140,10 @@ const b = {
158
140
  key_share: 51,
159
141
  transparency_info: 52,
160
142
  connection_id: 54
161
- }, We = f(b), ie = {
143
+ }, We = f(b), _e = {
162
144
  host_name: 0
163
- }, be = f(ie);
164
- class _e {
145
+ }, Pe = f(_e);
146
+ class oe {
165
147
  static decodeFromClient(e) {
166
148
  const t = new DataView(e.buffer);
167
149
  let r = 0;
@@ -169,22 +151,22 @@ class _e {
169
151
  r += 2;
170
152
  const s = [];
171
153
  for (; r < n + 2; ) {
172
- const _ = e[r];
154
+ const a = e[r];
173
155
  r += 1;
174
- const a = t.getUint16(r);
156
+ const _ = t.getUint16(r);
175
157
  r += 2;
176
- const c = e.slice(r, r + a);
177
- switch (r += a, _) {
178
- case ie.host_name:
158
+ const S = e.slice(r, r + _);
159
+ switch (r += _, a) {
160
+ case _e.host_name:
179
161
  s.push({
180
- name_type: be[_],
162
+ name_type: Pe[a],
181
163
  name: {
182
- host_name: new TextDecoder().decode(c)
164
+ host_name: new TextDecoder().decode(S)
183
165
  }
184
166
  });
185
167
  break;
186
168
  default:
187
- throw new Error(`Unsupported name type ${_}`);
169
+ throw new Error(`Unsupported name type ${a}`);
188
170
  }
189
171
  }
190
172
  return { server_name_list: s };
@@ -209,7 +191,7 @@ class _e {
209
191
  return t.writeUint16(b.server_name), t.writeUint16(0), t.uint8Array;
210
192
  }
211
193
  }
212
- const ae = {
194
+ const ce = {
213
195
  TLS1_CK_PSK_WITH_RC4_128_SHA: 138,
214
196
  TLS1_CK_PSK_WITH_3DES_EDE_CBC_SHA: 139,
215
197
  TLS1_CK_PSK_WITH_AES_128_CBC_SHA: 140,
@@ -412,14 +394,14 @@ const ae = {
412
394
  TLS1_CK_ECDHE_PSK_WITH_CHACHA20_POLY1305: 52396,
413
395
  TLS1_CK_DHE_PSK_WITH_CHACHA20_POLY1305: 52397,
414
396
  TLS1_CK_RSA_PSK_WITH_CHACHA20_POLY1305: 52398
415
- }, $ = f(ae), oe = {
397
+ }, z = f(ce), Se = {
416
398
  secp256r1: 23,
417
399
  secp384r1: 24,
418
400
  secp521r1: 25,
419
401
  x25519: 29,
420
402
  x448: 30
421
- }, V = f(oe);
422
- class Re {
403
+ }, Y = f(Se);
404
+ class be {
423
405
  /**
424
406
  * +--------------------------------------------------+
425
407
  * | Payload Length [2B] |
@@ -436,12 +418,12 @@ class Re {
436
418
  * +--------------------------------------------------+
437
419
  */
438
420
  static decodeFromClient(e) {
439
- const t = new y(e.buffer);
421
+ const t = new g(e.buffer);
440
422
  t.readUint16();
441
423
  const r = [];
442
424
  for (; !t.isFinished(); ) {
443
425
  const n = t.readUint16();
444
- n in V && r.push(V[n]);
426
+ n in Y && r.push(Y[n]);
445
427
  }
446
428
  return r;
447
429
  }
@@ -457,15 +439,15 @@ class Re {
457
439
  */
458
440
  static encodeForClient(e) {
459
441
  const t = new v(6);
460
- return t.writeUint16(b.supported_groups), t.writeUint16(2), t.writeUint16(oe[e]), t.uint8Array;
442
+ return t.writeUint16(b.supported_groups), t.writeUint16(2), t.writeUint16(Se[e]), t.uint8Array;
461
443
  }
462
444
  }
463
- const ce = {
445
+ const Ce = {
464
446
  uncompressed: 0,
465
447
  ansiX962_compressed_prime: 1,
466
448
  ansiX962_compressed_char2: 2
467
- }, z = f(ce);
468
- class Be {
449
+ }, X = f(Ce);
450
+ class Re {
469
451
  /**
470
452
  * +--------------------------------------------------+
471
453
  * | Payload Length [2B] |
@@ -482,10 +464,10 @@ class Be {
482
464
  * +--------------------------------------------------+
483
465
  */
484
466
  static decodeFromClient(e) {
485
- const t = new y(e.buffer), r = t.readUint8(), n = [];
467
+ const t = new g(e.buffer), r = t.readUint8(), n = [];
486
468
  for (let s = 0; s < r; s++) {
487
- const _ = t.readUint8();
488
- _ in z && n.push(z[_]);
469
+ const a = t.readUint8();
470
+ a in X && n.push(X[a]);
489
471
  }
490
472
  return n;
491
473
  }
@@ -505,15 +487,15 @@ class Be {
505
487
  */
506
488
  static encodeForClient(e) {
507
489
  const t = new v(6);
508
- return t.writeUint16(b.ec_point_formats), t.writeUint16(2), t.writeUint8(1), t.writeUint8(ce[e]), t.uint8Array;
490
+ return t.writeUint16(b.ec_point_formats), t.writeUint16(2), t.writeUint8(1), t.writeUint8(Ce[e]), t.uint8Array;
509
491
  }
510
492
  }
511
- const F = {
493
+ const j = {
512
494
  anonymous: 0,
513
495
  rsa: 1,
514
496
  dsa: 2,
515
497
  ecdsa: 3
516
- }, Y = f(F), j = {
498
+ }, Z = f(j), G = {
517
499
  none: 0,
518
500
  md5: 1,
519
501
  sha1: 2,
@@ -521,8 +503,8 @@ const F = {
521
503
  sha256: 4,
522
504
  sha384: 5,
523
505
  sha512: 6
524
- }, Z = f(j);
525
- class Pe {
506
+ }, J = f(G);
507
+ class Be {
526
508
  /**
527
509
  * Binary layout:
528
510
  *
@@ -539,19 +521,19 @@ class Pe {
539
521
  * +------------------------------------+
540
522
  */
541
523
  static decodeFromClient(e) {
542
- const t = new y(e.buffer);
524
+ const t = new g(e.buffer);
543
525
  t.readUint16();
544
526
  const r = [];
545
527
  for (; !t.isFinished(); ) {
546
528
  const n = t.readUint8(), s = t.readUint8();
547
- if (Y[s]) {
548
- if (!Z[n]) {
549
- U.warn(`Unknown hash algorithm: ${n}`);
529
+ if (Z[s]) {
530
+ if (!J[n]) {
531
+ M.warn(`Unknown hash algorithm: ${n}`);
550
532
  continue;
551
533
  }
552
534
  r.push({
553
- algorithm: Y[s],
554
- hash: Z[n]
535
+ algorithm: Z[s],
536
+ hash: J[n]
555
537
  });
556
538
  }
557
539
  }
@@ -570,26 +552,26 @@ class Pe {
570
552
  */
571
553
  static encodeforClient(e, t) {
572
554
  const r = new v(6);
573
- return r.writeUint16(b.signature_algorithms), r.writeUint16(2), r.writeUint8(j[e]), r.writeUint8(F[t]), r.uint8Array;
555
+ return r.writeUint16(b.signature_algorithms), r.writeUint16(2), r.writeUint8(G[e]), r.writeUint8(j[t]), r.uint8Array;
574
556
  }
575
557
  }
576
- const J = {
577
- server_name: _e,
578
- signature_algorithms: Pe,
579
- supported_groups: Re,
580
- ec_point_formats: Be
558
+ const Q = {
559
+ server_name: oe,
560
+ signature_algorithms: Be,
561
+ supported_groups: be,
562
+ ec_point_formats: Re
581
563
  };
582
564
  function Ue(i) {
583
- const e = new y(i.buffer), t = [];
565
+ const e = new g(i.buffer), t = [];
584
566
  for (; !e.isFinished(); ) {
585
- const r = e.offset, n = e.readUint16(), s = We[n], _ = e.readUint16(), a = e.readUint8Array(_);
586
- if (!(s in J))
567
+ const r = e.offset, n = e.readUint16(), s = We[n], a = e.readUint16(), _ = e.readUint8Array(a);
568
+ if (!(s in Q))
587
569
  continue;
588
- const c = J[s];
570
+ const S = Q[s];
589
571
  t.push({
590
572
  type: s,
591
- data: c.decodeFromClient(a),
592
- raw: i.slice(r, r + 4 + _)
573
+ data: S.decodeFromClient(_),
574
+ raw: i.slice(r, r + 4 + a)
593
575
  });
594
576
  }
595
577
  return t;
@@ -602,28 +584,28 @@ async function q(i, e, t, r) {
602
584
  !1,
603
585
  ["sign"]
604
586
  );
605
- let _ = n;
606
- const a = [];
607
- for (; B(a).byteLength < r; ) {
608
- _ = await X(s, _);
609
- const S = B([_, n]), A = await X(s, S);
610
- a.push(A);
611
- }
612
- return B(a).slice(0, r);
587
+ let a = n;
588
+ const _ = [];
589
+ for (; B(_).byteLength < r; ) {
590
+ a = await ee(s, a);
591
+ const c = B([a, n]), h = await ee(s, c);
592
+ _.push(h);
593
+ }
594
+ return B(_).slice(0, r);
613
595
  }
614
- async function X(i, e) {
596
+ async function ee(i, e) {
615
597
  return await crypto.subtle.sign(
616
598
  { name: "HMAC", hash: "SHA-256" },
617
599
  i,
618
600
  e
619
601
  );
620
602
  }
621
- const ve = {
603
+ const Me = {
622
604
  Null: 0
623
- }, Me = {
605
+ }, ve = {
624
606
  Warning: 1,
625
607
  Fatal: 2
626
- }, Se = f(Me), Ne = {
608
+ }, he = f(ve), xe = {
627
609
  CloseNotify: 0,
628
610
  UnexpectedMessage: 10,
629
611
  BadRecordMac: 20,
@@ -649,12 +631,12 @@ const ve = {
649
631
  UserCanceled: 90,
650
632
  NoRenegotiation: 100,
651
633
  UnsupportedExtension: 110
652
- }, Ce = f(Ne), C = {
634
+ }, le = f(xe), C = {
653
635
  ChangeCipherSpec: 20,
654
636
  Alert: 21,
655
637
  Handshake: 22,
656
638
  ApplicationData: 23
657
- }, T = {
639
+ }, E = {
658
640
  HelloRequest: 0,
659
641
  ClientHello: 1,
660
642
  ServerHello: 2,
@@ -663,7 +645,7 @@ const ve = {
663
645
  ServerHelloDone: 14,
664
646
  ClientKeyExchange: 16,
665
647
  Finished: 20
666
- }, xe = {
648
+ }, Ne = {
667
649
  /**
668
650
  * Indicates that a named curve is used. This option
669
651
  * SHOULD be used when applicable.
@@ -675,9 +657,9 @@ const ve = {
675
657
  }, ke = {
676
658
  secp256r1: 23
677
659
  };
678
- class Q extends Error {
660
+ class te extends Error {
679
661
  }
680
- const P = new Uint8Array([3, 3]), qe = crypto.subtle.generateKey(
662
+ const U = new Uint8Array([3, 3]), qe = crypto.subtle.generateKey(
681
663
  {
682
664
  name: "ECDH",
683
665
  namedCurve: "P-256"
@@ -688,7 +670,7 @@ const P = new Uint8Array([3, 3]), qe = crypto.subtle.generateKey(
688
670
  ["deriveKey", "deriveBits"]
689
671
  // Key usage
690
672
  );
691
- class Oe {
673
+ class Fe {
692
674
  constructor() {
693
675
  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 = {
694
676
  // We don't need to chunk the encrypted data.
@@ -705,7 +687,7 @@ class Oe {
705
687
  * This will spread some messages across multiple records,
706
688
  * but TLS supports it so that's fine.
707
689
  */
708
- downstream: Fe(this.MAX_CHUNK_SIZE)
690
+ downstream: Oe(this.MAX_CHUNK_SIZE)
709
691
  }, this.serverUpstreamWriter = this.serverEnd.upstream.writable.getWriter();
710
692
  const e = this;
711
693
  this.serverEnd.downstream.readable.pipeTo(
@@ -762,7 +744,7 @@ class Oe {
762
744
  */
763
745
  async TLSHandshake(e, t) {
764
746
  const r = await this.readNextHandshakeMessage(
765
- T.ClientHello
747
+ E.ClientHello
766
748
  );
767
749
  if (!r.body.cipher_suites.length)
768
750
  throw new Error(
@@ -771,45 +753,45 @@ class Oe {
771
753
  const n = crypto.getRandomValues(new Uint8Array(32));
772
754
  await this.writeTLSRecord(
773
755
  C.Handshake,
774
- g.serverHello(
756
+ K.serverHello(
775
757
  r.body,
776
758
  n,
777
- ve.Null
759
+ Me.Null
778
760
  )
779
761
  ), await this.writeTLSRecord(
780
762
  C.Handshake,
781
- g.certificate(t)
763
+ K.certificate(t)
782
764
  );
783
- const s = await qe, _ = r.body.random, a = await g.ECDHEServerKeyExchange(
784
- _,
765
+ const s = await qe, a = r.body.random, _ = await K.ECDHEServerKeyExchange(
766
+ a,
785
767
  n,
786
768
  s,
787
769
  e
788
770
  );
789
- await this.writeTLSRecord(C.Handshake, a), await this.writeTLSRecord(
771
+ await this.writeTLSRecord(C.Handshake, _), await this.writeTLSRecord(
790
772
  C.Handshake,
791
- g.serverHelloDone()
773
+ K.serverHelloDone()
792
774
  );
793
- const c = await this.readNextHandshakeMessage(
794
- T.ClientKeyExchange
775
+ const S = await this.readNextHandshakeMessage(
776
+ E.ClientKeyExchange
795
777
  );
796
778
  await this.readNextMessage(C.ChangeCipherSpec), this.sessionKeys = await this.deriveSessionKeys({
797
- clientRandom: _,
779
+ clientRandom: a,
798
780
  serverRandom: n,
799
781
  serverPrivateKey: s.privateKey,
800
782
  clientPublicKey: await crypto.subtle.importKey(
801
783
  "raw",
802
- c.body.exchange_keys,
784
+ S.body.exchange_keys,
803
785
  { name: "ECDH", namedCurve: "P-256" },
804
786
  !1,
805
787
  []
806
788
  )
807
- }), await this.readNextHandshakeMessage(T.Finished), await this.writeTLSRecord(
789
+ }), await this.readNextHandshakeMessage(E.Finished), await this.writeTLSRecord(
808
790
  C.ChangeCipherSpec,
809
- g.changeCipherSpec()
791
+ K.changeCipherSpec()
810
792
  ), await this.writeTLSRecord(
811
793
  C.Handshake,
812
- await g.createFinishedMessage(
794
+ await K.createFinishedMessage(
813
795
  this.handshakeMessages,
814
796
  this.sessionKeys.masterSecret
815
797
  )
@@ -833,38 +815,38 @@ class Oe {
833
815
  r,
834
816
  256
835
817
  // Length of the derived secret (256 bits for P-256)
836
- ), _ = new Uint8Array(
818
+ ), a = new Uint8Array(
837
819
  await q(
838
820
  s,
839
821
  new TextEncoder().encode("master secret"),
840
822
  u([e, t]),
841
823
  48
842
824
  )
843
- ), a = await q(
844
- _,
825
+ ), _ = await q(
826
+ a,
845
827
  new TextEncoder().encode("key expansion"),
846
828
  u([t, e]),
847
829
  // Client key, server key, client IV, server IV
848
830
  40
849
- ), c = new y(a), S = c.readUint8Array(16), A = c.readUint8Array(16), h = c.readUint8Array(4), l = c.readUint8Array(4);
831
+ ), S = new g(_), c = S.readUint8Array(16), h = S.readUint8Array(16), l = S.readUint8Array(4), A = S.readUint8Array(4);
850
832
  return {
851
- masterSecret: _,
833
+ masterSecret: a,
852
834
  clientWriteKey: await crypto.subtle.importKey(
853
835
  "raw",
854
- S,
836
+ c,
855
837
  { name: "AES-GCM" },
856
838
  !1,
857
839
  ["encrypt", "decrypt"]
858
840
  ),
859
841
  serverWriteKey: await crypto.subtle.importKey(
860
842
  "raw",
861
- A,
843
+ h,
862
844
  { name: "AES-GCM" },
863
845
  !1,
864
846
  ["encrypt", "decrypt"]
865
847
  ),
866
- clientIV: h,
867
- serverIV: l
848
+ clientIV: l,
849
+ serverIV: A
868
850
  };
869
851
  }
870
852
  async readNextHandshakeMessage(e) {
@@ -880,7 +862,7 @@ class Oe {
880
862
  t
881
863
  );
882
864
  while (r === !1);
883
- const n = E.TLSMessage(
865
+ const n = T.TLSMessage(
884
866
  t.type,
885
867
  r
886
868
  );
@@ -888,12 +870,12 @@ class Oe {
888
870
  }
889
871
  async readNextTLSRecord(e) {
890
872
  for (; ; ) {
891
- for (let a = 0; a < this.receivedTLSRecords.length; a++) {
892
- const c = this.receivedTLSRecords[a];
893
- if (c.type === e)
894
- return this.receivedTLSRecords.splice(a, 1), c;
873
+ for (let _ = 0; _ < this.receivedTLSRecords.length; _++) {
874
+ const S = this.receivedTLSRecords[_];
875
+ if (S.type === e)
876
+ return this.receivedTLSRecords.splice(_, 1), S;
895
877
  }
896
- const t = await this.pollBytes(5), r = t[3] << 8 | t[4], n = t[0], s = await this.pollBytes(r), _ = {
878
+ const t = await this.pollBytes(5), r = t[3] << 8 | t[4], n = t[0], s = await this.pollBytes(r), a = {
897
879
  type: n,
898
880
  version: {
899
881
  major: t[1],
@@ -902,13 +884,13 @@ class Oe {
902
884
  length: r,
903
885
  fragment: this.sessionKeys && n !== C.ChangeCipherSpec ? await this.decryptData(n, s) : s
904
886
  };
905
- if (_.type === C.Alert) {
906
- const a = Se[_.fragment[0]], c = Ce[_.fragment[1]];
887
+ if (a.type === C.Alert) {
888
+ const _ = he[a.fragment[0]], S = le[a.fragment[1]];
907
889
  throw new Error(
908
- `TLS non-warning alert received: ${a} ${c}`
890
+ `TLS non-warning alert received: ${_} ${S}`
909
891
  );
910
892
  }
911
- this.receivedTLSRecords.push(_);
893
+ this.receivedTLSRecords.push(a);
912
894
  }
913
895
  }
914
896
  /**
@@ -919,7 +901,7 @@ class Oe {
919
901
  for (; this.receivedBytesBuffer.length < e; ) {
920
902
  const { value: r, done: n } = await this.clientUpstreamReader.read();
921
903
  if (n)
922
- throw await this.close(), new Q("TLS connection closed");
904
+ throw await this.close(), new te("TLS connection closed");
923
905
  if (this.receivedBytesBuffer = u([
924
906
  this.receivedBytesBuffer,
925
907
  r
@@ -943,7 +925,7 @@ class Oe {
943
925
  this.serverUpstreamWriter.write(e.body);
944
926
  }
945
927
  } catch (e) {
946
- if (e instanceof Q)
928
+ if (e instanceof te)
947
929
  return;
948
930
  throw e;
949
931
  }
@@ -953,16 +935,16 @@ class Oe {
953
935
  * the AES-GCM algorithm.
954
936
  */
955
937
  async decryptData(e, t) {
956
- const r = this.sessionKeys.clientIV, n = t.slice(0, 8), s = new Uint8Array([...r, ...n]), _ = await crypto.subtle.decrypt(
938
+ const r = this.sessionKeys.clientIV, n = t.slice(0, 8), s = new Uint8Array([...r, ...n]), a = await crypto.subtle.decrypt(
957
939
  {
958
940
  name: "AES-GCM",
959
941
  iv: s,
960
942
  additionalData: new Uint8Array([
961
- ...G(this.receivedRecordSequenceNumber),
943
+ ...V(this.receivedRecordSequenceNumber),
962
944
  e,
963
- ...P,
945
+ ...U,
964
946
  // Payload length without IV and tag
965
- ...K(t.length - 8 - 16)
947
+ ...D(t.length - 8 - 16)
966
948
  ]),
967
949
  tagLength: 128
968
950
  },
@@ -970,7 +952,7 @@ class Oe {
970
952
  // Payload without the explicit IV
971
953
  t.slice(8)
972
954
  );
973
- return ++this.receivedRecordSequenceNumber, new Uint8Array(_);
955
+ return ++this.receivedRecordSequenceNumber, new Uint8Array(a);
974
956
  }
975
957
  async accumulateUntilMessageIsComplete(e) {
976
958
  this.partialTLSMessages[e.type] = u([
@@ -1009,27 +991,27 @@ class Oe {
1009
991
  */
1010
992
  async writeTLSRecord(e, t) {
1011
993
  e === C.Handshake && this.handshakeMessages.push(t), this.sessionKeys && e !== C.ChangeCipherSpec && (t = await this.encryptData(e, t));
1012
- const r = P, n = t.length, s = new Uint8Array(5);
994
+ const r = U, n = t.length, s = new Uint8Array(5);
1013
995
  s[0] = e, s[1] = r[0], s[2] = r[1], s[3] = n >> 8 & 255, s[4] = n & 255;
1014
- const _ = u([s, t]);
1015
- this.clientDownstreamWriter.write(_);
996
+ const a = u([s, t]);
997
+ this.clientDownstreamWriter.write(a);
1016
998
  }
1017
999
  /**
1018
1000
  * Encrypts data in a TLS 1.2-compliant manner using
1019
1001
  * the AES-GCM algorithm.
1020
1002
  */
1021
1003
  async encryptData(e, t) {
1022
- const r = this.sessionKeys.serverIV, n = crypto.getRandomValues(new Uint8Array(8)), s = new Uint8Array([...r, ...n]), _ = new Uint8Array([
1023
- ...G(this.sentRecordSequenceNumber),
1004
+ const r = this.sessionKeys.serverIV, n = crypto.getRandomValues(new Uint8Array(8)), s = new Uint8Array([...r, ...n]), a = new Uint8Array([
1005
+ ...V(this.sentRecordSequenceNumber),
1024
1006
  e,
1025
- ...P,
1007
+ ...U,
1026
1008
  // Payload length without IV and tag
1027
- ...K(t.length)
1028
- ]), a = await crypto.subtle.encrypt(
1009
+ ...D(t.length)
1010
+ ]), _ = await crypto.subtle.encrypt(
1029
1011
  {
1030
1012
  name: "AES-GCM",
1031
1013
  iv: s,
1032
- additionalData: _,
1014
+ additionalData: a,
1033
1015
  tagLength: 128
1034
1016
  },
1035
1017
  this.sessionKeys.serverWriteKey,
@@ -1037,21 +1019,21 @@ class Oe {
1037
1019
  );
1038
1020
  return ++this.sentRecordSequenceNumber, u([
1039
1021
  n,
1040
- new Uint8Array(a)
1022
+ new Uint8Array(_)
1041
1023
  ]);
1042
1024
  }
1043
1025
  }
1044
- class E {
1026
+ class T {
1045
1027
  static TLSMessage(e, t) {
1046
1028
  switch (e) {
1047
1029
  case C.Handshake:
1048
- return E.clientHandshake(t);
1030
+ return T.clientHandshake(t);
1049
1031
  case C.Alert:
1050
- return E.alert(t);
1032
+ return T.alert(t);
1051
1033
  case C.ChangeCipherSpec:
1052
- return E.changeCipherSpec();
1034
+ return T.changeCipherSpec();
1053
1035
  case C.ApplicationData:
1054
- return E.applicationData(t);
1036
+ return T.applicationData(t);
1055
1037
  default:
1056
1038
  throw new Error(`TLS: Unsupported TLS record type ${e}`);
1057
1039
  }
@@ -1080,12 +1062,12 @@ class E {
1080
1062
  * https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#tls-parameters-4
1081
1063
  */
1082
1064
  static parseCipherSuites(e) {
1083
- const t = new y(e);
1065
+ const t = new g(e);
1084
1066
  t.readUint16();
1085
1067
  const r = [];
1086
1068
  for (; !t.isFinished(); ) {
1087
1069
  const n = t.readUint16();
1088
- n in $ && r.push($[n]);
1070
+ n in z && r.push(z[n]);
1089
1071
  }
1090
1072
  return r;
1091
1073
  }
@@ -1104,25 +1086,25 @@ class E {
1104
1086
  static alert(e) {
1105
1087
  return {
1106
1088
  type: C.Alert,
1107
- level: Se[e[0]],
1108
- description: Ce[e[1]]
1089
+ level: he[e[0]],
1090
+ description: le[e[1]]
1109
1091
  };
1110
1092
  }
1111
1093
  static clientHandshake(e) {
1112
1094
  const t = e[0], r = e[1] << 16 | e[2] << 8 | e[3], n = e.slice(4);
1113
1095
  let s;
1114
1096
  switch (t) {
1115
- case T.HelloRequest:
1116
- s = E.clientHelloRequestPayload();
1097
+ case E.HelloRequest:
1098
+ s = T.clientHelloRequestPayload();
1117
1099
  break;
1118
- case T.ClientHello:
1119
- s = E.clientHelloPayload(n);
1100
+ case E.ClientHello:
1101
+ s = T.clientHelloPayload(n);
1120
1102
  break;
1121
- case T.ClientKeyExchange:
1122
- s = E.clientKeyExchangePayload(n);
1103
+ case E.ClientKeyExchange:
1104
+ s = T.clientKeyExchangePayload(n);
1123
1105
  break;
1124
- case T.Finished:
1125
- s = E.clientFinishedPayload(n);
1106
+ case E.Finished:
1107
+ s = T.clientFinishedPayload(n);
1126
1108
  break;
1127
1109
  default:
1128
1110
  throw new Error(`Invalid handshake type ${t}`);
@@ -1178,7 +1160,7 @@ class E {
1178
1160
  * +------+------+---------------------------+
1179
1161
  */
1180
1162
  static clientHelloPayload(e) {
1181
- const t = new y(e.buffer), r = {
1163
+ const t = new g(e.buffer), r = {
1182
1164
  client_version: t.readUint8Array(2),
1183
1165
  /**
1184
1166
  * Technically this consists of a GMT timestamp
@@ -1189,16 +1171,16 @@ class E {
1189
1171
  }, n = t.readUint8();
1190
1172
  r.session_id = t.readUint8Array(n);
1191
1173
  const s = t.readUint16();
1192
- r.cipher_suites = E.parseCipherSuites(
1174
+ r.cipher_suites = T.parseCipherSuites(
1193
1175
  t.readUint8Array(s).buffer
1194
1176
  );
1195
- const _ = t.readUint8();
1177
+ const a = t.readUint8();
1196
1178
  r.compression_methods = t.readUint8Array(
1197
- _
1179
+ a
1198
1180
  );
1199
- const a = t.readUint16();
1181
+ const _ = t.readUint16();
1200
1182
  return r.extensions = Ue(
1201
- t.readUint8Array(a)
1183
+ t.readUint8Array(_)
1202
1184
  ), r;
1203
1185
  }
1204
1186
  /**
@@ -1222,7 +1204,7 @@ class E {
1222
1204
  };
1223
1205
  }
1224
1206
  }
1225
- function Fe(i) {
1207
+ function Oe(i) {
1226
1208
  return new TransformStream({
1227
1209
  transform(e, t) {
1228
1210
  for (; e.length > 0; )
@@ -1230,18 +1212,18 @@ function Fe(i) {
1230
1212
  }
1231
1213
  });
1232
1214
  }
1233
- class g {
1215
+ class K {
1234
1216
  static certificate(e) {
1235
1217
  const t = [];
1236
1218
  for (const s of e)
1237
- t.push(w(s.byteLength)), t.push(new Uint8Array(s));
1219
+ t.push(y(s.byteLength)), t.push(new Uint8Array(s));
1238
1220
  const r = u(t), n = new Uint8Array([
1239
- ...w(r.byteLength),
1221
+ ...y(r.byteLength),
1240
1222
  ...r
1241
1223
  ]);
1242
1224
  return new Uint8Array([
1243
- T.Certificate,
1244
- ...w(n.length),
1225
+ E.Certificate,
1226
+ ...y(n.length),
1245
1227
  ...n
1246
1228
  ]);
1247
1229
  }
@@ -1281,35 +1263,35 @@ class g {
1281
1263
  static async ECDHEServerKeyExchange(e, t, r, n) {
1282
1264
  const s = new Uint8Array(
1283
1265
  await crypto.subtle.exportKey("raw", r.publicKey)
1284
- ), _ = new Uint8Array([
1266
+ ), a = new Uint8Array([
1285
1267
  // Curve type (1 byte)
1286
- xe.NamedCurve,
1268
+ Ne.NamedCurve,
1287
1269
  // Curve name (2 bytes)
1288
- ...K(ke.secp256r1),
1270
+ ...D(ke.secp256r1),
1289
1271
  // Public key length (1 byte)
1290
1272
  s.byteLength,
1291
1273
  // Public key (65 bytes, uncompressed format)
1292
1274
  ...s
1293
- ]), a = await crypto.subtle.sign(
1275
+ ]), _ = await crypto.subtle.sign(
1294
1276
  {
1295
1277
  name: "RSASSA-PKCS1-v1_5",
1296
1278
  hash: "SHA-256"
1297
1279
  },
1298
1280
  n,
1299
- new Uint8Array([...e, ...t, ..._])
1300
- ), c = new Uint8Array(a), S = new Uint8Array([
1301
- j.sha256,
1302
- F.rsa
1303
- ]), A = new Uint8Array([
1304
- ..._,
1305
- ...S,
1306
- ...K(c.length),
1307
- ...c
1281
+ new Uint8Array([...e, ...t, ...a])
1282
+ ), S = new Uint8Array(_), c = new Uint8Array([
1283
+ G.sha256,
1284
+ j.rsa
1285
+ ]), h = new Uint8Array([
1286
+ ...a,
1287
+ ...c,
1288
+ ...D(S.length),
1289
+ ...S
1308
1290
  ]);
1309
1291
  return new Uint8Array([
1310
- T.ServerKeyExchange,
1311
- ...w(A.length),
1312
- ...A
1292
+ E.ServerKeyExchange,
1293
+ ...y(h.length),
1294
+ ...h
1313
1295
  ]);
1314
1296
  }
1315
1297
  /**
@@ -1351,31 +1333,31 @@ class g {
1351
1333
  * +------------------------------------+
1352
1334
  */
1353
1335
  static serverHello(e, t, r) {
1354
- const n = e.extensions.map((a) => {
1355
- switch (a.type) {
1336
+ const n = e.extensions.map((_) => {
1337
+ switch (_.type) {
1356
1338
  case "server_name":
1357
- return _e.encodeForClient();
1339
+ return oe.encodeForClient();
1358
1340
  }
1359
- }).filter((a) => a !== void 0), s = u(n), _ = new Uint8Array([
1341
+ }).filter((_) => _ !== void 0), s = u(n), a = new Uint8Array([
1360
1342
  // Version field – 0x03, 0x03 means TLS 1.2
1361
- ...P,
1343
+ ...U,
1362
1344
  ...t,
1363
1345
  e.session_id.length,
1364
1346
  ...e.session_id,
1365
- ...K(ae.TLS1_CK_ECDHE_RSA_WITH_AES_128_GCM_SHA256),
1347
+ ...D(ce.TLS1_CK_ECDHE_RSA_WITH_AES_128_GCM_SHA256),
1366
1348
  r,
1367
1349
  // Extensions length (2 bytes)
1368
- ...K(s.length),
1350
+ ...D(s.length),
1369
1351
  ...s
1370
1352
  ]);
1371
1353
  return new Uint8Array([
1372
- T.ServerHello,
1373
- ...w(_.length),
1374
- ..._
1354
+ E.ServerHello,
1355
+ ...y(a.length),
1356
+ ...a
1375
1357
  ]);
1376
1358
  }
1377
1359
  static serverHelloDone() {
1378
- return new Uint8Array([T.ServerHelloDone, ...w(0)]);
1360
+ return new Uint8Array([E.ServerHelloDone, ...y(0)]);
1379
1361
  }
1380
1362
  /**
1381
1363
  * Server finished message.
@@ -1409,8 +1391,8 @@ class g {
1409
1391
  )
1410
1392
  );
1411
1393
  return new Uint8Array([
1412
- T.Finished,
1413
- ...w(n.length),
1394
+ E.Finished,
1395
+ ...y(n.length),
1414
1396
  ...n
1415
1397
  ]);
1416
1398
  }
@@ -1421,17 +1403,17 @@ class g {
1421
1403
  function je(i, e) {
1422
1404
  return Ge.generateCertificate(i, e);
1423
1405
  }
1424
- function Ht(i) {
1406
+ function Tt(i) {
1425
1407
  return `-----BEGIN CERTIFICATE-----
1426
- ${he(
1408
+ ${ue(
1427
1409
  Ae(i.buffer)
1428
1410
  )}
1429
1411
  -----END CERTIFICATE-----`;
1430
1412
  }
1431
- async function dt(i) {
1413
+ async function ft(i) {
1432
1414
  const e = await crypto.subtle.exportKey("pkcs8", i);
1433
1415
  return `-----BEGIN PRIVATE KEY-----
1434
- ${he(
1416
+ ${ue(
1435
1417
  Ae(e)
1436
1418
  )}
1437
1419
  -----END PRIVATE KEY-----`;
@@ -1503,7 +1485,7 @@ class Ge {
1503
1485
  }
1504
1486
  static signatureAlgorithm(e = "sha256WithRSAEncryption") {
1505
1487
  return o.sequence([
1506
- o.objectIdentifier(p(e)),
1488
+ o.objectIdentifier(w(e)),
1507
1489
  o.null()
1508
1490
  ]);
1509
1491
  }
@@ -1517,7 +1499,7 @@ class Ge {
1517
1499
  const t = [];
1518
1500
  for (const [r, n] of Object.entries(e)) {
1519
1501
  const s = [
1520
- o.objectIdentifier(p(r))
1502
+ o.objectIdentifier(w(r))
1521
1503
  ];
1522
1504
  switch (r) {
1523
1505
  case "countryName":
@@ -1535,13 +1517,13 @@ class Ge {
1535
1517
  o.ASN1(
1536
1518
  d.UTCTime,
1537
1519
  new TextEncoder().encode(
1538
- te((e == null ? void 0 : e.notBefore) ?? /* @__PURE__ */ new Date())
1520
+ ne((e == null ? void 0 : e.notBefore) ?? /* @__PURE__ */ new Date())
1539
1521
  )
1540
1522
  ),
1541
1523
  o.ASN1(
1542
1524
  d.UTCTime,
1543
1525
  new TextEncoder().encode(
1544
- te(
1526
+ ne(
1545
1527
  (e == null ? void 0 : e.notAfter) ?? Ve(/* @__PURE__ */ new Date(), 10)
1546
1528
  )
1547
1529
  )
@@ -1556,14 +1538,14 @@ class Ge {
1556
1538
  return t !== void 0 && r.push(
1557
1539
  o.integer(new Uint8Array([t]))
1558
1540
  ), o.sequence([
1559
- o.objectIdentifier(p("basicConstraints")),
1541
+ o.objectIdentifier(w("basicConstraints")),
1560
1542
  o.octetString(o.sequence(r))
1561
1543
  ]);
1562
1544
  }
1563
1545
  static keyUsage(e) {
1564
1546
  const t = new Uint8Array([0]);
1565
1547
  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([
1566
- o.objectIdentifier(p("keyUsage")),
1548
+ o.objectIdentifier(w("keyUsage")),
1567
1549
  o.boolean(!0),
1568
1550
  // Critical
1569
1551
  o.octetString(o.bitString(t))
@@ -1571,13 +1553,13 @@ class Ge {
1571
1553
  }
1572
1554
  static extKeyUsage(e = {}) {
1573
1555
  return o.sequence([
1574
- o.objectIdentifier(p("extKeyUsage")),
1556
+ o.objectIdentifier(w("extKeyUsage")),
1575
1557
  o.boolean(!0),
1576
1558
  // Critical
1577
1559
  o.octetString(
1578
1560
  o.sequence(
1579
1561
  Object.entries(e).map(([t, r]) => r ? o.objectIdentifier(
1580
- p(t)
1562
+ w(t)
1581
1563
  ) : o.null())
1582
1564
  )
1583
1565
  )
@@ -1586,23 +1568,23 @@ class Ge {
1586
1568
  static nsCertType(e) {
1587
1569
  const t = new Uint8Array([0]);
1588
1570
  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([
1589
- o.objectIdentifier(p("nsCertType")),
1571
+ o.objectIdentifier(w("nsCertType")),
1590
1572
  o.octetString(t)
1591
1573
  ]);
1592
1574
  }
1593
1575
  static subjectAltName(e) {
1594
- var s, _;
1595
- const t = ((s = e.dnsNames) == null ? void 0 : s.map((a) => {
1596
- const c = o.ia5String(a);
1597
- return o.contextSpecific(2, c);
1598
- })) || [], r = ((_ = e.ipAddresses) == null ? void 0 : _.map((a) => {
1599
- const c = o.ia5String(a);
1600
- return o.contextSpecific(7, c);
1576
+ var s, a;
1577
+ const t = ((s = e.dnsNames) == null ? void 0 : s.map((_) => {
1578
+ const S = o.ia5String(_);
1579
+ return o.contextSpecific(2, S);
1580
+ })) || [], r = ((a = e.ipAddresses) == null ? void 0 : a.map((_) => {
1581
+ const S = o.ia5String(_);
1582
+ return o.contextSpecific(7, S);
1601
1583
  })) || [], n = o.octetString(
1602
1584
  o.sequence([...t, ...r])
1603
1585
  );
1604
1586
  return o.sequence([
1605
- o.objectIdentifier(p("subjectAltName")),
1587
+ o.objectIdentifier(w("subjectAltName")),
1606
1588
  o.boolean(!0),
1607
1589
  n
1608
1590
  ]);
@@ -1718,13 +1700,13 @@ const $e = {
1718
1700
  "1.3.6.1.5.5.7.3.4": "emailProtection",
1719
1701
  "1.3.6.1.5.5.7.3.8": "timeStamping"
1720
1702
  };
1721
- function p(i) {
1703
+ function w(i) {
1722
1704
  for (const [e, t] of Object.entries($e))
1723
1705
  if (t === i)
1724
1706
  return e;
1725
1707
  throw new Error(`OID not found for name: ${i}`);
1726
1708
  }
1727
- const ee = 32, d = {
1709
+ const re = 32, d = {
1728
1710
  Boolean: 1,
1729
1711
  Integer: 2,
1730
1712
  BitString: 3,
@@ -1732,8 +1714,8 @@ const ee = 32, d = {
1732
1714
  Null: 5,
1733
1715
  OID: 6,
1734
1716
  Utf8String: 12,
1735
- Sequence: 16 | ee,
1736
- Set: 17 | ee,
1717
+ Sequence: 16 | re,
1718
+ Set: 17 | re,
1737
1719
  PrintableString: 19,
1738
1720
  IA5String: 22,
1739
1721
  UTCTime: 23
@@ -1750,8 +1732,8 @@ class o {
1750
1732
  r.unshift(t & 255), t >>= 8;
1751
1733
  const n = r.length, s = new Uint8Array(1 + n);
1752
1734
  s[0] = 128 | n;
1753
- for (let _ = 0; _ < n; _++)
1754
- s[_ + 1] = r[_];
1735
+ for (let a = 0; a < n; a++)
1736
+ s[a + 1] = r[a];
1755
1737
  return s;
1756
1738
  }
1757
1739
  }
@@ -1779,14 +1761,14 @@ class o {
1779
1761
  static objectIdentifier(e) {
1780
1762
  const t = e.split(".").map(Number), n = [t[0] * 40 + t[1]];
1781
1763
  for (let s = 2; s < t.length; s++) {
1782
- let _ = t[s];
1783
- const a = [];
1764
+ let a = t[s];
1765
+ const _ = [];
1784
1766
  do
1785
- a.unshift(_ & 127), _ >>= 7;
1786
- while (_ > 0);
1787
- for (let c = 0; c < a.length - 1; c++)
1788
- a[c] |= 128;
1789
- n.push(...a);
1767
+ _.unshift(a & 127), a >>= 7;
1768
+ while (a > 0);
1769
+ for (let S = 0; S < _.length - 1; S++)
1770
+ _[S] |= 128;
1771
+ n.push(..._);
1790
1772
  }
1791
1773
  return o.ASN1(d.OID, new Uint8Array(n));
1792
1774
  }
@@ -1822,45 +1804,62 @@ class o {
1822
1804
  function Ae(i) {
1823
1805
  return btoa(String.fromCodePoint(...new Uint8Array(i)));
1824
1806
  }
1825
- function he(i) {
1807
+ function ue(i) {
1826
1808
  var e;
1827
1809
  return ((e = i.match(/.{1,64}/g)) == null ? void 0 : e.join(`
1828
1810
  `)) || i;
1829
1811
  }
1830
- function te(i) {
1831
- const e = i.getUTCFullYear().toString().substr(2), t = D(i.getUTCMonth() + 1), r = D(i.getUTCDate()), n = D(i.getUTCHours()), s = D(i.getUTCMinutes()), _ = D(i.getUTCSeconds());
1832
- return `${e}${t}${r}${n}${s}${_}Z`;
1812
+ function ne(i) {
1813
+ const e = i.getUTCFullYear().toString().substr(2), t = P(i.getUTCMonth() + 1), r = P(i.getUTCDate()), n = P(i.getUTCHours()), s = P(i.getUTCMinutes()), a = P(i.getUTCSeconds());
1814
+ return `${e}${t}${r}${n}${s}${a}Z`;
1833
1815
  }
1834
- function D(i) {
1816
+ function P(i) {
1835
1817
  return i.toString().padStart(2, "0");
1836
1818
  }
1837
1819
  function Ve(i, e) {
1838
1820
  const t = new Date(i);
1839
1821
  return t.setUTCFullYear(t.getUTCFullYear() + e), t;
1840
1822
  }
1841
- async function ze(i, e, t, r) {
1842
- var S;
1843
- const n = typeof i == "string" ? new Request(i, e) : i;
1823
+ class ze extends Error {
1824
+ constructor(e, t, r) {
1825
+ super(
1826
+ `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.`
1827
+ ), this.name = "FirewallInterferenceError", this.url = e, this.status = t, this.statusText = r;
1828
+ }
1829
+ }
1830
+ const Ye = "X-Playground-Cors-Proxy";
1831
+ async function Xe(i, e, t, r) {
1832
+ var c;
1833
+ let n = typeof i == "string" ? new Request(i, e) : i;
1834
+ const s = r ? new URL(r) : null;
1835
+ let a = s ? new URL(n.url, s) : new URL(n.url);
1836
+ if (a.protocol === "http:") {
1837
+ a.protocol = "https:";
1838
+ const h = a.toString();
1839
+ n = await $(n, { url: h }), a = new URL(h);
1840
+ }
1844
1841
  if (!t)
1845
1842
  return await fetch(n);
1846
- const s = r ? new URL(r) : null, _ = new URL(
1847
- n.url,
1848
- s || void 0
1849
- );
1850
- if (s && _.protocol === s.protocol && _.hostname === s.hostname && _.port === s.port && _.pathname.startsWith(s.pathname))
1843
+ if (s && a.protocol === s.protocol && a.hostname === s.hostname && a.port === s.port && a.pathname.startsWith(s.pathname))
1851
1844
  return await fetch(n);
1852
- const [a, c] = await me(n);
1845
+ const [_, S] = await me(n);
1853
1846
  try {
1854
- return await fetch(a);
1847
+ return await fetch(_);
1855
1848
  } catch {
1856
- const h = ((S = new Headers(c.headers).get("x-cors-proxy-allowed-request-headers")) == null ? void 0 : S.split(",")) || [], l = h.includes("authorization") || h.includes("cookie"), H = await ge(c, {
1849
+ 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, {
1857
1850
  url: `${t}${n.url}`,
1858
- ...l && { credentials: "include" }
1859
- });
1860
- return await fetch(H, e);
1851
+ ...A && { credentials: "include" }
1852
+ }), p = await fetch(H, e);
1853
+ if (!p.headers.has(Ye))
1854
+ throw new ze(
1855
+ n.url,
1856
+ p.status,
1857
+ p.statusText
1858
+ );
1859
+ return p;
1861
1860
  }
1862
1861
  }
1863
- class Ye extends TransformStream {
1862
+ class Ze extends TransformStream {
1864
1863
  constructor() {
1865
1864
  let e = new Uint8Array(0), t = "SCAN_CHUNK_SIZE", r = 0;
1866
1865
  super({
@@ -1869,37 +1868,37 @@ class Ye extends TransformStream {
1869
1868
  if (t === "SCAN_CHUNK_SIZE") {
1870
1869
  if (e.length < 3)
1871
1870
  return;
1872
- let _ = 0;
1873
- for (; _ < e.length; ) {
1874
- const S = e[_];
1875
- if (!(S >= 48 && S <= 57 || // 0-9
1876
- S >= 97 && S <= 102 || // a-f
1877
- S >= 65 && S <= 70)) break;
1878
- _++;
1871
+ let a = 0;
1872
+ for (; a < e.length; ) {
1873
+ const c = e[a];
1874
+ if (!(c >= 48 && c <= 57 || // 0-9
1875
+ c >= 97 && c <= 102 || // a-f
1876
+ c >= 65 && c <= 70)) break;
1877
+ a++;
1879
1878
  }
1880
- if (_ === 0)
1879
+ if (a === 0)
1881
1880
  throw new Error("Invalid chunk size format");
1882
- if (e.length < _ + 2)
1881
+ if (e.length < a + 2)
1883
1882
  return;
1884
- if (e[_] !== 13 || // \r
1885
- e[_ + 1] !== 10)
1883
+ if (e[a] !== 13 || // \r
1884
+ e[a + 1] !== 10)
1886
1885
  throw new Error(
1887
1886
  "Invalid chunk size format. Expected CRLF after chunk size"
1888
1887
  );
1889
- const a = new TextDecoder().decode(
1890
- e.slice(0, _)
1891
- ), c = parseInt(a, 16);
1892
- if (e = e.slice(_ + 2), c === 0) {
1888
+ const _ = new TextDecoder().decode(
1889
+ e.slice(0, a)
1890
+ ), S = parseInt(_, 16);
1891
+ if (e = e.slice(a + 2), S === 0) {
1893
1892
  t = "SCAN_FINAL_CHUNK", s.terminate();
1894
1893
  return;
1895
1894
  }
1896
- r = c, t = "SCAN_CHUNK_DATA";
1895
+ r = S, t = "SCAN_CHUNK_DATA";
1897
1896
  } else if (t === "SCAN_CHUNK_DATA") {
1898
- const _ = Math.min(
1897
+ const a = Math.min(
1899
1898
  r,
1900
1899
  e.length
1901
- ), a = e.slice(0, _);
1902
- e = e.slice(_), r -= _, s.enqueue(a), r === 0 && (t = "SCAN_CHUNK_TRAILER");
1900
+ ), _ = e.slice(0, a);
1901
+ e = e.slice(a), r -= a, s.enqueue(_), r === 0 && (t = "SCAN_CHUNK_TRAILER");
1903
1902
  } else if (t === "SCAN_CHUNK_TRAILER") {
1904
1903
  if (e.length < 2)
1905
1904
  return;
@@ -1913,7 +1912,7 @@ class Ye extends TransformStream {
1913
1912
  });
1914
1913
  }
1915
1914
  }
1916
- const Ze = (i, e) => ({
1915
+ const Je = (i, e) => ({
1917
1916
  ...i,
1918
1917
  websocket: {
1919
1918
  url: (t, r, n) => `ws://playground.internal/?${new URLSearchParams({
@@ -1921,7 +1920,7 @@ const Ze = (i, e) => ({
1921
1920
  port: n
1922
1921
  }).toString()}`,
1923
1922
  subprotocol: "binary",
1924
- decorator: () => class extends Je {
1923
+ decorator: () => class extends Qe {
1925
1924
  constructor(t, r) {
1926
1925
  super(t, r, {
1927
1926
  CAroot: e.CAroot,
@@ -1931,18 +1930,18 @@ const Ze = (i, e) => ({
1931
1930
  }
1932
1931
  }
1933
1932
  });
1934
- class Je {
1933
+ class Qe {
1935
1934
  constructor(e, t, {
1936
1935
  CAroot: r,
1937
1936
  corsProxyUrl: n,
1938
1937
  outputType: s = "messages"
1939
1938
  } = {}) {
1940
1939
  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;
1941
- const _ = new URL(e);
1942
- this.host = _.searchParams.get("host"), this.port = parseInt(_.searchParams.get("port"), 10), this.binaryType = "arraybuffer", this.corsProxyUrl = n, this.CAroot = r, s === "messages" && this.clientDownstream.readable.pipeTo(
1940
+ const a = new URL(e);
1941
+ 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(
1943
1942
  new WritableStream({
1944
- write: (a) => {
1945
- this.emit("message", { data: a });
1943
+ write: (_) => {
1944
+ this.emit("message", { data: _ });
1946
1945
  },
1947
1946
  abort: () => {
1948
1947
  this.emit("error", new Error("ECONNREFUSED")), this.close();
@@ -2002,7 +2001,7 @@ class Je {
2002
2001
  switch (this.bufferedBytesFromClient = u([
2003
2002
  this.bufferedBytesFromClient,
2004
2003
  new Uint8Array(e)
2005
- ]), Qe(this.port, this.bufferedBytesFromClient)) {
2004
+ ]), tt(this.port, this.bufferedBytesFromClient)) {
2006
2005
  case !1:
2007
2006
  return;
2008
2007
  case "other":
@@ -2031,20 +2030,20 @@ class Je {
2031
2030
  issuer: this.CAroot.tbsDescription.subject
2032
2031
  },
2033
2032
  this.CAroot.keyPair
2034
- ), t = new Oe();
2033
+ ), t = new Fe();
2035
2034
  this.clientUpstream.readable.pipeTo(t.clientEnd.upstream.writable).catch(() => {
2036
2035
  }), t.clientEnd.downstream.readable.pipeTo(this.clientDownstream.writable).catch(() => {
2037
2036
  }), await t.TLSHandshake(e.keyPair.privateKey, [
2038
2037
  e.certificate,
2039
2038
  this.CAroot.certificate
2040
2039
  ]);
2041
- const r = await L.parseHttpRequest(
2040
+ const r = await m.parseHttpRequest(
2042
2041
  t.serverEnd.upstream.readable,
2043
2042
  this.host,
2044
2043
  "https"
2045
2044
  );
2046
2045
  try {
2047
- await L.fetchRawResponseBytes(
2046
+ await m.fetchRawResponseBytes(
2048
2047
  r,
2049
2048
  this.corsProxyUrl
2050
2049
  ).pipeTo(t.serverEnd.downstream.writable);
@@ -2052,13 +2051,13 @@ class Je {
2052
2051
  }
2053
2052
  }
2054
2053
  async fetchOverHTTP() {
2055
- const e = await L.parseHttpRequest(
2054
+ const e = await m.parseHttpRequest(
2056
2055
  this.clientUpstream.readable,
2057
2056
  this.host,
2058
2057
  "http"
2059
2058
  );
2060
2059
  try {
2061
- await L.fetchRawResponseBytes(
2060
+ await m.fetchRawResponseBytes(
2062
2061
  e,
2063
2062
  this.corsProxyUrl
2064
2063
  ).pipeTo(this.clientDownstream.writable);
@@ -2069,7 +2068,7 @@ class Je {
2069
2068
  this.emit("message", { data: new Uint8Array(0) }), this.readyState = this.CLOSING, this.emit("close"), this.readyState = this.CLOSED;
2070
2069
  }
2071
2070
  }
2072
- const Xe = [
2071
+ const et = [
2073
2072
  "GET",
2074
2073
  "POST",
2075
2074
  "HEAD",
@@ -2079,7 +2078,7 @@ const Xe = [
2079
2078
  "PUT",
2080
2079
  "TRACE"
2081
2080
  ];
2082
- function Qe(i, e) {
2081
+ function tt(i, e) {
2083
2082
  if (e.length < 8)
2084
2083
  return !1;
2085
2084
  if (i === 443 && e[0] === C.Handshake && // TLS versions between 1.0 and 1.2
@@ -2088,26 +2087,26 @@ function Qe(i, e) {
2088
2087
  const r = new TextDecoder("latin1", {
2089
2088
  fatal: !0
2090
2089
  }).decode(e);
2091
- return Xe.some(
2090
+ return et.some(
2092
2091
  (s) => r.startsWith(s + " ")
2093
2092
  ) ? "http" : "other";
2094
2093
  }
2095
- class L {
2094
+ class m {
2096
2095
  /**
2097
2096
  * Streams a HTTP response including the status line and headers.
2098
2097
  */
2099
2098
  static fetchRawResponseBytes(e, t) {
2100
2099
  return new ReadableStream({
2101
2100
  async start(r) {
2102
- var a;
2101
+ var _;
2103
2102
  let n;
2104
2103
  try {
2105
- n = await ze(
2104
+ n = await Xe(
2106
2105
  e,
2107
2106
  void 0,
2108
2107
  t
2109
2108
  );
2110
- } catch (c) {
2109
+ } catch (S) {
2111
2110
  r.enqueue(
2112
2111
  new TextEncoder().encode(
2113
2112
  `HTTP/1.1 400 Bad Request\r
@@ -2115,24 +2114,24 @@ Content-Length: 0\r
2115
2114
  \r
2116
2115
  `
2117
2116
  )
2118
- ), r.error(c);
2117
+ ), r.error(S);
2119
2118
  return;
2120
2119
  }
2121
- r.enqueue(L.headersAsBytes(n));
2122
- const s = (a = n.body) == null ? void 0 : a.getReader();
2120
+ r.enqueue(m.headersAsBytes(n));
2121
+ const s = (_ = n.body) == null ? void 0 : _.getReader();
2123
2122
  if (!s) {
2124
2123
  r.close();
2125
2124
  return;
2126
2125
  }
2127
- const _ = new TextEncoder();
2126
+ const a = new TextEncoder();
2128
2127
  for (; ; ) {
2129
- const { done: c, value: S } = await s.read();
2130
- if (S && (r.enqueue(
2131
- _.encode(`${S.length.toString(16)}\r
2128
+ const { done: S, value: c } = await s.read();
2129
+ if (c && (r.enqueue(
2130
+ a.encode(`${c.length.toString(16)}\r
2132
2131
  `)
2133
- ), r.enqueue(S), r.enqueue(_.encode(`\r
2134
- `))), c) {
2135
- r.enqueue(_.encode(`0\r
2132
+ ), r.enqueue(c), r.enqueue(a.encode(`\r
2133
+ `))), S) {
2134
+ r.enqueue(a.encode(`0\r
2136
2135
  \r
2137
2136
  `)), r.close();
2138
2137
  return;
@@ -2143,12 +2142,12 @@ Content-Length: 0\r
2143
2142
  }
2144
2143
  static headersAsBytes(e) {
2145
2144
  const t = `HTTP/1.1 ${e.status} ${e.statusText}`, r = {};
2146
- e.headers.forEach((_, a) => {
2147
- r[a.toLowerCase()] = _;
2145
+ e.headers.forEach((a, _) => {
2146
+ r[_.toLowerCase()] = a;
2148
2147
  }), delete r["content-length"], r["transfer-encoding"] = "chunked";
2149
2148
  const n = [];
2150
- for (const [_, a] of Object.entries(r))
2151
- n.push(`${_}: ${a}`);
2149
+ for (const [a, _] of Object.entries(r))
2150
+ n.push(`${a}: ${_}`);
2152
2151
  const s = [t, ...n].join(`\r
2153
2152
  `) + `\r
2154
2153
  \r
@@ -2160,55 +2159,55 @@ Content-Length: 0\r
2160
2159
  * with known headers and a readable body stream.
2161
2160
  */
2162
2161
  static async parseHttpRequest(e, t, r) {
2163
- let n = new Uint8Array(0), s = !1, _ = -1;
2164
- const a = e.getReader();
2165
- for (; _ === -1; ) {
2166
- const { done: N, value: R } = await a.read();
2167
- if (N) {
2162
+ let n = new Uint8Array(0), s = !1, a = -1;
2163
+ const _ = e.getReader();
2164
+ for (; a === -1; ) {
2165
+ const { done: x, value: R } = await _.read();
2166
+ if (x) {
2168
2167
  s = !0;
2169
2168
  break;
2170
2169
  }
2171
- n = u([n, R]), _ = et(
2170
+ n = u([n, R]), a = rt(
2172
2171
  n,
2173
2172
  new Uint8Array([13, 10, 13, 10])
2174
2173
  );
2175
2174
  }
2176
- a.releaseLock();
2177
- const c = n.slice(0, _), S = L.parseRequestHeaders(c), A = 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, l = n.slice(
2178
- _ + 4
2175
+ _.releaseLock();
2176
+ 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(
2177
+ a + 4
2179
2178
  /* Skip \r\n\r\n */
2180
2179
  );
2181
2180
  let H;
2182
- if (S.method !== "GET") {
2183
- const N = e.getReader();
2184
- let R = l.length, x = l.slice(-6);
2185
- const He = new TextEncoder().encode(`0\r
2181
+ if (c.method !== "GET") {
2182
+ const x = e.getReader();
2183
+ let R = A.length, N = A.slice(-6);
2184
+ const Ee = new TextEncoder().encode(`0\r
2186
2185
  \r
2187
2186
  `);
2188
2187
  H = new ReadableStream({
2189
- async start(I) {
2190
- l.length > 0 && I.enqueue(l), s && I.close();
2188
+ async start(W) {
2189
+ A.length > 0 && W.enqueue(A), s && W.close();
2191
2190
  },
2192
- async pull(I) {
2193
- const { done: de, value: m } = await N.read();
2194
- if (R += (m == null ? void 0 : m.length) || 0, m && (I.enqueue(m), x = u([
2195
- x,
2196
- m || new Uint8Array()
2197
- ]).slice(-5)), de || A === "content-length" && h !== void 0 && R >= h || A === "chunked" && x.every(
2198
- (Te, Ee) => Te === He[Ee]
2191
+ async pull(W) {
2192
+ const { done: Te, value: I } = await x.read();
2193
+ if (R += (I == null ? void 0 : I.length) || 0, I && (W.enqueue(I), N = u([
2194
+ N,
2195
+ I || new Uint8Array()
2196
+ ]).slice(-5)), Te || h === "content-length" && l !== void 0 && R >= l || h === "chunked" && N.every(
2197
+ (fe, pe) => fe === Ee[pe]
2199
2198
  )) {
2200
- I.close();
2199
+ W.close();
2201
2200
  return;
2202
2201
  }
2203
2202
  }
2204
- }), A === "chunked" && (H = H.pipeThrough(
2205
- new Ye()
2203
+ }), h === "chunked" && (H = H.pipeThrough(
2204
+ new Ze()
2206
2205
  ));
2207
2206
  }
2208
- const M = S.headers.get("Host") ?? t, ue = new URL(S.path, r + "://" + M);
2209
- return new Request(ue.toString(), {
2210
- method: S.method,
2211
- headers: S.headers,
2207
+ const p = c.headers.get("Host") ?? t, de = new URL(c.path, r + "://" + p);
2208
+ return new Request(de.toString(), {
2209
+ method: c.method,
2210
+ headers: c.headers,
2212
2211
  body: H,
2213
2212
  // In Node.js, duplex: 'half' is required when
2214
2213
  // the body stream is provided.
@@ -2218,51 +2217,96 @@ Content-Length: 0\r
2218
2217
  }
2219
2218
  static parseRequestHeaders(e) {
2220
2219
  const t = new TextDecoder().decode(e), r = t.split(`
2221
- `)[0], [n, s] = r.split(" "), _ = new Headers();
2222
- for (const a of t.split(`\r
2220
+ `)[0], [n, s] = r.split(" "), a = new Headers();
2221
+ for (const _ of t.split(`\r
2223
2222
  `).slice(1)) {
2224
- if (a === "")
2223
+ if (_ === "")
2225
2224
  break;
2226
- const [c, S] = a.split(": ");
2227
- _.set(c, S);
2225
+ const [S, c] = _.split(": ");
2226
+ a.set(S, c);
2228
2227
  }
2229
- return { method: n, path: s, headers: _ };
2228
+ return { method: n, path: s, headers: a };
2230
2229
  }
2231
2230
  }
2232
- function et(i, e) {
2231
+ function rt(i, e) {
2233
2232
  const t = i.length, r = e.length, n = t - r;
2234
2233
  for (let s = 0; s <= n; s++) {
2235
- let _ = !0;
2236
- for (let a = 0; a < r; a++)
2237
- if (i[s + a] !== e[a]) {
2238
- _ = !1;
2234
+ let a = !0;
2235
+ for (let _ = 0; _ < r; _++)
2236
+ if (i[s + _] !== e[_]) {
2237
+ a = !1;
2239
2238
  break;
2240
2239
  }
2241
- if (_)
2240
+ if (a)
2242
2241
  return s;
2243
2242
  }
2244
2243
  return -1;
2245
2244
  }
2246
- async function tt(i) {
2247
- const e = "icudt74l.dat", t = (await import("./shared/icudt74l.js")).dataFilename, r = await (await fetch(t)).arrayBuffer();
2245
+ async function nt(i = O) {
2246
+ switch (i) {
2247
+ case "8.5":
2248
+ return (await import("@php-wasm/web-8-5")).getIntlExtensionPath();
2249
+ case "8.4":
2250
+ return (await import("@php-wasm/web-8-4")).getIntlExtensionPath();
2251
+ case "8.3":
2252
+ return (await import("@php-wasm/web-8-3")).getIntlExtensionPath();
2253
+ case "8.2":
2254
+ return (await import("@php-wasm/web-8-2")).getIntlExtensionPath();
2255
+ case "8.1":
2256
+ return (await import("@php-wasm/web-8-1")).getIntlExtensionPath();
2257
+ case "8.0":
2258
+ return (await import("@php-wasm/web-8-0")).getIntlExtensionPath();
2259
+ case "7.4":
2260
+ return (await import("@php-wasm/web-7-4")).getIntlExtensionPath();
2261
+ case "7.3":
2262
+ return (await import("@php-wasm/web-7-3")).getIntlExtensionPath();
2263
+ case "7.2":
2264
+ return (await import("@php-wasm/web-7-2")).getIntlExtensionPath();
2265
+ }
2266
+ throw new Error(`Unsupported PHP version ${i}`);
2267
+ }
2268
+ async function st(i = O, e) {
2269
+ const t = ge(fetch), r = "intl.so", n = "icu.dat", s = await nt(i), a = (await import("./lib/extensions/intl/shared/icu.dat")).default, [_, S] = await Promise.all([
2270
+ t(s).then((c) => c.arrayBuffer()),
2271
+ t(a).then((c) => c.arrayBuffer())
2272
+ ]);
2248
2273
  return {
2249
- ...i,
2274
+ ...e,
2250
2275
  ENV: {
2251
- ...i.ENV,
2276
+ ...e.ENV,
2277
+ PHP_INI_SCAN_DIR: "/internal/shared/extensions",
2252
2278
  ICU_DATA: "/internal/shared"
2253
2279
  },
2254
- onRuntimeInitialized: (n) => {
2255
- i.onRuntimeInitialized && i.onRuntimeInitialized(n), W.fileExists(
2256
- n.FS,
2257
- `${n.ENV.ICU_DATA}/${e}`
2258
- ) || (n.FS.mkdirTree(n.ENV.ICU_DATA), n.FS.writeFile(
2259
- `${n.ENV.ICU_DATA}/${e}`,
2260
- new Uint8Array(r)
2280
+ onRuntimeInitialized: (c) => {
2281
+ e.onRuntimeInitialized && e.onRuntimeInitialized(c), L.fileExists(
2282
+ c.FS,
2283
+ "/internal/shared/extensions"
2284
+ ) || c.FS.mkdirTree("/internal/shared/extensions"), L.fileExists(
2285
+ c.FS,
2286
+ `/internal/shared/extensions/${r}`
2287
+ ) || c.FS.writeFile(
2288
+ `/internal/shared/extensions/${r}`,
2289
+ new Uint8Array(_)
2290
+ ), L.fileExists(
2291
+ c.FS,
2292
+ "/internal/shared/extensions/intl.ini"
2293
+ ) || c.FS.writeFile(
2294
+ "/internal/shared/extensions/intl.ini",
2295
+ [
2296
+ `extension=/internal/shared/extensions/${r}`
2297
+ ].join(`
2298
+ `)
2299
+ ), L.fileExists(
2300
+ c.FS,
2301
+ `${c.ENV.ICU_DATA}/${n}`
2302
+ ) || (c.FS.mkdirTree(c.ENV.ICU_DATA), c.FS.writeFile(
2303
+ `${c.ENV.ICU_DATA}/icudt74l.dat`,
2304
+ new Uint8Array(S)
2261
2305
  ));
2262
2306
  }
2263
2307
  };
2264
2308
  }
2265
- const rt = () => ({
2309
+ const it = () => ({
2266
2310
  websocket: {
2267
2311
  decorator: (i) => class extends i {
2268
2312
  constructor() {
@@ -2277,23 +2321,24 @@ const rt = () => ({
2277
2321
  }
2278
2322
  }
2279
2323
  });
2280
- async function Et(i, e = {}) {
2324
+ async function wt(i, e = {}) {
2281
2325
  var s;
2326
+ "setImmediate" in globalThis || (globalThis.setImmediate = (a) => setTimeout(a, 0));
2282
2327
  let t = {
2283
- ...rt(),
2328
+ ...it(),
2284
2329
  ...e.emscriptenOptions || {}
2285
2330
  };
2286
- e.tcpOverFetch && (t = Ze(
2331
+ e.tcpOverFetch && (t = Je(
2287
2332
  t,
2288
2333
  e.tcpOverFetch
2289
- )), e.withICU && (t = tt(t));
2334
+ )), e.withIntl && (t = st(i, t));
2290
2335
  const [r, n] = await Promise.all([
2291
2336
  De(i),
2292
2337
  t
2293
2338
  ]);
2294
- return (s = e.onPhpLoaderModuleLoaded) == null || s.call(e, r), await pe(r, n);
2339
+ return (s = e.onPhpLoaderModuleLoaded) == null || s.call(e, r), await we(r, n);
2295
2340
  }
2296
- function ft(i, e) {
2341
+ function Lt(i, e) {
2297
2342
  window.addEventListener("message", (t) => {
2298
2343
  t.source === i.contentWindow && (e && t.origin !== e || typeof t.data != "object" || t.data.type !== "relay" || window.parent.postMessage(t.data, "*"));
2299
2344
  }), window.addEventListener("message", (t) => {
@@ -2301,14 +2346,14 @@ function ft(i, e) {
2301
2346
  t.source === window.parent && (typeof t.data != "object" || t.data.type !== "relay" || (r = i == null ? void 0 : i.contentWindow) == null || r.postMessage(t.data));
2302
2347
  });
2303
2348
  }
2304
- async function pt(i) {
2349
+ async function yt(i) {
2305
2350
  const e = new Worker(i, { type: "module" });
2306
2351
  return new Promise((t, r) => {
2307
2352
  e.onerror = (s) => {
2308
- const _ = new Error(
2353
+ const a = new Error(
2309
2354
  `WebWorker failed to load at ${i}. ${s.message ? `Original error: ${s.message}` : ""}`
2310
2355
  );
2311
- _.filename = s.filename, r(_);
2356
+ a.filename = s.filename, r(a);
2312
2357
  };
2313
2358
  function n(s) {
2314
2359
  s.data === "worker-script-started" && (t(e), e.removeEventListener("message", n));
@@ -2316,7 +2361,7 @@ async function pt(i) {
2316
2361
  e.addEventListener("message", n);
2317
2362
  });
2318
2363
  }
2319
- function wt(i, e = { initialSync: {} }) {
2364
+ function mt(i, e = { initialSync: {} }) {
2320
2365
  return e = {
2321
2366
  ...e,
2322
2367
  initialSync: {
@@ -2324,105 +2369,105 @@ function wt(i, e = { initialSync: {} }) {
2324
2369
  direction: e.initialSync.direction ?? "opfs-to-memfs"
2325
2370
  }
2326
2371
  }, async function(t, r, n) {
2327
- return e.initialSync.direction === "opfs-to-memfs" ? (W.fileExists(r, n) && W.rmdir(r, n), W.mkdir(r, n), await nt(r, i, n)) : await le(
2372
+ 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(
2328
2373
  r,
2329
2374
  i,
2330
2375
  n,
2331
2376
  e.initialSync.onProgress
2332
- ), it(t, i, n);
2377
+ ), ot(t, i, n);
2333
2378
  };
2334
2379
  }
2335
- async function nt(i, e, t) {
2336
- W.mkdir(i, t);
2380
+ async function at(i, e, t) {
2381
+ L.mkdir(i, t);
2337
2382
  const r = new Le({
2338
2383
  concurrency: 40
2339
2384
  }), n = [], s = [
2340
2385
  [e, t]
2341
2386
  ];
2342
2387
  for (; s.length > 0; ) {
2343
- const [_, a] = s.pop();
2344
- for await (const c of _.values()) {
2345
- const S = r.run(async () => {
2346
- const A = se(
2347
- a,
2348
- c.name
2388
+ const [a, _] = s.pop();
2389
+ for await (const S of a.values()) {
2390
+ const c = r.run(async () => {
2391
+ const h = ae(
2392
+ _,
2393
+ S.name
2349
2394
  );
2350
- if (c.kind === "directory") {
2395
+ if (S.kind === "directory") {
2351
2396
  try {
2352
- i.mkdir(A);
2353
- } catch (h) {
2354
- if ((h == null ? void 0 : h.errno) !== 20)
2355
- throw U.error(h), h;
2397
+ i.mkdir(h);
2398
+ } catch (l) {
2399
+ if ((l == null ? void 0 : l.errno) !== 20)
2400
+ throw M.error(l), l;
2356
2401
  }
2357
- s.push([c, A]);
2358
- } else if (c.kind === "file") {
2359
- const h = await c.getFile(), l = new Uint8Array(await h.arrayBuffer());
2402
+ s.push([S, h]);
2403
+ } else if (S.kind === "file") {
2404
+ const l = await S.getFile(), A = new Uint8Array(await l.arrayBuffer());
2360
2405
  i.createDataFile(
2361
- a,
2362
- c.name,
2363
- l,
2406
+ _,
2407
+ S.name,
2408
+ A,
2364
2409
  !0,
2365
2410
  !0,
2366
2411
  !0
2367
2412
  );
2368
2413
  }
2369
- n.splice(n.indexOf(S), 1);
2414
+ n.splice(n.indexOf(c), 1);
2370
2415
  });
2371
- n.push(S);
2416
+ n.push(c);
2372
2417
  }
2373
2418
  for (; s.length === 0 && n.length > 0; )
2374
2419
  await Promise.any(n);
2375
2420
  }
2376
2421
  }
2377
- async function le(i, e, t, r) {
2422
+ async function He(i, e, t, r) {
2378
2423
  i.mkdirTree(t);
2379
2424
  const n = [];
2380
- async function s(A, h) {
2425
+ async function s(h, l) {
2381
2426
  await Promise.all(
2382
- i.readdir(A).filter(
2383
- (l) => l !== "." && l !== ".."
2384
- ).map(async (l) => {
2385
- const H = se(A, l);
2386
- if (!st(i, H)) {
2387
- n.push([h, H, l]);
2427
+ i.readdir(h).filter(
2428
+ (A) => A !== "." && A !== ".."
2429
+ ).map(async (A) => {
2430
+ const H = ae(h, A);
2431
+ if (!_t(i, H)) {
2432
+ n.push([l, H, A]);
2388
2433
  return;
2389
2434
  }
2390
- const M = await h.getDirectoryHandle(l, {
2435
+ const p = await l.getDirectoryHandle(A, {
2391
2436
  create: !0
2392
2437
  });
2393
- return await s(H, M);
2438
+ return await s(H, p);
2394
2439
  })
2395
2440
  );
2396
2441
  }
2397
2442
  await s(t, e);
2398
- let _ = 0;
2399
- const a = r && ot(r, 100), c = 100, S = /* @__PURE__ */ new Set();
2443
+ let a = 0;
2444
+ const _ = r && Ct(r, 100), S = 100, c = /* @__PURE__ */ new Set();
2400
2445
  try {
2401
- for (const [A, h, l] of n) {
2402
- const H = O(
2446
+ for (const [h, l, A] of n) {
2447
+ const H = F(
2448
+ h,
2403
2449
  A,
2404
- l,
2405
2450
  i,
2406
- h
2451
+ l
2407
2452
  ).then(() => {
2408
- _++, S.delete(H), a == null || a({
2409
- files: _,
2453
+ a++, c.delete(H), _ == null || _({
2454
+ files: a,
2410
2455
  total: n.length
2411
2456
  });
2412
2457
  });
2413
- S.add(H), S.size >= c && (await Promise.race(S), a == null || a({
2414
- files: _,
2458
+ c.add(H), c.size >= S && (await Promise.race(c), _ == null || _({
2459
+ files: a,
2415
2460
  total: n.length
2416
2461
  }));
2417
2462
  }
2418
2463
  } finally {
2419
- await Promise.allSettled(S);
2464
+ await Promise.allSettled(c);
2420
2465
  }
2421
2466
  }
2422
- function st(i, e) {
2467
+ function _t(i, e) {
2423
2468
  return i.isDir(i.lookupPath(e, { follow: !0 }).node.mode);
2424
2469
  }
2425
- async function O(i, e, t, r) {
2470
+ async function F(i, e, t, r) {
2426
2471
  let n;
2427
2472
  try {
2428
2473
  n = t.readFile(r, {
@@ -2431,7 +2476,7 @@ async function O(i, e, t, r) {
2431
2476
  } catch {
2432
2477
  return;
2433
2478
  }
2434
- const s = await i.getFileHandle(e, { create: !0 }), _ = s.createWritable !== void 0 ? (
2479
+ const s = await i.getFileHandle(e, { create: !0 }), a = s.createWritable !== void 0 ? (
2435
2480
  // Google Chrome, Firefox, probably more browsers
2436
2481
  await s.createWritable()
2437
2482
  ) : (
@@ -2439,43 +2484,43 @@ async function O(i, e, t, r) {
2439
2484
  await s.createSyncAccessHandle()
2440
2485
  );
2441
2486
  try {
2442
- await _.truncate(0), await _.write(n);
2487
+ await a.truncate(0), await a.write(n);
2443
2488
  } finally {
2444
- await _.close();
2489
+ await a.close();
2445
2490
  }
2446
2491
  }
2447
- function it(i, e, t) {
2448
- const r = [], n = Ke(i, t, (a) => {
2449
- r.push(a);
2450
- }), s = new _t(i, e, t);
2451
- async function _() {
2492
+ function ot(i, e, t) {
2493
+ const r = [], n = Ie(i, t, (_) => {
2494
+ r.push(_);
2495
+ }), s = new ct(i, e, t);
2496
+ async function a() {
2452
2497
  if (r.length === 0)
2453
2498
  return;
2454
- const a = await i.semaphore.acquire(), c = [...r];
2455
- r.splice(0, c.length);
2456
- const S = Ie(c);
2499
+ const _ = await i.semaphore.acquire(), S = [...r];
2500
+ r.splice(0, S.length);
2501
+ const c = Ke(S);
2457
2502
  try {
2458
- for (const A of S)
2459
- await s.processEntry(A);
2503
+ for (const h of c)
2504
+ await s.processEntry(h);
2460
2505
  } finally {
2461
- a();
2506
+ _();
2462
2507
  }
2463
2508
  }
2464
- return i.addEventListener("request.end", _), i.addEventListener("filesystem.write", _), function() {
2465
- n(), i.removeEventListener("request.end", _), i.removeEventListener("filesystem.write", _);
2509
+ return i.addEventListener("request.end", a), i.addEventListener("filesystem.write", a), function() {
2510
+ n(), i.removeEventListener("request.end", a), i.removeEventListener("filesystem.write", a);
2466
2511
  };
2467
2512
  }
2468
- class _t {
2513
+ class ct {
2469
2514
  constructor(e, t, r) {
2470
- this.php = e, this.opfs = t, this.memfsRoot = re(r);
2515
+ this.php = e, this.opfs = t, this.memfsRoot = se(r);
2471
2516
  }
2472
2517
  toOpfsPath(e) {
2473
- return re(e.substring(this.memfsRoot.length));
2518
+ return se(e.substring(this.memfsRoot.length));
2474
2519
  }
2475
2520
  async processEntry(e) {
2476
2521
  if (!e.path.startsWith(this.memfsRoot) || e.path === this.memfsRoot)
2477
2522
  return;
2478
- const t = this.toOpfsPath(e.path), r = await ne(this.opfs, t), n = at(t);
2523
+ const t = this.toOpfsPath(e.path), r = await ie(this.opfs, t), n = St(t);
2479
2524
  if (n)
2480
2525
  try {
2481
2526
  if (e.operation === "DELETE")
@@ -2492,27 +2537,27 @@ class _t {
2492
2537
  create: !0
2493
2538
  });
2494
2539
  else if (e.operation === "WRITE")
2495
- await O(
2540
+ await F(
2496
2541
  r,
2497
2542
  n,
2498
2543
  this.php[k].FS,
2499
2544
  e.path
2500
2545
  );
2501
2546
  else if (e.operation === "RENAME" && e.toPath.startsWith(this.memfsRoot)) {
2502
- const s = this.toOpfsPath(e.toPath), _ = await ne(
2547
+ const s = this.toOpfsPath(e.toPath), a = await ie(
2503
2548
  this.opfs,
2504
2549
  s
2505
2550
  );
2506
2551
  if (e.nodeType === "directory") {
2507
- const a = await _.getDirectoryHandle(
2552
+ const _ = await a.getDirectoryHandle(
2508
2553
  n,
2509
2554
  {
2510
2555
  create: !0
2511
2556
  }
2512
2557
  );
2513
- await le(
2558
+ await He(
2514
2559
  this.php[k].FS,
2515
- a,
2560
+ _,
2516
2561
  e.toPath
2517
2562
  ), await r.removeEntry(n, {
2518
2563
  recursive: !0
@@ -2522,8 +2567,8 @@ class _t {
2522
2567
  await r.removeEntry(n);
2523
2568
  } catch {
2524
2569
  }
2525
- await O(
2526
- _,
2570
+ await F(
2571
+ a,
2527
2572
  ye(s),
2528
2573
  this.php[k].FS,
2529
2574
  e.toPath
@@ -2531,52 +2576,53 @@ class _t {
2531
2576
  }
2532
2577
  }
2533
2578
  } catch (s) {
2534
- throw U.log({ entry: e, name: n }), U.error(s), s;
2579
+ throw M.log({ entry: e, name: n }), M.error(s), s;
2535
2580
  }
2536
2581
  }
2537
2582
  }
2538
- function re(i) {
2583
+ function se(i) {
2539
2584
  return i.replace(/\/$/, "").replace(/\/\/+/g, "/");
2540
2585
  }
2541
- function at(i) {
2586
+ function St(i) {
2542
2587
  return i.substring(i.lastIndexOf("/") + 1);
2543
2588
  }
2544
- async function ne(i, e) {
2589
+ async function ie(i, e) {
2545
2590
  const t = e.replace(/^\/+|\/+$/g, "").replace(/\/+/, "/");
2546
2591
  if (!t)
2547
2592
  return i;
2548
2593
  const r = t.split("/");
2549
2594
  let n = i;
2550
2595
  for (let s = 0; s < r.length - 1; s++) {
2551
- const _ = r[s];
2552
- n = await n.getDirectoryHandle(_, { create: !0 });
2596
+ const a = r[s];
2597
+ n = await n.getDirectoryHandle(a, { create: !0 });
2553
2598
  }
2554
2599
  return n;
2555
2600
  }
2556
- function ot(i, e) {
2601
+ function Ct(i, e) {
2557
2602
  let t = 0, r, n;
2558
- return function(..._) {
2559
- n = _;
2560
- const a = Date.now() - t;
2603
+ return function(...a) {
2604
+ n = a;
2605
+ const _ = Date.now() - t;
2561
2606
  if (r === void 0) {
2562
- const c = Math.max(0, e - a);
2607
+ const S = Math.max(0, e - _);
2563
2608
  r = setTimeout(() => {
2564
2609
  r = void 0, t = Date.now(), i(...n);
2565
- }, c);
2610
+ }, S);
2566
2611
  }
2567
2612
  };
2568
2613
  }
2569
2614
  export {
2570
- Ht as certificateToPEM,
2571
- mt as consumeAPI,
2572
- wt as createDirectoryHandleMountHandler,
2573
- gt as exposeAPI,
2574
- ze as fetchWithCorsProxy,
2615
+ ze as FirewallInterferenceError,
2616
+ Tt as certificateToPEM,
2617
+ Kt as consumeAPI,
2618
+ mt as createDirectoryHandleMountHandler,
2619
+ Dt as exposeAPI,
2620
+ Xe as fetchWithCorsProxy,
2575
2621
  je as generateCertificate,
2576
2622
  De as getPHPLoaderModule,
2577
- Et as loadWebRuntime,
2578
- dt as privateKeyToPEM,
2579
- ft as setupPostMessageRelay,
2580
- pt as spawnPHPWorkerThread
2623
+ wt as loadWebRuntime,
2624
+ ft as privateKeyToPEM,
2625
+ Lt as setupPostMessageRelay,
2626
+ yt as spawnPHPWorkerThread
2581
2627
  };
2582
2628
  //# sourceMappingURL=index.js.map