UNPKG

@unvision/jose

Version:

Implementation of the RFCs of the JOSE Working Group.

134 lines (133 loc) 4.07 kB
/// <reference types="node" /> import { KeyObject } from 'crypto'; import { SupportedJsonWebEncryptionKeyWrapAlgorithm } from '../jwe/algorithms/alg/types/supported-jsonwebencryption-keywrap-algorithm'; import { SupportedJsonWebSignatureAlgorithm } from '../jws/algorithms/types/supported-jsonwebsignature-algorithm'; import { SupportedEllipticCurve } from './algorithms/types/supported-elliptic-curve'; import { SupportedJsonWebKeyAlgorithm } from './algorithms/types/supported-jsonwebkey-algorithm'; import { JsonWebKeyParameters } from './jsonwebkey.parameters'; import { KeyOperation } from './types/key-operation'; import { PublicKeyUse } from './types/public-key-use'; /** * Implementation of a JSON Web Key. * * @see https://www.rfc-editor.org/rfc/rfc7517.html#section-4 */ export declare class JsonWebKey implements JsonWebKeyParameters { /** * Type of the JSON Web Key. */ readonly kty: SupportedJsonWebKeyAlgorithm; /** * Octet Sequence Base64Url encoded Secret. */ readonly k?: string; /** * Elliptic Curve. */ readonly crv?: SupportedEllipticCurve; /** * Elliptic Curve X Coordinate. */ readonly x?: string; /** * Elliptic Curve Y Coordinate. */ readonly y?: string; /** * RSA Modulus. */ readonly n?: string; /** * RSA Public Exponent. */ readonly e?: string; /** * Elliptic Curve Private Value. * RSA Private Exponent. */ readonly d?: string; /** * RSA First Prime Factor. */ readonly p?: string; /** * RSA Second Prime Factor. */ readonly q?: string; /** * RSA First Factor CRT Exponent. */ readonly dp?: string; /** * RSA Second Factor CRT Exponent. */ readonly dq?: string; /** * RSA First Factor CRT Coefficient. */ readonly qi?: string; /** * Indicates whether a Public JSON Web Key is used for Plaintext Encryption or Signature Verification. */ readonly use?: PublicKeyUse; /** * Operations for which the JSON Web Key are intended to be used. */ readonly key_ops?: KeyOperation[]; /** * JSON Web Encryption Key Wrap Algorithm or JSON Web Signature Algorithm allowed to use this JSON Web Key. */ readonly alg?: SupportedJsonWebEncryptionKeyWrapAlgorithm | SupportedJsonWebSignatureAlgorithm; /** * Identifier of the JSON Web Key. */ readonly kid?: string; /** * URL of the X.509 certificate of the JSON Web Key. */ readonly x5u?: string; /** * Chain of X.509 certificates of the JSON Web Key. */ readonly x5c?: string[]; /** * SHA-1 Thumbprint of the X.509 certificate of the JSON Web Key. */ readonly x5t?: string; /** * SHA-256 Thumbprint of the X.509 certificate of the JSON Web Key. */ readonly 'x5t#S256'?: string; /** * Additional JSON Web Key Parameters. */ readonly [parameter: string]: any; /** * Supported JSON Web Key Algorithms. */ private static readonly algorithms; /** * NodeJS Crypto Key. */ protected readonly cryptoKey: KeyObject; /** * Instantiates a new JSON Web Key based on the provided Parameters. * * @param parameters Parameters of the JSON Web Key. * @param additionalParameters Additional JSON Web Key Parameters. Overrides the attributes of `parameters`. */ constructor(parameters: JsonWebKeyParameters, additionalParameters?: Partial<JsonWebKeyParameters>); /** * Parses a JSON String into a JSON Web Key. * * @param data JSON String representation of the JSON Web Key to be parsed. * @returns Instance of a JSON Web Key based on the provided JSON String. */ static parse(data: string): JsonWebKey; /** * Returns the Parameters of the JSON Web Key. * * @param exportPublic Exports only the Public Parameters of the JSON Web Key. */ toJSON(exportPublic?: boolean): JsonWebKeyParameters; }