@dnax/core 0.16.5 → 0.16.7
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/app/hono.ts +4 -8
- package/lib/asyncLocalStorage.ts +22 -16
- package/lib/schema.ts +1 -1
- package/package.json +1 -1
- package/types/index.ts +1 -0
- package/utils/index.ts +1 -1
package/app/hono.ts
CHANGED
|
@@ -92,14 +92,10 @@ function HonoInstance(): typeof app {
|
|
|
92
92
|
var token = jwt.getToken("Bearer", c.req.header()["authorization"]) || "";
|
|
93
93
|
var { decode, valid, error } = jwt.verify(token);
|
|
94
94
|
let sessionData = {};
|
|
95
|
-
if (valid && decode) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
//console.log("Data", data);
|
|
100
|
-
sessionData = data;
|
|
101
|
-
})
|
|
102
|
-
.catch();
|
|
95
|
+
if (valid && decode && decode?.session) {
|
|
96
|
+
sessionData = decode?.session;
|
|
97
|
+
} else {
|
|
98
|
+
// console.log("No valid token", error);
|
|
103
99
|
}
|
|
104
100
|
|
|
105
101
|
let _v = {
|
package/lib/asyncLocalStorage.ts
CHANGED
|
@@ -39,26 +39,15 @@ const sessionStorage = () => ({
|
|
|
39
39
|
id: "",
|
|
40
40
|
state: {},
|
|
41
41
|
_v: {},
|
|
42
|
-
generateToken: true,
|
|
43
42
|
}
|
|
44
43
|
): any {
|
|
45
|
-
input.generateToken = input?.generateToken ?? true;
|
|
46
44
|
let store = asyncLocalStorage.getStore() as InstanceType<typeof Map>;
|
|
47
45
|
if (!input?.id) {
|
|
48
46
|
input.id = v4();
|
|
49
47
|
}
|
|
50
48
|
|
|
51
|
-
if (input?.generateToken) {
|
|
52
|
-
input.token =
|
|
53
|
-
input.token ||
|
|
54
|
-
jwt.sign(input.id, {
|
|
55
|
-
expiresIn: input?.expiresIn || "7d",
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
|
|
59
49
|
let data = {
|
|
60
|
-
|
|
61
|
-
state: input?.state,
|
|
50
|
+
state: input?.state || {},
|
|
62
51
|
role: input?.role || null,
|
|
63
52
|
_v: {
|
|
64
53
|
...(input?._v || {}),
|
|
@@ -66,11 +55,28 @@ const sessionStorage = () => ({
|
|
|
66
55
|
},
|
|
67
56
|
};
|
|
68
57
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
58
|
+
input.token =
|
|
59
|
+
input.token ||
|
|
60
|
+
jwt.sign(
|
|
61
|
+
{
|
|
62
|
+
id: input.id,
|
|
63
|
+
state: input?.state,
|
|
64
|
+
role: input?.role || null,
|
|
65
|
+
_v: {
|
|
66
|
+
...(input?._v || {}),
|
|
67
|
+
setAt: new Date().toString(),
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
expiresIn: input?.expiresIn || "7d",
|
|
72
|
+
}
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
store.set(key, {
|
|
76
|
+
...data,
|
|
77
|
+
token: input.token,
|
|
78
|
+
});
|
|
72
79
|
|
|
73
|
-
store.set(key, data);
|
|
74
80
|
return {
|
|
75
81
|
state: input.state,
|
|
76
82
|
_v: input._v,
|
package/lib/schema.ts
CHANGED
|
@@ -33,7 +33,7 @@ function buildSchema(col: Collection) {
|
|
|
33
33
|
propertySchema[f.name] = v.string().optional();
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
if (f?.type.match(/(string|richText|textarea)/)) {
|
|
36
|
+
if (f?.type.match(/(string|richText|textarea|markdown)/)) {
|
|
37
37
|
propertySchema[f.name] = v.string();
|
|
38
38
|
}
|
|
39
39
|
|
package/package.json
CHANGED
package/types/index.ts
CHANGED