@adonisjs/session 7.4.0 → 7.4.1

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 (27) hide show
  1. package/build/{chunk-S6P3TBEK.js → chunk-GB5FBZCV.js} +2 -2
  2. package/build/{chunk-A5YPZ5PH.js → chunk-OCQGCVXK.js} +2 -2
  3. package/build/{chunk-3R7KGADG.js → chunk-TZLOND27.js} +2 -2
  4. package/build/{chunk-MC7FIQFS.js → chunk-Y3BSCW5X.js} +5 -5
  5. package/build/{chunk-WBAYBMJJ.js → chunk-ZVSEMDIC.js} +1 -1
  6. package/build/{cookie-H7KRZB4T.js → cookie-WBWYVEDW.js} +2 -2
  7. package/build/factories/main.js +4 -4
  8. package/build/{file-YO7C2QWO.js → file-B6QKOZXW.js} +7 -3
  9. package/build/file-B6QKOZXW.js.map +1 -0
  10. package/build/index.js +3 -3
  11. package/build/providers/session_provider.js +3 -3
  12. package/build/{redis-KDWIBKUQ.js → redis-CAY24YIA.js} +2 -2
  13. package/build/src/client.js +2 -2
  14. package/build/src/plugins/edge.js +1 -1
  15. package/build/src/plugins/japa/api_client.js +2 -2
  16. package/build/src/plugins/japa/browser_client.js +2 -2
  17. package/build/src/session_middleware.js +3 -3
  18. package/build/src/stores/file.d.ts +5 -0
  19. package/package.json +12 -12
  20. package/build/file-YO7C2QWO.js.map +0 -1
  21. /package/build/{chunk-S6P3TBEK.js.map → chunk-GB5FBZCV.js.map} +0 -0
  22. /package/build/{chunk-A5YPZ5PH.js.map → chunk-OCQGCVXK.js.map} +0 -0
  23. /package/build/{chunk-3R7KGADG.js.map → chunk-TZLOND27.js.map} +0 -0
  24. /package/build/{chunk-MC7FIQFS.js.map → chunk-Y3BSCW5X.js.map} +0 -0
  25. /package/build/{chunk-WBAYBMJJ.js.map → chunk-ZVSEMDIC.js.map} +0 -0
  26. /package/build/{cookie-H7KRZB4T.js.map → cookie-WBWYVEDW.js.map} +0 -0
  27. /package/build/{redis-KDWIBKUQ.js.map → redis-CAY24YIA.js.map} +0 -0
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-TE5JP3SX.js";
4
4
  import {
5
5
  debug_default
6
- } from "./chunk-WBAYBMJJ.js";
6
+ } from "./chunk-ZVSEMDIC.js";
7
7
 
8
8
  // src/client.ts
9
9
  import { cuid } from "@adonisjs/core/helpers";
@@ -82,4 +82,4 @@ var SessionClient = class {
82
82
  export {
83
83
  SessionClient
84
84
  };
85
- //# sourceMappingURL=chunk-S6P3TBEK.js.map
85
+ //# sourceMappingURL=chunk-GB5FBZCV.js.map
@@ -5,7 +5,7 @@ import {
5
5
  import {
6
6
  __export,
7
7
  debug_default
8
- } from "./chunk-WBAYBMJJ.js";
8
+ } from "./chunk-ZVSEMDIC.js";
9
9
 
10
10
  // src/errors.ts
11
11
  var errors_exports = {};
@@ -391,4 +391,4 @@ export {
391
391
  errors_exports,
392
392
  Session
393
393
  };
394
- //# sourceMappingURL=chunk-A5YPZ5PH.js.map
394
+ //# sourceMappingURL=chunk-OCQGCVXK.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Session
3
- } from "./chunk-A5YPZ5PH.js";
3
+ } from "./chunk-OCQGCVXK.js";
4
4
 
5
5
  // src/session_middleware.ts
6
6
  import { ExceptionHandler } from "@adonisjs/core/http";
@@ -41,4 +41,4 @@ var SessionMiddleware = class {
41
41
  export {
42
42
  SessionMiddleware
43
43
  };
44
- //# sourceMappingURL=chunk-3R7KGADG.js.map
44
+ //# sourceMappingURL=chunk-TZLOND27.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  debug_default
3
- } from "./chunk-WBAYBMJJ.js";
3
+ } from "./chunk-ZVSEMDIC.js";
4
4
 
5
5
  // stubs/main.ts
6
6
  import { getDirname } from "@poppinss/utils";
@@ -100,7 +100,7 @@ function defineConfig(config) {
100
100
  var stores = {
101
101
  file: (config) => {
102
102
  return configProvider.create(async () => {
103
- const { FileStore } = await import("./file-YO7C2QWO.js");
103
+ const { FileStore } = await import("./file-B6QKOZXW.js");
104
104
  return (_, sessionConfig) => {
105
105
  return new FileStore(config, sessionConfig.age);
106
106
  };
@@ -108,7 +108,7 @@ var stores = {
108
108
  },
109
109
  redis: (config) => {
110
110
  return configProvider.create(async (app) => {
111
- const { RedisStore } = await import("./redis-KDWIBKUQ.js");
111
+ const { RedisStore } = await import("./redis-CAY24YIA.js");
112
112
  const redis = await app.container.make("redis");
113
113
  return (_, sessionConfig) => {
114
114
  return new RedisStore(redis.connection(config.connection), sessionConfig.age);
@@ -117,7 +117,7 @@ var stores = {
117
117
  },
118
118
  cookie: () => {
119
119
  return configProvider.create(async () => {
120
- const { CookieStore } = await import("./cookie-H7KRZB4T.js");
120
+ const { CookieStore } = await import("./cookie-WBWYVEDW.js");
121
121
  return (ctx, sessionConfig) => {
122
122
  return new CookieStore(sessionConfig.cookie, ctx);
123
123
  };
@@ -131,4 +131,4 @@ export {
131
131
  defineConfig,
132
132
  stores
133
133
  };
134
- //# sourceMappingURL=chunk-MC7FIQFS.js.map
134
+ //# sourceMappingURL=chunk-Y3BSCW5X.js.map
@@ -12,4 +12,4 @@ export {
12
12
  __export,
13
13
  debug_default
14
14
  };
15
- //# sourceMappingURL=chunk-WBAYBMJJ.js.map
15
+ //# sourceMappingURL=chunk-ZVSEMDIC.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  debug_default
3
- } from "./chunk-WBAYBMJJ.js";
3
+ } from "./chunk-ZVSEMDIC.js";
4
4
 
5
5
  // src/stores/cookie.ts
6
6
  var CookieStore = class {
@@ -53,4 +53,4 @@ var CookieStore = class {
53
53
  export {
54
54
  CookieStore
55
55
  };
56
- //# sourceMappingURL=cookie-H7KRZB4T.js.map
56
+ //# sourceMappingURL=cookie-WBWYVEDW.js.map
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  defineConfig
3
- } from "../chunk-MC7FIQFS.js";
3
+ } from "../chunk-Y3BSCW5X.js";
4
4
  import {
5
5
  SessionMiddleware
6
- } from "../chunk-3R7KGADG.js";
7
- import "../chunk-A5YPZ5PH.js";
6
+ } from "../chunk-TZLOND27.js";
7
+ import "../chunk-OCQGCVXK.js";
8
8
  import "../chunk-TE5JP3SX.js";
9
- import "../chunk-WBAYBMJJ.js";
9
+ import "../chunk-ZVSEMDIC.js";
10
10
 
11
11
  // factories/session_middleware_factory.ts
12
12
  import { Emitter } from "@adonisjs/core/events";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  debug_default
3
- } from "./chunk-WBAYBMJJ.js";
3
+ } from "./chunk-ZVSEMDIC.js";
4
4
 
5
5
  // src/stores/file.ts
6
6
  import { dirname, join } from "node:path";
@@ -10,6 +10,10 @@ import { access, mkdir, readFile, rm, writeFile, utimes, stat } from "node:fs/pr
10
10
  var FileStore = class {
11
11
  #config;
12
12
  #age;
13
+ /**
14
+ * @param {FileStoreConfig} config
15
+ * @param {string|number} The age must be in seconds or a time expression
16
+ */
13
17
  constructor(config, age) {
14
18
  this.#config = config;
15
19
  this.#age = age;
@@ -65,7 +69,7 @@ var FileStore = class {
65
69
  if (!stats) {
66
70
  return null;
67
71
  }
68
- const sessionWillExpireAt = stats.mtimeMs + string.milliseconds.parse(this.#age);
72
+ const sessionWillExpireAt = stats.mtimeMs + string.seconds.parse(this.#age) * 1e3;
69
73
  if (Date.now() > sessionWillExpireAt) {
70
74
  debug_default("file store: expired session data %s", sessionId);
71
75
  return null;
@@ -109,4 +113,4 @@ var FileStore = class {
109
113
  export {
110
114
  FileStore
111
115
  };
112
- //# sourceMappingURL=file-YO7C2QWO.js.map
116
+ //# sourceMappingURL=file-B6QKOZXW.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/stores/file.ts"],"sourcesContent":["/**\n * @adonisjs/session\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport type { Stats } from 'node:fs'\nimport { dirname, join } from 'node:path'\nimport string from '@poppinss/utils/string'\nimport { MessageBuilder } from '@adonisjs/core/helpers'\nimport { access, mkdir, readFile, rm, writeFile, utimes, stat } from 'node:fs/promises'\n\nimport debug from '../debug.js'\nimport type { FileStoreConfig, SessionData, SessionStoreContract } from '../types.js'\n\n/**\n * File store writes the session data on the file system as. Each session\n * id gets its own file.\n *\n */\nexport class FileStore implements SessionStoreContract {\n #config: FileStoreConfig\n #age: string | number\n\n /**\n * @param {FileStoreConfig} config\n * @param {string|number} The age must be in seconds or a time expression\n */\n constructor(config: FileStoreConfig, age: string | number) {\n this.#config = config\n this.#age = age\n debug('initiating file store %O', this.#config)\n }\n\n /**\n * Returns an absolute path to the session id file\n */\n #getFilePath(sessionId: string): string {\n return join(this.#config.location, `${sessionId}.txt`)\n }\n\n /**\n * Check if a file exists at a given path or not\n */\n async #pathExists(path: string) {\n try {\n await access(path)\n return true\n } catch {\n return false\n }\n }\n\n /**\n * Returns stats for a file and ignoring missing\n * files.\n */\n async #stats(path: string): Promise<Stats | null> {\n try {\n const stats = await stat(path)\n return stats\n } catch {\n return null\n }\n }\n\n /**\n * Output file with contents to the given path\n */\n async #outputFile(path: string, contents: string) {\n const pathDirname = dirname(path)\n\n const dirExists = await this.#pathExists(pathDirname)\n if (!dirExists) {\n await mkdir(pathDirname, { recursive: true })\n }\n\n await writeFile(path, contents, 'utf-8')\n }\n\n /**\n * Reads the session data from the disk.\n */\n async read(sessionId: string): Promise<SessionData | null> {\n const filePath = this.#getFilePath(sessionId)\n debug('file store: reading session data %', sessionId)\n\n /**\n * Return null when no session id file exists in first\n * place\n */\n const stats = await this.#stats(filePath)\n if (!stats) {\n return null\n }\n\n /**\n * Check if the file has been expired and return null (if expired)\n */\n const sessionWillExpireAt = stats.mtimeMs + string.seconds.parse(this.#age) * 1000\n if (Date.now() > sessionWillExpireAt) {\n debug('file store: expired session data %s', sessionId)\n return null\n }\n\n /**\n * Reading the file contents if the file exists\n */\n let contents = await readFile(filePath, 'utf-8')\n contents = contents.trim()\n if (!contents) {\n return null\n }\n\n /**\n * Verify contents with the session id and return them as an object. The verify\n * method can fail when the contents is not JSON>\n */\n try {\n return new MessageBuilder().verify<SessionData>(contents, sessionId)\n } catch {\n return null\n }\n }\n\n /**\n * Writes the session data to the disk as a string\n */\n async write(sessionId: string, values: SessionData): Promise<void> {\n debug('file store: writing session data %s: %O', sessionId, values)\n\n const filePath = this.#getFilePath(sessionId)\n const message = new MessageBuilder().build(values, undefined, sessionId)\n\n await this.#outputFile(filePath, message)\n }\n\n /**\n * Removes the session file from the disk\n */\n async destroy(sessionId: string): Promise<void> {\n debug('file store: destroying session data %s', sessionId)\n await rm(this.#getFilePath(sessionId), { force: true })\n }\n\n /**\n * Updates the session expiry by rewriting it to the\n * persistence store\n */\n async touch(sessionId: string): Promise<void> {\n debug('file store: touching session data %s', sessionId)\n await utimes(this.#getFilePath(sessionId), new Date(), new Date())\n }\n}\n"],"mappings":";;;;;AAUA,SAAS,SAAS,YAAY;AAC9B,OAAO,YAAY;AACnB,SAAS,sBAAsB;AAC/B,SAAS,QAAQ,OAAO,UAAU,IAAI,WAAW,QAAQ,YAAY;AAU9D,IAAM,YAAN,MAAgD;AAAA,EACrD;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,YAAY,QAAyB,KAAsB;AACzD,SAAK,UAAU;AACf,SAAK,OAAO;AACZ,kBAAM,4BAA4B,KAAK,OAAO;AAAA,EAChD;AAAA;AAAA;AAAA;AAAA,EAKA,aAAa,WAA2B;AACtC,WAAO,KAAK,KAAK,QAAQ,UAAU,GAAG,SAAS,MAAM;AAAA,EACvD;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,YAAY,MAAc;AAC9B,QAAI;AACF,YAAM,OAAO,IAAI;AACjB,aAAO;AAAA,IACT,QAAQ;AACN,aAAO;AAAA,IACT;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,OAAO,MAAqC;AAChD,QAAI;AACF,YAAM,QAAQ,MAAM,KAAK,IAAI;AAC7B,aAAO;AAAA,I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,KAAK,aAAa,SAAS,GAAG,EAAE,OAAO,KAAK,CAAC;AAAA,EACxD;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,MAAM,WAAkC;AAC5C,kBAAM,wCAAwC,SAAS;AACvD,UAAM,OAAO,KAAK,aAAa,SAAS,GAAG,oBAAI,KAAK,GAAG,oBAAI,KAAK,CAAC;AAAA,EACnE;AACF;","names":[]}
package/build/index.js CHANGED
@@ -3,16 +3,16 @@ import {
3
3
  defineConfig,
4
4
  stores,
5
5
  stubsRoot
6
- } from "./chunk-MC7FIQFS.js";
6
+ } from "./chunk-Y3BSCW5X.js";
7
7
  import {
8
8
  Session,
9
9
  errors_exports
10
- } from "./chunk-A5YPZ5PH.js";
10
+ } from "./chunk-OCQGCVXK.js";
11
11
  import {
12
12
  ReadOnlyValuesStore,
13
13
  ValuesStore
14
14
  } from "./chunk-TE5JP3SX.js";
15
- import "./chunk-WBAYBMJJ.js";
15
+ import "./chunk-ZVSEMDIC.js";
16
16
  export {
17
17
  ReadOnlyValuesStore,
18
18
  Session,
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  SessionMiddleware
3
- } from "../chunk-3R7KGADG.js";
4
- import "../chunk-A5YPZ5PH.js";
3
+ } from "../chunk-TZLOND27.js";
4
+ import "../chunk-OCQGCVXK.js";
5
5
  import "../chunk-TE5JP3SX.js";
6
- import "../chunk-WBAYBMJJ.js";
6
+ import "../chunk-ZVSEMDIC.js";
7
7
 
8
8
  // providers/session_provider.ts
9
9
  import { configProvider } from "@adonisjs/core";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  debug_default
3
- } from "./chunk-WBAYBMJJ.js";
3
+ } from "./chunk-ZVSEMDIC.js";
4
4
 
5
5
  // src/stores/redis.ts
6
6
  import string from "@poppinss/utils/string";
@@ -55,4 +55,4 @@ var RedisStore = class {
55
55
  export {
56
56
  RedisStore
57
57
  };
58
- //# sourceMappingURL=redis-KDWIBKUQ.js.map
58
+ //# sourceMappingURL=redis-CAY24YIA.js.map
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  SessionClient
3
- } from "../chunk-S6P3TBEK.js";
3
+ } from "../chunk-GB5FBZCV.js";
4
4
  import "../chunk-TE5JP3SX.js";
5
- import "../chunk-WBAYBMJJ.js";
5
+ import "../chunk-ZVSEMDIC.js";
6
6
  export {
7
7
  SessionClient
8
8
  };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  debug_default
3
- } from "../../chunk-WBAYBMJJ.js";
3
+ } from "../../chunk-ZVSEMDIC.js";
4
4
 
5
5
  // src/plugins/edge.ts
6
6
  var edgePluginSession = (edge) => {
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  SessionClient
3
- } from "../../../chunk-S6P3TBEK.js";
3
+ } from "../../../chunk-GB5FBZCV.js";
4
4
  import "../../../chunk-TE5JP3SX.js";
5
- import "../../../chunk-WBAYBMJJ.js";
5
+ import "../../../chunk-ZVSEMDIC.js";
6
6
 
7
7
  // src/plugins/japa/api_client.ts
8
8
  import lodash from "@poppinss/utils/lodash";
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  SessionClient
3
- } from "../../../chunk-S6P3TBEK.js";
3
+ } from "../../../chunk-GB5FBZCV.js";
4
4
  import "../../../chunk-TE5JP3SX.js";
5
- import "../../../chunk-WBAYBMJJ.js";
5
+ import "../../../chunk-ZVSEMDIC.js";
6
6
 
7
7
  // src/plugins/japa/browser_client.ts
8
8
  import { configProvider } from "@adonisjs/core";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  SessionMiddleware
3
- } from "../chunk-3R7KGADG.js";
4
- import "../chunk-A5YPZ5PH.js";
3
+ } from "../chunk-TZLOND27.js";
4
+ import "../chunk-OCQGCVXK.js";
5
5
  import "../chunk-TE5JP3SX.js";
6
- import "../chunk-WBAYBMJJ.js";
6
+ import "../chunk-ZVSEMDIC.js";
7
7
  export {
8
8
  SessionMiddleware as default
9
9
  };
@@ -10,9 +10,14 @@ import type { FileStoreConfig, SessionData, SessionStoreContract } from '../type
10
10
  /**
11
11
  * File store writes the session data on the file system as. Each session
12
12
  * id gets its own file.
13
+ *
13
14
  */
14
15
  export declare class FileStore implements SessionStoreContract {
15
16
  #private;
17
+ /**
18
+ * @param {FileStoreConfig} config
19
+ * @param {string|number} The age must be in seconds or a time expression
20
+ */
16
21
  constructor(config: FileStoreConfig, age: string | number);
17
22
  /**
18
23
  * Reads the session data from the disk.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@adonisjs/session",
3
3
  "description": "Session provider for AdonisJS",
4
- "version": "7.4.0",
4
+ "version": "7.4.1",
5
5
  "engines": {
6
6
  "node": ">=18.16.0"
7
7
  },
@@ -43,8 +43,8 @@
43
43
  "quick:test": "node --enable-source-maps --loader=ts-node/esm bin/test.ts"
44
44
  },
45
45
  "devDependencies": {
46
- "@adonisjs/assembler": "^7.4.0",
47
- "@adonisjs/core": "^6.6.0",
46
+ "@adonisjs/assembler": "^7.7.0",
47
+ "@adonisjs/core": "^6.9.1",
48
48
  "@adonisjs/eslint-config": "^1.3.0",
49
49
  "@adonisjs/i18n": "^2.1.0",
50
50
  "@adonisjs/prettier-config": "^1.3.0",
@@ -55,13 +55,13 @@
55
55
  "@japa/browser-client": "^2.0.3",
56
56
  "@japa/file-system": "^2.3.0",
57
57
  "@japa/plugin-adonisjs": "^3.0.1",
58
- "@japa/runner": "^3.1.2",
58
+ "@japa/runner": "^3.1.4",
59
59
  "@japa/snapshot": "^2.0.5",
60
- "@swc/core": "^1.4.14",
61
- "@types/node": "^20.12.7",
60
+ "@swc/core": "^1.5.25",
61
+ "@types/node": "^20.14.1",
62
62
  "@types/set-cookie-parser": "^2.4.7",
63
63
  "@types/supertest": "^6.0.2",
64
- "@vinejs/vine": "^2.0.0",
64
+ "@vinejs/vine": "^2.1.0",
65
65
  "c8": "^9.1.0",
66
66
  "copyfiles": "^2.4.1",
67
67
  "cross-env": "^7.0.3",
@@ -71,13 +71,13 @@
71
71
  "get-port": "^7.1.0",
72
72
  "github-label-sync": "^2.3.1",
73
73
  "husky": "^9.0.11",
74
- "np": "^10.0.3",
75
- "playwright": "^1.43.1",
76
- "prettier": "^3.2.5",
74
+ "np": "^10.0.5",
75
+ "playwright": "^1.44.1",
76
+ "prettier": "^3.3.0",
77
77
  "set-cookie-parser": "^2.6.0",
78
- "supertest": "^6.3.4",
78
+ "supertest": "^7.0.0",
79
79
  "ts-node": "^10.9.2",
80
- "tsup": "^8.0.2",
80
+ "tsup": "^8.1.0",
81
81
  "typescript": "^5.4.5"
82
82
  },
83
83
  "dependencies": {
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/stores/file.ts"],"sourcesContent":["/**\n * @adonisjs/session\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport type { Stats } from 'node:fs'\nimport { dirname, join } from 'node:path'\nimport string from '@poppinss/utils/string'\nimport { MessageBuilder } from '@adonisjs/core/helpers'\nimport { access, mkdir, readFile, rm, writeFile, utimes, stat } from 'node:fs/promises'\n\nimport debug from '../debug.js'\nimport type { FileStoreConfig, SessionData, SessionStoreContract } from '../types.js'\n\n/**\n * File store writes the session data on the file system as. Each session\n * id gets its own file.\n */\nexport class FileStore implements SessionStoreContract {\n #config: FileStoreConfig\n #age: string | number\n\n constructor(config: FileStoreConfig, age: string | number) {\n this.#config = config\n this.#age = age\n debug('initiating file store %O', this.#config)\n }\n\n /**\n * Returns an absolute path to the session id file\n */\n #getFilePath(sessionId: string): string {\n return join(this.#config.location, `${sessionId}.txt`)\n }\n\n /**\n * Check if a file exists at a given path or not\n */\n async #pathExists(path: string) {\n try {\n await access(path)\n return true\n } catch {\n return false\n }\n }\n\n /**\n * Returns stats for a file and ignoring missing\n * files.\n */\n async #stats(path: string): Promise<Stats | null> {\n try {\n const stats = await stat(path)\n return stats\n } catch {\n return null\n }\n }\n\n /**\n * Output file with contents to the given path\n */\n async #outputFile(path: string, contents: string) {\n const pathDirname = dirname(path)\n\n const dirExists = await this.#pathExists(pathDirname)\n if (!dirExists) {\n await mkdir(pathDirname, { recursive: true })\n }\n\n await writeFile(path, contents, 'utf-8')\n }\n\n /**\n * Reads the session data from the disk.\n */\n async read(sessionId: string): Promise<SessionData | null> {\n const filePath = this.#getFilePath(sessionId)\n debug('file store: reading session data %', sessionId)\n\n /**\n * Return null when no session id file exists in first\n * place\n */\n const stats = await this.#stats(filePath)\n if (!stats) {\n return null\n }\n\n /**\n * Check if the file has been expired and return null (if expired)\n */\n const sessionWillExpireAt = stats.mtimeMs + string.milliseconds.parse(this.#age)\n if (Date.now() > sessionWillExpireAt) {\n debug('file store: expired session data %s', sessionId)\n return null\n }\n\n /**\n * Reading the file contents if the file exists\n */\n let contents = await readFile(filePath, 'utf-8')\n contents = contents.trim()\n if (!contents) {\n return null\n }\n\n /**\n * Verify contents with the session id and return them as an object. The verify\n * method can fail when the contents is not JSON>\n */\n try {\n return new MessageBuilder().verify<SessionData>(contents, sessionId)\n } catch {\n return null\n }\n }\n\n /**\n * Writes the session data to the disk as a string\n */\n async write(sessionId: string, values: SessionData): Promise<void> {\n debug('file store: writing session data %s: %O', sessionId, values)\n\n const filePath = this.#getFilePath(sessionId)\n const message = new MessageBuilder().build(values, undefined, sessionId)\n\n await this.#outputFile(filePath, message)\n }\n\n /**\n * Removes the session file from the disk\n */\n async destroy(sessionId: string): Promise<void> {\n debug('file store: destroying session data %s', sessionId)\n await rm(this.#getFilePath(sessionId), { force: true })\n }\n\n /**\n * Updates the session expiry by rewriting it to the\n * persistence store\n */\n async touch(sessionId: string): Promise<void> {\n debug('file store: touching session data %s', sessionId)\n await utimes(this.#getFilePath(sessionId), new Date(), new Date())\n }\n}\n"],"mappings":";;;;;AAUA,SAAS,SAAS,YAAY;AAC9B,OAAO,YAAY;AACnB,SAAS,sBAAsB;AAC/B,SAAS,QAAQ,OAAO,UAAU,IAAI,WAAW,QAAQ,YAAY;AAS9D,IAAM,YAAN,MAAgD;AAAA,EACrD;AAAA,EACA;AAAA,E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