@guarani/jose
Version:
Implementation of the RFCs of the JOSE Working Group.
62 lines (61 loc) • 2.92 kB
TypeScript
/// <reference types="node" />
import { Nullable, Optional } from '@guarani/types';
import { JsonWebKey } from '../jwk/jsonwebkey';
import { JsonWebKeyLoader } from '../types/jsonwebkey-loader';
import { SupportedJsonWebSignatureAlgorithm } from './algorithms/types/supported-jsonwebsignature-algorithm';
import { JsonWebSignatureHeaderParams } from './jsonwebsignature-header.params';
import { JsonWebSignatureHeader } from './jsonwebsignature.header';
import { DecodeCompactParams } from './types/decode-compact.params';
/**
* Implementation of {@link https://www.rfc-editor.org/rfc/rfc7515.html RFC 7515}.
*/
export declare class JsonWebSignature {
/**
* Header of the JSON Web Signature.
*/
readonly header: JsonWebSignatureHeader;
/**
* Payload of the JSON Web Signature.
*/
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: JsonWebSignatureHeaderParams, payload?: Optional<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 decodeCompact(token: string): DecodeCompactParams;
/**
* Deserializes a JSON Web Signature Compact Token.
*
* @param token JSON Web Signature Compact Token to be Deserialized.
* @param key JSON Web Key used to verify the Signature of the JSON Web Signature Compact Token.
* @returns JSON Web Signature containing the Deserialized JSON Web Signature Header and Payload.
*/
static deserializeCompact(token: string, key: Nullable<JsonWebKey>, expectedAlgorithms?: Optional<SupportedJsonWebSignatureAlgorithm[]>): Promise<JsonWebSignature>;
/**
* Deserializes a JSON Web Signature Compact Token.
*
* @param token JSON Web Signature Compact Token to be Deserialized.
* @param keyLoader Function used to load the JSON Web Key used to verify
* the Signature of the JSON Web Signature Compact Token.
* @returns JSON Web Signature containing the Deserialized JSON Web Signature Header and Payload.
*/
static deserializeCompact(token: string, keyLoader: JsonWebKeyLoader, expectedAlgorithms?: Optional<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.
*/
serializeCompact(key?: Optional<JsonWebKey>): Promise<string>;
}