@derec-alliance/nodejs 0.0.1-alpha.6 → 0.0.1-alpha.9
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 +408 -71
- package/derec_library.d.ts +369 -221
- package/derec_library.js +1376 -400
- package/derec_library_bg.wasm +0 -0
- package/derec_library_bg.wasm.d.ts +77 -11
- package/index.d.ts +1214 -0
- package/index.js +106 -0
- package/package.json +6 -4
package/derec_library.d.ts
CHANGED
|
@@ -2,263 +2,411 @@
|
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Fluent builder for [`DeRecProtocolWasm`]. Mirrors the Rust
|
|
6
|
+
* [`crate::protocol::DeRecProtocolBuilder`] and the dotnet
|
|
7
|
+
* `DeRecProtocolBuilder` method-for-method so a developer who already
|
|
8
|
+
* knows one SDK can move between them without reaching for reference
|
|
9
|
+
* docs.
|
|
10
|
+
*
|
|
11
|
+
* Required setters: `withChannelStore`, `withShareStore`,
|
|
12
|
+
* `withSecretStore`, `withTransport`, `withOwnTransport`. Calling
|
|
13
|
+
* `build()` without all five throws.
|
|
14
|
+
*
|
|
15
|
+
* All optional setters carry the defaults documented on the Rust
|
|
16
|
+
* builder.
|
|
17
|
+
*/
|
|
18
|
+
export class DeRecProtocolBuilder {
|
|
19
|
+
free(): void;
|
|
20
|
+
[Symbol.dispose](): void;
|
|
21
|
+
/**
|
|
22
|
+
* Finalize the configuration. Throws if any of the required
|
|
23
|
+
* setters was not called.
|
|
24
|
+
*/
|
|
25
|
+
build(): DeRecProtocolWasm;
|
|
26
|
+
/**
|
|
27
|
+
* `secretId` is a JS `bigint` or `number`. Identifies the single
|
|
28
|
+
* secret this protocol instance manages; apps that juggle multiple
|
|
29
|
+
* secrets instantiate one protocol per id.
|
|
30
|
+
*/
|
|
31
|
+
constructor(secret_id: any);
|
|
32
|
+
/**
|
|
33
|
+
* Per-flow auto-accept policy.
|
|
34
|
+
*
|
|
35
|
+
* `policy` shape (all fields optional, default `false`):
|
|
36
|
+
* `{ pairing, prePair, storeShare, verifyShare, discovery, getShare, unpair, updateChannelInfo }`.
|
|
37
|
+
*
|
|
38
|
+
* When a field is `true`, `process()` internally accepts the
|
|
39
|
+
* matching incoming request and emits an `AutoAccepted` event in
|
|
40
|
+
* place of `ActionRequired`. See the Rust-side
|
|
41
|
+
* `AutoAcceptPolicy` rustdoc for the per-flow trade-offs.
|
|
42
|
+
* Default: every field `false`.
|
|
43
|
+
*/
|
|
44
|
+
withAutoAccept(policy: any): DeRecProtocolBuilder;
|
|
45
|
+
/**
|
|
46
|
+
* Whether outbound requests stamp `replyTo = ownTransport`.
|
|
47
|
+
* Default: false.
|
|
48
|
+
*/
|
|
49
|
+
withAutoReplyTo(enabled: boolean): DeRecProtocolBuilder;
|
|
50
|
+
/**
|
|
51
|
+
* Whether the protocol auto-replies on failed inbound processing.
|
|
52
|
+
* Default: false.
|
|
53
|
+
*/
|
|
54
|
+
withAutoRespondOnFailure(enabled: boolean): DeRecProtocolBuilder;
|
|
55
|
+
withChannelStore(store: any): DeRecProtocolBuilder;
|
|
56
|
+
/**
|
|
57
|
+
* `info` shape: `Record<string, string>`. Default: empty.
|
|
58
|
+
*/
|
|
59
|
+
withCommunicationInfo(info: any): DeRecProtocolBuilder;
|
|
60
|
+
/**
|
|
61
|
+
* Number of recent versions each helper must retain. Default: 3.
|
|
62
|
+
*/
|
|
63
|
+
withKeepVersionsCount(count: number): DeRecProtocolBuilder;
|
|
64
|
+
/**
|
|
65
|
+
* `endpoint` shape: `{ uri: string, protocol: string }`.
|
|
66
|
+
* `protocol` must be `"https"` (the only protocol supported today).
|
|
67
|
+
*/
|
|
68
|
+
withOwnTransport(endpoint: any): DeRecProtocolBuilder;
|
|
69
|
+
/**
|
|
70
|
+
* Declare the local node's acceptable parameter range for pair
|
|
71
|
+
* negotiation. `range` is a JS object whose keys mirror the
|
|
72
|
+
* `ParameterRange` proto (`minShareSize`, `maxShareSize`,
|
|
73
|
+
* `minTimeBetweenVerifications`, ...). Each field is `i64` —
|
|
74
|
+
* accept either a number or a `BigInt` on the JS side. Default:
|
|
75
|
+
* unset (no constraints advertised, every peer range accepted).
|
|
76
|
+
*/
|
|
77
|
+
withParameterRange(range: any): DeRecProtocolBuilder;
|
|
78
|
+
/**
|
|
79
|
+
* `id` is a JS `bigint` or `number`. Default: unset.
|
|
80
|
+
*/
|
|
81
|
+
withReplicaId(id: any): DeRecProtocolBuilder;
|
|
82
|
+
withSecretStore(store: any): DeRecProtocolBuilder;
|
|
83
|
+
withShareStore(store: any): DeRecProtocolBuilder;
|
|
84
|
+
withStateStore(store: any): DeRecProtocolBuilder;
|
|
85
|
+
/**
|
|
86
|
+
* Minimum number of shares required to reconstruct the secret.
|
|
87
|
+
* Default: 3.
|
|
88
|
+
*/
|
|
89
|
+
withThreshold(threshold: number): DeRecProtocolBuilder;
|
|
90
|
+
/**
|
|
91
|
+
* Protocol-wide staleness boundary (seconds). Clamped to at least
|
|
92
|
+
* 1. Default: 300.
|
|
93
|
+
*/
|
|
94
|
+
withTimeout(timeout_in_secs: number): DeRecProtocolBuilder;
|
|
95
|
+
withTransport(transport: any): DeRecProtocolBuilder;
|
|
96
|
+
/**
|
|
97
|
+
* `ack` is `"required"` (default) or `"not_required"`.
|
|
98
|
+
*/
|
|
99
|
+
withUnpairAck(ack: string): DeRecProtocolBuilder;
|
|
100
|
+
withUserSecretStore(store: any): DeRecProtocolBuilder;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Higher-level DeRec protocol orchestrator for TypeScript/JavaScript consumers.
|
|
105
|
+
*
|
|
106
|
+
* Wraps [`DeRecProtocol`](crate::protocol::DeRecProtocol) with JS-side store
|
|
107
|
+
* and transport adapters so that a TypeScript application can drive all five
|
|
108
|
+
* protocol flows without routing raw bytes manually.
|
|
6
109
|
*
|
|
7
|
-
* #
|
|
110
|
+
* # Stores
|
|
8
111
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
112
|
+
* Pass four JS objects that implement the interfaces documented on each
|
|
113
|
+
* parameter. All store methods must return `Promise`s — synchronous
|
|
114
|
+
* implementations can wrap their result with `Promise.resolve(...)`.
|
|
11
115
|
*
|
|
12
|
-
* #
|
|
116
|
+
* # Events
|
|
13
117
|
*
|
|
14
|
-
*
|
|
118
|
+
* [`process`](DeRecProtocolWasm::process) returns an `Array` of plain JS
|
|
119
|
+
* objects, each with a `type` discriminant field:
|
|
15
120
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
121
|
+
* | `type` | Additional fields |
|
|
122
|
+
* |--------------------|--------------------------------------------------------|
|
|
123
|
+
* | `PairingCompleted` | `channel_id: string`, `pairing_channel_id: string`, `kind: number` |
|
|
124
|
+
* | `ShareStored` | `channel_id: string`, `version: number` |
|
|
125
|
+
* | `ShareConfirmed` | `channel_id: string`, `version: number` |
|
|
126
|
+
* | `ShareVerified` | `channel_id: string`, `version: number` |
|
|
127
|
+
* | `SecretsDiscovered`| `channel_id: string`, `secrets: SecretVersionEntry[]` |
|
|
128
|
+
* | `SecretRecovered` | `secret: { helpers, secrets, replicas, owner_replica_id }` (same nested shape as `ReplicaSecretReceived.secret`) |
|
|
129
|
+
* | `NoOp` | _(none)_ |
|
|
130
|
+
*
|
|
131
|
+
* `SecretVersionEntry = { secret_id: bigint, versions: { version: number, description: string }[] }`
|
|
18
132
|
*/
|
|
19
|
-
export
|
|
133
|
+
export class DeRecProtocolWasm {
|
|
134
|
+
private constructor();
|
|
135
|
+
free(): void;
|
|
136
|
+
[Symbol.dispose](): void;
|
|
137
|
+
/**
|
|
138
|
+
* Accept a pending action from an `ActionRequired` event.
|
|
139
|
+
*
|
|
140
|
+
* # Arguments
|
|
141
|
+
*
|
|
142
|
+
* * `action_bytes` — Opaque `Uint8Array` from the `action` field of an `ActionRequired` event.
|
|
143
|
+
*
|
|
144
|
+
* # Returns
|
|
145
|
+
*
|
|
146
|
+
* An `Array` of event objects (same format as `process()`).
|
|
147
|
+
*/
|
|
148
|
+
accept(action_bytes: Uint8Array): Promise<any>;
|
|
149
|
+
/**
|
|
150
|
+
* Single entry point for all three contact modes (`InlineKeys`,
|
|
151
|
+
* `HashedKeys`, `NoKeys`).
|
|
152
|
+
*
|
|
153
|
+
* * `channel_id` — `null`/`undefined` lets the library mint a
|
|
154
|
+
* random id; otherwise `bigint` / `number` is used verbatim.
|
|
155
|
+
* * `contact_mode` — `0` (InlineKeys), `1` (HashedKeys), `2` (NoKeys).
|
|
156
|
+
* * `nonce` — `null`/`undefined` lets the library generate a fresh
|
|
157
|
+
* random `u64`; otherwise the supplied `bigint`/`number` is used.
|
|
158
|
+
* Required for `NoKeys` where callers typically pick a small
|
|
159
|
+
* human-typable value.
|
|
160
|
+
*/
|
|
161
|
+
createContact(channel_id: any, contact_mode: number, nonce: any): Promise<any>;
|
|
162
|
+
/**
|
|
163
|
+
* Derive the human-readable fingerprint for a paired channel. Both
|
|
164
|
+
* sides of a replica pair derive the same fingerprint from the
|
|
165
|
+
* shared key, enabling out-of-band confirmation before the channel
|
|
166
|
+
* transitions from `Pending` to `Paired`.
|
|
167
|
+
*/
|
|
168
|
+
getFingerprint(channel_id: any): Promise<string>;
|
|
169
|
+
/**
|
|
170
|
+
* Feed any incoming wire bytes to the protocol.
|
|
171
|
+
*
|
|
172
|
+
* Returns an `Array` of plain JS event objects (see struct-level docs for shapes).
|
|
173
|
+
* All five flows (pairing, sharing, verification, discovery, recovery) are
|
|
174
|
+
* handled through this single entry point.
|
|
175
|
+
*
|
|
176
|
+
* # Arguments
|
|
177
|
+
*
|
|
178
|
+
* * `message` — Raw wire bytes of an incoming `DeRecMessage`.
|
|
179
|
+
*/
|
|
180
|
+
process(message: Uint8Array): Promise<any>;
|
|
181
|
+
/**
|
|
182
|
+
* Reject a pending action from an `ActionRequired` event.
|
|
183
|
+
*
|
|
184
|
+
* # Arguments
|
|
185
|
+
*
|
|
186
|
+
* * `action_bytes` — Opaque `Uint8Array` from the `action` field of an `ActionRequired` event.
|
|
187
|
+
* * `status` — Numeric status code from `StatusEnum` (e.g. 2 for FAIL, 10 for REJECTED).
|
|
188
|
+
* * `memo` — Human-readable rejection reason.
|
|
189
|
+
*/
|
|
190
|
+
reject(action_bytes: Uint8Array, status: number, memo: string): Promise<void>;
|
|
191
|
+
/**
|
|
192
|
+
* Rebuild this protocol's `secret_id` namespace from a recovered
|
|
193
|
+
* `Secret`. Mirrors [`crate::protocol::DeRecProtocol::restore`] —
|
|
194
|
+
* see that method for the full contract.
|
|
195
|
+
*
|
|
196
|
+
* `recoveredSecret` is the typed `Secret` object carried by the
|
|
197
|
+
* `SecretRecovered` event; pass it verbatim.
|
|
198
|
+
*
|
|
199
|
+
* Errors surface as structured JS errors with a `code` field:
|
|
200
|
+
*
|
|
201
|
+
* | code | meaning |
|
|
202
|
+
* |--------------------|------------------------------------------------------------------|
|
|
203
|
+
* | `ALREADY_RESTORED` | A user-secret snapshot already exists for this `secret_id`. |
|
|
204
|
+
* | `CONFLICT` | Channels live at canonical helper / replica ids. The error |
|
|
205
|
+
* | | carries `channel_ids: string[]` listing the collisions. |
|
|
206
|
+
* | `INVARIANT` | The recovered `Secret` is internally inconsistent. |
|
|
207
|
+
* | `STORAGE` | A store I/O call failed mid-restore. |
|
|
208
|
+
*/
|
|
209
|
+
restore(recovered_secret: any, version: number): Promise<any>;
|
|
210
|
+
/**
|
|
211
|
+
* Generate an out-of-band contact message (QR code payload, deep link, …).
|
|
212
|
+
*
|
|
213
|
+
* Returns a plain JS `ContactMessage` object. The `channel_id` field identifies
|
|
214
|
+
* the pairing session and will match the `channel_id` in the eventual
|
|
215
|
+
* `PairingCompleted` event — read it directly from the returned object.
|
|
216
|
+
*
|
|
217
|
+
* The caller is responsible for serializing the contact for out-of-band
|
|
218
|
+
* delivery (QR code, deep link, etc.). The peer passes the deserialized object
|
|
219
|
+
* to [`start`](Self::start) with `FlowKind::Pairing`.
|
|
220
|
+
*
|
|
221
|
+
* # Arguments
|
|
222
|
+
*
|
|
223
|
+
* * `channel_id` — Optional `BigInt` channel identifier. Pass `null` or
|
|
224
|
+
* `undefined` to have the library generate a random one.
|
|
225
|
+
* * `contact_mode` — `0` for `InlineKeys` (keys embedded directly), `1`
|
|
226
|
+
* for `HashedKeys` (contact carries only a SHA-384 binding hash; the
|
|
227
|
+
* scanner fetches keys via a `PrePair` round-trip). `HashedKeys`
|
|
228
|
+
* requires the protocol's `own_transport` to be ephemeral.
|
|
229
|
+
* The secret identifier this protocol instance is bound to.
|
|
230
|
+
*/
|
|
231
|
+
secretId(): bigint;
|
|
232
|
+
/**
|
|
233
|
+
* Replace this node's local communication info. Does not contact peers —
|
|
234
|
+
* follow up with a `start(UpdateChannelInfo, ...)` to propagate.
|
|
235
|
+
*/
|
|
236
|
+
setCommunicationInfo(info: any): void;
|
|
237
|
+
/**
|
|
238
|
+
* Replace this node's local transport endpoint. See
|
|
239
|
+
* `setCommunicationInfo` for the matching update-propagation flow.
|
|
240
|
+
* IMPORTANT: keep the old endpoint operational during the changeover —
|
|
241
|
+
* see the Rust docs on `set_own_transport` for the discipline.
|
|
242
|
+
*/
|
|
243
|
+
setOwnTransport(uri: string, protocol: string): void;
|
|
244
|
+
/**
|
|
245
|
+
* Unified entry point for initiating any protocol flow.
|
|
246
|
+
*
|
|
247
|
+
* # Arguments
|
|
248
|
+
*
|
|
249
|
+
* * `flow_kind` — Flow discriminant:
|
|
250
|
+
* - `0` = Pairing (params: `{ kind: number, contact: ContactMessage, name?: string }`)
|
|
251
|
+
* - `1` = Discovery (params: `{ target: BigInt | BigInt[] | null }`)
|
|
252
|
+
* - `2` = ProtectSecret (params: `{ secrets: UserSecret[], description?: string }`)
|
|
253
|
+
* - `3` = VerifyShares (params: `{ version: number, target: BigInt | BigInt[] | null }`)
|
|
254
|
+
* - `4` = RecoverSecret (params: `{ secretId: Uint8Array, version: number }`)
|
|
255
|
+
*
|
|
256
|
+
* # Returns
|
|
257
|
+
*
|
|
258
|
+
* An `Array` of `*Started` / `*Failed` events describing the
|
|
259
|
+
* dispatched requests. Same shape as `process()`.
|
|
260
|
+
*/
|
|
261
|
+
start(flow_kind: number, params: any): Promise<any>;
|
|
262
|
+
/**
|
|
263
|
+
* Verify a fingerprint against the channel's locally-derived one. On
|
|
264
|
+
* match, the channel transitions from `Pending` to `Paired`. Returns
|
|
265
|
+
* `true` when the fingerprint matches and the channel is confirmed,
|
|
266
|
+
* `false` otherwise.
|
|
267
|
+
*/
|
|
268
|
+
verifyFingerprint(channel_id: any, fingerprint: string): Promise<boolean>;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
export function discovery_request_extract(envelope_bytes: Uint8Array, shared_key: Uint8Array): any;
|
|
272
|
+
|
|
273
|
+
export function discovery_request_produce(channel_id: bigint, shared_key: Uint8Array, reply_to: any): any;
|
|
274
|
+
|
|
275
|
+
export function discovery_response_extract(envelope_bytes: Uint8Array, shared_key: Uint8Array): any;
|
|
276
|
+
|
|
277
|
+
export function discovery_response_process(response: any): any;
|
|
278
|
+
|
|
279
|
+
export function discovery_response_produce(channel_id: bigint, secret_list: any, shared_key: Uint8Array): any;
|
|
20
280
|
|
|
21
281
|
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* * `channel_id` - Helper channel identifier
|
|
27
|
-
* * `secret_id` - Secret identifier being recovered
|
|
28
|
-
* * `version` - Share version being requested
|
|
29
|
-
* * `shared_key` - 32-byte symmetric key established during pairing
|
|
30
|
-
*
|
|
31
|
-
* # Returns
|
|
282
|
+
* Overwrite `trace_id` on a primitive-produced envelope and return the
|
|
283
|
+
* re-encoded bytes. The outer envelope is plaintext, so this does no
|
|
284
|
+
* crypto work.
|
|
32
285
|
*
|
|
33
|
-
*
|
|
34
|
-
* `
|
|
286
|
+
* Useful for consumers driving the protocol through primitives directly
|
|
287
|
+
* (the orchestrator-level `DeRecProtocol` already handles trace_id
|
|
288
|
+
* end-to-end on its own).
|
|
35
289
|
*/
|
|
36
|
-
export function
|
|
290
|
+
export function envelope_apply_trace_id(envelope_bytes: Uint8Array, trace_id: bigint): Uint8Array;
|
|
37
291
|
|
|
38
292
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* * `secret_id` - Secret identifier being recovered
|
|
44
|
-
* * `channel_id` - Helper channel identifier
|
|
45
|
-
* * `stored_share_request_wire_bytes` - Serialized outer `DeRecMessage` bytes
|
|
46
|
-
* carrying the encrypted inner `StoreShareRequestMessage` previously produced
|
|
47
|
-
* by the sharing flow for this helper
|
|
48
|
-
* * `request_wire_bytes` - Serialized outer `DeRecMessage` bytes carrying the
|
|
49
|
-
* encrypted inner `GetShareRequestMessage`
|
|
50
|
-
* * `shared_key` - 32-byte symmetric key established during pairing
|
|
51
|
-
*
|
|
52
|
-
* # Returns
|
|
53
|
-
*
|
|
54
|
-
* Serialized outer `DeRecMessage` bytes carrying an encrypted inner
|
|
55
|
-
* `GetShareResponseMessage`.
|
|
293
|
+
* Read `trace_id` off an inbound envelope without touching the encrypted
|
|
294
|
+
* inner payload. Returns `0` when the sender didn't set one — the protobuf
|
|
295
|
+
* default is indistinguishable from an explicit zero.
|
|
56
296
|
*/
|
|
57
|
-
export function
|
|
297
|
+
export function envelope_read_trace_id(envelope_bytes: Uint8Array): bigint;
|
|
58
298
|
|
|
59
299
|
/**
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
* * `secret_id` - Secret identifier
|
|
65
|
-
* * `channel_id` - Helper channel identifier
|
|
66
|
-
* * `version` - Share-distribution version being verified
|
|
67
|
-
* * `shared_key` - 32-byte symmetric key established during pairing
|
|
68
|
-
*
|
|
69
|
-
* # Returns
|
|
70
|
-
*
|
|
71
|
-
* A JS object with:
|
|
72
|
-
*
|
|
73
|
-
* - `wire_bytes`: serialized outer `DeRecMessage` bytes carrying an encrypted
|
|
74
|
-
* inner `VerifyShareRequestMessage`
|
|
300
|
+
* Structurally validate a JS-side [`ContactMessage`]. Throws on any
|
|
301
|
+
* mode/field inconsistency (unknown `contact_mode`, mode/field mismatch,
|
|
302
|
+
* wrong binding-hash length).
|
|
75
303
|
*/
|
|
76
|
-
export function
|
|
304
|
+
export function pairing_contact_message_validate(contact_message: any): void;
|
|
305
|
+
|
|
306
|
+
export function pairing_request_create_contact(channel_id: bigint, contact_mode: number, transport_protocol: any, nonce: any): any;
|
|
77
307
|
|
|
78
308
|
/**
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
* * `secret_id` - Secret identifier
|
|
84
|
-
* * `channel_id` - Helper channel identifier
|
|
85
|
-
* * `shared_key` - 32-byte symmetric key established during pairing
|
|
86
|
-
* * `share_content` - Share bytes whose possession is being proven
|
|
87
|
-
* * `request_bytes` - Serialized outer `DeRecMessage` bytes carrying encrypted
|
|
88
|
-
* inner `VerifyShareRequestMessage`
|
|
89
|
-
*
|
|
90
|
-
* # Returns
|
|
91
|
-
*
|
|
92
|
-
* A JS object with:
|
|
93
|
-
*
|
|
94
|
-
* - `wire_bytes`: serialized outer `DeRecMessage` bytes carrying an encrypted
|
|
95
|
-
* inner `VerifyShareResponseMessage`
|
|
309
|
+
* Decodes a proto-encoded [`ContactMessage`]. Structurally validates the
|
|
310
|
+
* decoded value before returning it to application code so consumers can
|
|
311
|
+
* trust the mode/field invariants documented on the wire format.
|
|
96
312
|
*/
|
|
97
|
-
export function
|
|
313
|
+
export function pairing_request_decode_contact(bytes: Uint8Array): any;
|
|
98
314
|
|
|
99
315
|
/**
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
* # Arguments
|
|
106
|
-
*
|
|
107
|
-
* * `contact_message_bytes` - Plain serialized `ContactMessage` bytes
|
|
108
|
-
* * `pair_response_wire_bytes` - Serialized outer `DeRecMessage` carrying encrypted inner response bytes
|
|
109
|
-
* * `pairing_secret_key_material` - Serialized responder-side `PairingSecretKeyMaterial`
|
|
110
|
-
*
|
|
111
|
-
* # Returns
|
|
112
|
-
*
|
|
113
|
-
* A JS object with:
|
|
114
|
-
*
|
|
115
|
-
* - `pairing_shared_key`: final shared pairing key
|
|
316
|
+
* Encodes a [`ContactMessage`] to proto wire bytes. Structurally validates
|
|
317
|
+
* the input first so a locally-constructed contact that violates the
|
|
318
|
+
* mode/field invariant is rejected at the boundary rather than silently
|
|
319
|
+
* serialized.
|
|
116
320
|
*/
|
|
117
|
-
export function
|
|
321
|
+
export function pairing_request_encode_contact(contact_message: any): Uint8Array;
|
|
322
|
+
|
|
323
|
+
export function pairing_request_extract(envelope_bytes: Uint8Array, secret_key: Uint8Array): any;
|
|
118
324
|
|
|
119
325
|
/**
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
* This is the **responder-side** step: the party that received the out-of-band
|
|
123
|
-
* contact creates the pairing request.
|
|
124
|
-
*
|
|
125
|
-
* # Arguments
|
|
126
|
-
*
|
|
127
|
-
* * `kind` - Sender role encoded as:
|
|
128
|
-
* - `0` => `SharerNonRecovery`
|
|
129
|
-
* - `1` => `SharerRecovery`
|
|
130
|
-
* - `2` => `Helper`
|
|
131
|
-
* * `transport_uri` - Transport endpoint the responder can use to receive follow-up traffic
|
|
132
|
-
* * `contact_message_bytes` - Plain serialized `ContactMessage` bytes
|
|
133
|
-
*
|
|
134
|
-
* # Returns
|
|
135
|
-
*
|
|
136
|
-
* A JS object with:
|
|
137
|
-
*
|
|
138
|
-
* - `wire_bytes`: serialized outer `DeRecMessage` bytes
|
|
139
|
-
* - `secret_key_material`: serialized responder-side `PairingSecretKeyMaterial`
|
|
326
|
+
* Initiator-side: decode an inbound plaintext `PrePairRequest` envelope.
|
|
140
327
|
*/
|
|
141
|
-
export function
|
|
328
|
+
export function pairing_request_extract_pre_pair(envelope_bytes: Uint8Array): any;
|
|
329
|
+
|
|
330
|
+
export function pairing_request_produce(kind: number, transport_protocol: any, contact_message: any, communication_info: any, parameter_range: any): any;
|
|
142
331
|
|
|
143
332
|
/**
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
*
|
|
153
|
-
* - `1` => `SharerRecovery`
|
|
154
|
-
* - `2` => `Helper`
|
|
155
|
-
* * `pair_request_wire_bytes` - Serialized outer `DeRecMessage` carrying encrypted inner request bytes
|
|
156
|
-
* * `pairing_secret_key_material` - Serialized initiator-side `PairingSecretKeyMaterial`
|
|
157
|
-
*
|
|
158
|
-
* # Returns
|
|
159
|
-
*
|
|
160
|
-
* A JS object with:
|
|
161
|
-
*
|
|
162
|
-
* - `wire_bytes`: serialized outer `DeRecMessage` bytes carrying encrypted inner response bytes
|
|
163
|
-
* - `transport_protocol`: transport information extracted from the pairing request
|
|
164
|
-
* - `pairing_shared_key`: final shared pairing key
|
|
333
|
+
* Scanner-side: build the plaintext `PrePairRequest` envelope for a
|
|
334
|
+
* `HASHED_KEYS` contact.
|
|
335
|
+
*/
|
|
336
|
+
export function pairing_request_produce_pre_pair(transport_protocol: any, contact_message: any): any;
|
|
337
|
+
|
|
338
|
+
export function pairing_response_extract(envelope_bytes: Uint8Array, secret_key: Uint8Array): any;
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Scanner-side: decode the inbound plaintext `PrePairResponse` envelope.
|
|
165
342
|
*/
|
|
166
|
-
export function
|
|
343
|
+
export function pairing_response_extract_pre_pair(envelope_bytes: Uint8Array): any;
|
|
344
|
+
|
|
345
|
+
export function pairing_response_process(contact_message: any, response: any, secret_key: Uint8Array): any;
|
|
167
346
|
|
|
168
347
|
/**
|
|
169
|
-
*
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
* # JavaScript input shape
|
|
173
|
-
*
|
|
174
|
-
* The `channels` argument must be a JS array of objects like:
|
|
175
|
-
*
|
|
176
|
-
* ```ts
|
|
177
|
-
* [
|
|
178
|
-
* { channel_id: 1, shared_key: new Uint8Array(32) },
|
|
179
|
-
* { channel_id: 2, shared_key: new Uint8Array(32) },
|
|
180
|
-
* ]
|
|
181
|
-
* ```
|
|
182
|
-
*
|
|
183
|
-
* Each `shared_key` must be exactly 32 bytes.
|
|
184
|
-
*
|
|
185
|
-
* The `keep_list` argument may be:
|
|
186
|
-
*
|
|
187
|
-
* - `undefined` or `null`, meaning no keep-list is provided
|
|
188
|
-
* - an array of integers, for example:
|
|
189
|
-
*
|
|
190
|
-
* ```ts
|
|
191
|
-
* [1, 2, 3]
|
|
192
|
-
* ```
|
|
193
|
-
*
|
|
194
|
-
* The `description` argument may be:
|
|
195
|
-
*
|
|
196
|
-
* - `undefined` or `null`, meaning no description is provided
|
|
197
|
-
* - a string, for example:
|
|
198
|
-
*
|
|
199
|
-
* ```ts
|
|
200
|
-
* "initial distribution"
|
|
201
|
-
* ```
|
|
202
|
-
*
|
|
203
|
-
* # Returns
|
|
204
|
-
*
|
|
205
|
-
* A JS object of the form:
|
|
206
|
-
*
|
|
207
|
-
* ```ts
|
|
208
|
-
* {
|
|
209
|
-
* value: {
|
|
210
|
-
* [channelId: number]: Uint8Array
|
|
211
|
-
* }
|
|
212
|
-
* }
|
|
213
|
-
* ```
|
|
214
|
-
*
|
|
215
|
-
* where each value is a serialized outer `DeRecMessage` envelope.
|
|
216
|
-
*
|
|
217
|
-
* # Arguments
|
|
218
|
-
*
|
|
219
|
-
* * `secret_id` - Secret identifier embedded into each generated share
|
|
220
|
-
* * `secret_data` - Secret bytes to split and distribute
|
|
221
|
-
* * `channels` - JS array of `{ channel_id, shared_key }` entries
|
|
222
|
-
* * `threshold` - Minimum number of shares required for reconstruction
|
|
223
|
-
* * `version` - Share-distribution version embedded into the generated messages
|
|
224
|
-
* * `keep_list` - Optional JS array of versions helpers should retain
|
|
225
|
-
* * `description` - Optional version description
|
|
348
|
+
* Scanner-side: validate the `PrePairResponse` against the contact's
|
|
349
|
+
* SHA-384 binding hash. Returns the validated keys + nonce on match.
|
|
226
350
|
*/
|
|
227
|
-
export function
|
|
351
|
+
export function pairing_response_process_pre_pair(contact_message: any, response: any): any;
|
|
352
|
+
|
|
353
|
+
export function pairing_response_produce(channel_id: bigint, request: any, secret_key: Uint8Array, communication_info: any, parameter_range: any): any;
|
|
228
354
|
|
|
229
355
|
/**
|
|
230
|
-
*
|
|
231
|
-
*
|
|
232
|
-
* # Arguments
|
|
233
|
-
*
|
|
234
|
-
* * `responses` - JS array of recovery response inputs. Each entry must contain:
|
|
235
|
-
* - `response_bytes`: serialized outer `DeRecMessage` response envelope
|
|
236
|
-
* - `shared_key`: 32-byte symmetric key for decrypting that response
|
|
237
|
-
* * `secret_id` - Secret identifier being recovered
|
|
238
|
-
* * `version` - Secret version being recovered
|
|
239
|
-
*
|
|
240
|
-
* # Returns
|
|
241
|
-
*
|
|
242
|
-
* The reconstructed secret bytes.
|
|
356
|
+
* Contact-creator side: publish the actual public keys back to the scanner.
|
|
243
357
|
*/
|
|
244
|
-
export function
|
|
358
|
+
export function pairing_response_produce_pre_pair(channel_id: bigint, request: any, secret_key: Uint8Array): any;
|
|
359
|
+
|
|
360
|
+
export function recovery_request_extract(envelope_bytes: Uint8Array, shared_key: Uint8Array): any;
|
|
361
|
+
|
|
362
|
+
export function recovery_request_produce(channel_id: bigint, secret_id: bigint, version: number, shared_key: Uint8Array, reply_to: any): any;
|
|
363
|
+
|
|
364
|
+
export function recovery_response_extract(envelope_bytes: Uint8Array, shared_key: Uint8Array): any;
|
|
365
|
+
|
|
366
|
+
export function recovery_response_produce(channel_id: bigint, request: any, stored_share_request: any, shared_key: Uint8Array): any;
|
|
367
|
+
|
|
368
|
+
export function recovery_response_recover(secret_id: bigint, version: number, responses: any): any;
|
|
369
|
+
|
|
370
|
+
export function sharing_request_extract(envelope_bytes: Uint8Array, shared_key: Uint8Array): any;
|
|
371
|
+
|
|
372
|
+
export function sharing_request_produce(channel_id: bigint, version: number, secret_id: bigint, committed_share: any, keep_list: any, description: string, shared_key: Uint8Array, reply_to: any, replica_id: any): any;
|
|
373
|
+
|
|
374
|
+
export function sharing_request_split(channels: any, secret_id: bigint, version: number, secret_data: Uint8Array, threshold: number): any;
|
|
375
|
+
|
|
376
|
+
export function sharing_response_extract(envelope_bytes: Uint8Array, shared_key: Uint8Array): any;
|
|
377
|
+
|
|
378
|
+
export function sharing_response_process(version: number, response: any): void;
|
|
379
|
+
|
|
380
|
+
export function sharing_response_produce(channel_id: bigint, request: any, shared_key: Uint8Array): any;
|
|
381
|
+
|
|
382
|
+
export function unpairing_request_extract(envelope_bytes: Uint8Array, shared_key: Uint8Array): any;
|
|
383
|
+
|
|
384
|
+
export function unpairing_request_produce(channel_id: bigint, memo: string, shared_key: Uint8Array, reply_to: any): any;
|
|
385
|
+
|
|
386
|
+
export function unpairing_response_extract(envelope_bytes: Uint8Array, shared_key: Uint8Array): any;
|
|
387
|
+
|
|
388
|
+
export function unpairing_response_process(response: any): any;
|
|
389
|
+
|
|
390
|
+
export function unpairing_response_produce(channel_id: bigint, shared_key: Uint8Array): any;
|
|
391
|
+
|
|
392
|
+
export function verification_request_extract(envelope_bytes: Uint8Array, shared_key: Uint8Array): any;
|
|
393
|
+
|
|
394
|
+
export function verification_request_produce(channel_id: bigint, secret_id: bigint, version: number, shared_key: Uint8Array, reply_to: any): any;
|
|
395
|
+
|
|
396
|
+
export function verification_response_extract(envelope_bytes: Uint8Array, shared_key: Uint8Array): any;
|
|
245
397
|
|
|
246
398
|
/**
|
|
247
|
-
*
|
|
248
|
-
*
|
|
249
|
-
*
|
|
250
|
-
*
|
|
251
|
-
*
|
|
252
|
-
*
|
|
253
|
-
*
|
|
254
|
-
*
|
|
255
|
-
* * `response_bytes` - Serialized outer `DeRecMessage` bytes carrying encrypted
|
|
256
|
-
* inner `VerifyShareResponseMessage`
|
|
257
|
-
*
|
|
258
|
-
* # Returns
|
|
259
|
-
*
|
|
260
|
-
* `true` if the verification response is valid, otherwise `false`.
|
|
399
|
+
* Verify a `VerifyShareResponseMessage` against the originating
|
|
400
|
+
* `VerifyShareRequestMessage` and the expected share content.
|
|
401
|
+
*
|
|
402
|
+
* `request` must be the request the **owner** previously produced for
|
|
403
|
+
* this challenge (kept by the caller in a per-`channel_id` pending-
|
|
404
|
+
* verification map). The primitive rejects any response whose
|
|
405
|
+
* `(nonce, secret_id, version)` triple doesn't match — that's the
|
|
406
|
+
* anti-replay gate.
|
|
261
407
|
*/
|
|
262
|
-
export function
|
|
408
|
+
export function verification_response_process(request: any, response: any, share_content: Uint8Array): boolean;
|
|
409
|
+
|
|
410
|
+
export function verification_response_produce(channel_id: bigint, request: any, shared_key: Uint8Array, share_content: Uint8Array): any;
|
|
263
411
|
|
|
264
412
|
export function wasm_start(): void;
|