@php-wasm/web 1.1.4 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/index.cjs +11 -11
  2. package/index.cjs.map +1 -1
  3. package/index.js +85 -79
  4. package/index.js.map +1 -1
  5. package/lib/fetch-with-cors-proxy.d.ts +1 -1
  6. package/package.json +7 -7
  7. package/php/asyncify/7_2_34/php_7_2.wasm +0 -0
  8. package/php/asyncify/7_3_33/php_7_3.wasm +0 -0
  9. package/php/asyncify/7_4_33/php_7_4.wasm +0 -0
  10. package/php/asyncify/8_0_30/php_8_0.wasm +0 -0
  11. package/php/asyncify/8_1_23/php_8_1.wasm +0 -0
  12. package/php/asyncify/8_2_10/php_8_2.wasm +0 -0
  13. package/php/asyncify/8_3_0/php_8_3.wasm +0 -0
  14. package/php/asyncify/8_4_0/php_8_4.wasm +0 -0
  15. package/php/asyncify/php_7_0.js +1 -1
  16. package/php/asyncify/php_7_1.js +1 -1
  17. package/php/asyncify/php_7_2.js +34 -8
  18. package/php/asyncify/php_7_3.js +34 -8
  19. package/php/asyncify/php_7_4.js +34 -8
  20. package/php/asyncify/php_8_0.js +34 -8
  21. package/php/asyncify/php_8_1.js +35 -9
  22. package/php/asyncify/php_8_2.js +34 -8
  23. package/php/asyncify/php_8_3.js +34 -8
  24. package/php/asyncify/php_8_4.js +34 -8
  25. package/php/jspi/7_2_34/php_7_2.wasm +0 -0
  26. package/php/jspi/7_3_33/php_7_3.wasm +0 -0
  27. package/php/jspi/7_4_33/php_7_4.wasm +0 -0
  28. package/php/jspi/8_0_30/php_8_0.wasm +0 -0
  29. package/php/jspi/8_1_23/php_8_1.wasm +0 -0
  30. package/php/jspi/8_2_10/php_8_2.wasm +0 -0
  31. package/php/jspi/8_3_0/php_8_3.wasm +0 -0
  32. package/php/jspi/8_4_0/php_8_4.wasm +0 -0
  33. package/php/jspi/php_7_0.js +1 -1
  34. package/php/jspi/php_7_1.js +1 -1
  35. package/php/jspi/php_7_2.js +35 -9
  36. package/php/jspi/php_7_3.js +35 -9
  37. package/php/jspi/php_7_4.js +35 -9
  38. package/php/jspi/php_8_0.js +33 -7
  39. package/php/jspi/php_8_1.js +33 -7
  40. package/php/jspi/php_8_2.js +33 -7
  41. package/php/jspi/php_8_3.js +33 -7
  42. package/php/jspi/php_8_4.js +33 -7
package/index.js CHANGED
@@ -606,8 +606,8 @@ async function q(i, e, t, r) {
606
606
  const a = [];
607
607
  for (; B(a).byteLength < r; ) {
608
608
  _ = await Q(s, _);
609
- const S = B([_, n]), A = await Q(s, S);
610
- a.push(A);
609
+ const S = B([_, n]), h = await Q(s, S);
610
+ a.push(h);
611
611
  }
612
612
  return B(a).slice(0, r);
613
613
  }
@@ -649,12 +649,12 @@ const ve = {
649
649
  UserCanceled: 90,
650
650
  NoRenegotiation: 100,
651
651
  UnsupportedExtension: 110
652
- }, Ae = f(Ne), C = {
652
+ }, he = f(Ne), C = {
653
653
  ChangeCipherSpec: 20,
654
654
  Alert: 21,
655
655
  Handshake: 22,
656
656
  ApplicationData: 23
657
- }, d = {
657
+ }, T = {
658
658
  HelloRequest: 0,
659
659
  ClientHello: 1,
660
660
  ServerHello: 2,
@@ -762,7 +762,7 @@ class Oe {
762
762
  */
763
763
  async TLSHandshake(e, t) {
764
764
  const r = await this.readNextHandshakeMessage(
765
- d.ClientHello
765
+ T.ClientHello
766
766
  );
767
767
  if (!r.body.cipher_suites.length)
768
768
  throw new Error(
@@ -791,7 +791,7 @@ class Oe {
791
791
  g.serverHelloDone()
792
792
  );
793
793
  const c = await this.readNextHandshakeMessage(
794
- d.ClientKeyExchange
794
+ T.ClientKeyExchange
795
795
  );
796
796
  await this.readNextMessage(C.ChangeCipherSpec), this.sessionKeys = await this.deriveSessionKeys({
797
797
  clientRandom: _,
@@ -804,7 +804,7 @@ class Oe {
804
804
  !1,
805
805
  []
806
806
  )
807
- }), await this.readNextHandshakeMessage(d.Finished), await this.writeTLSRecord(
807
+ }), await this.readNextHandshakeMessage(T.Finished), await this.writeTLSRecord(
808
808
  C.ChangeCipherSpec,
809
809
  g.changeCipherSpec()
810
810
  ), await this.writeTLSRecord(
@@ -846,7 +846,7 @@ class Oe {
846
846
  u([t, e]),
847
847
  // Client key, server key, client IV, server IV
848
848
  40
849
- ), c = new y(a), S = c.readUint8Array(16), A = c.readUint8Array(16), h = c.readUint8Array(4), l = c.readUint8Array(4);
849
+ ), c = new y(a), S = c.readUint8Array(16), h = c.readUint8Array(16), A = c.readUint8Array(4), l = c.readUint8Array(4);
850
850
  return {
851
851
  masterSecret: _,
852
852
  clientWriteKey: await crypto.subtle.importKey(
@@ -858,12 +858,12 @@ class Oe {
858
858
  ),
859
859
  serverWriteKey: await crypto.subtle.importKey(
860
860
  "raw",
861
- A,
861
+ h,
862
862
  { name: "AES-GCM" },
863
863
  !1,
864
864
  ["encrypt", "decrypt"]
865
865
  ),
866
- clientIV: h,
866
+ clientIV: A,
867
867
  serverIV: l
868
868
  };
869
869
  }
@@ -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 = Ce[_.fragment[0]], c = he[_.fragment[1]];
907
907
  throw new Error(
908
908
  `TLS non-warning alert received: ${a} ${c}`
909
909
  );
@@ -1105,23 +1105,23 @@ class E {
1105
1105
  return {
1106
1106
  type: C.Alert,
1107
1107
  level: Ce[e[0]],
1108
- description: Ae[e[1]]
1108
+ description: he[e[1]]
1109
1109
  };
1110
1110
  }
1111
1111
  static clientHandshake(e) {
1112
1112
  const t = e[0], r = e[1] << 16 | e[2] << 8 | e[3], n = e.slice(4);
1113
1113
  let s;
1114
1114
  switch (t) {
1115
- case d.HelloRequest:
1115
+ case T.HelloRequest:
1116
1116
  s = E.clientHelloRequestPayload();
1117
1117
  break;
1118
- case d.ClientHello:
1118
+ case T.ClientHello:
1119
1119
  s = E.clientHelloPayload(n);
1120
1120
  break;
1121
- case d.ClientKeyExchange:
1121
+ case T.ClientKeyExchange:
1122
1122
  s = E.clientKeyExchangePayload(n);
1123
1123
  break;
1124
- case d.Finished:
1124
+ case T.Finished:
1125
1125
  s = E.clientFinishedPayload(n);
1126
1126
  break;
1127
1127
  default:
@@ -1240,7 +1240,7 @@ class g {
1240
1240
  ...r
1241
1241
  ]);
1242
1242
  return new Uint8Array([
1243
- d.Certificate,
1243
+ T.Certificate,
1244
1244
  ...w(n.length),
1245
1245
  ...n
1246
1246
  ]);
@@ -1300,16 +1300,16 @@ class g {
1300
1300
  ), c = new Uint8Array(a), S = new Uint8Array([
1301
1301
  j.sha256,
1302
1302
  F.rsa
1303
- ]), A = new Uint8Array([
1303
+ ]), h = new Uint8Array([
1304
1304
  ..._,
1305
1305
  ...S,
1306
1306
  ...K(c.length),
1307
1307
  ...c
1308
1308
  ]);
1309
1309
  return new Uint8Array([
1310
- d.ServerKeyExchange,
1311
- ...w(A.length),
1312
- ...A
1310
+ T.ServerKeyExchange,
1311
+ ...w(h.length),
1312
+ ...h
1313
1313
  ]);
1314
1314
  }
1315
1315
  /**
@@ -1369,13 +1369,13 @@ class g {
1369
1369
  ...s
1370
1370
  ]);
1371
1371
  return new Uint8Array([
1372
- d.ServerHello,
1372
+ T.ServerHello,
1373
1373
  ...w(_.length),
1374
1374
  ..._
1375
1375
  ]);
1376
1376
  }
1377
1377
  static serverHelloDone() {
1378
- return new Uint8Array([d.ServerHelloDone, ...w(0)]);
1378
+ return new Uint8Array([T.ServerHelloDone, ...w(0)]);
1379
1379
  }
1380
1380
  /**
1381
1381
  * Server finished message.
@@ -1409,7 +1409,7 @@ class g {
1409
1409
  )
1410
1410
  );
1411
1411
  return new Uint8Array([
1412
- d.Finished,
1412
+ T.Finished,
1413
1413
  ...w(n.length),
1414
1414
  ...n
1415
1415
  ]);
@@ -1424,7 +1424,7 @@ function je(i, e) {
1424
1424
  function Ht(i) {
1425
1425
  return `-----BEGIN CERTIFICATE-----
1426
1426
  ${le(
1427
- he(i.buffer)
1427
+ Ae(i.buffer)
1428
1428
  )}
1429
1429
  -----END CERTIFICATE-----`;
1430
1430
  }
@@ -1432,7 +1432,7 @@ async function dt(i) {
1432
1432
  const e = await crypto.subtle.exportKey("pkcs8", i);
1433
1433
  return `-----BEGIN PRIVATE KEY-----
1434
1434
  ${le(
1435
- he(e)
1435
+ Ae(e)
1436
1436
  )}
1437
1437
  -----END PRIVATE KEY-----`;
1438
1438
  }
@@ -1533,13 +1533,13 @@ class Ge {
1533
1533
  static validity(e) {
1534
1534
  return o.sequence([
1535
1535
  o.ASN1(
1536
- H.UTCTime,
1536
+ d.UTCTime,
1537
1537
  new TextEncoder().encode(
1538
1538
  re((e == null ? void 0 : e.notBefore) ?? /* @__PURE__ */ new Date())
1539
1539
  )
1540
1540
  ),
1541
1541
  o.ASN1(
1542
- H.UTCTime,
1542
+ d.UTCTime,
1543
1543
  new TextEncoder().encode(
1544
1544
  re(
1545
1545
  (e == null ? void 0 : e.notAfter) ?? Ve(/* @__PURE__ */ new Date(), 10)
@@ -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, H = {
1727
+ const te = 32, d = {
1728
1728
  Boolean: 1,
1729
1729
  Integer: 2,
1730
1730
  BitString: 3,
@@ -1764,17 +1764,17 @@ class o {
1764
1764
  const t = new Uint8Array(e.length + 1);
1765
1765
  t[0] = 0, t.set(e, 1), e = t;
1766
1766
  }
1767
- return o.ASN1(H.Integer, e);
1767
+ return o.ASN1(d.Integer, e);
1768
1768
  }
1769
1769
  static bitString(e) {
1770
1770
  const t = new Uint8Array([0]), r = new Uint8Array(t.length + e.length);
1771
- return r.set(t), r.set(e, t.length), o.ASN1(H.BitString, r);
1771
+ return r.set(t), r.set(e, t.length), o.ASN1(d.BitString, r);
1772
1772
  }
1773
1773
  static octetString(e) {
1774
- return o.ASN1(H.OctetString, e);
1774
+ return o.ASN1(d.OctetString, e);
1775
1775
  }
1776
1776
  static null() {
1777
- return o.ASN1(H.Null, new Uint8Array(0));
1777
+ return o.ASN1(d.Null, new Uint8Array(0));
1778
1778
  }
1779
1779
  static objectIdentifier(e) {
1780
1780
  const t = e.split(".").map(Number), n = [t[0] * 40 + t[1]];
@@ -1788,25 +1788,25 @@ class o {
1788
1788
  a[c] |= 128;
1789
1789
  n.push(...a);
1790
1790
  }
1791
- return o.ASN1(H.OID, new Uint8Array(n));
1791
+ return o.ASN1(d.OID, new Uint8Array(n));
1792
1792
  }
1793
1793
  static utf8String(e) {
1794
1794
  const t = new TextEncoder().encode(e);
1795
- return o.ASN1(H.Utf8String, t);
1795
+ return o.ASN1(d.Utf8String, t);
1796
1796
  }
1797
1797
  static printableString(e) {
1798
1798
  const t = new TextEncoder().encode(e);
1799
- return o.ASN1(H.PrintableString, t);
1799
+ return o.ASN1(d.PrintableString, t);
1800
1800
  }
1801
1801
  static sequence(e) {
1802
- return o.ASN1(H.Sequence, u(e));
1802
+ return o.ASN1(d.Sequence, u(e));
1803
1803
  }
1804
1804
  static set(e) {
1805
- return o.ASN1(H.Set, u(e));
1805
+ return o.ASN1(d.Set, u(e));
1806
1806
  }
1807
1807
  static ia5String(e) {
1808
1808
  const t = new TextEncoder().encode(e);
1809
- return o.ASN1(H.IA5String, t);
1809
+ return o.ASN1(d.IA5String, t);
1810
1810
  }
1811
1811
  static contextSpecific(e, t, r = !1) {
1812
1812
  const n = (r ? 160 : 128) | e;
@@ -1814,12 +1814,12 @@ class o {
1814
1814
  }
1815
1815
  static boolean(e) {
1816
1816
  return o.ASN1(
1817
- H.Boolean,
1817
+ d.Boolean,
1818
1818
  new Uint8Array([e ? 255 : 0])
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
1825
  function le(i) {
@@ -1838,20 +1838,26 @@ function Ve(i, e) {
1838
1838
  const t = new Date(i);
1839
1839
  return t.setUTCFullYear(t.getUTCFullYear() + e), t;
1840
1840
  }
1841
- async function ze(i, e, t) {
1842
- var _;
1843
- const r = typeof i == "string" ? new Request(i, e) : i;
1841
+ async function ze(i, e, t, r) {
1842
+ var S;
1843
+ const n = typeof i == "string" ? new Request(i, e) : i;
1844
1844
  if (!t)
1845
- return await fetch(r);
1846
- const [n, s] = await me(r);
1847
- try {
1848
1845
  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))
1851
+ return await fetch(n);
1852
+ const [a, c] = await me(n);
1853
+ try {
1854
+ return await fetch(a);
1849
1855
  } catch {
1850
- const c = ((_ = new Headers(s.headers).get("x-cors-proxy-allowed-request-headers")) == null ? void 0 : _.split(",")) || [], S = c.includes("authorization") || c.includes("cookie"), A = await ge(s, {
1851
- url: `${t}${r.url}`,
1852
- ...S && { credentials: "include" }
1856
+ const A = ((S = new Headers(c.headers).get("x-cors-proxy-allowed-request-headers")) == null ? void 0 : S.split(",")) || [], l = A.includes("authorization") || A.includes("cookie"), H = await ge(c, {
1857
+ url: `${t}${n.url}`,
1858
+ ...l && { credentials: "include" }
1853
1859
  });
1854
- return await fetch(A, e);
1860
+ return await fetch(H, e);
1855
1861
  }
1856
1862
  }
1857
1863
  class Ye extends TransformStream {
@@ -2168,18 +2174,18 @@ Content-Length: 0\r
2168
2174
  );
2169
2175
  }
2170
2176
  a.releaseLock();
2171
- 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(
2177
+ const c = n.slice(0, _), S = L.parseRequestHeaders(c), h = 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, l = n.slice(
2172
2178
  _ + 4
2173
2179
  /* Skip \r\n\r\n */
2174
2180
  );
2175
- let T;
2181
+ let H;
2176
2182
  if (S.method !== "GET") {
2177
2183
  const N = e.getReader();
2178
2184
  let R = l.length, x = l.slice(-6);
2179
2185
  const He = new TextEncoder().encode(`0\r
2180
2186
  \r
2181
2187
  `);
2182
- T = new ReadableStream({
2188
+ H = new ReadableStream({
2183
2189
  async start(I) {
2184
2190
  l.length > 0 && I.enqueue(l), s && I.close();
2185
2191
  },
@@ -2188,14 +2194,14 @@ Content-Length: 0\r
2188
2194
  if (R += (m == null ? void 0 : m.length) || 0, m && (I.enqueue(m), x = u([
2189
2195
  x,
2190
2196
  m || new Uint8Array()
2191
- ]).slice(-5)), de || A === "content-length" && h !== void 0 && R >= h || A === "chunked" && x.every(
2197
+ ]).slice(-5)), de || h === "content-length" && A !== void 0 && R >= A || h === "chunked" && x.every(
2192
2198
  (Te, Ee) => Te === He[Ee]
2193
2199
  )) {
2194
2200
  I.close();
2195
2201
  return;
2196
2202
  }
2197
2203
  }
2198
- }), A === "chunked" && (T = T.pipeThrough(
2204
+ }), h === "chunked" && (H = H.pipeThrough(
2199
2205
  new Ye()
2200
2206
  ));
2201
2207
  }
@@ -2203,7 +2209,7 @@ Content-Length: 0\r
2203
2209
  return G.pathname = S.path, new Request(G.toString(), {
2204
2210
  method: S.method,
2205
2211
  headers: S.headers,
2206
- body: T,
2212
+ body: H,
2207
2213
  // In Node.js, duplex: 'half' is required when
2208
2214
  // the body stream is provided.
2209
2215
  // @ts-expect-error
@@ -2337,20 +2343,20 @@ async function nt(i, e, t) {
2337
2343
  const [_, a] = s.pop();
2338
2344
  for await (const c of _.values()) {
2339
2345
  const S = r.run(async () => {
2340
- const A = ie(
2346
+ const h = ie(
2341
2347
  a,
2342
2348
  c.name
2343
2349
  );
2344
2350
  if (c.kind === "directory") {
2345
2351
  try {
2346
- i.mkdir(A);
2347
- } catch (h) {
2348
- if ((h == null ? void 0 : h.errno) !== 20)
2349
- throw U.error(h), h;
2352
+ i.mkdir(h);
2353
+ } catch (A) {
2354
+ if ((A == null ? void 0 : A.errno) !== 20)
2355
+ throw U.error(A), A;
2350
2356
  }
2351
- s.push([c, A]);
2357
+ s.push([c, h]);
2352
2358
  } else if (c.kind === "file") {
2353
- const h = await c.getFile(), l = new Uint8Array(await h.arrayBuffer());
2359
+ const A = await c.getFile(), l = new Uint8Array(await A.arrayBuffer());
2354
2360
  i.createDataFile(
2355
2361
  a,
2356
2362
  c.name,
@@ -2371,20 +2377,20 @@ async function nt(i, e, t) {
2371
2377
  async function ue(i, e, t, r) {
2372
2378
  i.mkdirTree(t);
2373
2379
  const n = [];
2374
- async function s(A, h) {
2380
+ async function s(h, A) {
2375
2381
  await Promise.all(
2376
- i.readdir(A).filter(
2382
+ i.readdir(h).filter(
2377
2383
  (l) => l !== "." && l !== ".."
2378
2384
  ).map(async (l) => {
2379
- const T = ie(A, l);
2380
- if (!st(i, T)) {
2381
- n.push([h, T, l]);
2385
+ const H = ie(h, l);
2386
+ if (!st(i, H)) {
2387
+ n.push([A, H, l]);
2382
2388
  return;
2383
2389
  }
2384
- const M = await h.getDirectoryHandle(l, {
2390
+ const M = await A.getDirectoryHandle(l, {
2385
2391
  create: !0
2386
2392
  });
2387
- return await s(T, M);
2393
+ return await s(H, M);
2388
2394
  })
2389
2395
  );
2390
2396
  }
@@ -2392,19 +2398,19 @@ async function ue(i, e, t, r) {
2392
2398
  let _ = 0;
2393
2399
  const a = r && ot(r, 100), c = 100, S = /* @__PURE__ */ new Set();
2394
2400
  try {
2395
- for (const [A, h, l] of n) {
2396
- const T = O(
2397
- A,
2401
+ for (const [h, A, l] of n) {
2402
+ const H = O(
2403
+ h,
2398
2404
  l,
2399
2405
  i,
2400
- h
2406
+ A
2401
2407
  ).then(() => {
2402
- _++, S.delete(T), a == null || a({
2408
+ _++, S.delete(H), a == null || a({
2403
2409
  files: _,
2404
2410
  total: n.length
2405
2411
  });
2406
2412
  });
2407
- S.add(T), S.size >= c && (await Promise.race(S), a == null || a({
2413
+ S.add(H), S.size >= c && (await Promise.race(S), a == null || a({
2408
2414
  files: _,
2409
2415
  total: n.length
2410
2416
  }));
@@ -2449,8 +2455,8 @@ function it(i, e, t) {
2449
2455
  r.splice(0, c.length);
2450
2456
  const S = Ie(c);
2451
2457
  try {
2452
- for (const A of S)
2453
- await s.processEntry(A);
2458
+ for (const h of S)
2459
+ await s.processEntry(h);
2454
2460
  } finally {
2455
2461
  a();
2456
2462
  }