@metaadri/secureauth 1.2.0 → 1.2.1

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/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.2.0",
6
+ "version": "1.2.1",
7
7
  "description": "SecureAuth CLI - Add enterprise authentication to any Express app in one command",
8
8
  "bin": {
9
9
  "secureauth": "bin/cli.js"
package/src/scaffolder.js CHANGED
@@ -30,6 +30,7 @@ const LOCKOUT_CHECK_CODE = `
30
30
 
31
31
  const LOCKOUT_INCREMENT_CODE = `
32
32
  const failedAttempts = await userModel.incrementFailedAttempts(user.id);
33
+ const remaining = MAX_FAILED_ATTEMPTS - failedAttempts;
33
34
  `;
34
35
 
35
36
  const LOCKOUT_TRIGGER_CODE = `
@@ -111,8 +111,13 @@ module.exports = {
111
111
  db: {
112
112
  query: (text, params) => {
113
113
  const stmt = db.prepare(text);
114
- const rows = params ? stmt.all(...params) : stmt.all();
115
- return { rows };
114
+ const sql = text.trim().toUpperCase();
115
+ if (sql.startsWith('SELECT')) {
116
+ const rows = params ? stmt.all(...params) : stmt.all();
117
+ return { rows };
118
+ }
119
+ const info = params ? stmt.run(...params) : stmt.run();
120
+ return { rows: [], changes: info.changes };
116
121
  }
117
122
  }
118
123
  };
@@ -8,7 +8,6 @@ const loginLimiter = createRateLimiter(5, 15);
8
8
 
9
9
  router.post('/register', authController.register);
10
10
  router.post('/login', loginLimiter, authController.loginStep1);
11
- router.post('/demo/login', authController.demoLogin);
12
11
  router.post('/verify-2fa', loginLimiter, authController.verifyTOTP);
13
12
  router.get('/dashboard', checkAndRefreshToken, authController.getDashboard);
14
13
  router.get('/login-history', checkAndRefreshToken, authController.getLoginHistory);
@@ -1,7 +1,7 @@
1
- require('dotenv').config();
1
+ const path = require('path');
2
+ require('dotenv').config({ path: path.join(__dirname, '.env') });
2
3
  const express = require('express');
3
4
  const cors = require('cors');
4
- const path = require('path');
5
5
  const helmet = require('helmet');
6
6
 
7
7
  const authRoutes = require('./routes/authRoutes');
@@ -62,16 +62,15 @@ app.get('/', (req, res) => {
62
62
 
63
63
  let dbReady = false;
64
64
 
65
- initDatabase()
66
- .then(async () => {
67
- await seedAdminUser();
68
- await seedDemoUser();
69
- dbReady = true;
70
- console.log('Database initialized and seeded');
71
- })
72
- .catch(err => {
73
- console.error('Database initialization failed:', err.message);
74
- });
65
+ try {
66
+ initDatabase();
67
+ seedAdminUser();
68
+ seedDemoUser();
69
+ dbReady = true;
70
+ console.log('Database initialized and seeded');
71
+ } catch (err) {
72
+ console.error('Database initialization failed:', err.message);
73
+ }
75
74
 
76
75
  app.use((req, res, next) => {
77
76
  if (dbReady) return next();