UNPKG

@guarani/jose

Version:

Implementation of the RFCs of the JOSE Working Group.

99 lines (98 loc) 4.04 kB
/// <reference types="node" /> import { Optional } from '@guarani/types'; import { KeyObject } from 'crypto'; import { JsonWebKey } from '../../jsonwebkey'; import { JsonWebKeyParams } from '../../jsonwebkey.params'; import { EcKeyParams } from './ec-key.params'; import { ExportEcKeyOptions } from './types/export-ec-key.options'; import { GenerateEcKeyOptions } from './types/generate-ec-key.options'; import { SupportedEllipticCurve } from './types/supported-elliptic-curve'; /** * Implementation of {@link https://www.rfc-editor.org/rfc/rfc7518.html#section-6.2 RFC 7518 Section 6.2}. */ export declare class EcKey extends JsonWebKey implements EcKeyParams { /** * Type of the JSON Web Key. */ readonly kty: 'EC'; /** * Name of the Elliptic Curve. */ readonly crv: SupportedEllipticCurve; /** * X Coordinate. */ readonly x: string; /** * Y Coordinate. */ readonly y: string; /** * Private Key. */ readonly d?: Optional<string>; /** * Instantiates an Elliptic Curve JSON Web Key based on the provided Parameters. * * @param key Parameters of the Elliptic Curve JSON Web Key. * @param options Optional JSON Web Key Parameters. */ constructor(key: EcKeyParams, options?: Optional<JsonWebKeyParams>); /** * Generates a new Elliptic Curve JSON Web Key. * * @param options Options for the generation of the Elliptic Curve JSON Web Key. * @param params Optional JSON Web Key Parameters. * @returns Generated Elliptic Curve JSON Web Key. */ static generate(options: GenerateEcKeyOptions, params?: Optional<JsonWebKeyParams>): Promise<EcKey>; /** * Loads the provided JSON Web Key into a NodeJS Crypto Key. * * @param params Parameters of the JSON Web Key. * @returns NodeJS Crypto Key. */ protected loadCryptoKey(params: EcKeyParams): KeyObject; /** * Exports the SEC 1 Elliptic Curve Private Key DER Encoding of the Elliptic Curve JSON Web Key. * * @param options Options for exporting the data of the Elliptic Curve JSON Web Key. * @returns DER Encoded SEC 1 Elliptic Curve Private Key. */ export(options: ExportEcKeyOptions<'der', 'sec1', 'private'>): Buffer; /** * Exports the SEC 1 Elliptic Curve Private Key PEM Encoding of the Elliptic Curve JSON Web Key. * * @param options Options for exporting the data of the Elliptic Curve JSON Web Key. * @returns PEM Encoded SEC 1 Elliptic Curve Private Key. */ export(options: ExportEcKeyOptions<'pem', 'sec1', 'private'>): string; /** * Exports the PKCS#8 Elliptic Curve Private Key DER Encoding of the Elliptic Curve JSON Web Key. * * @param options Options for exporting the data of the Elliptic Curve JSON Web Key. * @returns DER Encoded PKCS#8 Elliptic Curve Private Key. */ export(options: ExportEcKeyOptions<'der', 'pkcs8', 'private'>): Buffer; /** * Exports the PKCS#8 Elliptic Curve Private Key PEM Encoding of the Elliptic Curve JSON Web Key. * * @param options Options for exporting the data of the Elliptic Curve JSON Web Key. * @returns PEM Encoded PKCS#8 Elliptic Curve Private Key. */ export(options: ExportEcKeyOptions<'pem', 'pkcs8', 'private'>): string; /** * Exports the SPKI Elliptic Curve Public Key DER Encoding of the Elliptic Curve JSON Web Key. * * @param options Options for exporting the data of the Elliptic Curve JSON Web Key. * @returns DER Encoded SPKI Elliptic Curve Public Key. */ export(options: ExportEcKeyOptions<'der', 'spki', 'public'>): Buffer; /** * Exports the SPKI Elliptic Curve Public Key PEM Encoding of the Elliptic Curve JSON Web Key. * * @param options Options for exporting the data of the Elliptic Curve JSON Web Key. * @returns PEM Encoded SPKI Elliptic Curve Public Key. */ export(options: ExportEcKeyOptions<'pem', 'spki', 'public'>): string; }