@mercuryworkshop/epoxy-transport 1.0.2 → 1.1.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mercuryworkshop/epoxy-transport",
3
- "version": "1.0.2",
3
+ "version": "1.1.0",
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": [],
@@ -11,7 +11,7 @@
11
11
  "build": "node esbuild.bundle.mjs"
12
12
  },
13
13
  "dependencies": {
14
- "@mercuryworkshop/epoxy-tls": "^1.1.1",
14
+ "@mercuryworkshop/epoxy-tls": "^1.4.1",
15
15
  "esbuild-plugin-umd-wrapper": "^2.0.0",
16
16
  "rollup": "^4.12.0",
17
17
  "rollup-plugin-node-resolve": "^5.2.0",
package/src/main.ts CHANGED
@@ -26,14 +26,19 @@ export class EpoxyClient implements BareTransport {
26
26
  ): Promise<TransferrableResponse> {
27
27
  if (body instanceof Blob)
28
28
  body = await body.arrayBuffer();
29
- let payload = await this.epxclient.fetch(remote.href, { method, body, headers, redirect: "manual" });
30
29
 
31
- return {
32
- body: payload.body!,
33
- headers: (payload as any).rawHeaders,
34
- status: payload.status,
35
- statusText: payload.statusText,
36
- };
30
+ try {
31
+ let payload = await this.epxclient.fetch(remote.href, { method, body, headers, redirect: "manual" });
32
+ return {
33
+ body: payload.body!,
34
+ headers: (payload as any).rawHeaders,
35
+ status: payload.status,
36
+ statusText: payload.statusText,
37
+ };
38
+ } catch (err) {
39
+ console.error(err);
40
+ throw err;
41
+ }
37
42
  }
38
43
 
39
44
  connect(
@@ -57,7 +62,11 @@ export class EpoxyClient implements BareTransport {
57
62
  );
58
63
 
59
64
  return async (data) => {
60
- (await epsocket).send(data);
65
+ if (typeof data === 'string') {
66
+ (await epsocket).send_text(data);
67
+ } else {
68
+ (await epsocket).send_binary(data);
69
+ }
61
70
  };
62
71
  }
63
72
  }