jose 4.8.3 → 4.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -3
- package/dist/browser/index.js +1 -1
- package/dist/browser/jwe/flattened/decrypt.js +3 -3
- package/dist/browser/jwk/thumbprint.js +7 -1
- package/dist/browser/jws/flattened/verify.js +1 -1
- package/dist/browser/lib/decrypt_key_management.js +4 -1
- package/dist/node/cjs/index.js +2 -1
- package/dist/node/cjs/jwe/flattened/decrypt.js +3 -3
- package/dist/node/cjs/jwk/thumbprint.js +9 -2
- package/dist/node/cjs/jws/flattened/verify.js +1 -1
- package/dist/node/cjs/lib/decrypt_key_management.js +4 -1
- package/dist/node/cjs/runtime/key_to_jwk.js +4 -0
- package/dist/node/esm/index.js +1 -1
- package/dist/node/esm/jwe/flattened/decrypt.js +3 -3
- package/dist/node/esm/jwk/thumbprint.js +7 -1
- package/dist/node/esm/jws/flattened/verify.js +1 -1
- package/dist/node/esm/lib/decrypt_key_management.js +4 -1
- package/dist/node/esm/runtime/key_to_jwk.js +4 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/jwe/compact/decrypt.d.ts +9 -7
- package/dist/types/jwe/compact/encrypt.d.ts +14 -20
- package/dist/types/jwe/flattened/decrypt.d.ts +12 -13
- package/dist/types/jwe/flattened/encrypt.d.ts +17 -26
- package/dist/types/jwe/general/decrypt.d.ts +13 -14
- package/dist/types/jwe/general/encrypt.d.ts +6 -15
- package/dist/types/jwk/embedded.d.ts +8 -7
- package/dist/types/jwk/thumbprint.d.ts +30 -7
- package/dist/types/jwks/local.d.ts +12 -15
- package/dist/types/jwks/remote.d.ts +22 -36
- package/dist/types/jws/compact/sign.d.ts +3 -6
- package/dist/types/jws/compact/verify.d.ts +11 -8
- package/dist/types/jws/flattened/sign.d.ts +3 -6
- package/dist/types/jws/flattened/verify.d.ts +12 -9
- package/dist/types/jws/general/sign.d.ts +7 -18
- package/dist/types/jws/general/verify.d.ts +14 -11
- package/dist/types/jwt/decrypt.d.ts +13 -12
- package/dist/types/jwt/encrypt.d.ts +15 -18
- package/dist/types/jwt/produce.d.ts +9 -14
- package/dist/types/jwt/sign.d.ts +2 -2
- package/dist/types/jwt/unsecured.d.ts +4 -4
- package/dist/types/jwt/verify.d.ts +15 -13
- package/dist/types/key/export.d.ts +13 -8
- package/dist/types/key/generate_key_pair.d.ts +14 -19
- package/dist/types/key/generate_secret.d.ts +3 -2
- package/dist/types/key/import.d.ts +50 -39
- package/dist/types/types.d.ts +203 -371
- package/dist/types/util/decode_jwt.d.ts +7 -6
- package/dist/types/util/decode_protected_header.d.ts +3 -2
- package/dist/types/util/errors.d.ts +20 -61
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -12,6 +12,7 @@ The following specifications are implemented by `jose`
|
|
|
12
12
|
- JSON Web Algorithms (JWA) - [RFC7518][spec-jwa]
|
|
13
13
|
- JSON Web Token (JWT) - [RFC7519][spec-jwt]
|
|
14
14
|
- JSON Web Key Thumbprint - [RFC7638][spec-thumbprint]
|
|
15
|
+
- JSON Web Key Thumbprint URI - [RFC9278][spec-thumbprint-uri]
|
|
15
16
|
- JWS Unencoded Payload Option - [RFC7797][spec-b64]
|
|
16
17
|
- CFRG Elliptic Curve ECDH and Signatures - [RFC8037][spec-okp]
|
|
17
18
|
- secp256k1 EC Key curve support - [JOSE Registrations for WebAuthn Algorithms][spec-secp256k1]
|
|
@@ -56,8 +57,9 @@ import * as jose from 'https://deno.land/x/jose/index.ts'
|
|
|
56
57
|
- Signing - [Compact](docs/classes/jws_compact_sign.CompactSign.md#readme), [Flattened](docs/classes/jws_flattened_sign.FlattenedSign.md#readme), [General](docs/classes/jws_general_sign.GeneralSign.md#readme)
|
|
57
58
|
- Verification - [Compact](docs/functions/jws_compact_verify.compactVerify.md#readme), [Flattened](docs/functions/jws_flattened_verify.flattenedVerify.md#readme), [General](docs/functions/jws_general_verify.generalVerify.md#readme)
|
|
58
59
|
- JSON Web Key (JWK)
|
|
59
|
-
- [
|
|
60
|
-
- [
|
|
60
|
+
- [Calculating JWK Thumbprint](docs/functions/jwk_thumbprint.calculateJwkThumbprint.md#readme)
|
|
61
|
+
- [Calculating JWK Thumbprint URI](docs/functions/jwk_thumbprint.calculateJwkThumbprintUri.md#readme)
|
|
62
|
+
- [Verification using a JWK Embedded in a JWS Header](docs/functions/jwk_embedded.EmbeddedJWK.md#readme)
|
|
61
63
|
- JSON Web Key Set (JWKS)
|
|
62
64
|
- [Verify using a local JWKSet](docs/functions/jwks_local.createLocalJWKSet.md#readme)
|
|
63
65
|
- [Verify using a remote JWKSet](docs/functions/jwks_remote.createRemoteJWKSet.md#readme)
|
|
@@ -104,7 +106,7 @@ import * as jose from 'https://deno.land/x/jose/index.ts'
|
|
|
104
106
|
- it supports JWK Key Format for all four key types (oct, RSA, EC and OKP)
|
|
105
107
|
- it is exclusively using native platform Key object representations (CryptoKey and KeyObject)
|
|
106
108
|
- there is JSON Web Encryption support
|
|
107
|
-
- it supports the
|
|
109
|
+
- it supports the General and Flattened JSON Serialization Syntaxes
|
|
108
110
|
- it supports the "crit" member validations to make sure extensions are handled correctly
|
|
109
111
|
|
|
110
112
|
#### How is it different from [`node-jose`](https://github.com/cisco/node-jose)?
|
|
@@ -142,6 +144,7 @@ install size should not be a cause for concern.
|
|
|
142
144
|
[spec-okp]: https://www.rfc-editor.org/rfc/rfc8037
|
|
143
145
|
[spec-secp256k1]: https://www.rfc-editor.org/rfc/rfc8812
|
|
144
146
|
[spec-thumbprint]: https://www.rfc-editor.org/rfc/rfc7638
|
|
147
|
+
[spec-thumbprint-uri]: https://www.rfc-editor.org/rfc/rfc9278
|
|
145
148
|
[support-sponsor]: https://github.com/sponsors/panva
|
|
146
149
|
[conditional-exports]: https://nodejs.org/api/packages.html#packages_conditional_exports
|
|
147
150
|
[webcrypto]: https://www.w3.org/TR/WebCryptoAPI/
|
package/dist/browser/index.js
CHANGED
|
@@ -14,7 +14,7 @@ export { FlattenedSign } from './jws/flattened/sign.js';
|
|
|
14
14
|
export { GeneralSign } from './jws/general/sign.js';
|
|
15
15
|
export { SignJWT } from './jwt/sign.js';
|
|
16
16
|
export { EncryptJWT } from './jwt/encrypt.js';
|
|
17
|
-
export { calculateJwkThumbprint } from './jwk/thumbprint.js';
|
|
17
|
+
export { calculateJwkThumbprint, calculateJwkThumbprintUri } from './jwk/thumbprint.js';
|
|
18
18
|
export { EmbeddedJWK } from './jwk/embedded.js';
|
|
19
19
|
export { createLocalJWKSet } from './jwks/local.js';
|
|
20
20
|
export { createRemoteJWKSet } from './jwks/remote.js';
|
|
@@ -43,8 +43,8 @@ export async function flattenedDecrypt(jwe, key, options) {
|
|
|
43
43
|
}
|
|
44
44
|
let parsedProt;
|
|
45
45
|
if (jwe.protected) {
|
|
46
|
-
const protectedHeader = base64url(jwe.protected);
|
|
47
46
|
try {
|
|
47
|
+
const protectedHeader = base64url(jwe.protected);
|
|
48
48
|
parsedProt = JSON.parse(decoder.decode(protectedHeader));
|
|
49
49
|
}
|
|
50
50
|
catch (_b) {
|
|
@@ -95,10 +95,10 @@ export async function flattenedDecrypt(jwe, key, options) {
|
|
|
95
95
|
}
|
|
96
96
|
let cek;
|
|
97
97
|
try {
|
|
98
|
-
cek = await decryptKeyManagement(alg, key, encryptedKey, joseHeader);
|
|
98
|
+
cek = await decryptKeyManagement(alg, key, encryptedKey, joseHeader, options);
|
|
99
99
|
}
|
|
100
100
|
catch (err) {
|
|
101
|
-
if (err instanceof TypeError) {
|
|
101
|
+
if (err instanceof TypeError || err instanceof JWEInvalid || err instanceof JOSENotSupported) {
|
|
102
102
|
throw err;
|
|
103
103
|
}
|
|
104
104
|
cek = generateCek(enc);
|
|
@@ -8,10 +8,11 @@ const check = (value, description) => {
|
|
|
8
8
|
throw new JWKInvalid(`${description} missing or invalid`);
|
|
9
9
|
}
|
|
10
10
|
};
|
|
11
|
-
export async function calculateJwkThumbprint(jwk, digestAlgorithm
|
|
11
|
+
export async function calculateJwkThumbprint(jwk, digestAlgorithm) {
|
|
12
12
|
if (!isObject(jwk)) {
|
|
13
13
|
throw new TypeError('JWK must be an object');
|
|
14
14
|
}
|
|
15
|
+
digestAlgorithm !== null && digestAlgorithm !== void 0 ? digestAlgorithm : (digestAlgorithm = 'sha256');
|
|
15
16
|
if (digestAlgorithm !== 'sha256' &&
|
|
16
17
|
digestAlgorithm !== 'sha384' &&
|
|
17
18
|
digestAlgorithm !== 'sha512') {
|
|
@@ -45,3 +46,8 @@ export async function calculateJwkThumbprint(jwk, digestAlgorithm = 'sha256') {
|
|
|
45
46
|
const data = encoder.encode(JSON.stringify(components));
|
|
46
47
|
return base64url(await digest(digestAlgorithm, data));
|
|
47
48
|
}
|
|
49
|
+
export async function calculateJwkThumbprintUri(jwk, digestAlgorithm) {
|
|
50
|
+
digestAlgorithm !== null && digestAlgorithm !== void 0 ? digestAlgorithm : (digestAlgorithm = 'sha256');
|
|
51
|
+
const thumbprint = await calculateJwkThumbprint(jwk, digestAlgorithm);
|
|
52
|
+
return `urn:ietf:params:oauth:jwk-thumbprint:sha-${digestAlgorithm.slice(-3)}:${thumbprint}`;
|
|
53
|
+
}
|
|
@@ -29,8 +29,8 @@ export async function flattenedVerify(jws, key, options) {
|
|
|
29
29
|
}
|
|
30
30
|
let parsedProt = {};
|
|
31
31
|
if (jws.protected) {
|
|
32
|
-
const protectedHeader = base64url(jws.protected);
|
|
33
32
|
try {
|
|
33
|
+
const protectedHeader = base64url(jws.protected);
|
|
34
34
|
parsedProt = JSON.parse(decoder.decode(protectedHeader));
|
|
35
35
|
}
|
|
36
36
|
catch (_b) {
|
|
@@ -9,7 +9,7 @@ import { importJWK } from '../key/import.js';
|
|
|
9
9
|
import checkKeyType from './check_key_type.js';
|
|
10
10
|
import isObject from './is_object.js';
|
|
11
11
|
import { unwrap as aesGcmKw } from './aesgcmkw.js';
|
|
12
|
-
async function decryptKeyManagement(alg, key, encryptedKey, joseHeader) {
|
|
12
|
+
async function decryptKeyManagement(alg, key, encryptedKey, joseHeader, options) {
|
|
13
13
|
checkKeyType(alg, key, 'decrypt');
|
|
14
14
|
switch (alg) {
|
|
15
15
|
case 'dir': {
|
|
@@ -63,6 +63,9 @@ async function decryptKeyManagement(alg, key, encryptedKey, joseHeader) {
|
|
|
63
63
|
throw new JWEInvalid('JWE Encrypted Key missing');
|
|
64
64
|
if (typeof joseHeader.p2c !== 'number')
|
|
65
65
|
throw new JWEInvalid(`JOSE Header "p2c" (PBES2 Count) missing or invalid`);
|
|
66
|
+
const p2cLimit = (options === null || options === void 0 ? void 0 : options.maxPBES2Count) || 10000;
|
|
67
|
+
if (joseHeader.p2c > p2cLimit)
|
|
68
|
+
throw new JWEInvalid(`JOSE Header "p2c" (PBES2 Count) out is of acceptable bounds`);
|
|
66
69
|
if (typeof joseHeader.p2s !== 'string')
|
|
67
70
|
throw new JWEInvalid(`JOSE Header "p2s" (PBES2 Salt) missing or invalid`);
|
|
68
71
|
return pbes2Kw(alg, key, encryptedKey, joseHeader.p2c, base64url(joseHeader.p2s));
|
package/dist/node/cjs/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.base64url = exports.generateSecret = exports.generateKeyPair = exports.errors = exports.decodeJwt = exports.decodeProtectedHeader = exports.importJWK = exports.importX509 = exports.importPKCS8 = exports.importSPKI = exports.exportJWK = exports.exportSPKI = exports.exportPKCS8 = exports.UnsecuredJWT = exports.createRemoteJWKSet = exports.createLocalJWKSet = exports.EmbeddedJWK = exports.calculateJwkThumbprint = exports.EncryptJWT = exports.SignJWT = exports.GeneralSign = exports.FlattenedSign = exports.CompactSign = exports.FlattenedEncrypt = exports.CompactEncrypt = exports.jwtDecrypt = exports.jwtVerify = exports.generalVerify = exports.flattenedVerify = exports.compactVerify = exports.GeneralEncrypt = exports.generalDecrypt = exports.flattenedDecrypt = exports.compactDecrypt = void 0;
|
|
3
|
+
exports.base64url = exports.generateSecret = exports.generateKeyPair = exports.errors = exports.decodeJwt = exports.decodeProtectedHeader = exports.importJWK = exports.importX509 = exports.importPKCS8 = exports.importSPKI = exports.exportJWK = exports.exportSPKI = exports.exportPKCS8 = exports.UnsecuredJWT = exports.createRemoteJWKSet = exports.createLocalJWKSet = exports.EmbeddedJWK = exports.calculateJwkThumbprintUri = exports.calculateJwkThumbprint = exports.EncryptJWT = exports.SignJWT = exports.GeneralSign = exports.FlattenedSign = exports.CompactSign = exports.FlattenedEncrypt = exports.CompactEncrypt = exports.jwtDecrypt = exports.jwtVerify = exports.generalVerify = exports.flattenedVerify = exports.compactVerify = exports.GeneralEncrypt = exports.generalDecrypt = exports.flattenedDecrypt = exports.compactDecrypt = void 0;
|
|
4
4
|
var decrypt_js_1 = require("./jwe/compact/decrypt.js");
|
|
5
5
|
Object.defineProperty(exports, "compactDecrypt", { enumerable: true, get: function () { return decrypt_js_1.compactDecrypt; } });
|
|
6
6
|
var decrypt_js_2 = require("./jwe/flattened/decrypt.js");
|
|
@@ -35,6 +35,7 @@ var encrypt_js_4 = require("./jwt/encrypt.js");
|
|
|
35
35
|
Object.defineProperty(exports, "EncryptJWT", { enumerable: true, get: function () { return encrypt_js_4.EncryptJWT; } });
|
|
36
36
|
var thumbprint_js_1 = require("./jwk/thumbprint.js");
|
|
37
37
|
Object.defineProperty(exports, "calculateJwkThumbprint", { enumerable: true, get: function () { return thumbprint_js_1.calculateJwkThumbprint; } });
|
|
38
|
+
Object.defineProperty(exports, "calculateJwkThumbprintUri", { enumerable: true, get: function () { return thumbprint_js_1.calculateJwkThumbprintUri; } });
|
|
38
39
|
var embedded_js_1 = require("./jwk/embedded.js");
|
|
39
40
|
Object.defineProperty(exports, "EmbeddedJWK", { enumerable: true, get: function () { return embedded_js_1.EmbeddedJWK; } });
|
|
40
41
|
var local_js_1 = require("./jwks/local.js");
|
|
@@ -46,8 +46,8 @@ async function flattenedDecrypt(jwe, key, options) {
|
|
|
46
46
|
}
|
|
47
47
|
let parsedProt;
|
|
48
48
|
if (jwe.protected) {
|
|
49
|
-
const protectedHeader = (0, base64url_js_1.decode)(jwe.protected);
|
|
50
49
|
try {
|
|
50
|
+
const protectedHeader = (0, base64url_js_1.decode)(jwe.protected);
|
|
51
51
|
parsedProt = JSON.parse(buffer_utils_js_1.decoder.decode(protectedHeader));
|
|
52
52
|
}
|
|
53
53
|
catch {
|
|
@@ -98,10 +98,10 @@ async function flattenedDecrypt(jwe, key, options) {
|
|
|
98
98
|
}
|
|
99
99
|
let cek;
|
|
100
100
|
try {
|
|
101
|
-
cek = await (0, decrypt_key_management_js_1.default)(alg, key, encryptedKey, joseHeader);
|
|
101
|
+
cek = await (0, decrypt_key_management_js_1.default)(alg, key, encryptedKey, joseHeader, options);
|
|
102
102
|
}
|
|
103
103
|
catch (err) {
|
|
104
|
-
if (err instanceof TypeError) {
|
|
104
|
+
if (err instanceof TypeError || err instanceof errors_js_1.JWEInvalid || err instanceof errors_js_1.JOSENotSupported) {
|
|
105
105
|
throw err;
|
|
106
106
|
}
|
|
107
107
|
cek = (0, cek_js_1.default)(enc);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.calculateJwkThumbprint = void 0;
|
|
3
|
+
exports.calculateJwkThumbprintUri = exports.calculateJwkThumbprint = void 0;
|
|
4
4
|
const digest_js_1 = require("../runtime/digest.js");
|
|
5
5
|
const base64url_js_1 = require("../runtime/base64url.js");
|
|
6
6
|
const errors_js_1 = require("../util/errors.js");
|
|
@@ -11,10 +11,11 @@ const check = (value, description) => {
|
|
|
11
11
|
throw new errors_js_1.JWKInvalid(`${description} missing or invalid`);
|
|
12
12
|
}
|
|
13
13
|
};
|
|
14
|
-
async function calculateJwkThumbprint(jwk, digestAlgorithm
|
|
14
|
+
async function calculateJwkThumbprint(jwk, digestAlgorithm) {
|
|
15
15
|
if (!(0, is_object_js_1.default)(jwk)) {
|
|
16
16
|
throw new TypeError('JWK must be an object');
|
|
17
17
|
}
|
|
18
|
+
digestAlgorithm !== null && digestAlgorithm !== void 0 ? digestAlgorithm : (digestAlgorithm = 'sha256');
|
|
18
19
|
if (digestAlgorithm !== 'sha256' &&
|
|
19
20
|
digestAlgorithm !== 'sha384' &&
|
|
20
21
|
digestAlgorithm !== 'sha512') {
|
|
@@ -49,3 +50,9 @@ async function calculateJwkThumbprint(jwk, digestAlgorithm = 'sha256') {
|
|
|
49
50
|
return (0, base64url_js_1.encode)(await (0, digest_js_1.default)(digestAlgorithm, data));
|
|
50
51
|
}
|
|
51
52
|
exports.calculateJwkThumbprint = calculateJwkThumbprint;
|
|
53
|
+
async function calculateJwkThumbprintUri(jwk, digestAlgorithm) {
|
|
54
|
+
digestAlgorithm !== null && digestAlgorithm !== void 0 ? digestAlgorithm : (digestAlgorithm = 'sha256');
|
|
55
|
+
const thumbprint = await calculateJwkThumbprint(jwk, digestAlgorithm);
|
|
56
|
+
return `urn:ietf:params:oauth:jwk-thumbprint:sha-${digestAlgorithm.slice(-3)}:${thumbprint}`;
|
|
57
|
+
}
|
|
58
|
+
exports.calculateJwkThumbprintUri = calculateJwkThumbprintUri;
|
|
@@ -32,8 +32,8 @@ async function flattenedVerify(jws, key, options) {
|
|
|
32
32
|
}
|
|
33
33
|
let parsedProt = {};
|
|
34
34
|
if (jws.protected) {
|
|
35
|
-
const protectedHeader = (0, base64url_js_1.decode)(jws.protected);
|
|
36
35
|
try {
|
|
36
|
+
const protectedHeader = (0, base64url_js_1.decode)(jws.protected);
|
|
37
37
|
parsedProt = JSON.parse(buffer_utils_js_1.decoder.decode(protectedHeader));
|
|
38
38
|
}
|
|
39
39
|
catch {
|
|
@@ -11,7 +11,7 @@ const import_js_1 = require("../key/import.js");
|
|
|
11
11
|
const check_key_type_js_1 = require("./check_key_type.js");
|
|
12
12
|
const is_object_js_1 = require("./is_object.js");
|
|
13
13
|
const aesgcmkw_js_1 = require("./aesgcmkw.js");
|
|
14
|
-
async function decryptKeyManagement(alg, key, encryptedKey, joseHeader) {
|
|
14
|
+
async function decryptKeyManagement(alg, key, encryptedKey, joseHeader, options) {
|
|
15
15
|
(0, check_key_type_js_1.default)(alg, key, 'decrypt');
|
|
16
16
|
switch (alg) {
|
|
17
17
|
case 'dir': {
|
|
@@ -65,6 +65,9 @@ async function decryptKeyManagement(alg, key, encryptedKey, joseHeader) {
|
|
|
65
65
|
throw new errors_js_1.JWEInvalid('JWE Encrypted Key missing');
|
|
66
66
|
if (typeof joseHeader.p2c !== 'number')
|
|
67
67
|
throw new errors_js_1.JWEInvalid(`JOSE Header "p2c" (PBES2 Count) missing or invalid`);
|
|
68
|
+
const p2cLimit = (options === null || options === void 0 ? void 0 : options.maxPBES2Count) || 10000;
|
|
69
|
+
if (joseHeader.p2c > p2cLimit)
|
|
70
|
+
throw new errors_js_1.JWEInvalid(`JOSE Header "p2c" (PBES2 Count) out is of acceptable bounds`);
|
|
68
71
|
if (typeof joseHeader.p2s !== 'string')
|
|
69
72
|
throw new errors_js_1.JWEInvalid(`JOSE Header "p2s" (PBES2 Salt) missing or invalid`);
|
|
70
73
|
return (0, pbes2kw_js_1.decrypt)(alg, key, encryptedKey, joseHeader.p2c, (0, base64url_js_1.decode)(joseHeader.p2s));
|
|
@@ -35,6 +35,10 @@ const keyToJWK = (key) => {
|
|
|
35
35
|
throw new TypeError((0, invalid_key_input_js_1.default)(key, ...is_key_like_js_1.types, 'Uint8Array'));
|
|
36
36
|
}
|
|
37
37
|
if (jwkExportSupported) {
|
|
38
|
+
if (keyObject.type !== 'secret' &&
|
|
39
|
+
!['rsa', 'ec', 'ed25519', 'x25519', 'ed448', 'x448'].includes(keyObject.asymmetricKeyType)) {
|
|
40
|
+
throw new errors_js_1.JOSENotSupported('Unsupported key asymmetricKeyType');
|
|
41
|
+
}
|
|
38
42
|
return keyObject.export({ format: 'jwk' });
|
|
39
43
|
}
|
|
40
44
|
switch (keyObject.type) {
|
package/dist/node/esm/index.js
CHANGED
|
@@ -14,7 +14,7 @@ export { FlattenedSign } from './jws/flattened/sign.js';
|
|
|
14
14
|
export { GeneralSign } from './jws/general/sign.js';
|
|
15
15
|
export { SignJWT } from './jwt/sign.js';
|
|
16
16
|
export { EncryptJWT } from './jwt/encrypt.js';
|
|
17
|
-
export { calculateJwkThumbprint } from './jwk/thumbprint.js';
|
|
17
|
+
export { calculateJwkThumbprint, calculateJwkThumbprintUri } from './jwk/thumbprint.js';
|
|
18
18
|
export { EmbeddedJWK } from './jwk/embedded.js';
|
|
19
19
|
export { createLocalJWKSet } from './jwks/local.js';
|
|
20
20
|
export { createRemoteJWKSet } from './jwks/remote.js';
|
|
@@ -43,8 +43,8 @@ export async function flattenedDecrypt(jwe, key, options) {
|
|
|
43
43
|
}
|
|
44
44
|
let parsedProt;
|
|
45
45
|
if (jwe.protected) {
|
|
46
|
-
const protectedHeader = base64url(jwe.protected);
|
|
47
46
|
try {
|
|
47
|
+
const protectedHeader = base64url(jwe.protected);
|
|
48
48
|
parsedProt = JSON.parse(decoder.decode(protectedHeader));
|
|
49
49
|
}
|
|
50
50
|
catch {
|
|
@@ -95,10 +95,10 @@ export async function flattenedDecrypt(jwe, key, options) {
|
|
|
95
95
|
}
|
|
96
96
|
let cek;
|
|
97
97
|
try {
|
|
98
|
-
cek = await decryptKeyManagement(alg, key, encryptedKey, joseHeader);
|
|
98
|
+
cek = await decryptKeyManagement(alg, key, encryptedKey, joseHeader, options);
|
|
99
99
|
}
|
|
100
100
|
catch (err) {
|
|
101
|
-
if (err instanceof TypeError) {
|
|
101
|
+
if (err instanceof TypeError || err instanceof JWEInvalid || err instanceof JOSENotSupported) {
|
|
102
102
|
throw err;
|
|
103
103
|
}
|
|
104
104
|
cek = generateCek(enc);
|
|
@@ -8,10 +8,11 @@ const check = (value, description) => {
|
|
|
8
8
|
throw new JWKInvalid(`${description} missing or invalid`);
|
|
9
9
|
}
|
|
10
10
|
};
|
|
11
|
-
export async function calculateJwkThumbprint(jwk, digestAlgorithm
|
|
11
|
+
export async function calculateJwkThumbprint(jwk, digestAlgorithm) {
|
|
12
12
|
if (!isObject(jwk)) {
|
|
13
13
|
throw new TypeError('JWK must be an object');
|
|
14
14
|
}
|
|
15
|
+
digestAlgorithm !== null && digestAlgorithm !== void 0 ? digestAlgorithm : (digestAlgorithm = 'sha256');
|
|
15
16
|
if (digestAlgorithm !== 'sha256' &&
|
|
16
17
|
digestAlgorithm !== 'sha384' &&
|
|
17
18
|
digestAlgorithm !== 'sha512') {
|
|
@@ -45,3 +46,8 @@ export async function calculateJwkThumbprint(jwk, digestAlgorithm = 'sha256') {
|
|
|
45
46
|
const data = encoder.encode(JSON.stringify(components));
|
|
46
47
|
return base64url(await digest(digestAlgorithm, data));
|
|
47
48
|
}
|
|
49
|
+
export async function calculateJwkThumbprintUri(jwk, digestAlgorithm) {
|
|
50
|
+
digestAlgorithm !== null && digestAlgorithm !== void 0 ? digestAlgorithm : (digestAlgorithm = 'sha256');
|
|
51
|
+
const thumbprint = await calculateJwkThumbprint(jwk, digestAlgorithm);
|
|
52
|
+
return `urn:ietf:params:oauth:jwk-thumbprint:sha-${digestAlgorithm.slice(-3)}:${thumbprint}`;
|
|
53
|
+
}
|
|
@@ -29,8 +29,8 @@ export async function flattenedVerify(jws, key, options) {
|
|
|
29
29
|
}
|
|
30
30
|
let parsedProt = {};
|
|
31
31
|
if (jws.protected) {
|
|
32
|
-
const protectedHeader = base64url(jws.protected);
|
|
33
32
|
try {
|
|
33
|
+
const protectedHeader = base64url(jws.protected);
|
|
34
34
|
parsedProt = JSON.parse(decoder.decode(protectedHeader));
|
|
35
35
|
}
|
|
36
36
|
catch {
|
|
@@ -9,7 +9,7 @@ import { importJWK } from '../key/import.js';
|
|
|
9
9
|
import checkKeyType from './check_key_type.js';
|
|
10
10
|
import isObject from './is_object.js';
|
|
11
11
|
import { unwrap as aesGcmKw } from './aesgcmkw.js';
|
|
12
|
-
async function decryptKeyManagement(alg, key, encryptedKey, joseHeader) {
|
|
12
|
+
async function decryptKeyManagement(alg, key, encryptedKey, joseHeader, options) {
|
|
13
13
|
checkKeyType(alg, key, 'decrypt');
|
|
14
14
|
switch (alg) {
|
|
15
15
|
case 'dir': {
|
|
@@ -63,6 +63,9 @@ async function decryptKeyManagement(alg, key, encryptedKey, joseHeader) {
|
|
|
63
63
|
throw new JWEInvalid('JWE Encrypted Key missing');
|
|
64
64
|
if (typeof joseHeader.p2c !== 'number')
|
|
65
65
|
throw new JWEInvalid(`JOSE Header "p2c" (PBES2 Count) missing or invalid`);
|
|
66
|
+
const p2cLimit = (options === null || options === void 0 ? void 0 : options.maxPBES2Count) || 10000;
|
|
67
|
+
if (joseHeader.p2c > p2cLimit)
|
|
68
|
+
throw new JWEInvalid(`JOSE Header "p2c" (PBES2 Count) out is of acceptable bounds`);
|
|
66
69
|
if (typeof joseHeader.p2s !== 'string')
|
|
67
70
|
throw new JWEInvalid(`JOSE Header "p2s" (PBES2 Salt) missing or invalid`);
|
|
68
71
|
return pbes2Kw(alg, key, encryptedKey, joseHeader.p2c, base64url(joseHeader.p2s));
|
|
@@ -33,6 +33,10 @@ const keyToJWK = (key) => {
|
|
|
33
33
|
throw new TypeError(invalidKeyInput(key, ...types, 'Uint8Array'));
|
|
34
34
|
}
|
|
35
35
|
if (jwkExportSupported) {
|
|
36
|
+
if (keyObject.type !== 'secret' &&
|
|
37
|
+
!['rsa', 'ec', 'ed25519', 'x25519', 'ed448', 'x448'].includes(keyObject.asymmetricKeyType)) {
|
|
38
|
+
throw new JOSENotSupported('Unsupported key asymmetricKeyType');
|
|
39
|
+
}
|
|
36
40
|
return keyObject.export({ format: 'jwk' });
|
|
37
41
|
}
|
|
38
42
|
switch (keyObject.type) {
|
package/dist/types/index.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ export { GeneralSign } from './jws/general/sign';
|
|
|
25
25
|
export type { Signature } from './jws/general/sign';
|
|
26
26
|
export { SignJWT } from './jwt/sign';
|
|
27
27
|
export { EncryptJWT } from './jwt/encrypt';
|
|
28
|
-
export { calculateJwkThumbprint } from './jwk/thumbprint';
|
|
28
|
+
export { calculateJwkThumbprint, calculateJwkThumbprintUri } from './jwk/thumbprint';
|
|
29
29
|
export { EmbeddedJWK } from './jwk/embedded';
|
|
30
30
|
export { createLocalJWKSet } from './jwks/local';
|
|
31
31
|
export { createRemoteJWKSet } from './jwks/remote';
|
|
@@ -1,26 +1,28 @@
|
|
|
1
1
|
import type { KeyLike, DecryptOptions, CompactJWEHeaderParameters, GetKeyFunction, FlattenedJWE, CompactDecryptResult, ResolvedKey } from '../../types';
|
|
2
2
|
/**
|
|
3
|
-
* Interface for Compact JWE Decryption dynamic key resolution.
|
|
4
|
-
*
|
|
3
|
+
* Interface for Compact JWE Decryption dynamic key resolution. No token components have been
|
|
4
|
+
* verified at the time of this function call.
|
|
5
5
|
*/
|
|
6
6
|
export interface CompactDecryptGetKey extends GetKeyFunction<CompactJWEHeaderParameters, FlattenedJWE> {
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
9
|
* Decrypts a Compact JWE.
|
|
10
10
|
*
|
|
11
|
-
* @param jwe Compact JWE.
|
|
12
|
-
* @param key Private Key or Secret to decrypt the JWE with.
|
|
13
|
-
* @param options JWE Decryption options.
|
|
14
|
-
*
|
|
15
11
|
* @example Usage
|
|
12
|
+
*
|
|
16
13
|
* ```js
|
|
17
|
-
* const jwe =
|
|
14
|
+
* const jwe =
|
|
15
|
+
* 'eyJhbGciOiJSU0EtT0FFUC0yNTYiLCJlbmMiOiJBMjU2R0NNIn0.nyQ19eq9ogh9wA7fFtnI2oouzy5_8b5DeLkoRMfi2yijgfTs2zEnayCEofz_qhnL-nwszabd9qUeHv0-IwvhhJJS7GUJOU3ikiIe42qcIAFme1A_Fo9CTxw4XTOy-I5qanl8So91u6hwfyN1VxAqVLsSE7_23EC-gfGEg_5znew9PyXXsOIE-K_HH7IQowRrlZ1X_bM_Liu53RzDpLDvRz59mp3S8L56YqpM8FexFGTGpEaoTcEIst375qncYt3-79IVR7gZN1RWsWgjPatfvVbnh74PglQcATSf3UUhaW0OAKn6q7r3PDx6DIKQ35bgHQg5QopuN00eIfLQL2trGw.W3grIVj5HVuAb76X.6PcuDe5D6ttWFYyv0oqqdDXfI2R8wBg1F2Q80UUA_Gv8eEimNWfxIWdLxrjzgQGSvIhxmFKuLM0.a93_Ug3uZHuczj70Zavx8Q'
|
|
18
16
|
*
|
|
19
17
|
* const { plaintext, protectedHeader } = await jose.compactDecrypt(jwe, privateKey)
|
|
20
18
|
*
|
|
21
19
|
* console.log(protectedHeader)
|
|
22
20
|
* console.log(new TextDecoder().decode(plaintext))
|
|
23
21
|
* ```
|
|
22
|
+
*
|
|
23
|
+
* @param jwe Compact JWE.
|
|
24
|
+
* @param key Private Key or Secret to decrypt the JWE with.
|
|
25
|
+
* @param options JWE Decryption options.
|
|
24
26
|
*/
|
|
25
27
|
export declare function compactDecrypt(jwe: string | Uint8Array, key: KeyLike | Uint8Array, options?: DecryptOptions): Promise<CompactDecryptResult>;
|
|
26
28
|
/**
|
|
@@ -3,11 +3,10 @@ import type { KeyLike, JWEKeyManagementHeaderParameters, CompactJWEHeaderParamet
|
|
|
3
3
|
* The CompactEncrypt class is a utility for creating Compact JWE strings.
|
|
4
4
|
*
|
|
5
5
|
* @example Usage
|
|
6
|
+
*
|
|
6
7
|
* ```js
|
|
7
8
|
* const jwe = await new jose.CompactEncrypt(
|
|
8
|
-
* new TextEncoder().encode(
|
|
9
|
-
* 'It’s a dangerous business, Frodo, going out your door.'
|
|
10
|
-
* )
|
|
9
|
+
* new TextEncoder().encode('It’s a dangerous business, Frodo, going out your door.'),
|
|
11
10
|
* )
|
|
12
11
|
* .setProtectedHeader({ alg: 'RSA-OAEP-256', enc: 'A256GCM' })
|
|
13
12
|
* .encrypt(publicKey)
|
|
@@ -17,29 +16,24 @@ import type { KeyLike, JWEKeyManagementHeaderParameters, CompactJWEHeaderParamet
|
|
|
17
16
|
*/
|
|
18
17
|
export declare class CompactEncrypt {
|
|
19
18
|
private _flattened;
|
|
20
|
-
/**
|
|
21
|
-
* @param plaintext Binary representation of the plaintext to encrypt.
|
|
22
|
-
*/
|
|
19
|
+
/** @param plaintext Binary representation of the plaintext to encrypt. */
|
|
23
20
|
constructor(plaintext: Uint8Array);
|
|
24
21
|
/**
|
|
25
|
-
* Sets a content encryption key to use, by default a random suitable one
|
|
26
|
-
*
|
|
22
|
+
* Sets a content encryption key to use, by default a random suitable one is generated for the JWE
|
|
23
|
+
* enc" (Encryption Algorithm) Header Parameter.
|
|
27
24
|
*
|
|
25
|
+
* @deprecated You should not use this method. It is only really intended for test and vector
|
|
26
|
+
* validation purposes.
|
|
28
27
|
* @param cek JWE Content Encryption Key.
|
|
29
|
-
*
|
|
30
|
-
* @deprecated You should not use this method. It is only really intended
|
|
31
|
-
* for test and vector validation purposes.
|
|
32
28
|
*/
|
|
33
29
|
setContentEncryptionKey(cek: Uint8Array): this;
|
|
34
30
|
/**
|
|
35
|
-
* Sets the JWE Initialization Vector to use for content encryption, by default
|
|
36
|
-
*
|
|
37
|
-
* Header Parameter.
|
|
31
|
+
* Sets the JWE Initialization Vector to use for content encryption, by default a random suitable
|
|
32
|
+
* one is generated for the JWE enc" (Encryption Algorithm) Header Parameter.
|
|
38
33
|
*
|
|
34
|
+
* @deprecated You should not use this method. It is only really intended for test and vector
|
|
35
|
+
* validation purposes.
|
|
39
36
|
* @param iv JWE Initialization Vector.
|
|
40
|
-
*
|
|
41
|
-
* @deprecated You should not use this method. It is only really intended
|
|
42
|
-
* for test and vector validation purposes.
|
|
43
37
|
*/
|
|
44
38
|
setInitializationVector(iv: Uint8Array): this;
|
|
45
39
|
/**
|
|
@@ -49,9 +43,9 @@ export declare class CompactEncrypt {
|
|
|
49
43
|
*/
|
|
50
44
|
setProtectedHeader(protectedHeader: CompactJWEHeaderParameters): this;
|
|
51
45
|
/**
|
|
52
|
-
* Sets the JWE Key Management parameters to be used when encrypting the Content
|
|
53
|
-
*
|
|
54
|
-
*
|
|
46
|
+
* Sets the JWE Key Management parameters to be used when encrypting the Content Encryption Key.
|
|
47
|
+
* You do not need to invoke this method, it is only really intended for test and vector
|
|
48
|
+
* validation purposes.
|
|
55
49
|
*
|
|
56
50
|
* @param parameters JWE Key Management parameters.
|
|
57
51
|
*/
|
|
@@ -1,39 +1,38 @@
|
|
|
1
1
|
import type { FlattenedDecryptResult, KeyLike, FlattenedJWE, JWEHeaderParameters, DecryptOptions, GetKeyFunction, ResolvedKey } from '../../types';
|
|
2
2
|
/**
|
|
3
|
-
* Interface for Flattened JWE Decryption dynamic key resolution.
|
|
4
|
-
*
|
|
3
|
+
* Interface for Flattened JWE Decryption dynamic key resolution. No token components have been
|
|
4
|
+
* verified at the time of this function call.
|
|
5
5
|
*/
|
|
6
6
|
export interface FlattenedDecryptGetKey extends GetKeyFunction<JWEHeaderParameters | undefined, FlattenedJWE> {
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
9
|
* Decrypts a Flattened JWE.
|
|
10
10
|
*
|
|
11
|
-
* @param jwe Flattened JWE.
|
|
12
|
-
* @param key Private Key or Secret to decrypt the JWE with.
|
|
13
|
-
* @param options JWE Decryption options.
|
|
14
|
-
*
|
|
15
11
|
* @example Usage
|
|
12
|
+
*
|
|
16
13
|
* ```js
|
|
17
14
|
* const jwe = {
|
|
18
15
|
* ciphertext: '9EzjFISUyoG-ifC2mSihfP0DPC80yeyrxhTzKt1C_VJBkxeBG0MI4Te61Pk45RAGubUvBpU9jm4',
|
|
19
16
|
* iv: '8Fy7A_IuoX5VXG9s',
|
|
20
17
|
* tag: 'W76IYV6arGRuDSaSyWrQNg',
|
|
21
|
-
* encrypted_key:
|
|
18
|
+
* encrypted_key:
|
|
19
|
+
* 'Z6eD4UK_yFb5ZoKvKkGAdqywEG_m0e4IYo0x8Vf30LAMJcsc-_zSgIeiF82teZyYi2YYduHKoqImk7MRnoPZOlEs0Q5BNK1OgBmSOhCE8DFyqh9Zh48TCTP6lmBQ52naqoUJFMtHzu-0LwZH26hxos0GP3Dt19O379MJB837TdKKa87skq0zHaVLAquRHOBF77GI54Bc7O49d8aOrSu1VEFGMThlW2caspPRiTSePDMDPq7_WGk50izRhB3Asl9wmP9wEeaTrkJKRnQj5ips1SAZ1hDBsqEQKKukxP1HtdcopHV5_qgwU8Hjm5EwSLMluMQuiE6hwlkXGOujZLVizA',
|
|
22
20
|
* aad: 'VGhlIEZlbGxvd3NoaXAgb2YgdGhlIFJpbmc',
|
|
23
|
-
* protected: 'eyJhbGciOiJSU0EtT0FFUC0yNTYiLCJlbmMiOiJBMjU2R0NNIn0'
|
|
21
|
+
* protected: 'eyJhbGciOiJSU0EtT0FFUC0yNTYiLCJlbmMiOiJBMjU2R0NNIn0',
|
|
24
22
|
* }
|
|
25
23
|
*
|
|
26
|
-
* const {
|
|
27
|
-
*
|
|
28
|
-
* protectedHeader,
|
|
29
|
-
* additionalAuthenticatedData
|
|
30
|
-
* } = await jose.flattenedDecrypt(jwe, privateKey)
|
|
24
|
+
* const { plaintext, protectedHeader, additionalAuthenticatedData } =
|
|
25
|
+
* await jose.flattenedDecrypt(jwe, privateKey)
|
|
31
26
|
*
|
|
32
27
|
* console.log(protectedHeader)
|
|
33
28
|
* const decoder = new TextDecoder()
|
|
34
29
|
* console.log(decoder.decode(plaintext))
|
|
35
30
|
* console.log(decoder.decode(additionalAuthenticatedData))
|
|
36
31
|
* ```
|
|
32
|
+
*
|
|
33
|
+
* @param jwe Flattened JWE.
|
|
34
|
+
* @param key Private Key or Secret to decrypt the JWE with.
|
|
35
|
+
* @param options JWE Decryption options.
|
|
37
36
|
*/
|
|
38
37
|
export declare function flattenedDecrypt(jwe: FlattenedJWE, key: KeyLike | Uint8Array, options?: DecryptOptions): Promise<FlattenedDecryptResult>;
|
|
39
38
|
/**
|
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
import type { KeyLike, FlattenedJWE, JWEHeaderParameters, JWEKeyManagementHeaderParameters, EncryptOptions } from '../../types';
|
|
2
|
-
/**
|
|
3
|
-
* @private
|
|
4
|
-
*/
|
|
2
|
+
/** @private */
|
|
5
3
|
export declare const unprotected: unique symbol;
|
|
6
4
|
/**
|
|
7
|
-
* The FlattenedEncrypt class is a utility for creating Flattened JWE
|
|
8
|
-
* objects.
|
|
5
|
+
* The FlattenedEncrypt class is a utility for creating Flattened JWE objects.
|
|
9
6
|
*
|
|
10
7
|
* @example Usage
|
|
8
|
+
*
|
|
11
9
|
* ```js
|
|
12
10
|
* const jwe = await new jose.FlattenedEncrypt(
|
|
13
|
-
* new TextEncoder().encode(
|
|
14
|
-
* 'It’s a dangerous business, Frodo, going out your door.'
|
|
15
|
-
* )
|
|
11
|
+
* new TextEncoder().encode('It’s a dangerous business, Frodo, going out your door.'),
|
|
16
12
|
* )
|
|
17
13
|
* .setProtectedHeader({ alg: 'RSA-OAEP-256', enc: 'A256GCM' })
|
|
18
14
|
* .setAdditionalAuthenticatedData(encoder.encode('The Fellowship of the Ring'))
|
|
@@ -30,15 +26,13 @@ export declare class FlattenedEncrypt {
|
|
|
30
26
|
private _cek;
|
|
31
27
|
private _iv;
|
|
32
28
|
private _keyManagementParameters;
|
|
33
|
-
/**
|
|
34
|
-
* @param plaintext Binary representation of the plaintext to encrypt.
|
|
35
|
-
*/
|
|
29
|
+
/** @param plaintext Binary representation of the plaintext to encrypt. */
|
|
36
30
|
constructor(plaintext: Uint8Array);
|
|
37
31
|
/**
|
|
38
|
-
* Sets the JWE Key Management parameters to be used when encrypting.
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
32
|
+
* Sets the JWE Key Management parameters to be used when encrypting. Use of this is method is
|
|
33
|
+
* really only needed for ECDH based algorithms when utilizing the Agreement PartyUInfo or
|
|
34
|
+
* Agreement PartyVInfo parameters. Other parameters will always be randomly generated when needed
|
|
35
|
+
* and missing.
|
|
42
36
|
*
|
|
43
37
|
* @param parameters JWE Key Management parameters.
|
|
44
38
|
*/
|
|
@@ -68,24 +62,21 @@ export declare class FlattenedEncrypt {
|
|
|
68
62
|
*/
|
|
69
63
|
setAdditionalAuthenticatedData(aad: Uint8Array): this;
|
|
70
64
|
/**
|
|
71
|
-
* Sets a content encryption key to use, by default a random suitable one
|
|
72
|
-
*
|
|
65
|
+
* Sets a content encryption key to use, by default a random suitable one is generated for the JWE
|
|
66
|
+
* enc" (Encryption Algorithm) Header Parameter.
|
|
73
67
|
*
|
|
68
|
+
* @deprecated You should not use this method. It is only really intended for test and vector
|
|
69
|
+
* validation purposes.
|
|
74
70
|
* @param cek JWE Content Encryption Key.
|
|
75
|
-
*
|
|
76
|
-
* @deprecated You should not use this method. It is only really intended
|
|
77
|
-
* for test and vector validation purposes.
|
|
78
71
|
*/
|
|
79
72
|
setContentEncryptionKey(cek: Uint8Array): this;
|
|
80
73
|
/**
|
|
81
|
-
* Sets the JWE Initialization Vector to use for content encryption, by default
|
|
82
|
-
*
|
|
83
|
-
* Header Parameter.
|
|
74
|
+
* Sets the JWE Initialization Vector to use for content encryption, by default a random suitable
|
|
75
|
+
* one is generated for the JWE enc" (Encryption Algorithm) Header Parameter.
|
|
84
76
|
*
|
|
77
|
+
* @deprecated You should not use this method. It is only really intended for test and vector
|
|
78
|
+
* validation purposes.
|
|
85
79
|
* @param iv JWE Initialization Vector.
|
|
86
|
-
*
|
|
87
|
-
* @deprecated You should not use this method. It is only really intended
|
|
88
|
-
* for test and vector validation purposes.
|
|
89
80
|
*/
|
|
90
81
|
setInitializationVector(iv: Uint8Array): this;
|
|
91
82
|
/**
|
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
import type { KeyLike, DecryptOptions, JWEHeaderParameters, GetKeyFunction, FlattenedJWE, GeneralJWE, GeneralDecryptResult, ResolvedKey } from '../../types';
|
|
2
2
|
/**
|
|
3
|
-
* Interface for General JWE Decryption dynamic key resolution.
|
|
4
|
-
*
|
|
3
|
+
* Interface for General JWE Decryption dynamic key resolution. No token components have been
|
|
4
|
+
* verified at the time of this function call.
|
|
5
5
|
*/
|
|
6
6
|
export interface GeneralDecryptGetKey extends GetKeyFunction<JWEHeaderParameters, FlattenedJWE> {
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
9
|
* Decrypts a General JWE.
|
|
10
10
|
*
|
|
11
|
-
* @param jwe General JWE.
|
|
12
|
-
* @param key Private Key or Secret to decrypt the JWE with.
|
|
13
|
-
* @param options JWE Decryption options.
|
|
14
|
-
*
|
|
15
11
|
* @example Usage
|
|
12
|
+
*
|
|
16
13
|
* ```js
|
|
17
14
|
* const jwe = {
|
|
18
15
|
* ciphertext: '9EzjFISUyoG-ifC2mSihfP0DPC80yeyrxhTzKt1C_VJBkxeBG0MI4Te61Pk45RAGubUvBpU9jm4',
|
|
@@ -22,22 +19,24 @@ export interface GeneralDecryptGetKey extends GetKeyFunction<JWEHeaderParameters
|
|
|
22
19
|
* protected: 'eyJhbGciOiJSU0EtT0FFUC0yNTYiLCJlbmMiOiJBMjU2R0NNIn0',
|
|
23
20
|
* recipients: [
|
|
24
21
|
* {
|
|
25
|
-
* encrypted_key:
|
|
26
|
-
*
|
|
27
|
-
*
|
|
22
|
+
* encrypted_key:
|
|
23
|
+
* 'Z6eD4UK_yFb5ZoKvKkGAdqywEG_m0e4IYo0x8Vf30LAMJcsc-_zSgIeiF82teZyYi2YYduHKoqImk7MRnoPZOlEs0Q5BNK1OgBmSOhCE8DFyqh9Zh48TCTP6lmBQ52naqoUJFMtHzu-0LwZH26hxos0GP3Dt19O379MJB837TdKKa87skq0zHaVLAquRHOBF77GI54Bc7O49d8aOrSu1VEFGMThlW2caspPRiTSePDMDPq7_WGk50izRhB3Asl9wmP9wEeaTrkJKRnQj5ips1SAZ1hDBsqEQKKukxP1HtdcopHV5_qgwU8Hjm5EwSLMluMQuiE6hwlkXGOujZLVizA',
|
|
24
|
+
* },
|
|
25
|
+
* ],
|
|
28
26
|
* }
|
|
29
27
|
*
|
|
30
|
-
* const {
|
|
31
|
-
*
|
|
32
|
-
* protectedHeader,
|
|
33
|
-
* additionalAuthenticatedData
|
|
34
|
-
* } = await jose.generalDecrypt(jwe, privateKey)
|
|
28
|
+
* const { plaintext, protectedHeader, additionalAuthenticatedData } =
|
|
29
|
+
* await jose.generalDecrypt(jwe, privateKey)
|
|
35
30
|
*
|
|
36
31
|
* console.log(protectedHeader)
|
|
37
32
|
* const decoder = new TextDecoder()
|
|
38
33
|
* console.log(decoder.decode(plaintext))
|
|
39
34
|
* console.log(decoder.decode(additionalAuthenticatedData))
|
|
40
35
|
* ```
|
|
36
|
+
*
|
|
37
|
+
* @param jwe General JWE.
|
|
38
|
+
* @param key Private Key or Secret to decrypt the JWE with.
|
|
39
|
+
* @param options JWE Decryption options.
|
|
41
40
|
*/
|
|
42
41
|
export declare function generalDecrypt(jwe: GeneralJWE, key: KeyLike | Uint8Array, options?: DecryptOptions): Promise<GeneralDecryptResult>;
|
|
43
42
|
/**
|