import { PublicKey } from "https://deno.land/x/fido2@3.5.3/lib/keyUtils.js";
Class representing a generic public key, with utility functions to convert between different formats using Webcrypto
Methods
Import public key from COSE data. Throws on any type of failure.
Internally this function converts COSE to a JWK, then calls .fromJwk() to import key to CryptoKey
Import a CryptoKey, makes basic checks and throws on failure
Import public key from JWK. Throws on any type of failure.
Import public key from SPKI PEM. Throws on any type of failure.
Returns internal algorithm, which should be of one of the following formats
- RsaHashedImportParams
- EcKeyImportParams
- undefined
Returns internal key in CryptoKey format
- Mainly intended for internal use
- Throws if internal CryptoKey does not exist
Sets internal algorithm identifier in format used by webcrypto, should be one of
- Allows adding missing properties
- Makes sure
alg.hash
is is{ hash: { name: 'foo'} }
format - Syncs back updated algorithm to this._key
Exports public key to COSE data
- Only works if original cose data from 'fromCose()' is available
- Throws on any kind of failure
Exports public key to JWK.
- Only works if original jwk from 'fromJwk()' is available
- Throws on any kind of failure
Exports public key to PEM.
- Reuses original PEM string if present.
- Possible to force regeneration of PEM string by setting 'forcedExport' parameter to true
- Throws on any kind of failure