Skip to content

Commit d4ded39

Browse files
committed
chore(release): 6.0.9
1 parent 4ae905b commit d4ded39

File tree

181 files changed

+21541
-5
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

181 files changed

+21541
-5
lines changed

CHANGELOG.md

+18
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,24 @@
22

33
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
44

5+
## [6.0.9](https://github.com/panva/jose/compare/v6.0.8...v6.0.9) (2025-03-11)
6+
7+
8+
### Documentation
9+
10+
* add more symbol document, ignore ts-private fields ([8b73687](https://github.com/panva/jose/commit/8b73687595a7ca608aa1b78870b6b165ad5249f2))
11+
* bump typedoc ([6163a8b](https://github.com/panva/jose/commit/6163a8b6a773100ed31d207b598db1259a7e13a8))
12+
* drop cdnjs links in README ([a910038](https://github.com/panva/jose/commit/a9100383ab16cb62c375401fac08a77f3c6c528d))
13+
* drop denoland/x links in README and add jsr ([3662b9e](https://github.com/panva/jose/commit/3662b9ec44403bd501fc895bea4ded623d23e7e1))
14+
* fix key export links from docs/README.md ([c8edfc2](https://github.com/panva/jose/commit/c8edfc29416d3339f6c78fdc42bdfdfadaa5cf7e))
15+
16+
17+
### Refactor
18+
19+
* always assume structuredClone is present ([f7898a9](https://github.com/panva/jose/commit/f7898a9487508684dbbeba990e0cc96d344b1ff6))
20+
* hide internal private fields and drop ProduceJWT inheritance ([ab18881](https://github.com/panva/jose/commit/ab18881a57524897aec300c9bf7bbd73d9e3447c))
21+
* less objects when JWE JWT Replicated Header Parameters are used ([c763a0e](https://github.com/panva/jose/commit/c763a0e373b0e814dc4705dd2eb7daa614eae43a))
22+
523
## [6.0.8](https://github.com/panva/jose/compare/v6.0.7...v6.0.8) (2025-02-26)
624

725

dist/deno/README.md

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# `jose` API Documentation
2+
3+
`jose` is JavaScript module for JSON Object Signing and Encryption, providing support for JSON Web Tokens (JWT), JSON Web Signature (JWS), JSON Web Encryption (JWE), JSON Web Key (JWK), JSON Web Key Set (JWKS), and more. The module is designed to work across various Web-interoperable runtimes including Node.js, browsers, Cloudflare Workers, Deno, Bun, and others.
4+
5+
## Sponsor
6+
7+
<picture>
8+
<source media="(prefers-color-scheme: dark)" srcset="../sponsor/Auth0byOkta_dark.png">
9+
<source media="(prefers-color-scheme: light)" srcset="../sponsor/Auth0byOkta_light.png">
10+
<img height="65" align="left" alt="Auth0 by Okta" src="../sponsor/Auth0byOkta_light.png">
11+
</picture>
12+
13+
If you want to quickly add JWT authentication to JavaScript apps, feel free to check out Auth0's JavaScript SDK and free plan. [Create an Auth0 account; it's free!][sponsor-auth0]<br><br>
14+
15+
## [💗 Help the project](https://github.com/sponsors/panva)
16+
17+
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](https://github.com/sponsors/panva).
18+
19+
## Available modules
20+
21+
**`example`** Deno import
22+
```js
23+
import * as jose from 'https://deno.land/x/[email protected]/index.ts'
24+
```
25+
26+
### JSON Web Tokens (JWT)
27+
28+
The `jose` module supports JSON Web Tokens (JWT) and provides functionality for signing and verifying tokens, as well as their JWT Claims Set validation.
29+
30+
- [JWT Claims Set Validation & Signature Verification](https://github.com/panva/jose/blob/v6.0.9/docs/jwt/verify/functions/jwtVerify.md) using the `jwtVerify` function
31+
- [Using a remote JSON Web Key Set (JWKS)](https://github.com/panva/jose/blob/v6.0.9/docs/jwks/remote/functions/createRemoteJWKSet.md)
32+
- [Using a local JSON Web Key Set (JWKS)](https://github.com/panva/jose/blob/v6.0.9/docs/jwks/local/functions/createLocalJWKSet.md)
33+
- [Signing](https://github.com/panva/jose/blob/v6.0.9/docs/jwt/sign/classes/SignJWT.md) using the `SignJWT` class
34+
- Utility functions
35+
- [Decoding Token's Protected Header](https://github.com/panva/jose/blob/v6.0.9/docs/util/decode_protected_header/functions/decodeProtectedHeader.md)
36+
- [Decoding JWT Claims Set](https://github.com/panva/jose/blob/v6.0.9/docs/util/decode_jwt/functions/decodeJwt.md) prior to its validation
37+
38+
### Encrypted JSON Web Tokens
39+
40+
The `jose` module supports encrypted JSON Web Tokens and provides functionality for encrypting and decrypting tokens, as well as their JWT Claims Set validation.
41+
42+
- [Decryption & JWT Claims Set Validation](https://github.com/panva/jose/blob/v6.0.9/docs/jwt/decrypt/functions/jwtDecrypt.md) using the `jwtDecrypt` function
43+
- [Encryption](https://github.com/panva/jose/blob/v6.0.9/docs/jwt/encrypt/classes/EncryptJWT.md) using the `EncryptJWT` class
44+
- Utility functions
45+
- [Decoding Token's Protected Header](https://github.com/panva/jose/blob/v6.0.9/docs/util/decode_protected_header/functions/decodeProtectedHeader.md)
46+
47+
### Key Utilities
48+
49+
The `jose` module supports importing, exporting, and generating keys and secrets in various formats, including PEM formats like SPKI, X.509 certificate, and PKCS #8, as well as JSON Web Key (JWK).
50+
51+
- Key Import Functions
52+
- [JWK Import](https://github.com/panva/jose/blob/v6.0.9/docs/key/import/functions/importJWK.md)
53+
- [Public Key Import (SPKI)](https://github.com/panva/jose/blob/v6.0.9/docs/key/import/functions/importSPKI.md)
54+
- [Public Key Import (X.509 Certificate)](https://github.com/panva/jose/blob/v6.0.9/docs/key/import/functions/importX509.md)
55+
- [Private Key Import (PKCS #8)](https://github.com/panva/jose/blob/v6.0.9/docs/key/import/functions/importPKCS8.md)
56+
- Key and Secret Generation Functions
57+
- [Asymmetric Key Pair Generation](https://github.com/panva/jose/blob/v6.0.9/docs/key/generate_key_pair/functions/generateKeyPair.md)
58+
- [Symmetric Secret Generation](https://github.com/panva/jose/blob/v6.0.9/docs/key/generate_secret/functions/generateSecret.md)
59+
- Key Export Functions
60+
- [JWK Export](https://github.com/panva/jose/blob/v6.0.9/docs/key/export/functions/exportJWK.md)
61+
- [Private Key Export](https://github.com/panva/jose/blob/v6.0.9/docs/key/export/functions/exportPKCS8.md)
62+
- [Public Key Export](https://github.com/panva/jose/blob/v6.0.9/docs/key/export/functions/exportSPKI.md)
63+
64+
### JSON Web Signature (JWS)
65+
66+
The `jose` module supports signing and verification of JWS messages with arbitrary payloads in Compact, Flattened JSON, and General JSON serialization syntaxes.
67+
68+
- Signing - [Compact](https://github.com/panva/jose/blob/v6.0.9/docs/jws/compact/sign/classes/CompactSign.md), [Flattened JSON](https://github.com/panva/jose/blob/v6.0.9/docs/jws/flattened/sign/classes/FlattenedSign.md), [General JSON](https://github.com/panva/jose/blob/v6.0.9/docs/jws/general/sign/classes/GeneralSign.md)
69+
- Verification - [Compact](https://github.com/panva/jose/blob/v6.0.9/docs/jws/compact/verify/functions/compactVerify.md), [Flattened JSON](https://github.com/panva/jose/blob/v6.0.9/docs/jws/flattened/verify/functions/flattenedVerify.md), [General JSON](https://github.com/panva/jose/blob/v6.0.9/docs/jws/general/verify/functions/generalVerify.md)
70+
- [Using a remote JSON Web Key Set (JWKS)](https://github.com/panva/jose/blob/v6.0.9/docs/jwks/remote/functions/createRemoteJWKSet.md)
71+
- [Using a local JSON Web Key Set (JWKS)](https://github.com/panva/jose/blob/v6.0.9/docs/jwks/local/functions/createLocalJWKSet.md)
72+
- Utility functions
73+
- [Decoding Token's Protected Header](https://github.com/panva/jose/blob/v6.0.9/docs/util/decode_protected_header/functions/decodeProtectedHeader.md)
74+
75+
### JSON Web Encryption (JWE)
76+
77+
The `jose` module supports encryption and decryption of JWE messages with arbitrary plaintext in Compact, Flattened JSON, and General JSON serialization syntaxes.
78+
79+
- Encryption - [Compact](https://github.com/panva/jose/blob/v6.0.9/docs/jwe/compact/encrypt/classes/CompactEncrypt.md), [Flattened JSON](https://github.com/panva/jose/blob/v6.0.9/docs/jwe/flattened/encrypt/classes/FlattenedEncrypt.md), [General JSON](https://github.com/panva/jose/blob/v6.0.9/docs/jwe/general/encrypt/classes/GeneralEncrypt.md)
80+
- Decryption - [Compact](https://github.com/panva/jose/blob/v6.0.9/docs/jwe/compact/decrypt/functions/compactDecrypt.md), [Flattened JSON](https://github.com/panva/jose/blob/v6.0.9/docs/jwe/flattened/decrypt/functions/flattenedDecrypt.md), [General JSON](https://github.com/panva/jose/blob/v6.0.9/docs/jwe/general/decrypt/functions/generalDecrypt.md)
81+
- Utility functions
82+
- [Decoding Token's Protected Header](https://github.com/panva/jose/blob/v6.0.9/docs/util/decode_protected_header/functions/decodeProtectedHeader.md)
83+
84+
### Other
85+
86+
The following are additional features and utilities provided by the `jose` module:
87+
88+
- [Calculating JWK Thumbprint](https://github.com/panva/jose/blob/v6.0.9/docs/jwk/thumbprint/functions/calculateJwkThumbprint.md)
89+
- [Calculating JWK Thumbprint URI](https://github.com/panva/jose/blob/v6.0.9/docs/jwk/thumbprint/functions/calculateJwkThumbprintUri.md)
90+
- [Verification using a JWK Embedded in a JWS Header](https://github.com/panva/jose/blob/v6.0.9/docs/jwk/embedded/functions/EmbeddedJWK.md)
91+
- [Unsecured JWT](https://github.com/panva/jose/blob/v6.0.9/docs/jwt/unsecured/classes/UnsecuredJWT.md)
92+
- [JOSE Errors](https://github.com/panva/jose/blob/v6.0.9/docs/util/errors/README.md)
93+
94+
[sponsor-auth0]: https://a0.to/signup/panva
95+
96+
[^cjs]: CJS style `let jose = require('jose')` is possible in Node.js versions where `process.features.require_module` is `true` or with the `--experimental-require-module` Node.js CLI flag.

dist/deno/index.ts

+118
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
export { compactDecrypt } from './jwe/compact/decrypt.ts'
2+
export type { CompactDecryptGetKey } from './jwe/compact/decrypt.ts'
3+
export { flattenedDecrypt } from './jwe/flattened/decrypt.ts'
4+
export type { FlattenedDecryptGetKey } from './jwe/flattened/decrypt.ts'
5+
export { generalDecrypt } from './jwe/general/decrypt.ts'
6+
export type { GeneralDecryptGetKey } from './jwe/general/decrypt.ts'
7+
export { GeneralEncrypt } from './jwe/general/encrypt.ts'
8+
export type { Recipient } from './jwe/general/encrypt.ts'
9+
10+
export { compactVerify } from './jws/compact/verify.ts'
11+
export type { CompactVerifyGetKey } from './jws/compact/verify.ts'
12+
export { flattenedVerify } from './jws/flattened/verify.ts'
13+
export type { FlattenedVerifyGetKey } from './jws/flattened/verify.ts'
14+
export { generalVerify } from './jws/general/verify.ts'
15+
export type { GeneralVerifyGetKey } from './jws/general/verify.ts'
16+
17+
export { jwtVerify } from './jwt/verify.ts'
18+
export type { JWTVerifyOptions, JWTVerifyGetKey } from './jwt/verify.ts'
19+
export { jwtDecrypt } from './jwt/decrypt.ts'
20+
export type { JWTDecryptOptions, JWTDecryptGetKey } from './jwt/decrypt.ts'
21+
22+
export { CompactEncrypt } from './jwe/compact/encrypt.ts'
23+
export { FlattenedEncrypt } from './jwe/flattened/encrypt.ts'
24+
25+
export { CompactSign } from './jws/compact/sign.ts'
26+
export { FlattenedSign } from './jws/flattened/sign.ts'
27+
export { GeneralSign } from './jws/general/sign.ts'
28+
export type { Signature } from './jws/general/sign.ts'
29+
30+
export { SignJWT } from './jwt/sign.ts'
31+
export { EncryptJWT } from './jwt/encrypt.ts'
32+
33+
export { calculateJwkThumbprint, calculateJwkThumbprintUri } from './jwk/thumbprint.ts'
34+
export { EmbeddedJWK } from './jwk/embedded.ts'
35+
36+
export { createLocalJWKSet } from './jwks/local.ts'
37+
export { createRemoteJWKSet, jwksCache, customFetch } from './jwks/remote.ts'
38+
export type {
39+
RemoteJWKSetOptions,
40+
JWKSCacheInput,
41+
ExportedJWKSCache,
42+
FetchImplementation,
43+
} from './jwks/remote.ts'
44+
45+
export { UnsecuredJWT } from './jwt/unsecured.ts'
46+
export type { UnsecuredResult } from './jwt/unsecured.ts'
47+
48+
export { exportPKCS8, exportSPKI, exportJWK } from './key/export.ts'
49+
50+
export { importSPKI, importPKCS8, importX509, importJWK } from './key/import.ts'
51+
export type { KeyImportOptions } from './key/import.ts'
52+
53+
export { decodeProtectedHeader } from './util/decode_protected_header.ts'
54+
export { decodeJwt } from './util/decode_jwt.ts'
55+
export type { ProtectedHeaderParameters } from './util/decode_protected_header.ts'
56+
57+
export * as errors from './util/errors.ts'
58+
59+
export { generateKeyPair } from './key/generate_key_pair.ts'
60+
export type { GenerateKeyPairResult, GenerateKeyPairOptions } from './key/generate_key_pair.ts'
61+
export { generateSecret } from './key/generate_secret.ts'
62+
export type { GenerateSecretOptions } from './key/generate_secret.ts'
63+
64+
export * as base64url from './util/base64url.ts'
65+
66+
export type {
67+
CompactDecryptResult,
68+
CompactJWEHeaderParameters,
69+
CompactJWSHeaderParameters,
70+
CompactVerifyResult,
71+
CritOption,
72+
CryptoKey,
73+
DecryptOptions,
74+
EncryptOptions,
75+
FlattenedDecryptResult,
76+
FlattenedJWE,
77+
FlattenedJWS,
78+
FlattenedJWSInput,
79+
FlattenedVerifyResult,
80+
GeneralDecryptResult,
81+
GeneralJWE,
82+
GeneralJWS,
83+
GeneralJWSInput,
84+
GeneralVerifyResult,
85+
GetKeyFunction,
86+
JoseHeaderParameters,
87+
JSONWebKeySet,
88+
JWEHeaderParameters,
89+
JWEKeyManagementHeaderParameters,
90+
JWK_EC_Private,
91+
JWK_EC_Public,
92+
JWK_oct,
93+
JWK_OKP_Private,
94+
JWK_OKP_Public,
95+
JWK_RSA_Private,
96+
JWK_RSA_Public,
97+
JWK,
98+
JWKParameters,
99+
JWSHeaderParameters,
100+
JWTClaimVerificationOptions,
101+
JWTDecryptResult,
102+
JWTHeaderParameters,
103+
JWTPayload,
104+
JWTVerifyResult,
105+
KeyObject,
106+
ProduceJWT,
107+
ResolvedKey,
108+
SignOptions,
109+
VerifyOptions,
110+
} from './types.d.ts'
111+
112+
/**
113+
* In prior releases this indicated whether a Node.js-specific build was loaded, this is now fixed
114+
* to `"WebCryptoAPI"`
115+
*
116+
* @deprecated
117+
*/
118+
export const cryptoRuntime = 'WebCryptoAPI'

dist/deno/jwe/compact/decrypt.ts

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
/**
2+
* Decrypting JSON Web Encryption (JWE) in Compact Serialization
3+
*
4+
* @module
5+
*/
6+
7+
import { flattenedDecrypt } from '../flattened/decrypt.ts'
8+
import { JWEInvalid } from '../../util/errors.ts'
9+
import { decoder } from '../../lib/buffer_utils.ts'
10+
import type * as types from '../../types.d.ts'
11+
12+
/**
13+
* Interface for Compact JWE Decryption dynamic key resolution. No token components have been
14+
* verified at the time of this function call.
15+
*/
16+
export interface CompactDecryptGetKey
17+
extends types.GetKeyFunction<types.CompactJWEHeaderParameters, types.FlattenedJWE> {}
18+
19+
/**
20+
* Decrypts a Compact JWE.
21+
*
22+
* This function is exported (as a named export) from the main `'jose'` module entry point as well
23+
* as from its subpath export `'jose/jwe/compact/decrypt'`.
24+
*
25+
* @param jwe Compact JWE.
26+
* @param key Private Key or Secret to decrypt the JWE with. See
27+
* {@link https://github.com/panva/jose/issues/210#jwe-alg Algorithm Key Requirements}.
28+
* @param options JWE Decryption options.
29+
*/
30+
export async function compactDecrypt(
31+
jwe: string | Uint8Array,
32+
key: types.CryptoKey | types.KeyObject | types.JWK | Uint8Array,
33+
options?: types.DecryptOptions,
34+
): Promise<types.CompactDecryptResult>
35+
/**
36+
* @param jwe Compact JWE.
37+
* @param getKey Function resolving Private Key or Secret to decrypt the JWE with. See
38+
* {@link https://github.com/panva/jose/issues/210#jwe-alg Algorithm Key Requirements}.
39+
* @param options JWE Decryption options.
40+
*/
41+
export async function compactDecrypt(
42+
jwe: string | Uint8Array,
43+
getKey: CompactDecryptGetKey,
44+
options?: types.DecryptOptions,
45+
): Promise<types.CompactDecryptResult & types.ResolvedKey>
46+
export async function compactDecrypt(
47+
jwe: string | Uint8Array,
48+
key: types.CryptoKey | types.KeyObject | types.JWK | Uint8Array | CompactDecryptGetKey,
49+
options?: types.DecryptOptions,
50+
) {
51+
if (jwe instanceof Uint8Array) {
52+
jwe = decoder.decode(jwe)
53+
}
54+
55+
if (typeof jwe !== 'string') {
56+
throw new JWEInvalid('Compact JWE must be a string or Uint8Array')
57+
}
58+
const {
59+
0: protectedHeader,
60+
1: encryptedKey,
61+
2: iv,
62+
3: ciphertext,
63+
4: tag,
64+
length,
65+
} = jwe.split('.')
66+
67+
if (length !== 5) {
68+
throw new JWEInvalid('Invalid Compact JWE')
69+
}
70+
71+
const decrypted = await flattenedDecrypt(
72+
{
73+
ciphertext,
74+
iv: iv || undefined,
75+
protected: protectedHeader,
76+
tag: tag || undefined,
77+
encrypted_key: encryptedKey || undefined,
78+
},
79+
key as Parameters<typeof flattenedDecrypt>[1],
80+
options,
81+
)
82+
83+
const result = { plaintext: decrypted.plaintext, protectedHeader: decrypted.protectedHeader! }
84+
85+
if (typeof key === 'function') {
86+
return { ...result, key: decrypted.key }
87+
}
88+
89+
return result
90+
}

0 commit comments

Comments
 (0)