secure-cookie
Version:
Cookie library/middleware with signing and encryption support
43 lines • 1.91 kB
TypeScript
/// <reference types="node" />
import { BinaryToTextEncoding, CipherKey, Encoding } from "crypto";
import { CIPHER_INFO } from "./ciphers";
export interface KeyStoreOpts {
signing?: {
keys: string[];
algorithm?: string | 'blake2b512' | 'blake2s256' | 'gost' | 'md4' | 'md5' | 'rmd160' | 'sha1' | 'sha224' | 'sha256' | 'sha3-224' | 'sha3-256' | 'sha3-384' | 'sha3-512' | 'sha384' | 'sha512' | 'sha512-224' | 'sha512-256' | 'shake128' | 'shake256' | 'sm3';
encoding?: BinaryToTextEncoding;
};
encryption?: {
keys: string[] | CipherKey[];
algorithm?: keyof typeof CIPHER_INFO | string;
encoding?: Encoding;
authTagLength?: number;
};
}
export declare type EncryptOptions = Required<KeyStoreOpts['encryption']> & {
key?: string | undefined;
};
export declare type DecryptOptions = Required<KeyStoreOpts['encryption']> & {
key?: string | CipherKey | undefined;
iv?: string | Buffer | undefined;
authTag?: string | Buffer | undefined;
};
export declare class KeyStore {
encryption: Required<NonNullable<KeyStoreOpts['encryption']>>;
signing: Required<NonNullable<KeyStoreOpts['signing']>>;
static cipherInfo: Record<string, {
ivLength: number | undefined;
keyLength: number;
}>;
constructor(opts?: KeyStoreOpts);
encrypt(data?: null, options?: Partial<EncryptOptions>): null;
encrypt(data: string | Buffer, options?: Partial<EncryptOptions>): string;
decrypt(data?: null, options?: Partial<DecryptOptions>): null;
decrypt(data: string | Buffer, options?: Partial<DecryptOptions>): string;
private static doDecrypt;
sign(data?: null, key?: string | CipherKey): null;
sign(data: string, key?: string | CipherKey): string;
verify(data: string, digest: string): boolean;
indexOf(data: string, digest: string): number;
}
//# sourceMappingURL=keystore.d.ts.map