@mercuryworkshop/epoxy-transport 2.0.1 → 2.0.2
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 +17 -7
- package/dist/module.js +17 -7
- package/package.json +6 -6
- package/src/main.ts +18 -8
package/dist/index.js
CHANGED
|
@@ -1530,15 +1530,17 @@ var EpoxyClient = class {
|
|
|
1530
1530
|
canstart = true;
|
|
1531
1531
|
epxclient = null;
|
|
1532
1532
|
wisp;
|
|
1533
|
+
EpoxyHandlers = null;
|
|
1533
1534
|
constructor({ wisp }) {
|
|
1534
1535
|
this.wisp = wisp;
|
|
1535
1536
|
}
|
|
1536
1537
|
async init() {
|
|
1537
|
-
const { EpoxyClient: EpoxyClient2, EpoxyClientOptions } = await epoxy_module_bundled_default();
|
|
1538
|
+
const { EpoxyClient: EpoxyClient2, EpoxyClientOptions, EpoxyHandlers } = await epoxy_module_bundled_default();
|
|
1538
1539
|
let options = new EpoxyClientOptions();
|
|
1539
1540
|
options.user_agent = navigator.userAgent;
|
|
1540
1541
|
options.udp_extension_required = false;
|
|
1541
1542
|
this.epxclient = await new EpoxyClient2(this.wisp, certs_module_default, options);
|
|
1543
|
+
this.EpoxyHandlers = EpoxyHandlers;
|
|
1542
1544
|
this.ready = true;
|
|
1543
1545
|
}
|
|
1544
1546
|
ready = false;
|
|
@@ -1561,18 +1563,26 @@ var EpoxyClient = class {
|
|
|
1561
1563
|
}
|
|
1562
1564
|
}
|
|
1563
1565
|
connect(url, origin, protocols, requestHeaders, onopen, onmessage, onclose, onerror) {
|
|
1564
|
-
let
|
|
1566
|
+
let handlers = new this.EpoxyHandlers(
|
|
1565
1567
|
onopen,
|
|
1566
1568
|
onclose,
|
|
1567
1569
|
onerror,
|
|
1568
|
-
(data) => data instanceof Uint8Array ? onmessage(data.buffer) : onmessage(data)
|
|
1570
|
+
(data) => data instanceof Uint8Array ? onmessage(data.buffer) : onmessage(data)
|
|
1571
|
+
);
|
|
1572
|
+
let epsocket = this.epxclient.connect_websocket(
|
|
1573
|
+
handlers,
|
|
1569
1574
|
url.href,
|
|
1570
1575
|
protocols,
|
|
1571
|
-
origin
|
|
1576
|
+
Object.assign({ "Origin": origin }, requestHeaders)
|
|
1572
1577
|
);
|
|
1573
|
-
return
|
|
1574
|
-
|
|
1575
|
-
|
|
1578
|
+
return [
|
|
1579
|
+
async (data) => {
|
|
1580
|
+
(await epsocket).send(data);
|
|
1581
|
+
},
|
|
1582
|
+
async (code, reason) => {
|
|
1583
|
+
(await epsocket).close(close, reason);
|
|
1584
|
+
}
|
|
1585
|
+
];
|
|
1576
1586
|
}
|
|
1577
1587
|
};
|
|
1578
1588
|
if (typeof module.exports == "object" && typeof exports == "object") {
|
package/dist/module.js
CHANGED
|
@@ -1491,15 +1491,17 @@ var EpoxyClient = class {
|
|
|
1491
1491
|
canstart = true;
|
|
1492
1492
|
epxclient = null;
|
|
1493
1493
|
wisp;
|
|
1494
|
+
EpoxyHandlers = null;
|
|
1494
1495
|
constructor({ wisp }) {
|
|
1495
1496
|
this.wisp = wisp;
|
|
1496
1497
|
}
|
|
1497
1498
|
async init() {
|
|
1498
|
-
const { EpoxyClient: EpoxyClient2, EpoxyClientOptions } = await epoxy_module_bundled_default();
|
|
1499
|
+
const { EpoxyClient: EpoxyClient2, EpoxyClientOptions, EpoxyHandlers } = await epoxy_module_bundled_default();
|
|
1499
1500
|
let options = new EpoxyClientOptions();
|
|
1500
1501
|
options.user_agent = navigator.userAgent;
|
|
1501
1502
|
options.udp_extension_required = false;
|
|
1502
1503
|
this.epxclient = await new EpoxyClient2(this.wisp, certs_module_default, options);
|
|
1504
|
+
this.EpoxyHandlers = EpoxyHandlers;
|
|
1503
1505
|
this.ready = true;
|
|
1504
1506
|
}
|
|
1505
1507
|
ready = false;
|
|
@@ -1522,18 +1524,26 @@ var EpoxyClient = class {
|
|
|
1522
1524
|
}
|
|
1523
1525
|
}
|
|
1524
1526
|
connect(url, origin, protocols, requestHeaders, onopen, onmessage, onclose, onerror) {
|
|
1525
|
-
let
|
|
1527
|
+
let handlers = new this.EpoxyHandlers(
|
|
1526
1528
|
onopen,
|
|
1527
1529
|
onclose,
|
|
1528
1530
|
onerror,
|
|
1529
|
-
(data) => data instanceof Uint8Array ? onmessage(data.buffer) : onmessage(data)
|
|
1531
|
+
(data) => data instanceof Uint8Array ? onmessage(data.buffer) : onmessage(data)
|
|
1532
|
+
);
|
|
1533
|
+
let epsocket = this.epxclient.connect_websocket(
|
|
1534
|
+
handlers,
|
|
1530
1535
|
url.href,
|
|
1531
1536
|
protocols,
|
|
1532
|
-
origin
|
|
1537
|
+
Object.assign({ "Origin": origin }, requestHeaders)
|
|
1533
1538
|
);
|
|
1534
|
-
return
|
|
1535
|
-
|
|
1536
|
-
|
|
1539
|
+
return [
|
|
1540
|
+
async (data) => {
|
|
1541
|
+
(await epsocket).send(data);
|
|
1542
|
+
},
|
|
1543
|
+
async (code, reason) => {
|
|
1544
|
+
(await epsocket).close(close, reason);
|
|
1545
|
+
}
|
|
1546
|
+
];
|
|
1537
1547
|
}
|
|
1538
1548
|
};
|
|
1539
1549
|
export {
|
package/package.json
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mercuryworkshop/epoxy-transport",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
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": [],
|
|
7
7
|
"author": "",
|
|
8
8
|
"type": "module",
|
|
9
|
-
"scripts": {
|
|
10
|
-
"build": "node esbuild.bundle.mjs"
|
|
11
|
-
},
|
|
12
9
|
"dependencies": {
|
|
13
10
|
"@mercuryworkshop/epoxy-tls": "^2.0.0-3",
|
|
14
11
|
"esbuild-plugin-umd-wrapper": "^2.0.0",
|
|
@@ -18,7 +15,7 @@
|
|
|
18
15
|
"ws": "8.16.0"
|
|
19
16
|
},
|
|
20
17
|
"devDependencies": {
|
|
21
|
-
"@mercuryworkshop/bare-mux": "^1.1.
|
|
18
|
+
"@mercuryworkshop/bare-mux": "^1.1.3",
|
|
22
19
|
"esbuild": "^0.19.11",
|
|
23
20
|
"esbuild-plugin-d.ts": "^1.2.2"
|
|
24
21
|
},
|
|
@@ -33,5 +30,8 @@
|
|
|
33
30
|
"import": "./lib/index.cjs"
|
|
34
31
|
}
|
|
35
32
|
}
|
|
33
|
+
},
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "node esbuild.bundle.mjs"
|
|
36
36
|
}
|
|
37
|
-
}
|
|
37
|
+
}
|
package/src/main.ts
CHANGED
|
@@ -6,17 +6,19 @@ export class EpoxyClient implements BareTransport {
|
|
|
6
6
|
canstart = true;
|
|
7
7
|
epxclient: Awaited<ReturnType<any>>["EpoxyClient"]["prototype"] = null!;
|
|
8
8
|
wisp: string;
|
|
9
|
+
EpoxyHandlers: Awaited<ReturnType<any>>["EpoxyHandlers"]["prototype"] = null!;
|
|
9
10
|
|
|
10
11
|
constructor({ wisp }) {
|
|
11
12
|
this.wisp = wisp;
|
|
12
13
|
}
|
|
13
14
|
async init() {
|
|
14
|
-
const { EpoxyClient, EpoxyClientOptions } = await epoxy();
|
|
15
|
+
const { EpoxyClient, EpoxyClientOptions, EpoxyHandlers } = await epoxy();
|
|
15
16
|
|
|
16
17
|
let options = new EpoxyClientOptions();
|
|
17
18
|
options.user_agent = navigator.userAgent;
|
|
18
19
|
options.udp_extension_required = false;
|
|
19
20
|
this.epxclient = await new EpoxyClient(this.wisp, ROOTS, options);
|
|
21
|
+
this.EpoxyHandlers = EpoxyHandlers;
|
|
20
22
|
|
|
21
23
|
this.ready = true;
|
|
22
24
|
}
|
|
@@ -56,19 +58,27 @@ export class EpoxyClient implements BareTransport {
|
|
|
56
58
|
onmessage: (data: Blob | ArrayBuffer | string) => void,
|
|
57
59
|
onclose: (code: number, reason: string) => void,
|
|
58
60
|
onerror: (error: string) => void,
|
|
59
|
-
): (data: Blob | ArrayBuffer | string) => void {
|
|
60
|
-
let
|
|
61
|
+
): [ (data: Blob | ArrayBuffer | string) => void, (code: number, reason: string) => void ] {
|
|
62
|
+
let handlers = new this.EpoxyHandlers(
|
|
61
63
|
onopen,
|
|
62
64
|
onclose,
|
|
63
65
|
onerror,
|
|
64
|
-
(data: Uint8Array | string) => data instanceof Uint8Array ? onmessage(data.buffer) : onmessage(data)
|
|
66
|
+
(data: Uint8Array | string) => data instanceof Uint8Array ? onmessage(data.buffer) : onmessage(data)
|
|
67
|
+
);
|
|
68
|
+
let epsocket = this.epxclient.connect_websocket(
|
|
69
|
+
handlers,
|
|
65
70
|
url.href,
|
|
66
71
|
protocols,
|
|
67
|
-
origin,
|
|
72
|
+
Object.assign({ "Origin": origin }, requestHeaders)
|
|
68
73
|
);
|
|
69
74
|
|
|
70
|
-
return
|
|
71
|
-
|
|
72
|
-
|
|
75
|
+
return [
|
|
76
|
+
async (data) => {
|
|
77
|
+
(await epsocket).send(data);
|
|
78
|
+
},
|
|
79
|
+
async (code, reason) => {
|
|
80
|
+
(await epsocket).close(close, reason)
|
|
81
|
+
}
|
|
82
|
+
]
|
|
73
83
|
}
|
|
74
84
|
}
|