@dmarket/p2p-tracker-core 1.2.1-SNAPSHOT-development.156 → 1.2.1-SNAPSHOT-development.165
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/VERSION +6 -6
- package/dmarket-p2p-tracker-core-domain.mjs +3503 -3343
- package/dmarket-p2p-tracker-core-domain.mjs.map +1 -1
- package/kotlin-kotlin-stdlib.mjs +38 -38
- package/kotlin-kotlin-stdlib.mjs.map +1 -1
- package/kotlinx-coroutines-core.mjs +1 -1
- package/kotlinx-io-kotlinx-io-bytestring.mjs +30 -30
- package/kotlinx-io-kotlinx-io-bytestring.mjs.map +1 -1
- package/kotlinx-io-kotlinx-io-core.mjs +451 -451
- package/kotlinx-io-kotlinx-io-core.mjs.map +1 -1
- package/kotlinx-serialization-kotlinx-serialization-core.mjs +87 -87
- package/kotlinx-serialization-kotlinx-serialization-core.mjs.map +1 -1
- package/kotlinx-serialization-kotlinx-serialization-json.mjs.map +1 -1
- package/ktor-ktor-client-core.mjs +2046 -1936
- package/ktor-ktor-client-core.mjs.map +1 -1
- package/ktor-ktor-events.mjs +5 -5
- package/ktor-ktor-http-cio.mjs +320 -320
- package/ktor-ktor-http-cio.mjs.map +1 -1
- package/ktor-ktor-http.mjs +626 -626
- package/ktor-ktor-io.mjs +631 -606
- package/ktor-ktor-io.mjs.map +1 -1
- package/ktor-ktor-utils.mjs +663 -663
- package/ktor-ktor-websockets.mjs +365 -365
- package/p2p-tracker-core.d.mts +5 -2
- package/p2p-tracker-core.mjs +7339 -6940
- package/p2p-tracker-core.mjs.map +1 -1
- package/package.json +1 -1
- package/pkg/README.md +27 -23
- package/pkg/client_wasm.d.ts +37 -2
- package/pkg/client_wasm.js +24 -5
- package/pkg/client_wasm_bg.wasm +0 -0
- package/pkg/client_wasm_bg.wasm.d.ts +1 -0
- package/pkg/snippets/web-spawn-05868593a72e2d44/js/spawn.js +2 -2
- package/pkg/spawn.js +4 -4
- package/transport/README.md +203 -16
- package/transport/dist/channel.d.ts +23 -3
- package/transport/dist/channel.d.ts.map +1 -1
- package/transport/dist/channel.js +3 -3
- package/transport/dist/channel.js.map +1 -1
- package/transport/dist/egress.d.ts +33 -0
- package/transport/dist/egress.d.ts.map +1 -0
- package/transport/dist/egress.js +311 -0
- package/transport/dist/egress.js.map +1 -0
- package/transport/dist/index.d.ts +5 -3
- package/transport/dist/index.d.ts.map +1 -1
- package/transport/dist/index.js +3 -2
- package/transport/dist/index.js.map +1 -1
- package/transport/dist/node-bridge.d.ts +12 -0
- package/transport/dist/node-bridge.d.ts.map +1 -0
- package/transport/dist/node-bridge.js +181 -0
- package/transport/dist/node-bridge.js.map +1 -0
- package/transport/dist/node-prover.d.ts +39 -0
- package/transport/dist/node-prover.d.ts.map +1 -0
- package/transport/dist/node-prover.js +124 -0
- package/transport/dist/node-prover.js.map +1 -0
- package/transport/dist/node-runtime.d.ts +11 -0
- package/transport/dist/node-runtime.d.ts.map +1 -0
- package/transport/dist/node-runtime.js +120 -0
- package/transport/dist/node-runtime.js.map +1 -0
- package/transport/dist/node-socket.d.ts +17 -0
- package/transport/dist/node-socket.d.ts.map +1 -0
- package/transport/dist/node-socket.js +109 -0
- package/transport/dist/node-socket.js.map +1 -0
- package/transport/dist/node-worker.d.ts +2 -0
- package/transport/dist/node-worker.d.ts.map +1 -0
- package/transport/dist/node-worker.js +75 -0
- package/transport/dist/node-worker.js.map +1 -0
- package/transport/dist/node.d.ts +9 -3
- package/transport/dist/node.d.ts.map +1 -1
- package/transport/dist/node.js +5 -61
- package/transport/dist/node.js.map +1 -1
- package/transport/dist/prover.d.ts +18 -2
- package/transport/dist/prover.d.ts.map +1 -1
- package/transport/dist/prover.js +33 -11
- package/transport/dist/prover.js.map +1 -1
- package/transport/dist/types.d.ts +24 -0
- package/transport/dist/types.d.ts.map +1 -1
- package/transport/package.json +4 -1
package/package.json
CHANGED
package/pkg/README.md
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
# client-wasm — browser-extension prover (wasm `cdylib`)
|
|
2
2
|
|
|
3
|
-
> **
|
|
4
|
-
>
|
|
5
|
-
>
|
|
6
|
-
>
|
|
7
|
-
>
|
|
8
|
-
> and the WebSocket transport lives in [`ts/`](ts/README.md). The **automated
|
|
9
|
-
> end-to-end run is deferred to a later, separately-scoped effort** — both host
|
|
10
|
-
> paths carry real cost (Node needs a single-threaded rebuild; headless Chrome
|
|
11
|
-
> pulls in Chromium). The manual recipe is kept in [`RUN_E2E.md`](RUN_E2E.md).
|
|
12
|
-
> (Branch journal `feature/DMA-61/wasm-client`, entries 10–12.)
|
|
3
|
+
> **Threaded WASM prover for browser extensions and plain Node.**
|
|
4
|
+
> Browser E2E runs in headless Chrome; the Node facade uses `worker_threads`
|
|
5
|
+
> and an application-owned raw TCP endpoint socket. Both use authenticated
|
|
6
|
+
> WebSocket to the notary. See [`ts/README.md`](ts/README.md) for the Node API
|
|
7
|
+
> and [`RUN_E2E.md`](RUN_E2E.md) for the real-service runners.
|
|
13
8
|
|
|
14
9
|
This crate is the wasm `cdylib` half of the prover: it injects a JS-backed
|
|
15
10
|
futures-io transport and calls `client-core`'s issuance + presentation flow. It
|
|
@@ -31,10 +26,12 @@ signature source; in brief:
|
|
|
31
26
|
| --- | --- | --- |
|
|
32
27
|
| `initialize(logging?, threadCount)` | `Promise<void>` | installs logging + the panic hook, starts the `web-spawn` spawner, builds the rayon MPC pool. **Await once** before `prove`. |
|
|
33
28
|
| `prove(notaryIo, serverIo, config, request, progressCb?)` | `Promise<ProveOutput>` | runs MPC-TLS + the length-prefixed phase-2 exchange → `client_core::issue_with_progress`. |
|
|
29
|
+
| `proveProxy(notaryIo, proxyConfig, request, progressCb?)` | `Promise<ProveOutput>` | one-channel proxy TLS → `client_core::issue_proxy_with_progress`; requires an enabled, routed notary. |
|
|
34
30
|
| `ProveOutput` | `{ attestation, secrets: Uint8Array; response: HttpResponse }` | the two opaque `postcard` blobs to persist together, plus the target's HTTP response. `Uint8Array` (not tsify `number[]`) so the large blobs don't bloat — journal 08. |
|
|
35
31
|
| `present(attestation, secrets, policy?)` | `Uint8Array` | offline (no notary/network, no `initialize`) → `client_core::present`; omit `policy` for the safe default redactions. |
|
|
36
32
|
|
|
37
|
-
DTOs (`src/types.rs`, tsify): `IssuanceConfig`, `
|
|
33
|
+
DTOs (`src/types.rs`, tsify): `IssuanceConfig`, `ProxyIssuanceConfig`,
|
|
34
|
+
`ProxyLimits`, `HttpRequest`, `HttpResponse`,
|
|
38
35
|
`RevealPolicy`, `RootStore` (`"mozilla" | { pem }`), `BodyReveal` (`"all" |
|
|
39
36
|
"none" | { jsonPaths }` — `jsonPaths` reveals each field **with its key path**,
|
|
40
37
|
is not directly `JSON.parse`-able, and widens to the whole array for any path
|
|
@@ -50,6 +47,14 @@ Both deliver raw bytes; the prover performs MPC-TLS. The client consumes the
|
|
|
50
47
|
injected `IoChannel` (the interface is exported into the `.d.ts` from a
|
|
51
48
|
`typescript_custom_section` in `src/io.rs` — the single source of truth).
|
|
52
49
|
|
|
50
|
+
Proxy mode uses only the notary channel; the notary authorizes and dials the
|
|
51
|
+
target. `ProxyIssuanceConfig` has `serverName`, optional `rootStore`, and optional
|
|
52
|
+
`limits` with independently defaulted finite capture ceilings. The existing
|
|
53
|
+
signature/client-auth defaults and result/presentation formats are unchanged.
|
|
54
|
+
`createProxyProver(wasm)` and `createNodeProxyProver()` expose this through the
|
|
55
|
+
extended JS facades. Both modes require the threaded build and worker assets.
|
|
56
|
+
`connectProxy` continues to mean the separate MPC target transport relay.
|
|
57
|
+
|
|
53
58
|
## Build & packaging
|
|
54
59
|
|
|
55
60
|
`./build.sh` runs `wasm-pack build --profile wasm --target web` and emits `pkg/`
|
|
@@ -82,20 +87,19 @@ For native mobile Rust clients, enable `client-core`'s `tcp` feature and pass
|
|
|
82
87
|
The caller still supplies the authenticated notary channel and a Tokio runtime.
|
|
83
88
|
Other mobile runtimes can supply their own futures-io stream instead.
|
|
84
89
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
Node needs a compatible WASM worker/bootstrap integration. This change does not
|
|
89
|
-
add mobile platform bindings to the scaffolded `client-cffi` crate.
|
|
90
|
+
The browser entry requires Web Workers and cross-origin isolation. The separate
|
|
91
|
+
`/node` entry supplies the worker runtime for plain Node, including asynchronous
|
|
92
|
+
presentation and explicit disposal. Native mobile bindings remain separate.
|
|
90
93
|
|
|
91
|
-
## Running end-to-end → [`RUN_E2E.md`](RUN_E2E.md)
|
|
94
|
+
## Running end-to-end → [`RUN_E2E.md`](RUN_E2E.md)
|
|
92
95
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
`
|
|
98
|
-
|
|
96
|
+
`E2E_PROVER=browser ./test-full-e2e/run.sh` drives the browser and endpoint proxy.
|
|
97
|
+
`E2E_PROVER=node ./test-full-e2e/run.sh` installs the npm tarball, uses the
|
|
98
|
+
application's endpoint TCP socket, and starts no browser or endpoint proxy.
|
|
99
|
+
Both submit presentations to the real validator/backend.
|
|
100
|
+
Add `E2E_MODE=proxy` to either command to open only the notary channel and let
|
|
101
|
+
the configured notary route the target connection. The runtime matrices check
|
|
102
|
+
large responses, failures and recovery as well as successful validation.
|
|
99
103
|
|
|
100
104
|
## Integrator note (cross-origin isolation)
|
|
101
105
|
|
package/pkg/client_wasm.d.ts
CHANGED
|
@@ -32,6 +32,23 @@ export interface CrateLogFilter {
|
|
|
32
32
|
*/
|
|
33
33
|
export type BodyReveal = "all" | "none" | { jsonPaths: string[] };
|
|
34
34
|
|
|
35
|
+
/**
|
|
36
|
+
* Local proxy capture ceilings. Every omitted field keeps its finite default;
|
|
37
|
+
* these values are not policy negotiated with the notary.
|
|
38
|
+
*/
|
|
39
|
+
export interface ProxyLimits {
|
|
40
|
+
maxSentData?: number;
|
|
41
|
+
maxRecvData?: number;
|
|
42
|
+
maxSentCiphertext?: number;
|
|
43
|
+
maxRecvCiphertext?: number;
|
|
44
|
+
maxCiphertext?: number;
|
|
45
|
+
maxSentRecords?: number;
|
|
46
|
+
maxRecvRecords?: number;
|
|
47
|
+
maxRecordPayload?: number;
|
|
48
|
+
maxHandshakeBytes?: number;
|
|
49
|
+
maxCertificateBytes?: number;
|
|
50
|
+
}
|
|
51
|
+
|
|
35
52
|
/**
|
|
36
53
|
* Logging configuration passed from JS to [`crate::initialize`].
|
|
37
54
|
*/
|
|
@@ -54,6 +71,16 @@ export interface LoggingConfig {
|
|
|
54
71
|
*/
|
|
55
72
|
export type RootStorePreset = "mozilla";
|
|
56
73
|
|
|
74
|
+
/**
|
|
75
|
+
* Proxy issuance takes only a notary channel. No target address or MPC
|
|
76
|
+
* preprocessing settings; signature/client-auth defaults match the MPC DTO.
|
|
77
|
+
*/
|
|
78
|
+
export interface ProxyIssuanceConfig {
|
|
79
|
+
serverName: string;
|
|
80
|
+
limits?: ProxyLimits;
|
|
81
|
+
rootStore?: RootStore;
|
|
82
|
+
}
|
|
83
|
+
|
|
57
84
|
/**
|
|
58
85
|
* The HTTP request to prove.
|
|
59
86
|
*
|
|
@@ -200,8 +227,8 @@ export class WorkerData {
|
|
|
200
227
|
* `web-spawn`'s spawner would start a second worker if re-run. Extension
|
|
201
228
|
* lifecycle code can easily call `initialize` more than once, so a duplicate
|
|
202
229
|
* call here is a no-op that returns `Ok(())`. On failure the one-time claim is
|
|
203
|
-
* released,
|
|
204
|
-
*
|
|
230
|
+
* released, but a partially initialized spawner/global pool cannot be reset.
|
|
231
|
+
* After failure, hosts must discard the worker/module before retrying.
|
|
205
232
|
*
|
|
206
233
|
* A near-verbatim port of upstream `dep/tlsn/crates/wasm/src/lib.rs`, with the
|
|
207
234
|
* idempotency guard added and logging configured locally rather than via
|
|
@@ -247,6 +274,13 @@ export function present(attestation_bytes: Uint8Array, secrets_bytes: Uint8Array
|
|
|
247
274
|
*/
|
|
248
275
|
export function prove(notary_io: IoChannel, server_io: IoChannel, config: IssuanceConfig, request: HttpRequest, progress_cb?: Function | null): Promise<ProveOutput>;
|
|
249
276
|
|
|
277
|
+
/**
|
|
278
|
+
* Issue through an enabled proxy notary using exactly one channel. The notary
|
|
279
|
+
* authorizes and dials the target; this call never opens a target relay or
|
|
280
|
+
* falls back to MPC. The threaded module must be initialized first.
|
|
281
|
+
*/
|
|
282
|
+
export function proveProxy(notary_io: IoChannel, config: ProxyIssuanceConfig, request: HttpRequest, progress_cb?: Function | null): Promise<ProveOutput>;
|
|
283
|
+
|
|
250
284
|
/**
|
|
251
285
|
* Starts the thread spawner on a dedicated worker thread.
|
|
252
286
|
*/
|
|
@@ -263,6 +297,7 @@ export interface InitOutput {
|
|
|
263
297
|
readonly initialize: (a: number, b: number) => any;
|
|
264
298
|
readonly present: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
|
|
265
299
|
readonly prove: (a: any, b: any, c: any, d: any, e: number) => any;
|
|
300
|
+
readonly proveProxy: (a: any, b: any, c: any, d: number) => any;
|
|
266
301
|
readonly proveoutput_attestation: (a: number) => [number, number];
|
|
267
302
|
readonly proveoutput_response: (a: number) => any;
|
|
268
303
|
readonly proveoutput_secrets: (a: number) => [number, number];
|
package/pkg/client_wasm.js
CHANGED
|
@@ -130,8 +130,8 @@ if (Symbol.dispose) WorkerData.prototype[Symbol.dispose] = WorkerData.prototype.
|
|
|
130
130
|
* `web-spawn`'s spawner would start a second worker if re-run. Extension
|
|
131
131
|
* lifecycle code can easily call `initialize` more than once, so a duplicate
|
|
132
132
|
* call here is a no-op that returns `Ok(())`. On failure the one-time claim is
|
|
133
|
-
* released,
|
|
134
|
-
*
|
|
133
|
+
* released, but a partially initialized spawner/global pool cannot be reset.
|
|
134
|
+
* After failure, hosts must discard the worker/module before retrying.
|
|
135
135
|
*
|
|
136
136
|
* A near-verbatim port of upstream `dep/tlsn/crates/wasm/src/lib.rs`, with the
|
|
137
137
|
* idempotency guard added and logging configured locally rather than via
|
|
@@ -208,6 +208,21 @@ export function prove(notary_io, server_io, config, request, progress_cb) {
|
|
|
208
208
|
return ret;
|
|
209
209
|
}
|
|
210
210
|
|
|
211
|
+
/**
|
|
212
|
+
* Issue through an enabled proxy notary using exactly one channel. The notary
|
|
213
|
+
* authorizes and dials the target; this call never opens a target relay or
|
|
214
|
+
* falls back to MPC. The threaded module must be initialized first.
|
|
215
|
+
* @param {IoChannel} notary_io
|
|
216
|
+
* @param {ProxyIssuanceConfig} config
|
|
217
|
+
* @param {HttpRequest} request
|
|
218
|
+
* @param {Function | null} [progress_cb]
|
|
219
|
+
* @returns {Promise<ProveOutput>}
|
|
220
|
+
*/
|
|
221
|
+
export function proveProxy(notary_io, config, request, progress_cb) {
|
|
222
|
+
const ret = wasm.proveProxy(notary_io, config, request, isLikeNone(progress_cb) ? 0 : addToExternrefTable0(progress_cb));
|
|
223
|
+
return ret;
|
|
224
|
+
}
|
|
225
|
+
|
|
211
226
|
/**
|
|
212
227
|
* Starts the thread spawner on a dedicated worker thread.
|
|
213
228
|
* @returns {Promise<any>}
|
|
@@ -620,6 +635,10 @@ function __wbg_get_imports(memory) {
|
|
|
620
635
|
const ret = arg0.node;
|
|
621
636
|
return ret;
|
|
622
637
|
},
|
|
638
|
+
__wbg_now_86c0d4ba3fa605b8: function() {
|
|
639
|
+
const ret = Date.now();
|
|
640
|
+
return ret;
|
|
641
|
+
},
|
|
623
642
|
__wbg_now_cace042f68c814d8: function(arg0) {
|
|
624
643
|
const ret = arg0.now();
|
|
625
644
|
return ret;
|
|
@@ -778,17 +797,17 @@ function __wbg_get_imports(memory) {
|
|
|
778
797
|
return ret;
|
|
779
798
|
}, arguments); },
|
|
780
799
|
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
781
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx:
|
|
800
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 1158, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
782
801
|
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_1fa5c626ec3a32f9___convert__closures_____invoke___wasm_bindgen_1fa5c626ec3a32f9___JsValue______true_);
|
|
783
802
|
return ret;
|
|
784
803
|
},
|
|
785
804
|
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
786
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx:
|
|
805
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 2735, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
787
806
|
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_1fa5c626ec3a32f9___convert__closures_____invoke___wasm_bindgen_1fa5c626ec3a32f9___JsValue__core_b7b33017ae0f8bb5___result__Result_____wasm_bindgen_1fa5c626ec3a32f9___JsError___true_);
|
|
788
807
|
return ret;
|
|
789
808
|
},
|
|
790
809
|
__wbindgen_cast_0000000000000003: function(arg0, arg1) {
|
|
791
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx:
|
|
810
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 2737, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
792
811
|
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_1fa5c626ec3a32f9___convert__closures_____invoke___js_sys_27d0ccca2911ffcd___futures__task__wait_async_polyfill__MessageEvent______true_);
|
|
793
812
|
return ret;
|
|
794
813
|
},
|
package/pkg/client_wasm_bg.wasm
CHANGED
|
Binary file
|
|
@@ -4,6 +4,7 @@ export const __wbg_proveoutput_free: (a: number, b: number) => void;
|
|
|
4
4
|
export const initialize: (a: number, b: number) => any;
|
|
5
5
|
export const present: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
|
|
6
6
|
export const prove: (a: any, b: any, c: any, d: any, e: number) => any;
|
|
7
|
+
export const proveProxy: (a: any, b: any, c: any, d: number) => any;
|
|
7
8
|
export const proveoutput_attestation: (a: number) => [number, number];
|
|
8
9
|
export const proveoutput_response: (a: number) => any;
|
|
9
10
|
export const proveoutput_secrets: (a: number) => [number, number];
|
|
@@ -17,7 +17,7 @@ registerMessageListener(self, 'web_spawn_start_spawner', async (data) => {
|
|
|
17
17
|
);
|
|
18
18
|
const [module, memory, spawnerPtr] = data;
|
|
19
19
|
const pkg = await import('../../../client_wasm.js');
|
|
20
|
-
const exports = await pkg.default({ module, memory });
|
|
20
|
+
const exports = await pkg.default({ module_or_path: module, memory });
|
|
21
21
|
|
|
22
22
|
const spawner = pkg.web_spawn_recover_spawner(spawnerPtr);
|
|
23
23
|
postMessage('web_spawn_spawner_ready');
|
|
@@ -33,7 +33,7 @@ registerMessageListener(self, 'web_spawn_start_worker', async (data) => {
|
|
|
33
33
|
const [module, memory, workerPtr] = data;
|
|
34
34
|
|
|
35
35
|
const pkg = await import('../../../client_wasm.js');
|
|
36
|
-
const exports = await pkg.default({ module, memory });
|
|
36
|
+
const exports = await pkg.default({ module_or_path: module, memory });
|
|
37
37
|
|
|
38
38
|
pkg.web_spawn_start_worker(workerPtr);
|
|
39
39
|
|
package/pkg/spawn.js
CHANGED
|
@@ -16,8 +16,8 @@ registerMessageListener(self, 'web_spawn_start_spawner', async (data) => {
|
|
|
16
16
|
import.meta.url
|
|
17
17
|
);
|
|
18
18
|
const [module, memory, spawnerPtr] = data;
|
|
19
|
-
const pkg = await import('
|
|
20
|
-
const exports = await pkg.default({ module, memory });
|
|
19
|
+
const pkg = await import('./client_wasm.js');
|
|
20
|
+
const exports = await pkg.default({ module_or_path: module, memory });
|
|
21
21
|
|
|
22
22
|
const spawner = pkg.web_spawn_recover_spawner(spawnerPtr);
|
|
23
23
|
postMessage('web_spawn_spawner_ready');
|
|
@@ -32,8 +32,8 @@ registerMessageListener(self, 'web_spawn_start_spawner', async (data) => {
|
|
|
32
32
|
registerMessageListener(self, 'web_spawn_start_worker', async (data) => {
|
|
33
33
|
const [module, memory, workerPtr] = data;
|
|
34
34
|
|
|
35
|
-
const pkg = await import('
|
|
36
|
-
const exports = await pkg.default({ module, memory });
|
|
35
|
+
const pkg = await import('./client_wasm.js');
|
|
36
|
+
const exports = await pkg.default({ module_or_path: module, memory });
|
|
37
37
|
|
|
38
38
|
pkg.web_spawn_start_worker(workerPtr);
|
|
39
39
|
|
package/transport/README.md
CHANGED
|
@@ -18,9 +18,11 @@ wasm pkg — a load-bearing invariant, see below):
|
|
|
18
18
|
| export | kind | purpose |
|
|
19
19
|
| --- | --- | --- |
|
|
20
20
|
| `createProver(wasm)` | façade | wraps an injected pkg module in the `Prover` surface below |
|
|
21
|
+
| `createProxyProver(wasm)` | façade | adds `proveProxy(notaryIo, proxyConfig, request, onProgress?)` to the existing surface |
|
|
22
|
+
| `ProxyClientWasmModule` / `ProxyProver` | types | extend the old module/facade interfaces without adding required old members |
|
|
21
23
|
| `Prover` | type | `initialize(logging?, threads?)` / `prove(notaryIo, serverIo, config, request, onProgress?)` / `present(attestation, secrets, policy?)` |
|
|
22
24
|
| `ClientWasmModule` | type | the injected-module contract (`import * as wasm from ".../pkg/client_wasm.js"` satisfies it) |
|
|
23
|
-
| `connectNotary(url, token, opts?)` | transport | the notary
|
|
25
|
+
| `connectNotary(url, token, opts?)` | transport | the notary channel for either mode, authenticated by the `Sec-WebSocket-Protocol` bearer subprotocol |
|
|
24
26
|
| `connectProxy(proxyBase, host, port, opts?)` | transport | the target byte pipe, tunnelled `WS → p2p-wss-proxy → TCP` |
|
|
25
27
|
| `connectTcp(host, port, { connect })` | transport | direct target TCP through an injected host connector |
|
|
26
28
|
| `TcpIoChannel` / `TcpSocket` / `TcpConnectOptions` | transport / types | adapt host Web Streams to `IoChannel` |
|
|
@@ -70,6 +72,53 @@ const presentation = prover.present(out.attestation, out.secrets, {
|
|
|
70
72
|
// POST `presentation` (Uint8Array) to your validating backend.
|
|
71
73
|
```
|
|
72
74
|
|
|
75
|
+
## Proxy issuance
|
|
76
|
+
|
|
77
|
+
Choose proxy explicitly when the notary has enabled it and authorized the target
|
|
78
|
+
DNS identity. It uses only the notary channel; the notary owns target DNS and
|
|
79
|
+
dialing. The same attestation/secrets, presentation and redaction APIs apply.
|
|
80
|
+
|
|
81
|
+
```ts
|
|
82
|
+
import * as wasm from "./pkg/client_wasm.js"; // keep loose and external
|
|
83
|
+
import { createProxyProver, connectNotary } from "@dmarket/steam-provenance";
|
|
84
|
+
|
|
85
|
+
const prover = createProxyProver(wasm); // checks the export before initialization
|
|
86
|
+
const notaryIo = await connectNotary("wss://notary.example/", bearerToken);
|
|
87
|
+
try {
|
|
88
|
+
const out = await prover.proveProxy(notaryIo,
|
|
89
|
+
{ serverName: "api.example.com", limits: { maxRecvData: 128 * 1024 } },
|
|
90
|
+
{ method: "GET", uri: "/v1/resource" });
|
|
91
|
+
// Persist out.attestation and out.secrets together; present later as usual.
|
|
92
|
+
} finally {
|
|
93
|
+
await notaryIo.close();
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
`ProxyIssuanceConfig` accepts `serverName`, `rootStore` and `limits`. Omitted
|
|
98
|
+
limits retain finite defaults: 16/128 KiB sent/received application plaintext,
|
|
99
|
+
64/256/320 KiB sent/received/combined TLS wire bytes, 512 records per direction,
|
|
100
|
+
18 KiB record payload, and 64 KiB handshake/certificate budgets. Byte caps include
|
|
101
|
+
HTTP headers or TLS record headers as applicable. Invalid or inconsistent limits
|
|
102
|
+
fail before protocol IO; the notary independently enforces its own limits.
|
|
103
|
+
Proxy has no MPC preprocessing settings and emits `PROXY_SETUP` and `PROOF`
|
|
104
|
+
stages through the existing progress-event shape.
|
|
105
|
+
|
|
106
|
+
Both modes require the threaded WASM build, workers and browser isolation.
|
|
107
|
+
`connectProxy` remains the MPC WebSocket-to-TCP transport relay; it is not used
|
|
108
|
+
by TLSN proxy mode. `createProver` and old injected modules retain their existing
|
|
109
|
+
MPC behavior. Proxy factories reject a module missing `proveProxy` explicitly;
|
|
110
|
+
issuance failures never trigger automatic MPC replay. Browser hosts own channel
|
|
111
|
+
cleanup and worker cancellation as with the existing facade.
|
|
112
|
+
|
|
113
|
+
For plain Node, import `createNodeProxyProver` from
|
|
114
|
+
`@dmarket/steam-provenance/node`. Its `proveProxy(notaryIo, config, request,
|
|
115
|
+
options?)` takes exactly one channel, with the same validation, one-operation
|
|
116
|
+
limit, cancellation, timeout and disposal rules as `createNodeProver` below.
|
|
117
|
+
Accepted channels close on success or failure; pre-aborted, invalid-option,
|
|
118
|
+
busy and disposed calls retain caller ownership. A failed or cancelled operation
|
|
119
|
+
discards the worker tree and a later call initializes a fresh one. The extended
|
|
120
|
+
object also retains `prove` and asynchronous `present`.
|
|
121
|
+
|
|
73
122
|
## Direct TCP for desktop and native hosts
|
|
74
123
|
|
|
75
124
|
In a Node-capable host, replace the target proxy channel with:
|
|
@@ -125,10 +174,7 @@ when an issuance fails.
|
|
|
125
174
|
errors, copies outgoing bytes before yielding, and waits for pending writes
|
|
126
175
|
before closing. Repeated `close()` calls share the same promise.
|
|
127
176
|
|
|
128
|
-
|
|
129
|
-
uses browser Web Workers. Electron needs a suitable renderer and host bridge;
|
|
130
|
-
plain Node needs a compatible WASM worker/bootstrap integration. A TCP adapter
|
|
131
|
-
alone does not supply that runtime. Native mobile Rust integrations can use
|
|
177
|
+
The Node runtime and caller-owned socket handoff are described below. Native mobile Rust integrations can use
|
|
132
178
|
`client-core` with `features = ["tcp"]`, a Tokio runtime, and
|
|
133
179
|
`client_core::connect_tcp((host, port))` as the target stream for `issue()`.
|
|
134
180
|
|
|
@@ -211,9 +257,9 @@ queue in `io.rs` is satisfied immediately here).
|
|
|
211
257
|
The generated wasm package (`../pkg`) must exist first — `src/wasm-compat.ts`
|
|
212
258
|
asserts this package's locally-declared types against the generated
|
|
213
259
|
`client_wasm.d.ts` (resolved via the `paths` mapping in `tsconfig.json`).
|
|
214
|
-
|
|
215
|
-
type-only and erased
|
|
216
|
-
with `
|
|
260
|
+
The browser entry has **no runtime dependency** on `../pkg`: its imports are
|
|
261
|
+
type-only and erased. The Node prover worker loads the adjacent `pkg/` at
|
|
262
|
+
runtime; distribute it together with `transport/`, as the root npm package does.
|
|
217
263
|
|
|
218
264
|
```sh
|
|
219
265
|
../build.sh # 1. build the wasm pkg (produces ../pkg/client_wasm.d.ts)
|
|
@@ -223,18 +269,159 @@ npm run build # emit dist/ (ESM + .d.ts)
|
|
|
223
269
|
npm test # build + adapter and loopback TCP tests
|
|
224
270
|
```
|
|
225
271
|
|
|
226
|
-
##
|
|
272
|
+
## Plain Node prover
|
|
273
|
+
|
|
274
|
+
The Node worker prover requires Node 24.18.0 or later; Node 26.7.0 is also tested
|
|
275
|
+
on macOS arm64. Its factories reject older runtimes before starting workers or
|
|
276
|
+
accepting channels. Package installation and browser-entry imports retain the
|
|
277
|
+
published Node >=18 requirement. CI uses Node 24.18.0 for worker tests.
|
|
278
|
+
|
|
279
|
+
Import `@dmarket/steam-provenance/node` from the installed npm package. The
|
|
280
|
+
transport package also exposes these APIs at `client-wasm-transport/node` when
|
|
281
|
+
staged alongside `pkg/`. Keep the Node entry and its worker files on disk;
|
|
282
|
+
do not inline them into an application bundle. The browser entry stays separate.
|
|
283
|
+
|
|
284
|
+
```js
|
|
285
|
+
import { createConnection } from "node:net";
|
|
286
|
+
import { once } from "node:events";
|
|
287
|
+
import { createNodeProver, wrapTcpSocket, connectNotary }
|
|
288
|
+
from "@dmarket/steam-provenance/node";
|
|
289
|
+
|
|
290
|
+
const prover = createNodeProver({ threadCount: 2, operationTimeoutMs: 120_000 });
|
|
291
|
+
let socket, serverIo, notaryIo;
|
|
292
|
+
try {
|
|
293
|
+
await prover.initialize();
|
|
294
|
+
notaryIo = await connectNotary(notaryUrl, accessToken);
|
|
295
|
+
socket = createConnection({ host: endpointAddress, port: 443 });
|
|
296
|
+
socket.on("error", error => console.error("endpoint socket error", error.code));
|
|
297
|
+
const connectionTimer = setTimeout(() => socket.destroy(new Error("connect timeout")), 10_000);
|
|
298
|
+
try { await once(socket, "connect"); }
|
|
299
|
+
finally { clearTimeout(connectionTimer); }
|
|
300
|
+
serverIo = wrapTcpSocket(socket);
|
|
301
|
+
const out = await prover.prove(notaryIo, serverIo,
|
|
302
|
+
{ serverName: "api.example.com" },
|
|
303
|
+
{ method: "GET", uri: "/v1/resource" },
|
|
304
|
+
{ signal: AbortSignal.timeout(120_000), onProgress: event => console.log(event.step) });
|
|
305
|
+
const presentation = await prover.present(out.attestation, out.secrets, {
|
|
306
|
+
redactRequestHeaderValues: ["authorization", "cookie", "user-agent"],
|
|
307
|
+
revealRequestTarget: false,
|
|
308
|
+
revealResponseHeaders: true,
|
|
309
|
+
revealResponseBody: "all",
|
|
310
|
+
});
|
|
311
|
+
// Send presentation to your validator; persist attestation + secrets together.
|
|
312
|
+
} finally {
|
|
313
|
+
await prover.dispose();
|
|
314
|
+
await serverIo?.abort();
|
|
315
|
+
socket?.destroy();
|
|
316
|
+
await notaryIo?.close();
|
|
317
|
+
}
|
|
318
|
+
```
|
|
227
319
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
320
|
+
The application opens the endpoint connection **once** and hands over that same
|
|
321
|
+
raw `net.Socket`. It must already be connected, readable/writable, binary, and
|
|
322
|
+
exclusively available: no `setEncoding`, competing data/readable listeners,
|
|
323
|
+
in-flight application writes, or consumed protocol bytes. TLS sockets, connecting
|
|
324
|
+
sockets, and closed sockets are rejected without taking ownership. On successful
|
|
325
|
+
handoff, the adapter owns IO and may close/destroy the socket. Unread buffered
|
|
326
|
+
bytes are retained. It enables `TCP_NODELAY` and `allowHalfOpen`: peer EOF ends
|
|
327
|
+
reads while accepted writes can still drain. Normal close is idempotent and
|
|
328
|
+
drains writes; after five seconds it destroys a blocked connection. `abort()`
|
|
329
|
+
destroys it immediately. Reusing this connection after a proof is not supported.
|
|
330
|
+
|
|
331
|
+
MPC-TLS runs inside the prover, so do not call `tls.connect()` or perform a TLS
|
|
332
|
+
handshake before handoff. `serverName` controls certificate identity and SNI and
|
|
333
|
+
can differ from the routing address. The notary uses its existing authenticated
|
|
334
|
+
WebSocket handshake; `connectNotary` also accepts an injected `WebSocketImpl`.
|
|
335
|
+
Application connection deadlines are separate from prover initialization and
|
|
336
|
+
issuance deadlines.
|
|
337
|
+
|
|
338
|
+
`createNodeProver` runs the existing threaded WASM inside dedicated
|
|
339
|
+
`worker_threads`, with no compatibility globals added to the application.
|
|
340
|
+
`initialize()` coalesces repeated/concurrent calls. `prove()` and `present()` are
|
|
341
|
+
asynchronous and allow one active operation per instance. A rejected concurrent
|
|
342
|
+
call, invalid options, or an already-aborted signal leaves ownership of the
|
|
343
|
+
channels with the caller. An accepted proof closes
|
|
344
|
+
both IO channels on success or failure. Custom channels must make `close()`
|
|
345
|
+
unblock IO; they can expose `abort()` for immediate cleanup. The bridge allows
|
|
346
|
+
one outstanding read, acknowledges write completion, splits messages at 64 KiB,
|
|
347
|
+
and limits queued writes to 8 MiB / 128 calls. Await writes for backpressure.
|
|
348
|
+
|
|
349
|
+
Initialization defaults to 30 seconds; proof/presentation calls default to
|
|
350
|
+
120 seconds including initialization, configurable per instance or call. An
|
|
351
|
+
AbortSignal, timeout, worker failure, or failed proof discards the entire worker
|
|
352
|
+
module; a later call initializes a fresh one. `dispose()` is terminal and
|
|
353
|
+
idempotent, settles outstanding calls, terminates the complete worker tree, and
|
|
354
|
+
bounds custom-channel cleanup to five seconds. Progress callback errors cannot
|
|
355
|
+
strand a proof. Logging defaults to Off; progress contains stages, not proof data.
|
|
356
|
+
|
|
357
|
+
Separate instances can run independently. Each uses a prover worker, a spawner,
|
|
358
|
+
a Rayon pool, and additional MPC workers; budget CPU and shared memory per
|
|
359
|
+
instance. `threadCount` defaults to available CPUs capped at 8 (range 1–32) and
|
|
360
|
+
also controls the parallelism reported to the MPC executor. A one-thread pool
|
|
361
|
+
still requires workers. No serial WASM rebuild or browser is involved.
|
|
233
362
|
|
|
234
363
|
## Integrator note (cross-origin isolation)
|
|
235
364
|
|
|
236
365
|
The multi-threaded wasm build uses `SharedArrayBuffer`, so the embedding
|
|
237
366
|
page/extension **must be cross-origin isolated** (COOP: `same-origin` + COEP:
|
|
238
367
|
`require-corp`). Plan the extension/page headers accordingly. A failed
|
|
239
|
-
`initialize()`
|
|
240
|
-
|
|
368
|
+
`initialize()` releases the façade's memo. After partial worker startup, discard
|
|
369
|
+
the browser worker/module before retrying; global Rust pools cannot be reset.
|
|
370
|
+
The Node facade performs that replacement automatically.
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
### Opt-in Worker egress for proxy issuance
|
|
374
|
+
|
|
375
|
+
Use `connectEgressNotary(workerUrl, token, options?)` when the operator selects
|
|
376
|
+
reverse Worker egress. It returns the ordinary `IoChannel` consumed by
|
|
377
|
+
`proveProxy`; the proof, presentation and validator APIs are unchanged.
|
|
378
|
+
`connectNotary` continues to select the existing direct notary protocol.
|
|
379
|
+
|
|
380
|
+
```ts
|
|
381
|
+
import { connectEgressNotary, createProxyProver } from "@dmarket/steam-provenance";
|
|
382
|
+
const prover = createProxyProver(wasm);
|
|
383
|
+
await prover.initialize(null, 2);
|
|
384
|
+
const io = await connectEgressNotary(
|
|
385
|
+
"wss://worker.example/notary/egress/v1", bearerToken,
|
|
386
|
+
{ timeoutMs: 240_000 },
|
|
387
|
+
);
|
|
388
|
+
try {
|
|
389
|
+
const result = await prover.proveProxy(io, proxyConfig, request);
|
|
390
|
+
// Existing presentation/disclosure API consumes result.attestation/secrets.
|
|
391
|
+
} finally {
|
|
392
|
+
await io.abort();
|
|
393
|
+
}
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
The connector is also exported from `/node`; use it with
|
|
397
|
+
`createNodeProxyProver`. `WebSocketImpl` injection supports Node WebSocket
|
|
398
|
+
implementations and gateway signing headers. For a signed gateway flow, omit
|
|
399
|
+
`token`, inject a constructor that signs the actual Worker-facing request URL,
|
|
400
|
+
and configure the gateway to mint `Authorization` before forwarding. The Worker
|
|
401
|
+
accepts that user credential; it never validates original API-key signatures or
|
|
402
|
+
forwards those signing headers. A raw API key is not a notary token. Service
|
|
403
|
+
credentials belong only in Worker/notary configuration, never in this API.
|
|
404
|
+
|
|
405
|
+
The frontend requires `tlsn.notary.egress.v1` and implements bounded binary
|
|
406
|
+
framing/credits with 64 KiB per-direction windows and a 16 KiB maximum payload.
|
|
407
|
+
It restricts all traffic to the client channel; the client cannot select an
|
|
408
|
+
upstream notary or send server-leg frames. The total timeout includes the
|
|
409
|
+
WebSocket handshake, admission, TLS, proof and signing (default 240 seconds,
|
|
410
|
+
maximum 600 seconds, reduced by the notary's advertised budget). WSS is required;
|
|
411
|
+
plain WS is allowed only for loopback fixtures. URL credentials, query parameters
|
|
412
|
+
and fragments are rejected.
|
|
413
|
+
|
|
414
|
+
One read and up to 16 writes (at most 1 MiB total) may be pending, matching the
|
|
415
|
+
existing WASM adapter's bounded batching. Writes copy their input and serialize;
|
|
416
|
+
only 64 KiB may be outstanding on the wire until consumption credits arrive.
|
|
417
|
+
Exceeding the local write queue fails the session. `close()` sends a directional FIN after queued writes;
|
|
418
|
+
`abort()` immediately stops a failed or cancelled session and clears pending IO.
|
|
419
|
+
On browser error/cancellation call `abort()` or terminate the owning worker.
|
|
420
|
+
The Node prover uses `abort()` during failed-operation disposal. Target EOF keeps
|
|
421
|
+
the client channel alive for the signing exchange. There is no direct-target,
|
|
422
|
+
transport or mode fallback. The MPC `proxyBaseUrl` setting remains separate.
|
|
423
|
+
|
|
424
|
+
The operator-controlled Worker is part of the notary's trusted observation path.
|
|
425
|
+
It sees the user credential and disclosed proof fields after outer WSS
|
|
426
|
+
termination. The inner target TLS remains between prover and target. This route
|
|
427
|
+
does not guarantee a source-IP country or Steam acceptance.
|
|
@@ -2,11 +2,31 @@ import type { IoChannel } from "./types.js";
|
|
|
2
2
|
/**
|
|
3
3
|
* Injectable `WebSocket` constructor. Defaults to the global browser
|
|
4
4
|
* `WebSocket`. Supplying one lets the transport run under a polyfill (e.g. the
|
|
5
|
-
* `ws` package in Node
|
|
5
|
+
* `ws` package in Node),
|
|
6
6
|
* without any code change.
|
|
7
7
|
*/
|
|
8
|
+
export interface WebSocketEvents {
|
|
9
|
+
open: unknown;
|
|
10
|
+
error: unknown;
|
|
11
|
+
close: {
|
|
12
|
+
code: number;
|
|
13
|
+
};
|
|
14
|
+
message: {
|
|
15
|
+
data: unknown;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export interface WebSocketLike {
|
|
19
|
+
binaryType: string;
|
|
20
|
+
readonly readyState: number;
|
|
21
|
+
readonly protocol: string;
|
|
22
|
+
send(data: Uint8Array<ArrayBuffer>): void;
|
|
23
|
+
close(): void;
|
|
24
|
+
addEventListener<K extends keyof WebSocketEvents>(type: K, listener: (event: WebSocketEvents[K]) => void, options?: {
|
|
25
|
+
once?: boolean;
|
|
26
|
+
}): void;
|
|
27
|
+
}
|
|
8
28
|
export type WebSocketCtor = {
|
|
9
|
-
new (url: string, protocols?: string | string[]):
|
|
29
|
+
new (url: string, protocols?: string | string[]): WebSocketLike;
|
|
10
30
|
};
|
|
11
31
|
/**
|
|
12
32
|
* Adapts a browser `WebSocket` into the wasm prover's `IoChannel`.
|
|
@@ -36,7 +56,7 @@ export type WebSocketCtor = {
|
|
|
36
56
|
*/
|
|
37
57
|
export declare class WsIoChannel implements IoChannel {
|
|
38
58
|
#private;
|
|
39
|
-
constructor(ws:
|
|
59
|
+
constructor(ws: WebSocketLike);
|
|
40
60
|
/** Resolves once the socket is open; rejects if it fails to open. */
|
|
41
61
|
whenReady(): Promise<void>;
|
|
42
62
|
/** The subprotocol the server selected (`""` until open / if none). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../src/channel.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../src/channel.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C;;;;;GAKG;AAEH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACxB,OAAO,EAAE;QAAE,IAAI,EAAE,OAAO,CAAA;KAAE,CAAC;CAC5B;AACD,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC;IAC1C,KAAK,IAAI,IAAI,CAAC;IACd,gBAAgB,CAAC,CAAC,SAAS,MAAM,eAAe,EAAE,IAAI,EAAE,CAAC,EACvD,QAAQ,EAAE,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,OAAO,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;CACtF;AACD,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,GAAG,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,aAAa,CAAC;CACjE,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,qBAAa,WAAY,YAAW,SAAS;;IAW3C,YAAY,EAAE,EAAE,aAAa,EAgC5B;IAED,qEAAqE;IACrE,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CAEzB;IAED,uEAAuE;IACvE,IAAI,QAAQ,IAAI,MAAM,CAErB;IAyBD,IAAI,IAAI,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAKjC;IAEK,KAAK,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAe3C;IAED,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAcrB;CACF"}
|
|
@@ -40,7 +40,7 @@ export class WsIoChannel {
|
|
|
40
40
|
// ArrayBuffer (not Blob); safe to set synchronously right after construction.
|
|
41
41
|
ws.binaryType = "arraybuffer";
|
|
42
42
|
this.#ready = new Promise((resolve, reject) => {
|
|
43
|
-
if (ws.readyState ===
|
|
43
|
+
if (ws.readyState === 1) {
|
|
44
44
|
resolve();
|
|
45
45
|
return;
|
|
46
46
|
}
|
|
@@ -103,7 +103,7 @@ export class WsIoChannel {
|
|
|
103
103
|
}
|
|
104
104
|
async write(data) {
|
|
105
105
|
await this.#ready;
|
|
106
|
-
if (this.#closed || this.#ws.readyState !==
|
|
106
|
+
if (this.#closed || this.#ws.readyState !== 1) {
|
|
107
107
|
// Fail loud: a silently-dropped write would strand a protocol frame and
|
|
108
108
|
// deadlock the notary (it never replies) — the exact hazard the io.rs
|
|
109
109
|
// write-completion fix guards against on the Rust side.
|
|
@@ -118,7 +118,7 @@ export class WsIoChannel {
|
|
|
118
118
|
this.#ws.send(data.slice());
|
|
119
119
|
}
|
|
120
120
|
close() {
|
|
121
|
-
if (this.#closed || this.#ws.readyState ===
|
|
121
|
+
if (this.#closed || this.#ws.readyState === 3) {
|
|
122
122
|
this.#onEof();
|
|
123
123
|
return Promise.resolve();
|
|
124
124
|
}
|