@derec-alliance/nodejs 0.0.4 → 0.0.6
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 +31 -11
- package/derec_descriptor.bin +0 -0
- package/derec_library.d.ts +112 -118
- package/derec_library.js +173 -160
- package/derec_library_bg.wasm +0 -0
- package/derec_library_bg.wasm.d.ts +33 -32
- package/index.d.ts +383 -164
- package/index.js +33 -3
- package/package.json +1 -1
- package/proto/contact.proto +15 -48
- package/proto/getshare.proto +4 -14
- package/proto/pair.proto +5 -29
- package/proto/prepair.proto +14 -39
- package/proto/secretidsversions.proto +4 -14
- package/proto/storeshare.proto +8 -39
- package/proto/unpair.proto +4 -14
- package/proto/updatechannelinfo.proto +16 -45
- package/proto/verify.proto +4 -14
package/README.md
CHANGED
|
@@ -126,7 +126,7 @@ const request = primitives.pairing.request.produce(
|
|
|
126
126
|
|
|
127
127
|
// Step 3: Initiator extracts the request and produces the response.
|
|
128
128
|
const { request: pairRequest } =
|
|
129
|
-
primitives.pairing.request.extract(request.envelope, contact.secret_key);
|
|
129
|
+
primitives.pairing.request.extract(request.envelope, contact.secret_key, null);
|
|
130
130
|
const produced = primitives.pairing.response.produce(
|
|
131
131
|
channelId,
|
|
132
132
|
pairRequest,
|
|
@@ -141,6 +141,7 @@ const processed = primitives.pairing.response.process(
|
|
|
141
141
|
request.initiator_contact_message,
|
|
142
142
|
pairResponse,
|
|
143
143
|
request.secret_key,
|
|
144
|
+
null,
|
|
144
145
|
);
|
|
145
146
|
|
|
146
147
|
// Both sides hold the same shared key and rekeyed channel id.
|
|
@@ -227,7 +228,7 @@ The orchestrator handles the whole chain automatically:
|
|
|
227
228
|
`ActionRequired` event with `action_kind: "PrePair"`. Call
|
|
228
229
|
`protocol.accept(action)` to publish the keys (the library builds the
|
|
229
230
|
response and routes it), or `protocol.reject(action, status, memo)` to
|
|
230
|
-
refuse.
|
|
231
|
+
refuse — `status` is a `StatusEnum` value such as `StatusEnum.Rejected`.
|
|
231
232
|
- **Scanner** — `protocol.start(FlowKind.Pairing, { kind, contact })` kicks
|
|
232
233
|
off the plaintext PrePair leg. `start()` returns a `DeRecEvent[]`
|
|
233
234
|
containing one `PairingStarted { channel_id, kind }` event that
|
|
@@ -322,6 +323,9 @@ to `protocol.restore(secret, version)` on a fresh `DeRecProtocol` instance to
|
|
|
322
323
|
commit canonical helper / replica state and wipe the throwaway recovery-mode
|
|
323
324
|
channels — at that point the device resumes normal operation as if the secret
|
|
324
325
|
had been protected here originally.
|
|
326
|
+
A helper or member with no endpoint in the recovered roster gets no channel;
|
|
327
|
+
`restore` returns a `PeerNotRestored` event for it (`reason: "NoTransports"`)
|
|
328
|
+
and restores the rest.
|
|
325
329
|
|
|
326
330
|
```ts
|
|
327
331
|
const events = await protocol.process(responseBytes);
|
|
@@ -332,8 +336,10 @@ for (const ev of events) {
|
|
|
332
336
|
}
|
|
333
337
|
```
|
|
334
338
|
|
|
335
|
-
Errors surface as
|
|
336
|
-
`
|
|
339
|
+
Errors surface as a `DeRecError` with a `category` and `code` —
|
|
340
|
+
`already_restored`, `restore_conflict` (with `channel_ids`), `invariant`,
|
|
341
|
+
`invalid_recovered_secret` (a malformed `secret`), or `store_error` (a store call failed; `category`
|
|
342
|
+
names the store).
|
|
337
343
|
|
|
338
344
|
> **Secret format:** the recoverable secret (the bytes helpers store and
|
|
339
345
|
> recovery reconstructs) is `[version byte] · payload` — v1's payload is
|
|
@@ -380,6 +386,12 @@ console.log("Valid:", isValid);
|
|
|
380
386
|
- No protobuf types are exposed
|
|
381
387
|
- No cryptographic operations occur in JavaScript
|
|
382
388
|
- Rust is the single source of truth
|
|
389
|
+
- Every `DeRecProtocol` method that touches protocol state returns a
|
|
390
|
+
`Promise`, including the `set*` setters. Overlapping calls on one
|
|
391
|
+
instance — a `tick()` timer firing while `process()` handles a message —
|
|
392
|
+
queue and run in the order they were made; they never collide. A store
|
|
393
|
+
or transport callback must not await a call on the instance that
|
|
394
|
+
invoked it, since that call waits behind the callback's own caller.
|
|
383
395
|
|
|
384
396
|
---
|
|
385
397
|
|
|
@@ -461,13 +473,13 @@ Two cross-cutting metadata fields appear on every channel-mode exchange:
|
|
|
461
473
|
end-to-end (random token on every outbound request, echo on every
|
|
462
474
|
response). Primitive-only callers can manipulate it directly via
|
|
463
475
|
`envelope.apply_trace_id(bytes, traceId)` and `envelope.read_trace_id(bytes)`.
|
|
464
|
-
- **`replyTo`** — optional `TransportProtocol` on request bodies, telling
|
|
465
|
-
the responder to route this exchange's response to
|
|
476
|
+
- **`replyTo`** — optional `TransportProtocol` list on request bodies, telling
|
|
477
|
+
the responder to route this exchange's response to alternate endpoints.
|
|
466
478
|
Set it per call (every `primitives.*.request.produce` takes a trailing
|
|
467
479
|
`reply_to` arg) or protocol-wide with the `autoReplyTo` constructor flag
|
|
468
|
-
on `DeRecProtocol` (stamps
|
|
469
|
-
request). Excludes pairing and `UpdateChannelInfo`, which
|
|
470
|
-
their own `
|
|
480
|
+
on `DeRecProtocol` (stamps this node's own transports into `replyTo` on
|
|
481
|
+
every outbound request). Excludes pairing and `UpdateChannelInfo`, which
|
|
482
|
+
already carry their own `supportedTransports` field.
|
|
471
483
|
|
|
472
484
|
The motivating case for `replyTo` is replicas: when Replica A sends a
|
|
473
485
|
request on a channel the helper paired with sibling Replica B, the
|
|
@@ -554,8 +566,7 @@ that you can retire as soon as the PrePair leg completes.
|
|
|
554
566
|
|
|
555
567
|
The recommended pattern is: pair on the ephemeral URI, then — as soon
|
|
556
568
|
as the pairing completes on the contact creator side — call
|
|
557
|
-
`setOwnTransports` with the permanent endpoint
|
|
558
|
-
deprecated and removed at 0.0.5) and start an
|
|
569
|
+
`setOwnTransports` with the permanent endpoint and start an
|
|
559
570
|
`UpdateChannelInfo` flow against the peer to announce the swap. Once
|
|
560
571
|
the peer acknowledges, retire the ephemeral URI. This keeps the
|
|
561
572
|
plaintext PrePair window tight while letting subsequent traffic ride
|
|
@@ -571,6 +582,15 @@ target is still `Pending`. Treat verification as a required step in
|
|
|
571
582
|
the pairing UX — a scanner that auto-pairs without it accepts a
|
|
572
583
|
MITM-vulnerable replica.
|
|
573
584
|
|
|
585
|
+
Until a device confirms, it ignores everything the peer sends on that
|
|
586
|
+
channel: `process` changes no store, sends nothing back, and returns
|
|
587
|
+
`{ type: "MessageIgnored", channel_id, reason: "PendingVerification",
|
|
588
|
+
trace_id }`. This matters most for a replica destination. The source's own
|
|
589
|
+
confirmation publishes the vault immediately, so that copy usually arrives
|
|
590
|
+
before the destination's user has confirmed. Confirming does not replay it:
|
|
591
|
+
once the destination's `verifyFingerprint` resolves `true`, call
|
|
592
|
+
`start(FlowKind.ReplicaDiscovery)` to pull the copy from the source.
|
|
593
|
+
|
|
574
594
|
### The `derec.*` namespace in `communicationInfo` is library-owned
|
|
575
595
|
|
|
576
596
|
`communicationInfo` is otherwise an opaque app-defined map, but every
|
package/derec_descriptor.bin
CHANGED
|
Binary file
|
package/derec_library.d.ts
CHANGED
|
@@ -9,11 +9,12 @@
|
|
|
9
9
|
* docs.
|
|
10
10
|
*
|
|
11
11
|
* Required setters: `withChannelStore`, `withShareStore`,
|
|
12
|
-
* `withSecretStore`, `
|
|
13
|
-
* `withOwnTransports`. Calling `build()` without all
|
|
12
|
+
* `withSecretStore`, `withUserSecretStore`, `withStateStore`,
|
|
13
|
+
* `withTransport`, and `withOwnTransports`. Calling `build()` without all
|
|
14
|
+
* seven throws.
|
|
14
15
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
16
|
+
* An optional setter that is never called leaves the Rust builder's default
|
|
17
|
+
* in force: the value is forwarded only when the application supplied one.
|
|
17
18
|
*/
|
|
18
19
|
export class DeRecProtocolBuilder {
|
|
19
20
|
free(): void;
|
|
@@ -43,7 +44,7 @@ export class DeRecProtocolBuilder {
|
|
|
43
44
|
*/
|
|
44
45
|
withAutoAccept(policy: any): DeRecProtocolBuilder;
|
|
45
46
|
/**
|
|
46
|
-
* Whether outbound requests
|
|
47
|
+
* Whether outbound requests carry this node's own transports as their reply-to list.
|
|
47
48
|
* Default: false.
|
|
48
49
|
*/
|
|
49
50
|
withAutoReplyTo(enabled: boolean): DeRecProtocolBuilder;
|
|
@@ -58,33 +59,21 @@ export class DeRecProtocolBuilder {
|
|
|
58
59
|
*/
|
|
59
60
|
withCommunicationInfo(info: any): DeRecProtocolBuilder;
|
|
60
61
|
/**
|
|
61
|
-
* Number of recent versions each helper must retain.
|
|
62
|
+
* Number of recent versions each helper must retain.
|
|
63
|
+
* Default: [`crate::protocol::DEFAULT_KEEP_VERSIONS_COUNT`].
|
|
62
64
|
*/
|
|
63
65
|
withKeepVersionsCount(count: number): DeRecProtocolBuilder;
|
|
64
|
-
/**
|
|
65
|
-
* `endpoint` shape: `{ uri: string, protocol: string }`.
|
|
66
|
-
* `protocol` is `"https"` or `"grpc"` (case-insensitive).
|
|
67
|
-
*
|
|
68
|
-
* @deprecated Use `withOwnTransports`, which takes the whole preference
|
|
69
|
-
* list — `withOwnTransports([endpoint])` is the direct replacement.
|
|
70
|
-
* Removed at 0.0.5.
|
|
71
|
-
*/
|
|
72
|
-
withOwnTransport(endpoint: any): DeRecProtocolBuilder;
|
|
73
66
|
/**
|
|
74
67
|
* Every transport endpoint this application serves, in preference
|
|
75
68
|
* order. `transports` is an array of `{ uri: string, protocol: string
|
|
76
69
|
* }` objects, `protocol` being `"https"` or `"grpc"`
|
|
77
|
-
* (case-insensitive)
|
|
70
|
+
* (case-insensitive).
|
|
78
71
|
*
|
|
79
72
|
* The order is the application's own preference and decides which of
|
|
80
73
|
* a peer's offered endpoints is used. Every listed transport must
|
|
81
74
|
* actually be served, because delivery is push-only — listing an
|
|
82
75
|
* endpoint this application does not serve makes pairing succeed and
|
|
83
76
|
* replies vanish.
|
|
84
|
-
*
|
|
85
|
-
* Supersedes [`Self::with_own_transport`] for applications serving
|
|
86
|
-
* more than one transport; the single-endpoint setter remains fully
|
|
87
|
-
* supported.
|
|
88
77
|
*/
|
|
89
78
|
withOwnTransports(transports: any[]): DeRecProtocolBuilder;
|
|
90
79
|
/**
|
|
@@ -108,7 +97,7 @@ export class DeRecProtocolBuilder {
|
|
|
108
97
|
withStateStore(store: any): DeRecProtocolBuilder;
|
|
109
98
|
/**
|
|
110
99
|
* Minimum number of shares required to reconstruct the secret.
|
|
111
|
-
* Default:
|
|
100
|
+
* Default: [`crate::protocol::DEFAULT_THRESHOLD`].
|
|
112
101
|
*/
|
|
113
102
|
withThreshold(threshold: number): DeRecProtocolBuilder;
|
|
114
103
|
/**
|
|
@@ -133,18 +122,13 @@ export class DeRecProtocolBuilder {
|
|
|
133
122
|
withTimeouts(timeouts: any): DeRecProtocolBuilder;
|
|
134
123
|
withTransport(transport: any): DeRecProtocolBuilder;
|
|
135
124
|
/**
|
|
136
|
-
* `ack` is `"required"` (default) or `"not_required"
|
|
125
|
+
* `ack` is exactly `"required"` (default) or `"not_required"`, naming
|
|
126
|
+
* [`UnpairAck::Required`] and [`UnpairAck::NotRequired`].
|
|
137
127
|
*/
|
|
138
128
|
withUnpairAck(ack: string): DeRecProtocolBuilder;
|
|
139
129
|
/**
|
|
140
130
|
* Accept plaintext transport endpoints — `http://` and `grpc://`.
|
|
141
|
-
* **Development only.** Default `false`.
|
|
142
|
-
* conflict rule when both are set.
|
|
143
|
-
*/
|
|
144
|
-
withUnsafeConnection(allow: boolean): DeRecProtocolBuilder;
|
|
145
|
-
/**
|
|
146
|
-
* Accept plaintext `http://` transport endpoints. **Development only.**
|
|
147
|
-
* Default `false`.
|
|
131
|
+
* **Development only.** Default `false`.
|
|
148
132
|
*
|
|
149
133
|
* With it `false`, plaintext is accepted only for an endpoint this
|
|
150
134
|
* device configured for *itself* that names loopback (`localhost`,
|
|
@@ -152,11 +136,8 @@ export class DeRecProtocolBuilder {
|
|
|
152
136
|
* With it `true`, plaintext is accepted for any host on any path,
|
|
153
137
|
* including endpoints a peer supplies. That is what makes the LAN case
|
|
154
138
|
* work (a phone against a laptop), and why the name is blunt.
|
|
155
|
-
*
|
|
156
|
-
* Superseded by `withUnsafeConnection`; still honored, and wins on
|
|
157
|
-
* conflict. Removed at 0.0.5.
|
|
158
139
|
*/
|
|
159
|
-
|
|
140
|
+
withUnsafeConnection(allow: boolean): DeRecProtocolBuilder;
|
|
160
141
|
withUserSecretStore(store: any): DeRecProtocolBuilder;
|
|
161
142
|
}
|
|
162
143
|
|
|
@@ -164,31 +145,46 @@ export class DeRecProtocolBuilder {
|
|
|
164
145
|
* Higher-level DeRec protocol orchestrator for TypeScript/JavaScript consumers.
|
|
165
146
|
*
|
|
166
147
|
* Wraps [`crate::protocol::DeRecProtocol`] with JS-side store
|
|
167
|
-
* and transport adapters so that a TypeScript application can drive
|
|
168
|
-
* protocol
|
|
148
|
+
* and transport adapters so that a TypeScript application can drive every
|
|
149
|
+
* protocol flow without routing raw bytes manually. Built with
|
|
150
|
+
* [`DeRecProtocolBuilderWasm`] (`DeRecProtocolBuilder` in JS).
|
|
169
151
|
*
|
|
170
152
|
* # Stores
|
|
171
153
|
*
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
*
|
|
154
|
+
* The five stores and the transport are JS objects implementing the
|
|
155
|
+
* `ChannelStore`, `ShareStore`, `SecretStore`, `UserSecretStore`,
|
|
156
|
+
* `StateStore` and `Transport` interfaces in `index.d.ts`. All their methods
|
|
157
|
+
* must return `Promise`s — synchronous implementations can wrap their result
|
|
158
|
+
* with `Promise.resolve(...)`.
|
|
175
159
|
*
|
|
176
|
-
* #
|
|
160
|
+
* # Concurrency
|
|
161
|
+
*
|
|
162
|
+
* Every method that touches protocol state is `async` and runs under one
|
|
163
|
+
* lock per instance, so overlapping calls on the same instance — a
|
|
164
|
+
* `tick` timer firing while `process` handles an inbound message — queue
|
|
165
|
+
* and run one at a time, in the order they were made. Distinct instances
|
|
166
|
+
* do not share the lock: two instances bound to the same `secret_id` and
|
|
167
|
+
* the same stores must still be serialized by the caller.
|
|
177
168
|
*
|
|
178
|
-
*
|
|
179
|
-
*
|
|
169
|
+
* A store or transport callback must not await a call on the instance
|
|
170
|
+
* that invoked it: that call queues behind the one waiting on the
|
|
171
|
+
* callback, and neither settles. Calling `free()` while a call is in
|
|
172
|
+
* flight throws.
|
|
180
173
|
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
*
|
|
187
|
-
* | `SecretsDiscovered`| `channel_id: string`, `secrets: SecretVersionEntry[]` |
|
|
188
|
-
* | `SecretRecovered` | `secret: { helpers, secrets, replicas }` (same nested shape as `ReplicaSecretReceived.secret`) |
|
|
189
|
-
* | `NoOp` | _(none)_ |
|
|
174
|
+
* Methods take `&self` for this reason: wasm-bindgen holds the borrow of
|
|
175
|
+
* the instance for an async call's whole lifetime, so under `&mut self` an
|
|
176
|
+
* overlapping call fails that borrow outside its promise and never
|
|
177
|
+
* settles.
|
|
178
|
+
*
|
|
179
|
+
* # Events
|
|
190
180
|
*
|
|
191
|
-
* `
|
|
181
|
+
* [`process`](DeRecProtocolWasm::process), [`start`](DeRecProtocolWasm::start),
|
|
182
|
+
* [`accept`](DeRecProtocolWasm::accept), [`tick`](DeRecProtocolWasm::tick)
|
|
183
|
+
* and [`restore`](DeRecProtocolWasm::restore) return an `Array` of plain JS
|
|
184
|
+
* objects, one per [`crate::protocol::DeRecEvent`], each tagged by a `type`
|
|
185
|
+
* field naming the variant. Every `u64` identifier (`channel_id`,
|
|
186
|
+
* `secret_id`, `replica_id`, `trace_id`) is a decimal string. The full set of
|
|
187
|
+
* shapes is the `DeRecEvent` union in `index.d.ts`.
|
|
192
188
|
*/
|
|
193
189
|
export class DeRecProtocolWasm {
|
|
194
190
|
private constructor();
|
|
@@ -261,46 +257,36 @@ export class DeRecProtocolWasm {
|
|
|
261
257
|
* # Returns
|
|
262
258
|
*
|
|
263
259
|
* An `Array` of removed channel ids as decimal strings.
|
|
260
|
+
*
|
|
261
|
+
* `older_than_secs` is a `u64`: a `bigint`, a non-negative safe-integer
|
|
262
|
+
* `number`, or a decimal string.
|
|
264
263
|
*/
|
|
265
|
-
removeExpiredChannels(older_than_secs:
|
|
264
|
+
removeExpiredChannels(older_than_secs: any): Promise<any>;
|
|
266
265
|
/**
|
|
267
266
|
* Rebuild this protocol's `secret_id` namespace from a recovered
|
|
268
267
|
* `Secret`. Mirrors [`crate::protocol::DeRecProtocol::restore`] —
|
|
269
268
|
* see that method for the full contract.
|
|
270
269
|
*
|
|
271
270
|
* `recoveredSecret` is the typed `Secret` object carried by the
|
|
272
|
-
* `SecretRecovered` event; pass it verbatim.
|
|
271
|
+
* `SecretRecovered` event; pass it verbatim. A helper or member whose
|
|
272
|
+
* `transports` is empty, `null` or absent gets no channel; it is
|
|
273
|
+
* reported as a `PeerNotRestored` event in the returned array and the
|
|
274
|
+
* rest of the roster is restored.
|
|
273
275
|
*
|
|
274
|
-
* Errors surface as
|
|
276
|
+
* Errors surface as a `DeRecError` (`category`, `code`, `message`):
|
|
275
277
|
*
|
|
276
278
|
* | code | meaning |
|
|
277
279
|
* |--------------------|------------------------------------------------------------------|
|
|
278
|
-
* | `
|
|
279
|
-
* | `
|
|
280
|
+
* | `already_restored` | A user-secret snapshot already exists for this `secret_id`. |
|
|
281
|
+
* | `restore_conflict` | Channels live at ids restore is about to write. The error |
|
|
280
282
|
* | | carries `channel_ids: string[]` listing the collisions. |
|
|
281
|
-
* | `
|
|
282
|
-
* | `
|
|
283
|
+
* | `invariant` | The recovered `Secret` is internally inconsistent. |
|
|
284
|
+
* | `invalid_recovered_secret` | `recoveredSecret` is malformed — e.g. a missing or |
|
|
285
|
+
* | | non-decimal `channel_id` / `replica_id`. |
|
|
286
|
+
* | `store_error` | A store call failed mid-restore; `category` names the store. |
|
|
283
287
|
*/
|
|
284
288
|
restore(recovered_secret: any, version: number): Promise<any>;
|
|
285
289
|
/**
|
|
286
|
-
* Generate an out-of-band contact message (QR code payload, deep link, …).
|
|
287
|
-
*
|
|
288
|
-
* Returns a plain JS `ContactMessage` object. The `channel_id` field identifies
|
|
289
|
-
* the pairing session and will match the `channel_id` in the eventual
|
|
290
|
-
* `PairingCompleted` event — read it directly from the returned object.
|
|
291
|
-
*
|
|
292
|
-
* The caller is responsible for serializing the contact for out-of-band
|
|
293
|
-
* delivery (QR code, deep link, etc.). The peer passes the deserialized object
|
|
294
|
-
* to [`start`](Self::start) with `FlowKind::Pairing`.
|
|
295
|
-
*
|
|
296
|
-
* # Arguments
|
|
297
|
-
*
|
|
298
|
-
* * `channel_id` — Optional `BigInt` channel identifier. Pass `null` or
|
|
299
|
-
* `undefined` to have the library generate a random one.
|
|
300
|
-
* * `contact_mode` — `0` for `InlineKeys` (keys embedded directly), `1`
|
|
301
|
-
* for `HashedKeys` (contact carries only a SHA-384 binding hash; the
|
|
302
|
-
* scanner fetches keys via a `PrePair` round-trip). `HashedKeys`
|
|
303
|
-
* requires the protocol's `own_transport` to be ephemeral.
|
|
304
290
|
* The secret identifier this protocol instance is bound to.
|
|
305
291
|
*/
|
|
306
292
|
secretId(): bigint;
|
|
@@ -308,32 +294,13 @@ export class DeRecProtocolWasm {
|
|
|
308
294
|
* Replace this node's local communication info. Does not contact peers —
|
|
309
295
|
* follow up with a `start(UpdateChannelInfo, ...)` to propagate.
|
|
310
296
|
*/
|
|
311
|
-
setCommunicationInfo(info: any): void
|
|
312
|
-
/**
|
|
313
|
-
* Replace this node's endpoint for one protocol, leaving the others
|
|
314
|
-
* alone. A node serves at most one endpoint per protocol, so the
|
|
315
|
-
* `(uri, protocol)` pair identifies the entry it replaces; an entry for
|
|
316
|
-
* a protocol not yet served is appended, and a replaced one keeps its
|
|
317
|
-
* position in the preference order.
|
|
318
|
-
*
|
|
319
|
-
* @deprecated Use `setOwnTransports`, which takes the whole preference
|
|
320
|
-
* list and is the only way to change which protocols this node serves,
|
|
321
|
-
* or their order. Removed at 0.0.5.
|
|
322
|
-
*
|
|
323
|
-
* See `setCommunicationInfo` for the matching update-propagation
|
|
324
|
-
* flow, and `setOwnTransports` to keep more than one endpoint.
|
|
325
|
-
* IMPORTANT: keep the old endpoint operational during the changeover —
|
|
326
|
-
* see the Rust docs on `set_own_transport` for the discipline.
|
|
327
|
-
*/
|
|
328
|
-
setOwnTransport(uri: string, protocol: string): void;
|
|
297
|
+
setCommunicationInfo(info: any): Promise<void>;
|
|
329
298
|
/**
|
|
330
299
|
* Replace every endpoint this node advertises, in preference order.
|
|
331
300
|
*
|
|
332
301
|
* `transports` is an array of `{ uri: string, protocol: string }`
|
|
333
|
-
* objects, same shape as `withOwnTransports
|
|
334
|
-
*
|
|
335
|
-
* `setOwnTransport` replaces only the entry for the protocol its URI
|
|
336
|
-
* names. A node serves at most one endpoint per protocol, so this list
|
|
302
|
+
* objects, same shape as `withOwnTransports`, and is its runtime
|
|
303
|
+
* counterpart. A node serves at most one endpoint per protocol, so this list
|
|
337
304
|
* is a preference order over distinct protocols and two entries of the
|
|
338
305
|
* same protocol are rejected.
|
|
339
306
|
*
|
|
@@ -342,18 +309,17 @@ export class DeRecProtocolWasm {
|
|
|
342
309
|
* operational during the changeover — see the Rust docs on
|
|
343
310
|
* `set_own_transports` for the discipline.
|
|
344
311
|
*/
|
|
345
|
-
setOwnTransports(transports: any[]): void
|
|
312
|
+
setOwnTransports(transports: any[]): Promise<void>;
|
|
346
313
|
/**
|
|
347
314
|
* Unified entry point for initiating any protocol flow.
|
|
348
315
|
*
|
|
349
316
|
* # Arguments
|
|
350
317
|
*
|
|
351
|
-
* * `flow_kind` —
|
|
352
|
-
*
|
|
353
|
-
*
|
|
354
|
-
*
|
|
355
|
-
*
|
|
356
|
-
* - `4` = RecoverSecret (params: `{ secretId: Uint8Array, version: number }`)
|
|
318
|
+
* * `flow_kind` — `FlowKind` discriminant: `0` Pairing, `1` Discovery,
|
|
319
|
+
* `2` ProtectSecret, `3` VerifyShares, `4` RecoverSecret, `5` Unpair,
|
|
320
|
+
* `6` UpdateChannelInfo, `7` ReplicaDiscovery, `8` UnpairReplica.
|
|
321
|
+
* * `params` — the flow's parameters, declared per kind in `index.d.ts`
|
|
322
|
+
* as `PairingParams`, `DiscoveryParams`, … `UnpairReplicaParams`.
|
|
357
323
|
*
|
|
358
324
|
* # Returns
|
|
359
325
|
*
|
|
@@ -411,30 +377,33 @@ export function envelope_apply_trace_id(envelope_bytes: Uint8Array, trace_id: bi
|
|
|
411
377
|
export function envelope_read_trace_id(envelope_bytes: Uint8Array): bigint;
|
|
412
378
|
|
|
413
379
|
/**
|
|
414
|
-
*
|
|
415
|
-
*
|
|
416
|
-
*
|
|
380
|
+
* A fresh replica identity. See [`crate::generate_replica_id`]: the caller
|
|
381
|
+
* persists it once per device and passes the same value on every protocol
|
|
382
|
+
* init. Never `0`.
|
|
417
383
|
*/
|
|
418
|
-
export function
|
|
384
|
+
export function generate_replica_id(): bigint;
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* The human-readable fingerprint of a pairing's shared key. Both ends derive
|
|
388
|
+
* the same value; comparing it out of band confirms the pairing.
|
|
389
|
+
*/
|
|
390
|
+
export function pairing_fingerprint(shared_key: Uint8Array): string;
|
|
419
391
|
|
|
420
392
|
export function pairing_request_create_contact(channel_id: bigint, contact_mode: number, transport_protocols: any, nonce: any): any;
|
|
421
393
|
|
|
422
394
|
/**
|
|
423
|
-
* Decodes
|
|
424
|
-
*
|
|
425
|
-
* trust the mode/field invariants documented on the wire format.
|
|
395
|
+
* Decodes proto `ContactMessage` wire bytes. See
|
|
396
|
+
* [`crate::primitives::pairing::request::decode_contact`].
|
|
426
397
|
*/
|
|
427
398
|
export function pairing_request_decode_contact(bytes: Uint8Array): any;
|
|
428
399
|
|
|
429
400
|
/**
|
|
430
|
-
* Encodes a [`ContactMessage`] to proto wire bytes.
|
|
431
|
-
*
|
|
432
|
-
* mode/field invariant is rejected at the boundary rather than silently
|
|
433
|
-
* serialized.
|
|
401
|
+
* Encodes a [`ContactMessage`] to proto wire bytes. See
|
|
402
|
+
* [`crate::primitives::pairing::request::encode_contact`].
|
|
434
403
|
*/
|
|
435
404
|
export function pairing_request_encode_contact(contact_message: any): Uint8Array;
|
|
436
405
|
|
|
437
|
-
export function pairing_request_extract(envelope_bytes: Uint8Array, secret_key: Uint8Array): any;
|
|
406
|
+
export function pairing_request_extract(envelope_bytes: Uint8Array, secret_key: Uint8Array, parameter_range: any): any;
|
|
438
407
|
|
|
439
408
|
/**
|
|
440
409
|
* Initiator-side: decode an inbound plaintext `PrePairRequest` envelope.
|
|
@@ -456,7 +425,7 @@ export function pairing_response_extract(envelope_bytes: Uint8Array, secret_key:
|
|
|
456
425
|
*/
|
|
457
426
|
export function pairing_response_extract_pre_pair(envelope_bytes: Uint8Array): any;
|
|
458
427
|
|
|
459
|
-
export function pairing_response_process(contact_message: any, response: any, secret_key: Uint8Array): any;
|
|
428
|
+
export function pairing_response_process(contact_message: any, response: any, secret_key: Uint8Array, parameter_range: any): any;
|
|
460
429
|
|
|
461
430
|
/**
|
|
462
431
|
* Scanner-side: validate the `PrePairResponse` against the contact's
|
|
@@ -464,6 +433,14 @@ export function pairing_response_process(contact_message: any, response: any, se
|
|
|
464
433
|
*/
|
|
465
434
|
export function pairing_response_process_pre_pair(contact_message: any, response: any): any;
|
|
466
435
|
|
|
436
|
+
/**
|
|
437
|
+
* Scanner side of a `NO_KEYS` pairing: accept the contact creator's public
|
|
438
|
+
* keys. There is no binding hash to check them against, so the channel this
|
|
439
|
+
* leads to MUST stay unusable until both sides confirm `pairing_fingerprint`
|
|
440
|
+
* out of band.
|
|
441
|
+
*/
|
|
442
|
+
export function pairing_response_process_pre_pair_no_keys(contact_message: any, response: any): any;
|
|
443
|
+
|
|
467
444
|
export function pairing_response_produce(channel_id: bigint, request: any, secret_key: Uint8Array, communication_info: any, parameter_range: any, unsafe_connection: boolean): any;
|
|
468
445
|
|
|
469
446
|
/**
|
|
@@ -471,6 +448,23 @@ export function pairing_response_produce(channel_id: bigint, request: any, secre
|
|
|
471
448
|
*/
|
|
472
449
|
export function pairing_response_produce_pre_pair(channel_id: bigint, request: any, secret_key: Uint8Array): any;
|
|
473
450
|
|
|
451
|
+
/**
|
|
452
|
+
* Contact-creator side of a `NO_KEYS` pairing: generate key material and
|
|
453
|
+
* answer the `PrePairRequest` with its public half.
|
|
454
|
+
*
|
|
455
|
+
* The caller MUST first match the request's `nonce` against the contact it
|
|
456
|
+
* issued, and MUST keep the resulting channel unusable until both sides
|
|
457
|
+
* confirm `pairing_fingerprint` out of band.
|
|
458
|
+
*/
|
|
459
|
+
export function pairing_response_produce_pre_pair_no_keys(channel_id: bigint, request: any): any;
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* The DeRec protocol version this build speaks — the `protocolVersionMajor`
|
|
463
|
+
* / `protocolVersionMinor` it writes into every envelope it produces —
|
|
464
|
+
* as `{ major, minor }`.
|
|
465
|
+
*/
|
|
466
|
+
export function protocol_version(): any;
|
|
467
|
+
|
|
474
468
|
export function recovery_request_extract(envelope_bytes: Uint8Array, shared_key: Uint8Array): any;
|
|
475
469
|
|
|
476
470
|
export function recovery_request_produce(channel_id: bigint, secret_id: bigint, version: number, shared_key: Uint8Array, reply_to: any): any;
|