corebasic 1.0.136 → 1.0.137

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.
Files changed (2) hide show
  1. package/libs/session.js +6 -1
  2. package/package.json +1 -1
package/libs/session.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import jwt from 'jsonwebtoken'
2
2
  import * as Privilege from './privileges.js'
3
+ import * as Utils from './utils.js'
3
4
  let app
4
5
 
5
6
 
@@ -66,9 +67,13 @@ export const start = (expressApp, allowedUrls) => {
66
67
  export const generateAccessToken = (userId, clientId) => {
67
68
  let data = { userId, clientId }
68
69
 
70
+ let now = Utils.now()
71
+ let accessTokenExpiry = new Date(now); accessTokenExpiry.setDate(accessTokenExpiry.getDate() + 1); accessTokenExpiry = accessTokenExpiry.getTime()
72
+ let refreshTokenExpiry = new Date(now); refreshTokenExpiry.setDate(refreshTokenExpiry.getDate() + 30); refreshTokenExpiry = refreshTokenExpiry.getTime()
73
+
69
74
  const accessToken = jwt.sign(data, ACCESS_TOKEN_SECRET, { expiresIn: '1d' });
70
75
  const refreshToken = jwt.sign(data, REFRESH_TOKEN_SECRET, { expiresIn: '30d' });
71
- return { accessToken, refreshToken };
76
+ return { accessToken, refreshToken, accessTokenExpiry, refreshTokenExpiry };
72
77
  }
73
78
 
74
79
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "corebasic",
3
3
  "type": "module",
4
- "version": "1.0.136",
4
+ "version": "1.0.137",
5
5
  "description": "",
6
6
  "main": "index.js",
7
7
  "scripts": {