UNPKG

cleansend

Version:

A TypeScript implementation of the OpenMsg Protocol - secure, decentralized messaging system with end-to-end encryption for cross-domain communication

314 lines 8.27 kB
/** * OpenMsg Protocol Type Definitions * * This module contains all TypeScript interfaces and types used throughout * the CleanSend OpenMsg Protocol implementation. These types ensure type safety * and provide clear contracts for data structures, API requests/responses, * and database models. */ /** * Application settings configuration * Contains environment-specific settings for the OpenMsg server */ export interface OpenMsgSettings { openmsgDomain: string; sandbox: boolean; sandboxDir: string; port: number; nodeEnv: string; } /** * Database connection configuration * MySQL connection pool settings */ export interface DatabaseConfig { host: string; user: string; password: string; database: string; waitForConnections: boolean; connectionLimit: number; queueLimit: number; } /** * OpenMsg user account stored in the database * Represents a registered user on this OpenMsg server */ export interface OpenMsgUser { id: number; self_openmsg_address: string; self_openmsg_address_name: string; password: string; password_salt: string; timestamp_created: Date; } /** * Temporary handshake record for connection establishment * Used during the authentication process between two OpenMsg users */ export interface OpenMsgHandshake { id: number; other_openmsg_address: string; pass_code: string; timestamp: Date; } /** * Established connection between two OpenMsg users * Contains encryption keys and authentication data for secure messaging */ export interface OpenMsgUserConnection { id: number; self_openmsg_address: string; other_openmsg_address: string; other_openmsg_address_name: string; other_acceptsMessages: number; auth_code: string; ident_code: string; message_crypt_key: string; timestamp_created: Date; } /** * One-time pass codes for authentication * Used to authorize new connections between OpenMsg users */ export interface OpenMsgPassCode { id: number; self_openmsg_address: string; pass_code: string; timestamp: Date; } /** * Outgoing messages waiting for delivery confirmation * Messages are moved here after being sent but before confirmation */ export interface OpenMsgMessageOutbox { id: number; self_openmsg_address: string; ident_code: string; message_hash: string; message_nonce: string; message_text: string; timestamp_created: Date; } /** * Successfully sent messages archive * Messages are moved here after delivery confirmation */ export interface OpenMsgMessageSent { id: number; self_openmsg_address: string; ident_code: string; message_hash: string; message_text: string; timestamp_read?: number; timestamp_created: Date; } /** * Received messages inbox * Stores decrypted messages received from other OpenMsg users */ export interface OpenMsgMessageInbox { id: number; self_openmsg_address: string; ident_code: string; message_hash: string; message_text: string; timestamp_created: Date; } /** * Authentication request from another OpenMsg server * Sent when a user wants to establish a connection with a user on this server */ export interface AuthRequest { receiving_openmsg_address_id: string; pass_code: string; sending_openmsg_address: string; sending_openmsg_address_name: string; sending_allow_replies: boolean; openmsg_version?: number; } /** * Authentication response sent back to requesting server * Contains connection credentials if authentication succeeds */ export interface AuthResponse { success?: boolean; error?: boolean; auth_code?: string; ident_code?: string; message_crypt_key?: string; receiving_openmsg_address_name?: string; error_message?: string; } /** * Authentication confirmation request * Sent to confirm that a handshake request is legitimate */ export interface AuthConfirmRequest { other_openmsg_address: string; pass_code: string; } /** * Authentication confirmation response * Confirms whether the handshake request was legitimate */ export interface AuthConfirmResponse { success?: boolean; error?: boolean; error_message?: string; } /** * Message receive request from another OpenMsg server * Contains an encrypted message for delivery to a user on this server */ export interface MessageReceiveRequest { receiving_openmsg_address_id: string; sending_openmsg_address_name?: string; ident_code: string; message_package: string; message_hash: string; message_salt: string; message_timestamp: number; openmsg_version?: number; verified_account?: { verified_account_signature?: string; verified_account_name?: string; verified_account_expires?: string; }; } /** * Message receive response sent back to sending server * Indicates whether the message was successfully received and processed */ export interface MessageReceiveResponse { success?: boolean; error?: boolean; response_code: string; error_message?: string; } /** * Message confirmation request * Sent to verify that a message originated from the claiming server */ export interface MessageConfirmRequest { message_hash: string; message_nonce: string; } /** * Message confirmation response * Confirms whether the message is authentic */ export interface MessageConfirmResponse { success?: boolean; error?: boolean; error_message?: string; } /** * Handshake initiation request (setup/testing endpoint) * Used to start a connection with another OpenMsg user */ export interface InitiateHandshakeRequest { other_openmsg_address: string; pass_code: string; } /** * Handshake initiation response * Result of attempting to establish a connection */ export interface InitiateHandshakeResponse { success?: boolean; error?: boolean; message: string; } /** * Send message request (setup/testing endpoint) * Used to send a message to a connected user */ export interface SendMessageRequest { message_text: string; sending_openmsg_address: string; receiving_openmsg_address: string; } /** * Send message response * Result of attempting to send a message */ export interface SendMessageResponse { success?: boolean; error?: boolean; response_code: string; error_message?: string; } /** * Pass code request (setup/testing endpoint) * Used to generate a one-time authentication code */ export interface RequestPassCodeRequest { self_openmsg_address: string; } /** * Pass code response * Contains the generated pass code */ export interface RequestPassCodeResponse { success?: boolean; error?: boolean; pass_code?: string; message?: string; error_message?: string; } /** * Encrypted message package for transmission * Contains all components needed for secure message delivery */ export interface MessagePackage { package: string; nonce: string; } /** * Encrypted message components * Used for detailed encryption/decryption operations */ export interface EncryptedMessage { encrypted: string; authTag: string; nonce: string; } /** * OpenMsg protocol error codes * Standardized error codes for different failure scenarios */ export type OpenMsgErrorCode = 'SM_E001' | 'SM_E002' | 'SM_E003' | 'SM_E004' | 'SM_E005'; /** * OpenMsg protocol success codes * Indicates successful message processing */ export type OpenMsgSuccessCode = 'SM_S888'; /** * Combined success/error response codes */ export type OpenMsgResponseCode = OpenMsgErrorCode | OpenMsgSuccessCode; /** * Standardized API error response * Used for all error responses in the OpenMsg protocol */ export interface ApiError { error: true; error_message: string; response_code?: OpenMsgErrorCode; } /** * Standardized API success response * Used for successful operations with optional data payload */ export interface ApiSuccess<T = any> { success: true; response_code?: OpenMsgSuccessCode; data?: T; } /** * Union type for all API responses * Every API endpoint returns either success or error */ export type ApiResponse<T = any> = ApiError | ApiSuccess<T>; //# sourceMappingURL=index.d.ts.map