@mercuryworkshop/epoxy-transport
Advanced tools
Comparing version 2.0.1 to 2.0.2
{ | ||
"name": "@mercuryworkshop/epoxy-transport", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "a bare transport that implements end-to-end encryption with epoxy-tls and wisp", | ||
@@ -9,5 +9,2 @@ "main": "./dist/index.mjs", | ||
"type": "module", | ||
"scripts": { | ||
"build": "node esbuild.bundle.mjs" | ||
}, | ||
"dependencies": { | ||
@@ -22,3 +19,3 @@ "@mercuryworkshop/epoxy-tls": "^2.0.0-3", | ||
"devDependencies": { | ||
"@mercuryworkshop/bare-mux": "^1.1.1", | ||
"@mercuryworkshop/bare-mux": "^1.1.3", | ||
"esbuild": "^0.19.11", | ||
@@ -38,3 +35,6 @@ "esbuild-plugin-d.ts": "^1.2.2" | ||
} | ||
}, | ||
"scripts": { | ||
"build": "node esbuild.bundle.mjs" | ||
} | ||
} | ||
} |
@@ -9,2 +9,3 @@ import { BareHeaders, BareResponse, TransferrableResponse, type BareTransport } from "@mercuryworkshop/bare-mux"; | ||
wisp: string; | ||
EpoxyHandlers: Awaited<ReturnType<any>>["EpoxyHandlers"]["prototype"] = null!; | ||
@@ -15,3 +16,3 @@ constructor({ wisp }) { | ||
async init() { | ||
const { EpoxyClient, EpoxyClientOptions } = await epoxy(); | ||
const { EpoxyClient, EpoxyClientOptions, EpoxyHandlers } = await epoxy(); | ||
@@ -22,2 +23,3 @@ let options = new EpoxyClientOptions(); | ||
this.epxclient = await new EpoxyClient(this.wisp, ROOTS, options); | ||
this.EpoxyHandlers = EpoxyHandlers; | ||
@@ -62,17 +64,25 @@ this.ready = true; | ||
onerror: (error: string) => void, | ||
): (data: Blob | ArrayBuffer | string) => void { | ||
let epsocket = this.epxclient.connect_ws( | ||
): [ (data: Blob | ArrayBuffer | string) => void, (code: number, reason: string) => void ] { | ||
let handlers = new this.EpoxyHandlers( | ||
onopen, | ||
onclose, | ||
onerror, | ||
(data: Uint8Array | string) => data instanceof Uint8Array ? onmessage(data.buffer) : onmessage(data), | ||
(data: Uint8Array | string) => data instanceof Uint8Array ? onmessage(data.buffer) : onmessage(data) | ||
); | ||
let epsocket = this.epxclient.connect_websocket( | ||
handlers, | ||
url.href, | ||
protocols, | ||
origin, | ||
Object.assign({ "Origin": origin }, requestHeaders) | ||
); | ||
return async (data) => { | ||
await epsocket.send(data); | ||
} | ||
return [ | ||
async (data) => { | ||
(await epsocket).send(data); | ||
}, | ||
async (code, reason) => { | ||
(await epsocket).close(close, reason) | ||
} | ||
] | ||
} | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3891219
17552