UNPKG

@coin-voyage/paykit

Version:

Seamless crypto payments. Onboard users from any chain, any coin into your app with one click.

27 lines (26 loc) 1.27 kB
/** * Generates an authorization signature for API requests. * * ⚠️ **Warning:** This function should only be run on the server. * It uses the API secret, which must remain confidential. Running this * code in a client-side environment risks exposing sensitive information * to end users or malicious actors. * * This function creates a signed authorization string using the provided API key and secret. * The generated string includes the API key, a timestamp (in seconds since epoch), * and a SHA-512 hash signature of the concatenated API key, secret, and timestamp. * * @param {string} apiKey - The API key used for authentication. * @param {string} apiSecret - The API secret used to generate the signature. * @returns {string} - A formatted authorization string in the format: * `APIKey=<apiKey>,signature=<signature>,timestamp=<timestamp>`. * * @example * const apiKey = 'yourApiKey'; * const apiSecret = 'yourApiSecret'; * const authSignature = generateAuthorizationSignature(apiKey, apiSecret); * console.log(authSignature); * // Example output: * // APIKey=yourApiKey,signature=2ee76043a90a...,timestamp=1737106896 */ export declare function generateAuthorizationSignature(apiKey: string, apiSecret: string): string;