// #region SyncWebSocketMsgType enum export const SYNC_WEB_SOCKET_MSG_TYPE_AUTH_CHALLENGE_INIT = 'auth-challenge-init'; export const SYNC_WEB_SOCKET_MSG_TYPE_AUTH_INIT = 'auth-init'; export const SYNC_WEB_SOCKET_MSG_TYPE_AUTH_CHALLENGE = 'auth-challenge'; export const SYNC_WEB_SOCKET_MSG_TYPE_AUTH_PROOF = 'auth-proof'; export const SYNC_WEB_SOCKET_MSG_TYPE_AUTH_OK = 'auth-ok'; export const SYNC_WEB_SOCKET_MSG_TYPE_AUTH_FAIL = 'auth-fail'; export const SYNC_WEB_SOCKET_MSG_TYPE_SYNC_FRAME = 'sync-frame'; export const SYNC_WEB_SOCKET_MSG_TYPE_SYNC_FRAME_RESPONSE = 'sync-frame-response'; export const SYNC_WEB_SOCKET_MSG_TYPE_SYNC_FRAME_AUTHENTICATED = 'sync-frame-authenticated'; export const SYNC_WEB_SOCKET_MSG_TYPE_SYNC_FRAME_RESPONSE_AUTHENTICATED = 'sync-frame-response-authenticated'; export const SYNC_WEB_SOCKET_MSG_TYPE_DOMAIN_PAYLOAD = 'domain-payload'; export const SYNC_WEB_SOCKET_MSG_TYPE_DOMAIN_PAYLOAD_BATCH = 'domain-payload-batch'; export const SYNC_WEB_SOCKET_MSG_TYPE_SYNC_ERROR = 'sync-error'; /** * Message types transmitted over the stateful WebSocket connection * during a sync saga session handshake and execution. */ export type SyncWebSocketMsgType = | typeof SYNC_WEB_SOCKET_MSG_TYPE_AUTH_CHALLENGE_INIT | typeof SYNC_WEB_SOCKET_MSG_TYPE_AUTH_INIT | typeof SYNC_WEB_SOCKET_MSG_TYPE_AUTH_CHALLENGE | typeof SYNC_WEB_SOCKET_MSG_TYPE_AUTH_PROOF | typeof SYNC_WEB_SOCKET_MSG_TYPE_AUTH_OK | typeof SYNC_WEB_SOCKET_MSG_TYPE_AUTH_FAIL | typeof SYNC_WEB_SOCKET_MSG_TYPE_SYNC_FRAME | typeof SYNC_WEB_SOCKET_MSG_TYPE_SYNC_FRAME_RESPONSE | typeof SYNC_WEB_SOCKET_MSG_TYPE_SYNC_FRAME_AUTHENTICATED | typeof SYNC_WEB_SOCKET_MSG_TYPE_SYNC_FRAME_RESPONSE_AUTHENTICATED | typeof SYNC_WEB_SOCKET_MSG_TYPE_DOMAIN_PAYLOAD | typeof SYNC_WEB_SOCKET_MSG_TYPE_DOMAIN_PAYLOAD_BATCH | typeof SYNC_WEB_SOCKET_MSG_TYPE_SYNC_ERROR ; export const SyncWebSocketMsgType = { /** Sent by server/receiver to trigger connection authentication. */ auth_challenge_init: SYNC_WEB_SOCKET_MSG_TYPE_AUTH_CHALLENGE_INIT, /** Sent by client/sender to start the authentication handshake with the target session address. */ auth_init: SYNC_WEB_SOCKET_MSG_TYPE_AUTH_INIT, /** Sent by server/receiver with dynamic connect challenges to be solved. */ auth_challenge: SYNC_WEB_SOCKET_MSG_TYPE_AUTH_CHALLENGE, /** Sent by client/sender with proof of session keystone evolution solving challenges. */ auth_proof: SYNC_WEB_SOCKET_MSG_TYPE_AUTH_PROOF, /** Sent by server/receiver signaling successful challenge resolution and upgrade to active sync. */ auth_ok: SYNC_WEB_SOCKET_MSG_TYPE_AUTH_OK, /** Sent when authentication fails. */ auth_fail: SYNC_WEB_SOCKET_MSG_TYPE_AUTH_FAIL, /** Sent by client/sender to transmit the next sync transaction context without payload ibgibs. */ sync_frame: SYNC_WEB_SOCKET_MSG_TYPE_SYNC_FRAME, /** Sent by server/receiver responding with the next sync transaction context. */ sync_frame_response: SYNC_WEB_SOCKET_MSG_TYPE_SYNC_FRAME_RESPONSE, /** Sent by server/receiver after context is validated/authenticated to signal payload transmission. */ sync_frame_authenticated: SYNC_WEB_SOCKET_MSG_TYPE_SYNC_FRAME_AUTHENTICATED, /** Sent by client/sender after response context is validated/authenticated to signal payload transmission. */ sync_frame_response_authenticated: SYNC_WEB_SOCKET_MSG_TYPE_SYNC_FRAME_RESPONSE_AUTHENTICATED, /** Sent to stream a single domain payload ibgib. */ domain_payload: SYNC_WEB_SOCKET_MSG_TYPE_DOMAIN_PAYLOAD, /** Sent to stream a batch of domain payload ibgibs. */ domain_payload_batch: SYNC_WEB_SOCKET_MSG_TYPE_DOMAIN_PAYLOAD_BATCH, /** Sent when a sync runtime execution error occurs. */ sync_error: SYNC_WEB_SOCKET_MSG_TYPE_SYNC_ERROR, } satisfies { readonly [key: string]: SyncWebSocketMsgType }; export const SYNC_WEB_SOCKET_MSG_TYPE_VALID_VALUES: SyncWebSocketMsgType[] = Object.values(SyncWebSocketMsgType); export function isSyncWebSocketMsgType(value: any): value is SyncWebSocketMsgType { return SYNC_WEB_SOCKET_MSG_TYPE_VALID_VALUES.includes(value); } // #endregion SyncWebSocketMsgType enum