balda 0.0.64 → 0.0.65
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/lib/index.cjs +46 -46
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +142 -112
- package/lib/index.d.ts +142 -112
- package/lib/index.js +46 -46
- package/lib/index.js.map +1 -1
- package/package.json +3 -2
package/lib/index.d.cts
CHANGED
|
@@ -193,6 +193,118 @@ type FilePluginOptions = {
|
|
|
193
193
|
allowedMimeTypes?: (FileAllowedMimeType | (string & {}))[];
|
|
194
194
|
};
|
|
195
195
|
|
|
196
|
+
type SessionStore = {
|
|
197
|
+
get: (sid: string) => Promise<Record<string, any> | undefined>;
|
|
198
|
+
set: (sid: string, value: Record<string, any>, ttlSeconds?: number) => Promise<void>;
|
|
199
|
+
destroy: (sid: string) => Promise<void>;
|
|
200
|
+
};
|
|
201
|
+
type SessionOptions = {
|
|
202
|
+
/** Cookie name used for session id */
|
|
203
|
+
name?: string;
|
|
204
|
+
/**
|
|
205
|
+
* Secret for signing the session cookie (sets `signed: true` on the session cookie).
|
|
206
|
+
* Requires `cookie({ sign: true, secret })` with the same secret.
|
|
207
|
+
*/
|
|
208
|
+
secret?: string;
|
|
209
|
+
/** TTL seconds for session */
|
|
210
|
+
ttl?: number;
|
|
211
|
+
/** Custom store, default is in-memory */
|
|
212
|
+
store?: SessionStore;
|
|
213
|
+
/** Whether to set HttpOnly secure flags */
|
|
214
|
+
cookie?: {
|
|
215
|
+
path?: string;
|
|
216
|
+
httpOnly?: boolean;
|
|
217
|
+
secure?: boolean;
|
|
218
|
+
sameSite?: "Strict" | "Lax" | "None";
|
|
219
|
+
domain?: string;
|
|
220
|
+
};
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Cookie options for setting cookies
|
|
225
|
+
*/
|
|
226
|
+
type CookieOptions = {
|
|
227
|
+
/**
|
|
228
|
+
* Domain for the cookie.
|
|
229
|
+
* ⚠️ Must not contain CR, LF, semicolons, or other control chars.
|
|
230
|
+
*/
|
|
231
|
+
domain?: string;
|
|
232
|
+
/**
|
|
233
|
+
* Path for the cookie.
|
|
234
|
+
* ⚠️ Must not contain CR, LF, or semicolons.
|
|
235
|
+
*/
|
|
236
|
+
path?: string;
|
|
237
|
+
/**
|
|
238
|
+
* Expiration date for the cookie.
|
|
239
|
+
* ⚠️ Will throw if the Date is invalid (NaN getTime).
|
|
240
|
+
*/
|
|
241
|
+
expires?: Date;
|
|
242
|
+
/**
|
|
243
|
+
* Max age in seconds for the cookie. Must be a non-negative integer.
|
|
244
|
+
* Falsy values (including 0) are only skipped if undefined;
|
|
245
|
+
* pass maxAge: 0 to immediately expire.
|
|
246
|
+
*/
|
|
247
|
+
maxAge?: number;
|
|
248
|
+
/**
|
|
249
|
+
* Whether the cookie is secure (HTTPS only)
|
|
250
|
+
* @default true
|
|
251
|
+
*
|
|
252
|
+
* ⚠️ Must be `true` when `sameSite` is `"None"`.
|
|
253
|
+
*/
|
|
254
|
+
secure?: boolean;
|
|
255
|
+
/**
|
|
256
|
+
* Whether the cookie is HTTP only (prevents JavaScript access)
|
|
257
|
+
* @default true
|
|
258
|
+
*/
|
|
259
|
+
httpOnly?: boolean;
|
|
260
|
+
/**
|
|
261
|
+
* SameSite attribute for the cookie
|
|
262
|
+
*
|
|
263
|
+
* - "Strict": Most secure, cookie not sent on cross-site requests
|
|
264
|
+
* - "Lax": Balanced, cookie sent on top-level navigation
|
|
265
|
+
* - "None": Least secure, requires secure=true
|
|
266
|
+
*
|
|
267
|
+
* ⚠️ "None" requires `secure: true`; combination is rejected at runtime.
|
|
268
|
+
*/
|
|
269
|
+
sameSite?: "Strict" | "Lax" | "None";
|
|
270
|
+
/**
|
|
271
|
+
* Whether this individual cookie should be signed.
|
|
272
|
+
* The middleware must have `sign: true` and a `secret` set for this to work.
|
|
273
|
+
* Overrides the global `sign` option for this cookie only.
|
|
274
|
+
*/
|
|
275
|
+
signed?: boolean;
|
|
276
|
+
/**
|
|
277
|
+
* Priority for the cookie
|
|
278
|
+
*/
|
|
279
|
+
priority?: "Low" | "Medium" | "High";
|
|
280
|
+
};
|
|
281
|
+
/**
|
|
282
|
+
* Options for the cookie middleware
|
|
283
|
+
*/
|
|
284
|
+
type CookieMiddlewareOptions = {
|
|
285
|
+
/**
|
|
286
|
+
* Secret key(s) for signing cookies.
|
|
287
|
+
* - Provide a single string for static signing.
|
|
288
|
+
* - Provide an array for key rotation: signing uses `secret[0]`,
|
|
289
|
+
* verification accepts any entry in the array.
|
|
290
|
+
* Required when `sign` is enabled.
|
|
291
|
+
*/
|
|
292
|
+
secret?: string | string[];
|
|
293
|
+
/**
|
|
294
|
+
* Default options applied to all cookies set via `res.cookie()`.
|
|
295
|
+
*/
|
|
296
|
+
defaults?: CookieOptions;
|
|
297
|
+
/**
|
|
298
|
+
* Whether to enable cookie parsing (defaults to true)
|
|
299
|
+
*/
|
|
300
|
+
parse?: boolean;
|
|
301
|
+
/**
|
|
302
|
+
* Whether to enable cookie signing by default for all cookies (defaults to false).
|
|
303
|
+
* Individual cookies can override this via `CookieOptions.signed`.
|
|
304
|
+
*/
|
|
305
|
+
sign?: boolean;
|
|
306
|
+
};
|
|
307
|
+
|
|
196
308
|
/**
|
|
197
309
|
* The request object with type-safe path parameters.
|
|
198
310
|
* This is the main object that is passed to the handler function.
|
|
@@ -379,6 +491,36 @@ declare class Request<Params extends Record<string, string> = Record<string, str
|
|
|
379
491
|
* @timeout middleware is required
|
|
380
492
|
*/
|
|
381
493
|
timeout?: boolean;
|
|
494
|
+
/**
|
|
495
|
+
* Session dirty tracking - true if session was modified and needs to be saved.
|
|
496
|
+
* @internal
|
|
497
|
+
*/
|
|
498
|
+
_sessionDirty: boolean;
|
|
499
|
+
/**
|
|
500
|
+
* Session ID for the current request.
|
|
501
|
+
* @internal
|
|
502
|
+
*/
|
|
503
|
+
_sessionId?: string;
|
|
504
|
+
/**
|
|
505
|
+
* Session TTL in seconds.
|
|
506
|
+
* @internal
|
|
507
|
+
*/
|
|
508
|
+
_sessionTtl?: number;
|
|
509
|
+
/**
|
|
510
|
+
* Session store instance.
|
|
511
|
+
* @internal
|
|
512
|
+
*/
|
|
513
|
+
_sessionStore?: SessionStore;
|
|
514
|
+
/**
|
|
515
|
+
* Session cookie name.
|
|
516
|
+
* @internal
|
|
517
|
+
*/
|
|
518
|
+
_sessionCookieName?: string;
|
|
519
|
+
/**
|
|
520
|
+
* Session cookie defaults.
|
|
521
|
+
* @internal
|
|
522
|
+
*/
|
|
523
|
+
_sessionCookieDefaults?: CookieOptions;
|
|
382
524
|
get session(): Record<string, any> | undefined;
|
|
383
525
|
set session(value: Record<string, any> | undefined);
|
|
384
526
|
/**
|
|
@@ -1125,91 +1267,6 @@ type OpenIdConnectOptions = {
|
|
|
1125
1267
|
*/
|
|
1126
1268
|
declare const controller: (path?: string, swaggerOptions?: SwaggerRouteOptions) => (target: any) => void;
|
|
1127
1269
|
|
|
1128
|
-
/**
|
|
1129
|
-
* Cookie options for setting cookies
|
|
1130
|
-
*/
|
|
1131
|
-
type CookieOptions = {
|
|
1132
|
-
/**
|
|
1133
|
-
* Domain for the cookie.
|
|
1134
|
-
* ⚠️ Must not contain CR, LF, semicolons, or other control chars.
|
|
1135
|
-
*/
|
|
1136
|
-
domain?: string;
|
|
1137
|
-
/**
|
|
1138
|
-
* Path for the cookie.
|
|
1139
|
-
* ⚠️ Must not contain CR, LF, or semicolons.
|
|
1140
|
-
*/
|
|
1141
|
-
path?: string;
|
|
1142
|
-
/**
|
|
1143
|
-
* Expiration date for the cookie.
|
|
1144
|
-
* ⚠️ Will throw if the Date is invalid (NaN getTime).
|
|
1145
|
-
*/
|
|
1146
|
-
expires?: Date;
|
|
1147
|
-
/**
|
|
1148
|
-
* Max age in seconds for the cookie. Must be a non-negative integer.
|
|
1149
|
-
* Falsy values (including 0) are only skipped if undefined;
|
|
1150
|
-
* pass maxAge: 0 to immediately expire.
|
|
1151
|
-
*/
|
|
1152
|
-
maxAge?: number;
|
|
1153
|
-
/**
|
|
1154
|
-
* Whether the cookie is secure (HTTPS only)
|
|
1155
|
-
* @default true
|
|
1156
|
-
*
|
|
1157
|
-
* ⚠️ Must be `true` when `sameSite` is `"None"`.
|
|
1158
|
-
*/
|
|
1159
|
-
secure?: boolean;
|
|
1160
|
-
/**
|
|
1161
|
-
* Whether the cookie is HTTP only (prevents JavaScript access)
|
|
1162
|
-
* @default true
|
|
1163
|
-
*/
|
|
1164
|
-
httpOnly?: boolean;
|
|
1165
|
-
/**
|
|
1166
|
-
* SameSite attribute for the cookie
|
|
1167
|
-
*
|
|
1168
|
-
* - "Strict": Most secure, cookie not sent on cross-site requests
|
|
1169
|
-
* - "Lax": Balanced, cookie sent on top-level navigation
|
|
1170
|
-
* - "None": Least secure, requires secure=true
|
|
1171
|
-
*
|
|
1172
|
-
* ⚠️ "None" requires `secure: true`; combination is rejected at runtime.
|
|
1173
|
-
*/
|
|
1174
|
-
sameSite?: "Strict" | "Lax" | "None";
|
|
1175
|
-
/**
|
|
1176
|
-
* Whether this individual cookie should be signed.
|
|
1177
|
-
* The middleware must have `sign: true` and a `secret` set for this to work.
|
|
1178
|
-
* Overrides the global `sign` option for this cookie only.
|
|
1179
|
-
*/
|
|
1180
|
-
signed?: boolean;
|
|
1181
|
-
/**
|
|
1182
|
-
* Priority for the cookie
|
|
1183
|
-
*/
|
|
1184
|
-
priority?: "Low" | "Medium" | "High";
|
|
1185
|
-
};
|
|
1186
|
-
/**
|
|
1187
|
-
* Options for the cookie middleware
|
|
1188
|
-
*/
|
|
1189
|
-
type CookieMiddlewareOptions = {
|
|
1190
|
-
/**
|
|
1191
|
-
* Secret key(s) for signing cookies.
|
|
1192
|
-
* - Provide a single string for static signing.
|
|
1193
|
-
* - Provide an array for key rotation: signing uses `secret[0]`,
|
|
1194
|
-
* verification accepts any entry in the array.
|
|
1195
|
-
* Required when `sign` is enabled.
|
|
1196
|
-
*/
|
|
1197
|
-
secret?: string | string[];
|
|
1198
|
-
/**
|
|
1199
|
-
* Default options applied to all cookies set via `res.cookie()`.
|
|
1200
|
-
*/
|
|
1201
|
-
defaults?: CookieOptions;
|
|
1202
|
-
/**
|
|
1203
|
-
* Whether to enable cookie parsing (defaults to true)
|
|
1204
|
-
*/
|
|
1205
|
-
parse?: boolean;
|
|
1206
|
-
/**
|
|
1207
|
-
* Whether to enable cookie signing by default for all cookies (defaults to false).
|
|
1208
|
-
* Individual cookies can override this via `CookieOptions.signed`.
|
|
1209
|
-
*/
|
|
1210
|
-
sign?: boolean;
|
|
1211
|
-
};
|
|
1212
|
-
|
|
1213
1270
|
/**
|
|
1214
1271
|
* The response object with per-status-code type-safe response bodies.
|
|
1215
1272
|
* When response schemas are provided (e.g. via the `responses` route option), each shorthand
|
|
@@ -2635,33 +2692,6 @@ type StorageOptions$1 = MemoryStorageStrategy | CustomStorageStrategy;
|
|
|
2635
2692
|
*/
|
|
2636
2693
|
type RateLimiterKeyOptions = IpRateLimiterOptions | CustomRateLimiterOptions;
|
|
2637
2694
|
|
|
2638
|
-
type SessionStore = {
|
|
2639
|
-
get: (sid: string) => Promise<Record<string, any> | undefined>;
|
|
2640
|
-
set: (sid: string, value: Record<string, any>, ttlSeconds?: number) => Promise<void>;
|
|
2641
|
-
destroy: (sid: string) => Promise<void>;
|
|
2642
|
-
};
|
|
2643
|
-
type SessionOptions = {
|
|
2644
|
-
/** Cookie name used for session id */
|
|
2645
|
-
name?: string;
|
|
2646
|
-
/**
|
|
2647
|
-
* Secret for signing the session cookie (sets `signed: true` on the session cookie).
|
|
2648
|
-
* Requires `cookie({ sign: true, secret })` with the same secret.
|
|
2649
|
-
*/
|
|
2650
|
-
secret?: string;
|
|
2651
|
-
/** TTL seconds for session */
|
|
2652
|
-
ttl?: number;
|
|
2653
|
-
/** Custom store, default is in-memory */
|
|
2654
|
-
store?: SessionStore;
|
|
2655
|
-
/** Whether to set HttpOnly secure flags */
|
|
2656
|
-
cookie?: {
|
|
2657
|
-
path?: string;
|
|
2658
|
-
httpOnly?: boolean;
|
|
2659
|
-
secure?: boolean;
|
|
2660
|
-
sameSite?: "Strict" | "Lax" | "None";
|
|
2661
|
-
domain?: string;
|
|
2662
|
-
};
|
|
2663
|
-
};
|
|
2664
|
-
|
|
2665
2695
|
/**
|
|
2666
2696
|
* Swagger plugin that serves the swagger UI and JSON specification, by default the UI will be available at /docs and the JSON specification at /docs/json
|
|
2667
2697
|
* @warning The json specification is always available at /${globalOptions.path}/json
|
package/lib/index.d.ts
CHANGED
|
@@ -193,6 +193,118 @@ type FilePluginOptions = {
|
|
|
193
193
|
allowedMimeTypes?: (FileAllowedMimeType | (string & {}))[];
|
|
194
194
|
};
|
|
195
195
|
|
|
196
|
+
type SessionStore = {
|
|
197
|
+
get: (sid: string) => Promise<Record<string, any> | undefined>;
|
|
198
|
+
set: (sid: string, value: Record<string, any>, ttlSeconds?: number) => Promise<void>;
|
|
199
|
+
destroy: (sid: string) => Promise<void>;
|
|
200
|
+
};
|
|
201
|
+
type SessionOptions = {
|
|
202
|
+
/** Cookie name used for session id */
|
|
203
|
+
name?: string;
|
|
204
|
+
/**
|
|
205
|
+
* Secret for signing the session cookie (sets `signed: true` on the session cookie).
|
|
206
|
+
* Requires `cookie({ sign: true, secret })` with the same secret.
|
|
207
|
+
*/
|
|
208
|
+
secret?: string;
|
|
209
|
+
/** TTL seconds for session */
|
|
210
|
+
ttl?: number;
|
|
211
|
+
/** Custom store, default is in-memory */
|
|
212
|
+
store?: SessionStore;
|
|
213
|
+
/** Whether to set HttpOnly secure flags */
|
|
214
|
+
cookie?: {
|
|
215
|
+
path?: string;
|
|
216
|
+
httpOnly?: boolean;
|
|
217
|
+
secure?: boolean;
|
|
218
|
+
sameSite?: "Strict" | "Lax" | "None";
|
|
219
|
+
domain?: string;
|
|
220
|
+
};
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Cookie options for setting cookies
|
|
225
|
+
*/
|
|
226
|
+
type CookieOptions = {
|
|
227
|
+
/**
|
|
228
|
+
* Domain for the cookie.
|
|
229
|
+
* ⚠️ Must not contain CR, LF, semicolons, or other control chars.
|
|
230
|
+
*/
|
|
231
|
+
domain?: string;
|
|
232
|
+
/**
|
|
233
|
+
* Path for the cookie.
|
|
234
|
+
* ⚠️ Must not contain CR, LF, or semicolons.
|
|
235
|
+
*/
|
|
236
|
+
path?: string;
|
|
237
|
+
/**
|
|
238
|
+
* Expiration date for the cookie.
|
|
239
|
+
* ⚠️ Will throw if the Date is invalid (NaN getTime).
|
|
240
|
+
*/
|
|
241
|
+
expires?: Date;
|
|
242
|
+
/**
|
|
243
|
+
* Max age in seconds for the cookie. Must be a non-negative integer.
|
|
244
|
+
* Falsy values (including 0) are only skipped if undefined;
|
|
245
|
+
* pass maxAge: 0 to immediately expire.
|
|
246
|
+
*/
|
|
247
|
+
maxAge?: number;
|
|
248
|
+
/**
|
|
249
|
+
* Whether the cookie is secure (HTTPS only)
|
|
250
|
+
* @default true
|
|
251
|
+
*
|
|
252
|
+
* ⚠️ Must be `true` when `sameSite` is `"None"`.
|
|
253
|
+
*/
|
|
254
|
+
secure?: boolean;
|
|
255
|
+
/**
|
|
256
|
+
* Whether the cookie is HTTP only (prevents JavaScript access)
|
|
257
|
+
* @default true
|
|
258
|
+
*/
|
|
259
|
+
httpOnly?: boolean;
|
|
260
|
+
/**
|
|
261
|
+
* SameSite attribute for the cookie
|
|
262
|
+
*
|
|
263
|
+
* - "Strict": Most secure, cookie not sent on cross-site requests
|
|
264
|
+
* - "Lax": Balanced, cookie sent on top-level navigation
|
|
265
|
+
* - "None": Least secure, requires secure=true
|
|
266
|
+
*
|
|
267
|
+
* ⚠️ "None" requires `secure: true`; combination is rejected at runtime.
|
|
268
|
+
*/
|
|
269
|
+
sameSite?: "Strict" | "Lax" | "None";
|
|
270
|
+
/**
|
|
271
|
+
* Whether this individual cookie should be signed.
|
|
272
|
+
* The middleware must have `sign: true` and a `secret` set for this to work.
|
|
273
|
+
* Overrides the global `sign` option for this cookie only.
|
|
274
|
+
*/
|
|
275
|
+
signed?: boolean;
|
|
276
|
+
/**
|
|
277
|
+
* Priority for the cookie
|
|
278
|
+
*/
|
|
279
|
+
priority?: "Low" | "Medium" | "High";
|
|
280
|
+
};
|
|
281
|
+
/**
|
|
282
|
+
* Options for the cookie middleware
|
|
283
|
+
*/
|
|
284
|
+
type CookieMiddlewareOptions = {
|
|
285
|
+
/**
|
|
286
|
+
* Secret key(s) for signing cookies.
|
|
287
|
+
* - Provide a single string for static signing.
|
|
288
|
+
* - Provide an array for key rotation: signing uses `secret[0]`,
|
|
289
|
+
* verification accepts any entry in the array.
|
|
290
|
+
* Required when `sign` is enabled.
|
|
291
|
+
*/
|
|
292
|
+
secret?: string | string[];
|
|
293
|
+
/**
|
|
294
|
+
* Default options applied to all cookies set via `res.cookie()`.
|
|
295
|
+
*/
|
|
296
|
+
defaults?: CookieOptions;
|
|
297
|
+
/**
|
|
298
|
+
* Whether to enable cookie parsing (defaults to true)
|
|
299
|
+
*/
|
|
300
|
+
parse?: boolean;
|
|
301
|
+
/**
|
|
302
|
+
* Whether to enable cookie signing by default for all cookies (defaults to false).
|
|
303
|
+
* Individual cookies can override this via `CookieOptions.signed`.
|
|
304
|
+
*/
|
|
305
|
+
sign?: boolean;
|
|
306
|
+
};
|
|
307
|
+
|
|
196
308
|
/**
|
|
197
309
|
* The request object with type-safe path parameters.
|
|
198
310
|
* This is the main object that is passed to the handler function.
|
|
@@ -379,6 +491,36 @@ declare class Request<Params extends Record<string, string> = Record<string, str
|
|
|
379
491
|
* @timeout middleware is required
|
|
380
492
|
*/
|
|
381
493
|
timeout?: boolean;
|
|
494
|
+
/**
|
|
495
|
+
* Session dirty tracking - true if session was modified and needs to be saved.
|
|
496
|
+
* @internal
|
|
497
|
+
*/
|
|
498
|
+
_sessionDirty: boolean;
|
|
499
|
+
/**
|
|
500
|
+
* Session ID for the current request.
|
|
501
|
+
* @internal
|
|
502
|
+
*/
|
|
503
|
+
_sessionId?: string;
|
|
504
|
+
/**
|
|
505
|
+
* Session TTL in seconds.
|
|
506
|
+
* @internal
|
|
507
|
+
*/
|
|
508
|
+
_sessionTtl?: number;
|
|
509
|
+
/**
|
|
510
|
+
* Session store instance.
|
|
511
|
+
* @internal
|
|
512
|
+
*/
|
|
513
|
+
_sessionStore?: SessionStore;
|
|
514
|
+
/**
|
|
515
|
+
* Session cookie name.
|
|
516
|
+
* @internal
|
|
517
|
+
*/
|
|
518
|
+
_sessionCookieName?: string;
|
|
519
|
+
/**
|
|
520
|
+
* Session cookie defaults.
|
|
521
|
+
* @internal
|
|
522
|
+
*/
|
|
523
|
+
_sessionCookieDefaults?: CookieOptions;
|
|
382
524
|
get session(): Record<string, any> | undefined;
|
|
383
525
|
set session(value: Record<string, any> | undefined);
|
|
384
526
|
/**
|
|
@@ -1125,91 +1267,6 @@ type OpenIdConnectOptions = {
|
|
|
1125
1267
|
*/
|
|
1126
1268
|
declare const controller: (path?: string, swaggerOptions?: SwaggerRouteOptions) => (target: any) => void;
|
|
1127
1269
|
|
|
1128
|
-
/**
|
|
1129
|
-
* Cookie options for setting cookies
|
|
1130
|
-
*/
|
|
1131
|
-
type CookieOptions = {
|
|
1132
|
-
/**
|
|
1133
|
-
* Domain for the cookie.
|
|
1134
|
-
* ⚠️ Must not contain CR, LF, semicolons, or other control chars.
|
|
1135
|
-
*/
|
|
1136
|
-
domain?: string;
|
|
1137
|
-
/**
|
|
1138
|
-
* Path for the cookie.
|
|
1139
|
-
* ⚠️ Must not contain CR, LF, or semicolons.
|
|
1140
|
-
*/
|
|
1141
|
-
path?: string;
|
|
1142
|
-
/**
|
|
1143
|
-
* Expiration date for the cookie.
|
|
1144
|
-
* ⚠️ Will throw if the Date is invalid (NaN getTime).
|
|
1145
|
-
*/
|
|
1146
|
-
expires?: Date;
|
|
1147
|
-
/**
|
|
1148
|
-
* Max age in seconds for the cookie. Must be a non-negative integer.
|
|
1149
|
-
* Falsy values (including 0) are only skipped if undefined;
|
|
1150
|
-
* pass maxAge: 0 to immediately expire.
|
|
1151
|
-
*/
|
|
1152
|
-
maxAge?: number;
|
|
1153
|
-
/**
|
|
1154
|
-
* Whether the cookie is secure (HTTPS only)
|
|
1155
|
-
* @default true
|
|
1156
|
-
*
|
|
1157
|
-
* ⚠️ Must be `true` when `sameSite` is `"None"`.
|
|
1158
|
-
*/
|
|
1159
|
-
secure?: boolean;
|
|
1160
|
-
/**
|
|
1161
|
-
* Whether the cookie is HTTP only (prevents JavaScript access)
|
|
1162
|
-
* @default true
|
|
1163
|
-
*/
|
|
1164
|
-
httpOnly?: boolean;
|
|
1165
|
-
/**
|
|
1166
|
-
* SameSite attribute for the cookie
|
|
1167
|
-
*
|
|
1168
|
-
* - "Strict": Most secure, cookie not sent on cross-site requests
|
|
1169
|
-
* - "Lax": Balanced, cookie sent on top-level navigation
|
|
1170
|
-
* - "None": Least secure, requires secure=true
|
|
1171
|
-
*
|
|
1172
|
-
* ⚠️ "None" requires `secure: true`; combination is rejected at runtime.
|
|
1173
|
-
*/
|
|
1174
|
-
sameSite?: "Strict" | "Lax" | "None";
|
|
1175
|
-
/**
|
|
1176
|
-
* Whether this individual cookie should be signed.
|
|
1177
|
-
* The middleware must have `sign: true` and a `secret` set for this to work.
|
|
1178
|
-
* Overrides the global `sign` option for this cookie only.
|
|
1179
|
-
*/
|
|
1180
|
-
signed?: boolean;
|
|
1181
|
-
/**
|
|
1182
|
-
* Priority for the cookie
|
|
1183
|
-
*/
|
|
1184
|
-
priority?: "Low" | "Medium" | "High";
|
|
1185
|
-
};
|
|
1186
|
-
/**
|
|
1187
|
-
* Options for the cookie middleware
|
|
1188
|
-
*/
|
|
1189
|
-
type CookieMiddlewareOptions = {
|
|
1190
|
-
/**
|
|
1191
|
-
* Secret key(s) for signing cookies.
|
|
1192
|
-
* - Provide a single string for static signing.
|
|
1193
|
-
* - Provide an array for key rotation: signing uses `secret[0]`,
|
|
1194
|
-
* verification accepts any entry in the array.
|
|
1195
|
-
* Required when `sign` is enabled.
|
|
1196
|
-
*/
|
|
1197
|
-
secret?: string | string[];
|
|
1198
|
-
/**
|
|
1199
|
-
* Default options applied to all cookies set via `res.cookie()`.
|
|
1200
|
-
*/
|
|
1201
|
-
defaults?: CookieOptions;
|
|
1202
|
-
/**
|
|
1203
|
-
* Whether to enable cookie parsing (defaults to true)
|
|
1204
|
-
*/
|
|
1205
|
-
parse?: boolean;
|
|
1206
|
-
/**
|
|
1207
|
-
* Whether to enable cookie signing by default for all cookies (defaults to false).
|
|
1208
|
-
* Individual cookies can override this via `CookieOptions.signed`.
|
|
1209
|
-
*/
|
|
1210
|
-
sign?: boolean;
|
|
1211
|
-
};
|
|
1212
|
-
|
|
1213
1270
|
/**
|
|
1214
1271
|
* The response object with per-status-code type-safe response bodies.
|
|
1215
1272
|
* When response schemas are provided (e.g. via the `responses` route option), each shorthand
|
|
@@ -2635,33 +2692,6 @@ type StorageOptions$1 = MemoryStorageStrategy | CustomStorageStrategy;
|
|
|
2635
2692
|
*/
|
|
2636
2693
|
type RateLimiterKeyOptions = IpRateLimiterOptions | CustomRateLimiterOptions;
|
|
2637
2694
|
|
|
2638
|
-
type SessionStore = {
|
|
2639
|
-
get: (sid: string) => Promise<Record<string, any> | undefined>;
|
|
2640
|
-
set: (sid: string, value: Record<string, any>, ttlSeconds?: number) => Promise<void>;
|
|
2641
|
-
destroy: (sid: string) => Promise<void>;
|
|
2642
|
-
};
|
|
2643
|
-
type SessionOptions = {
|
|
2644
|
-
/** Cookie name used for session id */
|
|
2645
|
-
name?: string;
|
|
2646
|
-
/**
|
|
2647
|
-
* Secret for signing the session cookie (sets `signed: true` on the session cookie).
|
|
2648
|
-
* Requires `cookie({ sign: true, secret })` with the same secret.
|
|
2649
|
-
*/
|
|
2650
|
-
secret?: string;
|
|
2651
|
-
/** TTL seconds for session */
|
|
2652
|
-
ttl?: number;
|
|
2653
|
-
/** Custom store, default is in-memory */
|
|
2654
|
-
store?: SessionStore;
|
|
2655
|
-
/** Whether to set HttpOnly secure flags */
|
|
2656
|
-
cookie?: {
|
|
2657
|
-
path?: string;
|
|
2658
|
-
httpOnly?: boolean;
|
|
2659
|
-
secure?: boolean;
|
|
2660
|
-
sameSite?: "Strict" | "Lax" | "None";
|
|
2661
|
-
domain?: string;
|
|
2662
|
-
};
|
|
2663
|
-
};
|
|
2664
|
-
|
|
2665
2695
|
/**
|
|
2666
2696
|
* Swagger plugin that serves the swagger UI and JSON specification, by default the UI will be available at /docs and the JSON specification at /docs/json
|
|
2667
2697
|
* @warning The json specification is always available at /${globalOptions.path}/json
|