import { Key } from "../Key"; import { JWK as _JWK } from "./JWK"; import { PrivateKey } from "../PrivateKey"; import { PublicKey } from "../PublicKey"; /** * ExportableKey defines the formats a crypographic key can be converted to * Default is all */ export type ExportableKey = ExportableKey.All; /** * Factory options to customise export / import functions */ interface Options { pemLabel: string; } /** * Declaration merge to contain key conversion functions */ export declare namespace ExportableKey { type All = Common & JWK & PEM; interface Common { to: { Buffer: () => Buffer; String: (encoding?: BufferEncoding) => string; }; } interface JWK { to: { JWK: (base?: _JWK.Base) => _JWK; }; } interface PEM { to: { PEM: () => string; }; } /** * factory to create Key property with desired functions * which allow converting the Key raw into different formats * * @param key * @param opts * @returns object with exportable functions */ const factory: (key: PublicKey | PrivateKey, opts: Options) => { Buffer: () => Buffer; Hex: () => string; JWK: (base?: _JWK.Base) => _JWK; PEM: () => string; String: (encoding?: BufferEncoding) => string; }; } export declare namespace ImportableKey { /** * factory to create Key property with desired functions * allows creation of a given Key through different data types * * @param ctor - the Key Class * @param opts * @returns object with importable functions */ const factory: (ctor: { new (bytes: any): T; }, opts: Options) => { Buffer: (value: Buffer) => T; Hex: (value: string) => T; PEM: (value: string) => T; String: (value: string, encoding?: BufferEncoding) => T; }; } export {};