@mercuryworkshop/epoxy-transport 2.0.0 → 2.0.1
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/dist/index.js +1 -0
- package/dist/module.js +1 -0
- package/package.json +1 -1
- package/src/main.ts +61 -60
package/dist/index.js
CHANGED
|
@@ -1537,6 +1537,7 @@ var EpoxyClient = class {
|
|
|
1537
1537
|
const { EpoxyClient: EpoxyClient2, EpoxyClientOptions } = await epoxy_module_bundled_default();
|
|
1538
1538
|
let options = new EpoxyClientOptions();
|
|
1539
1539
|
options.user_agent = navigator.userAgent;
|
|
1540
|
+
options.udp_extension_required = false;
|
|
1540
1541
|
this.epxclient = await new EpoxyClient2(this.wisp, certs_module_default, options);
|
|
1541
1542
|
this.ready = true;
|
|
1542
1543
|
}
|
package/dist/module.js
CHANGED
|
@@ -1498,6 +1498,7 @@ var EpoxyClient = class {
|
|
|
1498
1498
|
const { EpoxyClient: EpoxyClient2, EpoxyClientOptions } = await epoxy_module_bundled_default();
|
|
1499
1499
|
let options = new EpoxyClientOptions();
|
|
1500
1500
|
options.user_agent = navigator.userAgent;
|
|
1501
|
+
options.udp_extension_required = false;
|
|
1501
1502
|
this.epxclient = await new EpoxyClient2(this.wisp, certs_module_default, options);
|
|
1502
1503
|
this.ready = true;
|
|
1503
1504
|
}
|
package/package.json
CHANGED
package/src/main.ts
CHANGED
|
@@ -3,71 +3,72 @@ import epoxy from "@mercuryworkshop/epoxy-tls";
|
|
|
3
3
|
//@ts-expect-error typescript doesnt follow the npm exports for some reason
|
|
4
4
|
import ROOTS from "@mercuryworkshop/epoxy-tls/certs"
|
|
5
5
|
export class EpoxyClient implements BareTransport {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
canstart = true;
|
|
7
|
+
epxclient: Awaited<ReturnType<any>>["EpoxyClient"]["prototype"] = null!;
|
|
8
|
+
wisp: string;
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
constructor({ wisp }) {
|
|
11
|
+
this.wisp = wisp;
|
|
12
|
+
}
|
|
13
|
+
async init() {
|
|
14
|
+
const { EpoxyClient, EpoxyClientOptions } = await epoxy();
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
let options = new EpoxyClientOptions();
|
|
17
|
+
options.user_agent = navigator.userAgent;
|
|
18
|
+
options.udp_extension_required = false;
|
|
19
|
+
this.epxclient = await new EpoxyClient(this.wisp, ROOTS, options);
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
this.ready = true;
|
|
22
|
+
}
|
|
23
|
+
ready = false;
|
|
24
|
+
async meta() { }
|
|
24
25
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
26
|
+
async request(
|
|
27
|
+
remote: URL,
|
|
28
|
+
method: string,
|
|
29
|
+
body: BodyInit | null,
|
|
30
|
+
headers: BareHeaders,
|
|
31
|
+
signal: AbortSignal | undefined
|
|
32
|
+
): Promise<TransferrableResponse> {
|
|
33
|
+
if (body instanceof Blob)
|
|
34
|
+
body = await body.arrayBuffer();
|
|
34
35
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
36
|
+
try {
|
|
37
|
+
let payload = await this.epxclient.fetch(remote.href, { method, body, headers, redirect: "manual" });
|
|
38
|
+
return {
|
|
39
|
+
body: payload.body!,
|
|
40
|
+
headers: (payload as any).rawHeaders,
|
|
41
|
+
status: payload.status,
|
|
42
|
+
statusText: payload.statusText,
|
|
43
|
+
};
|
|
44
|
+
} catch (err) {
|
|
45
|
+
console.error(err);
|
|
46
|
+
throw err;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
48
49
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
50
|
+
connect(
|
|
51
|
+
url: URL,
|
|
52
|
+
origin: string,
|
|
53
|
+
protocols: string[],
|
|
54
|
+
requestHeaders: BareHeaders,
|
|
55
|
+
onopen: (protocol: string) => void,
|
|
56
|
+
onmessage: (data: Blob | ArrayBuffer | string) => void,
|
|
57
|
+
onclose: (code: number, reason: string) => void,
|
|
58
|
+
onerror: (error: string) => void,
|
|
59
|
+
): (data: Blob | ArrayBuffer | string) => void {
|
|
60
|
+
let epsocket = this.epxclient.connect_ws(
|
|
61
|
+
onopen,
|
|
62
|
+
onclose,
|
|
63
|
+
onerror,
|
|
64
|
+
(data: Uint8Array | string) => data instanceof Uint8Array ? onmessage(data.buffer) : onmessage(data),
|
|
65
|
+
url.href,
|
|
66
|
+
protocols,
|
|
67
|
+
origin,
|
|
68
|
+
);
|
|
68
69
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
return async (data) => {
|
|
71
|
+
await epsocket.send(data);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
73
74
|
}
|