@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 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
- await localSession
97
- .get(decode?.sessionId)
98
- .then((data) => {
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 = {
@@ -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
- token: input?.token || null,
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
- if (input?.generateToken) {
70
- localSession.set(input?.id, data);
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dnax/core",
3
- "version": "0.16.5",
3
+ "version": "0.16.7",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "bin": {
package/types/index.ts CHANGED
@@ -60,6 +60,7 @@ export type Field = {
60
60
  | "ipv4"
61
61
  | "ipv6"
62
62
  | "url"
63
+ | "markdown"
63
64
  | "date"
64
65
  | "datetime-local"
65
66
  | "email"
package/utils/index.ts CHANGED
@@ -59,7 +59,7 @@ const jwt = {
59
59
  ) => {
60
60
  // console.log("payload", payload, options);
61
61
 
62
- return jwto.sign({ sessionId: payload }, JWT_SECRET, {
62
+ return jwto.sign({ session: payload }, JWT_SECRET, {
63
63
  ...options,
64
64
  });
65
65
  },