Skip to main content
Module

x/jose/index.ts>importSPKI

"JSON Web Almost Everything" - JWA, JWS, JWE, JWT, JWK, JWKS for Node.js, Browser, Cloudflare Workers, Deno, Bun, and other Web-interoperable runtimes.
Extremely Popular
Go to Latest
function importSPKI
import { importSPKI } from "https://deno.land/x/jose@v4.12.1/index.ts";

Imports a PEM-encoded SPKI string as a runtime-specific public key representation (KeyObject or CryptoKey). See Algorithm Key Requirements to learn about key to algorithm requirements and mapping.

Examples

Usage

const algorithm = 'ES256'
const spki = `-----BEGIN PUBLIC KEY-----
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEFlHHWfLk0gLBbsLTcuCrbCqoHqmM
YJepMC+Q+Dd6RBmBiA41evUsNMwLeN+PNFqib+xwi9JkJ8qhZkq8Y/IzGg==
-----END PUBLIC KEY-----`
const ecPublicKey = await jose.importSPKI(spki, algorithm)

Parameters

spki: string

PEM-encoded SPKI string

alg: string

(Only effective in Web Crypto API runtimes) JSON Web Algorithm identifier to be used with the imported key, its presence is only enforced in Web Crypto API runtimes.

optional
options: PEMImportOptions