UNPKG

@sgnl-ai/set-transmitter

Version:

HTTP transmission library for Security Event Tokens (SET) with CAEP/SSF support

54 lines (48 loc) 1.98 kB
export { EventType, EventTypes } from './constants.mjs'; interface TransmitOptions { authToken?: string; headers?: Record<string, string>; timeout?: number; retry?: RetryConfig; parseResponse?: boolean; validateStatus?: (status: number) => boolean; } interface RetryConfig { maxAttempts?: number; retryableStatuses?: number[]; backoffMs?: number; maxBackoffMs?: number; backoffMultiplier?: number; } interface TransmitResult { status: 'success' | 'failed'; statusCode: number; body: string | Record<string, unknown>; headers: Record<string, string>; error?: string; retryable?: boolean; } interface TransmitterConfig { defaultOptions?: TransmitOptions; } declare function transmitSET(jwt: string, url: string, options?: TransmitOptions): Promise<TransmitResult>; declare function createTransmitter(defaultOptions?: TransmitOptions): (jwt: string, url: string, options?: TransmitOptions) => Promise<TransmitResult>; declare function isValidSET(jwt: string): boolean; declare class TransmissionError extends Error { readonly statusCode?: number | undefined; readonly retryable: boolean; readonly responseBody?: string | undefined; readonly responseHeaders?: Record<string, string> | undefined; constructor(message: string, statusCode?: number | undefined, retryable?: boolean, responseBody?: string | undefined, responseHeaders?: Record<string, string> | undefined); } declare class TimeoutError extends TransmissionError { constructor(message: string, timeout: number); } declare class NetworkError extends TransmissionError { cause?: Error; constructor(message: string, cause?: Error); } declare class ValidationError extends Error { constructor(message: string); } export { NetworkError, type RetryConfig, TimeoutError, TransmissionError, type TransmitOptions, type TransmitResult, type TransmitterConfig, ValidationError, createTransmitter, isValidSET, transmitSET };