unjwt 0.5.17 → 0.5.19
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 +12 -20
- package/dist/index.d.mts +6 -5
- package/dist/index.mjs +4 -4
- package/dist/jwe.d.mts +3 -2
- package/dist/jwe.mjs +3 -3
- package/dist/jwk.d.mts +2 -2
- package/dist/jwk.mjs +2 -2
- package/dist/jws.d.mts +3 -2
- package/dist/jws.mjs +3 -3
- package/dist/shared/{unjwt.tM5bsBSH.mjs → unjwt.BhoZWy2Y.mjs} +51 -2
- package/dist/shared/{unjwt.BQUETRUD.d.mts → unjwt.BoKDWMcu.d.mts} +3 -2
- package/dist/shared/{unjwt.ClaeEBcy.d.mts → unjwt.Ca4-7Myr.d.mts} +2 -2
- package/dist/shared/{unjwt.Bui8we0H.mjs → unjwt.CcMe4dwj.mjs} +2 -2
- package/dist/shared/{unjwt.Djt8pPsc.d.mts → unjwt.DMz8YzKh.d.mts} +14 -2
- package/dist/shared/{unjwt.fumhLslo.d.mts → unjwt.DYM9KPZR.d.mts} +3 -2
- package/dist/shared/{unjwt.D5J5ziZr.mjs → unjwt.TAStXINk.mjs} +2 -2
- package/dist/shared/unjwt.b323eNLO.d.mts +3 -0
- package/dist/shared/{unjwt.DuLUtSpD.d.mts → unjwt.cZWaB7OK.d.mts} +7 -3
- package/dist/shared/{unjwt.A5jxFsjh.mjs → unjwt.kE816XJO.mjs} +26 -6
- package/dist/utils.d.mts +3 -2
- package/dist/utils.mjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -36,24 +36,20 @@ import { encrypt, decrypt } from "unjwt/jwe";
|
|
|
36
36
|
// JWK functions
|
|
37
37
|
import {
|
|
38
38
|
generateKey,
|
|
39
|
-
|
|
40
|
-
exportKey,
|
|
41
|
-
wrapKey,
|
|
42
|
-
unwrapKey,
|
|
43
|
-
getJWKFromSet,
|
|
39
|
+
generateJWK,
|
|
44
40
|
importJWKFromPEM,
|
|
45
41
|
exportJWKToPEM,
|
|
46
42
|
deriveKeyFromPassword,
|
|
43
|
+
deriveJWKFromPassword,
|
|
47
44
|
} from "unjwt/jwk";
|
|
48
45
|
// Utility functions
|
|
49
46
|
import {
|
|
50
47
|
isJWK,
|
|
51
48
|
isJWKSet,
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
randomBytes,
|
|
49
|
+
isSymmetricJWK,
|
|
50
|
+
isAsymmetricJWK,
|
|
51
|
+
isPrivateJWK,
|
|
52
|
+
isPublicJWK,
|
|
57
53
|
} from "unjwt/utils";
|
|
58
54
|
```
|
|
59
55
|
|
|
@@ -68,24 +64,20 @@ import { encrypt, decrypt } from "https://esm.sh/unjwt/jwe";
|
|
|
68
64
|
// JWK functions
|
|
69
65
|
import {
|
|
70
66
|
generateKey,
|
|
71
|
-
|
|
72
|
-
exportKey,
|
|
73
|
-
wrapKey,
|
|
74
|
-
unwrapKey,
|
|
75
|
-
getJWKFromSet,
|
|
67
|
+
generateJWK,
|
|
76
68
|
importJWKFromPEM,
|
|
77
69
|
exportJWKToPEM,
|
|
78
70
|
deriveKeyFromPassword,
|
|
71
|
+
deriveJWKFromPassword,
|
|
79
72
|
} from "https://esm.sh/unjwt/jwk";
|
|
80
73
|
// Utility functions
|
|
81
74
|
import {
|
|
82
75
|
isJWK,
|
|
83
76
|
isJWKSet,
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
randomBytes,
|
|
77
|
+
isSymmetricJWK,
|
|
78
|
+
isAsymmetricJWK,
|
|
79
|
+
isPrivateJWK,
|
|
80
|
+
isPublicJWK,
|
|
89
81
|
} from "https://esm.sh/unjwt/utils";
|
|
90
82
|
```
|
|
91
83
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export { d as JWEDecryptOptions, e as JWEDecryptResult, b as JWEEncryptOptions, J as JWEHeaderParameters, c as JWEKeyLookupFunction, a as JWEKeyManagementHeaderParameters, j as jwe } from './shared/unjwt.
|
|
4
|
-
export {
|
|
5
|
-
export { j as
|
|
1
|
+
export { E as ExpiresIn } from './shared/unjwt.b323eNLO.mjs';
|
|
2
|
+
export { i as utils } from './shared/unjwt.cZWaB7OK.mjs';
|
|
3
|
+
export { d as JWEDecryptOptions, e as JWEDecryptResult, b as JWEEncryptOptions, J as JWEHeaderParameters, c as JWEKeyLookupFunction, a as JWEKeyManagementHeaderParameters, j as jwe } from './shared/unjwt.BoKDWMcu.mjs';
|
|
4
|
+
export { j as jwk } from './shared/unjwt.DMz8YzKh.mjs';
|
|
5
|
+
export { J as JWSAlgorithm, a as JWSHeaderParameters, f as JWSKeyLookupFunction, b as JWSProtectedHeader, c as JWSSignOptions, e as JWSVerifyOptions, d as JWSVerifyResult, j as jws } from './shared/unjwt.DYM9KPZR.mjs';
|
|
6
|
+
export { C as CompositeKey, f as ContentEncryptionAlgorithm, D as DeriveKeyOptions, e as DeriveKeyReturn, c as GenerateJWKOptions, d as GenerateJWKReturn, G as GenerateKeyAlgorithm, a as GenerateKeyOptions, b as GenerateKeyReturn, t as JWK, O as JWKAlgorithm, P as JWKPEMAlgorithm, J as JWKParameters, u as JWKSet, E as JWK_AES_CBC_HMAC, F as JWK_AES_GCM, B as JWK_AES_GCM_KW, A as JWK_AES_KW, N as JWK_Asymmetric_Algorithm, j as JWK_EC, I as JWK_ECDH_ES, y as JWK_ECDSA, i as JWK_EC_Private, h as JWK_EC_Public, v as JWK_HMAC, p as JWK_OKP, o as JWK_OKP_Private, n as JWK_OKP_Public, L as JWK_OKP_SIGN, H as JWK_PBES2, s as JWK_Private, r as JWK_Public, m as JWK_RSA, z as JWK_RSA_ENC, x as JWK_RSA_PSS, l as JWK_RSA_Private, k as JWK_RSA_Public, w as JWK_RSA_SIGN, M as JWK_Symmetric_Algorithm, q as JWK_oct, S as JWT, T as JWTClaimValidationOptions, R as JWTClaims, Q as JoseHeaderParameters, K as KeyManagementAlgorithm, U as UnwrapKeyOptions, W as WrapKeyOptions, g as WrapKeyResult } from './shared/unjwt.Ca4-7Myr.mjs';
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { i as utils } from './shared/unjwt.
|
|
2
|
-
export { j as jwe } from './shared/unjwt.
|
|
3
|
-
export { j as jwk } from './shared/unjwt.
|
|
4
|
-
export { j as jws } from './shared/unjwt.
|
|
1
|
+
export { i as utils } from './shared/unjwt.BhoZWy2Y.mjs';
|
|
2
|
+
export { j as jwe } from './shared/unjwt.TAStXINk.mjs';
|
|
3
|
+
export { j as jwk } from './shared/unjwt.kE816XJO.mjs';
|
|
4
|
+
export { j as jws } from './shared/unjwt.CcMe4dwj.mjs';
|
package/dist/jwe.d.mts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export { C as CompositeKey, f as ContentEncryptionAlgorithm, D as DeriveKeyOptions, e as DeriveKeyReturn, c as GenerateJWKOptions, d as GenerateJWKReturn, G as GenerateKeyAlgorithm, a as GenerateKeyOptions, b as GenerateKeyReturn, t as JWK, O as JWKAlgorithm, P as JWKPEMAlgorithm, J as JWKParameters, u as JWKSet, E as JWK_AES_CBC_HMAC, F as JWK_AES_GCM, B as JWK_AES_GCM_KW, A as JWK_AES_KW, N as JWK_Asymmetric_Algorithm, j as JWK_EC, I as JWK_ECDH_ES, y as JWK_ECDSA, i as JWK_EC_Private, h as JWK_EC_Public, v as JWK_HMAC, p as JWK_OKP, o as JWK_OKP_Private, n as JWK_OKP_Public, L as JWK_OKP_SIGN, H as JWK_PBES2, s as JWK_Private, r as JWK_Public, m as JWK_RSA, z as JWK_RSA_ENC, x as JWK_RSA_PSS, l as JWK_RSA_Private, k as JWK_RSA_Public, w as JWK_RSA_SIGN, M as JWK_Symmetric_Algorithm, q as JWK_oct, S as JWT, T as JWTClaimValidationOptions, R as JWTClaims, Q as JoseHeaderParameters, K as KeyManagementAlgorithm, U as UnwrapKeyOptions, W as WrapKeyOptions, g as WrapKeyResult } from './shared/unjwt.
|
|
2
|
-
export { d as JWEDecryptOptions, e as JWEDecryptResult, b as JWEEncryptOptions, J as JWEHeaderParameters, c as JWEKeyLookupFunction, a as JWEKeyManagementHeaderParameters, g as decrypt, f as encrypt } from './shared/unjwt.
|
|
1
|
+
export { C as CompositeKey, f as ContentEncryptionAlgorithm, D as DeriveKeyOptions, e as DeriveKeyReturn, c as GenerateJWKOptions, d as GenerateJWKReturn, G as GenerateKeyAlgorithm, a as GenerateKeyOptions, b as GenerateKeyReturn, t as JWK, O as JWKAlgorithm, P as JWKPEMAlgorithm, J as JWKParameters, u as JWKSet, E as JWK_AES_CBC_HMAC, F as JWK_AES_GCM, B as JWK_AES_GCM_KW, A as JWK_AES_KW, N as JWK_Asymmetric_Algorithm, j as JWK_EC, I as JWK_ECDH_ES, y as JWK_ECDSA, i as JWK_EC_Private, h as JWK_EC_Public, v as JWK_HMAC, p as JWK_OKP, o as JWK_OKP_Private, n as JWK_OKP_Public, L as JWK_OKP_SIGN, H as JWK_PBES2, s as JWK_Private, r as JWK_Public, m as JWK_RSA, z as JWK_RSA_ENC, x as JWK_RSA_PSS, l as JWK_RSA_Private, k as JWK_RSA_Public, w as JWK_RSA_SIGN, M as JWK_Symmetric_Algorithm, q as JWK_oct, S as JWT, T as JWTClaimValidationOptions, R as JWTClaims, Q as JoseHeaderParameters, K as KeyManagementAlgorithm, U as UnwrapKeyOptions, W as WrapKeyOptions, g as WrapKeyResult } from './shared/unjwt.Ca4-7Myr.mjs';
|
|
2
|
+
export { d as JWEDecryptOptions, e as JWEDecryptResult, b as JWEEncryptOptions, J as JWEHeaderParameters, c as JWEKeyLookupFunction, a as JWEKeyManagementHeaderParameters, g as decrypt, f as encrypt } from './shared/unjwt.BoKDWMcu.mjs';
|
|
3
|
+
import './shared/unjwt.b323eNLO.mjs';
|
package/dist/jwe.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import './shared/unjwt.
|
|
2
|
-
import './shared/unjwt.
|
|
3
|
-
export { d as decrypt, e as encrypt } from './shared/unjwt.
|
|
1
|
+
import './shared/unjwt.kE816XJO.mjs';
|
|
2
|
+
import './shared/unjwt.BhoZWy2Y.mjs';
|
|
3
|
+
export { d as decrypt, e as encrypt } from './shared/unjwt.TAStXINk.mjs';
|
package/dist/jwk.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { C as CompositeKey, f as ContentEncryptionAlgorithm, D as DeriveKeyOptions, e as DeriveKeyReturn, c as GenerateJWKOptions, d as GenerateJWKReturn, G as GenerateKeyAlgorithm, a as GenerateKeyOptions, b as GenerateKeyReturn, t as JWK, O as JWKAlgorithm, P as JWKPEMAlgorithm, J as JWKParameters, u as JWKSet, E as JWK_AES_CBC_HMAC, F as JWK_AES_GCM, B as JWK_AES_GCM_KW, A as JWK_AES_KW, N as JWK_Asymmetric_Algorithm, j as JWK_EC, I as JWK_ECDH_ES, y as JWK_ECDSA, i as JWK_EC_Private, h as JWK_EC_Public, v as JWK_HMAC, p as JWK_OKP, o as JWK_OKP_Private, n as JWK_OKP_Public, L as JWK_OKP_SIGN, H as JWK_PBES2, s as JWK_Private, r as JWK_Public, m as JWK_RSA, z as JWK_RSA_ENC, x as JWK_RSA_PSS, l as JWK_RSA_Private, k as JWK_RSA_Public, w as JWK_RSA_SIGN, M as JWK_Symmetric_Algorithm, q as JWK_oct, S as JWT, T as JWTClaimValidationOptions, R as JWTClaims, Q as JoseHeaderParameters, K as KeyManagementAlgorithm, U as UnwrapKeyOptions, W as WrapKeyOptions, g as WrapKeyResult } from './shared/unjwt.
|
|
2
|
-
export { d as deriveKeyFromPassword,
|
|
1
|
+
export { C as CompositeKey, f as ContentEncryptionAlgorithm, D as DeriveKeyOptions, e as DeriveKeyReturn, c as GenerateJWKOptions, d as GenerateJWKReturn, G as GenerateKeyAlgorithm, a as GenerateKeyOptions, b as GenerateKeyReturn, t as JWK, O as JWKAlgorithm, P as JWKPEMAlgorithm, J as JWKParameters, u as JWKSet, E as JWK_AES_CBC_HMAC, F as JWK_AES_GCM, B as JWK_AES_GCM_KW, A as JWK_AES_KW, N as JWK_Asymmetric_Algorithm, j as JWK_EC, I as JWK_ECDH_ES, y as JWK_ECDSA, i as JWK_EC_Private, h as JWK_EC_Public, v as JWK_HMAC, p as JWK_OKP, o as JWK_OKP_Private, n as JWK_OKP_Public, L as JWK_OKP_SIGN, H as JWK_PBES2, s as JWK_Private, r as JWK_Public, m as JWK_RSA, z as JWK_RSA_ENC, x as JWK_RSA_PSS, l as JWK_RSA_Private, k as JWK_RSA_Public, w as JWK_RSA_SIGN, M as JWK_Symmetric_Algorithm, q as JWK_oct, S as JWT, T as JWTClaimValidationOptions, R as JWTClaims, Q as JoseHeaderParameters, K as KeyManagementAlgorithm, U as UnwrapKeyOptions, W as WrapKeyOptions, g as WrapKeyResult } from './shared/unjwt.Ca4-7Myr.mjs';
|
|
2
|
+
export { b as deriveJWKFromPassword, d as deriveKeyFromPassword, f as exportJWKToPEM, e as exportKey, a as generateJWK, g as generateKey, h as getJWKFromSet, c as importJWKFromPEM, i as importKey, u as unwrapKey, w as wrapKey } from './shared/unjwt.DMz8YzKh.mjs';
|
package/dist/jwk.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import './shared/unjwt.
|
|
2
|
-
export { h as deriveKeyFromPassword,
|
|
1
|
+
import './shared/unjwt.BhoZWy2Y.mjs';
|
|
2
|
+
export { k as deriveJWKFromPassword, h as deriveKeyFromPassword, n as exportJWKToPEM, l as exportKey, f as generateJWK, c as generateKey, b as getJWKFromSet, m as importJWKFromPEM, i as importKey, u as unwrapKey, w as wrapKey } from './shared/unjwt.kE816XJO.mjs';
|
package/dist/jws.d.mts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export { C as CompositeKey, f as ContentEncryptionAlgorithm, D as DeriveKeyOptions, e as DeriveKeyReturn, c as GenerateJWKOptions, d as GenerateJWKReturn, G as GenerateKeyAlgorithm, a as GenerateKeyOptions, b as GenerateKeyReturn, t as JWK, O as JWKAlgorithm, P as JWKPEMAlgorithm, J as JWKParameters, u as JWKSet, E as JWK_AES_CBC_HMAC, F as JWK_AES_GCM, B as JWK_AES_GCM_KW, A as JWK_AES_KW, N as JWK_Asymmetric_Algorithm, j as JWK_EC, I as JWK_ECDH_ES, y as JWK_ECDSA, i as JWK_EC_Private, h as JWK_EC_Public, v as JWK_HMAC, p as JWK_OKP, o as JWK_OKP_Private, n as JWK_OKP_Public, L as JWK_OKP_SIGN, H as JWK_PBES2, s as JWK_Private, r as JWK_Public, m as JWK_RSA, z as JWK_RSA_ENC, x as JWK_RSA_PSS, l as JWK_RSA_Private, k as JWK_RSA_Public, w as JWK_RSA_SIGN, M as JWK_Symmetric_Algorithm, q as JWK_oct, S as JWT, T as JWTClaimValidationOptions, R as JWTClaims, Q as JoseHeaderParameters, K as KeyManagementAlgorithm, U as UnwrapKeyOptions, W as WrapKeyOptions, g as WrapKeyResult } from './shared/unjwt.
|
|
2
|
-
export { J as JWSAlgorithm, a as JWSHeaderParameters, f as JWSKeyLookupFunction, b as JWSProtectedHeader, c as JWSSignOptions, e as JWSVerifyOptions, d as JWSVerifyResult, s as sign, v as verify } from './shared/unjwt.
|
|
1
|
+
export { C as CompositeKey, f as ContentEncryptionAlgorithm, D as DeriveKeyOptions, e as DeriveKeyReturn, c as GenerateJWKOptions, d as GenerateJWKReturn, G as GenerateKeyAlgorithm, a as GenerateKeyOptions, b as GenerateKeyReturn, t as JWK, O as JWKAlgorithm, P as JWKPEMAlgorithm, J as JWKParameters, u as JWKSet, E as JWK_AES_CBC_HMAC, F as JWK_AES_GCM, B as JWK_AES_GCM_KW, A as JWK_AES_KW, N as JWK_Asymmetric_Algorithm, j as JWK_EC, I as JWK_ECDH_ES, y as JWK_ECDSA, i as JWK_EC_Private, h as JWK_EC_Public, v as JWK_HMAC, p as JWK_OKP, o as JWK_OKP_Private, n as JWK_OKP_Public, L as JWK_OKP_SIGN, H as JWK_PBES2, s as JWK_Private, r as JWK_Public, m as JWK_RSA, z as JWK_RSA_ENC, x as JWK_RSA_PSS, l as JWK_RSA_Private, k as JWK_RSA_Public, w as JWK_RSA_SIGN, M as JWK_Symmetric_Algorithm, q as JWK_oct, S as JWT, T as JWTClaimValidationOptions, R as JWTClaims, Q as JoseHeaderParameters, K as KeyManagementAlgorithm, U as UnwrapKeyOptions, W as WrapKeyOptions, g as WrapKeyResult } from './shared/unjwt.Ca4-7Myr.mjs';
|
|
2
|
+
export { J as JWSAlgorithm, a as JWSHeaderParameters, f as JWSKeyLookupFunction, b as JWSProtectedHeader, c as JWSSignOptions, e as JWSVerifyOptions, d as JWSVerifyResult, s as sign, v as verify } from './shared/unjwt.DYM9KPZR.mjs';
|
|
3
|
+
import './shared/unjwt.b323eNLO.mjs';
|
package/dist/jws.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import './shared/unjwt.
|
|
2
|
-
import './shared/unjwt.
|
|
3
|
-
export { s as sign, v as verify } from './shared/unjwt.
|
|
1
|
+
import './shared/unjwt.kE816XJO.mjs';
|
|
2
|
+
import './shared/unjwt.BhoZWy2Y.mjs';
|
|
3
|
+
export { s as sign, v as verify } from './shared/unjwt.CcMe4dwj.mjs';
|
|
@@ -46,6 +46,54 @@ function getPlaintextBytes(payload) {
|
|
|
46
46
|
"Plaintext must be a string, Uint8Array, or a JSON-serializable object."
|
|
47
47
|
);
|
|
48
48
|
}
|
|
49
|
+
const TIME_CONSTANTS = Object.freeze({
|
|
50
|
+
s: 1,
|
|
51
|
+
second: 1,
|
|
52
|
+
seconds: 1,
|
|
53
|
+
m: 60,
|
|
54
|
+
minute: 60,
|
|
55
|
+
minutes: 60,
|
|
56
|
+
h: 3600,
|
|
57
|
+
hour: 3600,
|
|
58
|
+
hours: 3600,
|
|
59
|
+
D: 86400,
|
|
60
|
+
day: 86400,
|
|
61
|
+
days: 86400,
|
|
62
|
+
W: 604800,
|
|
63
|
+
week: 604800,
|
|
64
|
+
weeks: 604800,
|
|
65
|
+
M: 2592e3,
|
|
66
|
+
month: 2592e3,
|
|
67
|
+
months: 2592e3,
|
|
68
|
+
Y: 31536e3,
|
|
69
|
+
year: 31536e3,
|
|
70
|
+
years: 31536e3
|
|
71
|
+
});
|
|
72
|
+
const EXPIRES_IN_REGEX = /^(\d+)(s|second|seconds|m|minute|minutes|h|hour|hours|D|day|days|W|week|weeks|M|month|months|Y|year|years)?$/;
|
|
73
|
+
function computeExpiresInSeconds(expiresIn) {
|
|
74
|
+
if (typeof expiresIn === "number") {
|
|
75
|
+
if (!Number.isInteger(expiresIn) || expiresIn <= 0) {
|
|
76
|
+
throw new TypeError(
|
|
77
|
+
"If 'expiresIn' is a number, it must be a positive integer representing seconds."
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
return expiresIn;
|
|
81
|
+
}
|
|
82
|
+
if (typeof expiresIn === "string") {
|
|
83
|
+
const match = expiresIn.match(EXPIRES_IN_REGEX);
|
|
84
|
+
if (!match || !match[1]) {
|
|
85
|
+
throw new TypeError(
|
|
86
|
+
"Invalid 'expiresIn' format. Must be a positive integer or a string like '10m', '2h', '7D', etc."
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
const value = Number.parseInt(match[1], 10);
|
|
90
|
+
const unit = match[2] || "s";
|
|
91
|
+
return value * TIME_CONSTANTS[unit];
|
|
92
|
+
}
|
|
93
|
+
throw new TypeError(
|
|
94
|
+
"'expiresIn' must be a number or a string representing time duration."
|
|
95
|
+
);
|
|
96
|
+
}
|
|
49
97
|
function computeJwtTimeClaims(payload, headerTyp, expiresIn, currentDate = /* @__PURE__ */ new Date()) {
|
|
50
98
|
if (expiresIn === void 0 || !headerTyp?.toLowerCase().includes("jwt") || !(payload && typeof payload === "object") || payload instanceof Uint8Array || payload.exp) {
|
|
51
99
|
return void 0;
|
|
@@ -53,7 +101,7 @@ function computeJwtTimeClaims(payload, headerTyp, expiresIn, currentDate = /* @_
|
|
|
53
101
|
const now = Math.round(currentDate.getTime() / 1e3);
|
|
54
102
|
const claims = { ...payload };
|
|
55
103
|
claims.iat ||= now;
|
|
56
|
-
claims.exp = claims.iat + expiresIn;
|
|
104
|
+
claims.exp = claims.iat + computeExpiresInSeconds(expiresIn);
|
|
57
105
|
return claims;
|
|
58
106
|
}
|
|
59
107
|
function validateJwtClaims(jwtClaims, options = {}) {
|
|
@@ -359,6 +407,7 @@ const index = {
|
|
|
359
407
|
base64Encode: base64Encode,
|
|
360
408
|
base64UrlDecode: base64UrlDecode,
|
|
361
409
|
base64UrlEncode: base64UrlEncode,
|
|
410
|
+
computeExpiresInSeconds: computeExpiresInSeconds,
|
|
362
411
|
computeJwtTimeClaims: computeJwtTimeClaims,
|
|
363
412
|
concatUint8Arrays: concatUint8Arrays,
|
|
364
413
|
decodeMaybeJWTString: decodeMaybeJWTString,
|
|
@@ -384,4 +433,4 @@ const index = {
|
|
|
384
433
|
validateJwtClaims: validateJwtClaims
|
|
385
434
|
};
|
|
386
435
|
|
|
387
|
-
export { isPrivateJWK as A, isPublicJWK as B, isJWTContent as C, decodeMaybeJWTString as D, isJWK as a, applyTypCtyDefaults as b, computeJwtTimeClaims as c, base64UrlEncode as d, base64UrlDecode as e, decodePayloadFromBytes as f, getPlaintextBytes as g, validateJwtClaims as h, index as i, isCryptoKeyPair as j, isCryptoKey as k, textDecoder as l, isJWKSet as m, decodePayloadFromB64UrlSegment as n, validateCriticalHeadersJWS as o, concatUint8Arrays as p, base64Decode as q, randomBytes as r, sanitizeObject as s, textEncoder as t, base64Encode as u, validateCriticalHeadersJWE as v, assertCryptoKey as w, isAsymmetricJWK as x, maybeArray as y, isSymmetricJWK as z };
|
|
436
|
+
export { isPrivateJWK as A, isPublicJWK as B, isJWTContent as C, decodeMaybeJWTString as D, computeExpiresInSeconds as E, isJWK as a, applyTypCtyDefaults as b, computeJwtTimeClaims as c, base64UrlEncode as d, base64UrlDecode as e, decodePayloadFromBytes as f, getPlaintextBytes as g, validateJwtClaims as h, index as i, isCryptoKeyPair as j, isCryptoKey as k, textDecoder as l, isJWKSet as m, decodePayloadFromB64UrlSegment as n, validateCriticalHeadersJWS as o, concatUint8Arrays as p, base64Decode as q, randomBytes as r, sanitizeObject as s, textEncoder as t, base64Encode as u, validateCriticalHeadersJWE as v, assertCryptoKey as w, isAsymmetricJWK as x, maybeArray as y, isSymmetricJWK as z };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { K as KeyManagementAlgorithm, f as ContentEncryptionAlgorithm, Q as JoseHeaderParameters, h as JWK_EC_Public, i as JWK_EC_Private, t as JWK, T as JWTClaimValidationOptions, R as JWTClaims, C as CompositeKey, D as DeriveKeyOptions, e as DeriveKeyReturn, c as GenerateJWKOptions, d as GenerateJWKReturn, G as GenerateKeyAlgorithm, a as GenerateKeyOptions, b as GenerateKeyReturn, O as JWKAlgorithm, P as JWKPEMAlgorithm, J as JWKParameters, u as JWKSet, E as JWK_AES_CBC_HMAC, F as JWK_AES_GCM, B as JWK_AES_GCM_KW, A as JWK_AES_KW, N as JWK_Asymmetric_Algorithm, j as JWK_EC, I as JWK_ECDH_ES, y as JWK_ECDSA, v as JWK_HMAC, p as JWK_OKP, o as JWK_OKP_Private, n as JWK_OKP_Public, L as JWK_OKP_SIGN, H as JWK_PBES2, s as JWK_Private, r as JWK_Public, m as JWK_RSA, z as JWK_RSA_ENC, x as JWK_RSA_PSS, l as JWK_RSA_Private, k as JWK_RSA_Public, w as JWK_RSA_SIGN, M as JWK_Symmetric_Algorithm, q as JWK_oct, S as JWT, U as UnwrapKeyOptions, W as WrapKeyOptions, g as WrapKeyResult } from './unjwt.
|
|
1
|
+
import { K as KeyManagementAlgorithm, f as ContentEncryptionAlgorithm, Q as JoseHeaderParameters, h as JWK_EC_Public, i as JWK_EC_Private, t as JWK, T as JWTClaimValidationOptions, R as JWTClaims, C as CompositeKey, D as DeriveKeyOptions, e as DeriveKeyReturn, c as GenerateJWKOptions, d as GenerateJWKReturn, G as GenerateKeyAlgorithm, a as GenerateKeyOptions, b as GenerateKeyReturn, O as JWKAlgorithm, P as JWKPEMAlgorithm, J as JWKParameters, u as JWKSet, E as JWK_AES_CBC_HMAC, F as JWK_AES_GCM, B as JWK_AES_GCM_KW, A as JWK_AES_KW, N as JWK_Asymmetric_Algorithm, j as JWK_EC, I as JWK_ECDH_ES, y as JWK_ECDSA, v as JWK_HMAC, p as JWK_OKP, o as JWK_OKP_Private, n as JWK_OKP_Public, L as JWK_OKP_SIGN, H as JWK_PBES2, s as JWK_Private, r as JWK_Public, m as JWK_RSA, z as JWK_RSA_ENC, x as JWK_RSA_PSS, l as JWK_RSA_Private, k as JWK_RSA_Public, w as JWK_RSA_SIGN, M as JWK_Symmetric_Algorithm, q as JWK_oct, S as JWT, U as UnwrapKeyOptions, W as WrapKeyOptions, g as WrapKeyResult } from './unjwt.Ca4-7Myr.mjs';
|
|
2
|
+
import { E as ExpiresIn } from './unjwt.b323eNLO.mjs';
|
|
2
3
|
|
|
3
4
|
/** Recognized JWE Header Parameters, any other Header Members may also be present. */
|
|
4
5
|
interface JWEHeaderParameters extends JoseHeaderParameters {
|
|
@@ -77,7 +78,7 @@ interface JWEEncryptOptions {
|
|
|
77
78
|
/** Date to use when computing NumericDate claims, defaults to `new Date()`. */
|
|
78
79
|
currentDate?: Date;
|
|
79
80
|
/** Time at which the JWT should expire, if no `exp` was already provided (only when typ is "JWT" or explicitly parsing JWT). */
|
|
80
|
-
expiresIn?:
|
|
81
|
+
expiresIn?: ExpiresIn;
|
|
81
82
|
/** Additional JWE Protected Header parameters. */
|
|
82
83
|
protectedHeader?: Omit<JWEHeaderParameters, "alg" | "enc" | "iv" | "tag" | "p2s" | "p2c" | "epk" | "apu" | "apv">;
|
|
83
84
|
/** Initialization Vector for AES-GCMKW key wrapping. Generated if not provided. */
|
|
@@ -46,9 +46,9 @@ interface DeriveKeyOptions {
|
|
|
46
46
|
/** Mark the derived key as extractable. Defaults to false. */
|
|
47
47
|
extractable?: boolean;
|
|
48
48
|
/** Export the derived key as JWK. If true, the key will be returned in JWK_oct format. */
|
|
49
|
-
toJWK?: boolean |
|
|
49
|
+
toJWK?: undefined | boolean | Omit<JWKParameters, "alg" | "kty" | "key_ops" | "ext">;
|
|
50
50
|
}
|
|
51
|
-
type DeriveKeyReturn<TOptions extends DeriveKeyOptions> = TOptions["toJWK"] extends true ? JWK_oct : CryptoKey;
|
|
51
|
+
type DeriveKeyReturn<TOptions extends DeriveKeyOptions> = TOptions["toJWK"] extends true ? JWK_oct : TOptions["toJWK"] extends object ? JWK_oct : CryptoKey;
|
|
52
52
|
type KeyManagementAlgorithm = JWK_RSA_ENC | JWK_AES_KW | JWK_AES_GCM | JWK_AES_GCM_KW | JWK_PBES2 | JWK_ECDH_ES;
|
|
53
53
|
type ContentEncryptionAlgorithm = JWK_AES_GCM | JWK_AES_CBC_HMAC;
|
|
54
54
|
/** Options for the wrapKey function. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as importKey, s as sign$1, b as getJWKFromSet, v as verify$1 } from './unjwt.
|
|
2
|
-
import { s as sanitizeObject, a as isJWK, b as applyTypCtyDefaults, c as computeJwtTimeClaims, d as base64UrlEncode, t as textEncoder, l as textDecoder, e as base64UrlDecode, m as isJWKSet, n as decodePayloadFromB64UrlSegment, o as validateCriticalHeadersJWS, h as validateJwtClaims } from './unjwt.
|
|
1
|
+
import { i as importKey, s as sign$1, b as getJWKFromSet, v as verify$1 } from './unjwt.kE816XJO.mjs';
|
|
2
|
+
import { s as sanitizeObject, a as isJWK, b as applyTypCtyDefaults, c as computeJwtTimeClaims, d as base64UrlEncode, t as textEncoder, l as textDecoder, e as base64UrlDecode, m as isJWKSet, n as decodePayloadFromB64UrlSegment, o as validateCriticalHeadersJWS, h as validateJwtClaims } from './unjwt.BhoZWy2Y.mjs';
|
|
3
3
|
|
|
4
4
|
async function sign(payload, key, options = {}) {
|
|
5
5
|
const { protectedHeader: additionalProtectedHeader } = options;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { G as GenerateKeyAlgorithm, a as GenerateKeyOptions, b as GenerateKeyReturn, J as JWKParameters, c as GenerateJWKOptions, d as GenerateJWKReturn, H as JWK_PBES2, D as DeriveKeyOptions, e as DeriveKeyReturn, q as JWK_oct, t as JWK, K as KeyManagementAlgorithm, W as WrapKeyOptions, g as WrapKeyResult, U as UnwrapKeyOptions, P as JWKPEMAlgorithm, u as JWKSet, Q as JoseHeaderParameters, C as CompositeKey, f as ContentEncryptionAlgorithm, O as JWKAlgorithm, E as JWK_AES_CBC_HMAC, F as JWK_AES_GCM, B as JWK_AES_GCM_KW, A as JWK_AES_KW, N as JWK_Asymmetric_Algorithm, j as JWK_EC, I as JWK_ECDH_ES, y as JWK_ECDSA, i as JWK_EC_Private, h as JWK_EC_Public, v as JWK_HMAC, p as JWK_OKP, o as JWK_OKP_Private, n as JWK_OKP_Public, L as JWK_OKP_SIGN, s as JWK_Private, r as JWK_Public, m as JWK_RSA, z as JWK_RSA_ENC, x as JWK_RSA_PSS, l as JWK_RSA_Private, k as JWK_RSA_Public, w as JWK_RSA_SIGN, M as JWK_Symmetric_Algorithm, S as JWT, T as JWTClaimValidationOptions, R as JWTClaims } from './unjwt.
|
|
1
|
+
import { G as GenerateKeyAlgorithm, a as GenerateKeyOptions, b as GenerateKeyReturn, J as JWKParameters, c as GenerateJWKOptions, d as GenerateJWKReturn, H as JWK_PBES2, D as DeriveKeyOptions, e as DeriveKeyReturn, q as JWK_oct, t as JWK, K as KeyManagementAlgorithm, W as WrapKeyOptions, g as WrapKeyResult, U as UnwrapKeyOptions, P as JWKPEMAlgorithm, u as JWKSet, Q as JoseHeaderParameters, C as CompositeKey, f as ContentEncryptionAlgorithm, O as JWKAlgorithm, E as JWK_AES_CBC_HMAC, F as JWK_AES_GCM, B as JWK_AES_GCM_KW, A as JWK_AES_KW, N as JWK_Asymmetric_Algorithm, j as JWK_EC, I as JWK_ECDH_ES, y as JWK_ECDSA, i as JWK_EC_Private, h as JWK_EC_Public, v as JWK_HMAC, p as JWK_OKP, o as JWK_OKP_Private, n as JWK_OKP_Public, L as JWK_OKP_SIGN, s as JWK_Private, r as JWK_Public, m as JWK_RSA, z as JWK_RSA_ENC, x as JWK_RSA_PSS, l as JWK_RSA_Private, k as JWK_RSA_Public, w as JWK_RSA_SIGN, M as JWK_Symmetric_Algorithm, S as JWT, T as JWTClaimValidationOptions, R as JWTClaims } from './unjwt.Ca4-7Myr.mjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* This is a fork of Jose library's utility functions.
|
|
@@ -40,6 +40,16 @@ declare function generateJWK<TAlg extends GenerateKeyAlgorithm>(alg: TAlg, jwkPa
|
|
|
40
40
|
* @returns A Promise resolving to the derived key (CryptoKey) or its JWK_oct representation.
|
|
41
41
|
*/
|
|
42
42
|
declare function deriveKeyFromPassword<TAlg extends JWK_PBES2, TOptions extends DeriveKeyOptions>(password: string | Uint8Array<ArrayBuffer>, alg: TAlg, options: TOptions): Promise<DeriveKeyReturn<TOptions>>;
|
|
43
|
+
/**
|
|
44
|
+
* Derives a Json Web Key (JWK) from a password using PBKDF2 as specified by PBES2 algorithms.
|
|
45
|
+
*
|
|
46
|
+
* @param password The password to derive the key from (string or Uint8Array).
|
|
47
|
+
* @param alg The PBES2 algorithm identifier (e.g., "PBES2-HS256+A128KW").
|
|
48
|
+
* @param jwkParams Optional partial JWK to merge with the generated key, allowing overrides.
|
|
49
|
+
* @param options Configuration options including salt and iterations.
|
|
50
|
+
* @returns A Promise resolving to the derived JWK (JWK_oct).
|
|
51
|
+
*/
|
|
52
|
+
declare function deriveJWKFromPassword(password: string | Uint8Array<ArrayBuffer>, alg: JWK_PBES2, options: Omit<DeriveKeyOptions, "toJWK">, jwkParams?: Omit<JWKParameters, "alg" | "kty" | "key_ops" | "ext">): Promise<JWK_oct>;
|
|
43
53
|
/**
|
|
44
54
|
* Imports a key from various formats (CryptoKey, JWK, Uint8Array).
|
|
45
55
|
*
|
|
@@ -177,6 +187,7 @@ declare const jwk_KeyManagementAlgorithm: typeof KeyManagementAlgorithm;
|
|
|
177
187
|
declare const jwk_UnwrapKeyOptions: typeof UnwrapKeyOptions;
|
|
178
188
|
declare const jwk_WrapKeyOptions: typeof WrapKeyOptions;
|
|
179
189
|
declare const jwk_WrapKeyResult: typeof WrapKeyResult;
|
|
190
|
+
declare const jwk_deriveJWKFromPassword: typeof deriveJWKFromPassword;
|
|
180
191
|
declare const jwk_deriveKeyFromPassword: typeof deriveKeyFromPassword;
|
|
181
192
|
declare const jwk_exportJWKToPEM: typeof exportJWKToPEM;
|
|
182
193
|
declare const jwk_exportKey: typeof exportKey;
|
|
@@ -237,6 +248,7 @@ declare namespace jwk {
|
|
|
237
248
|
jwk_UnwrapKeyOptions as UnwrapKeyOptions,
|
|
238
249
|
jwk_WrapKeyOptions as WrapKeyOptions,
|
|
239
250
|
jwk_WrapKeyResult as WrapKeyResult,
|
|
251
|
+
jwk_deriveJWKFromPassword as deriveJWKFromPassword,
|
|
240
252
|
jwk_deriveKeyFromPassword as deriveKeyFromPassword,
|
|
241
253
|
jwk_exportJWKToPEM as exportJWKToPEM,
|
|
242
254
|
jwk_exportKey as exportKey,
|
|
@@ -250,4 +262,4 @@ declare namespace jwk {
|
|
|
250
262
|
};
|
|
251
263
|
}
|
|
252
264
|
|
|
253
|
-
export { generateJWK as a,
|
|
265
|
+
export { generateJWK as a, deriveJWKFromPassword as b, importJWKFromPEM as c, deriveKeyFromPassword as d, exportKey as e, exportJWKToPEM as f, generateKey as g, getJWKFromSet as h, importKey as i, jwk as j, unwrapKey as u, wrapKey as w };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { v as JWK_HMAC, w as JWK_RSA_SIGN, x as JWK_RSA_PSS, y as JWK_ECDSA, Q as JoseHeaderParameters, t as JWK, u as JWKSet, T as JWTClaimValidationOptions, R as JWTClaims, C as CompositeKey, f as ContentEncryptionAlgorithm, D as DeriveKeyOptions, e as DeriveKeyReturn, c as GenerateJWKOptions, d as GenerateJWKReturn, G as GenerateKeyAlgorithm, a as GenerateKeyOptions, b as GenerateKeyReturn, O as JWKAlgorithm, P as JWKPEMAlgorithm, J as JWKParameters, E as JWK_AES_CBC_HMAC, F as JWK_AES_GCM, B as JWK_AES_GCM_KW, A as JWK_AES_KW, N as JWK_Asymmetric_Algorithm, j as JWK_EC, I as JWK_ECDH_ES, i as JWK_EC_Private, h as JWK_EC_Public, p as JWK_OKP, o as JWK_OKP_Private, n as JWK_OKP_Public, L as JWK_OKP_SIGN, H as JWK_PBES2, s as JWK_Private, r as JWK_Public, m as JWK_RSA, z as JWK_RSA_ENC, l as JWK_RSA_Private, k as JWK_RSA_Public, M as JWK_Symmetric_Algorithm, q as JWK_oct, S as JWT, K as KeyManagementAlgorithm, U as UnwrapKeyOptions, W as WrapKeyOptions, g as WrapKeyResult } from './unjwt.
|
|
1
|
+
import { v as JWK_HMAC, w as JWK_RSA_SIGN, x as JWK_RSA_PSS, y as JWK_ECDSA, Q as JoseHeaderParameters, t as JWK, u as JWKSet, T as JWTClaimValidationOptions, R as JWTClaims, C as CompositeKey, f as ContentEncryptionAlgorithm, D as DeriveKeyOptions, e as DeriveKeyReturn, c as GenerateJWKOptions, d as GenerateJWKReturn, G as GenerateKeyAlgorithm, a as GenerateKeyOptions, b as GenerateKeyReturn, O as JWKAlgorithm, P as JWKPEMAlgorithm, J as JWKParameters, E as JWK_AES_CBC_HMAC, F as JWK_AES_GCM, B as JWK_AES_GCM_KW, A as JWK_AES_KW, N as JWK_Asymmetric_Algorithm, j as JWK_EC, I as JWK_ECDH_ES, i as JWK_EC_Private, h as JWK_EC_Public, p as JWK_OKP, o as JWK_OKP_Private, n as JWK_OKP_Public, L as JWK_OKP_SIGN, H as JWK_PBES2, s as JWK_Private, r as JWK_Public, m as JWK_RSA, z as JWK_RSA_ENC, l as JWK_RSA_Private, k as JWK_RSA_Public, M as JWK_Symmetric_Algorithm, q as JWK_oct, S as JWT, K as KeyManagementAlgorithm, U as UnwrapKeyOptions, W as WrapKeyOptions, g as WrapKeyResult } from './unjwt.Ca4-7Myr.mjs';
|
|
2
|
+
import { E as ExpiresIn } from './unjwt.b323eNLO.mjs';
|
|
2
3
|
|
|
3
4
|
type JWS_SIGN_EXTRA = "Ed25519" | "EdDSA";
|
|
4
5
|
/** JWS Signing Algorithm Identifier. */
|
|
@@ -35,7 +36,7 @@ interface JWSSignOptions {
|
|
|
35
36
|
/**
|
|
36
37
|
* Time at which the JWS should expire, if no `exp` was already provided.
|
|
37
38
|
*/
|
|
38
|
-
expiresIn?:
|
|
39
|
+
expiresIn?: ExpiresIn;
|
|
39
40
|
}
|
|
40
41
|
/** Result of JWS verification */
|
|
41
42
|
interface JWSVerifyResult<T extends JWTClaims | Uint8Array<ArrayBuffer> | string = JWTClaims | Uint8Array<ArrayBuffer> | string> {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as importKey, e as encryptKey, g as generateIV, a as encrypt$1, u as unwrapKey, d as decrypt$1 } from './unjwt.
|
|
2
|
-
import { r as randomBytes, a as isJWK, s as sanitizeObject, b as applyTypCtyDefaults, c as computeJwtTimeClaims, g as getPlaintextBytes, d as base64UrlEncode, t as textEncoder, e as base64UrlDecode, f as decodePayloadFromBytes, v as validateCriticalHeadersJWE, h as validateJwtClaims, j as isCryptoKeyPair, k as isCryptoKey } from './unjwt.
|
|
1
|
+
import { i as importKey, e as encryptKey, g as generateIV, a as encrypt$1, u as unwrapKey, d as decrypt$1 } from './unjwt.kE816XJO.mjs';
|
|
2
|
+
import { r as randomBytes, a as isJWK, s as sanitizeObject, b as applyTypCtyDefaults, c as computeJwtTimeClaims, g as getPlaintextBytes, d as base64UrlEncode, t as textEncoder, e as base64UrlDecode, f as decodePayloadFromBytes, v as validateCriticalHeadersJWE, h as validateJwtClaims, j as isCryptoKeyPair, k as isCryptoKey } from './unjwt.BhoZWy2Y.mjs';
|
|
3
3
|
|
|
4
4
|
async function encrypt(payload, key, options = {}) {
|
|
5
5
|
const {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { R as JWTClaims, T as JWTClaimValidationOptions, t as JWK, u as JWKSet, q as JWK_oct, s as JWK_Private, r as JWK_Public } from './unjwt.
|
|
1
|
+
import { R as JWTClaims, T as JWTClaimValidationOptions, t as JWK, u as JWKSet, q as JWK_oct, s as JWK_Private, r as JWK_Public } from './unjwt.Ca4-7Myr.mjs';
|
|
2
|
+
import { E as ExpiresIn } from './unjwt.b323eNLO.mjs';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Apply default typ/cty semantics shared by JWS & JWE.
|
|
@@ -37,8 +38,9 @@ declare function decodePayloadFromB64UrlSegment<T = unknown>(payloadEncoded: str
|
|
|
37
38
|
} | undefined, forceUint8Array?: boolean): T | Uint8Array<ArrayBuffer> | string;
|
|
38
39
|
/** Convert plaintext input to bytes, shared by JWS & JWE when preparing payload. */
|
|
39
40
|
declare function getPlaintextBytes(payload: string | Uint8Array<ArrayBuffer> | Record<string, any>): Uint8Array<ArrayBuffer>;
|
|
41
|
+
declare function computeExpiresInSeconds(expiresIn: ExpiresIn): number;
|
|
40
42
|
/** Optionally compute iat/exp when signing JWTs. */
|
|
41
|
-
declare function computeJwtTimeClaims(payload: unknown, headerTyp: string | undefined, expiresIn?:
|
|
43
|
+
declare function computeJwtTimeClaims(payload: unknown, headerTyp: string | undefined, expiresIn?: ExpiresIn, currentDate?: Date): JWTClaims | undefined;
|
|
42
44
|
/** Validate JWT claims under JWS verification rules (or custom JWE implementations). */
|
|
43
45
|
declare function validateJwtClaims(jwtClaims: JWTClaims, options?: JWTClaimValidationOptions): void;
|
|
44
46
|
/** Validate critical headers in JWS semantics. */
|
|
@@ -105,6 +107,7 @@ declare const index_base64Decode: typeof base64Decode;
|
|
|
105
107
|
declare const index_base64Encode: typeof base64Encode;
|
|
106
108
|
declare const index_base64UrlDecode: typeof base64UrlDecode;
|
|
107
109
|
declare const index_base64UrlEncode: typeof base64UrlEncode;
|
|
110
|
+
declare const index_computeExpiresInSeconds: typeof computeExpiresInSeconds;
|
|
108
111
|
declare const index_computeJwtTimeClaims: typeof computeJwtTimeClaims;
|
|
109
112
|
declare const index_concatUint8Arrays: typeof concatUint8Arrays;
|
|
110
113
|
declare const index_decodeMaybeJWTString: typeof decodeMaybeJWTString;
|
|
@@ -136,6 +139,7 @@ declare namespace index {
|
|
|
136
139
|
index_base64Encode as base64Encode,
|
|
137
140
|
index_base64UrlDecode as base64UrlDecode,
|
|
138
141
|
index_base64UrlEncode as base64UrlEncode,
|
|
142
|
+
index_computeExpiresInSeconds as computeExpiresInSeconds,
|
|
139
143
|
index_computeJwtTimeClaims as computeJwtTimeClaims,
|
|
140
144
|
index_concatUint8Arrays as concatUint8Arrays,
|
|
141
145
|
index_decodeMaybeJWTString as decodeMaybeJWTString,
|
|
@@ -162,4 +166,4 @@ declare namespace index {
|
|
|
162
166
|
};
|
|
163
167
|
}
|
|
164
168
|
|
|
165
|
-
export {
|
|
169
|
+
export { computeJwtTimeClaims as A, validateJwtClaims as B, validateCriticalHeadersJWS as C, validateCriticalHeadersJWE as D, sanitizeObject as E, textDecoder as a, base64Encode as b, base64UrlEncode as c, base64Decode as d, base64UrlDecode as e, concatUint8Arrays as f, isJWK as g, isJWKSet as h, index as i, assertCryptoKey as j, isCryptoKey as k, isCryptoKeyPair as l, maybeArray as m, isSymmetricJWK as n, isAsymmetricJWK as o, isPrivateJWK as p, isPublicJWK as q, randomBytes as r, applyTypCtyDefaults as s, textEncoder as t, isJWTContent as u, decodeMaybeJWTString as v, decodePayloadFromBytes as w, decodePayloadFromB64UrlSegment as x, getPlaintextBytes as y, computeExpiresInSeconds as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { k as isCryptoKey, p as concatUint8Arrays, d as base64UrlEncode, q as base64Decode, u as base64Encode, t as textEncoder, s as sanitizeObject, w as assertCryptoKey, a as isJWK, e as base64UrlDecode, x as isAsymmetricJWK, r as randomBytes, m as isJWKSet } from './unjwt.
|
|
1
|
+
import { k as isCryptoKey, p as concatUint8Arrays, d as base64UrlEncode, q as base64Decode, u as base64Encode, t as textEncoder, s as sanitizeObject, w as assertCryptoKey, a as isJWK, e as base64UrlDecode, x as isAsymmetricJWK, r as randomBytes, m as isJWKSet } from './unjwt.BhoZWy2Y.mjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* This is a fork of Jose library's utility functions.
|
|
@@ -1488,7 +1488,8 @@ async function generateJWK(alg, jwkParams, options = {}) {
|
|
|
1488
1488
|
});
|
|
1489
1489
|
}
|
|
1490
1490
|
async function deriveKeyFromPassword(password, alg, options) {
|
|
1491
|
-
const { salt, iterations,
|
|
1491
|
+
const { salt, iterations, extractable, keyUsage } = options;
|
|
1492
|
+
const exportToJWK = options.toJWK !== void 0 && options.toJWK !== false;
|
|
1492
1493
|
if (!(salt instanceof Uint8Array) || salt.length < 8) {
|
|
1493
1494
|
throw new Error("PBES2 Salt Input (salt) must be 8 or more octets");
|
|
1494
1495
|
}
|
|
@@ -1507,7 +1508,7 @@ async function deriveKeyFromPassword(password, alg, options) {
|
|
|
1507
1508
|
const wrappingAlg = alg.slice(-6);
|
|
1508
1509
|
const defaultUsages = ["wrapKey", "unwrapKey"];
|
|
1509
1510
|
const finalUsages = keyUsage ?? defaultUsages;
|
|
1510
|
-
const finalExtractable =
|
|
1511
|
+
const finalExtractable = exportToJWK ? true : extractable === true;
|
|
1511
1512
|
const derivedKey = await crypto.subtle.importKey(
|
|
1512
1513
|
"raw",
|
|
1513
1514
|
derivedBytes,
|
|
@@ -1515,12 +1516,30 @@ async function deriveKeyFromPassword(password, alg, options) {
|
|
|
1515
1516
|
finalExtractable,
|
|
1516
1517
|
finalUsages
|
|
1517
1518
|
);
|
|
1518
|
-
if (
|
|
1519
|
+
if (exportToJWK) {
|
|
1519
1520
|
const jwk = await keyToJWK(derivedKey);
|
|
1520
|
-
|
|
1521
|
+
const {
|
|
1522
|
+
alg: _a,
|
|
1523
|
+
kty: _k,
|
|
1524
|
+
key_ops: _ko,
|
|
1525
|
+
ext: _e,
|
|
1526
|
+
...additionalKeyParams
|
|
1527
|
+
} = typeof options.toJWK === "object" ? options.toJWK : {};
|
|
1528
|
+
return { ...additionalKeyParams, ...jwk, alg: wrappingAlg, kty: "oct" };
|
|
1521
1529
|
}
|
|
1522
1530
|
return derivedKey;
|
|
1523
1531
|
}
|
|
1532
|
+
async function deriveJWKFromPassword(password, alg, options, jwkParams) {
|
|
1533
|
+
const {
|
|
1534
|
+
// @ts-expect-error destructuring just to avoid passing it down
|
|
1535
|
+
toJWK: _,
|
|
1536
|
+
...opts
|
|
1537
|
+
} = options;
|
|
1538
|
+
return deriveKeyFromPassword(password, alg, {
|
|
1539
|
+
...opts,
|
|
1540
|
+
toJWK: jwkParams || true
|
|
1541
|
+
});
|
|
1542
|
+
}
|
|
1524
1543
|
async function importKey(key, alg) {
|
|
1525
1544
|
if (typeof key === "string") {
|
|
1526
1545
|
key = textEncoder.encode(key);
|
|
@@ -2090,6 +2109,7 @@ function inferAesImportAlgorithm(enc, cekLengthBytes) {
|
|
|
2090
2109
|
|
|
2091
2110
|
const jwk = {
|
|
2092
2111
|
__proto__: null,
|
|
2112
|
+
deriveJWKFromPassword: deriveJWKFromPassword,
|
|
2093
2113
|
deriveKeyFromPassword: deriveKeyFromPassword,
|
|
2094
2114
|
exportJWKToPEM: exportJWKToPEM,
|
|
2095
2115
|
exportKey: exportKey,
|
|
@@ -2102,4 +2122,4 @@ const jwk = {
|
|
|
2102
2122
|
wrapKey: wrapKey
|
|
2103
2123
|
};
|
|
2104
2124
|
|
|
2105
|
-
export { encrypt as a, getJWKFromSet as b, generateKey as c, decrypt as d, encryptKey as e, generateJWK as f, generateIV as g, deriveKeyFromPassword as h, importKey as i, jwk as j,
|
|
2125
|
+
export { encrypt as a, getJWKFromSet as b, generateKey as c, decrypt as d, encryptKey as e, generateJWK as f, generateIV as g, deriveKeyFromPassword as h, importKey as i, jwk as j, deriveJWKFromPassword as k, exportKey as l, importJWKFromPEM as m, exportJWKToPEM as n, sign as s, unwrapKey as u, verify as v, wrapKey as w };
|
package/dist/utils.d.mts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import './shared/unjwt.
|
|
2
|
-
export { s as applyTypCtyDefaults, j as assertCryptoKey, d as base64Decode, b as base64Encode, e as base64UrlDecode, c as base64UrlEncode, z as computeJwtTimeClaims, f as concatUint8Arrays, v as decodeMaybeJWTString, x as decodePayloadFromB64UrlSegment, w as decodePayloadFromBytes, y as getPlaintextBytes, o as isAsymmetricJWK, k as isCryptoKey, l as isCryptoKeyPair, g as isJWK, h as isJWKSet, u as isJWTContent, p as isPrivateJWK, q as isPublicJWK, n as isSymmetricJWK, m as maybeArray, r as randomBytes,
|
|
1
|
+
import './shared/unjwt.Ca4-7Myr.mjs';
|
|
2
|
+
export { s as applyTypCtyDefaults, j as assertCryptoKey, d as base64Decode, b as base64Encode, e as base64UrlDecode, c as base64UrlEncode, z as computeExpiresInSeconds, A as computeJwtTimeClaims, f as concatUint8Arrays, v as decodeMaybeJWTString, x as decodePayloadFromB64UrlSegment, w as decodePayloadFromBytes, y as getPlaintextBytes, o as isAsymmetricJWK, k as isCryptoKey, l as isCryptoKeyPair, g as isJWK, h as isJWKSet, u as isJWTContent, p as isPrivateJWK, q as isPublicJWK, n as isSymmetricJWK, m as maybeArray, r as randomBytes, E as sanitizeObject, a as textDecoder, t as textEncoder, D as validateCriticalHeadersJWE, C as validateCriticalHeadersJWS, B as validateJwtClaims } from './shared/unjwt.cZWaB7OK.mjs';
|
|
3
|
+
import './shared/unjwt.b323eNLO.mjs';
|
package/dist/utils.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { b as applyTypCtyDefaults, w as assertCryptoKey, q as base64Decode, u as base64Encode, e as base64UrlDecode, d as base64UrlEncode, c as computeJwtTimeClaims, p as concatUint8Arrays, D as decodeMaybeJWTString, n as decodePayloadFromB64UrlSegment, f as decodePayloadFromBytes, g as getPlaintextBytes, x as isAsymmetricJWK, k as isCryptoKey, j as isCryptoKeyPair, a as isJWK, m as isJWKSet, C as isJWTContent, A as isPrivateJWK, B as isPublicJWK, z as isSymmetricJWK, y as maybeArray, r as randomBytes, s as sanitizeObject, l as textDecoder, t as textEncoder, v as validateCriticalHeadersJWE, o as validateCriticalHeadersJWS, h as validateJwtClaims } from './shared/unjwt.
|
|
1
|
+
export { b as applyTypCtyDefaults, w as assertCryptoKey, q as base64Decode, u as base64Encode, e as base64UrlDecode, d as base64UrlEncode, E as computeExpiresInSeconds, c as computeJwtTimeClaims, p as concatUint8Arrays, D as decodeMaybeJWTString, n as decodePayloadFromB64UrlSegment, f as decodePayloadFromBytes, g as getPlaintextBytes, x as isAsymmetricJWK, k as isCryptoKey, j as isCryptoKeyPair, a as isJWK, m as isJWKSet, C as isJWTContent, A as isPrivateJWK, B as isPublicJWK, z as isSymmetricJWK, y as maybeArray, r as randomBytes, s as sanitizeObject, l as textDecoder, t as textEncoder, v as validateCriticalHeadersJWE, o as validateCriticalHeadersJWS, h as validateJwtClaims } from './shared/unjwt.BhoZWy2Y.mjs';
|