@unvision/jose
Version:
Implementation of the RFCs of the JOSE Working Group.
54 lines (53 loc) • 2.35 kB
TypeScript
/// <reference types="node" />
import { JsonWebKey } from '../jwk/jsonwebkey';
import { JsonWebKeyLoader } from '../types/jsonwebkey-loader';
import { SupportedJsonWebSignatureAlgorithm } from './algorithms/types/supported-jsonwebsignature-algorithm';
import { JsonWebSignatureHeader } from './jsonwebsignature.header';
import { JsonWebSignatureHeaderParameters } from './jsonwebsignature.header.parameters';
/**
* Implementation of a JSON Web Signature.
*
* @see https://www.rfc-editor.org/rfc/rfc7515.html
*/
export declare class JsonWebSignature {
/**
* JSON Web Signature Header.
*/
readonly header: JsonWebSignatureHeader;
/**
* JSON Web Signature Payload.
*/
readonly payload: Buffer;
/**
* Instantiates a new JSON Web Signature based on the provided JSON Web Signature Header and Payload.
*
* @param header JSON Web Signature Header.
* @param payload Buffer to be used as the Payload.
*/
constructor(header: JsonWebSignatureHeaderParameters, payload?: Buffer);
/**
* Decodes the Parameters of the provided JSON Web Signature Compact Token.
*
* ***note: this method does not validate the signature of the token.***
*
* @param token JSON Web Signature Compact Token to be decoded.
* @returns Decoded Parameters of the JSON Web Signature Compact Token.
*/
static decode(token: string): [JsonWebSignatureHeader, Buffer, Buffer];
/**
* Deserializes a JSON Web Signature Compact Token.
*
* @param token JSON Web Signature Compact Token to be Deserialized.
* @param keyOrKeyLoader JSON Web Key used to verify the Signature of the JSON Web Signature Compact Token.
* @param expectedAlgorithms JSON Web Signature Algorithms expected to be defined by the Header.
* @returns JSON Web Signature containing the Deserialized JSON Web Signature Header and Payload.
*/
static verify(token: string, keyOrKeyLoader: JsonWebKey | JsonWebKeyLoader | null, expectedAlgorithms?: SupportedJsonWebSignatureAlgorithm[]): Promise<JsonWebSignature>;
/**
* Serializes the JSON Web Signature into a Compact Token.
*
* @param key JSON Web Key used to Sign the JSON Web Signature Token.
* @returns JSON Web Signature Compact Token.
*/
sign(key?: JsonWebKey): Promise<string>;
}