@php-wasm/web 3.1.19 → 3.1.21
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 +38 -3
- package/index.cjs +17 -17
- package/index.cjs.map +1 -1
- package/index.js +383 -330
- package/index.js.map +1 -1
- package/lib/directory-handle-mount.d.ts +9 -1
- package/lib/get-php-loader-module.d.ts +2 -2
- package/lib/index.d.ts +1 -1
- package/lib/load-runtime.d.ts +2 -2
- package/package.json +20 -18
package/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { LatestSupportedPHPVersion as
|
|
2
|
-
import { consumeAPI as
|
|
3
|
-
import { concatArrayBuffers as
|
|
1
|
+
import { LatestSupportedPHPVersion as V, FSHelpers as L, isLegacyPHPVersion as ge, createLegacyPhpIniPreRunStep as Ie, loadPHPRuntime as Ke, __private__dont__use as O } from "@php-wasm/universal";
|
|
2
|
+
import { consumeAPI as Dt, exposeAPI as Wt } from "@php-wasm/universal";
|
|
3
|
+
import { concatArrayBuffers as v, concatUint8Arrays as H, Semaphore as De, joinPaths as oe, basename as We } from "@php-wasm/util";
|
|
4
4
|
import { logger as U } from "@php-wasm/logger";
|
|
5
|
-
import { fetchWithCorsProxy as
|
|
6
|
-
import { FirewallInterferenceError as
|
|
7
|
-
import { createMemoizedFetch as
|
|
8
|
-
import { journalFSEvents as
|
|
9
|
-
async function
|
|
5
|
+
import { fetchWithCorsProxy as Pe } from "@php-wasm/web-service-worker";
|
|
6
|
+
import { FirewallInterferenceError as bt, fetchWithCorsProxy as Rt } from "@php-wasm/web-service-worker";
|
|
7
|
+
import { createMemoizedFetch as be } from "@wp-playground/common";
|
|
8
|
+
import { journalFSEvents as Re, normalizeFilesystemOperations as Be } from "@php-wasm/fs-journal";
|
|
9
|
+
async function Ue(i = V) {
|
|
10
10
|
switch (i) {
|
|
11
11
|
case "8.5":
|
|
12
12
|
return (await import("@php-wasm/web-8-5")).getPHPLoaderModule();
|
|
@@ -22,27 +22,29 @@ async function Pe(i = G) {
|
|
|
22
22
|
return (await import("@php-wasm/web-8-0")).getPHPLoaderModule();
|
|
23
23
|
case "7.4":
|
|
24
24
|
return (await import("@php-wasm/web-7-4")).getPHPLoaderModule();
|
|
25
|
+
case "5.2":
|
|
26
|
+
return (await import("@php-wasm/web-5-2")).getPHPLoaderModule();
|
|
25
27
|
}
|
|
26
28
|
throw new Error(`Unsupported PHP version ${i}`);
|
|
27
29
|
}
|
|
28
|
-
function
|
|
30
|
+
function p(i) {
|
|
29
31
|
return Object.fromEntries(Object.entries(i).map(([e, t]) => [t, e]));
|
|
30
32
|
}
|
|
31
|
-
function
|
|
33
|
+
function W(i) {
|
|
32
34
|
return new Uint8Array([i >> 8 & 255, i & 255]);
|
|
33
35
|
}
|
|
34
|
-
function
|
|
36
|
+
function m(i) {
|
|
35
37
|
return new Uint8Array([
|
|
36
38
|
i >> 16 & 255,
|
|
37
39
|
i >> 8 & 255,
|
|
38
40
|
i & 255
|
|
39
41
|
]);
|
|
40
42
|
}
|
|
41
|
-
function
|
|
43
|
+
function Z(i) {
|
|
42
44
|
const e = new ArrayBuffer(8);
|
|
43
45
|
return new DataView(e).setBigUint64(0, BigInt(i), !1), new Uint8Array(e);
|
|
44
46
|
}
|
|
45
|
-
class
|
|
47
|
+
class I {
|
|
46
48
|
constructor(e) {
|
|
47
49
|
this.offset = 0, this.buffer = e, this.view = new DataView(e);
|
|
48
50
|
}
|
|
@@ -66,7 +68,7 @@ class m {
|
|
|
66
68
|
return this.offset >= this.buffer.byteLength;
|
|
67
69
|
}
|
|
68
70
|
}
|
|
69
|
-
class
|
|
71
|
+
class N {
|
|
70
72
|
constructor(e) {
|
|
71
73
|
this.offset = 0, this.buffer = new ArrayBuffer(e), this.uint8Array = new Uint8Array(this.buffer), this.view = new DataView(this.buffer);
|
|
72
74
|
}
|
|
@@ -83,7 +85,7 @@ class x {
|
|
|
83
85
|
this.uint8Array.set(e, this.offset), this.offset += e.length;
|
|
84
86
|
}
|
|
85
87
|
}
|
|
86
|
-
const
|
|
88
|
+
const P = {
|
|
87
89
|
server_name: 0,
|
|
88
90
|
max_fragment_length: 1,
|
|
89
91
|
client_certificate_url: 2,
|
|
@@ -138,10 +140,10 @@ const D = {
|
|
|
138
140
|
transparency_info: 52,
|
|
139
141
|
connection_id: 54,
|
|
140
142
|
renegotiation_info: 65281
|
|
141
|
-
},
|
|
143
|
+
}, xe = p(P), ce = {
|
|
142
144
|
host_name: 0
|
|
143
|
-
},
|
|
144
|
-
class
|
|
145
|
+
}, ve = p(ce);
|
|
146
|
+
class Se {
|
|
145
147
|
static decodeFromClient(e) {
|
|
146
148
|
const t = new DataView(e.buffer);
|
|
147
149
|
let n = 0;
|
|
@@ -155,9 +157,9 @@ class oe {
|
|
|
155
157
|
n += 2;
|
|
156
158
|
const S = e.slice(n, n + _);
|
|
157
159
|
switch (n += _, a) {
|
|
158
|
-
case
|
|
160
|
+
case ce.host_name:
|
|
159
161
|
s.push({
|
|
160
|
-
name_type:
|
|
162
|
+
name_type: ve[a],
|
|
161
163
|
name: {
|
|
162
164
|
host_name: new TextDecoder().decode(S)
|
|
163
165
|
}
|
|
@@ -185,16 +187,16 @@ class oe {
|
|
|
185
187
|
throw new Error(
|
|
186
188
|
"Encoding non-empty lists for ClientHello is not supported yet. Only empty lists meant for ServerHello are supported today."
|
|
187
189
|
);
|
|
188
|
-
const t = new
|
|
189
|
-
return t.writeUint16(
|
|
190
|
+
const t = new N(4);
|
|
191
|
+
return t.writeUint16(P.server_name), t.writeUint16(0), t.uint8Array;
|
|
190
192
|
}
|
|
191
193
|
}
|
|
192
|
-
const
|
|
194
|
+
const Ce = {
|
|
193
195
|
uncompressed: 0,
|
|
194
196
|
ansiX962_compressed_prime: 1,
|
|
195
197
|
ansiX962_compressed_char2: 2
|
|
196
|
-
},
|
|
197
|
-
class
|
|
198
|
+
}, X = p(Ce);
|
|
199
|
+
class le {
|
|
198
200
|
/**
|
|
199
201
|
* +--------------------------------------------------+
|
|
200
202
|
* | Payload Length [2B] |
|
|
@@ -211,10 +213,10 @@ class Se {
|
|
|
211
213
|
* +--------------------------------------------------+
|
|
212
214
|
*/
|
|
213
215
|
static decodeFromClient(e) {
|
|
214
|
-
const t = new
|
|
216
|
+
const t = new I(e.buffer), n = t.readUint8(), r = [];
|
|
215
217
|
for (let s = 0; s < n; s++) {
|
|
216
218
|
const a = t.readUint8();
|
|
217
|
-
a in
|
|
219
|
+
a in X && r.push(X[a]);
|
|
218
220
|
}
|
|
219
221
|
return r;
|
|
220
222
|
}
|
|
@@ -233,11 +235,11 @@ class Se {
|
|
|
233
235
|
* +--------------------------------------------------+
|
|
234
236
|
*/
|
|
235
237
|
static encodeForClient(e) {
|
|
236
|
-
const t = new
|
|
237
|
-
return t.writeUint16(
|
|
238
|
+
const t = new N(6);
|
|
239
|
+
return t.writeUint16(P.ec_point_formats), t.writeUint16(2), t.writeUint8(1), t.writeUint8(Ce[e]), t.uint8Array;
|
|
238
240
|
}
|
|
239
241
|
}
|
|
240
|
-
const
|
|
242
|
+
const he = {
|
|
241
243
|
decodeFromClient(i) {
|
|
242
244
|
const e = i[0] ?? 0;
|
|
243
245
|
return {
|
|
@@ -249,7 +251,7 @@ const Ce = {
|
|
|
249
251
|
* with an empty renegotiated_connection field.
|
|
250
252
|
*/
|
|
251
253
|
encodeForClient() {
|
|
252
|
-
const i =
|
|
254
|
+
const i = P.renegotiation_info, e = new Uint8Array([0]);
|
|
253
255
|
return new Uint8Array([
|
|
254
256
|
i >> 8 & 255,
|
|
255
257
|
i & 255,
|
|
@@ -258,7 +260,7 @@ const Ce = {
|
|
|
258
260
|
...e
|
|
259
261
|
]);
|
|
260
262
|
}
|
|
261
|
-
},
|
|
263
|
+
}, Ae = {
|
|
262
264
|
TLS1_CK_PSK_WITH_RC4_128_SHA: 138,
|
|
263
265
|
TLS1_CK_PSK_WITH_3DES_EDE_CBC_SHA: 139,
|
|
264
266
|
TLS1_CK_PSK_WITH_AES_128_CBC_SHA: 140,
|
|
@@ -461,14 +463,14 @@ const Ce = {
|
|
|
461
463
|
TLS1_CK_ECDHE_PSK_WITH_CHACHA20_POLY1305: 52396,
|
|
462
464
|
TLS1_CK_DHE_PSK_WITH_CHACHA20_POLY1305: 52397,
|
|
463
465
|
TLS1_CK_RSA_PSK_WITH_CHACHA20_POLY1305: 52398
|
|
464
|
-
},
|
|
466
|
+
}, J = p(Ae), ue = {
|
|
465
467
|
secp256r1: 23,
|
|
466
468
|
secp384r1: 24,
|
|
467
469
|
secp521r1: 25,
|
|
468
470
|
x25519: 29,
|
|
469
471
|
x448: 30
|
|
470
|
-
},
|
|
471
|
-
class
|
|
472
|
+
}, Q = p(ue);
|
|
473
|
+
class Me {
|
|
472
474
|
/**
|
|
473
475
|
* +--------------------------------------------------+
|
|
474
476
|
* | Payload Length [2B] |
|
|
@@ -485,12 +487,12 @@ class Ue {
|
|
|
485
487
|
* +--------------------------------------------------+
|
|
486
488
|
*/
|
|
487
489
|
static decodeFromClient(e) {
|
|
488
|
-
const t = new
|
|
490
|
+
const t = new I(e.buffer);
|
|
489
491
|
t.readUint16();
|
|
490
492
|
const n = [];
|
|
491
493
|
for (; !t.isFinished(); ) {
|
|
492
494
|
const r = t.readUint16();
|
|
493
|
-
r in
|
|
495
|
+
r in Q && n.push(Q[r]);
|
|
494
496
|
}
|
|
495
497
|
return n;
|
|
496
498
|
}
|
|
@@ -505,16 +507,16 @@ class Ue {
|
|
|
505
507
|
* +--------------------------------------------------+
|
|
506
508
|
*/
|
|
507
509
|
static encodeForClient(e) {
|
|
508
|
-
const t = new
|
|
509
|
-
return t.writeUint16(
|
|
510
|
+
const t = new N(6);
|
|
511
|
+
return t.writeUint16(P.supported_groups), t.writeUint16(2), t.writeUint16(ue[e]), t.uint8Array;
|
|
510
512
|
}
|
|
511
513
|
}
|
|
512
|
-
const
|
|
514
|
+
const z = {
|
|
513
515
|
anonymous: 0,
|
|
514
516
|
rsa: 1,
|
|
515
517
|
dsa: 2,
|
|
516
518
|
ecdsa: 3
|
|
517
|
-
},
|
|
519
|
+
}, ee = p(z), Y = {
|
|
518
520
|
none: 0,
|
|
519
521
|
md5: 1,
|
|
520
522
|
sha1: 2,
|
|
@@ -522,8 +524,8 @@ const $ = {
|
|
|
522
524
|
sha256: 4,
|
|
523
525
|
sha384: 5,
|
|
524
526
|
sha512: 6
|
|
525
|
-
},
|
|
526
|
-
class
|
|
527
|
+
}, te = p(Y);
|
|
528
|
+
class Ne {
|
|
527
529
|
/**
|
|
528
530
|
* Binary layout:
|
|
529
531
|
*
|
|
@@ -540,19 +542,19 @@ class xe {
|
|
|
540
542
|
* +------------------------------------+
|
|
541
543
|
*/
|
|
542
544
|
static decodeFromClient(e) {
|
|
543
|
-
const t = new
|
|
545
|
+
const t = new I(e.buffer);
|
|
544
546
|
t.readUint16();
|
|
545
547
|
const n = [];
|
|
546
548
|
for (; !t.isFinished(); ) {
|
|
547
549
|
const r = t.readUint8(), s = t.readUint8();
|
|
548
|
-
if (
|
|
549
|
-
if (!
|
|
550
|
+
if (ee[s]) {
|
|
551
|
+
if (!te[r]) {
|
|
550
552
|
U.warn(`Unknown hash algorithm: ${r}`);
|
|
551
553
|
continue;
|
|
552
554
|
}
|
|
553
555
|
n.push({
|
|
554
|
-
algorithm:
|
|
555
|
-
hash:
|
|
556
|
+
algorithm: ee[s],
|
|
557
|
+
hash: te[r]
|
|
556
558
|
});
|
|
557
559
|
}
|
|
558
560
|
}
|
|
@@ -570,24 +572,24 @@ class xe {
|
|
|
570
572
|
* +--------------------------------------------------+
|
|
571
573
|
*/
|
|
572
574
|
static encodeforClient(e, t) {
|
|
573
|
-
const n = new
|
|
574
|
-
return n.writeUint16(
|
|
575
|
+
const n = new N(6);
|
|
576
|
+
return n.writeUint16(P.signature_algorithms), n.writeUint16(2), n.writeUint8(Y[e]), n.writeUint8(z[t]), n.uint8Array;
|
|
575
577
|
}
|
|
576
578
|
}
|
|
577
|
-
const
|
|
578
|
-
server_name:
|
|
579
|
-
signature_algorithms:
|
|
580
|
-
supported_groups:
|
|
581
|
-
ec_point_formats:
|
|
582
|
-
renegotiation_info:
|
|
579
|
+
const ne = {
|
|
580
|
+
server_name: Se,
|
|
581
|
+
signature_algorithms: Ne,
|
|
582
|
+
supported_groups: Me,
|
|
583
|
+
ec_point_formats: le,
|
|
584
|
+
renegotiation_info: he
|
|
583
585
|
};
|
|
584
|
-
function
|
|
585
|
-
const e = new
|
|
586
|
+
function ke(i) {
|
|
587
|
+
const e = new I(i.buffer), t = [];
|
|
586
588
|
for (; !e.isFinished(); ) {
|
|
587
|
-
const n = e.offset, r = e.readUint16(), s =
|
|
588
|
-
if (!(s in
|
|
589
|
+
const n = e.offset, r = e.readUint16(), s = xe[r], a = e.readUint16(), _ = e.readUint8Array(a);
|
|
590
|
+
if (!(s in ne))
|
|
589
591
|
continue;
|
|
590
|
-
const S =
|
|
592
|
+
const S = ne[s];
|
|
591
593
|
t.push({
|
|
592
594
|
type: s,
|
|
593
595
|
data: S.decodeFromClient(_),
|
|
@@ -596,8 +598,8 @@ function Me(i) {
|
|
|
596
598
|
}
|
|
597
599
|
return t;
|
|
598
600
|
}
|
|
599
|
-
async function
|
|
600
|
-
const r =
|
|
601
|
+
async function G(i, e, t, n) {
|
|
602
|
+
const r = v([e, t]), s = await crypto.subtle.importKey(
|
|
601
603
|
"raw",
|
|
602
604
|
i,
|
|
603
605
|
{ name: "HMAC", hash: { name: "SHA-256" } },
|
|
@@ -606,26 +608,26 @@ async function O(i, e, t, n) {
|
|
|
606
608
|
);
|
|
607
609
|
let a = r;
|
|
608
610
|
const _ = [];
|
|
609
|
-
for (;
|
|
610
|
-
a = await
|
|
611
|
-
const c =
|
|
611
|
+
for (; v(_).byteLength < n; ) {
|
|
612
|
+
a = await re(s, a);
|
|
613
|
+
const c = v([a, r]), C = await re(s, c);
|
|
612
614
|
_.push(C);
|
|
613
615
|
}
|
|
614
|
-
return
|
|
616
|
+
return v(_).slice(0, n);
|
|
615
617
|
}
|
|
616
|
-
async function
|
|
618
|
+
async function re(i, e) {
|
|
617
619
|
return await crypto.subtle.sign(
|
|
618
620
|
{ name: "HMAC", hash: "SHA-256" },
|
|
619
621
|
i,
|
|
620
622
|
e
|
|
621
623
|
);
|
|
622
624
|
}
|
|
623
|
-
const
|
|
625
|
+
const Fe = {
|
|
624
626
|
Null: 0
|
|
625
|
-
},
|
|
627
|
+
}, He = {
|
|
626
628
|
Warning: 1,
|
|
627
629
|
Fatal: 2
|
|
628
|
-
},
|
|
630
|
+
}, de = p(He), fe = {
|
|
629
631
|
CloseNotify: 0,
|
|
630
632
|
UnexpectedMessage: 10,
|
|
631
633
|
BadRecordMac: 20,
|
|
@@ -651,12 +653,12 @@ const ve = {
|
|
|
651
653
|
UserCanceled: 90,
|
|
652
654
|
NoRenegotiation: 100,
|
|
653
655
|
UnsupportedExtension: 110
|
|
654
|
-
},
|
|
656
|
+
}, Ee = p(fe), l = {
|
|
655
657
|
ChangeCipherSpec: 20,
|
|
656
658
|
Alert: 21,
|
|
657
659
|
Handshake: 22,
|
|
658
660
|
ApplicationData: 23
|
|
659
|
-
},
|
|
661
|
+
}, f = {
|
|
660
662
|
HelloRequest: 0,
|
|
661
663
|
ClientHello: 1,
|
|
662
664
|
ServerHello: 2,
|
|
@@ -665,7 +667,7 @@ const ve = {
|
|
|
665
667
|
ServerHelloDone: 14,
|
|
666
668
|
ClientKeyExchange: 16,
|
|
667
669
|
Finished: 20
|
|
668
|
-
},
|
|
670
|
+
}, qe = {
|
|
669
671
|
/**
|
|
670
672
|
* Indicates that a named curve is used. This option
|
|
671
673
|
* SHOULD be used when applicable.
|
|
@@ -674,12 +676,12 @@ const ve = {
|
|
|
674
676
|
/**
|
|
675
677
|
* Values 248 through 255 are reserved for private use.
|
|
676
678
|
*/
|
|
677
|
-
},
|
|
679
|
+
}, Oe = {
|
|
678
680
|
secp256r1: 23
|
|
679
681
|
};
|
|
680
|
-
class
|
|
682
|
+
class j extends Error {
|
|
681
683
|
}
|
|
682
|
-
const
|
|
684
|
+
const M = new Uint8Array([3, 3]), je = crypto.subtle.generateKey(
|
|
683
685
|
{
|
|
684
686
|
name: "ECDH",
|
|
685
687
|
namedCurve: "P-256"
|
|
@@ -690,7 +692,7 @@ const B = new Uint8Array([3, 3]), Fe = crypto.subtle.generateKey(
|
|
|
690
692
|
["deriveKey", "deriveBits"]
|
|
691
693
|
// Key usage
|
|
692
694
|
);
|
|
693
|
-
class
|
|
695
|
+
class Ge {
|
|
694
696
|
constructor() {
|
|
695
697
|
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 = {
|
|
696
698
|
// We don't need to chunk the encrypted data.
|
|
@@ -707,7 +709,7 @@ class qe {
|
|
|
707
709
|
* This will spread some messages across multiple records,
|
|
708
710
|
* but TLS supports it so that's fine.
|
|
709
711
|
*/
|
|
710
|
-
downstream:
|
|
712
|
+
downstream: $e(this.MAX_CHUNK_SIZE)
|
|
711
713
|
}, this.serverUpstreamWriter = this.serverEnd.upstream.writable.getWriter();
|
|
712
714
|
const e = this;
|
|
713
715
|
this.serverEnd.downstream.readable.pipeTo(
|
|
@@ -764,7 +766,7 @@ class qe {
|
|
|
764
766
|
*/
|
|
765
767
|
async TLSHandshake(e, t) {
|
|
766
768
|
const n = await this.readNextHandshakeMessage(
|
|
767
|
-
|
|
769
|
+
f.ClientHello
|
|
768
770
|
);
|
|
769
771
|
if (!n.body.cipher_suites.length)
|
|
770
772
|
throw new Error(
|
|
@@ -773,16 +775,16 @@ class qe {
|
|
|
773
775
|
const r = crypto.getRandomValues(new Uint8Array(32));
|
|
774
776
|
await this.writeTLSRecord(
|
|
775
777
|
l.Handshake,
|
|
776
|
-
|
|
778
|
+
D.serverHello(
|
|
777
779
|
n.body,
|
|
778
780
|
r,
|
|
779
|
-
|
|
781
|
+
Fe.Null
|
|
780
782
|
)
|
|
781
783
|
), await this.writeTLSRecord(
|
|
782
784
|
l.Handshake,
|
|
783
|
-
|
|
785
|
+
D.certificate(t)
|
|
784
786
|
);
|
|
785
|
-
const s = await
|
|
787
|
+
const s = await je, a = n.body.random, _ = await D.ECDHEServerKeyExchange(
|
|
786
788
|
a,
|
|
787
789
|
r,
|
|
788
790
|
s,
|
|
@@ -790,10 +792,10 @@ class qe {
|
|
|
790
792
|
);
|
|
791
793
|
await this.writeTLSRecord(l.Handshake, _), await this.writeTLSRecord(
|
|
792
794
|
l.Handshake,
|
|
793
|
-
|
|
795
|
+
D.serverHelloDone()
|
|
794
796
|
);
|
|
795
797
|
const S = await this.readNextHandshakeMessage(
|
|
796
|
-
|
|
798
|
+
f.ClientKeyExchange
|
|
797
799
|
);
|
|
798
800
|
await this.readNextMessage(l.ChangeCipherSpec), this.sessionKeys = await this.deriveSessionKeys({
|
|
799
801
|
clientRandom: a,
|
|
@@ -806,12 +808,12 @@ class qe {
|
|
|
806
808
|
!1,
|
|
807
809
|
[]
|
|
808
810
|
)
|
|
809
|
-
}), await this.readNextHandshakeMessage(
|
|
811
|
+
}), await this.readNextHandshakeMessage(f.Finished), await this.writeTLSRecord(
|
|
810
812
|
l.ChangeCipherSpec,
|
|
811
|
-
|
|
813
|
+
D.changeCipherSpec()
|
|
812
814
|
), await this.writeTLSRecord(
|
|
813
815
|
l.Handshake,
|
|
814
|
-
await
|
|
816
|
+
await D.createFinishedMessage(
|
|
815
817
|
this.handshakeMessages,
|
|
816
818
|
this.sessionKeys.masterSecret
|
|
817
819
|
)
|
|
@@ -836,19 +838,19 @@ class qe {
|
|
|
836
838
|
256
|
|
837
839
|
// Length of the derived secret (256 bits for P-256)
|
|
838
840
|
), a = new Uint8Array(
|
|
839
|
-
await
|
|
841
|
+
await G(
|
|
840
842
|
s,
|
|
841
843
|
new TextEncoder().encode("master secret"),
|
|
842
|
-
|
|
844
|
+
H([e, t]),
|
|
843
845
|
48
|
|
844
846
|
)
|
|
845
|
-
), _ = await
|
|
847
|
+
), _ = await G(
|
|
846
848
|
a,
|
|
847
849
|
new TextEncoder().encode("key expansion"),
|
|
848
|
-
|
|
850
|
+
H([t, e]),
|
|
849
851
|
// Client key, server key, client IV, server IV
|
|
850
852
|
40
|
|
851
|
-
), S = new
|
|
853
|
+
), S = new I(_), c = S.readUint8Array(16), C = S.readUint8Array(16), h = S.readUint8Array(4), A = S.readUint8Array(4);
|
|
852
854
|
return {
|
|
853
855
|
masterSecret: a,
|
|
854
856
|
clientWriteKey: await crypto.subtle.importKey(
|
|
@@ -880,7 +882,7 @@ class qe {
|
|
|
880
882
|
do
|
|
881
883
|
t = await this.readNextTLSRecord(e), n = await this.accumulateUntilMessageIsComplete(t);
|
|
882
884
|
while (n === !1);
|
|
883
|
-
const r =
|
|
885
|
+
const r = E.TLSMessage(
|
|
884
886
|
t.type,
|
|
885
887
|
n
|
|
886
888
|
);
|
|
@@ -903,8 +905,8 @@ class qe {
|
|
|
903
905
|
fragment: this.sessionKeys && r !== l.ChangeCipherSpec ? await this.decryptData(r, s) : s
|
|
904
906
|
};
|
|
905
907
|
if (a.type === l.Alert) {
|
|
906
|
-
const _ = a.fragment[0], S = a.fragment[1], c =
|
|
907
|
-
throw _ ===
|
|
908
|
+
const _ = a.fragment[0], S = a.fragment[1], c = de[_], C = Ee[S];
|
|
909
|
+
throw _ === He.Warning && S === fe.CloseNotify ? new j(
|
|
908
910
|
"TLS connection closed by peer (CloseNotify)"
|
|
909
911
|
) : new Error(
|
|
910
912
|
`TLS alert received: ${c} ${C}`
|
|
@@ -921,8 +923,8 @@ class qe {
|
|
|
921
923
|
for (; this.receivedBytesBuffer.length < e; ) {
|
|
922
924
|
const { value: n, done: r } = await this.clientUpstreamReader.read();
|
|
923
925
|
if (r)
|
|
924
|
-
throw await this.close(), new
|
|
925
|
-
if (this.receivedBytesBuffer =
|
|
926
|
+
throw await this.close(), new j("TLS connection closed");
|
|
927
|
+
if (this.receivedBytesBuffer = H([
|
|
926
928
|
this.receivedBytesBuffer,
|
|
927
929
|
n
|
|
928
930
|
]), this.receivedBytesBuffer.length >= e)
|
|
@@ -945,7 +947,7 @@ class qe {
|
|
|
945
947
|
this.serverUpstreamWriter.write(e.body);
|
|
946
948
|
}
|
|
947
949
|
} catch (e) {
|
|
948
|
-
if (e instanceof
|
|
950
|
+
if (e instanceof j)
|
|
949
951
|
return;
|
|
950
952
|
throw e;
|
|
951
953
|
}
|
|
@@ -960,11 +962,11 @@ class qe {
|
|
|
960
962
|
name: "AES-GCM",
|
|
961
963
|
iv: s,
|
|
962
964
|
additionalData: new Uint8Array([
|
|
963
|
-
...
|
|
965
|
+
...Z(this.receivedRecordSequenceNumber),
|
|
964
966
|
e,
|
|
965
|
-
...
|
|
967
|
+
...M,
|
|
966
968
|
// Payload length without IV and tag
|
|
967
|
-
...
|
|
969
|
+
...W(t.length - 8 - 16)
|
|
968
970
|
]),
|
|
969
971
|
tagLength: 128
|
|
970
972
|
},
|
|
@@ -975,7 +977,7 @@ class qe {
|
|
|
975
977
|
return ++this.receivedRecordSequenceNumber, new Uint8Array(a);
|
|
976
978
|
}
|
|
977
979
|
async accumulateUntilMessageIsComplete(e) {
|
|
978
|
-
this.partialTLSMessages[e.type] =
|
|
980
|
+
this.partialTLSMessages[e.type] = H([
|
|
979
981
|
this.partialTLSMessages[e.type] || new Uint8Array(),
|
|
980
982
|
e.fragment
|
|
981
983
|
]);
|
|
@@ -1011,9 +1013,9 @@ class qe {
|
|
|
1011
1013
|
*/
|
|
1012
1014
|
async writeTLSRecord(e, t) {
|
|
1013
1015
|
e === l.Handshake && this.handshakeMessages.push(t), this.sessionKeys && e !== l.ChangeCipherSpec && (t = await this.encryptData(e, t));
|
|
1014
|
-
const n =
|
|
1016
|
+
const n = M, r = t.length, s = new Uint8Array(5);
|
|
1015
1017
|
s[0] = e, s[1] = n[0], s[2] = n[1], s[3] = r >> 8 & 255, s[4] = r & 255;
|
|
1016
|
-
const a =
|
|
1018
|
+
const a = H([s, t]);
|
|
1017
1019
|
this.clientDownstreamWriter.write(a);
|
|
1018
1020
|
}
|
|
1019
1021
|
/**
|
|
@@ -1022,11 +1024,11 @@ class qe {
|
|
|
1022
1024
|
*/
|
|
1023
1025
|
async encryptData(e, t) {
|
|
1024
1026
|
const n = this.sessionKeys.serverIV, r = crypto.getRandomValues(new Uint8Array(8)), s = new Uint8Array([...n, ...r]), a = new Uint8Array([
|
|
1025
|
-
...
|
|
1027
|
+
...Z(this.sentRecordSequenceNumber),
|
|
1026
1028
|
e,
|
|
1027
|
-
...
|
|
1029
|
+
...M,
|
|
1028
1030
|
// Payload length without IV and tag
|
|
1029
|
-
...
|
|
1031
|
+
...W(t.length)
|
|
1030
1032
|
]), _ = await crypto.subtle.encrypt(
|
|
1031
1033
|
{
|
|
1032
1034
|
name: "AES-GCM",
|
|
@@ -1037,23 +1039,23 @@ class qe {
|
|
|
1037
1039
|
this.sessionKeys.serverWriteKey,
|
|
1038
1040
|
t
|
|
1039
1041
|
);
|
|
1040
|
-
return ++this.sentRecordSequenceNumber,
|
|
1042
|
+
return ++this.sentRecordSequenceNumber, H([
|
|
1041
1043
|
r,
|
|
1042
1044
|
new Uint8Array(_)
|
|
1043
1045
|
]);
|
|
1044
1046
|
}
|
|
1045
1047
|
}
|
|
1046
|
-
class
|
|
1048
|
+
class E {
|
|
1047
1049
|
static TLSMessage(e, t) {
|
|
1048
1050
|
switch (e) {
|
|
1049
1051
|
case l.Handshake:
|
|
1050
|
-
return
|
|
1052
|
+
return E.clientHandshake(t);
|
|
1051
1053
|
case l.Alert:
|
|
1052
|
-
return
|
|
1054
|
+
return E.alert(t);
|
|
1053
1055
|
case l.ChangeCipherSpec:
|
|
1054
|
-
return
|
|
1056
|
+
return E.changeCipherSpec();
|
|
1055
1057
|
case l.ApplicationData:
|
|
1056
|
-
return
|
|
1058
|
+
return E.applicationData(t);
|
|
1057
1059
|
default:
|
|
1058
1060
|
throw new Error(`TLS: Unsupported TLS record type ${e}`);
|
|
1059
1061
|
}
|
|
@@ -1082,12 +1084,12 @@ class T {
|
|
|
1082
1084
|
* https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#tls-parameters-4
|
|
1083
1085
|
*/
|
|
1084
1086
|
static parseCipherSuites(e) {
|
|
1085
|
-
const t = new
|
|
1087
|
+
const t = new I(e);
|
|
1086
1088
|
t.readUint16();
|
|
1087
1089
|
const n = [];
|
|
1088
1090
|
for (; !t.isFinished(); ) {
|
|
1089
1091
|
const r = t.readUint16();
|
|
1090
|
-
r in
|
|
1092
|
+
r in J && n.push(J[r]);
|
|
1091
1093
|
}
|
|
1092
1094
|
return n;
|
|
1093
1095
|
}
|
|
@@ -1106,25 +1108,25 @@ class T {
|
|
|
1106
1108
|
static alert(e) {
|
|
1107
1109
|
return {
|
|
1108
1110
|
type: l.Alert,
|
|
1109
|
-
level:
|
|
1110
|
-
description:
|
|
1111
|
+
level: de[e[0]],
|
|
1112
|
+
description: Ee[e[1]]
|
|
1111
1113
|
};
|
|
1112
1114
|
}
|
|
1113
1115
|
static clientHandshake(e) {
|
|
1114
1116
|
const t = e[0], n = e[1] << 16 | e[2] << 8 | e[3], r = e.slice(4);
|
|
1115
1117
|
let s;
|
|
1116
1118
|
switch (t) {
|
|
1117
|
-
case
|
|
1118
|
-
s =
|
|
1119
|
+
case f.HelloRequest:
|
|
1120
|
+
s = E.clientHelloRequestPayload();
|
|
1119
1121
|
break;
|
|
1120
|
-
case
|
|
1121
|
-
s =
|
|
1122
|
+
case f.ClientHello:
|
|
1123
|
+
s = E.clientHelloPayload(r);
|
|
1122
1124
|
break;
|
|
1123
|
-
case
|
|
1124
|
-
s =
|
|
1125
|
+
case f.ClientKeyExchange:
|
|
1126
|
+
s = E.clientKeyExchangePayload(r);
|
|
1125
1127
|
break;
|
|
1126
|
-
case
|
|
1127
|
-
s =
|
|
1128
|
+
case f.Finished:
|
|
1129
|
+
s = E.clientFinishedPayload(r);
|
|
1128
1130
|
break;
|
|
1129
1131
|
default:
|
|
1130
1132
|
throw new Error(`Invalid handshake type ${t}`);
|
|
@@ -1180,7 +1182,7 @@ class T {
|
|
|
1180
1182
|
* +------+------+---------------------------+
|
|
1181
1183
|
*/
|
|
1182
1184
|
static clientHelloPayload(e) {
|
|
1183
|
-
const t = new
|
|
1185
|
+
const t = new I(e.buffer), n = {
|
|
1184
1186
|
client_version: t.readUint8Array(2),
|
|
1185
1187
|
/**
|
|
1186
1188
|
* Technically this consists of a GMT timestamp
|
|
@@ -1191,7 +1193,7 @@ class T {
|
|
|
1191
1193
|
}, r = t.readUint8();
|
|
1192
1194
|
n.session_id = t.readUint8Array(r);
|
|
1193
1195
|
const s = t.readUint16();
|
|
1194
|
-
n.cipher_suites =
|
|
1196
|
+
n.cipher_suites = E.parseCipherSuites(
|
|
1195
1197
|
t.readUint8Array(s).buffer
|
|
1196
1198
|
);
|
|
1197
1199
|
const a = t.readUint8();
|
|
@@ -1199,7 +1201,7 @@ class T {
|
|
|
1199
1201
|
a
|
|
1200
1202
|
);
|
|
1201
1203
|
const _ = t.readUint16();
|
|
1202
|
-
return n.extensions =
|
|
1204
|
+
return n.extensions = ke(
|
|
1203
1205
|
t.readUint8Array(_)
|
|
1204
1206
|
), n;
|
|
1205
1207
|
}
|
|
@@ -1224,7 +1226,7 @@ class T {
|
|
|
1224
1226
|
};
|
|
1225
1227
|
}
|
|
1226
1228
|
}
|
|
1227
|
-
function
|
|
1229
|
+
function $e(i) {
|
|
1228
1230
|
return new TransformStream({
|
|
1229
1231
|
transform(e, t) {
|
|
1230
1232
|
for (; e.length > 0; )
|
|
@@ -1232,18 +1234,18 @@ function Oe(i) {
|
|
|
1232
1234
|
}
|
|
1233
1235
|
});
|
|
1234
1236
|
}
|
|
1235
|
-
class
|
|
1237
|
+
class D {
|
|
1236
1238
|
static certificate(e) {
|
|
1237
1239
|
const t = [];
|
|
1238
1240
|
for (const s of e)
|
|
1239
|
-
t.push(
|
|
1240
|
-
const n =
|
|
1241
|
-
...
|
|
1241
|
+
t.push(m(s.byteLength)), t.push(new Uint8Array(s));
|
|
1242
|
+
const n = H(t), r = new Uint8Array([
|
|
1243
|
+
...m(n.byteLength),
|
|
1242
1244
|
...n
|
|
1243
1245
|
]);
|
|
1244
1246
|
return new Uint8Array([
|
|
1245
|
-
|
|
1246
|
-
...
|
|
1247
|
+
f.Certificate,
|
|
1248
|
+
...m(r.length),
|
|
1247
1249
|
...r
|
|
1248
1250
|
]);
|
|
1249
1251
|
}
|
|
@@ -1285,9 +1287,9 @@ class I {
|
|
|
1285
1287
|
await crypto.subtle.exportKey("raw", n.publicKey)
|
|
1286
1288
|
), a = new Uint8Array([
|
|
1287
1289
|
// Curve type (1 byte)
|
|
1288
|
-
|
|
1290
|
+
qe.NamedCurve,
|
|
1289
1291
|
// Curve name (2 bytes)
|
|
1290
|
-
...
|
|
1292
|
+
...W(Oe.secp256r1),
|
|
1291
1293
|
// Public key length (1 byte)
|
|
1292
1294
|
s.byteLength,
|
|
1293
1295
|
// Public key (65 bytes, uncompressed format)
|
|
@@ -1300,17 +1302,17 @@ class I {
|
|
|
1300
1302
|
r,
|
|
1301
1303
|
new Uint8Array([...e, ...t, ...a])
|
|
1302
1304
|
), S = new Uint8Array(_), c = new Uint8Array([
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
+
Y.sha256,
|
|
1306
|
+
z.rsa
|
|
1305
1307
|
]), C = new Uint8Array([
|
|
1306
1308
|
...a,
|
|
1307
1309
|
...c,
|
|
1308
|
-
...
|
|
1310
|
+
...W(S.length),
|
|
1309
1311
|
...S
|
|
1310
1312
|
]);
|
|
1311
1313
|
return new Uint8Array([
|
|
1312
|
-
|
|
1313
|
-
...
|
|
1314
|
+
f.ServerKeyExchange,
|
|
1315
|
+
...m(C.length),
|
|
1314
1316
|
...C
|
|
1315
1317
|
]);
|
|
1316
1318
|
}
|
|
@@ -1356,34 +1358,34 @@ class I {
|
|
|
1356
1358
|
const r = e.extensions.map((_) => {
|
|
1357
1359
|
switch (_.type) {
|
|
1358
1360
|
case "server_name":
|
|
1359
|
-
return
|
|
1361
|
+
return Se.encodeForClient();
|
|
1360
1362
|
case "ec_point_formats":
|
|
1361
|
-
return
|
|
1363
|
+
return le.encodeForClient(
|
|
1362
1364
|
"uncompressed"
|
|
1363
1365
|
);
|
|
1364
1366
|
case "renegotiation_info":
|
|
1365
|
-
return
|
|
1367
|
+
return he.encodeForClient();
|
|
1366
1368
|
}
|
|
1367
|
-
}).filter((_) => _ !== void 0), s =
|
|
1369
|
+
}).filter((_) => _ !== void 0), s = H(r), a = new Uint8Array([
|
|
1368
1370
|
// Version field – 0x03, 0x03 means TLS 1.2
|
|
1369
|
-
...
|
|
1371
|
+
...M,
|
|
1370
1372
|
...t,
|
|
1371
1373
|
e.session_id.length,
|
|
1372
1374
|
...e.session_id,
|
|
1373
|
-
...
|
|
1375
|
+
...W(Ae.TLS1_CK_ECDHE_RSA_WITH_AES_128_GCM_SHA256),
|
|
1374
1376
|
n,
|
|
1375
1377
|
// Extensions length (2 bytes)
|
|
1376
|
-
...
|
|
1378
|
+
...W(s.length),
|
|
1377
1379
|
...s
|
|
1378
1380
|
]);
|
|
1379
1381
|
return new Uint8Array([
|
|
1380
|
-
|
|
1381
|
-
...
|
|
1382
|
+
f.ServerHello,
|
|
1383
|
+
...m(a.length),
|
|
1382
1384
|
...a
|
|
1383
1385
|
]);
|
|
1384
1386
|
}
|
|
1385
1387
|
static serverHelloDone() {
|
|
1386
|
-
return new Uint8Array([
|
|
1388
|
+
return new Uint8Array([f.ServerHelloDone, ...m(0)]);
|
|
1387
1389
|
}
|
|
1388
1390
|
/**
|
|
1389
1391
|
* Server finished message.
|
|
@@ -1406,9 +1408,9 @@ class I {
|
|
|
1406
1408
|
static async createFinishedMessage(e, t) {
|
|
1407
1409
|
const n = await crypto.subtle.digest(
|
|
1408
1410
|
"SHA-256",
|
|
1409
|
-
|
|
1411
|
+
H(e)
|
|
1410
1412
|
), r = new Uint8Array(
|
|
1411
|
-
await
|
|
1413
|
+
await G(
|
|
1412
1414
|
t,
|
|
1413
1415
|
new TextEncoder().encode("server finished"),
|
|
1414
1416
|
n,
|
|
@@ -1417,8 +1419,8 @@ class I {
|
|
|
1417
1419
|
)
|
|
1418
1420
|
);
|
|
1419
1421
|
return new Uint8Array([
|
|
1420
|
-
|
|
1421
|
-
...
|
|
1422
|
+
f.Finished,
|
|
1423
|
+
...m(r.length),
|
|
1422
1424
|
...r
|
|
1423
1425
|
]);
|
|
1424
1426
|
}
|
|
@@ -1426,25 +1428,25 @@ class I {
|
|
|
1426
1428
|
return new Uint8Array([1]);
|
|
1427
1429
|
}
|
|
1428
1430
|
}
|
|
1429
|
-
function
|
|
1430
|
-
return
|
|
1431
|
+
function Ve(i, e) {
|
|
1432
|
+
return ze.generateCertificate(i, e);
|
|
1431
1433
|
}
|
|
1432
|
-
function
|
|
1434
|
+
function Tt(i) {
|
|
1433
1435
|
return `-----BEGIN CERTIFICATE-----
|
|
1434
|
-
${
|
|
1435
|
-
|
|
1436
|
+
${pe(
|
|
1437
|
+
Te(i.buffer)
|
|
1436
1438
|
)}
|
|
1437
1439
|
-----END CERTIFICATE-----`;
|
|
1438
1440
|
}
|
|
1439
|
-
async function
|
|
1441
|
+
async function pt(i) {
|
|
1440
1442
|
const e = await crypto.subtle.exportKey("pkcs8", i);
|
|
1441
1443
|
return `-----BEGIN PRIVATE KEY-----
|
|
1442
|
-
${
|
|
1443
|
-
|
|
1444
|
+
${pe(
|
|
1445
|
+
Te(e)
|
|
1444
1446
|
)}
|
|
1445
1447
|
-----END PRIVATE KEY-----`;
|
|
1446
1448
|
}
|
|
1447
|
-
class
|
|
1449
|
+
class ze {
|
|
1448
1450
|
static async generateCertificate(e, t) {
|
|
1449
1451
|
const n = await crypto.subtle.generateKey(
|
|
1450
1452
|
{
|
|
@@ -1511,7 +1513,7 @@ class Ge {
|
|
|
1511
1513
|
}
|
|
1512
1514
|
static signatureAlgorithm(e = "sha256WithRSAEncryption") {
|
|
1513
1515
|
return o.sequence([
|
|
1514
|
-
o.objectIdentifier(
|
|
1516
|
+
o.objectIdentifier(w(e)),
|
|
1515
1517
|
o.null()
|
|
1516
1518
|
]);
|
|
1517
1519
|
}
|
|
@@ -1525,7 +1527,7 @@ class Ge {
|
|
|
1525
1527
|
const t = [];
|
|
1526
1528
|
for (const [n, r] of Object.entries(e)) {
|
|
1527
1529
|
const s = [
|
|
1528
|
-
o.objectIdentifier(
|
|
1530
|
+
o.objectIdentifier(w(n))
|
|
1529
1531
|
];
|
|
1530
1532
|
switch (n) {
|
|
1531
1533
|
case "countryName":
|
|
@@ -1541,16 +1543,16 @@ class Ge {
|
|
|
1541
1543
|
static validity(e) {
|
|
1542
1544
|
return o.sequence([
|
|
1543
1545
|
o.ASN1(
|
|
1544
|
-
|
|
1546
|
+
d.UTCTime,
|
|
1545
1547
|
new TextEncoder().encode(
|
|
1546
|
-
|
|
1548
|
+
ie((e == null ? void 0 : e.notBefore) ?? /* @__PURE__ */ new Date())
|
|
1547
1549
|
)
|
|
1548
1550
|
),
|
|
1549
1551
|
o.ASN1(
|
|
1550
|
-
|
|
1552
|
+
d.UTCTime,
|
|
1551
1553
|
new TextEncoder().encode(
|
|
1552
|
-
|
|
1553
|
-
(e == null ? void 0 : e.notAfter) ??
|
|
1554
|
+
ie(
|
|
1555
|
+
(e == null ? void 0 : e.notAfter) ?? Ze(/* @__PURE__ */ new Date(), 10)
|
|
1554
1556
|
)
|
|
1555
1557
|
)
|
|
1556
1558
|
)
|
|
@@ -1564,14 +1566,14 @@ class Ge {
|
|
|
1564
1566
|
return t !== void 0 && n.push(
|
|
1565
1567
|
o.integer(new Uint8Array([t]))
|
|
1566
1568
|
), o.sequence([
|
|
1567
|
-
o.objectIdentifier(
|
|
1569
|
+
o.objectIdentifier(w("basicConstraints")),
|
|
1568
1570
|
o.octetString(o.sequence(n))
|
|
1569
1571
|
]);
|
|
1570
1572
|
}
|
|
1571
1573
|
static keyUsage(e) {
|
|
1572
1574
|
const t = new Uint8Array([0]);
|
|
1573
1575
|
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([
|
|
1574
|
-
o.objectIdentifier(
|
|
1576
|
+
o.objectIdentifier(w("keyUsage")),
|
|
1575
1577
|
o.boolean(!0),
|
|
1576
1578
|
// Critical
|
|
1577
1579
|
o.octetString(o.bitString(t))
|
|
@@ -1579,13 +1581,13 @@ class Ge {
|
|
|
1579
1581
|
}
|
|
1580
1582
|
static extKeyUsage(e = {}) {
|
|
1581
1583
|
return o.sequence([
|
|
1582
|
-
o.objectIdentifier(
|
|
1584
|
+
o.objectIdentifier(w("extKeyUsage")),
|
|
1583
1585
|
o.boolean(!0),
|
|
1584
1586
|
// Critical
|
|
1585
1587
|
o.octetString(
|
|
1586
1588
|
o.sequence(
|
|
1587
1589
|
Object.entries(e).map(([t, n]) => n ? o.objectIdentifier(
|
|
1588
|
-
|
|
1590
|
+
w(t)
|
|
1589
1591
|
) : o.null())
|
|
1590
1592
|
)
|
|
1591
1593
|
)
|
|
@@ -1594,7 +1596,7 @@ class Ge {
|
|
|
1594
1596
|
static nsCertType(e) {
|
|
1595
1597
|
const t = new Uint8Array([0]);
|
|
1596
1598
|
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([
|
|
1597
|
-
o.objectIdentifier(
|
|
1599
|
+
o.objectIdentifier(w("nsCertType")),
|
|
1598
1600
|
o.octetString(t)
|
|
1599
1601
|
]);
|
|
1600
1602
|
}
|
|
@@ -1610,13 +1612,13 @@ class Ge {
|
|
|
1610
1612
|
o.sequence([...t, ...n])
|
|
1611
1613
|
);
|
|
1612
1614
|
return o.sequence([
|
|
1613
|
-
o.objectIdentifier(
|
|
1615
|
+
o.objectIdentifier(w("subjectAltName")),
|
|
1614
1616
|
o.boolean(!0),
|
|
1615
1617
|
r
|
|
1616
1618
|
]);
|
|
1617
1619
|
}
|
|
1618
1620
|
}
|
|
1619
|
-
const
|
|
1621
|
+
const Ye = {
|
|
1620
1622
|
// Algorithm OIDs
|
|
1621
1623
|
"1.2.840.113549.1.1.1": "rsaEncryption",
|
|
1622
1624
|
"1.2.840.113549.1.1.4": "md5WithRSAEncryption",
|
|
@@ -1726,13 +1728,13 @@ const $e = {
|
|
|
1726
1728
|
"1.3.6.1.5.5.7.3.4": "emailProtection",
|
|
1727
1729
|
"1.3.6.1.5.5.7.3.8": "timeStamping"
|
|
1728
1730
|
};
|
|
1729
|
-
function
|
|
1730
|
-
for (const [e, t] of Object.entries(
|
|
1731
|
+
function w(i) {
|
|
1732
|
+
for (const [e, t] of Object.entries(Ye))
|
|
1731
1733
|
if (t === i)
|
|
1732
1734
|
return e;
|
|
1733
1735
|
throw new Error(`OID not found for name: ${i}`);
|
|
1734
1736
|
}
|
|
1735
|
-
const
|
|
1737
|
+
const se = 32, d = {
|
|
1736
1738
|
Boolean: 1,
|
|
1737
1739
|
Integer: 2,
|
|
1738
1740
|
BitString: 3,
|
|
@@ -1740,8 +1742,8 @@ const ne = 32, H = {
|
|
|
1740
1742
|
Null: 5,
|
|
1741
1743
|
OID: 6,
|
|
1742
1744
|
Utf8String: 12,
|
|
1743
|
-
Sequence: 16 |
|
|
1744
|
-
Set: 17 |
|
|
1745
|
+
Sequence: 16 | se,
|
|
1746
|
+
Set: 17 | se,
|
|
1745
1747
|
PrintableString: 19,
|
|
1746
1748
|
IA5String: 22,
|
|
1747
1749
|
UTCTime: 23
|
|
@@ -1772,17 +1774,17 @@ class o {
|
|
|
1772
1774
|
const t = new Uint8Array(e.length + 1);
|
|
1773
1775
|
t[0] = 0, t.set(e, 1), e = t;
|
|
1774
1776
|
}
|
|
1775
|
-
return o.ASN1(
|
|
1777
|
+
return o.ASN1(d.Integer, e);
|
|
1776
1778
|
}
|
|
1777
1779
|
static bitString(e) {
|
|
1778
1780
|
const t = new Uint8Array([0]), n = new Uint8Array(t.length + e.length);
|
|
1779
|
-
return n.set(t), n.set(e, t.length), o.ASN1(
|
|
1781
|
+
return n.set(t), n.set(e, t.length), o.ASN1(d.BitString, n);
|
|
1780
1782
|
}
|
|
1781
1783
|
static octetString(e) {
|
|
1782
|
-
return o.ASN1(
|
|
1784
|
+
return o.ASN1(d.OctetString, e);
|
|
1783
1785
|
}
|
|
1784
1786
|
static null() {
|
|
1785
|
-
return o.ASN1(
|
|
1787
|
+
return o.ASN1(d.Null, new Uint8Array(0));
|
|
1786
1788
|
}
|
|
1787
1789
|
static objectIdentifier(e) {
|
|
1788
1790
|
const t = e.split(".").map(Number), r = [t[0] * 40 + t[1]];
|
|
@@ -1796,25 +1798,25 @@ class o {
|
|
|
1796
1798
|
_[S] |= 128;
|
|
1797
1799
|
r.push(..._);
|
|
1798
1800
|
}
|
|
1799
|
-
return o.ASN1(
|
|
1801
|
+
return o.ASN1(d.OID, new Uint8Array(r));
|
|
1800
1802
|
}
|
|
1801
1803
|
static utf8String(e) {
|
|
1802
1804
|
const t = new TextEncoder().encode(e);
|
|
1803
|
-
return o.ASN1(
|
|
1805
|
+
return o.ASN1(d.Utf8String, t);
|
|
1804
1806
|
}
|
|
1805
1807
|
static printableString(e) {
|
|
1806
1808
|
const t = new TextEncoder().encode(e);
|
|
1807
|
-
return o.ASN1(
|
|
1809
|
+
return o.ASN1(d.PrintableString, t);
|
|
1808
1810
|
}
|
|
1809
1811
|
static sequence(e) {
|
|
1810
|
-
return o.ASN1(
|
|
1812
|
+
return o.ASN1(d.Sequence, H(e));
|
|
1811
1813
|
}
|
|
1812
1814
|
static set(e) {
|
|
1813
|
-
return o.ASN1(
|
|
1815
|
+
return o.ASN1(d.Set, H(e));
|
|
1814
1816
|
}
|
|
1815
1817
|
static ia5String(e) {
|
|
1816
1818
|
const t = new TextEncoder().encode(e);
|
|
1817
|
-
return o.ASN1(
|
|
1819
|
+
return o.ASN1(d.IA5String, t);
|
|
1818
1820
|
}
|
|
1819
1821
|
static contextSpecific(e, t, n = !1) {
|
|
1820
1822
|
const r = (n ? 160 : 128) | e;
|
|
@@ -1822,36 +1824,36 @@ class o {
|
|
|
1822
1824
|
}
|
|
1823
1825
|
static boolean(e) {
|
|
1824
1826
|
return o.ASN1(
|
|
1825
|
-
|
|
1827
|
+
d.Boolean,
|
|
1826
1828
|
new Uint8Array([e ? 255 : 0])
|
|
1827
1829
|
);
|
|
1828
1830
|
}
|
|
1829
1831
|
}
|
|
1830
|
-
function
|
|
1832
|
+
function Te(i) {
|
|
1831
1833
|
return btoa(String.fromCodePoint(...new Uint8Array(i)));
|
|
1832
1834
|
}
|
|
1833
|
-
function
|
|
1835
|
+
function pe(i) {
|
|
1834
1836
|
var e;
|
|
1835
1837
|
return ((e = i.match(/.{1,64}/g)) == null ? void 0 : e.join(`
|
|
1836
1838
|
`)) || i;
|
|
1837
1839
|
}
|
|
1838
|
-
function
|
|
1839
|
-
const e = i.getUTCFullYear().toString().substr(2), t =
|
|
1840
|
+
function ie(i) {
|
|
1841
|
+
const e = i.getUTCFullYear().toString().substr(2), t = B(i.getUTCMonth() + 1), n = B(i.getUTCDate()), r = B(i.getUTCHours()), s = B(i.getUTCMinutes()), a = B(i.getUTCSeconds());
|
|
1840
1842
|
return `${e}${t}${n}${r}${s}${a}Z`;
|
|
1841
1843
|
}
|
|
1842
|
-
function
|
|
1844
|
+
function B(i) {
|
|
1843
1845
|
return i.toString().padStart(2, "0");
|
|
1844
1846
|
}
|
|
1845
|
-
function
|
|
1847
|
+
function Ze(i, e) {
|
|
1846
1848
|
const t = new Date(i);
|
|
1847
1849
|
return t.setUTCFullYear(t.getUTCFullYear() + e), t;
|
|
1848
1850
|
}
|
|
1849
|
-
class
|
|
1851
|
+
class Xe extends TransformStream {
|
|
1850
1852
|
constructor() {
|
|
1851
1853
|
let e = new Uint8Array(0), t = "SCAN_CHUNK_SIZE", n = 0;
|
|
1852
1854
|
super({
|
|
1853
1855
|
transform(r, s) {
|
|
1854
|
-
for (e =
|
|
1856
|
+
for (e = H([e, r]); e.length > 0; )
|
|
1855
1857
|
if (t === "SCAN_CHUNK_SIZE") {
|
|
1856
1858
|
if (e.length < 3)
|
|
1857
1859
|
return;
|
|
@@ -1899,7 +1901,7 @@ class ze extends TransformStream {
|
|
|
1899
1901
|
});
|
|
1900
1902
|
}
|
|
1901
1903
|
}
|
|
1902
|
-
const
|
|
1904
|
+
const Je = (i, e) => ({
|
|
1903
1905
|
...i,
|
|
1904
1906
|
websocket: {
|
|
1905
1907
|
url: (t, n, r) => `ws://playground.internal/?${new URLSearchParams({
|
|
@@ -1907,7 +1909,7 @@ const Ye = (i, e) => ({
|
|
|
1907
1909
|
port: r
|
|
1908
1910
|
}).toString()}`,
|
|
1909
1911
|
subprotocol: "binary",
|
|
1910
|
-
decorator: () => class extends
|
|
1912
|
+
decorator: () => class extends Qe {
|
|
1911
1913
|
constructor(t, n) {
|
|
1912
1914
|
super(t, n, {
|
|
1913
1915
|
CAroot: e.CAroot,
|
|
@@ -1917,7 +1919,7 @@ const Ye = (i, e) => ({
|
|
|
1917
1919
|
}
|
|
1918
1920
|
}
|
|
1919
1921
|
});
|
|
1920
|
-
class
|
|
1922
|
+
class Qe {
|
|
1921
1923
|
constructor(e, t, {
|
|
1922
1924
|
CAroot: n,
|
|
1923
1925
|
corsProxyUrl: r,
|
|
@@ -1985,10 +1987,10 @@ class Ze {
|
|
|
1985
1987
|
*/
|
|
1986
1988
|
send(e) {
|
|
1987
1989
|
if (!(this.readyState === this.CLOSING || this.readyState === this.CLOSED) && (this.clientUpstreamWriter.write(new Uint8Array(e)), !this.fetchInitiated))
|
|
1988
|
-
switch (this.bufferedBytesFromClient =
|
|
1990
|
+
switch (this.bufferedBytesFromClient = H([
|
|
1989
1991
|
this.bufferedBytesFromClient,
|
|
1990
1992
|
new Uint8Array(e)
|
|
1991
|
-
]),
|
|
1993
|
+
]), tt(this.port, this.bufferedBytesFromClient)) {
|
|
1992
1994
|
case !1:
|
|
1993
1995
|
return;
|
|
1994
1996
|
case "other":
|
|
@@ -2007,7 +2009,7 @@ class Ze {
|
|
|
2007
2009
|
throw new Error(
|
|
2008
2010
|
"TLS protocol is only supported when the TCPOverFetchWebsocket is instantiated with a CAroot"
|
|
2009
2011
|
);
|
|
2010
|
-
const e = await
|
|
2012
|
+
const e = await Ve(
|
|
2011
2013
|
{
|
|
2012
2014
|
subject: {
|
|
2013
2015
|
commonName: this.host,
|
|
@@ -2017,14 +2019,14 @@ class Ze {
|
|
|
2017
2019
|
issuer: this.CAroot.tbsDescription.subject
|
|
2018
2020
|
},
|
|
2019
2021
|
this.CAroot.keyPair
|
|
2020
|
-
), t = new
|
|
2022
|
+
), t = new Ge();
|
|
2021
2023
|
this.clientUpstream.readable.pipeTo(t.clientEnd.upstream.writable).catch(() => {
|
|
2022
2024
|
}), t.clientEnd.downstream.readable.pipeTo(this.clientDownstream.writable).catch(() => {
|
|
2023
2025
|
}), await t.TLSHandshake(e.keyPair.privateKey, [
|
|
2024
2026
|
e.certificate,
|
|
2025
2027
|
this.CAroot.certificate
|
|
2026
2028
|
]);
|
|
2027
|
-
const { request: n, expectsContinue: r } = await
|
|
2029
|
+
const { request: n, expectsContinue: r } = await g.parseHttpRequest(
|
|
2028
2030
|
t.serverEnd.upstream.readable,
|
|
2029
2031
|
this.host,
|
|
2030
2032
|
"https"
|
|
@@ -2038,7 +2040,7 @@ class Ze {
|
|
|
2038
2040
|
), s.releaseLock();
|
|
2039
2041
|
}
|
|
2040
2042
|
try {
|
|
2041
|
-
await
|
|
2043
|
+
await g.fetchRawResponseBytes(
|
|
2042
2044
|
n,
|
|
2043
2045
|
this.corsProxyUrl
|
|
2044
2046
|
).pipeTo(t.serverEnd.downstream.writable);
|
|
@@ -2046,7 +2048,7 @@ class Ze {
|
|
|
2046
2048
|
}
|
|
2047
2049
|
}
|
|
2048
2050
|
async fetchOverHTTP() {
|
|
2049
|
-
const { request: e, expectsContinue: t } = await
|
|
2051
|
+
const { request: e, expectsContinue: t } = await g.parseHttpRequest(
|
|
2050
2052
|
this.clientUpstream.readable,
|
|
2051
2053
|
this.host,
|
|
2052
2054
|
"http"
|
|
@@ -2060,7 +2062,7 @@ class Ze {
|
|
|
2060
2062
|
), n.releaseLock();
|
|
2061
2063
|
}
|
|
2062
2064
|
try {
|
|
2063
|
-
await
|
|
2065
|
+
await g.fetchRawResponseBytes(
|
|
2064
2066
|
e,
|
|
2065
2067
|
this.corsProxyUrl
|
|
2066
2068
|
).pipeTo(this.clientDownstream.writable);
|
|
@@ -2071,7 +2073,7 @@ class Ze {
|
|
|
2071
2073
|
this.emit("message", { data: new Uint8Array(0) }), this.readyState = this.CLOSING, this.emit("close"), this.readyState = this.CLOSED;
|
|
2072
2074
|
}
|
|
2073
2075
|
}
|
|
2074
|
-
const
|
|
2076
|
+
const et = [
|
|
2075
2077
|
"GET",
|
|
2076
2078
|
"POST",
|
|
2077
2079
|
"HEAD",
|
|
@@ -2081,7 +2083,7 @@ const Je = [
|
|
|
2081
2083
|
"PUT",
|
|
2082
2084
|
"TRACE"
|
|
2083
2085
|
];
|
|
2084
|
-
function
|
|
2086
|
+
function tt(i, e) {
|
|
2085
2087
|
if (e.length < 8)
|
|
2086
2088
|
return !1;
|
|
2087
2089
|
if (i === 443 && e[0] === l.Handshake && // TLS versions between 1.0 and 1.2
|
|
@@ -2090,11 +2092,11 @@ function Xe(i, e) {
|
|
|
2090
2092
|
const n = new TextDecoder("latin1", {
|
|
2091
2093
|
fatal: !0
|
|
2092
2094
|
}).decode(e);
|
|
2093
|
-
return
|
|
2095
|
+
return et.some(
|
|
2094
2096
|
(s) => n.startsWith(s + " ")
|
|
2095
2097
|
) ? "http" : "other";
|
|
2096
2098
|
}
|
|
2097
|
-
class
|
|
2099
|
+
class g {
|
|
2098
2100
|
/**
|
|
2099
2101
|
* Streams a HTTP response including the status line and headers.
|
|
2100
2102
|
*/
|
|
@@ -2104,7 +2106,7 @@ class y {
|
|
|
2104
2106
|
var _;
|
|
2105
2107
|
let r;
|
|
2106
2108
|
try {
|
|
2107
|
-
r = await
|
|
2109
|
+
r = await Pe(
|
|
2108
2110
|
e,
|
|
2109
2111
|
void 0,
|
|
2110
2112
|
t
|
|
@@ -2120,7 +2122,7 @@ Content-Length: 0\r
|
|
|
2120
2122
|
), n.error(S);
|
|
2121
2123
|
return;
|
|
2122
2124
|
}
|
|
2123
|
-
n.enqueue(
|
|
2125
|
+
n.enqueue(g.headersAsBytes(r));
|
|
2124
2126
|
const s = (_ = r.body) == null ? void 0 : _.getReader();
|
|
2125
2127
|
if (!s) {
|
|
2126
2128
|
n.close();
|
|
@@ -2165,58 +2167,58 @@ Content-Length: 0\r
|
|
|
2165
2167
|
let r = new Uint8Array(0), s = !1, a = -1;
|
|
2166
2168
|
const _ = e.getReader();
|
|
2167
2169
|
for (; a === -1; ) {
|
|
2168
|
-
const { done:
|
|
2169
|
-
if (
|
|
2170
|
+
const { done: k, value: b } = await _.read();
|
|
2171
|
+
if (k) {
|
|
2170
2172
|
s = !0;
|
|
2171
2173
|
break;
|
|
2172
2174
|
}
|
|
2173
|
-
r =
|
|
2175
|
+
r = H([r, b]), a = nt(
|
|
2174
2176
|
r,
|
|
2175
2177
|
new Uint8Array([13, 10, 13, 10])
|
|
2176
2178
|
);
|
|
2177
2179
|
}
|
|
2178
2180
|
_.releaseLock();
|
|
2179
|
-
const S = r.slice(0, a), c =
|
|
2181
|
+
const S = r.slice(0, a), c = g.parseRequestHeaders(S), C = c.headers.get("Transfer-Encoding") !== null ? "chunked" : "content-length", h = c.headers.get("Content-Length") !== null ? parseInt(c.headers.get("Content-Length"), 10) : void 0, A = r.slice(
|
|
2180
2182
|
a + 4
|
|
2181
2183
|
/* Skip \r\n\r\n */
|
|
2182
2184
|
);
|
|
2183
|
-
let
|
|
2185
|
+
let u;
|
|
2184
2186
|
if (c.method !== "GET") {
|
|
2185
|
-
const
|
|
2186
|
-
let
|
|
2187
|
-
const
|
|
2187
|
+
const k = e.getReader();
|
|
2188
|
+
let b = A.length, F = A.slice(-6);
|
|
2189
|
+
const Le = new TextEncoder().encode(`0\r
|
|
2188
2190
|
\r
|
|
2189
2191
|
`);
|
|
2190
|
-
|
|
2191
|
-
async start(
|
|
2192
|
-
A.length > 0 &&
|
|
2193
|
-
const
|
|
2194
|
-
(s ||
|
|
2192
|
+
u = new ReadableStream({
|
|
2193
|
+
async start(R) {
|
|
2194
|
+
A.length > 0 && R.enqueue(A);
|
|
2195
|
+
const q = C === "content-length" && h !== void 0 && b >= h;
|
|
2196
|
+
(s || q) && R.close();
|
|
2195
2197
|
},
|
|
2196
|
-
async pull(
|
|
2197
|
-
const { done:
|
|
2198
|
-
if (
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
]).slice(-5)),
|
|
2202
|
-
(
|
|
2198
|
+
async pull(R) {
|
|
2199
|
+
const { done: q, value: K } = await k.read();
|
|
2200
|
+
if (b += (K == null ? void 0 : K.length) || 0, K && (R.enqueue(K), F = H([
|
|
2201
|
+
F,
|
|
2202
|
+
K || new Uint8Array()
|
|
2203
|
+
]).slice(-5)), q || C === "content-length" && h !== void 0 && b >= h || C === "chunked" && F.every(
|
|
2204
|
+
(ye, me) => ye === Le[me]
|
|
2203
2205
|
)) {
|
|
2204
|
-
|
|
2206
|
+
R.close();
|
|
2205
2207
|
return;
|
|
2206
2208
|
}
|
|
2207
2209
|
}
|
|
2208
|
-
}), C === "chunked" && (
|
|
2209
|
-
new
|
|
2210
|
+
}), C === "chunked" && (u = u.pipeThrough(
|
|
2211
|
+
new Xe()
|
|
2210
2212
|
));
|
|
2211
2213
|
}
|
|
2212
|
-
const
|
|
2214
|
+
const T = c.headers.get("Host") ?? t, y = new URL(c.path, n + "://" + T);
|
|
2213
2215
|
return {
|
|
2214
|
-
request: new Request(
|
|
2216
|
+
request: new Request(y.toString(), {
|
|
2215
2217
|
method: c.method,
|
|
2216
2218
|
headers: c.headers,
|
|
2217
|
-
body:
|
|
2219
|
+
body: u,
|
|
2218
2220
|
// @ts-expect-error duplex is required for streaming request bodies
|
|
2219
|
-
duplex:
|
|
2221
|
+
duplex: u ? "half" : void 0
|
|
2220
2222
|
}),
|
|
2221
2223
|
expectsContinue: c.expectsContinue
|
|
2222
2224
|
};
|
|
@@ -2239,7 +2241,7 @@ Content-Length: 0\r
|
|
|
2239
2241
|
return a.delete("Expect"), { method: r, path: s, headers: a, expectsContinue: _ };
|
|
2240
2242
|
}
|
|
2241
2243
|
}
|
|
2242
|
-
function
|
|
2244
|
+
function nt(i, e) {
|
|
2243
2245
|
const t = i.length, n = e.length, r = t - n;
|
|
2244
2246
|
for (let s = 0; s <= r; s++) {
|
|
2245
2247
|
let a = !0;
|
|
@@ -2253,7 +2255,7 @@ function Qe(i, e) {
|
|
|
2253
2255
|
}
|
|
2254
2256
|
return -1;
|
|
2255
2257
|
}
|
|
2256
|
-
async function
|
|
2258
|
+
async function rt(i = V) {
|
|
2257
2259
|
switch (i) {
|
|
2258
2260
|
case "8.5":
|
|
2259
2261
|
return (await import("@php-wasm/web-8-5")).getIntlExtensionPath();
|
|
@@ -2272,8 +2274,8 @@ async function et(i = G) {
|
|
|
2272
2274
|
}
|
|
2273
2275
|
throw new Error(`Unsupported PHP version ${i}`);
|
|
2274
2276
|
}
|
|
2275
|
-
async function
|
|
2276
|
-
const t =
|
|
2277
|
+
async function st(i = V, e) {
|
|
2278
|
+
const t = be(fetch), n = "intl.so", r = "icu.dat", s = await rt(i), a = (await import("./shared/icu.dat")).default, [_, S] = await Promise.all([
|
|
2277
2279
|
t(s).then((c) => c.arrayBuffer()),
|
|
2278
2280
|
t(a).then((c) => c.arrayBuffer())
|
|
2279
2281
|
]);
|
|
@@ -2285,16 +2287,16 @@ async function tt(i = G, e) {
|
|
|
2285
2287
|
ICU_DATA: "/internal/shared"
|
|
2286
2288
|
},
|
|
2287
2289
|
onRuntimeInitialized: (c) => {
|
|
2288
|
-
e.onRuntimeInitialized && e.onRuntimeInitialized(c),
|
|
2290
|
+
e.onRuntimeInitialized && e.onRuntimeInitialized(c), L.fileExists(
|
|
2289
2291
|
c.FS,
|
|
2290
2292
|
"/internal/shared/extensions"
|
|
2291
|
-
) || c.FS.mkdirTree("/internal/shared/extensions"),
|
|
2293
|
+
) || c.FS.mkdirTree("/internal/shared/extensions"), L.fileExists(
|
|
2292
2294
|
c.FS,
|
|
2293
2295
|
`/internal/shared/extensions/${n}`
|
|
2294
2296
|
) || c.FS.writeFile(
|
|
2295
2297
|
`/internal/shared/extensions/${n}`,
|
|
2296
2298
|
new Uint8Array(_)
|
|
2297
|
-
),
|
|
2299
|
+
), L.fileExists(
|
|
2298
2300
|
c.FS,
|
|
2299
2301
|
"/internal/shared/extensions/intl.ini"
|
|
2300
2302
|
) || c.FS.writeFile(
|
|
@@ -2303,7 +2305,7 @@ async function tt(i = G, e) {
|
|
|
2303
2305
|
`extension=/internal/shared/extensions/${n}`
|
|
2304
2306
|
].join(`
|
|
2305
2307
|
`)
|
|
2306
|
-
),
|
|
2308
|
+
), L.fileExists(
|
|
2307
2309
|
c.FS,
|
|
2308
2310
|
`${c.ENV.ICU_DATA}/${r}`
|
|
2309
2311
|
) || (c.FS.mkdirTree(c.ENV.ICU_DATA), c.FS.writeFile(
|
|
@@ -2313,7 +2315,7 @@ async function tt(i = G, e) {
|
|
|
2313
2315
|
}
|
|
2314
2316
|
};
|
|
2315
2317
|
}
|
|
2316
|
-
const
|
|
2318
|
+
const it = () => ({
|
|
2317
2319
|
websocket: {
|
|
2318
2320
|
decorator: (i) => class extends i {
|
|
2319
2321
|
constructor() {
|
|
@@ -2328,24 +2330,40 @@ const nt = () => ({
|
|
|
2328
2330
|
}
|
|
2329
2331
|
}
|
|
2330
2332
|
});
|
|
2331
|
-
async function
|
|
2332
|
-
var
|
|
2333
|
-
"setImmediate" in globalThis || (globalThis.setImmediate = (
|
|
2333
|
+
async function Lt(i, e = {}) {
|
|
2334
|
+
var a;
|
|
2335
|
+
"setImmediate" in globalThis || (globalThis.setImmediate = (_) => setTimeout(_, 0));
|
|
2334
2336
|
let t = {
|
|
2335
|
-
...
|
|
2337
|
+
...it(),
|
|
2336
2338
|
...e.emscriptenOptions || {}
|
|
2337
2339
|
};
|
|
2338
|
-
e.tcpOverFetch && (t =
|
|
2340
|
+
e.tcpOverFetch && (t = Je(
|
|
2339
2341
|
t,
|
|
2340
2342
|
e.tcpOverFetch
|
|
2341
|
-
))
|
|
2342
|
-
const
|
|
2343
|
-
|
|
2343
|
+
));
|
|
2344
|
+
const n = ge(i);
|
|
2345
|
+
if (n) {
|
|
2346
|
+
const _ = await t, S = _.preRun || [];
|
|
2347
|
+
t = {
|
|
2348
|
+
..._,
|
|
2349
|
+
preRun: [...S, Ie()]
|
|
2350
|
+
};
|
|
2351
|
+
}
|
|
2352
|
+
if (n && e.withIntl)
|
|
2353
|
+
throw new Error(
|
|
2354
|
+
`The intl extension is not available for legacy PHP ${i}.`
|
|
2355
|
+
);
|
|
2356
|
+
n || e.withIntl && (t = st(
|
|
2357
|
+
i,
|
|
2358
|
+
t
|
|
2359
|
+
));
|
|
2360
|
+
const [r, s] = await Promise.all([
|
|
2361
|
+
Ue(i),
|
|
2344
2362
|
t
|
|
2345
2363
|
]);
|
|
2346
|
-
return (
|
|
2364
|
+
return (a = e.onPhpLoaderModuleLoaded) == null || a.call(e, r), await Ke(r, s);
|
|
2347
2365
|
}
|
|
2348
|
-
function
|
|
2366
|
+
function yt(i, e) {
|
|
2349
2367
|
window.addEventListener("message", (t) => {
|
|
2350
2368
|
t.source === i.contentWindow && (e && t.origin !== e || typeof t.data != "object" || t.data.type !== "relay" || window.parent.postMessage(t.data, "*"));
|
|
2351
2369
|
}), window.addEventListener("message", (t) => {
|
|
@@ -2353,7 +2371,7 @@ function pt(i, e) {
|
|
|
2353
2371
|
t.source === window.parent && (typeof t.data != "object" || t.data.type !== "relay" || (n = i == null ? void 0 : i.contentWindow) == null || n.postMessage(t.data));
|
|
2354
2372
|
});
|
|
2355
2373
|
}
|
|
2356
|
-
async function
|
|
2374
|
+
async function mt(i) {
|
|
2357
2375
|
const e = new Worker(i, { type: "module" });
|
|
2358
2376
|
return new Promise((t, n) => {
|
|
2359
2377
|
e.onerror = (s) => {
|
|
@@ -2368,7 +2386,8 @@ async function wt(i) {
|
|
|
2368
2386
|
e.addEventListener("message", r);
|
|
2369
2387
|
});
|
|
2370
2388
|
}
|
|
2371
|
-
|
|
2389
|
+
const at = 1e3;
|
|
2390
|
+
function gt(i, e = { initialSync: {} }) {
|
|
2372
2391
|
return e = {
|
|
2373
2392
|
...e,
|
|
2374
2393
|
initialSync: {
|
|
@@ -2376,17 +2395,20 @@ function Lt(i, e = { initialSync: {} }) {
|
|
|
2376
2395
|
direction: e.initialSync.direction ?? "opfs-to-memfs"
|
|
2377
2396
|
}
|
|
2378
2397
|
}, async function(t, n, r) {
|
|
2379
|
-
|
|
2398
|
+
var a;
|
|
2399
|
+
e.initialSync.direction === "opfs-to-memfs" ? (L.fileExists(n, r) && L.rmdir(n, r), L.mkdir(n, r), await _t(n, i, r)) : await we(
|
|
2380
2400
|
n,
|
|
2381
2401
|
i,
|
|
2382
2402
|
r,
|
|
2383
2403
|
e.initialSync.onProgress
|
|
2384
|
-
)
|
|
2404
|
+
);
|
|
2405
|
+
const s = ct(t, i, r);
|
|
2406
|
+
return (a = e.onMount) == null || a.call(e, s), s.unmount;
|
|
2385
2407
|
};
|
|
2386
2408
|
}
|
|
2387
|
-
async function
|
|
2388
|
-
|
|
2389
|
-
const n = new
|
|
2409
|
+
async function _t(i, e, t) {
|
|
2410
|
+
L.mkdir(i, t);
|
|
2411
|
+
const n = new De({
|
|
2390
2412
|
concurrency: 40
|
|
2391
2413
|
}), r = [], s = [
|
|
2392
2414
|
[e, t]
|
|
@@ -2395,7 +2417,7 @@ async function rt(i, e, t) {
|
|
|
2395
2417
|
const [a, _] = s.pop();
|
|
2396
2418
|
for await (const S of a.values()) {
|
|
2397
2419
|
const c = n.run(async () => {
|
|
2398
|
-
const C =
|
|
2420
|
+
const C = oe(
|
|
2399
2421
|
_,
|
|
2400
2422
|
S.name
|
|
2401
2423
|
);
|
|
@@ -2426,7 +2448,7 @@ async function rt(i, e, t) {
|
|
|
2426
2448
|
await Promise.any(r);
|
|
2427
2449
|
}
|
|
2428
2450
|
}
|
|
2429
|
-
async function
|
|
2451
|
+
async function we(i, e, t, n) {
|
|
2430
2452
|
i.mkdirTree(t);
|
|
2431
2453
|
const r = [];
|
|
2432
2454
|
async function s(C, h) {
|
|
@@ -2434,35 +2456,35 @@ async function fe(i, e, t, n) {
|
|
|
2434
2456
|
i.readdir(C).filter(
|
|
2435
2457
|
(A) => A !== "." && A !== ".."
|
|
2436
2458
|
).map(async (A) => {
|
|
2437
|
-
const
|
|
2438
|
-
if (!
|
|
2439
|
-
r.push([h,
|
|
2459
|
+
const u = oe(C, A);
|
|
2460
|
+
if (!ot(i, u)) {
|
|
2461
|
+
r.push([h, u, A]);
|
|
2440
2462
|
return;
|
|
2441
2463
|
}
|
|
2442
|
-
const
|
|
2464
|
+
const T = await h.getDirectoryHandle(A, {
|
|
2443
2465
|
create: !0
|
|
2444
2466
|
});
|
|
2445
|
-
return await s(
|
|
2467
|
+
return await s(u, T);
|
|
2446
2468
|
})
|
|
2447
2469
|
);
|
|
2448
2470
|
}
|
|
2449
2471
|
await s(t, e);
|
|
2450
2472
|
let a = 0;
|
|
2451
|
-
const _ = n &&
|
|
2473
|
+
const _ = n && lt(n, 100), S = 100, c = /* @__PURE__ */ new Set();
|
|
2452
2474
|
try {
|
|
2453
2475
|
for (const [C, h, A] of r) {
|
|
2454
|
-
const
|
|
2476
|
+
const u = $(
|
|
2455
2477
|
C,
|
|
2456
2478
|
A,
|
|
2457
2479
|
i,
|
|
2458
2480
|
h
|
|
2459
2481
|
).then(() => {
|
|
2460
|
-
a++, c.delete(
|
|
2482
|
+
a++, c.delete(u), _ == null || _({
|
|
2461
2483
|
files: a,
|
|
2462
2484
|
total: r.length
|
|
2463
2485
|
});
|
|
2464
2486
|
});
|
|
2465
|
-
c.add(
|
|
2487
|
+
c.add(u), c.size >= S && (await Promise.race(c), _ == null || _({
|
|
2466
2488
|
files: a,
|
|
2467
2489
|
total: r.length
|
|
2468
2490
|
}));
|
|
@@ -2471,10 +2493,10 @@ async function fe(i, e, t, n) {
|
|
|
2471
2493
|
await Promise.allSettled(c);
|
|
2472
2494
|
}
|
|
2473
2495
|
}
|
|
2474
|
-
function
|
|
2496
|
+
function ot(i, e) {
|
|
2475
2497
|
return i.isDir(i.lookupPath(e, { follow: !0 }).node.mode);
|
|
2476
2498
|
}
|
|
2477
|
-
async function
|
|
2499
|
+
async function $(i, e, t, n) {
|
|
2478
2500
|
let r;
|
|
2479
2501
|
try {
|
|
2480
2502
|
r = t.readFile(n, {
|
|
@@ -2496,38 +2518,69 @@ async function j(i, e, t, n) {
|
|
|
2496
2518
|
await a.close();
|
|
2497
2519
|
}
|
|
2498
2520
|
}
|
|
2499
|
-
function
|
|
2500
|
-
const
|
|
2501
|
-
|
|
2502
|
-
}),
|
|
2503
|
-
|
|
2504
|
-
|
|
2521
|
+
function ct(i, e, t, n = {}) {
|
|
2522
|
+
const r = [], s = Re(i, t, (u) => {
|
|
2523
|
+
r.push(u);
|
|
2524
|
+
}), a = new St(i, e, t);
|
|
2525
|
+
let _;
|
|
2526
|
+
function S() {
|
|
2527
|
+
return _ === void 0 && (_ = h().finally(() => {
|
|
2528
|
+
_ = void 0;
|
|
2529
|
+
})), _;
|
|
2530
|
+
}
|
|
2531
|
+
async function c() {
|
|
2532
|
+
try {
|
|
2533
|
+
await S();
|
|
2534
|
+
} finally {
|
|
2535
|
+
s(), i.removeEventListener("request.end", C), i.removeEventListener("filesystem.write", C);
|
|
2536
|
+
}
|
|
2537
|
+
}
|
|
2538
|
+
function C() {
|
|
2539
|
+
S().catch((u) => {
|
|
2540
|
+
U.error(u);
|
|
2541
|
+
});
|
|
2542
|
+
}
|
|
2543
|
+
async function h() {
|
|
2544
|
+
const u = n.maxFlushPasses ?? at;
|
|
2545
|
+
for (let T = 0; r.length > 0; T++) {
|
|
2546
|
+
if (T >= u) {
|
|
2547
|
+
const y = r.length, x = y === 1 ? `${y} journal entry remains` : `${y} journal entries remain`;
|
|
2548
|
+
throw new Error(
|
|
2549
|
+
`OPFS flush for "${t}" did not settle after ${u} journal batches; ${x}. This can happen when filesystem writes are continuously enqueued while flushing.`
|
|
2550
|
+
);
|
|
2551
|
+
}
|
|
2552
|
+
await A();
|
|
2553
|
+
}
|
|
2554
|
+
}
|
|
2555
|
+
async function A() {
|
|
2556
|
+
if (r.length === 0)
|
|
2505
2557
|
return;
|
|
2506
|
-
const
|
|
2507
|
-
|
|
2508
|
-
const
|
|
2558
|
+
const u = await i.semaphore.acquire(), T = [...r];
|
|
2559
|
+
r.splice(0, T.length);
|
|
2560
|
+
const y = Be(T);
|
|
2509
2561
|
try {
|
|
2510
|
-
for (const
|
|
2511
|
-
await
|
|
2562
|
+
for (const x of y)
|
|
2563
|
+
await a.processEntry(x);
|
|
2512
2564
|
} finally {
|
|
2513
|
-
|
|
2565
|
+
u();
|
|
2514
2566
|
}
|
|
2515
2567
|
}
|
|
2516
|
-
return i.addEventListener("request.end",
|
|
2517
|
-
|
|
2568
|
+
return i.addEventListener("request.end", C), i.addEventListener("filesystem.write", C), {
|
|
2569
|
+
flush: S,
|
|
2570
|
+
unmount: c
|
|
2518
2571
|
};
|
|
2519
2572
|
}
|
|
2520
|
-
class
|
|
2573
|
+
class St {
|
|
2521
2574
|
constructor(e, t, n) {
|
|
2522
|
-
this.php = e, this.opfs = t, this.memfsRoot =
|
|
2575
|
+
this.php = e, this.opfs = t, this.memfsRoot = ae(n);
|
|
2523
2576
|
}
|
|
2524
2577
|
toOpfsPath(e) {
|
|
2525
|
-
return
|
|
2578
|
+
return ae(e.substring(this.memfsRoot.length));
|
|
2526
2579
|
}
|
|
2527
2580
|
async processEntry(e) {
|
|
2528
2581
|
if (!e.path.startsWith(this.memfsRoot) || e.path === this.memfsRoot)
|
|
2529
2582
|
return;
|
|
2530
|
-
const t = this.toOpfsPath(e.path), n = await
|
|
2583
|
+
const t = this.toOpfsPath(e.path), n = await _e(this.opfs, t), r = Ct(t);
|
|
2531
2584
|
if (r)
|
|
2532
2585
|
try {
|
|
2533
2586
|
if (e.operation === "DELETE")
|
|
@@ -2544,14 +2597,14 @@ class at {
|
|
|
2544
2597
|
create: !0
|
|
2545
2598
|
});
|
|
2546
2599
|
else if (e.operation === "WRITE")
|
|
2547
|
-
await
|
|
2600
|
+
await $(
|
|
2548
2601
|
n,
|
|
2549
2602
|
r,
|
|
2550
|
-
this.php[
|
|
2603
|
+
this.php[O].FS,
|
|
2551
2604
|
e.path
|
|
2552
2605
|
);
|
|
2553
2606
|
else if (e.operation === "RENAME" && e.toPath.startsWith(this.memfsRoot)) {
|
|
2554
|
-
const s = this.toOpfsPath(e.toPath), a = await
|
|
2607
|
+
const s = this.toOpfsPath(e.toPath), a = await _e(
|
|
2555
2608
|
this.opfs,
|
|
2556
2609
|
s
|
|
2557
2610
|
);
|
|
@@ -2562,8 +2615,8 @@ class at {
|
|
|
2562
2615
|
create: !0
|
|
2563
2616
|
}
|
|
2564
2617
|
);
|
|
2565
|
-
await
|
|
2566
|
-
this.php[
|
|
2618
|
+
await we(
|
|
2619
|
+
this.php[O].FS,
|
|
2567
2620
|
_,
|
|
2568
2621
|
e.toPath
|
|
2569
2622
|
), await n.removeEntry(r, {
|
|
@@ -2574,10 +2627,10 @@ class at {
|
|
|
2574
2627
|
await n.removeEntry(r);
|
|
2575
2628
|
} catch {
|
|
2576
2629
|
}
|
|
2577
|
-
await
|
|
2630
|
+
await $(
|
|
2578
2631
|
a,
|
|
2579
|
-
|
|
2580
|
-
this.php[
|
|
2632
|
+
We(s),
|
|
2633
|
+
this.php[O].FS,
|
|
2581
2634
|
e.toPath
|
|
2582
2635
|
);
|
|
2583
2636
|
}
|
|
@@ -2587,13 +2640,13 @@ class at {
|
|
|
2587
2640
|
}
|
|
2588
2641
|
}
|
|
2589
2642
|
}
|
|
2590
|
-
function
|
|
2643
|
+
function ae(i) {
|
|
2591
2644
|
return i.replace(/\/$/, "").replace(/\/\/+/g, "/");
|
|
2592
2645
|
}
|
|
2593
|
-
function
|
|
2646
|
+
function Ct(i) {
|
|
2594
2647
|
return i.substring(i.lastIndexOf("/") + 1);
|
|
2595
2648
|
}
|
|
2596
|
-
async function
|
|
2649
|
+
async function _e(i, e) {
|
|
2597
2650
|
const t = e.replace(/^\/+|\/+$/g, "").replace(/\/+/, "/");
|
|
2598
2651
|
if (!t)
|
|
2599
2652
|
return i;
|
|
@@ -2605,7 +2658,7 @@ async function ie(i, e) {
|
|
|
2605
2658
|
}
|
|
2606
2659
|
return r;
|
|
2607
2660
|
}
|
|
2608
|
-
function
|
|
2661
|
+
function lt(i, e) {
|
|
2609
2662
|
let t = 0, n, r;
|
|
2610
2663
|
return function(...a) {
|
|
2611
2664
|
r = a;
|
|
@@ -2619,17 +2672,17 @@ function ot(i, e) {
|
|
|
2619
2672
|
};
|
|
2620
2673
|
}
|
|
2621
2674
|
export {
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2675
|
+
bt as FirewallInterferenceError,
|
|
2676
|
+
Tt as certificateToPEM,
|
|
2677
|
+
Dt as consumeAPI,
|
|
2678
|
+
gt as createDirectoryHandleMountHandler,
|
|
2679
|
+
Wt as exposeAPI,
|
|
2680
|
+
Rt as fetchWithCorsProxy,
|
|
2681
|
+
Ve as generateCertificate,
|
|
2682
|
+
Ue as getPHPLoaderModule,
|
|
2683
|
+
Lt as loadWebRuntime,
|
|
2684
|
+
pt as privateKeyToPEM,
|
|
2685
|
+
yt as setupPostMessageRelay,
|
|
2686
|
+
mt as spawnPHPWorkerThread
|
|
2634
2687
|
};
|
|
2635
2688
|
//# sourceMappingURL=index.js.map
|