Skip to main content
webcrypto.SubtleCrypto.importKey - node__crypto.d.ts - Node documentation
method webcrypto.SubtleCrypto.importKey

Usage in Deno

```typescript import { type webcrypto } from "node:node__crypto.d.ts"; ```
SubtleCrypto.importKey(
format: "jwk",
keyData: JsonWebKey,
extractable: boolean,
keyUsages: readonly KeyUsage[],
): Promise<CryptoKey>
The `subtle.importKey()` method attempts to interpret the provided `keyData` as the given `format` to create a `` instance using the provided `algorithm`, `extractable`, and `keyUsages` arguments. If the import is successful, the returned promise will be resolved with the created ``. If importing a `'PBKDF2'` key, `extractable` must be `false`.

Parameters

format: "jwk"
Must be one of `'raw'`, `'pkcs8'`, `'spki'`, or `'jwk'`.
keyData: JsonWebKey
extractable: boolean
keyUsages: readonly KeyUsage[]
See [Key usages](https://nodejs.org/docs/latest/api/webcrypto.html#cryptokeyusages).

Return Type

Promise<CryptoKey>
SubtleCrypto.importKey(
format: Exclude<KeyFormat, "jwk">,
keyData: BufferSource,
extractable: boolean,
keyUsages: KeyUsage[],
): Promise<CryptoKey>

Parameters

format: Exclude<KeyFormat, "jwk">
keyData: BufferSource
extractable: boolean
keyUsages: KeyUsage[]

Return Type

Promise<CryptoKey>