@php-wasm/web 3.0.18 → 3.0.20

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,7 +1,7 @@
1
1
  import { LatestSupportedPHPVersion as fe, FSHelpers as W, loadPHPRuntime as pe, __private__dont__use as k } from "@php-wasm/universal";
2
2
  import { consumeAPI as mt, exposeAPI as gt } from "@php-wasm/universal";
3
3
  import { jspi as we } from "wasm-feature-detect";
4
- import { concatArrayBuffers as B, concatUint8Arrays as u, Semaphore as Le, joinPaths as ie, basename as ye } from "@php-wasm/util";
4
+ import { concatArrayBuffers as B, concatUint8Arrays as u, Semaphore as Le, joinPaths as se, basename as ye } from "@php-wasm/util";
5
5
  import { logger as U } from "@php-wasm/logger";
6
6
  import { teeRequest as me, cloneRequest as ge } from "@php-wasm/web-service-worker";
7
7
  import { journalFSEvents as Ke, normalizeFilesystemOperations as Ie } from "@php-wasm/fs-journal";
@@ -59,7 +59,7 @@ function w(i) {
59
59
  i & 255
60
60
  ]);
61
61
  }
62
- function $(i) {
62
+ function G(i) {
63
63
  const e = new ArrayBuffer(8);
64
64
  return new DataView(e).setBigUint64(0, BigInt(i), !1), new Uint8Array(e);
65
65
  }
@@ -158,10 +158,10 @@ const b = {
158
158
  key_share: 51,
159
159
  transparency_info: 52,
160
160
  connection_id: 54
161
- }, We = f(b), _e = {
161
+ }, We = f(b), ie = {
162
162
  host_name: 0
163
- }, be = f(_e);
164
- class ae {
163
+ }, be = f(ie);
164
+ class _e {
165
165
  static decodeFromClient(e) {
166
166
  const t = new DataView(e.buffer);
167
167
  let r = 0;
@@ -175,7 +175,7 @@ class ae {
175
175
  r += 2;
176
176
  const c = e.slice(r, r + a);
177
177
  switch (r += a, _) {
178
- case _e.host_name:
178
+ case ie.host_name:
179
179
  s.push({
180
180
  name_type: be[_],
181
181
  name: {
@@ -209,7 +209,7 @@ class ae {
209
209
  return t.writeUint16(b.server_name), t.writeUint16(0), t.uint8Array;
210
210
  }
211
211
  }
212
- const oe = {
212
+ const ae = {
213
213
  TLS1_CK_PSK_WITH_RC4_128_SHA: 138,
214
214
  TLS1_CK_PSK_WITH_3DES_EDE_CBC_SHA: 139,
215
215
  TLS1_CK_PSK_WITH_AES_128_CBC_SHA: 140,
@@ -412,13 +412,13 @@ const oe = {
412
412
  TLS1_CK_ECDHE_PSK_WITH_CHACHA20_POLY1305: 52396,
413
413
  TLS1_CK_DHE_PSK_WITH_CHACHA20_POLY1305: 52397,
414
414
  TLS1_CK_RSA_PSK_WITH_CHACHA20_POLY1305: 52398
415
- }, V = f(oe), ce = {
415
+ }, $ = f(ae), oe = {
416
416
  secp256r1: 23,
417
417
  secp384r1: 24,
418
418
  secp521r1: 25,
419
419
  x25519: 29,
420
420
  x448: 30
421
- }, z = f(ce);
421
+ }, V = f(oe);
422
422
  class Re {
423
423
  /**
424
424
  * +--------------------------------------------------+
@@ -441,7 +441,7 @@ class Re {
441
441
  const r = [];
442
442
  for (; !t.isFinished(); ) {
443
443
  const n = t.readUint16();
444
- n in z && r.push(z[n]);
444
+ n in V && r.push(V[n]);
445
445
  }
446
446
  return r;
447
447
  }
@@ -457,14 +457,14 @@ class Re {
457
457
  */
458
458
  static encodeForClient(e) {
459
459
  const t = new v(6);
460
- return t.writeUint16(b.supported_groups), t.writeUint16(2), t.writeUint16(ce[e]), t.uint8Array;
460
+ return t.writeUint16(b.supported_groups), t.writeUint16(2), t.writeUint16(oe[e]), t.uint8Array;
461
461
  }
462
462
  }
463
- const Se = {
463
+ const ce = {
464
464
  uncompressed: 0,
465
465
  ansiX962_compressed_prime: 1,
466
466
  ansiX962_compressed_char2: 2
467
- }, Y = f(Se);
467
+ }, z = f(ce);
468
468
  class Be {
469
469
  /**
470
470
  * +--------------------------------------------------+
@@ -485,7 +485,7 @@ class Be {
485
485
  const t = new y(e.buffer), r = t.readUint8(), n = [];
486
486
  for (let s = 0; s < r; s++) {
487
487
  const _ = t.readUint8();
488
- _ in Y && n.push(Y[_]);
488
+ _ in z && n.push(z[_]);
489
489
  }
490
490
  return n;
491
491
  }
@@ -505,7 +505,7 @@ class Be {
505
505
  */
506
506
  static encodeForClient(e) {
507
507
  const t = new v(6);
508
- return t.writeUint16(b.ec_point_formats), t.writeUint16(2), t.writeUint8(1), t.writeUint8(Se[e]), t.uint8Array;
508
+ return t.writeUint16(b.ec_point_formats), t.writeUint16(2), t.writeUint8(1), t.writeUint8(ce[e]), t.uint8Array;
509
509
  }
510
510
  }
511
511
  const F = {
@@ -513,7 +513,7 @@ const F = {
513
513
  rsa: 1,
514
514
  dsa: 2,
515
515
  ecdsa: 3
516
- }, Z = f(F), j = {
516
+ }, Y = f(F), j = {
517
517
  none: 0,
518
518
  md5: 1,
519
519
  sha1: 2,
@@ -521,7 +521,7 @@ const F = {
521
521
  sha256: 4,
522
522
  sha384: 5,
523
523
  sha512: 6
524
- }, J = f(j);
524
+ }, Z = f(j);
525
525
  class Pe {
526
526
  /**
527
527
  * Binary layout:
@@ -544,14 +544,14 @@ class Pe {
544
544
  const r = [];
545
545
  for (; !t.isFinished(); ) {
546
546
  const n = t.readUint8(), s = t.readUint8();
547
- if (Z[s]) {
548
- if (!J[n]) {
547
+ if (Y[s]) {
548
+ if (!Z[n]) {
549
549
  U.warn(`Unknown hash algorithm: ${n}`);
550
550
  continue;
551
551
  }
552
552
  r.push({
553
- algorithm: Z[s],
554
- hash: J[n]
553
+ algorithm: Y[s],
554
+ hash: Z[n]
555
555
  });
556
556
  }
557
557
  }
@@ -573,8 +573,8 @@ class Pe {
573
573
  return r.writeUint16(b.signature_algorithms), r.writeUint16(2), r.writeUint8(j[e]), r.writeUint8(F[t]), r.uint8Array;
574
574
  }
575
575
  }
576
- const X = {
577
- server_name: ae,
576
+ const J = {
577
+ server_name: _e,
578
578
  signature_algorithms: Pe,
579
579
  supported_groups: Re,
580
580
  ec_point_formats: Be
@@ -583,9 +583,9 @@ function Ue(i) {
583
583
  const e = new y(i.buffer), t = [];
584
584
  for (; !e.isFinished(); ) {
585
585
  const r = e.offset, n = e.readUint16(), s = We[n], _ = e.readUint16(), a = e.readUint8Array(_);
586
- if (!(s in X))
586
+ if (!(s in J))
587
587
  continue;
588
- const c = X[s];
588
+ const c = J[s];
589
589
  t.push({
590
590
  type: s,
591
591
  data: c.decodeFromClient(a),
@@ -605,13 +605,13 @@ async function q(i, e, t, r) {
605
605
  let _ = n;
606
606
  const a = [];
607
607
  for (; B(a).byteLength < r; ) {
608
- _ = await Q(s, _);
609
- const S = B([_, n]), A = await Q(s, S);
608
+ _ = await X(s, _);
609
+ const S = B([_, n]), A = await X(s, S);
610
610
  a.push(A);
611
611
  }
612
612
  return B(a).slice(0, r);
613
613
  }
614
- async function Q(i, e) {
614
+ async function X(i, e) {
615
615
  return await crypto.subtle.sign(
616
616
  { name: "HMAC", hash: "SHA-256" },
617
617
  i,
@@ -623,7 +623,7 @@ const ve = {
623
623
  }, Me = {
624
624
  Warning: 1,
625
625
  Fatal: 2
626
- }, Ce = f(Me), Ne = {
626
+ }, Se = f(Me), Ne = {
627
627
  CloseNotify: 0,
628
628
  UnexpectedMessage: 10,
629
629
  BadRecordMac: 20,
@@ -649,7 +649,7 @@ const ve = {
649
649
  UserCanceled: 90,
650
650
  NoRenegotiation: 100,
651
651
  UnsupportedExtension: 110
652
- }, Ae = f(Ne), C = {
652
+ }, Ce = f(Ne), C = {
653
653
  ChangeCipherSpec: 20,
654
654
  Alert: 21,
655
655
  Handshake: 22,
@@ -675,7 +675,7 @@ const ve = {
675
675
  }, ke = {
676
676
  secp256r1: 23
677
677
  };
678
- class ee extends Error {
678
+ class Q extends Error {
679
679
  }
680
680
  const P = new Uint8Array([3, 3]), qe = crypto.subtle.generateKey(
681
681
  {
@@ -903,7 +903,7 @@ class Oe {
903
903
  fragment: this.sessionKeys && n !== C.ChangeCipherSpec ? await this.decryptData(n, s) : s
904
904
  };
905
905
  if (_.type === C.Alert) {
906
- const a = Ce[_.fragment[0]], c = Ae[_.fragment[1]];
906
+ const a = Se[_.fragment[0]], c = Ce[_.fragment[1]];
907
907
  throw new Error(
908
908
  `TLS non-warning alert received: ${a} ${c}`
909
909
  );
@@ -919,7 +919,7 @@ class Oe {
919
919
  for (; this.receivedBytesBuffer.length < e; ) {
920
920
  const { value: r, done: n } = await this.clientUpstreamReader.read();
921
921
  if (n)
922
- throw await this.close(), new ee("TLS connection closed");
922
+ throw await this.close(), new Q("TLS connection closed");
923
923
  if (this.receivedBytesBuffer = u([
924
924
  this.receivedBytesBuffer,
925
925
  r
@@ -943,7 +943,7 @@ class Oe {
943
943
  this.serverUpstreamWriter.write(e.body);
944
944
  }
945
945
  } catch (e) {
946
- if (e instanceof ee)
946
+ if (e instanceof Q)
947
947
  return;
948
948
  throw e;
949
949
  }
@@ -958,7 +958,7 @@ class Oe {
958
958
  name: "AES-GCM",
959
959
  iv: s,
960
960
  additionalData: new Uint8Array([
961
- ...$(this.receivedRecordSequenceNumber),
961
+ ...G(this.receivedRecordSequenceNumber),
962
962
  e,
963
963
  ...P,
964
964
  // Payload length without IV and tag
@@ -1020,7 +1020,7 @@ class Oe {
1020
1020
  */
1021
1021
  async encryptData(e, t) {
1022
1022
  const r = this.sessionKeys.serverIV, n = crypto.getRandomValues(new Uint8Array(8)), s = new Uint8Array([...r, ...n]), _ = new Uint8Array([
1023
- ...$(this.sentRecordSequenceNumber),
1023
+ ...G(this.sentRecordSequenceNumber),
1024
1024
  e,
1025
1025
  ...P,
1026
1026
  // Payload length without IV and tag
@@ -1085,7 +1085,7 @@ class E {
1085
1085
  const r = [];
1086
1086
  for (; !t.isFinished(); ) {
1087
1087
  const n = t.readUint16();
1088
- n in V && r.push(V[n]);
1088
+ n in $ && r.push($[n]);
1089
1089
  }
1090
1090
  return r;
1091
1091
  }
@@ -1104,8 +1104,8 @@ class E {
1104
1104
  static alert(e) {
1105
1105
  return {
1106
1106
  type: C.Alert,
1107
- level: Ce[e[0]],
1108
- description: Ae[e[1]]
1107
+ level: Se[e[0]],
1108
+ description: Ce[e[1]]
1109
1109
  };
1110
1110
  }
1111
1111
  static clientHandshake(e) {
@@ -1354,7 +1354,7 @@ class g {
1354
1354
  const n = e.extensions.map((a) => {
1355
1355
  switch (a.type) {
1356
1356
  case "server_name":
1357
- return ae.encodeForClient();
1357
+ return _e.encodeForClient();
1358
1358
  }
1359
1359
  }).filter((a) => a !== void 0), s = u(n), _ = new Uint8Array([
1360
1360
  // Version field – 0x03, 0x03 means TLS 1.2
@@ -1362,7 +1362,7 @@ class g {
1362
1362
  ...t,
1363
1363
  e.session_id.length,
1364
1364
  ...e.session_id,
1365
- ...K(oe.TLS1_CK_ECDHE_RSA_WITH_AES_128_GCM_SHA256),
1365
+ ...K(ae.TLS1_CK_ECDHE_RSA_WITH_AES_128_GCM_SHA256),
1366
1366
  r,
1367
1367
  // Extensions length (2 bytes)
1368
1368
  ...K(s.length),
@@ -1423,16 +1423,16 @@ function je(i, e) {
1423
1423
  }
1424
1424
  function Ht(i) {
1425
1425
  return `-----BEGIN CERTIFICATE-----
1426
- ${le(
1427
- he(i.buffer)
1426
+ ${he(
1427
+ Ae(i.buffer)
1428
1428
  )}
1429
1429
  -----END CERTIFICATE-----`;
1430
1430
  }
1431
1431
  async function dt(i) {
1432
1432
  const e = await crypto.subtle.exportKey("pkcs8", i);
1433
1433
  return `-----BEGIN PRIVATE KEY-----
1434
- ${le(
1435
- he(e)
1434
+ ${he(
1435
+ Ae(e)
1436
1436
  )}
1437
1437
  -----END PRIVATE KEY-----`;
1438
1438
  }
@@ -1535,13 +1535,13 @@ class Ge {
1535
1535
  o.ASN1(
1536
1536
  d.UTCTime,
1537
1537
  new TextEncoder().encode(
1538
- re((e == null ? void 0 : e.notBefore) ?? /* @__PURE__ */ new Date())
1538
+ te((e == null ? void 0 : e.notBefore) ?? /* @__PURE__ */ new Date())
1539
1539
  )
1540
1540
  ),
1541
1541
  o.ASN1(
1542
1542
  d.UTCTime,
1543
1543
  new TextEncoder().encode(
1544
- re(
1544
+ te(
1545
1545
  (e == null ? void 0 : e.notAfter) ?? Ve(/* @__PURE__ */ new Date(), 10)
1546
1546
  )
1547
1547
  )
@@ -1724,7 +1724,7 @@ function p(i) {
1724
1724
  return e;
1725
1725
  throw new Error(`OID not found for name: ${i}`);
1726
1726
  }
1727
- const te = 32, d = {
1727
+ const ee = 32, d = {
1728
1728
  Boolean: 1,
1729
1729
  Integer: 2,
1730
1730
  BitString: 3,
@@ -1732,8 +1732,8 @@ const te = 32, d = {
1732
1732
  Null: 5,
1733
1733
  OID: 6,
1734
1734
  Utf8String: 12,
1735
- Sequence: 16 | te,
1736
- Set: 17 | te,
1735
+ Sequence: 16 | ee,
1736
+ Set: 17 | ee,
1737
1737
  PrintableString: 19,
1738
1738
  IA5String: 22,
1739
1739
  UTCTime: 23
@@ -1819,15 +1819,15 @@ class o {
1819
1819
  );
1820
1820
  }
1821
1821
  }
1822
- function he(i) {
1822
+ function Ae(i) {
1823
1823
  return btoa(String.fromCodePoint(...new Uint8Array(i)));
1824
1824
  }
1825
- function le(i) {
1825
+ function he(i) {
1826
1826
  var e;
1827
1827
  return ((e = i.match(/.{1,64}/g)) == null ? void 0 : e.join(`
1828
1828
  `)) || i;
1829
1829
  }
1830
- function re(i) {
1830
+ function te(i) {
1831
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
1832
  return `${e}${t}${r}${n}${s}${_}Z`;
1833
1833
  }
@@ -2205,8 +2205,8 @@ Content-Length: 0\r
2205
2205
  new Ye()
2206
2206
  ));
2207
2207
  }
2208
- const M = S.headers.get("Host") ?? t, G = new URL(S.path, r + "://" + M);
2209
- return G.pathname = S.path, new Request(G.toString(), {
2208
+ const M = S.headers.get("Host") ?? t, ue = new URL(S.path, r + "://" + M);
2209
+ return new Request(ue.toString(), {
2210
2210
  method: S.method,
2211
2211
  headers: S.headers,
2212
2212
  body: H,
@@ -2324,7 +2324,7 @@ function wt(i, e = { initialSync: {} }) {
2324
2324
  direction: e.initialSync.direction ?? "opfs-to-memfs"
2325
2325
  }
2326
2326
  }, 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 ue(
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(
2328
2328
  r,
2329
2329
  i,
2330
2330
  n,
@@ -2343,7 +2343,7 @@ async function nt(i, e, t) {
2343
2343
  const [_, a] = s.pop();
2344
2344
  for await (const c of _.values()) {
2345
2345
  const S = r.run(async () => {
2346
- const A = ie(
2346
+ const A = se(
2347
2347
  a,
2348
2348
  c.name
2349
2349
  );
@@ -2374,7 +2374,7 @@ async function nt(i, e, t) {
2374
2374
  await Promise.any(n);
2375
2375
  }
2376
2376
  }
2377
- async function ue(i, e, t, r) {
2377
+ async function le(i, e, t, r) {
2378
2378
  i.mkdirTree(t);
2379
2379
  const n = [];
2380
2380
  async function s(A, h) {
@@ -2382,7 +2382,7 @@ async function ue(i, e, t, r) {
2382
2382
  i.readdir(A).filter(
2383
2383
  (l) => l !== "." && l !== ".."
2384
2384
  ).map(async (l) => {
2385
- const H = ie(A, l);
2385
+ const H = se(A, l);
2386
2386
  if (!st(i, H)) {
2387
2387
  n.push([h, H, l]);
2388
2388
  return;
@@ -2467,15 +2467,15 @@ function it(i, e, t) {
2467
2467
  }
2468
2468
  class _t {
2469
2469
  constructor(e, t, r) {
2470
- this.php = e, this.opfs = t, this.memfsRoot = ne(r);
2470
+ this.php = e, this.opfs = t, this.memfsRoot = re(r);
2471
2471
  }
2472
2472
  toOpfsPath(e) {
2473
- return ne(e.substring(this.memfsRoot.length));
2473
+ return re(e.substring(this.memfsRoot.length));
2474
2474
  }
2475
2475
  async processEntry(e) {
2476
2476
  if (!e.path.startsWith(this.memfsRoot) || e.path === this.memfsRoot)
2477
2477
  return;
2478
- const t = this.toOpfsPath(e.path), r = await se(this.opfs, t), n = at(t);
2478
+ const t = this.toOpfsPath(e.path), r = await ne(this.opfs, t), n = at(t);
2479
2479
  if (n)
2480
2480
  try {
2481
2481
  if (e.operation === "DELETE")
@@ -2499,7 +2499,7 @@ class _t {
2499
2499
  e.path
2500
2500
  );
2501
2501
  else if (e.operation === "RENAME" && e.toPath.startsWith(this.memfsRoot)) {
2502
- const s = this.toOpfsPath(e.toPath), _ = await se(
2502
+ const s = this.toOpfsPath(e.toPath), _ = await ne(
2503
2503
  this.opfs,
2504
2504
  s
2505
2505
  );
@@ -2510,7 +2510,7 @@ class _t {
2510
2510
  create: !0
2511
2511
  }
2512
2512
  );
2513
- await ue(
2513
+ await le(
2514
2514
  this.php[k].FS,
2515
2515
  a,
2516
2516
  e.toPath
@@ -2535,13 +2535,13 @@ class _t {
2535
2535
  }
2536
2536
  }
2537
2537
  }
2538
- function ne(i) {
2538
+ function re(i) {
2539
2539
  return i.replace(/\/$/, "").replace(/\/\/+/g, "/");
2540
2540
  }
2541
2541
  function at(i) {
2542
2542
  return i.substring(i.lastIndexOf("/") + 1);
2543
2543
  }
2544
- async function se(i, e) {
2544
+ async function ne(i, e) {
2545
2545
  const t = e.replace(/^\/+|\/+$/g, "").replace(/\/+/, "/");
2546
2546
  if (!t)
2547
2547
  return i;