paseto-ts
Version:
PASETO v4 (encrypt, decrypt, sign & verify) in TypeScript
28 lines (27 loc) • 1.34 kB
TypeScript
import type { Assertion, Footer, Payload } from "../lib/types.js";
/**
* Decrypts a PASETO v4.local token and returns the message.
* The key must have the version and purpose of `k4.local`.
* @param {string | Uint8Array} key 32 byte key used to encrypt the message. Must be prepended with `k4.local.`.
* @param {string | Uint8Array} token PASETO v4.local token
* @param {object} options Options
* @param {Footer | string | Uint8Array} options.footer Optional footer
* @param {Assertion | string | Uint8Array} options.assertion Optional assertion
* @param {number} options.maxDepth Maximum depth of nested objects in the payload and footer; defaults to 32
* @param {number} options.maxKeys Maximum number of keys in an object in the payload and footer; defaults to 128
* @returns {Uint8Array} Decrypted payload
* @see https://github.com/paseto-standard/paseto-spec/blob/master/docs/01-Protocol-Versions/Version4.md#decrypt
*/
export declare function decrypt<T extends {
[key: string]: any;
} = {
[key: string]: any;
}>(key: string | Uint8Array, token: string | Uint8Array, { assertion, maxDepth, maxKeys, validatePayload, }?: {
assertion?: Assertion | string | Uint8Array;
maxDepth?: number;
maxKeys?: number;
validatePayload?: boolean;
}): {
payload: Payload & T;
footer: Footer | string;
};