p2party 0.14.2 → 0.14.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/README.md +230 -30
  2. package/docs/getting-started.md +15 -0
  3. package/docs/protocol-v4-security.md +40 -0
  4. package/docs/references.md +28 -8
  5. package/docs/session-api.md +10 -2
  6. package/lib/api/signalingServerApi.d.ts +13 -2
  7. package/lib/api/webrtc/applyIceConfiguration.d.ts +9 -0
  8. package/lib/api/webrtc/dataChannelHandler.d.ts +10 -0
  9. package/lib/api/webrtc/deleteRoomData.d.ts +13 -0
  10. package/lib/api/webrtc/disconnectFromAllRoomsQuery.d.ts +2 -1
  11. package/lib/api/webrtc/disconnectFromRoomQuery.d.ts +2 -1
  12. package/lib/api/webrtc/disconnectQuery.d.ts +2 -1
  13. package/lib/api/webrtc/iceRepair.d.ts +3 -1
  14. package/lib/api/webrtc/index.d.ts +2 -1
  15. package/lib/api/webrtc/interfaces.d.ts +37 -0
  16. package/lib/api/webrtc/negotiationLock.d.ts +24 -0
  17. package/lib/api/webrtc/pendingOffer.d.ts +29 -0
  18. package/lib/api/webrtc/rebindDeadline.d.ts +61 -0
  19. package/lib/api/webrtc/remoteTransportChange.d.ts +142 -0
  20. package/lib/api/webrtc/retiredRemoteTransports.d.ts +70 -0
  21. package/lib/api/webrtc/roomEdgeBudget.d.ts +10 -0
  22. package/lib/api/webrtc/setDescriptionQuery.d.ts +8 -1
  23. package/lib/api/webrtc/settleOnClose.d.ts +36 -0
  24. package/lib/blindRendezvous/admissionInput.d.ts +11 -0
  25. package/lib/blindRendezvous/admissionPolicy.d.ts +217 -0
  26. package/lib/blindRendezvous/canonicalSchema.d.ts +139 -0
  27. package/lib/blindRendezvous/carrierEnvelope.d.ts +105 -0
  28. package/lib/blindRendezvous/coreReduce.d.ts +199 -0
  29. package/lib/blindRendezvous/derivations.d.ts +381 -0
  30. package/lib/blindRendezvous/identityHelloAdmission.d.ts +89 -0
  31. package/lib/blindRendezvous/identityHelloAdmissionPersistence.d.ts +133 -0
  32. package/lib/blindRendezvous/identityHelloHistoricalEvidence.d.ts +52 -0
  33. package/lib/blindRendezvous/identityHelloOpen.d.ts +167 -0
  34. package/lib/blindRendezvous/identityHelloTrial.d.ts +271 -0
  35. package/lib/blindRendezvous/localAdmissibleProject.d.ts +101 -0
  36. package/lib/blindRendezvous/localPresenceKeyBinding.d.ts +108 -0
  37. package/lib/blindRendezvous/localStableIdentityCustody.d.ts +46 -0
  38. package/lib/blindRendezvous/normativeKernel.d.ts +222 -0
  39. package/lib/blindRendezvous/operation.d.ts +137 -0
  40. package/lib/blindRendezvous/operationPayload.d.ts +134 -0
  41. package/lib/blindRendezvous/pairBootstrapSuite.d.ts +93 -0
  42. package/lib/blindRendezvous/pairCrypto.d.ts +122 -0
  43. package/lib/blindRendezvous/pairLedger.d.ts +154 -0
  44. package/lib/blindRendezvous/pairOpenBudget.d.ts +67 -0
  45. package/lib/blindRendezvous/pairOpenReservation.d.ts +157 -0
  46. package/lib/blindRendezvous/pairPlaintext.d.ts +240 -0
  47. package/lib/blindRendezvous/pairStepEnvelope.d.ts +60 -0
  48. package/lib/blindRendezvous/plannerState.d.ts +61 -0
  49. package/lib/blindRendezvous/projections.d.ts +71 -0
  50. package/lib/blindRendezvous/publicWindow.d.ts +330 -0
  51. package/lib/blindRendezvous/retainedOperationStore.d.ts +187 -0
  52. package/lib/blindRendezvous/roomInviteV2.d.ts +92 -0
  53. package/lib/blindRendezvous/roomPolicyV4.d.ts +90 -0
  54. package/lib/blindRendezvous/schemas.d.ts +221 -0
  55. package/lib/blindRendezvous/storeDescriptor.d.ts +160 -0
  56. package/lib/cryptography/aeadWasm.d.ts +18 -0
  57. package/lib/cryptography/byteInput.d.ts +12 -0
  58. package/lib/cryptography/carrierAead.d.ts +23 -0
  59. package/lib/cryptography/chacha20poly1305.d.ts +7 -0
  60. package/lib/cryptography/fips202.d.ts +10 -0
  61. package/lib/cryptography/hpke.d.ts +84 -0
  62. package/lib/cryptography/hpkeSuite.d.ts +39 -0
  63. package/lib/cryptography/hybridKem.d.ts +42 -0
  64. package/lib/cryptography/hybridKemSuite.d.ts +22 -0
  65. package/lib/cryptography/interfaces.d.ts +3 -0
  66. package/lib/cryptography/mlkem.d.ts +27 -1
  67. package/lib/cryptography/mnemonic.d.ts +65 -1
  68. package/lib/cryptography/ownedEd25519KeyMaterial.d.ts +27 -0
  69. package/lib/cryptography/webCryptoSha256.d.ts +20 -0
  70. package/lib/cryptography/x25519.d.ts +18 -0
  71. package/lib/cryptography/xchacha20poly1305.d.ts +7 -0
  72. package/lib/db/api.d.ts +6 -3
  73. package/lib/db/identityEd25519ClientBoundary.d.ts +13 -0
  74. package/lib/db/src/getDB.d.ts +2 -2
  75. package/lib/db/types.d.ts +52 -4
  76. package/lib/db.worker.js +1 -1
  77. package/lib/handlers/coverChannelRegistry.d.ts +22 -0
  78. package/lib/handlers/edgeTeardownFollowUp.d.ts +35 -0
  79. package/lib/handlers/handleChallenge.d.ts +2 -1
  80. package/lib/handlers/handleConnectToPeer.d.ts +1 -1
  81. package/lib/handlers/handleHandshake.d.ts +2 -6
  82. package/lib/handlers/handleSendMessage.d.ts +60 -7
  83. package/lib/handlers/handleWebSocketMessage.d.ts +1 -1
  84. package/lib/handlers/handshakeCore.d.ts +2 -7
  85. package/lib/handlers/handshakeFrame.d.ts +25 -0
  86. package/lib/handlers/ratchetGateWait.d.ts +13 -0
  87. package/lib/handlers/reconcile.d.ts +24 -0
  88. package/lib/handlers/requestRoom.d.ts +30 -0
  89. package/lib/handlers/roomResponse.d.ts +53 -0
  90. package/lib/index.d.ts +99 -12
  91. package/lib/index.js +1 -1
  92. package/lib/index.min.js +1 -1
  93. package/lib/index.mjs +1 -1
  94. package/lib/libcrypto.provenance.json +5 -5
  95. package/lib/libcrypto.wasm +0 -0
  96. package/lib/middleware/roomListenerMiddleware.d.ts +4 -1
  97. package/lib/reducers/commonSlice.d.ts +3 -2
  98. package/lib/reducers/keyPairSlice.d.ts +3 -6
  99. package/lib/reducers/roomSlice.d.ts +81 -5
  100. package/lib/reducers/signalingServerSlice.d.ts +3 -2
  101. package/lib/session.d.ts +6 -3
  102. package/lib/session.js +1 -1
  103. package/lib/session.mjs +1 -1
  104. package/lib/store.d.ts +4 -2
  105. package/lib/utils/constants.d.ts +12 -0
  106. package/lib/utils/correlationId.d.ts +4 -0
  107. package/lib/utils/identityRestore.d.ts +108 -0
  108. package/lib/utils/interfaces.d.ts +25 -6
  109. package/lib/utils/roomConnectAdmission.d.ts +15 -0
  110. package/lib/utils/roomLeaveCoordinator.d.ts +38 -0
  111. package/lib/utils/roomRequestCoordinator.d.ts +104 -0
  112. package/lib/utils/roomRosterReconciler.d.ts +83 -0
  113. package/lib/utils/sdpFingerprint.d.ts +6 -0
  114. package/lib/utils/signalingAttemptLifecycle.d.ts +33 -0
  115. package/lib/utils/signalingAuth.d.ts +21 -2
  116. package/lib/utils/signalingBounds.d.ts +6 -0
  117. package/lib/utils/signalingFrame.d.ts +21 -0
  118. package/lib/utils/signalingHeartbeatWatchdog.d.ts +45 -0
  119. package/lib/utils/signalingIngressQueue.d.ts +49 -0
  120. package/lib/utils/signalingPeerRequestDebouncer.d.ts +13 -0
  121. package/lib/utils/signalingRoomLifecycle.d.ts +7 -0
  122. package/lib/utils/signalingRoomOperationLifecycle.d.ts +14 -0
  123. package/lib/utils/signalingServerBoundary.d.ts +11 -0
  124. package/lib/utils/terminalSettlement.d.ts +53 -0
  125. package/lib/utils/transportIdentity.d.ts +5 -0
  126. package/package.json +1 -1
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Process-local custody for one persisted stable Ed25519 identity key.
3
+ *
4
+ * Trusted key storage constructs this handle from the secret key and its
5
+ * non-reused record revision. The public key is derived rather than accepted
6
+ * from the caller, so later receiver-key custody cannot bind an unrelated
7
+ * public identity. This internal module is absent from the package barrel.
8
+ */
9
+ import type { LibCrypto } from "../cryptography/libcrypto";
10
+ declare const localStableIdentityCustodyBrand: unique symbol;
11
+ /** Opaque live custody for one exact persisted stable identity key record. */
12
+ export interface LocalStableIdentityCustodyV1 {
13
+ readonly [localStableIdentityCustodyBrand]: true;
14
+ }
15
+ export interface CreateLocalStableIdentityCustodyOptionsV1 {
16
+ readonly module: LibCrypto;
17
+ readonly stableEd25519SecretKey: Uint8Array;
18
+ readonly localIdentityKeyRecordRevision: bigint;
19
+ }
20
+ export interface LocalStableIdentityCustodySnapshotV1 {
21
+ readonly version: 1;
22
+ readonly localStableEd25519PublicKey: Uint8Array;
23
+ readonly localIdentityKeyRecordRevision: bigint;
24
+ }
25
+ export declare class LocalStableIdentityCustodyError extends Error {
26
+ readonly name = "LocalStableIdentityCustodyError";
27
+ constructor(message: string);
28
+ }
29
+ /**
30
+ * Copy one stable secret and derive its public identity before minting custody.
31
+ *
32
+ * All caller-controlled values are captured before the first await. Mutating
33
+ * or wiping the caller's secret after invocation therefore cannot change the
34
+ * key held by the returned capability.
35
+ */
36
+ export declare const createLocalStableIdentityCustodyV1: (options: CreateLocalStableIdentityCustodyOptionsV1) => Promise<LocalStableIdentityCustodyV1>;
37
+ /** Return a fresh non-secret projection and assert that custody is still live. */
38
+ export declare const snapshotLocalStableIdentityCustodyV1: (custody: LocalStableIdentityCustodyV1) => LocalStableIdentityCustodySnapshotV1;
39
+ /**
40
+ * Wipe stable identity custody after its persisted key record is retired.
41
+ *
42
+ * Destruction is idempotent for a genuine handle. Dependent receiver custody
43
+ * retains the exact handle and therefore fails closed after this transition.
44
+ */
45
+ export declare const destroyLocalStableIdentityCustodyV1: (custody: LocalStableIdentityCustodyV1) => void;
46
+ export {};
@@ -0,0 +1,222 @@
1
+ /**
2
+ * Blind-rendezvous registry shape validators, intentionally absent from the
3
+ * package's public barrel.
4
+ *
5
+ * This module validates the logical shape of the kernel manifest, claim
6
+ * registry, claim evaluations, and formal-obligation records so separate tools
7
+ * cannot accept different registry shapes. It deliberately evaluates no claim
8
+ * and exposes no positive-wording authorizer.
9
+ *
10
+ * Every field table and closed enumeration below is now imported from
11
+ * `projections.ts`, which derives them from the canonical binary schema. The
12
+ * schema is the SSOT for bytes, widths, ordering, and bounds; this module owns
13
+ * only the cross-record reference, ordering, and acyclicity rules that a
14
+ * per-value encoding cannot express.
15
+ *
16
+ * The schema itself is still PROPOSED, not frozen: acquiring real protocol
17
+ * hashes additionally requires the Phase-0 freeze, deterministic vectors, and
18
+ * the module-8 resolver/evaluator.
19
+ */
20
+ export type Bytes32 = Uint8Array;
21
+ export type Uint16 = number;
22
+ export type KernelModuleIdV1 = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8;
23
+ export type KernelEntrypointIdV1 = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
24
+ export interface KernelEntrypointV1 {
25
+ entrypointId: KernelEntrypointIdV1;
26
+ inputSchemaHash: Bytes32;
27
+ outputSchemaHash: Bytes32;
28
+ normativeSourceHash: Bytes32;
29
+ }
30
+ export interface ExecutableRendezvousKernelModuleV1 {
31
+ moduleId: KernelModuleIdV1;
32
+ entrypoints: readonly KernelEntrypointV1[];
33
+ executableArtifactHash: Bytes32;
34
+ normativeSourceTreeHash: Bytes32;
35
+ canonicalVectorSetHash: Bytes32;
36
+ }
37
+ export interface ExecutableRendezvousKernelManifestV1 {
38
+ version: 1;
39
+ canonicalBinarySchemaHash: Bytes32;
40
+ modules: readonly ExecutableRendezvousKernelModuleV1[];
41
+ }
42
+ export interface BlindRendezvousImplementationBuildManifestV1 {
43
+ version: 1;
44
+ releaseRegistryHash: Bytes32;
45
+ implementationArtifactSetDigest: Bytes32;
46
+ executableModuleArtifactHashes: readonly Bytes32[];
47
+ productionSchedulerArtifactHash: Bytes32;
48
+ canonicalTraceSetDigest: Bytes32;
49
+ }
50
+ export type ClaimEvaluationStateV1 = "not-implemented" | "not-evaluated" | "unknown" | "expired" | "failed" | "satisfied";
51
+ export type ClaimScopeKindV1 = "release" | "deployment" | "room" | "carrier-instance" | "edge" | "r2-conformance-record";
52
+ export interface ClaimAssumptionV1 {
53
+ assumptionId: Uint16;
54
+ kind: "cryptographic" | "protocol" | "deployment" | "environmental";
55
+ canonicalStatement: string;
56
+ verification: {
57
+ kind: "declared-foundational";
58
+ } | {
59
+ kind: "evidence-verified";
60
+ verifierEntrypointId: KernelEntrypointIdV1;
61
+ };
62
+ }
63
+ export interface ClaimEvidenceKindV1 {
64
+ evidenceKindId: Uint16;
65
+ canonicalSchemaHash: Bytes32;
66
+ verifierEntrypointId: KernelEntrypointIdV1;
67
+ }
68
+ export interface ClaimWordingByStateV1 {
69
+ notImplemented: Uint16;
70
+ notEvaluated: Uint16;
71
+ unknown: Uint16;
72
+ expired: Uint16;
73
+ failed: Uint16;
74
+ satisfied: Uint16;
75
+ }
76
+ export interface ClaimDefinitionV1 {
77
+ claimId: Uint16;
78
+ scopeKind: ClaimScopeKindV1;
79
+ scopeSchemaHash: Bytes32;
80
+ predicateEntrypointId: KernelEntrypointIdV1;
81
+ assumptionIds: readonly Uint16[];
82
+ requiredEvidenceKindIds: readonly Uint16[];
83
+ prerequisiteClaimIds: readonly Uint16[];
84
+ requiredFormalObligationIds: readonly Uint16[];
85
+ wordingIdByState: ClaimWordingByStateV1;
86
+ forbiddenWordingIds: readonly Uint16[];
87
+ }
88
+ export interface ClaimRegistryV1 {
89
+ version: 1;
90
+ assumptions: readonly ClaimAssumptionV1[];
91
+ evidenceKinds: readonly ClaimEvidenceKindV1[];
92
+ claims: readonly ClaimDefinitionV1[];
93
+ wordingCatalogHash: Bytes32;
94
+ }
95
+ export interface ClaimWordingCatalogV1 {
96
+ version: 1;
97
+ wording: readonly {
98
+ claimId: Uint16;
99
+ wordingId: Uint16;
100
+ state: ClaimEvaluationStateV1;
101
+ canonicalText: string;
102
+ }[];
103
+ reasons: readonly {
104
+ reasonId: Uint16;
105
+ canonicalText: string;
106
+ }[];
107
+ }
108
+ export interface ClaimEvidenceBindingV1 {
109
+ evidenceKindId: Uint16;
110
+ evidenceId: Bytes32;
111
+ }
112
+ export interface ClaimPrerequisiteBindingV1 {
113
+ claimId: Uint16;
114
+ evaluationDigest: Bytes32;
115
+ }
116
+ export interface ClaimFormalResultBindingV1 {
117
+ obligationId: Uint16;
118
+ resultDigest: Bytes32;
119
+ }
120
+ export type ClaimAssumptionBindingV1 = {
121
+ assumptionId: Uint16;
122
+ kind: "declared-foundational";
123
+ } | {
124
+ assumptionId: Uint16;
125
+ kind: "evidence-verified";
126
+ evidenceId: Bytes32;
127
+ };
128
+ export interface ClaimEvaluationDatasetV1 {
129
+ version: 1;
130
+ releaseRegistryHash: Bytes32;
131
+ claimRegistryHash: Bytes32;
132
+ claimId: Uint16;
133
+ canonicalScope: Uint8Array;
134
+ assumptionBindings: readonly ClaimAssumptionBindingV1[];
135
+ evidenceBindings: readonly ClaimEvidenceBindingV1[];
136
+ prerequisiteBindings: readonly ClaimPrerequisiteBindingV1[];
137
+ formalResultBindings: readonly ClaimFormalResultBindingV1[];
138
+ evidenceSaturated: boolean;
139
+ firstSaturatedEvidenceId: Bytes32 | null;
140
+ }
141
+ export interface ClaimEvaluationInputV1 {
142
+ releaseRegistryHash: Bytes32;
143
+ claimRegistryHash: Bytes32;
144
+ claimId: Uint16;
145
+ scopeDigest: Bytes32;
146
+ evaluatedAtMs: bigint;
147
+ evaluationClockUncertaintyMs: bigint;
148
+ implementationPresent: boolean;
149
+ evaluationDatasetDigest: Bytes32;
150
+ }
151
+ export interface ClaimEvaluationV1 {
152
+ version: 1;
153
+ input: ClaimEvaluationInputV1;
154
+ state: ClaimEvaluationStateV1;
155
+ reasonIds: readonly Uint16[];
156
+ selectedWordingId: Uint16;
157
+ validThroughMs: bigint | null;
158
+ }
159
+ export interface CurrentClaimEvaluationRegistryRootsV1 {
160
+ releaseRegistryHash: Bytes32;
161
+ claimRegistryHash: Bytes32;
162
+ }
163
+ export type FormalObligationKindV1 = "algebraic" | "safety" | "liveness-refinement" | "computational-game";
164
+ export interface FormalObligationV1 {
165
+ obligationId: Uint16;
166
+ kind: FormalObligationKindV1;
167
+ modelSourceHash: Bytes32;
168
+ propertySourceHash: Bytes32;
169
+ abstractionMapHash: Bytes32;
170
+ toolchainLockHash: Bytes32;
171
+ proofScopeSchemaHash: Bytes32;
172
+ scopeCoverageEntrypointId: KernelEntrypointIdV1;
173
+ assumptionIds: readonly Uint16[];
174
+ }
175
+ export interface FormalObligationRegistryV1 {
176
+ version: 1;
177
+ obligations: readonly FormalObligationV1[];
178
+ }
179
+ export interface FormalProofScopeArtifactV1 {
180
+ version: 1;
181
+ obligationId: Uint16;
182
+ canonicalScope: Uint8Array;
183
+ }
184
+ export interface FormalProofResultV1 {
185
+ version: 1;
186
+ releaseRegistryHash: Bytes32;
187
+ formalObligationRegistryHash: Bytes32;
188
+ obligationId: Uint16;
189
+ modelSourceHash: Bytes32;
190
+ propertySourceHash: Bytes32;
191
+ assumptionSetHash: Bytes32;
192
+ abstractionMapHash: Bytes32;
193
+ toolchainLockHash: Bytes32;
194
+ proofScopeDigest: Bytes32;
195
+ implementationArtifactSetDigest: Bytes32;
196
+ canonicalTraceSetDigest: Bytes32;
197
+ schedulerWorkloadDigest: Bytes32;
198
+ result: "proved-within-scope" | "counterexample" | "inconclusive";
199
+ proofArtifactDigest: Bytes32;
200
+ counterexampleTraceDigest: Bytes32 | null;
201
+ }
202
+ export interface FormalProofValidationContextV1 {
203
+ releaseRegistryHash: Bytes32;
204
+ formalObligationRegistryHash: Bytes32;
205
+ expectedAssumptionSetHash: Bytes32;
206
+ }
207
+ export declare const validateExecutableRendezvousKernelManifestV1: (manifest: ExecutableRendezvousKernelManifestV1) => void;
208
+ export declare const validateClaimRegistryV1: (registry: ClaimRegistryV1) => void;
209
+ export declare const validateFormalObligationRegistryV1: (registry: FormalObligationRegistryV1) => void;
210
+ export declare const validateNormativeRegistriesV1: (manifest: ExecutableRendezvousKernelManifestV1, claimRegistry: ClaimRegistryV1, formalRegistry: FormalObligationRegistryV1) => void;
211
+ /**
212
+ * Checks the v0.4 structural publication set. This is not cryptographic
213
+ * release conformance until a caller verifies canonically derived roots.
214
+ */
215
+ export declare const validateV04ReleaseConformanceShapeV1: (manifest: ExecutableRendezvousKernelManifestV1, claimRegistry: ClaimRegistryV1, formalRegistry: FormalObligationRegistryV1) => void;
216
+ /**
217
+ * Validates artifact shape and its binding to caller-supplied current roots.
218
+ * It deliberately does not verify evidence, run the predicate, or authorize
219
+ * claim wording.
220
+ */
221
+ export declare const validateClaimEvaluationShapeV1: (evaluation: ClaimEvaluationV1, definition: ClaimDefinitionV1, currentRoots: CurrentClaimEvaluationRegistryRootsV1) => void;
222
+ export declare const validateFormalProofResultV1: (result: FormalProofResultV1, obligation: FormalObligationV1, validationContext: FormalProofValidationContextV1) => void;
@@ -0,0 +1,137 @@
1
+ /**
2
+ * The canonical authenticated room operation (Section 4.4).
3
+ *
4
+ * Outer validity is deliberately endpoint-independent: every room member can
5
+ * validate the canonical framing, author chain, lifetime, payload class, slot,
6
+ * and signature of any operation — including a `PAIR_STEP` addressed to two
7
+ * other members — so the same delivered bytes enter every member's core set.
8
+ * Pair AEAD and inner ledger rules are a separate edge-local step that can
9
+ * fail one edge without removing the operation from `CoreRoomState`. That
10
+ * split is what keeps another pair's private plaintext out of room convergence.
11
+ */
12
+ import type { LibCrypto } from "../cryptography/libcrypto";
13
+ import type { DecodedNonPairOperationPayloadV1 } from "./operationPayload";
14
+ import type { PairStepEnvelopeV1 } from "./pairStepEnvelope";
15
+ import type { RoomPolicyV4 } from "./roomPolicyV4";
16
+ export type OperationKindV1 = "PRESENCE" | "LEAVE" | "PAIR_STEP" | "STORE_HINT" | "ADMISSION_REVOKE";
17
+ export type OperationLifetimeV1 = "WINDOW_TRANSIENT" | "GRANT_HORIZON" | "PAIR_CAUSAL";
18
+ export type OperationPayloadClassV1 = 0 | 1;
19
+ export interface AuthenticatedRoomOperationV1 {
20
+ version: 1;
21
+ roomContextConfirmation: Uint8Array;
22
+ logicalWindow: bigint;
23
+ expiresAfterWindow: bigint;
24
+ lifetime: OperationLifetimeV1;
25
+ authorEpochEd25519Key: Uint8Array;
26
+ authorSequence: bigint;
27
+ previousAuthorOperationId: Uint8Array | null;
28
+ kind: OperationKindV1;
29
+ semanticSlot: Uint8Array;
30
+ dependencies: readonly Uint8Array[];
31
+ operationPayloadClass: OperationPayloadClassV1;
32
+ fixedPayload: Uint8Array;
33
+ operationPadding: Uint8Array;
34
+ authorSignature: Uint8Array;
35
+ }
36
+ export type UnsignedRoomOperationV1 = Omit<AuthenticatedRoomOperationV1, "authorSignature">;
37
+ export declare class OperationValidationError extends Error {
38
+ readonly name = "OperationValidationError";
39
+ constructor(message: string);
40
+ }
41
+ /**
42
+ * Longest period for which exact signed bytes can still be needed as inert
43
+ * author/dependency evidence.
44
+ *
45
+ * A LEAVE can be created at the end of a presence's transient lifetime and
46
+ * itself remain transient for one full retention interval, hence the checked
47
+ * two-interval dependency bound. Pair-causal and authority horizons may be
48
+ * longer and share this one SSOT.
49
+ */
50
+ export declare const requiredRoomRetentionWindows: (roomPolicy: RoomPolicyV4) => bigint;
51
+ /**
52
+ * The numerically smallest permitted class whose frozen codec fits the payload
53
+ * (`OperationPayloadClassFor`). The sender must use it and the receiver
54
+ * recomputes it, so a larger-than-necessary class is noncanonical rather than
55
+ * merely wasteful — otherwise class choice would leak a sender-selectable
56
+ * signal into a fixed-size traffic model.
57
+ */
58
+ export declare const operationPayloadClassFor: (kind: OperationKindV1, payloadBytes: number) => OperationPayloadClassV1;
59
+ declare const operationValidationContextBrand: unique symbol;
60
+ /**
61
+ * A process-local proof that one exact capability and one exact policy were
62
+ * used to derive this room context.
63
+ *
64
+ * The brand is backed by a private WeakMap, not by a caller-constructible
65
+ * property. This prevents a caller from pairing a real RoomContextId with a
66
+ * different policy and thereby changing admission semantics.
67
+ */
68
+ export interface OperationValidationContext {
69
+ readonly [operationValidationContextBrand]: true;
70
+ /** Canonical local `RoomContextId`; never supplied by a carrier. */
71
+ readonly roomContextId: Uint8Array;
72
+ /** `RoomContextConfirmation` derived from the local room context. */
73
+ readonly roomContextConfirmation: Uint8Array;
74
+ readonly roomPolicy: RoomPolicyV4;
75
+ /** The explicit reference window; never ambient wall-clock time. */
76
+ readonly referenceWindow: bigint;
77
+ }
78
+ /**
79
+ * Initialize the sole trusted operation-validation context from room secret
80
+ * material. Neither the capability nor PolicyHash is retained or exposed.
81
+ */
82
+ export declare const createOperationValidationContext: (capability: Uint8Array, roomPolicy: RoomPolicyV4, referenceWindow: bigint) => Promise<OperationValidationContext>;
83
+ /**
84
+ * Rebind an initialized room to an explicit reference window without needing
85
+ * to expose or reload its capability.
86
+ */
87
+ export declare const operationValidationContextAt: (context: OperationValidationContext, referenceWindow: bigint) => OperationValidationContext;
88
+ /** Return an independently owned, still-branded copy for an async boundary. */
89
+ export declare const snapshotOperationValidationContext: (context: OperationValidationContext) => OperationValidationContext;
90
+ /**
91
+ * Public cheap structural gate.
92
+ *
93
+ * Its return type intentionally remains void: the decoded pair envelope is an
94
+ * internal validation artifact, not a value callers may treat as trusted
95
+ * without the semantic-slot and author-signature checks below.
96
+ */
97
+ export declare const validateOperationStructure: (operation: AuthenticatedRoomOperationV1, context: OperationValidationContext) => void;
98
+ /** Verify the author signature over the exact domain-separated transcript. */
99
+ export declare const verifyOperationSignature: (operation: AuthenticatedRoomOperationV1, module?: LibCrypto) => Promise<boolean>;
100
+ export type DecodedOperationPayloadV1 = DecodedNonPairOperationPayloadV1 | {
101
+ readonly kind: "PAIR_STEP";
102
+ readonly value: PairStepEnvelopeV1;
103
+ };
104
+ export declare const validateOperationOuter: (operation: AuthenticatedRoomOperationV1, context: OperationValidationContext, module?: LibCrypto) => Promise<PairStepEnvelopeV1 | null>;
105
+ /**
106
+ * Authenticate a bounded reducer candidate.
107
+ *
108
+ * Unlike `validateOperationOuter`, this accepts exact outer-expired bytes only
109
+ * through the policy-derived inert evidence horizon. It still performs no
110
+ * nested payload signature work, so author quota/fork classification remains
111
+ * the first expensive-work boundary.
112
+ */
113
+ export declare const validateOperationCandidateOuter: (operation: AuthenticatedRoomOperationV1, context: OperationValidationContext, module?: LibCrypto) => Promise<PairStepEnvelopeV1 | null>;
114
+ /**
115
+ * Full intrinsic validation: authenticated outer candidate followed by the
116
+ * one nested payload codec selected by its signed kind.
117
+ *
118
+ * LEAVE's referenced-presence rule remains set-dependent and is completed by
119
+ * CoreReduce after the dependency is available.
120
+ */
121
+ export declare const validateOperationAndDecodePayload: (operation: AuthenticatedRoomOperationV1, context: OperationValidationContext, module?: LibCrypto) => Promise<DecodedOperationPayloadV1>;
122
+ /** Validate an operation without exposing its decoded payload artifact. */
123
+ export declare const validateOperation: (operation: AuthenticatedRoomOperationV1, context: OperationValidationContext, module?: LibCrypto) => Promise<void>;
124
+ /** Sign an operation over the exact transcript and return the signed form. */
125
+ export declare const signOperation: (unsigned: UnsignedRoomOperationV1, authorSecretKey: Uint8Array, module?: LibCrypto) => Promise<AuthenticatedRoomOperationV1>;
126
+ /** The unique canonical encoding of a signed operation. */
127
+ export declare const encodeOperation: (operation: AuthenticatedRoomOperationV1) => Uint8Array;
128
+ /** Decode and prove the bytes are the unique encoding of the result. */
129
+ export declare const decodeOperation: (encoded: Uint8Array) => AuthenticatedRoomOperationV1;
130
+ /**
131
+ * `OperationId`, derived only after carrier decryption and validation. It is
132
+ * never sent to a store as a logical identifier.
133
+ */
134
+ export declare const deriveOperationId: (operation: AuthenticatedRoomOperationV1) => Promise<Uint8Array>;
135
+ /** Build the all-zero padding a payload needs to reach its class length. */
136
+ export declare const operationPaddingFor: (operationPayloadClass: OperationPayloadClassV1, payloadBytes: number) => Uint8Array;
137
+ export {};
@@ -0,0 +1,134 @@
1
+ /**
2
+ * Closed non-pair operation payload codecs and intrinsic validation.
3
+ *
4
+ * The schema descriptors in `schemas.ts` are the byte SSOT. This module adds
5
+ * only rules that cannot be expressed by field widths alone: room/policy
6
+ * binding, interval containment, semantic-slot derivation, and signatures.
7
+ *
8
+ * A LEAVE's same-author/live-presence dependency is intentionally completed
9
+ * by `CoreReduce`, after the referenced operation is available. Rejecting a
10
+ * missing dependency here would make acceptance depend on carrier arrival
11
+ * order. Stable presence ownership is likewise verified only when a trusted
12
+ * local address-book key or the pair-private stable key is available.
13
+ */
14
+ import type { LibCrypto } from "../cryptography/libcrypto";
15
+ import type { AuthenticatedRoomOperationV1 } from "./operation";
16
+ import type { CorePresenceFactV1 } from "./coreReduce";
17
+ import type { RoomPolicyV4 } from "./roomPolicyV4";
18
+ import type { StoreDescriptorV1, StoreRouteV1 } from "./storeDescriptor";
19
+ export interface AdmissionGrantV1 {
20
+ version: 1;
21
+ roomContextId: Uint8Array;
22
+ stableEd25519PublicKey: Uint8Array;
23
+ generation: bigint;
24
+ issuedAtLogicalWindow: bigint;
25
+ notBeforeLogicalWindow: bigint;
26
+ notAfterLogicalWindow: bigint;
27
+ authoritySignature: Uint8Array;
28
+ }
29
+ export interface AdmissionRevokeV1 {
30
+ version: 1;
31
+ roomContextId: Uint8Array;
32
+ stableIdentityCommitment: Uint8Array;
33
+ minimumAcceptedGeneration: bigint;
34
+ effectiveLogicalWindow: bigint;
35
+ expiresAfterLogicalWindow: bigint;
36
+ authoritySignature: Uint8Array;
37
+ }
38
+ export interface PresenceCoreV1 {
39
+ version: 1;
40
+ stableIdentityCommitment: Uint8Array;
41
+ rendezvousHybridKemPublicKey: Uint8Array;
42
+ receiverKeyValidThroughLogicalWindow: bigint;
43
+ presenceNonce: Uint8Array;
44
+ validThroughLogicalWindow: bigint;
45
+ }
46
+ export interface PresencePermitV1 {
47
+ version: 1;
48
+ roomContextId: Uint8Array;
49
+ presenceProofTranscriptHash: Uint8Array;
50
+ permitSerial: Uint8Array;
51
+ generation: bigint;
52
+ issuedAtLogicalWindow: bigint;
53
+ notBeforeLogicalWindow: bigint;
54
+ notAfterLogicalWindow: bigint;
55
+ authoritySignature: Uint8Array;
56
+ }
57
+ export interface PresenceV1 {
58
+ core: PresenceCoreV1;
59
+ stableOwnershipSignature: Uint8Array;
60
+ authorityPermit: PresencePermitV1 | null;
61
+ }
62
+ export interface LeaveV1 {
63
+ version: 1;
64
+ presenceOperationId: Uint8Array;
65
+ effectiveLogicalWindow: bigint;
66
+ }
67
+ export interface StoreHintOperationV1 {
68
+ version: 1;
69
+ descriptor: StoreDescriptorV1;
70
+ routes: readonly StoreRouteV1[];
71
+ hintExpiresAfterLogicalWindow: bigint;
72
+ }
73
+ export type DecodedNonPairOperationPayloadV1 = {
74
+ readonly kind: "PRESENCE";
75
+ readonly value: PresenceV1;
76
+ } | {
77
+ readonly kind: "LEAVE";
78
+ readonly value: LeaveV1;
79
+ } | {
80
+ readonly kind: "STORE_HINT";
81
+ readonly value: StoreHintOperationV1;
82
+ } | {
83
+ readonly kind: "ADMISSION_REVOKE";
84
+ readonly value: AdmissionRevokeV1;
85
+ };
86
+ export interface NonPairPayloadValidationContext {
87
+ readonly roomContextId: Uint8Array;
88
+ readonly roomPolicy: RoomPolicyV4;
89
+ }
90
+ export interface AdmissionGrantValidationContext extends NonPairPayloadValidationContext {
91
+ /** Logical window of the HELLO or ACCEPT carrying this grant. */
92
+ readonly carriedAtLogicalWindow: bigint;
93
+ readonly referenceWindow: bigint;
94
+ }
95
+ export declare class OperationPayloadValidationError extends Error {
96
+ readonly name = "OperationPayloadValidationError";
97
+ constructor(message: string);
98
+ }
99
+ export declare const encodeAdmissionGrantV1: (value: AdmissionGrantV1) => Uint8Array;
100
+ export declare const decodeAdmissionGrantV1: (bytes: Uint8Array) => AdmissionGrantV1;
101
+ export declare const encodeAdmissionRevokeV1: (value: AdmissionRevokeV1) => Uint8Array;
102
+ export declare const decodeAdmissionRevokeV1: (bytes: Uint8Array) => AdmissionRevokeV1;
103
+ export declare const encodePresenceV1: (value: PresenceV1) => Uint8Array;
104
+ export declare const decodePresenceV1: (bytes: Uint8Array) => PresenceV1;
105
+ export declare const encodeLeaveV1: (value: LeaveV1) => Uint8Array;
106
+ export declare const decodeLeaveV1: (bytes: Uint8Array) => LeaveV1;
107
+ export declare const encodeStoreHintOperationV1: (value: StoreHintOperationV1) => Uint8Array;
108
+ export declare const decodeStoreHintOperationV1: (bytes: Uint8Array) => StoreHintOperationV1;
109
+ /**
110
+ * Validate a pair-private admission grant at the one decision snapshot.
111
+ *
112
+ * This does not apply frontend allow/deny policy or a revocation floor. Those
113
+ * belong to the sole admission kernel after it has captured its trusted
114
+ * snapshot; this function proves only the grant's canonical authority facts.
115
+ */
116
+ export declare const validateAdmissionGrantV1: (grant: AdmissionGrantV1, context: AdmissionGrantValidationContext, module?: LibCrypto) => Promise<void>;
117
+ /**
118
+ * Verify the stable ownership proof once a trusted local lookup or pair flight
119
+ * supplies the exact stable public key. The key is deliberately absent from
120
+ * room-wide presence, so core validation cannot call this function itself.
121
+ */
122
+ export declare const validatePresenceOwnershipV1: (operation: AuthenticatedRoomOperationV1, presence: PresenceV1, stableEd25519PublicKey: Uint8Array, context: NonPairPayloadValidationContext, module?: LibCrypto) => Promise<void>;
123
+ /**
124
+ * Verify ownership directly from a trusted Core presence fact.
125
+ *
126
+ * Core already authenticated the outer operation and preserved every field
127
+ * used by the ownership transcript. This avoids fabricating an incomplete
128
+ * `AuthenticatedRoomOperationV1` merely to perform a local address-book
129
+ * lookup. The function proves only the signature/commitment relation; the
130
+ * caller must still obtain the fact from a genuine current or retained Core
131
+ * projection before treating it as admission evidence.
132
+ */
133
+ export declare const validateCorePresenceFactOwnershipV1: (fact: CorePresenceFactV1, stableEd25519PublicKey: Uint8Array, context: NonPairPayloadValidationContext, module?: LibCrypto) => Promise<void>;
134
+ export declare const decodeAndValidateNonPairOperationPayload: (operation: AuthenticatedRoomOperationV1, context: NonPairPayloadValidationContext, module?: LibCrypto) => Promise<DecodedNonPairOperationPayloadV1>;
@@ -0,0 +1,93 @@
1
+ /**
2
+ * Constants-only registry for the complete pair-bootstrap suite selected by
3
+ * RoomPolicyV4 and encoded in PairBootstrapHeaderV1.
4
+ *
5
+ * This is the ID-to-cryptography SSOT. Schema geometry, policy validation,
6
+ * HPKE bootstrap, and established pair flights must project from this object
7
+ * rather than independently assigning meaning to suite ID 1.
8
+ */
9
+ export declare const PAIR_BOOTSTRAP_SUITE_ID_V1 = 1;
10
+ export declare const PAIR_BOOTSTRAP_SUITE_V1: Readonly<{
11
+ readonly id: 1;
12
+ readonly hybridKem: Readonly<{
13
+ readonly standardName: "MLKEM768-X25519";
14
+ readonly specification: "draft-irtf-cfrg-concrete-hybrid-kems-04";
15
+ readonly seedBytes: 32;
16
+ readonly publicKeyBytes: 1216;
17
+ readonly secretKeyBytes: 32;
18
+ readonly ciphertextBytes: 1120;
19
+ readonly sharedSecretBytes: 32;
20
+ readonly randomnessBytes: 64;
21
+ }>;
22
+ readonly hpke: Readonly<{
23
+ readonly specification: Readonly<{
24
+ kem: "draft-ietf-hpke-pq-05";
25
+ kemKeyDerivation: "draft-ietf-hpke-hpke-03";
26
+ keySchedule: "RFC 9180";
27
+ }>;
28
+ readonly kemId: 25722;
29
+ readonly kdfId: 1;
30
+ readonly aeadId: 3;
31
+ readonly publicKeyBytes: 1216;
32
+ readonly secretKeyBytes: 32;
33
+ readonly encapsulatedKeyBytes: 1120;
34
+ readonly sharedSecretBytes: 32;
35
+ readonly keyBytes: 32;
36
+ readonly nonceBytes: 12;
37
+ readonly tagBytes: 16;
38
+ readonly pskBytes: 32;
39
+ readonly pskIdBytes: 32;
40
+ }>;
41
+ readonly establishedPairAead: Readonly<{
42
+ standardName: "XChaCha20-Poly1305-IETF";
43
+ kdfId: 1;
44
+ keyBytes: number;
45
+ nonceBytes: number;
46
+ tagBytes: number;
47
+ }>;
48
+ readonly routingTagBytes: 32;
49
+ }>;
50
+ export declare const PAIR_BOOTSTRAP_SUITES_BY_ID: Readonly<{
51
+ readonly 1: Readonly<{
52
+ readonly id: 1;
53
+ readonly hybridKem: Readonly<{
54
+ readonly standardName: "MLKEM768-X25519";
55
+ readonly specification: "draft-irtf-cfrg-concrete-hybrid-kems-04";
56
+ readonly seedBytes: 32;
57
+ readonly publicKeyBytes: 1216;
58
+ readonly secretKeyBytes: 32;
59
+ readonly ciphertextBytes: 1120;
60
+ readonly sharedSecretBytes: 32;
61
+ readonly randomnessBytes: 64;
62
+ }>;
63
+ readonly hpke: Readonly<{
64
+ readonly specification: Readonly<{
65
+ kem: "draft-ietf-hpke-pq-05";
66
+ kemKeyDerivation: "draft-ietf-hpke-hpke-03";
67
+ keySchedule: "RFC 9180";
68
+ }>;
69
+ readonly kemId: 25722;
70
+ readonly kdfId: 1;
71
+ readonly aeadId: 3;
72
+ readonly publicKeyBytes: 1216;
73
+ readonly secretKeyBytes: 32;
74
+ readonly encapsulatedKeyBytes: 1120;
75
+ readonly sharedSecretBytes: 32;
76
+ readonly keyBytes: 32;
77
+ readonly nonceBytes: 12;
78
+ readonly tagBytes: 16;
79
+ readonly pskBytes: 32;
80
+ readonly pskIdBytes: 32;
81
+ }>;
82
+ readonly establishedPairAead: Readonly<{
83
+ standardName: "XChaCha20-Poly1305-IETF";
84
+ kdfId: 1;
85
+ keyBytes: number;
86
+ nonceBytes: number;
87
+ tagBytes: number;
88
+ }>;
89
+ readonly routingTagBytes: 32;
90
+ }>;
91
+ }>;
92
+ export type PairBootstrapSuiteIdV1 = keyof typeof PAIR_BOOTSTRAP_SUITES_BY_ID;
93
+ export declare const getPairBootstrapSuite: (suiteId: number) => typeof PAIR_BOOTSTRAP_SUITE_V1;