corebasic 1.0.169 → 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.
Files changed (2) hide show
  1. package/libs/auth.js +4 -2
  2. 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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "corebasic",
3
3
  "type": "module",
4
- "version": "1.0.169",
4
+ "version": "1.0.170",
5
5
  "description": "",
6
6
  "main": "index.js",
7
7
  "scripts": {