UNPKG

@quan-to/chevronlib

Version:

Chevron GPG Library Wrapper for Node.JS

111 lines (110 loc) 5.04 kB
/** * Checks if the data string is a base64 encoded payload * * @param {string} data - A string to be tested * @returns {boolean} - True if the string is a valid base64 format */ declare const isBase64: (data: string) => boolean; /** * Returns all fingerprints contained in the specified key * @param {string} asciiArmoredKey - The private / public key you want the fingerprints in ASCII Armored Format * @returns {string[]} the fingerprints in the specified keys */ declare const getKeyFingerprints: (asciiArmoredKey: string) => any; /** * Loads the specified key into memory store for later use * * Both public and private keys can be loaded using loadKey * @param {string} asciiArmoredKey - The private / public key you want the fingerprints in ASCII Armored Format * @returns {Promise<string>} the first fingerprint of the loaded key */ declare const loadKey: (asciiArmoredKey: string) => Promise<unknown>; /** * Signs the specified data using a pre-loaded and pre-unlocked key specified by fingerprint * * The key should be previously loaded with loadKey and unlocked with unlockKey * The data should be always encoded as base64 * * @param {string} data - Base64 Encoded Data to be signed * @param {string} fingerprint - Fingerprint of the key used to sign data * @returns {Promise<string>} - The ASCII Armored PGP Signature */ declare const signData: (data: string, fingerprint: string) => Promise<string>; /** * Verifies the signature of a payload and returns true if it's valid. * * The data should be always encoded as base64 * The signature field can be in ASCII Armored Format or base64 encoded binary PGP Signature * * @param {string} data - Base64 Encoded Data to be signed * @param {string} signature - A ASCII Armored Format or Base64 Encoded Binary PGP Signature * @returns {Promise<boolean>} */ declare const verifySignature: (data: string, signature: string) => Promise<boolean | void>; /** * Unlocks a pre-loaded private key with the specified password * * The private key should be pre-loaded with loadKey function * * @param {string} fingerprint - Fingerprint of the private key that should be unlocked for use * @param {string} password - Password of the private key * @returns {Promise} */ declare const unlockKey: (fingerprint: string, password: string) => Promise<unknown>; /** * Generates a new PGP Private Key by the specified password, identifier and bits (key-length) * * The Identifier should be in one of the following formats: * - "Name" * - "Name <email>" * The key-length (bits parameter) should not be less than 2048 * The key is not automatically loaded into memory after generation * * @param {string} password - The password to encrypt the private key * @param {string} identifier - The identifier of the key * @param {number} bits - Number of bits of the RSA Key (recommended 3072) * @returns {Promise<string>} - The generated private key */ declare const generateKey: (password: string, identifier: string, bits: number) => Promise<string | void>; /** * Returns a ASCII Armored public key of a pre-loaded key * * The public/private key should be pre-loaded with loadKey * * @param {string} fingerprint - Fingerprint to fetch the public key * @returns {string} - The public key */ declare const getPublicKey: (fingerprint: string) => string; /** * Signs the specified data using a pre-loaded and pre-unlocked key specified by fingerprint * and returns in Quanto Signature Format * * The key should be previously loaded with loadKey and unlocked with unlockKey * The data should be always encoded as base64 * * @param {string} data - Base64 Encoded Data to be signed * @param {string} fingerprint - Fingerprint of the key used to sign data * @returns {Promise<string>} - The ASCII Armored PGP Signature */ declare const quantoSignData: (data: string, fingerprint: string) => Promise<string>; /** * Verifies the signature in Quanto Signature Format of a payload and returns true if it's valid. * * The data should be always encoded as base64 * The signature field can be in ASCII Armored Format or base64 encoded binary PGP Signature * * @param {string} data - Base64 Encoded Data to be signed * @param {string} signature - A ASCII Armored Format or Base64 Encoded Binary PGP Signature * @returns {Promise<boolean>} */ declare const quantoVerifySignature: (data: string, signature: string) => Promise<boolean | void>; /** * Changes a private key password * * @param {string} keyData - The private key * @param {string} currentPassword - The current password of the key * @param {string} newPassword - The new password for the key * @returns {Promise<string>>} the same private key encrypted with the newPassword */ declare const changeKeyPassword: (keyData: string, currentPassword: string, newPassword: string) => Promise<string | void>; export { verifySignature, signData, getKeyFingerprints, loadKey, unlockKey, generateKey, getPublicKey, isBase64, quantoSignData, quantoVerifySignature, changeKeyPassword, };