@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 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mercuryworkshop/epoxy-transport",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
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": [],
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
- canstart = true;
7
- epxclient: Awaited<ReturnType<any>>["EpoxyClient"]["prototype"] = null!;
8
- wisp: string;
6
+ canstart = true;
7
+ epxclient: Awaited<ReturnType<any>>["EpoxyClient"]["prototype"] = null!;
8
+ wisp: string;
9
9
 
10
- constructor({ wisp }) {
11
- this.wisp = wisp;
12
- }
13
- async init() {
14
- const { EpoxyClient, EpoxyClientOptions } = await epoxy();
10
+ constructor({ wisp }) {
11
+ this.wisp = wisp;
12
+ }
13
+ async init() {
14
+ const { EpoxyClient, EpoxyClientOptions } = await epoxy();
15
15
 
16
- let options = new EpoxyClientOptions();
17
- options.user_agent = navigator.userAgent;
18
- this.epxclient = await new EpoxyClient(this.wisp, ROOTS, options);
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
- this.ready = true;
21
- }
22
- ready = false;
23
- async meta() { }
21
+ this.ready = true;
22
+ }
23
+ ready = false;
24
+ async meta() { }
24
25
 
25
- async request(
26
- remote: URL,
27
- method: string,
28
- body: BodyInit | null,
29
- headers: BareHeaders,
30
- signal: AbortSignal | undefined
31
- ): Promise<TransferrableResponse> {
32
- if (body instanceof Blob)
33
- body = await body.arrayBuffer();
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
- try {
36
- let payload = await this.epxclient.fetch(remote.href, { method, body, headers, redirect: "manual" });
37
- return {
38
- body: payload.body!,
39
- headers: (payload as any).rawHeaders,
40
- status: payload.status,
41
- statusText: payload.statusText,
42
- };
43
- } catch (err) {
44
- console.error(err);
45
- throw err;
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
- connect(
50
- url: URL,
51
- origin: string,
52
- protocols: string[],
53
- requestHeaders: BareHeaders,
54
- onopen: (protocol: string) => void,
55
- onmessage: (data: Blob | ArrayBuffer | string) => void,
56
- onclose: (code: number, reason: string) => void,
57
- onerror: (error: string) => void,
58
- ): (data: Blob | ArrayBuffer | string) => void {
59
- let epsocket = this.epxclient.connect_ws(
60
- onopen,
61
- onclose,
62
- onerror,
63
- (data: Uint8Array | string) => data instanceof Uint8Array ? onmessage(data.buffer) : onmessage(data),
64
- url.href,
65
- protocols,
66
- origin,
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
- return async (data) => {
70
- await epsocket.send(data);
71
- }
72
- }
70
+ return async (data) => {
71
+ await epsocket.send(data);
72
+ }
73
+ }
73
74
  }