/// declare type coseMap = Map; declare type jwk = { kty?: string; use?: string; key_ops?: string[]; alg?: string; kid?: string; x5u?: string; x5c?: string[]; x5t?: string; 'x5t#S256'?: string; crv?: string; x?: string; y?: string; d?: string; n?: string; e?: string; p?: string; q?: string; dp?: string; dq?: string; qi?: string; oth?: { r?: string; d?: string; t?: string; }[]; k?: string; ext?: boolean; [key: string]: unknown; }; declare type pem = string; declare type pemType = 'PUBLIC KEY' | 'PRIVATE KEY'; /** * Parse between JSON Web Key (JWK), CBOR Object Signing and Encryption (COSE) and PEM. */ declare class KeyParser { static readonly BUFFER_TYPE_COSE_KEY_PARAMETER_NAME: string[]; private constructor(); private static findCoseKeyAllParameterFromLabel; private static findCoseKeyParameterValueFromLabel; private static findJSONWebKeyParameterFromName; private static findJSONWebKeyParameterValueFromValue; private static convertCoseJoseValue; private static convertJoseCoseKey; private static convertJoseCoseValue; /** * Parse COSE key to JWK format. * * @param coseMap COSE key * @returns JWK */ static cose2jwk(coseMap: coseMap): jwk; /** * Parse JWK to COSE key. * * @param jwk JWK * @returns COSE key */ static jwk2cose(jwk: jwk): coseMap; /** * Parse JWK to PEM. * * @param jwk JWK * @returns PEM */ static jwk2pem(jwk: jwk): Promise; /** * Parse PEM to JWK. * * This method's parameter `alg` is specified in JWK's "alg" parameter ({@link https://www.iana.org/assignments/jose/jose.xhtml#web-signature-encryption-algorithms | here} is registry). * * @param pem PEM * @param alg JWK's "alg" parameter * @returns JWK */ static pem2jwk(pem: pem, alg?: string): Promise; /** * Parse COSE key to PEM. * * @param coseMap COSE key * @returns PEM */ static cose2pem(coseMap: coseMap): Promise; /** * Parse PEM to COSE key. * * This method's parameter `alg` is specified in JWK's "alg" parameter ({@link https://www.iana.org/assignments/jose/jose.xhtml#web-signature-encryption-algorithms | here} is registry). * * @param pem PEM * @param alg Key algorithm, specified with JWK's "alg" parameter * @returns COSE key */ static pem2cose(pem: string, alg?: string): Promise; /** * Parse attestation object in webauthn to JWK. * * @param attObj Attestation object * @returns JWK */ static attestationObject2jwk(attObj: Buffer): jwk; /** * Parse DER format key to PEM format. * * @param type Key type * @param der DER format key * @returns PEM format key */ static der2pem(type: pemType, der: Buffer): string; /** * Parse PEM format key to DER format. * * @param pem PEM format key * @returns DER format key */ static pem2der(pem: pem): Buffer; } export default KeyParser;