@faasjs/http 0.0.2-beta.99 → 0.0.3-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs ADDED
@@ -0,0 +1,578 @@
1
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
+ }) : x)(function(x) {
4
+ if (typeof require !== "undefined")
5
+ return require.apply(this, arguments);
6
+ throw new Error('Dynamic require of "' + x + '" is not supported');
7
+ });
8
+
9
+ // src/index.ts
10
+ import {
11
+ usePlugin
12
+ } from "@faasjs/func";
13
+
14
+ // ../deep_merge/src/index.ts
15
+ var shouldMerge = function(item) {
16
+ const type = Object.prototype.toString.call(item);
17
+ return type === "[object Object]" || type === "[object Array]";
18
+ };
19
+ function deepMerge(...sources) {
20
+ let acc = /* @__PURE__ */ Object.create(null);
21
+ for (const source of sources)
22
+ if (source instanceof Array) {
23
+ if (!(acc instanceof Array))
24
+ acc = [];
25
+ acc = [...new Set(source.concat(...acc))];
26
+ } else if (shouldMerge(source))
27
+ for (const [key, value] of Object.entries(source)) {
28
+ let val;
29
+ if (shouldMerge(value))
30
+ val = deepMerge(acc[key], value);
31
+ else
32
+ val = value;
33
+ acc = {
34
+ ...acc,
35
+ [key]: val
36
+ };
37
+ }
38
+ return acc;
39
+ }
40
+
41
+ // src/index.ts
42
+ import { Logger } from "@faasjs/logger";
43
+
44
+ // src/session.ts
45
+ import {
46
+ randomBytes,
47
+ pbkdf2Sync,
48
+ createCipheriv,
49
+ createHmac,
50
+ createDecipheriv
51
+ } from "crypto";
52
+ var Session = class {
53
+ constructor(cookie, config) {
54
+ this.cookie = cookie;
55
+ this.config = Object.assign({
56
+ key: "key",
57
+ secret: randomBytes(128).toString("hex"),
58
+ salt: "salt",
59
+ signedSalt: "signedSalt",
60
+ keylen: 64,
61
+ iterations: 100,
62
+ digest: "sha256",
63
+ cipherName: "aes-256-cbc"
64
+ }, config);
65
+ this.secret = pbkdf2Sync(
66
+ this.config.secret,
67
+ this.config.salt,
68
+ this.config.iterations,
69
+ this.config.keylen / 2,
70
+ this.config.digest
71
+ );
72
+ this.signedSecret = pbkdf2Sync(
73
+ this.config.secret,
74
+ this.config.signedSalt,
75
+ this.config.iterations,
76
+ this.config.keylen,
77
+ this.config.digest
78
+ );
79
+ this.content = /* @__PURE__ */ Object.create(null);
80
+ }
81
+ invoke(cookie) {
82
+ try {
83
+ this.content = cookie ? this.decode(cookie) : /* @__PURE__ */ Object.create(null);
84
+ } catch (error) {
85
+ console.error(error);
86
+ this.content = /* @__PURE__ */ Object.create(null);
87
+ }
88
+ this.changed = false;
89
+ }
90
+ encode(text) {
91
+ if (typeof text !== "string")
92
+ text = JSON.stringify(text);
93
+ const iv = randomBytes(16);
94
+ const cipher = createCipheriv(this.config.cipherName, this.secret, iv);
95
+ const encrypted = Buffer.concat([cipher.update(text), cipher.final()]).toString("base64");
96
+ const main = Buffer.from([encrypted, iv.toString("base64")].join("--")).toString("base64");
97
+ const hmac = createHmac(this.config.digest, this.signedSecret);
98
+ hmac.update(main);
99
+ const digest = hmac.digest("hex");
100
+ return main + "--" + digest;
101
+ }
102
+ decode(text) {
103
+ text = decodeURIComponent(text);
104
+ const signedParts = text.split("--");
105
+ const hmac = createHmac(this.config.digest, this.signedSecret);
106
+ hmac.update(signedParts[0]);
107
+ const digest = hmac.digest("hex");
108
+ if (signedParts[1] !== digest)
109
+ throw Error("Not valid");
110
+ const message = Buffer.from(signedParts[0], "base64").toString();
111
+ const parts = message.split("--").map(function(part2) {
112
+ return Buffer.from(part2, "base64");
113
+ });
114
+ const cipher = createDecipheriv(this.config.cipherName, this.secret, parts[1]);
115
+ const part = Buffer.from(cipher.update(parts[0])).toString("utf8");
116
+ const final = cipher.final("utf8");
117
+ const decrypt = [part, final].join("");
118
+ return JSON.parse(decrypt);
119
+ }
120
+ read(key) {
121
+ return this.content[key];
122
+ }
123
+ write(key, value) {
124
+ if (value === null || typeof value === "undefined")
125
+ delete this.content[key];
126
+ else
127
+ this.content[key] = value;
128
+ this.changed = true;
129
+ return this;
130
+ }
131
+ update() {
132
+ if (this.changed)
133
+ this.cookie.write(this.config.key, this.encode(JSON.stringify(this.content)));
134
+ return this;
135
+ }
136
+ };
137
+
138
+ // src/cookie.ts
139
+ var Cookie = class {
140
+ constructor(config) {
141
+ this.config = deepMerge({
142
+ path: "/",
143
+ expires: 31536e3,
144
+ secure: true,
145
+ httpOnly: true,
146
+ session: {}
147
+ }, config);
148
+ this.session = new Session(this, this.config.session);
149
+ this.content = /* @__PURE__ */ Object.create(null);
150
+ this.setCookie = /* @__PURE__ */ Object.create(null);
151
+ }
152
+ invoke(cookie) {
153
+ this.content = /* @__PURE__ */ Object.create(null);
154
+ if (cookie)
155
+ cookie.split(";").forEach((x) => {
156
+ x = x.trim();
157
+ const k = /([^=]+)/.exec(x);
158
+ if (k !== null)
159
+ this.content[k[0]] = decodeURIComponent(x.replace(`${k[0]}=`, "").replace(/;$/, ""));
160
+ });
161
+ this.setCookie = /* @__PURE__ */ Object.create(null);
162
+ this.session.invoke(this.read(this.session.config.key));
163
+ return this;
164
+ }
165
+ read(key) {
166
+ return this.content[key];
167
+ }
168
+ write(key, value, opts) {
169
+ opts = Object.assign(this.config, opts || {});
170
+ let cookie;
171
+ if (value === null || typeof value === "undefined") {
172
+ opts.expires = "Thu, 01 Jan 1970 00:00:01 GMT";
173
+ cookie = `${key}=;`;
174
+ delete this.content[key];
175
+ } else {
176
+ cookie = `${key}=${encodeURIComponent(value)};`;
177
+ this.content[key] = value;
178
+ }
179
+ if (typeof opts.expires === "number")
180
+ cookie += `max-age=${opts.expires};`;
181
+ else if (typeof opts.expires === "string")
182
+ cookie += `expires=${opts.expires};`;
183
+ cookie += `path=${opts.path || "/"};`;
184
+ if (opts.domain)
185
+ cookie += `domain=${opts.domain};`;
186
+ if (opts.secure)
187
+ cookie += "Secure;";
188
+ if (opts.httpOnly)
189
+ cookie += "HttpOnly;";
190
+ if (opts.sameSite)
191
+ cookie += `SameSite=${opts.sameSite};`;
192
+ this.setCookie[key] = cookie;
193
+ return this;
194
+ }
195
+ headers() {
196
+ if (Object.keys(this.setCookie).length === 0)
197
+ return {};
198
+ else
199
+ return { "Set-Cookie": Object.values(this.setCookie) };
200
+ }
201
+ };
202
+
203
+ // src/validator.ts
204
+ var Validator = class {
205
+ constructor(config) {
206
+ this.paramsConfig = config.params;
207
+ this.cookieConfig = config.cookie;
208
+ this.sessionConfig = config.session;
209
+ this.before = config.before;
210
+ }
211
+ async valid(request, logger) {
212
+ if (this.before) {
213
+ const result = await this.before(request);
214
+ if (result)
215
+ throw new HttpError(result);
216
+ }
217
+ this.request = request;
218
+ if (this.paramsConfig && request.params) {
219
+ logger.debug("Valid Params");
220
+ this.validContent("params", request.params, "", this.paramsConfig, logger);
221
+ }
222
+ if (this.cookieConfig && request.cookie) {
223
+ logger.debug("Valid Cookie");
224
+ if (request.cookie == null)
225
+ throw Error("Not found Cookie");
226
+ this.validContent(
227
+ "cookie",
228
+ request.cookie.content,
229
+ "",
230
+ this.cookieConfig,
231
+ logger
232
+ );
233
+ }
234
+ if (this.sessionConfig && request.session) {
235
+ logger.debug("Valid Session");
236
+ if (request.session == null)
237
+ throw Error("Not found Session");
238
+ this.validContent(
239
+ "session",
240
+ request.session.content,
241
+ "",
242
+ this.sessionConfig,
243
+ logger
244
+ );
245
+ }
246
+ }
247
+ validContent(type, params, baseKey, config, logger) {
248
+ if (config.whitelist) {
249
+ const paramsKeys = Object.keys(params);
250
+ const rulesKeys = Object.keys(config.rules);
251
+ const diff = paramsKeys.filter((k) => !rulesKeys.includes(k));
252
+ if (diff.length > 0) {
253
+ if (config.whitelist === "error") {
254
+ const diffKeys = diff.map((k) => `${baseKey}${k}`);
255
+ const error = Error(
256
+ `[${type}] Not permitted keys: ${diffKeys.join(", ")}`
257
+ );
258
+ if (config.onError) {
259
+ const res = config.onError(`${type}.whitelist`, baseKey, diffKeys);
260
+ if (res)
261
+ throw new HttpError(res);
262
+ }
263
+ throw error;
264
+ } else if (config.whitelist === "ignore")
265
+ for (const key of diff)
266
+ delete params[key];
267
+ }
268
+ }
269
+ for (const key in config.rules) {
270
+ const rule = config.rules[key];
271
+ if (!rule)
272
+ continue;
273
+ let value = params[key];
274
+ if (rule.default) {
275
+ if (type === "cookie" || type === "session")
276
+ logger.warn("Cookie and Session not support default rule.");
277
+ else if (typeof value === "undefined" && rule.default) {
278
+ value = typeof rule.default === "function" ? rule.default(this.request) : rule.default;
279
+ params[key] = value;
280
+ }
281
+ }
282
+ if (rule.required) {
283
+ if (typeof value === "undefined" || value === null) {
284
+ const error = Error(`[${type}] ${baseKey}${key} is required.`);
285
+ if (config.onError) {
286
+ const res = config.onError(
287
+ `${type}.rule.required`,
288
+ `${baseKey}${key}`,
289
+ value
290
+ );
291
+ if (res)
292
+ throw new HttpError(res);
293
+ }
294
+ throw error;
295
+ }
296
+ }
297
+ if (typeof value !== "undefined" && value !== null) {
298
+ if (rule.type)
299
+ if (type === "cookie")
300
+ logger.warn("Cookie not support type rule");
301
+ else {
302
+ let typed = true;
303
+ switch (rule.type) {
304
+ case "array":
305
+ typed = Array.isArray(value);
306
+ break;
307
+ case "object":
308
+ typed = Object.prototype.toString.call(value) === "[object Object]";
309
+ break;
310
+ default:
311
+ typed = typeof value === rule.type;
312
+ break;
313
+ }
314
+ if (!typed) {
315
+ const error = Error(
316
+ `[${type}] ${baseKey}${key} must be a ${rule.type}.`
317
+ );
318
+ if (config.onError) {
319
+ const res = config.onError(
320
+ `${type}.rule.type`,
321
+ `${baseKey}${key}`,
322
+ value
323
+ );
324
+ if (res)
325
+ throw new HttpError(res);
326
+ }
327
+ throw error;
328
+ }
329
+ }
330
+ if (rule.regexp && (rule.type === "string" || !rule.type) && !rule.regexp.test(value)) {
331
+ const error = Error(
332
+ `[${type}] ${baseKey}${key} must match ${rule.regexp}.`
333
+ );
334
+ if (config.onError) {
335
+ const res = config.onError(
336
+ `${type}.rule.regexp`,
337
+ `${baseKey}${key}`,
338
+ value
339
+ );
340
+ if (res)
341
+ throw new HttpError(res);
342
+ }
343
+ throw error;
344
+ }
345
+ if (rule.in && !rule.in.includes(value)) {
346
+ const error = Error(
347
+ `[${type}] ${baseKey}${key} must be in ${rule.in.join(", ")}.`
348
+ );
349
+ if (config.onError) {
350
+ const res = config.onError(
351
+ `${type}.rule.in`,
352
+ `${baseKey}${key}`,
353
+ value
354
+ );
355
+ if (res)
356
+ throw new HttpError(res);
357
+ }
358
+ throw error;
359
+ }
360
+ if (rule.config) {
361
+ if (type === "cookie")
362
+ logger.warn("Cookie not support nest rule.");
363
+ else if (Array.isArray(value))
364
+ for (const val of value)
365
+ this.validContent(
366
+ type,
367
+ val,
368
+ baseKey ? `${baseKey}.${key}.` : `${key}.`,
369
+ rule.config,
370
+ logger
371
+ );
372
+ else if (typeof value === "object")
373
+ this.validContent(
374
+ type,
375
+ value,
376
+ baseKey ? `${baseKey}.${key}.` : `${key}.`,
377
+ rule.config,
378
+ logger
379
+ );
380
+ }
381
+ }
382
+ }
383
+ }
384
+ };
385
+
386
+ // src/index.ts
387
+ import {
388
+ gzipSync,
389
+ deflateSync,
390
+ brotliCompressSync
391
+ } from "zlib";
392
+ var ContentType = {
393
+ plain: "text/plain",
394
+ html: "text/html",
395
+ xml: "application/xml",
396
+ csv: "text/csv",
397
+ css: "text/css",
398
+ javascript: "application/javascript",
399
+ json: "application/json",
400
+ jsonp: "application/javascript"
401
+ };
402
+ var HttpError = class extends Error {
403
+ constructor({
404
+ statusCode,
405
+ message
406
+ }) {
407
+ super(message);
408
+ if (Error.captureStackTrace)
409
+ Error.captureStackTrace(this, HttpError);
410
+ this.statusCode = statusCode || 500;
411
+ this.message = message;
412
+ }
413
+ };
414
+ var Name = "http";
415
+ var Http = class {
416
+ constructor(config) {
417
+ this.type = Name;
418
+ this.name = Name;
419
+ this.name = (config == null ? void 0 : config.name) || this.type;
420
+ this.config = (config == null ? void 0 : config.config) || /* @__PURE__ */ Object.create(null);
421
+ if (config == null ? void 0 : config.validator)
422
+ this.validatorOptions = config.validator;
423
+ this.headers = /* @__PURE__ */ Object.create(null);
424
+ this.cookie = new Cookie(this.config.cookie || {});
425
+ this.session = this.cookie.session;
426
+ }
427
+ async onDeploy(data, next) {
428
+ var _a;
429
+ data.dependencies["@faasjs/http"] = "*";
430
+ await next();
431
+ const logger = new Logger(this.name);
432
+ logger.debug("Generate api gateway's config");
433
+ logger.debug("%j", data);
434
+ const config = data.config.plugins ? deepMerge(data.config.plugins[this.name || this.type], { config: this.config }) : { config: this.config };
435
+ if (!config.config.path) {
436
+ config.config.path = "/" + ((_a = data.name) == null ? void 0 : _a.replace(/_/g, "/").replace(/\/index$/, ""));
437
+ if (config.config.path === "/index")
438
+ config.config.path = "/";
439
+ if (config.config.ignorePathPrefix) {
440
+ config.config.path = config.config.path.replace(new RegExp("^" + config.config.ignorePathPrefix), "");
441
+ if (config.config.path === "")
442
+ config.config.path = "/";
443
+ }
444
+ }
445
+ logger.debug("Api gateway's config: %j", config);
446
+ const Provider = __require(config.provider.type).Provider;
447
+ const provider = new Provider(config.provider.config);
448
+ await provider.deploy(this.type, data, config);
449
+ }
450
+ async onMount(data, next) {
451
+ data.logger.debug("[onMount] merge config");
452
+ if (data.config.plugins && data.config.plugins[this.name || this.type])
453
+ this.config = deepMerge(this.config, data.config.plugins[this.name || this.type].config);
454
+ data.logger.debug("[onMount] prepare cookie & session");
455
+ this.cookie = new Cookie(this.config.cookie || {});
456
+ this.session = this.cookie.session;
457
+ if (this.validatorOptions) {
458
+ data.logger.debug("[onMount] prepare validator");
459
+ this.validator = new Validator(this.validatorOptions);
460
+ }
461
+ await next();
462
+ }
463
+ async onInvoke(data, next) {
464
+ var _a, _b;
465
+ this.headers = data.event.headers || /* @__PURE__ */ Object.create(null);
466
+ this.body = data.event.body;
467
+ this.params = data.event.queryString || /* @__PURE__ */ Object.create(null);
468
+ this.response = { headers: /* @__PURE__ */ Object.create(null) };
469
+ if (data.event.body) {
470
+ if ((_a = this.headers["content-type"]) == null ? void 0 : _a.includes("application/json")) {
471
+ data.logger.debug("[onInvoke] Parse params from json body");
472
+ this.params = Object.assign(this.params, JSON.parse(data.event.body));
473
+ } else {
474
+ data.logger.debug("[onInvoke] Parse params from raw body");
475
+ this.params = data.event.body || /* @__PURE__ */ Object.create(null);
476
+ }
477
+ data.logger.debug("[onInvoke] Params: %j", this.params);
478
+ }
479
+ this.cookie.invoke(this.headers.cookie);
480
+ if (this.headers.cookie) {
481
+ data.logger.debug("[onInvoke] Cookie: %j", this.cookie.content);
482
+ data.logger.debug("[onInvoke] Session: %j", this.session.content);
483
+ }
484
+ try {
485
+ if (this.validator) {
486
+ data.logger.debug("[onInvoke] Valid request");
487
+ await this.validator.valid({
488
+ headers: this.headers,
489
+ params: this.params,
490
+ cookie: this.cookie,
491
+ session: this.session
492
+ }, data.logger);
493
+ }
494
+ await next();
495
+ } catch (error) {
496
+ data.response = error;
497
+ }
498
+ this.session.update();
499
+ if (data.response)
500
+ if (data.response instanceof Error || ((_b = data.response.constructor) == null ? void 0 : _b.name) === "Error") {
501
+ data.logger.error(data.response);
502
+ this.response.body = JSON.stringify({ error: { message: data.response.message } });
503
+ try {
504
+ this.response.statusCode = data.response.statusCode || 500;
505
+ } catch (error) {
506
+ this.response.statusCode = 500;
507
+ }
508
+ } else if (Object.prototype.toString.call(data.response) === "[object Object]" && data.response.statusCode && data.response.headers)
509
+ this.response = data.response;
510
+ else
511
+ this.response.body = JSON.stringify({ data: data.response });
512
+ if (!this.response.statusCode)
513
+ this.response.statusCode = this.response.body ? 200 : 201;
514
+ this.response.headers = Object.assign({
515
+ "Content-Type": "application/json; charset=utf-8",
516
+ "Cache-Control": "no-cache, no-store"
517
+ }, this.cookie.headers(), this.response.headers);
518
+ data.response = Object.assign({}, data.response, this.response);
519
+ const originBody = data.response.body;
520
+ data.response.originBody = originBody;
521
+ if (originBody && !data.response.isBase64Encoded && typeof originBody !== "string")
522
+ data.response.body = JSON.stringify(originBody);
523
+ if (!data.response.body || data.response.isBase64Encoded || typeof data.response.body !== "string" || data.response.body.length < 1024)
524
+ return;
525
+ const acceptEncoding = this.headers["accept-encoding"] || this.headers["Accept-Encoding"];
526
+ if (!acceptEncoding || !/(br|gzip|deflate)/.test(acceptEncoding))
527
+ return;
528
+ try {
529
+ if (acceptEncoding.includes("br")) {
530
+ data.response.headers["Content-Encoding"] = "br";
531
+ data.response.body = brotliCompressSync(originBody).toString("base64");
532
+ } else if (acceptEncoding.includes("gzip")) {
533
+ data.response.headers["Content-Encoding"] = "gzip";
534
+ data.response.body = gzipSync(originBody).toString("base64");
535
+ } else if (acceptEncoding.includes("deflate")) {
536
+ data.response.headers["Content-Encoding"] = "deflate";
537
+ data.response.body = deflateSync(originBody).toString("base64");
538
+ } else
539
+ throw Error("No matched compression.");
540
+ data.response.isBase64Encoded = true;
541
+ } catch (error) {
542
+ console.error(error);
543
+ data.response.body = originBody;
544
+ delete data.response.headers["Content-Encoding"];
545
+ }
546
+ }
547
+ setHeader(key, value) {
548
+ this.response.headers[key] = value;
549
+ return this;
550
+ }
551
+ setContentType(type, charset = "utf-8") {
552
+ if (ContentType[type])
553
+ this.setHeader("Content-Type", `${ContentType[type]}; charset=${charset}`);
554
+ else
555
+ this.setHeader("Content-Type", `${type}; charset=${charset}`);
556
+ return this;
557
+ }
558
+ setStatusCode(code) {
559
+ this.response.statusCode = code;
560
+ return this;
561
+ }
562
+ setBody(body) {
563
+ this.response.body = body;
564
+ return this;
565
+ }
566
+ };
567
+ function useHttp(config) {
568
+ return usePlugin(new Http(config));
569
+ }
570
+ export {
571
+ ContentType,
572
+ Cookie,
573
+ Http,
574
+ HttpError,
575
+ Session,
576
+ Validator,
577
+ useHttp
578
+ };
package/package.json CHANGED
@@ -1,24 +1,33 @@
1
1
  {
2
2
  "name": "@faasjs/http",
3
- "version": "0.0.2-beta.99",
3
+ "version": "0.0.3-beta.2",
4
4
  "license": "MIT",
5
- "main": "lib/index.js",
6
- "module": "lib/index.es.js",
7
- "types": "lib/index.d.ts",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "module": "dist/index.cjs",
8
+ "homepage": "https://faasjs.com/docs/http",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/faasjs/faasjs.git",
12
+ "directory": "packages/http"
13
+ },
14
+ "bugs": {
15
+ "url": "https://github.com/faasjs/faasjs/issues"
16
+ },
17
+ "funding": "https://github.com/sponsors/faasjs",
8
18
  "scripts": {
9
- "prepack": "rm -rf ./lib && rollup -c && mv lib/*/src/* lib/"
19
+ "build": "tsup-node src/index.ts --format esm,cjs",
20
+ "build:types": "tsup-node src/index.ts --dts-only"
10
21
  },
11
22
  "files": [
12
- "lib"
23
+ "dist"
13
24
  ],
14
- "devDependencies": {
15
- "@faasjs/func": "^0.0.2-beta.99",
16
- "@types/debug": "*",
17
- "@types/jest": "*",
18
- "@types/node": "*",
19
- "rollup": "*",
20
- "rollup-plugin-typescript2": "*",
21
- "typescript": "*"
25
+ "dependencies": {
26
+ "@faasjs/func": "^0.0.3-beta.2",
27
+ "@faasjs/logger": "^0.0.3-beta.2"
22
28
  },
23
- "gitHead": "8c2bc1591c90b91123b6295845f43e09fac3e53b"
29
+ "engines": {
30
+ "npm": ">=8.0.0",
31
+ "node": ">=16.0.0"
32
+ }
24
33
  }
package/lib/cookie.d.ts DELETED
@@ -1,41 +0,0 @@
1
- import { Session, SessionOptions } from './session';
2
- export interface CookieOptions {
3
- domain?: string;
4
- path?: string;
5
- expires?: number;
6
- secure?: boolean;
7
- httpOnly?: boolean;
8
- sameSite?: 'Strict' | 'Lax' | 'None';
9
- session?: SessionOptions;
10
- [key: string]: any;
11
- }
12
- export declare class Cookie<C, S> {
13
- session: Session<S, C>;
14
- content: C;
15
- readonly config: {
16
- domain?: string;
17
- path: string;
18
- expires: number;
19
- secure: boolean;
20
- httpOnly: boolean;
21
- sameSite?: 'Strict' | 'Lax' | 'None';
22
- session: SessionOptions;
23
- };
24
- private setCookie;
25
- constructor(config: CookieOptions);
26
- invoke(cookie: string | undefined): this;
27
- read(key: string): any;
28
- write(key: string, value: any, opts?: {
29
- domain?: string;
30
- path?: string;
31
- expires?: number | string;
32
- secure?: boolean;
33
- httpOnly?: boolean;
34
- sameSite?: 'Strict' | 'Lax' | 'None';
35
- }): this;
36
- headers(): {
37
- 'Set-Cookie'?: undefined;
38
- } | {
39
- 'Set-Cookie': string[];
40
- };
41
- }