@cello-protocol/client 0.0.21 → 0.0.22

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 (53) hide show
  1. package/dist/client-send-helpers.d.ts +25 -0
  2. package/dist/client-send-helpers.d.ts.map +1 -0
  3. package/dist/client-send-helpers.js +118 -0
  4. package/dist/client-send-helpers.js.map +1 -0
  5. package/dist/client-startup.d.ts +74 -0
  6. package/dist/client-startup.d.ts.map +1 -0
  7. package/dist/client-startup.js +337 -0
  8. package/dist/client-startup.js.map +1 -0
  9. package/dist/client-wiring.d.ts +120 -0
  10. package/dist/client-wiring.d.ts.map +1 -0
  11. package/dist/client-wiring.js +289 -0
  12. package/dist/client-wiring.js.map +1 -0
  13. package/dist/client.d.ts +29 -169
  14. package/dist/client.d.ts.map +1 -1
  15. package/dist/client.js +222 -5396
  16. package/dist/client.js.map +1 -1
  17. package/dist/connection-inbound-handler.d.ts +47 -0
  18. package/dist/connection-inbound-handler.d.ts.map +1 -0
  19. package/dist/connection-inbound-handler.js +325 -0
  20. package/dist/connection-inbound-handler.js.map +1 -0
  21. package/dist/connection-manager.d.ts +191 -0
  22. package/dist/connection-manager.d.ts.map +1 -0
  23. package/dist/connection-manager.js +692 -0
  24. package/dist/connection-manager.js.map +1 -0
  25. package/dist/frame-dispatch.d.ts +28 -0
  26. package/dist/frame-dispatch.d.ts.map +1 -0
  27. package/dist/frame-dispatch.js +118 -0
  28. package/dist/frame-dispatch.js.map +1 -0
  29. package/dist/registration-manager.d.ts +54 -0
  30. package/dist/registration-manager.d.ts.map +1 -0
  31. package/dist/registration-manager.js +248 -0
  32. package/dist/registration-manager.js.map +1 -0
  33. package/dist/relay-stream-manager.d.ts +136 -0
  34. package/dist/relay-stream-manager.d.ts.map +1 -0
  35. package/dist/relay-stream-manager.js +834 -0
  36. package/dist/relay-stream-manager.js.map +1 -0
  37. package/dist/seal-manager.d.ts +133 -0
  38. package/dist/seal-manager.d.ts.map +1 -0
  39. package/dist/seal-manager.js +803 -0
  40. package/dist/seal-manager.js.map +1 -0
  41. package/dist/session-assignment-parser.d.ts +33 -0
  42. package/dist/session-assignment-parser.d.ts.map +1 -0
  43. package/dist/session-assignment-parser.js +149 -0
  44. package/dist/session-assignment-parser.js.map +1 -0
  45. package/dist/session-manager.d.ts +132 -0
  46. package/dist/session-manager.d.ts.map +1 -0
  47. package/dist/session-manager.js +605 -0
  48. package/dist/session-manager.js.map +1 -0
  49. package/dist/signaling-manager.d.ts +85 -0
  50. package/dist/signaling-manager.d.ts.map +1 -0
  51. package/dist/signaling-manager.js +597 -0
  52. package/dist/signaling-manager.js.map +1 -0
  53. package/package.json +3 -3
@@ -0,0 +1,325 @@
1
+ /**
2
+ * connection-inbound-handler.ts — B-side inbound connection request handlers.
3
+ *
4
+ * Extracted from ConnectionManager to keep it under 900 lines.
5
+ * Handles connection_request_inbound and disclosure_response_inbound frames,
6
+ * which include package decode, policy evaluation, and response dispatch.
7
+ */
8
+ import { Encoder } from "cbor-x";
9
+ import * as lp from "it-length-prefixed";
10
+ import { decodeConnectionPackage, validateConnectionPackage, } from "@cello-protocol/protocol-types";
11
+ import { mlDsaVerify } from "@cello-protocol/crypto";
12
+ const CBOR_ENC = new Encoder({ tagUint8Array: false });
13
+ /**
14
+ * Handle a connection_request_inbound frame (B-side, Round 1).
15
+ * Decodes and validates the package, evaluates against the policy,
16
+ * and sends a connection_response to the directory.
17
+ */
18
+ export async function handleInboundConnectionRequest(deps, frame) {
19
+ const stream = deps.ctx.getPersistentSignalingStream();
20
+ if (!stream)
21
+ return;
22
+ const connectionRequestId = frame["connection_request_id"];
23
+ const fromPubkey = frame["from_pubkey"];
24
+ const packageCborRaw = frame["package_cbor"];
25
+ const packageCbor = packageCborRaw instanceof Uint8Array ? packageCborRaw
26
+ : Buffer.isBuffer(packageCborRaw) ? new Uint8Array(packageCborRaw) : null;
27
+ if (!connectionRequestId || !fromPubkey || !packageCbor)
28
+ return;
29
+ const senderRegisteredAt = typeof frame["sender_registered_at"] === "number"
30
+ ? frame["sender_registered_at"] : 0;
31
+ const senderIsProvisional = frame["sender_is_provisional"] === true;
32
+ let verdict = "reject";
33
+ let rejectReason;
34
+ let unmetRequirements;
35
+ const isWhitelisted = deps.ctx.whitelist.includes(fromPubkey);
36
+ if (isWhitelisted) {
37
+ verdict = "accept";
38
+ }
39
+ else if (!deps.connectionPolicy) {
40
+ verdict = "accept";
41
+ }
42
+ else {
43
+ let pkg;
44
+ try {
45
+ pkg = decodeConnectionPackage(packageCbor);
46
+ }
47
+ catch {
48
+ verdict = "reject";
49
+ rejectReason = "package_decode_failed";
50
+ pkg = null;
51
+ }
52
+ if (pkg !== null) {
53
+ const fromPubkeyBytes = Buffer.from(fromPubkey, "hex");
54
+ const validatedPackage = validateConnectionPackage(pkg, fromPubkeyBytes, Date.now(), mlDsaVerify);
55
+ if (!validatedPackage.valid) {
56
+ verdict = "reject";
57
+ rejectReason = validatedPackage.reason;
58
+ }
59
+ else {
60
+ const context = {
61
+ registered_at: senderRegisteredAt,
62
+ is_provisional: senderIsProvisional,
63
+ conversation_count: 0,
64
+ clean_close_rate: 0,
65
+ };
66
+ if (deps.ctx.trackEvaluateCount) {
67
+ deps.ctx.incrementEvaluateCallCount();
68
+ }
69
+ const { evaluateConnectionPackage } = await import("./connection-policy.js");
70
+ const report = evaluateConnectionPackage(validatedPackage, deps.connectionPolicy, context, Date.now());
71
+ if (report.verdict === "auto_accept") {
72
+ verdict = "accept";
73
+ }
74
+ else if (report.verdict === "auto_reject") {
75
+ verdict = "reject";
76
+ rejectReason = report.reason;
77
+ }
78
+ else if (report.verdict === "auto_insufficient") {
79
+ if (deps.ctx.round2TimeoutMs > 0) {
80
+ deps.pendingInboundRequests.set(connectionRequestId, {
81
+ connection_request_id: connectionRequestId,
82
+ from_pubkey: fromPubkey,
83
+ package_cbor: packageCbor,
84
+ round: 1,
85
+ });
86
+ const disclosureFrame = CBOR_ENC.encode({
87
+ type: "disclosure_request",
88
+ connection_request_id: connectionRequestId,
89
+ requested_items: report.unmet_requirements.map((u) => ({
90
+ type: u.signal_type,
91
+ condition: u.condition,
92
+ })),
93
+ });
94
+ try {
95
+ stream.send(lp.encode.single(disclosureFrame));
96
+ }
97
+ catch { /* stream closed */ }
98
+ setTimeout(() => {
99
+ const stillPending = deps.pendingInboundRequests.get(connectionRequestId);
100
+ if (stillPending) {
101
+ deps.pendingInboundRequests.delete(connectionRequestId);
102
+ const currentStream = deps.ctx.getPersistentSignalingStream();
103
+ if (currentStream) {
104
+ const timeoutFrame = CBOR_ENC.encode({
105
+ type: "connection_response",
106
+ connection_request_id: connectionRequestId,
107
+ verdict: "reject",
108
+ reason: "disclosure_timeout",
109
+ });
110
+ try {
111
+ currentStream.send(lp.encode.single(timeoutFrame));
112
+ }
113
+ catch { /* stream closed */ }
114
+ }
115
+ }
116
+ }, deps.ctx.round2TimeoutMs);
117
+ return;
118
+ }
119
+ verdict = "insufficient";
120
+ unmetRequirements = report.unmet_requirements;
121
+ }
122
+ else {
123
+ // pending_agent_review: store for agent review and fire callback
124
+ deps.pendingInboundRequests.set(connectionRequestId, {
125
+ connection_request_id: connectionRequestId,
126
+ from_pubkey: fromPubkey,
127
+ package_cbor: packageCbor,
128
+ round: 1,
129
+ });
130
+ const reviewItem = {
131
+ connection_request_id: connectionRequestId,
132
+ from_pubkey: fromPubkey,
133
+ report,
134
+ package_cbor: packageCbor,
135
+ sender_registered_at: senderRegisteredAt,
136
+ sender_is_provisional: senderIsProvisional,
137
+ };
138
+ const awaitResolver = deps.pendingAwaitConnectionRequestResolvers.shift();
139
+ if (awaitResolver) {
140
+ awaitResolver({ connection_request_id: connectionRequestId, from_pubkey: fromPubkey, report });
141
+ }
142
+ else {
143
+ deps.pendingReviewQueue.push(reviewItem);
144
+ }
145
+ if (deps.ctx.persistence) {
146
+ void deps.ctx.persistence.persistPendingConnectionRequest({
147
+ requestId: connectionRequestId,
148
+ fromPubkey,
149
+ packageCbor,
150
+ round: 1,
151
+ });
152
+ }
153
+ if (deps.onConnectionPendingReview) {
154
+ deps.onConnectionPendingReview({
155
+ type: "connection_request_inbound",
156
+ from_pubkey: fromPubkey,
157
+ connection_request_id: connectionRequestId,
158
+ package_cbor: packageCbor,
159
+ sender_registered_at: senderRegisteredAt,
160
+ sender_is_provisional: senderIsProvisional,
161
+ });
162
+ }
163
+ if (deps.ctx.round2TimeoutMs > 0) {
164
+ setTimeout(() => {
165
+ const stillPending = deps.pendingInboundRequests.get(connectionRequestId);
166
+ if (stillPending) {
167
+ deps.pendingInboundRequests.delete(connectionRequestId);
168
+ const currentStream = deps.ctx.getPersistentSignalingStream();
169
+ if (currentStream) {
170
+ const responseFrame = CBOR_ENC.encode({
171
+ type: "connection_response",
172
+ connection_request_id: connectionRequestId,
173
+ verdict: "reject",
174
+ reason: "disclosure_timeout",
175
+ });
176
+ try {
177
+ currentStream.send(lp.encode.single(responseFrame));
178
+ }
179
+ catch { /* stream closed */ }
180
+ }
181
+ }
182
+ }, deps.ctx.round2TimeoutMs);
183
+ }
184
+ return;
185
+ }
186
+ }
187
+ }
188
+ }
189
+ // DB-003: cross-check logic
190
+ if (verdict === "accept" && deps.ctx.crossCheckDirectoryOnInbound) {
191
+ deps.profileUncheckedPeers.add(fromPubkey);
192
+ }
193
+ const responsePayload = {
194
+ type: "connection_response",
195
+ connection_request_id: connectionRequestId,
196
+ verdict,
197
+ };
198
+ if (rejectReason !== undefined)
199
+ responsePayload["reason"] = rejectReason;
200
+ if (unmetRequirements !== undefined)
201
+ responsePayload["unmet_requirements"] = unmetRequirements;
202
+ const responseFrame = CBOR_ENC.encode(responsePayload);
203
+ try {
204
+ stream.send(lp.encode.single(responseFrame));
205
+ }
206
+ catch { /* stream closed */ }
207
+ }
208
+ /**
209
+ * Handle a disclosure_response_inbound frame (B-side, Round 2).
210
+ * Re-evaluates the updated package and sends final connection_response.
211
+ */
212
+ export async function handleDisclosureResponse(deps, frame) {
213
+ const stream = deps.ctx.getPersistentSignalingStream();
214
+ if (!stream)
215
+ return;
216
+ const connectionRequestId = frame["connection_request_id"];
217
+ const packageCborRaw = frame["package_cbor"];
218
+ const packageCbor = packageCborRaw instanceof Uint8Array ? packageCborRaw
219
+ : Buffer.isBuffer(packageCborRaw) ? new Uint8Array(packageCborRaw) : null;
220
+ if (!connectionRequestId || !packageCbor)
221
+ return;
222
+ const pending = deps.pendingInboundRequests.get(connectionRequestId);
223
+ if (!pending)
224
+ return;
225
+ deps.pendingInboundRequests.delete(connectionRequestId);
226
+ const fromPubkey = pending.from_pubkey;
227
+ let verdict = "reject";
228
+ let rejectReason;
229
+ let unmetRequirements;
230
+ if (!deps.connectionPolicy) {
231
+ verdict = "accept";
232
+ }
233
+ else {
234
+ let pkg;
235
+ try {
236
+ pkg = decodeConnectionPackage(packageCbor);
237
+ }
238
+ catch {
239
+ verdict = "reject";
240
+ rejectReason = "package_decode_failed";
241
+ pkg = null;
242
+ }
243
+ if (pkg !== null) {
244
+ const fromPubkeyBytes = Buffer.from(fromPubkey, "hex");
245
+ const validatedPackage = validateConnectionPackage(pkg, fromPubkeyBytes, Date.now(), mlDsaVerify);
246
+ if (!validatedPackage.valid) {
247
+ verdict = "reject";
248
+ rejectReason = validatedPackage.reason;
249
+ }
250
+ else {
251
+ const context = {
252
+ registered_at: 0,
253
+ is_provisional: false,
254
+ conversation_count: 0,
255
+ clean_close_rate: 0,
256
+ };
257
+ if (deps.ctx.trackEvaluateCount) {
258
+ deps.ctx.incrementEvaluateCallCount();
259
+ }
260
+ const { evaluateConnectionPackage } = await import("./connection-policy.js");
261
+ const report = evaluateConnectionPackage(validatedPackage, deps.connectionPolicy, context, Date.now());
262
+ if (report.verdict === "auto_accept") {
263
+ verdict = "accept";
264
+ }
265
+ else if (report.verdict === "auto_reject") {
266
+ verdict = "reject";
267
+ rejectReason = report.reason;
268
+ }
269
+ else if (report.verdict === "auto_insufficient") {
270
+ verdict = "insufficient";
271
+ unmetRequirements = report.unmet_requirements;
272
+ }
273
+ else {
274
+ // pending_agent_review in Round 2
275
+ const round2Report = { ...report, is_round_2: true };
276
+ deps.pendingInboundRequests.set(connectionRequestId, {
277
+ connection_request_id: connectionRequestId,
278
+ from_pubkey: fromPubkey,
279
+ package_cbor: packageCbor,
280
+ round: 2,
281
+ });
282
+ if (deps.ctx.persistence) {
283
+ void deps.ctx.persistence.persistPendingConnectionRequest({
284
+ requestId: connectionRequestId,
285
+ fromPubkey,
286
+ packageCbor,
287
+ round: 2,
288
+ });
289
+ }
290
+ const round2ReviewItem = {
291
+ connection_request_id: connectionRequestId,
292
+ from_pubkey: fromPubkey,
293
+ report: round2Report,
294
+ package_cbor: packageCbor,
295
+ sender_registered_at: 0,
296
+ sender_is_provisional: false,
297
+ };
298
+ const awaitResolver = deps.pendingAwaitConnectionRequestResolvers.shift();
299
+ if (awaitResolver) {
300
+ awaitResolver({ connection_request_id: connectionRequestId, from_pubkey: fromPubkey, report: round2Report });
301
+ }
302
+ else {
303
+ deps.pendingReviewQueue.push(round2ReviewItem);
304
+ }
305
+ return;
306
+ }
307
+ }
308
+ }
309
+ }
310
+ const responsePayload = {
311
+ type: "connection_response",
312
+ connection_request_id: connectionRequestId,
313
+ verdict,
314
+ };
315
+ if (rejectReason !== undefined)
316
+ responsePayload["reason"] = rejectReason;
317
+ if (unmetRequirements !== undefined)
318
+ responsePayload["unmet_requirements"] = unmetRequirements;
319
+ const responseFrame = CBOR_ENC.encode(responsePayload);
320
+ try {
321
+ stream.send(lp.encode.single(responseFrame));
322
+ }
323
+ catch { /* stream closed */ }
324
+ }
325
+ //# sourceMappingURL=connection-inbound-handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection-inbound-handler.js","sourceRoot":"","sources":["../src/connection-inbound-handler.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACjC,OAAO,KAAK,EAAE,MAAM,oBAAoB,CAAC;AACzC,OAAO,EACL,uBAAuB,EAAE,yBAAyB,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CAAC,eAAe,CAAe,CAAC;IACrE,IAAI,CAAC;QACH,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC;IAC/C,CAAC;IAAC,MAAM,CAAC,CAAC,mBAAmB,CAAC,CAAC;AACjC,CAAC"}
@@ -0,0 +1,191 @@
1
+ /**
2
+ * ConnectionManager — CONNREQ-002, CONNREQ-003
3
+ *
4
+ * Extracted from CelloClientImpl. Owns all connection domain state:
5
+ * connections, connectionsByPeer, profileUncheckedPeers, connectionPolicy,
6
+ * pending resolvers, review queue, etc.
7
+ */
8
+ import type { Stream } from "@libp2p/interface";
9
+ import type { Logger } from "@cello-protocol/interfaces";
10
+ import type { ClientStatePersistence } from "./client-state-persistence.js";
11
+ type ConnectionReport = import("./connection-policy.js").ConnectionReport;
12
+ type SignalRequirementPolicy = import("./connection-policy.js").SignalRequirementPolicy;
13
+ type ClientConnectionRecord = import("@cello-protocol/protocol-types").ClientConnectionRecord;
14
+ type ConnectionRequestInbound = import("@cello-protocol/protocol-types").ConnectionRequestInbound;
15
+ type ConnectionEstablished = import("@cello-protocol/protocol-types").ConnectionEstablished;
16
+ type DisclosureRequestInbound = import("@cello-protocol/protocol-types").DisclosureRequestInbound;
17
+ export type ReviewQueueItem = {
18
+ connection_request_id: string;
19
+ from_pubkey: string;
20
+ report: Extract<ConnectionReport, {
21
+ verdict: "pending_agent_review";
22
+ }>;
23
+ package_cbor: Uint8Array;
24
+ sender_registered_at: number;
25
+ sender_is_provisional: boolean;
26
+ };
27
+ /**
28
+ * Narrow interface exposing only what ConnectionManager needs from CelloClientImpl.
29
+ */
30
+ export interface ConnectionContext {
31
+ readonly logger: Logger;
32
+ readonly persistence: ClientStatePersistence | null;
33
+ readonly connectionTimeoutMs: number;
34
+ readonly round2TimeoutMs: number;
35
+ readonly trackEvaluateCount: boolean;
36
+ readonly whitelist: string[];
37
+ readonly crossCheckDirectoryOnInbound: boolean;
38
+ getPersistentSignalingStream(): Stream | null;
39
+ openPersistentSignalingStream(): Promise<boolean>;
40
+ incrementEvaluateCallCount(): void;
41
+ }
42
+ export declare class ConnectionManager {
43
+ #private;
44
+ constructor(ctx: ConnectionContext, opts?: {
45
+ connectionPolicy?: SignalRequirementPolicy;
46
+ onConnectionPendingReview?: (event: ConnectionRequestInbound) => void;
47
+ });
48
+ get pendingConnectionRequestResolverCount(): number;
49
+ listConnections(): ClientConnectionRecord[];
50
+ hasConnection(counterpartyPubkeyHex: string): string | null;
51
+ getConnectionIdForPeer(pubkeyHex: string): string | undefined;
52
+ hasConnectionPolicy(): boolean;
53
+ setPolicy(policy: SignalRequirementPolicy): void;
54
+ getPolicy(): SignalRequirementPolicy;
55
+ onConnectionEstablished(handler: (event: ConnectionEstablished) => void): void;
56
+ onDisclosureRequested(handler: (event: DisclosureRequestInbound) => void): void;
57
+ setOnConnectionPendingReview(handler: (event: ConnectionRequestInbound) => void): void;
58
+ /** Called during loadPersistedState to restore connection records. */
59
+ addConnection(id: string, record: ClientConnectionRecord): void;
60
+ addConnectionByPeer(pubkey: string, id: string): void;
61
+ addProfileUncheckedPeer(pubkey: string): void;
62
+ acceptConnection(connectionRequestId: string): Promise<{
63
+ accepted: true;
64
+ connection_id: string;
65
+ } | {
66
+ error: {
67
+ reason: "no_pending_request" | "already_decided";
68
+ };
69
+ }>;
70
+ rejectConnection(connectionRequestId: string, reason?: string): Promise<{
71
+ rejected: true;
72
+ } | {
73
+ error: {
74
+ reason: "no_pending_request" | "already_decided";
75
+ };
76
+ }>;
77
+ requestMoreDisclosure(connectionRequestId: string, requestedItems: unknown[]): Promise<{
78
+ request_sent: true;
79
+ } | {
80
+ error: {
81
+ reason: "no_pending_request" | "already_decided" | "max_rounds_reached";
82
+ };
83
+ }>;
84
+ awaitConnectionRequest(timeoutMs?: number): Promise<{
85
+ type: "pending_review";
86
+ connection_request_id: string;
87
+ from_pubkey: string;
88
+ report: Extract<ConnectionReport, {
89
+ verdict: "pending_agent_review";
90
+ }>;
91
+ } | {
92
+ type: "timeout";
93
+ }>;
94
+ cello_request_connection(opts: {
95
+ target_pubkey: string;
96
+ package_cbor: Uint8Array;
97
+ dialTimeoutMs?: number;
98
+ sendTimeoutMs?: number;
99
+ waitTimeoutMs?: number;
100
+ }): Promise<{
101
+ result: "established";
102
+ connection_id: string;
103
+ } | {
104
+ result: "rejected";
105
+ reason: string;
106
+ } | {
107
+ result: "insufficient";
108
+ unmet_requirements: unknown[];
109
+ } | {
110
+ result: "disclosure_requested";
111
+ connection_request_id: string;
112
+ requested_items: unknown[];
113
+ } | {
114
+ result: "timeout";
115
+ stage: "dial" | "send" | "wait";
116
+ } | {
117
+ result: "error";
118
+ reason: string;
119
+ }>;
120
+ cello_respond_to_disclosure_request(opts: {
121
+ connection_request_id: string;
122
+ package_cbor: Uint8Array;
123
+ }): Promise<{
124
+ result: "established";
125
+ connection_id: string;
126
+ } | {
127
+ result: "rejected";
128
+ reason: string;
129
+ } | {
130
+ result: "insufficient";
131
+ unmet_requirements: unknown[];
132
+ } | {
133
+ result: "timeout";
134
+ } | {
135
+ result: "error";
136
+ reason: string;
137
+ }>;
138
+ cello_request_more_disclosure(opts: {
139
+ connection_request_id: string;
140
+ requested_items: unknown[];
141
+ }): Promise<{
142
+ error: "max_rounds_reached";
143
+ } | {
144
+ ok: true;
145
+ }>;
146
+ /**
147
+ * Restore a decided request ID from persisted state.
148
+ * Called during loadPersistedState to restore the #decidedRequests set.
149
+ */
150
+ restoreDecidedRequest(requestId: string): void;
151
+ /**
152
+ * Restore a pending inbound request from persisted state.
153
+ * Called during loadPersistedState to restore the #pendingInboundRequests map.
154
+ */
155
+ restorePendingInboundRequest(opts: {
156
+ connection_request_id: string;
157
+ from_pubkey: string;
158
+ package_cbor: Uint8Array;
159
+ round: number;
160
+ }): void;
161
+ /**
162
+ * Restore a review queue item from persisted state.
163
+ * Called during loadPersistedState to restore the #pendingReviewQueue.
164
+ */
165
+ restoreReviewQueueItem(item: ReviewQueueItem): void;
166
+ _injectPendingConnectionRequest(opts: {
167
+ connection_request_id: string;
168
+ from_pubkey: string;
169
+ package_cbor: Uint8Array;
170
+ round: number;
171
+ }): void;
172
+ _injectConnectionFrame(frame: Record<string, unknown>): void;
173
+ /**
174
+ * Route connection outcome frames from the signaling reader.
175
+ * Called by CelloClientImpl#runPersistentSignalingReader when a connection-related frame arrives.
176
+ */
177
+ routeConnectionFrame(frame: Record<string, unknown>): void;
178
+ /**
179
+ * Unblock all pending connection request resolvers when the signaling stream closes.
180
+ * CONNREQ-003 AC-005.
181
+ */
182
+ unblockAllOnStreamClose(): void;
183
+ handleInboundConnectionRequest(frame: Record<string, unknown>): Promise<void>;
184
+ /**
185
+ * Handle a disclosure_response_inbound frame (B-side, Round 2).
186
+ * Re-evaluates the updated package and sends final connection_response.
187
+ */
188
+ handleDisclosureResponse(frame: Record<string, unknown>): Promise<void>;
189
+ }
190
+ export {};
191
+ //# sourceMappingURL=connection-manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection-manager.d.ts","sourceRoot":"","sources":["../src/connection-manager.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAQ5E,KAAK,gBAAgB,GAAG,OAAO,wBAAwB,EAAE,gBAAgB,CAAC;AAC1E,KAAK,uBAAuB,GAAG,OAAO,wBAAwB,EAAE,uBAAuB,CAAC;AACxF,KAAK,sBAAsB,GAAG,OAAO,gCAAgC,EAAE,sBAAsB,CAAC;AAC9F,KAAK,wBAAwB,GAAG,OAAO,gCAAgC,EAAE,wBAAwB,CAAC;AAClG,KAAK,qBAAqB,GAAG,OAAO,gCAAgC,EAAE,qBAAqB,CAAC;AAC5F,KAAK,wBAAwB,GAAG,OAAO,gCAAg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