@adonisjs/session 7.0.0-13 → 7.0.0-14
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/chunk-2X5L327N.js +28 -0
- package/build/chunk-2X5L327N.js.map +1 -0
- package/build/chunk-4TGV4EVQ.js +85 -0
- package/build/chunk-4TGV4EVQ.js.map +1 -0
- package/build/chunk-C6BYE7BG.js +390 -0
- package/build/chunk-C6BYE7BG.js.map +1 -0
- package/build/chunk-KM6IRYLY.js +151 -0
- package/build/chunk-KM6IRYLY.js.map +1 -0
- package/build/chunk-QH2GQQKL.js +134 -0
- package/build/chunk-QH2GQQKL.js.map +1 -0
- package/build/chunk-WBAYBMJJ.js +15 -0
- package/build/chunk-WBAYBMJJ.js.map +1 -0
- package/build/{stubs/config.stub → config.stub} +3 -1
- package/build/cookie-H7KRZB4T.js +56 -0
- package/build/cookie-H7KRZB4T.js.map +1 -0
- package/build/factories/main.js +50 -9
- package/build/factories/main.js.map +1 -0
- package/build/file-YO7C2QWO.js +112 -0
- package/build/file-YO7C2QWO.js.map +1 -0
- package/build/index.js +18 -12
- package/build/index.js.map +1 -0
- package/build/providers/session_provider.js +51 -59
- package/build/providers/session_provider.js.map +1 -0
- package/build/redis-KDWIBKUQ.js +58 -0
- package/build/redis-KDWIBKUQ.js.map +1 -0
- package/build/src/client.js +9 -85
- package/build/src/client.js.map +1 -0
- package/build/src/plugins/edge.js +71 -91
- package/build/src/plugins/edge.js.map +1 -0
- package/build/src/plugins/japa/api_client.js +99 -140
- package/build/src/plugins/japa/api_client.js.map +1 -0
- package/build/src/plugins/japa/browser_client.js +82 -109
- package/build/src/plugins/japa/browser_client.js.map +1 -0
- package/build/src/session_middleware.js +10 -58
- package/build/src/session_middleware.js.map +1 -0
- package/package.json +58 -41
- package/build/configure.js +0 -45
- package/build/factories/session_middleware_factory.js +0 -48
- package/build/src/debug.js +0 -10
- package/build/src/define_config.js +0 -105
- package/build/src/errors.js +0 -17
- package/build/src/session.js +0 -387
- package/build/src/stores/cookie.js +0 -60
- package/build/src/stores/file.js +0 -133
- package/build/src/stores/memory.js +0 -33
- package/build/src/stores/redis.js +0 -66
- package/build/src/types.js +0 -9
- package/build/src/values_store.js +0 -159
- package/build/stubs/main.js +0 -10
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__export
|
|
3
|
+
} from "./chunk-WBAYBMJJ.js";
|
|
4
|
+
|
|
5
|
+
// src/errors.ts
|
|
6
|
+
var errors_exports = {};
|
|
7
|
+
__export(errors_exports, {
|
|
8
|
+
E_SESSION_NOT_MUTABLE: () => E_SESSION_NOT_MUTABLE,
|
|
9
|
+
E_SESSION_NOT_READY: () => E_SESSION_NOT_READY
|
|
10
|
+
});
|
|
11
|
+
import { createError } from "@poppinss/utils";
|
|
12
|
+
var E_SESSION_NOT_MUTABLE = createError(
|
|
13
|
+
"Session store is in readonly mode and cannot be mutated",
|
|
14
|
+
"E_SESSION_NOT_MUTABLE",
|
|
15
|
+
500
|
|
16
|
+
);
|
|
17
|
+
var E_SESSION_NOT_READY = createError(
|
|
18
|
+
"Session store has not been initiated. Make sure you have registered the session middleware",
|
|
19
|
+
"E_SESSION_NOT_READY",
|
|
20
|
+
500
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
export {
|
|
24
|
+
E_SESSION_NOT_MUTABLE,
|
|
25
|
+
E_SESSION_NOT_READY,
|
|
26
|
+
errors_exports
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=chunk-2X5L327N.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/errors.ts"],"sourcesContent":["/*\n * @adonisjs/session\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport { createError } from '@poppinss/utils'\n\n/**\n * Raised when session store is not mutable\n */\nexport const E_SESSION_NOT_MUTABLE = createError(\n 'Session store is in readonly mode and cannot be mutated',\n 'E_SESSION_NOT_MUTABLE',\n 500\n)\n\n/**\n * Raised when session store has been initiated\n */\nexport const E_SESSION_NOT_READY = createError(\n 'Session store has not been initiated. Make sure you have registered the session middleware',\n 'E_SESSION_NOT_READY',\n 500\n)\n"],"mappings":";;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,SAAS,mBAAmB;AAKrB,IAAM,wBAAwB;AAAA,EACnC;AAAA,EACA;AAAA,EACA;AACF;AAKO,IAAM,sBAAsB;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AACF;","names":[]}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ValuesStore
|
|
3
|
+
} from "./chunk-KM6IRYLY.js";
|
|
4
|
+
import {
|
|
5
|
+
debug_default
|
|
6
|
+
} from "./chunk-WBAYBMJJ.js";
|
|
7
|
+
|
|
8
|
+
// src/client.ts
|
|
9
|
+
import { cuid } from "@adonisjs/core/helpers";
|
|
10
|
+
var SessionClient = class {
|
|
11
|
+
/**
|
|
12
|
+
* Data store
|
|
13
|
+
*/
|
|
14
|
+
#valuesStore = new ValuesStore({});
|
|
15
|
+
/**
|
|
16
|
+
* Flash messages store
|
|
17
|
+
*/
|
|
18
|
+
#flashMessagesStore = new ValuesStore({});
|
|
19
|
+
/**
|
|
20
|
+
* The session store to use for reading and writing session data
|
|
21
|
+
*/
|
|
22
|
+
#store;
|
|
23
|
+
/**
|
|
24
|
+
* Session key for setting flash messages
|
|
25
|
+
*/
|
|
26
|
+
flashKey = "__flash__";
|
|
27
|
+
/**
|
|
28
|
+
* Session to use when no explicit session id is
|
|
29
|
+
* defined
|
|
30
|
+
*/
|
|
31
|
+
sessionId = cuid();
|
|
32
|
+
constructor(store) {
|
|
33
|
+
this.#store = store;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Merge session data
|
|
37
|
+
*/
|
|
38
|
+
merge(values) {
|
|
39
|
+
this.#valuesStore.merge(values);
|
|
40
|
+
return this;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Merge flash messages
|
|
44
|
+
*/
|
|
45
|
+
flash(values) {
|
|
46
|
+
this.#flashMessagesStore.merge(values);
|
|
47
|
+
return this;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Commits data to the session store.
|
|
51
|
+
*/
|
|
52
|
+
async commit() {
|
|
53
|
+
if (!this.#flashMessagesStore.isEmpty) {
|
|
54
|
+
this.#valuesStore.set(this.flashKey, this.#flashMessagesStore.toJSON());
|
|
55
|
+
}
|
|
56
|
+
debug_default("committing session data during api request");
|
|
57
|
+
if (!this.#valuesStore.isEmpty) {
|
|
58
|
+
this.#store.write(this.sessionId, this.#valuesStore.toJSON());
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Destroys the session data with the store
|
|
63
|
+
*/
|
|
64
|
+
async destroy(sessionId) {
|
|
65
|
+
debug_default("destroying session data during api request");
|
|
66
|
+
this.#store.destroy(sessionId || this.sessionId);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Loads session data from the session store
|
|
70
|
+
*/
|
|
71
|
+
async load(sessionId) {
|
|
72
|
+
const contents = await this.#store.read(sessionId || this.sessionId);
|
|
73
|
+
const store = new ValuesStore(contents);
|
|
74
|
+
const flashMessages = store.pull(this.flashKey, {});
|
|
75
|
+
return {
|
|
76
|
+
values: store.all(),
|
|
77
|
+
flashMessages
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export {
|
|
83
|
+
SessionClient
|
|
84
|
+
};
|
|
85
|
+
//# sourceMappingURL=chunk-4TGV4EVQ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/client.ts"],"sourcesContent":["/*\n * @adonisjs/session\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport { cuid } from '@adonisjs/core/helpers'\n\nimport debug from './debug.js'\nimport { ValuesStore } from './values_store.js'\nimport type { SessionData, SessionStoreContract } from './types.js'\n\n/**\n * Session client exposes the API to set session data as a client\n */\nexport class SessionClient {\n /**\n * Data store\n */\n #valuesStore = new ValuesStore({})\n\n /**\n * Flash messages store\n */\n #flashMessagesStore = new ValuesStore({})\n\n /**\n * The session store to use for reading and writing session data\n */\n #store: SessionStoreContract\n\n /**\n * Session key for setting flash messages\n */\n flashKey = '__flash__'\n\n /**\n * Session to use when no explicit session id is\n * defined\n */\n sessionId = cuid()\n\n constructor(store: SessionStoreContract) {\n this.#store = store\n }\n\n /**\n * Merge session data\n */\n merge(values: SessionData) {\n this.#valuesStore.merge(values)\n return this\n }\n\n /**\n * Merge flash messages\n */\n flash(values: SessionData) {\n this.#flashMessagesStore.merge(values)\n return this\n }\n\n /**\n * Commits data to the session store.\n */\n async commit() {\n if (!this.#flashMessagesStore.isEmpty) {\n this.#valuesStore.set(this.flashKey, this.#flashMessagesStore.toJSON())\n }\n\n debug('committing session data during api request')\n if (!this.#valuesStore.isEmpty) {\n this.#store.write(this.sessionId, this.#valuesStore.toJSON())\n }\n }\n\n /**\n * Destroys the session data with the store\n */\n async destroy(sessionId?: string) {\n debug('destroying session data during api request')\n this.#store.destroy(sessionId || this.sessionId)\n }\n\n /**\n * Loads session data from the session store\n */\n async load(sessionId?: string) {\n const contents = await this.#store.read(sessionId || this.sessionId)\n const store = new ValuesStore(contents)\n const flashMessages = store.pull(this.flashKey, {})\n\n return {\n values: store.all(),\n flashMessages,\n }\n }\n}\n"],"mappings":";;;;;;;;AASA,SAAS,YAAY;AASd,IAAM,gBAAN,MAAoB;AAAA;AAAA;AAAA;AAAA,EAIzB,eAAe,IAAI,YAAY,CAAC,CAAC;AAAA;AAAA;AAAA;AAAA,EAKjC,sBAAsB,IAAI,YAAY,CAAC,CAAC;AAAA;AAAA;AAAA;AAAA,EAKxC;AAAA;AAAA;AAAA;AAAA,EAKA,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA,EA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
9
|
+
import {
|
|
10
|
+
debug_default
|
|
11
|
+
} from "./chunk-WBAYBMJJ.js";
|
|
12
|
+
|
|
13
|
+
// src/session_middleware.ts
|
|
14
|
+
import { ExceptionHandler } from "@adonisjs/core/http";
|
|
15
|
+
|
|
16
|
+
// src/session.ts
|
|
17
|
+
import lodash from "@poppinss/utils/lodash";
|
|
18
|
+
import { cuid } from "@adonisjs/core/helpers";
|
|
19
|
+
var Session = class {
|
|
20
|
+
#config;
|
|
21
|
+
#store;
|
|
22
|
+
#emitter;
|
|
23
|
+
#ctx;
|
|
24
|
+
#readonly = false;
|
|
25
|
+
/**
|
|
26
|
+
* Session values store
|
|
27
|
+
*/
|
|
28
|
+
#valuesStore;
|
|
29
|
+
/**
|
|
30
|
+
* Session id refers to the session id that will be committed
|
|
31
|
+
* as a cookie during the response.
|
|
32
|
+
*/
|
|
33
|
+
#sessionId;
|
|
34
|
+
/**
|
|
35
|
+
* Session id from cookie refers to the value we read from the
|
|
36
|
+
* cookie during the HTTP request.
|
|
37
|
+
*
|
|
38
|
+
* This only might not exist during the first request. Also during
|
|
39
|
+
* session id re-generation, this value will be different from
|
|
40
|
+
* the session id.
|
|
41
|
+
*/
|
|
42
|
+
#sessionIdFromCookie;
|
|
43
|
+
/**
|
|
44
|
+
* Store of flash messages that be written during the
|
|
45
|
+
* HTTP request
|
|
46
|
+
*/
|
|
47
|
+
responseFlashMessages = new ValuesStore({});
|
|
48
|
+
/**
|
|
49
|
+
* Store of flash messages for the current HTTP request.
|
|
50
|
+
*/
|
|
51
|
+
flashMessages = new ValuesStore({});
|
|
52
|
+
/**
|
|
53
|
+
* The key to use for storing flash messages inside
|
|
54
|
+
* the session store.
|
|
55
|
+
*/
|
|
56
|
+
flashKey = "__flash__";
|
|
57
|
+
/**
|
|
58
|
+
* Session id for the current HTTP request
|
|
59
|
+
*/
|
|
60
|
+
get sessionId() {
|
|
61
|
+
return this.#sessionId;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* A boolean to know if a fresh session is created during
|
|
65
|
+
* the request
|
|
66
|
+
*/
|
|
67
|
+
get fresh() {
|
|
68
|
+
return this.#sessionIdFromCookie === void 0;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* A boolean to know if session is in readonly
|
|
72
|
+
* state
|
|
73
|
+
*/
|
|
74
|
+
get readonly() {
|
|
75
|
+
return this.#readonly;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* A boolean to know if session store has been initiated
|
|
79
|
+
*/
|
|
80
|
+
get initiated() {
|
|
81
|
+
return !!this.#valuesStore;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* A boolean to know if the session id has been re-generated
|
|
85
|
+
* during the current request
|
|
86
|
+
*/
|
|
87
|
+
get hasRegeneratedSession() {
|
|
88
|
+
return !!(this.#sessionIdFromCookie && this.#sessionIdFromCookie !== this.#sessionId);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* A boolean to know if the session store is empty
|
|
92
|
+
*/
|
|
93
|
+
get isEmpty() {
|
|
94
|
+
return this.#valuesStore?.isEmpty ?? true;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* A boolean to know if the session store has been
|
|
98
|
+
* modified
|
|
99
|
+
*/
|
|
100
|
+
get hasBeenModified() {
|
|
101
|
+
return this.#valuesStore?.hasBeenModified ?? false;
|
|
102
|
+
}
|
|
103
|
+
constructor(config, storeFactory, emitter, ctx) {
|
|
104
|
+
this.#ctx = ctx;
|
|
105
|
+
this.#config = config;
|
|
106
|
+
this.#emitter = emitter;
|
|
107
|
+
this.#store = storeFactory(ctx, config);
|
|
108
|
+
this.#sessionIdFromCookie = ctx.request.cookie(config.cookieName, void 0);
|
|
109
|
+
this.#sessionId = this.#sessionIdFromCookie || cuid();
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Returns the flash messages store for a given
|
|
113
|
+
* mode
|
|
114
|
+
*/
|
|
115
|
+
#getFlashStore(mode) {
|
|
116
|
+
if (!this.#valuesStore) {
|
|
117
|
+
throw new E_SESSION_NOT_READY();
|
|
118
|
+
}
|
|
119
|
+
if (mode === "write" && this.readonly) {
|
|
120
|
+
throw new E_SESSION_NOT_MUTABLE();
|
|
121
|
+
}
|
|
122
|
+
return this.responseFlashMessages;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Returns the store instance for a given mode
|
|
126
|
+
*/
|
|
127
|
+
#getValuesStore(mode) {
|
|
128
|
+
if (!this.#valuesStore) {
|
|
129
|
+
throw new E_SESSION_NOT_READY();
|
|
130
|
+
}
|
|
131
|
+
if (mode === "write" && this.readonly) {
|
|
132
|
+
throw new E_SESSION_NOT_MUTABLE();
|
|
133
|
+
}
|
|
134
|
+
return this.#valuesStore;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Initiates the session store. The method results in a noop
|
|
138
|
+
* when called multiple times
|
|
139
|
+
*/
|
|
140
|
+
async initiate(readonly) {
|
|
141
|
+
if (this.#valuesStore) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
debug_default("initiating session (readonly: %s)", readonly);
|
|
145
|
+
this.#readonly = readonly;
|
|
146
|
+
const contents = await this.#store.read(this.#sessionId);
|
|
147
|
+
this.#valuesStore = new ValuesStore(contents);
|
|
148
|
+
if (this.has(this.flashKey)) {
|
|
149
|
+
debug_default("reading flash data");
|
|
150
|
+
if (this.#readonly) {
|
|
151
|
+
this.flashMessages.update(this.get(this.flashKey, null));
|
|
152
|
+
} else {
|
|
153
|
+
this.flashMessages.update(this.pull(this.flashKey, null));
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
if ("view" in this.#ctx) {
|
|
157
|
+
this.#ctx.view.share({
|
|
158
|
+
session: new ReadOnlyValuesStore(this.#valuesStore.all()),
|
|
159
|
+
flashMessages: new ReadOnlyValuesStore(this.flashMessages.all()),
|
|
160
|
+
old: function(key, defaultValue) {
|
|
161
|
+
return this.flashMessages.get(key, defaultValue);
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
this.#emitter.emit("session:initiated", { session: this });
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Put a key-value pair to the session data store
|
|
169
|
+
*/
|
|
170
|
+
put(key, value) {
|
|
171
|
+
this.#getValuesStore("write").set(key, value);
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Check if a key exists inside the datastore
|
|
175
|
+
*/
|
|
176
|
+
has(key) {
|
|
177
|
+
return this.#getValuesStore("read").has(key);
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Get the value of a key from the session datastore.
|
|
181
|
+
* You can specify a default value to use, when key
|
|
182
|
+
* does not exists or has undefined value.
|
|
183
|
+
*/
|
|
184
|
+
get(key, defaultValue) {
|
|
185
|
+
return this.#getValuesStore("read").get(key, defaultValue);
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Get everything from the session store
|
|
189
|
+
*/
|
|
190
|
+
all() {
|
|
191
|
+
return this.#getValuesStore("read").all();
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Remove a key from the session datastore
|
|
195
|
+
*/
|
|
196
|
+
forget(key) {
|
|
197
|
+
return this.#getValuesStore("write").unset(key);
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Read value for a key from the session datastore
|
|
201
|
+
* and remove it simultaneously.
|
|
202
|
+
*/
|
|
203
|
+
pull(key, defaultValue) {
|
|
204
|
+
return this.#getValuesStore("write").pull(key, defaultValue);
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Increment the value of a key inside the session
|
|
208
|
+
* store.
|
|
209
|
+
*
|
|
210
|
+
* A new key will be defined if does not exists already.
|
|
211
|
+
* The value of a new key will be 1
|
|
212
|
+
*/
|
|
213
|
+
increment(key, steps = 1) {
|
|
214
|
+
return this.#getValuesStore("write").increment(key, steps);
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Increment the value of a key inside the session
|
|
218
|
+
* store.
|
|
219
|
+
*
|
|
220
|
+
* A new key will be defined if does not exists already.
|
|
221
|
+
* The value of a new key will be -1
|
|
222
|
+
*/
|
|
223
|
+
decrement(key, steps = 1) {
|
|
224
|
+
return this.#getValuesStore("write").decrement(key, steps);
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Empty the session store
|
|
228
|
+
*/
|
|
229
|
+
clear() {
|
|
230
|
+
return this.#getValuesStore("write").clear();
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Flash validation error messages. Make sure the error
|
|
234
|
+
* is an instance of VineJS ValidationException
|
|
235
|
+
*/
|
|
236
|
+
flashValidationErrors(error) {
|
|
237
|
+
const errorsBag = error.messages.reduce((result, message) => {
|
|
238
|
+
if (result[message.field]) {
|
|
239
|
+
result[message.field].push(message.message);
|
|
240
|
+
} else {
|
|
241
|
+
result[message.field] = [message.message];
|
|
242
|
+
}
|
|
243
|
+
return result;
|
|
244
|
+
}, {});
|
|
245
|
+
this.flashExcept(["_csrf", "_method"]);
|
|
246
|
+
this.flash("errors", errorsBag);
|
|
247
|
+
}
|
|
248
|
+
flash(key, value) {
|
|
249
|
+
if (typeof key === "string") {
|
|
250
|
+
if (value) {
|
|
251
|
+
this.#getFlashStore("write").set(key, value);
|
|
252
|
+
}
|
|
253
|
+
} else {
|
|
254
|
+
this.#getFlashStore("write").merge(key);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Flash form input data to the flash messages store
|
|
259
|
+
*/
|
|
260
|
+
flashAll() {
|
|
261
|
+
return this.#getFlashStore("write").set("input", this.#ctx.request.original());
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Flash form input data (except some keys) to the flash messages store
|
|
265
|
+
*/
|
|
266
|
+
flashExcept(keys) {
|
|
267
|
+
this.#getFlashStore("write").set("input", lodash.omit(this.#ctx.request.original(), keys));
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Flash form input data (only some keys) to the flash messages store
|
|
271
|
+
*/
|
|
272
|
+
flashOnly(keys) {
|
|
273
|
+
this.#getFlashStore("write").set("input", lodash.pick(this.#ctx.request.original(), keys));
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Reflash messages from the last request in the current response
|
|
277
|
+
*/
|
|
278
|
+
reflash() {
|
|
279
|
+
this.#getFlashStore("write").set("reflashed", this.flashMessages.all());
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Reflash messages (only some keys) from the last
|
|
283
|
+
* request in the current response
|
|
284
|
+
*/
|
|
285
|
+
reflashOnly(keys) {
|
|
286
|
+
this.#getFlashStore("write").set("reflashed", lodash.pick(this.flashMessages.all(), keys));
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Reflash messages (except some keys) from the last
|
|
290
|
+
* request in the current response
|
|
291
|
+
*/
|
|
292
|
+
reflashExcept(keys) {
|
|
293
|
+
this.#getFlashStore("write").set("reflashed", lodash.omit(this.flashMessages.all(), keys));
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Re-generate the session id and migrate data to it.
|
|
297
|
+
*/
|
|
298
|
+
regenerate() {
|
|
299
|
+
this.#sessionId = cuid();
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Commit session changes. No more mutations will be
|
|
303
|
+
* allowed after commit.
|
|
304
|
+
*/
|
|
305
|
+
async commit() {
|
|
306
|
+
if (!this.#valuesStore || this.readonly) {
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
if (!this.responseFlashMessages.isEmpty) {
|
|
310
|
+
const { input, reflashed, ...others } = this.responseFlashMessages.all();
|
|
311
|
+
this.put(this.flashKey, { ...reflashed, ...input, ...others });
|
|
312
|
+
}
|
|
313
|
+
debug_default("committing session data");
|
|
314
|
+
this.#ctx.response.cookie(this.#config.cookieName, this.#sessionId, this.#config.cookie);
|
|
315
|
+
if (this.isEmpty) {
|
|
316
|
+
if (this.#sessionIdFromCookie) {
|
|
317
|
+
await this.#store.destroy(this.#sessionIdFromCookie);
|
|
318
|
+
}
|
|
319
|
+
this.#emitter.emit("session:committed", { session: this });
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
if (!this.hasBeenModified) {
|
|
323
|
+
if (this.#sessionIdFromCookie && this.#sessionIdFromCookie !== this.#sessionId) {
|
|
324
|
+
await this.#store.destroy(this.#sessionIdFromCookie);
|
|
325
|
+
await this.#store.write(this.#sessionId, this.#valuesStore.toJSON());
|
|
326
|
+
this.#emitter.emit("session:migrated", {
|
|
327
|
+
fromSessionId: this.#sessionIdFromCookie,
|
|
328
|
+
toSessionId: this.sessionId,
|
|
329
|
+
session: this
|
|
330
|
+
});
|
|
331
|
+
} else {
|
|
332
|
+
await this.#store.touch(this.#sessionId);
|
|
333
|
+
}
|
|
334
|
+
this.#emitter.emit("session:committed", { session: this });
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
if (this.#sessionIdFromCookie && this.#sessionIdFromCookie !== this.#sessionId) {
|
|
338
|
+
await this.#store.destroy(this.#sessionIdFromCookie);
|
|
339
|
+
await this.#store.write(this.#sessionId, this.#valuesStore.toJSON());
|
|
340
|
+
this.#emitter.emit("session:migrated", {
|
|
341
|
+
fromSessionId: this.#sessionIdFromCookie,
|
|
342
|
+
toSessionId: this.sessionId,
|
|
343
|
+
session: this
|
|
344
|
+
});
|
|
345
|
+
} else {
|
|
346
|
+
await this.#store.write(this.#sessionId, this.#valuesStore.toJSON());
|
|
347
|
+
}
|
|
348
|
+
this.#emitter.emit("session:committed", { session: this });
|
|
349
|
+
}
|
|
350
|
+
};
|
|
351
|
+
|
|
352
|
+
// src/session_middleware.ts
|
|
353
|
+
var originalErrorHandler = ExceptionHandler.prototype.renderValidationErrorAsHTML;
|
|
354
|
+
ExceptionHandler.macro("renderValidationErrorAsHTML", async function(error, ctx) {
|
|
355
|
+
if (ctx.session) {
|
|
356
|
+
ctx.session.flashValidationErrors(error);
|
|
357
|
+
ctx.response.redirect("back", true);
|
|
358
|
+
} else {
|
|
359
|
+
return originalErrorHandler(error, ctx);
|
|
360
|
+
}
|
|
361
|
+
});
|
|
362
|
+
var SessionMiddleware = class {
|
|
363
|
+
#config;
|
|
364
|
+
#emitter;
|
|
365
|
+
constructor(config, emitter) {
|
|
366
|
+
this.#config = config;
|
|
367
|
+
this.#emitter = emitter;
|
|
368
|
+
}
|
|
369
|
+
async handle(ctx, next) {
|
|
370
|
+
if (!this.#config.enabled) {
|
|
371
|
+
return next();
|
|
372
|
+
}
|
|
373
|
+
ctx.session = new Session(
|
|
374
|
+
this.#config,
|
|
375
|
+
this.#config.stores[this.#config.store],
|
|
376
|
+
// reference to store factory
|
|
377
|
+
this.#emitter,
|
|
378
|
+
ctx
|
|
379
|
+
);
|
|
380
|
+
await ctx.session.initiate(false);
|
|
381
|
+
const response = await next();
|
|
382
|
+
await ctx.session.commit();
|
|
383
|
+
return response;
|
|
384
|
+
}
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
export {
|
|
388
|
+
SessionMiddleware
|
|
389
|
+
};
|
|
390
|
+
//# sourceMappingURL=chunk-C6BYE7BG.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/session_middleware.ts","../src/session.ts"],"sourcesContent":["/*\n * @adonisjs/session\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport { EmitterService } from '@adonisjs/core/types'\nimport type { NextFn } from '@adonisjs/core/types/http'\nimport { ExceptionHandler, HttpContext } from '@adonisjs/core/http'\n\nimport { Session } from './session.js'\nimport type { SessionConfig, SessionStoreFactory } from './types.js'\n\n/**\n * HttpContext augmentations\n */\ndeclare module '@adonisjs/core/http' {\n export interface HttpContext {\n session: Session\n }\n}\n\n/**\n * Overwriting validation exception renderer\n */\nconst originalErrorHandler = ExceptionHandler.prototype.renderValidationErrorAsHTML\nExceptionHandler.macro('renderValidationErrorAsHTML', async function (error, ctx) {\n if (ctx.session) {\n ctx.session.flashValidationErrors(error)\n ctx.response.redirect('back', true)\n } else {\n return originalErrorHandler(error, ctx)\n }\n})\n\n/**\n * Session middleware is used to initiate the session store\n * and commit its values during an HTTP request\n */\nexport default class SessionMiddleware<KnownStores extends Record<string, SessionStoreFactory>> {\n #config: SessionConfig & {\n store: keyof KnownStores\n stores: KnownStores\n }\n #emitter: EmitterService\n\n constructor(\n config: SessionConfig & {\n store: keyof KnownStores\n stores: KnownStores\n },\n emitter: EmitterService\n ) {\n this.#config = config\n this.#emitter = emitter\n }\n\n async handle(ctx: HttpContext, next: NextFn) {\n if (!this.#config.enabled) {\n return next()\n }\n\n ctx.session = new Session(\n this.#config,\n this.#config.stores[this.#config.store], // reference to store factory\n this.#emitter,\n ctx\n )\n\n /**\n * Initiate session store\n */\n await ctx.session.initiate(false)\n\n /**\n * Call next middlewares or route handler\n */\n const response = await next()\n\n /**\n * Commit store mutations\n */\n await ctx.session.commit()\n\n /**\n * Return response\n */\n return response\n }\n}\n","/*\n * @adonisjs/session\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport lodash from '@poppinss/utils/lodash'\nimport { cuid } from '@adonisjs/core/helpers'\nimport type { HttpContext } from '@adonisjs/core/http'\nimport type { EmitterService } from '@adonisjs/core/types'\nimport type { HttpError } from '@adonisjs/core/types/http'\n\nimport debug from './debug.js'\nimport * as errors from './errors.js'\nimport { ReadOnlyValuesStore, ValuesStore } from './values_store.js'\nimport type {\n SessionData,\n SessionConfig,\n SessionStoreFactory,\n AllowedSessionValues,\n SessionStoreContract,\n} from './types.js'\n\n/**\n * The session class exposes the API to read and write values to\n * the session store.\n *\n * A session instance is isolated between requests but\n * uses a centralized persistence store and\n */\nexport class Session {\n #config: SessionConfig\n #store: SessionStoreContract\n #emitter: EmitterService\n #ctx: HttpContext\n #readonly: boolean = false\n\n /**\n * Session values store\n */\n #valuesStore?: ValuesStore\n\n /**\n * Session id refers to the session id that will be committed\n * as a cookie during the response.\n */\n #sessionId: string\n\n /**\n * Session id from cookie refers to the value we read from the\n * cookie during the HTTP request.\n *\n * This only might not exist during the first request. Also during\n * session id re-generation, this value will be different from\n * the session id.\n */\n #sessionIdFromCookie?: string\n\n /**\n * Store of flash messages that be written during the\n * HTTP request\n */\n responseFlashMessages = new ValuesStore({})\n\n /**\n * Store of flash messages for the current HTTP request.\n */\n flashMessages = new ValuesStore({})\n\n /**\n * The key to use for storing flash messages inside\n * the session store.\n */\n flashKey: string = '__flash__'\n\n /**\n * Session id for the current HTTP request\n */\n get sessionId() {\n return this.#sessionId\n }\n\n /**\n * A boolean to know if a fresh session is created during\n * the request\n */\n get fresh(): boolean {\n return this.#sessionIdFromCookie === undefined\n }\n\n /**\n * A boolean to know if session is in readonly\n * state\n */\n get readonly() {\n return this.#readonly\n }\n\n /**\n * A boolean to know if session store has been initiated\n */\n get initiated() {\n return !!this.#valuesStore\n }\n\n /**\n * A boolean to know if the session id has been re-generated\n * during the current request\n */\n get hasRegeneratedSession() {\n return !!(this.#sessionIdFromCookie && this.#sessionIdFromCookie !== this.#sessionId)\n }\n\n /**\n * A boolean to know if the session store is empty\n */\n get isEmpty() {\n return this.#valuesStore?.isEmpty ?? true\n }\n\n /**\n * A boolean to know if the session store has been\n * modified\n */\n get hasBeenModified() {\n return this.#valuesStore?.hasBeenModified ?? false\n }\n\n constructor(\n config: SessionConfig,\n storeFactory: SessionStoreFactory,\n emitter: EmitterService,\n ctx: HttpContext\n ) {\n this.#ctx = ctx\n this.#config = config\n this.#emitter = emitter\n this.#store = storeFactory(ctx, config)\n this.#sessionIdFromCookie = ctx.request.cookie(config.cookieName, undefined)\n this.#sessionId = this.#sessionIdFromCookie || cuid()\n }\n\n /**\n * Returns the flash messages store for a given\n * mode\n */\n #getFlashStore(mode: 'write' | 'read'): ValuesStore {\n if (!this.#valuesStore) {\n throw new errors.E_SESSION_NOT_READY()\n }\n\n if (mode === 'write' && this.readonly) {\n throw new errors.E_SESSION_NOT_MUTABLE()\n }\n\n return this.responseFlashMessages\n }\n\n /**\n * Returns the store instance for a given mode\n */\n #getValuesStore(mode: 'write' | 'read'): ValuesStore {\n if (!this.#valuesStore) {\n throw new errors.E_SESSION_NOT_READY()\n }\n\n if (mode === 'write' && this.readonly) {\n throw new errors.E_SESSION_NOT_MUTABLE()\n }\n\n return this.#valuesStore\n }\n\n /**\n * Initiates the session store. The method results in a noop\n * when called multiple times\n */\n async initiate(readonly: boolean): Promise<void> {\n if (this.#valuesStore) {\n return\n }\n\n debug('initiating session (readonly: %s)', readonly)\n\n this.#readonly = readonly\n const contents = await this.#store.read(this.#sessionId)\n this.#valuesStore = new ValuesStore(contents)\n\n /**\n * Extract flash messages from the store and keep a local\n * copy of it.\n */\n if (this.has(this.flashKey)) {\n debug('reading flash data')\n if (this.#readonly) {\n this.flashMessages.update(this.get(this.flashKey, null))\n } else {\n this.flashMessages.update(this.pull(this.flashKey, null))\n }\n }\n\n /**\n * Share session with the templates. We assume the view property\n * is a reference to edge templates\n */\n if ('view' in this.#ctx) {\n this.#ctx.view.share({\n session: new ReadOnlyValuesStore(this.#valuesStore.all()),\n flashMessages: new ReadOnlyValuesStore(this.flashMessages.all()),\n old: function (key: string, defaultValue?: any) {\n return this.flashMessages.get(key, defaultValue)\n },\n })\n }\n\n this.#emitter.emit('session:initiated', { session: this })\n }\n\n /**\n * Put a key-value pair to the session data store\n */\n put(key: string, value: AllowedSessionValues) {\n this.#getValuesStore('write').set(key, value)\n }\n\n /**\n * Check if a key exists inside the datastore\n */\n has(key: string): boolean {\n return this.#getValuesStore('read').has(key)\n }\n\n /**\n * Get the value of a key from the session datastore.\n * You can specify a default value to use, when key\n * does not exists or has undefined value.\n */\n get(key: string, defaultValue?: any) {\n return this.#getValuesStore('read').get(key, defaultValue)\n }\n\n /**\n * Get everything from the session store\n */\n all() {\n return this.#getValuesStore('read').all()\n }\n\n /**\n * Remove a key from the session datastore\n */\n forget(key: string) {\n return this.#getValuesStore('write').unset(key)\n }\n\n /**\n * Read value for a key from the session datastore\n * and remove it simultaneously.\n */\n pull(key: string, defaultValue?: any) {\n return this.#getValuesStore('write').pull(key, defaultValue)\n }\n\n /**\n * Increment the value of a key inside the session\n * store.\n *\n * A new key will be defined if does not exists already.\n * The value of a new key will be 1\n */\n increment(key: string, steps: number = 1) {\n return this.#getValuesStore('write').increment(key, steps)\n }\n\n /**\n * Increment the value of a key inside the session\n * store.\n *\n * A new key will be defined if does not exists already.\n * The value of a new key will be -1\n */\n decrement(key: string, steps: number = 1) {\n return this.#getValuesStore('write').decrement(key, steps)\n }\n\n /**\n * Empty the session store\n */\n clear() {\n return this.#getValuesStore('write').clear()\n }\n\n /**\n * Flash validation error messages. Make sure the error\n * is an instance of VineJS ValidationException\n */\n flashValidationErrors(error: HttpError) {\n const errorsBag = error.messages.reduce((result: Record<string, string[]>, message: any) => {\n if (result[message.field]) {\n result[message.field].push(message.message)\n } else {\n result[message.field] = [message.message]\n }\n return result\n }, {})\n\n this.flashExcept(['_csrf', '_method'])\n this.flash('errors', errorsBag)\n }\n\n /**\n * Add a key-value pair to flash messages\n */\n flash(key: string, value: AllowedSessionValues): void\n flash(keyValue: SessionData): void\n flash(key: string | SessionData, value?: AllowedSessionValues): void {\n if (typeof key === 'string') {\n if (value) {\n this.#getFlashStore('write').set(key, value)\n }\n } else {\n this.#getFlashStore('write').merge(key)\n }\n }\n\n /**\n * Flash form input data to the flash messages store\n */\n flashAll() {\n return this.#getFlashStore('write').set('input', this.#ctx.request.original())\n }\n\n /**\n * Flash form input data (except some keys) to the flash messages store\n */\n flashExcept(keys: string[]): void {\n this.#getFlashStore('write').set('input', lodash.omit(this.#ctx.request.original(), keys))\n }\n\n /**\n * Flash form input data (only some keys) to the flash messages store\n */\n flashOnly(keys: string[]): void {\n this.#getFlashStore('write').set('input', lodash.pick(this.#ctx.request.original(), keys))\n }\n\n /**\n * Reflash messages from the last request in the current response\n */\n reflash(): void {\n this.#getFlashStore('write').set('reflashed', this.flashMessages.all())\n }\n\n /**\n * Reflash messages (only some keys) from the last\n * request in the current response\n */\n reflashOnly(keys: string[]) {\n this.#getFlashStore('write').set('reflashed', lodash.pick(this.flashMessages.all(), keys))\n }\n\n /**\n * Reflash messages (except some keys) from the last\n * request in the current response\n */\n reflashExcept(keys: string[]) {\n this.#getFlashStore('write').set('reflashed', lodash.omit(this.flashMessages.all(), keys))\n }\n\n /**\n * Re-generate the session id and migrate data to it.\n */\n regenerate() {\n this.#sessionId = cuid()\n }\n\n /**\n * Commit session changes. No more mutations will be\n * allowed after commit.\n */\n async commit() {\n if (!this.#valuesStore || this.readonly) {\n return\n }\n\n /**\n * If the flash messages store is not empty, we should put\n * its messages inside main session store.\n */\n if (!this.responseFlashMessages.isEmpty) {\n const { input, reflashed, ...others } = this.responseFlashMessages.all()\n this.put(this.flashKey, { ...reflashed, ...input, ...others })\n }\n\n debug('committing session data')\n\n /**\n * Touch the session id cookie to stay alive\n */\n this.#ctx.response.cookie(this.#config.cookieName, this.#sessionId, this.#config.cookie!)\n\n /**\n * Delete the session data when the session store\n * is empty.\n *\n * Also we only destroy the session id we read from the cookie.\n * If there was no session id in the cookie, there won't be\n * any data inside the store either.\n */\n if (this.isEmpty) {\n if (this.#sessionIdFromCookie) {\n await this.#store.destroy(this.#sessionIdFromCookie)\n }\n this.#emitter.emit('session:committed', { session: this })\n return\n }\n\n /**\n * Touch the store expiry when the session store was\n * not modified.\n */\n if (!this.hasBeenModified) {\n if (this.#sessionIdFromCookie && this.#sessionIdFromCookie !== this.#sessionId) {\n await this.#store.destroy(this.#sessionIdFromCookie)\n await this.#store.write(this.#sessionId, this.#valuesStore.toJSON())\n this.#emitter.emit('session:migrated', {\n fromSessionId: this.#sessionIdFromCookie,\n toSessionId: this.sessionId,\n session: this,\n })\n } else {\n await this.#store.touch(this.#sessionId)\n }\n this.#emitter.emit('session:committed', { session: this })\n return\n }\n\n /**\n * Otherwise commit to the session store\n */\n if (this.#sessionIdFromCookie && this.#sessionIdFromCookie !== this.#sessionId) {\n await this.#store.destroy(this.#sessionIdFromCookie)\n await this.#store.write(this.#sessionId, this.#valuesStore.toJSON())\n this.#emitter.emit('session:migrated', {\n fromSessionId: this.#sessionIdFromCookie,\n toSessionId: this.sessionId,\n session: this,\n })\n } else {\n await this.#store.write(this.#sessionId, this.#valuesStore.toJSON())\n }\n\n this.#emitter.emit('session:committed', { session: this })\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAWA,SAAS,wBAAqC;;;ACF9C,OAAO,YAAY;AACnB,SAAS,YAAY;AAuBd,IAAM,UAAN,MAAc;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAqB;AAAA;AAAA;AAAA;AAAA,EAKrB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,wBAAwB,IAAI,YAAY,CAAC,CAAC;AAAA;AAAA;AAAA;AAAA,EAK1C,gBAAgB,IAAI,YAAY,CAAC,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMlC,WAAmB;AAAA;AAAA;AAAA;AAAA,EAKnB,IAAI,YAAY;AACd,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,IAAI,QAAiB;AACnB,WAAO,KAAK,yBAAyB;AAAA,EACvC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,IAAI,WAAW;AACb,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,YAAY;AACd,WAAO,CAAC,CAAC,KAAK;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,IAAI,wBAAwB;AAC1B,WAAO,CAAC,EAAE,KAAK,wBAAwB,KAAK,yBAAyB,KAAK;AAAA,EAC5E;AAAA;AAAA;AAAA;AA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