UNPKG

@humanmark/sdk-js

Version:

Browser-native JavaScript SDK for Humanmark human verification challenges

55 lines 1.98 kB
/** * HTTP utility functions * Helper functions for HTTP operations and status checking */ /** * Checks if an HTTP status code indicates a server error * @param status - HTTP status code * @returns true if status is 5xx */ export declare function isServerError(status: number): boolean; /** * Checks if an HTTP status code indicates the request should be retried * @param status - HTTP status code * @returns true if the request should be retried */ export declare function isRetryableStatus(status: number): boolean; /** * Checks if an HTTP status code indicates an API key error * @param status - HTTP status code * @returns true if status is 401 or 403 */ export declare function isApiKeyError(status: number): boolean; /** * Checks if an error is a network error that can be retried * @param error - The error to check * @returns true if the error is retryable */ export declare function isRetryableNetworkError(error: unknown): boolean; /** * Categorizes a network error as temporary or permanent * @param error - The error to categorize * @returns 'temporary' | 'permanent' | 'unknown' */ export declare function categorizeNetworkError(error: unknown): 'temporary' | 'permanent' | 'unknown'; /** * Creates a fetch options object with common settings * @param method - HTTP method * @param headers - Headers object * @param body - Optional request body * @param signal - Optional abort signal * @returns Fetch options object */ export declare function createFetchOptions(method: string, headers: Record<string, string>, body?: unknown, signal?: AbortSignal): RequestInit; /** * Safely extracts error message from unknown error * @param error - The error to extract message from * @returns Error message string */ export declare function getErrorMessage(error: unknown): string; /** * Checks if the browser is online * @returns true if online, false if offline */ export declare function isOnline(): boolean; //# sourceMappingURL=http.d.ts.map