@derec-alliance/nodejs 0.0.1-alpha.9 → 0.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/README.md CHANGED
@@ -224,9 +224,8 @@ The orchestrator handles the whole chain automatically:
224
224
  keys published by the peer do not match the commitment the scanner
225
225
  originally accepted.
226
226
 
227
- End-to-end orchestrator-level coverage is in
228
- `bindings/nodejs/protocol.ts::runHashedKeysPairingFlow` (happy path +
229
- tampered-hash assertion).
227
+ This flow is covered end to end — happy path and tampered-hash — for every
228
+ SDK. See [End-to-end test coverage](https://github.com/derecalliance/lib-derec#end-to-end-test-coverage).
230
229
 
231
230
  ---
232
231
 
@@ -430,8 +429,8 @@ typed `ReplicaSecretReceived` event:
430
429
  `secret` + `shares` give the Destination everything it needs to act in the
431
430
  Source's place during recovery.
432
431
 
433
- End-to-end coverage lives in
434
- [`runReplicaPairingAndSecretSyncFlow`](../../bindings/nodejs/protocol.ts).
432
+ End-to-end coverage lives in the repository's tests — see
433
+ [End-to-end test coverage](https://github.com/derecalliance/lib-derec#end-to-end-test-coverage).
435
434
 
436
435
  ---
437
436
 
@@ -88,22 +88,49 @@ export class DeRecProtocolBuilder {
88
88
  */
89
89
  withThreshold(threshold: number): DeRecProtocolBuilder;
90
90
  /**
91
- * Protocol-wide staleness boundary (seconds). Clamped to at least
92
- * 1. Default: 300.
91
+ * Configure the four waiting periods in one call.
92
+ *
93
+ * Object shape — every field optional, and **absent means "keep the
94
+ * library default"**:
95
+ *
96
+ * ```text
97
+ * {
98
+ * inbound_message_secs?: number, // staleness / replay window
99
+ * sharing_round_secs?: number,
100
+ * unpair_ack_secs?: number,
101
+ * expired_channels?: { enabled: boolean, timeout_in_secs: number },
102
+ * }
103
+ * ```
104
+ *
105
+ * Values are forwarded verbatim; clamping and the meaning of a disabled
106
+ * `expired_channels` are library decisions, not this shim's. Not calling
107
+ * this leaves every default in force.
93
108
  */
94
- withTimeout(timeout_in_secs: number): DeRecProtocolBuilder;
109
+ withTimeouts(timeouts: any): DeRecProtocolBuilder;
95
110
  withTransport(transport: any): DeRecProtocolBuilder;
96
111
  /**
97
112
  * `ack` is `"required"` (default) or `"not_required"`.
98
113
  */
99
114
  withUnpairAck(ack: string): DeRecProtocolBuilder;
115
+ /**
116
+ * Accept plaintext `http://` transport endpoints. **Development only.**
117
+ * Default `false`.
118
+ *
119
+ * With it `false`, plaintext is accepted only for an endpoint this
120
+ * device configured for *itself* that names loopback (`localhost`,
121
+ * `127.0.0.1`, `::1`) — so a local dev server needs no configuration.
122
+ * With it `true`, plaintext is accepted for any host on any path,
123
+ * including endpoints a peer supplies. That is what makes the LAN case
124
+ * work (a phone against a laptop), and why the name is blunt.
125
+ */
126
+ withUnsafeHttp(allow: boolean): DeRecProtocolBuilder;
100
127
  withUserSecretStore(store: any): DeRecProtocolBuilder;
101
128
  }
102
129
 
103
130
  /**
104
131
  * Higher-level DeRec protocol orchestrator for TypeScript/JavaScript consumers.
105
132
  *
106
- * Wraps [`DeRecProtocol`](crate::protocol::DeRecProtocol) with JS-side store
133
+ * Wraps [`crate::protocol::DeRecProtocol`] with JS-side store
107
134
  * and transport adapters so that a TypeScript application can drive all five
108
135
  * protocol flows without routing raw bytes manually.
109
136
  *
@@ -125,7 +152,7 @@ export class DeRecProtocolBuilder {
125
152
  * | `ShareConfirmed` | `channel_id: string`, `version: number` |
126
153
  * | `ShareVerified` | `channel_id: string`, `version: number` |
127
154
  * | `SecretsDiscovered`| `channel_id: string`, `secrets: SecretVersionEntry[]` |
128
- * | `SecretRecovered` | `secret: { helpers, secrets, replicas, owner_replica_id }` (same nested shape as `ReplicaSecretReceived.secret`) |
155
+ * | `SecretRecovered` | `secret: { helpers, secrets, replicas }` (same nested shape as `ReplicaSecretReceived.secret`) |
129
156
  * | `NoOp` | _(none)_ |
130
157
  *
131
158
  * `SecretVersionEntry = { secret_id: bigint, versions: { version: number, description: string }[] }`
@@ -170,7 +197,8 @@ export class DeRecProtocolWasm {
170
197
  * Feed any incoming wire bytes to the protocol.
171
198
  *
172
199
  * Returns an `Array` of plain JS event objects (see struct-level docs for shapes).
173
- * All five flows (pairing, sharing, verification, discovery, recovery) are
200
+ * Every inbound flow — pairing, sharing, verification, discovery,
201
+ * recovery, unpairing, channel-info updates and the replica flows — is
174
202
  * handled through this single entry point.
175
203
  *
176
204
  * # Arguments
@@ -188,6 +216,20 @@ export class DeRecProtocolWasm {
188
216
  * * `memo` — Human-readable rejection reason.
189
217
  */
190
218
  reject(action_bytes: Uint8Array, status: number, memo: string): Promise<void>;
219
+ /**
220
+ * Remove `Pending` channels older than `older_than_secs`, along with
221
+ * their pairing keys.
222
+ *
223
+ * Independent of the configured cleanup policy — it sweeps at the
224
+ * threshold given, even when the policy is disabled. The age
225
+ * comparison is strict, so a channel created within the current
226
+ * second survives even `0`.
227
+ *
228
+ * # Returns
229
+ *
230
+ * An `Array` of removed channel ids as decimal strings.
231
+ */
232
+ removeExpiredChannels(older_than_secs: number): Promise<any>;
191
233
  /**
192
234
  * Rebuild this protocol's `secret_id` namespace from a recovered
193
235
  * `Secret`. Mirrors [`crate::protocol::DeRecProtocol::restore`] —
@@ -259,6 +301,18 @@ export class DeRecProtocolWasm {
259
301
  * dispatched requests. Same shape as `process()`.
260
302
  */
261
303
  start(flow_kind: number, params: any): Promise<any>;
304
+ /**
305
+ * Advance time-driven state without an inbound message.
306
+ *
307
+ * Timeouts are otherwise only evaluated by `process`, so a publish whose
308
+ * helpers all go quiet has nothing left to close it. Call this from a
309
+ * timer — `setInterval`, a service-worker alarm, a job runner — at an
310
+ * interval shorter than the configured timeout.
311
+ *
312
+ * Returns an `Array` of plain JS event objects, empty when nothing was
313
+ * in flight. Safe to call at any time.
314
+ */
315
+ tick(): Promise<any>;
262
316
  /**
263
317
  * Verify a fingerprint against the channel's locally-derived one. On
264
318
  * match, the channel transitions from `Pending` to `Paired`. Returns
@@ -369,7 +423,7 @@ export function recovery_response_recover(secret_id: bigint, version: number, re
369
423
 
370
424
  export function sharing_request_extract(envelope_bytes: Uint8Array, shared_key: Uint8Array): any;
371
425
 
372
- export function sharing_request_produce(channel_id: bigint, version: number, secret_id: bigint, committed_share: any, keep_list: any, description: string, shared_key: Uint8Array, reply_to: any, replica_id: any): any;
426
+ export function sharing_request_produce(channel_id: bigint, version: number, secret_id: bigint, committed_share: any, keep_list: any, description: string, shared_key: Uint8Array, reply_to: any): any;
373
427
 
374
428
  export function sharing_request_split(channels: any, secret_id: bigint, version: number, secret_data: Uint8Array, threshold: number): any;
375
429