@adonisjs/session 7.0.0-13 → 7.0.0-15

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 (52) hide show
  1. package/build/chunk-2X5L327N.js +28 -0
  2. package/build/chunk-2X5L327N.js.map +1 -0
  3. package/build/chunk-HIQQAMXD.js +133 -0
  4. package/build/chunk-HIQQAMXD.js.map +1 -0
  5. package/build/chunk-K4OSGJVW.js +402 -0
  6. package/build/chunk-K4OSGJVW.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/{stubs/config.stub → config/session.stub} +3 -1
  14. package/build/cookie-H7KRZB4T.js +56 -0
  15. package/build/cookie-H7KRZB4T.js.map +1 -0
  16. package/build/factories/main.js +50 -9
  17. package/build/factories/main.js.map +1 -0
  18. package/build/file-YO7C2QWO.js +112 -0
  19. package/build/file-YO7C2QWO.js.map +1 -0
  20. package/build/index.d.ts +0 -1
  21. package/build/index.js +16 -12
  22. package/build/index.js.map +1 -0
  23. package/build/providers/session_provider.js +51 -59
  24. package/build/providers/session_provider.js.map +1 -0
  25. package/build/redis-KDWIBKUQ.js +58 -0
  26. package/build/redis-KDWIBKUQ.js.map +1 -0
  27. package/build/src/client.js +9 -85
  28. package/build/src/client.js.map +1 -0
  29. package/build/src/plugins/edge.js +101 -91
  30. package/build/src/plugins/edge.js.map +1 -0
  31. package/build/src/plugins/japa/api_client.js +99 -140
  32. package/build/src/plugins/japa/api_client.js.map +1 -0
  33. package/build/src/plugins/japa/browser_client.js +82 -109
  34. package/build/src/plugins/japa/browser_client.js.map +1 -0
  35. package/build/src/session.d.ts +14 -5
  36. package/build/src/session_middleware.js +10 -58
  37. package/build/src/session_middleware.js.map +1 -0
  38. package/build/src/values_store.d.ts +7 -7
  39. package/package.json +60 -43
  40. package/build/configure.js +0 -45
  41. package/build/factories/session_middleware_factory.js +0 -48
  42. package/build/src/debug.js +0 -10
  43. package/build/src/define_config.js +0 -105
  44. package/build/src/errors.js +0 -17
  45. package/build/src/session.js +0 -387
  46. package/build/src/stores/cookie.js +0 -60
  47. package/build/src/stores/file.js +0 -133
  48. package/build/src/stores/memory.js +0 -33
  49. package/build/src/stores/redis.js +0 -66
  50. package/build/src/types.js +0 -9
  51. package/build/src/values_store.js +0 -159
  52. package/build/stubs/main.js +0 -10
package/package.json CHANGED
@@ -1,21 +1,17 @@
1
1
  {
2
2
  "name": "@adonisjs/session",
3
3
  "description": "Session provider for AdonisJS",
4
- "version": "7.0.0-13",
4
+ "version": "7.0.0-15",
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/factories",
15
- "build/configure.d.ts",
16
- "build/configure.js",
17
- "build/index.d.ts",
18
- "build/index.js"
11
+ "build",
12
+ "!build/bin",
13
+ "!build/tests",
14
+ "!build/tests_helpers"
19
15
  ],
20
16
  "exports": {
21
17
  ".": "./build/index.js",
@@ -33,9 +29,11 @@
33
29
  "test": "cross-env NODE_DEBUG=adonisjs:session c8 npm run quick:test",
34
30
  "clean": "del-cli build",
35
31
  "typecheck": "tsc --noEmit",
36
- "copy:templates": "copyfiles \"stubs/**/*.stub\" build",
37
- "compile": "npm run lint && npm run clean && tsc",
38
- "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",
39
37
  "prepublishOnly": "npm run build",
40
38
  "lint": "eslint . --ext=.ts",
41
39
  "format": "prettier --write .",
@@ -45,50 +43,51 @@
45
43
  "quick:test": "node --enable-source-maps --loader=ts-node/esm bin/test.ts"
46
44
  },
47
45
  "devDependencies": {
48
- "@adonisjs/assembler": "^6.1.3-25",
49
- "@adonisjs/core": "^6.1.5-28",
50
- "@adonisjs/eslint-config": "^1.1.8",
51
- "@adonisjs/prettier-config": "^1.1.8",
52
- "@adonisjs/redis": "^8.0.0-11",
53
- "@adonisjs/tsconfig": "^1.1.8",
54
- "@japa/api-client": "^2.0.0",
55
- "@japa/assert": "^2.0.0",
56
- "@japa/browser-client": "^2.0.0",
57
- "@japa/file-system": "^2.0.0",
58
- "@japa/plugin-adonisjs": "^2.0.0",
59
- "@japa/runner": "^3.0.4",
60
- "@japa/snapshot": "^2.0.0",
61
- "@swc/core": "1.3.82",
62
- "@types/node": "^20.8.7",
63
- "@types/set-cookie-parser": "^2.4.4",
64
- "@types/supertest": "^2.0.14",
65
- "@vinejs/vine": "^1.6.0",
46
+ "@adonisjs/assembler": "^7.0.0-1",
47
+ "@adonisjs/core": "^6.1.5-36",
48
+ "@adonisjs/eslint-config": "^1.2.0",
49
+ "@adonisjs/prettier-config": "^1.2.0",
50
+ "@adonisjs/redis": "^8.0.0-14",
51
+ "@adonisjs/tsconfig": "^1.2.0",
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.1.1",
56
+ "@japa/plugin-adonisjs": "^2.0.1",
57
+ "@japa/runner": "^3.1.1",
58
+ "@japa/snapshot": "^2.0.4",
59
+ "@swc/core": "^1.3.101",
60
+ "@types/node": "^20.10.5",
61
+ "@types/set-cookie-parser": "^2.4.7",
62
+ "@types/supertest": "^6.0.1",
63
+ "@vinejs/vine": "^1.7.0",
66
64
  "c8": "^8.0.0",
67
65
  "copyfiles": "^2.4.1",
68
66
  "cross-env": "^7.0.3",
69
67
  "del-cli": "^5.0.0",
70
- "edge.js": "^6.0.0-8",
71
- "eslint": "^8.51.0",
68
+ "edge.js": "^6.0.0",
69
+ "eslint": "^8.56.0",
72
70
  "get-port": "^7.0.0",
73
71
  "github-label-sync": "^2.3.1",
74
72
  "husky": "^8.0.3",
75
- "np": "^8.0.4",
76
- "playwright": "^1.38.0",
77
- "prettier": "^3.0.2",
73
+ "np": "^9.2.0",
74
+ "playwright": "^1.40.1",
75
+ "prettier": "^3.1.1",
78
76
  "set-cookie-parser": "^2.6.0",
79
77
  "supertest": "^6.3.3",
80
- "ts-node": "^10.9.1",
81
- "typescript": "^5.1.6"
78
+ "ts-node": "^10.9.2",
79
+ "tsup": "^8.0.1",
80
+ "typescript": "^5.3.3"
82
81
  },
83
82
  "dependencies": {
84
- "@poppinss/utils": "^6.5.0"
83
+ "@poppinss/utils": "^6.7.0"
85
84
  },
86
85
  "peerDependencies": {
87
- "@adonisjs/core": "^6.1.5-28",
88
- "@adonisjs/redis": "^8.0.0-11",
89
- "@japa/api-client": "^2.0.0",
90
- "@japa/browser-client": "^2.0.0",
91
- "edge.js": "^6.0.0-8"
86
+ "@adonisjs/core": "^6.1.5-36",
87
+ "@adonisjs/redis": "^8.0.0-14",
88
+ "@japa/api-client": "^2.0.2",
89
+ "@japa/browser-client": "^2.0.2",
90
+ "edge.js": "^6.0.0"
92
91
  },
93
92
  "peerDependenciesMeta": {
94
93
  "@adonisjs/redis": {
@@ -148,5 +147,23 @@
148
147
  "factories/**",
149
148
  "bin/**"
150
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/plugins/edge.ts",
158
+ "./src/plugins/japa/api_client.ts",
159
+ "./src/plugins/japa/browser_client.ts",
160
+ "./src/client.ts"
161
+ ],
162
+ "outDir": "./build",
163
+ "clean": true,
164
+ "format": "esm",
165
+ "dts": false,
166
+ "sourcemap": true,
167
+ "target": "esnext"
151
168
  }
152
169
  }
@@ -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', '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,48 +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 { Emitter } from '@adonisjs/core/events';
10
- import { AppFactory } from '@adonisjs/core/factories/app';
11
- import { defineConfig } from '../index.js';
12
- import SessionMiddleware from '../src/session_middleware.js';
13
- /**
14
- * Exposes the API to create an instance of the session middleware
15
- * without additional plumbing
16
- */
17
- export class SessionMiddlewareFactory {
18
- #config = {
19
- store: 'memory',
20
- stores: {},
21
- };
22
- #emitter;
23
- #getApp() {
24
- return new AppFactory().create(new URL('./', import.meta.url), () => { });
25
- }
26
- #getEmitter() {
27
- return this.#emitter || new Emitter(this.#getApp());
28
- }
29
- /**
30
- * Merge custom options
31
- */
32
- merge(options) {
33
- if (options.config) {
34
- this.#config = options.config;
35
- }
36
- if (options.emitter) {
37
- this.#emitter = options.emitter;
38
- }
39
- return this;
40
- }
41
- /**
42
- * Creates an instance of the session middleware
43
- */
44
- async create() {
45
- const config = await defineConfig(this.#config).resolver(this.#getApp());
46
- return new SessionMiddleware(config, this.#getEmitter());
47
- }
48
- }
@@ -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,105 +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
- /// <reference types="@adonisjs/redis/redis_provider" />
10
- import string from '@poppinss/utils/string';
11
- import { configProvider } from '@adonisjs/core';
12
- import { InvalidArgumentsException } from '@poppinss/utils';
13
- import debug from './debug.js';
14
- import { MemoryStore } from './stores/memory.js';
15
- /**
16
- * Helper to normalize session config
17
- */
18
- export function defineConfig(config) {
19
- debug('processing session config %O', config);
20
- /**
21
- * Make sure a store is defined
22
- */
23
- if (!config.store) {
24
- throw new InvalidArgumentsException('Missing "store" property inside the session config');
25
- }
26
- /**
27
- * Destructuring config with the default values. We pull out
28
- * stores and cookie values, since we have to transform
29
- * them in the output value.
30
- */
31
- const { stores, cookie, ...rest } = {
32
- enabled: true,
33
- age: '2h',
34
- cookieName: 'adonis_session',
35
- clearWithBrowser: false,
36
- ...config,
37
- };
38
- const cookieOptions = { ...cookie };
39
- /**
40
- * Define maxAge property when session id cookie is
41
- * not a session cookie.
42
- */
43
- if (!rest.clearWithBrowser) {
44
- cookieOptions.maxAge = string.seconds.parse(rest.age);
45
- debug('computing maxAge "%s" for session id cookie', cookieOptions.maxAge);
46
- }
47
- return configProvider.create(async (app) => {
48
- const storesNames = Object.keys(config.stores);
49
- /**
50
- * List of stores with memory store always configured
51
- */
52
- const storesList = {
53
- memory: () => new MemoryStore(),
54
- };
55
- /**
56
- * Looping for stores and resolving them
57
- */
58
- for (let storeName of storesNames) {
59
- const store = config.stores[storeName];
60
- if (typeof store === 'function') {
61
- storesList[storeName] = store;
62
- }
63
- else {
64
- storesList[storeName] = await store.resolver(app);
65
- }
66
- }
67
- const transformedConfig = {
68
- ...rest,
69
- cookie: cookieOptions,
70
- stores: storesList,
71
- };
72
- debug('transformed session config %O', transformedConfig);
73
- return transformedConfig;
74
- });
75
- }
76
- /**
77
- * Inbuilt stores to store the session data.
78
- */
79
- export const stores = {
80
- file: (config) => {
81
- return configProvider.create(async () => {
82
- const { FileStore } = await import('./stores/file.js');
83
- return (_, sessionConfig) => {
84
- return new FileStore(config, sessionConfig.age);
85
- };
86
- });
87
- },
88
- redis: (config) => {
89
- return configProvider.create(async (app) => {
90
- const { RedisStore } = await import('./stores/redis.js');
91
- const redis = await app.container.make('redis');
92
- return (_, sessionConfig) => {
93
- return new RedisStore(redis.connection(config.connection), sessionConfig.age);
94
- };
95
- });
96
- },
97
- cookie: () => {
98
- return configProvider.create(async () => {
99
- const { CookieStore } = await import('./stores/cookie.js');
100
- return (ctx, sessionConfig) => {
101
- return new CookieStore(sessionConfig.cookie, ctx);
102
- };
103
- });
104
- },
105
- };
@@ -1,17 +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 { createError } from '@poppinss/utils';
10
- /**
11
- * Raised when session store is not mutable
12
- */
13
- export const E_SESSION_NOT_MUTABLE = createError('Session store is in readonly mode and cannot be mutated', 'E_SESSION_NOT_MUTABLE', 500);
14
- /**
15
- * Raised when session store has been initiated
16
- */
17
- export const E_SESSION_NOT_READY = createError('Session store has not been initiated. Make sure you have registered the session middleware', 'E_SESSION_NOT_READY', 500);