unjwt 0.7.1 → 0.7.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/dist/_chunks/_internal.mjs +5 -5
- package/dist/_chunks/index.d.mts +30 -7
- package/dist/_chunks/jwe.d.mts +2 -2
- package/dist/_chunks/jwe.mjs +5 -5
- package/dist/_chunks/jwk.mjs +24 -9
- package/dist/_chunks/jws.d.mts +2 -2
- package/dist/_chunks/jws.mjs +5 -5
- package/dist/_chunks/libs/unsecure.d.mts +1 -1
- package/dist/_chunks/libs/unsecure.mjs +1 -1
- package/dist/_chunks/utils.mjs +2 -2
- package/dist/adapters/elysia/index.d.mts +244 -0
- package/dist/adapters/elysia/index.mjs +608 -0
- package/dist/adapters/h3v1/index.d.mts +120 -42
- package/dist/adapters/h3v1/index.mjs +16 -13
- package/dist/adapters/h3v2/index.d.mts +140 -20
- package/dist/adapters/h3v2/index.mjs +16 -13
- package/dist/core/jwe.d.mts +3 -3
- package/dist/core/jwe.mjs +2 -2
- package/dist/core/jwk.d.mts +10 -10
- package/dist/core/jwk.mjs +2 -2
- package/dist/core/jws.d.mts +3 -3
- package/dist/core/jws.mjs +2 -2
- package/dist/core/utils/index.d.mts +20 -7
- package/dist/core/utils/index.mjs +2 -2
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +4 -4
- package/package.json +21 -12
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { JWTError, decodePayloadFromB64UrlSegment, inferJWEAllowedAlgorithms, inferJWSAllowedAlgorithms, isCryptoKey, isCryptoKeyPair, isJWK, validateJwtClaims } from "./utils.mjs";
|
|
2
|
+
import { base64UrlDecode, safeJsonParse, textEncoder } from "./libs/unsecure.mjs";
|
|
3
|
+
import { assertOctKeyLength } from "./jwk.mjs";
|
|
3
4
|
function buildJWKSetFilter(header) {
|
|
4
5
|
const kid = header?.kid;
|
|
5
6
|
const alg = header?.alg;
|
|
@@ -35,8 +36,7 @@ function parseEphemeralKey(ephemeralKey) {
|
|
|
35
36
|
}
|
|
36
37
|
async function resolveSigningKey(alg, key, usage) {
|
|
37
38
|
if (key instanceof Uint8Array) {
|
|
38
|
-
|
|
39
|
-
if (key.length < minBytes) throw new JWTError(`${alg} requires a key of at least ${minBytes} bytes`, "ERR_JWK_INVALID");
|
|
39
|
+
assertOctKeyLength(key, alg);
|
|
40
40
|
return crypto.subtle.importKey("raw", key, {
|
|
41
41
|
name: "HMAC",
|
|
42
42
|
hash: `SHA-${alg.slice(-3)}`
|
|
@@ -85,4 +85,4 @@ function decodeJWSPayload(payloadSegment, useB64, forceUint8Array) {
|
|
|
85
85
|
if (useB64) return decodePayloadFromB64UrlSegment(payloadSegment, forceUint8Array);
|
|
86
86
|
return forceUint8Array ? textEncoder.encode(payloadSegment) : payloadSegment;
|
|
87
87
|
}
|
|
88
|
-
export {
|
|
88
|
+
export { JWE_ALG_CTX, JWS_ALG_CTX, buildJWKSetFilter, checkAlgAllowed, decodeJWSPayload, decodeProtectedHeader, parseEphemeralKey, resolveSigningKey, validateJwtClaimsIfJsonPayload };
|
package/dist/_chunks/index.d.mts
CHANGED
|
@@ -66,7 +66,12 @@ type GenerateKeyAlgorithm = Exclude<JWKAlgorithm, "none" | "dir" | JWK_PBES2>;
|
|
|
66
66
|
interface GenerateKeyOptions {
|
|
67
67
|
/** Key usages for the generated key(s). Note: For composite keys (CBC), default usages are applied separately. */
|
|
68
68
|
keyUsage?: KeyUsage[];
|
|
69
|
-
/**
|
|
69
|
+
/**
|
|
70
|
+
* Mark the key(s) as extractable. Defaults to true. Ignored when `toJWK` is set —
|
|
71
|
+
* the JWK output requires exporting the intermediate key. For long-lived asymmetric
|
|
72
|
+
* private keys that should never leave the runtime, prefer `false` (and omit `toJWK`):
|
|
73
|
+
* the key still signs/decrypts but its material cannot be exported.
|
|
74
|
+
*/
|
|
70
75
|
extractable?: boolean;
|
|
71
76
|
/** RSA modulus length. Defaults to 2048. */
|
|
72
77
|
modulusLength?: number;
|
|
@@ -84,7 +89,7 @@ interface GenerateKeyOptions {
|
|
|
84
89
|
type GenerateKeyReturnJWK<TAlg extends GenerateKeyAlgorithm> = TAlg extends JWK_Asymmetric_Algorithm ? JWK_Pair<TAlg> : TAlg extends JWK_AES_CBC_HMAC | JWK_Symmetric_Algorithm ? JWK_oct<TAlg> : never;
|
|
85
90
|
type GenerateKeyReturnCrypto<TAlg extends GenerateKeyAlgorithm> = TAlg extends JWK_AES_CBC_HMAC ? Uint8Array<ArrayBuffer> : TAlg extends JWK_Asymmetric_Algorithm ? CryptoKeyPair : CryptoKey;
|
|
86
91
|
type GenerateKeyReturn<TAlg extends GenerateKeyAlgorithm, TOptions extends GenerateKeyOptions> = TOptions["toJWK"] extends true ? GenerateKeyReturnJWK<TAlg> : GenerateKeyReturnCrypto<TAlg>;
|
|
87
|
-
type GenerateJWKOptions = Omit<GenerateKeyOptions, "toJWK">;
|
|
92
|
+
type GenerateJWKOptions = Omit<GenerateKeyOptions, "toJWK" | "extractable">;
|
|
88
93
|
type GenerateJWKReturn<TAlg extends GenerateKeyAlgorithm> = GenerateKeyReturnJWK<TAlg>;
|
|
89
94
|
/** Options for the deriveKeyFromPassword function. */
|
|
90
95
|
interface DeriveKeyOptions {
|
|
@@ -94,7 +99,7 @@ interface DeriveKeyOptions {
|
|
|
94
99
|
iterations: number;
|
|
95
100
|
/** Key usages for the derived key. Defaults to ["wrapKey", "unwrapKey"]. */
|
|
96
101
|
keyUsage?: KeyUsage[];
|
|
97
|
-
/** Mark the derived key as extractable. Defaults to false. */
|
|
102
|
+
/** Mark the derived key as extractable. Defaults to false. Ignored when `toJWK` is set — the JWK output requires exporting the derived key. */
|
|
98
103
|
extractable?: boolean;
|
|
99
104
|
/**
|
|
100
105
|
* Export the derived key as JWK_oct. When `true`, returns the derived key in
|
|
@@ -126,7 +131,15 @@ type WrappingKeyFor<A extends KeyManagementAlgorithm> = A extends JWK_RSA_ENC ?
|
|
|
126
131
|
type UnwrappingKeyFor<A extends KeyManagementAlgorithm> = A extends JWK_RSA_ENC ? CryptoKey | JWK_RSA_Private<A> : A extends JWK_ECDH_ES ? CryptoKey | JWK_EC_Private<A> | JWK_OKP_Private<A> : A extends JWK_PBES2 ? string | Uint8Array<ArrayBuffer> | JWK_oct<A> : A extends JWK_AES_KW ? CryptoKey | JWK_oct<A> : A extends JWK_AES_GCM_KW ? CryptoKey | JWK_oct<A | `A${"128" | "192" | "256"}GCM`> : A extends "dir" ? CryptoKey | JWK_oct | Uint8Array<ArrayBuffer> : never;
|
|
127
132
|
/** Options for the wrapKey function. */
|
|
128
133
|
interface WrapKeyOptions {
|
|
129
|
-
/**
|
|
134
|
+
/**
|
|
135
|
+
* Initialization Vector for AES-GCMKW. A fresh random IV is generated when
|
|
136
|
+
* not provided — production code should always omit this option.
|
|
137
|
+
*
|
|
138
|
+
* **Never reuse an IV and never derive it from external input.** A single
|
|
139
|
+
* IV reused under the same wrapping key breaks AES-GCM entirely (plaintext
|
|
140
|
+
* recovery and forgery). Provided only for tests and reproduction of known
|
|
141
|
+
* vectors in security research.
|
|
142
|
+
*/
|
|
130
143
|
iv?: Uint8Array<ArrayBuffer>;
|
|
131
144
|
/** PBES2 Salt value (p2s). Required for PBES2 algorithms. */
|
|
132
145
|
p2s?: Uint8Array<ArrayBuffer>;
|
|
@@ -654,7 +667,12 @@ interface JWSVerifyResult<T extends JOSEPayload = JOSEPayload> {
|
|
|
654
667
|
}
|
|
655
668
|
/** Options for JWS verification */
|
|
656
669
|
interface JWSVerifyOptions extends JWTClaimValidationOptions {
|
|
657
|
-
/**
|
|
670
|
+
/**
|
|
671
|
+
* List of allowed algorithms. If provided, the JWS `alg` must be in this list.
|
|
672
|
+
* When omitted, the allowlist is inferred from the key's shape — keys without
|
|
673
|
+
* usable metadata (raw `Uint8Array`/string, alg-less JWKs, lookup functions)
|
|
674
|
+
* cannot be inferred and require this option explicitly.
|
|
675
|
+
*/
|
|
658
676
|
algorithms?: JWSAlgorithm[];
|
|
659
677
|
/** If true, forces the payload to be returned as a Uint8Array, otherwise type is inferred. */
|
|
660
678
|
forceUint8Array?: boolean;
|
|
@@ -949,7 +967,12 @@ interface JWEEncryptOptions {
|
|
|
949
967
|
* JWE (JSON Web Encryption) decryption options
|
|
950
968
|
*/
|
|
951
969
|
interface JWEDecryptOptions extends JWTClaimValidationOptions {
|
|
952
|
-
/**
|
|
970
|
+
/**
|
|
971
|
+
* A list of allowed JWE "alg" (Algorithm) Header Parameter values for key management.
|
|
972
|
+
* When omitted, the allowlist is inferred from the key's shape — password strings
|
|
973
|
+
* and raw `Uint8Array` keys infer the PBES2 family plus `dir`; lookup functions
|
|
974
|
+
* cannot be inferred and require this option explicitly.
|
|
975
|
+
*/
|
|
953
976
|
algorithms?: KeyManagementAlgorithm[];
|
|
954
977
|
/** A list of allowed JWE "enc" (Encryption Algorithm) Header Parameter values for content encryption. */
|
|
955
978
|
encryptionAlgorithms?: ContentEncryptionAlgorithm[];
|
|
@@ -1116,4 +1139,4 @@ type ExpiresIn = Duration;
|
|
|
1116
1139
|
type NotBeforeIn = Duration;
|
|
1117
1140
|
/** Duration for `maxTokenAge` validation on {@link verify} / {@link decrypt}. */
|
|
1118
1141
|
type MaxTokenAge = Duration;
|
|
1119
|
-
export {
|
|
1142
|
+
export { CompositeKey, ContentEncryptionAlgorithm, DeriveKeyOptions, DeriveKeyReturn, Duration, ExpiresIn, GenerateJWKOptions, GenerateJWKReturn, GenerateKeyAlgorithm, GenerateKeyOptions, GenerateKeyReturn, JOSEPayload, JWEAsymmetricPrivateJWK, JWEAsymmetricPublicJWK, JWEDecryptJWK, JWEDecryptOptions, JWEDecryptResult, JWEEncryptJWK, JWEEncryptOptions, JWEFlattenedSerialization, JWEGeneralRecipient, JWEGeneralSerialization, JWEHeaderParameters, JWEKeyManagementHeaderParameters, JWEMultiDecryptOptions, JWEMultiDecryptResult, JWEMultiEncryptOptions, JWEMultiRecipient, JWEProtectedHeader, JWK, JWKAlgorithm, JWKCacheAdapter, JWKLookupFunction, JWKLookupFunctionHeader, JWKPEMAlgorithm, JWKParameters, JWKSet, JWK_AES_CBC_HMAC, JWK_AES_GCM, JWK_AES_GCM_KW, JWK_AES_KW, JWK_Asymmetric, JWK_Asymmetric_Algorithm, JWK_EC, JWK_ECDH_ES, JWK_ECDSA, JWK_EC_Private, JWK_EC_Public, JWK_HMAC, JWK_OKP, JWK_OKP_Private, JWK_OKP_Public, JWK_OKP_SIGN, JWK_PBES2, JWK_Pair, JWK_Private, JWK_Public, JWK_RSA, JWK_RSA_ENC, JWK_RSA_PSS, JWK_RSA_Private, JWK_RSA_Public, JWK_RSA_SIGN, JWK_Symmetric, JWK_Symmetric_Algorithm, JWK_oct, JWSAlgorithm, JWSAsymmetricPrivateJWK, JWSAsymmetricPublicJWK, JWSFlattenedSerialization, JWSGeneralSerialization, JWSGeneralSignature, JWSHeaderParameters, JWSMultiSignOptions, JWSMultiSigner, JWSMultiVerifyAllOptions, JWSMultiVerifyOptions, JWSMultiVerifyOutcome, JWSMultiVerifyResult, JWSProtectedHeader, JWSSignJWK, JWSSignOptions, JWSVerifyJWK, JWSVerifyOptions, JWSVerifyResult, JWT, JWTClaimValidationOptions, JWTClaims, JWTError, JWTErrorCauseMap, JWTErrorCode, JoseHeaderParameters, KeyManagementAlgorithm, MaxTokenAge, NotBeforeIn, StrictOmit, UnwrapKeyOptions, UnwrappingKeyFor, WrapKeyOptions, WrapKeyResult, WrappingKeyFor, isJWTError };
|
package/dist/_chunks/jwe.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ContentEncryptionAlgorithm, JOSEPayload, JWEDecryptJWK, JWEDecryptOptions, JWEDecryptResult, JWEEncryptJWK, JWEEncryptOptions, JWEFlattenedSerialization, JWEGeneralSerialization, JWEMultiDecryptOptions, JWEMultiDecryptResult, JWEMultiEncryptOptions, JWEMultiRecipient, JWKLookupFunction, JWKSet, KeyManagementAlgorithm } from "./index.mjs";
|
|
2
2
|
/**
|
|
3
3
|
* Encrypt a payload to multiple recipients using JWE General JSON Serialization
|
|
4
4
|
* (RFC 7516 §7.2.1).
|
|
@@ -81,4 +81,4 @@ declare function decrypt<T extends JOSEPayload>(jwe: string, key: CryptoKey | JW
|
|
|
81
81
|
declare function decrypt(jwe: string, key: CryptoKey | JWKSet | JWEDecryptJWK | string | Uint8Array<ArrayBuffer> | JWKLookupFunction, options: JWEDecryptOptions & {
|
|
82
82
|
forceUint8Array: true;
|
|
83
83
|
}): Promise<JWEDecryptResult<Uint8Array<ArrayBuffer>>>;
|
|
84
|
-
export {
|
|
84
|
+
export { decrypt, decryptMulti, encrypt, encryptMulti, generalToFlattened };
|
package/dist/_chunks/jwe.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { JWTError, applyTypCtyDefaults, computeJwtTimeClaims, decodePayloadFromBytes, getPlaintextBytes, isCryptoKey, isJWK, isJWKSet, validateCriticalHeadersJWE } from "./utils.mjs";
|
|
2
|
+
import { base64UrlDecode, base64UrlEncode, sanitizeObjectCopy, secureRandomBytes, textEncoder } from "./libs/unsecure.mjs";
|
|
3
|
+
import { decrypt as decrypt$1, encrypt as encrypt$1, encryptKey, generateCEK, generateIV, getJWKsFromSet, importKey, unwrapKey } from "./jwk.mjs";
|
|
4
|
+
import { JWE_ALG_CTX, buildJWKSetFilter, checkAlgAllowed, decodeProtectedHeader, parseEphemeralKey, validateJwtClaimsIfJsonPayload } from "./_internal.mjs";
|
|
5
5
|
const DIRECT_ALGS = /* @__PURE__ */ new Set(["dir", "ECDH-ES"]);
|
|
6
6
|
async function encryptMulti(payload, recipients, options = {}) {
|
|
7
7
|
if (!Array.isArray(recipients) || recipients.length === 0) throw new JWTError("encryptMulti requires at least one recipient.", "ERR_JWE_INVALID");
|
|
@@ -404,4 +404,4 @@ function _buildJWEHeader(alg, enc, key, userHeader, keyManagementParams, payload
|
|
|
404
404
|
header.enc = enc;
|
|
405
405
|
return applyTypCtyDefaults(header, payload);
|
|
406
406
|
}
|
|
407
|
-
export {
|
|
407
|
+
export { decrypt, decryptMulti, encrypt, encryptMulti, generalToFlattened };
|
package/dist/_chunks/jwk.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { JWTError, assertCryptoKey, concatUint8Arrays, isAsymmetricJWK, isCryptoKey, isCryptoKeyPair, isJWK, isJWKSet } from "./utils.mjs";
|
|
2
|
+
import { base64Decode, base64Encode, base64UrlDecode, base64UrlEncode, sanitizeObjectCopy, secureRandomBytes, textEncoder } from "./libs/unsecure.mjs";
|
|
3
3
|
async function sign(alg, key, data) {
|
|
4
4
|
checkSigCryptoKey(key, alg, "sign");
|
|
5
5
|
const signature = await crypto.subtle.sign(subtleAlgorithm(alg, key.algorithm), key, data);
|
|
@@ -151,6 +151,16 @@ function checkCEKLength(cek, expected) {
|
|
|
151
151
|
const actual = cek.byteLength << 3;
|
|
152
152
|
if (actual !== expected) throw new Error(`Invalid Content Encryption Key length. Expected ${expected} bits, got ${actual} bits`);
|
|
153
153
|
}
|
|
154
|
+
function assertOctKeyLength(bytes, alg) {
|
|
155
|
+
if (!alg) return;
|
|
156
|
+
if (alg === "HS256" || alg === "HS384" || alg === "HS512") {
|
|
157
|
+
const minBytes = Number.parseInt(alg.slice(2), 10) >> 3;
|
|
158
|
+
if (bytes.length < minBytes) throw new JWTError(`${alg} requires a key of at least ${minBytes} bytes (got ${bytes.length})`, "ERR_JWK_INVALID");
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
const exactBits = /^A(128|192|256)(GCM)?KW$/.test(alg) ? Number.parseInt(alg.slice(1, 4), 10) : CEK_BIT_LENGTHS[alg];
|
|
162
|
+
if (exactBits !== void 0 && bytes.length << 3 !== exactBits) throw new JWTError(`${alg} requires a key of exactly ${exactBits >> 3} bytes (got ${bytes.length})`, "ERR_JWK_INVALID");
|
|
163
|
+
}
|
|
154
164
|
function checkAESCryptoKey(key, alg, usage) {
|
|
155
165
|
switch (alg) {
|
|
156
166
|
case "A128GCM":
|
|
@@ -1011,7 +1021,7 @@ const getSPKI = (x509) => {
|
|
|
1011
1021
|
};
|
|
1012
1022
|
async function generateKey(alg, options = {}) {
|
|
1013
1023
|
const exportToJWK = options.toJWK !== void 0 && options.toJWK !== false;
|
|
1014
|
-
const defaultExtractable = options.extractable !== false;
|
|
1024
|
+
const defaultExtractable = exportToJWK || options.extractable !== false;
|
|
1015
1025
|
if (alg === "A128CBC-HS256" || alg === "A192CBC-HS384" || alg === "A256CBC-HS512") {
|
|
1016
1026
|
const keyBytes = secureRandomBytes(bitLengthCEK(alg) >> 3);
|
|
1017
1027
|
if (exportToJWK) return keyToJWK(keyBytes);
|
|
@@ -1039,7 +1049,7 @@ async function generateKey(alg, options = {}) {
|
|
|
1039
1049
|
return key;
|
|
1040
1050
|
}
|
|
1041
1051
|
async function generateJWK(alg, options) {
|
|
1042
|
-
const { keyUsage,
|
|
1052
|
+
const { keyUsage, modulusLength, publicExponent, namedCurve, ...jwkParams } = options ?? {};
|
|
1043
1053
|
const kid = typeof jwkParams.kid === "string" ? jwkParams.kid : crypto.randomUUID();
|
|
1044
1054
|
const extraParams = {
|
|
1045
1055
|
...jwkParams,
|
|
@@ -1047,7 +1057,6 @@ async function generateJWK(alg, options) {
|
|
|
1047
1057
|
};
|
|
1048
1058
|
const result = await generateKey(alg, {
|
|
1049
1059
|
keyUsage,
|
|
1050
|
-
extractable,
|
|
1051
1060
|
modulusLength,
|
|
1052
1061
|
publicExponent,
|
|
1053
1062
|
namedCurve,
|
|
@@ -1089,12 +1098,11 @@ async function deriveKeyFromPassword(password, alg, options) {
|
|
|
1089
1098
|
return derivedKey;
|
|
1090
1099
|
}
|
|
1091
1100
|
async function deriveJWKFromPassword(password, alg, options) {
|
|
1092
|
-
const { salt, iterations, keyUsage,
|
|
1101
|
+
const { salt, iterations, keyUsage, ...jwkParams } = options;
|
|
1093
1102
|
const result = await deriveKeyFromPassword(password, alg, {
|
|
1094
1103
|
salt,
|
|
1095
1104
|
iterations,
|
|
1096
1105
|
keyUsage,
|
|
1097
|
-
extractable,
|
|
1098
1106
|
toJWK: true
|
|
1099
1107
|
});
|
|
1100
1108
|
return Object.keys(jwkParams).length > 0 ? {
|
|
@@ -1131,9 +1139,16 @@ async function importKey(key, algOrOptions) {
|
|
|
1131
1139
|
}
|
|
1132
1140
|
if (isJWK(key)) if ("k" in key && typeof key.k === "string") {
|
|
1133
1141
|
const rawBytes = base64UrlDecode(key.k, { returnAs: "uint8array" });
|
|
1142
|
+
assertOctKeyLength(rawBytes, key.alg || alg);
|
|
1134
1143
|
if (typeof algOrOptions === "object" && algOrOptions.asCryptoKey) {
|
|
1135
1144
|
const { algorithm, usage, extractable = false } = algOrOptions;
|
|
1136
1145
|
if (!algorithm || !usage) throw new JWTError("asCryptoKey option requires `algorithm` and `usage` to be provided.", "ERR_JWK_INVALID");
|
|
1146
|
+
if (typeof algorithm === "object" && algorithm.name === "HMAC") {
|
|
1147
|
+
const hash = algorithm.hash;
|
|
1148
|
+
const hashName = typeof hash === "string" ? hash : hash?.name;
|
|
1149
|
+
const minBytes = Number.parseInt(hashName?.slice(-3) ?? "", 10) / 8;
|
|
1150
|
+
if (minBytes && rawBytes.length < minBytes) throw new JWTError(`HMAC with ${hashName} requires a key of at least ${minBytes} bytes (got ${rawBytes.length})`, "ERR_JWK_INVALID");
|
|
1151
|
+
}
|
|
1137
1152
|
return crypto.subtle.importKey("raw", rawBytes, algorithm, extractable, usage);
|
|
1138
1153
|
}
|
|
1139
1154
|
return rawBytes;
|
|
@@ -1310,7 +1325,7 @@ async function unwrapKey(alg, wrappedKey, unwrappingKey, options = {}) {
|
|
|
1310
1325
|
return await crypto.subtle.importKey("raw", unwrappedCekBytes, options.unwrappedKeyAlgorithm || { name: "AES-GCM" }, defaultExtractable, options.keyUsage || ["encrypt", "decrypt"]);
|
|
1311
1326
|
}
|
|
1312
1327
|
async function importPEM(pem, alg, options) {
|
|
1313
|
-
const extractable =
|
|
1328
|
+
const extractable = true;
|
|
1314
1329
|
const pemType = options?.pemType ?? inferPEMType(pem);
|
|
1315
1330
|
if (!pemType) throw new JWTError("Cannot infer PEM type from the input; pass \"options.pemType\" explicitly.", "ERR_JWK_INVALID");
|
|
1316
1331
|
let cryptoKey;
|
|
@@ -1622,4 +1637,4 @@ function inferAesImportAlgorithm(enc, cekLengthBytes) {
|
|
|
1622
1637
|
length: bitLength
|
|
1623
1638
|
};
|
|
1624
1639
|
}
|
|
1625
|
-
export {
|
|
1640
|
+
export { WeakMapJWKCache, assertOctKeyLength, clearJWKCache, configureJWKCache, decrypt, deriveJWKFromPassword, deriveKeyFromPassword, deriveSharedSecret, encrypt, encryptKey, exportKey, exportPEM, exportToPEM, generateCEK, generateIV, generateJWK, generateKey, getJWKFromSet, getJWKsFromSet, importFromPEM, importKey, importPEM, sign, unwrapKey, verify, wrapKey };
|
package/dist/_chunks/jws.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { JOSEPayload, JWKLookupFunction, JWKSet, JWSAlgorithm, JWSFlattenedSerialization, JWSGeneralSerialization, JWSMultiSignOptions, JWSMultiSigner, JWSMultiVerifyAllOptions, JWSMultiVerifyOptions, JWSMultiVerifyOutcome, JWSMultiVerifyResult, JWSSignJWK, JWSSignOptions, JWSVerifyJWK, JWSVerifyOptions, JWSVerifyResult } from "./index.mjs";
|
|
2
2
|
/**
|
|
3
3
|
* Sign a payload with multiple signers using JWS General JSON Serialization
|
|
4
4
|
* (RFC 7515 §7.2.1).
|
|
@@ -108,4 +108,4 @@ declare function verify<T extends JOSEPayload>(jws: string, key: CryptoKey | JWK
|
|
|
108
108
|
declare function verify(jws: string, key: CryptoKey | JWKSet | JWSVerifyJWK | Uint8Array<ArrayBuffer> | JWKLookupFunction, options: JWSVerifyOptions & {
|
|
109
109
|
forceUint8Array: true;
|
|
110
110
|
}): Promise<JWSVerifyResult<Uint8Array<ArrayBuffer>>>;
|
|
111
|
-
export {
|
|
111
|
+
export { generalToFlattenedJWS, sign, signMulti, verify, verifyMulti, verifyMultiAll };
|
package/dist/_chunks/jws.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { JWTError, applyTypCtyDefaults, computeJwtTimeClaims, getPlaintextBytes, isJWK, isJWKSet, validateCriticalHeadersJWS } from "./utils.mjs";
|
|
2
|
+
import { base64UrlDecode, base64UrlEncode, sanitizeObjectCopy, textDecoder, textEncoder } from "./libs/unsecure.mjs";
|
|
3
|
+
import { getJWKsFromSet, importKey, sign as sign$1, verify as verify$1 } from "./jwk.mjs";
|
|
4
|
+
import { JWS_ALG_CTX, buildJWKSetFilter, checkAlgAllowed, decodeJWSPayload, decodeProtectedHeader, resolveSigningKey, validateJwtClaimsIfJsonPayload } from "./_internal.mjs";
|
|
5
5
|
async function signMulti(payload, signers, options = {}) {
|
|
6
6
|
if (!Array.isArray(signers) || signers.length === 0) throw new JWTError("signMulti requires at least one signer.", "ERR_JWS_INVALID");
|
|
7
7
|
const resolvedAlgs = signers.map((s, i) => _resolveSignerAlg(s.key, i));
|
|
@@ -346,4 +346,4 @@ function _buildJWSHeader(alg, key, userHeader, payload) {
|
|
|
346
346
|
if (header.b64 === true) delete header.b64;
|
|
347
347
|
return header;
|
|
348
348
|
}
|
|
349
|
-
export {
|
|
349
|
+
export { generalToFlattenedJWS, sign, signMulti, verify, verifyMulti, verifyMultiAll };
|
|
@@ -91,4 +91,4 @@ declare function base64UrlDecode(data: Uint8Array): Uint8Array<ArrayBuffer>;
|
|
|
91
91
|
type DecodeReturnAs = "string" | "uint8array" | "bytes";
|
|
92
92
|
declare const textEncoder: TextEncoder;
|
|
93
93
|
declare const textDecoder: TextDecoder;
|
|
94
|
-
export {
|
|
94
|
+
export { base64Decode, base64Encode, base64UrlDecode, base64UrlEncode, safeJsonParse, sanitizeObject, sanitizeObjectCopy, secureRandomBytes, textDecoder, textEncoder };
|
|
@@ -146,4 +146,4 @@ function secureRandomBytes(length) {
|
|
|
146
146
|
}
|
|
147
147
|
return bytes;
|
|
148
148
|
}
|
|
149
|
-
export {
|
|
149
|
+
export { base64Decode, base64Encode, base64UrlDecode, base64UrlEncode, safeJsonParse, sanitizeObject, sanitizeObjectCopy, secureRandomBytes, textDecoder, textEncoder };
|
package/dist/_chunks/utils.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { base64UrlDecode, safeJsonParse, textDecoder, textEncoder } from "./libs/unsecure.mjs";
|
|
2
2
|
var JWTError = class extends Error {
|
|
3
3
|
code;
|
|
4
4
|
cause;
|
|
@@ -387,4 +387,4 @@ function isPublicJWK(key) {
|
|
|
387
387
|
}
|
|
388
388
|
return false;
|
|
389
389
|
}
|
|
390
|
-
export {
|
|
390
|
+
export { JWTError, applyTypCtyDefaults, assertCryptoKey, computeDurationInSeconds, computeExpiresInSeconds, computeJwtTimeClaims, computeMaxTokenAgeSeconds, concatUint8Arrays, decodeMaybeJWTString, decodePayloadFromB64UrlSegment, decodePayloadFromBytes, getPlaintextBytes, inferJWEAllowedAlgorithms, inferJWSAllowedAlgorithms, isAsymmetricJWK, isCryptoKey, isCryptoKeyPair, isJWK, isJWKSet, isJWTContent, isJWTError, isPrivateJWK, isPublicJWK, isSymmetricJWK, maybeArray, validateCriticalHeadersJWE, validateCriticalHeadersJWS, validateJwtClaims };
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import { CompositeKey, ContentEncryptionAlgorithm, DeriveKeyOptions, DeriveKeyReturn, Duration, ExpiresIn, GenerateJWKOptions, GenerateJWKReturn, GenerateKeyAlgorithm, GenerateKeyOptions, GenerateKeyReturn, JOSEPayload, JWEAsymmetricPrivateJWK, JWEAsymmetricPublicJWK, JWEDecryptJWK, JWEDecryptOptions, JWEDecryptResult, JWEEncryptJWK, JWEEncryptOptions, JWEFlattenedSerialization, JWEGeneralRecipient, JWEGeneralSerialization, JWEHeaderParameters, JWEKeyManagementHeaderParameters, JWEMultiDecryptOptions, JWEMultiDecryptResult, JWEMultiEncryptOptions, JWEMultiRecipient, JWEProtectedHeader, JWK, JWKAlgorithm, JWKCacheAdapter, JWKLookupFunction, JWKLookupFunctionHeader, JWKPEMAlgorithm, JWKParameters, JWKSet, JWK_AES_CBC_HMAC, JWK_AES_GCM, JWK_AES_GCM_KW, JWK_AES_KW, JWK_Asymmetric, JWK_Asymmetric_Algorithm, JWK_EC, JWK_ECDH_ES, JWK_ECDSA, JWK_EC_Private, JWK_EC_Public, JWK_HMAC, JWK_OKP, JWK_OKP_Private, JWK_OKP_Public, JWK_OKP_SIGN, JWK_PBES2, JWK_Pair, JWK_Private, JWK_Public, JWK_RSA, JWK_RSA_ENC, JWK_RSA_PSS, JWK_RSA_Private, JWK_RSA_Public, JWK_RSA_SIGN, JWK_Symmetric, JWK_Symmetric_Algorithm, JWK_oct, JWSAlgorithm, JWSAsymmetricPrivateJWK, JWSAsymmetricPublicJWK, JWSFlattenedSerialization, JWSGeneralSerialization, JWSGeneralSignature, JWSHeaderParameters, JWSMultiSignOptions, JWSMultiSigner, JWSMultiVerifyAllOptions, JWSMultiVerifyOptions, JWSMultiVerifyOutcome, JWSMultiVerifyResult, JWSProtectedHeader, JWSSignJWK, JWSSignOptions, JWSVerifyJWK, JWSVerifyOptions, JWSVerifyResult, JWT, JWTClaimValidationOptions, JWTClaims, JoseHeaderParameters, KeyManagementAlgorithm, MaxTokenAge, NotBeforeIn, StrictOmit, UnwrapKeyOptions, UnwrappingKeyFor, WrapKeyOptions, WrapKeyResult, WrappingKeyFor } from "../../_chunks/index.mjs";
|
|
2
|
+
import { deriveJWKFromPassword, exportPEM, generateJWK, importPEM } from "../../core/jwk.mjs";
|
|
3
|
+
import { Elysia } from "elysia";
|
|
4
|
+
interface CookieAttributes {
|
|
5
|
+
domain?: string;
|
|
6
|
+
expires?: Date;
|
|
7
|
+
httpOnly?: boolean;
|
|
8
|
+
maxAge?: number;
|
|
9
|
+
path?: string;
|
|
10
|
+
priority?: "low" | "medium" | "high";
|
|
11
|
+
sameSite?: boolean | "lax" | "strict" | "none";
|
|
12
|
+
secure?: boolean;
|
|
13
|
+
partitioned?: boolean;
|
|
14
|
+
}
|
|
15
|
+
interface ChunkableCookie {
|
|
16
|
+
value: unknown;
|
|
17
|
+
set(config: CookieAttributes & {
|
|
18
|
+
value: string;
|
|
19
|
+
}): unknown;
|
|
20
|
+
}
|
|
21
|
+
type ChunkableCookieJar = Record<string, ChunkableCookie>;
|
|
22
|
+
type WriteChunkedCookieOptions = CookieAttributes & {
|
|
23
|
+
chunkMaxLength?: number;
|
|
24
|
+
};
|
|
25
|
+
interface SessionContext {
|
|
26
|
+
cookie: ChunkableCookieJar;
|
|
27
|
+
request: {
|
|
28
|
+
headers: {
|
|
29
|
+
get(name: string): string | null;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
interface SessionClaims extends Required<Pick<JWTClaims, "jti" | "iat">>, StrictOmit<JWTClaims, "jti" | "iat"> {}
|
|
34
|
+
type SessionData<T extends Record<string, any> = SessionClaims> = StrictOmit<T, "jti" | "iat" | "exp">;
|
|
35
|
+
type SessionUpdate<T extends Record<string, any> = SessionClaims> = Partial<SessionData<T>> | ((oldData: SessionData<T>) => Partial<SessionData<T>> | undefined);
|
|
36
|
+
interface SessionManager<T extends Record<string, any> = SessionClaims, ConfigMaxAge extends ExpiresIn | undefined = ExpiresIn | undefined> {
|
|
37
|
+
readonly id: string | undefined;
|
|
38
|
+
readonly createdAt: number;
|
|
39
|
+
readonly expiresAt: ConfigMaxAge extends ExpiresIn ? number : "exp" extends keyof T ? T["exp"] : number | undefined;
|
|
40
|
+
readonly data: SessionData<T>;
|
|
41
|
+
readonly token: string | undefined;
|
|
42
|
+
update: (update?: SessionUpdate<T>) => Promise<SessionManager<T, ConfigMaxAge>>;
|
|
43
|
+
clear: () => Promise<SessionManager<T, ConfigMaxAge>>;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Explicit return type for the `jwsSession` / `jweSession` plugin factories.
|
|
47
|
+
*
|
|
48
|
+
* Modelling Elysia's generics by hand is required by `isolatedDeclarations`
|
|
49
|
+
* (the factories return an inferred `new Elysia().resolve().macro()` type that
|
|
50
|
+
* cannot otherwise be emitted). `Resolved` is the scoped `Ephemeral.resolve`
|
|
51
|
+
* augmentation — typically `{ [P in ContextKey]: SessionManager }` — so consumers
|
|
52
|
+
* read a typed `ctx[contextKey]`. `GuardName` is the guard macro key (derived
|
|
53
|
+
* from the context key, e.g. `requireSession`), so multiple session plugins on
|
|
54
|
+
* one app each expose a distinct guard rather than colliding. `macroFn` is left
|
|
55
|
+
* `{}`: consumers only need `Metadata.macro` for the `{ [GuardName]: true }`
|
|
56
|
+
* route option.
|
|
57
|
+
*/
|
|
58
|
+
type SessionPlugin<Resolved extends Record<string, unknown>, GuardName extends string = "requireSession"> = Elysia<"", {
|
|
59
|
+
decorator: {};
|
|
60
|
+
store: {};
|
|
61
|
+
derive: {};
|
|
62
|
+
resolve: {};
|
|
63
|
+
}, {
|
|
64
|
+
typebox: {};
|
|
65
|
+
error: {};
|
|
66
|
+
}, {
|
|
67
|
+
schema: {};
|
|
68
|
+
standaloneSchema: {};
|
|
69
|
+
macro: { [M in GuardName]?: boolean };
|
|
70
|
+
macroFn: {};
|
|
71
|
+
parser: {};
|
|
72
|
+
response: {};
|
|
73
|
+
}, {}, {
|
|
74
|
+
derive: {};
|
|
75
|
+
resolve: Resolved;
|
|
76
|
+
schema: {};
|
|
77
|
+
standaloneSchema: {};
|
|
78
|
+
response: {};
|
|
79
|
+
}, {
|
|
80
|
+
derive: {};
|
|
81
|
+
resolve: {};
|
|
82
|
+
schema: {};
|
|
83
|
+
standaloneSchema: {};
|
|
84
|
+
response: {};
|
|
85
|
+
}>;
|
|
86
|
+
interface SessionJWS<T extends Record<string, any> = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined> {
|
|
87
|
+
id: string | undefined;
|
|
88
|
+
createdAt: number;
|
|
89
|
+
expiresAt: MaxAge extends ExpiresIn ? number : T["exp"];
|
|
90
|
+
data: SessionData<T>;
|
|
91
|
+
token: string | undefined;
|
|
92
|
+
}
|
|
93
|
+
interface SessionHooksJWS<T extends Record<string, any> = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined, TContext extends SessionContext = SessionContext> {
|
|
94
|
+
onRead?: (args: {
|
|
95
|
+
session: SessionJWS<T, MaxAge> & {
|
|
96
|
+
id: string;
|
|
97
|
+
token: string;
|
|
98
|
+
};
|
|
99
|
+
context: TContext;
|
|
100
|
+
config: SessionConfigJWS<T, MaxAge, TContext>;
|
|
101
|
+
}) => void | Promise<void>;
|
|
102
|
+
onUpdate?: (args: {
|
|
103
|
+
session: SessionJWS<T, MaxAge> & {
|
|
104
|
+
id: string;
|
|
105
|
+
token: string;
|
|
106
|
+
};
|
|
107
|
+
oldSession: SessionJWS<T, MaxAge>;
|
|
108
|
+
context: TContext;
|
|
109
|
+
config: SessionConfigJWS<T, MaxAge, TContext>;
|
|
110
|
+
}) => void | Promise<void>;
|
|
111
|
+
onClear?: (args: {
|
|
112
|
+
oldSession: SessionJWS<T, MaxAge> | undefined;
|
|
113
|
+
context: TContext;
|
|
114
|
+
config: SessionConfigJWS<T, MaxAge, TContext>;
|
|
115
|
+
}) => void | Promise<void>;
|
|
116
|
+
onExpire?: (args: {
|
|
117
|
+
session: {
|
|
118
|
+
id: string | undefined;
|
|
119
|
+
createdAt: number | undefined;
|
|
120
|
+
expiresAt: number | undefined;
|
|
121
|
+
token: string;
|
|
122
|
+
};
|
|
123
|
+
context: TContext;
|
|
124
|
+
error: Error;
|
|
125
|
+
config: SessionConfigJWS<T, MaxAge, TContext>;
|
|
126
|
+
}) => void | Promise<void>;
|
|
127
|
+
onError?: (args: {
|
|
128
|
+
session: SessionJWS<T, MaxAge>;
|
|
129
|
+
context: TContext;
|
|
130
|
+
error: any;
|
|
131
|
+
config: SessionConfigJWS<T, MaxAge, TContext>;
|
|
132
|
+
}) => void | Promise<void>;
|
|
133
|
+
onVerifyKeyLookup?: (args: {
|
|
134
|
+
header: JWKLookupFunctionHeader;
|
|
135
|
+
context: TContext;
|
|
136
|
+
config: SessionConfigJWS<T, MaxAge, TContext>;
|
|
137
|
+
}) => JWKSet | JWSVerifyJWK | Promise<JWKSet | JWSVerifyJWK>;
|
|
138
|
+
}
|
|
139
|
+
interface SessionConfigJWS<T extends Record<string, any> = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined, TContext extends SessionContext = SessionContext> {
|
|
140
|
+
key: JWK_oct<JWK_HMAC> | {
|
|
141
|
+
privateKey: JWSAsymmetricPrivateJWK;
|
|
142
|
+
publicKey: JWSAsymmetricPublicJWK | JWSAsymmetricPublicJWK[] | JWKSet;
|
|
143
|
+
};
|
|
144
|
+
maxAge?: MaxAge;
|
|
145
|
+
name?: string;
|
|
146
|
+
/** Context property the session is exposed under. Default `"session"`. */
|
|
147
|
+
contextKey?: string;
|
|
148
|
+
cookie?: false | (CookieAttributes & {
|
|
149
|
+
chunkMaxLength?: number;
|
|
150
|
+
});
|
|
151
|
+
sessionHeader?: false | string;
|
|
152
|
+
generateId?: () => string;
|
|
153
|
+
jws?: {
|
|
154
|
+
signOptions?: Omit<JWSSignOptions, "expiresIn">;
|
|
155
|
+
verifyOptions?: JWTClaimValidationOptions;
|
|
156
|
+
};
|
|
157
|
+
hooks?: SessionHooksJWS<T, MaxAge, TContext>;
|
|
158
|
+
}
|
|
159
|
+
declare function createJWSSession<T extends Record<string, any> = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined, TContext extends SessionContext = SessionContext>(context: TContext, config: SessionConfigJWS<T, MaxAge, TContext>): Promise<SessionManager<T, MaxAge>>;
|
|
160
|
+
declare function jwsSession<T extends Record<string, any> = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined, K extends string = "session">(config: SessionConfigJWS<T, MaxAge> & (K extends "session" ? {
|
|
161
|
+
contextKey?: K;
|
|
162
|
+
} : {
|
|
163
|
+
contextKey: K;
|
|
164
|
+
})): SessionPlugin<{ [P in K]: SessionManager<T, MaxAge> }, `require${Capitalize<K>}`>;
|
|
165
|
+
interface SessionJWE<T extends Record<string, any> = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined> {
|
|
166
|
+
id: string | undefined;
|
|
167
|
+
createdAt: number;
|
|
168
|
+
expiresAt: MaxAge extends ExpiresIn ? number : T["exp"];
|
|
169
|
+
data: SessionData<T>;
|
|
170
|
+
token: string | undefined;
|
|
171
|
+
}
|
|
172
|
+
interface SessionHooksJWE<T extends Record<string, any> = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined, TContext extends SessionContext = SessionContext> {
|
|
173
|
+
onRead?: (args: {
|
|
174
|
+
session: SessionJWE<T, MaxAge> & {
|
|
175
|
+
id: string;
|
|
176
|
+
token: string;
|
|
177
|
+
};
|
|
178
|
+
context: TContext;
|
|
179
|
+
config: SessionConfigJWE<T, MaxAge, TContext>;
|
|
180
|
+
}) => void | Promise<void>;
|
|
181
|
+
onUpdate?: (args: {
|
|
182
|
+
session: SessionJWE<T, MaxAge> & {
|
|
183
|
+
id: string;
|
|
184
|
+
token: string;
|
|
185
|
+
};
|
|
186
|
+
oldSession: SessionJWE<T, MaxAge>;
|
|
187
|
+
context: TContext;
|
|
188
|
+
config: SessionConfigJWE<T, MaxAge, TContext>;
|
|
189
|
+
}) => void | Promise<void>;
|
|
190
|
+
onClear?: (args: {
|
|
191
|
+
oldSession: SessionJWE<T, MaxAge> | undefined;
|
|
192
|
+
context: TContext;
|
|
193
|
+
config: SessionConfigJWE<T, MaxAge, TContext>;
|
|
194
|
+
}) => void | Promise<void>;
|
|
195
|
+
onExpire?: (args: {
|
|
196
|
+
session: {
|
|
197
|
+
id: string | undefined;
|
|
198
|
+
createdAt: number | undefined;
|
|
199
|
+
expiresAt: number | undefined;
|
|
200
|
+
token: string;
|
|
201
|
+
};
|
|
202
|
+
context: TContext;
|
|
203
|
+
error: Error;
|
|
204
|
+
config: SessionConfigJWE<T, MaxAge, TContext>;
|
|
205
|
+
}) => void | Promise<void>;
|
|
206
|
+
onError?: (args: {
|
|
207
|
+
session: SessionJWE<T, MaxAge>;
|
|
208
|
+
context: TContext;
|
|
209
|
+
error: any;
|
|
210
|
+
config: SessionConfigJWE<T, MaxAge, TContext>;
|
|
211
|
+
}) => void | Promise<void>;
|
|
212
|
+
onUnsealKeyLookup?: (args: {
|
|
213
|
+
header: JWEHeaderParameters;
|
|
214
|
+
context: TContext;
|
|
215
|
+
config: SessionConfigJWE<T, MaxAge, TContext>;
|
|
216
|
+
}) => JWEDecryptJWK | Promise<JWEDecryptJWK>;
|
|
217
|
+
}
|
|
218
|
+
interface SessionConfigJWE<T extends Record<string, any> = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined, TContext extends SessionContext = SessionContext> {
|
|
219
|
+
key: string | JWEEncryptJWK | {
|
|
220
|
+
privateKey: JWEAsymmetricPrivateJWK;
|
|
221
|
+
publicKey?: JWEAsymmetricPublicJWK;
|
|
222
|
+
};
|
|
223
|
+
maxAge?: MaxAge;
|
|
224
|
+
name?: string;
|
|
225
|
+
/** Context property the session is exposed under. Default `"session"`. */
|
|
226
|
+
contextKey?: string;
|
|
227
|
+
cookie?: false | (CookieAttributes & {
|
|
228
|
+
chunkMaxLength?: number;
|
|
229
|
+
});
|
|
230
|
+
sessionHeader?: false | string;
|
|
231
|
+
generateId?: () => string;
|
|
232
|
+
jwe?: {
|
|
233
|
+
encryptOptions?: Omit<JWEEncryptOptions, "expiresIn">;
|
|
234
|
+
decryptOptions?: JWTClaimValidationOptions;
|
|
235
|
+
};
|
|
236
|
+
hooks?: SessionHooksJWE<T, MaxAge, TContext>;
|
|
237
|
+
}
|
|
238
|
+
declare function createJWESession<T extends Record<string, any> = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined, TContext extends SessionContext = SessionContext>(context: TContext, config: SessionConfigJWE<T, MaxAge, TContext>): Promise<SessionManager<T, MaxAge>>;
|
|
239
|
+
declare function jweSession<T extends Record<string, any> = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined, K extends string = "session">(config: SessionConfigJWE<T, MaxAge> & (K extends "session" ? {
|
|
240
|
+
contextKey?: K;
|
|
241
|
+
} : {
|
|
242
|
+
contextKey: K;
|
|
243
|
+
})): SessionPlugin<{ [P in K]: SessionManager<T, MaxAge> }, `require${Capitalize<K>}`>;
|
|
244
|
+
export { type ChunkableCookie, type ChunkableCookieJar, type CompositeKey, type ContentEncryptionAlgorithm, type CookieAttributes, type DeriveKeyOptions, type DeriveKeyReturn, type Duration, type ExpiresIn, type GenerateJWKOptions, type GenerateJWKReturn, type GenerateKeyAlgorithm, type GenerateKeyOptions, type GenerateKeyReturn, type JOSEPayload, type JWEAsymmetricPrivateJWK, type JWEAsymmetricPublicJWK, type JWEDecryptJWK, type JWEDecryptOptions, type JWEDecryptResult, type JWEEncryptJWK, type JWEEncryptOptions, type JWEFlattenedSerialization, type JWEGeneralRecipient, type JWEGeneralSerialization, type JWEHeaderParameters, type JWEKeyManagementHeaderParameters, type JWEMultiDecryptOptions, type JWEMultiDecryptResult, type JWEMultiEncryptOptions, type JWEMultiRecipient, type JWEProtectedHeader, type JWK, type JWKAlgorithm, type JWKCacheAdapter, type JWKLookupFunction, type JWKLookupFunctionHeader, type JWKPEMAlgorithm, type JWKParameters, type JWKSet, type JWK_AES_CBC_HMAC, type JWK_AES_GCM, type JWK_AES_GCM_KW, type JWK_AES_KW, type JWK_Asymmetric, type JWK_Asymmetric_Algorithm, type JWK_EC, type JWK_ECDH_ES, type JWK_ECDSA, type JWK_EC_Private, type JWK_EC_Public, type JWK_HMAC, type JWK_OKP, type JWK_OKP_Private, type JWK_OKP_Public, type JWK_OKP_SIGN, type JWK_PBES2, type JWK_Pair, type JWK_Private, type JWK_Public, type JWK_RSA, type JWK_RSA_ENC, type JWK_RSA_PSS, type JWK_RSA_Private, type JWK_RSA_Public, type JWK_RSA_SIGN, type JWK_Symmetric, type JWK_Symmetric_Algorithm, type JWK_oct, type JWSAlgorithm, type JWSAsymmetricPrivateJWK, type JWSAsymmetricPublicJWK, type JWSFlattenedSerialization, type JWSGeneralSerialization, type JWSGeneralSignature, type JWSHeaderParameters, type JWSMultiSignOptions, type JWSMultiSigner, type JWSMultiVerifyAllOptions, type JWSMultiVerifyOptions, type JWSMultiVerifyOutcome, type JWSMultiVerifyResult, type JWSProtectedHeader, type JWSSignJWK, type JWSSignOptions, type JWSVerifyJWK, type JWSVerifyOptions, type JWSVerifyResult, type JWT, type JWTClaimValidationOptions, type JWTClaims, type JoseHeaderParameters, type KeyManagementAlgorithm, type MaxTokenAge, type NotBeforeIn, type SessionClaims, type SessionConfigJWE, type SessionConfigJWS, type SessionContext, type SessionData, type SessionHooksJWE, type SessionHooksJWS, type SessionJWE, type SessionJWS, type SessionManager, type SessionPlugin, type SessionUpdate, type UnwrapKeyOptions, type UnwrappingKeyFor, type WrapKeyOptions, type WrapKeyResult, type WrappingKeyFor, type WriteChunkedCookieOptions, createJWESession, createJWSSession, deriveJWKFromPassword, exportPEM, generateJWK, importPEM, jweSession, jwsSession };
|