@derec-alliance/nodejs 0.0.5 → 0.0.7

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/derec_library.js CHANGED
@@ -8,11 +8,12 @@
8
8
  * docs.
9
9
  *
10
10
  * Required setters: `withChannelStore`, `withShareStore`,
11
- * `withSecretStore`, `withTransport`, and either `withOwnTransport` or
12
- * `withOwnTransports`. Calling `build()` without all five throws.
11
+ * `withSecretStore`, `withUserSecretStore`, `withStateStore`,
12
+ * `withTransport`, and `withOwnTransports`. Calling `build()` without all
13
+ * seven throws.
13
14
  *
14
- * All optional setters carry the defaults documented on the Rust
15
- * builder.
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 stamp `replyTo = ownTransport`.
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}
@@ -125,49 +126,17 @@ class DeRecProtocolBuilder {
125
126
  }
126
127
  return DeRecProtocolBuilder.__wrap(ret[0]);
127
128
  }
128
- /**
129
- * Number of recent versions each helper must retain. Default: 3.
130
- * @param {number} count
131
- * @returns {DeRecProtocolBuilder}
132
- */
133
- withKeepVersionsCount(count) {
134
- const ptr = this.__destroy_into_raw();
135
- const ret = wasm.derecprotocolbuilder_withKeepVersionsCount(ptr, count);
136
- return DeRecProtocolBuilder.__wrap(ret);
137
- }
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
129
  /**
157
130
  * Every transport endpoint this application serves, in preference
158
131
  * order. `transports` is an array of `{ uri: string, protocol: string
159
132
  * }` objects, `protocol` being `"https"` or `"grpc"`
160
- * (case-insensitive), same shape as [`Self::with_own_transport`].
133
+ * (case-insensitive).
161
134
  *
162
135
  * The order is the application's own preference and decides which of
163
136
  * a peer's offered endpoints is used. Every listed transport must
164
137
  * actually be served, because delivery is push-only — listing an
165
138
  * endpoint this application does not serve makes pairing succeed and
166
139
  * 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
140
  * @param {any[]} transports
172
141
  * @returns {DeRecProtocolBuilder}
173
142
  */
@@ -244,7 +213,7 @@ class DeRecProtocolBuilder {
244
213
  }
245
214
  /**
246
215
  * Minimum number of shares required to reconstruct the secret.
247
- * Default: 3.
216
+ * Default: [`crate::protocol::DEFAULT_THRESHOLD`].
248
217
  * @param {number} threshold
249
218
  * @returns {DeRecProtocolBuilder}
250
219
  */
@@ -292,7 +261,8 @@ class DeRecProtocolBuilder {
292
261
  return DeRecProtocolBuilder.__wrap(ret);
293
262
  }
294
263
  /**
295
- * `ack` is `"required"` (default) or `"not_required"`.
264
+ * `ack` is exactly `"required"` (default) or `"not_required"`, naming
265
+ * [`UnpairAck::Required`] and [`UnpairAck::NotRequired`].
296
266
  * @param {string} ack
297
267
  * @returns {DeRecProtocolBuilder}
298
268
  */
@@ -308,19 +278,7 @@ class DeRecProtocolBuilder {
308
278
  }
309
279
  /**
310
280
  * Accept plaintext transport endpoints — `http://` and `grpc://`.
311
- * **Development only.** Default `false`. See `withUnsafeHttp` for the
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`.
281
+ * **Development only.** Default `false`.
324
282
  *
325
283
  * With it `false`, plaintext is accepted only for an endpoint this
326
284
  * device configured for *itself* that names loopback (`localhost`,
@@ -328,15 +286,12 @@ class DeRecProtocolBuilder {
328
286
  * With it `true`, plaintext is accepted for any host on any path,
329
287
  * including endpoints a peer supplies. That is what makes the LAN case
330
288
  * 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
289
  * @param {boolean} allow
335
290
  * @returns {DeRecProtocolBuilder}
336
291
  */
337
- withUnsafeHttp(allow) {
292
+ withUnsafeConnection(allow) {
338
293
  const ptr = this.__destroy_into_raw();
339
- const ret = wasm.derecprotocolbuilder_withUnsafeHttp(ptr, allow);
294
+ const ret = wasm.derecprotocolbuilder_withUnsafeConnection(ptr, allow);
340
295
  return DeRecProtocolBuilder.__wrap(ret);
341
296
  }
342
297
  /**
@@ -356,31 +311,46 @@ exports.DeRecProtocolBuilder = DeRecProtocolBuilder;
356
311
  * Higher-level DeRec protocol orchestrator for TypeScript/JavaScript consumers.
357
312
  *
358
313
  * Wraps [`crate::protocol::DeRecProtocol`] with JS-side store
359
- * and transport adapters so that a TypeScript application can drive all five
360
- * protocol flows without routing raw bytes manually.
314
+ * and transport adapters so that a TypeScript application can drive every
315
+ * protocol flow without routing raw bytes manually. Built with
316
+ * [`DeRecProtocolBuilderWasm`] (`DeRecProtocolBuilder` in JS).
361
317
  *
362
318
  * # Stores
363
319
  *
364
- * Pass four JS objects that implement the interfaces documented on each
365
- * parameter. All store methods must return `Promise`s — synchronous
366
- * implementations can wrap their result with `Promise.resolve(...)`.
320
+ * The five stores and the transport are JS objects implementing the
321
+ * `ChannelStore`, `ShareStore`, `SecretStore`, `UserSecretStore`,
322
+ * `StateStore` and `Transport` interfaces in `index.d.ts`. All their methods
323
+ * must return `Promise`s — synchronous implementations can wrap their result
324
+ * with `Promise.resolve(...)`.
367
325
  *
368
- * # Events
326
+ * # Concurrency
327
+ *
328
+ * Every method that touches protocol state is `async` and runs under one
329
+ * lock per instance, so overlapping calls on the same instance — a
330
+ * `tick` timer firing while `process` handles an inbound message — queue
331
+ * and run one at a time, in the order they were made. Distinct instances
332
+ * do not share the lock: two instances bound to the same `secret_id` and
333
+ * the same stores must still be serialized by the caller.
369
334
  *
370
- * [`process`](DeRecProtocolWasm::process) returns an `Array` of plain JS
371
- * objects, each with a `type` discriminant field:
335
+ * A store or transport callback must not await a call on the instance
336
+ * that invoked it: that call queues behind the one waiting on the
337
+ * callback, and neither settles. Calling `free()` while a call is in
338
+ * flight throws.
372
339
  *
373
- * | `type` | Additional fields |
374
- * |--------------------|--------------------------------------------------------|
375
- * | `PairingCompleted` | `channel_id: string`, `pairing_channel_id: string`, `kind: number` |
376
- * | `ShareStored` | `channel_id: string`, `version: number` |
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)_ |
340
+ * Methods take `&self` for this reason: wasm-bindgen holds the borrow of
341
+ * the instance for an async call's whole lifetime, so under `&mut self` an
342
+ * overlapping call fails that borrow outside its promise and never
343
+ * settles.
382
344
  *
383
- * `SecretVersionEntry = { secret_id: bigint, versions: { version: number, description: string }[] }`
345
+ * # Events
346
+ *
347
+ * [`process`](DeRecProtocolWasm::process), [`start`](DeRecProtocolWasm::start),
348
+ * [`accept`](DeRecProtocolWasm::accept), [`tick`](DeRecProtocolWasm::tick)
349
+ * and [`restore`](DeRecProtocolWasm::restore) return an `Array` of plain JS
350
+ * objects, one per [`crate::protocol::DeRecEvent`], each tagged by a `type`
351
+ * field naming the variant. Every `u64` identifier (`channel_id`,
352
+ * `secret_id`, `replica_id`, `trace_id`) is a decimal string. The full set of
353
+ * shapes is the `DeRecEvent` union in `index.d.ts`.
384
354
  */
385
355
  class DeRecProtocolWasm {
386
356
  static __wrap(ptr) {
@@ -503,7 +473,10 @@ class DeRecProtocolWasm {
503
473
  * # Returns
504
474
  *
505
475
  * An `Array` of removed channel ids as decimal strings.
506
- * @param {number} older_than_secs
476
+ *
477
+ * `older_than_secs` is a `u64`: a `bigint`, a non-negative safe-integer
478
+ * `number`, or a decimal string.
479
+ * @param {any} older_than_secs
507
480
  * @returns {Promise<any>}
508
481
  */
509
482
  removeExpiredChannels(older_than_secs) {
@@ -516,17 +489,22 @@ class DeRecProtocolWasm {
516
489
  * see that method for the full contract.
517
490
  *
518
491
  * `recoveredSecret` is the typed `Secret` object carried by the
519
- * `SecretRecovered` event; pass it verbatim.
492
+ * `SecretRecovered` event; pass it verbatim. A helper or member whose
493
+ * `transports` is empty, `null` or absent gets no channel; it is
494
+ * reported as a `PeerNotRestored` event in the returned array and the
495
+ * rest of the roster is restored.
520
496
  *
521
- * Errors surface as structured JS errors with a `code` field:
497
+ * Errors surface as a `DeRecError` (`category`, `code`, `message`):
522
498
  *
523
499
  * | code | meaning |
524
500
  * |--------------------|------------------------------------------------------------------|
525
- * | `ALREADY_RESTORED` | A user-secret snapshot already exists for this `secret_id`. |
526
- * | `CONFLICT` | Channels live at canonical helper / replica ids. The error |
501
+ * | `already_restored` | A user-secret snapshot already exists for this `secret_id`. |
502
+ * | `restore_conflict` | Channels live at ids restore is about to write. The error |
527
503
  * | | carries `channel_ids: string[]` listing the collisions. |
528
- * | `INVARIANT` | The recovered `Secret` is internally inconsistent. |
529
- * | `STORAGE` | A store I/O call failed mid-restore. |
504
+ * | `invariant` | The recovered `Secret` is internally inconsistent. |
505
+ * | `invalid_recovered_secret` | `recoveredSecret` is malformed — e.g. a missing or |
506
+ * | | non-decimal `channel_id` / `replica_id`. |
507
+ * | `store_error` | A store call failed mid-restore; `category` names the store. |
530
508
  * @param {any} recovered_secret
531
509
  * @param {number} version
532
510
  * @returns {Promise<any>}
@@ -536,24 +514,6 @@ class DeRecProtocolWasm {
536
514
  return ret;
537
515
  }
538
516
  /**
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
517
  * The secret identifier this protocol instance is bound to.
558
518
  * @returns {bigint}
559
519
  */
@@ -565,49 +525,18 @@ class DeRecProtocolWasm {
565
525
  * Replace this node's local communication info. Does not contact peers —
566
526
  * follow up with a `start(UpdateChannelInfo, ...)` to propagate.
567
527
  * @param {any} info
528
+ * @returns {Promise<void>}
568
529
  */
569
530
  setCommunicationInfo(info) {
570
531
  const ret = wasm.derecprotocolwasm_setCommunicationInfo(this.__wbg_ptr, info);
571
- if (ret[1]) {
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
- }
532
+ return ret;
602
533
  }
603
534
  /**
604
535
  * Replace every endpoint this node advertises, in preference order.
605
536
  *
606
537
  * `transports` is an array of `{ uri: string, protocol: string }`
607
- * objects, same shape as `withOwnTransports`. The runtime counterpart
608
- * to that builder setter, and the way to change the whole set:
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
538
+ * objects, same shape as `withOwnTransports`, and is its runtime
539
+ * counterpart. A node serves at most one endpoint per protocol, so this list
611
540
  * is a preference order over distinct protocols and two entries of the
612
541
  * same protocol are rejected.
613
542
  *
@@ -616,26 +545,24 @@ class DeRecProtocolWasm {
616
545
  * operational during the changeover — see the Rust docs on
617
546
  * `set_own_transports` for the discipline.
618
547
  * @param {any[]} transports
548
+ * @returns {Promise<void>}
619
549
  */
620
550
  setOwnTransports(transports) {
621
551
  const ptr0 = passArrayJsValueToWasm0(transports, wasm.__wbindgen_malloc);
622
552
  const len0 = WASM_VECTOR_LEN;
623
553
  const ret = wasm.derecprotocolwasm_setOwnTransports(this.__wbg_ptr, ptr0, len0);
624
- if (ret[1]) {
625
- throw takeFromExternrefTable0(ret[0]);
626
- }
554
+ return ret;
627
555
  }
628
556
  /**
629
557
  * Unified entry point for initiating any protocol flow.
630
558
  *
631
559
  * # Arguments
632
560
  *
633
- * * `flow_kind` — Flow discriminant:
634
- * - `0` = Pairing (params: `{ kind: number, contact: ContactMessage, name?: string }`)
635
- * - `1` = Discovery (params: `{ target: BigInt | BigInt[] | null }`)
636
- * - `2` = ProtectSecret (params: `{ secrets: UserSecret[], description?: string }`)
637
- * - `3` = VerifyShares (params: `{ version: number, target: BigInt | BigInt[] | null }`)
638
- * - `4` = RecoverSecret (params: `{ secretId: Uint8Array, version: number }`)
561
+ * * `flow_kind` — `FlowKind` discriminant: `0` Pairing, `1` Discovery,
562
+ * `2` ProtectSecret, `3` VerifyShares, `4` RecoverSecret, `5` Unpair,
563
+ * `6` UpdateChannelInfo, `7` ReplicaDiscovery, `8` UnpairReplica.
564
+ * * `params` — the flow's parameters, declared per kind in `index.d.ts`
565
+ * as `PairingParams`, `DiscoveryParams`, … `UnpairReplicaParams`.
639
566
  *
640
567
  * # Returns
641
568
  *
@@ -811,18 +738,44 @@ function envelope_read_trace_id(envelope_bytes) {
811
738
  exports.envelope_read_trace_id = envelope_read_trace_id;
812
739
 
813
740
  /**
814
- * Structurally validate a JS-side [`ContactMessage`]. Throws on any
815
- * mode/field inconsistency (unknown `contact_mode`, mode/field mismatch,
816
- * wrong binding-hash length).
817
- * @param {any} contact_message
741
+ * A fresh replica identity. See [`crate::generate_replica_id`]: the caller
742
+ * persists it once per device and passes the same value on every protocol
743
+ * init. Never `0`.
744
+ * @returns {bigint}
818
745
  */
819
- function pairing_contact_message_validate(contact_message) {
820
- const ret = wasm.pairing_contact_message_validate(contact_message);
821
- if (ret[1]) {
822
- throw takeFromExternrefTable0(ret[0]);
746
+ function generate_replica_id() {
747
+ const ret = wasm.generate_replica_id();
748
+ return BigInt.asUintN(64, ret);
749
+ }
750
+ exports.generate_replica_id = generate_replica_id;
751
+
752
+ /**
753
+ * The human-readable fingerprint of a pairing's shared key. Both ends derive
754
+ * the same value; comparing it out of band confirms the pairing.
755
+ * @param {Uint8Array} shared_key
756
+ * @returns {string}
757
+ */
758
+ function pairing_fingerprint(shared_key) {
759
+ let deferred3_0;
760
+ let deferred3_1;
761
+ try {
762
+ const ptr0 = passArray8ToWasm0(shared_key, wasm.__wbindgen_malloc);
763
+ const len0 = WASM_VECTOR_LEN;
764
+ const ret = wasm.pairing_fingerprint(ptr0, len0);
765
+ var ptr2 = ret[0];
766
+ var len2 = ret[1];
767
+ if (ret[3]) {
768
+ ptr2 = 0; len2 = 0;
769
+ throw takeFromExternrefTable0(ret[2]);
770
+ }
771
+ deferred3_0 = ptr2;
772
+ deferred3_1 = len2;
773
+ return getStringFromWasm0(ptr2, len2);
774
+ } finally {
775
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
823
776
  }
824
777
  }
825
- exports.pairing_contact_message_validate = pairing_contact_message_validate;
778
+ exports.pairing_fingerprint = pairing_fingerprint;
826
779
 
827
780
  /**
828
781
  * @param {bigint} channel_id
@@ -841,9 +794,8 @@ function pairing_request_create_contact(channel_id, contact_mode, transport_prot
841
794
  exports.pairing_request_create_contact = pairing_request_create_contact;
842
795
 
843
796
  /**
844
- * Decodes a proto-encoded [`ContactMessage`]. Structurally validates the
845
- * decoded value before returning it to application code so consumers can
846
- * trust the mode/field invariants documented on the wire format.
797
+ * Decodes proto `ContactMessage` wire bytes. See
798
+ * [`crate::primitives::pairing::request::decode_contact`].
847
799
  * @param {Uint8Array} bytes
848
800
  * @returns {any}
849
801
  */
@@ -859,10 +811,8 @@ function pairing_request_decode_contact(bytes) {
859
811
  exports.pairing_request_decode_contact = pairing_request_decode_contact;
860
812
 
861
813
  /**
862
- * Encodes a [`ContactMessage`] to proto wire bytes. Structurally validates
863
- * the input first so a locally-constructed contact that violates the
864
- * mode/field invariant is rejected at the boundary rather than silently
865
- * serialized.
814
+ * Encodes a [`ContactMessage`] to proto wire bytes. See
815
+ * [`crate::primitives::pairing::request::encode_contact`].
866
816
  * @param {any} contact_message
867
817
  * @returns {Uint8Array}
868
818
  */
@@ -880,14 +830,15 @@ exports.pairing_request_encode_contact = pairing_request_encode_contact;
880
830
  /**
881
831
  * @param {Uint8Array} envelope_bytes
882
832
  * @param {Uint8Array} secret_key
833
+ * @param {any} parameter_range
883
834
  * @returns {any}
884
835
  */
885
- function pairing_request_extract(envelope_bytes, secret_key) {
836
+ function pairing_request_extract(envelope_bytes, secret_key, parameter_range) {
886
837
  const ptr0 = passArray8ToWasm0(envelope_bytes, wasm.__wbindgen_malloc);
887
838
  const len0 = WASM_VECTOR_LEN;
888
839
  const ptr1 = passArray8ToWasm0(secret_key, wasm.__wbindgen_malloc);
889
840
  const len1 = WASM_VECTOR_LEN;
890
- const ret = wasm.pairing_request_extract(ptr0, len0, ptr1, len1);
841
+ const ret = wasm.pairing_request_extract(ptr0, len0, ptr1, len1, parameter_range);
891
842
  if (ret[2]) {
892
843
  throw takeFromExternrefTable0(ret[1]);
893
844
  }
@@ -982,12 +933,13 @@ exports.pairing_response_extract_pre_pair = pairing_response_extract_pre_pair;
982
933
  * @param {any} contact_message
983
934
  * @param {any} response
984
935
  * @param {Uint8Array} secret_key
936
+ * @param {any} parameter_range
985
937
  * @returns {any}
986
938
  */
987
- function pairing_response_process(contact_message, response, secret_key) {
939
+ function pairing_response_process(contact_message, response, secret_key, parameter_range) {
988
940
  const ptr0 = passArray8ToWasm0(secret_key, wasm.__wbindgen_malloc);
989
941
  const len0 = WASM_VECTOR_LEN;
990
- const ret = wasm.pairing_response_process(contact_message, response, ptr0, len0);
942
+ const ret = wasm.pairing_response_process(contact_message, response, ptr0, len0, parameter_range);
991
943
  if (ret[2]) {
992
944
  throw takeFromExternrefTable0(ret[1]);
993
945
  }
@@ -1011,6 +963,24 @@ function pairing_response_process_pre_pair(contact_message, response) {
1011
963
  }
1012
964
  exports.pairing_response_process_pre_pair = pairing_response_process_pre_pair;
1013
965
 
966
+ /**
967
+ * Scanner side of a `NO_KEYS` pairing: accept the contact creator's public
968
+ * keys. There is no binding hash to check them against, so the channel this
969
+ * leads to MUST stay unusable until both sides confirm `pairing_fingerprint`
970
+ * out of band.
971
+ * @param {any} contact_message
972
+ * @param {any} response
973
+ * @returns {any}
974
+ */
975
+ function pairing_response_process_pre_pair_no_keys(contact_message, response) {
976
+ const ret = wasm.pairing_response_process_pre_pair_no_keys(contact_message, response);
977
+ if (ret[2]) {
978
+ throw takeFromExternrefTable0(ret[1]);
979
+ }
980
+ return takeFromExternrefTable0(ret[0]);
981
+ }
982
+ exports.pairing_response_process_pre_pair_no_keys = pairing_response_process_pre_pair_no_keys;
983
+
1014
984
  /**
1015
985
  * @param {bigint} channel_id
1016
986
  * @param {any} request
@@ -1049,6 +1019,41 @@ function pairing_response_produce_pre_pair(channel_id, request, secret_key) {
1049
1019
  }
1050
1020
  exports.pairing_response_produce_pre_pair = pairing_response_produce_pre_pair;
1051
1021
 
1022
+ /**
1023
+ * Contact-creator side of a `NO_KEYS` pairing: generate key material and
1024
+ * answer the `PrePairRequest` with its public half.
1025
+ *
1026
+ * The caller MUST first match the request's `nonce` against the contact it
1027
+ * issued, and MUST keep the resulting channel unusable until both sides
1028
+ * confirm `pairing_fingerprint` out of band.
1029
+ * @param {bigint} channel_id
1030
+ * @param {any} request
1031
+ * @returns {any}
1032
+ */
1033
+ function pairing_response_produce_pre_pair_no_keys(channel_id, request) {
1034
+ const ret = wasm.pairing_response_produce_pre_pair_no_keys(channel_id, request);
1035
+ if (ret[2]) {
1036
+ throw takeFromExternrefTable0(ret[1]);
1037
+ }
1038
+ return takeFromExternrefTable0(ret[0]);
1039
+ }
1040
+ exports.pairing_response_produce_pre_pair_no_keys = pairing_response_produce_pre_pair_no_keys;
1041
+
1042
+ /**
1043
+ * The DeRec protocol version this build speaks — the `protocolVersionMajor`
1044
+ * / `protocolVersionMinor` it writes into every envelope it produces —
1045
+ * as `{ major, minor }`.
1046
+ * @returns {any}
1047
+ */
1048
+ function protocol_version() {
1049
+ const ret = wasm.protocol_version();
1050
+ if (ret[2]) {
1051
+ throw takeFromExternrefTable0(ret[1]);
1052
+ }
1053
+ return takeFromExternrefTable0(ret[0]);
1054
+ }
1055
+ exports.protocol_version = protocol_version;
1056
+
1052
1057
  /**
1053
1058
  * @param {Uint8Array} envelope_bytes
1054
1059
  * @param {Uint8Array} shared_key
@@ -1574,9 +1579,6 @@ function __wbg_get_imports() {
1574
1579
  wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
1575
1580
  }
1576
1581
  },
1577
- __wbg_error_dd408a7b3cb542dd: function(arg0) {
1578
- console.error(arg0);
1579
- },
1580
1582
  __wbg_from_74f3d90e0ff11240: function(arg0) {
1581
1583
  const ret = Array.from(arg0);
1582
1584
  return ret;
@@ -1811,7 +1813,7 @@ function __wbg_get_imports() {
1811
1813
  return ret;
1812
1814
  },
1813
1815
  __wbindgen_cast_0000000000000001: function(arg0, arg1) {
1814
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 383, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
1816
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 404, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
1815
1817
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h379e0770a020d351);
1816
1818
  return ret;
1817
1819
  },
Binary file