UNPKG

451-tools

Version:

Censorship resilient and distributed publishing: informed by the needs of publishers and their audiences, More Mirrors implements a set of offline fallback strategies for censorship resilient websites.

35 lines (34 loc) 1.74 kB
/** * Generates an ECDSA key pair using the SubtleCrypto API. * @returns {Promise<{ publicKey: string, privateKey: string }>} The public and private keys in Base64 encoding. * - The private key is encoded in PKCS#8 format. * - The public key is encoded in SPKI format. * - Both keys are compatible with the P-256 elliptic curve. */ export function generateKeyPair(): Promise<{ publicKey: string; privateKey: string; }>; /** * Signs the provided parameters using the given ECDSA private key. * @param {object} params - The parameters to sign. * @param {string} privateKeyBase64 - The private key in Base64 encoding (P-256 curve). * @returns {Promise<string>} The generated signature in hexadecimal format. */ export function signParams(params: object, privateKeyBase64: string): Promise<string>; /** * Generates a signed URL with the given base URL, parameters, and private key. * @param {string} baseUrl - The base URL to append the parameters and signature. * @param {object} params - The parameters to include in the query string. * @param {string} privateKey - The private key to sign the parameters (Base64 encoded). * @returns {Promise<string>} The signed URL. */ export function generateSignedLink(baseUrl: string, params: object, privateKey: string): Promise<string>; /** * Saves a key to a file with specified options. * @param {string} filePath - The file path where the key will be saved. * @param {string} key - The Base64-encoded key content to save. * @param {object} options - Options for file saving (e.g., file permissions). * - For private keys, it's recommended to use mode 0o600 for security. */ export function saveKeyToFile(filePath: string, key: string, options: object): Promise<void>;