unjwt 0.8.1 → 0.8.3

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.
Files changed (37) hide show
  1. package/README.md +4 -4
  2. package/dist/THIRD-PARTY-LICENSES.md.gz +0 -0
  3. package/dist/_chunks/_codec-jwe.d.mts +101 -22
  4. package/dist/_chunks/_codec-jws.mjs +306 -232
  5. package/dist/_chunks/_cookie-attributes.d.mts +12 -0
  6. package/dist/_chunks/_jwt-internal.mjs +9 -6
  7. package/dist/_chunks/digest.d.mts +8 -0
  8. package/dist/_chunks/{algorithms.mjs → digest.mjs} +78 -8
  9. package/dist/_chunks/index.d.mts +313 -268
  10. package/dist/_chunks/index2.d.mts +2 -1
  11. package/dist/_chunks/index3.d.mts +1 -0
  12. package/dist/_chunks/jwe.d.mts +4 -4
  13. package/dist/_chunks/jwe.mjs +21 -3
  14. package/dist/_chunks/jwk.mjs +219 -173
  15. package/dist/_chunks/jws.d.mts +10 -10
  16. package/dist/_chunks/jws.mjs +18 -6
  17. package/dist/_chunks/jwt.d.mts +2 -1
  18. package/dist/_chunks/libs/cookie-es.mjs +255 -0
  19. package/dist/adapters/elysia/index.d.mts +32 -15
  20. package/dist/adapters/elysia/index.mjs +46 -67
  21. package/dist/adapters/h3/index.d.mts +135 -0
  22. package/dist/adapters/h3/index.mjs +119 -0
  23. package/dist/adapters/h3v1/index.d.mts +100 -27
  24. package/dist/adapters/h3v1/index.mjs +59 -76
  25. package/dist/core/jwe.d.mts +2 -2
  26. package/dist/core/jwk.d.mts +22 -14
  27. package/dist/core/jwk.mjs +2 -2
  28. package/dist/core/jws.d.mts +2 -2
  29. package/dist/core/utils/index.d.mts +2 -1
  30. package/dist/core/utils/index.mjs +2 -2
  31. package/dist/index.d.mts +4 -3
  32. package/dist/index.mjs +3 -3
  33. package/dist/session/index.d.mts +44 -0
  34. package/dist/session/index.mjs +113 -0
  35. package/package.json +37 -18
  36. package/dist/adapters/h3v2/index.d.mts +0 -65
  37. package/dist/adapters/h3v2/index.mjs +0 -139
@@ -0,0 +1,135 @@
1
+ import { JWESessionConfig, JWESessionHooks, JWSSessionConfig, JWSSessionHooks, OpenedSessionState, SessionClaims, SessionData, SessionDecryptOptions, SessionDefinition, SessionEncryptOptions, SessionIssueOptions, SessionManager, SessionRecord, SessionSignOptions, SessionState, SessionUpdate, SessionUpdateTrigger, SessionVerifyOptions } from "../../_chunks/_codec-jwe.mjs";
2
+ import { CompositeKey, ContentEncryptionAlgorithm, DeriveJWKOptions, DeriveJWKReturn, DeriveKeyOptions, DeriveKeyReturn, Duration, ECDHEphemeralKeyInput, ExpiresIn, GenerateJWKOptions, GenerateJWKReturn, GenerateKeyAlgorithm, GenerateKeyOptions, GenerateKeyReturn, GeneratedJWKMap, GeneratedKeyMap, ImportedKey, ImportedKeyMap, ImportedPEMJWK, JOSEConsumerOptions, JOSELimits, JOSEPayload, JOSEPayloadMode, JOSEPayloadTypeMap, JWEAsymmetricPrivateJWK, JWEAsymmetricPublicJWK, JWEDecryptJWK, JWEDecryptOptions, JWEDecryptResult, JWEEncryptJWK, JWEEncryptOptions, JWEFlattenedSerialization, JWEGeneralRecipient, JWEGeneralSerialization, JWEHeaderParameters, JWEKeyLookup, JWEKeyManagementHeaderParameters, JWELibraryHeaderName, JWEMultiDecryptKey, JWEMultiDecryptOptions, JWEMultiDecryptResult, JWEMultiEncryptOptions, JWEMultiRecipient, JWEProtectedHeader, JWK, JWKAlgorithm, JWKCacheAdapter, JWKLookupFunction, JWKLookupFunctionHeader, JWKMetadata, JWKPEMAlgorithm, JWKParameters, JWKSet, JWK_AES_Algorithm, 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, JWSHashedAlgorithm, JWSHeaderParameters, JWSKeyLookup, JWSMultiSignOptions, JWSMultiSigner, JWSMultiVerifyAllOptions, JWSMultiVerifyOptions, JWSMultiVerifyOutcome, JWSMultiVerifyResult, JWSProtectedHeader, JWSSignJWK, JWSSignOptions, JWSVerifyJWK, JWSVerifyOptions, JWSVerifyResult, JWT, JWTClaimValidationOptions, JWTClaims, JWTConfirmation, JWTTimeClaimOptions, JoseHeaderParameters, KeyManagementAlgorithm, KeyWrapAlgorithmOf, KeyWrappingAlgorithm, MaxTokenAge, NotBeforeIn, PEMType, PayloadOf, ToPublicJWKReturn, UnwrapKeyOptions, UnwrapKeyResult, UnwrappingKeyFor, WrapKeyOptions, WrapKeyResult, WrappingKeyFor } from "../../_chunks/index.mjs";
3
+ import { thumbprint } from "../../_chunks/index2.mjs";
4
+ import { deriveJWKFromPassword, exportPEM, generateJWK, importPEM, toPublicJWK } from "../../core/jwk.mjs";
5
+ import { HTTPEvent, setCookie } from "h3";
6
+ type CookieSerializeOptions = NonNullable<Parameters<typeof setCookie>[3]>;
7
+ /**
8
+ * Session state for the current request, mirroring the claims of its JWE token.
9
+ * @deprecated `unjwt/adapters/h3` (and `h3v2`) is removed in 0.9.0. `unjwt/session` takes the h3 v2 event as it is; a handler that throws after a write keeps its cookie through an `onUpdate`/`onClear` hook that copies `res.headers.getSetCookie()` into `res.errHeaders`.
10
+ */
11
+ interface SessionJWE<T extends SessionRecord = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined> extends SessionState<T, MaxAge> {}
12
+ /**
13
+ * JWE session hooks; `onRead`, `onExpire` and `onError` are mutually exclusive per token.
14
+ * @deprecated `unjwt/adapters/h3` (and `h3v2`) is removed in 0.9.0. `unjwt/session` takes the h3 v2 event as it is; a handler that throws after a write keeps its cookie through an `onUpdate`/`onClear` hook that copies `res.headers.getSetCookie()` into `res.errHeaders`.
15
+ */
16
+ interface SessionHooksJWE<T extends SessionRecord = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined, TEvent extends HTTPEvent = HTTPEvent> extends JWESessionHooks<SessionJWE<T, MaxAge>, SessionManager<T, MaxAge>, {
17
+ event: TEvent;
18
+ }, SessionConfigJWE<T, MaxAge, TEvent>> {}
19
+ /**
20
+ * Configuration for a JWE-backed (encrypted) session.
21
+ * @deprecated `unjwt/adapters/h3` (and `h3v2`) is removed in 0.9.0. `unjwt/session` takes the h3 v2 event as it is; a handler that throws after a write keeps its cookie through an `onUpdate`/`onClear` hook that copies `res.headers.getSetCookie()` into `res.errHeaders`.
22
+ */
23
+ interface SessionConfigJWE<T extends SessionRecord = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined, TEvent extends HTTPEvent = HTTPEvent> extends JWESessionConfig<MaxAge, CookieSerializeOptions> {
24
+ /** Cookie and session-header name. Default `"h3-jwe"`; a `.<digits>` suffix throws `ERR_SESSION_CONFIG_INVALID`. */
25
+ name?: string;
26
+ hooks?: SessionHooksJWE<T, MaxAge, TEvent>;
27
+ }
28
+ /**
29
+ * Defines a JWE (encrypted) session once; its `use`, `token`, `issue` and `open` serve every request.
30
+ * @deprecated `unjwt/adapters/h3` (and `h3v2`) is removed in 0.9.0. `unjwt/session` takes the h3 v2 event as it is; a handler that throws after a write keeps its cookie through an `onUpdate`/`onClear` hook that copies `res.headers.getSetCookie()` into `res.errHeaders`.
31
+ */
32
+ export declare function defineJWESession<T extends SessionRecord = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined, TEvent extends HTTPEvent = HTTPEvent>(config: SessionConfigJWE<T, MaxAge, TEvent>): SessionDefinition<T, MaxAge, TEvent>;
33
+ /**
34
+ * Create a JWE (encrypted) session manager for the request.
35
+ * @deprecated Use `defineJWESession(config).use(event)`.
36
+ */
37
+ export declare function useJWESession<T extends SessionRecord = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined, TEvent extends HTTPEvent = HTTPEvent>(event: TEvent, config: SessionConfigJWE<T, MaxAge, TEvent>): Promise<SessionManager<T, MaxAge>>;
38
+ /**
39
+ * Get (and lazily initialize) the session for the current request.
40
+ * @deprecated Use `defineJWESession(config).use(event)`; the manager exposes the same state.
41
+ */
42
+ export declare function getJWESession<T extends SessionRecord = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined, TEvent extends HTTPEvent = HTTPEvent>(event: TEvent, config: SessionConfigJWE<T, MaxAge, TEvent>): Promise<SessionJWE<T, MaxAge>>;
43
+ /**
44
+ * Read the raw session token: cookie first, then the session header (default `x-<name>-session`, optional `Bearer`).
45
+ * @deprecated Use `defineJWESession(config).token(event)`.
46
+ */
47
+ export declare function getJWESessionToken<T extends SessionRecord = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined, TEvent extends HTTPEvent = HTTPEvent>(event: TEvent, config: SessionConfigJWE<T, MaxAge, TEvent>): string | undefined;
48
+ /**
49
+ * Update the session data (if provided) and reissue the JWE; `options.maxAge` overrides this token's lifetime.
50
+ * @deprecated Use `(await defineJWESession(config).use(event)).update(update, options)`.
51
+ */
52
+ export declare function updateJWESession<T extends SessionRecord = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined, TEvent extends HTTPEvent = HTTPEvent>(event: TEvent, config: SessionConfigJWE<T, MaxAge, TEvent>, update?: SessionUpdate<T>, options?: SessionIssueOptions): Promise<SessionJWE<T, MaxAge> & {
53
+ id: string;
54
+ token: string;
55
+ }>;
56
+ /**
57
+ * Seal the session as a compact JWE without writing a cookie; fresh `jti` if no ID, no token source needed.
58
+ * @deprecated Use `defineJWESession(config).issue(data)` to mint a token, or `(await defineJWESession(config).use(event)).token` for the current one.
59
+ */
60
+ export declare function sealJWESession<T extends SessionRecord = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined, TEvent extends HTTPEvent = HTTPEvent>(event: TEvent, config: SessionConfigJWE<T, MaxAge, TEvent>): Promise<string>;
61
+ /**
62
+ * Decrypt a compact JWE into a session, checking `typ`, pinned `alg`/`enc`, `jti`/`iat` and `exp` (required with `maxAge`).
63
+ * @deprecated Use `defineJWESession(config).open(sealed)`.
64
+ */
65
+ export declare function unsealJWESession<T extends SessionRecord = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined, TEvent extends HTTPEvent = HTTPEvent>(event: TEvent, config: SessionConfigJWE<T, MaxAge, TEvent>, sealed: string): Promise<Partial<SessionJWE<T, MaxAge>>>;
66
+ /**
67
+ * Drop the session cookie and leave an empty session for the rest of the request.
68
+ * @deprecated Use `(await defineJWESession(config).use(event)).clear()`.
69
+ */
70
+ export declare function clearJWESession<T extends SessionRecord = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined, TEvent extends HTTPEvent = HTTPEvent>(event: TEvent, config: SessionConfigJWE<T, MaxAge, TEvent>): Promise<void>;
71
+ /**
72
+ * Session state for the current request, mirroring the claims of its JWS token.
73
+ * @deprecated `unjwt/adapters/h3` (and `h3v2`) is removed in 0.9.0. `unjwt/session` takes the h3 v2 event as it is; a handler that throws after a write keeps its cookie through an `onUpdate`/`onClear` hook that copies `res.headers.getSetCookie()` into `res.errHeaders`.
74
+ */
75
+ interface SessionJWS<T extends SessionRecord = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined> extends SessionState<T, MaxAge> {}
76
+ /**
77
+ * JWS session hooks; `onRead`, `onExpire` and `onError` are mutually exclusive per token.
78
+ * @deprecated `unjwt/adapters/h3` (and `h3v2`) is removed in 0.9.0. `unjwt/session` takes the h3 v2 event as it is; a handler that throws after a write keeps its cookie through an `onUpdate`/`onClear` hook that copies `res.headers.getSetCookie()` into `res.errHeaders`.
79
+ */
80
+ interface SessionHooksJWS<T extends SessionRecord = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined, TEvent extends HTTPEvent = HTTPEvent> extends JWSSessionHooks<SessionJWS<T, MaxAge>, SessionManager<T, MaxAge>, {
81
+ event: TEvent;
82
+ }, SessionConfigJWS<T, MaxAge, TEvent>> {}
83
+ /**
84
+ * Configuration for a JWS-backed (signed, not encrypted) session.
85
+ * @deprecated `unjwt/adapters/h3` (and `h3v2`) is removed in 0.9.0. `unjwt/session` takes the h3 v2 event as it is; a handler that throws after a write keeps its cookie through an `onUpdate`/`onClear` hook that copies `res.headers.getSetCookie()` into `res.errHeaders`.
86
+ */
87
+ interface SessionConfigJWS<T extends SessionRecord = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined, TEvent extends HTTPEvent = HTTPEvent> extends JWSSessionConfig<MaxAge, CookieSerializeOptions> {
88
+ /** Cookie and session-header name. Default `"h3-jws"`; a `.<digits>` suffix throws `ERR_SESSION_CONFIG_INVALID`. */
89
+ name?: string;
90
+ hooks?: SessionHooksJWS<T, MaxAge, TEvent>;
91
+ }
92
+ /**
93
+ * Defines a JWS (signed, not encrypted) session once, its data readable by clients; `use`, `token`, `issue` and `open` serve every request.
94
+ * @deprecated `unjwt/adapters/h3` (and `h3v2`) is removed in 0.9.0. `unjwt/session` takes the h3 v2 event as it is; a handler that throws after a write keeps its cookie through an `onUpdate`/`onClear` hook that copies `res.headers.getSetCookie()` into `res.errHeaders`.
95
+ */
96
+ export declare function defineJWSSession<T extends SessionRecord = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined, TEvent extends HTTPEvent = HTTPEvent>(config: SessionConfigJWS<T, MaxAge, TEvent>): SessionDefinition<T, MaxAge, TEvent>;
97
+ /**
98
+ * Create a JWS (signed, not encrypted) session manager for the request.
99
+ * @deprecated Use `defineJWSSession(config).use(event)`.
100
+ */
101
+ export declare function useJWSSession<T extends SessionRecord = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined, TEvent extends HTTPEvent = HTTPEvent>(event: TEvent, config: SessionConfigJWS<T, MaxAge, TEvent>): Promise<SessionManager<T, MaxAge>>;
102
+ /**
103
+ * Get (and lazily initialize) the session for the current request.
104
+ * @deprecated Use `defineJWSSession(config).use(event)`; the manager exposes the same state.
105
+ */
106
+ export declare function getJWSSession<T extends SessionRecord = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined, TEvent extends HTTPEvent = HTTPEvent>(event: TEvent, config: SessionConfigJWS<T, MaxAge, TEvent>): Promise<SessionJWS<T, MaxAge>>;
107
+ /**
108
+ * Read the raw session token: cookie first, then the session header (default `x-<name>-session`, optional `Bearer`).
109
+ * @deprecated Use `defineJWSSession(config).token(event)`.
110
+ */
111
+ export declare function getJWSSessionToken<T extends SessionRecord = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined, TEvent extends HTTPEvent = HTTPEvent>(event: TEvent, config: SessionConfigJWS<T, MaxAge, TEvent>): string | undefined;
112
+ /**
113
+ * Update the session data (if provided) and reissue the JWS; `options.maxAge` overrides this token's lifetime.
114
+ * @deprecated Use `(await defineJWSSession(config).use(event)).update(update, options)`.
115
+ */
116
+ export declare function updateJWSSession<T extends SessionRecord = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined, TEvent extends HTTPEvent = HTTPEvent>(event: TEvent, config: SessionConfigJWS<T, MaxAge, TEvent>, update?: SessionUpdate<T>, options?: SessionIssueOptions): Promise<SessionJWS<T, MaxAge> & {
117
+ id: string;
118
+ token: string;
119
+ }>;
120
+ /**
121
+ * Sign the session as a compact JWS without writing a cookie; fresh `jti` if no ID, no token source needed.
122
+ * @deprecated Use `defineJWSSession(config).issue(data)` to mint a token, or `(await defineJWSSession(config).use(event)).token` for the current one.
123
+ */
124
+ export declare function signJWSSession<T extends SessionRecord = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined, TEvent extends HTTPEvent = HTTPEvent>(event: TEvent, config: SessionConfigJWS<T, MaxAge, TEvent>): Promise<string>;
125
+ /**
126
+ * Verify a compact JWS into a session, checking `typ`, pinned `alg`, `jti`/`iat` and `exp` (required with `maxAge`).
127
+ * @deprecated Use `defineJWSSession(config).open(token)`.
128
+ */
129
+ export declare function verifyJWSSession<T extends SessionRecord = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined, TEvent extends HTTPEvent = HTTPEvent>(event: TEvent, config: SessionConfigJWS<T, MaxAge, TEvent>, token: string): Promise<Partial<SessionJWS<T, MaxAge>>>;
130
+ /**
131
+ * Drop the session cookie and leave an empty session for the rest of the request.
132
+ * @deprecated Use `(await defineJWSSession(config).use(event)).clear()`.
133
+ */
134
+ export declare function clearJWSSession<T extends SessionRecord = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined, TEvent extends HTTPEvent = HTTPEvent>(event: TEvent, config: SessionConfigJWS<T, MaxAge, TEvent>): Promise<void>;
135
+ export { type CompositeKey, type ContentEncryptionAlgorithm, type DeriveJWKOptions, type DeriveJWKReturn, type DeriveKeyOptions, type DeriveKeyReturn, type Duration, type ECDHEphemeralKeyInput, type ExpiresIn, type GenerateJWKOptions, type GenerateJWKReturn, type GenerateKeyAlgorithm, type GenerateKeyOptions, type GenerateKeyReturn, type GeneratedJWKMap, type GeneratedKeyMap, type ImportedKey, type ImportedKeyMap, type ImportedPEMJWK, type JOSEConsumerOptions, type JOSELimits, type JOSEPayload, type JOSEPayloadMode, type JOSEPayloadTypeMap, type JWEAsymmetricPrivateJWK, type JWEAsymmetricPublicJWK, type JWEDecryptJWK, type JWEDecryptOptions, type JWEDecryptResult, type JWEEncryptJWK, type JWEEncryptOptions, type JWEFlattenedSerialization, type JWEGeneralRecipient, type JWEGeneralSerialization, type JWEHeaderParameters, type JWEKeyLookup, type JWEKeyManagementHeaderParameters, type JWELibraryHeaderName, type JWEMultiDecryptKey, type JWEMultiDecryptOptions, type JWEMultiDecryptResult, type JWEMultiEncryptOptions, type JWEMultiRecipient, type JWEProtectedHeader, type JWK, type JWKAlgorithm, type JWKCacheAdapter, type JWKLookupFunction, type JWKLookupFunctionHeader, type JWKMetadata, type JWKPEMAlgorithm, type JWKParameters, type JWKSet, type JWK_AES_Algorithm, 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 JWSHashedAlgorithm, type JWSHeaderParameters, type JWSKeyLookup, 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 JWTConfirmation, type JWTTimeClaimOptions, type JoseHeaderParameters, type KeyManagementAlgorithm, type KeyWrapAlgorithmOf, type KeyWrappingAlgorithm, type MaxTokenAge, type NotBeforeIn, type OpenedSessionState, type PEMType, type PayloadOf, type SessionClaims, type SessionConfigJWE, type SessionConfigJWS, type SessionData, type SessionDecryptOptions, type SessionDefinition, type SessionEncryptOptions, type SessionHooksJWE, type SessionHooksJWS, type SessionIssueOptions, type SessionJWE, type SessionJWS, type SessionManager, type SessionSignOptions, type SessionUpdate, type SessionUpdateTrigger, type SessionVerifyOptions, type ToPublicJWKReturn, type UnwrapKeyOptions, type UnwrapKeyResult, type UnwrappingKeyFor, type WrapKeyOptions, type WrapKeyResult, type WrappingKeyFor, deriveJWKFromPassword, exportPEM, generateJWK, importPEM, thumbprint, toPublicJWK };
@@ -0,0 +1,119 @@
1
+ import { deriveJWKFromPassword, exportPEM, generateJWK, importPEM, thumbprint, toPublicJWK } from "../../_chunks/jwk.mjs";
2
+ import { bindSession, createJWECodec, createJWSCodec, defineSession, dropSession, encodeSession, issueSession, loadSession, openSessionToken, sessionActions, setCookieName, setCookieValues } from "../../_chunks/_codec-jws.mjs";
3
+ import { getCookie, getEventContext, setCookie } from "h3";
4
+ const PREFIX = "[unjwt/h3]";
5
+ const h3SessionDriver = {
6
+ prefix: PREFIX,
7
+ state: (event) => getEventContext(event).sessions ||= Object.create(null),
8
+ header: (event, name) => event.req.headers.get(name),
9
+ cookies: (event) => hasResponse(event) ? responseCookieJar(event) : { read: (name) => getCookie(event, name) }
10
+ };
11
+ function responseCookieJar(event) {
12
+ return {
13
+ read: (name) => getCookie(event, name),
14
+ written: (name) => setCookieValues(event.res.headers.getSetCookie())[name],
15
+ write: (name, value, attrs) => {
16
+ setCookie(event, name, value, attrs);
17
+ stageErrCookie(event, name);
18
+ }
19
+ };
20
+ }
21
+ function hasResponse(event) {
22
+ return "res" in event && Boolean(event.res);
23
+ }
24
+ function stageErrCookie(event, cookieName) {
25
+ const isThisCookie = (cookie) => setCookieName(cookie) === cookieName;
26
+ const errHeaders = event.res.errHeaders;
27
+ const staged = [...errHeaders.getSetCookie().filter((cookie) => !isThisCookie(cookie)), ...event.res.headers.getSetCookie().filter((cookie) => isThisCookie(cookie))];
28
+ errHeaders.delete("set-cookie");
29
+ for (const cookie of staged) errHeaders.append("set-cookie", cookie);
30
+ }
31
+ const codec$1 = createJWECodec({
32
+ prefix: PREFIX,
33
+ defaultName: "h3-jwe"
34
+ });
35
+ const hookArgs$1 = (event) => ({ event });
36
+ function defineJWESession(config) {
37
+ return defineSession(config, {
38
+ driver: h3SessionDriver,
39
+ hookArgs: hookArgs$1,
40
+ codec: codec$1
41
+ });
42
+ }
43
+ async function useJWESession(event, config) {
44
+ return defineJWESession(config).use(event);
45
+ }
46
+ async function getJWESession(event, config) {
47
+ return loadSession(bind$1(event, config));
48
+ }
49
+ function getJWESessionToken(event, config) {
50
+ return defineJWESession(config).token(event);
51
+ }
52
+ async function updateJWESession(event, config, update, options) {
53
+ return issueSession(bind$1(event, config), update, options);
54
+ }
55
+ async function sealJWESession(event, config) {
56
+ return encodeSession(bind$1(event, config));
57
+ }
58
+ async function unsealJWESession(event, config, sealed) {
59
+ return openSessionToken(codec$1, config, {
60
+ token: sealed,
61
+ args: { event }
62
+ });
63
+ }
64
+ async function clearJWESession(event, config) {
65
+ return dropSession(bind$1(event, config));
66
+ }
67
+ function bind$1(event, config) {
68
+ return bindSession(event, config, {
69
+ driver: h3SessionDriver,
70
+ hookArgs: hookArgs$1,
71
+ codec: codec$1,
72
+ actions: sessionActions()
73
+ });
74
+ }
75
+ const codec = createJWSCodec({
76
+ prefix: PREFIX,
77
+ defaultName: "h3-jws"
78
+ });
79
+ const hookArgs = (event) => ({ event });
80
+ function defineJWSSession(config) {
81
+ return defineSession(config, {
82
+ driver: h3SessionDriver,
83
+ hookArgs,
84
+ codec
85
+ });
86
+ }
87
+ async function useJWSSession(event, config) {
88
+ return defineJWSSession(config).use(event);
89
+ }
90
+ async function getJWSSession(event, config) {
91
+ return loadSession(bind(event, config));
92
+ }
93
+ function getJWSSessionToken(event, config) {
94
+ return defineJWSSession(config).token(event);
95
+ }
96
+ async function updateJWSSession(event, config, update, options) {
97
+ return issueSession(bind(event, config), update, options);
98
+ }
99
+ async function signJWSSession(event, config) {
100
+ return encodeSession(bind(event, config));
101
+ }
102
+ async function verifyJWSSession(event, config, token) {
103
+ return openSessionToken(codec, config, {
104
+ token,
105
+ args: { event }
106
+ });
107
+ }
108
+ async function clearJWSSession(event, config) {
109
+ return dropSession(bind(event, config));
110
+ }
111
+ function bind(event, config) {
112
+ return bindSession(event, config, {
113
+ driver: h3SessionDriver,
114
+ hookArgs,
115
+ codec,
116
+ actions: sessionActions()
117
+ });
118
+ }
119
+ export { clearJWESession, clearJWSSession, defineJWESession, defineJWSSession, deriveJWKFromPassword, exportPEM, generateJWK, getJWESession, getJWESessionToken, getJWSSession, getJWSSessionToken, importPEM, sealJWESession, signJWSSession, thumbprint, toPublicJWK, unsealJWESession, updateJWESession, updateJWSSession, useJWESession, useJWSSession, verifyJWSSession };
@@ -1,10 +1,13 @@
1
- import { CompositeKey, ContentEncryptionAlgorithm, DeriveKeyOptions, DeriveKeyReturn, Duration, ECDHEphemeralKeyInput, ExpiresIn, GenerateJWKOptions, GenerateJWKReturn, GenerateKeyAlgorithm, GenerateKeyOptions, GenerateKeyReturn, GeneratedJWKMap, GeneratedKeyMap, ImportedKey, ImportedKeyMap, JOSEConsumerOptions, JOSELimits, JOSEPayload, JOSEPayloadMode, JOSEPayloadTypeMap, JWEAsymmetricPrivateJWK, JWEAsymmetricPublicJWK, JWEDecryptJWK, JWEDecryptOptions, JWEDecryptResult, JWEEncryptJWK, JWEEncryptOptions, JWEFlattenedSerialization, JWEGeneralRecipient, JWEGeneralSerialization, JWEHeaderParameters, JWEKeyManagementHeaderParameters, JWELibraryHeaderName, JWEMultiDecryptKey, JWEMultiDecryptOptions, JWEMultiDecryptResult, JWEMultiEncryptOptions, JWEMultiRecipient, JWEProtectedHeader, JWK, JWKAlgorithm, JWKCacheAdapter, JWKLookupFunction, JWKLookupFunctionHeader, JWKMetadata, 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, JWTTimeClaimOptions, JoseHeaderParameters, KeyManagementAlgorithm, MaxTokenAge, NotBeforeIn, PayloadOf, UnwrapKeyOptions, UnwrapKeyResult, UnwrappingKeyFor, WrapKeyOptions, WrapKeyResult, WrappingKeyFor } from "../../_chunks/index.mjs";
2
- import { JWESessionConfig, JWESessionHooks, JWSSessionConfig, JWSSessionHooks, SessionClaims, SessionData, SessionDecryptOptions, SessionEncryptOptions, SessionIssueOptions, SessionManager, SessionRecord, SessionSignOptions, SessionState, SessionUpdate, SessionUpdateTrigger, SessionVerifyOptions } from "../../_chunks/_codec-jwe.mjs";
1
+ import { JWESessionConfig, JWESessionHooks, JWSSessionConfig, JWSSessionHooks, OpenedSessionState, SessionClaims, SessionData, SessionDecryptOptions, SessionDefinition, SessionEncryptOptions, SessionIssueOptions, SessionManager, SessionRecord, SessionSignOptions, SessionState, SessionUpdate, SessionUpdateTrigger, SessionVerifyOptions } from "../../_chunks/_codec-jwe.mjs";
2
+ import { CompositeKey, ContentEncryptionAlgorithm, DeriveJWKOptions, DeriveJWKReturn, DeriveKeyOptions, DeriveKeyReturn, Duration, ECDHEphemeralKeyInput, ExpiresIn, GenerateJWKOptions, GenerateJWKReturn, GenerateKeyAlgorithm, GenerateKeyOptions, GenerateKeyReturn, GeneratedJWKMap, GeneratedKeyMap, ImportedKey, ImportedKeyMap, ImportedPEMJWK, JOSEConsumerOptions, JOSELimits, JOSEPayload, JOSEPayloadMode, JOSEPayloadTypeMap, JWEAsymmetricPrivateJWK, JWEAsymmetricPublicJWK, JWEDecryptJWK, JWEDecryptOptions, JWEDecryptResult, JWEEncryptJWK, JWEEncryptOptions, JWEFlattenedSerialization, JWEGeneralRecipient, JWEGeneralSerialization, JWEHeaderParameters, JWEKeyLookup, JWEKeyManagementHeaderParameters, JWELibraryHeaderName, JWEMultiDecryptKey, JWEMultiDecryptOptions, JWEMultiDecryptResult, JWEMultiEncryptOptions, JWEMultiRecipient, JWEProtectedHeader, JWK, JWKAlgorithm, JWKCacheAdapter, JWKLookupFunction, JWKLookupFunctionHeader, JWKMetadata, JWKPEMAlgorithm, JWKParameters, JWKSet, JWK_AES_Algorithm, 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, JWSHashedAlgorithm, JWSHeaderParameters, JWSKeyLookup, JWSMultiSignOptions, JWSMultiSigner, JWSMultiVerifyAllOptions, JWSMultiVerifyOptions, JWSMultiVerifyOutcome, JWSMultiVerifyResult, JWSProtectedHeader, JWSSignJWK, JWSSignOptions, JWSVerifyJWK, JWSVerifyOptions, JWSVerifyResult, JWT, JWTClaimValidationOptions, JWTClaims, JWTConfirmation, JWTTimeClaimOptions, JoseHeaderParameters, KeyManagementAlgorithm, KeyWrapAlgorithmOf, KeyWrappingAlgorithm, MaxTokenAge, NotBeforeIn, PEMType, PayloadOf, ToPublicJWKReturn, UnwrapKeyOptions, UnwrapKeyResult, UnwrappingKeyFor, WrapKeyOptions, WrapKeyResult, WrappingKeyFor } from "../../_chunks/index.mjs";
3
3
  import { thumbprint } from "../../_chunks/index2.mjs";
4
- import { deriveJWKFromPassword, exportPEM, generateJWK, importPEM } from "../../core/jwk.mjs";
5
- import { H3Event, H3EventContext } from "h3";
6
- import { CookieSerializeOptions } from "cookie-es";
7
- /** Event shapes the adapter reads from: an h3 v1 event, or any request-like object. */
4
+ import { deriveJWKFromPassword, exportPEM, generateJWK, importPEM, toPublicJWK } from "../../core/jwk.mjs";
5
+ import { H3Event, H3EventContext, setCookie } from "h3";
6
+ type CookieSerializeOptions = NonNullable<Parameters<typeof setCookie>[3]>;
7
+ /**
8
+ * Event shapes the adapter reads from in websockets.
9
+ * @deprecated `unjwt/adapters/h3v1` is removed in 0.9.0. Nuxt 4.6+ runs sessions through `unjwt/session` with handlers from `nuxt/server`; h3 v2, Nuxt 5 and Nitro 3 through `unjwt/adapters/h3`.
10
+ */
8
11
  type CompatEvent = {
9
12
  request: {
10
13
  headers: Headers;
@@ -14,62 +17,132 @@ type CompatEvent = {
14
17
  headers: Headers;
15
18
  context: H3EventContext;
16
19
  };
17
- /** Session state for the current request, mirroring the claims of its JWE token. */
20
+ /**
21
+ * Session state for the current request, mirroring the claims of its JWE token.
22
+ * @deprecated `unjwt/adapters/h3v1` is removed in 0.9.0. Nuxt 4.6+ runs sessions through `unjwt/session` with handlers from `nuxt/server`; h3 v2, Nuxt 5 and Nitro 3 through `unjwt/adapters/h3`.
23
+ */
18
24
  interface SessionJWE<T extends SessionRecord = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined> extends SessionState<T, MaxAge> {}
19
- /** JWE session hooks; `onRead`, `onExpire` and `onError` are mutually exclusive per token. */
25
+ /**
26
+ * JWE session hooks; `onRead`, `onExpire` and `onError` are mutually exclusive per token.
27
+ * @deprecated `unjwt/adapters/h3v1` is removed in 0.9.0. Nuxt 4.6+ runs sessions through `unjwt/session` with handlers from `nuxt/server`; h3 v2, Nuxt 5 and Nitro 3 through `unjwt/adapters/h3`.
28
+ */
20
29
  interface SessionHooksJWE<T extends SessionRecord = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined, TEvent extends CompatEvent | H3Event = CompatEvent | H3Event> extends JWESessionHooks<SessionJWE<T, MaxAge>, SessionManager<T, MaxAge>, {
21
30
  event: TEvent;
22
31
  }, SessionConfigJWE<T, MaxAge, TEvent>> {}
23
- /** Configuration for a JWE-backed (encrypted) session. */
32
+ /**
33
+ * Configuration for a JWE-backed (encrypted) session.
34
+ * @deprecated `unjwt/adapters/h3v1` is removed in 0.9.0. Nuxt 4.6+ runs sessions through `unjwt/session` with handlers from `nuxt/server`; h3 v2, Nuxt 5 and Nitro 3 through `unjwt/adapters/h3`.
35
+ */
24
36
  interface SessionConfigJWE<T extends SessionRecord = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined, TEvent extends CompatEvent | H3Event = CompatEvent | H3Event> extends JWESessionConfig<MaxAge, CookieSerializeOptions> {
25
37
  /** Cookie and session-header name. Default `"h3-jwe"`; a `.<digits>` suffix throws `ERR_SESSION_CONFIG_INVALID`. */
26
38
  name?: string;
27
39
  hooks?: SessionHooksJWE<T, MaxAge, TEvent>;
28
40
  }
29
- /** Create a JWE (encrypted) session manager for the request. */
41
+ /**
42
+ * Defines a JWE (encrypted) session once; its `use`, `token`, `issue` and `open` serve every request.
43
+ * @deprecated `unjwt/adapters/h3v1` is removed in 0.9.0. Nuxt 4.6+ runs sessions through `unjwt/session` with handlers from `nuxt/server`; h3 v2, Nuxt 5 and Nitro 3 through `unjwt/adapters/h3`.
44
+ */
45
+ export declare function defineJWESession<T extends SessionRecord = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined, TEvent extends CompatEvent | H3Event = CompatEvent | H3Event>(config: SessionConfigJWE<T, MaxAge, TEvent>): SessionDefinition<T, MaxAge, TEvent>;
46
+ /**
47
+ * Create a JWE (encrypted) session manager for the request.
48
+ * @deprecated Use `defineJWESession(config).use(event)`.
49
+ */
30
50
  export declare function useJWESession<T extends SessionRecord = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined, TEvent extends CompatEvent | H3Event = CompatEvent | H3Event>(event: TEvent, config: SessionConfigJWE<T, MaxAge, TEvent>): Promise<SessionManager<T, MaxAge>>;
31
- /** Get (and lazily initialize) the session for the current request. */
51
+ /**
52
+ * Get (and lazily initialize) the session for the current request.
53
+ * @deprecated Use `defineJWESession(config).use(event)`; the manager exposes the same state.
54
+ */
32
55
  export declare function getJWESession<T extends SessionRecord = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined, TEvent extends CompatEvent | H3Event = CompatEvent | H3Event>(event: TEvent, config: SessionConfigJWE<T, MaxAge, TEvent>): Promise<SessionJWE<T, MaxAge>>;
33
- /** Read the raw session token: cookie first, then the session header (default `x-<name>-session`, optional `Bearer`). */
56
+ /**
57
+ * Read the raw session token: cookie first, then the session header (default `x-<name>-session`, optional `Bearer`).
58
+ * @deprecated Use `defineJWESession(config).token(event)`.
59
+ */
34
60
  export declare function getJWESessionToken<T extends SessionRecord = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined, TEvent extends CompatEvent | H3Event = CompatEvent | H3Event>(event: TEvent, config: SessionConfigJWE<T, MaxAge, TEvent>): string | undefined;
35
- /** Update the session data (if provided) and reissue the JWE; `options.maxAge` overrides this token's lifetime. */
61
+ /**
62
+ * Update the session data (if provided) and reissue the JWE; `options.maxAge` overrides this token's lifetime.
63
+ * @deprecated Use `(await defineJWESession(config).use(event)).update(update, options)`.
64
+ */
36
65
  export declare function updateJWESession<T extends SessionRecord = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined, TEvent extends CompatEvent | H3Event = CompatEvent | H3Event>(event: TEvent, config: SessionConfigJWE<T, MaxAge, TEvent>, update?: SessionUpdate<T>, options?: SessionIssueOptions): Promise<SessionJWE<T, MaxAge> & {
37
66
  id: string;
38
67
  token: string;
39
68
  }>;
40
- /** Seal the session as a compact JWE without writing a cookie; fresh `jti` if no ID, no token source needed. */
69
+ /**
70
+ * Seal the session as a compact JWE without writing a cookie; fresh `jti` if no ID, no token source needed.
71
+ * @deprecated Use `defineJWESession(config).issue(data)` to mint a token, or `(await defineJWESession(config).use(event)).token` for the current one.
72
+ */
41
73
  export declare function sealJWESession<T extends SessionRecord = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined, TEvent extends CompatEvent | H3Event = CompatEvent | H3Event>(event: TEvent, config: SessionConfigJWE<T, MaxAge, TEvent>): Promise<string>;
42
- /** Decrypt a compact JWE into a session, checking `typ`, pinned `alg`/`enc`, `jti`/`iat` and `exp` (required with `maxAge`). */
74
+ /**
75
+ * Decrypt a compact JWE into a session, checking `typ`, pinned `alg`/`enc`, `jti`/`iat` and `exp` (required with `maxAge`).
76
+ * @deprecated Use `defineJWESession(config).open(sealed)`.
77
+ */
43
78
  export declare function unsealJWESession<T extends SessionRecord = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined, TEvent extends CompatEvent | H3Event = CompatEvent | H3Event>(event: TEvent, config: SessionConfigJWE<T, MaxAge, TEvent>, sealed: string): Promise<Partial<SessionJWE<T, MaxAge>>>;
44
- /** Drop the session cookie and leave an empty session for the rest of the request. */
79
+ /**
80
+ * Drop the session cookie and leave an empty session for the rest of the request.
81
+ * @deprecated Use `(await defineJWESession(config).use(event)).clear()`.
82
+ */
45
83
  export declare function clearJWESession<T extends SessionRecord = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined, TEvent extends CompatEvent | H3Event = CompatEvent | H3Event>(event: TEvent, config: SessionConfigJWE<T, MaxAge, TEvent>): Promise<void>;
46
- /** Session state for the current request, mirroring the claims of its JWS token. */
84
+ /**
85
+ * Session state for the current request, mirroring the claims of its JWS token.
86
+ * @deprecated `unjwt/adapters/h3v1` is removed in 0.9.0. Nuxt 4.6+ runs sessions through `unjwt/session` with handlers from `nuxt/server`; h3 v2, Nuxt 5 and Nitro 3 through `unjwt/adapters/h3`.
87
+ */
47
88
  interface SessionJWS<T extends SessionRecord = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined> extends SessionState<T, MaxAge> {}
48
- /** JWS session hooks; `onRead`, `onExpire` and `onError` are mutually exclusive per token. */
89
+ /**
90
+ * JWS session hooks; `onRead`, `onExpire` and `onError` are mutually exclusive per token.
91
+ * @deprecated `unjwt/adapters/h3v1` is removed in 0.9.0. Nuxt 4.6+ runs sessions through `unjwt/session` with handlers from `nuxt/server`; h3 v2, Nuxt 5 and Nitro 3 through `unjwt/adapters/h3`.
92
+ */
49
93
  interface SessionHooksJWS<T extends SessionRecord = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined, TEvent extends CompatEvent | H3Event = CompatEvent | H3Event> extends JWSSessionHooks<SessionJWS<T, MaxAge>, SessionManager<T, MaxAge>, {
50
94
  event: TEvent;
51
95
  }, SessionConfigJWS<T, MaxAge, TEvent>> {}
52
- /** Configuration for a JWS-backed (signed, not encrypted) session. */
96
+ /**
97
+ * Configuration for a JWS-backed (signed, not encrypted) session.
98
+ * @deprecated `unjwt/adapters/h3v1` is removed in 0.9.0. Nuxt 4.6+ runs sessions through `unjwt/session` with handlers from `nuxt/server`; h3 v2, Nuxt 5 and Nitro 3 through `unjwt/adapters/h3`.
99
+ */
53
100
  interface SessionConfigJWS<T extends SessionRecord = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined, TEvent extends CompatEvent | H3Event = CompatEvent | H3Event> extends JWSSessionConfig<MaxAge, CookieSerializeOptions> {
54
101
  /** Cookie and session-header name. Default `"h3-jws"`; a `.<digits>` suffix throws `ERR_SESSION_CONFIG_INVALID`. */
55
102
  name?: string;
56
103
  hooks?: SessionHooksJWS<T, MaxAge, TEvent>;
57
104
  }
58
- /** Create a JWS (signed, not encrypted) session manager for the request; clients can read its data. */
105
+ /**
106
+ * Defines a JWS (signed, not encrypted) session once, its data readable by clients; `use`, `token`, `issue` and `open` serve every request.
107
+ * @deprecated `unjwt/adapters/h3v1` is removed in 0.9.0. Nuxt 4.6+ runs sessions through `unjwt/session` with handlers from `nuxt/server`; h3 v2, Nuxt 5 and Nitro 3 through `unjwt/adapters/h3`.
108
+ */
109
+ export declare function defineJWSSession<T extends SessionRecord = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined, TEvent extends CompatEvent | H3Event = CompatEvent | H3Event>(config: SessionConfigJWS<T, MaxAge, TEvent>): SessionDefinition<T, MaxAge, TEvent>;
110
+ /**
111
+ * Create a JWS (signed, not encrypted) session manager for the request.
112
+ * @deprecated Use `defineJWSSession(config).use(event)`.
113
+ */
59
114
  export declare function useJWSSession<T extends SessionRecord = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined, TEvent extends CompatEvent | H3Event = CompatEvent | H3Event>(event: TEvent, config: SessionConfigJWS<T, MaxAge, TEvent>): Promise<SessionManager<T, MaxAge>>;
60
- /** Get (and lazily initialize) the session for the current request. */
115
+ /**
116
+ * Get (and lazily initialize) the session for the current request.
117
+ * @deprecated Use `defineJWSSession(config).use(event)`; the manager exposes the same state.
118
+ */
61
119
  export declare function getJWSSession<T extends SessionRecord = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined, TEvent extends CompatEvent | H3Event = CompatEvent | H3Event>(event: TEvent, config: SessionConfigJWS<T, MaxAge, TEvent>): Promise<SessionJWS<T, MaxAge>>;
62
- /** Read the raw session token: cookie first, then the session header (default `x-<name>-session`, optional `Bearer`). */
120
+ /**
121
+ * Read the raw session token: cookie first, then the session header (default `x-<name>-session`, optional `Bearer`).
122
+ * @deprecated Use `defineJWSSession(config).token(event)`.
123
+ */
63
124
  export declare function getJWSSessionToken<T extends SessionRecord = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined, TEvent extends CompatEvent | H3Event = CompatEvent | H3Event>(event: TEvent, config: SessionConfigJWS<T, MaxAge, TEvent>): string | undefined;
64
- /** Update the session data (if provided) and reissue the JWS; `options.maxAge` overrides this token's lifetime. */
125
+ /**
126
+ * Update the session data (if provided) and reissue the JWS; `options.maxAge` overrides this token's lifetime.
127
+ * @deprecated Use `(await defineJWSSession(config).use(event)).update(update, options)`.
128
+ */
65
129
  export declare function updateJWSSession<T extends SessionRecord = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined, TEvent extends CompatEvent | H3Event = CompatEvent | H3Event>(event: TEvent, config: SessionConfigJWS<T, MaxAge, TEvent>, update?: SessionUpdate<T>, options?: SessionIssueOptions): Promise<SessionJWS<T, MaxAge> & {
66
130
  id: string;
67
131
  token: string;
68
132
  }>;
69
- /** Sign the session as a compact JWS without writing a cookie; fresh `jti` if no ID, no token source needed. */
133
+ /**
134
+ * Sign the session as a compact JWS without writing a cookie; fresh `jti` if no ID, no token source needed.
135
+ * @deprecated Use `defineJWSSession(config).issue(data)` to mint a token, or `(await defineJWSSession(config).use(event)).token` for the current one.
136
+ */
70
137
  export declare function signJWSSession<T extends SessionRecord = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined, TEvent extends CompatEvent | H3Event = CompatEvent | H3Event>(event: TEvent, config: SessionConfigJWS<T, MaxAge, TEvent>): Promise<string>;
71
- /** Verify a compact JWS into a session, checking `typ`, pinned `alg`, `jti`/`iat` and `exp` (required with `maxAge`). */
138
+ /**
139
+ * Verify a compact JWS into a session, checking `typ`, pinned `alg`, `jti`/`iat` and `exp` (required with `maxAge`).
140
+ * @deprecated Use `defineJWSSession(config).open(token)`.
141
+ */
72
142
  export declare function verifyJWSSession<T extends SessionRecord = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined, TEvent extends CompatEvent | H3Event = CompatEvent | H3Event>(event: TEvent, config: SessionConfigJWS<T, MaxAge, TEvent>, token: string): Promise<Partial<SessionJWS<T, MaxAge>>>;
73
- /** Drop the session cookie and leave an empty session for the rest of the request. */
143
+ /**
144
+ * Drop the session cookie and leave an empty session for the rest of the request.
145
+ * @deprecated Use `(await defineJWSSession(config).use(event)).clear()`.
146
+ */
74
147
  export declare function clearJWSSession<T extends SessionRecord = SessionClaims, MaxAge extends ExpiresIn | undefined = ExpiresIn | undefined, TEvent extends CompatEvent | H3Event = CompatEvent | H3Event>(event: TEvent, config: SessionConfigJWS<T, MaxAge, TEvent>): Promise<void>;
75
- export { type CompositeKey, type ContentEncryptionAlgorithm, type DeriveKeyOptions, type DeriveKeyReturn, type Duration, type ECDHEphemeralKeyInput, type ExpiresIn, type GenerateJWKOptions, type GenerateJWKReturn, type GenerateKeyAlgorithm, type GenerateKeyOptions, type GenerateKeyReturn, type GeneratedJWKMap, type GeneratedKeyMap, type ImportedKey, type ImportedKeyMap, type JOSEConsumerOptions, type JOSELimits, type JOSEPayload, type JOSEPayloadMode, type JOSEPayloadTypeMap, 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 JWELibraryHeaderName, type JWEMultiDecryptKey, type JWEMultiDecryptOptions, type JWEMultiDecryptResult, type JWEMultiEncryptOptions, type JWEMultiRecipient, type JWEProtectedHeader, type JWK, type JWKAlgorithm, type JWKCacheAdapter, type JWKLookupFunction, type JWKLookupFunctionHeader, type JWKMetadata, 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 JWTTimeClaimOptions, type JoseHeaderParameters, type KeyManagementAlgorithm, type MaxTokenAge, type NotBeforeIn, type PayloadOf, type SessionClaims, type SessionConfigJWE, type SessionConfigJWS, type SessionData, type SessionDecryptOptions, type SessionEncryptOptions, type SessionHooksJWE, type SessionHooksJWS, type SessionIssueOptions, type SessionJWE, type SessionJWS, type SessionManager, type SessionSignOptions, type SessionUpdate, type SessionUpdateTrigger, type SessionVerifyOptions, type UnwrapKeyOptions, type UnwrapKeyResult, type UnwrappingKeyFor, type WrapKeyOptions, type WrapKeyResult, type WrappingKeyFor, deriveJWKFromPassword, exportPEM, generateJWK, importPEM, thumbprint };
148
+ export { type CompatEvent, type CompositeKey, type ContentEncryptionAlgorithm, type DeriveJWKOptions, type DeriveJWKReturn, type DeriveKeyOptions, type DeriveKeyReturn, type Duration, type ECDHEphemeralKeyInput, type ExpiresIn, type GenerateJWKOptions, type GenerateJWKReturn, type GenerateKeyAlgorithm, type GenerateKeyOptions, type GenerateKeyReturn, type GeneratedJWKMap, type GeneratedKeyMap, type ImportedKey, type ImportedKeyMap, type ImportedPEMJWK, type JOSEConsumerOptions, type JOSELimits, type JOSEPayload, type JOSEPayloadMode, type JOSEPayloadTypeMap, type JWEAsymmetricPrivateJWK, type JWEAsymmetricPublicJWK, type JWEDecryptJWK, type JWEDecryptOptions, type JWEDecryptResult, type JWEEncryptJWK, type JWEEncryptOptions, type JWEFlattenedSerialization, type JWEGeneralRecipient, type JWEGeneralSerialization, type JWEHeaderParameters, type JWEKeyLookup, type JWEKeyManagementHeaderParameters, type JWELibraryHeaderName, type JWEMultiDecryptKey, type JWEMultiDecryptOptions, type JWEMultiDecryptResult, type JWEMultiEncryptOptions, type JWEMultiRecipient, type JWEProtectedHeader, type JWK, type JWKAlgorithm, type JWKCacheAdapter, type JWKLookupFunction, type JWKLookupFunctionHeader, type JWKMetadata, type JWKPEMAlgorithm, type JWKParameters, type JWKSet, type JWK_AES_Algorithm, 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 JWSHashedAlgorithm, type JWSHeaderParameters, type JWSKeyLookup, 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 JWTConfirmation, type JWTTimeClaimOptions, type JoseHeaderParameters, type KeyManagementAlgorithm, type KeyWrapAlgorithmOf, type KeyWrappingAlgorithm, type MaxTokenAge, type NotBeforeIn, type OpenedSessionState, type PEMType, type PayloadOf, type SessionClaims, type SessionConfigJWE, type SessionConfigJWS, type SessionData, type SessionDecryptOptions, type SessionDefinition, type SessionEncryptOptions, type SessionHooksJWE, type SessionHooksJWS, type SessionIssueOptions, type SessionJWE, type SessionJWS, type SessionManager, type SessionSignOptions, type SessionUpdate, type SessionUpdateTrigger, type SessionVerifyOptions, type ToPublicJWKReturn, type UnwrapKeyOptions, type UnwrapKeyResult, type UnwrappingKeyFor, type WrapKeyOptions, type WrapKeyResult, type WrappingKeyFor, deriveJWKFromPassword, exportPEM, generateJWK, importPEM, thumbprint, toPublicJWK };