@derec-alliance/react-native 0.0.8 → 0.0.10
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 +410 -9
- 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/Convert.cpp +9 -0
- package/cpp/Convert.h +8 -2
- package/cpp/Primitives.cpp +123 -29
- package/cpp/ProtocolHost.cpp +4 -5
- package/cpp/StoreCallbacks.cpp +148 -61
- package/cpp/StoreCallbacks.h +8 -1
- package/cpp/derec_ffi.h +127 -48
- package/ios/DeRecFFI.xcframework/Info.plist +5 -5
- package/ios/DeRecFFI.xcframework/ios-arm64/Headers/derec_ffi.h +127 -48
- package/ios/DeRecFFI.xcframework/ios-arm64/libderec_library.a +0 -0
- package/ios/DeRecFFI.xcframework/ios-arm64_x86_64-simulator/Headers/derec_ffi.h +127 -48
- package/ios/DeRecFFI.xcframework/ios-arm64_x86_64-simulator/libderec_library.a +2 -2
- package/lib/errors.d.ts +11 -1
- package/lib/errors.js +66 -1
- package/lib/messages.js +5 -3
- package/lib/primitives.d.ts +3 -3
- package/lib/primitives.js +7 -3
- package/lib/protocol.d.ts +110 -10
- package/lib/protocol.js +166 -11
- package/lib/types.d.ts +474 -48
- package/lib/types.js +23 -1
- package/package.json +4 -17
- package/schema/derec_descriptor.bin +0 -0
- package/schema/proto/committedderecshare.proto +93 -0
- package/schema/proto/communicationinfo.proto +104 -0
- package/schema/proto/contact.proto +258 -0
- package/schema/proto/derecmessage.proto +232 -0
- package/schema/proto/derecsecret.proto +163 -0
- package/schema/proto/derectransport.proto +38 -0
- package/schema/proto/error.proto +68 -0
- package/schema/proto/getshare.proto +184 -0
- package/schema/proto/pair.proto +284 -0
- package/schema/proto/parameterrange.proto +36 -0
- package/schema/proto/prepair.proto +163 -0
- package/schema/proto/result.proto +194 -0
- package/schema/proto/secretidsversions.proto +199 -0
- package/schema/proto/storeshare.proto +242 -0
- package/schema/proto/transportprotocol.proto +112 -0
- package/schema/proto/unpair.proto +132 -0
- package/schema/proto/updatechannelinfo.proto +100 -0
- package/schema/proto/verify.proto +160 -0
- package/src/errors.ts +69 -1
- package/src/messages.ts +5 -3
- package/src/primitives.ts +19 -4
- package/src/protocol.ts +175 -13
- package/src/types.ts +481 -52
package/src/types.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
// Copyright (c) 2026 DeRec Alliance. All rights reserved.
|
|
3
3
|
|
|
4
|
+
import type { DeRecErrorCode } from './errors';
|
|
4
5
|
import { getNative } from './native';
|
|
5
6
|
|
|
6
7
|
export interface SecretStore {
|
|
@@ -177,9 +178,18 @@ export type ReplicaFilter = ChannelFilter<ReplicaRoleName>;
|
|
|
177
178
|
* return new TextEncoder().encode(`[${inner.join(",")}]`);
|
|
178
179
|
* ```
|
|
179
180
|
*
|
|
180
|
-
* Do not
|
|
181
|
+
* Do not re-serialise a parsed record. Every id in these records is a `u64`,
|
|
181
182
|
* and `JSON.parse` silently rounds anything above 2^53 — the corruption only
|
|
182
183
|
* appears once a real id happens to be large.
|
|
184
|
+
*
|
|
185
|
+
* A helper record's `weight` is the number of Shamir subshares that helper
|
|
186
|
+
* receives: the weight the last `start(ProtectSecret)` resolved for it, which
|
|
187
|
+
* every publish the library starts on its own reuses (1 for a new pairing and
|
|
188
|
+
* for a record written before the field existed). Parsing a stored helper
|
|
189
|
+
* record to read `Helper.weight` is safe and is the normal way to pre-fill
|
|
190
|
+
* the weights the user is shown: it is a small integer, and the channel id
|
|
191
|
+
* comes from the store call's `channelId` argument, never from the parsed
|
|
192
|
+
* object. Keep persisting the original bytes.
|
|
183
193
|
*/
|
|
184
194
|
export interface ChannelStore {
|
|
185
195
|
load(
|
|
@@ -237,6 +247,24 @@ export interface Share {
|
|
|
237
247
|
secretId: string;
|
|
238
248
|
version: number;
|
|
239
249
|
bytes: Uint8Array;
|
|
250
|
+
/**
|
|
251
|
+
* How many subshares the share carries, recorded on the owner side only:
|
|
252
|
+
* the library sets it on every share the owner saves (including a replica
|
|
253
|
+
* Destination's mirrored copies) and leaves it absent on a helper's share.
|
|
254
|
+
* Owner shares stored before the field existed read back absent; the
|
|
255
|
+
* library never backfills them. Persist it as given and return it
|
|
256
|
+
* unchanged. `null` and `undefined` both mean no count.
|
|
257
|
+
*/
|
|
258
|
+
subshares?: number | null;
|
|
259
|
+
/**
|
|
260
|
+
* The threshold this version was split with, recorded on the owner side
|
|
261
|
+
* only, on the same shares as `subshares`: a later round may change the
|
|
262
|
+
* threshold, so this is the only record of the one an older version needs
|
|
263
|
+
* to be recoverable. Absent on a helper's share and on owner shares stored
|
|
264
|
+
* before the field existed. Persist it as given and return it unchanged.
|
|
265
|
+
* `null` and `undefined` both mean none.
|
|
266
|
+
*/
|
|
267
|
+
threshold?: number | null;
|
|
240
268
|
}
|
|
241
269
|
|
|
242
270
|
/**
|
|
@@ -258,6 +286,11 @@ export interface ShareStore {
|
|
|
258
286
|
versions: number[],
|
|
259
287
|
): Promise<Share[]>;
|
|
260
288
|
loadAll(secretId: string, channelIds: string[]): Promise<Share[]>;
|
|
289
|
+
/**
|
|
290
|
+
* Reject, or throw, a {@link shareStoreRefusal} `Error` to refuse a share
|
|
291
|
+
* update on a helper channel; any other rejection is an ordinary backend
|
|
292
|
+
* failure.
|
|
293
|
+
*/
|
|
261
294
|
save(secretId: string, channelId: string, share: Share): Promise<void>;
|
|
262
295
|
latestVersion(secretId: string): Promise<number | null>;
|
|
263
296
|
removeChannel(secretId: string, channelId: string): Promise<void>;
|
|
@@ -266,9 +299,9 @@ export interface ShareStore {
|
|
|
266
299
|
* `versions`. Idempotent: a version that is not stored is skipped, and
|
|
267
300
|
* an empty array is a no-op.
|
|
268
301
|
*
|
|
269
|
-
* A helper calls this to apply `StoreShareRequestMessage.
|
|
270
|
-
*
|
|
271
|
-
*
|
|
302
|
+
* A helper calls this to apply `StoreShareRequestMessage.keepVersion`:
|
|
303
|
+
* once the incoming share is persisted, every version stored on the
|
|
304
|
+
* channel other than the incoming one and `keepVersion` is removed.
|
|
272
305
|
* Shares under other channels or partitions must be left untouched.
|
|
273
306
|
*/
|
|
274
307
|
removeVersions(
|
|
@@ -277,26 +310,37 @@ export interface ShareStore {
|
|
|
277
310
|
versions: number[],
|
|
278
311
|
): Promise<void>;
|
|
279
312
|
/**
|
|
280
|
-
* Owner only: the
|
|
281
|
-
* `version`. Asked once per sharing round, before anything is
|
|
282
|
-
* including the rounds the library starts itself; the answer
|
|
283
|
-
* `
|
|
313
|
+
* Owner only: the one older version every helper keeps after the owner
|
|
314
|
+
* distributes `version`. Asked once per sharing round, before anything is
|
|
315
|
+
* sent, including the rounds the library starts itself; the answer
|
|
316
|
+
* becomes `keepVersion` for every helper.
|
|
317
|
+
*
|
|
318
|
+
* Resolve to an integer in `0..=4294967295`. A helper that stores
|
|
319
|
+
* `version` keeps it and the returned version, and deletes every other
|
|
320
|
+
* version it holds; `0` keeps no other version. An answer equal to or
|
|
321
|
+
* greater than `version` fails the round with `invalid_keep_version`
|
|
322
|
+
* before anything is sent.
|
|
284
323
|
*
|
|
285
|
-
* Return
|
|
286
|
-
*
|
|
287
|
-
*
|
|
288
|
-
*
|
|
289
|
-
*
|
|
290
|
-
*
|
|
291
|
-
*
|
|
292
|
-
* still open. Leave out only versions whose round failed or that the user
|
|
293
|
-
* rolled back; a list that leaves out too much can make the secret
|
|
294
|
-
* unrecoverable.
|
|
324
|
+
* Return the last valid version: the newest one whose `SharingComplete`
|
|
325
|
+
* reported `threshold_met`. A version whose round is still open is
|
|
326
|
+
* deleted from every helper that stores `version` unless it is the one
|
|
327
|
+
* returned here. Only the application knows which versions committed.
|
|
328
|
+
* When a helper confirms `version`, the library also removes this
|
|
329
|
+
* device's rows for that channel other than `version` and the returned
|
|
330
|
+
* version.
|
|
295
331
|
*/
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
332
|
+
keepVersion(secretId: string, version: number): Promise<number>;
|
|
333
|
+
/**
|
|
334
|
+
* Record a verification challenge the helper is about to answer for
|
|
335
|
+
* `(secretId, channelId, version)`. Called once per accepted challenge,
|
|
336
|
+
* after the challenged share is found and before the helper answers.
|
|
337
|
+
*
|
|
338
|
+
* Reject, or throw, a {@link shareStoreRefusal} `Error` to refuse the
|
|
339
|
+
* verification on a helper channel; the library answers the owner with
|
|
340
|
+
* the mapped status instead of the verification result. Any other
|
|
341
|
+
* rejection is an ordinary backend failure.
|
|
342
|
+
*/
|
|
343
|
+
recordVerification(secretId: string, channelId: string, version: number): Promise<void>;
|
|
300
344
|
}
|
|
301
345
|
|
|
302
346
|
export interface UserSecretEntry {
|
|
@@ -313,6 +357,14 @@ export interface UserSecrets {
|
|
|
313
357
|
* when none is recorded. Store and return it unchanged: replica members
|
|
314
358
|
* compare it to detect a conflicting copy of the same version. */
|
|
315
359
|
author_replica_id?: string;
|
|
360
|
+
/** The threshold the next publish splits at unless
|
|
361
|
+
* `ProtectSecretParams.threshold` passes its own. Every publish writes the
|
|
362
|
+
* threshold it used, and `restore` and replica hydration write the
|
|
363
|
+
* recovered roster's. Absent on a snapshot written before the threshold
|
|
364
|
+
* was recorded, or restored from a roster that carries none; the
|
|
365
|
+
* builder's `withThreshold` then applies. Store and return it unchanged.
|
|
366
|
+
* `null` and `undefined` both mean none. */
|
|
367
|
+
threshold?: number | null;
|
|
316
368
|
}
|
|
317
369
|
|
|
318
370
|
/**
|
|
@@ -356,6 +408,18 @@ export interface StateStore {
|
|
|
356
408
|
loadAll(secretId: string, kind: 0 | 1 | 2 | 3 | 4): Promise<Uint8Array[]>;
|
|
357
409
|
}
|
|
358
410
|
|
|
411
|
+
/**
|
|
412
|
+
* The five stores `DeRecProtocolBuilder.build` requires, bundled for
|
|
413
|
+
* `DeRecProtocolBuilder.withStores`.
|
|
414
|
+
*/
|
|
415
|
+
export interface StoresInit {
|
|
416
|
+
channelStore: ChannelStore;
|
|
417
|
+
shareStore: ShareStore;
|
|
418
|
+
secretStore: SecretStore;
|
|
419
|
+
userSecretStore: UserSecretStore;
|
|
420
|
+
stateStore: StateStore;
|
|
421
|
+
}
|
|
422
|
+
|
|
359
423
|
/** A transport protocol, by name. */
|
|
360
424
|
export type TransportProtocolName = "https" | "grpc";
|
|
361
425
|
|
|
@@ -455,6 +519,34 @@ export function generate_replica_id(): bigint {
|
|
|
455
519
|
return getNative().generate_replica_id();
|
|
456
520
|
}
|
|
457
521
|
|
|
522
|
+
/** Reason a `ShareStore` gives for refusing a `save` or `recordVerification`
|
|
523
|
+
* call, carried on the `refusal` property of the `Error` {@link
|
|
524
|
+
* shareStoreRefusal} builds. The app picks the reason; the library alone
|
|
525
|
+
* decides the status and memo that reach the peer. */
|
|
526
|
+
export type ShareStoreRefusalReason = "too_frequent" | "size_limit_exceeded" | "rejected";
|
|
527
|
+
|
|
528
|
+
const SHARE_STORE_REFUSAL_REASONS: ShareStoreRefusalReason[] = [
|
|
529
|
+
"too_frequent",
|
|
530
|
+
"size_limit_exceeded",
|
|
531
|
+
"rejected",
|
|
532
|
+
];
|
|
533
|
+
|
|
534
|
+
/**
|
|
535
|
+
* Builds the `Error` a `ShareStore`'s `save`/`recordVerification` throws, or
|
|
536
|
+
* rejects its promise with, to refuse the call: `reason` tagged onto the
|
|
537
|
+
* error's `refusal` property.
|
|
538
|
+
*/
|
|
539
|
+
export function shareStoreRefusal(reason: ShareStoreRefusalReason): Error {
|
|
540
|
+
if (!SHARE_STORE_REFUSAL_REASONS.includes(reason)) {
|
|
541
|
+
throw new Error(
|
|
542
|
+
`unknown share store refusal reason ${JSON.stringify(reason)}; expected one of ${JSON.stringify(SHARE_STORE_REFUSAL_REASONS)}`,
|
|
543
|
+
);
|
|
544
|
+
}
|
|
545
|
+
const error = new Error(`share store refused: ${reason}`);
|
|
546
|
+
(error as Error & { refusal: ShareStoreRefusalReason }).refusal = reason;
|
|
547
|
+
return error;
|
|
548
|
+
}
|
|
549
|
+
|
|
458
550
|
/**
|
|
459
551
|
* Builds a {@link Transport} that tries each endpoint in the order the peer
|
|
460
552
|
* offered it and stops at the first success.
|
|
@@ -541,7 +633,10 @@ export enum SenderKind {
|
|
|
541
633
|
* are ignored. A man-in-the-middle on the plaintext `PrePair` leg leaves
|
|
542
634
|
* the two sides with different shared keys and so different fingerprints,
|
|
543
635
|
* which is what the comparison catches — the role `contact_binding_hash`
|
|
544
|
-
* plays for `HashedKeys`.
|
|
636
|
+
* plays for `HashedKeys`. The creator's `PrePair` response also carries a
|
|
637
|
+
* commitment to a nonce it reveals only in its `PairResponse`, and the
|
|
638
|
+
* channel key depends on that nonce, so whoever answers the scanner cannot
|
|
639
|
+
* search offline for keys that make the two fingerprints agree.
|
|
545
640
|
*/
|
|
546
641
|
export enum ContactMode {
|
|
547
642
|
InlineKeys = 0,
|
|
@@ -603,6 +698,14 @@ export interface ContactMessage {
|
|
|
603
698
|
/** Present only when `contact_mode === ContactMode.HashedKeys`. SHA-384 digest (48 bytes). */
|
|
604
699
|
contact_binding_hash?: Uint8Array;
|
|
605
700
|
timestamp?: Timestamp;
|
|
701
|
+
/**
|
|
702
|
+
* Present only when `contact_mode === ContactMode.InlineKeys`. The
|
|
703
|
+
* creator's 32-byte commitment to the fingerprint nonce its
|
|
704
|
+
* `PairResponseMessage` reveals. For the other modes it arrives with the
|
|
705
|
+
* keys in the `PrePairResponseMessage`; a contact filled in from a
|
|
706
|
+
* `ProcessPrePairResult` must carry it alongside the two keys.
|
|
707
|
+
*/
|
|
708
|
+
fingerprint_commitment?: Uint8Array;
|
|
606
709
|
/** Every transport endpoint the creator of this contact can be reached
|
|
607
710
|
* on, in its own preference order. */
|
|
608
711
|
supported_transports: TransportProtocol[];
|
|
@@ -629,6 +732,60 @@ export interface DiscoveryParams {
|
|
|
629
732
|
export interface ProtectSecretParams {
|
|
630
733
|
secrets: UserSecret[];
|
|
631
734
|
description?: string;
|
|
735
|
+
/**
|
|
736
|
+
* Channel ID to how many subshares that channel should hold. The map is the
|
|
737
|
+
* full assignment, not a patch: a paired helper absent from it holds one
|
|
738
|
+
* subshare. The resolved weights are stored on each helper's channel
|
|
739
|
+
* record. A key is a channel id as bigint or decimal string, e.g. the
|
|
740
|
+
* `channel_id` string from an event.
|
|
741
|
+
*
|
|
742
|
+
* Weights are the user's choice. Before `start`, show the user each paired
|
|
743
|
+
* helper's current weight, pre-filled from your `ChannelStore` (the stored
|
|
744
|
+
* `Helper.weight`, which is safe to read; see `ChannelStore`), and pass the
|
|
745
|
+
* user's final choice as the whole map. Reading the stored weights first is
|
|
746
|
+
* the normal flow. Every other `start(ProtectSecret)` the app makes, such
|
|
747
|
+
* as a republish after editing the secrets or the follow-up after
|
|
748
|
+
* `restore`, must pass the stored weights unchanged: a helper left out
|
|
749
|
+
* returns to 1, which silently undoes the user's choice. Only the
|
|
750
|
+
* publishes the library starts on its own (after pairing, after a
|
|
751
|
+
* fingerprint is confirmed) reuse the stored weights by themselves.
|
|
752
|
+
*
|
|
753
|
+
* A stored weight the round's threshold does not allow fails the
|
|
754
|
+
* publishes the library starts on its own with `invalid_weight`, before
|
|
755
|
+
* anything is sent: `process()` throws with the message's `events`
|
|
756
|
+
* (`PairingCompleted` included); `accept()` throws after the pairing has
|
|
757
|
+
* completed and its response was sent, without returning
|
|
758
|
+
* `PairingCompleted`; `verifyFingerprint()` throws after the promotion,
|
|
759
|
+
* which stands, and a retry resolves `true` and publishes nothing. Call
|
|
760
|
+
* `start` with `ProtectSecret` and valid weights to publish.
|
|
761
|
+
*
|
|
762
|
+
* When the paired helpers' resolved total is below the round's threshold
|
|
763
|
+
* (see `threshold`), `start` skips the split: no helper is sent anything, so no
|
|
764
|
+
* `ProtectSecretStarted` / `ProtectSecretFailed` comes back for one. A
|
|
765
|
+
* paired replica still gets its usual secret-only copy and events; with
|
|
766
|
+
* none paired, `start` resolves with no events at all — this is not an
|
|
767
|
+
* error. The version still advances and the secrets/description are
|
|
768
|
+
* saved as the latest snapshot, so the next publish that reaches
|
|
769
|
+
* threshold shares it. Sum the weights about to be assigned against the
|
|
770
|
+
* threshold beforehand, or count the returned helper events afterward,
|
|
771
|
+
* to detect the case.
|
|
772
|
+
*/
|
|
773
|
+
weights?: Map<bigint | string, number>;
|
|
774
|
+
/**
|
|
775
|
+
* The threshold this round splits at: the number of distinct subshares
|
|
776
|
+
* that reconstruct this version. Absent keeps the stored threshold
|
|
777
|
+
* (`UserSecrets.threshold`), or the builder's `withThreshold` when none is
|
|
778
|
+
* stored; a value changes it, and the new threshold is stored with this
|
|
779
|
+
* round. Leave it absent on the follow-up after `restore`, which has
|
|
780
|
+
* already put the recovered threshold back. Publishes the library starts
|
|
781
|
+
* on its own always use the stored threshold.
|
|
782
|
+
*
|
|
783
|
+
* The resolved threshold must be at least 2 (`invalid_threshold`), above
|
|
784
|
+
* every resolved weight (`invalid_weight`), and no greater than a
|
|
785
|
+
* `withMaxSubshares` cap (`invalid_input`). Each check runs before
|
|
786
|
+
* anything is written or sent.
|
|
787
|
+
*/
|
|
788
|
+
threshold?: number;
|
|
632
789
|
}
|
|
633
790
|
export interface VerifySharesParams {
|
|
634
791
|
secretId: bigint | string;
|
|
@@ -750,6 +907,15 @@ export type DeRecEvent =
|
|
|
750
907
|
updated_transports?: Endpoint[];
|
|
751
908
|
}
|
|
752
909
|
| { type: "ShareStored"; channel_id: string; version: number }
|
|
910
|
+
/** The library refused an inbound share (helper side) instead of raising
|
|
911
|
+
* `ActionRequired`: nothing was stored, no stored version was removed, and
|
|
912
|
+
* the owner was answered with `status` and `memo`, which it observes as
|
|
913
|
+
* `ShareRejected`. `status` is FORMAT_ERROR (the share does not decode),
|
|
914
|
+
* VERIFICATION_FAILED (it does not verify against its commitment),
|
|
915
|
+
* SIZE_LIMIT_EXCEEDED (outside the helper's size range) or
|
|
916
|
+
* VERSION_CONFLICT (a different share is stored at `version`). A refusal
|
|
917
|
+
* from the application's own share store does not raise it. */
|
|
918
|
+
| { type: "ShareRefused"; channel_id: string; version: number; status: StatusEnum; memo: string }
|
|
753
919
|
| { type: "ShareConfirmed"; channel_id: string; version: number }
|
|
754
920
|
| { type: "ShareRejected"; channel_id: string; version: number; status: StatusEnum; memo: string }
|
|
755
921
|
/** A publishing round finished — every targeted helper confirmed,
|
|
@@ -812,7 +978,21 @@ export type DeRecEvent =
|
|
|
812
978
|
* not fail the round. `behind` is the application's retry list — the
|
|
813
979
|
* library keeps no durable per-member sync state. */
|
|
814
980
|
| { type: "ReplicaSyncComplete"; version: number; synced: string[]; behind: string[] }
|
|
815
|
-
|
|
981
|
+
/** A helper's verification proof checked out (owner side). `subshares` is
|
|
982
|
+
* how many subshares this helper holds for `version`: the count on the
|
|
983
|
+
* owner's stored share for this channel and version, not the helper's
|
|
984
|
+
* current weight; absent when that share was stored before the count was
|
|
985
|
+
* recorded. `threshold` is the threshold `version` was split with, from
|
|
986
|
+
* the same owner share, not the current one; absent when that share was
|
|
987
|
+
* stored before the threshold was recorded. To judge whether a version is
|
|
988
|
+
* recoverable, sum `subshares` over its `ShareVerified` events and compare
|
|
989
|
+
* with their `threshold`. If either is absent on any of those events, the
|
|
990
|
+
* result is unknown: an absent count is not `0` or `1`. */
|
|
991
|
+
| { type: "ShareVerified"; channel_id: string; version: number; subshares?: number; threshold?: number }
|
|
992
|
+
/** A helper answered a verification challenge, but its proof does not
|
|
993
|
+
* match the share this device stored. The challenge is spent; a new
|
|
994
|
+
* `VerifyShares` round challenges the helper again. */
|
|
995
|
+
| { type: "ShareVerifyInvalid"; channel_id: string; version: number }
|
|
816
996
|
/** A helper refused a verification challenge: its response carried a
|
|
817
997
|
* non-OK `status` instead of a proof. The challenge is spent; a new
|
|
818
998
|
* `VerifyShares` round challenges the helper again. */
|
|
@@ -855,7 +1035,12 @@ export type DeRecEvent =
|
|
|
855
1035
|
/** Every endpoint this peer advertised, in the order it offered them. */
|
|
856
1036
|
transports: Endpoint[];
|
|
857
1037
|
shared_key: Uint8Array;
|
|
858
|
-
communication_info?: Record<string, string
|
|
1038
|
+
communication_info?: Record<string, string> | null;
|
|
1039
|
+
/** Shamir subshares this helper received in the round that wrote the
|
|
1040
|
+
* roster. `restore` writes it into the helper's channel record, so the
|
|
1041
|
+
* next publish gives it the same count. Every event carries it;
|
|
1042
|
+
* `restore` reads an absent value as 1. */
|
|
1043
|
+
weight?: number;
|
|
859
1044
|
}>;
|
|
860
1045
|
secrets: Array<{
|
|
861
1046
|
id: Uint8Array;
|
|
@@ -877,10 +1062,15 @@ export type DeRecEvent =
|
|
|
877
1062
|
/** Every endpoint this peer advertised, in the order it offered them. */
|
|
878
1063
|
transports: Endpoint[];
|
|
879
1064
|
role: "Source" | "Destination";
|
|
880
|
-
communication_info?: Record<string, string
|
|
1065
|
+
communication_info?: Record<string, string> | null;
|
|
881
1066
|
}>;
|
|
882
1067
|
shared_key: Uint8Array;
|
|
883
1068
|
};
|
|
1069
|
+
/** The threshold the secret was split with. Absent when the roster
|
|
1070
|
+
* records none. `restore` writes it into the snapshot, so the next
|
|
1071
|
+
* publish splits at the same threshold; to change it, pass
|
|
1072
|
+
* `threshold` on `start(ProtectSecret)`. */
|
|
1073
|
+
threshold?: number;
|
|
884
1074
|
};
|
|
885
1075
|
}
|
|
886
1076
|
|
|
@@ -892,6 +1082,26 @@ export type DeRecEvent =
|
|
|
892
1082
|
* non-Ok status (HashedKeys flow). Distinct from a cryptographic
|
|
893
1083
|
* hash mismatch, which surfaces as a thrown error from `process()`. */
|
|
894
1084
|
| { type: "PrePairRejected"; channel_id: string; status: StatusEnum; memo: string }
|
|
1085
|
+
/** The peer answered a message from this device with an
|
|
1086
|
+
* `ErrorResponseMessage`: it could not process it, typically because the
|
|
1087
|
+
* body could not be decoded (`FORMAT_ERROR`). Never answered. */
|
|
1088
|
+
| { type: "ErrorResponseReceived"; channel_id: string; status: StatusEnum; memo: string }
|
|
1089
|
+
/** This device refused an inbound `PairRequest` under a protocol rule
|
|
1090
|
+
* (`INCOMPATIBLE_PARAMETER_RANGE` or `REPLICA_ID_CONFLICT`), whatever the
|
|
1091
|
+
* auto-accept or `auto_respond_on_failure` setting, and sent the requester a
|
|
1092
|
+
* `PairResponse` carrying `status` and `memo`. No channel was created.
|
|
1093
|
+
* Returned by `process()`; it does not throw. `memo` is what the requester
|
|
1094
|
+
* reads, written from its side. `error_code` (`"incompatible_parameter_range"`
|
|
1095
|
+
* or `"replica_id_conflict"`) and `message` carry the local reason, as on
|
|
1096
|
+
* `RequestFailed`; `message` is never sent to the peer. */
|
|
1097
|
+
| {
|
|
1098
|
+
type: "PairingRefused";
|
|
1099
|
+
channel_id: string;
|
|
1100
|
+
status: StatusEnum;
|
|
1101
|
+
memo: string;
|
|
1102
|
+
error_code: DeRecErrorCode;
|
|
1103
|
+
message: string;
|
|
1104
|
+
}
|
|
895
1105
|
|
|
896
1106
|
/** Fires alongside `PairingCompleted` on replica-mode pair handshakes.
|
|
897
1107
|
* `peer_replica_id` is the peer's `u64` as a **decimal** string,
|
|
@@ -931,6 +1141,11 @@ export type DeRecEvent =
|
|
|
931
1141
|
transports: Endpoint[];
|
|
932
1142
|
shared_key: Uint8Array;
|
|
933
1143
|
communication_info?: Record<string, string>;
|
|
1144
|
+
/** Shamir subshares this helper received in the round that wrote the
|
|
1145
|
+
* roster. `restore` writes it into the helper's channel record, so the
|
|
1146
|
+
* next publish gives it the same count. Every event carries it;
|
|
1147
|
+
* `restore` reads an absent value as 1. */
|
|
1148
|
+
weight?: number;
|
|
934
1149
|
}>;
|
|
935
1150
|
secrets: Array<{
|
|
936
1151
|
id: Uint8Array;
|
|
@@ -954,6 +1169,11 @@ export type DeRecEvent =
|
|
|
954
1169
|
}>;
|
|
955
1170
|
shared_key: Uint8Array;
|
|
956
1171
|
};
|
|
1172
|
+
/** The threshold the secret was split with. Absent when the roster
|
|
1173
|
+
* records none. `restore` writes it into the snapshot, so the next
|
|
1174
|
+
* publish splits at the same threshold; to change it, pass
|
|
1175
|
+
* `threshold` on `start(ProtectSecret)`. */
|
|
1176
|
+
threshold?: number;
|
|
957
1177
|
};
|
|
958
1178
|
shares: Array<{
|
|
959
1179
|
channel_id: string;
|
|
@@ -983,6 +1203,11 @@ export type DeRecEvent =
|
|
|
983
1203
|
transports: Endpoint[];
|
|
984
1204
|
shared_key: Uint8Array;
|
|
985
1205
|
communication_info?: Record<string, string>;
|
|
1206
|
+
/** Shamir subshares this helper received in the round that wrote the
|
|
1207
|
+
* roster. `restore` writes it into the helper's channel record, so the
|
|
1208
|
+
* next publish gives it the same count. Every event carries it;
|
|
1209
|
+
* `restore` reads an absent value as 1. */
|
|
1210
|
+
weight?: number;
|
|
986
1211
|
}>;
|
|
987
1212
|
secrets: Array<{
|
|
988
1213
|
id: Uint8Array;
|
|
@@ -1006,6 +1231,11 @@ export type DeRecEvent =
|
|
|
1006
1231
|
}>;
|
|
1007
1232
|
shared_key: Uint8Array;
|
|
1008
1233
|
};
|
|
1234
|
+
/** The threshold the secret was split with. Absent when the roster
|
|
1235
|
+
* records none. `restore` writes it into the snapshot, so the next
|
|
1236
|
+
* publish splits at the same threshold; to change it, pass
|
|
1237
|
+
* `threshold` on `start(ProtectSecret)`. */
|
|
1238
|
+
threshold?: number;
|
|
1009
1239
|
};
|
|
1010
1240
|
shares: Array<{
|
|
1011
1241
|
channel_id: string;
|
|
@@ -1041,6 +1271,11 @@ export type DeRecEvent =
|
|
|
1041
1271
|
transports: Endpoint[];
|
|
1042
1272
|
shared_key: Uint8Array;
|
|
1043
1273
|
communication_info?: Record<string, string>;
|
|
1274
|
+
/** Shamir subshares this helper received in the round that wrote the
|
|
1275
|
+
* roster. `restore` writes it into the helper's channel record, so the
|
|
1276
|
+
* next publish gives it the same count. Every event carries it;
|
|
1277
|
+
* `restore` reads an absent value as 1. */
|
|
1278
|
+
weight?: number;
|
|
1044
1279
|
}>;
|
|
1045
1280
|
secrets: Array<{
|
|
1046
1281
|
id: Uint8Array;
|
|
@@ -1063,8 +1298,28 @@ export type DeRecEvent =
|
|
|
1063
1298
|
}>;
|
|
1064
1299
|
shared_key: Uint8Array;
|
|
1065
1300
|
};
|
|
1301
|
+
/** The threshold the secret was split with. Absent when the roster
|
|
1302
|
+
* records none. `restore` writes it into the snapshot, so the next
|
|
1303
|
+
* publish splits at the same threshold; to change it, pass
|
|
1304
|
+
* `threshold` on `start(ProtectSecret)`. */
|
|
1305
|
+
threshold?: number;
|
|
1066
1306
|
};
|
|
1067
1307
|
}
|
|
1308
|
+
/** This device's library refused a group member's copy of the secret:
|
|
1309
|
+
* `FORMAT_ERROR` (the payload does not decode or is not self-consistent)
|
|
1310
|
+
* or `VERIFICATION_FAILED` (a share map entry does not verify against its
|
|
1311
|
+
* commitment). Nothing was written. On a push the publisher was answered
|
|
1312
|
+
* with this `status` and `memo`, which it observes as
|
|
1313
|
+
* `ReplicaSyncRejected`; a copy served by a catch-up is not answered. */
|
|
1314
|
+
| {
|
|
1315
|
+
type: "ReplicaSecretRefused";
|
|
1316
|
+
channel_id: string;
|
|
1317
|
+
from_replica_id: string;
|
|
1318
|
+
secret_id: string;
|
|
1319
|
+
version: number;
|
|
1320
|
+
status: StatusEnum;
|
|
1321
|
+
memo: string;
|
|
1322
|
+
}
|
|
1068
1323
|
/** Peer's ack of a secret sync we sent. `status` is the `StatusEnum`
|
|
1069
1324
|
* integer (0 = Ok), `memo` is the peer's explanation. */
|
|
1070
1325
|
| {
|
|
@@ -1101,6 +1356,37 @@ export type DeRecEvent =
|
|
|
1101
1356
|
* is the same label vocabulary as `ActionRequired.action_kind`
|
|
1102
1357
|
* (`"Pairing"`, `"StoreShare"`, …). */
|
|
1103
1358
|
| { type: "AutoAccepted"; channel_id: string; action_kind: PendingActionKind }
|
|
1359
|
+
/** A request that arrived on an authenticated channel failed while it
|
|
1360
|
+
* was being handled. Every such request is owed exactly one response.
|
|
1361
|
+
* When the library sent it, `responded` is `true` and `action` is absent.
|
|
1362
|
+
* Otherwise `responded` is `false` and `action` is the same opaque token
|
|
1363
|
+
* `ActionRequired` carries: pass it to `reject` to send the response
|
|
1364
|
+
* (`accept` refuses it). `action` is also absent when `reject` could
|
|
1365
|
+
* never answer it: a request on a replica group channel that names no
|
|
1366
|
+
* member, which has no reply target, or, with `autoRespondOnFailure`
|
|
1367
|
+
* off, a replica copy that hands this device the group key and fails
|
|
1368
|
+
* before that key is stored. Resolve each token once: the library is
|
|
1369
|
+
* stateless, so rejecting the same token twice sends two responses.
|
|
1370
|
+
* `action_kind` is the type of the failed request, `"Failed"` when its
|
|
1371
|
+
* body could not be decoded or is a request the channel cannot carry.
|
|
1372
|
+
* `status` is the `StatusEnum` value that was sent, or would have been,
|
|
1373
|
+
* and `memo` the wire-safe memo sent with it, or that would have been:
|
|
1374
|
+
* `reject(action, status, memo)` sends exactly the response
|
|
1375
|
+
* `autoRespondOnFailure` would have sent. `message` is a local
|
|
1376
|
+
* description, never sent to the peer. Reported
|
|
1377
|
+
* instead of a thrown error from `process()` or `accept()`, so the call's
|
|
1378
|
+
* other events are kept. */
|
|
1379
|
+
| {
|
|
1380
|
+
type: "RequestFailed";
|
|
1381
|
+
channel_id: string;
|
|
1382
|
+
action_kind: PendingActionKind;
|
|
1383
|
+
responded: boolean;
|
|
1384
|
+
status: StatusEnum;
|
|
1385
|
+
memo: string;
|
|
1386
|
+
error_code: DeRecErrorCode;
|
|
1387
|
+
message: string;
|
|
1388
|
+
action?: Uint8Array;
|
|
1389
|
+
}
|
|
1104
1390
|
| { type: "NoOp" }
|
|
1105
1391
|
/** An inbound message was dropped untouched: no store was written and
|
|
1106
1392
|
* nothing was sent back. `reason` says why.
|
|
@@ -1111,8 +1397,12 @@ export type DeRecEvent =
|
|
|
1111
1397
|
* Confirming does not replay it: after `verifyFingerprint` succeeds, a
|
|
1112
1398
|
* replica destination calls `start(FlowKind.ReplicaDiscovery)` to pull
|
|
1113
1399
|
* the copy itself. `"Expired"` means the message was older than the
|
|
1114
|
-
* inbound timeout. `
|
|
1115
|
-
* the
|
|
1400
|
+
* inbound timeout. `"TimestampMismatch"` means the envelope's timestamp
|
|
1401
|
+
* and the encrypted inner message's timestamp differ, or either is
|
|
1402
|
+
* absent. `"StaleResponse"` means a `VerifyShareResponse` answered an
|
|
1403
|
+
* earlier challenge that a newer one on the channel has replaced; the
|
|
1404
|
+
* outstanding challenge is kept. `trace_id` matches the peer's
|
|
1405
|
+
* `*Started` event for the same round (`"0"` when the sender set none). */
|
|
1116
1406
|
| {
|
|
1117
1407
|
type: "MessageIgnored";
|
|
1118
1408
|
channel_id: string;
|
|
@@ -1145,22 +1435,29 @@ export type DeRecEvent =
|
|
|
1145
1435
|
* targeted channels are unaffected. */
|
|
1146
1436
|
| { type: "DiscoveryFailed"; channel_id: string; error: string }
|
|
1147
1437
|
/** A share-storage request was dispatched to `channel_id`. Emitted per
|
|
1148
|
-
* targeted peer by `start(ProtectSecret)`.
|
|
1149
|
-
|
|
1438
|
+
* targeted peer by `start(ProtectSecret)`. `weight` is the number of
|
|
1439
|
+
* subshares sent, which is also the weight now stored for this channel:
|
|
1440
|
+
* its `ProtectSecretParams.weights` entry, 1 when the map does not name
|
|
1441
|
+
* it, or the stored weight on a publish the library starts on its own. */
|
|
1442
|
+
| { type: "ProtectSecretStarted"; channel_id: string; version: number; trace_id: string; weight: number }
|
|
1150
1443
|
/** A share-storage request could not be dispatched to `channel_id`. */
|
|
1151
1444
|
| {
|
|
1152
1445
|
type: "ProtectSecretFailed";
|
|
1153
1446
|
channel_id: string;
|
|
1154
1447
|
version: number;
|
|
1155
1448
|
error: string;
|
|
1449
|
+
/** Number of subshares that were to be sent to this channel; see
|
|
1450
|
+
* `ProtectSecretStarted.weight`. */
|
|
1451
|
+
weight: number;
|
|
1156
1452
|
}
|
|
1157
1453
|
/** A verify-share challenge was dispatched to `channel_id`. */
|
|
1158
1454
|
| { type: "VerifySharesStarted"; channel_id: string; version: number; trace_id: string }
|
|
1159
|
-
/**
|
|
1455
|
+
/** Verification reached no verdict for `channel_id`. `reason` says why. */
|
|
1160
1456
|
| {
|
|
1161
1457
|
type: "VerifySharesFailed";
|
|
1162
1458
|
channel_id: string;
|
|
1163
1459
|
version: number;
|
|
1460
|
+
reason: VerifyFailureReason;
|
|
1164
1461
|
error: string;
|
|
1165
1462
|
}
|
|
1166
1463
|
/** A recovery share request was dispatched to `channel_id`. */
|
|
@@ -1172,9 +1469,13 @@ export type DeRecEvent =
|
|
|
1172
1469
|
version: number;
|
|
1173
1470
|
error: string;
|
|
1174
1471
|
}
|
|
1175
|
-
/** An unpair request was dispatched to `channel_id
|
|
1176
|
-
* `
|
|
1177
|
-
*
|
|
1472
|
+
/** An unpair request was dispatched to `channel_id`, by
|
|
1473
|
+
* `start(Unpair)` or by `restore` for each recovery channel. Under
|
|
1474
|
+
* `UnpairAck.Required` the channel is now `"Unpairing"`, and an
|
|
1475
|
+
* `Unpaired` event follows once the peer acknowledges or the
|
|
1476
|
+
* acknowledgement window elapses, or `UnpairRejected` if the peer
|
|
1477
|
+
* refuses (the channel is `"Paired"` again). Under
|
|
1478
|
+
* `UnpairAck.NotRequired`, `Unpaired` follows in the same event vec. */
|
|
1178
1479
|
| { type: "UnpairFailed"; channel_id: string; error: string }
|
|
1179
1480
|
| { type: "UnpairStarted"; channel_id: string; trace_id: string }
|
|
1180
1481
|
/** An update-channel-info request was dispatched to `channel_id`. */
|
|
@@ -1198,16 +1499,20 @@ export type DeRecEvent =
|
|
|
1198
1499
|
* oracle. Anyone who knows a HashedKeys contact's nonce can elicit a
|
|
1199
1500
|
* key-publish response. Keep off unless you control both ends of
|
|
1200
1501
|
* the transport.
|
|
1201
|
-
* - `storeShare` — the helper's
|
|
1202
|
-
*
|
|
1203
|
-
*
|
|
1204
|
-
*
|
|
1205
|
-
* `
|
|
1206
|
-
*
|
|
1207
|
-
*
|
|
1208
|
-
*
|
|
1209
|
-
*
|
|
1210
|
-
*
|
|
1502
|
+
* - `storeShare` — the helper's admission-control point for inbound
|
|
1503
|
+
* shares beyond what the library already checks: this device's own
|
|
1504
|
+
* configured `minShareSize`/`maxShareSize` is enforced against every
|
|
1505
|
+
* inbound share's actual length regardless of this flag, before
|
|
1506
|
+
* `ActionRequired` is ever considered — an out-of-range share is
|
|
1507
|
+
* refused with `StatusEnum.SizeLimitExceeded` either way, and this
|
|
1508
|
+
* flag has no say in it. While this is `false`, `ActionRequired`
|
|
1509
|
+
* carries the decoded request, which is where a tighter or per-user
|
|
1510
|
+
* size limit, storage quota, or any other app-specific decline
|
|
1511
|
+
* belongs — call `reject()` for that. Setting it `true` removes that
|
|
1512
|
+
* opportunity: every in-range share from every paired Owner is stored
|
|
1513
|
+
* unconditionally, unless the share store refuses it. Keep off in any
|
|
1514
|
+
* deployment with per-user storage limits tighter than this device's
|
|
1515
|
+
* own configured range.
|
|
1211
1516
|
* - `unpair` — destructive. Accepting deletes the local channel
|
|
1212
1517
|
* record before any UI confirmation.
|
|
1213
1518
|
* - `updateChannelInfo` — silently overwrites the channel record with
|
|
@@ -1298,12 +1603,17 @@ export interface CommunicationInfo {
|
|
|
1298
1603
|
|
|
1299
1604
|
/** Why a `MessageIgnored` event dropped a message. Matches the Rust
|
|
1300
1605
|
* `IgnoreReason` discriminants one-for-one. */
|
|
1301
|
-
export type IgnoreReason = "PendingVerification" | "Expired";
|
|
1606
|
+
export type IgnoreReason = "PendingVerification" | "Expired" | "TimestampMismatch" | "StaleResponse";
|
|
1302
1607
|
|
|
1303
1608
|
/** Why a `PeerNotRestored` event left a roster entry without a channel.
|
|
1304
1609
|
* Matches the Rust `NotRestoredReason` discriminants one-for-one. */
|
|
1305
1610
|
export type NotRestoredReason = "NoTransports";
|
|
1306
1611
|
|
|
1612
|
+
/** Why a `VerifySharesFailed` event reached no verdict for a channel.
|
|
1613
|
+
* Matches the Rust `VerifyFailureReason` discriminants
|
|
1614
|
+
* one-for-one. */
|
|
1615
|
+
export type VerifyFailureReason = "NoSharedKey" | "NoProof" | "DispatchFailed";
|
|
1616
|
+
|
|
1307
1617
|
/** Why a `RecoveryShareCorrupted` event set a helper's share aside.
|
|
1308
1618
|
* Matches the Rust `CorruptionReason` discriminants one-for-one:
|
|
1309
1619
|
* `Malformed` — no decodable share for the requested secret and version;
|
|
@@ -1313,10 +1623,11 @@ export type NotRestoredReason = "NoTransports";
|
|
|
1313
1623
|
export type CorruptionReason = "Malformed" | "InvalidProof" | "Inconsistent";
|
|
1314
1624
|
|
|
1315
1625
|
/**
|
|
1316
|
-
* The label vocabulary for `ActionRequired.action_kind
|
|
1317
|
-
* `AutoAccepted.action_kind` — one value per
|
|
1318
|
-
* protocol can raise
|
|
1319
|
-
*
|
|
1626
|
+
* The label vocabulary for `ActionRequired.action_kind`,
|
|
1627
|
+
* `AutoAccepted.action_kind` and `RequestFailed.action_kind` — one value per
|
|
1628
|
+
* pending-action kind the protocol can raise, plus `"Failed"` for a request
|
|
1629
|
+
* whose body could not be decoded or that the channel cannot carry. Matches the Rust `PendingActionKind`
|
|
1630
|
+
* discriminants one-for-one.
|
|
1320
1631
|
*/
|
|
1321
1632
|
export type PendingActionKind =
|
|
1322
1633
|
| "Pairing"
|
|
@@ -1326,7 +1637,8 @@ export type PendingActionKind =
|
|
|
1326
1637
|
| "Discovery"
|
|
1327
1638
|
| "GetShare"
|
|
1328
1639
|
| "Unpair"
|
|
1329
|
-
| "UpdateChannelInfo"
|
|
1640
|
+
| "UpdateChannelInfo"
|
|
1641
|
+
| "Failed";
|
|
1330
1642
|
|
|
1331
1643
|
export interface ParameterRange {
|
|
1332
1644
|
min_share_size: bigint;
|
|
@@ -1341,6 +1653,100 @@ export interface ParameterRange {
|
|
|
1341
1653
|
max_unresponsive_deactivation_timeout: bigint;
|
|
1342
1654
|
}
|
|
1343
1655
|
|
|
1656
|
+
/**
|
|
1657
|
+
* `parameter_range` bounds inside `DeRecProtocolConfig`. Each bound is a
|
|
1658
|
+
* JSON number or a decimal string — the string form carries a bound past
|
|
1659
|
+
* `Number.MAX_SAFE_INTEGER` through a config file or a JSON encoder whose
|
|
1660
|
+
* numbers are `f64`. An absent bound is `0` ("no bound"), the same as
|
|
1661
|
+
* `DeRecProtocolBuilder.withParameterRange`.
|
|
1662
|
+
*/
|
|
1663
|
+
export interface DeRecParameterRangeConfig {
|
|
1664
|
+
min_share_size?: number | string;
|
|
1665
|
+
max_share_size?: number | string;
|
|
1666
|
+
min_time_between_verifications?: number | string;
|
|
1667
|
+
max_time_between_verifications?: number | string;
|
|
1668
|
+
min_time_between_share_updates?: number | string;
|
|
1669
|
+
max_time_between_share_updates?: number | string;
|
|
1670
|
+
min_unresponsive_deletion_timeout?: number | string;
|
|
1671
|
+
max_unresponsive_deletion_timeout?: number | string;
|
|
1672
|
+
min_unresponsive_deactivation_timeout?: number | string;
|
|
1673
|
+
max_unresponsive_deactivation_timeout?: number | string;
|
|
1674
|
+
}
|
|
1675
|
+
|
|
1676
|
+
/**
|
|
1677
|
+
* `auto_accept` inside `DeRecProtocolConfig`: the same eight flows as
|
|
1678
|
+
* {@link AutoAcceptPolicy}, named as the canonical JSON spells them rather
|
|
1679
|
+
* than in `camelCase`. An absent flow is `false`. See {@link AutoAcceptPolicy}
|
|
1680
|
+
* for per-field caveats.
|
|
1681
|
+
*/
|
|
1682
|
+
export interface DeRecAutoAcceptConfig {
|
|
1683
|
+
pairing?: boolean;
|
|
1684
|
+
pre_pair?: boolean;
|
|
1685
|
+
store_share?: boolean;
|
|
1686
|
+
verify_share?: boolean;
|
|
1687
|
+
discovery?: boolean;
|
|
1688
|
+
get_share?: boolean;
|
|
1689
|
+
unpair?: boolean;
|
|
1690
|
+
update_channel_info?: boolean;
|
|
1691
|
+
}
|
|
1692
|
+
|
|
1693
|
+
/**
|
|
1694
|
+
* Every data setting of `DeRecProtocolBuilder` in one serializable value, in
|
|
1695
|
+
* the canonical `snake_case` JSON shape every SDK accepts — the format for a
|
|
1696
|
+
* config file or a user record. Passed to `DeRecProtocolBuilder.withConfig`.
|
|
1697
|
+
*
|
|
1698
|
+
* Every field is optional: an absent or `null` field leaves that setting
|
|
1699
|
+
* unset. Stores, the delivery transport and the constructor's `secretId` are
|
|
1700
|
+
* not settings and are not carried here.
|
|
1701
|
+
*
|
|
1702
|
+
* Configs layer: apply a general config, then a per-user one, then any
|
|
1703
|
+
* individual `with*` call, and the last write wins per field —
|
|
1704
|
+
* `timeouts` merges per field too, so a config that sets only
|
|
1705
|
+
* `inbound_message_secs` keeps whatever `sharing_round_secs` an earlier
|
|
1706
|
+
* config or call set. Every other nested object (`parameter_range`,
|
|
1707
|
+
* `auto_accept`, `own_transports`) replaces as a whole.
|
|
1708
|
+
*
|
|
1709
|
+
* Values set through a field here are validated by `build()` exactly as the
|
|
1710
|
+
* matching `with*` setter's value would be: there is one rule set.
|
|
1711
|
+
*
|
|
1712
|
+
* ```json
|
|
1713
|
+
* {
|
|
1714
|
+
* "threshold": 3,
|
|
1715
|
+
* "max_subshares": "12",
|
|
1716
|
+
* "timeouts": { "inbound_message_secs": 120, "sharing_round_secs": 30 },
|
|
1717
|
+
* "parameter_range": { "min_share_size": 1, "max_share_size": 4096 },
|
|
1718
|
+
* "auto_accept": { "pairing": true, "store_share": true },
|
|
1719
|
+
* "auto_respond_on_failure": false,
|
|
1720
|
+
* "auto_reply_to": false,
|
|
1721
|
+
* "unpair_ack": "required",
|
|
1722
|
+
* "unsafe_connection": false,
|
|
1723
|
+
* "communication_info": { "name": "alice" },
|
|
1724
|
+
* "own_transports": [{ "uri": "https://me.example.com/derec", "protocol": "https" }],
|
|
1725
|
+
* "replica_id": "9007199254740993"
|
|
1726
|
+
* }
|
|
1727
|
+
* ```
|
|
1728
|
+
*/
|
|
1729
|
+
export interface DeRecProtocolConfig {
|
|
1730
|
+
threshold?: number;
|
|
1731
|
+
/** Decimal string. A `bigint` is rejected; call
|
|
1732
|
+
* `DeRecProtocolBuilder.withMaxSubshares` directly for a `bigint`. */
|
|
1733
|
+
max_subshares?: string;
|
|
1734
|
+
timeouts?: Timeouts;
|
|
1735
|
+
parameter_range?: DeRecParameterRangeConfig;
|
|
1736
|
+
auto_accept?: DeRecAutoAcceptConfig;
|
|
1737
|
+
auto_respond_on_failure?: boolean;
|
|
1738
|
+
auto_reply_to?: boolean;
|
|
1739
|
+
/** Its name, or the discriminant `0` (`"required"`) / `1`
|
|
1740
|
+
* (`"not_required"`). */
|
|
1741
|
+
unpair_ack?: UnpairAck | 0 | 1;
|
|
1742
|
+
unsafe_connection?: boolean;
|
|
1743
|
+
communication_info?: Record<string, string>;
|
|
1744
|
+
own_transports?: Endpoint[];
|
|
1745
|
+
/** Decimal string. A `bigint` is rejected; call
|
|
1746
|
+
* `DeRecProtocolBuilder.withReplicaId` directly for a `bigint`. */
|
|
1747
|
+
replica_id?: string;
|
|
1748
|
+
}
|
|
1749
|
+
|
|
1344
1750
|
export interface PairRequestMessage {
|
|
1345
1751
|
sender_kind: number;
|
|
1346
1752
|
mlkem_ciphertext: Uint8Array;
|
|
@@ -1368,6 +1774,11 @@ export interface PairResponseMessage {
|
|
|
1368
1774
|
* its own derivation. Zero on rejection (non-Ok `result.status`).
|
|
1369
1775
|
*/
|
|
1370
1776
|
channel_id: bigint;
|
|
1777
|
+
/**
|
|
1778
|
+
* Present only when `result.status === Ok`. The 32-byte fingerprint nonce
|
|
1779
|
+
* the contact creator committed to in `fingerprint_commitment`.
|
|
1780
|
+
*/
|
|
1781
|
+
fingerprint_nonce?: Uint8Array;
|
|
1371
1782
|
}
|
|
1372
1783
|
|
|
1373
1784
|
export interface PrePairRequestMessage {
|
|
@@ -1388,6 +1799,12 @@ export interface PrePairResponseMessage {
|
|
|
1388
1799
|
ecies_public_key?: Uint8Array;
|
|
1389
1800
|
nonce: bigint;
|
|
1390
1801
|
timestamp?: Timestamp;
|
|
1802
|
+
/**
|
|
1803
|
+
* Present only when `result.status === Ok`. The creator's 32-byte
|
|
1804
|
+
* commitment to the fingerprint nonce its `PairResponseMessage` reveals,
|
|
1805
|
+
* covering the two keys above.
|
|
1806
|
+
*/
|
|
1807
|
+
fingerprint_commitment?: Uint8Array;
|
|
1391
1808
|
}
|
|
1392
1809
|
|
|
1393
1810
|
export interface GetShareRequestMessage {
|
|
@@ -1437,7 +1854,7 @@ export interface StoreShareRequestMessage {
|
|
|
1437
1854
|
share: Uint8Array;
|
|
1438
1855
|
share_algorithm: number;
|
|
1439
1856
|
version: number;
|
|
1440
|
-
|
|
1857
|
+
keep_version: number;
|
|
1441
1858
|
version_description: string;
|
|
1442
1859
|
timestamp?: Timestamp;
|
|
1443
1860
|
secret_id: bigint;
|
|
@@ -1584,7 +2001,7 @@ export interface PrePairResponseExtractResult {
|
|
|
1584
2001
|
|
|
1585
2002
|
export interface ProcessPrePairResult {
|
|
1586
2003
|
|
|
1587
|
-
/** Initiator's ML-KEM-
|
|
2004
|
+
/** Initiator's ML-KEM-1024 encapsulation key, validated against the
|
|
1588
2005
|
* contact's `contactBindingHash`. */
|
|
1589
2006
|
mlkem_encapsulation_key: Uint8Array;
|
|
1590
2007
|
|
|
@@ -1594,8 +2011,20 @@ export interface ProcessPrePairResult {
|
|
|
1594
2011
|
|
|
1595
2012
|
/** Nonce echoed from the original `ContactMessage`. */
|
|
1596
2013
|
nonce: bigint;
|
|
2014
|
+
|
|
2015
|
+
/** The creator's 32-byte commitment to its fingerprint nonce. Copy it into
|
|
2016
|
+
* the contact the pair request is built from, alongside the two keys. */
|
|
2017
|
+
fingerprint_commitment: Uint8Array;
|
|
1597
2018
|
}
|
|
1598
2019
|
|
|
2020
|
+
/**
|
|
2021
|
+
* A channel paired with how many subshares it holds. A weight of `1` is an
|
|
2022
|
+
* ordinary helper; every weight must satisfy `1 <= weight < threshold`.
|
|
2023
|
+
* `channelId` is a channel id as bigint or decimal string, e.g. the
|
|
2024
|
+
* `channel_id` string from an event.
|
|
2025
|
+
*/
|
|
2026
|
+
export type WeightedChannel = [channelId: bigint | string, weight: number];
|
|
2027
|
+
|
|
1599
2028
|
export interface SplitResult {
|
|
1600
2029
|
/** Map keyed by channel id (`bigint`). */
|
|
1601
2030
|
shares: Map<bigint, CommittedDeRecShare>;
|