@adonisjs/session 7.0.0-1 → 7.0.0-11

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 (57) hide show
  1. package/README.md +5 -8
  2. package/build/configure.js +29 -2
  3. package/build/factories/main.d.ts +1 -0
  4. package/build/factories/main.js +9 -0
  5. package/build/factories/session_middleware_factory.d.ts +22 -0
  6. package/build/factories/session_middleware_factory.js +47 -0
  7. package/build/index.d.ts +5 -3
  8. package/build/index.js +5 -3
  9. package/build/providers/session_provider.d.ts +15 -4
  10. package/build/providers/session_provider.js +37 -20
  11. package/build/src/client.d.ts +23 -30
  12. package/build/src/client.js +46 -61
  13. package/build/src/debug.d.ts +3 -0
  14. package/build/src/debug.js +10 -0
  15. package/build/src/define_config.d.ts +6 -3
  16. package/build/src/define_config.js +34 -5
  17. package/build/src/drivers/cookie.d.ts +7 -9
  18. package/build/src/drivers/cookie.js +10 -6
  19. package/build/src/drivers/file.d.ts +11 -14
  20. package/build/src/drivers/file.js +90 -34
  21. package/build/src/drivers/memory.d.ts +4 -8
  22. package/build/src/drivers/memory.js +0 -3
  23. package/build/src/drivers/redis.d.ts +4 -6
  24. package/build/src/drivers/redis.js +25 -29
  25. package/build/src/drivers_collection.d.ts +21 -0
  26. package/build/src/drivers_collection.js +38 -0
  27. package/build/src/errors.d.ts +8 -0
  28. package/build/src/errors.js +17 -0
  29. package/build/src/helpers.d.ts +6 -0
  30. package/build/src/helpers.js +43 -0
  31. package/build/src/plugins/edge.d.ts +6 -0
  32. package/build/src/plugins/edge.js +92 -0
  33. package/build/src/plugins/japa/api_client.d.ts +75 -0
  34. package/build/src/plugins/japa/api_client.js +145 -0
  35. package/build/src/plugins/japa/browser_client.d.ts +36 -0
  36. package/build/src/plugins/japa/browser_client.js +119 -0
  37. package/build/src/session.d.ts +86 -59
  38. package/build/src/session.js +235 -222
  39. package/build/src/session_middleware.d.ts +19 -2
  40. package/build/src/session_middleware.js +43 -4
  41. package/build/src/store.d.ts +48 -35
  42. package/build/src/store.js +85 -57
  43. package/build/src/types/extended.d.ts +19 -0
  44. package/build/src/types/main.d.ts +106 -0
  45. package/build/src/types/main.js +9 -0
  46. package/build/stubs/config.stub +28 -92
  47. package/package.json +49 -26
  48. package/build/src/bindings/api_client.d.ts +0 -2
  49. package/build/src/bindings/api_client.js +0 -135
  50. package/build/src/bindings/http_context.d.ts +0 -5
  51. package/build/src/bindings/http_context.js +0 -17
  52. package/build/src/bindings/types.d.ts +0 -77
  53. package/build/src/session_manager.d.ts +0 -38
  54. package/build/src/session_manager.js +0 -149
  55. package/build/src/types.d.ts +0 -61
  56. package/build/src/types.js +0 -1
  57. /package/build/src/{bindings/types.js → types/extended.js} +0 -0
package/README.md CHANGED
@@ -2,10 +2,10 @@
2
2
 
3
3
  <br />
4
4
 
5
- [![gh-workflow-image]][gh-workflow-url] [![npm-image]][npm-url] ![][typescript-image] [![license-image]][license-url] [![snyk-image]][snyk-url]
5
+ [![gh-workflow-image]][gh-workflow-url] [![npm-image]][npm-url] ![][typescript-image] [![license-image]][license-url]
6
6
 
7
7
  ## Introduction
8
- Add sessions to your AdonisJS application. Cookie, Redis, and File drivers are included out of the box.
8
+ Use sessions in your AdonisJS applications with a unified API to persist session data across different data-stores. Has inbuilt support for **cookie**, **files**, and **redis** drivers.
9
9
 
10
10
  ## Official Documentation
11
11
  The documentation is available on the [AdonisJS website](https://docs.adonisjs.com/guides/sessions)
@@ -19,10 +19,10 @@ We encourage you to read the [contribution guide](https://github.com/adonisjs/.g
19
19
  In order to ensure that the AdonisJS community is welcoming to all, please review and abide by the [Code of Conduct](https://github.com/adonisjs/.github/blob/main/docs/CODE_OF_CONDUCT.md).
20
20
 
21
21
  ## License
22
- AdonisJS ally is open-sourced software licensed under the [MIT license](LICENSE.md).
22
+ AdonisJS session is open-sourced software licensed under the [MIT license](LICENSE.md).
23
23
 
24
- [gh-workflow-image]: https://img.shields.io/github/actions/workflow/status/adonisjs/session/test.yml?style=for-the-badge
25
- [gh-workflow-url]: https://github.com/adonisjs/session/actions/workflows/test.yml "Github action"
24
+ [gh-workflow-image]: https://img.shields.io/github/actions/workflow/status/adonisjs/session/checks.yml?style=for-the-badge
25
+ [gh-workflow-url]: https://github.com/adonisjs/session/actions/workflows/checks.yml "Github action"
26
26
 
27
27
  [npm-image]: https://img.shields.io/npm/v/@adonisjs/session/latest.svg?style=for-the-badge&logo=npm
28
28
  [npm-url]: https://www.npmjs.com/package/@adonisjs/session/v/latest "npm"
@@ -31,6 +31,3 @@ AdonisJS ally is open-sourced software licensed under the [MIT license](LICENSE.
31
31
 
32
32
  [license-url]: LICENSE.md
33
33
  [license-image]: https://img.shields.io/github/license/adonisjs/session?style=for-the-badge
34
-
35
- [snyk-image]: https://img.shields.io/snyk/vulnerabilities/github/adonisjs/session?label=Snyk%20Vulnerabilities&style=for-the-badge
36
- [snyk-url]: https://snyk.io/test/github/adonisjs/session?targetFile=package.json "snyk"
@@ -10,9 +10,36 @@
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');
14
- await command.defineEnvVariables({ SESSION_DRIVER: 'cookie' });
15
- await command.updateRcFile((rcFile) => {
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) => {
16
43
  rcFile.addProvider('@adonisjs/session/session_provider');
17
44
  });
18
45
  }
@@ -0,0 +1 @@
1
+ export { SessionMiddlewareFactory } from './session_middleware_factory.js';
@@ -0,0 +1,9 @@
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
+ export { SessionMiddlewareFactory } from './session_middleware_factory.js';
@@ -0,0 +1,22 @@
1
+ import { Emitter } from '@adonisjs/core/events';
2
+ import { EventsList } from '@adonisjs/core/types';
3
+ import { SessionConfig } from '../src/types/main.js';
4
+ import SessionMiddleware from '../src/session_middleware.js';
5
+ /**
6
+ * Exposes the API to create an instance of the session middleware
7
+ * without additional plumbing
8
+ */
9
+ export declare class SessionMiddlewareFactory {
10
+ #private;
11
+ /**
12
+ * Merge custom options
13
+ */
14
+ merge(options: {
15
+ config?: Partial<SessionConfig>;
16
+ emitter?: Emitter<EventsList>;
17
+ }): this;
18
+ /**
19
+ * Creates an instance of the session middleware
20
+ */
21
+ create(): Promise<SessionMiddleware>;
22
+ }
@@ -0,0 +1,47 @@
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 { registerSessionDriver } from '../src/helpers.js';
13
+ import SessionMiddleware from '../src/session_middleware.js';
14
+ /**
15
+ * Exposes the API to create an instance of the session middleware
16
+ * without additional plumbing
17
+ */
18
+ export class SessionMiddlewareFactory {
19
+ #config = { driver: 'memory' };
20
+ #emitter;
21
+ #getApp() {
22
+ return new AppFactory().create(new URL('./', import.meta.url), () => { });
23
+ }
24
+ #getEmitter() {
25
+ return this.#emitter || new Emitter(this.#getApp());
26
+ }
27
+ /**
28
+ * Merge custom options
29
+ */
30
+ merge(options) {
31
+ if (options.config) {
32
+ this.#config = options.config;
33
+ }
34
+ if (options.emitter) {
35
+ this.#emitter = options.emitter;
36
+ }
37
+ return this;
38
+ }
39
+ /**
40
+ * Creates an instance of the session middleware
41
+ */
42
+ async create() {
43
+ const config = defineConfig(this.#config);
44
+ await registerSessionDriver(this.#getApp(), config.driver);
45
+ return new SessionMiddleware(config, this.#getEmitter());
46
+ }
47
+ }
package/build/index.d.ts CHANGED
@@ -6,7 +6,9 @@
6
6
  * For the full copyright and license information, please view the LICENSE
7
7
  * file that was distributed with this source code.
8
8
  */
9
- import './src/bindings/types.js';
10
- export { defineConfig } from './src/define_config.js';
11
- export { stubsRoot } from './stubs/main.js';
9
+ import './src/types/extended.js';
10
+ export * as errors from './src/errors.js';
12
11
  export { configure } from './configure.js';
12
+ export { stubsRoot } from './stubs/main.js';
13
+ export { defineConfig } from './src/define_config.js';
14
+ export { default as driversList } from './src/drivers_collection.js';
package/build/index.js CHANGED
@@ -6,7 +6,9 @@
6
6
  * For the full copyright and license information, please view the LICENSE
7
7
  * file that was distributed with this source code.
8
8
  */
9
- import './src/bindings/types.js';
10
- export { defineConfig } from './src/define_config.js';
11
- export { stubsRoot } from './stubs/main.js';
9
+ import './src/types/extended.js';
10
+ export * as errors from './src/errors.js';
12
11
  export { configure } from './configure.js';
12
+ export { stubsRoot } from './stubs/main.js';
13
+ export { defineConfig } from './src/define_config.js';
14
+ export { default as driversList } from './src/drivers_collection.js';
@@ -1,13 +1,24 @@
1
- import { ApplicationService } from '@adonisjs/core/types';
1
+ import type { Edge } from 'edge.js';
2
+ import type { ApplicationService } from '@adonisjs/core/types';
3
+ /**
4
+ * Session provider configures the session management inside an
5
+ * AdonisJS application
6
+ */
2
7
  export default class SessionProvider {
3
8
  protected app: ApplicationService;
4
9
  constructor(app: ApplicationService);
5
10
  /**
6
- * Register Session Manager in the container
11
+ * Returns edge when it's installed
7
12
  */
8
- register(): Promise<void>;
13
+ protected getEdge(): Promise<Edge | null>;
9
14
  /**
10
- * Register bindings
15
+ * Registering muddleware
16
+ */
17
+ register(): void;
18
+ /**
19
+ * Registering the active driver when middleware is used
20
+ * +
21
+ * Adding edge tags (if edge is installed)
11
22
  */
12
23
  boot(): Promise<void>;
13
24
  }
@@ -6,38 +6,55 @@
6
6
  * For the full copyright and license information, please view the LICENSE
7
7
  * file that was distributed with this source code.
8
8
  */
9
- import { extendHttpContext } from '../src/bindings/http_context.js';
10
- import { extendApiClient } from '../src/bindings/api_client.js';
9
+ import debug from '../src/debug.js';
10
+ import { registerSessionDriver } from '../src/helpers.js';
11
+ import SessionMiddleware from '../src/session_middleware.js';
12
+ /**
13
+ * Session provider configures the session management inside an
14
+ * AdonisJS application
15
+ */
11
16
  export default class SessionProvider {
12
17
  app;
13
18
  constructor(app) {
14
19
  this.app = app;
15
20
  }
16
21
  /**
17
- * Register Session Manager in the container
22
+ * Returns edge when it's installed
18
23
  */
19
- async register() {
20
- this.app.container.singleton('session', async () => {
21
- const { SessionManager } = await import('../src/session_manager.js');
22
- const encryption = await this.app.container.make('encryption');
23
- const redis = await this.app.container.make('redis').catch(() => undefined);
24
+ async getEdge() {
25
+ try {
26
+ const { default: edge } = await import('edge.js');
27
+ debug('Detected edge.js package. Adding session primitives to it');
28
+ return edge;
29
+ }
30
+ catch {
31
+ return null;
32
+ }
33
+ }
34
+ /**
35
+ * Registering muddleware
36
+ */
37
+ register() {
38
+ this.app.container.singleton(SessionMiddleware, async (resolver) => {
24
39
  const config = this.app.config.get('session', {});
25
- return new SessionManager(config, encryption, redis);
40
+ const emitter = await resolver.make('emitter');
41
+ return new SessionMiddleware(config, emitter);
26
42
  });
27
43
  }
28
44
  /**
29
- * Register bindings
45
+ * Registering the active driver when middleware is used
46
+ * +
47
+ * Adding edge tags (if edge is installed)
30
48
  */
31
49
  async boot() {
32
- const sessionManager = await this.app.container.make('session');
33
- /**
34
- * Add `session` getter to the HttpContext class
35
- */
36
- extendHttpContext(sessionManager);
37
- /**
38
- * Add some macros and getter to japa/api-client classes for
39
- * easier testing
40
- */
41
- extendApiClient(sessionManager);
50
+ this.app.container.resolving(SessionMiddleware, async () => {
51
+ const config = this.app.config.get('session');
52
+ await registerSessionDriver(this.app, config.driver);
53
+ });
54
+ const edge = await this.getEdge();
55
+ if (edge) {
56
+ const { edgePluginSession } = await import('../src/plugins/edge.js');
57
+ edge.use(edgePluginSession);
58
+ }
42
59
  }
43
60
  }
@@ -1,47 +1,40 @@
1
- import { Store } from './store.js';
2
- import type { SessionConfig, SessionDriverContract } from './types.js';
3
- import type { CookieClient } from '@adonisjs/core/http';
1
+ import type { SessionData, SessionDriverContract } from './types/main.js';
4
2
  /**
5
- * SessionClient exposes the API to set session data as a client
3
+ * Session client exposes the API to set session data as a client
6
4
  */
7
- export declare class SessionClient extends Store {
5
+ export declare class SessionClient {
8
6
  #private;
9
7
  /**
10
- * Each instance of client works on a single session id. Generate
11
- * multiple client instances for a different session id
8
+ * Session key for setting flash messages
9
+ */
10
+ flashKey: string;
11
+ /**
12
+ * Session to use when no explicit session id is
13
+ * defined
12
14
  */
13
15
  sessionId: string;
16
+ constructor(driver: SessionDriverContract);
14
17
  /**
15
- * Flash messages store. They are merged with the session data during
16
- * commit
18
+ * Merge session data
17
19
  */
18
- flashMessages: Store;
19
- constructor(config: SessionConfig, driver: SessionDriverContract, cookieClient: CookieClient, values: {
20
- [key: string]: any;
21
- } | null);
20
+ merge(values: SessionData): this;
22
21
  /**
23
- * Find if the sessions are enabled
22
+ * Merge flash messages
24
23
  */
25
- isEnabled(): boolean;
24
+ flash(values: SessionData): this;
26
25
  /**
27
- * Load session from the driver
26
+ * Commits data to the session store.
28
27
  */
29
- load(cookies: Record<string, any>): Promise<{
30
- session: any;
31
- flashMessages: any;
32
- }>;
28
+ commit(): Promise<void>;
33
29
  /**
34
- * Commits the session data to the session store and returns
35
- * the session id and cookie name for it to be accessible
36
- * by the server
30
+ * Destroys the session data with the store
37
31
  */
38
- commit(): Promise<{
39
- sessionId: string;
40
- signedSessionId: string;
41
- cookieName: string;
42
- }>;
32
+ destroy(sessionId?: string): Promise<void>;
43
33
  /**
44
- * Clear the session store
34
+ * Loads session data from the session store
45
35
  */
46
- forget(): Promise<void>;
36
+ load(sessionId?: string): Promise<{
37
+ values: any;
38
+ flashMessages: any;
39
+ }>;
47
40
  }
@@ -7,94 +7,79 @@
7
7
  * file that was distributed with this source code.
8
8
  */
9
9
  import { cuid } from '@adonisjs/core/helpers';
10
+ import debug from './debug.js';
10
11
  import { Store } from './store.js';
11
12
  /**
12
- * SessionClient exposes the API to set session data as a client
13
+ * Session client exposes the API to set session data as a client
13
14
  */
14
- export class SessionClient extends Store {
15
+ export class SessionClient {
15
16
  /**
16
- * Session configuration
17
+ * Data store
17
18
  */
18
- #config;
19
+ #store = new Store({});
19
20
  /**
20
- * The session driver used to read and write session data
21
+ * Flash messages store
21
22
  */
22
- #driver;
23
- /**
24
- * Cookie client contract to sign and unsign cookies
25
- */
26
- #cookieClient;
23
+ #flashMessagesStore = new Store({});
27
24
  /**
28
- * Each instance of client works on a single session id. Generate
29
- * multiple client instances for a different session id
25
+ * The session driver to use for reading and writing session data
30
26
  */
31
- sessionId = cuid();
27
+ #driver;
32
28
  /**
33
29
  * Session key for setting flash messages
34
30
  */
35
- #flashMessagesKey = '__flash__';
31
+ flashKey = '__flash__';
36
32
  /**
37
- * Flash messages store. They are merged with the session data during
38
- * commit
33
+ * Session to use when no explicit session id is
34
+ * defined
39
35
  */
40
- flashMessages = new Store({});
41
- constructor(config, driver, cookieClient, values) {
42
- super(values);
43
- this.#config = config;
36
+ sessionId = cuid();
37
+ constructor(driver) {
44
38
  this.#driver = driver;
45
- this.#cookieClient = cookieClient;
46
39
  }
47
40
  /**
48
- * Find if the sessions are enabled
41
+ * Merge session data
49
42
  */
50
- isEnabled() {
51
- return this.#config.enabled;
43
+ merge(values) {
44
+ this.#store.merge(values);
45
+ return this;
52
46
  }
53
47
  /**
54
- * Load session from the driver
48
+ * Merge flash messages
55
49
  */
56
- async load(cookies) {
57
- const sessionIdCookie = cookies[this.#config.cookieName];
58
- const sessionId = sessionIdCookie ? sessionIdCookie.value : this.sessionId;
59
- const contents = await this.#driver.read(sessionId);
60
- const store = new Store(contents);
61
- const flashMessages = store.pull(this.#flashMessagesKey, null);
62
- return {
63
- session: store.all(),
64
- flashMessages,
65
- };
50
+ flash(values) {
51
+ this.#flashMessagesStore.merge(values);
52
+ return this;
66
53
  }
67
54
  /**
68
- * Commits the session data to the session store and returns
69
- * the session id and cookie name for it to be accessible
70
- * by the server
55
+ * Commits data to the session store.
71
56
  */
72
57
  async commit() {
73
- this.set(this.#flashMessagesKey, this.flashMessages.all());
74
- await this.#driver.write(this.sessionId, this.toJSON());
75
- /**
76
- * Clear from the session client memory
77
- */
78
- this.clear();
79
- this.flashMessages.clear();
80
- return {
81
- sessionId: this.sessionId,
82
- signedSessionId: this.#cookieClient.sign(this.#config.cookieName, this.sessionId),
83
- cookieName: this.#config.cookieName,
84
- };
58
+ if (!this.#flashMessagesStore.isEmpty) {
59
+ this.#store.set(this.flashKey, this.#flashMessagesStore.toJSON());
60
+ }
61
+ debug('committing session data during api request');
62
+ if (!this.#store.isEmpty) {
63
+ this.#driver.write(this.sessionId, this.#store.toJSON());
64
+ }
65
+ }
66
+ /**
67
+ * Destroys the session data with the store
68
+ */
69
+ async destroy(sessionId) {
70
+ debug('destroying session data during api request');
71
+ this.#driver.destroy(sessionId || this.sessionId);
85
72
  }
86
73
  /**
87
- * Clear the session store
74
+ * Loads session data from the session store
88
75
  */
89
- async forget() {
90
- /**
91
- * Clear from the session client memory
92
- */
93
- this.clear();
94
- this.flashMessages.clear();
95
- /**
96
- * Clear with the driver
97
- */
98
- await this.#driver.destroy(this.sessionId);
76
+ async load(sessionId) {
77
+ const contents = await this.#driver.read(sessionId || this.sessionId);
78
+ const store = new Store(contents);
79
+ const flashMessages = store.pull(this.flashKey, {});
80
+ return {
81
+ values: store.all(),
82
+ flashMessages,
83
+ };
99
84
  }
100
85
  }
@@ -0,0 +1,3 @@
1
+ /// <reference types="@types/node" resolution-mode="require"/>
2
+ declare const _default: import("util").DebugLogger;
3
+ export default _default;
@@ -0,0 +1,10 @@
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,5 +1,8 @@
1
- import { SessionConfig } from './types.js';
1
+ import type { CookieOptions } from '@adonisjs/core/types/http';
2
+ import type { SessionConfig } from './types/main.js';
2
3
  /**
3
- * Helper to define session config
4
+ * Helper to normalize session config
4
5
  */
5
- export declare function defineConfig(config: SessionConfig): SessionConfig;
6
+ export declare function defineConfig(config: Partial<SessionConfig>): SessionConfig & {
7
+ cookie: Partial<CookieOptions>;
8
+ };
@@ -1,13 +1,42 @@
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';
1
10
  import { InvalidArgumentsException } from '@poppinss/utils';
11
+ import debug from './debug.js';
2
12
  /**
3
- * Helper to define session config
13
+ * Helper to normalize session config
4
14
  */
5
15
  export function defineConfig(config) {
6
- if (!config.cookieName) {
7
- throw new InvalidArgumentsException('Missing "cookieName" property inside the session config');
8
- }
16
+ /**
17
+ * Make sure a driver is defined
18
+ */
9
19
  if (!config.driver) {
10
20
  throw new InvalidArgumentsException('Missing "driver" property inside the session config');
11
21
  }
12
- return config;
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
+ };
13
42
  }
@@ -1,23 +1,21 @@
1
1
  import type { HttpContext } from '@adonisjs/core/http';
2
- import type { SessionConfig, SessionDriverContract } from '../types.js';
2
+ import { CookieOptions } from '@adonisjs/core/types/http';
3
+ import type { SessionData, SessionDriverContract } from '../types/main.js';
3
4
  /**
4
- * Cookie driver utilizes the encrypted HTTP cookies to write session value.
5
+ * Cookie driver stores the session data inside an encrypted
6
+ * cookie.
5
7
  */
6
8
  export declare class CookieDriver implements SessionDriverContract {
7
9
  #private;
8
- constructor(config: SessionConfig, ctx: HttpContext);
10
+ constructor(config: Partial<CookieOptions>, ctx: HttpContext);
9
11
  /**
10
12
  * Read session value from the cookie
11
13
  */
12
- read(sessionId: string): {
13
- [key: string]: any;
14
- } | null;
14
+ read(sessionId: string): SessionData | null;
15
15
  /**
16
16
  * Write session values to the cookie
17
17
  */
18
- write(sessionId: string, values: {
19
- [key: string]: any;
20
- }): void;
18
+ write(sessionId: string, values: SessionData): void;
21
19
  /**
22
20
  * Removes the session cookie
23
21
  */