@adonisjs/session 6.4.0 → 7.0.0-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 (59) hide show
  1. package/README.md +25 -42
  2. package/build/configure.d.ts +5 -0
  3. package/build/configure.js +18 -0
  4. package/build/index.d.ts +12 -0
  5. package/build/index.js +12 -0
  6. package/build/providers/session_provider.d.ts +13 -0
  7. package/build/providers/session_provider.js +43 -0
  8. package/build/src/bindings/api_client.d.ts +2 -0
  9. package/build/src/{Bindings/Tests.js → bindings/api_client.js} +8 -13
  10. package/build/src/bindings/http_context.d.ts +5 -0
  11. package/build/src/bindings/http_context.js +17 -0
  12. package/build/{adonis-typings/tests.d.ts → src/bindings/types.d.ts} +26 -5
  13. package/build/{adonis-typings/session.js → src/bindings/types.js} +2 -1
  14. package/build/src/{Client/index.d.ts → client.d.ts} +7 -15
  15. package/build/src/client.js +100 -0
  16. package/build/src/define_config.d.ts +5 -0
  17. package/build/src/define_config.js +13 -0
  18. package/build/src/{Drivers/Cookie.d.ts → drivers/cookie.d.ts} +4 -6
  19. package/build/src/{Drivers/Cookie.js → drivers/cookie.js} +10 -12
  20. package/build/src/{Drivers/File.d.ts → drivers/file.d.ts} +3 -8
  21. package/build/src/{Drivers/File.js → drivers/file.js} +20 -23
  22. package/build/src/{Drivers/Memory.d.ts → drivers/memory.d.ts} +2 -3
  23. package/build/src/{Drivers/Memory.js → drivers/memory.js} +3 -7
  24. package/build/src/{Drivers/Redis.d.ts → drivers/redis.d.ts} +5 -15
  25. package/build/src/drivers/redis.js +74 -0
  26. package/build/src/{Session/index.d.ts → session.d.ts} +6 -67
  27. package/build/src/session.js +371 -0
  28. package/build/src/session_manager.d.ts +38 -0
  29. package/build/src/session_manager.js +149 -0
  30. package/build/src/session_middleware.d.ts +5 -0
  31. package/build/src/session_middleware.js +20 -0
  32. package/build/src/{Store/index.d.ts → store.d.ts} +3 -7
  33. package/build/src/{Store/index.js → store.js} +18 -18
  34. package/build/src/types.d.ts +61 -0
  35. package/build/src/types.js +1 -0
  36. package/build/{templates/session.txt → stubs/config.stub} +12 -15
  37. package/build/stubs/main.d.ts +1 -0
  38. package/build/{adonis-typings/tests.js → stubs/main.js} +2 -3
  39. package/package.json +96 -134
  40. package/build/adonis-typings/container.d.ts +0 -14
  41. package/build/adonis-typings/container.js +0 -8
  42. package/build/adonis-typings/context.d.ts +0 -14
  43. package/build/adonis-typings/context.js +0 -8
  44. package/build/adonis-typings/index.d.ts +0 -4
  45. package/build/adonis-typings/index.js +0 -12
  46. package/build/adonis-typings/session.d.ts +0 -265
  47. package/build/config.d.ts +0 -13
  48. package/build/config.js +0 -18
  49. package/build/instructions.md +0 -10
  50. package/build/providers/SessionProvider.d.ts +0 -31
  51. package/build/providers/SessionProvider.js +0 -56
  52. package/build/src/Bindings/Server.d.ts +0 -10
  53. package/build/src/Bindings/Server.js +0 -42
  54. package/build/src/Bindings/Tests.d.ts +0 -7
  55. package/build/src/Client/index.js +0 -93
  56. package/build/src/Drivers/Redis.js +0 -73
  57. package/build/src/Session/index.js +0 -352
  58. package/build/src/SessionManager/index.d.ts +0 -78
  59. package/build/src/SessionManager/index.js +0 -148
@@ -0,0 +1,61 @@
1
+ import type { CookieOptions } from '@adonisjs/core/types/http';
2
+ import type { SessionManager } from './session_manager.js';
3
+ import type { HttpContext } from '@adonisjs/core/http';
4
+ /**
5
+ * The callback to be passed to the `extend` method. It is invoked
6
+ * for each request (if extended driver is in use).
7
+ */
8
+ export type ExtendCallback = (manager: SessionManager, config: SessionConfig, ctx: HttpContext) => SessionDriverContract;
9
+ /**
10
+ * Shape of a driver that every session driver must have
11
+ */
12
+ export interface SessionDriverContract {
13
+ read(sessionId: string): Promise<Record<string, any> | null> | Record<string, any> | null;
14
+ write(sessionId: string, values: Record<string, any>): Promise<void> | void;
15
+ destroy(sessionId: string): Promise<void> | void;
16
+ touch(sessionId: string): Promise<void> | void;
17
+ }
18
+ /**
19
+ * Shape of session config.
20
+ */
21
+ export interface SessionConfig {
22
+ /**
23
+ * Enable/disable session for the entire application lifecycle
24
+ */
25
+ enabled: boolean;
26
+ /**
27
+ * The driver in play
28
+ */
29
+ driver: string;
30
+ /**
31
+ * Cookie name.
32
+ */
33
+ cookieName: string;
34
+ /**
35
+ * Clear session when browser closes
36
+ */
37
+ clearWithBrowser: boolean;
38
+ /**
39
+ * Age of session cookie
40
+ */
41
+ age: string | number;
42
+ /**
43
+ * Config for the cookie driver and also the session id
44
+ * cookie
45
+ */
46
+ cookie: Omit<Partial<CookieOptions>, 'maxAge' | 'expires'>;
47
+ /**
48
+ * Config for the file driver
49
+ */
50
+ file?: {
51
+ location: string;
52
+ };
53
+ /**
54
+ * The redis connection to use from the `config/redis` file
55
+ */
56
+ redisConnection?: string;
57
+ }
58
+ /**
59
+ * The values allowed by the `session.put` method
60
+ */
61
+ export type AllowedSessionValues = string | boolean | number | object | Date | Array<any>;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,15 +1,12 @@
1
- /**
2
- * Config source: https://git.io/JeYHp
3
- *
4
- * Feel free to let us know via PR, if you find something broken in this config
5
- * file.
6
- */
1
+ ---
2
+ to: {{ app.configPath('session.ts') }}
3
+ ---
7
4
 
8
- import Env from '@ioc:Adonis/Core/Env'
9
- import Application from '@ioc:Adonis/Core/Application'
10
- import { sessionConfig } from '@adonisjs/session/build/config'
5
+ import env from '#start/env'
6
+ import app from '@adonisjs/core/services/app'
7
+ import { defineConfig } from '@adonisjs/session'
11
8
 
12
- export default sessionConfig({
9
+ export default defineConfig({
13
10
  /*
14
11
  |--------------------------------------------------------------------------
15
12
  | Enable/Disable sessions
@@ -36,7 +33,7 @@ export default sessionConfig({
36
33
  | Note: Switching drivers will make existing sessions invalid.
37
34
  |
38
35
  */
39
- driver: Env.get('SESSION_DRIVER'),
36
+ driver: env.get('SESSION_DRIVER'),
40
37
 
41
38
  /*
42
39
  |--------------------------------------------------------------------------
@@ -54,7 +51,7 @@ export default sessionConfig({
54
51
  |--------------------------------------------------------------------------
55
52
  |
56
53
  | Whether or not you want to destroy the session when browser closes. Setting
57
- | this value to `true` will ignore the `age`.
54
+ | this value to "true" will ignore the "age".
58
55
  |
59
56
  */
60
57
  clearWithBrowser: false,
@@ -70,7 +67,7 @@ export default sessionConfig({
70
67
  | The value can be a number in milliseconds or a string that must be valid
71
68
  | as per https://npmjs.org/package/ms package.
72
69
  |
73
- | Example: `2 days`, `2.5 hrs`, `1y`, `5s` and so on.
70
+ | Example: "2 days", "2.5 hrs", "1y", "5s" and so on.
74
71
  |
75
72
  */
76
73
  age: '2h',
@@ -100,7 +97,7 @@ export default sessionConfig({
100
97
  |
101
98
  */
102
99
  file: {
103
- location: Application.tmpPath('sessions'),
100
+ location: app.tmpPath('sessions'),
104
101
  },
105
102
 
106
103
  /*
@@ -109,7 +106,7 @@ export default sessionConfig({
109
106
  |--------------------------------------------------------------------------
110
107
  |
111
108
  | The redis connection you want session driver to use. The same connection
112
- | must be defined inside `config/redis.ts` file as well.
109
+ | must be defined inside "config/redis.ts" file as well.
113
110
  |
114
111
  */
115
112
  redisConnection: 'local',
@@ -0,0 +1 @@
1
+ export declare const stubsRoot: string;
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /*
3
2
  * @adonisjs/session
4
3
  *
@@ -7,5 +6,5 @@
7
6
  * For the full copyright and license information, please view the LICENSE
8
7
  * file that was distributed with this source code.
9
8
  */
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- require("@japa/api-client");
9
+ import { getDirname } from '@poppinss/utils';
10
+ export const stubsRoot = getDirname(import.meta.url);
package/package.json CHANGED
@@ -1,167 +1,129 @@
1
1
  {
2
2
  "name": "@adonisjs/session",
3
- "version": "6.4.0",
4
3
  "description": "Session provider for AdonisJS",
5
- "typings": "./build/adonis-typings/index.d.ts",
6
- "main": "build/providers/SessionProvider.js",
4
+ "version": "7.0.0-1",
5
+ "engines": {
6
+ "node": ">=18.16.0"
7
+ },
8
+ "main": "build/index.js",
9
+ "type": "module",
7
10
  "files": [
8
- "build/adonis-typings",
9
- "build/providers",
10
11
  "build/src",
11
- "build/config.js",
12
- "build/config.d.ts",
13
- "build/templates",
14
- "build/instructions.md"
12
+ "build/stubs",
13
+ "build/providers",
14
+ "build/index.d.ts",
15
+ "build/index.js",
16
+ "build/configure.d.ts",
17
+ "build/configure.js"
15
18
  ],
16
- "dependencies": {
17
- "@poppinss/utils": "^4.0.4",
18
- "fs-extra": "^10.1.0"
19
- },
20
- "peerDependencies": {
21
- "@adonisjs/core": "^5.8.0"
22
- },
23
- "devDependencies": {
24
- "@adonisjs/core": "^5.8.2",
25
- "@adonisjs/mrm-preset": "^5.0.3",
26
- "@adonisjs/redis": "^7.3.0",
27
- "@adonisjs/require-ts": "^2.0.11",
28
- "@japa/assert": "^1.3.4",
29
- "@japa/preset-adonis": "^1.0.15",
30
- "@japa/run-failed-tests": "^1.0.7",
31
- "@japa/runner": "^2.0.8",
32
- "@japa/spec-reporter": "^1.1.12",
33
- "@poppinss/dev-utils": "^2.0.3",
34
- "@types/node": "^17.0.34",
35
- "@types/supertest": "^2.0.12",
36
- "commitizen": "^4.2.4",
37
- "copyfiles": "^2.4.1",
38
- "cz-conventional-changelog": "^3.3.0",
39
- "del-cli": "^4.0.1",
40
- "eslint": "^8.15.0",
41
- "eslint-config-prettier": "^8.5.0",
42
- "eslint-plugin-adonis": "^2.1.0",
43
- "eslint-plugin-prettier": "^4.0.0",
44
- "github-label-sync": "^2.2.0",
45
- "husky": "^8.0.1",
46
- "mrm": "^4.0.0",
47
- "np": "^7.6.1",
48
- "prettier": "^2.6.2",
49
- "set-cookie-parser": "^2.4.8",
50
- "supertest": "^6.2.3",
51
- "typescript": "^4.6.4"
19
+ "exports": {
20
+ ".": "./build/index.js",
21
+ "./session_provider": "./build/providers/session_provider.js",
22
+ "./session_middleware": "./build/src/session_middleware.js",
23
+ "./types": "./build/src/types.js"
52
24
  },
53
25
  "scripts": {
54
- "mrm": "mrm --preset=@adonisjs/mrm-preset",
55
26
  "pretest": "npm run lint",
56
- "test": "node -r @adonisjs/require-ts/build/register ./bin/test.ts",
57
- "clean": "del build",
27
+ "test": "c8 npm run quick:test",
28
+ "clean": "del-cli build",
29
+ "typecheck": "tsc --noEmit",
30
+ "copy:templates": "copyfiles \"stubs/**/*.stub\" build",
58
31
  "compile": "npm run lint && npm run clean && tsc",
59
- "copyfiles": "copyfiles \"templates/**/*.txt\" \"instructions.md\" build",
60
- "build": "npm run compile && npm run copyfiles",
61
- "commit": "git-cz",
62
- "release": "np --message=\"chore(release): %s\"",
63
- "version": "npm run build",
32
+ "build": "npm run compile && npm run copy:templates",
64
33
  "prepublishOnly": "npm run build",
65
34
  "lint": "eslint . --ext=.ts",
66
35
  "format": "prettier --write .",
67
- "sync-labels": "github-label-sync --labels ./node_modules/@adonisjs/mrm-preset/gh-labels.json adonisjs/session"
36
+ "release": "np",
37
+ "version": "npm run build",
38
+ "sync-labels": "github-label-sync --labels .github/labels.json adonisjs/ally",
39
+ "quick:test": "node --enable-source-maps --loader=ts-node/esm bin/test.ts"
40
+ },
41
+ "devDependencies": {
42
+ "@adonisjs/application": "7.1.2-8",
43
+ "@adonisjs/core": "6.1.5-10",
44
+ "@adonisjs/eslint-config": "^1.1.8",
45
+ "@adonisjs/prettier-config": "^1.1.8",
46
+ "@adonisjs/redis": "8.0.0-3",
47
+ "@adonisjs/tsconfig": "^1.1.8",
48
+ "@adonisjs/view": "7.0.0-4",
49
+ "@japa/api-client": "2.0.0-0",
50
+ "@japa/assert": "2.0.0-1",
51
+ "@japa/file-system": "2.0.0-1",
52
+ "@japa/plugin-adonisjs": "2.0.0-1",
53
+ "@japa/runner": "3.0.0-6",
54
+ "@poppinss/dev-utils": "^2.0.3",
55
+ "@swc/core": "^1.3.70",
56
+ "@types/fs-extra": "^11.0.1",
57
+ "@types/node": "^20.4.2",
58
+ "@types/set-cookie-parser": "^2.4.3",
59
+ "@types/supertest": "^2.0.12",
60
+ "c8": "^8.0.0",
61
+ "copyfiles": "^2.4.1",
62
+ "del-cli": "^5.0.0",
63
+ "eslint": "^8.45.0",
64
+ "github-label-sync": "^2.3.1",
65
+ "husky": "^8.0.3",
66
+ "np": "^8.0.4",
67
+ "prettier": "^3.0.0",
68
+ "set-cookie-parser": "^2.6.0",
69
+ "supertest": "^6.3.3",
70
+ "ts-node": "^10.9.1",
71
+ "typescript": "^5.1.6"
72
+ },
73
+ "dependencies": {
74
+ "@poppinss/utils": "6.5.0-3",
75
+ "fs-extra": "^11.1.1"
76
+ },
77
+ "peerDependencies": {
78
+ "@adonisjs/core": "6.1.5-10",
79
+ "@adonisjs/redis": "8.0.0-3"
80
+ },
81
+ "peerDependenciesMeta": {
82
+ "@adonisjs/redis": {
83
+ "optional": true
84
+ }
68
85
  },
86
+ "author": "virk,adonisjs",
87
+ "license": "MIT",
88
+ "homepage": "https://github.com/adonisjs/adonis-session#readme",
69
89
  "repository": {
70
90
  "type": "git",
71
91
  "url": "git+https://github.com/adonisjs/adonis-session.git"
72
92
  },
93
+ "bugs": {
94
+ "url": "https://github.com/adonisjs/adonis-session/issues"
95
+ },
73
96
  "keywords": [
74
97
  "session",
75
98
  "adonisjs"
76
99
  ],
77
- "author": "virk,adonisjs",
78
- "license": "MIT",
79
- "bugs": {
80
- "url": "https://github.com/adonisjs/adonis-session/issues"
100
+ "eslintConfig": {
101
+ "extends": "@adonisjs/eslint-config/package"
81
102
  },
82
- "homepage": "https://github.com/adonisjs/adonis-session#readme",
83
- "nyc": {
84
- "exclude": [
85
- "test"
86
- ],
87
- "extension": [
88
- ".ts"
103
+ "prettier": "@adonisjs/prettier-config",
104
+ "commitlint": {
105
+ "extends": [
106
+ "@commitlint/config-conventional"
89
107
  ]
90
108
  },
91
- "husky": {
92
- "hooks": {
93
- "commit-msg": "node ./node_modules/@adonisjs/mrm-preset/validateCommit/conventional/validate.js"
94
- }
95
- },
96
- "config": {
97
- "commitizen": {
98
- "path": "cz-conventional-changelog"
99
- }
100
- },
101
109
  "publishConfig": {
102
- "tag": "latest",
103
- "access": "public"
104
- },
105
- "adonisjs": {
106
- "instructionsMd": "./build/instructions.md",
107
- "templates": {
108
- "config": [
109
- "session.txt"
110
- ]
111
- },
112
- "env": {
113
- "SESSION_DRIVER": "cookie"
114
- },
115
- "types": "@adonisjs/session",
116
- "providers": [
117
- "@adonisjs/session"
118
- ]
110
+ "access": "public",
111
+ "tag": "next"
119
112
  },
120
113
  "np": {
121
- "contents": ".",
114
+ "message": "chore(release): %s",
115
+ "tag": "next",
116
+ "branch": "main",
122
117
  "anyBranch": false
123
118
  },
124
- "mrmConfig": {
125
- "core": true,
126
- "license": "MIT",
127
- "services": [
128
- "github-actions"
129
- ],
130
- "minNodeVersion": "14.15.4",
131
- "probotApps": [
132
- "stale",
133
- "lock"
134
- ],
135
- "runGhActionsOnWindows": false
136
- },
137
- "eslintConfig": {
138
- "extends": [
139
- "plugin:adonis/typescriptPackage",
140
- "prettier"
141
- ],
142
- "plugins": [
143
- "prettier"
119
+ "c8": {
120
+ "reporter": [
121
+ "text",
122
+ "html"
144
123
  ],
145
- "rules": {
146
- "prettier/prettier": [
147
- "error",
148
- {
149
- "endOfLine": "auto"
150
- }
151
- ]
152
- }
153
- },
154
- "eslintIgnore": [
155
- "build"
156
- ],
157
- "prettier": {
158
- "trailingComma": "es5",
159
- "semi": false,
160
- "singleQuote": true,
161
- "useTabs": false,
162
- "quoteProps": "consistent",
163
- "bracketSpacing": true,
164
- "arrowParens": "always",
165
- "printWidth": 100
124
+ "exclude": [
125
+ "tests/**",
126
+ "stubs/**"
127
+ ]
166
128
  }
167
129
  }
@@ -1,14 +0,0 @@
1
- /**
2
- * @adonisjs/session
3
- *
4
- * (c) Harminder Virk <virk@adonisjs.com>
5
- *
6
- * For the full copyright and license information, please view the LICENSE
7
- * file that was distributed with this source code.
8
- */
9
- declare module '@ioc:Adonis/Core/Application' {
10
- import { SessionManagerContract } from '@ioc:Adonis/Addons/Session';
11
- interface ContainerBindings {
12
- 'Adonis/Addons/Session': SessionManagerContract;
13
- }
14
- }
@@ -1,8 +0,0 @@
1
- /**
2
- * @adonisjs/session
3
- *
4
- * (c) Harminder Virk <virk@adonisjs.com>
5
- *
6
- * For the full copyright and license information, please view the LICENSE
7
- * file that was distributed with this source code.
8
- */
@@ -1,14 +0,0 @@
1
- /**
2
- * @adonisjs/session
3
- *
4
- * (c) Harminder Virk <virk@adonisjs.com>
5
- *
6
- * For the full copyright and license information, please view the LICENSE
7
- * file that was distributed with this source code.
8
- */
9
- declare module '@ioc:Adonis/Core/HttpContext' {
10
- import { SessionContract } from '@ioc:Adonis/Addons/Session';
11
- interface HttpContextContract {
12
- session: SessionContract;
13
- }
14
- }
@@ -1,8 +0,0 @@
1
- /**
2
- * @adonisjs/session
3
- *
4
- * (c) Harminder Virk <virk@adonisjs.com>
5
- *
6
- * For the full copyright and license information, please view the LICENSE
7
- * file that was distributed with this source code.
8
- */
@@ -1,4 +0,0 @@
1
- /// <reference path="session.d.ts" />
2
- /// <reference path="context.d.ts" />
3
- /// <reference path="container.d.ts" />
4
- /// <reference path="tests.d.ts" />
@@ -1,12 +0,0 @@
1
- /*
2
- * @adonisjs/session
3
- *
4
- * (c) Harminder Virk <virk@adonisjs.com>
5
- *
6
- * For the full copyright and license information, please view the LICENSE
7
- * file that was distributed with this source code.
8
- */
9
- /// <reference path="./session.ts" />
10
- /// <reference path="./context.ts" />
11
- /// <reference path="./container.ts" />
12
- /// <reference path="./tests.ts" />