Files
Filip Skokan 8d9ece5c1a fix(types): correct JWK and CryptoKey types
Declare JWK shapes as aliases so they satisfy the implicit index
signatures used by host `JsonWebKey` types. Export the AKP variants,
add "oth", and exclude private members from embedded JWK headers.

Alias the host `CryptoKey` when available and use a checked fallback
otherwise, avoiding both a competing nominal type and an `any` result.
Narrow `KeyObject.type` to the values it can hold.

Signed-off-by: Filip Skokan <[email protected]>
2026-07-29 18:44:48 +02:00

1.5 KiB

Function: exportJWK()

💗 Help the project

Support from the community to continue maintaining and improving this module is welcome. If you find the module useful, please consider supporting the project by becoming a sponsor.

â–¸ exportJWK(key): Promise<JWK>

Exports a CryptoKey, KeyObject, or Uint8Array to a JWK.

This function is exported (as a named export) from the main 'jose' module entry point as well as from its subpath export 'jose/key/export'.

Parameters

Parameter Type Description
key Uint8Array | CryptoKey | KeyObject Key to export as JWK.

Returns

Promise<JWK>

Example

const privateJwk = await jose.exportJWK(privateKey)
const publicJwk = await jose.exportJWK(publicKey)

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