@mercuryworkshop/epoxy-transport 2.1.18 → 2.1.20
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 +94 -53
- package/dist/index.mjs +94 -53
- package/package.json +3 -3
- package/src/main.ts +42 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mercuryworkshop/epoxy-transport",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.20",
|
|
4
4
|
"description": "a bare transport that implements end-to-end encryption with epoxy-tls and wisp",
|
|
5
5
|
"main": "./dist/index.mjs",
|
|
6
6
|
"keywords": [],
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
"license": "AGPL-3.0-only",
|
|
10
10
|
"scripts": {
|
|
11
11
|
"build": "node esbuild.bundle.mjs",
|
|
12
|
-
"
|
|
12
|
+
"prepack": "npm run build"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@mercuryworkshop/epoxy-tls": "2.1.
|
|
15
|
+
"@mercuryworkshop/epoxy-tls": "2.1.11-1"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"@mercuryworkshop/bare-mux": "^2.1.3",
|
package/src/main.ts
CHANGED
|
@@ -1,34 +1,64 @@
|
|
|
1
1
|
import type { BareHeaders, TransferrableResponse, BareTransport } from "@mercuryworkshop/bare-mux";
|
|
2
|
-
import initEpoxy, { EpoxyClient, EpoxyClientOptions, EpoxyHandlers, info } from "@mercuryworkshop/epoxy-tls";
|
|
2
|
+
import initEpoxy, { EpoxyClient, EpoxyClientOptions, EpoxyHandlers, info as epoxyInfo } from "@mercuryworkshop/epoxy-tls";
|
|
3
3
|
|
|
4
|
-
export {
|
|
4
|
+
export { epoxyInfo };
|
|
5
|
+
|
|
6
|
+
export type EpoxyOptions = {
|
|
7
|
+
wisp_v2?: boolean,
|
|
8
|
+
udp_extension_required?: boolean,
|
|
9
|
+
|
|
10
|
+
title_case_headers?: boolean,
|
|
11
|
+
ws_title_case_headers?: boolean,
|
|
12
|
+
|
|
13
|
+
wisp_ws_protocols?: string[],
|
|
14
|
+
|
|
15
|
+
redirect_limit?: number,
|
|
16
|
+
header_limit?: number,
|
|
17
|
+
buffer_size?: number,
|
|
18
|
+
}
|
|
19
|
+
const opts = [
|
|
20
|
+
"wisp_v2",
|
|
21
|
+
"udp_extension_required",
|
|
22
|
+
"title_case_headers",
|
|
23
|
+
"ws_title_case_headers",
|
|
24
|
+
"wisp_ws_protocols",
|
|
25
|
+
"redirect_limit",
|
|
26
|
+
"header_limit",
|
|
27
|
+
"buffer_size"
|
|
28
|
+
];
|
|
5
29
|
|
|
6
30
|
export default class EpoxyTransport implements BareTransport {
|
|
7
31
|
canstart = true;
|
|
8
32
|
ready = false;
|
|
9
33
|
|
|
34
|
+
client_version: typeof epoxyInfo;
|
|
10
35
|
client: EpoxyClient = null!;
|
|
11
|
-
|
|
12
36
|
wisp: string;
|
|
13
|
-
|
|
14
|
-
udp_extension_required: boolean;
|
|
37
|
+
opts: EpoxyOptions;
|
|
15
38
|
|
|
16
|
-
constructor({ wisp
|
|
17
|
-
this.wisp = wisp;
|
|
18
|
-
this.
|
|
19
|
-
|
|
39
|
+
constructor(opts: EpoxyOptions & { wisp: string }) {
|
|
40
|
+
this.wisp = opts.wisp;
|
|
41
|
+
this.opts = opts;
|
|
42
|
+
|
|
43
|
+
this.client_version = epoxyInfo;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
setopt(opts: EpoxyClientOptions, opt: string) {
|
|
47
|
+
// == allows both null and undefined
|
|
48
|
+
if (this.opts[opt] != null) opts[opt] = this.opts[opt];
|
|
20
49
|
}
|
|
50
|
+
|
|
21
51
|
async init() {
|
|
22
52
|
await initEpoxy();
|
|
23
53
|
|
|
24
54
|
let options = new EpoxyClientOptions();
|
|
25
55
|
options.user_agent = navigator.userAgent;
|
|
26
|
-
|
|
27
|
-
options.wisp_v2 = this.wisp_v2;
|
|
56
|
+
opts.forEach(x => this.setopt(options, x))
|
|
28
57
|
this.client = new EpoxyClient(this.wisp, options);
|
|
29
58
|
|
|
30
59
|
this.ready = true;
|
|
31
60
|
}
|
|
61
|
+
|
|
32
62
|
async meta() { }
|
|
33
63
|
|
|
34
64
|
async request(
|
|
@@ -71,6 +101,7 @@ export default class EpoxyTransport implements BareTransport {
|
|
|
71
101
|
onerror,
|
|
72
102
|
(data: Uint8Array | string) => data instanceof Uint8Array ? onmessage(data.buffer) : onmessage(data)
|
|
73
103
|
);
|
|
104
|
+
|
|
74
105
|
let ws = this.client.connect_websocket(
|
|
75
106
|
handlers,
|
|
76
107
|
url.href,
|