@dnax/core 0.2.9 → 0.2.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.
- package/app/hono.ts +13 -4
- package/package.json +1 -1
- package/utils/index.ts +1 -1
package/app/hono.ts
CHANGED
|
@@ -41,22 +41,31 @@ function HonoInstance(): typeof app {
|
|
|
41
41
|
var { decode, valid, error } = jwt.verify(token);
|
|
42
42
|
c.set("_STUDIO_SECRET_KEY_", secretKeyStudio);
|
|
43
43
|
c.set("isStudio", isStudio(secretKeyStudio));
|
|
44
|
-
|
|
44
|
+
let _v = {
|
|
45
45
|
token: token || null,
|
|
46
46
|
ip:
|
|
47
47
|
c.req.raw.headers?.get("CF-Connecting-IP") ||
|
|
48
48
|
c.req.raw.headers?.get("x-forwarded-for") ||
|
|
49
49
|
c.req.raw.headers?.get("x-real-ip"),
|
|
50
50
|
isAuth: valid ? true : false,
|
|
51
|
-
}
|
|
51
|
+
};
|
|
52
|
+
c.set("_v", _v);
|
|
52
53
|
c.set("tenant-id", c.req.header()["tenant-id"]);
|
|
53
54
|
if (token && valid) {
|
|
54
55
|
session.set({
|
|
55
56
|
state: decode?.state || {},
|
|
56
57
|
access: decode?.access || {},
|
|
57
|
-
_v:
|
|
58
|
+
_v: { ...(_v || {}) },
|
|
58
59
|
token: token,
|
|
59
60
|
});
|
|
61
|
+
} else {
|
|
62
|
+
// no valid token
|
|
63
|
+
session.set({
|
|
64
|
+
state: {},
|
|
65
|
+
access: {},
|
|
66
|
+
_v: { ...(_v || {}) },
|
|
67
|
+
token: null,
|
|
68
|
+
});
|
|
60
69
|
}
|
|
61
70
|
|
|
62
71
|
// If token wrong or break
|
|
@@ -171,7 +180,7 @@ function HonoInstance(): typeof app {
|
|
|
171
180
|
token: c.var["token"] || null,
|
|
172
181
|
action: action,
|
|
173
182
|
c: c,
|
|
174
|
-
isAuth: false,
|
|
183
|
+
isAuth: c.var?._v?.isAuth || false,
|
|
175
184
|
rest: new useRest({ tenant_id: tenant_id }),
|
|
176
185
|
session: sessionStorage(),
|
|
177
186
|
});
|
package/package.json
CHANGED