Skip to main content
Module

x/fido2/lib/toolbox.js>importJWK

A node.js library for performing FIDO 2.0 / WebAuthn server functionality
Go to Latest
function importJWK
Re-export
import { importJWK } from "https://deno.land/x/fido2@3.2.5/lib/toolbox.js";

Imports a JWK to a runtime-specific key representation (KeyLike). Either JWK "alg" (Algorithm) Parameter must be present or the optional "alg" argument. When running on a runtime using Web Cryptography API the jwk parameters "use", "key_ops", and "ext" are also used in the resulting CryptoKey. See Algorithm Key Requirements to learn about key to algorithm requirements and mapping.

Examples

Usage

const ecPublicKey = await jose.importJWK({
  crv: 'P-256',
  kty: 'EC',
  x: 'ySK38C1jBdLwDsNWKzzBHqKYEE5Cgv-qjWvorUXk9fw',
  y: '_LeQBw07cf5t57Iavn4j-BqJsAD1dpoz8gokd3sBsOo'
}, 'ES256')

const rsaPublicKey = await jose.importJWK({
  kty: 'RSA',
  e: 'AQAB',
  n: '12oBZRhCiZFJLcPg59LkZZ9mdhSMTKAQZYq32k_ti5SBB6jerkh-WzOMAO664r_qyLkqHUSp3u5SbXtseZEpN3XPWGKSxjsy-1JyEFTdLSYe6f9gfrmxkUF_7DTpq0gn6rntP05g2-wFW50YO7mosfdslfrTJYWHFhJALabAeYirYD7-9kqq9ebfFMF4sRRELbv9oi36As6Q9B3Qb5_C1rAzqfao_PCsf9EPsTZsVVVkA5qoIAr47lo1ipfiBPxUCCNSdvkmDTYgvvRm6ZoMjFbvOtgyts55fXKdMWv7I9HMD5HwE9uW839PWA514qhbcIsXEYSFMPMV6fnlsiZvQQ'
}, 'PS256')

Parameters

jwk: JWK

JSON Web Key.

optional
alg: string

JSON Web Algorithm identifier to be used with the imported key. Default is the "alg" property on the JWK.

optional
octAsKeyObject: boolean

Forces a symmetric key to be imported to a KeyObject or CryptoKey. Default is true unless JWK "ext" (Extractable) is true.

Returns

Promise<KeyLike | Uint8Array>