unjwt 0.5.37 → 0.5.39
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 +142 -663
- package/dist/_chunks/chunk.mjs +13 -0
- package/dist/_chunks/h3v1.mjs +598 -0
- package/dist/_chunks/index.d.mts +250 -0
- package/dist/_chunks/index2.d.mts +108 -0
- package/dist/_chunks/jwe.d.mts +43 -0
- package/dist/_chunks/jwe.mjs +132 -0
- package/dist/_chunks/jwk.d.mts +575 -0
- package/dist/_chunks/jwk.mjs +1592 -0
- package/dist/_chunks/jws.d.mts +46 -0
- package/dist/_chunks/jws.mjs +2069 -0
- package/dist/_chunks/utils.mjs +374 -0
- package/dist/adapters/h3.d.mts +3 -265
- package/dist/adapters/h3.mjs +3 -706
- package/dist/adapters/h3v1.d.mts +3 -8
- package/dist/adapters/h3v1.mjs +3 -7
- package/dist/adapters/h3v2.d.mts +145 -146
- package/dist/adapters/h3v2.mjs +505 -596
- package/dist/index.d.mts +6 -8
- package/dist/index.mjs +5 -4
- package/dist/jwe.d.mts +3 -4
- package/dist/jwe.mjs +4 -3
- package/dist/jwk.d.mts +3 -2
- package/dist/jwk.mjs +3 -2
- package/dist/jws.d.mts +3 -3
- package/dist/jws.mjs +4 -3
- package/dist/utils.d.mts +3 -3
- package/dist/utils.mjs +2 -1
- package/package.json +33 -31
- package/dist/shared/unjwt.4JQCoID_.d.mts +0 -161
- package/dist/shared/unjwt.B-v62plj.mjs +0 -249
- package/dist/shared/unjwt.BCi3FEWr.d.mts +0 -328
- package/dist/shared/unjwt.BYDTEWa-.d.mts +0 -269
- package/dist/shared/unjwt.Be8NxwFK.mjs +0 -438
- package/dist/shared/unjwt.BqdNUKDr.d.mts +0 -64
- package/dist/shared/unjwt.CMNtw8ek.d.mts +0 -155
- package/dist/shared/unjwt.Cy2MlkUe.d.mts +0 -174
- package/dist/shared/unjwt.D0_ccT7g.d.mts +0 -166
- package/dist/shared/unjwt.DdLN9vwI.mjs +0 -163
- package/dist/shared/unjwt.Dpl__ZAR.mjs +0 -2121
- package/dist/shared/unjwt.JdKqVANs.d.mts +0 -5
package/dist/adapters/h3v1.d.mts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export { SessionClaims, SessionConfigJWE, SessionConfigJWS, SessionData, SessionHooksJWE, SessionHooksJWS, SessionJWE, SessionJWEConfig, SessionJWS, SessionJWSConfig, SessionManager, SessionUpdate, clearJWESession, clearJWSSession, getJWESession, getJWESessionToken, getJWSSession, sealJWESession, signJWSSession, unsealJWESession, updateJWESession, updateJWSSession, useJWESession, useJWSSession, verifyJWSSession }
|
|
4
|
-
export { d as deriveJWKFromPassword, e as exportJWKToPEM, g as generateJWK, i as importJWKFromPEM } from '../shared/unjwt.BYDTEWa-.mjs';
|
|
5
|
-
import '../shared/unjwt.JdKqVANs.mjs';
|
|
6
|
-
import 'cookie-es';
|
|
7
|
-
import 'h3';
|
|
8
|
-
import '../shared/unjwt.BqdNUKDr.mjs';
|
|
1
|
+
import { $ as JWK_RSA_ENC, A as JWKPEMAlgorithm, B as JWK_ECDH_ES, C as GenerateJWKOptions, D as GenerateKeyReturn, E as GenerateKeyOptions, F as JWK_AES_GCM_KW, G as JWK_OKP, H as JWK_EC_Private, I as JWK_AES_KW, J as JWK_OKP_SIGN, K as JWK_OKP_Private, L as JWK_Asymmetric, M as JWKSet, N as JWK_AES_CBC_HMAC, O as JWK, P as JWK_AES_GCM, Q as JWK_RSA, R as JWK_Asymmetric_Algorithm, S as DeriveKeyReturn, T as GenerateKeyAlgorithm, U as JWK_EC_Public, V as JWK_ECDSA, W as JWK_HMAC, X as JWK_Private, Y as JWK_PBES2, Z as JWK_Public, a as JWEDecryptOptions, at as JWK_Symmetric_Algorithm, b as ContentEncryptionAlgorithm, c as JWEHeaderParameters, ct as UnwrapKeyOptions, et as JWK_RSA_PSS, f as JWT, h as JoseHeaderParameters, i as importJWKFromPEM, it as JWK_Symmetric, j as JWKParameters, k as JWKAlgorithm, l as JWEKeyLookupFunction, lt as WrapKeyOptions, m as JWTClaims, n as exportJWKToPEM, nt as JWK_RSA_Public, o as JWEDecryptResult, ot as JWK_oct, p as JWTClaimValidationOptions, q as JWK_OKP_Public, r as generateJWK, rt as JWK_RSA_SIGN, s as JWEEncryptOptions, st as KeyManagementAlgorithm, t as deriveJWKFromPassword, tt as JWK_RSA_Private, u as JWEKeyManagementHeaderParameters, ut as WrapKeyResult, w as GenerateJWKReturn, x as DeriveKeyOptions, y as CompositeKey, z as JWK_EC } from "../_chunks/jwk.mjs";
|
|
2
|
+
import { C as SessionData, S as SessionClaims, T as SessionUpdate, _ as getJWESessionToken, a as clearJWSSession, b as updateJWESession, c as updateJWSSession, d as SessionConfigJWE, f as SessionHooksJWE, g as getJWESession, h as clearJWESession, i as SessionJWSConfig, l as useJWSSession, m as SessionJWEConfig, n as SessionHooksJWS, o as getJWSSession, p as SessionJWE, r as SessionJWS, s as signJWSSession, t as SessionConfigJWS, u as verifyJWSSession, v as sealJWESession, w as SessionManager, x as useJWESession, y as unsealJWESession } from "../_chunks/index.mjs";
|
|
3
|
+
export { CompositeKey, ContentEncryptionAlgorithm, DeriveKeyOptions, DeriveKeyReturn, GenerateJWKOptions, GenerateJWKReturn, GenerateKeyAlgorithm, GenerateKeyOptions, GenerateKeyReturn, JWEDecryptOptions, JWEDecryptResult, JWEEncryptOptions, JWEHeaderParameters, JWEKeyLookupFunction, JWEKeyManagementHeaderParameters, JWK, JWKAlgorithm, 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_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, JWT, JWTClaimValidationOptions, JWTClaims, JoseHeaderParameters, KeyManagementAlgorithm, SessionClaims, SessionConfigJWE, SessionConfigJWS, SessionData, SessionHooksJWE, SessionHooksJWS, SessionJWE, SessionJWEConfig, SessionJWS, SessionJWSConfig, SessionManager, SessionUpdate, UnwrapKeyOptions, WrapKeyOptions, WrapKeyResult, clearJWESession, clearJWSSession, deriveJWKFromPassword, exportJWKToPEM, generateJWK, getJWESession, getJWESessionToken, getJWSSession, importJWKFromPEM, sealJWESession, signJWSSession, unsealJWESession, updateJWESession, updateJWSSession, useJWESession, useJWSSession, verifyJWSSession };
|
package/dist/adapters/h3v1.mjs
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import 'h3';
|
|
5
|
-
import 'cookie-es';
|
|
6
|
-
import '../shared/unjwt.B-v62plj.mjs';
|
|
7
|
-
import '../shared/unjwt.DdLN9vwI.mjs';
|
|
1
|
+
import { a as deriveJWKFromPassword, c as importJWKFromPEM, o as exportJWKToPEM, s as generateJWK } from "../_chunks/jws.mjs";
|
|
2
|
+
import { a as useJWSSession, c as getJWESession, d as unsealJWESession, f as updateJWESession, i as updateJWSSession, l as getJWESessionToken, n as getJWSSession, o as verifyJWSSession, p as useJWESession, r as signJWSSession, s as clearJWESession, t as clearJWSSession, u as sealJWESession } from "../_chunks/h3v1.mjs";
|
|
3
|
+
export { clearJWESession, clearJWSSession, deriveJWKFromPassword, exportJWKToPEM, generateJWK, getJWESession, getJWESessionToken, getJWSSession, importJWKFromPEM, sealJWESession, signJWSSession, unsealJWESession, updateJWESession, updateJWSSession, useJWESession, useJWSSession, verifyJWSSession };
|
package/dist/adapters/h3v2.d.mts
CHANGED
|
@@ -1,177 +1,177 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
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, v as JWK, S as JWKAlgorithm, T as JWKPEMAlgorithm, J as JWKParameters, H as JWK_AES_CBC_HMAC, I as JWK_AES_GCM, L as JWK_AES_GCM_KW, F as JWK_AES_KW, s as JWK_Asymmetric, R as JWK_Asymmetric_Algorithm, j as JWK_EC, O as JWK_ECDH_ES, A as JWK_ECDSA, i as JWK_EC_Private, h as JWK_EC_Public, x as JWK_HMAC, p as JWK_OKP, o as JWK_OKP_Private, n as JWK_OKP_Public, P as JWK_OKP_SIGN, N as JWK_PBES2, m as JWK_RSA, B as JWK_RSA_ENC, z as JWK_RSA_PSS, l as JWK_RSA_Private, k as JWK_RSA_Public, y as JWK_RSA_SIGN, Q as JWK_Symmetric_Algorithm, q as JWK_oct, Y as JWT, V as JoseHeaderParameters, K as KeyManagementAlgorithm, U as UnwrapKeyOptions, W as WrapKeyOptions, g as WrapKeyResult } from '../shared/unjwt.BCi3FEWr.mjs';
|
|
5
|
-
import { S as StrictOmit } from '../shared/unjwt.JdKqVANs.mjs';
|
|
6
|
-
import { HTTPEvent } from 'h3';
|
|
7
|
-
import { CookieSerializeOptions } from 'cookie-es';
|
|
8
|
-
import { c as JWSSignOptions, b as JWSProtectedHeader } from '../shared/unjwt.BqdNUKDr.mjs';
|
|
9
|
-
export { d as deriveJWKFromPassword, e as exportJWKToPEM, g as generateJWK, i as importJWKFromPEM } from '../shared/unjwt.BYDTEWa-.mjs';
|
|
1
|
+
import { $ as JWK_RSA_ENC, A as JWKPEMAlgorithm, B as JWK_ECDH_ES, C as GenerateJWKOptions, D as GenerateKeyReturn, E as GenerateKeyOptions, F as JWK_AES_GCM_KW, G as JWK_OKP, H as JWK_EC_Private, I as JWK_AES_KW, J as JWK_OKP_SIGN, K as JWK_OKP_Private, L as JWK_Asymmetric, M as JWKSet, N as JWK_AES_CBC_HMAC, O as JWK, P as JWK_AES_GCM, Q as JWK_RSA, R as JWK_Asymmetric_Algorithm, S as DeriveKeyReturn, T as GenerateKeyAlgorithm, U as JWK_EC_Public, V as JWK_ECDSA, W as JWK_HMAC, X as JWK_Private, Y as JWK_PBES2, Z as JWK_Public, _ as JWSProtectedHeader, a as JWEDecryptOptions, at as JWK_Symmetric_Algorithm, b as ContentEncryptionAlgorithm, c as JWEHeaderParameters, ct as UnwrapKeyOptions, d as StrictOmit, et as JWK_RSA_PSS, f as JWT, g as ExpiresIn, h as JoseHeaderParameters, i as importJWKFromPEM, it as JWK_Symmetric, j as JWKParameters, k as JWKAlgorithm, l as JWEKeyLookupFunction, lt as WrapKeyOptions, m as JWTClaims, n as exportJWKToPEM, nt as JWK_RSA_Public, o as JWEDecryptResult, ot as JWK_oct, p as JWTClaimValidationOptions, q as JWK_OKP_Public, r as generateJWK, rt as JWK_RSA_SIGN, s as JWEEncryptOptions, st as KeyManagementAlgorithm, t as deriveJWKFromPassword, tt as JWK_RSA_Private, u as JWEKeyManagementHeaderParameters, ut as WrapKeyResult, v as JWSSignOptions, w as GenerateJWKReturn, x as DeriveKeyOptions, y as CompositeKey, z as JWK_EC } from "../_chunks/jwk.mjs";
|
|
2
|
+
import { HTTPEvent } from "h3";
|
|
3
|
+
import { CookieSerializeOptions } from "cookie-es";
|
|
10
4
|
|
|
11
|
-
|
|
12
|
-
}
|
|
5
|
+
//#region src/adapters/h3v2/session/types.d.ts
|
|
6
|
+
interface SessionClaims extends Required<Pick<JWTClaims, "jti" | "iat">>, StrictOmit<JWTClaims, "jti" | "iat"> {}
|
|
13
7
|
type SessionData<T extends Record<string, any> = SessionClaims> = StrictOmit<T, "jti" | "iat" | "exp">;
|
|
14
8
|
type SessionUpdate<T extends Record<string, any> = SessionClaims> = Partial<SessionData<T>> | ((oldData: SessionData<T>) => Partial<SessionData<T>> | undefined);
|
|
15
9
|
interface SessionManager<T extends Record<string, any> = SessionClaims, ConfigMaxAge extends ExpiresIn | undefined = ExpiresIn | undefined> {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
10
|
+
readonly id: string | undefined;
|
|
11
|
+
readonly createdAt: number;
|
|
12
|
+
readonly expiresAt: ConfigMaxAge extends ExpiresIn ? number : "exp" extends keyof T ? T["exp"] : number | undefined;
|
|
13
|
+
readonly data: SessionData<T>;
|
|
14
|
+
readonly token: string | undefined;
|
|
15
|
+
update: (update: SessionUpdate<T>) => Promise<SessionManager<T, ConfigMaxAge>>;
|
|
16
|
+
clear: () => Promise<SessionManager<T, ConfigMaxAge>>;
|
|
23
17
|
}
|
|
24
|
-
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/adapters/h3v2/session/jwe.d.ts
|
|
25
20
|
declare const kGetSessionPromise$1: unique symbol;
|
|
21
|
+
declare const kSessionToken$1: unique symbol;
|
|
26
22
|
interface SessionJWE<T extends Record<string, any> = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined> {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
id: string | undefined;
|
|
24
|
+
createdAt: number;
|
|
25
|
+
expiresAt: MaxAge extends ExpiresIn ? number : T["exp"];
|
|
26
|
+
data: SessionData<T>;
|
|
27
|
+
[kGetSessionPromise$1]?: Promise<SessionJWE<T, MaxAge>>;
|
|
28
|
+
[kSessionToken$1]?: string;
|
|
32
29
|
}
|
|
33
30
|
interface SessionHooksJWE<T extends Record<string, any> = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined> {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
31
|
+
onRead?: (args: {
|
|
32
|
+
session: SessionJWE<T, MaxAge>;
|
|
33
|
+
event: HTTPEvent;
|
|
34
|
+
config: SessionConfigJWE<T, MaxAge>;
|
|
35
|
+
}) => void | Promise<void>;
|
|
36
|
+
onUpdate?: (args: {
|
|
37
|
+
session: SessionJWE<T, MaxAge>;
|
|
38
|
+
oldSession: SessionJWE<T, MaxAge>;
|
|
39
|
+
event: HTTPEvent;
|
|
40
|
+
config: SessionConfigJWE<T, MaxAge>;
|
|
41
|
+
}) => void | Promise<void>;
|
|
42
|
+
onClear?: (args: {
|
|
43
|
+
session: SessionJWE<T, MaxAge> | undefined;
|
|
44
|
+
event: HTTPEvent;
|
|
45
|
+
config: Partial<SessionConfigJWE<T, MaxAge>>;
|
|
46
|
+
}) => void | Promise<void>;
|
|
47
|
+
onExpire?: (args: {
|
|
48
|
+
event: HTTPEvent;
|
|
49
|
+
error: Error;
|
|
50
|
+
config: SessionConfigJWE<T, MaxAge>;
|
|
51
|
+
}) => void | Promise<void>;
|
|
52
|
+
onError?: (args: {
|
|
53
|
+
event: HTTPEvent;
|
|
54
|
+
error: any;
|
|
55
|
+
config: SessionConfigJWE<T, MaxAge>;
|
|
56
|
+
}) => void | Promise<void>;
|
|
57
|
+
onUnsealKeyLookup?: (args: {
|
|
58
|
+
header: JWEHeaderParameters;
|
|
59
|
+
event: HTTPEvent;
|
|
60
|
+
config: SessionConfigJWE<T, MaxAge>;
|
|
61
|
+
}) => JWK_Symmetric | JWK_Private | Promise<JWK_Symmetric | JWK_Private>;
|
|
65
62
|
}
|
|
66
63
|
interface SessionConfigJWE<T extends Record<string, any> = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined> {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
64
|
+
/** Shared secret used, string for PBES2 or Json Web Key (JWK) */
|
|
65
|
+
key: string | JWK_Symmetric | {
|
|
66
|
+
privateKey: JWK_Private | JWK_Symmetric;
|
|
67
|
+
publicKey?: JWK_Public;
|
|
68
|
+
};
|
|
69
|
+
/** Session lifetime in seconds (used to derive exp from iat) */
|
|
70
|
+
maxAge?: MaxAge;
|
|
71
|
+
/** Default is "h3" */
|
|
72
|
+
name?: string;
|
|
73
|
+
/** Default is secure, httpOnly, path="/" */
|
|
74
|
+
cookie?: false | (CookieSerializeOptions & {
|
|
75
|
+
chunkMaxLength?: number;
|
|
76
|
+
});
|
|
77
|
+
/** Default is x-h3-session / x-{name}-session */
|
|
78
|
+
sessionHeader?: false | string;
|
|
79
|
+
/** Default is crypto.randomUUID */
|
|
80
|
+
generateId?: () => string;
|
|
81
|
+
/** JWE configuration overrides */
|
|
82
|
+
jwe?: {
|
|
83
|
+
encryptOptions?: Omit<JWEEncryptOptions, "expiresIn">;
|
|
84
|
+
decryptOptions?: JWTClaimValidationOptions;
|
|
85
|
+
};
|
|
86
|
+
hooks?: SessionHooksJWE<T, MaxAge>;
|
|
90
87
|
}
|
|
91
88
|
/**
|
|
92
|
-
|
|
93
|
-
|
|
89
|
+
* Create a session manager for the current request.
|
|
90
|
+
*/
|
|
94
91
|
declare function useJWESession<T extends Record<string, any> = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined>(event: HTTPEvent, config: SessionConfigJWE<T, MaxAge>): Promise<SessionManager<T, MaxAge>>;
|
|
95
92
|
/**
|
|
96
|
-
|
|
97
|
-
|
|
93
|
+
* Get the session for the current request.
|
|
94
|
+
*/
|
|
98
95
|
declare function getJWESession<T extends Record<string, any> = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined>(event: HTTPEvent, config: SessionConfigJWE<T, MaxAge>): Promise<SessionJWE<T, MaxAge>>;
|
|
99
96
|
declare function getJWESessionToken<T extends Record<string, any> = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined>(event: HTTPEvent, config: SessionConfigJWE<T, MaxAge>): string | undefined;
|
|
100
97
|
/**
|
|
101
|
-
|
|
102
|
-
|
|
98
|
+
* Update the session data for the current request.
|
|
99
|
+
*/
|
|
103
100
|
declare function updateJWESession<T extends Record<string, any> = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined>(event: HTTPEvent, config: SessionConfigJWE<T, MaxAge>, update?: SessionUpdate<T>): Promise<SessionJWE<T, MaxAge>>;
|
|
104
101
|
/**
|
|
105
|
-
|
|
106
|
-
|
|
102
|
+
* Produce a JWE for the current session.
|
|
103
|
+
*/
|
|
107
104
|
declare function sealJWESession<T extends Record<string, any> = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined>(event: HTTPEvent, config: SessionConfigJWE<T, MaxAge>): Promise<string>;
|
|
108
105
|
/**
|
|
109
|
-
|
|
110
|
-
|
|
106
|
+
* Decrypt the JWE and return a Session-compatible object.
|
|
107
|
+
*/
|
|
111
108
|
declare function unsealJWESession<T extends Record<string, any> = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined>(event: HTTPEvent, config: SessionConfigJWE<T, MaxAge>, sealed: string): Promise<Partial<SessionJWE<T, MaxAge>>>;
|
|
112
109
|
/**
|
|
113
|
-
|
|
114
|
-
|
|
110
|
+
* Clear the session (delete from context and drop cookie).
|
|
111
|
+
*/
|
|
115
112
|
declare function clearJWESession<T extends Record<string, any> = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined>(event: HTTPEvent, config: Partial<SessionConfigJWE<T, MaxAge>>): Promise<void>;
|
|
116
|
-
|
|
113
|
+
//#endregion
|
|
114
|
+
//#region src/adapters/h3v2/session/jws.d.ts
|
|
117
115
|
declare const kGetSessionPromise: unique symbol;
|
|
116
|
+
declare const kSessionToken: unique symbol;
|
|
118
117
|
interface SessionJWS<T extends Record<string, any> = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined> {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
118
|
+
id: string | undefined;
|
|
119
|
+
createdAt: number;
|
|
120
|
+
expiresAt: MaxAge extends ExpiresIn ? number : T["exp"];
|
|
121
|
+
data: SessionData<T>;
|
|
122
|
+
[kGetSessionPromise]?: Promise<SessionJWS<T, MaxAge>>;
|
|
123
|
+
[kSessionToken]?: string;
|
|
124
124
|
}
|
|
125
125
|
interface SessionHooksJWS<T extends Record<string, any> = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined> {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
126
|
+
onRead?: (args: {
|
|
127
|
+
session: SessionJWS<T, MaxAge>;
|
|
128
|
+
event: HTTPEvent;
|
|
129
|
+
config: SessionConfigJWS<T, MaxAge>;
|
|
130
|
+
}) => void | Promise<void>;
|
|
131
|
+
onUpdate?: (args: {
|
|
132
|
+
session: SessionJWS<T, MaxAge>;
|
|
133
|
+
oldSession: SessionJWS<T, MaxAge>;
|
|
134
|
+
event: HTTPEvent;
|
|
135
|
+
config: SessionConfigJWS<T, MaxAge>;
|
|
136
|
+
}) => void | Promise<void>;
|
|
137
|
+
onClear?: (args: {
|
|
138
|
+
session: SessionJWS<T, MaxAge> | undefined;
|
|
139
|
+
event: HTTPEvent;
|
|
140
|
+
config: Partial<SessionConfigJWS<T, MaxAge>>;
|
|
141
|
+
}) => void | Promise<void>;
|
|
142
|
+
onExpire?: (args: {
|
|
143
|
+
event: HTTPEvent;
|
|
144
|
+
error: Error;
|
|
145
|
+
config: SessionConfigJWS<T, MaxAge>;
|
|
146
|
+
}) => void | Promise<void>;
|
|
147
|
+
onError?: (args: {
|
|
148
|
+
event: HTTPEvent;
|
|
149
|
+
error: any;
|
|
150
|
+
config: SessionConfigJWS<T, MaxAge>;
|
|
151
|
+
}) => void | Promise<void>;
|
|
152
|
+
onVerifyKeyLookup?: (args: {
|
|
153
|
+
header: JWSProtectedHeader;
|
|
154
|
+
event: HTTPEvent;
|
|
155
|
+
config: SessionConfigJWS<T, MaxAge>;
|
|
156
|
+
}) => JWKSet | JWK_Symmetric | JWK_Public | Promise<JWKSet | JWK_Symmetric | JWK_Public>;
|
|
157
157
|
}
|
|
158
158
|
interface SessionConfigJWS<T extends Record<string, any> = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined> {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
159
|
+
key: JWK_Symmetric | {
|
|
160
|
+
privateKey: JWK_Private;
|
|
161
|
+
publicKey: JWK_Public | JWK_Public[] | JWKSet;
|
|
162
|
+
};
|
|
163
|
+
maxAge?: MaxAge;
|
|
164
|
+
name?: string;
|
|
165
|
+
cookie?: false | (CookieSerializeOptions & {
|
|
166
|
+
chunkMaxLength?: number;
|
|
167
|
+
});
|
|
168
|
+
sessionHeader?: false | string;
|
|
169
|
+
generateId?: () => string;
|
|
170
|
+
jws?: {
|
|
171
|
+
signOptions?: Omit<JWSSignOptions, "expiresIn">;
|
|
172
|
+
verifyOptions?: JWTClaimValidationOptions;
|
|
173
|
+
};
|
|
174
|
+
hooks?: SessionHooksJWS<T, MaxAge>;
|
|
175
175
|
}
|
|
176
176
|
declare function useJWSSession<T extends Record<string, any> = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined>(event: HTTPEvent, config: SessionConfigJWS<T, MaxAge>): Promise<SessionManager<T, MaxAge>>;
|
|
177
177
|
declare function getJWSSession<T extends Record<string, any> = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined>(event: HTTPEvent, config: SessionConfigJWS<T, MaxAge>): Promise<SessionJWS<T, MaxAge>>;
|
|
@@ -180,6 +180,5 @@ declare function updateJWSSession<T extends Record<string, any> = SessionClaims,
|
|
|
180
180
|
declare function signJWSSession<T extends Record<string, any> = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined>(event: HTTPEvent, config: SessionConfigJWS<T, MaxAge>): Promise<string>;
|
|
181
181
|
declare function verifyJWSSession<T extends Record<string, any> = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined>(event: HTTPEvent, config: SessionConfigJWS<T, MaxAge>, token: string): Promise<Partial<SessionJWS<T, MaxAge>>>;
|
|
182
182
|
declare function clearJWSSession<T extends Record<string, any> = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined>(event: HTTPEvent, config: Partial<SessionConfigJWS<T, MaxAge>>): Promise<void>;
|
|
183
|
-
|
|
184
|
-
export { JWEEncryptOptions, JWEHeaderParameters, JWKSet, JWK_Private, JWK_Public, JWK_Symmetric, JWTClaimValidationOptions, JWTClaims, clearJWESession, clearJWSSession, getJWESession, getJWESessionToken, getJWSSession, getJWSSessionToken, sealJWESession, signJWSSession, unsealJWESession, updateJWESession, updateJWSSession, useJWESession, useJWSSession, verifyJWSSession };
|
|
185
|
-
export type { SessionClaims, SessionConfigJWE, SessionConfigJWS, SessionData, SessionHooksJWE, SessionHooksJWS, SessionJWE, SessionJWS, SessionManager, SessionUpdate };
|
|
183
|
+
//#endregion
|
|
184
|
+
export { CompositeKey, ContentEncryptionAlgorithm, DeriveKeyOptions, DeriveKeyReturn, GenerateJWKOptions, GenerateJWKReturn, GenerateKeyAlgorithm, GenerateKeyOptions, GenerateKeyReturn, JWEDecryptOptions, JWEDecryptResult, JWEEncryptOptions, JWEHeaderParameters, JWEKeyLookupFunction, JWEKeyManagementHeaderParameters, JWK, JWKAlgorithm, 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_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, JWT, JWTClaimValidationOptions, type JWTClaims, JoseHeaderParameters, KeyManagementAlgorithm, SessionClaims, SessionConfigJWE, SessionConfigJWS, SessionData, SessionHooksJWE, SessionHooksJWS, SessionJWE, SessionJWS, SessionManager, SessionUpdate, UnwrapKeyOptions, WrapKeyOptions, WrapKeyResult, clearJWESession, clearJWSSession, deriveJWKFromPassword, exportJWKToPEM, generateJWK, getJWESession, getJWESessionToken, getJWSSession, getJWSSessionToken, importJWKFromPEM, sealJWESession, signJWSSession, unsealJWESession, updateJWESession, updateJWSSession, useJWESession, useJWSSession, verifyJWSSession };
|