corebasic 1.0.168 → 1.0.170
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/libs/auth.js +4 -2
- package/libs/session.js +1 -1
- package/package.json +1 -1
package/libs/auth.js
CHANGED
|
@@ -56,7 +56,7 @@ async function attemptLogin(req, res) {
|
|
|
56
56
|
throw {...errMessage, mode: 'verify', info: "Invalid/Expired OTP"}
|
|
57
57
|
} else { // generate login
|
|
58
58
|
let otp = mob === '0123456789' ? '1234' : otpGenerator.generate(4, { upperCaseAlphabets: false, specialChars: false, digital: true, lowerCaseAlphabets: false });
|
|
59
|
-
if (mob === '0123456789' || await sendOtp(mob, otp, req.body.app)) {
|
|
59
|
+
if (mob === '0123456789' || await sendOtp(mob, otp, req.body.app, req.body.hash)) {
|
|
60
60
|
let userId = req.body.userId ?? Utils.uid()
|
|
61
61
|
let now = Utils.now().getTime()
|
|
62
62
|
let data = req.body.data ?? {}
|
|
@@ -70,8 +70,10 @@ async function attemptLogin(req, res) {
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
|
|
73
|
-
async function sendOtp(mob, otp, app) {
|
|
73
|
+
async function sendOtp(mob, otp, app, hash) {
|
|
74
74
|
try {
|
|
75
|
+
if (app && hash)
|
|
76
|
+
app = encodeURIComponent(`${app} (#${hash})`) // Of the form '<app> (#<hash>)' for better readability
|
|
75
77
|
let api = process.env.SMS_API.replace(':phone', mob).replace(':otp', otp).replace(':app', app ?? 'app')
|
|
76
78
|
await axios.get(api)
|
|
77
79
|
return true
|
package/libs/session.js
CHANGED
|
@@ -81,7 +81,7 @@ export const generateAccessToken = (userId, clientId) => {
|
|
|
81
81
|
let refreshTokenExpiry = new Date(now); refreshTokenExpiry.setDate(refreshTokenExpiry.getDate() + 30); refreshTokenExpiry = refreshTokenExpiry.getTime()
|
|
82
82
|
|
|
83
83
|
const accessToken = jwt.sign(data, ACCESS_TOKEN_SECRET, { expiresIn: '1d' });
|
|
84
|
-
const refreshToken = jwt.sign(data, REFRESH_TOKEN_SECRET, { expiresIn: '
|
|
84
|
+
const refreshToken = jwt.sign(data, REFRESH_TOKEN_SECRET, { expiresIn: '365d' });
|
|
85
85
|
return { accessToken, refreshToken, accessTokenExpiry, refreshTokenExpiry };
|
|
86
86
|
}
|
|
87
87
|
|