@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
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @adonisjs/redis
|
|
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 lodash from '@poppinss/utils/lodash';
|
|
10
|
-
import { RuntimeException } from '@poppinss/utils';
|
|
11
|
-
/**
|
|
12
|
-
* Readonly session store
|
|
13
|
-
*/
|
|
14
|
-
export class ReadOnlyValuesStore {
|
|
15
|
-
/**
|
|
16
|
-
* Underlying store values
|
|
17
|
-
*/
|
|
18
|
-
values;
|
|
19
|
-
/**
|
|
20
|
-
* Find if store is empty or not
|
|
21
|
-
*/
|
|
22
|
-
get isEmpty() {
|
|
23
|
-
return !this.values || Object.keys(this.values).length === 0;
|
|
24
|
-
}
|
|
25
|
-
constructor(values) {
|
|
26
|
-
this.values = values || {};
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Get value for a given key
|
|
30
|
-
*/
|
|
31
|
-
get(key, defaultValue) {
|
|
32
|
-
const value = lodash.get(this.values, key);
|
|
33
|
-
if (defaultValue !== undefined && (value === null || value === undefined)) {
|
|
34
|
-
return defaultValue;
|
|
35
|
-
}
|
|
36
|
-
return value;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* A boolean to know if value exists. Extra guards to check
|
|
40
|
-
* arrays for it's length as well.
|
|
41
|
-
*/
|
|
42
|
-
has(key, checkForArraysLength = true) {
|
|
43
|
-
const value = this.get(key);
|
|
44
|
-
if (!Array.isArray(value)) {
|
|
45
|
-
return !!value;
|
|
46
|
-
}
|
|
47
|
-
return checkForArraysLength ? value.length > 0 : !!value;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Get all values
|
|
51
|
-
*/
|
|
52
|
-
all() {
|
|
53
|
-
return this.values;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Returns object representation of values
|
|
57
|
-
*/
|
|
58
|
-
toObject() {
|
|
59
|
-
return this.all();
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Returns the store values
|
|
63
|
-
*/
|
|
64
|
-
toJSON() {
|
|
65
|
-
return this.all();
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Returns string representation of the store
|
|
69
|
-
*/
|
|
70
|
-
toString() {
|
|
71
|
-
return JSON.stringify(this.all());
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Session store encapsulates the session data and offers a
|
|
76
|
-
* declarative API to mutate it.
|
|
77
|
-
*/
|
|
78
|
-
export class ValuesStore extends ReadOnlyValuesStore {
|
|
79
|
-
/**
|
|
80
|
-
* A boolean to know if store has been
|
|
81
|
-
* modified
|
|
82
|
-
*/
|
|
83
|
-
#modified = false;
|
|
84
|
-
constructor(values) {
|
|
85
|
-
super(values);
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Find if the store has been modified.
|
|
89
|
-
*/
|
|
90
|
-
get hasBeenModified() {
|
|
91
|
-
return this.#modified;
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Set key/value pair
|
|
95
|
-
*/
|
|
96
|
-
set(key, value) {
|
|
97
|
-
this.#modified = true;
|
|
98
|
-
lodash.set(this.values, key, value);
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Remove key
|
|
102
|
-
*/
|
|
103
|
-
unset(key) {
|
|
104
|
-
this.#modified = true;
|
|
105
|
-
lodash.unset(this.values, key);
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Pull value from the store. It is same as calling
|
|
109
|
-
* store.get and then store.unset
|
|
110
|
-
*/
|
|
111
|
-
pull(key, defaultValue) {
|
|
112
|
-
return ((value) => {
|
|
113
|
-
this.unset(key);
|
|
114
|
-
return value;
|
|
115
|
-
})(this.get(key, defaultValue));
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Increment number. The method raises an error when
|
|
119
|
-
* nderlying value is not a number
|
|
120
|
-
*/
|
|
121
|
-
increment(key, steps = 1) {
|
|
122
|
-
const value = this.get(key, 0);
|
|
123
|
-
if (typeof value !== 'number') {
|
|
124
|
-
throw new RuntimeException(`Cannot increment "${key}". Existing value is not a number`);
|
|
125
|
-
}
|
|
126
|
-
this.set(key, value + steps);
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Increment number. The method raises an error when
|
|
130
|
-
* nderlying value is not a number
|
|
131
|
-
*/
|
|
132
|
-
decrement(key, steps = 1) {
|
|
133
|
-
const value = this.get(key, 0);
|
|
134
|
-
if (typeof value !== 'number') {
|
|
135
|
-
throw new RuntimeException(`Cannot decrement "${key}". Existing value is not a number`);
|
|
136
|
-
}
|
|
137
|
-
this.set(key, value - steps);
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* Overwrite existing store data with new values.
|
|
141
|
-
*/
|
|
142
|
-
update(values) {
|
|
143
|
-
this.#modified = true;
|
|
144
|
-
this.values = values;
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Update to merge values
|
|
148
|
-
*/
|
|
149
|
-
merge(values) {
|
|
150
|
-
this.#modified = true;
|
|
151
|
-
lodash.merge(this.values, values);
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* Reset store by clearing it's values.
|
|
155
|
-
*/
|
|
156
|
-
clear() {
|
|
157
|
-
this.update({});
|
|
158
|
-
}
|
|
159
|
-
}
|
package/build/stubs/main.js
DELETED
|
@@ -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 { getDirname } from '@poppinss/utils';
|
|
10
|
-
export const stubsRoot = getDirname(import.meta.url);
|