UNPKG

@guarani/jose

Version:

Implementation of the RFCs of the JOSE Working Group.

48 lines (47 loc) 1.92 kB
/// <reference types="node" /> import { Optional } from '@guarani/types'; import { JsonWebKey } from '../jwk/jsonwebkey'; import { JsonWebEncryptionHeaderParams } from './jsonwebencryption-header.params'; import { JsonWebEncryptionHeader } from './jsonwebencryption.header'; /** * Implementation of {@link https://www.rfc-editor.org/rfc/rfc7516.html RFC 7516}. */ export declare class JsonWebEncryption { /** * Header of the JSON Web Encryption. */ readonly header: JsonWebEncryptionHeader; /** * Plaintext of the JSON Web Encryption. */ readonly plaintext: Buffer; /** * Instantiates a new JSON Web Encryption based on the provided JSON Web Encryption Header and Plaintext. * * @param header JSON Web Encryption Header. * @param plaintext Buffer to be used as the Plaintext. */ constructor(header: JsonWebEncryptionHeaderParams, plaintext?: Optional<Buffer>); /** * Decodes the provided JSON Web Encryption Token and returns its parsed Parameters. * * @param token JSON Web Encryption Token to be Decoded. * @returns Parsed Parameters of the JSON Web Encryption Token. */ private static decodeCompact; /** * Deserializes a JSON Web Encryption Compact Token. * * @param token JSON Web Encryption Compact Token to be Deserialized. * @param key JSON Web Key used to Deserialize the JSON Web Encryption Compact Token. * @returns JSON Web Encryption containing the Deserialized JSON Web Encryption Header and Plaintext. */ static deserializeCompact(token: string, key: JsonWebKey): Promise<JsonWebEncryption>; /** * Serializes the JSON Web Encryption into a Compact Token. * * @param key JSON Web Key used to Serialize the JSON Web Encryption. * @returns JSON Web Encryption Compact Token. */ serializeCompact(key: JsonWebKey): Promise<string>; }