auth-vir
Version:
Auth made easy and secure via JWT cookies, CSRF tokens, and password hashing helpers.
45 lines (44 loc) • 1.53 kB
TypeScript
/**
* The keys required to sign and encrypt the JWT in their raw form for storage in a secure secrets
* database (such as AWS Secrets Manager) for later parsing by {@link parseJwtKeys}.
*
* These keys should be kept secret and never shared with any frontend, client, etc.
*
* @category Internal
*/
export type RawJwtKeys = Readonly<{
encryptionKey: string;
signingKey: string;
}>;
/**
* The keys required to sign and encrypt the JWT.
*
* These keys should be kept secret and never shared with any frontend, client, etc.
*
* @category Internal
*/
export type JwtKeys = Readonly<{
/**
* Encryption key for JWTs. This is a Uint8Array because `EncryptJWT.encrypt` does not support
* `CryptoKey` for our chosen encryption algorithm.
*/
encryptionKey: Readonly<Uint8Array>;
/** Signing key for JWTs. */
signingKey: Readonly<CryptoKey>;
}>;
/**
* Generate fresh and serialized JWT signing and encryption keys. These should be stored in a secure
* secrets database (such as AWS Secrets Manager) for later parsing by {@link parseJwtKeys}.
*
* These keys should be kept secret and never shared with any frontend, client, etc.
*
* @category Keys
*/
export declare function generateNewJwtKeys(): Promise<RawJwtKeys>;
/**
* Parses an instance of {@link RawJwtKeys} and produces the final {@link JwtKeys} object required by
* all authentication functionality.
*
* @category Keys
*/
export declare function parseJwtKeys(rawKeys: Readonly<RawJwtKeys>): Promise<Readonly<JwtKeys>>;