mirror of
https://github.com/hanzoai/jose.git
synced 2026-09-24 17:00:01 +00:00
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]>
1.5 KiB
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
Example
const privateJwk = await jose.exportJWK(privateKey)
const publicJwk = await jose.exportJWK(publicKey)
console.log(privateJwk)
console.log(publicJwk)