@alessiofrittoli/crypto-signature
Version:
Lightweight TypeScript Signatures library
25 lines (22 loc) • 1.06 kB
TypeScript
import crypto from 'crypto';
import { Algo } from '@alessiofrittoli/crypto-algorithm/types';
declare namespace Sign {
/**
* Signature algorithm parameter.
*
* @link https://datatracker.ietf.org/doc/html/rfc7518#section-3.1
*/
type AlgorithmJwkName = Algo.JwkName;
type Hash = Algo.Hash;
/**
* The private key used for HMAC or the PEM private key for RSA, ECDSA and RSASSA-PSS signing algorithms.
*
*/
type PrivateKey<TAlg extends Algo.Name = Algo.Name> = (TAlg extends `HMAC` ? (crypto.BinaryLike | crypto.KeyObject | CryptoKey) : (crypto.KeyLike | crypto.SignKeyObjectInput | crypto.SignPrivateKeyInput | CryptoKey));
/**
* The public key used for HMAC, or RSA, ECDSA and RSASSA-PSS signing verifications.
*
*/
type PublicKey<TAlg extends Algo.Name = Algo.Name> = (TAlg extends `HMAC` ? (crypto.BinaryLike | crypto.KeyObject | CryptoKey) : (crypto.KeyLike | crypto.VerifyKeyObjectInput | crypto.VerifyPublicKeyInput | crypto.VerifyJsonWebKeyInput | CryptoKey));
}
export { Sign };