jose/docs/functions/_jwk_from_key_like_.fromkeylike.md
2020-12-16 18:45:02 +01:00

922 B

Function: fromKeyLike

fromKeyLike(key: KeyLike): Promise<JWK>

Defined in src/jwk/from_key_like.ts:32

Converts a runtime-specific key representation (KeyLike) to a JWK.

example

// ESM import
import fromKeyLike from 'jose/jwk/from_key_like'

example

// CJS import
const { default: fromKeyLike } = require('jose/jwk/from_key_like')

example

// usage
const privateJwk = fromKeyLike(privateKey)
const publicJwk = fromKeyLike(publicKey)

console.log(privateJwk)
console.log(publicJwk)

Parameters:

Name Type Description
key KeyLike Key representation to transform to a JWK.

Returns: Promise<JWK>