@derec-alliance/react-native 0.0.10 → 0.1.0

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.
@@ -25,9 +25,15 @@ import "google/protobuf/empty.proto";
25
25
  ///
26
26
  /// # Security
27
27
  ///
28
- /// This service provides no security guarantees of its own. Every
29
- /// `DeRecMessage` carries its payload signed and encrypted at the
30
- /// application layer, and remains valid regardless of transport.
28
+ /// This service provides no security guarantees of its own. On an established
29
+ /// channel, every `DeRecMessage` payload is encrypted and authenticated with
30
+ /// AES-256-GCM under the channel's shared key at the application layer; the
31
+ /// pairing messages are protected by the pairing handshake instead. Messages
32
+ /// are not signed. The envelope header is not covered by the authentication
33
+ /// tag: the receiver binds `timestamp` and the protocol version to copies in
34
+ /// the authenticated payload, and `channelId` selects the key, so none of
35
+ /// them can be altered undetected; `sequence` and `traceId` carry no
36
+ /// authenticated meaning. A message remains valid regardless of transport.
31
37
  service DeRecTransport {
32
38
  /// Deliver one DeRec envelope to this endpoint.
33
39
  ///
@@ -123,6 +123,7 @@ message PrePairRequestMessage {
123
123
  // ```
124
124
  //
125
125
  // and verify it matches the original `ContactMessage.contactBindingHash`.
126
+ // Keys whose sizes are not the fixed ones count as a mismatch.
126
127
  // - Only on a match, proceed to construct and send a normal
127
128
  // `PairRequestMessage`.
128
129
  //
@@ -110,9 +110,10 @@ enum StatusEnum {
110
110
  // - corrupted ciphertext
111
111
  DECRYPTION_FAILED = 7;
112
112
 
113
- // The message signature or authentication could not be verified.
113
+ // A share does not verify against its Merkle commitment.
114
114
  //
115
- // This indicates that the message integrity or authenticity check failed.
115
+ // Sent in answer to a share whose subshares and Merkle path do not
116
+ // reproduce the commitment it carries.
116
117
  VERIFICATION_FAILED = 8;
117
118
 
118
119
  // The message format is invalid.
@@ -54,8 +54,10 @@ enum Protocol {
54
54
  /// how to establish communication channels.
55
55
  ///
56
56
  /// A TransportProtocol does not itself provide security guarantees.
57
- /// All DeRec protocol messages MUST still be signed and encrypted at the
58
- /// application layer, regardless of the underlying transport.
57
+ /// DeRec protocol messages on an established channel are encrypted and
58
+ /// authenticated with AES-256-GCM at the application layer, regardless of
59
+ /// the underlying transport; the pairing messages are protected by the
60
+ /// pairing handshake.
59
61
  ///
60
62
  /// # Semantics
61
63
  ///
package/src/errors.ts CHANGED
@@ -32,6 +32,7 @@ export const DEREC_ERROR_CATEGORIES = [
32
32
  "protobuf",
33
33
  "invariant",
34
34
  "state_store",
35
+ "transport",
35
36
  ] as const;
36
37
 
37
38
  export type DeRecErrorCategory = (typeof DEREC_ERROR_CATEGORIES)[number];
@@ -76,6 +77,7 @@ export const DEREC_ERROR_CODES = [
76
77
  "unexpected_replica_id",
77
78
  "incompatible_parameter_range",
78
79
  "fingerprint_commitment_mismatch",
80
+ "pairing_expired",
79
81
  "empty_channels",
80
82
  "duplicate_channel_id",
81
83
  "invalid_threshold",
@@ -100,6 +102,7 @@ export const DEREC_ERROR_CODES = [
100
102
  "ffi_nul_in_string",
101
103
  "transport_invalid",
102
104
  "no_usable_endpoint",
105
+ "transport_send_failed",
103
106
  ] as const;
104
107
 
105
108
  export type DeRecErrorCode = (typeof DEREC_ERROR_CODES)[number];
@@ -119,7 +122,12 @@ export interface DeRecError {
119
122
  * Clear exactly these and retry `restore`.
120
123
  */
121
124
  channel_ids?: string[];
122
- /** The channel the failing inbound message arrived on, when `process()` could tell. */
125
+ /**
126
+ * The channel the error is about: the one named by
127
+ * `"channel_already_paired"`, `"fingerprint_mismatch"` and
128
+ * `"role_mismatch"`, or, on a failed `process()`, the channel the failing
129
+ * inbound message arrived on.
130
+ */
123
131
  channel_id?: string;
124
132
  /**
125
133
  * On a failed `process()`: the events it produced before failing, such as
package/src/primitives.ts CHANGED
@@ -895,4 +895,28 @@ export const envelope = {
895
895
  read_trace_id(envelope_bytes: Uint8Array): bigint {
896
896
  return call('read_trace_id_from_envelope', envelope_bytes) as bigint;
897
897
  },
898
+ /**
899
+ * Read the encrypted `message` field off an envelope, without the channel
900
+ * key: the part of an envelope an application can key duplicate detection
901
+ * on.
902
+ *
903
+ * It cannot be changed without failing decryption, and every message is
904
+ * sealed under a fresh random nonce, so it is the same for every copy of
905
+ * one message and different for every other message, even one with the
906
+ * same body. The cleartext fields around it (`sequence`, `traceId`) are
907
+ * not authenticated, and protobuf accepts more than one encoding of the
908
+ * same envelope, so a copy can arrive as different bytes: a hash of the
909
+ * raw envelope does not identify a message. How to key on these bytes (as
910
+ * they are, or hashed) and for how long is the application's choice.
911
+ *
912
+ * The plaintext `PrePair` leg of `HashedKeys` pairing is the exception: its
913
+ * `message` field is not encrypted, so a copy re-encoded inside it reads
914
+ * differently. That leg is not authenticated at all; the contact's nonce
915
+ * is what binds it.
916
+ *
917
+ * Throws when the bytes are not an envelope.
918
+ */
919
+ encrypted_payload(envelope_bytes: Uint8Array): Uint8Array {
920
+ return bytes(call('encrypted_payload_from_envelope', envelope_bytes));
921
+ },
898
922
  };
package/src/protocol.ts CHANGED
@@ -479,6 +479,18 @@ export class DeRecProtocolBuilder {
479
479
  return this;
480
480
  }
481
481
 
482
+ /**
483
+ * The oldest protocol version whose messages this device still accepts.
484
+ * An inbound envelope naming an older version is ignored with
485
+ * `MessageIgnored` reason `"ProtocolVersionTooOld"`: nothing is
486
+ * decrypted, stored or answered. Default: 0.0, which accepts every
487
+ * version.
488
+ */
489
+ withMinProtocolVersion(major: number, minor: number): this {
490
+ this.config.min_protocol_version = { major, minor };
491
+ return this;
492
+ }
493
+
482
494
  /**
483
495
  * Declare the bounds this node advertises during pair negotiation.
484
496
  *
@@ -702,6 +714,23 @@ export class DeRecProtocol {
702
714
  start(flowKind: FlowKind.Unpair, params: UnpairParams): Promise<DeRecEvent[]>;
703
715
  start(flowKind: FlowKind.UpdateChannelInfo, params: UpdateChannelInfoParams): Promise<DeRecEvent[]>;
704
716
  start(flowKind: FlowKind.ReplicaDiscovery, params?: ReplicaDiscoveryParams): Promise<DeRecEvent[]>;
717
+ /** Remove a member from the replica group; naming this device is a
718
+ * voluntary departure. It tells every member, the departing one included,
719
+ * then either drops the named member on this device at once, with any key
720
+ * only it used, and reports `ReplicaRemoved`, or, when removing this
721
+ * device, publishes without its own row and then drops the whole
722
+ * `secret_id` partition, reporting `SelfRemovedFromGroup`. Either way it
723
+ * publishes the latest snapshot, or an empty payload when there is none,
724
+ * with a roster that omits the member; that round's events follow, as for
725
+ * `start(FlowKind.ProtectSecret)`. The application publishes nothing
726
+ * itself to complete a removal.
727
+ *
728
+ * The departing member is on no distribution list from then on. Every
729
+ * other member flags it when told and drops it, with `ReplicaRemoved`,
730
+ * once that roster arrives. When this device removes itself, the remaining
731
+ * members acknowledge the publish after it dropped the group channel, and
732
+ * `process` fails those acknowledgements with an unknown-channel error,
733
+ * which can be disregarded. */
705
734
  start(flowKind: FlowKind.UnpairReplica, params: UnpairReplicaParams): Promise<DeRecEvent[]>;
706
735
  async start(flowKind: FlowKind, params?: unknown): Promise<DeRecEvent[]> {
707
736
  const paramsBytes = buildStartParams(flowKind, params);
package/src/types.ts CHANGED
@@ -756,7 +756,7 @@ export interface ProtectSecretParams {
756
756
  * (`PairingCompleted` included); `accept()` throws after the pairing has
757
757
  * completed and its response was sent, without returning
758
758
  * `PairingCompleted`; `verifyFingerprint()` throws after the promotion,
759
- * which stands, and a retry resolves `true` and publishes nothing. Call
759
+ * which stands, and a retry resolves and publishes nothing. Call
760
760
  * `start` with `ProtectSecret` and valid weights to publish.
761
761
  *
762
762
  * When the paired helpers' resolved total is below the round's threshold
@@ -833,6 +833,24 @@ export interface Timeouts {
833
833
  /** How long to wait for an unpair acknowledgement before dropping local
834
834
  * channel state anyway. Library default: 60. */
835
835
  unpair_ack_secs?: number;
836
+ /** How long a recovery waits for a helper to answer its share request. A
837
+ * recovery decides only once every helper it asked has answered or this
838
+ * has elapsed since the requests went out; each silent helper is then
839
+ * reported as `RecoverSecretFailed` with error `"timeout"`. The budget is
840
+ * a **human** one when helpers approve share requests by hand. The same
841
+ * budget bounds a replica version check (`FlowKind.ReplicaDiscovery`):
842
+ * once it elapses, the check concludes on the versions already reported.
843
+ * Library default: 300. */
844
+ get_share_response_secs?: number;
845
+ /** How long a pairing stays possible: how old a contact may be when it is
846
+ * scanned or answered, and how old a pairing request may be when it is
847
+ * accepted. Both sides enforce it and nothing is sent on expiry: the
848
+ * scanner refuses an expired contact, and the creator ignores a request on
849
+ * one and refuses a late accept, with `pairing_expired`. The remedy is to
850
+ * scan or share a fresh contact. A scanner's `expired_channels` timeout
851
+ * should be at least this plus the time a response takes to arrive.
852
+ * Library default: 30. */
853
+ pairing_secs?: number;
836
854
  /** Removal of channels still awaiting out-of-band fingerprint
837
855
  * confirmation — every replica pairing, and every `NoKeys` pairing.
838
856
  * Unlike the others this can be disabled, leaving the sweep to the
@@ -850,11 +868,19 @@ export type ReplicaDiscoveryParams = Record<string, never>;
850
868
  * source must be removable by the devices that remain, and the library
851
869
  * checks no role. Ask the user before starting this flow, above all when it
852
870
  * names the source. Removing the source promotes the first remaining member
853
- * in the order the channel store's `listReplicas` returns. The removed
854
- * member is not asked and gets no event when told to leave: when a roster
855
- * excluding it arrives it drops its whole `secret_id` partition and emits
856
- * `SelfRemovedFromGroup`. The secret survives on the remaining members and
857
- * the helpers. */
871
+ * in the order the channel store's `listReplicas` returns; removing a sole
872
+ * source dissolves the group. The removed member is not asked: when the
873
+ * notice naming it arrives it drops its whole `secret_id` partition and
874
+ * emits `SelfRemovedFromGroup`. If the notice is lost it keeps what it held,
875
+ * but it is sent nothing new and the remaining members refuse its messages
876
+ * once the roster without it has reached them. The secret survives on the
877
+ * remaining members and the helpers.
878
+ *
879
+ * Removal does not replace the group key, so it relies on the removed
880
+ * device's library deleting its copy. That covers a lost or stolen device
881
+ * whose storage was not read. Whoever read a device's storage keeps the
882
+ * group key and can decrypt every later publication it obtains, the one
883
+ * completing the removal included. */
858
884
  export interface UnpairReplicaParams {
859
885
  /** The member to remove, as a **decimal** `u64` string — the same form
860
886
  * `ReplicaPaired.peer_replica_id` hands back. A value naming no current
@@ -864,6 +890,26 @@ export interface UnpairReplicaParams {
864
890
  memo?: string;
865
891
  }
866
892
 
893
+ /** A helper named by a recovery decision (`RecoveryDisputed`,
894
+ * `RecoveryConflict`), so the app can tell the owner who is on each side.
895
+ * `channel_id` is the `u64` as a **decimal** string; `communication_info`
896
+ * is what the helper advertised when it paired, read from its channel
897
+ * record, and is absent when it advertised none. */
898
+ export interface RecoveryHelper {
899
+ channel_id: string;
900
+ communication_info?: Record<string, string>;
901
+ }
902
+
903
+ /** One secret a recovery reconstructed, reported in `RecoveryConflict`.
904
+ * `secret` has the shape of `SecretRecovered.secret`, so a confirmed
905
+ * candidate is passed to `restore` the same way. `supported_by` are the
906
+ * helpers whose shares reconstruct it, in the order their shares were
907
+ * collected. */
908
+ export interface RecoveryCandidate {
909
+ secret: Extract<DeRecEvent, { type: "SecretRecovered" }>["secret"];
910
+ supported_by: RecoveryHelper[];
911
+ }
912
+
867
913
  export type DeRecEvent =
868
914
  | {
869
915
  type: "PairingCompleted";
@@ -917,6 +963,11 @@ export type DeRecEvent =
917
963
  * from the application's own share store does not raise it. */
918
964
  | { type: "ShareRefused"; channel_id: string; version: number; status: StatusEnum; memo: string }
919
965
  | { type: "ShareConfirmed"; channel_id: string; version: number }
966
+ /** A helper rejected or failed to store our share. `status` and `memo`
967
+ * come from the helper's response, except for a helper that did not
968
+ * answer within `timeouts.sharing_round_secs`: `tick()` then reports it
969
+ * with status `FAIL` and memo `"timeout"`. The memo of a helper's own
970
+ * answer is free text and can read the same. */
920
971
  | { type: "ShareRejected"; channel_id: string; version: number; status: StatusEnum; memo: string }
921
972
  /** A publishing round finished — every targeted helper confirmed,
922
973
  * rejected, or timed out.
@@ -948,11 +999,17 @@ export type DeRecEvent =
948
999
  status: StatusEnum;
949
1000
  memo: string;
950
1001
  }
951
- /** A secret sync could not be delivered to a member at all — distinct from
952
- * `ReplicaSyncRejected`, which is the member answering "no". */
1002
+ /** A secret sync could not be delivered to a member, or the member did not
1003
+ * acknowledge it within `timeouts.sharing_round_secs` — distinct from
1004
+ * `ReplicaSyncRejected`, which is the member answering "no". `reason` is
1005
+ * `"timeout"` when the member did not acknowledge in time (reported by
1006
+ * `tick()`); otherwise the transport or encoding failure, rendered for
1007
+ * display. */
953
1008
  | { type: "ReplicaSyncFailed"; replica_id: string; version: number; reason: string }
954
1009
  /** A member left the group and its roster row was dropped. Fires on the
955
- * members that remain. */
1010
+ * device that ran the removal, when it starts it, and on every other
1011
+ * remaining member when the roster without the member arrives. The
1012
+ * departing device reports `SelfRemovedFromGroup` instead. */
956
1013
  | { type: "ReplicaRemoved"; replica_id: string }
957
1014
  /** The group's source role moved to another member because the previous
958
1015
  * source is leaving. Fires on the device that chose the successor — which
@@ -961,9 +1018,11 @@ export type DeRecEvent =
961
1018
  | { type: "ReplicaSourceChanged"; replica_id: string }
962
1019
  /** This device left the group and dropped its whole `secret_id` partition —
963
1020
  * group channel, helper channels, shares, secrets and the snapshot. Fires
964
- * only once it was told to leave *and* has since seen a roster excluding
965
- * it; absence alone never destroys a copy of the secret. The teardown is
966
- * automatic: this device is not asked first and gets no earlier event. */
1021
+ * when this device is told to leave, when it removes itself after
1022
+ * publishing the roster without it, or when a roster excluding it arrives
1023
+ * after it was told to leave by a device on an earlier release. The
1024
+ * teardown is automatic: this device is not asked first and gets no
1025
+ * earlier event. */
967
1026
  | { type: "SelfRemovedFromGroup"; version: number }
968
1027
  /** A replica catch-up finished. `fetched_from` is absent when this device
969
1028
  * was already current, in which case no hydration event follows. */
@@ -1003,25 +1062,36 @@ export type DeRecEvent =
1003
1062
 
1004
1063
  secrets: Array<{ secret_id: string; versions: Array<{ version: number; description: string }> }>;
1005
1064
  }
1065
+ /** A helper's share was collected for a recovery. Nothing is
1066
+ * reconstructed until every helper asked has answered or
1067
+ * `timeouts.get_share_response_secs` has passed since the requests went
1068
+ * out (each silent helper is then reported as `RecoverSecretFailed` with
1069
+ * error `"timeout"`). The recovery then decides exactly once:
1070
+ * `SecretRecovered`, `RecoveryDisputed`, `RecoveryConflict` or
1071
+ * `RecoveryIncomplete`. */
1006
1072
  | { type: "RecoveryShareReceived"; channel_id: string; shares_received: number }
1007
- | { type: "RecoveryShareError"; channel_id: string; shares_received: number; error: string }
1008
1073
  /** A helper refused a recovery share request: its response carried a
1009
1074
  * non-OK `status` (e.g. `UNKNOWN_SHARE_VERSION`) instead of a share. The
1010
- * refusal is not collected — it does not count towards `shares_received`
1011
- * and the recovery stays open for the other helpers' shares — but it does
1012
- * answer that helper's `RecoverSecretStarted`. */
1075
+ * refusal is not collected and does not count towards `shares_received`,
1076
+ * but it is that helper's answer: it answers the helper's
1077
+ * `RecoverSecretStarted`, and when it is the last answer due the recovery
1078
+ * decides on the shares it holds. */
1013
1079
  | { type: "RecoveryShareRefused"; channel_id: string; version: number; status: StatusEnum; memo: string }
1014
1080
  /** A helper answered with a share that cannot be part of the secret;
1015
1081
  * `reason` says how it failed. `Malformed` and `InvalidProof` are judged
1016
- * on arrival; `Inconsistent` (valid on its own but disagreeing with the
1017
- * shares the secret was rebuilt from) is reported alongside
1018
- * `SecretRecovered`, once per helper. The share is set aside — it does
1019
- * not count towards `shares_received` and never blocks the recovery. An
1020
- * honest helper never sends one, so the app may treat it as a sign of a
1021
- * damaged or compromised helper, e.g. offer to unpair it. It also
1022
- * answers that helper's `RecoverSecretStarted`. */
1082
+ * on arrival and count as that helper's answer; `Forged` (its group
1083
+ * reconstructs under one key, but not to a secret, or a single share
1084
+ * reconstructs alone) is reported with the recovery's decision, once per
1085
+ * helper. The share is set aside — it does not count towards
1086
+ * `shares_received` and never blocks the recovery. An honest helper never
1087
+ * sends one, so the app may treat it as a sign of a damaged or
1088
+ * compromised helper, e.g. offer to unpair it. A share that only
1089
+ * disagrees with the others is never reported here: it is a dispute
1090
+ * (`RecoveryDisputed` / `RecoveryConflict`), not evidence against its
1091
+ * helper. It also answers that helper's `RecoverSecretStarted`. */
1023
1092
  | { type: "RecoveryShareCorrupted"; channel_id: string; version: number; reason: CorruptionReason }
1024
- /** Recovery completed — the typed `Secret` snapshot the owner
1093
+ /** Recovery completed — one secret reconstructed and every collected
1094
+ * share is part of it. `secret` is the typed `Secret` snapshot the owner
1025
1095
  * originally protected. Mirrors `ReplicaSecretReceived.secret`:
1026
1096
  * `secrets` is the user-facing `Vec<UserSecret>` the application
1027
1097
  * fed to `start(FlowKind.ProtectSecret)`; `helpers` and `replicas`
@@ -1073,6 +1143,47 @@ export type DeRecEvent =
1073
1143
  threshold?: number;
1074
1144
  };
1075
1145
  }
1146
+ /** A recovery reconstructed two or more different secrets for `version`,
1147
+ * so it cannot tell which is the owner's. Each candidate is a complete,
1148
+ * self-consistent secret, rebuilt from the shares of the helpers in its
1149
+ * `supported_by`. Fewer than the threshold of colluding helpers can forge
1150
+ * one, so the library never picks: involve the owner and pass the
1151
+ * candidate's `secret` they confirm to `restore`, exactly as the `secret`
1152
+ * of `SecretRecovered`. The helpers backing a rejected candidate are
1153
+ * suspect. `disputed_by` names the helpers holding valid shares of yet
1154
+ * another split that does not reconstruct, so no helper's answer goes
1155
+ * unshown. The recovery is closed when this is emitted. */
1156
+ | {
1157
+ type: "RecoveryConflict";
1158
+ version: number;
1159
+ candidates: RecoveryCandidate[];
1160
+ disputed_by: RecoveryHelper[];
1161
+ }
1162
+ /** A recovery reconstructed one secret for `version`, but other helpers
1163
+ * hold valid shares of a different split that does not reconstruct.
1164
+ * `secret` is complete and self-consistent, rebuilt from the shares of
1165
+ * `supported_by`, and has the shape of `SecretRecovered.secret`. The
1166
+ * shares of `disputed_by` each pass their own proof but belong to another
1167
+ * split at the same version, which an honest sharing never produces.
1168
+ * Either side can be the owner's: colluding helpers can forge a complete
1169
+ * split, and the honest helpers may be too few to reconstruct theirs. The
1170
+ * library never picks: show the owner what `secret` holds and who stands
1171
+ * on each side, and pass `secret` to `restore` only once they confirm it.
1172
+ * The recovery is closed when this is emitted. */
1173
+ | {
1174
+ type: "RecoveryDisputed";
1175
+ version: number;
1176
+ secret: Extract<DeRecEvent, { type: "SecretRecovered" }>["secret"];
1177
+ supported_by: RecoveryHelper[];
1178
+ disputed_by: RecoveryHelper[];
1179
+ }
1180
+ /** A recovery of `(secret_id, version)` closed without reconstructing a
1181
+ * secret: every helper asked has answered, or the rest timed out, and no
1182
+ * collected shares reconstruct. `secret_id` and `version` name the
1183
+ * recovery that closed, since recoveries of several secrets can be open at
1184
+ * once. `shares_received` is the number of helpers whose shares were
1185
+ * collected. Start `RecoverSecret` again to retry. */
1186
+ | { type: "RecoveryIncomplete"; secret_id: string; version: number; shares_received: number }
1076
1187
 
1077
1188
  | { type: "Unpaired"; channel_id: string }
1078
1189
 
@@ -1401,8 +1512,18 @@ export type DeRecEvent =
1401
1512
  * and the encrypted inner message's timestamp differ, or either is
1402
1513
  * absent. `"StaleResponse"` means a `VerifyShareResponse` answered an
1403
1514
  * 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). */
1515
+ * outstanding challenge is kept. `"Superseded"` means a
1516
+ * `StoreShareRequest` for a version older than the newest one this
1517
+ * helper stores on the channel, and not stored itself; it is not stored
1518
+ * and not answered. `"ProtocolVersionTooOld"` means the envelope names a
1519
+ * protocol version older than the one set with `withMinProtocolVersion`;
1520
+ * nothing is decrypted, stored or answered. `"ProtocolVersionMismatch"`
1521
+ * means the envelope's protocol version and the copy inside the
1522
+ * encrypted payload differ: the envelope was altered or built by a
1523
+ * non-conforming peer; a payload from a release that writes no version
1524
+ * reads as 0.0, the version such a release puts on its envelope.
1525
+ * `trace_id` matches the peer's `*Started` event for the same round
1526
+ * (`"0"` when the sender set none). */
1406
1527
  | {
1407
1528
  type: "MessageIgnored";
1408
1529
  channel_id: string;
@@ -1474,7 +1595,9 @@ export type DeRecEvent =
1474
1595
  * `UnpairAck.Required` the channel is now `"Unpairing"`, and an
1475
1596
  * `Unpaired` event follows once the peer acknowledges or the
1476
1597
  * acknowledgement window elapses, or `UnpairRejected` if the peer
1477
- * refuses (the channel is `"Paired"` again). Under
1598
+ * refuses: after `start(Unpair)` the channel is `"Paired"` again; a
1599
+ * recovery channel `restore` unpaired is dropped instead, and
1600
+ * `Unpaired` follows the `UnpairRejected`. Under
1478
1601
  * `UnpairAck.NotRequired`, `Unpaired` follows in the same event vec. */
1479
1602
  | { type: "UnpairFailed"; channel_id: string; error: string }
1480
1603
  | { type: "UnpairStarted"; channel_id: string; trace_id: string }
@@ -1603,7 +1726,7 @@ export interface CommunicationInfo {
1603
1726
 
1604
1727
  /** Why a `MessageIgnored` event dropped a message. Matches the Rust
1605
1728
  * `IgnoreReason` discriminants one-for-one. */
1606
- export type IgnoreReason = "PendingVerification" | "Expired" | "TimestampMismatch" | "StaleResponse";
1729
+ export type IgnoreReason = "PendingVerification" | "Expired" | "TimestampMismatch" | "StaleResponse" | "Superseded" | "ProtocolVersionTooOld" | "ProtocolVersionMismatch";
1607
1730
 
1608
1731
  /** Why a `PeerNotRestored` event left a roster entry without a channel.
1609
1732
  * Matches the Rust `NotRestoredReason` discriminants one-for-one. */
@@ -1618,9 +1741,9 @@ export type VerifyFailureReason = "NoSharedKey" | "NoProof" | "DispatchFailed";
1618
1741
  * Matches the Rust `CorruptionReason` discriminants one-for-one:
1619
1742
  * `Malformed` — no decodable share for the requested secret and version;
1620
1743
  * `InvalidProof` — the share fails its own Merkle proof;
1621
- * `Inconsistent` — valid on its own, but its commitment root or ciphertext
1622
- * disagrees with the shares the secret was rebuilt from. */
1623
- export type CorruptionReason = "Malformed" | "InvalidProof" | "Inconsistent";
1744
+ * `Forged` — its group reconstructs under one key, but not to a secret, or
1745
+ * a single share reconstructs alone; an honest split produces neither. */
1746
+ export type CorruptionReason = "Malformed" | "InvalidProof" | "Forged";
1624
1747
 
1625
1748
  /**
1626
1749
  * The label vocabulary for `ActionRequired.action_kind`,
@@ -1722,7 +1845,8 @@ export interface DeRecAutoAcceptConfig {
1722
1845
  * "unsafe_connection": false,
1723
1846
  * "communication_info": { "name": "alice" },
1724
1847
  * "own_transports": [{ "uri": "https://me.example.com/derec", "protocol": "https" }],
1725
- * "replica_id": "9007199254740993"
1848
+ * "replica_id": "9007199254740993",
1849
+ * "min_protocol_version": { "major": 0, "minor": 1 }
1726
1850
  * }
1727
1851
  * ```
1728
1852
  */
@@ -1745,6 +1869,7 @@ export interface DeRecProtocolConfig {
1745
1869
  /** Decimal string. A `bigint` is rejected; call
1746
1870
  * `DeRecProtocolBuilder.withReplicaId` directly for a `bigint`. */
1747
1871
  replica_id?: string;
1872
+ min_protocol_version?: { major: number; minor: number };
1748
1873
  }
1749
1874
 
1750
1875
  export interface PairRequestMessage {
@@ -2041,3 +2166,4 @@ export interface UnpairingProcessResult {
2041
2166
  export interface DiscoveryProcessResult {
2042
2167
  secret_list: SecretVersionEntry[];
2043
2168
  }
2169
+