/** * @module sync-websocket-peer-helpers * * Reusable, isomorphic pure validation helper functions and policies for the * WebSocket Sync Peer connect process. */ import { HashAlgorithm } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs'; import { IbGib_V1 } from '@ibgib/ts-gib/dist/V1/types.mjs'; import { KeystoneIbGib_V1, KeystoneChallenge } from '../../../../keystone/keystone-types.mjs'; import { IbGibSpaceAny } from '../../../../witness/space/space-base-v1.mjs'; import { MetaspaceService } from '../../../../witness/space/metaspace/metaspace-types.mjs'; /** * Standard configuration defaults for the Ephemeral Session Keystone. */ export declare const SESSION_KEYSTONE_POLICY: { readonly COMMON: { readonly ALGO: HashAlgorithm; readonly TYPE: "hash-reveal-v1"; readonly ROUNDS: 2; readonly REPLENISH: "top-up"; }; readonly CONNECT_POOL: { readonly ID: "connect"; readonly VERB: "connect"; readonly SIZE: 10; readonly SELECT_SEQUENTIALLY: 2; readonly SELECT_RANDOMLY: 2; readonly TARGET_BINDING_COUNT: 0; readonly SERVER_DEMAND_COUNT: 3; }; }; /** * Resolves the deterministic dynamic upfront pre-filter challenge. */ export declare function getConnectChallenge(keystone: KeystoneIbGib_V1): { challengeId: string; challenge: KeystoneChallenge; }; /** * Validates the upfront solution against the session keystone's first connect * challenge. */ export declare function checkConnectSolution(keystone: KeystoneIbGib_V1, solutionValue: string): Promise; /** * Validates the upfront connect parameter solutions before socket connection upgrades. */ export declare function validateUpfrontConnect({ sAddr, solution, space, metaspace, }: { sAddr: string; solution: string; space: IbGibSpaceAny; metaspace: MetaspaceService; }): Promise<{ sAddr_tjp: string; authorizedS: KeystoneIbGib_V1; }>; /** * Verifies the multi-turn evolved Keystone challenge proof frame. */ export declare function verifyConnectProof({ proofFrame, sKeystone_latest, challengeUuid, demandedIds, }: { proofFrame: KeystoneIbGib_V1; sKeystone_latest: KeystoneIbGib_V1; challengeUuid: string; demandedIds: string[]; }): Promise; /** * Isomorphic pure function to intrinsically validate, persist, and register * posted keystones. Shared between REST API and sync websocket receiver peers. */ export declare function validateAndRegisterPostKeystones({ ibGibs, metaspace, space }: { ibGibs: any[]; metaspace: MetaspaceService; space: IbGibSpaceAny; }): Promise; /** * Isomorphic pure function to validate a keystone evolution transition and * related S session keystones, and persist them to metaspace. Shared across * REST API evolve handlers and future socket evolution channels. */ export declare function validateAndRegisterEvolveKeystone({ domainAddr, keystoneIbGib, relatedKeystoneIbGibs, metaspace, space }: { /** * Address of the root parent domain identity keystone. */ domainAddr: string; /** * The main evolved keystone frame being synchronized. */ keystoneIbGib: KeystoneIbGib_V1; /** * Array of other keystone frames related to this evolution. * Distinction in intent: * 1. Ephemeral Session Keystones: Temporary keystones generated to verify * WebSocket connection sessions (under 'sync' claims, targeted via * claim.target = sAddr). * 2. Persistent Delegate Keystones: Long-lived sub-keystones registered in * the parent's `delegates` dictionary that are evolved concurrently * (e.g., during 'manage' password changes). */ relatedKeystoneIbGibs?: IbGib_V1[]; /** * The MetaspaceService instance. */ metaspace: MetaspaceService; /** * The active storage space. */ space: IbGibSpaceAny; }): Promise; /** * Packages a binary ibGib into a length-prefixed binary packet for direct WebSocket transmission: * [4-byte meta JSON length (Big-Endian UInt32)][metadata JSON (UTF-8)][raw binary payload bytes] */ export declare function packBinaryDomainPayload(ibGib: IbGib_V1): Uint8Array; /** * Reconstitutes an IbGib_V1 from a length-prefixed binary packet received over WebSocket: * [4-byte meta JSON length (Big-Endian UInt32)][metadata JSON (UTF-8)][raw binary payload bytes] */ export declare function unpackBinaryDomainPayload(packet: Uint8Array): IbGib_V1; /** * Default threshold constants for domain payload batching: * - Up to 50 ibgibs per batch * - Up to 2 MB total serialized payload per batch */ export declare const DEFAULT_SYNC_BATCH_MAX_ITEMS = 50; export declare const DEFAULT_SYNC_BATCH_MAX_BYTES: number; export interface DomainPayloadChunk { type: 'text_batch' | 'binary_single'; ibGibs?: IbGib_V1[]; binaryIbGib?: IbGib_V1; } /** * Splits an array of domain ibgibs into transmission chunks: * - Group text/JSON ibgibs into batches of up to maxItems or maxBytes * - Send binary stones individually via opcode 0x2 */ export declare function chunkDomainPayloads({ payloads, maxItems, maxBytes }: { payloads: IbGib_V1[]; maxItems?: number; maxBytes?: number; }): DomainPayloadChunk[]; //# sourceMappingURL=sync-websocket-peer-helpers.d.mts.map