@derec-alliance/nodejs 0.0.1-alpha.8 → 0.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/README.md +7 -0
- package/derec_library.d.ts +60 -6
- package/derec_library.js +177 -106
- package/derec_library_bg.wasm +0 -0
- package/derec_library_bg.wasm.d.ts +43 -40
- package/index.d.ts +361 -28
- package/index.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -318,6 +318,13 @@ for (const ev of events) {
|
|
|
318
318
|
Errors surface as objects with a `code` field — `ALREADY_RESTORED`,
|
|
319
319
|
`CONFLICT` (with `channel_ids`), `INVARIANT`, or `STORAGE`.
|
|
320
320
|
|
|
321
|
+
> **Secret format:** the recoverable secret (the bytes helpers store and
|
|
322
|
+
> recovery reconstructs) is `[version byte] · payload` — v1's payload is
|
|
323
|
+
> **gzip (RFC 1952)** compressed **JSON**, with byte fields as **standard
|
|
324
|
+
> base64 with padding (RFC 4648 §4)** and `u64` fields as decimal strings.
|
|
325
|
+
> See the `derec-library` `protocol::types::secret` reference documentation
|
|
326
|
+
> for the full field schema.
|
|
327
|
+
|
|
321
328
|
---
|
|
322
329
|
|
|
323
330
|
## Verification Flow
|
package/derec_library.d.ts
CHANGED
|
@@ -88,15 +88,42 @@ export class DeRecProtocolBuilder {
|
|
|
88
88
|
*/
|
|
89
89
|
withThreshold(threshold: number): DeRecProtocolBuilder;
|
|
90
90
|
/**
|
|
91
|
-
*
|
|
92
|
-
*
|
|
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
|
-
|
|
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
|
|
|
@@ -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
|
|
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
|
-
*
|
|
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
|
|
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
|
|