UNPKG

@guarani/jose

Version:

Implementation of the RFCs of the JOSE Working Group.

58 lines (57 loc) 2.24 kB
/// <reference types="node" /> import { Optional } from '@guarani/types'; import { KeyObject } from 'crypto'; import { JsonWebKey } from '../../jsonwebkey'; import { JsonWebKeyParams } from '../../jsonwebkey.params'; import { OctKeyParams } from './oct-key.params'; import { ExportOctKeyOptions } from './types/export-oct-key.options'; import { GenerateOctKeyOptions } from './types/generate-oct-key.options'; /** * Implementation of {@link https://www.rfc-editor.org/rfc/rfc7518.html#section-6.4 RFC 7518 Section 6.4}. */ export declare class OctKey extends JsonWebKey implements OctKeyParams { /** * Type of the JSON Web Key. */ readonly kty: 'oct'; /** * Base64Url encoded Octet. */ readonly k: string; /** * Instantiates an Octet Sequence JSON Web Key based on the provided Parameters. * * @param key Parameters of the Octet Sequence JSON Web Key. * @param options Optional JSON Web Key Parameters. */ constructor(key: OctKeyParams, options?: Optional<JsonWebKeyParams>); /** * Generates a new Octet Sequence JSON Web Key. * * @param options Options for the generation of the Octet Sequence JSON Web Key. * @param params Optional JSON Web Key Parameters. * @returns Generated Octet Sequence JSON Web Key. */ static generate(options: GenerateOctKeyOptions, params?: Optional<JsonWebKeyParams>): Promise<OctKey>; /** * 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: OctKeyParams): KeyObject; /** * Exports the data of the Octet Sequence JSON Web Key into a String. * * @param options Options for exporting the data of the Octet Sequence JSON Web Key. * @returns Resulting String. */ export(options: ExportOctKeyOptions<globalThis.BufferEncoding>): string; /** * Exports the data of the Octet Sequence JSON Web Key into a Buffer. * * @param options Options for exporting the data of the Octet Sequence JSON Web Key. * @returns Resulting Buffer. */ export(options: ExportOctKeyOptions<'buffer'>): Buffer; }