/** * @module SyncPeer_V1 witness class for base class plumbing of sync peers. * * You are expected to implement concrete peer classes for concrete architecture. */ import { IbGib_V1 } from '@ibgib/ts-gib/dist/V1/types.mjs'; import { SubjectWitness } from '../../common/pubsub/subject/subject-types.mjs'; import { SyncSagaContextIbGib_V1 } from '../sync-saga-context/sync-saga-context-types.mjs'; import { ConnectSyncPeerOpts, InitializeSyncPeerOpts, SyncPeerData_V1, SyncPeerRel8ns_V1, SyncPeerWitness } from './sync-peer-types.mjs'; import { LightWitnessBase_V1 } from '../../witness/light-witness-base-v1.mjs'; import { KeystoneIbGib_V1 } from '../../keystone/keystone-types.mjs'; import { IbGibAddr } from '@ibgib/ts-gib/dist/types.mjs'; /** * Abstract witness for talking to a Sync Peer (e.g. Remote Node or Local Simulator). * * Takes a SyncSagaContext (Request) and returns a SyncSagaContext (Response). * * Implements the core "Sync Protocol Transport" logic. Once connected, does: * 1. Push Context & Dependencies (Sender -> Receiver) * 2. Send Request (RPC) * 3. Pull Response & Dependencies (Receiver -> Sender) */ export declare abstract class SyncPeer_V1 extends LightWitnessBase_V1 implements SyncPeerWitness { protected lc: string; opts: TInitializeOpts | undefined; payloadIbGibsDomainReceived$: SubjectWitness; currentSessionIdentity: KeystoneIbGib_V1 | undefined; currentSenderIdentity: KeystoneIbGib_V1 | undefined; get currentSessionIdentityAddr(): IbGibAddr | undefined; signContext({ contextAddr, }: { contextAddr: IbGibAddr; }): Promise; /** * Evolves the session identity (S_n -> S_n+1) solving the demanded connect challenges. */ signContextConnect({ challengeUuid, demandedIds, }: { challengeUuid: string; demandedIds: string[]; }): Promise; get classname(): string; constructor(initialData: SyncPeerData_V1, initialRel8ns?: SyncPeerRel8ns_V1); initialize(): Promise; /** * Establishes the connection context. * * This method provides boilerplate error handling and logging, * delegating the actual connection logic to `connectImpl`. */ connect(opts: TConnectOpts): Promise; /** * Concrete pre-connect check. Should throw if connect conditions are not * met. * * Use this to check what {@link opts} are, as well as any other state per * concrete sync peer. * * @see {@link connect} * @see {@link connectImpl} */ protected abstract preConnectCheck(opts: TConnectOpts): Promise; /** * Concrete implementation for establishing the connection context. * * This MUST be implemented by subclasses to handle transport-specific * negotiation (e.g., WebSocket upgrade) */ protected abstract connectImpl(opts: TConnectOpts): Promise; /** * Pre-connect phase: establishes session identity. * * Shared base implementation: * 1. Derives `sessionSecret = KDF(senderSecret, sagaId)`. * 2. Creates session keystone genesis S (connect + sync pools) in `controlSpace`. * 3. Evolves `senderIdentity` → `newSenderIdentity` (I1) with a `sync` * claim targeting S^Stjp, stored in `controlSpace`. * 4. Delegates posting of both keystones to the receiver via the abstract * hook {@link postEstablishToReceiver} (peer-specific transport). * * Returns `undefined` (no-op) if no `senderIdentity` was provided in opts. * * @returns The session keystone genesis (S^Stjp) so the coordinator can * hold a reference for subsequent per-turn signing. The name * `newSenderIdentity` (I1) is scoped only within this method. */ establishSessionIdentity(): Promise; /** * Peer-specific hook: transmits `newSenderIdentity` (I1) and * `sessionIdentity` (S) to the receiver's domain registry. * * - **Innerspace**: puts both into `receiverMetaspace` / `receiverSpace`. * - **WebSocket**: HTTP POST to the domain provider's keystone endpoint. */ protected abstract postEstablishToReceiver(opts: { newSenderIdentity: KeystoneIbGib_V1; sessionIdentity: KeystoneIbGib_V1; }): Promise; /** * base implementation just sets the opts property. * * override this in concrete classes for further initialization code * specific to the sender. * * @see {@link SyncPeerWitness.opts} */ initializeOpts(opts: TInitializeOpts): Promise; setOptionalOpts(arg: Partial): void; protected authenticateAndValidate({ context, }: { context: SyncSagaContextIbGib_V1; }): Promise; /** * Witness the synchronization context (Send/Receive). * * At this point in code, we are sending the context OUTGOING. The {@link context} should * have a fully populated {@link SyncSagaContextIbGib_V1.sagaFrame} * * @param arg The OUTGOING context (Request). * @returns The INCOMING context (Response), or undefined if failed/empty. */ witness(context: SyncSagaContextIbGib_V1): Promise; /** * At this point, this is a validated, authenticated and authorized context * to send. * * This is responsible for: * * * physical sending outgoing {@link context}, the sync saga frame and msg * stone(s)... * * AND sending OUTGOING domain ibgibs * {@link SyncSagaContextIbGib_V1.payloadIbGibsDomain} * * getting back the other end's resultant context ibgib, sync saga frame * and msg stone(s) in their entirety... * * AND stream/receiving the RESPONSE payload domain ibgibs, publishing * these to this.payloadIbGibsDomainReceived$. * * BUT this should return as soon as the resultant context ibgib comes * back. * * So this returns the RESPONSE context, possibly BEFORE the response DOMAIN * ibgibs have been completely received/streamed. The coordinator is * responsible for awaiting this stream. * * @returns next sync saga context if another round, or undefined if we're * done. (might throw if there's an error?) */ protected abstract sendContextRequest(context: SyncSagaContextIbGib_V1): Promise; /** * Abstract accessor to get an IbGib from the Local space/store. * Needed for inspecting rela8ns during the graph walk. * * Default implementation simply looks in controlSpace */ protected getLocalIbGib(addr: string): Promise; } //# sourceMappingURL=sync-peer-v1.d.mts.map