@derec-alliance/nodejs 0.0.5 → 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 +39 -38
- package/index.d.ts +372 -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/derec_library.js
CHANGED
|
@@ -8,11 +8,12 @@
|
|
|
8
8
|
* docs.
|
|
9
9
|
*
|
|
10
10
|
* Required setters: `withChannelStore`, `withShareStore`,
|
|
11
|
-
* `withSecretStore`, `
|
|
12
|
-
* `withOwnTransports`. Calling `build()` without all
|
|
11
|
+
* `withSecretStore`, `withUserSecretStore`, `withStateStore`,
|
|
12
|
+
* `withTransport`, and `withOwnTransports`. Calling `build()` without all
|
|
13
|
+
* seven throws.
|
|
13
14
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
15
|
+
* An optional setter that is never called leaves the Rust builder's default
|
|
16
|
+
* in force: the value is forwarded only when the application supplied one.
|
|
16
17
|
*/
|
|
17
18
|
class DeRecProtocolBuilder {
|
|
18
19
|
static __wrap(ptr) {
|
|
@@ -82,7 +83,7 @@ class DeRecProtocolBuilder {
|
|
|
82
83
|
return DeRecProtocolBuilder.__wrap(ret[0]);
|
|
83
84
|
}
|
|
84
85
|
/**
|
|
85
|
-
* Whether outbound requests
|
|
86
|
+
* Whether outbound requests carry this node's own transports as their reply-to list.
|
|
86
87
|
* Default: false.
|
|
87
88
|
* @param {boolean} enabled
|
|
88
89
|
* @returns {DeRecProtocolBuilder}
|
|
@@ -126,7 +127,8 @@ class DeRecProtocolBuilder {
|
|
|
126
127
|
return DeRecProtocolBuilder.__wrap(ret[0]);
|
|
127
128
|
}
|
|
128
129
|
/**
|
|
129
|
-
* Number of recent versions each helper must retain.
|
|
130
|
+
* Number of recent versions each helper must retain.
|
|
131
|
+
* Default: [`crate::protocol::DEFAULT_KEEP_VERSIONS_COUNT`].
|
|
130
132
|
* @param {number} count
|
|
131
133
|
* @returns {DeRecProtocolBuilder}
|
|
132
134
|
*/
|
|
@@ -135,39 +137,17 @@ class DeRecProtocolBuilder {
|
|
|
135
137
|
const ret = wasm.derecprotocolbuilder_withKeepVersionsCount(ptr, count);
|
|
136
138
|
return DeRecProtocolBuilder.__wrap(ret);
|
|
137
139
|
}
|
|
138
|
-
/**
|
|
139
|
-
* `endpoint` shape: `{ uri: string, protocol: string }`.
|
|
140
|
-
* `protocol` is `"https"` or `"grpc"` (case-insensitive).
|
|
141
|
-
*
|
|
142
|
-
* @deprecated Use `withOwnTransports`, which takes the whole preference
|
|
143
|
-
* list — `withOwnTransports([endpoint])` is the direct replacement.
|
|
144
|
-
* Removed at 0.0.5.
|
|
145
|
-
* @param {any} endpoint
|
|
146
|
-
* @returns {DeRecProtocolBuilder}
|
|
147
|
-
*/
|
|
148
|
-
withOwnTransport(endpoint) {
|
|
149
|
-
const ptr = this.__destroy_into_raw();
|
|
150
|
-
const ret = wasm.derecprotocolbuilder_withOwnTransport(ptr, endpoint);
|
|
151
|
-
if (ret[2]) {
|
|
152
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
153
|
-
}
|
|
154
|
-
return DeRecProtocolBuilder.__wrap(ret[0]);
|
|
155
|
-
}
|
|
156
140
|
/**
|
|
157
141
|
* Every transport endpoint this application serves, in preference
|
|
158
142
|
* order. `transports` is an array of `{ uri: string, protocol: string
|
|
159
143
|
* }` objects, `protocol` being `"https"` or `"grpc"`
|
|
160
|
-
* (case-insensitive)
|
|
144
|
+
* (case-insensitive).
|
|
161
145
|
*
|
|
162
146
|
* The order is the application's own preference and decides which of
|
|
163
147
|
* a peer's offered endpoints is used. Every listed transport must
|
|
164
148
|
* actually be served, because delivery is push-only — listing an
|
|
165
149
|
* endpoint this application does not serve makes pairing succeed and
|
|
166
150
|
* replies vanish.
|
|
167
|
-
*
|
|
168
|
-
* Supersedes [`Self::with_own_transport`] for applications serving
|
|
169
|
-
* more than one transport; the single-endpoint setter remains fully
|
|
170
|
-
* supported.
|
|
171
151
|
* @param {any[]} transports
|
|
172
152
|
* @returns {DeRecProtocolBuilder}
|
|
173
153
|
*/
|
|
@@ -244,7 +224,7 @@ class DeRecProtocolBuilder {
|
|
|
244
224
|
}
|
|
245
225
|
/**
|
|
246
226
|
* Minimum number of shares required to reconstruct the secret.
|
|
247
|
-
* Default:
|
|
227
|
+
* Default: [`crate::protocol::DEFAULT_THRESHOLD`].
|
|
248
228
|
* @param {number} threshold
|
|
249
229
|
* @returns {DeRecProtocolBuilder}
|
|
250
230
|
*/
|
|
@@ -292,7 +272,8 @@ class DeRecProtocolBuilder {
|
|
|
292
272
|
return DeRecProtocolBuilder.__wrap(ret);
|
|
293
273
|
}
|
|
294
274
|
/**
|
|
295
|
-
* `ack` is `"required"` (default) or `"not_required"
|
|
275
|
+
* `ack` is exactly `"required"` (default) or `"not_required"`, naming
|
|
276
|
+
* [`UnpairAck::Required`] and [`UnpairAck::NotRequired`].
|
|
296
277
|
* @param {string} ack
|
|
297
278
|
* @returns {DeRecProtocolBuilder}
|
|
298
279
|
*/
|
|
@@ -308,19 +289,7 @@ class DeRecProtocolBuilder {
|
|
|
308
289
|
}
|
|
309
290
|
/**
|
|
310
291
|
* Accept plaintext transport endpoints — `http://` and `grpc://`.
|
|
311
|
-
* **Development only.** Default `false`.
|
|
312
|
-
* conflict rule when both are set.
|
|
313
|
-
* @param {boolean} allow
|
|
314
|
-
* @returns {DeRecProtocolBuilder}
|
|
315
|
-
*/
|
|
316
|
-
withUnsafeConnection(allow) {
|
|
317
|
-
const ptr = this.__destroy_into_raw();
|
|
318
|
-
const ret = wasm.derecprotocolbuilder_withUnsafeConnection(ptr, allow);
|
|
319
|
-
return DeRecProtocolBuilder.__wrap(ret);
|
|
320
|
-
}
|
|
321
|
-
/**
|
|
322
|
-
* Accept plaintext `http://` transport endpoints. **Development only.**
|
|
323
|
-
* Default `false`.
|
|
292
|
+
* **Development only.** Default `false`.
|
|
324
293
|
*
|
|
325
294
|
* With it `false`, plaintext is accepted only for an endpoint this
|
|
326
295
|
* device configured for *itself* that names loopback (`localhost`,
|
|
@@ -328,15 +297,12 @@ class DeRecProtocolBuilder {
|
|
|
328
297
|
* With it `true`, plaintext is accepted for any host on any path,
|
|
329
298
|
* including endpoints a peer supplies. That is what makes the LAN case
|
|
330
299
|
* work (a phone against a laptop), and why the name is blunt.
|
|
331
|
-
*
|
|
332
|
-
* Superseded by `withUnsafeConnection`; still honored, and wins on
|
|
333
|
-
* conflict. Removed at 0.0.5.
|
|
334
300
|
* @param {boolean} allow
|
|
335
301
|
* @returns {DeRecProtocolBuilder}
|
|
336
302
|
*/
|
|
337
|
-
|
|
303
|
+
withUnsafeConnection(allow) {
|
|
338
304
|
const ptr = this.__destroy_into_raw();
|
|
339
|
-
const ret = wasm.
|
|
305
|
+
const ret = wasm.derecprotocolbuilder_withUnsafeConnection(ptr, allow);
|
|
340
306
|
return DeRecProtocolBuilder.__wrap(ret);
|
|
341
307
|
}
|
|
342
308
|
/**
|
|
@@ -356,31 +322,46 @@ exports.DeRecProtocolBuilder = DeRecProtocolBuilder;
|
|
|
356
322
|
* Higher-level DeRec protocol orchestrator for TypeScript/JavaScript consumers.
|
|
357
323
|
*
|
|
358
324
|
* Wraps [`crate::protocol::DeRecProtocol`] with JS-side store
|
|
359
|
-
* and transport adapters so that a TypeScript application can drive
|
|
360
|
-
* protocol
|
|
325
|
+
* and transport adapters so that a TypeScript application can drive every
|
|
326
|
+
* protocol flow without routing raw bytes manually. Built with
|
|
327
|
+
* [`DeRecProtocolBuilderWasm`] (`DeRecProtocolBuilder` in JS).
|
|
361
328
|
*
|
|
362
329
|
* # Stores
|
|
363
330
|
*
|
|
364
|
-
*
|
|
365
|
-
*
|
|
366
|
-
*
|
|
331
|
+
* The five stores and the transport are JS objects implementing the
|
|
332
|
+
* `ChannelStore`, `ShareStore`, `SecretStore`, `UserSecretStore`,
|
|
333
|
+
* `StateStore` and `Transport` interfaces in `index.d.ts`. All their methods
|
|
334
|
+
* must return `Promise`s — synchronous implementations can wrap their result
|
|
335
|
+
* with `Promise.resolve(...)`.
|
|
367
336
|
*
|
|
368
|
-
* #
|
|
337
|
+
* # Concurrency
|
|
369
338
|
*
|
|
370
|
-
*
|
|
371
|
-
*
|
|
339
|
+
* Every method that touches protocol state is `async` and runs under one
|
|
340
|
+
* lock per instance, so overlapping calls on the same instance — a
|
|
341
|
+
* `tick` timer firing while `process` handles an inbound message — queue
|
|
342
|
+
* and run one at a time, in the order they were made. Distinct instances
|
|
343
|
+
* do not share the lock: two instances bound to the same `secret_id` and
|
|
344
|
+
* the same stores must still be serialized by the caller.
|
|
372
345
|
*
|
|
373
|
-
*
|
|
374
|
-
*
|
|
375
|
-
*
|
|
376
|
-
*
|
|
377
|
-
* | `ShareConfirmed` | `channel_id: string`, `version: number` |
|
|
378
|
-
* | `ShareVerified` | `channel_id: string`, `version: number` |
|
|
379
|
-
* | `SecretsDiscovered`| `channel_id: string`, `secrets: SecretVersionEntry[]` |
|
|
380
|
-
* | `SecretRecovered` | `secret: { helpers, secrets, replicas }` (same nested shape as `ReplicaSecretReceived.secret`) |
|
|
381
|
-
* | `NoOp` | _(none)_ |
|
|
346
|
+
* A store or transport callback must not await a call on the instance
|
|
347
|
+
* that invoked it: that call queues behind the one waiting on the
|
|
348
|
+
* callback, and neither settles. Calling `free()` while a call is in
|
|
349
|
+
* flight throws.
|
|
382
350
|
*
|
|
383
|
-
*
|
|
351
|
+
* Methods take `&self` for this reason: wasm-bindgen holds the borrow of
|
|
352
|
+
* the instance for an async call's whole lifetime, so under `&mut self` an
|
|
353
|
+
* overlapping call fails that borrow outside its promise and never
|
|
354
|
+
* settles.
|
|
355
|
+
*
|
|
356
|
+
* # Events
|
|
357
|
+
*
|
|
358
|
+
* [`process`](DeRecProtocolWasm::process), [`start`](DeRecProtocolWasm::start),
|
|
359
|
+
* [`accept`](DeRecProtocolWasm::accept), [`tick`](DeRecProtocolWasm::tick)
|
|
360
|
+
* and [`restore`](DeRecProtocolWasm::restore) return an `Array` of plain JS
|
|
361
|
+
* objects, one per [`crate::protocol::DeRecEvent`], each tagged by a `type`
|
|
362
|
+
* field naming the variant. Every `u64` identifier (`channel_id`,
|
|
363
|
+
* `secret_id`, `replica_id`, `trace_id`) is a decimal string. The full set of
|
|
364
|
+
* shapes is the `DeRecEvent` union in `index.d.ts`.
|
|
384
365
|
*/
|
|
385
366
|
class DeRecProtocolWasm {
|
|
386
367
|
static __wrap(ptr) {
|
|
@@ -503,7 +484,10 @@ class DeRecProtocolWasm {
|
|
|
503
484
|
* # Returns
|
|
504
485
|
*
|
|
505
486
|
* An `Array` of removed channel ids as decimal strings.
|
|
506
|
-
*
|
|
487
|
+
*
|
|
488
|
+
* `older_than_secs` is a `u64`: a `bigint`, a non-negative safe-integer
|
|
489
|
+
* `number`, or a decimal string.
|
|
490
|
+
* @param {any} older_than_secs
|
|
507
491
|
* @returns {Promise<any>}
|
|
508
492
|
*/
|
|
509
493
|
removeExpiredChannels(older_than_secs) {
|
|
@@ -516,17 +500,22 @@ class DeRecProtocolWasm {
|
|
|
516
500
|
* see that method for the full contract.
|
|
517
501
|
*
|
|
518
502
|
* `recoveredSecret` is the typed `Secret` object carried by the
|
|
519
|
-
* `SecretRecovered` event; pass it verbatim.
|
|
503
|
+
* `SecretRecovered` event; pass it verbatim. A helper or member whose
|
|
504
|
+
* `transports` is empty, `null` or absent gets no channel; it is
|
|
505
|
+
* reported as a `PeerNotRestored` event in the returned array and the
|
|
506
|
+
* rest of the roster is restored.
|
|
520
507
|
*
|
|
521
|
-
* Errors surface as
|
|
508
|
+
* Errors surface as a `DeRecError` (`category`, `code`, `message`):
|
|
522
509
|
*
|
|
523
510
|
* | code | meaning |
|
|
524
511
|
* |--------------------|------------------------------------------------------------------|
|
|
525
|
-
* | `
|
|
526
|
-
* | `
|
|
512
|
+
* | `already_restored` | A user-secret snapshot already exists for this `secret_id`. |
|
|
513
|
+
* | `restore_conflict` | Channels live at ids restore is about to write. The error |
|
|
527
514
|
* | | carries `channel_ids: string[]` listing the collisions. |
|
|
528
|
-
* | `
|
|
529
|
-
* | `
|
|
515
|
+
* | `invariant` | The recovered `Secret` is internally inconsistent. |
|
|
516
|
+
* | `invalid_recovered_secret` | `recoveredSecret` is malformed — e.g. a missing or |
|
|
517
|
+
* | | non-decimal `channel_id` / `replica_id`. |
|
|
518
|
+
* | `store_error` | A store call failed mid-restore; `category` names the store. |
|
|
530
519
|
* @param {any} recovered_secret
|
|
531
520
|
* @param {number} version
|
|
532
521
|
* @returns {Promise<any>}
|
|
@@ -536,24 +525,6 @@ class DeRecProtocolWasm {
|
|
|
536
525
|
return ret;
|
|
537
526
|
}
|
|
538
527
|
/**
|
|
539
|
-
* Generate an out-of-band contact message (QR code payload, deep link, …).
|
|
540
|
-
*
|
|
541
|
-
* Returns a plain JS `ContactMessage` object. The `channel_id` field identifies
|
|
542
|
-
* the pairing session and will match the `channel_id` in the eventual
|
|
543
|
-
* `PairingCompleted` event — read it directly from the returned object.
|
|
544
|
-
*
|
|
545
|
-
* The caller is responsible for serializing the contact for out-of-band
|
|
546
|
-
* delivery (QR code, deep link, etc.). The peer passes the deserialized object
|
|
547
|
-
* to [`start`](Self::start) with `FlowKind::Pairing`.
|
|
548
|
-
*
|
|
549
|
-
* # Arguments
|
|
550
|
-
*
|
|
551
|
-
* * `channel_id` — Optional `BigInt` channel identifier. Pass `null` or
|
|
552
|
-
* `undefined` to have the library generate a random one.
|
|
553
|
-
* * `contact_mode` — `0` for `InlineKeys` (keys embedded directly), `1`
|
|
554
|
-
* for `HashedKeys` (contact carries only a SHA-384 binding hash; the
|
|
555
|
-
* scanner fetches keys via a `PrePair` round-trip). `HashedKeys`
|
|
556
|
-
* requires the protocol's `own_transport` to be ephemeral.
|
|
557
528
|
* The secret identifier this protocol instance is bound to.
|
|
558
529
|
* @returns {bigint}
|
|
559
530
|
*/
|
|
@@ -565,49 +536,18 @@ class DeRecProtocolWasm {
|
|
|
565
536
|
* Replace this node's local communication info. Does not contact peers —
|
|
566
537
|
* follow up with a `start(UpdateChannelInfo, ...)` to propagate.
|
|
567
538
|
* @param {any} info
|
|
539
|
+
* @returns {Promise<void>}
|
|
568
540
|
*/
|
|
569
541
|
setCommunicationInfo(info) {
|
|
570
542
|
const ret = wasm.derecprotocolwasm_setCommunicationInfo(this.__wbg_ptr, info);
|
|
571
|
-
|
|
572
|
-
throw takeFromExternrefTable0(ret[0]);
|
|
573
|
-
}
|
|
574
|
-
}
|
|
575
|
-
/**
|
|
576
|
-
* Replace this node's endpoint for one protocol, leaving the others
|
|
577
|
-
* alone. A node serves at most one endpoint per protocol, so the
|
|
578
|
-
* `(uri, protocol)` pair identifies the entry it replaces; an entry for
|
|
579
|
-
* a protocol not yet served is appended, and a replaced one keeps its
|
|
580
|
-
* position in the preference order.
|
|
581
|
-
*
|
|
582
|
-
* @deprecated Use `setOwnTransports`, which takes the whole preference
|
|
583
|
-
* list and is the only way to change which protocols this node serves,
|
|
584
|
-
* or their order. Removed at 0.0.5.
|
|
585
|
-
*
|
|
586
|
-
* See `setCommunicationInfo` for the matching update-propagation
|
|
587
|
-
* flow, and `setOwnTransports` to keep more than one endpoint.
|
|
588
|
-
* IMPORTANT: keep the old endpoint operational during the changeover —
|
|
589
|
-
* see the Rust docs on `set_own_transport` for the discipline.
|
|
590
|
-
* @param {string} uri
|
|
591
|
-
* @param {string} protocol
|
|
592
|
-
*/
|
|
593
|
-
setOwnTransport(uri, protocol) {
|
|
594
|
-
const ptr0 = passStringToWasm0(uri, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
595
|
-
const len0 = WASM_VECTOR_LEN;
|
|
596
|
-
const ptr1 = passStringToWasm0(protocol, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
597
|
-
const len1 = WASM_VECTOR_LEN;
|
|
598
|
-
const ret = wasm.derecprotocolwasm_setOwnTransport(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
599
|
-
if (ret[1]) {
|
|
600
|
-
throw takeFromExternrefTable0(ret[0]);
|
|
601
|
-
}
|
|
543
|
+
return ret;
|
|
602
544
|
}
|
|
603
545
|
/**
|
|
604
546
|
* Replace every endpoint this node advertises, in preference order.
|
|
605
547
|
*
|
|
606
548
|
* `transports` is an array of `{ uri: string, protocol: string }`
|
|
607
|
-
* objects, same shape as `withOwnTransports
|
|
608
|
-
*
|
|
609
|
-
* `setOwnTransport` replaces only the entry for the protocol its URI
|
|
610
|
-
* names. A node serves at most one endpoint per protocol, so this list
|
|
549
|
+
* objects, same shape as `withOwnTransports`, and is its runtime
|
|
550
|
+
* counterpart. A node serves at most one endpoint per protocol, so this list
|
|
611
551
|
* is a preference order over distinct protocols and two entries of the
|
|
612
552
|
* same protocol are rejected.
|
|
613
553
|
*
|
|
@@ -616,26 +556,24 @@ class DeRecProtocolWasm {
|
|
|
616
556
|
* operational during the changeover — see the Rust docs on
|
|
617
557
|
* `set_own_transports` for the discipline.
|
|
618
558
|
* @param {any[]} transports
|
|
559
|
+
* @returns {Promise<void>}
|
|
619
560
|
*/
|
|
620
561
|
setOwnTransports(transports) {
|
|
621
562
|
const ptr0 = passArrayJsValueToWasm0(transports, wasm.__wbindgen_malloc);
|
|
622
563
|
const len0 = WASM_VECTOR_LEN;
|
|
623
564
|
const ret = wasm.derecprotocolwasm_setOwnTransports(this.__wbg_ptr, ptr0, len0);
|
|
624
|
-
|
|
625
|
-
throw takeFromExternrefTable0(ret[0]);
|
|
626
|
-
}
|
|
565
|
+
return ret;
|
|
627
566
|
}
|
|
628
567
|
/**
|
|
629
568
|
* Unified entry point for initiating any protocol flow.
|
|
630
569
|
*
|
|
631
570
|
* # Arguments
|
|
632
571
|
*
|
|
633
|
-
* * `flow_kind` —
|
|
634
|
-
*
|
|
635
|
-
*
|
|
636
|
-
*
|
|
637
|
-
*
|
|
638
|
-
* - `4` = RecoverSecret (params: `{ secretId: Uint8Array, version: number }`)
|
|
572
|
+
* * `flow_kind` — `FlowKind` discriminant: `0` Pairing, `1` Discovery,
|
|
573
|
+
* `2` ProtectSecret, `3` VerifyShares, `4` RecoverSecret, `5` Unpair,
|
|
574
|
+
* `6` UpdateChannelInfo, `7` ReplicaDiscovery, `8` UnpairReplica.
|
|
575
|
+
* * `params` — the flow's parameters, declared per kind in `index.d.ts`
|
|
576
|
+
* as `PairingParams`, `DiscoveryParams`, … `UnpairReplicaParams`.
|
|
639
577
|
*
|
|
640
578
|
* # Returns
|
|
641
579
|
*
|
|
@@ -811,18 +749,44 @@ function envelope_read_trace_id(envelope_bytes) {
|
|
|
811
749
|
exports.envelope_read_trace_id = envelope_read_trace_id;
|
|
812
750
|
|
|
813
751
|
/**
|
|
814
|
-
*
|
|
815
|
-
*
|
|
816
|
-
*
|
|
817
|
-
* @
|
|
752
|
+
* A fresh replica identity. See [`crate::generate_replica_id`]: the caller
|
|
753
|
+
* persists it once per device and passes the same value on every protocol
|
|
754
|
+
* init. Never `0`.
|
|
755
|
+
* @returns {bigint}
|
|
818
756
|
*/
|
|
819
|
-
function
|
|
820
|
-
const ret = wasm.
|
|
821
|
-
|
|
822
|
-
|
|
757
|
+
function generate_replica_id() {
|
|
758
|
+
const ret = wasm.generate_replica_id();
|
|
759
|
+
return BigInt.asUintN(64, ret);
|
|
760
|
+
}
|
|
761
|
+
exports.generate_replica_id = generate_replica_id;
|
|
762
|
+
|
|
763
|
+
/**
|
|
764
|
+
* The human-readable fingerprint of a pairing's shared key. Both ends derive
|
|
765
|
+
* the same value; comparing it out of band confirms the pairing.
|
|
766
|
+
* @param {Uint8Array} shared_key
|
|
767
|
+
* @returns {string}
|
|
768
|
+
*/
|
|
769
|
+
function pairing_fingerprint(shared_key) {
|
|
770
|
+
let deferred3_0;
|
|
771
|
+
let deferred3_1;
|
|
772
|
+
try {
|
|
773
|
+
const ptr0 = passArray8ToWasm0(shared_key, wasm.__wbindgen_malloc);
|
|
774
|
+
const len0 = WASM_VECTOR_LEN;
|
|
775
|
+
const ret = wasm.pairing_fingerprint(ptr0, len0);
|
|
776
|
+
var ptr2 = ret[0];
|
|
777
|
+
var len2 = ret[1];
|
|
778
|
+
if (ret[3]) {
|
|
779
|
+
ptr2 = 0; len2 = 0;
|
|
780
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
781
|
+
}
|
|
782
|
+
deferred3_0 = ptr2;
|
|
783
|
+
deferred3_1 = len2;
|
|
784
|
+
return getStringFromWasm0(ptr2, len2);
|
|
785
|
+
} finally {
|
|
786
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
823
787
|
}
|
|
824
788
|
}
|
|
825
|
-
exports.
|
|
789
|
+
exports.pairing_fingerprint = pairing_fingerprint;
|
|
826
790
|
|
|
827
791
|
/**
|
|
828
792
|
* @param {bigint} channel_id
|
|
@@ -841,9 +805,8 @@ function pairing_request_create_contact(channel_id, contact_mode, transport_prot
|
|
|
841
805
|
exports.pairing_request_create_contact = pairing_request_create_contact;
|
|
842
806
|
|
|
843
807
|
/**
|
|
844
|
-
* Decodes
|
|
845
|
-
*
|
|
846
|
-
* trust the mode/field invariants documented on the wire format.
|
|
808
|
+
* Decodes proto `ContactMessage` wire bytes. See
|
|
809
|
+
* [`crate::primitives::pairing::request::decode_contact`].
|
|
847
810
|
* @param {Uint8Array} bytes
|
|
848
811
|
* @returns {any}
|
|
849
812
|
*/
|
|
@@ -859,10 +822,8 @@ function pairing_request_decode_contact(bytes) {
|
|
|
859
822
|
exports.pairing_request_decode_contact = pairing_request_decode_contact;
|
|
860
823
|
|
|
861
824
|
/**
|
|
862
|
-
* Encodes a [`ContactMessage`] to proto wire bytes.
|
|
863
|
-
*
|
|
864
|
-
* mode/field invariant is rejected at the boundary rather than silently
|
|
865
|
-
* serialized.
|
|
825
|
+
* Encodes a [`ContactMessage`] to proto wire bytes. See
|
|
826
|
+
* [`crate::primitives::pairing::request::encode_contact`].
|
|
866
827
|
* @param {any} contact_message
|
|
867
828
|
* @returns {Uint8Array}
|
|
868
829
|
*/
|
|
@@ -880,14 +841,15 @@ exports.pairing_request_encode_contact = pairing_request_encode_contact;
|
|
|
880
841
|
/**
|
|
881
842
|
* @param {Uint8Array} envelope_bytes
|
|
882
843
|
* @param {Uint8Array} secret_key
|
|
844
|
+
* @param {any} parameter_range
|
|
883
845
|
* @returns {any}
|
|
884
846
|
*/
|
|
885
|
-
function pairing_request_extract(envelope_bytes, secret_key) {
|
|
847
|
+
function pairing_request_extract(envelope_bytes, secret_key, parameter_range) {
|
|
886
848
|
const ptr0 = passArray8ToWasm0(envelope_bytes, wasm.__wbindgen_malloc);
|
|
887
849
|
const len0 = WASM_VECTOR_LEN;
|
|
888
850
|
const ptr1 = passArray8ToWasm0(secret_key, wasm.__wbindgen_malloc);
|
|
889
851
|
const len1 = WASM_VECTOR_LEN;
|
|
890
|
-
const ret = wasm.pairing_request_extract(ptr0, len0, ptr1, len1);
|
|
852
|
+
const ret = wasm.pairing_request_extract(ptr0, len0, ptr1, len1, parameter_range);
|
|
891
853
|
if (ret[2]) {
|
|
892
854
|
throw takeFromExternrefTable0(ret[1]);
|
|
893
855
|
}
|
|
@@ -982,12 +944,13 @@ exports.pairing_response_extract_pre_pair = pairing_response_extract_pre_pair;
|
|
|
982
944
|
* @param {any} contact_message
|
|
983
945
|
* @param {any} response
|
|
984
946
|
* @param {Uint8Array} secret_key
|
|
947
|
+
* @param {any} parameter_range
|
|
985
948
|
* @returns {any}
|
|
986
949
|
*/
|
|
987
|
-
function pairing_response_process(contact_message, response, secret_key) {
|
|
950
|
+
function pairing_response_process(contact_message, response, secret_key, parameter_range) {
|
|
988
951
|
const ptr0 = passArray8ToWasm0(secret_key, wasm.__wbindgen_malloc);
|
|
989
952
|
const len0 = WASM_VECTOR_LEN;
|
|
990
|
-
const ret = wasm.pairing_response_process(contact_message, response, ptr0, len0);
|
|
953
|
+
const ret = wasm.pairing_response_process(contact_message, response, ptr0, len0, parameter_range);
|
|
991
954
|
if (ret[2]) {
|
|
992
955
|
throw takeFromExternrefTable0(ret[1]);
|
|
993
956
|
}
|
|
@@ -1011,6 +974,24 @@ function pairing_response_process_pre_pair(contact_message, response) {
|
|
|
1011
974
|
}
|
|
1012
975
|
exports.pairing_response_process_pre_pair = pairing_response_process_pre_pair;
|
|
1013
976
|
|
|
977
|
+
/**
|
|
978
|
+
* Scanner side of a `NO_KEYS` pairing: accept the contact creator's public
|
|
979
|
+
* keys. There is no binding hash to check them against, so the channel this
|
|
980
|
+
* leads to MUST stay unusable until both sides confirm `pairing_fingerprint`
|
|
981
|
+
* out of band.
|
|
982
|
+
* @param {any} contact_message
|
|
983
|
+
* @param {any} response
|
|
984
|
+
* @returns {any}
|
|
985
|
+
*/
|
|
986
|
+
function pairing_response_process_pre_pair_no_keys(contact_message, response) {
|
|
987
|
+
const ret = wasm.pairing_response_process_pre_pair_no_keys(contact_message, response);
|
|
988
|
+
if (ret[2]) {
|
|
989
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
990
|
+
}
|
|
991
|
+
return takeFromExternrefTable0(ret[0]);
|
|
992
|
+
}
|
|
993
|
+
exports.pairing_response_process_pre_pair_no_keys = pairing_response_process_pre_pair_no_keys;
|
|
994
|
+
|
|
1014
995
|
/**
|
|
1015
996
|
* @param {bigint} channel_id
|
|
1016
997
|
* @param {any} request
|
|
@@ -1049,6 +1030,41 @@ function pairing_response_produce_pre_pair(channel_id, request, secret_key) {
|
|
|
1049
1030
|
}
|
|
1050
1031
|
exports.pairing_response_produce_pre_pair = pairing_response_produce_pre_pair;
|
|
1051
1032
|
|
|
1033
|
+
/**
|
|
1034
|
+
* Contact-creator side of a `NO_KEYS` pairing: generate key material and
|
|
1035
|
+
* answer the `PrePairRequest` with its public half.
|
|
1036
|
+
*
|
|
1037
|
+
* The caller MUST first match the request's `nonce` against the contact it
|
|
1038
|
+
* issued, and MUST keep the resulting channel unusable until both sides
|
|
1039
|
+
* confirm `pairing_fingerprint` out of band.
|
|
1040
|
+
* @param {bigint} channel_id
|
|
1041
|
+
* @param {any} request
|
|
1042
|
+
* @returns {any}
|
|
1043
|
+
*/
|
|
1044
|
+
function pairing_response_produce_pre_pair_no_keys(channel_id, request) {
|
|
1045
|
+
const ret = wasm.pairing_response_produce_pre_pair_no_keys(channel_id, request);
|
|
1046
|
+
if (ret[2]) {
|
|
1047
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1048
|
+
}
|
|
1049
|
+
return takeFromExternrefTable0(ret[0]);
|
|
1050
|
+
}
|
|
1051
|
+
exports.pairing_response_produce_pre_pair_no_keys = pairing_response_produce_pre_pair_no_keys;
|
|
1052
|
+
|
|
1053
|
+
/**
|
|
1054
|
+
* The DeRec protocol version this build speaks — the `protocolVersionMajor`
|
|
1055
|
+
* / `protocolVersionMinor` it writes into every envelope it produces —
|
|
1056
|
+
* as `{ major, minor }`.
|
|
1057
|
+
* @returns {any}
|
|
1058
|
+
*/
|
|
1059
|
+
function protocol_version() {
|
|
1060
|
+
const ret = wasm.protocol_version();
|
|
1061
|
+
if (ret[2]) {
|
|
1062
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1063
|
+
}
|
|
1064
|
+
return takeFromExternrefTable0(ret[0]);
|
|
1065
|
+
}
|
|
1066
|
+
exports.protocol_version = protocol_version;
|
|
1067
|
+
|
|
1052
1068
|
/**
|
|
1053
1069
|
* @param {Uint8Array} envelope_bytes
|
|
1054
1070
|
* @param {Uint8Array} shared_key
|
|
@@ -1574,9 +1590,6 @@ function __wbg_get_imports() {
|
|
|
1574
1590
|
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
1575
1591
|
}
|
|
1576
1592
|
},
|
|
1577
|
-
__wbg_error_dd408a7b3cb542dd: function(arg0) {
|
|
1578
|
-
console.error(arg0);
|
|
1579
|
-
},
|
|
1580
1593
|
__wbg_from_74f3d90e0ff11240: function(arg0) {
|
|
1581
1594
|
const ret = Array.from(arg0);
|
|
1582
1595
|
return ret;
|
|
@@ -1811,7 +1824,7 @@ function __wbg_get_imports() {
|
|
|
1811
1824
|
return ret;
|
|
1812
1825
|
},
|
|
1813
1826
|
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
1814
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx:
|
|
1827
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 395, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
1815
1828
|
const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h379e0770a020d351);
|
|
1816
1829
|
return ret;
|
|
1817
1830
|
},
|
package/derec_library_bg.wasm
CHANGED
|
Binary file
|