@derec-alliance/react-native 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/lib/native.d.ts CHANGED
@@ -6,6 +6,10 @@
6
6
  * surface passes `ArrayBuffer`s that TurboModule specs cannot express.
7
7
  */
8
8
  export interface DeRecNative {
9
- version(): string;
9
+ version(): {
10
+ major: number;
11
+ minor: number;
12
+ };
13
+ generate_replica_id(): bigint;
10
14
  }
11
15
  export declare function getNative(): DeRecNative;
@@ -1,14 +1,4 @@
1
- import type { CommittedDeRecShare, CommunicationInfo, ContactMessage, ContactMode, CreateContactResult, DiscoveryProcessResult, GetSecretIdsVersionsRequestMessage, GetSecretIdsVersionsResponseMessage, GetShareRequestMessage, GetShareResponseMessage, PairRequestMessage, PairResponseMessage, PairingProcessResult, PairingRequestProduceResult, PairingResponseProduceResult, ParameterRange, PrePairRequestExtractResult, PrePairRequestMessage, PrePairResponseExtractResult, PrePairResponseMessage, ProcessPrePairResult, ProducePrePairResult, ProduceResult, RecoverResult, SecretVersionEntry, SenderKind, SharingResponseProduceResult, SplitResult, StoreShareRequestMessage, StoreShareResponseMessage, TransportProtocol, UnpairRequestMessage, UnpairResponseMessage, UnpairingProcessResult, VerifyShareRequestMessage, VerifyShareResponseMessage } from './types';
2
- /**
3
- * `ContactMessage` keeps its own dedicated codec rather than going through
4
- * the generic message codec: `encode_contact_message` /
5
- * `decode_contact_message` also enforce the mode/field invariant — an
6
- * `InlineKeys` contact must carry keys, a `HashedKeys` one must carry only
7
- * the commitment — so a malformed contact is rejected here rather than
8
- * travelling.
9
- */
10
- declare function encodeContact(contact_message: ContactMessage): Uint8Array;
11
- declare function decodeContact(wire: Uint8Array | ArrayBuffer): ContactMessage;
1
+ import type { CommittedDeRecShare, CommunicationInfo, ContactMessage, ContactMode, CreateContactResult, DiscoveryProcessResult, GetSecretIdsVersionsRequestMessage, GetSecretIdsVersionsResponseMessage, GetShareRequestMessage, GetShareResponseMessage, PairRequestMessage, PairResponseMessage, PairingProcessResult, PairingRequestProduceResult, PairingResponseProduceResult, ParameterRange, PrePairRequestExtractResult, PrePairRequestMessage, PrePairResponseExtractResult, PrePairResponseMessage, ProcessPrePairResult, ProducePrePairNoKeysResult, ProducePrePairResult, ProduceResult, RecoverResult, SecretVersionEntry, SenderKind, SharingResponseProduceResult, SplitResult, StoreShareRequestMessage, StoreShareResponseMessage, TransportProtocol, UnpairRequestMessage, UnpairResponseMessage, UnpairingProcessResult, VerifyShareRequestMessage, VerifyShareResponseMessage } from './types';
12
2
  export declare const primitives: {
13
3
  discovery: {
14
4
  request: {
@@ -27,15 +17,20 @@ export declare const primitives: {
27
17
  };
28
18
  pairing: {
29
19
  request: {
30
- create_contact(channel_id: bigint, contact_mode: ContactMode | number, transport_protocols: TransportProtocol[]): CreateContactResult;
31
- /** Proto-encodes a `ContactMessage`. Rejects a contact that violates the
32
- * mode/field invariant rather than serializing it. */
33
- encode_contact: typeof encodeContact;
34
- /** Decodes proto `ContactMessage` bytes. Rejects a contact that violates
35
- * the mode/field invariant rather than returning it. */
36
- decode_contact: typeof decodeContact;
20
+ /** Creates an out-of-band `ContactMessage`. `nonce` omitted or `null`
21
+ * lets the library draw a random one; `ContactMode.NoKeys` requires the
22
+ * caller to supply it. */
23
+ create_contact(channel_id: bigint, contact_mode: ContactMode | number, transport_protocols: TransportProtocol[], nonce?: bigint | number | null): CreateContactResult;
24
+ /** Serializes a `ContactMessage` to the bytes delivered out of band.
25
+ * Refuses a contact that violates the invariants of its contact mode or
26
+ * advertises no endpoint. */
27
+ encode_contact(contact_message: ContactMessage): Uint8Array;
28
+ /** Parses out-of-band contact bytes back into a `ContactMessage`.
29
+ * Refuses bytes that are not a contact, or a contact that violates the
30
+ * invariants of its contact mode. */
31
+ decode_contact(bytes: Uint8Array | ArrayBuffer): ContactMessage;
37
32
  produce(kind: SenderKind, transport_protocols: TransportProtocol[], contact_message: ContactMessage, communication_info: CommunicationInfo | null, parameter_range: ParameterRange | null): PairingRequestProduceResult;
38
- extract(envelope_bytes: Uint8Array, secret_key: Uint8Array): {
33
+ extract(envelope_bytes: Uint8Array, secret_key: Uint8Array, parameter_range: ParameterRange | null): {
39
34
  request: PairRequestMessage;
40
35
  };
41
36
  produce_pre_pair(own_transports: TransportProtocol[], contact_message: ContactMessage): ProducePrePairResult;
@@ -46,11 +41,14 @@ export declare const primitives: {
46
41
  extract(envelope_bytes: Uint8Array, secret_key: Uint8Array): {
47
42
  response: PairResponseMessage;
48
43
  };
49
- process(contact_message: ContactMessage, response: PairResponseMessage, secret_key: Uint8Array): PairingProcessResult;
44
+ process(contact_message: ContactMessage, response: PairResponseMessage, secret_key: Uint8Array, parameter_range: ParameterRange | null): PairingProcessResult;
50
45
  produce_pre_pair(channel_id: bigint, request: PrePairRequestMessage, secret_key: Uint8Array): ProducePrePairResult;
51
46
  extract_pre_pair(envelope_bytes: Uint8Array): PrePairResponseExtractResult;
52
47
  process_pre_pair(contact_message: ContactMessage, response: PrePairResponseMessage): ProcessPrePairResult;
48
+ produce_pre_pair_no_keys(channel_id: bigint, request: PrePairRequestMessage): ProducePrePairNoKeysResult;
49
+ process_pre_pair_no_keys(contact_message: ContactMessage, response: PrePairResponseMessage): ProcessPrePairResult;
53
50
  };
51
+ fingerprint(shared_key: Uint8Array): string;
54
52
  };
55
53
  recovery: {
56
54
  request: {
@@ -134,4 +132,3 @@ export declare const envelope: {
134
132
  apply_trace_id(envelope_bytes: Uint8Array, trace_id: bigint): Uint8Array;
135
133
  read_trace_id(envelope_bytes: Uint8Array): bigint;
136
134
  };
137
- export {};
package/lib/primitives.js CHANGED
@@ -35,19 +35,16 @@ function replyTo(value) {
35
35
  return value && value.length > 0 ? encodeTransportList(value) : new Uint8Array(0);
36
36
  }
37
37
  /**
38
- * `ContactMessage` keeps its own dedicated codec rather than going through
39
- * the generic message codec: `encode_contact_message` /
40
- * `decode_contact_message` also enforce the mode/field invariant — an
41
- * `InlineKeys` contact must carry keys, a `HashedKeys` one must carry only
42
- * the commitment — so a malformed contact is rejected here rather than
43
- * travelling.
38
+ * Every contact crossing the native seam goes through the core's contact
39
+ * codec, which also refuses a contact that violates the invariants of its
40
+ * contact mode. Delegates to `pairing.request.encode_contact` /
41
+ * `decode_contact`, defined below.
44
42
  */
45
43
  function encodeContact(contact_message) {
46
- return bytes(call('encode_contact_message', (0, codec_1.jsonToBytes)((0, messages_1.plainMessage)(contact_message))));
44
+ return pairing.request.encode_contact(contact_message);
47
45
  }
48
46
  function decodeContact(wire) {
49
- const json = call('decode_contact_message', wire);
50
- return (0, messages_1.reviveMessage)((0, codec_1.jsonFromBytes)(json));
47
+ return pairing.request.decode_contact(wire);
51
48
  }
52
49
  const discovery = {
53
50
  request: {
@@ -131,23 +128,31 @@ function decodeTransportList(framed) {
131
128
  }
132
129
  const pairing = {
133
130
  request: {
134
- create_contact(channel_id, contact_mode, transport_protocols) {
135
- // The C entry point also accepts a caller-supplied nonce behind a
136
- // presence flag. `@derec-alliance/nodejs` has no such parameter, so the
137
- // flag is 0 and the library generates one — the same behaviour, not a
138
- // default invented here.
139
- const result = call('create_contact_message', channel_id, contact_mode, encodeTransportList(transport_protocols), 0, 0n);
131
+ /** Creates an out-of-band `ContactMessage`. `nonce` omitted or `null`
132
+ * lets the library draw a random one; `ContactMode.NoKeys` requires the
133
+ * caller to supply it. */
134
+ create_contact(channel_id, contact_mode, transport_protocols, nonce) {
135
+ // The C entry point carries `Option<u64>` as a presence flag plus a
136
+ // value; an absent nonce clears the flag and the library draws one.
137
+ const result = call('create_contact_message', channel_id, contact_mode, encodeTransportList(transport_protocols), nonce == null ? 0 : 1, nonce ?? 0n);
140
138
  return {
141
139
  contact_message: decodeContact(result.contact_wire_bytes),
142
140
  secret_key: bytes(result.secret_key_material),
143
141
  };
144
142
  },
145
- /** Proto-encodes a `ContactMessage`. Rejects a contact that violates the
146
- * mode/field invariant rather than serializing it. */
147
- encode_contact: encodeContact,
148
- /** Decodes proto `ContactMessage` bytes. Rejects a contact that violates
149
- * the mode/field invariant rather than returning it. */
150
- decode_contact: decodeContact,
143
+ /** Serializes a `ContactMessage` to the bytes delivered out of band.
144
+ * Refuses a contact that violates the invariants of its contact mode or
145
+ * advertises no endpoint. */
146
+ encode_contact(contact_message) {
147
+ return bytes(call('encode_contact_message', (0, codec_1.jsonToBytes)((0, messages_1.plainMessage)(contact_message))));
148
+ },
149
+ /** Parses out-of-band contact bytes back into a `ContactMessage`.
150
+ * Refuses bytes that are not a contact, or a contact that violates the
151
+ * invariants of its contact mode. */
152
+ decode_contact(bytes) {
153
+ const json = call('decode_contact_message', bytes);
154
+ return (0, messages_1.reviveMessage)((0, codec_1.jsonFromBytes)(json));
155
+ },
151
156
  produce(kind, transport_protocols, contact_message, communication_info, parameter_range) {
152
157
  const result = call('produce_pair_request_message', kind, encodeTransportList(transport_protocols), encodeContact(contact_message), (0, messages_1.encodeOptionalMessage)(messages_1.MessageKind.CommunicationInfo, communication_info), (0, messages_1.encodeOptionalMessage)(messages_1.MessageKind.ParameterRange, parameter_range));
153
158
  return {
@@ -156,8 +161,8 @@ const pairing = {
156
161
  secret_key: bytes(result.secret_key_material),
157
162
  };
158
163
  },
159
- extract(envelope_bytes, secret_key) {
160
- const result = call('extract_pair_request', envelope_bytes, secret_key);
164
+ extract(envelope_bytes, secret_key, parameter_range) {
165
+ const result = call('extract_pair_request', envelope_bytes, secret_key, (0, messages_1.encodeOptionalMessage)(messages_1.MessageKind.ParameterRange, parameter_range));
161
166
  return {
162
167
  request: (0, messages_1.decodeMessage)(messages_1.MessageKind.PairRequest, result.request_proto_bytes),
163
168
  };
@@ -189,8 +194,8 @@ const pairing = {
189
194
  response: (0, messages_1.decodeMessage)(messages_1.MessageKind.PairResponse, result.response_proto_bytes),
190
195
  };
191
196
  },
192
- process(contact_message, response, secret_key) {
193
- const result = call('process_pair_response_message', encodeContact(contact_message), (0, messages_1.encodeMessage)(messages_1.MessageKind.PairResponse, response), secret_key);
197
+ process(contact_message, response, secret_key, parameter_range) {
198
+ const result = call('process_pair_response_message', encodeContact(contact_message), (0, messages_1.encodeMessage)(messages_1.MessageKind.PairResponse, response), secret_key, (0, messages_1.encodeOptionalMessage)(messages_1.MessageKind.ParameterRange, parameter_range));
194
199
  return { shared_key: bytes(result.shared_key), channel_id: result.channel_id };
195
200
  },
196
201
  produce_pre_pair(channel_id, request, secret_key) {
@@ -211,6 +216,24 @@ const pairing = {
211
216
  nonce: result.nonce,
212
217
  };
213
218
  },
219
+ produce_pre_pair_no_keys(channel_id, request) {
220
+ const result = call('produce_pre_pair_no_keys_response_message', channel_id, (0, messages_1.encodeMessage)(messages_1.MessageKind.PrePairRequest, request));
221
+ return {
222
+ envelope: bytes(result.envelope_wire_bytes),
223
+ secret_key_material: bytes(result.secret_key_material),
224
+ };
225
+ },
226
+ process_pre_pair_no_keys(contact_message, response) {
227
+ const result = call('process_pre_pair_no_keys_response_message', encodeContact(contact_message), (0, messages_1.encodeMessage)(messages_1.MessageKind.PrePairResponse, response));
228
+ return {
229
+ mlkem_encapsulation_key: bytes(result.mlkem_encapsulation_key),
230
+ ecies_public_key: bytes(result.ecies_public_key),
231
+ nonce: result.nonce,
232
+ };
233
+ },
234
+ },
235
+ fingerprint(shared_key) {
236
+ return call('pairing_fingerprint', shared_key);
214
237
  },
215
238
  };
216
239
  const recovery = {
package/lib/protocol.d.ts CHANGED
@@ -1,19 +1,10 @@
1
1
  import { FlowKind } from './types';
2
- import type { AutoAcceptPolicy, ChannelStore, ContactMessage, ContactMode, DeRecEvent, DiscoveryParams, PairingParams, ParameterRange, ProtectSecretParams, RecoverSecretParams, UnpairReplicaParams, SecretStore, ShareStore, StateStore, ReplicaDiscoveryParams, Timeouts, Transport, UnpairAck, UnpairParams, UpdateChannelInfoParams, UserSecretStore, VerifySharesParams } from './types';
2
+ import type { AutoAcceptPolicy, ChannelStore, ContactMessage, ContactMode, DeRecEvent, Endpoint, DiscoveryParams, PairingParams, ParameterRange, ProtectSecretParams, RecoverSecretParams, UnpairReplicaParams, SecretStore, ShareStore, StateStore, StatusEnum, ReplicaDiscoveryParams, Timeouts, Transport, UnpairAck, UnpairParams, UpdateChannelInfoParams, UserSecretStore, VerifySharesParams } from './types';
3
3
  /** Shape of the `__DeRec` host object as seen from this file: every member is
4
4
  * a plain callable, since the JSI layer exposes host functions this way and
5
5
  * TypeScript has no static knowledge of them (see `primitives.ts`'s `call`
6
6
  * helper, which uses the same escape hatch). */
7
7
  type NativeHost = Record<string, (...args: any[]) => any>;
8
- /**
9
- * Maps a transport protocol name to the `derec_proto::Protocol` discriminant.
10
- * The shared enum fixture every other numeric mapping in this SDK is checked
11
- * against does not carry this enum (it
12
- * only covers the Rust-internal serde enums listed under its `"enums"` key);
13
- * the transport `Protocol` enum lives in `protobufs/transportprotocol.proto`
14
- * instead, where `HTTPS = 0` and `GRPC = 1` are defined.
15
- */
16
- export declare function protocolDiscriminant(protocol: string): number;
17
8
  /**
18
9
  * `ProtectSecretParamsJson` (`library/src/interop/ffi/protocol/flow.rs`): every
19
10
  * `UserSecret.id`/`.data` byte array travels as a bare JSON array of decimal
@@ -47,9 +38,9 @@ export declare function buildRestoreParams(recoveredSecret: Extract<DeRecEvent,
47
38
  *
48
39
  * Every value the caller supplies is forwarded verbatim — defaults, clamping
49
40
  * and the meaning of a disabled cleanup policy are library decisions.
50
- * `threshold`, `keep_versions_count`, `auto_respond_on_failure`,
51
- * `unpair_ack`, `auto_reply_to` and `auto_accept` are omitted entirely from
52
- * the emitted config unless their setter was called: `ProtocolConfig` has a
41
+ * `threshold`, `auto_respond_on_failure`, `unpair_ack`, `auto_reply_to`
42
+ * and `auto_accept` are omitted entirely from the emitted config unless
43
+ * their setter was called: `ProtocolConfig` has a
53
44
  * `#[serde(default = "...")]` on each of them, reading the same constants
54
45
  * `DeRecProtocolBuilder::new` uses, so an absent key resolves to the
55
46
  * library's own default rather than one frozen into this shim.
@@ -58,7 +49,6 @@ export declare class DeRecProtocolBuilder {
58
49
  private readonly secretIdValue;
59
50
  private config;
60
51
  private stores;
61
- private communicationInfo;
62
52
  constructor(secretId: bigint | number);
63
53
  withChannelStore(store: ChannelStore): this;
64
54
  withShareStore(store: ShareStore): this;
@@ -66,21 +56,10 @@ export declare class DeRecProtocolBuilder {
66
56
  withUserSecretStore(store: UserSecretStore): this;
67
57
  withStateStore(store: StateStore): this;
68
58
  withTransport(transport: Transport): this;
69
- /**
70
- * @deprecated Use {@link withOwnTransports}, which takes the whole
71
- * preference list — `withOwnTransports([endpoint])` is the direct
72
- * replacement. Removed at 0.0.5.
73
- */
74
- withOwnTransport(endpoint: {
75
- uri: string;
76
- protocol: string;
77
- }): this;
78
59
  /**
79
60
  * Set every transport endpoint this application serves, in preference
80
- * order. Written to the config's `own_transports` array, which takes
81
- * precedence over `own_transport_uri` / `own_transport_protocol` on the
82
- * Rust side when non-empty — see `ProtocolConfig` in
83
- * `library/src/interop/ffi/protocol/handle/mod.rs`.
61
+ * order. Written to the config's `own_transports` array — see
62
+ * `ProtocolConfig` in `library/src/interop/ffi/protocol/handle/mod.rs`.
84
63
  *
85
64
  * The order given is forwarded verbatim: it is not sorted, deduplicated,
86
65
  * or reordered here. It is this application's own preference and
@@ -89,18 +68,12 @@ export declare class DeRecProtocolBuilder {
89
68
  * listing an endpoint this application does not serve makes pairing
90
69
  * succeed and replies vanish.
91
70
  *
92
- * Supersedes {@link withOwnTransport} for applications serving more
93
- * than one transport; the single-endpoint setter remains fully
94
- * supported.
71
+ * Required: `build()` with no own transport is refused by the library,
72
+ * since a node with no endpoint cannot be reached by any peer.
95
73
  */
96
- withOwnTransports(transports: {
97
- uri: string;
98
- protocol: string;
99
- }[]): this;
74
+ withOwnTransports(transports: Endpoint[]): this;
100
75
  /** Default: 3. */
101
76
  withThreshold(threshold: number): this;
102
- /** Default: 3. */
103
- withKeepVersionsCount(count: number): this;
104
77
  /**
105
78
  * Every field is optional; not calling this at all leaves all four at the
106
79
  * library's defaults — `timeouts` is genuinely absent from the JSON in
@@ -109,38 +82,14 @@ export declare class DeRecProtocolBuilder {
109
82
  * `snake_case` keys one for one.
110
83
  */
111
84
  withTimeouts(timeouts: Timeouts): this;
112
- /**
113
- * @deprecated Use {@link withUnsafeConnection}, which names both gated
114
- * schemes. Removed at 0.0.5. Default: false.
115
- */
116
- withUnsafeHttp(allow: boolean): this;
117
85
  /**
118
86
  * Accept plaintext `http://` and `grpc://` transport endpoints.
119
- * **Development only.** Default: false. Supersedes
120
- * {@link withUnsafeHttp}, which names only the HTTP scheme.
121
- *
122
- * Either flag alone is honored. Setting both to disagreeing values fails
123
- * construction with the error code `CONFLICTING_PLAINTEXT_OPT_IN` rather
124
- * than resolving silently, because precedence would hand the decision to
125
- * the flag being removed.
87
+ * **Development only.** Default: false.
126
88
  */
127
89
  withUnsafeConnection(allow: boolean): this;
128
90
  /**
129
- * Default: empty. `derec_protocol_new`'s own `communication_info` argument
130
- * is a pre-encoded `CommunicationInfo` protobuf message, and this SDK has
131
- * no encoder for that message — the C ABI exposes one only for
132
- * `ContactMessage`. Hand-rolling one here would be SDK-side protocol logic
133
- * with no test coverage — exactly what this codebase's "Rust decides, the
134
- * SDK only marshals" rule forbids. Instead,
135
- * `build()` constructs the protocol with an empty `communication_info`
136
- * (a legitimate, always-accepted value — see `decode_communication_info`
137
- * in `library/src/interop/ffi/protocol/handle/mod.rs`, which treats a zero-length
138
- * buffer as "no entries") and then calls the already-bound
139
- * {@link DeRecProtocol.setCommunicationInfo}, which takes the same map as
140
- * plain JSON (`derec_protocol_set_communication_info` in
141
- * `library/src/interop/ffi/protocol/handle/config.rs`). That setter is queued on
142
- * the protocol's serial worker before `build()` returns, so it is ordered
143
- * ahead of every call the caller can subsequently make.
91
+ * Default: empty. Written to the config's `communication_info` key, so the
92
+ * map is part of the protocol from construction.
144
93
  */
145
94
  withCommunicationInfo(info: Record<string, string>): this;
146
95
  /** Default: false. */
@@ -149,7 +98,10 @@ export declare class DeRecProtocolBuilder {
149
98
  withUnpairAck(ack: UnpairAck): this;
150
99
  /** Default: false. */
151
100
  withAutoReplyTo(enabled: boolean): this;
152
- /** Default: empty policy (every flow off). */
101
+ /**
102
+ * Default: empty policy (every flow off). A flow left out of `policy` is
103
+ * left out of the config, and the library applies its own default to it.
104
+ */
153
105
  withAutoAccept(policy: AutoAcceptPolicy): this;
154
106
  /** Default: unset. */
155
107
  withReplicaId(replicaId: bigint | number): this;
@@ -160,6 +112,9 @@ export declare class DeRecProtocolBuilder {
160
112
  * against the peer's range on inbound ones: a range that fails to
161
113
  * intersect rejects the pairing. Every bound is optional and defaults to
162
114
  * `0`, which the protocol reads as "no constraint on this dimension".
115
+ * Bounds cross to the library as decimal strings, so the full `i64` range
116
+ * survives; a bound left out is left out of the config, and the library
117
+ * applies its default.
163
118
  *
164
119
  * Default: unset — no constraints advertised, every peer range accepted.
165
120
  */
@@ -169,9 +124,8 @@ export declare class DeRecProtocolBuilder {
169
124
  /**
170
125
  * Thin wrapper around the `ProtocolHost` JSI host object, mirroring
171
126
  * `@derec-alliance/nodejs`'s `DeRecProtocol` — same methods, and the same
172
- * sync/async split except for `setCommunicationInfo` and `setOwnTransport`,
173
- * which return a `Promise` here (see their own doc comments for why);
174
- * `secretId` is synchronous and everything else returns a `Promise`. Every method encodes its
127
+ * sync/async split: `secretId` is synchronous and everything else returns a
128
+ * `Promise`. Every method encodes its
175
129
  * arguments into the wire shape the host function expects and decodes its
176
130
  * result back into the typed value declared here; no protocol decision is
177
131
  * made in this class.
@@ -191,53 +145,32 @@ export declare class DeRecProtocol {
191
145
  static fromHost(host: NativeHost): DeRecProtocol;
192
146
  secretId(): bigint;
193
147
  /**
194
- * Returns a `Promise`, where `@derec-alliance/nodejs` declares this
195
- * `void`. The native setter takes the same handle mutex a running flow
196
- * holds across its store callbacks, so calling it on the JavaScript thread
197
- * would block that thread until the flow released the mutex — which it
198
- * cannot do while it is waiting on the JavaScript thread. The binding
199
- * therefore queues the setter onto the same serial worker every flow runs
200
- * on, which orders it after any call already in flight. The nodejs SDK is
201
- * WASM and single-threaded, so it has no such hazard.
148
+ * Replaces this node's local communication info.
202
149
  *
203
- * Callers that ignore the result behave exactly as before, so this stays
204
- * source-compatible with nodejs-shaped code; awaiting it additionally
205
- * surfaces a failure that would otherwise be swallowed.
150
+ * The native setter takes the same handle mutex a running flow holds
151
+ * across its store callbacks, so calling it on the JavaScript thread would
152
+ * block that thread until the flow released the mutex — which it cannot do
153
+ * while it is waiting on the JavaScript thread. The binding therefore
154
+ * queues the setter onto the same serial worker every flow runs on, which
155
+ * orders it after any call already in flight. Awaiting the returned
156
+ * `Promise` surfaces a failure that would otherwise be swallowed.
206
157
  */
207
158
  setCommunicationInfo(info: Record<string, string>): Promise<void>;
208
- /**
209
- * Replace this node's endpoint for one protocol, leaving the others
210
- * alone. A node serves at most one endpoint per protocol, so the
211
- * `(uri, protocol)` pair identifies the entry it replaces; an entry for a
212
- * protocol not yet served is appended, and a replaced one keeps its
213
- * position in the preference order.
214
- *
215
- * Returns a `Promise` for the same reason {@link setCommunicationInfo} does.
216
- *
217
- * @deprecated Use {@link setOwnTransports}, which takes the whole
218
- * preference list and is the only way to change which protocols this node
219
- * serves, or their order. Removed at 0.0.5.
220
- */
221
- setOwnTransport(uri: string, protocol: string): Promise<void>;
222
159
  /**
223
160
  * Replaces every endpoint this node advertises, in preference order —
224
- * the runtime counterpart to `withOwnTransports`, and the only way to
225
- * change a multi-endpoint node's set ({@link setOwnTransport} collapses
226
- * it to the one endpoint it is given).
161
+ * the runtime counterpart to `withOwnTransports`.
227
162
  *
228
163
  * Every entry is validated before any is stored, so a malformed URI
229
164
  * leaves the previous set intact. An empty array is rejected.
230
165
  *
231
- * Returns a `Promise` for the same reason {@link setCommunicationInfo} does.
166
+ * Queued onto the serial worker for the same reason as
167
+ * {@link setCommunicationInfo}.
232
168
  */
233
- setOwnTransports(transports: {
234
- uri: string;
235
- protocol: string;
236
- }[]): Promise<void>;
169
+ setOwnTransports(transports: Endpoint[]): Promise<void>;
237
170
  /**
238
171
  * Decodes the `contact_wire_bytes` `derec_protocol_create_contact`
239
172
  * produces into a typed `ContactMessage`, so an application can read the
240
- * contact's `nonce`, `transport_protocol` and mode without a protobuf
173
+ * contact's `nonce`, `supported_transports` and mode without a protobuf
241
174
  * codec of its own. Feed the returned object straight back into
242
175
  * `start(FlowKind.Pairing, { contact })`, which re-encodes it.
243
176
  */
@@ -254,14 +187,44 @@ export declare class DeRecProtocol {
254
187
  process(message: Uint8Array): Promise<DeRecEvent[]>;
255
188
  tick(): Promise<DeRecEvent[]>;
256
189
  accept(actionBytes: Uint8Array): Promise<DeRecEvent[]>;
257
- reject(actionBytes: Uint8Array, status: number, memo: string): Promise<void>;
190
+ reject(actionBytes: Uint8Array, status: StatusEnum, memo: string): Promise<void>;
258
191
  getFingerprint(channelId: bigint | number): Promise<string>;
192
+ /**
193
+ * Verify `fingerprint` against the channel's locally-derived one. On
194
+ * match, the channel transitions from `Pending` to `Paired`. Returns
195
+ * `true` on confirmation, `false` on mismatch.
196
+ *
197
+ * On a replica destination, confirming is also the decision to adopt the
198
+ * group's vault: the source's publish is then installed as it arrives,
199
+ * with no further prompt. Ask the user before calling this; to decline,
200
+ * never confirm.
201
+ */
259
202
  verifyFingerprint(channelId: bigint | number, fingerprint: string): Promise<boolean>;
260
203
  removeExpiredChannels(olderThanSecs: number): Promise<string[]>;
204
+ /**
205
+ * Rebuild this protocol's `secret_id` namespace from a recovered `Secret`.
206
+ * Pass the `secret` carried by the `SecretRecovered` event verbatim.
207
+ * Recovery and restore are separate steps on purpose: `SecretRecovered`
208
+ * writes nothing. Show the user what was recovered, or ask them, before
209
+ * calling `restore`, which commits it to this device.
210
+ * A helper or member whose `transports` is empty gets no channel: it is
211
+ * reported as a `PeerNotRestored` event in the returned array and the rest
212
+ * of the roster is restored.
213
+ *
214
+ * Rejects with a `DeRecError`; among its codes:
215
+ *
216
+ * | code | meaning |
217
+ * |--------------------|-------------------------------------------------------------|
218
+ * | `already_restored` | A user-secret snapshot already exists for this `secret_id`. |
219
+ * | `restore_conflict` | Channels live at ids restore is about to write. The error |
220
+ * | | carries `channel_ids: string[]` listing the collisions. |
221
+ */
261
222
  restore(recoveredSecret: Extract<DeRecEvent, {
262
223
  type: 'SecretRecovered';
263
224
  }>['secret'], version: number): Promise<DeRecEvent[]>;
264
225
  /** Release the native handle. Safe to call more than once. */
265
226
  free(): void;
227
+ /** Same as {@link DeRecProtocol.free}, for `using`. */
228
+ [Symbol.dispose](): void;
266
229
  }
267
230
  export {};