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,167 @@
1
+ /**
2
+ * Reservation-gated identity HELLO opener.
3
+ *
4
+ * This module is the sole current path from a committed pair-open reservation
5
+ * to HPKE work. It derives every transcript input from opaque trial
6
+ * provenance, authenticates the complete HELLO identity bundle, and retains
7
+ * HelloRoot only inside an opaque process-local result.
8
+ *
9
+ * The only next-state transition consumes the open into an opaque admission
10
+ * claim while leaving HelloRoot in this module's private custody.
11
+ * Pair-ledger persistence, ACCEPT construction, and any release of HelloRoot
12
+ * remain deliberately out of scope. This module is absent from the package
13
+ * barrel.
14
+ */
15
+ import type { LibCrypto } from "../cryptography/libcrypto";
16
+ import type { ActivePairOperationCandidateSnapshotV1, VerifiedHistoricalPairPresenceSnapshotV1 } from "./coreReduce";
17
+ import type { ExpectedIdentityHelloTrialV1, LocalHelloReceiverCustodySnapshotV1 } from "./identityHelloTrial";
18
+ import type { PairAttemptLeaseV1 } from "./admissionPolicy";
19
+ import type { AdmissionGrantV1 } from "./operationPayload";
20
+ import type { PairOuterBindingV1, PairPlaintextV1 } from "./pairPlaintext";
21
+ import type { ReservedIdentityHelloOpenV1 } from "./pairOpenReservation";
22
+ import type { RoomPolicyV4 } from "./roomPolicyV4";
23
+ declare const verifiedIdentityHelloOpenBrand: unique symbol;
24
+ declare const identityHelloAdmissionClaimBrand: unique symbol;
25
+ declare const consumedIdentityHelloAdmissionClaimBrand: unique symbol;
26
+ /** Opaque authenticated HELLO result. HelloRoot is never structurally exposed. */
27
+ export interface VerifiedIdentityHelloOpenV1 {
28
+ readonly [verifiedIdentityHelloOpenBrand]: true;
29
+ }
30
+ /**
31
+ * Process-local claim on one authenticated HELLO and its root custody.
32
+ *
33
+ * This is deliberately not `VerifiedAdmissionContextV1`: that fact may only
34
+ * be minted after the admission boundary has atomically captured and
35
+ * correlated every trusted state fence. This internal type is absent from the
36
+ * package barrel and never exposes HelloRoot.
37
+ */
38
+ export interface IdentityHelloAdmissionClaimV1 {
39
+ readonly [identityHelloAdmissionClaimBrand]: true;
40
+ }
41
+ /**
42
+ * Internal one-use transfer of an admission claim into asynchronous
43
+ * verification custody. It exposes no fields and retains the same private
44
+ * HelloRoot allocation; no secret is copied across this transition.
45
+ */
46
+ export interface ConsumedIdentityHelloAdmissionClaimV1 {
47
+ readonly [consumedIdentityHelloAdmissionClaimBrand]: true;
48
+ }
49
+ export interface IdentityHelloAdmissionClaimSnapshotV1 {
50
+ readonly version: 1;
51
+ readonly roomContextId: Uint8Array;
52
+ readonly roomPolicy: RoomPolicyV4;
53
+ /** Current-Core fence at the successful open; a later capture may advance. */
54
+ readonly exactOpenedCoreStateBytes: Uint8Array;
55
+ /** Exact HELLO-time Core row selecting the complete evidence bundle. */
56
+ readonly exactHistoricalEvidenceCoreStateBytes: Uint8Array;
57
+ /** Canonical Core + remote/local PRESENCE + author-prefix evidence. */
58
+ readonly exactHistoricalEvidenceBundleBytes: Uint8Array;
59
+ readonly openedAtReferenceWindow: bigint;
60
+ readonly receiverKeyRecordRevision: bigint;
61
+ readonly localIdentityKeyRecordRevision: bigint;
62
+ readonly localStableEd25519PublicKey: Uint8Array;
63
+ readonly decisionRole: "hello-responder";
64
+ readonly operationId: Uint8Array;
65
+ readonly kind: "IDENTITY_HELLO";
66
+ readonly logicalWindow: bigint;
67
+ readonly validThroughLogicalWindow: bigint;
68
+ readonly pairEdgeId: Uint8Array;
69
+ readonly endpointPresenceOperationIds: readonly [Uint8Array, Uint8Array];
70
+ readonly direction: 0;
71
+ readonly pairSequence: 0n;
72
+ readonly previousPairOperationId: null;
73
+ readonly pairDependencies: readonly [];
74
+ readonly stableEd25519PublicKey: Uint8Array;
75
+ readonly claimedStableIdentityCommitment: Uint8Array;
76
+ readonly optionalGrant: AdmissionGrantV1 | null;
77
+ readonly pairIdentitySignatureHash: Uint8Array;
78
+ readonly admittedPresenceOperationId: Uint8Array;
79
+ readonly admittedPresenceEvidenceRetainThroughLogicalWindow: bigint;
80
+ readonly basePairAttemptLease: PairAttemptLeaseV1;
81
+ }
82
+ export interface VerifiedIdentityHelloOpenSnapshotV1 {
83
+ readonly version: 1;
84
+ readonly helloOperationId: Uint8Array;
85
+ readonly activeCandidate: ActivePairOperationCandidateSnapshotV1;
86
+ readonly pairOuterBinding: PairOuterBindingV1;
87
+ readonly plaintext: PairPlaintextV1;
88
+ readonly localPresenceEvidence: VerifiedHistoricalPairPresenceSnapshotV1;
89
+ readonly remotePresenceEvidence: VerifiedHistoricalPairPresenceSnapshotV1;
90
+ readonly pairIdentitySignatureHash: Uint8Array;
91
+ /**
92
+ * Pre-admission base lease. Sole Admit may validate a carried grant, narrow
93
+ * this horizon, and persist the result atomically; this opener may not.
94
+ */
95
+ readonly basePairAttemptLease: PairAttemptLeaseV1;
96
+ readonly trialOrdinal: number;
97
+ readonly receiverKeyRecordRevision: bigint;
98
+ readonly localIdentityKeyRecordRevision: bigint;
99
+ readonly localStableEd25519PublicKey: Uint8Array;
100
+ }
101
+ export type OpenReservedIdentityHelloResultV1 = {
102
+ readonly kind: "opened";
103
+ readonly value: VerifiedIdentityHelloOpenV1;
104
+ } | {
105
+ readonly kind: "not-this-trial";
106
+ } | {
107
+ readonly kind: "rejected";
108
+ } | {
109
+ readonly kind: "deferred";
110
+ readonly reason: "missing-presence-evidence";
111
+ };
112
+ export declare class IdentityHelloOpenError extends Error {
113
+ readonly name = "IdentityHelloOpenError";
114
+ constructor(message: string);
115
+ }
116
+ /**
117
+ * Consume one committed reservation and try its exact expected HELLO trial.
118
+ *
119
+ * Reservation and trial consumption happen synchronously before the first
120
+ * await. `not-this-trial` means the routing tag or HPKE authentication did not
121
+ * match. `rejected` means authenticated bytes failed the closed HELLO identity
122
+ * gate. Provenance, programming, storage, or cryptographic infrastructure
123
+ * failures throw.
124
+ */
125
+ export declare const openReservedIdentityHelloV1: (capability: ReservedIdentityHelloOpenV1, trial: ExpectedIdentityHelloTrialV1, module: LibCrypto) => Promise<OpenReservedIdentityHelloResultV1>;
126
+ /** Return a fresh deeply owned snapshot containing no HelloRoot. */
127
+ export declare const snapshotVerifiedIdentityHelloOpenV1: (value: VerifiedIdentityHelloOpenV1) => VerifiedIdentityHelloOpenSnapshotV1;
128
+ /**
129
+ * Consume one authenticated HELLO into the only admission-claim handle.
130
+ *
131
+ * The transition is synchronous and moves, rather than copies, the private
132
+ * state. The old handle becomes unusable before control returns, and no root
133
+ * bytes cross the API.
134
+ */
135
+ export declare const takeVerifiedIdentityHelloOpenForAdmissionV1: (value: VerifiedIdentityHelloOpenV1) => IdentityHelloAdmissionClaimV1;
136
+ /** @internal Fresh deeply owned claim projection containing no HelloRoot. */
137
+ export declare const snapshotIdentityHelloAdmissionClaimV1: (value: IdentityHelloAdmissionClaimV1) => IdentityHelloAdmissionClaimSnapshotV1;
138
+ /**
139
+ * Synchronously spend one admission claim into in-flight verification custody.
140
+ *
141
+ * The source entry is deleted before return, so reentrancy and concurrent
142
+ * verification cannot reuse it. The private state and HelloRoot allocation are
143
+ * moved without copying. A minting failure wipes the transferred root.
144
+ *
145
+ * @internal
146
+ */
147
+ export declare const takeIdentityHelloAdmissionClaimForVerificationV1: (value: IdentityHelloAdmissionClaimV1) => ConsumedIdentityHelloAdmissionClaimV1;
148
+ /** @internal Fresh owned non-secret projection of one live consumed claim. */
149
+ export declare const snapshotConsumedIdentityHelloAdmissionClaimV1: (value: ConsumedIdentityHelloAdmissionClaimV1) => IdentityHelloAdmissionClaimSnapshotV1;
150
+ /**
151
+ * Assert and project the exact live receiver/stable custody carried through
152
+ * the authenticated HELLO transition.
153
+ *
154
+ * This internal accessor returns no capability or secret. Its only caller is
155
+ * the admission capture verifier, which compares both persisted revisions and
156
+ * the captured local-ownership row before minting trusted policy context.
157
+ *
158
+ * @internal
159
+ */
160
+ export declare const snapshotConsumedIdentityHelloAdmissionLocalCustodyV1: (value: ConsumedIdentityHelloAdmissionClaimV1) => LocalHelloReceiverCustodySnapshotV1;
161
+ /** Wipe in-flight HelloRoot custody. Idempotent for a genuine handle. */
162
+ export declare const destroyConsumedIdentityHelloAdmissionClaimV1: (value: ConsumedIdentityHelloAdmissionClaimV1) => void;
163
+ /** Wipe the retained HelloRoot. Idempotent for a genuine claim handle. */
164
+ export declare const destroyIdentityHelloAdmissionClaimV1: (value: IdentityHelloAdmissionClaimV1) => void;
165
+ /** Wipe the retained HelloRoot. Idempotent for a genuine handle. */
166
+ export declare const destroyVerifiedIdentityHelloOpenV1: (value: VerifiedIdentityHelloOpenV1) => void;
167
+ export {};
@@ -0,0 +1,271 @@
1
+ /**
2
+ * Provenance-checked local custody and receiver trial for identity HELLO.
3
+ *
4
+ * Expensive local ownership and hybrid-key verification happen exactly once
5
+ * when trusted room/key storage creates `LocalHelloReceiverCustodyV1`.
6
+ * Per-candidate `ExpectedIdentityHelloTrialV1` construction is synchronous,
7
+ * bounded, and cryptography-free. A later durable budget reservation binds
8
+ * the exact opaque candidate and trial objects. The opener can additionally
9
+ * assert the custody identity sealed inside that trial before it invokes the
10
+ * explicitly internal one-use secret transfer below.
11
+ *
12
+ * This module deliberately does not reserve work, run HPKE, authorize a peer,
13
+ * mutate a pair ledger, or publish a response. It is absent from the package
14
+ * barrel.
15
+ */
16
+ import type { LibCrypto } from "../cryptography/libcrypto";
17
+ import type { ActivePairOperationCandidateSnapshotV1, ActivePairOperationCandidateV1, VerifiedHistoricalPairPresenceEvidenceV1, VerifiedHistoricalPairPresenceSnapshotV1 } from "./coreReduce";
18
+ import type { ReservedIdentityHelloOpenV1 } from "./pairOpenReservation";
19
+ import type { RoomPolicyV4 } from "./roomPolicyV4";
20
+ import type { LocalStableIdentityCustodyV1 } from "./localStableIdentityCustody";
21
+ declare const localHelloReceiverCustodyBrand: unique symbol;
22
+ declare const historicalIdentityHelloEvidenceViewBrand: unique symbol;
23
+ declare const expectedIdentityHelloTrialBrand: unique symbol;
24
+ /**
25
+ * Opaque room-specific custody for one local presence receiver key.
26
+ *
27
+ * The current constructor is an interim trusted local-storage boundary:
28
+ * `receiverKeyRecordRevision` and `roomRoot` have no independent storage
29
+ * provenance yet. Stable identity ownership is already sealed by an exact
30
+ * `LocalStableIdentityCustodyV1` handle. The future atomic room/key adapter
31
+ * must be the sole caller. None of these values become per-trial inputs.
32
+ */
33
+ export interface LocalHelloReceiverCustodyV1 {
34
+ readonly [localHelloReceiverCustodyBrand]: true;
35
+ }
36
+ /**
37
+ * Opaque bounded endpoint-evidence lookup for one exact HELLO-time Core view.
38
+ *
39
+ * It is not admission or topology authority. The trusted caller supplies the
40
+ * locally selected subset; the later planner/explicit-state fence decides
41
+ * whether an authenticated endpoint may receive a response.
42
+ */
43
+ export interface HistoricalIdentityHelloEvidenceViewV1 {
44
+ readonly [historicalIdentityHelloEvidenceViewBrand]: true;
45
+ }
46
+ /** Opaque, process-local, one-use candidate trial. */
47
+ export interface ExpectedIdentityHelloTrialV1 {
48
+ readonly [expectedIdentityHelloTrialBrand]: true;
49
+ }
50
+ export interface CreateLocalHelloReceiverCustodyOptionsV1 {
51
+ readonly module: LibCrypto;
52
+ readonly localPresenceEvidence: VerifiedHistoricalPairPresenceEvidenceV1;
53
+ /** Suite-1 MLKEM768-X25519 deterministic receiver seed. */
54
+ readonly recipientHybridKemSecretSeed: Uint8Array;
55
+ /** Exact room-specific HPKE PSK derived by trusted initialized-room state. */
56
+ readonly roomRoot: Uint8Array;
57
+ readonly localStableIdentityCustody: LocalStableIdentityCustodyV1;
58
+ readonly receiverKeyRecordRevision: bigint;
59
+ }
60
+ export interface LocalHelloReceiverCustodySnapshotV1 {
61
+ readonly version: 1;
62
+ readonly localPresenceOperationId: Uint8Array;
63
+ readonly exactPresenceOperationBytes: Uint8Array;
64
+ readonly sourceEvidenceCoreStateBytes: Uint8Array;
65
+ readonly sourceEvidenceLogicalWindow: bigint;
66
+ readonly roomContextId: Uint8Array;
67
+ readonly roomPolicy: RoomPolicyV4;
68
+ readonly advertisedReceiverHybridKemPublicKey: Uint8Array;
69
+ readonly receiverKeyValidThroughLogicalWindow: bigint;
70
+ readonly receiverEvidenceRetainThroughLogicalWindow: bigint;
71
+ readonly localStableEd25519PublicKey: Uint8Array;
72
+ readonly localIdentityKeyRecordRevision: bigint;
73
+ readonly receiverKeyRecordRevision: bigint;
74
+ }
75
+ export interface CreateHistoricalIdentityHelloEvidenceViewOptionsV1 {
76
+ /**
77
+ * A nonempty bounded subset of observed PRESENCE evidence from one genuine
78
+ * HELLO-time Core result. Production supplies the Project-selected subset
79
+ * needed by local receiver trials, never the whole raw overcapacity roster.
80
+ */
81
+ readonly historicalPresenceEvidence: readonly VerifiedHistoricalPairPresenceEvidenceV1[];
82
+ }
83
+ /**
84
+ * Compact, deeply owned metadata for one bounded historical evidence view.
85
+ *
86
+ * Presence operation IDs are sufficient for deterministic membership and
87
+ * lookup. Exact operation/prefix snapshots are resolved one at a time only
88
+ * after a durable pair-open reservation has been consumed.
89
+ */
90
+ export interface HistoricalIdentityHelloEvidenceViewSnapshotV1 {
91
+ readonly version: 1;
92
+ readonly exactCoreStateBytes: Uint8Array;
93
+ readonly roomContextId: Uint8Array;
94
+ readonly roomPolicy: RoomPolicyV4;
95
+ readonly helloLogicalWindow: bigint;
96
+ readonly minimumRetainThroughLogicalWindow: bigint;
97
+ readonly presenceOperationIds: readonly Uint8Array[];
98
+ }
99
+ export interface CreateExpectedIdentityHelloTrialOptionsV1 {
100
+ readonly activeCandidate: ActivePairOperationCandidateV1;
101
+ readonly receiverCustody: LocalHelloReceiverCustodyV1;
102
+ readonly historicalEvidenceView: HistoricalIdentityHelloEvidenceViewV1;
103
+ readonly trialOrdinal: number;
104
+ }
105
+ /**
106
+ * Deeply owned non-secret view for durable reservation/CAS binding.
107
+ *
108
+ * `exactCoreStateBytes` is the current active-operation fence.
109
+ * `exactEvidenceCoreStateBytes` is the potentially older, exact HELLO-window
110
+ * presence-proof fence. They intentionally need not be equal.
111
+ */
112
+ export interface ExpectedIdentityHelloTrialSnapshotV1 {
113
+ readonly version: 1;
114
+ readonly activeOperationId: Uint8Array;
115
+ readonly exactCoreStateBytes: Uint8Array;
116
+ readonly exactEvidenceCoreStateBytes: Uint8Array;
117
+ readonly roomContextId: Uint8Array;
118
+ readonly roomPolicy: RoomPolicyV4;
119
+ readonly helloLogicalWindow: bigint;
120
+ readonly localPresenceOperationId: Uint8Array;
121
+ readonly advertisedReceiverHybridKemPublicKey: Uint8Array;
122
+ readonly receiverKeyValidThroughLogicalWindow: bigint;
123
+ readonly receiverEvidenceRetainThroughLogicalWindow: bigint;
124
+ readonly trialOrdinal: number;
125
+ readonly receiverKeyRecordRevision: bigint;
126
+ readonly localIdentityKeyRecordRevision: bigint;
127
+ readonly activeCandidate: ActivePairOperationCandidateSnapshotV1;
128
+ readonly receiverCustody: LocalHelloReceiverCustodySnapshotV1;
129
+ readonly localPresenceEvidence: VerifiedHistoricalPairPresenceSnapshotV1;
130
+ readonly historicalEvidenceView: HistoricalIdentityHelloEvidenceViewSnapshotV1;
131
+ }
132
+ /**
133
+ * Small private-to-the-pair-kernel projection used before work is charged.
134
+ *
135
+ * It contains no decoded room roster, presence operation, author prefix,
136
+ * receiver secret, RoomRoot, or caller-controlled coordinate.
137
+ *
138
+ * @internal
139
+ */
140
+ export interface ExpectedIdentityHelloTrialReservationProjectionV1 {
141
+ readonly version: 1;
142
+ readonly activeOperationId: Uint8Array;
143
+ readonly exactCurrentCoreStateBytes: Uint8Array;
144
+ readonly exactEvidenceCoreStateBytes: Uint8Array;
145
+ readonly roomContextId: Uint8Array;
146
+ readonly localPresenceOperationId: Uint8Array;
147
+ readonly receiverKeyRecordRevision: bigint;
148
+ readonly capturedReferenceWindow: bigint;
149
+ readonly completeEnvelopeBytes: number;
150
+ }
151
+ /**
152
+ * Internal one-use transfer returned only after consuming a genuine durable
153
+ * reservation.
154
+ *
155
+ * Both returned secrets are fresh owned copies and MUST be wiped by the
156
+ * consumer in a `finally` block. The reusable custody master remains live
157
+ * until explicitly destroyed because concurrent HELLO trials may need it.
158
+ *
159
+ * @internal
160
+ */
161
+ export interface ConsumedExpectedIdentityHelloTrialV1 {
162
+ readonly snapshot: ExpectedIdentityHelloTrialSnapshotV1;
163
+ readonly activeCandidate: ActivePairOperationCandidateV1;
164
+ readonly receiverCustody: LocalHelloReceiverCustodyV1;
165
+ readonly localPresenceEvidence: VerifiedHistoricalPairPresenceEvidenceV1;
166
+ /**
167
+ * Exact-ID lookup over the bounded fenced view. This function exists only
168
+ * after the durable reservation is consumed; it returns an opaque genuine
169
+ * evidence handle, never a caller-assembled structural proof.
170
+ */
171
+ readonly resolveHistoricalPresenceEvidence: (presenceOperationId: Uint8Array) => VerifiedHistoricalPairPresenceEvidenceV1 | null;
172
+ readonly recipientHybridKemSecretSeed: Uint8Array;
173
+ readonly roomRoot: Uint8Array;
174
+ }
175
+ export declare class IdentityHelloTrialError extends Error {
176
+ readonly name = "IdentityHelloTrialError";
177
+ constructor(message: string);
178
+ }
179
+ /**
180
+ * Capture one bounded exact-Core evidence subset.
181
+ *
182
+ * The O(selected-member-count) provenance work and canonical Core decode
183
+ * happen once here. Every later receiver-key trial reuses the opaque result
184
+ * and performs no raw-roster walk. A view may omit an otherwise valid Core
185
+ * presence because Project did not select it; a HELLO naming an omitted
186
+ * endpoint is deferred and can never bypass later planner/admission fences.
187
+ */
188
+ export declare const createHistoricalIdentityHelloEvidenceViewV1: (options: CreateHistoricalIdentityHelloEvidenceViewOptionsV1) => Promise<HistoricalIdentityHelloEvidenceViewV1>;
189
+ /** Return fresh compact metadata, never per-presence operation snapshots. */
190
+ export declare const snapshotHistoricalIdentityHelloEvidenceViewV1: (view: HistoricalIdentityHelloEvidenceViewV1) => HistoricalIdentityHelloEvidenceViewSnapshotV1;
191
+ /**
192
+ * Create reusable local receiver custody.
193
+ *
194
+ * All caller bytes and execution dependencies are captured before the first
195
+ * await. Expensive verification occurs here once per persisted key record,
196
+ * never once per attacker-supplied PAIR_STEP.
197
+ */
198
+ export declare const createLocalHelloReceiverCustodyV1: (options: CreateLocalHelloReceiverCustodyOptionsV1) => Promise<LocalHelloReceiverCustodyV1>;
199
+ /** Return a fresh non-secret custody projection. */
200
+ export declare const snapshotLocalHelloReceiverCustodyV1: (custody: LocalHelloReceiverCustodyV1) => LocalHelloReceiverCustodySnapshotV1;
201
+ /**
202
+ * Create one cheap expected trial from already-verified local custody.
203
+ *
204
+ * This function is intentionally synchronous and performs no signature, KEM,
205
+ * KDF, AEAD, or storage work.
206
+ */
207
+ export declare const createExpectedIdentityHelloTrialV1: (options: CreateExpectedIdentityHelloTrialOptionsV1) => ExpectedIdentityHelloTrialV1;
208
+ /** Return a fresh, independently owned, non-secret trial snapshot. */
209
+ export declare const snapshotExpectedIdentityHelloTrialV1: (trial: ExpectedIdentityHelloTrialV1) => ExpectedIdentityHelloTrialSnapshotV1;
210
+ /**
211
+ * Return the only pre-budget projection used by reservation.
212
+ *
213
+ * All fields were captured once when the trial was constructed. In
214
+ * particular, this function performs no Core decode, roster walk, evidence
215
+ * snapshot, operation decode, signature work, KEM work, or secret copy.
216
+ *
217
+ * @internal
218
+ */
219
+ export declare const snapshotExpectedIdentityHelloTrialReservationProjectionV1: (trial: ExpectedIdentityHelloTrialV1, activeCandidate: ActivePairOperationCandidateV1) => ExpectedIdentityHelloTrialReservationProjectionV1;
220
+ /**
221
+ * Recheck all opaque dependencies without materializing structural data.
222
+ *
223
+ * @internal
224
+ */
225
+ export declare const assertExpectedIdentityHelloTrialReservationLivenessV1: (trial: ExpectedIdentityHelloTrialV1, activeCandidate: ActivePairOperationCandidateV1) => void;
226
+ /**
227
+ * Bind reservation to the exact opaque active-candidate object.
228
+ *
229
+ * Custody is deliberately not a reservation input: its identity is sealed
230
+ * inside the trial, so the reservation caller cannot substitute one.
231
+ *
232
+ * @internal
233
+ */
234
+ export declare const assertExpectedIdentityHelloTrialCandidateBindingV1: (trial: ExpectedIdentityHelloTrialV1, activeCandidate: ActivePairOperationCandidateV1) => void;
235
+ /**
236
+ * Bind the future opener to the exact opaque candidate and custody objects.
237
+ *
238
+ * Matching structural bytes are insufficient.
239
+ *
240
+ * @internal
241
+ */
242
+ export declare const assertExpectedIdentityHelloTrialBindingsV1: (trial: ExpectedIdentityHelloTrialV1, activeCandidate: ActivePairOperationCandidateV1, receiverCustody: LocalHelloReceiverCustodyV1) => void;
243
+ /**
244
+ * Consume one genuine committed reservation, then transfer trial secrets.
245
+ *
246
+ * The reservation capability is deleted before this function can copy either
247
+ * secret. Its privately bound candidate must be the exact candidate sealed
248
+ * inside the trial; no caller-supplied candidate participates in this check.
249
+ *
250
+ * This explicit import creates a narrow cycle with `pairOpenReservation.ts`.
251
+ * Neither module performs top-level work, so the cycle contains bindings only.
252
+ *
253
+ * @internal
254
+ */
255
+ export declare const consumeReservedExpectedIdentityHelloTrialForPairOpenV1: (capability: ReservedIdentityHelloOpenV1, trial: ExpectedIdentityHelloTrialV1) => ConsumedExpectedIdentityHelloTrialV1;
256
+ /** Invalidate one unused trial. Idempotent for a genuine handle. */
257
+ export declare const destroyExpectedIdentityHelloTrialV1: (trial: ExpectedIdentityHelloTrialV1) => void;
258
+ /**
259
+ * Invalidate one reusable historical evidence view.
260
+ *
261
+ * Destruction is idempotent for a genuine handle. Any dependent unconsumed
262
+ * trial subsequently fails closed at reservation or consumption.
263
+ */
264
+ export declare const destroyHistoricalIdentityHelloEvidenceViewV1: (view: HistoricalIdentityHelloEvidenceViewV1) => void;
265
+ /**
266
+ * Wipe reusable receiver custody after its key record is retired.
267
+ *
268
+ * Destruction is idempotent for a genuine handle.
269
+ */
270
+ export declare const destroyLocalHelloReceiverCustodyV1: (custody: LocalHelloReceiverCustodyV1) => void;
271
+ export {};
@@ -0,0 +1,101 @@
1
+ /**
2
+ * Pure local-admissible projection semantics.
3
+ *
4
+ * This module computes the diagnostic `LocalAdmissibleStateV1` from complete,
5
+ * deeply owned inputs. It deliberately does not mint topology, reservation,
6
+ * admission, persistence, or publication authority. The effectful HELLO path
7
+ * must later wrap this kernel behind an opaque handle tied by object identity
8
+ * to one genuine `TrustedAdmissionSnapshotV1` and its exact planner/CAS row.
9
+ *
10
+ * Authority-mode projection remains unavailable until the protected
11
+ * non-omission custody constructor is implemented. There is no fallback to
12
+ * address-book or open eligibility.
13
+ */
14
+ import type { LibCrypto } from "../cryptography/libcrypto";
15
+ import type { FrontendRoomControlsV1 } from "./admissionPolicy";
16
+ import type { CoreRoomStateV1 } from "./coreReduce";
17
+ import type { PlannerAndExplicitStateV1 } from "./plannerState";
18
+ import type { RoomPolicyV4 } from "./roomPolicyV4";
19
+ export type LocalPresenceEligibilityV1 = "open" | "local-address-book-proved" | "authority-permit-proved";
20
+ export interface LocalAdmissiblePeerV1 {
21
+ readonly localPeerId: string;
22
+ readonly presenceOperationId: Uint8Array;
23
+ readonly stableIdentityCommitment: Uint8Array;
24
+ readonly rank: Uint8Array;
25
+ readonly eligibility: LocalPresenceEligibilityV1;
26
+ readonly desiredEdge: boolean;
27
+ }
28
+ export interface LocalAdmissibleStateV1 {
29
+ readonly version: 1;
30
+ readonly referenceWindow: bigint;
31
+ readonly coreOperationsDigest: Uint8Array;
32
+ readonly localPresenceOperationId: Uint8Array | null;
33
+ readonly localPresenceRank: Uint8Array | null;
34
+ readonly peers: readonly LocalAdmissiblePeerV1[];
35
+ readonly requestedExplicitPeerIds: readonly string[];
36
+ }
37
+ export type LocalAdmissibleProjectStatusV1 = "ready" | "policy-unavailable" | "projection-resource-overcapacity" | "no-unambiguous-local-presence";
38
+ export type LocalAdmissiblePlannerStatusV1 = "ready" | "unavailable" | "full-mesh-overcapacity";
39
+ /**
40
+ * Structural inputs for the pure semantic kernel.
41
+ *
42
+ * `maxPairLedgerEntriesPerRoom` is needed only to validate the captured
43
+ * planner row. A future trusted wrapper pins it from the room resource policy;
44
+ * accepting this structural object does not establish that provenance.
45
+ */
46
+ export interface LocalAdmissibleProjectSemanticInputV1 {
47
+ readonly version: 1;
48
+ readonly roomContextId: Uint8Array;
49
+ readonly roomPolicy: RoomPolicyV4;
50
+ readonly referenceWindow: bigint;
51
+ readonly coreRoomState: CoreRoomStateV1;
52
+ readonly frontendControls: FrontendRoomControlsV1 | null;
53
+ /**
54
+ * Structural premise only. The trusted wrapper must replace this with a
55
+ * process-local brand that binds every exact owned Core fact and OperationId
56
+ * to one of these stable keys, a verified stable-ownership signature, and
57
+ * current local author, identity, and receiver-key custody.
58
+ */
59
+ readonly localPresenceOwnership: {
60
+ readonly version: 1;
61
+ readonly localPresenceOperationIds: readonly Uint8Array[];
62
+ readonly localStableIdentityKeys: readonly Uint8Array[];
63
+ };
64
+ readonly plannerAndExplicitState: PlannerAndExplicitStateV1;
65
+ readonly maxRetainedValidOperationsPerRoom: number;
66
+ readonly maxPairLedgerEntriesPerRoom: number;
67
+ }
68
+ export interface LocalAdmissibleProjectSemanticResultV1 {
69
+ readonly version: 1;
70
+ readonly projectionStatus: LocalAdmissibleProjectStatusV1;
71
+ readonly plannerStatus: LocalAdmissiblePlannerStatusV1;
72
+ readonly observedRosterHash: Uint8Array;
73
+ readonly state: LocalAdmissibleStateV1;
74
+ /**
75
+ * SSOT for the two distinct attempt origins. `state.peers[].desiredEdge` is
76
+ * only their UI-friendly OR and must never be used to enforce attemptMode.
77
+ */
78
+ readonly topologySelections: readonly LocalTopologySelectionFactV1[];
79
+ }
80
+ export interface LocalTopologySelectionFactV1 {
81
+ readonly presenceOperationId: Uint8Array;
82
+ readonly plannerSelected: boolean;
83
+ /**
84
+ * Local outbound intent only. An incoming signed `attemptMode="explicit"`
85
+ * does not require this bit; it requires the separately captured receiver
86
+ * `allowOnDemandEdges` gate.
87
+ */
88
+ readonly locallyRequestedExplicit: boolean;
89
+ }
90
+ export declare class LocalAdmissibleProjectError extends Error {
91
+ readonly name = "LocalAdmissibleProjectError";
92
+ constructor(message: string);
93
+ }
94
+ /**
95
+ * Evaluate the local Project rules over one owned structural snapshot.
96
+ *
97
+ * The return value is a diagnostic fact only. It is intentionally cloneable
98
+ * and therefore MUST NOT be accepted by a topology or admission transition as
99
+ * proof that a peer was selected.
100
+ */
101
+ export declare const evaluateLocalAdmissibleProjectionSemanticsV1: (inputValue: unknown, module?: LibCrypto) => Promise<LocalAdmissibleProjectSemanticResultV1>;
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Process-local custody for a room/window author epoch and a verified binding
3
+ * from one exact local PRESENCE to its live local key records.
4
+ *
5
+ * `VerifiedLocalPresenceKeyBindingV1` is intentionally only a per-presence key
6
+ * binding. It proves neither a complete/non-omitted local-presence set nor a
7
+ * current Core view, and it grants no topology, admission, lease, persistence,
8
+ * publication, or signaling authority. This internal module is absent from the
9
+ * package barrel.
10
+ */
11
+ import type { LibCrypto } from "../cryptography/libcrypto";
12
+ import type { VerifiedHistoricalPairPresenceEvidenceV1 } from "./coreReduce";
13
+ import type { LocalHelloReceiverCustodyV1 } from "./identityHelloTrial";
14
+ import type { OperationValidationContext } from "./operation";
15
+ import type { RoomPolicyV4 } from "./roomPolicyV4";
16
+ declare const localAuthorEpochCustodyBrand: unique symbol;
17
+ declare const verifiedLocalPresenceKeyBindingBrand: unique symbol;
18
+ /**
19
+ * Opaque live custody for one exact room/window author epoch key record.
20
+ *
21
+ * This capability is runtime-distinct from stable-identity custody. Possessing
22
+ * either handle can never be substituted for the other, even by a type cast.
23
+ */
24
+ export interface LocalAuthorEpochCustodyV1 {
25
+ readonly [localAuthorEpochCustodyBrand]: true;
26
+ }
27
+ export interface CreateLocalAuthorEpochCustodyOptionsV1 {
28
+ readonly module: LibCrypto;
29
+ readonly authorEpochEd25519SecretKey: Uint8Array;
30
+ /** Non-reused revision of the persisted author-epoch key record. */
31
+ readonly authorEpochKeyRecordRevision: bigint;
32
+ readonly roomContextId: Uint8Array;
33
+ readonly logicalWindow: bigint;
34
+ }
35
+ export interface LocalAuthorEpochCustodySnapshotV1 {
36
+ readonly version: 1;
37
+ readonly authorEpochEd25519PublicKey: Uint8Array;
38
+ readonly authorEpochKeyRecordRevision: bigint;
39
+ readonly roomContextId: Uint8Array;
40
+ readonly logicalWindow: bigint;
41
+ }
42
+ /**
43
+ * Opaque proof that one genuine retained local PRESENCE matches live local
44
+ * stable-identity, receiver-key, and author-epoch custody.
45
+ *
46
+ * The handle is not a roster/set ownership proof. In particular, it says
47
+ * nothing about omitted presences, a current Core snapshot, or authorization.
48
+ */
49
+ export interface VerifiedLocalPresenceKeyBindingV1 {
50
+ readonly [verifiedLocalPresenceKeyBindingBrand]: true;
51
+ }
52
+ export interface CreateVerifiedLocalPresenceKeyBindingOptionsV1 {
53
+ readonly localPresenceEvidence: VerifiedHistoricalPairPresenceEvidenceV1;
54
+ readonly receiverCustody: LocalHelloReceiverCustodyV1;
55
+ readonly authorEpochCustody: LocalAuthorEpochCustodyV1;
56
+ readonly initializedRoom: OperationValidationContext;
57
+ }
58
+ export interface VerifiedLocalPresenceKeyBindingSnapshotV1 {
59
+ readonly version: 1;
60
+ readonly localPresenceOperationId: Uint8Array;
61
+ readonly exactPresenceOperationBytes: Uint8Array;
62
+ readonly roomContextId: Uint8Array;
63
+ readonly roomPolicy: RoomPolicyV4;
64
+ readonly presenceLogicalWindow: bigint;
65
+ readonly provedAtLogicalWindow: bigint;
66
+ readonly authorEpochEd25519PublicKey: Uint8Array;
67
+ readonly authorEpochKeyRecordRevision: bigint;
68
+ readonly advertisedReceiverHybridKemPublicKey: Uint8Array;
69
+ readonly receiverKeyValidThroughLogicalWindow: bigint;
70
+ readonly receiverKeyRecordRevision: bigint;
71
+ readonly localStableEd25519PublicKey: Uint8Array;
72
+ readonly localIdentityKeyRecordRevision: bigint;
73
+ }
74
+ export declare class LocalPresenceKeyBindingError extends Error {
75
+ readonly name = "LocalPresenceKeyBindingError";
76
+ constructor(message: string);
77
+ }
78
+ /**
79
+ * Capture and validate one room/window author secret before minting custody.
80
+ */
81
+ export declare const createLocalAuthorEpochCustodyV1: (options: CreateLocalAuthorEpochCustodyOptionsV1) => Promise<LocalAuthorEpochCustodyV1>;
82
+ /** Return a fresh non-secret projection and assert that custody is live. */
83
+ export declare const snapshotLocalAuthorEpochCustodyV1: (custody: LocalAuthorEpochCustodyV1) => LocalAuthorEpochCustodySnapshotV1;
84
+ /**
85
+ * Wipe author-epoch custody after the corresponding local key record retires.
86
+ *
87
+ * Destruction is idempotent for a genuine handle. It neither owns nor retires
88
+ * the historical receiver or stable-identity custody used by a binding.
89
+ */
90
+ export declare const destroyLocalAuthorEpochCustodyV1: (custody: LocalAuthorEpochCustodyV1) => void;
91
+ /**
92
+ * Verify one exact local PRESENCE/key relation and mint an empty opaque handle.
93
+ *
94
+ * Every caller-controlled byte is captured through genuine handles before the
95
+ * ownership-signature await. The exact handles are then re-read, so retiring a
96
+ * nested author, receiver, or stable key during verification fails closed.
97
+ */
98
+ export declare const createVerifiedLocalPresenceKeyBindingV1: (options: CreateVerifiedLocalPresenceKeyBindingOptionsV1) => Promise<VerifiedLocalPresenceKeyBindingV1>;
99
+ /** Return fresh non-secret facts while every retained handle remains live. */
100
+ export declare const snapshotVerifiedLocalPresenceKeyBindingV1: (binding: VerifiedLocalPresenceKeyBindingV1) => VerifiedLocalPresenceKeyBindingSnapshotV1;
101
+ /**
102
+ * Invalidate one binding without dereferencing its nested custody handles.
103
+ *
104
+ * This remains safe and idempotent after author, receiver, or stable custody
105
+ * has already been retired and wiped.
106
+ */
107
+ export declare const destroyVerifiedLocalPresenceKeyBindingV1: (binding: VerifiedLocalPresenceKeyBindingV1) => void;
108
+ export {};