@php-wasm/web 3.1.34 → 3.1.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs +16 -16
- package/index.cjs.map +1 -1
- package/index.js +498 -424
- package/index.js.map +1 -1
- package/lib/directory-handle-mount.d.ts +3 -1
- package/lib/tcp-over-fetch-websocket.d.ts +2 -0
- package/package.json +17 -17
package/index.js
CHANGED
|
@@ -1,13 +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 { jspi as
|
|
9
|
-
import { journalFSEvents as
|
|
10
|
-
async function
|
|
1
|
+
import { LatestSupportedPHPVersion as Se, withResolvedPHPExtensions as We, resolvePHPExtension as Y, isLegacyPHPVersion as Pe, createLegacyPhpIniPreRunStep as be, loadPHPRuntime as Re, FSHelpers as M, __private__dont__use as O } from "@php-wasm/universal";
|
|
2
|
+
import { consumeAPI as xt, exposeAPI as Nt } from "@php-wasm/universal";
|
|
3
|
+
import { concatArrayBuffers as v, concatUint8Arrays as H, Semaphore as Be, joinPaths as le, basename as Ue } from "@php-wasm/util";
|
|
4
|
+
import { logger as g } from "@php-wasm/logger";
|
|
5
|
+
import { fetchWithCorsProxy as ve } from "@php-wasm/web-service-worker";
|
|
6
|
+
import { FirewallInterferenceError as qt, fetchWithCorsProxy as Ft } from "@php-wasm/web-service-worker";
|
|
7
|
+
import { createMemoizedFetch as Me } from "@wp-playground/common";
|
|
8
|
+
import { jspi as xe } from "wasm-feature-detect";
|
|
9
|
+
import { journalFSEvents as Ne, normalizeFilesystemOperations as ke } from "@php-wasm/fs-journal";
|
|
10
|
+
async function qe(i = Se) {
|
|
11
11
|
switch (i) {
|
|
12
12
|
case "8.5":
|
|
13
13
|
return (await import("@php-wasm/web-8-5")).getPHPLoaderModule();
|
|
@@ -28,13 +28,13 @@ async function xe(i = oe) {
|
|
|
28
28
|
}
|
|
29
29
|
throw new Error(`Unsupported PHP version ${i}`);
|
|
30
30
|
}
|
|
31
|
-
function
|
|
31
|
+
function w(i) {
|
|
32
32
|
return Object.fromEntries(Object.entries(i).map(([e, t]) => [t, e]));
|
|
33
33
|
}
|
|
34
|
-
function
|
|
34
|
+
function W(i) {
|
|
35
35
|
return new Uint8Array([i >> 8 & 255, i & 255]);
|
|
36
36
|
}
|
|
37
|
-
function
|
|
37
|
+
function L(i) {
|
|
38
38
|
return new Uint8Array([
|
|
39
39
|
i >> 16 & 255,
|
|
40
40
|
i >> 8 & 255,
|
|
@@ -45,7 +45,7 @@ function Z(i) {
|
|
|
45
45
|
const e = new ArrayBuffer(8);
|
|
46
46
|
return new DataView(e).setBigUint64(0, BigInt(i), !1), new Uint8Array(e);
|
|
47
47
|
}
|
|
48
|
-
class
|
|
48
|
+
class I {
|
|
49
49
|
constructor(e) {
|
|
50
50
|
this.offset = 0, this.buffer = e, this.view = new DataView(e);
|
|
51
51
|
}
|
|
@@ -86,7 +86,7 @@ class N {
|
|
|
86
86
|
this.uint8Array.set(e, this.offset), this.offset += e.length;
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
|
-
const
|
|
89
|
+
const P = {
|
|
90
90
|
server_name: 0,
|
|
91
91
|
max_fragment_length: 1,
|
|
92
92
|
client_certificate_url: 2,
|
|
@@ -141,10 +141,10 @@ const W = {
|
|
|
141
141
|
transparency_info: 52,
|
|
142
142
|
connection_id: 54,
|
|
143
143
|
renegotiation_info: 65281
|
|
144
|
-
},
|
|
144
|
+
}, Fe = w(P), Ce = {
|
|
145
145
|
host_name: 0
|
|
146
|
-
},
|
|
147
|
-
class
|
|
146
|
+
}, Oe = w(Ce);
|
|
147
|
+
class he {
|
|
148
148
|
static decodeFromClient(e) {
|
|
149
149
|
const t = new DataView(e.buffer);
|
|
150
150
|
let n = 0;
|
|
@@ -156,13 +156,13 @@ class Ce {
|
|
|
156
156
|
n += 1;
|
|
157
157
|
const _ = t.getUint16(n);
|
|
158
158
|
n += 2;
|
|
159
|
-
const
|
|
159
|
+
const o = e.slice(n, n + _);
|
|
160
160
|
switch (n += _, a) {
|
|
161
|
-
case
|
|
161
|
+
case Ce.host_name:
|
|
162
162
|
s.push({
|
|
163
|
-
name_type:
|
|
163
|
+
name_type: Oe[a],
|
|
164
164
|
name: {
|
|
165
|
-
host_name: new TextDecoder().decode(
|
|
165
|
+
host_name: new TextDecoder().decode(o)
|
|
166
166
|
}
|
|
167
167
|
});
|
|
168
168
|
break;
|
|
@@ -189,15 +189,15 @@ class Ce {
|
|
|
189
189
|
"Encoding non-empty lists for ClientHello is not supported yet. Only empty lists meant for ServerHello are supported today."
|
|
190
190
|
);
|
|
191
191
|
const t = new N(4);
|
|
192
|
-
return t.writeUint16(
|
|
192
|
+
return t.writeUint16(P.server_name), t.writeUint16(0), t.uint8Array;
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
|
-
const
|
|
195
|
+
const ue = {
|
|
196
196
|
uncompressed: 0,
|
|
197
197
|
ansiX962_compressed_prime: 1,
|
|
198
198
|
ansiX962_compressed_char2: 2
|
|
199
|
-
}, J =
|
|
200
|
-
class
|
|
199
|
+
}, J = w(ue);
|
|
200
|
+
class Ae {
|
|
201
201
|
/**
|
|
202
202
|
* +--------------------------------------------------+
|
|
203
203
|
* | Payload Length [2B] |
|
|
@@ -214,7 +214,7 @@ class he {
|
|
|
214
214
|
* +--------------------------------------------------+
|
|
215
215
|
*/
|
|
216
216
|
static decodeFromClient(e) {
|
|
217
|
-
const t = new
|
|
217
|
+
const t = new I(e.buffer), n = t.readUint8(), r = [];
|
|
218
218
|
for (let s = 0; s < n; s++) {
|
|
219
219
|
const a = t.readUint8();
|
|
220
220
|
a in J && r.push(J[a]);
|
|
@@ -237,10 +237,10 @@ class he {
|
|
|
237
237
|
*/
|
|
238
238
|
static encodeForClient(e) {
|
|
239
239
|
const t = new N(6);
|
|
240
|
-
return t.writeUint16(
|
|
240
|
+
return t.writeUint16(P.ec_point_formats), t.writeUint16(2), t.writeUint8(1), t.writeUint8(ue[e]), t.uint8Array;
|
|
241
241
|
}
|
|
242
242
|
}
|
|
243
|
-
const
|
|
243
|
+
const He = {
|
|
244
244
|
decodeFromClient(i) {
|
|
245
245
|
const e = i[0] ?? 0;
|
|
246
246
|
return {
|
|
@@ -252,7 +252,7 @@ const Ae = {
|
|
|
252
252
|
* with an empty renegotiated_connection field.
|
|
253
253
|
*/
|
|
254
254
|
encodeForClient() {
|
|
255
|
-
const i =
|
|
255
|
+
const i = P.renegotiation_info, e = new Uint8Array([0]);
|
|
256
256
|
return new Uint8Array([
|
|
257
257
|
i >> 8 & 255,
|
|
258
258
|
i & 255,
|
|
@@ -261,7 +261,7 @@ const Ae = {
|
|
|
261
261
|
...e
|
|
262
262
|
]);
|
|
263
263
|
}
|
|
264
|
-
},
|
|
264
|
+
}, de = {
|
|
265
265
|
TLS1_CK_PSK_WITH_RC4_128_SHA: 138,
|
|
266
266
|
TLS1_CK_PSK_WITH_3DES_EDE_CBC_SHA: 139,
|
|
267
267
|
TLS1_CK_PSK_WITH_AES_128_CBC_SHA: 140,
|
|
@@ -464,14 +464,14 @@ const Ae = {
|
|
|
464
464
|
TLS1_CK_ECDHE_PSK_WITH_CHACHA20_POLY1305: 52396,
|
|
465
465
|
TLS1_CK_DHE_PSK_WITH_CHACHA20_POLY1305: 52397,
|
|
466
466
|
TLS1_CK_RSA_PSK_WITH_CHACHA20_POLY1305: 52398
|
|
467
|
-
}, X =
|
|
467
|
+
}, X = w(de), fe = {
|
|
468
468
|
secp256r1: 23,
|
|
469
469
|
secp384r1: 24,
|
|
470
470
|
secp521r1: 25,
|
|
471
471
|
x25519: 29,
|
|
472
472
|
x448: 30
|
|
473
|
-
}, Q =
|
|
474
|
-
class
|
|
473
|
+
}, Q = w(fe);
|
|
474
|
+
class je {
|
|
475
475
|
/**
|
|
476
476
|
* +--------------------------------------------------+
|
|
477
477
|
* | Payload Length [2B] |
|
|
@@ -488,7 +488,7 @@ class qe {
|
|
|
488
488
|
* +--------------------------------------------------+
|
|
489
489
|
*/
|
|
490
490
|
static decodeFromClient(e) {
|
|
491
|
-
const t = new
|
|
491
|
+
const t = new I(e.buffer);
|
|
492
492
|
t.readUint16();
|
|
493
493
|
const n = [];
|
|
494
494
|
for (; !t.isFinished(); ) {
|
|
@@ -509,7 +509,7 @@ class qe {
|
|
|
509
509
|
*/
|
|
510
510
|
static encodeForClient(e) {
|
|
511
511
|
const t = new N(6);
|
|
512
|
-
return t.writeUint16(
|
|
512
|
+
return t.writeUint16(P.supported_groups), t.writeUint16(2), t.writeUint16(fe[e]), t.uint8Array;
|
|
513
513
|
}
|
|
514
514
|
}
|
|
515
515
|
const V = {
|
|
@@ -517,7 +517,7 @@ const V = {
|
|
|
517
517
|
rsa: 1,
|
|
518
518
|
dsa: 2,
|
|
519
519
|
ecdsa: 3
|
|
520
|
-
}, ee =
|
|
520
|
+
}, ee = w(V), z = {
|
|
521
521
|
none: 0,
|
|
522
522
|
md5: 1,
|
|
523
523
|
sha1: 2,
|
|
@@ -525,8 +525,8 @@ const V = {
|
|
|
525
525
|
sha256: 4,
|
|
526
526
|
sha384: 5,
|
|
527
527
|
sha512: 6
|
|
528
|
-
}, te =
|
|
529
|
-
class
|
|
528
|
+
}, te = w(z);
|
|
529
|
+
class Ge {
|
|
530
530
|
/**
|
|
531
531
|
* Binary layout:
|
|
532
532
|
*
|
|
@@ -543,14 +543,14 @@ class Fe {
|
|
|
543
543
|
* +------------------------------------+
|
|
544
544
|
*/
|
|
545
545
|
static decodeFromClient(e) {
|
|
546
|
-
const t = new
|
|
546
|
+
const t = new I(e.buffer);
|
|
547
547
|
t.readUint16();
|
|
548
548
|
const n = [];
|
|
549
549
|
for (; !t.isFinished(); ) {
|
|
550
550
|
const r = t.readUint8(), s = t.readUint8();
|
|
551
551
|
if (ee[s]) {
|
|
552
552
|
if (!te[r]) {
|
|
553
|
-
|
|
553
|
+
g.warn(`Unknown hash algorithm: ${r}`);
|
|
554
554
|
continue;
|
|
555
555
|
}
|
|
556
556
|
n.push({
|
|
@@ -574,26 +574,26 @@ class Fe {
|
|
|
574
574
|
*/
|
|
575
575
|
static encodeforClient(e, t) {
|
|
576
576
|
const n = new N(6);
|
|
577
|
-
return n.writeUint16(
|
|
577
|
+
return n.writeUint16(P.signature_algorithms), n.writeUint16(2), n.writeUint8(z[e]), n.writeUint8(V[t]), n.uint8Array;
|
|
578
578
|
}
|
|
579
579
|
}
|
|
580
580
|
const ne = {
|
|
581
|
-
server_name:
|
|
582
|
-
signature_algorithms:
|
|
583
|
-
supported_groups:
|
|
584
|
-
ec_point_formats:
|
|
585
|
-
renegotiation_info:
|
|
581
|
+
server_name: he,
|
|
582
|
+
signature_algorithms: Ge,
|
|
583
|
+
supported_groups: je,
|
|
584
|
+
ec_point_formats: Ae,
|
|
585
|
+
renegotiation_info: He
|
|
586
586
|
};
|
|
587
|
-
function
|
|
588
|
-
const e = new
|
|
587
|
+
function $e(i) {
|
|
588
|
+
const e = new I(i.buffer), t = [];
|
|
589
589
|
for (; !e.isFinished(); ) {
|
|
590
|
-
const n = e.offset, r = e.readUint16(), s =
|
|
590
|
+
const n = e.offset, r = e.readUint16(), s = Fe[r], a = e.readUint16(), _ = e.readUint8Array(a);
|
|
591
591
|
if (!(s in ne))
|
|
592
592
|
continue;
|
|
593
|
-
const
|
|
593
|
+
const o = ne[s];
|
|
594
594
|
t.push({
|
|
595
595
|
type: s,
|
|
596
|
-
data:
|
|
596
|
+
data: o.decodeFromClient(_),
|
|
597
597
|
raw: i.slice(n, n + 4 + a)
|
|
598
598
|
});
|
|
599
599
|
}
|
|
@@ -611,8 +611,8 @@ async function G(i, e, t, n) {
|
|
|
611
611
|
const _ = [];
|
|
612
612
|
for (; v(_).byteLength < n; ) {
|
|
613
613
|
a = await re(s, a);
|
|
614
|
-
const S = v([a, r]),
|
|
615
|
-
_.push(
|
|
614
|
+
const S = v([a, r]), l = await re(s, S);
|
|
615
|
+
_.push(l);
|
|
616
616
|
}
|
|
617
617
|
return v(_).slice(0, n);
|
|
618
618
|
}
|
|
@@ -623,12 +623,12 @@ async function re(i, e) {
|
|
|
623
623
|
e
|
|
624
624
|
);
|
|
625
625
|
}
|
|
626
|
-
const
|
|
626
|
+
const Ve = {
|
|
627
627
|
Null: 0
|
|
628
|
-
},
|
|
628
|
+
}, Ee = {
|
|
629
629
|
Warning: 1,
|
|
630
630
|
Fatal: 2
|
|
631
|
-
},
|
|
631
|
+
}, Te = w(Ee), pe = {
|
|
632
632
|
CloseNotify: 0,
|
|
633
633
|
UnexpectedMessage: 10,
|
|
634
634
|
BadRecordMac: 20,
|
|
@@ -654,12 +654,12 @@ const je = {
|
|
|
654
654
|
UserCanceled: 90,
|
|
655
655
|
NoRenegotiation: 100,
|
|
656
656
|
UnsupportedExtension: 110
|
|
657
|
-
},
|
|
657
|
+
}, we = w(pe), h = {
|
|
658
658
|
ChangeCipherSpec: 20,
|
|
659
659
|
Alert: 21,
|
|
660
660
|
Handshake: 22,
|
|
661
661
|
ApplicationData: 23
|
|
662
|
-
},
|
|
662
|
+
}, E = {
|
|
663
663
|
HelloRequest: 0,
|
|
664
664
|
ClientHello: 1,
|
|
665
665
|
ServerHello: 2,
|
|
@@ -668,7 +668,7 @@ const je = {
|
|
|
668
668
|
ServerHelloDone: 14,
|
|
669
669
|
ClientKeyExchange: 16,
|
|
670
670
|
Finished: 20
|
|
671
|
-
},
|
|
671
|
+
}, ze = {
|
|
672
672
|
/**
|
|
673
673
|
* Indicates that a named curve is used. This option
|
|
674
674
|
* SHOULD be used when applicable.
|
|
@@ -677,12 +677,12 @@ const je = {
|
|
|
677
677
|
/**
|
|
678
678
|
* Values 248 through 255 are reserved for private use.
|
|
679
679
|
*/
|
|
680
|
-
},
|
|
680
|
+
}, Ye = {
|
|
681
681
|
secp256r1: 23
|
|
682
682
|
};
|
|
683
683
|
class j extends Error {
|
|
684
684
|
}
|
|
685
|
-
const x = new Uint8Array([3, 3]),
|
|
685
|
+
const x = new Uint8Array([3, 3]), Ze = crypto.subtle.generateKey(
|
|
686
686
|
{
|
|
687
687
|
name: "ECDH",
|
|
688
688
|
namedCurve: "P-256"
|
|
@@ -693,7 +693,7 @@ const x = new Uint8Array([3, 3]), Ve = crypto.subtle.generateKey(
|
|
|
693
693
|
["deriveKey", "deriveBits"]
|
|
694
694
|
// Key usage
|
|
695
695
|
);
|
|
696
|
-
class
|
|
696
|
+
class Je {
|
|
697
697
|
constructor() {
|
|
698
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 = {
|
|
699
699
|
// We don't need to chunk the encrypted data.
|
|
@@ -710,14 +710,14 @@ class ze {
|
|
|
710
710
|
* This will spread some messages across multiple records,
|
|
711
711
|
* but TLS supports it so that's fine.
|
|
712
712
|
*/
|
|
713
|
-
downstream:
|
|
713
|
+
downstream: Xe(this.MAX_CHUNK_SIZE)
|
|
714
714
|
}, this.serverUpstreamWriter = this.serverEnd.upstream.writable.getWriter();
|
|
715
715
|
const e = this;
|
|
716
716
|
this.serverEnd.downstream.readable.pipeTo(
|
|
717
717
|
new WritableStream({
|
|
718
718
|
async write(t) {
|
|
719
719
|
await e.writeTLSRecord(
|
|
720
|
-
|
|
720
|
+
h.ApplicationData,
|
|
721
721
|
t
|
|
722
722
|
);
|
|
723
723
|
},
|
|
@@ -767,7 +767,7 @@ class ze {
|
|
|
767
767
|
*/
|
|
768
768
|
async TLSHandshake(e, t) {
|
|
769
769
|
const n = await this.readNextHandshakeMessage(
|
|
770
|
-
|
|
770
|
+
E.ClientHello
|
|
771
771
|
);
|
|
772
772
|
if (!n.body.cipher_suites.length)
|
|
773
773
|
throw new Error(
|
|
@@ -775,46 +775,46 @@ class ze {
|
|
|
775
775
|
);
|
|
776
776
|
const r = crypto.getRandomValues(new Uint8Array(32));
|
|
777
777
|
await this.writeTLSRecord(
|
|
778
|
-
|
|
779
|
-
|
|
778
|
+
h.Handshake,
|
|
779
|
+
D.serverHello(
|
|
780
780
|
n.body,
|
|
781
781
|
r,
|
|
782
|
-
|
|
782
|
+
Ve.Null
|
|
783
783
|
)
|
|
784
784
|
), await this.writeTLSRecord(
|
|
785
|
-
|
|
786
|
-
|
|
785
|
+
h.Handshake,
|
|
786
|
+
D.certificate(t)
|
|
787
787
|
);
|
|
788
|
-
const s = await
|
|
788
|
+
const s = await Ze, a = n.body.random, _ = await D.ECDHEServerKeyExchange(
|
|
789
789
|
a,
|
|
790
790
|
r,
|
|
791
791
|
s,
|
|
792
792
|
e
|
|
793
793
|
);
|
|
794
|
-
await this.writeTLSRecord(
|
|
795
|
-
|
|
796
|
-
|
|
794
|
+
await this.writeTLSRecord(h.Handshake, _), await this.writeTLSRecord(
|
|
795
|
+
h.Handshake,
|
|
796
|
+
D.serverHelloDone()
|
|
797
797
|
);
|
|
798
|
-
const
|
|
799
|
-
|
|
798
|
+
const o = await this.readNextHandshakeMessage(
|
|
799
|
+
E.ClientKeyExchange
|
|
800
800
|
);
|
|
801
|
-
await this.readNextMessage(
|
|
801
|
+
await this.readNextMessage(h.ChangeCipherSpec), this.sessionKeys = await this.deriveSessionKeys({
|
|
802
802
|
clientRandom: a,
|
|
803
803
|
serverRandom: r,
|
|
804
804
|
serverPrivateKey: s.privateKey,
|
|
805
805
|
clientPublicKey: await crypto.subtle.importKey(
|
|
806
806
|
"raw",
|
|
807
|
-
|
|
807
|
+
o.body.exchange_keys,
|
|
808
808
|
{ name: "ECDH", namedCurve: "P-256" },
|
|
809
809
|
!1,
|
|
810
810
|
[]
|
|
811
811
|
)
|
|
812
|
-
}), await this.readNextHandshakeMessage(
|
|
813
|
-
|
|
814
|
-
|
|
812
|
+
}), await this.readNextHandshakeMessage(E.Finished), await this.writeTLSRecord(
|
|
813
|
+
h.ChangeCipherSpec,
|
|
814
|
+
D.changeCipherSpec()
|
|
815
815
|
), await this.writeTLSRecord(
|
|
816
|
-
|
|
817
|
-
await
|
|
816
|
+
h.Handshake,
|
|
817
|
+
await D.createFinishedMessage(
|
|
818
818
|
this.handshakeMessages,
|
|
819
819
|
this.sessionKeys.masterSecret
|
|
820
820
|
)
|
|
@@ -851,7 +851,7 @@ class ze {
|
|
|
851
851
|
H([t, e]),
|
|
852
852
|
// Client key, server key, client IV, server IV
|
|
853
853
|
40
|
|
854
|
-
),
|
|
854
|
+
), o = new I(_), S = o.readUint8Array(16), l = o.readUint8Array(16), C = o.readUint8Array(4), A = o.readUint8Array(4);
|
|
855
855
|
return {
|
|
856
856
|
masterSecret: a,
|
|
857
857
|
clientWriteKey: await crypto.subtle.importKey(
|
|
@@ -863,17 +863,17 @@ class ze {
|
|
|
863
863
|
),
|
|
864
864
|
serverWriteKey: await crypto.subtle.importKey(
|
|
865
865
|
"raw",
|
|
866
|
-
|
|
866
|
+
l,
|
|
867
867
|
{ name: "AES-GCM" },
|
|
868
868
|
!1,
|
|
869
869
|
["encrypt", "decrypt"]
|
|
870
870
|
),
|
|
871
|
-
clientIV:
|
|
871
|
+
clientIV: C,
|
|
872
872
|
serverIV: A
|
|
873
873
|
};
|
|
874
874
|
}
|
|
875
875
|
async readNextHandshakeMessage(e) {
|
|
876
|
-
const t = await this.readNextMessage(
|
|
876
|
+
const t = await this.readNextMessage(h.Handshake);
|
|
877
877
|
if (t.msg_type !== e)
|
|
878
878
|
throw new Error(`Expected ${e} message`);
|
|
879
879
|
return t;
|
|
@@ -883,18 +883,18 @@ class ze {
|
|
|
883
883
|
do
|
|
884
884
|
t = await this.readNextTLSRecord(e), n = await this.accumulateUntilMessageIsComplete(t);
|
|
885
885
|
while (n === !1);
|
|
886
|
-
const r =
|
|
886
|
+
const r = T.TLSMessage(
|
|
887
887
|
t.type,
|
|
888
888
|
n
|
|
889
889
|
);
|
|
890
|
-
return t.type ===
|
|
890
|
+
return t.type === h.Handshake && this.handshakeMessages.push(t.fragment), r;
|
|
891
891
|
}
|
|
892
892
|
async readNextTLSRecord(e) {
|
|
893
893
|
for (; ; ) {
|
|
894
894
|
for (let _ = 0; _ < this.receivedTLSRecords.length; _++) {
|
|
895
|
-
const
|
|
896
|
-
if (
|
|
897
|
-
return this.receivedTLSRecords.splice(_, 1),
|
|
895
|
+
const o = this.receivedTLSRecords[_];
|
|
896
|
+
if (o.type === e)
|
|
897
|
+
return this.receivedTLSRecords.splice(_, 1), o;
|
|
898
898
|
}
|
|
899
899
|
const t = await this.pollBytes(5), n = t[3] << 8 | t[4], r = t[0], s = await this.pollBytes(n), a = {
|
|
900
900
|
type: r,
|
|
@@ -903,14 +903,14 @@ class ze {
|
|
|
903
903
|
minor: t[2]
|
|
904
904
|
},
|
|
905
905
|
length: n,
|
|
906
|
-
fragment: this.sessionKeys && r !==
|
|
906
|
+
fragment: this.sessionKeys && r !== h.ChangeCipherSpec ? await this.decryptData(r, s) : s
|
|
907
907
|
};
|
|
908
|
-
if (a.type ===
|
|
909
|
-
const _ = a.fragment[0],
|
|
910
|
-
throw _ ===
|
|
908
|
+
if (a.type === h.Alert) {
|
|
909
|
+
const _ = a.fragment[0], o = a.fragment[1], S = Te[_], l = we[o];
|
|
910
|
+
throw _ === Ee.Warning && o === pe.CloseNotify ? new j(
|
|
911
911
|
"TLS connection closed by peer (CloseNotify)"
|
|
912
912
|
) : new Error(
|
|
913
|
-
`TLS alert received: ${S} ${
|
|
913
|
+
`TLS alert received: ${S} ${l}`
|
|
914
914
|
);
|
|
915
915
|
}
|
|
916
916
|
this.receivedTLSRecords.push(a);
|
|
@@ -943,7 +943,7 @@ class ze {
|
|
|
943
943
|
try {
|
|
944
944
|
for (; ; ) {
|
|
945
945
|
const e = await this.readNextMessage(
|
|
946
|
-
|
|
946
|
+
h.ApplicationData
|
|
947
947
|
);
|
|
948
948
|
this.serverUpstreamWriter.write(e.body);
|
|
949
949
|
}
|
|
@@ -967,7 +967,7 @@ class ze {
|
|
|
967
967
|
e,
|
|
968
968
|
...x,
|
|
969
969
|
// Payload length without IV and tag
|
|
970
|
-
...
|
|
970
|
+
...W(t.length - 8 - 16)
|
|
971
971
|
]),
|
|
972
972
|
tagLength: 128
|
|
973
973
|
},
|
|
@@ -984,7 +984,7 @@ class ze {
|
|
|
984
984
|
]);
|
|
985
985
|
const t = this.partialTLSMessages[e.type];
|
|
986
986
|
switch (e.type) {
|
|
987
|
-
case
|
|
987
|
+
case h.Handshake: {
|
|
988
988
|
if (t.length < 4)
|
|
989
989
|
return !1;
|
|
990
990
|
const n = t[1] << 8 | t[2];
|
|
@@ -992,13 +992,13 @@ class ze {
|
|
|
992
992
|
return !1;
|
|
993
993
|
break;
|
|
994
994
|
}
|
|
995
|
-
case
|
|
995
|
+
case h.Alert: {
|
|
996
996
|
if (t.length < 2)
|
|
997
997
|
return !1;
|
|
998
998
|
break;
|
|
999
999
|
}
|
|
1000
|
-
case
|
|
1001
|
-
case
|
|
1000
|
+
case h.ChangeCipherSpec:
|
|
1001
|
+
case h.ApplicationData:
|
|
1002
1002
|
break;
|
|
1003
1003
|
default:
|
|
1004
1004
|
throw new Error(`TLS: Unsupported record type ${e.type}`);
|
|
@@ -1013,7 +1013,7 @@ class ze {
|
|
|
1013
1013
|
* only kicks in after the handshake is complete.
|
|
1014
1014
|
*/
|
|
1015
1015
|
async writeTLSRecord(e, t) {
|
|
1016
|
-
e ===
|
|
1016
|
+
e === h.Handshake && this.handshakeMessages.push(t), this.sessionKeys && e !== h.ChangeCipherSpec && (t = await this.encryptData(e, t));
|
|
1017
1017
|
const n = x, r = t.length, s = new Uint8Array(5);
|
|
1018
1018
|
s[0] = e, s[1] = n[0], s[2] = n[1], s[3] = r >> 8 & 255, s[4] = r & 255;
|
|
1019
1019
|
const a = H([s, t]);
|
|
@@ -1029,7 +1029,7 @@ class ze {
|
|
|
1029
1029
|
e,
|
|
1030
1030
|
...x,
|
|
1031
1031
|
// Payload length without IV and tag
|
|
1032
|
-
...
|
|
1032
|
+
...W(t.length)
|
|
1033
1033
|
]), _ = await crypto.subtle.encrypt(
|
|
1034
1034
|
{
|
|
1035
1035
|
name: "AES-GCM",
|
|
@@ -1046,17 +1046,17 @@ class ze {
|
|
|
1046
1046
|
]);
|
|
1047
1047
|
}
|
|
1048
1048
|
}
|
|
1049
|
-
class
|
|
1049
|
+
class T {
|
|
1050
1050
|
static TLSMessage(e, t) {
|
|
1051
1051
|
switch (e) {
|
|
1052
|
-
case
|
|
1053
|
-
return
|
|
1054
|
-
case
|
|
1055
|
-
return
|
|
1056
|
-
case
|
|
1057
|
-
return
|
|
1058
|
-
case
|
|
1059
|
-
return
|
|
1052
|
+
case h.Handshake:
|
|
1053
|
+
return T.clientHandshake(t);
|
|
1054
|
+
case h.Alert:
|
|
1055
|
+
return T.alert(t);
|
|
1056
|
+
case h.ChangeCipherSpec:
|
|
1057
|
+
return T.changeCipherSpec();
|
|
1058
|
+
case h.ApplicationData:
|
|
1059
|
+
return T.applicationData(t);
|
|
1060
1060
|
default:
|
|
1061
1061
|
throw new Error(`TLS: Unsupported TLS record type ${e}`);
|
|
1062
1062
|
}
|
|
@@ -1085,7 +1085,7 @@ class E {
|
|
|
1085
1085
|
* https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#tls-parameters-4
|
|
1086
1086
|
*/
|
|
1087
1087
|
static parseCipherSuites(e) {
|
|
1088
|
-
const t = new
|
|
1088
|
+
const t = new I(e);
|
|
1089
1089
|
t.readUint16();
|
|
1090
1090
|
const n = [];
|
|
1091
1091
|
for (; !t.isFinished(); ) {
|
|
@@ -1096,44 +1096,44 @@ class E {
|
|
|
1096
1096
|
}
|
|
1097
1097
|
static applicationData(e) {
|
|
1098
1098
|
return {
|
|
1099
|
-
type:
|
|
1099
|
+
type: h.ApplicationData,
|
|
1100
1100
|
body: e
|
|
1101
1101
|
};
|
|
1102
1102
|
}
|
|
1103
1103
|
static changeCipherSpec() {
|
|
1104
1104
|
return {
|
|
1105
|
-
type:
|
|
1105
|
+
type: h.ChangeCipherSpec,
|
|
1106
1106
|
body: new Uint8Array()
|
|
1107
1107
|
};
|
|
1108
1108
|
}
|
|
1109
1109
|
static alert(e) {
|
|
1110
1110
|
return {
|
|
1111
|
-
type:
|
|
1112
|
-
level:
|
|
1113
|
-
description:
|
|
1111
|
+
type: h.Alert,
|
|
1112
|
+
level: Te[e[0]],
|
|
1113
|
+
description: we[e[1]]
|
|
1114
1114
|
};
|
|
1115
1115
|
}
|
|
1116
1116
|
static clientHandshake(e) {
|
|
1117
1117
|
const t = e[0], n = e[1] << 16 | e[2] << 8 | e[3], r = e.slice(4);
|
|
1118
1118
|
let s;
|
|
1119
1119
|
switch (t) {
|
|
1120
|
-
case
|
|
1121
|
-
s =
|
|
1120
|
+
case E.HelloRequest:
|
|
1121
|
+
s = T.clientHelloRequestPayload();
|
|
1122
1122
|
break;
|
|
1123
|
-
case
|
|
1124
|
-
s =
|
|
1123
|
+
case E.ClientHello:
|
|
1124
|
+
s = T.clientHelloPayload(r);
|
|
1125
1125
|
break;
|
|
1126
|
-
case
|
|
1127
|
-
s =
|
|
1126
|
+
case E.ClientKeyExchange:
|
|
1127
|
+
s = T.clientKeyExchangePayload(r);
|
|
1128
1128
|
break;
|
|
1129
|
-
case
|
|
1130
|
-
s =
|
|
1129
|
+
case E.Finished:
|
|
1130
|
+
s = T.clientFinishedPayload(r);
|
|
1131
1131
|
break;
|
|
1132
1132
|
default:
|
|
1133
1133
|
throw new Error(`Invalid handshake type ${t}`);
|
|
1134
1134
|
}
|
|
1135
1135
|
return {
|
|
1136
|
-
type:
|
|
1136
|
+
type: h.Handshake,
|
|
1137
1137
|
msg_type: t,
|
|
1138
1138
|
length: n,
|
|
1139
1139
|
body: s
|
|
@@ -1183,7 +1183,7 @@ class E {
|
|
|
1183
1183
|
* +------+------+---------------------------+
|
|
1184
1184
|
*/
|
|
1185
1185
|
static clientHelloPayload(e) {
|
|
1186
|
-
const t = new
|
|
1186
|
+
const t = new I(e.buffer), n = {
|
|
1187
1187
|
client_version: t.readUint8Array(2),
|
|
1188
1188
|
/**
|
|
1189
1189
|
* Technically this consists of a GMT timestamp
|
|
@@ -1194,7 +1194,7 @@ class E {
|
|
|
1194
1194
|
}, r = t.readUint8();
|
|
1195
1195
|
n.session_id = t.readUint8Array(r);
|
|
1196
1196
|
const s = t.readUint16();
|
|
1197
|
-
n.cipher_suites =
|
|
1197
|
+
n.cipher_suites = T.parseCipherSuites(
|
|
1198
1198
|
t.readUint8Array(s).buffer
|
|
1199
1199
|
);
|
|
1200
1200
|
const a = t.readUint8();
|
|
@@ -1202,7 +1202,7 @@ class E {
|
|
|
1202
1202
|
a
|
|
1203
1203
|
);
|
|
1204
1204
|
const _ = t.readUint16();
|
|
1205
|
-
return n.extensions =
|
|
1205
|
+
return n.extensions = $e(
|
|
1206
1206
|
t.readUint8Array(_)
|
|
1207
1207
|
), n;
|
|
1208
1208
|
}
|
|
@@ -1227,7 +1227,7 @@ class E {
|
|
|
1227
1227
|
};
|
|
1228
1228
|
}
|
|
1229
1229
|
}
|
|
1230
|
-
function
|
|
1230
|
+
function Xe(i) {
|
|
1231
1231
|
return new TransformStream({
|
|
1232
1232
|
transform(e, t) {
|
|
1233
1233
|
for (; e.length > 0; )
|
|
@@ -1235,18 +1235,18 @@ function Ye(i) {
|
|
|
1235
1235
|
}
|
|
1236
1236
|
});
|
|
1237
1237
|
}
|
|
1238
|
-
class
|
|
1238
|
+
class D {
|
|
1239
1239
|
static certificate(e) {
|
|
1240
1240
|
const t = [];
|
|
1241
1241
|
for (const s of e)
|
|
1242
|
-
t.push(
|
|
1242
|
+
t.push(L(s.byteLength)), t.push(new Uint8Array(s));
|
|
1243
1243
|
const n = H(t), r = new Uint8Array([
|
|
1244
|
-
...
|
|
1244
|
+
...L(n.byteLength),
|
|
1245
1245
|
...n
|
|
1246
1246
|
]);
|
|
1247
1247
|
return new Uint8Array([
|
|
1248
|
-
|
|
1249
|
-
...
|
|
1248
|
+
E.Certificate,
|
|
1249
|
+
...L(r.length),
|
|
1250
1250
|
...r
|
|
1251
1251
|
]);
|
|
1252
1252
|
}
|
|
@@ -1288,9 +1288,9 @@ class K {
|
|
|
1288
1288
|
await crypto.subtle.exportKey("raw", n.publicKey)
|
|
1289
1289
|
), a = new Uint8Array([
|
|
1290
1290
|
// Curve type (1 byte)
|
|
1291
|
-
|
|
1291
|
+
ze.NamedCurve,
|
|
1292
1292
|
// Curve name (2 bytes)
|
|
1293
|
-
...
|
|
1293
|
+
...W(Ye.secp256r1),
|
|
1294
1294
|
// Public key length (1 byte)
|
|
1295
1295
|
s.byteLength,
|
|
1296
1296
|
// Public key (65 bytes, uncompressed format)
|
|
@@ -1302,19 +1302,19 @@ class K {
|
|
|
1302
1302
|
},
|
|
1303
1303
|
r,
|
|
1304
1304
|
new Uint8Array([...e, ...t, ...a])
|
|
1305
|
-
),
|
|
1305
|
+
), o = new Uint8Array(_), S = new Uint8Array([
|
|
1306
1306
|
z.sha256,
|
|
1307
1307
|
V.rsa
|
|
1308
|
-
]),
|
|
1308
|
+
]), l = new Uint8Array([
|
|
1309
1309
|
...a,
|
|
1310
1310
|
...S,
|
|
1311
|
-
...
|
|
1312
|
-
...
|
|
1311
|
+
...W(o.length),
|
|
1312
|
+
...o
|
|
1313
1313
|
]);
|
|
1314
1314
|
return new Uint8Array([
|
|
1315
|
-
|
|
1316
|
-
...
|
|
1317
|
-
...
|
|
1315
|
+
E.ServerKeyExchange,
|
|
1316
|
+
...L(l.length),
|
|
1317
|
+
...l
|
|
1318
1318
|
]);
|
|
1319
1319
|
}
|
|
1320
1320
|
/**
|
|
@@ -1359,13 +1359,13 @@ class K {
|
|
|
1359
1359
|
const r = e.extensions.map((_) => {
|
|
1360
1360
|
switch (_.type) {
|
|
1361
1361
|
case "server_name":
|
|
1362
|
-
return
|
|
1362
|
+
return he.encodeForClient();
|
|
1363
1363
|
case "ec_point_formats":
|
|
1364
|
-
return
|
|
1364
|
+
return Ae.encodeForClient(
|
|
1365
1365
|
"uncompressed"
|
|
1366
1366
|
);
|
|
1367
1367
|
case "renegotiation_info":
|
|
1368
|
-
return
|
|
1368
|
+
return He.encodeForClient();
|
|
1369
1369
|
}
|
|
1370
1370
|
}).filter((_) => _ !== void 0), s = H(r), a = new Uint8Array([
|
|
1371
1371
|
// Version field – 0x03, 0x03 means TLS 1.2
|
|
@@ -1373,20 +1373,20 @@ class K {
|
|
|
1373
1373
|
...t,
|
|
1374
1374
|
e.session_id.length,
|
|
1375
1375
|
...e.session_id,
|
|
1376
|
-
...
|
|
1376
|
+
...W(de.TLS1_CK_ECDHE_RSA_WITH_AES_128_GCM_SHA256),
|
|
1377
1377
|
n,
|
|
1378
1378
|
// Extensions length (2 bytes)
|
|
1379
|
-
...
|
|
1379
|
+
...W(s.length),
|
|
1380
1380
|
...s
|
|
1381
1381
|
]);
|
|
1382
1382
|
return new Uint8Array([
|
|
1383
|
-
|
|
1384
|
-
...
|
|
1383
|
+
E.ServerHello,
|
|
1384
|
+
...L(a.length),
|
|
1385
1385
|
...a
|
|
1386
1386
|
]);
|
|
1387
1387
|
}
|
|
1388
1388
|
static serverHelloDone() {
|
|
1389
|
-
return new Uint8Array([
|
|
1389
|
+
return new Uint8Array([E.ServerHelloDone, ...L(0)]);
|
|
1390
1390
|
}
|
|
1391
1391
|
/**
|
|
1392
1392
|
* Server finished message.
|
|
@@ -1420,8 +1420,8 @@ class K {
|
|
|
1420
1420
|
)
|
|
1421
1421
|
);
|
|
1422
1422
|
return new Uint8Array([
|
|
1423
|
-
|
|
1424
|
-
...
|
|
1423
|
+
E.Finished,
|
|
1424
|
+
...L(r.length),
|
|
1425
1425
|
...r
|
|
1426
1426
|
]);
|
|
1427
1427
|
}
|
|
@@ -1429,25 +1429,25 @@ class K {
|
|
|
1429
1429
|
return new Uint8Array([1]);
|
|
1430
1430
|
}
|
|
1431
1431
|
}
|
|
1432
|
-
function
|
|
1433
|
-
return
|
|
1432
|
+
function Qe(i, e) {
|
|
1433
|
+
return et.generateCertificate(i, e);
|
|
1434
1434
|
}
|
|
1435
|
-
function
|
|
1435
|
+
function Dt(i) {
|
|
1436
1436
|
return `-----BEGIN CERTIFICATE-----
|
|
1437
|
-
${
|
|
1438
|
-
|
|
1437
|
+
${me(
|
|
1438
|
+
ye(i.buffer)
|
|
1439
1439
|
)}
|
|
1440
1440
|
-----END CERTIFICATE-----`;
|
|
1441
1441
|
}
|
|
1442
|
-
async function
|
|
1442
|
+
async function Wt(i) {
|
|
1443
1443
|
const e = await crypto.subtle.exportKey("pkcs8", i);
|
|
1444
1444
|
return `-----BEGIN PRIVATE KEY-----
|
|
1445
|
-
${
|
|
1446
|
-
|
|
1445
|
+
${me(
|
|
1446
|
+
ye(e)
|
|
1447
1447
|
)}
|
|
1448
1448
|
-----END PRIVATE KEY-----`;
|
|
1449
1449
|
}
|
|
1450
|
-
class
|
|
1450
|
+
class et {
|
|
1451
1451
|
static async generateCertificate(e, t) {
|
|
1452
1452
|
const n = await crypto.subtle.generateKey(
|
|
1453
1453
|
{
|
|
@@ -1482,17 +1482,17 @@ class Je {
|
|
|
1482
1482
|
t,
|
|
1483
1483
|
e.buffer
|
|
1484
1484
|
);
|
|
1485
|
-
return
|
|
1485
|
+
return c.sequence([
|
|
1486
1486
|
new Uint8Array(e.buffer),
|
|
1487
1487
|
this.signatureAlgorithm("sha256WithRSAEncryption"),
|
|
1488
|
-
|
|
1488
|
+
c.bitString(new Uint8Array(n))
|
|
1489
1489
|
]);
|
|
1490
1490
|
}
|
|
1491
1491
|
static async signingRequest(e, t) {
|
|
1492
1492
|
const n = [];
|
|
1493
1493
|
return e.keyUsage && n.push(this.keyUsage(e.keyUsage)), e.extKeyUsage && n.push(this.extKeyUsage(e.extKeyUsage)), e.subjectAltNames && n.push(this.subjectAltName(e.subjectAltNames)), e.nsCertType && n.push(this.nsCertType(e.nsCertType)), e.basicConstraints && n.push(
|
|
1494
1494
|
this.basicConstraints(e.basicConstraints)
|
|
1495
|
-
),
|
|
1495
|
+
), c.sequence([
|
|
1496
1496
|
this.version(e.version),
|
|
1497
1497
|
this.serialNumber(e.serialNumber),
|
|
1498
1498
|
this.signatureAlgorithm(e.signatureAlgorithm),
|
|
@@ -1504,56 +1504,56 @@ class Je {
|
|
|
1504
1504
|
]);
|
|
1505
1505
|
}
|
|
1506
1506
|
static version(e = 2) {
|
|
1507
|
-
return
|
|
1507
|
+
return c.ASN1(
|
|
1508
1508
|
160,
|
|
1509
|
-
|
|
1509
|
+
c.integer(new Uint8Array([e]))
|
|
1510
1510
|
);
|
|
1511
1511
|
}
|
|
1512
1512
|
static serialNumber(e = crypto.getRandomValues(new Uint8Array(4))) {
|
|
1513
|
-
return
|
|
1513
|
+
return c.integer(e);
|
|
1514
1514
|
}
|
|
1515
1515
|
static signatureAlgorithm(e = "sha256WithRSAEncryption") {
|
|
1516
|
-
return
|
|
1517
|
-
|
|
1518
|
-
|
|
1516
|
+
return c.sequence([
|
|
1517
|
+
c.objectIdentifier(y(e)),
|
|
1518
|
+
c.null()
|
|
1519
1519
|
]);
|
|
1520
1520
|
}
|
|
1521
1521
|
static async subjectPublicKeyInfo(e) {
|
|
1522
1522
|
return new Uint8Array(await crypto.subtle.exportKey("spki", e));
|
|
1523
1523
|
}
|
|
1524
1524
|
static extensions(e) {
|
|
1525
|
-
return
|
|
1525
|
+
return c.ASN1(163, c.sequence(e));
|
|
1526
1526
|
}
|
|
1527
1527
|
static distinguishedName(e) {
|
|
1528
1528
|
const t = [];
|
|
1529
1529
|
for (const [n, r] of Object.entries(e)) {
|
|
1530
1530
|
const s = [
|
|
1531
|
-
|
|
1531
|
+
c.objectIdentifier(y(n))
|
|
1532
1532
|
];
|
|
1533
1533
|
switch (n) {
|
|
1534
1534
|
case "countryName":
|
|
1535
|
-
s.push(
|
|
1535
|
+
s.push(c.printableString(r));
|
|
1536
1536
|
break;
|
|
1537
1537
|
default:
|
|
1538
|
-
s.push(
|
|
1538
|
+
s.push(c.utf8String(r));
|
|
1539
1539
|
}
|
|
1540
|
-
t.push(
|
|
1540
|
+
t.push(c.set([c.sequence(s)]));
|
|
1541
1541
|
}
|
|
1542
|
-
return
|
|
1542
|
+
return c.sequence(t);
|
|
1543
1543
|
}
|
|
1544
1544
|
static validity(e) {
|
|
1545
|
-
return
|
|
1546
|
-
|
|
1547
|
-
|
|
1545
|
+
return c.sequence([
|
|
1546
|
+
c.ASN1(
|
|
1547
|
+
f.UTCTime,
|
|
1548
1548
|
new TextEncoder().encode(
|
|
1549
1549
|
ie((e == null ? void 0 : e.notBefore) ?? /* @__PURE__ */ new Date())
|
|
1550
1550
|
)
|
|
1551
1551
|
),
|
|
1552
|
-
|
|
1553
|
-
|
|
1552
|
+
c.ASN1(
|
|
1553
|
+
f.UTCTime,
|
|
1554
1554
|
new TextEncoder().encode(
|
|
1555
1555
|
ie(
|
|
1556
|
-
(e == null ? void 0 : e.notAfter) ??
|
|
1556
|
+
(e == null ? void 0 : e.notAfter) ?? nt(/* @__PURE__ */ new Date(), 10)
|
|
1557
1557
|
)
|
|
1558
1558
|
)
|
|
1559
1559
|
)
|
|
@@ -1563,63 +1563,63 @@ class Je {
|
|
|
1563
1563
|
ca: e = !0,
|
|
1564
1564
|
pathLenConstraint: t = void 0
|
|
1565
1565
|
}) {
|
|
1566
|
-
const n = [
|
|
1566
|
+
const n = [c.boolean(e)];
|
|
1567
1567
|
return t !== void 0 && n.push(
|
|
1568
|
-
|
|
1569
|
-
),
|
|
1570
|
-
|
|
1571
|
-
|
|
1568
|
+
c.integer(new Uint8Array([t]))
|
|
1569
|
+
), c.sequence([
|
|
1570
|
+
c.objectIdentifier(y("basicConstraints")),
|
|
1571
|
+
c.octetString(c.sequence(n))
|
|
1572
1572
|
]);
|
|
1573
1573
|
}
|
|
1574
1574
|
static keyUsage(e) {
|
|
1575
1575
|
const t = new Uint8Array([0]);
|
|
1576
|
-
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),
|
|
1577
|
-
|
|
1578
|
-
|
|
1576
|
+
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), c.sequence([
|
|
1577
|
+
c.objectIdentifier(y("keyUsage")),
|
|
1578
|
+
c.boolean(!0),
|
|
1579
1579
|
// Critical
|
|
1580
|
-
|
|
1580
|
+
c.octetString(c.bitString(t))
|
|
1581
1581
|
]);
|
|
1582
1582
|
}
|
|
1583
1583
|
static extKeyUsage(e = {}) {
|
|
1584
|
-
return
|
|
1585
|
-
|
|
1586
|
-
|
|
1584
|
+
return c.sequence([
|
|
1585
|
+
c.objectIdentifier(y("extKeyUsage")),
|
|
1586
|
+
c.boolean(!0),
|
|
1587
1587
|
// Critical
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
Object.entries(e).map(([t, n]) => n ?
|
|
1591
|
-
|
|
1592
|
-
) :
|
|
1588
|
+
c.octetString(
|
|
1589
|
+
c.sequence(
|
|
1590
|
+
Object.entries(e).map(([t, n]) => n ? c.objectIdentifier(
|
|
1591
|
+
y(t)
|
|
1592
|
+
) : c.null())
|
|
1593
1593
|
)
|
|
1594
1594
|
)
|
|
1595
1595
|
]);
|
|
1596
1596
|
}
|
|
1597
1597
|
static nsCertType(e) {
|
|
1598
1598
|
const t = new Uint8Array([0]);
|
|
1599
|
-
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),
|
|
1600
|
-
|
|
1601
|
-
|
|
1599
|
+
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), c.sequence([
|
|
1600
|
+
c.objectIdentifier(y("nsCertType")),
|
|
1601
|
+
c.octetString(t)
|
|
1602
1602
|
]);
|
|
1603
1603
|
}
|
|
1604
1604
|
static subjectAltName(e) {
|
|
1605
1605
|
var s, a;
|
|
1606
1606
|
const t = ((s = e.dnsNames) == null ? void 0 : s.map((_) => {
|
|
1607
|
-
const
|
|
1608
|
-
return
|
|
1607
|
+
const o = c.ia5String(_);
|
|
1608
|
+
return c.contextSpecific(2, o);
|
|
1609
1609
|
})) || [], n = ((a = e.ipAddresses) == null ? void 0 : a.map((_) => {
|
|
1610
|
-
const
|
|
1611
|
-
return
|
|
1612
|
-
})) || [], r =
|
|
1613
|
-
|
|
1610
|
+
const o = c.ia5String(_);
|
|
1611
|
+
return c.contextSpecific(7, o);
|
|
1612
|
+
})) || [], r = c.octetString(
|
|
1613
|
+
c.sequence([...t, ...n])
|
|
1614
1614
|
);
|
|
1615
|
-
return
|
|
1616
|
-
|
|
1617
|
-
|
|
1615
|
+
return c.sequence([
|
|
1616
|
+
c.objectIdentifier(y("subjectAltName")),
|
|
1617
|
+
c.boolean(!0),
|
|
1618
1618
|
r
|
|
1619
1619
|
]);
|
|
1620
1620
|
}
|
|
1621
1621
|
}
|
|
1622
|
-
const
|
|
1622
|
+
const tt = {
|
|
1623
1623
|
// Algorithm OIDs
|
|
1624
1624
|
"1.2.840.113549.1.1.1": "rsaEncryption",
|
|
1625
1625
|
"1.2.840.113549.1.1.4": "md5WithRSAEncryption",
|
|
@@ -1729,13 +1729,13 @@ const Xe = {
|
|
|
1729
1729
|
"1.3.6.1.5.5.7.3.4": "emailProtection",
|
|
1730
1730
|
"1.3.6.1.5.5.7.3.8": "timeStamping"
|
|
1731
1731
|
};
|
|
1732
|
-
function
|
|
1733
|
-
for (const [e, t] of Object.entries(
|
|
1732
|
+
function y(i) {
|
|
1733
|
+
for (const [e, t] of Object.entries(tt))
|
|
1734
1734
|
if (t === i)
|
|
1735
1735
|
return e;
|
|
1736
1736
|
throw new Error(`OID not found for name: ${i}`);
|
|
1737
1737
|
}
|
|
1738
|
-
const se = 32,
|
|
1738
|
+
const se = 32, f = {
|
|
1739
1739
|
Boolean: 1,
|
|
1740
1740
|
Integer: 2,
|
|
1741
1741
|
BitString: 3,
|
|
@@ -1749,7 +1749,7 @@ const se = 32, d = {
|
|
|
1749
1749
|
IA5String: 22,
|
|
1750
1750
|
UTCTime: 23
|
|
1751
1751
|
};
|
|
1752
|
-
class
|
|
1752
|
+
class c {
|
|
1753
1753
|
// Helper functions for ASN.1 DER encoding
|
|
1754
1754
|
static length_(e) {
|
|
1755
1755
|
if (e < 128)
|
|
@@ -1767,7 +1767,7 @@ class o {
|
|
|
1767
1767
|
}
|
|
1768
1768
|
}
|
|
1769
1769
|
static ASN1(e, t) {
|
|
1770
|
-
const n =
|
|
1770
|
+
const n = c.length_(t.length), r = new Uint8Array(1 + n.length + t.length);
|
|
1771
1771
|
return r[0] = e, r.set(n, 1), r.set(t, 1 + n.length), r;
|
|
1772
1772
|
}
|
|
1773
1773
|
static integer(e) {
|
|
@@ -1778,17 +1778,17 @@ class o {
|
|
|
1778
1778
|
const n = new Uint8Array(e.length + 1);
|
|
1779
1779
|
n[0] = 0, n.set(e, 1), e = n;
|
|
1780
1780
|
}
|
|
1781
|
-
return
|
|
1781
|
+
return c.ASN1(f.Integer, e);
|
|
1782
1782
|
}
|
|
1783
1783
|
static bitString(e) {
|
|
1784
1784
|
const t = new Uint8Array([0]), n = new Uint8Array(t.length + e.length);
|
|
1785
|
-
return n.set(t), n.set(e, t.length),
|
|
1785
|
+
return n.set(t), n.set(e, t.length), c.ASN1(f.BitString, n);
|
|
1786
1786
|
}
|
|
1787
1787
|
static octetString(e) {
|
|
1788
|
-
return
|
|
1788
|
+
return c.ASN1(f.OctetString, e);
|
|
1789
1789
|
}
|
|
1790
1790
|
static null() {
|
|
1791
|
-
return
|
|
1791
|
+
return c.ASN1(f.Null, new Uint8Array(0));
|
|
1792
1792
|
}
|
|
1793
1793
|
static objectIdentifier(e) {
|
|
1794
1794
|
const t = e.split(".").map(Number), r = [t[0] * 40 + t[1]];
|
|
@@ -1798,61 +1798,61 @@ class o {
|
|
|
1798
1798
|
do
|
|
1799
1799
|
_.unshift(a & 127), a >>= 7;
|
|
1800
1800
|
while (a > 0);
|
|
1801
|
-
for (let
|
|
1802
|
-
_[
|
|
1801
|
+
for (let o = 0; o < _.length - 1; o++)
|
|
1802
|
+
_[o] |= 128;
|
|
1803
1803
|
r.push(..._);
|
|
1804
1804
|
}
|
|
1805
|
-
return
|
|
1805
|
+
return c.ASN1(f.OID, new Uint8Array(r));
|
|
1806
1806
|
}
|
|
1807
1807
|
static utf8String(e) {
|
|
1808
1808
|
const t = new TextEncoder().encode(e);
|
|
1809
|
-
return
|
|
1809
|
+
return c.ASN1(f.Utf8String, t);
|
|
1810
1810
|
}
|
|
1811
1811
|
static printableString(e) {
|
|
1812
1812
|
const t = new TextEncoder().encode(e);
|
|
1813
|
-
return
|
|
1813
|
+
return c.ASN1(f.PrintableString, t);
|
|
1814
1814
|
}
|
|
1815
1815
|
static sequence(e) {
|
|
1816
|
-
return
|
|
1816
|
+
return c.ASN1(f.Sequence, H(e));
|
|
1817
1817
|
}
|
|
1818
1818
|
static set(e) {
|
|
1819
|
-
return
|
|
1819
|
+
return c.ASN1(f.Set, H(e));
|
|
1820
1820
|
}
|
|
1821
1821
|
static ia5String(e) {
|
|
1822
1822
|
const t = new TextEncoder().encode(e);
|
|
1823
|
-
return
|
|
1823
|
+
return c.ASN1(f.IA5String, t);
|
|
1824
1824
|
}
|
|
1825
1825
|
static contextSpecific(e, t, n = !1) {
|
|
1826
1826
|
const r = (n ? 160 : 128) | e;
|
|
1827
|
-
return
|
|
1827
|
+
return c.ASN1(r, t);
|
|
1828
1828
|
}
|
|
1829
1829
|
static boolean(e) {
|
|
1830
|
-
return
|
|
1831
|
-
|
|
1830
|
+
return c.ASN1(
|
|
1831
|
+
f.Boolean,
|
|
1832
1832
|
new Uint8Array([e ? 255 : 0])
|
|
1833
1833
|
);
|
|
1834
1834
|
}
|
|
1835
1835
|
}
|
|
1836
|
-
function
|
|
1836
|
+
function ye(i) {
|
|
1837
1837
|
return btoa(String.fromCodePoint(...new Uint8Array(i)));
|
|
1838
1838
|
}
|
|
1839
|
-
function
|
|
1839
|
+
function me(i) {
|
|
1840
1840
|
var e;
|
|
1841
1841
|
return ((e = i.match(/.{1,64}/g)) == null ? void 0 : e.join(`
|
|
1842
1842
|
`)) || i;
|
|
1843
1843
|
}
|
|
1844
1844
|
function ie(i) {
|
|
1845
|
-
const e = i.getUTCFullYear().toString().substr(2), t =
|
|
1845
|
+
const e = i.getUTCFullYear().toString().substr(2), t = U(i.getUTCMonth() + 1), n = U(i.getUTCDate()), r = U(i.getUTCHours()), s = U(i.getUTCMinutes()), a = U(i.getUTCSeconds());
|
|
1846
1846
|
return `${e}${t}${n}${r}${s}${a}Z`;
|
|
1847
1847
|
}
|
|
1848
|
-
function
|
|
1848
|
+
function U(i) {
|
|
1849
1849
|
return i.toString().padStart(2, "0");
|
|
1850
1850
|
}
|
|
1851
|
-
function
|
|
1851
|
+
function nt(i, e) {
|
|
1852
1852
|
const t = new Date(i);
|
|
1853
1853
|
return t.setUTCFullYear(t.getUTCFullYear() + e), t;
|
|
1854
1854
|
}
|
|
1855
|
-
class
|
|
1855
|
+
class rt extends TransformStream {
|
|
1856
1856
|
constructor() {
|
|
1857
1857
|
let e = new Uint8Array(0), t = "SCAN_CHUNK_SIZE", n = 0;
|
|
1858
1858
|
super({
|
|
@@ -1880,12 +1880,12 @@ class et extends TransformStream {
|
|
|
1880
1880
|
);
|
|
1881
1881
|
const _ = new TextDecoder().decode(
|
|
1882
1882
|
e.slice(0, a)
|
|
1883
|
-
),
|
|
1884
|
-
if (e = e.slice(a + 2),
|
|
1883
|
+
), o = parseInt(_, 16);
|
|
1884
|
+
if (e = e.slice(a + 2), o === 0) {
|
|
1885
1885
|
t = "SCAN_FINAL_CHUNK", s.terminate();
|
|
1886
1886
|
return;
|
|
1887
1887
|
}
|
|
1888
|
-
n =
|
|
1888
|
+
n = o, t = "SCAN_CHUNK_DATA";
|
|
1889
1889
|
} else if (t === "SCAN_CHUNK_DATA") {
|
|
1890
1890
|
const a = Math.min(
|
|
1891
1891
|
n,
|
|
@@ -1905,7 +1905,7 @@ class et extends TransformStream {
|
|
|
1905
1905
|
});
|
|
1906
1906
|
}
|
|
1907
1907
|
}
|
|
1908
|
-
const
|
|
1908
|
+
const st = (i, e) => ({
|
|
1909
1909
|
...i,
|
|
1910
1910
|
websocket: {
|
|
1911
1911
|
url: (t, n, r) => `ws://playground.internal/?${new URLSearchParams({
|
|
@@ -1913,7 +1913,7 @@ const tt = (i, e) => ({
|
|
|
1913
1913
|
port: r
|
|
1914
1914
|
}).toString()}`,
|
|
1915
1915
|
subprotocol: "binary",
|
|
1916
|
-
decorator: () => class extends
|
|
1916
|
+
decorator: () => class extends it {
|
|
1917
1917
|
constructor(t, n) {
|
|
1918
1918
|
super(t, n, {
|
|
1919
1919
|
CAroot: e.CAroot,
|
|
@@ -1923,7 +1923,7 @@ const tt = (i, e) => ({
|
|
|
1923
1923
|
}
|
|
1924
1924
|
}
|
|
1925
1925
|
});
|
|
1926
|
-
class
|
|
1926
|
+
class it {
|
|
1927
1927
|
constructor(e, t, {
|
|
1928
1928
|
CAroot: n,
|
|
1929
1929
|
corsProxyUrl: r,
|
|
@@ -1994,7 +1994,7 @@ class nt {
|
|
|
1994
1994
|
switch (this.bufferedBytesFromClient = H([
|
|
1995
1995
|
this.bufferedBytesFromClient,
|
|
1996
1996
|
new Uint8Array(e)
|
|
1997
|
-
]),
|
|
1997
|
+
]), _t(this.port, this.bufferedBytesFromClient)) {
|
|
1998
1998
|
case !1:
|
|
1999
1999
|
return;
|
|
2000
2000
|
case "other":
|
|
@@ -2013,7 +2013,7 @@ class nt {
|
|
|
2013
2013
|
throw new Error(
|
|
2014
2014
|
"TLS protocol is only supported when the TCPOverFetchWebsocket is instantiated with a CAroot"
|
|
2015
2015
|
);
|
|
2016
|
-
const e = await
|
|
2016
|
+
const e = await Qe(
|
|
2017
2017
|
{
|
|
2018
2018
|
subject: {
|
|
2019
2019
|
commonName: this.host,
|
|
@@ -2023,14 +2023,14 @@ class nt {
|
|
|
2023
2023
|
issuer: this.CAroot.tbsDescription.subject
|
|
2024
2024
|
},
|
|
2025
2025
|
this.CAroot.keyPair
|
|
2026
|
-
), t = new
|
|
2026
|
+
), t = new Je();
|
|
2027
2027
|
this.clientUpstream.readable.pipeTo(t.clientEnd.upstream.writable).catch(() => {
|
|
2028
2028
|
}), t.clientEnd.downstream.readable.pipeTo(this.clientDownstream.writable).catch(() => {
|
|
2029
2029
|
}), await t.TLSHandshake(e.keyPair.privateKey, [
|
|
2030
2030
|
e.certificate,
|
|
2031
2031
|
this.CAroot.certificate
|
|
2032
2032
|
]);
|
|
2033
|
-
const { request: n, expectsContinue: r } = await
|
|
2033
|
+
const { request: n, expectsContinue: r } = await p.parseHttpRequest(
|
|
2034
2034
|
t.serverEnd.upstream.readable,
|
|
2035
2035
|
this.host,
|
|
2036
2036
|
"https"
|
|
@@ -2044,7 +2044,7 @@ class nt {
|
|
|
2044
2044
|
), s.releaseLock();
|
|
2045
2045
|
}
|
|
2046
2046
|
try {
|
|
2047
|
-
await
|
|
2047
|
+
await p.fetchRawResponseBytes(
|
|
2048
2048
|
n,
|
|
2049
2049
|
this.corsProxyUrl
|
|
2050
2050
|
).pipeTo(t.serverEnd.downstream.writable);
|
|
@@ -2052,7 +2052,7 @@ class nt {
|
|
|
2052
2052
|
}
|
|
2053
2053
|
}
|
|
2054
2054
|
async fetchOverHTTP() {
|
|
2055
|
-
const { request: e, expectsContinue: t } = await
|
|
2055
|
+
const { request: e, expectsContinue: t } = await p.parseHttpRequest(
|
|
2056
2056
|
this.clientUpstream.readable,
|
|
2057
2057
|
this.host,
|
|
2058
2058
|
"http"
|
|
@@ -2066,7 +2066,7 @@ class nt {
|
|
|
2066
2066
|
), n.releaseLock();
|
|
2067
2067
|
}
|
|
2068
2068
|
try {
|
|
2069
|
-
await
|
|
2069
|
+
await p.fetchRawResponseBytes(
|
|
2070
2070
|
e,
|
|
2071
2071
|
this.corsProxyUrl
|
|
2072
2072
|
).pipeTo(this.clientDownstream.writable);
|
|
@@ -2077,7 +2077,7 @@ class nt {
|
|
|
2077
2077
|
this.emit("message", { data: new Uint8Array(0) }), this.readyState = this.CLOSING, this.emit("close"), this.readyState = this.CLOSED;
|
|
2078
2078
|
}
|
|
2079
2079
|
}
|
|
2080
|
-
const
|
|
2080
|
+
const at = [
|
|
2081
2081
|
"GET",
|
|
2082
2082
|
"POST",
|
|
2083
2083
|
"HEAD",
|
|
@@ -2087,20 +2087,20 @@ const rt = [
|
|
|
2087
2087
|
"PUT",
|
|
2088
2088
|
"TRACE"
|
|
2089
2089
|
];
|
|
2090
|
-
function
|
|
2090
|
+
function _t(i, e) {
|
|
2091
2091
|
if (e.length < 8)
|
|
2092
2092
|
return !1;
|
|
2093
|
-
if (i === 443 && e[0] ===
|
|
2093
|
+
if (i === 443 && e[0] === h.Handshake && // TLS versions between 1.0 and 1.2
|
|
2094
2094
|
e[1] === 3 && e[2] >= 1 && e[2] <= 3)
|
|
2095
2095
|
return "tls";
|
|
2096
2096
|
const n = new TextDecoder("latin1", {
|
|
2097
2097
|
fatal: !0
|
|
2098
2098
|
}).decode(e);
|
|
2099
|
-
return
|
|
2099
|
+
return at.some(
|
|
2100
2100
|
(s) => n.startsWith(s + " ")
|
|
2101
2101
|
) ? "http" : "other";
|
|
2102
2102
|
}
|
|
2103
|
-
class
|
|
2103
|
+
class p {
|
|
2104
2104
|
/**
|
|
2105
2105
|
* Streams a HTTP response including the status line and headers.
|
|
2106
2106
|
*/
|
|
@@ -2110,12 +2110,12 @@ class L {
|
|
|
2110
2110
|
var _;
|
|
2111
2111
|
let r;
|
|
2112
2112
|
try {
|
|
2113
|
-
r = await
|
|
2113
|
+
r = await ve(
|
|
2114
2114
|
e,
|
|
2115
2115
|
void 0,
|
|
2116
2116
|
t
|
|
2117
2117
|
);
|
|
2118
|
-
} catch (
|
|
2118
|
+
} catch (o) {
|
|
2119
2119
|
n.enqueue(
|
|
2120
2120
|
new TextEncoder().encode(
|
|
2121
2121
|
`HTTP/1.1 400 Bad Request\r
|
|
@@ -2123,10 +2123,10 @@ Content-Length: 0\r
|
|
|
2123
2123
|
\r
|
|
2124
2124
|
`
|
|
2125
2125
|
)
|
|
2126
|
-
), n.error(
|
|
2126
|
+
), n.error(o);
|
|
2127
2127
|
return;
|
|
2128
2128
|
}
|
|
2129
|
-
n.enqueue(
|
|
2129
|
+
n.enqueue(p.headersAsBytes(r));
|
|
2130
2130
|
const s = (_ = r.body) == null ? void 0 : _.getReader();
|
|
2131
2131
|
if (!s) {
|
|
2132
2132
|
n.close();
|
|
@@ -2134,12 +2134,12 @@ Content-Length: 0\r
|
|
|
2134
2134
|
}
|
|
2135
2135
|
const a = new TextEncoder();
|
|
2136
2136
|
for (; ; ) {
|
|
2137
|
-
const { done:
|
|
2137
|
+
const { done: o, value: S } = await s.read();
|
|
2138
2138
|
if (S && (n.enqueue(
|
|
2139
2139
|
a.encode(`${S.length.toString(16)}\r
|
|
2140
2140
|
`)
|
|
2141
2141
|
), n.enqueue(S), n.enqueue(a.encode(`\r
|
|
2142
|
-
`))),
|
|
2142
|
+
`))), o) {
|
|
2143
2143
|
n.enqueue(a.encode(`0\r
|
|
2144
2144
|
\r
|
|
2145
2145
|
`)), n.close();
|
|
@@ -2171,81 +2171,105 @@ Content-Length: 0\r
|
|
|
2171
2171
|
let r = new Uint8Array(0), s = !1, a = -1;
|
|
2172
2172
|
const _ = e.getReader();
|
|
2173
2173
|
for (; a === -1; ) {
|
|
2174
|
-
const { done: k, value:
|
|
2174
|
+
const { done: k, value: R } = await _.read();
|
|
2175
2175
|
if (k) {
|
|
2176
2176
|
s = !0;
|
|
2177
2177
|
break;
|
|
2178
2178
|
}
|
|
2179
|
-
r = H([r,
|
|
2179
|
+
r = H([r, R]), a = ot(
|
|
2180
2180
|
r,
|
|
2181
2181
|
new Uint8Array([13, 10, 13, 10])
|
|
2182
2182
|
);
|
|
2183
2183
|
}
|
|
2184
2184
|
_.releaseLock();
|
|
2185
|
-
const
|
|
2185
|
+
const o = r.slice(0, a), S = p.parseRequestHeaders(o), l = p.expectsContinue(
|
|
2186
|
+
S.headers
|
|
2187
|
+
), C = S.headers.get("Transfer-Encoding") !== null ? "chunked" : "content-length", A = S.headers.get("Content-Length") !== null ? parseInt(S.headers.get("Content-Length"), 10) : void 0, u = r.slice(
|
|
2186
2188
|
a + 4
|
|
2187
2189
|
/* Skip \r\n\r\n */
|
|
2188
2190
|
);
|
|
2189
|
-
let
|
|
2190
|
-
if (S.method !== "GET") {
|
|
2191
|
+
let d;
|
|
2192
|
+
if (S.method !== "GET" && S.method !== "HEAD") {
|
|
2191
2193
|
const k = e.getReader();
|
|
2192
|
-
let
|
|
2193
|
-
const
|
|
2194
|
+
let R = u.length, q = u.slice(-6);
|
|
2195
|
+
const Ie = new TextEncoder().encode(`0\r
|
|
2194
2196
|
\r
|
|
2195
2197
|
`);
|
|
2196
|
-
|
|
2197
|
-
async start(
|
|
2198
|
-
|
|
2199
|
-
const F = C === "content-length" &&
|
|
2200
|
-
(s || F) &&
|
|
2198
|
+
d = new ReadableStream({
|
|
2199
|
+
async start(B) {
|
|
2200
|
+
u.length > 0 && B.enqueue(u);
|
|
2201
|
+
const F = C === "content-length" && A !== void 0 && R >= A;
|
|
2202
|
+
(s || F) && B.close();
|
|
2201
2203
|
},
|
|
2202
|
-
async pull(
|
|
2203
|
-
const { done: F, value:
|
|
2204
|
-
if (
|
|
2204
|
+
async pull(B) {
|
|
2205
|
+
const { done: F, value: K } = await k.read();
|
|
2206
|
+
if (R += (K == null ? void 0 : K.length) || 0, K && (B.enqueue(K), q = H([
|
|
2205
2207
|
q,
|
|
2206
|
-
|
|
2207
|
-
]).slice(-5)), F || C === "content-length" &&
|
|
2208
|
-
(
|
|
2208
|
+
K || new Uint8Array()
|
|
2209
|
+
]).slice(-5)), F || C === "content-length" && A !== void 0 && R >= A || C === "chunked" && q.every(
|
|
2210
|
+
(Ke, De) => Ke === Ie[De]
|
|
2209
2211
|
)) {
|
|
2210
|
-
|
|
2212
|
+
B.close();
|
|
2211
2213
|
return;
|
|
2212
2214
|
}
|
|
2213
2215
|
}
|
|
2214
|
-
}), C === "chunked" && (
|
|
2215
|
-
new
|
|
2216
|
+
}), C === "chunked" && (d = d.pipeThrough(
|
|
2217
|
+
new rt()
|
|
2216
2218
|
));
|
|
2217
2219
|
}
|
|
2218
|
-
const
|
|
2220
|
+
const m = S.headers.get("Host") ?? t, b = new URL(S.path, n + "://" + m), ge = p.normalizeRequestHeadersForFetch(
|
|
2221
|
+
S.headers
|
|
2222
|
+
);
|
|
2219
2223
|
return {
|
|
2220
|
-
request: new Request(
|
|
2224
|
+
request: new Request(b.toString(), {
|
|
2221
2225
|
method: S.method,
|
|
2222
|
-
headers:
|
|
2223
|
-
body:
|
|
2226
|
+
headers: ge,
|
|
2227
|
+
body: d,
|
|
2224
2228
|
// @ts-expect-error duplex is required for streaming request bodies
|
|
2225
|
-
duplex:
|
|
2229
|
+
duplex: d ? "half" : void 0
|
|
2226
2230
|
}),
|
|
2227
|
-
expectsContinue:
|
|
2231
|
+
expectsContinue: l
|
|
2228
2232
|
};
|
|
2229
2233
|
}
|
|
2230
2234
|
static parseRequestHeaders(e) {
|
|
2231
|
-
var c;
|
|
2232
2235
|
const t = new TextDecoder().decode(e), n = t.split(`
|
|
2233
2236
|
`)[0], [r, s] = n.split(" "), a = new Headers();
|
|
2234
|
-
for (const
|
|
2237
|
+
for (const _ of t.split(`\r
|
|
2235
2238
|
`).slice(1)) {
|
|
2236
|
-
if (
|
|
2239
|
+
if (_ === "")
|
|
2237
2240
|
break;
|
|
2238
|
-
const
|
|
2239
|
-
if (
|
|
2241
|
+
const o = _.indexOf(":");
|
|
2242
|
+
if (o === -1)
|
|
2240
2243
|
continue;
|
|
2241
|
-
const
|
|
2242
|
-
|
|
2244
|
+
const S = _.slice(0, o).trim(), l = _.slice(o + 1).trimStart();
|
|
2245
|
+
S !== "" && a.set(S, l);
|
|
2243
2246
|
}
|
|
2244
|
-
|
|
2245
|
-
|
|
2247
|
+
return { method: r, path: s, headers: a };
|
|
2248
|
+
}
|
|
2249
|
+
static expectsContinue(e) {
|
|
2250
|
+
var t;
|
|
2251
|
+
return ((t = e.get("Expect")) == null ? void 0 : t.toLowerCase()) === "100-continue";
|
|
2252
|
+
}
|
|
2253
|
+
static normalizeRequestHeadersForFetch(e) {
|
|
2254
|
+
const t = new Headers(e);
|
|
2255
|
+
for (const n of [
|
|
2256
|
+
"Connection",
|
|
2257
|
+
"Content-Length",
|
|
2258
|
+
"Expect",
|
|
2259
|
+
"Host",
|
|
2260
|
+
"Keep-Alive",
|
|
2261
|
+
"Proxy-Authenticate",
|
|
2262
|
+
"Proxy-Authorization",
|
|
2263
|
+
"TE",
|
|
2264
|
+
"Trailer",
|
|
2265
|
+
"Transfer-Encoding",
|
|
2266
|
+
"Upgrade"
|
|
2267
|
+
])
|
|
2268
|
+
t.delete(n);
|
|
2269
|
+
return t;
|
|
2246
2270
|
}
|
|
2247
2271
|
}
|
|
2248
|
-
function
|
|
2272
|
+
function ot(i, e) {
|
|
2249
2273
|
const t = i.length, n = e.length, r = t - n;
|
|
2250
2274
|
for (let s = 0; s <= r; s++) {
|
|
2251
2275
|
let a = !0;
|
|
@@ -2259,7 +2283,7 @@ function it(i, e) {
|
|
|
2259
2283
|
}
|
|
2260
2284
|
return -1;
|
|
2261
2285
|
}
|
|
2262
|
-
async function
|
|
2286
|
+
async function ct(i = Se) {
|
|
2263
2287
|
switch (i) {
|
|
2264
2288
|
case "8.5":
|
|
2265
2289
|
return (await import("@php-wasm/web-8-5")).getIntlExtensionPath();
|
|
@@ -2278,17 +2302,17 @@ async function at(i = oe) {
|
|
|
2278
2302
|
}
|
|
2279
2303
|
throw new Error(`Unsupported PHP version ${i}`);
|
|
2280
2304
|
}
|
|
2281
|
-
async function
|
|
2305
|
+
async function St(i, e, t, n = []) {
|
|
2282
2306
|
if (!n.length)
|
|
2283
2307
|
return t;
|
|
2284
2308
|
const r = await Promise.all(
|
|
2285
2309
|
n.map(
|
|
2286
|
-
(s) =>
|
|
2310
|
+
(s) => lt(i, e, s)
|
|
2287
2311
|
)
|
|
2288
2312
|
);
|
|
2289
|
-
return
|
|
2313
|
+
return We(t, r);
|
|
2290
2314
|
}
|
|
2291
|
-
async function
|
|
2315
|
+
async function lt(i, e, t) {
|
|
2292
2316
|
if (typeof t == "object" && "source" in t) {
|
|
2293
2317
|
if (e === "asyncify")
|
|
2294
2318
|
throw new Error(
|
|
@@ -2302,14 +2326,14 @@ async function ot(i, e, t) {
|
|
|
2302
2326
|
const n = typeof t == "string" ? t : t.name;
|
|
2303
2327
|
if (n !== "intl")
|
|
2304
2328
|
throw new Error(`Unknown bundled PHP web extension: ${String(n)}.`);
|
|
2305
|
-
const r =
|
|
2329
|
+
const r = Me(fetch), s = await ct(i), a = (await import("../intl/shared/icu.dat")).default, [_, o] = await Promise.all(
|
|
2306
2330
|
[s, a].map(async (S) => {
|
|
2307
|
-
const
|
|
2308
|
-
if (!
|
|
2331
|
+
const l = await r(S);
|
|
2332
|
+
if (!l.ok)
|
|
2309
2333
|
throw new Error(
|
|
2310
|
-
`Failed to fetch bundled PHP web extension asset: ${
|
|
2334
|
+
`Failed to fetch bundled PHP web extension asset: ${l.url || S} (${l.status} ${l.statusText}).`
|
|
2311
2335
|
);
|
|
2312
|
-
return await
|
|
2336
|
+
return await l.arrayBuffer();
|
|
2313
2337
|
})
|
|
2314
2338
|
);
|
|
2315
2339
|
return await Y({
|
|
@@ -2325,12 +2349,12 @@ async function ot(i, e, t) {
|
|
|
2325
2349
|
extraFiles: {
|
|
2326
2350
|
files: {
|
|
2327
2351
|
// The Intl extension looks for the hard-coded ICU data name.
|
|
2328
|
-
"/internal/shared/icudt74l.dat": new Uint8Array(
|
|
2352
|
+
"/internal/shared/icudt74l.dat": new Uint8Array(o)
|
|
2329
2353
|
}
|
|
2330
2354
|
}
|
|
2331
2355
|
});
|
|
2332
2356
|
}
|
|
2333
|
-
const
|
|
2357
|
+
const Ct = () => ({
|
|
2334
2358
|
websocket: {
|
|
2335
2359
|
decorator: (i) => class extends i {
|
|
2336
2360
|
constructor() {
|
|
@@ -2345,47 +2369,47 @@ const ct = () => ({
|
|
|
2345
2369
|
}
|
|
2346
2370
|
}
|
|
2347
2371
|
});
|
|
2348
|
-
async function
|
|
2349
|
-
var
|
|
2372
|
+
async function bt(i, e = {}) {
|
|
2373
|
+
var o;
|
|
2350
2374
|
"setImmediate" in globalThis || (globalThis.setImmediate = (S) => setTimeout(S, 0));
|
|
2351
|
-
const t = await
|
|
2375
|
+
const t = await xe() ? "jspi" : "asyncify";
|
|
2352
2376
|
let n = {
|
|
2353
|
-
...
|
|
2377
|
+
...Ct(),
|
|
2354
2378
|
...e.emscriptenOptions || {},
|
|
2355
2379
|
phpWasmAsyncMode: t
|
|
2356
2380
|
};
|
|
2357
|
-
e.tcpOverFetch && (n =
|
|
2381
|
+
e.tcpOverFetch && (n = st(
|
|
2358
2382
|
n,
|
|
2359
2383
|
e.tcpOverFetch
|
|
2360
2384
|
));
|
|
2361
|
-
const r =
|
|
2362
|
-
if (e.withIntl && !
|
|
2363
|
-
const S = await n,
|
|
2385
|
+
const r = Pe(i), s = [...e.extensions ?? []];
|
|
2386
|
+
if (e.withIntl && !ht(s, "intl") && s.push("intl"), r) {
|
|
2387
|
+
const S = await n, l = S.preRun || [];
|
|
2364
2388
|
n = {
|
|
2365
2389
|
...S,
|
|
2366
|
-
preRun: [...
|
|
2390
|
+
preRun: [...l, be()]
|
|
2367
2391
|
};
|
|
2368
2392
|
}
|
|
2369
2393
|
if (r && s.length)
|
|
2370
2394
|
throw new Error(
|
|
2371
2395
|
`Extensions are not available for legacy PHP ${i}.`
|
|
2372
2396
|
);
|
|
2373
|
-
r || (n =
|
|
2397
|
+
r || (n = St(
|
|
2374
2398
|
i,
|
|
2375
2399
|
t,
|
|
2376
2400
|
await n,
|
|
2377
2401
|
s
|
|
2378
2402
|
));
|
|
2379
2403
|
const [a, _] = await Promise.all([
|
|
2380
|
-
|
|
2404
|
+
qe(i),
|
|
2381
2405
|
n
|
|
2382
2406
|
]);
|
|
2383
|
-
return (
|
|
2407
|
+
return (o = e.onPhpLoaderModuleLoaded) == null || o.call(e, a), await Re(a, _);
|
|
2384
2408
|
}
|
|
2385
|
-
function
|
|
2409
|
+
function ht(i, e) {
|
|
2386
2410
|
return i.some((t) => typeof t == "string" ? t === e : !("source" in t) && t.name === e);
|
|
2387
2411
|
}
|
|
2388
|
-
function
|
|
2412
|
+
function Rt(i, e) {
|
|
2389
2413
|
window.addEventListener("message", (t) => {
|
|
2390
2414
|
t.source === i.contentWindow && (e && t.origin !== e || typeof t.data != "object" || t.data.type !== "relay" || window.parent.postMessage(t.data, "*"));
|
|
2391
2415
|
}), window.addEventListener("message", (t) => {
|
|
@@ -2393,7 +2417,7 @@ function Wt(i, e) {
|
|
|
2393
2417
|
t.source === window.parent && (typeof t.data != "object" || t.data.type !== "relay" || (n = i == null ? void 0 : i.contentWindow) == null || n.postMessage(t.data));
|
|
2394
2418
|
});
|
|
2395
2419
|
}
|
|
2396
|
-
async function
|
|
2420
|
+
async function Bt(i) {
|
|
2397
2421
|
const e = new Worker(i, { type: "module" });
|
|
2398
2422
|
return new Promise((t, n) => {
|
|
2399
2423
|
e.onerror = (s) => {
|
|
@@ -2408,8 +2432,8 @@ async function Pt(i) {
|
|
|
2408
2432
|
e.addEventListener("message", r);
|
|
2409
2433
|
});
|
|
2410
2434
|
}
|
|
2411
|
-
const
|
|
2412
|
-
function
|
|
2435
|
+
const ut = 1e3;
|
|
2436
|
+
function Ut(i, e = { initialSync: {} }) {
|
|
2413
2437
|
return e = {
|
|
2414
2438
|
...e,
|
|
2415
2439
|
initialSync: {
|
|
@@ -2417,45 +2441,72 @@ function bt(i, e = { initialSync: {} }) {
|
|
|
2417
2441
|
direction: e.initialSync.direction ?? "opfs-to-memfs"
|
|
2418
2442
|
}
|
|
2419
2443
|
}, async function(t, n, r) {
|
|
2420
|
-
var a;
|
|
2421
|
-
e.initialSync.direction === "opfs-to-memfs"
|
|
2422
|
-
n,
|
|
2423
|
-
i,
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2444
|
+
var s, a, _, o;
|
|
2445
|
+
if (e.initialSync.direction === "opfs-to-memfs") {
|
|
2446
|
+
M.fileExists(n, r) && M.rmdir(n, r), M.mkdir(n, r), await At(n, i, r);
|
|
2447
|
+
const S = ae(t, i, r);
|
|
2448
|
+
return (s = e.onMount) == null || s.call(e, S), S.unmount;
|
|
2449
|
+
} else {
|
|
2450
|
+
const S = ae(t, i, r);
|
|
2451
|
+
(a = e.onMount) == null || a.call(e, S);
|
|
2452
|
+
let l;
|
|
2453
|
+
try {
|
|
2454
|
+
await Le(
|
|
2455
|
+
n,
|
|
2456
|
+
i,
|
|
2457
|
+
r,
|
|
2458
|
+
async (C) => {
|
|
2459
|
+
var A, u;
|
|
2460
|
+
l = {
|
|
2461
|
+
...C,
|
|
2462
|
+
phase: "copying"
|
|
2463
|
+
}, await ((u = (A = e.initialSync).onProgress) == null ? void 0 : u.call(A, l));
|
|
2464
|
+
}
|
|
2465
|
+
), await ((o = (_ = e.initialSync).onProgress) == null ? void 0 : o.call(_, {
|
|
2466
|
+
files: (l == null ? void 0 : l.files) ?? 0,
|
|
2467
|
+
total: (l == null ? void 0 : l.total) ?? 0,
|
|
2468
|
+
phase: "flushing"
|
|
2469
|
+
})), S.flush().catch((C) => {
|
|
2470
|
+
g.error("OPFS flush failed after initial sync", {
|
|
2471
|
+
error: C,
|
|
2472
|
+
vfsMountPoint: r
|
|
2473
|
+
});
|
|
2474
|
+
});
|
|
2475
|
+
} catch (C) {
|
|
2476
|
+
throw await S.unmount(), C;
|
|
2477
|
+
}
|
|
2478
|
+
return S.unmount;
|
|
2479
|
+
}
|
|
2429
2480
|
};
|
|
2430
2481
|
}
|
|
2431
|
-
async function
|
|
2482
|
+
async function At(i, e, t) {
|
|
2432
2483
|
M.mkdir(i, t);
|
|
2433
|
-
const n = new
|
|
2484
|
+
const n = new Be({
|
|
2434
2485
|
concurrency: 40
|
|
2435
2486
|
}), r = [], s = [
|
|
2436
2487
|
[e, t]
|
|
2437
2488
|
];
|
|
2438
2489
|
for (; s.length > 0; ) {
|
|
2439
2490
|
const [a, _] = s.pop();
|
|
2440
|
-
for await (const
|
|
2491
|
+
for await (const o of a.values()) {
|
|
2441
2492
|
const S = n.run(async () => {
|
|
2442
|
-
const
|
|
2493
|
+
const l = le(
|
|
2443
2494
|
_,
|
|
2444
|
-
|
|
2495
|
+
o.name
|
|
2445
2496
|
);
|
|
2446
|
-
if (
|
|
2497
|
+
if (o.kind === "directory") {
|
|
2447
2498
|
try {
|
|
2448
|
-
i.mkdir(
|
|
2449
|
-
} catch (
|
|
2450
|
-
if ((
|
|
2451
|
-
throw
|
|
2499
|
+
i.mkdir(l);
|
|
2500
|
+
} catch (C) {
|
|
2501
|
+
if ((C == null ? void 0 : C.errno) !== 20)
|
|
2502
|
+
throw g.error(C), C;
|
|
2452
2503
|
}
|
|
2453
|
-
s.push([
|
|
2454
|
-
} else if (
|
|
2455
|
-
const
|
|
2504
|
+
s.push([o, l]);
|
|
2505
|
+
} else if (o.kind === "file") {
|
|
2506
|
+
const C = await o.getFile(), A = new Uint8Array(await C.arrayBuffer());
|
|
2456
2507
|
i.createDataFile(
|
|
2457
2508
|
_,
|
|
2458
|
-
|
|
2509
|
+
o.name,
|
|
2459
2510
|
A,
|
|
2460
2511
|
!0,
|
|
2461
2512
|
!0,
|
|
@@ -2470,43 +2521,47 @@ async function lt(i, e, t) {
|
|
|
2470
2521
|
await Promise.any(r);
|
|
2471
2522
|
}
|
|
2472
2523
|
}
|
|
2473
|
-
async function
|
|
2524
|
+
async function Le(i, e, t, n) {
|
|
2474
2525
|
i.mkdirTree(t);
|
|
2475
2526
|
const r = [];
|
|
2476
|
-
async function s(
|
|
2527
|
+
async function s(l, C) {
|
|
2477
2528
|
await Promise.all(
|
|
2478
|
-
i.readdir(
|
|
2529
|
+
i.readdir(l).filter(
|
|
2479
2530
|
(A) => A !== "." && A !== ".."
|
|
2480
2531
|
).map(async (A) => {
|
|
2481
|
-
const u =
|
|
2482
|
-
if (!
|
|
2483
|
-
r.push([
|
|
2532
|
+
const u = le(l, A);
|
|
2533
|
+
if (!Ht(i, u)) {
|
|
2534
|
+
r.push([C, u, A]);
|
|
2484
2535
|
return;
|
|
2485
2536
|
}
|
|
2486
|
-
const
|
|
2537
|
+
const d = await C.getDirectoryHandle(A, {
|
|
2487
2538
|
create: !0
|
|
2488
2539
|
});
|
|
2489
|
-
return await s(u,
|
|
2540
|
+
return await s(u, d);
|
|
2490
2541
|
})
|
|
2491
2542
|
);
|
|
2492
2543
|
}
|
|
2493
2544
|
await s(t, e);
|
|
2494
2545
|
let a = 0;
|
|
2495
|
-
|
|
2546
|
+
await (n == null ? void 0 : n({
|
|
2547
|
+
files: a,
|
|
2548
|
+
total: r.length
|
|
2549
|
+
}));
|
|
2550
|
+
const _ = n && Et(n, 100), o = 100, S = /* @__PURE__ */ new Set();
|
|
2496
2551
|
try {
|
|
2497
|
-
for (const [
|
|
2552
|
+
for (const [l, C, A] of r) {
|
|
2498
2553
|
const u = $(
|
|
2499
|
-
|
|
2554
|
+
l,
|
|
2500
2555
|
A,
|
|
2501
2556
|
i,
|
|
2502
|
-
|
|
2557
|
+
C
|
|
2503
2558
|
).then(() => {
|
|
2504
2559
|
a++, S.delete(u), _ == null || _({
|
|
2505
2560
|
files: a,
|
|
2506
2561
|
total: r.length
|
|
2507
2562
|
});
|
|
2508
2563
|
});
|
|
2509
|
-
S.add(u), S.size >=
|
|
2564
|
+
S.add(u), S.size >= o && (await Promise.race(S), _ == null || _({
|
|
2510
2565
|
files: a,
|
|
2511
2566
|
total: r.length
|
|
2512
2567
|
}));
|
|
@@ -2514,8 +2569,12 @@ async function ye(i, e, t, n) {
|
|
|
2514
2569
|
} finally {
|
|
2515
2570
|
await Promise.allSettled(S);
|
|
2516
2571
|
}
|
|
2572
|
+
_ == null || _.cancel(), await (n == null ? void 0 : n({
|
|
2573
|
+
files: r.length,
|
|
2574
|
+
total: r.length
|
|
2575
|
+
}));
|
|
2517
2576
|
}
|
|
2518
|
-
function
|
|
2577
|
+
function Ht(i, e) {
|
|
2519
2578
|
return i.isDir(i.lookupPath(e, { follow: !0 }).node.mode);
|
|
2520
2579
|
}
|
|
2521
2580
|
async function $(i, e, t, n) {
|
|
@@ -2540,35 +2599,35 @@ async function $(i, e, t, n) {
|
|
|
2540
2599
|
await a.close();
|
|
2541
2600
|
}
|
|
2542
2601
|
}
|
|
2543
|
-
function
|
|
2544
|
-
const r = [], s =
|
|
2602
|
+
function ae(i, e, t, n = {}) {
|
|
2603
|
+
const r = [], s = Ne(i, t, (u) => {
|
|
2545
2604
|
r.push(u);
|
|
2546
|
-
}), a = new
|
|
2605
|
+
}), a = new dt(i, e, t);
|
|
2547
2606
|
let _;
|
|
2548
|
-
function
|
|
2549
|
-
return _ === void 0 && (_ =
|
|
2607
|
+
function o() {
|
|
2608
|
+
return _ === void 0 && (_ = C().finally(() => {
|
|
2550
2609
|
_ = void 0;
|
|
2551
2610
|
})), _;
|
|
2552
2611
|
}
|
|
2553
2612
|
async function S() {
|
|
2554
2613
|
try {
|
|
2555
|
-
await
|
|
2614
|
+
await o();
|
|
2556
2615
|
} finally {
|
|
2557
|
-
s(), i.removeEventListener("request.end",
|
|
2616
|
+
s(), i.removeEventListener("request.end", l), i.removeEventListener("filesystem.write", l);
|
|
2558
2617
|
}
|
|
2559
2618
|
}
|
|
2560
|
-
function
|
|
2561
|
-
|
|
2562
|
-
|
|
2619
|
+
function l() {
|
|
2620
|
+
o().catch((u) => {
|
|
2621
|
+
g.error(u);
|
|
2563
2622
|
});
|
|
2564
2623
|
}
|
|
2565
|
-
async function
|
|
2566
|
-
const u = n.maxFlushPasses ??
|
|
2567
|
-
for (let
|
|
2568
|
-
if (
|
|
2569
|
-
const
|
|
2624
|
+
async function C() {
|
|
2625
|
+
const u = n.maxFlushPasses ?? ut;
|
|
2626
|
+
for (let d = 0; r.length > 0; d++) {
|
|
2627
|
+
if (d >= u) {
|
|
2628
|
+
const m = r.length, b = m === 1 ? `${m} journal entry remains` : `${m} journal entries remain`;
|
|
2570
2629
|
throw new Error(
|
|
2571
|
-
`OPFS flush for "${t}" did not settle after ${u} journal batches; ${
|
|
2630
|
+
`OPFS flush for "${t}" did not settle after ${u} journal batches; ${b}. This can happen when filesystem writes are continuously enqueued while flushing.`
|
|
2572
2631
|
);
|
|
2573
2632
|
}
|
|
2574
2633
|
await A();
|
|
@@ -2577,32 +2636,32 @@ function At(i, e, t, n = {}) {
|
|
|
2577
2636
|
async function A() {
|
|
2578
2637
|
if (r.length === 0)
|
|
2579
2638
|
return;
|
|
2580
|
-
const u = await i.semaphore.acquire(),
|
|
2581
|
-
r.splice(0,
|
|
2582
|
-
const
|
|
2639
|
+
const u = await i.semaphore.acquire(), d = [...r];
|
|
2640
|
+
r.splice(0, d.length);
|
|
2641
|
+
const m = ke(d);
|
|
2583
2642
|
try {
|
|
2584
|
-
for (const
|
|
2585
|
-
await a.processEntry(
|
|
2643
|
+
for (const b of m)
|
|
2644
|
+
await a.processEntry(b);
|
|
2586
2645
|
} finally {
|
|
2587
2646
|
u();
|
|
2588
2647
|
}
|
|
2589
2648
|
}
|
|
2590
|
-
return i.addEventListener("request.end",
|
|
2591
|
-
flush:
|
|
2649
|
+
return i.addEventListener("request.end", l), i.addEventListener("filesystem.write", l), {
|
|
2650
|
+
flush: o,
|
|
2592
2651
|
unmount: S
|
|
2593
2652
|
};
|
|
2594
2653
|
}
|
|
2595
|
-
class
|
|
2654
|
+
class dt {
|
|
2596
2655
|
constructor(e, t, n) {
|
|
2597
|
-
this.php = e, this.opfs = t, this.memfsRoot =
|
|
2656
|
+
this.php = e, this.opfs = t, this.memfsRoot = _e(n);
|
|
2598
2657
|
}
|
|
2599
2658
|
toOpfsPath(e) {
|
|
2600
|
-
return
|
|
2659
|
+
return _e(e.substring(this.memfsRoot.length));
|
|
2601
2660
|
}
|
|
2602
2661
|
async processEntry(e) {
|
|
2603
2662
|
if (!e.path.startsWith(this.memfsRoot) || e.path === this.memfsRoot)
|
|
2604
2663
|
return;
|
|
2605
|
-
const t = this.toOpfsPath(e.path), n = await
|
|
2664
|
+
const t = this.toOpfsPath(e.path), n = await oe(this.opfs, t), r = ft(t);
|
|
2606
2665
|
if (r)
|
|
2607
2666
|
try {
|
|
2608
2667
|
if (e.operation === "DELETE")
|
|
@@ -2626,7 +2685,7 @@ class ut {
|
|
|
2626
2685
|
e.path
|
|
2627
2686
|
);
|
|
2628
2687
|
else if (e.operation === "RENAME" && e.toPath.startsWith(this.memfsRoot)) {
|
|
2629
|
-
const s = this.toOpfsPath(e.toPath), a = await
|
|
2688
|
+
const s = this.toOpfsPath(e.toPath), a = await oe(
|
|
2630
2689
|
this.opfs,
|
|
2631
2690
|
s
|
|
2632
2691
|
);
|
|
@@ -2637,7 +2696,7 @@ class ut {
|
|
|
2637
2696
|
create: !0
|
|
2638
2697
|
}
|
|
2639
2698
|
);
|
|
2640
|
-
await
|
|
2699
|
+
await Le(
|
|
2641
2700
|
this.php[O].FS,
|
|
2642
2701
|
_,
|
|
2643
2702
|
e.toPath
|
|
@@ -2651,24 +2710,24 @@ class ut {
|
|
|
2651
2710
|
}
|
|
2652
2711
|
await $(
|
|
2653
2712
|
a,
|
|
2654
|
-
|
|
2713
|
+
Ue(s),
|
|
2655
2714
|
this.php[O].FS,
|
|
2656
2715
|
e.toPath
|
|
2657
2716
|
);
|
|
2658
2717
|
}
|
|
2659
2718
|
}
|
|
2660
2719
|
} catch (s) {
|
|
2661
|
-
throw
|
|
2720
|
+
throw g.log({ entry: e, name: r }), g.error(s), s;
|
|
2662
2721
|
}
|
|
2663
2722
|
}
|
|
2664
2723
|
}
|
|
2665
|
-
function
|
|
2724
|
+
function _e(i) {
|
|
2666
2725
|
return i.replace(/\/$/, "").replace(/\/\/+/g, "/");
|
|
2667
2726
|
}
|
|
2668
|
-
function
|
|
2727
|
+
function ft(i) {
|
|
2669
2728
|
return i.substring(i.lastIndexOf("/") + 1);
|
|
2670
2729
|
}
|
|
2671
|
-
async function
|
|
2730
|
+
async function oe(i, e) {
|
|
2672
2731
|
const t = e.replace(/^\/+|\/+$/g, "").replace(/\/+/, "/");
|
|
2673
2732
|
if (!t)
|
|
2674
2733
|
return i;
|
|
@@ -2680,31 +2739,46 @@ async function _e(i, e) {
|
|
|
2680
2739
|
}
|
|
2681
2740
|
return r;
|
|
2682
2741
|
}
|
|
2683
|
-
function
|
|
2742
|
+
function Et(i, e) {
|
|
2684
2743
|
let t = 0, n, r;
|
|
2685
|
-
|
|
2686
|
-
r =
|
|
2687
|
-
const
|
|
2744
|
+
const s = function(..._) {
|
|
2745
|
+
r = _;
|
|
2746
|
+
const o = Date.now() - t;
|
|
2688
2747
|
if (n === void 0) {
|
|
2689
|
-
const
|
|
2748
|
+
const S = Math.max(0, e - o);
|
|
2690
2749
|
n = setTimeout(() => {
|
|
2691
|
-
n = void 0, t = Date.now()
|
|
2692
|
-
|
|
2750
|
+
n = void 0, t = Date.now();
|
|
2751
|
+
const l = r;
|
|
2752
|
+
r = void 0;
|
|
2753
|
+
try {
|
|
2754
|
+
Promise.resolve(i(...l)).catch(
|
|
2755
|
+
ce
|
|
2756
|
+
);
|
|
2757
|
+
} catch (C) {
|
|
2758
|
+
ce(C);
|
|
2759
|
+
}
|
|
2760
|
+
}, S);
|
|
2693
2761
|
}
|
|
2694
2762
|
};
|
|
2763
|
+
return s.cancel = () => {
|
|
2764
|
+
n !== void 0 && clearTimeout(n), n = void 0, r = void 0;
|
|
2765
|
+
}, s;
|
|
2766
|
+
}
|
|
2767
|
+
function ce(i) {
|
|
2768
|
+
g.error("Throttled progress callback failed", { error: i });
|
|
2695
2769
|
}
|
|
2696
2770
|
export {
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2771
|
+
qt as FirewallInterferenceError,
|
|
2772
|
+
Dt as certificateToPEM,
|
|
2773
|
+
xt as consumeAPI,
|
|
2774
|
+
Ut as createDirectoryHandleMountHandler,
|
|
2775
|
+
Nt as exposeAPI,
|
|
2776
|
+
Ft as fetchWithCorsProxy,
|
|
2777
|
+
Qe as generateCertificate,
|
|
2778
|
+
qe as getPHPLoaderModule,
|
|
2779
|
+
bt as loadWebRuntime,
|
|
2780
|
+
Wt as privateKeyToPEM,
|
|
2781
|
+
Rt as setupPostMessageRelay,
|
|
2782
|
+
Bt as spawnPHPWorkerThread
|
|
2709
2783
|
};
|
|
2710
2784
|
//# sourceMappingURL=index.js.map
|