@php-wasm/web 3.1.21 → 3.1.25
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/README.md +41 -6
- package/index.cjs +12 -13
- package/index.cjs.map +1 -1
- package/index.js +342 -319
- package/index.js.map +1 -1
- package/lib/extensions/load-extensions.d.ts +38 -0
- package/lib/index.d.ts +1 -0
- package/lib/load-runtime.d.ts +11 -0
- package/package.json +21 -21
- package/test/playwright/browser-globals.d.ts +13 -0
- package/lib/extensions/intl/with-intl.d.ts +0 -2
- package/test/playwright/globals.d.ts +0 -1
package/index.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { LatestSupportedPHPVersion as
|
|
2
|
-
import { consumeAPI as
|
|
3
|
-
import { concatArrayBuffers as v, concatUint8Arrays as H, Semaphore as
|
|
4
|
-
import { logger as
|
|
5
|
-
import { fetchWithCorsProxy as
|
|
6
|
-
import { FirewallInterferenceError as
|
|
7
|
-
import { createMemoizedFetch as
|
|
8
|
-
import {
|
|
9
|
-
|
|
1
|
+
import { LatestSupportedPHPVersion as oe, withResolvedPHPExtensions as Ie, resolvePHPExtension as Y, isLegacyPHPVersion as Ke, createLegacyPhpIniPreRunStep as De, loadPHPRuntime as We, FSHelpers as M, __private__dont__use as O } from "@php-wasm/universal";
|
|
2
|
+
import { consumeAPI as Ut, exposeAPI as vt } from "@php-wasm/universal";
|
|
3
|
+
import { concatArrayBuffers as v, concatUint8Arrays as H, Semaphore as Pe, joinPaths as ce, basename as be } from "@php-wasm/util";
|
|
4
|
+
import { logger as B } from "@php-wasm/logger";
|
|
5
|
+
import { fetchWithCorsProxy as Re } from "@php-wasm/web-service-worker";
|
|
6
|
+
import { FirewallInterferenceError as xt, fetchWithCorsProxy as Nt } from "@php-wasm/web-service-worker";
|
|
7
|
+
import { createMemoizedFetch as Be } from "@wp-playground/common";
|
|
8
|
+
import { jspi as Ue } from "wasm-feature-detect";
|
|
9
|
+
import { journalFSEvents as ve, normalizeFilesystemOperations as Me } from "@php-wasm/fs-journal";
|
|
10
|
+
async function xe(i = oe) {
|
|
10
11
|
switch (i) {
|
|
11
12
|
case "8.5":
|
|
12
13
|
return (await import("@php-wasm/web-8-5")).getPHPLoaderModule();
|
|
@@ -30,7 +31,7 @@ async function Ue(i = V) {
|
|
|
30
31
|
function p(i) {
|
|
31
32
|
return Object.fromEntries(Object.entries(i).map(([e, t]) => [t, e]));
|
|
32
33
|
}
|
|
33
|
-
function
|
|
34
|
+
function D(i) {
|
|
34
35
|
return new Uint8Array([i >> 8 & 255, i & 255]);
|
|
35
36
|
}
|
|
36
37
|
function m(i) {
|
|
@@ -44,7 +45,7 @@ function Z(i) {
|
|
|
44
45
|
const e = new ArrayBuffer(8);
|
|
45
46
|
return new DataView(e).setBigUint64(0, BigInt(i), !1), new Uint8Array(e);
|
|
46
47
|
}
|
|
47
|
-
class
|
|
48
|
+
class g {
|
|
48
49
|
constructor(e) {
|
|
49
50
|
this.offset = 0, this.buffer = e, this.view = new DataView(e);
|
|
50
51
|
}
|
|
@@ -85,7 +86,7 @@ class N {
|
|
|
85
86
|
this.uint8Array.set(e, this.offset), this.offset += e.length;
|
|
86
87
|
}
|
|
87
88
|
}
|
|
88
|
-
const
|
|
89
|
+
const W = {
|
|
89
90
|
server_name: 0,
|
|
90
91
|
max_fragment_length: 1,
|
|
91
92
|
client_certificate_url: 2,
|
|
@@ -140,10 +141,10 @@ const P = {
|
|
|
140
141
|
transparency_info: 52,
|
|
141
142
|
connection_id: 54,
|
|
142
143
|
renegotiation_info: 65281
|
|
143
|
-
},
|
|
144
|
+
}, Ne = p(W), Se = {
|
|
144
145
|
host_name: 0
|
|
145
|
-
},
|
|
146
|
-
class
|
|
146
|
+
}, ke = p(Se);
|
|
147
|
+
class Ce {
|
|
147
148
|
static decodeFromClient(e) {
|
|
148
149
|
const t = new DataView(e.buffer);
|
|
149
150
|
let n = 0;
|
|
@@ -155,13 +156,13 @@ class Se {
|
|
|
155
156
|
n += 1;
|
|
156
157
|
const _ = t.getUint16(n);
|
|
157
158
|
n += 2;
|
|
158
|
-
const
|
|
159
|
+
const c = e.slice(n, n + _);
|
|
159
160
|
switch (n += _, a) {
|
|
160
|
-
case
|
|
161
|
+
case Se.host_name:
|
|
161
162
|
s.push({
|
|
162
|
-
name_type:
|
|
163
|
+
name_type: ke[a],
|
|
163
164
|
name: {
|
|
164
|
-
host_name: new TextDecoder().decode(
|
|
165
|
+
host_name: new TextDecoder().decode(c)
|
|
165
166
|
}
|
|
166
167
|
});
|
|
167
168
|
break;
|
|
@@ -188,15 +189,15 @@ class Se {
|
|
|
188
189
|
"Encoding non-empty lists for ClientHello is not supported yet. Only empty lists meant for ServerHello are supported today."
|
|
189
190
|
);
|
|
190
191
|
const t = new N(4);
|
|
191
|
-
return t.writeUint16(
|
|
192
|
+
return t.writeUint16(W.server_name), t.writeUint16(0), t.uint8Array;
|
|
192
193
|
}
|
|
193
194
|
}
|
|
194
|
-
const
|
|
195
|
+
const le = {
|
|
195
196
|
uncompressed: 0,
|
|
196
197
|
ansiX962_compressed_prime: 1,
|
|
197
198
|
ansiX962_compressed_char2: 2
|
|
198
|
-
},
|
|
199
|
-
class
|
|
199
|
+
}, J = p(le);
|
|
200
|
+
class he {
|
|
200
201
|
/**
|
|
201
202
|
* +--------------------------------------------------+
|
|
202
203
|
* | Payload Length [2B] |
|
|
@@ -213,10 +214,10 @@ class le {
|
|
|
213
214
|
* +--------------------------------------------------+
|
|
214
215
|
*/
|
|
215
216
|
static decodeFromClient(e) {
|
|
216
|
-
const t = new
|
|
217
|
+
const t = new g(e.buffer), n = t.readUint8(), r = [];
|
|
217
218
|
for (let s = 0; s < n; s++) {
|
|
218
219
|
const a = t.readUint8();
|
|
219
|
-
a in
|
|
220
|
+
a in J && r.push(J[a]);
|
|
220
221
|
}
|
|
221
222
|
return r;
|
|
222
223
|
}
|
|
@@ -236,10 +237,10 @@ class le {
|
|
|
236
237
|
*/
|
|
237
238
|
static encodeForClient(e) {
|
|
238
239
|
const t = new N(6);
|
|
239
|
-
return t.writeUint16(
|
|
240
|
+
return t.writeUint16(W.ec_point_formats), t.writeUint16(2), t.writeUint8(1), t.writeUint8(le[e]), t.uint8Array;
|
|
240
241
|
}
|
|
241
242
|
}
|
|
242
|
-
const
|
|
243
|
+
const Ae = {
|
|
243
244
|
decodeFromClient(i) {
|
|
244
245
|
const e = i[0] ?? 0;
|
|
245
246
|
return {
|
|
@@ -251,7 +252,7 @@ const he = {
|
|
|
251
252
|
* with an empty renegotiated_connection field.
|
|
252
253
|
*/
|
|
253
254
|
encodeForClient() {
|
|
254
|
-
const i =
|
|
255
|
+
const i = W.renegotiation_info, e = new Uint8Array([0]);
|
|
255
256
|
return new Uint8Array([
|
|
256
257
|
i >> 8 & 255,
|
|
257
258
|
i & 255,
|
|
@@ -260,7 +261,7 @@ const he = {
|
|
|
260
261
|
...e
|
|
261
262
|
]);
|
|
262
263
|
}
|
|
263
|
-
},
|
|
264
|
+
}, ue = {
|
|
264
265
|
TLS1_CK_PSK_WITH_RC4_128_SHA: 138,
|
|
265
266
|
TLS1_CK_PSK_WITH_3DES_EDE_CBC_SHA: 139,
|
|
266
267
|
TLS1_CK_PSK_WITH_AES_128_CBC_SHA: 140,
|
|
@@ -463,14 +464,14 @@ const he = {
|
|
|
463
464
|
TLS1_CK_ECDHE_PSK_WITH_CHACHA20_POLY1305: 52396,
|
|
464
465
|
TLS1_CK_DHE_PSK_WITH_CHACHA20_POLY1305: 52397,
|
|
465
466
|
TLS1_CK_RSA_PSK_WITH_CHACHA20_POLY1305: 52398
|
|
466
|
-
},
|
|
467
|
+
}, X = p(ue), He = {
|
|
467
468
|
secp256r1: 23,
|
|
468
469
|
secp384r1: 24,
|
|
469
470
|
secp521r1: 25,
|
|
470
471
|
x25519: 29,
|
|
471
472
|
x448: 30
|
|
472
|
-
}, Q = p(
|
|
473
|
-
class
|
|
473
|
+
}, Q = p(He);
|
|
474
|
+
class qe {
|
|
474
475
|
/**
|
|
475
476
|
* +--------------------------------------------------+
|
|
476
477
|
* | Payload Length [2B] |
|
|
@@ -487,7 +488,7 @@ class Me {
|
|
|
487
488
|
* +--------------------------------------------------+
|
|
488
489
|
*/
|
|
489
490
|
static decodeFromClient(e) {
|
|
490
|
-
const t = new
|
|
491
|
+
const t = new g(e.buffer);
|
|
491
492
|
t.readUint16();
|
|
492
493
|
const n = [];
|
|
493
494
|
for (; !t.isFinished(); ) {
|
|
@@ -508,15 +509,15 @@ class Me {
|
|
|
508
509
|
*/
|
|
509
510
|
static encodeForClient(e) {
|
|
510
511
|
const t = new N(6);
|
|
511
|
-
return t.writeUint16(
|
|
512
|
+
return t.writeUint16(W.supported_groups), t.writeUint16(2), t.writeUint16(He[e]), t.uint8Array;
|
|
512
513
|
}
|
|
513
514
|
}
|
|
514
|
-
const
|
|
515
|
+
const V = {
|
|
515
516
|
anonymous: 0,
|
|
516
517
|
rsa: 1,
|
|
517
518
|
dsa: 2,
|
|
518
519
|
ecdsa: 3
|
|
519
|
-
}, ee = p(
|
|
520
|
+
}, ee = p(V), z = {
|
|
520
521
|
none: 0,
|
|
521
522
|
md5: 1,
|
|
522
523
|
sha1: 2,
|
|
@@ -524,8 +525,8 @@ const z = {
|
|
|
524
525
|
sha256: 4,
|
|
525
526
|
sha384: 5,
|
|
526
527
|
sha512: 6
|
|
527
|
-
}, te = p(
|
|
528
|
-
class
|
|
528
|
+
}, te = p(z);
|
|
529
|
+
class Fe {
|
|
529
530
|
/**
|
|
530
531
|
* Binary layout:
|
|
531
532
|
*
|
|
@@ -542,14 +543,14 @@ class Ne {
|
|
|
542
543
|
* +------------------------------------+
|
|
543
544
|
*/
|
|
544
545
|
static decodeFromClient(e) {
|
|
545
|
-
const t = new
|
|
546
|
+
const t = new g(e.buffer);
|
|
546
547
|
t.readUint16();
|
|
547
548
|
const n = [];
|
|
548
549
|
for (; !t.isFinished(); ) {
|
|
549
550
|
const r = t.readUint8(), s = t.readUint8();
|
|
550
551
|
if (ee[s]) {
|
|
551
552
|
if (!te[r]) {
|
|
552
|
-
|
|
553
|
+
B.warn(`Unknown hash algorithm: ${r}`);
|
|
553
554
|
continue;
|
|
554
555
|
}
|
|
555
556
|
n.push({
|
|
@@ -573,26 +574,26 @@ class Ne {
|
|
|
573
574
|
*/
|
|
574
575
|
static encodeforClient(e, t) {
|
|
575
576
|
const n = new N(6);
|
|
576
|
-
return n.writeUint16(
|
|
577
|
+
return n.writeUint16(W.signature_algorithms), n.writeUint16(2), n.writeUint8(z[e]), n.writeUint8(V[t]), n.uint8Array;
|
|
577
578
|
}
|
|
578
579
|
}
|
|
579
580
|
const ne = {
|
|
580
|
-
server_name:
|
|
581
|
-
signature_algorithms:
|
|
582
|
-
supported_groups:
|
|
583
|
-
ec_point_formats:
|
|
584
|
-
renegotiation_info:
|
|
581
|
+
server_name: Ce,
|
|
582
|
+
signature_algorithms: Fe,
|
|
583
|
+
supported_groups: qe,
|
|
584
|
+
ec_point_formats: he,
|
|
585
|
+
renegotiation_info: Ae
|
|
585
586
|
};
|
|
586
|
-
function
|
|
587
|
-
const e = new
|
|
587
|
+
function Oe(i) {
|
|
588
|
+
const e = new g(i.buffer), t = [];
|
|
588
589
|
for (; !e.isFinished(); ) {
|
|
589
|
-
const n = e.offset, r = e.readUint16(), s =
|
|
590
|
+
const n = e.offset, r = e.readUint16(), s = Ne[r], a = e.readUint16(), _ = e.readUint8Array(a);
|
|
590
591
|
if (!(s in ne))
|
|
591
592
|
continue;
|
|
592
|
-
const
|
|
593
|
+
const c = ne[s];
|
|
593
594
|
t.push({
|
|
594
595
|
type: s,
|
|
595
|
-
data:
|
|
596
|
+
data: c.decodeFromClient(_),
|
|
596
597
|
raw: i.slice(n, n + 4 + a)
|
|
597
598
|
});
|
|
598
599
|
}
|
|
@@ -610,7 +611,7 @@ async function G(i, e, t, n) {
|
|
|
610
611
|
const _ = [];
|
|
611
612
|
for (; v(_).byteLength < n; ) {
|
|
612
613
|
a = await re(s, a);
|
|
613
|
-
const
|
|
614
|
+
const S = v([a, r]), C = await re(s, S);
|
|
614
615
|
_.push(C);
|
|
615
616
|
}
|
|
616
617
|
return v(_).slice(0, n);
|
|
@@ -622,12 +623,12 @@ async function re(i, e) {
|
|
|
622
623
|
e
|
|
623
624
|
);
|
|
624
625
|
}
|
|
625
|
-
const
|
|
626
|
+
const je = {
|
|
626
627
|
Null: 0
|
|
627
|
-
},
|
|
628
|
+
}, de = {
|
|
628
629
|
Warning: 1,
|
|
629
630
|
Fatal: 2
|
|
630
|
-
},
|
|
631
|
+
}, fe = p(de), Ee = {
|
|
631
632
|
CloseNotify: 0,
|
|
632
633
|
UnexpectedMessage: 10,
|
|
633
634
|
BadRecordMac: 20,
|
|
@@ -653,7 +654,7 @@ const Fe = {
|
|
|
653
654
|
UserCanceled: 90,
|
|
654
655
|
NoRenegotiation: 100,
|
|
655
656
|
UnsupportedExtension: 110
|
|
656
|
-
},
|
|
657
|
+
}, Te = p(Ee), l = {
|
|
657
658
|
ChangeCipherSpec: 20,
|
|
658
659
|
Alert: 21,
|
|
659
660
|
Handshake: 22,
|
|
@@ -667,7 +668,7 @@ const Fe = {
|
|
|
667
668
|
ServerHelloDone: 14,
|
|
668
669
|
ClientKeyExchange: 16,
|
|
669
670
|
Finished: 20
|
|
670
|
-
},
|
|
671
|
+
}, Ge = {
|
|
671
672
|
/**
|
|
672
673
|
* Indicates that a named curve is used. This option
|
|
673
674
|
* SHOULD be used when applicable.
|
|
@@ -676,12 +677,12 @@ const Fe = {
|
|
|
676
677
|
/**
|
|
677
678
|
* Values 248 through 255 are reserved for private use.
|
|
678
679
|
*/
|
|
679
|
-
},
|
|
680
|
+
}, $e = {
|
|
680
681
|
secp256r1: 23
|
|
681
682
|
};
|
|
682
683
|
class j extends Error {
|
|
683
684
|
}
|
|
684
|
-
const
|
|
685
|
+
const x = new Uint8Array([3, 3]), Ve = crypto.subtle.generateKey(
|
|
685
686
|
{
|
|
686
687
|
name: "ECDH",
|
|
687
688
|
namedCurve: "P-256"
|
|
@@ -692,7 +693,7 @@ const M = new Uint8Array([3, 3]), je = crypto.subtle.generateKey(
|
|
|
692
693
|
["deriveKey", "deriveBits"]
|
|
693
694
|
// Key usage
|
|
694
695
|
);
|
|
695
|
-
class
|
|
696
|
+
class ze {
|
|
696
697
|
constructor() {
|
|
697
698
|
this.receivedRecordSequenceNumber = 0, this.sentRecordSequenceNumber = 0, this.closed = !1, this.receivedBytesBuffer = new Uint8Array(), this.receivedTLSRecords = [], this.partialTLSMessages = {}, this.handshakeMessages = [], this.MAX_CHUNK_SIZE = 1024 * 16, this.clientEnd = {
|
|
698
699
|
// We don't need to chunk the encrypted data.
|
|
@@ -709,7 +710,7 @@ class Ge {
|
|
|
709
710
|
* This will spread some messages across multiple records,
|
|
710
711
|
* but TLS supports it so that's fine.
|
|
711
712
|
*/
|
|
712
|
-
downstream:
|
|
713
|
+
downstream: Ye(this.MAX_CHUNK_SIZE)
|
|
713
714
|
}, this.serverUpstreamWriter = this.serverEnd.upstream.writable.getWriter();
|
|
714
715
|
const e = this;
|
|
715
716
|
this.serverEnd.downstream.readable.pipeTo(
|
|
@@ -775,16 +776,16 @@ class Ge {
|
|
|
775
776
|
const r = crypto.getRandomValues(new Uint8Array(32));
|
|
776
777
|
await this.writeTLSRecord(
|
|
777
778
|
l.Handshake,
|
|
778
|
-
|
|
779
|
+
K.serverHello(
|
|
779
780
|
n.body,
|
|
780
781
|
r,
|
|
781
|
-
|
|
782
|
+
je.Null
|
|
782
783
|
)
|
|
783
784
|
), await this.writeTLSRecord(
|
|
784
785
|
l.Handshake,
|
|
785
|
-
|
|
786
|
+
K.certificate(t)
|
|
786
787
|
);
|
|
787
|
-
const s = await
|
|
788
|
+
const s = await Ve, a = n.body.random, _ = await K.ECDHEServerKeyExchange(
|
|
788
789
|
a,
|
|
789
790
|
r,
|
|
790
791
|
s,
|
|
@@ -792,9 +793,9 @@ class Ge {
|
|
|
792
793
|
);
|
|
793
794
|
await this.writeTLSRecord(l.Handshake, _), await this.writeTLSRecord(
|
|
794
795
|
l.Handshake,
|
|
795
|
-
|
|
796
|
+
K.serverHelloDone()
|
|
796
797
|
);
|
|
797
|
-
const
|
|
798
|
+
const c = await this.readNextHandshakeMessage(
|
|
798
799
|
f.ClientKeyExchange
|
|
799
800
|
);
|
|
800
801
|
await this.readNextMessage(l.ChangeCipherSpec), this.sessionKeys = await this.deriveSessionKeys({
|
|
@@ -803,17 +804,17 @@ class Ge {
|
|
|
803
804
|
serverPrivateKey: s.privateKey,
|
|
804
805
|
clientPublicKey: await crypto.subtle.importKey(
|
|
805
806
|
"raw",
|
|
806
|
-
|
|
807
|
+
c.body.exchange_keys,
|
|
807
808
|
{ name: "ECDH", namedCurve: "P-256" },
|
|
808
809
|
!1,
|
|
809
810
|
[]
|
|
810
811
|
)
|
|
811
812
|
}), await this.readNextHandshakeMessage(f.Finished), await this.writeTLSRecord(
|
|
812
813
|
l.ChangeCipherSpec,
|
|
813
|
-
|
|
814
|
+
K.changeCipherSpec()
|
|
814
815
|
), await this.writeTLSRecord(
|
|
815
816
|
l.Handshake,
|
|
816
|
-
await
|
|
817
|
+
await K.createFinishedMessage(
|
|
817
818
|
this.handshakeMessages,
|
|
818
819
|
this.sessionKeys.masterSecret
|
|
819
820
|
)
|
|
@@ -850,12 +851,12 @@ class Ge {
|
|
|
850
851
|
H([t, e]),
|
|
851
852
|
// Client key, server key, client IV, server IV
|
|
852
853
|
40
|
|
853
|
-
),
|
|
854
|
+
), c = new g(_), S = c.readUint8Array(16), C = c.readUint8Array(16), h = c.readUint8Array(4), A = c.readUint8Array(4);
|
|
854
855
|
return {
|
|
855
856
|
masterSecret: a,
|
|
856
857
|
clientWriteKey: await crypto.subtle.importKey(
|
|
857
858
|
"raw",
|
|
858
|
-
|
|
859
|
+
S,
|
|
859
860
|
{ name: "AES-GCM" },
|
|
860
861
|
!1,
|
|
861
862
|
["encrypt", "decrypt"]
|
|
@@ -891,9 +892,9 @@ class Ge {
|
|
|
891
892
|
async readNextTLSRecord(e) {
|
|
892
893
|
for (; ; ) {
|
|
893
894
|
for (let _ = 0; _ < this.receivedTLSRecords.length; _++) {
|
|
894
|
-
const
|
|
895
|
-
if (
|
|
896
|
-
return this.receivedTLSRecords.splice(_, 1),
|
|
895
|
+
const c = this.receivedTLSRecords[_];
|
|
896
|
+
if (c.type === e)
|
|
897
|
+
return this.receivedTLSRecords.splice(_, 1), c;
|
|
897
898
|
}
|
|
898
899
|
const t = await this.pollBytes(5), n = t[3] << 8 | t[4], r = t[0], s = await this.pollBytes(n), a = {
|
|
899
900
|
type: r,
|
|
@@ -905,11 +906,11 @@ class Ge {
|
|
|
905
906
|
fragment: this.sessionKeys && r !== l.ChangeCipherSpec ? await this.decryptData(r, s) : s
|
|
906
907
|
};
|
|
907
908
|
if (a.type === l.Alert) {
|
|
908
|
-
const _ = a.fragment[0],
|
|
909
|
-
throw _ ===
|
|
909
|
+
const _ = a.fragment[0], c = a.fragment[1], S = fe[_], C = Te[c];
|
|
910
|
+
throw _ === de.Warning && c === Ee.CloseNotify ? new j(
|
|
910
911
|
"TLS connection closed by peer (CloseNotify)"
|
|
911
912
|
) : new Error(
|
|
912
|
-
`TLS alert received: ${
|
|
913
|
+
`TLS alert received: ${S} ${C}`
|
|
913
914
|
);
|
|
914
915
|
}
|
|
915
916
|
this.receivedTLSRecords.push(a);
|
|
@@ -964,9 +965,9 @@ class Ge {
|
|
|
964
965
|
additionalData: new Uint8Array([
|
|
965
966
|
...Z(this.receivedRecordSequenceNumber),
|
|
966
967
|
e,
|
|
967
|
-
...
|
|
968
|
+
...x,
|
|
968
969
|
// Payload length without IV and tag
|
|
969
|
-
...
|
|
970
|
+
...D(t.length - 8 - 16)
|
|
970
971
|
]),
|
|
971
972
|
tagLength: 128
|
|
972
973
|
},
|
|
@@ -1013,7 +1014,7 @@ class Ge {
|
|
|
1013
1014
|
*/
|
|
1014
1015
|
async writeTLSRecord(e, t) {
|
|
1015
1016
|
e === l.Handshake && this.handshakeMessages.push(t), this.sessionKeys && e !== l.ChangeCipherSpec && (t = await this.encryptData(e, t));
|
|
1016
|
-
const n =
|
|
1017
|
+
const n = x, r = t.length, s = new Uint8Array(5);
|
|
1017
1018
|
s[0] = e, s[1] = n[0], s[2] = n[1], s[3] = r >> 8 & 255, s[4] = r & 255;
|
|
1018
1019
|
const a = H([s, t]);
|
|
1019
1020
|
this.clientDownstreamWriter.write(a);
|
|
@@ -1026,9 +1027,9 @@ class Ge {
|
|
|
1026
1027
|
const n = this.sessionKeys.serverIV, r = crypto.getRandomValues(new Uint8Array(8)), s = new Uint8Array([...n, ...r]), a = new Uint8Array([
|
|
1027
1028
|
...Z(this.sentRecordSequenceNumber),
|
|
1028
1029
|
e,
|
|
1029
|
-
...
|
|
1030
|
+
...x,
|
|
1030
1031
|
// Payload length without IV and tag
|
|
1031
|
-
...
|
|
1032
|
+
...D(t.length)
|
|
1032
1033
|
]), _ = await crypto.subtle.encrypt(
|
|
1033
1034
|
{
|
|
1034
1035
|
name: "AES-GCM",
|
|
@@ -1084,12 +1085,12 @@ class E {
|
|
|
1084
1085
|
* https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#tls-parameters-4
|
|
1085
1086
|
*/
|
|
1086
1087
|
static parseCipherSuites(e) {
|
|
1087
|
-
const t = new
|
|
1088
|
+
const t = new g(e);
|
|
1088
1089
|
t.readUint16();
|
|
1089
1090
|
const n = [];
|
|
1090
1091
|
for (; !t.isFinished(); ) {
|
|
1091
1092
|
const r = t.readUint16();
|
|
1092
|
-
r in
|
|
1093
|
+
r in X && n.push(X[r]);
|
|
1093
1094
|
}
|
|
1094
1095
|
return n;
|
|
1095
1096
|
}
|
|
@@ -1108,8 +1109,8 @@ class E {
|
|
|
1108
1109
|
static alert(e) {
|
|
1109
1110
|
return {
|
|
1110
1111
|
type: l.Alert,
|
|
1111
|
-
level:
|
|
1112
|
-
description:
|
|
1112
|
+
level: fe[e[0]],
|
|
1113
|
+
description: Te[e[1]]
|
|
1113
1114
|
};
|
|
1114
1115
|
}
|
|
1115
1116
|
static clientHandshake(e) {
|
|
@@ -1182,7 +1183,7 @@ class E {
|
|
|
1182
1183
|
* +------+------+---------------------------+
|
|
1183
1184
|
*/
|
|
1184
1185
|
static clientHelloPayload(e) {
|
|
1185
|
-
const t = new
|
|
1186
|
+
const t = new g(e.buffer), n = {
|
|
1186
1187
|
client_version: t.readUint8Array(2),
|
|
1187
1188
|
/**
|
|
1188
1189
|
* Technically this consists of a GMT timestamp
|
|
@@ -1201,7 +1202,7 @@ class E {
|
|
|
1201
1202
|
a
|
|
1202
1203
|
);
|
|
1203
1204
|
const _ = t.readUint16();
|
|
1204
|
-
return n.extensions =
|
|
1205
|
+
return n.extensions = Oe(
|
|
1205
1206
|
t.readUint8Array(_)
|
|
1206
1207
|
), n;
|
|
1207
1208
|
}
|
|
@@ -1226,7 +1227,7 @@ class E {
|
|
|
1226
1227
|
};
|
|
1227
1228
|
}
|
|
1228
1229
|
}
|
|
1229
|
-
function
|
|
1230
|
+
function Ye(i) {
|
|
1230
1231
|
return new TransformStream({
|
|
1231
1232
|
transform(e, t) {
|
|
1232
1233
|
for (; e.length > 0; )
|
|
@@ -1234,7 +1235,7 @@ function $e(i) {
|
|
|
1234
1235
|
}
|
|
1235
1236
|
});
|
|
1236
1237
|
}
|
|
1237
|
-
class
|
|
1238
|
+
class K {
|
|
1238
1239
|
static certificate(e) {
|
|
1239
1240
|
const t = [];
|
|
1240
1241
|
for (const s of e)
|
|
@@ -1287,9 +1288,9 @@ class D {
|
|
|
1287
1288
|
await crypto.subtle.exportKey("raw", n.publicKey)
|
|
1288
1289
|
), a = new Uint8Array([
|
|
1289
1290
|
// Curve type (1 byte)
|
|
1290
|
-
|
|
1291
|
+
Ge.NamedCurve,
|
|
1291
1292
|
// Curve name (2 bytes)
|
|
1292
|
-
...
|
|
1293
|
+
...D($e.secp256r1),
|
|
1293
1294
|
// Public key length (1 byte)
|
|
1294
1295
|
s.byteLength,
|
|
1295
1296
|
// Public key (65 bytes, uncompressed format)
|
|
@@ -1301,14 +1302,14 @@ class D {
|
|
|
1301
1302
|
},
|
|
1302
1303
|
r,
|
|
1303
1304
|
new Uint8Array([...e, ...t, ...a])
|
|
1304
|
-
),
|
|
1305
|
-
|
|
1306
|
-
|
|
1305
|
+
), c = new Uint8Array(_), S = new Uint8Array([
|
|
1306
|
+
z.sha256,
|
|
1307
|
+
V.rsa
|
|
1307
1308
|
]), C = new Uint8Array([
|
|
1308
1309
|
...a,
|
|
1309
|
-
...
|
|
1310
|
-
...
|
|
1311
|
-
...
|
|
1310
|
+
...S,
|
|
1311
|
+
...D(c.length),
|
|
1312
|
+
...c
|
|
1312
1313
|
]);
|
|
1313
1314
|
return new Uint8Array([
|
|
1314
1315
|
f.ServerKeyExchange,
|
|
@@ -1358,24 +1359,24 @@ class D {
|
|
|
1358
1359
|
const r = e.extensions.map((_) => {
|
|
1359
1360
|
switch (_.type) {
|
|
1360
1361
|
case "server_name":
|
|
1361
|
-
return
|
|
1362
|
+
return Ce.encodeForClient();
|
|
1362
1363
|
case "ec_point_formats":
|
|
1363
|
-
return
|
|
1364
|
+
return he.encodeForClient(
|
|
1364
1365
|
"uncompressed"
|
|
1365
1366
|
);
|
|
1366
1367
|
case "renegotiation_info":
|
|
1367
|
-
return
|
|
1368
|
+
return Ae.encodeForClient();
|
|
1368
1369
|
}
|
|
1369
1370
|
}).filter((_) => _ !== void 0), s = H(r), a = new Uint8Array([
|
|
1370
1371
|
// Version field – 0x03, 0x03 means TLS 1.2
|
|
1371
|
-
...
|
|
1372
|
+
...x,
|
|
1372
1373
|
...t,
|
|
1373
1374
|
e.session_id.length,
|
|
1374
1375
|
...e.session_id,
|
|
1375
|
-
...
|
|
1376
|
+
...D(ue.TLS1_CK_ECDHE_RSA_WITH_AES_128_GCM_SHA256),
|
|
1376
1377
|
n,
|
|
1377
1378
|
// Extensions length (2 bytes)
|
|
1378
|
-
...
|
|
1379
|
+
...D(s.length),
|
|
1379
1380
|
...s
|
|
1380
1381
|
]);
|
|
1381
1382
|
return new Uint8Array([
|
|
@@ -1428,25 +1429,25 @@ class D {
|
|
|
1428
1429
|
return new Uint8Array([1]);
|
|
1429
1430
|
}
|
|
1430
1431
|
}
|
|
1431
|
-
function
|
|
1432
|
-
return
|
|
1432
|
+
function Ze(i, e) {
|
|
1433
|
+
return Je.generateCertificate(i, e);
|
|
1433
1434
|
}
|
|
1434
|
-
function
|
|
1435
|
+
function gt(i) {
|
|
1435
1436
|
return `-----BEGIN CERTIFICATE-----
|
|
1436
|
-
${
|
|
1437
|
-
|
|
1437
|
+
${we(
|
|
1438
|
+
pe(i.buffer)
|
|
1438
1439
|
)}
|
|
1439
1440
|
-----END CERTIFICATE-----`;
|
|
1440
1441
|
}
|
|
1441
|
-
async function
|
|
1442
|
+
async function It(i) {
|
|
1442
1443
|
const e = await crypto.subtle.exportKey("pkcs8", i);
|
|
1443
1444
|
return `-----BEGIN PRIVATE KEY-----
|
|
1444
|
-
${
|
|
1445
|
-
|
|
1445
|
+
${we(
|
|
1446
|
+
pe(e)
|
|
1446
1447
|
)}
|
|
1447
1448
|
-----END PRIVATE KEY-----`;
|
|
1448
1449
|
}
|
|
1449
|
-
class
|
|
1450
|
+
class Je {
|
|
1450
1451
|
static async generateCertificate(e, t) {
|
|
1451
1452
|
const n = await crypto.subtle.generateKey(
|
|
1452
1453
|
{
|
|
@@ -1552,7 +1553,7 @@ class ze {
|
|
|
1552
1553
|
d.UTCTime,
|
|
1553
1554
|
new TextEncoder().encode(
|
|
1554
1555
|
ie(
|
|
1555
|
-
(e == null ? void 0 : e.notAfter) ??
|
|
1556
|
+
(e == null ? void 0 : e.notAfter) ?? Qe(/* @__PURE__ */ new Date(), 10)
|
|
1556
1557
|
)
|
|
1557
1558
|
)
|
|
1558
1559
|
)
|
|
@@ -1603,11 +1604,11 @@ class ze {
|
|
|
1603
1604
|
static subjectAltName(e) {
|
|
1604
1605
|
var s, a;
|
|
1605
1606
|
const t = ((s = e.dnsNames) == null ? void 0 : s.map((_) => {
|
|
1606
|
-
const
|
|
1607
|
-
return o.contextSpecific(2,
|
|
1607
|
+
const c = o.ia5String(_);
|
|
1608
|
+
return o.contextSpecific(2, c);
|
|
1608
1609
|
})) || [], n = ((a = e.ipAddresses) == null ? void 0 : a.map((_) => {
|
|
1609
|
-
const
|
|
1610
|
-
return o.contextSpecific(7,
|
|
1610
|
+
const c = o.ia5String(_);
|
|
1611
|
+
return o.contextSpecific(7, c);
|
|
1611
1612
|
})) || [], r = o.octetString(
|
|
1612
1613
|
o.sequence([...t, ...n])
|
|
1613
1614
|
);
|
|
@@ -1618,7 +1619,7 @@ class ze {
|
|
|
1618
1619
|
]);
|
|
1619
1620
|
}
|
|
1620
1621
|
}
|
|
1621
|
-
const
|
|
1622
|
+
const Xe = {
|
|
1622
1623
|
// Algorithm OIDs
|
|
1623
1624
|
"1.2.840.113549.1.1.1": "rsaEncryption",
|
|
1624
1625
|
"1.2.840.113549.1.1.4": "md5WithRSAEncryption",
|
|
@@ -1729,7 +1730,7 @@ const Ye = {
|
|
|
1729
1730
|
"1.3.6.1.5.5.7.3.8": "timeStamping"
|
|
1730
1731
|
};
|
|
1731
1732
|
function w(i) {
|
|
1732
|
-
for (const [e, t] of Object.entries(
|
|
1733
|
+
for (const [e, t] of Object.entries(Xe))
|
|
1733
1734
|
if (t === i)
|
|
1734
1735
|
return e;
|
|
1735
1736
|
throw new Error(`OID not found for name: ${i}`);
|
|
@@ -1770,9 +1771,12 @@ class o {
|
|
|
1770
1771
|
return r[0] = e, r.set(n, 1), r.set(t, 1 + n.length), r;
|
|
1771
1772
|
}
|
|
1772
1773
|
static integer(e) {
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
t
|
|
1774
|
+
let t = 0;
|
|
1775
|
+
for (; t < e.length - 1 && e[t] === 0 && e[t + 1] < 128; )
|
|
1776
|
+
t++;
|
|
1777
|
+
if (t > 0 && (e = e.subarray(t)), e[0] > 127) {
|
|
1778
|
+
const n = new Uint8Array(e.length + 1);
|
|
1779
|
+
n[0] = 0, n.set(e, 1), e = n;
|
|
1776
1780
|
}
|
|
1777
1781
|
return o.ASN1(d.Integer, e);
|
|
1778
1782
|
}
|
|
@@ -1794,8 +1798,8 @@ class o {
|
|
|
1794
1798
|
do
|
|
1795
1799
|
_.unshift(a & 127), a >>= 7;
|
|
1796
1800
|
while (a > 0);
|
|
1797
|
-
for (let
|
|
1798
|
-
_[
|
|
1801
|
+
for (let c = 0; c < _.length - 1; c++)
|
|
1802
|
+
_[c] |= 128;
|
|
1799
1803
|
r.push(..._);
|
|
1800
1804
|
}
|
|
1801
1805
|
return o.ASN1(d.OID, new Uint8Array(r));
|
|
@@ -1829,26 +1833,26 @@ class o {
|
|
|
1829
1833
|
);
|
|
1830
1834
|
}
|
|
1831
1835
|
}
|
|
1832
|
-
function
|
|
1836
|
+
function pe(i) {
|
|
1833
1837
|
return btoa(String.fromCodePoint(...new Uint8Array(i)));
|
|
1834
1838
|
}
|
|
1835
|
-
function
|
|
1839
|
+
function we(i) {
|
|
1836
1840
|
var e;
|
|
1837
1841
|
return ((e = i.match(/.{1,64}/g)) == null ? void 0 : e.join(`
|
|
1838
1842
|
`)) || i;
|
|
1839
1843
|
}
|
|
1840
1844
|
function ie(i) {
|
|
1841
|
-
const e = i.getUTCFullYear().toString().substr(2), t =
|
|
1845
|
+
const e = i.getUTCFullYear().toString().substr(2), t = R(i.getUTCMonth() + 1), n = R(i.getUTCDate()), r = R(i.getUTCHours()), s = R(i.getUTCMinutes()), a = R(i.getUTCSeconds());
|
|
1842
1846
|
return `${e}${t}${n}${r}${s}${a}Z`;
|
|
1843
1847
|
}
|
|
1844
|
-
function
|
|
1848
|
+
function R(i) {
|
|
1845
1849
|
return i.toString().padStart(2, "0");
|
|
1846
1850
|
}
|
|
1847
|
-
function
|
|
1851
|
+
function Qe(i, e) {
|
|
1848
1852
|
const t = new Date(i);
|
|
1849
1853
|
return t.setUTCFullYear(t.getUTCFullYear() + e), t;
|
|
1850
1854
|
}
|
|
1851
|
-
class
|
|
1855
|
+
class et extends TransformStream {
|
|
1852
1856
|
constructor() {
|
|
1853
1857
|
let e = new Uint8Array(0), t = "SCAN_CHUNK_SIZE", n = 0;
|
|
1854
1858
|
super({
|
|
@@ -1859,10 +1863,10 @@ class Xe extends TransformStream {
|
|
|
1859
1863
|
return;
|
|
1860
1864
|
let a = 0;
|
|
1861
1865
|
for (; a < e.length; ) {
|
|
1862
|
-
const
|
|
1863
|
-
if (!(
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
+
const S = e[a];
|
|
1867
|
+
if (!(S >= 48 && S <= 57 || // 0-9
|
|
1868
|
+
S >= 97 && S <= 102 || // a-f
|
|
1869
|
+
S >= 65 && S <= 70)) break;
|
|
1866
1870
|
a++;
|
|
1867
1871
|
}
|
|
1868
1872
|
if (a === 0)
|
|
@@ -1876,12 +1880,12 @@ class Xe extends TransformStream {
|
|
|
1876
1880
|
);
|
|
1877
1881
|
const _ = new TextDecoder().decode(
|
|
1878
1882
|
e.slice(0, a)
|
|
1879
|
-
),
|
|
1880
|
-
if (e = e.slice(a + 2),
|
|
1883
|
+
), c = parseInt(_, 16);
|
|
1884
|
+
if (e = e.slice(a + 2), c === 0) {
|
|
1881
1885
|
t = "SCAN_FINAL_CHUNK", s.terminate();
|
|
1882
1886
|
return;
|
|
1883
1887
|
}
|
|
1884
|
-
n =
|
|
1888
|
+
n = c, t = "SCAN_CHUNK_DATA";
|
|
1885
1889
|
} else if (t === "SCAN_CHUNK_DATA") {
|
|
1886
1890
|
const a = Math.min(
|
|
1887
1891
|
n,
|
|
@@ -1901,7 +1905,7 @@ class Xe extends TransformStream {
|
|
|
1901
1905
|
});
|
|
1902
1906
|
}
|
|
1903
1907
|
}
|
|
1904
|
-
const
|
|
1908
|
+
const tt = (i, e) => ({
|
|
1905
1909
|
...i,
|
|
1906
1910
|
websocket: {
|
|
1907
1911
|
url: (t, n, r) => `ws://playground.internal/?${new URLSearchParams({
|
|
@@ -1909,7 +1913,7 @@ const Je = (i, e) => ({
|
|
|
1909
1913
|
port: r
|
|
1910
1914
|
}).toString()}`,
|
|
1911
1915
|
subprotocol: "binary",
|
|
1912
|
-
decorator: () => class extends
|
|
1916
|
+
decorator: () => class extends nt {
|
|
1913
1917
|
constructor(t, n) {
|
|
1914
1918
|
super(t, n, {
|
|
1915
1919
|
CAroot: e.CAroot,
|
|
@@ -1919,7 +1923,7 @@ const Je = (i, e) => ({
|
|
|
1919
1923
|
}
|
|
1920
1924
|
}
|
|
1921
1925
|
});
|
|
1922
|
-
class
|
|
1926
|
+
class nt {
|
|
1923
1927
|
constructor(e, t, {
|
|
1924
1928
|
CAroot: n,
|
|
1925
1929
|
corsProxyUrl: r,
|
|
@@ -1990,7 +1994,7 @@ class Qe {
|
|
|
1990
1994
|
switch (this.bufferedBytesFromClient = H([
|
|
1991
1995
|
this.bufferedBytesFromClient,
|
|
1992
1996
|
new Uint8Array(e)
|
|
1993
|
-
]),
|
|
1997
|
+
]), st(this.port, this.bufferedBytesFromClient)) {
|
|
1994
1998
|
case !1:
|
|
1995
1999
|
return;
|
|
1996
2000
|
case "other":
|
|
@@ -2009,7 +2013,7 @@ class Qe {
|
|
|
2009
2013
|
throw new Error(
|
|
2010
2014
|
"TLS protocol is only supported when the TCPOverFetchWebsocket is instantiated with a CAroot"
|
|
2011
2015
|
);
|
|
2012
|
-
const e = await
|
|
2016
|
+
const e = await Ze(
|
|
2013
2017
|
{
|
|
2014
2018
|
subject: {
|
|
2015
2019
|
commonName: this.host,
|
|
@@ -2019,14 +2023,14 @@ class Qe {
|
|
|
2019
2023
|
issuer: this.CAroot.tbsDescription.subject
|
|
2020
2024
|
},
|
|
2021
2025
|
this.CAroot.keyPair
|
|
2022
|
-
), t = new
|
|
2026
|
+
), t = new ze();
|
|
2023
2027
|
this.clientUpstream.readable.pipeTo(t.clientEnd.upstream.writable).catch(() => {
|
|
2024
2028
|
}), t.clientEnd.downstream.readable.pipeTo(this.clientDownstream.writable).catch(() => {
|
|
2025
2029
|
}), await t.TLSHandshake(e.keyPair.privateKey, [
|
|
2026
2030
|
e.certificate,
|
|
2027
2031
|
this.CAroot.certificate
|
|
2028
2032
|
]);
|
|
2029
|
-
const { request: n, expectsContinue: r } = await
|
|
2033
|
+
const { request: n, expectsContinue: r } = await L.parseHttpRequest(
|
|
2030
2034
|
t.serverEnd.upstream.readable,
|
|
2031
2035
|
this.host,
|
|
2032
2036
|
"https"
|
|
@@ -2040,7 +2044,7 @@ class Qe {
|
|
|
2040
2044
|
), s.releaseLock();
|
|
2041
2045
|
}
|
|
2042
2046
|
try {
|
|
2043
|
-
await
|
|
2047
|
+
await L.fetchRawResponseBytes(
|
|
2044
2048
|
n,
|
|
2045
2049
|
this.corsProxyUrl
|
|
2046
2050
|
).pipeTo(t.serverEnd.downstream.writable);
|
|
@@ -2048,7 +2052,7 @@ class Qe {
|
|
|
2048
2052
|
}
|
|
2049
2053
|
}
|
|
2050
2054
|
async fetchOverHTTP() {
|
|
2051
|
-
const { request: e, expectsContinue: t } = await
|
|
2055
|
+
const { request: e, expectsContinue: t } = await L.parseHttpRequest(
|
|
2052
2056
|
this.clientUpstream.readable,
|
|
2053
2057
|
this.host,
|
|
2054
2058
|
"http"
|
|
@@ -2062,7 +2066,7 @@ class Qe {
|
|
|
2062
2066
|
), n.releaseLock();
|
|
2063
2067
|
}
|
|
2064
2068
|
try {
|
|
2065
|
-
await
|
|
2069
|
+
await L.fetchRawResponseBytes(
|
|
2066
2070
|
e,
|
|
2067
2071
|
this.corsProxyUrl
|
|
2068
2072
|
).pipeTo(this.clientDownstream.writable);
|
|
@@ -2073,7 +2077,7 @@ class Qe {
|
|
|
2073
2077
|
this.emit("message", { data: new Uint8Array(0) }), this.readyState = this.CLOSING, this.emit("close"), this.readyState = this.CLOSED;
|
|
2074
2078
|
}
|
|
2075
2079
|
}
|
|
2076
|
-
const
|
|
2080
|
+
const rt = [
|
|
2077
2081
|
"GET",
|
|
2078
2082
|
"POST",
|
|
2079
2083
|
"HEAD",
|
|
@@ -2083,7 +2087,7 @@ const et = [
|
|
|
2083
2087
|
"PUT",
|
|
2084
2088
|
"TRACE"
|
|
2085
2089
|
];
|
|
2086
|
-
function
|
|
2090
|
+
function st(i, e) {
|
|
2087
2091
|
if (e.length < 8)
|
|
2088
2092
|
return !1;
|
|
2089
2093
|
if (i === 443 && e[0] === l.Handshake && // TLS versions between 1.0 and 1.2
|
|
@@ -2092,11 +2096,11 @@ function tt(i, e) {
|
|
|
2092
2096
|
const n = new TextDecoder("latin1", {
|
|
2093
2097
|
fatal: !0
|
|
2094
2098
|
}).decode(e);
|
|
2095
|
-
return
|
|
2099
|
+
return rt.some(
|
|
2096
2100
|
(s) => n.startsWith(s + " ")
|
|
2097
2101
|
) ? "http" : "other";
|
|
2098
2102
|
}
|
|
2099
|
-
class
|
|
2103
|
+
class L {
|
|
2100
2104
|
/**
|
|
2101
2105
|
* Streams a HTTP response including the status line and headers.
|
|
2102
2106
|
*/
|
|
@@ -2106,12 +2110,12 @@ class g {
|
|
|
2106
2110
|
var _;
|
|
2107
2111
|
let r;
|
|
2108
2112
|
try {
|
|
2109
|
-
r = await
|
|
2113
|
+
r = await Re(
|
|
2110
2114
|
e,
|
|
2111
2115
|
void 0,
|
|
2112
2116
|
t
|
|
2113
2117
|
);
|
|
2114
|
-
} catch (
|
|
2118
|
+
} catch (c) {
|
|
2115
2119
|
n.enqueue(
|
|
2116
2120
|
new TextEncoder().encode(
|
|
2117
2121
|
`HTTP/1.1 400 Bad Request\r
|
|
@@ -2119,10 +2123,10 @@ Content-Length: 0\r
|
|
|
2119
2123
|
\r
|
|
2120
2124
|
`
|
|
2121
2125
|
)
|
|
2122
|
-
), n.error(
|
|
2126
|
+
), n.error(c);
|
|
2123
2127
|
return;
|
|
2124
2128
|
}
|
|
2125
|
-
n.enqueue(
|
|
2129
|
+
n.enqueue(L.headersAsBytes(r));
|
|
2126
2130
|
const s = (_ = r.body) == null ? void 0 : _.getReader();
|
|
2127
2131
|
if (!s) {
|
|
2128
2132
|
n.close();
|
|
@@ -2130,12 +2134,12 @@ Content-Length: 0\r
|
|
|
2130
2134
|
}
|
|
2131
2135
|
const a = new TextEncoder();
|
|
2132
2136
|
for (; ; ) {
|
|
2133
|
-
const { done:
|
|
2134
|
-
if (
|
|
2135
|
-
a.encode(`${
|
|
2137
|
+
const { done: c, value: S } = await s.read();
|
|
2138
|
+
if (S && (n.enqueue(
|
|
2139
|
+
a.encode(`${S.length.toString(16)}\r
|
|
2136
2140
|
`)
|
|
2137
|
-
), n.enqueue(
|
|
2138
|
-
`))),
|
|
2141
|
+
), n.enqueue(S), n.enqueue(a.encode(`\r
|
|
2142
|
+
`))), c) {
|
|
2139
2143
|
n.enqueue(a.encode(`0\r
|
|
2140
2144
|
\r
|
|
2141
2145
|
`)), n.close();
|
|
@@ -2167,81 +2171,81 @@ Content-Length: 0\r
|
|
|
2167
2171
|
let r = new Uint8Array(0), s = !1, a = -1;
|
|
2168
2172
|
const _ = e.getReader();
|
|
2169
2173
|
for (; a === -1; ) {
|
|
2170
|
-
const { done: k, value:
|
|
2174
|
+
const { done: k, value: P } = await _.read();
|
|
2171
2175
|
if (k) {
|
|
2172
2176
|
s = !0;
|
|
2173
2177
|
break;
|
|
2174
2178
|
}
|
|
2175
|
-
r = H([r,
|
|
2179
|
+
r = H([r, P]), a = it(
|
|
2176
2180
|
r,
|
|
2177
2181
|
new Uint8Array([13, 10, 13, 10])
|
|
2178
2182
|
);
|
|
2179
2183
|
}
|
|
2180
2184
|
_.releaseLock();
|
|
2181
|
-
const
|
|
2185
|
+
const c = r.slice(0, a), S = L.parseRequestHeaders(c), C = S.headers.get("Transfer-Encoding") !== null ? "chunked" : "content-length", h = S.headers.get("Content-Length") !== null ? parseInt(S.headers.get("Content-Length"), 10) : void 0, A = r.slice(
|
|
2182
2186
|
a + 4
|
|
2183
2187
|
/* Skip \r\n\r\n */
|
|
2184
2188
|
);
|
|
2185
2189
|
let u;
|
|
2186
|
-
if (
|
|
2190
|
+
if (S.method !== "GET") {
|
|
2187
2191
|
const k = e.getReader();
|
|
2188
|
-
let
|
|
2189
|
-
const
|
|
2192
|
+
let P = A.length, q = A.slice(-6);
|
|
2193
|
+
const me = new TextEncoder().encode(`0\r
|
|
2190
2194
|
\r
|
|
2191
2195
|
`);
|
|
2192
2196
|
u = new ReadableStream({
|
|
2193
|
-
async start(
|
|
2194
|
-
A.length > 0 &&
|
|
2195
|
-
const
|
|
2196
|
-
(s ||
|
|
2197
|
+
async start(b) {
|
|
2198
|
+
A.length > 0 && b.enqueue(A);
|
|
2199
|
+
const F = C === "content-length" && h !== void 0 && P >= h;
|
|
2200
|
+
(s || F) && b.close();
|
|
2197
2201
|
},
|
|
2198
|
-
async pull(
|
|
2199
|
-
const { done:
|
|
2200
|
-
if (
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
]).slice(-5)),
|
|
2204
|
-
(
|
|
2202
|
+
async pull(b) {
|
|
2203
|
+
const { done: F, value: I } = await k.read();
|
|
2204
|
+
if (P += (I == null ? void 0 : I.length) || 0, I && (b.enqueue(I), q = H([
|
|
2205
|
+
q,
|
|
2206
|
+
I || new Uint8Array()
|
|
2207
|
+
]).slice(-5)), F || C === "content-length" && h !== void 0 && P >= h || C === "chunked" && q.every(
|
|
2208
|
+
(Le, ge) => Le === me[ge]
|
|
2205
2209
|
)) {
|
|
2206
|
-
|
|
2210
|
+
b.close();
|
|
2207
2211
|
return;
|
|
2208
2212
|
}
|
|
2209
2213
|
}
|
|
2210
2214
|
}), C === "chunked" && (u = u.pipeThrough(
|
|
2211
|
-
new
|
|
2215
|
+
new et()
|
|
2212
2216
|
));
|
|
2213
2217
|
}
|
|
2214
|
-
const T =
|
|
2218
|
+
const T = S.headers.get("Host") ?? t, y = new URL(S.path, n + "://" + T);
|
|
2215
2219
|
return {
|
|
2216
2220
|
request: new Request(y.toString(), {
|
|
2217
|
-
method:
|
|
2218
|
-
headers:
|
|
2221
|
+
method: S.method,
|
|
2222
|
+
headers: S.headers,
|
|
2219
2223
|
body: u,
|
|
2220
2224
|
// @ts-expect-error duplex is required for streaming request bodies
|
|
2221
2225
|
duplex: u ? "half" : void 0
|
|
2222
2226
|
}),
|
|
2223
|
-
expectsContinue:
|
|
2227
|
+
expectsContinue: S.expectsContinue
|
|
2224
2228
|
};
|
|
2225
2229
|
}
|
|
2226
2230
|
static parseRequestHeaders(e) {
|
|
2227
|
-
var
|
|
2231
|
+
var c;
|
|
2228
2232
|
const t = new TextDecoder().decode(e), n = t.split(`
|
|
2229
2233
|
`)[0], [r, s] = n.split(" "), a = new Headers();
|
|
2230
|
-
for (const
|
|
2234
|
+
for (const S of t.split(`\r
|
|
2231
2235
|
`).slice(1)) {
|
|
2232
|
-
if (
|
|
2236
|
+
if (S === "")
|
|
2233
2237
|
break;
|
|
2234
|
-
const C =
|
|
2238
|
+
const C = S.indexOf(":");
|
|
2235
2239
|
if (C === -1)
|
|
2236
2240
|
continue;
|
|
2237
|
-
const h =
|
|
2241
|
+
const h = S.slice(0, C).trim(), A = S.slice(C + 1).trimStart();
|
|
2238
2242
|
h !== "" && a.set(h, A);
|
|
2239
2243
|
}
|
|
2240
|
-
const _ = ((
|
|
2244
|
+
const _ = ((c = a.get("Expect")) == null ? void 0 : c.toLowerCase()) === "100-continue";
|
|
2241
2245
|
return a.delete("Expect"), { method: r, path: s, headers: a, expectsContinue: _ };
|
|
2242
2246
|
}
|
|
2243
2247
|
}
|
|
2244
|
-
function
|
|
2248
|
+
function it(i, e) {
|
|
2245
2249
|
const t = i.length, n = e.length, r = t - n;
|
|
2246
2250
|
for (let s = 0; s <= r; s++) {
|
|
2247
2251
|
let a = !0;
|
|
@@ -2255,7 +2259,7 @@ function nt(i, e) {
|
|
|
2255
2259
|
}
|
|
2256
2260
|
return -1;
|
|
2257
2261
|
}
|
|
2258
|
-
async function
|
|
2262
|
+
async function at(i = oe) {
|
|
2259
2263
|
switch (i) {
|
|
2260
2264
|
case "8.5":
|
|
2261
2265
|
return (await import("@php-wasm/web-8-5")).getIntlExtensionPath();
|
|
@@ -2274,48 +2278,60 @@ async function rt(i = V) {
|
|
|
2274
2278
|
}
|
|
2275
2279
|
throw new Error(`Unsupported PHP version ${i}`);
|
|
2276
2280
|
}
|
|
2277
|
-
async function
|
|
2278
|
-
|
|
2279
|
-
t
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2281
|
+
async function _t(i, e, t, n = []) {
|
|
2282
|
+
if (!n.length)
|
|
2283
|
+
return t;
|
|
2284
|
+
const r = await Promise.all(
|
|
2285
|
+
n.map(
|
|
2286
|
+
(s) => ot(i, e, s)
|
|
2287
|
+
)
|
|
2288
|
+
);
|
|
2289
|
+
return Ie(t, r);
|
|
2290
|
+
}
|
|
2291
|
+
async function ot(i, e, t) {
|
|
2292
|
+
if (typeof t == "object" && "source" in t) {
|
|
2293
|
+
if (e === "asyncify")
|
|
2294
|
+
throw new Error(
|
|
2295
|
+
"External PHP extensions require JSPI. Asyncify is only supported for PHP.wasm bundled extensions."
|
|
2296
|
+
);
|
|
2297
|
+
return await Y({
|
|
2298
|
+
...t,
|
|
2299
|
+
phpVersion: i
|
|
2300
|
+
});
|
|
2301
|
+
}
|
|
2302
|
+
const n = typeof t == "string" ? t : t.name;
|
|
2303
|
+
if (n !== "intl")
|
|
2304
|
+
throw new Error(`Unknown bundled PHP web extension: ${String(n)}.`);
|
|
2305
|
+
const r = Be(fetch), s = await at(i), a = (await import("../intl/shared/icu.dat")).default, [_, c] = await Promise.all(
|
|
2306
|
+
[s, a].map(async (S) => {
|
|
2307
|
+
const C = await r(S);
|
|
2308
|
+
if (!C.ok)
|
|
2309
|
+
throw new Error(
|
|
2310
|
+
`Failed to fetch bundled PHP web extension asset: ${C.url || S} (${C.status} ${C.statusText}).`
|
|
2311
|
+
);
|
|
2312
|
+
return await C.arrayBuffer();
|
|
2313
|
+
})
|
|
2314
|
+
);
|
|
2315
|
+
return await Y({
|
|
2316
|
+
source: {
|
|
2317
|
+
format: "so",
|
|
2318
|
+
name: "intl",
|
|
2319
|
+
bytes: new Uint8Array(_)
|
|
2320
|
+
},
|
|
2321
|
+
phpVersion: i,
|
|
2322
|
+
env: {
|
|
2287
2323
|
ICU_DATA: "/internal/shared"
|
|
2288
2324
|
},
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
`/internal/shared/extensions/${n}`
|
|
2296
|
-
) || c.FS.writeFile(
|
|
2297
|
-
`/internal/shared/extensions/${n}`,
|
|
2298
|
-
new Uint8Array(_)
|
|
2299
|
-
), L.fileExists(
|
|
2300
|
-
c.FS,
|
|
2301
|
-
"/internal/shared/extensions/intl.ini"
|
|
2302
|
-
) || c.FS.writeFile(
|
|
2303
|
-
"/internal/shared/extensions/intl.ini",
|
|
2304
|
-
[
|
|
2305
|
-
`extension=/internal/shared/extensions/${n}`
|
|
2306
|
-
].join(`
|
|
2307
|
-
`)
|
|
2308
|
-
), L.fileExists(
|
|
2309
|
-
c.FS,
|
|
2310
|
-
`${c.ENV.ICU_DATA}/${r}`
|
|
2311
|
-
) || (c.FS.mkdirTree(c.ENV.ICU_DATA), c.FS.writeFile(
|
|
2312
|
-
`${c.ENV.ICU_DATA}/icudt74l.dat`,
|
|
2313
|
-
new Uint8Array(S)
|
|
2314
|
-
));
|
|
2325
|
+
extraFiles: {
|
|
2326
|
+
targetPath: "/internal/shared",
|
|
2327
|
+
files: {
|
|
2328
|
+
// The Intl extension looks for the hard-coded ICU data name.
|
|
2329
|
+
"icudt74l.dat": new Uint8Array(c)
|
|
2330
|
+
}
|
|
2315
2331
|
}
|
|
2316
|
-
};
|
|
2332
|
+
});
|
|
2317
2333
|
}
|
|
2318
|
-
const
|
|
2334
|
+
const ct = () => ({
|
|
2319
2335
|
websocket: {
|
|
2320
2336
|
decorator: (i) => class extends i {
|
|
2321
2337
|
constructor() {
|
|
@@ -2330,40 +2346,47 @@ const it = () => ({
|
|
|
2330
2346
|
}
|
|
2331
2347
|
}
|
|
2332
2348
|
});
|
|
2333
|
-
async function
|
|
2334
|
-
var
|
|
2335
|
-
"setImmediate" in globalThis || (globalThis.setImmediate = (
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
...
|
|
2349
|
+
async function Dt(i, e = {}) {
|
|
2350
|
+
var c;
|
|
2351
|
+
"setImmediate" in globalThis || (globalThis.setImmediate = (S) => setTimeout(S, 0));
|
|
2352
|
+
const t = await Ue() ? "jspi" : "asyncify";
|
|
2353
|
+
let n = {
|
|
2354
|
+
...ct(),
|
|
2355
|
+
...e.emscriptenOptions || {},
|
|
2356
|
+
phpWasmAsyncMode: t
|
|
2339
2357
|
};
|
|
2340
|
-
e.tcpOverFetch && (
|
|
2341
|
-
|
|
2358
|
+
e.tcpOverFetch && (n = tt(
|
|
2359
|
+
n,
|
|
2342
2360
|
e.tcpOverFetch
|
|
2343
2361
|
));
|
|
2344
|
-
const
|
|
2345
|
-
if (
|
|
2346
|
-
const
|
|
2347
|
-
|
|
2348
|
-
...
|
|
2349
|
-
preRun: [...
|
|
2362
|
+
const r = Ke(i), s = [...e.extensions ?? []];
|
|
2363
|
+
if (e.withIntl && !St(s, "intl") && s.push("intl"), r) {
|
|
2364
|
+
const S = await n, C = S.preRun || [];
|
|
2365
|
+
n = {
|
|
2366
|
+
...S,
|
|
2367
|
+
preRun: [...C, De()]
|
|
2350
2368
|
};
|
|
2351
2369
|
}
|
|
2352
|
-
if (
|
|
2370
|
+
if (r && s.length)
|
|
2353
2371
|
throw new Error(
|
|
2354
|
-
`
|
|
2372
|
+
`Extensions are not available for legacy PHP ${i}.`
|
|
2355
2373
|
);
|
|
2356
|
-
|
|
2374
|
+
r || (n = _t(
|
|
2357
2375
|
i,
|
|
2358
|
-
t
|
|
2376
|
+
t,
|
|
2377
|
+
await n,
|
|
2378
|
+
s
|
|
2359
2379
|
));
|
|
2360
|
-
const [
|
|
2361
|
-
|
|
2362
|
-
|
|
2380
|
+
const [a, _] = await Promise.all([
|
|
2381
|
+
xe(i),
|
|
2382
|
+
n
|
|
2363
2383
|
]);
|
|
2364
|
-
return (
|
|
2384
|
+
return (c = e.onPhpLoaderModuleLoaded) == null || c.call(e, a), await We(a, _);
|
|
2385
|
+
}
|
|
2386
|
+
function St(i, e) {
|
|
2387
|
+
return i.some((t) => typeof t == "string" ? t === e : !("source" in t) && t.name === e);
|
|
2365
2388
|
}
|
|
2366
|
-
function
|
|
2389
|
+
function Wt(i, e) {
|
|
2367
2390
|
window.addEventListener("message", (t) => {
|
|
2368
2391
|
t.source === i.contentWindow && (e && t.origin !== e || typeof t.data != "object" || t.data.type !== "relay" || window.parent.postMessage(t.data, "*"));
|
|
2369
2392
|
}), window.addEventListener("message", (t) => {
|
|
@@ -2371,7 +2394,7 @@ function yt(i, e) {
|
|
|
2371
2394
|
t.source === window.parent && (typeof t.data != "object" || t.data.type !== "relay" || (n = i == null ? void 0 : i.contentWindow) == null || n.postMessage(t.data));
|
|
2372
2395
|
});
|
|
2373
2396
|
}
|
|
2374
|
-
async function
|
|
2397
|
+
async function Pt(i) {
|
|
2375
2398
|
const e = new Worker(i, { type: "module" });
|
|
2376
2399
|
return new Promise((t, n) => {
|
|
2377
2400
|
e.onerror = (s) => {
|
|
@@ -2386,8 +2409,8 @@ async function mt(i) {
|
|
|
2386
2409
|
e.addEventListener("message", r);
|
|
2387
2410
|
});
|
|
2388
2411
|
}
|
|
2389
|
-
const
|
|
2390
|
-
function
|
|
2412
|
+
const Ct = 1e3;
|
|
2413
|
+
function bt(i, e = { initialSync: {} }) {
|
|
2391
2414
|
return e = {
|
|
2392
2415
|
...e,
|
|
2393
2416
|
initialSync: {
|
|
@@ -2396,59 +2419,59 @@ function gt(i, e = { initialSync: {} }) {
|
|
|
2396
2419
|
}
|
|
2397
2420
|
}, async function(t, n, r) {
|
|
2398
2421
|
var a;
|
|
2399
|
-
e.initialSync.direction === "opfs-to-memfs" ? (
|
|
2422
|
+
e.initialSync.direction === "opfs-to-memfs" ? (M.fileExists(n, r) && M.rmdir(n, r), M.mkdir(n, r), await lt(n, i, r)) : await ye(
|
|
2400
2423
|
n,
|
|
2401
2424
|
i,
|
|
2402
2425
|
r,
|
|
2403
2426
|
e.initialSync.onProgress
|
|
2404
2427
|
);
|
|
2405
|
-
const s =
|
|
2428
|
+
const s = At(t, i, r);
|
|
2406
2429
|
return (a = e.onMount) == null || a.call(e, s), s.unmount;
|
|
2407
2430
|
};
|
|
2408
2431
|
}
|
|
2409
|
-
async function
|
|
2410
|
-
|
|
2411
|
-
const n = new
|
|
2432
|
+
async function lt(i, e, t) {
|
|
2433
|
+
M.mkdir(i, t);
|
|
2434
|
+
const n = new Pe({
|
|
2412
2435
|
concurrency: 40
|
|
2413
2436
|
}), r = [], s = [
|
|
2414
2437
|
[e, t]
|
|
2415
2438
|
];
|
|
2416
2439
|
for (; s.length > 0; ) {
|
|
2417
2440
|
const [a, _] = s.pop();
|
|
2418
|
-
for await (const
|
|
2419
|
-
const
|
|
2420
|
-
const C =
|
|
2441
|
+
for await (const c of a.values()) {
|
|
2442
|
+
const S = n.run(async () => {
|
|
2443
|
+
const C = ce(
|
|
2421
2444
|
_,
|
|
2422
|
-
|
|
2445
|
+
c.name
|
|
2423
2446
|
);
|
|
2424
|
-
if (
|
|
2447
|
+
if (c.kind === "directory") {
|
|
2425
2448
|
try {
|
|
2426
2449
|
i.mkdir(C);
|
|
2427
2450
|
} catch (h) {
|
|
2428
2451
|
if ((h == null ? void 0 : h.errno) !== 20)
|
|
2429
|
-
throw
|
|
2452
|
+
throw B.error(h), h;
|
|
2430
2453
|
}
|
|
2431
|
-
s.push([
|
|
2432
|
-
} else if (
|
|
2433
|
-
const h = await
|
|
2454
|
+
s.push([c, C]);
|
|
2455
|
+
} else if (c.kind === "file") {
|
|
2456
|
+
const h = await c.getFile(), A = new Uint8Array(await h.arrayBuffer());
|
|
2434
2457
|
i.createDataFile(
|
|
2435
2458
|
_,
|
|
2436
|
-
|
|
2459
|
+
c.name,
|
|
2437
2460
|
A,
|
|
2438
2461
|
!0,
|
|
2439
2462
|
!0,
|
|
2440
2463
|
!0
|
|
2441
2464
|
);
|
|
2442
2465
|
}
|
|
2443
|
-
r.splice(r.indexOf(
|
|
2466
|
+
r.splice(r.indexOf(S), 1);
|
|
2444
2467
|
});
|
|
2445
|
-
r.push(
|
|
2468
|
+
r.push(S);
|
|
2446
2469
|
}
|
|
2447
2470
|
for (; s.length === 0 && r.length > 0; )
|
|
2448
2471
|
await Promise.any(r);
|
|
2449
2472
|
}
|
|
2450
2473
|
}
|
|
2451
|
-
async function
|
|
2474
|
+
async function ye(i, e, t, n) {
|
|
2452
2475
|
i.mkdirTree(t);
|
|
2453
2476
|
const r = [];
|
|
2454
2477
|
async function s(C, h) {
|
|
@@ -2456,8 +2479,8 @@ async function we(i, e, t, n) {
|
|
|
2456
2479
|
i.readdir(C).filter(
|
|
2457
2480
|
(A) => A !== "." && A !== ".."
|
|
2458
2481
|
).map(async (A) => {
|
|
2459
|
-
const u =
|
|
2460
|
-
if (!
|
|
2482
|
+
const u = ce(C, A);
|
|
2483
|
+
if (!ht(i, u)) {
|
|
2461
2484
|
r.push([h, u, A]);
|
|
2462
2485
|
return;
|
|
2463
2486
|
}
|
|
@@ -2470,7 +2493,7 @@ async function we(i, e, t, n) {
|
|
|
2470
2493
|
}
|
|
2471
2494
|
await s(t, e);
|
|
2472
2495
|
let a = 0;
|
|
2473
|
-
const _ = n &&
|
|
2496
|
+
const _ = n && dt(n, 100), c = 100, S = /* @__PURE__ */ new Set();
|
|
2474
2497
|
try {
|
|
2475
2498
|
for (const [C, h, A] of r) {
|
|
2476
2499
|
const u = $(
|
|
@@ -2479,21 +2502,21 @@ async function we(i, e, t, n) {
|
|
|
2479
2502
|
i,
|
|
2480
2503
|
h
|
|
2481
2504
|
).then(() => {
|
|
2482
|
-
a++,
|
|
2505
|
+
a++, S.delete(u), _ == null || _({
|
|
2483
2506
|
files: a,
|
|
2484
2507
|
total: r.length
|
|
2485
2508
|
});
|
|
2486
2509
|
});
|
|
2487
|
-
|
|
2510
|
+
S.add(u), S.size >= c && (await Promise.race(S), _ == null || _({
|
|
2488
2511
|
files: a,
|
|
2489
2512
|
total: r.length
|
|
2490
2513
|
}));
|
|
2491
2514
|
}
|
|
2492
2515
|
} finally {
|
|
2493
|
-
await Promise.allSettled(
|
|
2516
|
+
await Promise.allSettled(S);
|
|
2494
2517
|
}
|
|
2495
2518
|
}
|
|
2496
|
-
function
|
|
2519
|
+
function ht(i, e) {
|
|
2497
2520
|
return i.isDir(i.lookupPath(e, { follow: !0 }).node.mode);
|
|
2498
2521
|
}
|
|
2499
2522
|
async function $(i, e, t, n) {
|
|
@@ -2518,35 +2541,35 @@ async function $(i, e, t, n) {
|
|
|
2518
2541
|
await a.close();
|
|
2519
2542
|
}
|
|
2520
2543
|
}
|
|
2521
|
-
function
|
|
2522
|
-
const r = [], s =
|
|
2544
|
+
function At(i, e, t, n = {}) {
|
|
2545
|
+
const r = [], s = ve(i, t, (u) => {
|
|
2523
2546
|
r.push(u);
|
|
2524
|
-
}), a = new
|
|
2547
|
+
}), a = new ut(i, e, t);
|
|
2525
2548
|
let _;
|
|
2526
|
-
function
|
|
2549
|
+
function c() {
|
|
2527
2550
|
return _ === void 0 && (_ = h().finally(() => {
|
|
2528
2551
|
_ = void 0;
|
|
2529
2552
|
})), _;
|
|
2530
2553
|
}
|
|
2531
|
-
async function
|
|
2554
|
+
async function S() {
|
|
2532
2555
|
try {
|
|
2533
|
-
await
|
|
2556
|
+
await c();
|
|
2534
2557
|
} finally {
|
|
2535
2558
|
s(), i.removeEventListener("request.end", C), i.removeEventListener("filesystem.write", C);
|
|
2536
2559
|
}
|
|
2537
2560
|
}
|
|
2538
2561
|
function C() {
|
|
2539
|
-
|
|
2540
|
-
|
|
2562
|
+
c().catch((u) => {
|
|
2563
|
+
B.error(u);
|
|
2541
2564
|
});
|
|
2542
2565
|
}
|
|
2543
2566
|
async function h() {
|
|
2544
|
-
const u = n.maxFlushPasses ??
|
|
2567
|
+
const u = n.maxFlushPasses ?? Ct;
|
|
2545
2568
|
for (let T = 0; r.length > 0; T++) {
|
|
2546
2569
|
if (T >= u) {
|
|
2547
|
-
const y = r.length,
|
|
2570
|
+
const y = r.length, U = y === 1 ? `${y} journal entry remains` : `${y} journal entries remain`;
|
|
2548
2571
|
throw new Error(
|
|
2549
|
-
`OPFS flush for "${t}" did not settle after ${u} journal batches; ${
|
|
2572
|
+
`OPFS flush for "${t}" did not settle after ${u} journal batches; ${U}. This can happen when filesystem writes are continuously enqueued while flushing.`
|
|
2550
2573
|
);
|
|
2551
2574
|
}
|
|
2552
2575
|
await A();
|
|
@@ -2557,20 +2580,20 @@ function ct(i, e, t, n = {}) {
|
|
|
2557
2580
|
return;
|
|
2558
2581
|
const u = await i.semaphore.acquire(), T = [...r];
|
|
2559
2582
|
r.splice(0, T.length);
|
|
2560
|
-
const y =
|
|
2583
|
+
const y = Me(T);
|
|
2561
2584
|
try {
|
|
2562
|
-
for (const
|
|
2563
|
-
await a.processEntry(
|
|
2585
|
+
for (const U of y)
|
|
2586
|
+
await a.processEntry(U);
|
|
2564
2587
|
} finally {
|
|
2565
2588
|
u();
|
|
2566
2589
|
}
|
|
2567
2590
|
}
|
|
2568
2591
|
return i.addEventListener("request.end", C), i.addEventListener("filesystem.write", C), {
|
|
2569
|
-
flush:
|
|
2570
|
-
unmount:
|
|
2592
|
+
flush: c,
|
|
2593
|
+
unmount: S
|
|
2571
2594
|
};
|
|
2572
2595
|
}
|
|
2573
|
-
class
|
|
2596
|
+
class ut {
|
|
2574
2597
|
constructor(e, t, n) {
|
|
2575
2598
|
this.php = e, this.opfs = t, this.memfsRoot = ae(n);
|
|
2576
2599
|
}
|
|
@@ -2580,7 +2603,7 @@ class St {
|
|
|
2580
2603
|
async processEntry(e) {
|
|
2581
2604
|
if (!e.path.startsWith(this.memfsRoot) || e.path === this.memfsRoot)
|
|
2582
2605
|
return;
|
|
2583
|
-
const t = this.toOpfsPath(e.path), n = await _e(this.opfs, t), r =
|
|
2606
|
+
const t = this.toOpfsPath(e.path), n = await _e(this.opfs, t), r = Ht(t);
|
|
2584
2607
|
if (r)
|
|
2585
2608
|
try {
|
|
2586
2609
|
if (e.operation === "DELETE")
|
|
@@ -2615,7 +2638,7 @@ class St {
|
|
|
2615
2638
|
create: !0
|
|
2616
2639
|
}
|
|
2617
2640
|
);
|
|
2618
|
-
await
|
|
2641
|
+
await ye(
|
|
2619
2642
|
this.php[O].FS,
|
|
2620
2643
|
_,
|
|
2621
2644
|
e.toPath
|
|
@@ -2629,21 +2652,21 @@ class St {
|
|
|
2629
2652
|
}
|
|
2630
2653
|
await $(
|
|
2631
2654
|
a,
|
|
2632
|
-
|
|
2655
|
+
be(s),
|
|
2633
2656
|
this.php[O].FS,
|
|
2634
2657
|
e.toPath
|
|
2635
2658
|
);
|
|
2636
2659
|
}
|
|
2637
2660
|
}
|
|
2638
2661
|
} catch (s) {
|
|
2639
|
-
throw
|
|
2662
|
+
throw B.log({ entry: e, name: r }), B.error(s), s;
|
|
2640
2663
|
}
|
|
2641
2664
|
}
|
|
2642
2665
|
}
|
|
2643
2666
|
function ae(i) {
|
|
2644
2667
|
return i.replace(/\/$/, "").replace(/\/\/+/g, "/");
|
|
2645
2668
|
}
|
|
2646
|
-
function
|
|
2669
|
+
function Ht(i) {
|
|
2647
2670
|
return i.substring(i.lastIndexOf("/") + 1);
|
|
2648
2671
|
}
|
|
2649
2672
|
async function _e(i, e) {
|
|
@@ -2658,31 +2681,31 @@ async function _e(i, e) {
|
|
|
2658
2681
|
}
|
|
2659
2682
|
return r;
|
|
2660
2683
|
}
|
|
2661
|
-
function
|
|
2684
|
+
function dt(i, e) {
|
|
2662
2685
|
let t = 0, n, r;
|
|
2663
2686
|
return function(...a) {
|
|
2664
2687
|
r = a;
|
|
2665
2688
|
const _ = Date.now() - t;
|
|
2666
2689
|
if (n === void 0) {
|
|
2667
|
-
const
|
|
2690
|
+
const c = Math.max(0, e - _);
|
|
2668
2691
|
n = setTimeout(() => {
|
|
2669
2692
|
n = void 0, t = Date.now(), i(...r);
|
|
2670
|
-
},
|
|
2693
|
+
}, c);
|
|
2671
2694
|
}
|
|
2672
2695
|
};
|
|
2673
2696
|
}
|
|
2674
2697
|
export {
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2698
|
+
xt as FirewallInterferenceError,
|
|
2699
|
+
gt as certificateToPEM,
|
|
2700
|
+
Ut as consumeAPI,
|
|
2701
|
+
bt as createDirectoryHandleMountHandler,
|
|
2702
|
+
vt as exposeAPI,
|
|
2703
|
+
Nt as fetchWithCorsProxy,
|
|
2704
|
+
Ze as generateCertificate,
|
|
2705
|
+
xe as getPHPLoaderModule,
|
|
2706
|
+
Dt as loadWebRuntime,
|
|
2707
|
+
It as privateKeyToPEM,
|
|
2708
|
+
Wt as setupPostMessageRelay,
|
|
2709
|
+
Pt as spawnPHPWorkerThread
|
|
2687
2710
|
};
|
|
2688
2711
|
//# sourceMappingURL=index.js.map
|