@adonisjs/session 7.0.0-9 → 7.1.0

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 (76) hide show
  1. package/build/chunk-2X5L327N.js +28 -0
  2. package/build/chunk-2X5L327N.js.map +1 -0
  3. package/build/chunk-73JRAAAW.js +402 -0
  4. package/build/chunk-73JRAAAW.js.map +1 -0
  5. package/build/chunk-7YIO32ZH.js +134 -0
  6. package/build/chunk-7YIO32ZH.js.map +1 -0
  7. package/build/chunk-S6P3TBEK.js +85 -0
  8. package/build/chunk-S6P3TBEK.js.map +1 -0
  9. package/build/chunk-TE5JP3SX.js +151 -0
  10. package/build/chunk-TE5JP3SX.js.map +1 -0
  11. package/build/chunk-WBAYBMJJ.js +15 -0
  12. package/build/chunk-WBAYBMJJ.js.map +1 -0
  13. package/build/config/session.stub +51 -0
  14. package/build/cookie-H7KRZB4T.js +56 -0
  15. package/build/cookie-H7KRZB4T.js.map +1 -0
  16. package/build/factories/main.d.ts +1 -0
  17. package/build/factories/main.js +50 -0
  18. package/build/factories/main.js.map +1 -0
  19. package/build/factories/session_middleware_factory.d.ts +27 -0
  20. package/build/file-YO7C2QWO.js +112 -0
  21. package/build/file-YO7C2QWO.js.map +1 -0
  22. package/build/index.d.ts +1 -3
  23. package/build/index.js +18 -14
  24. package/build/index.js.map +1 -0
  25. package/build/providers/session_provider.d.ts +22 -5
  26. package/build/providers/session_provider.js +51 -59
  27. package/build/providers/session_provider.js.map +1 -0
  28. package/build/redis-KDWIBKUQ.js +58 -0
  29. package/build/redis-KDWIBKUQ.js.map +1 -0
  30. package/build/src/client.d.ts +24 -19
  31. package/build/src/client.js +9 -81
  32. package/build/src/client.js.map +1 -0
  33. package/build/src/debug.d.ts +1 -1
  34. package/build/src/define_config.d.ts +24 -3
  35. package/build/src/{edge_plugin_adonisjs_session.d.ts → plugins/edge.d.ts} +1 -1
  36. package/build/src/plugins/edge.js +102 -0
  37. package/build/src/plugins/edge.js.map +1 -0
  38. package/build/src/plugins/japa/api_client.d.ts +75 -0
  39. package/build/src/plugins/japa/api_client.js +100 -0
  40. package/build/src/plugins/japa/api_client.js.map +1 -0
  41. package/build/src/plugins/japa/browser_client.d.ts +36 -0
  42. package/build/src/plugins/japa/browser_client.js +88 -0
  43. package/build/src/plugins/japa/browser_client.js.map +1 -0
  44. package/build/src/session.d.ts +21 -12
  45. package/build/src/session_middleware.d.ts +7 -4
  46. package/build/src/session_middleware.js +10 -59
  47. package/build/src/session_middleware.js.map +1 -0
  48. package/build/src/{drivers → stores}/cookie.d.ts +4 -4
  49. package/build/src/{drivers → stores}/file.d.ts +4 -4
  50. package/build/src/{drivers → stores}/memory.d.ts +3 -3
  51. package/build/src/{drivers → stores}/redis.d.ts +5 -5
  52. package/build/src/{types/main.d.ts → types.d.ts} +11 -31
  53. package/build/src/types.js +1 -0
  54. package/build/src/types.js.map +1 -0
  55. package/build/src/{store.d.ts → values_store.d.ts} +10 -10
  56. package/package.json +75 -44
  57. package/build/configure.js +0 -45
  58. package/build/src/debug.js +0 -10
  59. package/build/src/define_config.js +0 -42
  60. package/build/src/drivers/cookie.js +0 -60
  61. package/build/src/drivers/file.js +0 -133
  62. package/build/src/drivers/memory.js +0 -33
  63. package/build/src/drivers/redis.js +0 -70
  64. package/build/src/drivers_collection.d.ts +0 -22
  65. package/build/src/drivers_collection.js +0 -38
  66. package/build/src/edge_plugin_adonisjs_session.js +0 -92
  67. package/build/src/errors.js +0 -17
  68. package/build/src/helpers.d.ts +0 -6
  69. package/build/src/helpers.js +0 -43
  70. package/build/src/session.js +0 -384
  71. package/build/src/store.js +0 -159
  72. package/build/src/types/extended.d.ts +0 -19
  73. package/build/src/types/extended.js +0 -9
  74. package/build/src/types/main.js +0 -9
  75. package/build/stubs/config.stub +0 -49
  76. package/build/stubs/main.js +0 -10
package/package.json CHANGED
@@ -1,26 +1,26 @@
1
1
  {
2
2
  "name": "@adonisjs/session",
3
3
  "description": "Session provider for AdonisJS",
4
- "version": "7.0.0-9",
4
+ "version": "7.1.0",
5
5
  "engines": {
6
6
  "node": ">=18.16.0"
7
7
  },
8
8
  "main": "build/index.js",
9
9
  "type": "module",
10
10
  "files": [
11
- "build/src",
12
- "build/stubs",
13
- "build/providers",
14
- "build/configure.d.ts",
15
- "build/configure.js",
16
- "build/index.d.ts",
17
- "build/index.js"
11
+ "build",
12
+ "!build/bin",
13
+ "!build/tests",
14
+ "!build/tests_helpers"
18
15
  ],
19
16
  "exports": {
20
17
  ".": "./build/index.js",
21
18
  "./factories": "./build/factories/main.js",
22
19
  "./session_provider": "./build/providers/session_provider.js",
23
20
  "./session_middleware": "./build/src/session_middleware.js",
21
+ "./plugins/edge": "./build/src/plugins/edge.js",
22
+ "./plugins/api_client": "./build/src/plugins/japa/api_client.js",
23
+ "./plugins/browser_client": "./build/src/plugins/japa/browser_client.js",
24
24
  "./client": "./build/src/client.js",
25
25
  "./types": "./build/src/types.js"
26
26
  },
@@ -29,9 +29,11 @@
29
29
  "test": "cross-env NODE_DEBUG=adonisjs:session c8 npm run quick:test",
30
30
  "clean": "del-cli build",
31
31
  "typecheck": "tsc --noEmit",
32
- "copy:templates": "copyfiles \"stubs/**/*.stub\" build",
33
- "compile": "npm run lint && npm run clean && tsc",
34
- "build": "npm run compile && npm run copy:templates",
32
+ "copy:templates": "copyfiles \"stubs/**/*.stub\" --up=\"1\" build",
33
+ "precompile": "npm run lint && npm run clean",
34
+ "compile": "tsup-node && tsc --emitDeclarationOnly --declaration",
35
+ "postcompile": "npm run copy:templates",
36
+ "build": "npm run compile",
35
37
  "prepublishOnly": "npm run build",
36
38
  "lint": "eslint . --ext=.ts",
37
39
  "format": "prettier --write .",
@@ -41,47 +43,51 @@
41
43
  "quick:test": "node --enable-source-maps --loader=ts-node/esm bin/test.ts"
42
44
  },
43
45
  "devDependencies": {
44
- "@adonisjs/assembler": "^6.1.3-18",
45
- "@adonisjs/core": "^6.1.5-24",
46
- "@adonisjs/eslint-config": "^1.1.8",
47
- "@adonisjs/prettier-config": "^1.1.8",
48
- "@adonisjs/redis": "^8.0.0-10",
49
- "@adonisjs/tsconfig": "^1.1.8",
50
- "@japa/api-client": "^2.0.0-0",
51
- "@japa/assert": "^2.0.0-1",
52
- "@japa/browser-client": "^2.0.0-3",
53
- "@japa/file-system": "^2.0.0-1",
54
- "@japa/plugin-adonisjs": "^2.0.0-1",
55
- "@japa/runner": "^3.0.0-6",
56
- "@japa/snapshot": "^2.0.0-1",
57
- "@swc/core": "^1.3.78",
58
- "@types/node": "^20.5.1",
59
- "@types/set-cookie-parser": "^2.4.3",
60
- "@types/supertest": "^2.0.12",
61
- "@vinejs/vine": "^1.6.0",
62
- "c8": "^8.0.0",
46
+ "@adonisjs/assembler": "^7.1.0",
47
+ "@adonisjs/core": "^6.2.1",
48
+ "@adonisjs/eslint-config": "^1.2.1",
49
+ "@adonisjs/prettier-config": "^1.2.1",
50
+ "@adonisjs/redis": "^8.0.0",
51
+ "@adonisjs/tsconfig": "^1.2.1",
52
+ "@japa/api-client": "^2.0.2",
53
+ "@japa/assert": "^2.1.0",
54
+ "@japa/browser-client": "^2.0.2",
55
+ "@japa/file-system": "^2.2.0",
56
+ "@japa/plugin-adonisjs": "^3.0.0",
57
+ "@japa/runner": "^3.1.1",
58
+ "@japa/snapshot": "^2.0.4",
59
+ "@swc/core": "^1.3.105",
60
+ "@types/node": "^20.11.5",
61
+ "@types/set-cookie-parser": "^2.4.7",
62
+ "@types/supertest": "^6.0.2",
63
+ "@vinejs/vine": "^1.7.0",
64
+ "c8": "^9.1.0",
63
65
  "copyfiles": "^2.4.1",
64
66
  "cross-env": "^7.0.3",
65
67
  "del-cli": "^5.0.0",
66
- "edge.js": "^6.0.0-8",
67
- "eslint": "^8.47.0",
68
+ "edge.js": "^6.0.1",
69
+ "eslint": "^8.56.0",
70
+ "get-port": "^7.0.0",
68
71
  "github-label-sync": "^2.3.1",
69
72
  "husky": "^8.0.3",
70
- "np": "^8.0.4",
71
- "playwright": "^1.37.1",
72
- "prettier": "^3.0.2",
73
+ "np": "^9.2.0",
74
+ "playwright": "^1.41.1",
75
+ "prettier": "^3.2.4",
73
76
  "set-cookie-parser": "^2.6.0",
74
- "supertest": "^6.3.3",
75
- "ts-node": "^10.9.1",
76
- "typescript": "^5.1.6"
77
+ "supertest": "^6.3.4",
78
+ "ts-node": "^10.9.2",
79
+ "tsup": "^8.0.1",
80
+ "typescript": "^5.3.3"
77
81
  },
78
82
  "dependencies": {
79
- "@poppinss/utils": "^6.5.0-5"
83
+ "@poppinss/utils": "^6.7.1"
80
84
  },
81
85
  "peerDependencies": {
82
- "@adonisjs/core": "^6.1.5-22",
83
- "@adonisjs/redis": "^8.0.0-10",
84
- "edge.js": "^6.0.0-8"
86
+ "@adonisjs/core": "^6.2.0",
87
+ "@adonisjs/redis": "^8.0.0",
88
+ "@japa/api-client": "^2.0.2",
89
+ "@japa/browser-client": "^2.0.2",
90
+ "edge.js": "^6.0.1"
85
91
  },
86
92
  "peerDependenciesMeta": {
87
93
  "@adonisjs/redis": {
@@ -89,6 +95,12 @@
89
95
  },
90
96
  "edge.js": {
91
97
  "optional": true
98
+ },
99
+ "@japa/api-client": {
100
+ "optional": true
101
+ },
102
+ "@japa/browser-client": {
103
+ "optional": true
92
104
  }
93
105
  },
94
106
  "author": "virk,adonisjs",
@@ -116,11 +128,11 @@
116
128
  },
117
129
  "publishConfig": {
118
130
  "access": "public",
119
- "tag": "next"
131
+ "tag": "latest"
120
132
  },
121
133
  "np": {
122
134
  "message": "chore(release): %s",
123
- "tag": "next",
135
+ "tag": "latest",
124
136
  "branch": "main",
125
137
  "anyBranch": false
126
138
  },
@@ -135,5 +147,24 @@
135
147
  "factories/**",
136
148
  "bin/**"
137
149
  ]
150
+ },
151
+ "tsup": {
152
+ "entry": [
153
+ "./index.ts",
154
+ "./factories/main.ts",
155
+ "./providers/session_provider.ts",
156
+ "./src/session_middleware.ts",
157
+ "./src/types.ts",
158
+ "./src/plugins/edge.ts",
159
+ "./src/plugins/japa/api_client.ts",
160
+ "./src/plugins/japa/browser_client.ts",
161
+ "./src/client.ts"
162
+ ],
163
+ "outDir": "./build",
164
+ "clean": true,
165
+ "format": "esm",
166
+ "dts": false,
167
+ "sourcemap": true,
168
+ "target": "esnext"
138
169
  }
139
170
  }
@@ -1,45 +0,0 @@
1
- /*
2
- * @adonisjs/session
3
- *
4
- * (c) AdonisJS
5
- *
6
- * For the full copyright and license information, please view the LICENSE
7
- * file that was distributed with this source code.
8
- */
9
- /**
10
- * Configures the package
11
- */
12
- export async function configure(command) {
13
- /**
14
- * Publish config file
15
- */
16
- await command.publishStub('config.stub');
17
- const codemods = await command.createCodemods();
18
- /**
19
- * Define environment variables
20
- */
21
- await codemods.defineEnvVariables({ SESSION_DRIVER: 'cookie' });
22
- /**
23
- * Define environment variables validations
24
- */
25
- await codemods.defineEnvValidations({
26
- variables: {
27
- SESSION_DRIVER: `Env.schema.enum(['cookie', 'redis', 'file', 'memory'] as const)`,
28
- },
29
- leadingComment: 'Variables for configuring session package',
30
- });
31
- /**
32
- * Register middleware
33
- */
34
- await codemods.registerMiddleware('router', [
35
- {
36
- path: '@adonisjs/session/session_middleware',
37
- },
38
- ]);
39
- /**
40
- * Register provider
41
- */
42
- await codemods.updateRcFile((rcFile) => {
43
- rcFile.addProvider('@adonisjs/session/session_provider');
44
- });
45
- }
@@ -1,10 +0,0 @@
1
- /*
2
- * @adonisjs/session
3
- *
4
- * (c) AdonisJS
5
- *
6
- * For the full copyright and license information, please view the LICENSE
7
- * file that was distributed with this source code.
8
- */
9
- import { debuglog } from 'node:util';
10
- export default debuglog('adonisjs:session');
@@ -1,42 +0,0 @@
1
- /*
2
- * @adonisjs/session
3
- *
4
- * (c) AdonisJS
5
- *
6
- * For the full copyright and license information, please view the LICENSE
7
- * file that was distributed with this source code.
8
- */
9
- import string from '@poppinss/utils/string';
10
- import { InvalidArgumentsException } from '@poppinss/utils';
11
- import debug from './debug.js';
12
- /**
13
- * Helper to normalize session config
14
- */
15
- export function defineConfig(config) {
16
- /**
17
- * Make sure a driver is defined
18
- */
19
- if (!config.driver) {
20
- throw new InvalidArgumentsException('Missing "driver" property inside the session config');
21
- }
22
- const age = config.age || '2h';
23
- const clearWithBrowser = config.clearWithBrowser ?? false;
24
- const cookieOptions = { ...config.cookie };
25
- /**
26
- * Define maxAge property when session id cookie is
27
- * not a session cookie.
28
- */
29
- if (!clearWithBrowser) {
30
- debug('computing maxAge for session id cookie');
31
- cookieOptions.maxAge = string.seconds.parse(config.age || age);
32
- }
33
- return {
34
- enabled: true,
35
- age,
36
- clearWithBrowser,
37
- cookieName: 'adonis_session',
38
- cookie: cookieOptions,
39
- driver: config.driver,
40
- ...config,
41
- };
42
- }
@@ -1,60 +0,0 @@
1
- /*
2
- * @adonisjs/session
3
- *
4
- * (c) AdonisJS
5
- *
6
- * For the full copyright and license information, please view the LICENSE
7
- * file that was distributed with this source code.
8
- */
9
- import debug from '../debug.js';
10
- /**
11
- * Cookie driver stores the session data inside an encrypted
12
- * cookie.
13
- */
14
- export class CookieDriver {
15
- #ctx;
16
- #config;
17
- constructor(config, ctx) {
18
- this.#config = config;
19
- this.#ctx = ctx;
20
- debug('initiating cookie driver %O', this.#config);
21
- }
22
- /**
23
- * Read session value from the cookie
24
- */
25
- read(sessionId) {
26
- debug('cookie driver: reading session data %s', sessionId);
27
- const cookieValue = this.#ctx.request.encryptedCookie(sessionId);
28
- if (typeof cookieValue !== 'object') {
29
- return null;
30
- }
31
- return cookieValue;
32
- }
33
- /**
34
- * Write session values to the cookie
35
- */
36
- write(sessionId, values) {
37
- debug('cookie driver: writing session data %s: %O', sessionId, values);
38
- this.#ctx.response.encryptedCookie(sessionId, values, this.#config);
39
- }
40
- /**
41
- * Removes the session cookie
42
- */
43
- destroy(sessionId) {
44
- debug('cookie driver: destroying session data %s', sessionId);
45
- if (this.#ctx.request.cookiesList()[sessionId]) {
46
- this.#ctx.response.clearCookie(sessionId);
47
- }
48
- }
49
- /**
50
- * Updates the cookie with existing cookie values
51
- */
52
- touch(sessionId) {
53
- const value = this.read(sessionId);
54
- debug('cookie driver: touching session data %s', sessionId);
55
- if (!value) {
56
- return;
57
- }
58
- this.write(sessionId, value);
59
- }
60
- }
@@ -1,133 +0,0 @@
1
- /**
2
- * @adonisjs/session
3
- *
4
- * (c) AdonisJS
5
- *
6
- * For the full copyright and license information, please view the LICENSE
7
- * file that was distributed with this source code.
8
- */
9
- import { dirname, join } from 'node:path';
10
- import string from '@poppinss/utils/string';
11
- import { MessageBuilder } from '@adonisjs/core/helpers';
12
- import { access, mkdir, readFile, rm, writeFile, utimes, stat } from 'node:fs/promises';
13
- import debug from '../debug.js';
14
- /**
15
- * File driver writes the session data on the file system as. Each session
16
- * id gets its own file.
17
- */
18
- export class FileDriver {
19
- #config;
20
- #age;
21
- constructor(config, age) {
22
- this.#config = config;
23
- this.#age = age;
24
- debug('initiating file driver %O', this.#config);
25
- }
26
- /**
27
- * Returns an absolute path to the session id file
28
- */
29
- #getFilePath(sessionId) {
30
- return join(this.#config.location, `${sessionId}.txt`);
31
- }
32
- /**
33
- * Check if a file exists at a given path or not
34
- */
35
- async #pathExists(path) {
36
- try {
37
- await access(path);
38
- return true;
39
- }
40
- catch {
41
- return false;
42
- }
43
- }
44
- /**
45
- * Returns stats for a file and ignoring missing
46
- * files.
47
- */
48
- async #stats(path) {
49
- try {
50
- const stats = await stat(path);
51
- return stats;
52
- }
53
- catch {
54
- return null;
55
- }
56
- }
57
- /**
58
- * Output file with contents to the given path
59
- */
60
- async #outputFile(path, contents) {
61
- const pathDirname = dirname(path);
62
- const dirExists = await this.#pathExists(pathDirname);
63
- if (!dirExists) {
64
- await mkdir(pathDirname, { recursive: true });
65
- }
66
- await writeFile(path, contents, 'utf-8');
67
- }
68
- /**
69
- * Reads the session data from the disk.
70
- */
71
- async read(sessionId) {
72
- const filePath = this.#getFilePath(sessionId);
73
- debug('file driver: reading session data %', sessionId);
74
- /**
75
- * Return null when no session id file exists in first
76
- * place
77
- */
78
- const stats = await this.#stats(filePath);
79
- if (!stats) {
80
- return null;
81
- }
82
- /**
83
- * Check if the file has been expired and return null (if expired)
84
- */
85
- const sessionWillExpireAt = stats.mtimeMs + string.milliseconds.parse(this.#age);
86
- if (Date.now() > sessionWillExpireAt) {
87
- debug('file driver: expired session data %s', sessionId);
88
- return null;
89
- }
90
- /**
91
- * Reading the file contents if the file exists
92
- */
93
- let contents = await readFile(filePath, 'utf-8');
94
- contents = contents.trim();
95
- if (!contents) {
96
- return null;
97
- }
98
- /**
99
- * Verify contents with the session id and return them as an object. The verify
100
- * method can fail when the contents is not JSON>
101
- */
102
- try {
103
- return new MessageBuilder().verify(contents, sessionId);
104
- }
105
- catch {
106
- return null;
107
- }
108
- }
109
- /**
110
- * Writes the session data to the disk as a string
111
- */
112
- async write(sessionId, values) {
113
- debug('file driver: writing session data %s: %O', sessionId, values);
114
- const filePath = this.#getFilePath(sessionId);
115
- const message = new MessageBuilder().build(values, undefined, sessionId);
116
- await this.#outputFile(filePath, message);
117
- }
118
- /**
119
- * Removes the session file from the disk
120
- */
121
- async destroy(sessionId) {
122
- debug('file driver: destroying session data %s', sessionId);
123
- await rm(this.#getFilePath(sessionId), { force: true });
124
- }
125
- /**
126
- * Updates the session expiry by rewriting it to the
127
- * persistence store
128
- */
129
- async touch(sessionId) {
130
- debug('file driver: touching session data %s', sessionId);
131
- await utimes(this.#getFilePath(sessionId), new Date(), new Date());
132
- }
133
- }
@@ -1,33 +0,0 @@
1
- /**
2
- * @adonisjs/session
3
- *
4
- * (c) AdonisJS
5
- *
6
- * For the full copyright and license information, please view the LICENSE
7
- * file that was distributed with this source code.
8
- */
9
- /**
10
- * Memory driver is meant to be used for writing tests.
11
- */
12
- export class MemoryDriver {
13
- static sessions = new Map();
14
- /**
15
- * Read session id value from the memory
16
- */
17
- read(sessionId) {
18
- return MemoryDriver.sessions.get(sessionId) || null;
19
- }
20
- /**
21
- * Save in memory value for a given session id
22
- */
23
- write(sessionId, values) {
24
- MemoryDriver.sessions.set(sessionId, values);
25
- }
26
- /**
27
- * Cleanup for a single session
28
- */
29
- destroy(sessionId) {
30
- MemoryDriver.sessions.delete(sessionId);
31
- }
32
- touch() { }
33
- }
@@ -1,70 +0,0 @@
1
- /**
2
- * @adonisjs/session
3
- *
4
- * (c) AdonisJS
5
- *
6
- * For the full copyright and license information, please view the LICENSE
7
- * file that was distributed with this source code.
8
- */
9
- import string from '@poppinss/utils/string';
10
- import { MessageBuilder } from '@adonisjs/core/helpers';
11
- import debug from '../debug.js';
12
- /**
13
- * File driver to read/write session to filesystem
14
- */
15
- export class RedisDriver {
16
- #config;
17
- #redis;
18
- #ttlSeconds;
19
- constructor(redis, config, age) {
20
- this.#config = config;
21
- this.#redis = redis;
22
- this.#ttlSeconds = string.seconds.parse(age);
23
- debug('initiating redis driver %O', this.#config);
24
- }
25
- /**
26
- * Returns file contents. A new file will be created if it's
27
- * missing.
28
- */
29
- async read(sessionId) {
30
- debug('redis driver: reading session data %s', sessionId);
31
- const contents = await this.#redis.connection(this.#config.connection).get(sessionId);
32
- if (!contents) {
33
- return null;
34
- }
35
- /**
36
- * Verify contents with the session id and return them as an object. The verify
37
- * method can fail when the contents is not JSON>
38
- */
39
- try {
40
- return new MessageBuilder().verify(contents, sessionId);
41
- }
42
- catch {
43
- return null;
44
- }
45
- }
46
- /**
47
- * Write session values to a file
48
- */
49
- async write(sessionId, values) {
50
- debug('redis driver: writing session data %s, %O', sessionId, values);
51
- const message = new MessageBuilder().build(values, undefined, sessionId);
52
- await this.#redis
53
- .connection(this.#config.connection)
54
- .setex(sessionId, this.#ttlSeconds, message);
55
- }
56
- /**
57
- * Cleanup session file by removing it
58
- */
59
- async destroy(sessionId) {
60
- debug('redis driver: destroying session data %s', sessionId);
61
- await this.#redis.connection(this.#config.connection).del(sessionId);
62
- }
63
- /**
64
- * Updates the value expiry
65
- */
66
- async touch(sessionId) {
67
- debug('redis driver: touching session data %s', sessionId);
68
- await this.#redis.connection(this.#config.connection).expire(sessionId, this.#ttlSeconds);
69
- }
70
- }
@@ -1,22 +0,0 @@
1
- import type { HttpContext } from '@adonisjs/core/http';
2
- import type { SessionDriversList } from './types/main.js';
3
- /**
4
- * A global collection of session drivers
5
- */
6
- declare class SessionDriversCollection {
7
- /**
8
- * List of registered drivers
9
- */
10
- list: Partial<SessionDriversList>;
11
- /**
12
- * Extend drivers collection and add a custom
13
- * driver to it.
14
- */
15
- extend<Name extends keyof SessionDriversList>(driverName: Name, factoryCallback: SessionDriversList[Name]): this;
16
- /**
17
- * Creates the driver instance with config
18
- */
19
- create<Name extends keyof SessionDriversList>(name: Name, config: Parameters<SessionDriversList[Name]>[0], ctx: HttpContext): ReturnType<SessionDriversList[Name]>;
20
- }
21
- declare const sessionDriversList: SessionDriversCollection;
22
- export default sessionDriversList;
@@ -1,38 +0,0 @@
1
- /*
2
- * @adonisjs/session
3
- *
4
- * (c) AdonisJS
5
- *
6
- * For the full copyright and license information, please view the LICENSE
7
- * file that was distributed with this source code.
8
- */
9
- import { RuntimeException } from '@poppinss/utils';
10
- /**
11
- * A global collection of session drivers
12
- */
13
- class SessionDriversCollection {
14
- /**
15
- * List of registered drivers
16
- */
17
- list = {};
18
- /**
19
- * Extend drivers collection and add a custom
20
- * driver to it.
21
- */
22
- extend(driverName, factoryCallback) {
23
- this.list[driverName] = factoryCallback;
24
- return this;
25
- }
26
- /**
27
- * Creates the driver instance with config
28
- */
29
- create(name, config, ctx) {
30
- const driverFactory = this.list[name];
31
- if (!driverFactory) {
32
- throw new RuntimeException(`Unknown session driver "${String(name)}". Make sure the driver is registered`);
33
- }
34
- return driverFactory(config, ctx);
35
- }
36
- }
37
- const sessionDriversList = new SessionDriversCollection();
38
- export default sessionDriversList;