@derec-alliance/react-native 0.0.2 → 0.0.4
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 +46 -2
- package/android/src/main/jniLibs/arm64-v8a/libderec_library.a +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libderec_library.a +0 -0
- package/android/src/main/jniLibs/x86_64/libderec_library.a +0 -0
- package/cpp/Primitives.cpp +27 -18
- package/cpp/ProtocolHost.cpp +37 -0
- package/cpp/StoreCallbacks.cpp +127 -19
- package/cpp/derec_ffi.h +145 -24
- package/ios/DeRecFFI.xcframework/ios-arm64/Headers/derec_ffi.h +145 -24
- package/ios/DeRecFFI.xcframework/ios-arm64/libderec_library.a +0 -0
- package/ios/DeRecFFI.xcframework/ios-arm64_x86_64-simulator/Headers/derec_ffi.h +145 -24
- package/ios/DeRecFFI.xcframework/ios-arm64_x86_64-simulator/libderec_library.a +2 -2
- package/lib/primitives.d.ts +9 -9
- package/lib/primitives.js +63 -13
- package/lib/protocol.d.ts +85 -6
- package/lib/protocol.js +119 -8
- package/lib/types.d.ts +313 -29
- package/lib/types.js +109 -2
- package/package.json +2 -1
- package/src/primitives.ts +77 -21
- package/src/protocol.ts +138 -13
- package/src/types.ts +379 -35
package/lib/types.d.ts
CHANGED
|
@@ -10,6 +10,99 @@ export interface SecretStore {
|
|
|
10
10
|
save(secretId: string, channelId: string, kind: 0 | 1 | 2, value: Uint8Array): Promise<void>;
|
|
11
11
|
remove(secretId: string, channelId: string, kind: 0 | 1 | 2): Promise<void>;
|
|
12
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* A channel's lifecycle status, as the Rust variant name the core emits.
|
|
15
|
+
*/
|
|
16
|
+
export type ChannelStatusName = "Pending" | "Paired" | "Unpairing";
|
|
17
|
+
/**
|
|
18
|
+
* A peer's role on a helper channel, as the Rust variant name.
|
|
19
|
+
*/
|
|
20
|
+
export type SenderKindName = "Owner" | "Helper" | "ReplicaSource" | "ReplicaDestination";
|
|
21
|
+
/**
|
|
22
|
+
* A member's role within a replica group, as the Rust variant name.
|
|
23
|
+
*/
|
|
24
|
+
export type ReplicaRoleName = "Source" | "Destination";
|
|
25
|
+
/**
|
|
26
|
+
* Narrows a listing from {@link ChannelStore}.
|
|
27
|
+
*
|
|
28
|
+
* Every field is a restriction, and every field's empty value means "do not
|
|
29
|
+
* restrict on this" — a filter of all-empties selects everything.
|
|
30
|
+
* Restrictions combine with AND, and `exclude` is applied last, overriding
|
|
31
|
+
* `ids`.
|
|
32
|
+
*
|
|
33
|
+
* **Returning everything under the `secretId` and ignoring the filter is
|
|
34
|
+
* correct**, and the implementation to write unless there is a measured reason
|
|
35
|
+
* not to. The library re-applies the filter to whatever you return and drops
|
|
36
|
+
* what it excludes, so a superset is trimmed before anything acts on it.
|
|
37
|
+
*
|
|
38
|
+
* Pushing the filter into your query — a `WHERE` clause, a key-condition
|
|
39
|
+
* expression — is an optimization you opt into. It saves transferring rows the
|
|
40
|
+
* caller discards, which costs bandwidth everywhere and real money on a metered
|
|
41
|
+
* backing that bills by bytes read. Verify one against
|
|
42
|
+
* `library/tests/fixtures/channel_filter.json`.
|
|
43
|
+
*
|
|
44
|
+
* The asymmetry is what makes pushdown worth verifying: the re-check can drop
|
|
45
|
+
* rows but cannot recover one that was never returned, so selecting too *few*
|
|
46
|
+
* is undetectable at runtime — no exception, no event, just a share that was
|
|
47
|
+
* never published. That matters most here, because TypeScript accepts a
|
|
48
|
+
* function of fewer parameters where more are declared: a store written before
|
|
49
|
+
* this parameter existed still satisfies the interface and compiles clean under
|
|
50
|
+
* `--strict`, so the type system cannot see the gap either.
|
|
51
|
+
*
|
|
52
|
+
* Ids are decimal strings, like every other `u64` on this bridge.
|
|
53
|
+
*/
|
|
54
|
+
export interface ChannelFilter<Role> {
|
|
55
|
+
/** Restrict to these ids. Empty selects every record. */
|
|
56
|
+
ids: string[];
|
|
57
|
+
/** Restrict to these statuses. Empty selects any status. */
|
|
58
|
+
status: ChannelStatusName[];
|
|
59
|
+
/** Restrict to this role. `null` selects any role. */
|
|
60
|
+
role: Role | null;
|
|
61
|
+
/** Omit these ids, applied after `ids`. Empty omits nothing. */
|
|
62
|
+
exclude: string[];
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Whether a channel or member with these attributes survives `filter`.
|
|
66
|
+
*
|
|
67
|
+
* Every empty field means "do not restrict", `exclude` is applied after `ids`,
|
|
68
|
+
* and the restrictions combine with AND — the same contract the core states on
|
|
69
|
+
* `ChannelFilter`. A store whose backing cannot express the filter as a query
|
|
70
|
+
* can list and call this; that is correct but transfers the rows the filter
|
|
71
|
+
* exists to leave behind.
|
|
72
|
+
*
|
|
73
|
+
* `id` is a decimal string, as ids are everywhere on this bridge. `role` is the
|
|
74
|
+
* peer's `SenderKind` name for `listHelpers` and the member's `ReplicaRole`
|
|
75
|
+
* name for `listReplicas`.
|
|
76
|
+
*/
|
|
77
|
+
export declare function channelFilterMatches(filter: HelperFilter | ReplicaFilter | null | undefined, id: string, status: ChannelStatusName, role: SenderKindName | ReplicaRoleName): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* The endpoints a peer-supplied message advertises, in the peer's own order.
|
|
80
|
+
*
|
|
81
|
+
* Yields `supported_transports` when it is non-empty, and otherwise the
|
|
82
|
+
* singular `transport_protocol` — which is how every implementation predating
|
|
83
|
+
* the offer list advertises, and the reason this is a function rather than a
|
|
84
|
+
* field read. Reading `transport_protocol` directly is a bug: its meaning
|
|
85
|
+
* narrowed to "one entry of a list, and possibly absent", so a peer that has
|
|
86
|
+
* moved past it looks unreachable to a reader that was correct before 0.0.3.
|
|
87
|
+
*
|
|
88
|
+
* Reports what was advertised, not what is acceptable — nothing here is
|
|
89
|
+
* validated, and the protocol still applies its own transport policy to
|
|
90
|
+
* whatever it records.
|
|
91
|
+
*/
|
|
92
|
+
export declare function advertisedEndpoints(message: {
|
|
93
|
+
transport_protocol?: TransportProtocol;
|
|
94
|
+
supported_transports?: TransportProtocol[];
|
|
95
|
+
} | null | undefined): TransportProtocol[];
|
|
96
|
+
/**
|
|
97
|
+
* Narrows `listHelpers`. Ids are the channel's `channel_id` and the role is
|
|
98
|
+
* the **peer's** `peer_role`.
|
|
99
|
+
*/
|
|
100
|
+
export type HelperFilter = ChannelFilter<SenderKindName>;
|
|
101
|
+
/**
|
|
102
|
+
* Narrows `listReplicas`. Ids are the member's `replica_id` and the role is
|
|
103
|
+
* the member's `role`.
|
|
104
|
+
*/
|
|
105
|
+
export type ReplicaFilter = ChannelFilter<ReplicaRoleName>;
|
|
13
106
|
/**
|
|
14
107
|
* Channel-record persistence.
|
|
15
108
|
*
|
|
@@ -30,7 +123,7 @@ export interface SecretStore {
|
|
|
30
123
|
*
|
|
31
124
|
* `listHelpers` and `listReplicas` are **not** arrays of that union — they
|
|
32
125
|
* return a JSON array of the **inner** records with the tag stripped:
|
|
33
|
-
* `[{ channel_id,
|
|
126
|
+
* `[{ schema_version, channel_id, transports, ... }, ...]`, `HelperChannel` for the first and
|
|
34
127
|
* `ReplicaMember` for the second. Wrapping each element back in
|
|
35
128
|
* `{ "Helper": ... }` will not decode.
|
|
36
129
|
*
|
|
@@ -50,8 +143,16 @@ export interface ChannelStore {
|
|
|
50
143
|
load(secretId: string, channelId: string, replicaId: string): Promise<Uint8Array | null | undefined>;
|
|
51
144
|
save(secretId: string, channelId: string, replicaId: string, bytes: Uint8Array): Promise<void>;
|
|
52
145
|
remove(secretId: string, channelId: string, replicaId: string): Promise<boolean>;
|
|
53
|
-
/**
|
|
54
|
-
|
|
146
|
+
/**
|
|
147
|
+
* JSON array of the helper channels stored under `secretId` that `filter`
|
|
148
|
+
* selects.
|
|
149
|
+
*
|
|
150
|
+
* Apply the filter in your query rather than listing everything and
|
|
151
|
+
* discarding rows; see {@link ChannelFilter}. The library re-applies it to
|
|
152
|
+
* whatever you return, so ignoring it is slow rather than wrong — but
|
|
153
|
+
* returning fewer rows than it selects is wrong, and undetectable.
|
|
154
|
+
*/
|
|
155
|
+
listHelpers(secretId: string, filter: HelperFilter): Promise<Uint8Array | null | undefined>;
|
|
55
156
|
/**
|
|
56
157
|
* JSON array of the replica-group members stored under `secretId`,
|
|
57
158
|
* including this device's own row.
|
|
@@ -70,7 +171,7 @@ export interface ChannelStore {
|
|
|
70
171
|
* insertion order after arbitrary edits are both effectively arbitrary.
|
|
71
172
|
* Order explicitly to make succession predictable.
|
|
72
173
|
*/
|
|
73
|
-
listReplicas(secretId: string): Promise<Uint8Array | null | undefined>;
|
|
174
|
+
listReplicas(secretId: string, filter: ReplicaFilter): Promise<Uint8Array | null | undefined>;
|
|
74
175
|
linkChannel(secretId: string, channelId: string, linkedChannelId: string): Promise<void>;
|
|
75
176
|
linkedChannels(secretId: string, channelId: string): Promise<string[]>;
|
|
76
177
|
}
|
|
@@ -114,7 +215,7 @@ export interface UserSecretStore {
|
|
|
114
215
|
* returns the exact blob it received, `remove` drops the row, and
|
|
115
216
|
* `loadAll` returns every blob whose `kind` matches the requested
|
|
116
217
|
* category (`0` = PendingVerification, `1` = PendingRecovery,
|
|
117
|
-
* `2` = PendingUnpair, `3` = SharingRound, `4` =
|
|
218
|
+
* `2` = PendingUnpair, `3` = SharingRound, `4` = PendingReplicaDiscovery).
|
|
118
219
|
*
|
|
119
220
|
* Rows are keyed by `(secretId, StateKey)` — the `keyJson` buffer is
|
|
120
221
|
* a JSON object `{ kind, channel_id?, version? }` matching the `kind`
|
|
@@ -152,11 +253,80 @@ export interface StateStore {
|
|
|
152
253
|
* DeRec over request/response transports" in the Rust SDK README.
|
|
153
254
|
*/
|
|
154
255
|
export interface Transport {
|
|
155
|
-
|
|
256
|
+
/**
|
|
257
|
+
* Delivers `message` to a peer reachable at any of `endpoints`.
|
|
258
|
+
*
|
|
259
|
+
* `endpoints` are the addresses that peer advertised, in the order it
|
|
260
|
+
* offered them, already filtered to those the library will record. The
|
|
261
|
+
* library does not rank them: which to dial, and whether to fall back when
|
|
262
|
+
* one is unreachable, is this implementation's choice. Never empty.
|
|
263
|
+
*
|
|
264
|
+
* Delivery to any one endpoint is success. Reject only when the message
|
|
265
|
+
* reached none of them.
|
|
266
|
+
*
|
|
267
|
+
* **Deliver once.** Every entry addresses the same peer, so sending to all
|
|
268
|
+
* of them delivers one authenticated message several times. Stop at the
|
|
269
|
+
* first success. The protocol's handlers are idempotent, so a duplicate
|
|
270
|
+
* does not corrupt state, but it is still a duplicate to anything counting
|
|
271
|
+
* messages, and a peer entitled to treat re-delivery as a replay will.
|
|
272
|
+
*
|
|
273
|
+
* **Prefer an adapter to writing this by hand.** Choosing which endpoint to
|
|
274
|
+
* dial is yours and stays here; the bookkeeping around it is the same
|
|
275
|
+
* everywhere and is already written and tested. Write a {@link SendOne} and
|
|
276
|
+
* wrap it in {@link sequentialFailover}. Taking `endpoints[0]` type-checks,
|
|
277
|
+
* passes every test, and silently gives up the failover the list exists to
|
|
278
|
+
* provide — if that is genuinely wanted, say so with
|
|
279
|
+
* {@link singleEndpointTransport} rather than by indexing.
|
|
280
|
+
*/
|
|
281
|
+
send(endpoints: ReadonlyArray<{
|
|
156
282
|
protocol: string;
|
|
157
283
|
uri: string;
|
|
158
|
-
}
|
|
284
|
+
}>, message: Uint8Array): Promise<void>;
|
|
159
285
|
}
|
|
286
|
+
/**
|
|
287
|
+
* Delivers one message to one endpoint.
|
|
288
|
+
*
|
|
289
|
+
* The narrow half of a transport: everything genuinely about dialing, and
|
|
290
|
+
* nothing about which endpoint to dial. Pass one of these to
|
|
291
|
+
* {@link sequentialFailover} or {@link singleEndpointTransport} to get a
|
|
292
|
+
* {@link Transport}.
|
|
293
|
+
*
|
|
294
|
+
* Rejecting means the endpoint did not receive the message. The rejection
|
|
295
|
+
* reason need not distinguish "unreachable" from "rejected":
|
|
296
|
+
* {@link sequentialFailover} treats both as a reason to try the next endpoint,
|
|
297
|
+
* which is the safe reading. Trying an endpoint that would have refused costs
|
|
298
|
+
* a round trip; skipping one that would have worked costs the delivery.
|
|
299
|
+
*/
|
|
300
|
+
export type SendOne = (endpoint: {
|
|
301
|
+
protocol: string;
|
|
302
|
+
uri: string;
|
|
303
|
+
}, message: Uint8Array) => Promise<void>;
|
|
304
|
+
/**
|
|
305
|
+
* Builds a {@link Transport} that tries each endpoint in the order the peer
|
|
306
|
+
* offered it and stops at the first success.
|
|
307
|
+
*
|
|
308
|
+
* An error is thrown only when every endpoint failed. The message is delivered
|
|
309
|
+
* at most once.
|
|
310
|
+
*
|
|
311
|
+
* This is the right default. A peer advertising several endpoints is saying it
|
|
312
|
+
* can be reached at any of them, and the reason 0.0.3 records the whole list is
|
|
313
|
+
* so one being down does not end the conversation.
|
|
314
|
+
*/
|
|
315
|
+
export declare function sequentialFailover(dialer: SendOne): Transport;
|
|
316
|
+
/**
|
|
317
|
+
* Builds a {@link Transport} that uses the first endpoint only.
|
|
318
|
+
*
|
|
319
|
+
* Reproduces the pre-0.0.3 behaviour exactly, for an application that genuinely
|
|
320
|
+
* serves one endpoint or has a reason not to fail over.
|
|
321
|
+
*
|
|
322
|
+
* It exists so that choosing it is visible. `endpoints[0]` written inline looks
|
|
323
|
+
* like an implementation detail and reads as finished; naming this records that
|
|
324
|
+
* failover was considered and declined, which is a claim a reviewer can
|
|
325
|
+
* disagree with. If the peers this application talks to advertise more than one
|
|
326
|
+
* endpoint, prefer {@link sequentialFailover} — every endpoint after the first
|
|
327
|
+
* is reachability being thrown away.
|
|
328
|
+
*/
|
|
329
|
+
export declare function singleEndpointTransport(dialer: SendOne): Transport;
|
|
160
330
|
export declare enum SenderKind {
|
|
161
331
|
Owner = 0,
|
|
162
332
|
Helper = 1,
|
|
@@ -205,18 +375,25 @@ export declare enum FlowKind {
|
|
|
205
375
|
/** Ask the replica group whether this device is behind, and catch up if it
|
|
206
376
|
* is. Replica-only, and takes no parameters — the group and this device's
|
|
207
377
|
* own version both come from the stores. */
|
|
208
|
-
|
|
378
|
+
ReplicaDiscovery = 7,
|
|
209
379
|
/** Remove a member from the replica group. Replica-only. Naming this device
|
|
210
380
|
* is a voluntary departure; naming another is an eviction. Params:
|
|
211
381
|
* `{ replica_id: string; memo?: string }` — `replica_id` is a decimal
|
|
212
382
|
* string so ids above 2^53 survive JS number handling. */
|
|
213
|
-
|
|
383
|
+
UnpairReplica = 8
|
|
214
384
|
}
|
|
215
385
|
export type UnpairAck = "required" | "not_required";
|
|
216
386
|
export interface ContactMessage {
|
|
217
387
|
channel_id: bigint;
|
|
218
388
|
/** `ContactMode` numeric value (0 = INLINE_KEYS, 1 = HASHED_KEYS, 2 = NO_KEYS). */
|
|
219
389
|
contact_mode: number;
|
|
390
|
+
/**
|
|
391
|
+
* @deprecated Reading this field directly is incorrect: its meaning narrowed
|
|
392
|
+
* to "one entry of a list, and possibly absent", so a peer advertising only
|
|
393
|
+
* `supported_transports` looks unreachable to a reader that was correct
|
|
394
|
+
* before 0.0.3. Call {@link advertisedEndpoints}, which resolves both
|
|
395
|
+
* spellings. Removed at 0.0.5.
|
|
396
|
+
*/
|
|
220
397
|
transport_protocol?: TransportProtocol;
|
|
221
398
|
nonce: bigint;
|
|
222
399
|
/** Present only when `contact_mode === ContactMode.InlineKeys`. */
|
|
@@ -226,6 +403,10 @@ export interface ContactMessage {
|
|
|
226
403
|
/** Present only when `contact_mode === ContactMode.HashedKeys`. SHA-384 digest (48 bytes). */
|
|
227
404
|
contact_binding_hash?: Uint8Array;
|
|
228
405
|
timestamp?: Timestamp;
|
|
406
|
+
/** Every transport endpoint the creator of this contact can be reached
|
|
407
|
+
* on, in its own preference order. Empty means "only
|
|
408
|
+
* `transport_protocol` is offered". */
|
|
409
|
+
supported_transports: TransportProtocol[];
|
|
229
410
|
}
|
|
230
411
|
export interface UserSecret {
|
|
231
412
|
id: Uint8Array;
|
|
@@ -263,11 +444,23 @@ export interface UpdateChannelInfoParams {
|
|
|
263
444
|
/** New communication-info map. `null`/absent leaves the peer's stored
|
|
264
445
|
* map untouched; pass an empty object to clear it. */
|
|
265
446
|
communication_info?: Record<string, string>;
|
|
266
|
-
/**
|
|
447
|
+
/**
|
|
448
|
+
* New transport endpoint. Absent leaves it untouched.
|
|
449
|
+
*
|
|
450
|
+
* @deprecated Use `own_transports`, which carries every endpoint this node
|
|
451
|
+
* now serves; its first entry also fills this field for peers predating the
|
|
452
|
+
* list. Removed at 0.0.5.
|
|
453
|
+
*/
|
|
267
454
|
transport_protocol?: {
|
|
268
455
|
uri: string;
|
|
269
456
|
protocol: number;
|
|
270
457
|
};
|
|
458
|
+
/**
|
|
459
|
+
* Every endpoint this node now serves, in its own preference order.
|
|
460
|
+
* Omitted leaves the target(s)' stored set untouched. Takes precedence
|
|
461
|
+
* over `transport_protocol`, whose first entry it also fills.
|
|
462
|
+
*/
|
|
463
|
+
own_transports?: TransportProtocol[];
|
|
271
464
|
}
|
|
272
465
|
/**
|
|
273
466
|
* How long the protocol waits on each thing that can keep it waiting. Every
|
|
@@ -297,10 +490,10 @@ export interface Timeouts {
|
|
|
297
490
|
timeout_in_secs: number;
|
|
298
491
|
};
|
|
299
492
|
}
|
|
300
|
-
/** `
|
|
493
|
+
/** `ReplicaDiscovery` takes no parameters: the group and this device's own version
|
|
301
494
|
* are both read from the stores. The argument may be omitted entirely. */
|
|
302
|
-
export type
|
|
303
|
-
export interface
|
|
495
|
+
export type ReplicaDiscoveryParams = Record<string, never>;
|
|
496
|
+
export interface UnpairReplicaParams {
|
|
304
497
|
/** The member to remove, as a **decimal** `u64` string — the same form
|
|
305
498
|
* `ReplicaPaired.peer_replica_id` hands back. A value naming no current
|
|
306
499
|
* member is rejected; it is not silently ignored. */
|
|
@@ -319,7 +512,7 @@ export type DeRecEvent = {
|
|
|
319
512
|
type: "ActionRequired";
|
|
320
513
|
channel_id: string;
|
|
321
514
|
action: Uint8Array;
|
|
322
|
-
action_kind:
|
|
515
|
+
action_kind: PendingActionKind;
|
|
323
516
|
peer_communication_info?: Record<string, string>;
|
|
324
517
|
sender_kind?: SenderKind;
|
|
325
518
|
version?: number;
|
|
@@ -406,7 +599,7 @@ export type DeRecEvent = {
|
|
|
406
599
|
/** A replica catch-up finished. `fetched_from` is absent when this device
|
|
407
600
|
* was already current, in which case no hydration event follows. */
|
|
408
601
|
| {
|
|
409
|
-
type: "
|
|
602
|
+
type: "ReplicaDiscoveryComplete";
|
|
410
603
|
local_version: number;
|
|
411
604
|
group_version: number;
|
|
412
605
|
fetched_from?: string;
|
|
@@ -455,7 +648,11 @@ export type DeRecEvent = {
|
|
|
455
648
|
secret: {
|
|
456
649
|
helpers: Array<{
|
|
457
650
|
channel_id: string;
|
|
458
|
-
|
|
651
|
+
/** Every endpoint this peer advertised, in the order it offered them. */
|
|
652
|
+
transports: Array<{
|
|
653
|
+
uri: string;
|
|
654
|
+
protocol: number;
|
|
655
|
+
}>;
|
|
459
656
|
shared_key: Uint8Array;
|
|
460
657
|
communication_info: Record<string, string>;
|
|
461
658
|
}>;
|
|
@@ -476,7 +673,11 @@ export type DeRecEvent = {
|
|
|
476
673
|
* originated, which is why no separate owner field is needed. */
|
|
477
674
|
members: Array<{
|
|
478
675
|
replica_id: string;
|
|
479
|
-
|
|
676
|
+
/** Every endpoint this peer advertised, in the order it offered them. */
|
|
677
|
+
transports: Array<{
|
|
678
|
+
uri: string;
|
|
679
|
+
protocol: number;
|
|
680
|
+
}>;
|
|
480
681
|
role: "Source" | "Destination";
|
|
481
682
|
communication_info: Record<string, string>;
|
|
482
683
|
}>;
|
|
@@ -504,7 +705,7 @@ export type DeRecEvent = {
|
|
|
504
705
|
/** Fires alongside `PairingCompleted` on replica-mode pair handshakes.
|
|
505
706
|
* `peer_replica_id` is the peer's `u64` as a **decimal** string,
|
|
506
707
|
* matching the wire `derec.replica_id` representation and every other
|
|
507
|
-
* id across this boundary. Pass it back verbatim — `
|
|
708
|
+
* id across this boundary. Pass it back verbatim — `UnpairReplica`
|
|
508
709
|
* expects the same decimal form. The local side's role
|
|
509
710
|
* (`ReplicaSource` vs `ReplicaDestination`) is on the persisted
|
|
510
711
|
* channel record — replica pairings are unidirectional, so there is
|
|
@@ -529,7 +730,11 @@ export type DeRecEvent = {
|
|
|
529
730
|
secret: {
|
|
530
731
|
helpers: Array<{
|
|
531
732
|
channel_id: string;
|
|
532
|
-
|
|
733
|
+
/** Every endpoint this peer advertised, in the order it offered them. */
|
|
734
|
+
transports: Array<{
|
|
735
|
+
uri: string;
|
|
736
|
+
protocol: number;
|
|
737
|
+
}>;
|
|
533
738
|
shared_key: Uint8Array;
|
|
534
739
|
communication_info: Record<string, string>;
|
|
535
740
|
}>;
|
|
@@ -548,7 +753,11 @@ export type DeRecEvent = {
|
|
|
548
753
|
* originated, which is why no separate owner field is needed. */
|
|
549
754
|
members: Array<{
|
|
550
755
|
replica_id: string;
|
|
551
|
-
|
|
756
|
+
/** Every endpoint this peer advertised, in the order it offered them. */
|
|
757
|
+
transports: Array<{
|
|
758
|
+
uri: string;
|
|
759
|
+
protocol: number;
|
|
760
|
+
}>;
|
|
552
761
|
role: "Source" | "Destination";
|
|
553
762
|
communication_info: Record<string, string>;
|
|
554
763
|
}>;
|
|
@@ -578,7 +787,11 @@ export type DeRecEvent = {
|
|
|
578
787
|
secret: {
|
|
579
788
|
helpers: Array<{
|
|
580
789
|
channel_id: string;
|
|
581
|
-
|
|
790
|
+
/** Every endpoint this peer advertised, in the order it offered them. */
|
|
791
|
+
transports: Array<{
|
|
792
|
+
uri: string;
|
|
793
|
+
protocol: number;
|
|
794
|
+
}>;
|
|
582
795
|
shared_key: Uint8Array;
|
|
583
796
|
communication_info: Record<string, string>;
|
|
584
797
|
}>;
|
|
@@ -597,7 +810,11 @@ export type DeRecEvent = {
|
|
|
597
810
|
* originated, which is why no separate owner field is needed. */
|
|
598
811
|
members: Array<{
|
|
599
812
|
replica_id: string;
|
|
600
|
-
|
|
813
|
+
/** Every endpoint this peer advertised, in the order it offered them. */
|
|
814
|
+
transports: Array<{
|
|
815
|
+
uri: string;
|
|
816
|
+
protocol: number;
|
|
817
|
+
}>;
|
|
601
818
|
role: "Source" | "Destination";
|
|
602
819
|
communication_info: Record<string, string>;
|
|
603
820
|
}>;
|
|
@@ -647,7 +864,7 @@ export type DeRecEvent = {
|
|
|
647
864
|
| {
|
|
648
865
|
type: "AutoAccepted";
|
|
649
866
|
channel_id: string;
|
|
650
|
-
action_kind:
|
|
867
|
+
action_kind: PendingActionKind;
|
|
651
868
|
} | {
|
|
652
869
|
type: "NoOp";
|
|
653
870
|
}
|
|
@@ -658,12 +875,14 @@ export type DeRecEvent = {
|
|
|
658
875
|
type: "PairingStarted";
|
|
659
876
|
channel_id: string;
|
|
660
877
|
kind: SenderKind;
|
|
878
|
+
trace_id: string;
|
|
661
879
|
}
|
|
662
880
|
/** A discovery request was dispatched to `channel_id`. Emitted per
|
|
663
881
|
* targeted helper by `start(Discovery)`. */
|
|
664
882
|
| {
|
|
665
883
|
type: "DiscoveryStarted";
|
|
666
884
|
channel_id: string;
|
|
885
|
+
trace_id: string;
|
|
667
886
|
}
|
|
668
887
|
/** A discovery request could not be dispatched to `channel_id`. Other
|
|
669
888
|
* targeted channels are unaffected. */
|
|
@@ -678,6 +897,7 @@ export type DeRecEvent = {
|
|
|
678
897
|
type: "ProtectSecretStarted";
|
|
679
898
|
channel_id: string;
|
|
680
899
|
version: number;
|
|
900
|
+
trace_id: string;
|
|
681
901
|
}
|
|
682
902
|
/** A share-storage request could not be dispatched to `channel_id`. */
|
|
683
903
|
| {
|
|
@@ -691,6 +911,7 @@ export type DeRecEvent = {
|
|
|
691
911
|
type: "VerifySharesStarted";
|
|
692
912
|
channel_id: string;
|
|
693
913
|
version: number;
|
|
914
|
+
trace_id: string;
|
|
694
915
|
}
|
|
695
916
|
/** A verify-share challenge could not be dispatched to `channel_id`. */
|
|
696
917
|
| {
|
|
@@ -704,6 +925,7 @@ export type DeRecEvent = {
|
|
|
704
925
|
type: "RecoverSecretStarted";
|
|
705
926
|
channel_id: string;
|
|
706
927
|
version: number;
|
|
928
|
+
trace_id: string;
|
|
707
929
|
}
|
|
708
930
|
/** A recovery share request could not be dispatched to `channel_id`. */
|
|
709
931
|
| {
|
|
@@ -722,11 +944,13 @@ export type DeRecEvent = {
|
|
|
722
944
|
} | {
|
|
723
945
|
type: "UnpairStarted";
|
|
724
946
|
channel_id: string;
|
|
947
|
+
trace_id: string;
|
|
725
948
|
}
|
|
726
949
|
/** An update-channel-info request was dispatched to `channel_id`. */
|
|
727
950
|
| {
|
|
728
951
|
type: "UpdateChannelInfoStarted";
|
|
729
952
|
channel_id: string;
|
|
953
|
+
trace_id: string;
|
|
730
954
|
}
|
|
731
955
|
/** An update-channel-info request could not be dispatched to
|
|
732
956
|
* `channel_id`. */
|
|
@@ -787,7 +1011,12 @@ export interface GetSecretIdsVersionsRequestMessage {
|
|
|
787
1011
|
timestamp?: Timestamp;
|
|
788
1012
|
/** Ephemeral endpoint where the requester wants the response routed.
|
|
789
1013
|
* Absent means "use the channel's stored peer endpoint". */
|
|
790
|
-
|
|
1014
|
+
/**
|
|
1015
|
+
* Every endpoint the requester can be answered on for this exchange, in
|
|
1016
|
+
* its own preference order. Omitted means route to the endpoints already
|
|
1017
|
+
* recorded for the channel.
|
|
1018
|
+
*/
|
|
1019
|
+
reply_to?: TransportProtocol[];
|
|
791
1020
|
/** Replica-group member that sent this; see `replicaId` semantics. */
|
|
792
1021
|
replica_id?: bigint;
|
|
793
1022
|
}
|
|
@@ -826,6 +1055,13 @@ export interface CommunicationInfoKeyValue {
|
|
|
826
1055
|
export interface CommunicationInfo {
|
|
827
1056
|
communication_info_entries: CommunicationInfoKeyValue[];
|
|
828
1057
|
}
|
|
1058
|
+
/**
|
|
1059
|
+
* The label vocabulary for `ActionRequired.action_kind` and
|
|
1060
|
+
* `AutoAccepted.action_kind` — one value per pending-action kind the
|
|
1061
|
+
* protocol can raise. Matches the Rust `PendingActionKind` discriminants
|
|
1062
|
+
* one-for-one.
|
|
1063
|
+
*/
|
|
1064
|
+
export type PendingActionKind = "Pairing" | "PrePair" | "StoreShare" | "VerifyShare" | "Discovery" | "GetShare" | "Unpair" | "UpdateChannelInfo";
|
|
829
1065
|
export interface ParameterRange {
|
|
830
1066
|
min_share_size: bigint;
|
|
831
1067
|
max_share_size: bigint;
|
|
@@ -845,8 +1081,18 @@ export interface PairRequestMessage {
|
|
|
845
1081
|
nonce: bigint;
|
|
846
1082
|
communication_info?: CommunicationInfo;
|
|
847
1083
|
parameter_range?: ParameterRange;
|
|
1084
|
+
/**
|
|
1085
|
+
* @deprecated Reading this field directly is incorrect: its meaning narrowed
|
|
1086
|
+
* to "one entry of a list, and possibly absent", so a peer advertising only
|
|
1087
|
+
* `supported_transports` looks unreachable to a reader that was correct
|
|
1088
|
+
* before 0.0.3. Call {@link advertisedEndpoints}, which resolves both
|
|
1089
|
+
* spellings. Removed at 0.0.5.
|
|
1090
|
+
*/
|
|
848
1091
|
transport_protocol?: TransportProtocol;
|
|
849
1092
|
timestamp?: Timestamp;
|
|
1093
|
+
/** Every transport endpoint the initiator can be reached on, in its own
|
|
1094
|
+
* preference order. Empty means "only `transport_protocol` is offered". */
|
|
1095
|
+
supported_transports: TransportProtocol[];
|
|
850
1096
|
}
|
|
851
1097
|
export interface PairResponseMessage {
|
|
852
1098
|
result?: DeRecResult;
|
|
@@ -865,8 +1111,21 @@ export interface PairResponseMessage {
|
|
|
865
1111
|
}
|
|
866
1112
|
export interface PrePairRequestMessage {
|
|
867
1113
|
nonce: bigint;
|
|
1114
|
+
/**
|
|
1115
|
+
* @deprecated Reading this field directly is incorrect: its meaning narrowed
|
|
1116
|
+
* to "one entry of a list, and possibly absent", so a peer advertising only
|
|
1117
|
+
* `supported_transports` looks unreachable to a reader that was correct
|
|
1118
|
+
* before 0.0.3. Call {@link advertisedEndpoints}, which resolves both
|
|
1119
|
+
* spellings. Removed at 0.0.5.
|
|
1120
|
+
*/
|
|
868
1121
|
transport_protocol?: TransportProtocol;
|
|
869
1122
|
timestamp?: Timestamp;
|
|
1123
|
+
/**
|
|
1124
|
+
* Every endpoint the sender can be reached on for the PrePair reply, in
|
|
1125
|
+
* its own preference order. At least one of this and `transport_protocol`
|
|
1126
|
+
* must be present.
|
|
1127
|
+
*/
|
|
1128
|
+
supported_transports?: TransportProtocol[];
|
|
870
1129
|
}
|
|
871
1130
|
export interface PrePairResponseMessage {
|
|
872
1131
|
result?: DeRecResult;
|
|
@@ -882,7 +1141,12 @@ export interface GetShareRequestMessage {
|
|
|
882
1141
|
version: number;
|
|
883
1142
|
timestamp?: Timestamp;
|
|
884
1143
|
/** Ephemeral response endpoint; see `replyTo` semantics. */
|
|
885
|
-
|
|
1144
|
+
/**
|
|
1145
|
+
* Every endpoint the requester can be answered on for this exchange, in
|
|
1146
|
+
* its own preference order. Omitted means route to the endpoints already
|
|
1147
|
+
* recorded for the channel.
|
|
1148
|
+
*/
|
|
1149
|
+
reply_to?: TransportProtocol[];
|
|
886
1150
|
/** Replica-group member that sent this; see `replicaId` semantics. */
|
|
887
1151
|
replica_id?: bigint;
|
|
888
1152
|
}
|
|
@@ -917,7 +1181,12 @@ export interface StoreShareRequestMessage {
|
|
|
917
1181
|
timestamp?: Timestamp;
|
|
918
1182
|
secret_id: bigint;
|
|
919
1183
|
/** Ephemeral response endpoint; see `replyTo` semantics. */
|
|
920
|
-
|
|
1184
|
+
/**
|
|
1185
|
+
* Every endpoint the requester can be answered on for this exchange, in
|
|
1186
|
+
* its own preference order. Omitted means route to the endpoints already
|
|
1187
|
+
* recorded for the channel.
|
|
1188
|
+
*/
|
|
1189
|
+
reply_to?: TransportProtocol[];
|
|
921
1190
|
/** Replica-group member that sent this; see `replicaId` semantics. */
|
|
922
1191
|
replica_id?: bigint;
|
|
923
1192
|
}
|
|
@@ -933,7 +1202,12 @@ export interface UnpairRequestMessage {
|
|
|
933
1202
|
memo: string;
|
|
934
1203
|
timestamp?: Timestamp;
|
|
935
1204
|
/** Ephemeral response endpoint; see `replyTo` semantics. */
|
|
936
|
-
|
|
1205
|
+
/**
|
|
1206
|
+
* Every endpoint the requester can be answered on for this exchange, in
|
|
1207
|
+
* its own preference order. Omitted means route to the endpoints already
|
|
1208
|
+
* recorded for the channel.
|
|
1209
|
+
*/
|
|
1210
|
+
reply_to?: TransportProtocol[];
|
|
937
1211
|
/** Replica-group member that sent this; see `replicaId` semantics. */
|
|
938
1212
|
replica_id?: bigint;
|
|
939
1213
|
}
|
|
@@ -947,7 +1221,12 @@ export interface VerifyShareRequestMessage {
|
|
|
947
1221
|
nonce: bigint;
|
|
948
1222
|
timestamp?: Timestamp;
|
|
949
1223
|
/** Ephemeral response endpoint; see `replyTo` semantics. */
|
|
950
|
-
|
|
1224
|
+
/**
|
|
1225
|
+
* Every endpoint the requester can be answered on for this exchange, in
|
|
1226
|
+
* its own preference order. Omitted means route to the endpoints already
|
|
1227
|
+
* recorded for the channel.
|
|
1228
|
+
*/
|
|
1229
|
+
reply_to?: TransportProtocol[];
|
|
951
1230
|
}
|
|
952
1231
|
export interface VerifyShareResponseMessage {
|
|
953
1232
|
result?: DeRecResult;
|
|
@@ -974,7 +1253,12 @@ export interface PairingRequestProduceResult extends ProduceResult {
|
|
|
974
1253
|
secret_key: Uint8Array;
|
|
975
1254
|
}
|
|
976
1255
|
export interface PairingResponseProduceResult extends ProduceResult {
|
|
977
|
-
|
|
1256
|
+
/**
|
|
1257
|
+
* Every endpoint the requester advertised, in the order it offered them,
|
|
1258
|
+
* filtered to those the library will record. Never empty. Choosing which
|
|
1259
|
+
* to dial, and failing over when one is unreachable, is the application's.
|
|
1260
|
+
*/
|
|
1261
|
+
peer_transports: TransportProtocol[];
|
|
978
1262
|
shared_key: Uint8Array;
|
|
979
1263
|
/**
|
|
980
1264
|
* Post-handshake rekey channel id the responder is committing to.
|