@adonisjs/session 7.0.0-3 → 7.0.0-5
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/build/configure.js +18 -0
- package/build/src/debug.d.ts +1 -1
- package/build/src/drivers/file.js +1 -1
- package/build/src/drivers/redis.js +1 -1
- package/build/src/drivers_collection.js +2 -2
- package/build/src/helpers.js +6 -0
- package/build/stubs/config.stub +28 -90
- package/package.json +10 -10
package/build/configure.js
CHANGED
|
@@ -10,8 +10,26 @@
|
|
|
10
10
|
* Configures the package
|
|
11
11
|
*/
|
|
12
12
|
export async function configure(command) {
|
|
13
|
+
/**
|
|
14
|
+
* Publish config file
|
|
15
|
+
*/
|
|
13
16
|
await command.publishStub('config.stub');
|
|
17
|
+
/**
|
|
18
|
+
* Define environment variables
|
|
19
|
+
*/
|
|
14
20
|
await command.defineEnvVariables({ SESSION_DRIVER: 'cookie' });
|
|
21
|
+
/**
|
|
22
|
+
* Define environment variables validations
|
|
23
|
+
*/
|
|
24
|
+
await command.defineEnvValidations({
|
|
25
|
+
variables: {
|
|
26
|
+
SESSION_DRIVER: `Env.schema.enum(['cookie', 'redis', 'file', 'memory' as const])`,
|
|
27
|
+
},
|
|
28
|
+
leadingComment: 'Variables for configuring session package',
|
|
29
|
+
});
|
|
30
|
+
/**
|
|
31
|
+
* Register provider
|
|
32
|
+
*/
|
|
15
33
|
await command.updateRcFile((rcFile) => {
|
|
16
34
|
rcFile.addProvider('@adonisjs/session/session_provider');
|
|
17
35
|
});
|
package/build/src/debug.d.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { dirname, join } from 'node:path';
|
|
10
10
|
import string from '@poppinss/utils/string';
|
|
11
|
-
import { MessageBuilder } from '@
|
|
11
|
+
import { MessageBuilder } from '@adonisjs/core/helpers';
|
|
12
12
|
import { access, mkdir, readFile, rm, writeFile, utimes, stat } from 'node:fs/promises';
|
|
13
13
|
import debug from '../debug.js';
|
|
14
14
|
/**
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
9
|
import string from '@poppinss/utils/string';
|
|
10
|
-
import { MessageBuilder } from '@
|
|
10
|
+
import { MessageBuilder } from '@adonisjs/core/helpers';
|
|
11
11
|
import debug from '../debug.js';
|
|
12
12
|
/**
|
|
13
13
|
* File driver to read/write session to filesystem
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* @adonisjs/
|
|
2
|
+
* @adonisjs/session
|
|
3
3
|
*
|
|
4
4
|
* (c) AdonisJS
|
|
5
5
|
*
|
|
@@ -29,7 +29,7 @@ class SessionDriversCollection {
|
|
|
29
29
|
create(name, config, ctx) {
|
|
30
30
|
const driverFactory = this.list[name];
|
|
31
31
|
if (!driverFactory) {
|
|
32
|
-
throw new RuntimeException(`Unknown
|
|
32
|
+
throw new RuntimeException(`Unknown session driver "${String(name)}". Make sure the driver is registered`);
|
|
33
33
|
}
|
|
34
34
|
return driverFactory(config, ctx);
|
|
35
35
|
}
|
package/build/src/helpers.js
CHANGED
|
@@ -12,6 +12,12 @@ import sessionDriversList from './drivers_collection.js';
|
|
|
12
12
|
* Lazily imports and registers a driver with the sessionDriversList
|
|
13
13
|
*/
|
|
14
14
|
export async function registerSessionDriver(app, driverInUse) {
|
|
15
|
+
/**
|
|
16
|
+
* Noop when the driver is already registered
|
|
17
|
+
*/
|
|
18
|
+
if (sessionDriversList.list[driverInUse]) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
15
21
|
debug('registering %s driver', driverInUse);
|
|
16
22
|
if (driverInUse === 'cookie') {
|
|
17
23
|
const { CookieDriver } = await import('../src/drivers/cookie.js');
|
package/build/stubs/config.stub
CHANGED
|
@@ -7,107 +7,45 @@ import app from '@adonisjs/core/services/app'
|
|
|
7
7
|
import { defineConfig } from '@adonisjs/session'
|
|
8
8
|
|
|
9
9
|
export default defineConfig({
|
|
10
|
-
/*
|
|
11
|
-
|--------------------------------------------------------------------------
|
|
12
|
-
| Enable/Disable sessions
|
|
13
|
-
|--------------------------------------------------------------------------
|
|
14
|
-
|
|
|
15
|
-
| Setting the following property to "false" will disable the session for the
|
|
16
|
-
| entire application
|
|
17
|
-
|
|
|
18
|
-
*/
|
|
19
10
|
enabled: true,
|
|
20
|
-
|
|
21
|
-
/*
|
|
22
|
-
|--------------------------------------------------------------------------
|
|
23
|
-
| Driver
|
|
24
|
-
|--------------------------------------------------------------------------
|
|
25
|
-
|
|
|
26
|
-
| The session driver to use. You can choose between one of the following
|
|
27
|
-
| drivers.
|
|
28
|
-
|
|
|
29
|
-
| - cookie (Uses signed cookies to store session values)
|
|
30
|
-
| - file (Uses filesystem to store session values)
|
|
31
|
-
| - redis (Uses redis. Make sure to install "@adonisjs/redis" as well)
|
|
32
|
-
|
|
|
33
|
-
| Note: Switching drivers will make existing sessions invalid.
|
|
34
|
-
|
|
|
35
|
-
*/
|
|
36
|
-
driver: env.get('SESSION_DRIVER'),
|
|
37
|
-
|
|
38
|
-
/*
|
|
39
|
-
|--------------------------------------------------------------------------
|
|
40
|
-
| Cookie name
|
|
41
|
-
|--------------------------------------------------------------------------
|
|
42
|
-
|
|
|
43
|
-
| The name of the cookie that will hold the session id.
|
|
44
|
-
|
|
|
45
|
-
*/
|
|
46
11
|
cookieName: 'adonis-session',
|
|
47
12
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
|
53
|
-
| Whether or not you want to destroy the session when browser closes. Setting
|
|
54
|
-
| this value to "true" will ignore the "age".
|
|
55
|
-
|
|
|
56
|
-
*/
|
|
13
|
+
/**
|
|
14
|
+
* When set to true, the session id cookie will be deleted
|
|
15
|
+
* once the user closes the browser.
|
|
16
|
+
*/
|
|
57
17
|
clearWithBrowser: false,
|
|
58
18
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
|
64
|
-
| The duration for which session stays active after no activity. A new HTTP
|
|
65
|
-
| request to the server is considered as activity.
|
|
66
|
-
|
|
|
67
|
-
| The value can be a number in milliseconds or a string that must be valid
|
|
68
|
-
| as per https://npmjs.org/package/ms package.
|
|
69
|
-
|
|
|
70
|
-
| Example: "2 days", "2.5 hrs", "1y", "5s" and so on.
|
|
71
|
-
|
|
|
72
|
-
*/
|
|
19
|
+
/**
|
|
20
|
+
* Define how long to keep the session data alive without
|
|
21
|
+
* any activity.
|
|
22
|
+
*/
|
|
73
23
|
age: '2h',
|
|
74
24
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
|
83
|
-
*/
|
|
25
|
+
/**
|
|
26
|
+
* The driver to use. Make sure to validate the environment
|
|
27
|
+
* variable in order to infer the driver name without any
|
|
28
|
+
* errors.
|
|
29
|
+
*/
|
|
30
|
+
driver: env.get('SESSION_DRIVER'),
|
|
31
|
+
|
|
84
32
|
cookie: {
|
|
85
33
|
path: '/',
|
|
86
34
|
httpOnly: true,
|
|
87
35
|
sameSite: false,
|
|
88
36
|
},
|
|
89
37
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
/*
|
|
104
|
-
|--------------------------------------------------------------------------
|
|
105
|
-
| Redis driver
|
|
106
|
-
|--------------------------------------------------------------------------
|
|
107
|
-
|
|
|
108
|
-
| The redis connection you want session driver to use. The same connection
|
|
109
|
-
| must be defined inside "config/redis.ts" file as well.
|
|
110
|
-
|
|
|
111
|
-
*/
|
|
112
|
-
redisConnection: 'local',
|
|
38
|
+
/**
|
|
39
|
+
* Settings for the file driver
|
|
40
|
+
*/
|
|
41
|
+
// file: {
|
|
42
|
+
// location: app.tmpPath('sessions'),
|
|
43
|
+
// },
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Settings for the redis driver
|
|
47
|
+
*/
|
|
48
|
+
// redis: {
|
|
49
|
+
// connection: 'main'
|
|
50
|
+
// },
|
|
113
51
|
})
|
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.0.0-
|
|
4
|
+
"version": "7.0.0-5",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=18.16.0"
|
|
7
7
|
},
|
|
@@ -40,19 +40,19 @@
|
|
|
40
40
|
"quick:test": "node --enable-source-maps --loader=ts-node/esm bin/test.ts"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@adonisjs/
|
|
43
|
+
"@adonisjs/assembler": "^6.1.3-18",
|
|
44
|
+
"@adonisjs/core": "^6.1.5-18",
|
|
44
45
|
"@adonisjs/eslint-config": "^1.1.8",
|
|
45
46
|
"@adonisjs/prettier-config": "^1.1.8",
|
|
46
|
-
"@adonisjs/redis": "^8.0.0-
|
|
47
|
+
"@adonisjs/redis": "^8.0.0-9",
|
|
47
48
|
"@adonisjs/tsconfig": "^1.1.8",
|
|
48
|
-
"@japa/api-client": "^2.0.0-0",
|
|
49
49
|
"@japa/assert": "^2.0.0-1",
|
|
50
50
|
"@japa/file-system": "^2.0.0-1",
|
|
51
51
|
"@japa/plugin-adonisjs": "^2.0.0-1",
|
|
52
52
|
"@japa/runner": "^3.0.0-6",
|
|
53
53
|
"@japa/snapshot": "^2.0.0-1",
|
|
54
|
-
"@swc/core": "^1.3.
|
|
55
|
-
"@types/node": "^20.
|
|
54
|
+
"@swc/core": "^1.3.78",
|
|
55
|
+
"@types/node": "^20.5.1",
|
|
56
56
|
"@types/set-cookie-parser": "^2.4.3",
|
|
57
57
|
"@types/supertest": "^2.0.12",
|
|
58
58
|
"@vinejs/vine": "^1.6.0",
|
|
@@ -60,11 +60,11 @@
|
|
|
60
60
|
"copyfiles": "^2.4.1",
|
|
61
61
|
"cross-env": "^7.0.3",
|
|
62
62
|
"del-cli": "^5.0.0",
|
|
63
|
-
"eslint": "^8.
|
|
63
|
+
"eslint": "^8.47.0",
|
|
64
64
|
"github-label-sync": "^2.3.1",
|
|
65
65
|
"husky": "^8.0.3",
|
|
66
66
|
"np": "^8.0.4",
|
|
67
|
-
"prettier": "^3.0.
|
|
67
|
+
"prettier": "^3.0.2",
|
|
68
68
|
"set-cookie-parser": "^2.6.0",
|
|
69
69
|
"supertest": "^6.3.3",
|
|
70
70
|
"ts-node": "^10.9.1",
|
|
@@ -74,8 +74,8 @@
|
|
|
74
74
|
"@poppinss/utils": "^6.5.0-5"
|
|
75
75
|
},
|
|
76
76
|
"peerDependencies": {
|
|
77
|
-
"@adonisjs/core": "^6.1.5-
|
|
78
|
-
"@adonisjs/redis": "^8.0.0-
|
|
77
|
+
"@adonisjs/core": "^6.1.5-18",
|
|
78
|
+
"@adonisjs/redis": "^8.0.0-9"
|
|
79
79
|
},
|
|
80
80
|
"peerDependenciesMeta": {
|
|
81
81
|
"@adonisjs/redis": {
|