@naisys/erp 3.0.0-beta.35 → 3.0.0-beta.37

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.
@@ -83,7 +83,7 @@ var LlmModelSchema = object({
83
83
  outputCost: number().default(0),
84
84
  cacheWriteCost: number().optional(),
85
85
  cacheReadCost: number().optional(),
86
- cacheTtlSeconds: number().int().positive().optional(),
86
+ cacheTtlSeconds: number().int().min(300).optional(),
87
87
  supportsVision: boolean().optional(),
88
88
  supportsHearing: boolean().optional(),
89
89
  supportsComputerUse: boolean().optional()
@@ -127,7 +127,7 @@ object({
127
127
  outputCost: number().default(0),
128
128
  cacheWriteCost: number().optional(),
129
129
  cacheReadCost: number().optional(),
130
- cacheTtlSeconds: number().int().positive().optional(),
130
+ cacheTtlSeconds: number().int().min(300).optional(),
131
131
  supportsVision: boolean().optional(),
132
132
  supportsHearing: boolean().optional(),
133
133
  supportsComputerUse: boolean().optional()
Binary file
Binary file
Binary file
@@ -4,6 +4,18 @@
4
4
  <meta charset="UTF-8" />
5
5
 
6
6
  <link rel="icon" type="image/x-icon" href="/erp/favicon.ico" />
7
+ <link
8
+ rel="icon"
9
+ type="image/png"
10
+ sizes="32x32"
11
+ href="/erp/favicon-32x32.png"
12
+ />
13
+ <link
14
+ rel="icon"
15
+ type="image/png"
16
+ sizes="16x16"
17
+ href="/erp/favicon-16x16.png"
18
+ />
7
19
  <link
8
20
  rel="apple-touch-icon"
9
21
  sizes="180x180"
@@ -33,7 +45,7 @@
33
45
  <meta name="format-detection" content="telephone=no" />
34
46
 
35
47
  <title>NAISYS ERP</title>
36
- <script type="module" crossorigin src="/erp/assets/index-D3fO2pbt.js"></script>
48
+ <script type="module" crossorigin src="/erp/assets/index-jH5OYerq.js"></script>
37
49
  <link rel="modulepreload" crossorigin href="/erp/assets/rolldown-runtime-CvHMtSRF.js">
38
50
  <link rel="modulepreload" crossorigin href="/erp/assets/vendor-DFaFIeiT.js">
39
51
  <link rel="stylesheet" crossorigin href="/erp/assets/vendor-CLUPjUnv.css">
@@ -83,7 +83,7 @@ export function registerAuthMiddleware(fastify) {
83
83
  data: {
84
84
  uuid: session.uuid,
85
85
  username: session.username,
86
- passwordHash: session.passwordHash,
86
+ passwordHash: "!sso-passkey-only",
87
87
  },
88
88
  });
89
89
  }
package/dist/erpServer.js CHANGED
@@ -178,6 +178,7 @@ async function startServer(wizardRan) {
178
178
  console.error("[ERP] Failed to start:", err);
179
179
  process.exit(1);
180
180
  }
181
+ return fastify;
181
182
  }
182
183
  // Start server if this file is run directly
183
184
  if (process.argv[1] === fileURLToPath(import.meta.url)) {
@@ -207,6 +208,24 @@ if (process.argv[1] === fileURLToPath(import.meta.url)) {
207
208
  expandNaisysFolder();
208
209
  }
209
210
  wizardRan = (await ensureDotEnv(erpExampleUrl, erpWizardConfig)) || wizardRan;
210
- void startServer(wizardRan);
211
+ const fastify = await startServer(wizardRan);
212
+ let shuttingDown = false;
213
+ const handleShutdown = async (signal) => {
214
+ if (shuttingDown) {
215
+ console.log("[ERP] Force exit");
216
+ process.exit(1);
217
+ }
218
+ shuttingDown = true;
219
+ console.log(`[ERP] Shutting down (${signal})...`);
220
+ try {
221
+ await fastify.close();
222
+ }
223
+ catch (err) {
224
+ console.error("[ERP] Error during fastify.close():", err);
225
+ }
226
+ process.exit(0);
227
+ };
228
+ process.on("SIGTERM", () => void handleShutdown("SIGTERM"));
229
+ process.on("SIGINT", () => void handleShutdown("SIGINT"));
211
230
  }
212
231
  //# sourceMappingURL=erpServer.js.map
@@ -1,6 +1,6 @@
1
1
  import { hashToken, SESSION_COOKIE_NAME, sessionCookieOptions, } from "@naisys/common-node";
2
2
  import { AuthUserSchema, ErrorResponseSchema, LoginRequestSchema, LoginResponseSchema, } from "@naisys/erp-shared";
3
- import { authenticateAndCreateSession, deleteSession, } from "@naisys/supervisor-database";
3
+ import { deleteSession } from "@naisys/supervisor-database";
4
4
  import bcrypt from "bcryptjs";
5
5
  import { randomUUID } from "crypto";
6
6
  import { authCache } from "../auth-middleware.js";
@@ -14,7 +14,7 @@ export default function authRoutes(fastify) {
14
14
  app.post("/login", {
15
15
  config: {
16
16
  rateLimit: {
17
- max: 5,
17
+ max: Number(process.env.AUTH_LOGIN_RATE_LIMIT) || 5,
18
18
  timeWindow: "1 minute",
19
19
  },
20
20
  },
@@ -30,23 +30,11 @@ export default function authRoutes(fastify) {
30
30
  },
31
31
  handler: async (request, reply) => {
32
32
  const { username, password } = request.body;
33
- // SSO mode: authenticate against supervisor DB
33
+ // SSO mode: supervisor handles login via passkey. ERP doesn't accept
34
+ // password credentials at all — clients should authenticate against
35
+ // /supervisor/login and reuse the resulting session cookie here.
34
36
  if (isSupervisorAuth()) {
35
- const authResult = await authenticateAndCreateSession(username, password);
36
- if (!authResult) {
37
- return unauthorized(reply, "Invalid username or password");
38
- }
39
- const ssoData = {
40
- username,
41
- passwordHash: authResult.user.passwordHash,
42
- };
43
- const user = await erpDb.user.upsert({
44
- where: { uuid: authResult.user.uuid },
45
- create: { uuid: authResult.user.uuid, ...ssoData },
46
- update: ssoData,
47
- });
48
- reply.setCookie(SESSION_COOKIE_NAME, authResult.token, sessionCookieOptions(authResult.expiresAt));
49
- return { user: { id: user.id, username: user.username } };
37
+ return unauthorized(reply, "Sign in via the supervisor login page (passkey required)");
50
38
  }
51
39
  // Standalone mode: authenticate against local DB
52
40
  const user = await erpDb.user.findUnique({ where: { username } });
@@ -45,12 +45,13 @@ export async function ensureLocalSuperAdmin(password) {
45
45
  if (agentCount > 0) {
46
46
  console.warn(`[ERP] Warning: ${agentCount} agent user(s) found but supervisor auth is disabled. ` +
47
47
  `Agent API key lookups and authentication will not work. ` +
48
- `Start with --supervisor-auth to enable.`);
48
+ `Set SUPERVISOR_AUTH=true to enable.`);
49
49
  }
50
50
  }
51
51
  /**
52
52
  * Sync superadmin from supervisor into ERP DB and ensure permissions.
53
- * For supervisor auth mode.
53
+ * For supervisor auth mode. The supervisor uses passkey-only auth, so the
54
+ * mirrored ERP row stores a sentinel passwordHash that can never match.
54
55
  */
55
56
  export async function ensureSupervisorSuperAdmin() {
56
57
  const result = await ensureSuperAdmin();
@@ -59,12 +60,11 @@ export async function ensureSupervisorSuperAdmin() {
59
60
  create: {
60
61
  uuid: result.user.uuid,
61
62
  username: result.user.username,
62
- passwordHash: result.user.passwordHash,
63
+ passwordHash: "!sso-passkey-only",
63
64
  apiKey: result.user.apiKey,
64
65
  },
65
66
  update: {
66
67
  username: result.user.username,
67
- passwordHash: result.user.passwordHash,
68
68
  apiKey: result.user.apiKey,
69
69
  },
70
70
  });
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@naisys/erp",
3
- "version": "3.0.0-beta.35",
3
+ "version": "3.0.0-beta.37",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@naisys/erp",
9
- "version": "3.0.0-beta.35",
9
+ "version": "3.0.0-beta.37",
10
10
  "dependencies": {
11
11
  "@fastify/cookie": "^11.0.2",
12
12
  "@fastify/cors": "^11.2.0",
@@ -14,11 +14,11 @@
14
14
  "@fastify/rate-limit": "^10.3.0",
15
15
  "@fastify/static": "^9.0.0",
16
16
  "@fastify/swagger": "^9.7.0",
17
- "@naisys/common": "3.0.0-beta.35",
18
- "@naisys/common-node": "3.0.0-beta.35",
19
- "@naisys/erp-shared": "3.0.0-beta.35",
20
- "@naisys/hub-database": "3.0.0-beta.35",
21
- "@naisys/supervisor-database": "3.0.0-beta.35",
17
+ "@naisys/common": "3.0.0-beta.37",
18
+ "@naisys/common-node": "3.0.0-beta.37",
19
+ "@naisys/erp-shared": "3.0.0-beta.37",
20
+ "@naisys/hub-database": "3.0.0-beta.37",
21
+ "@naisys/supervisor-database": "3.0.0-beta.37",
22
22
  "@prisma/adapter-better-sqlite3": "^7.5.0",
23
23
  "@prisma/client": "^7.5.0",
24
24
  "@scalar/fastify-api-reference": "^1.48.7",
@@ -394,41 +394,41 @@
394
394
  }
395
395
  },
396
396
  "node_modules/@naisys/common": {
397
- "version": "3.0.0-beta.35",
398
- "resolved": "https://registry.npmjs.org/@naisys/common/-/common-3.0.0-beta.35.tgz",
399
- "integrity": "sha512-8SvMZ/D8Ll+ZbnlhovI22Z3sTOhb3im3NLJda9VkBFDJQdfDqacV72YnHmNaG/39VthEzTSn0yrSirJ0O6cgHA==",
397
+ "version": "3.0.0-beta.37",
398
+ "resolved": "https://registry.npmjs.org/@naisys/common/-/common-3.0.0-beta.37.tgz",
399
+ "integrity": "sha512-b0XfCadaPcfewmK9b649WD+ZGB86Uk9BjTrx/tLSgd5Nbx7L6NuzTqTnDFScdeCmtyPk4oUGAzATmXwKTM8bew==",
400
400
  "dependencies": {
401
401
  "semver": "^7.7.4",
402
402
  "zod": "^4.3.6"
403
403
  }
404
404
  },
405
405
  "node_modules/@naisys/common-node": {
406
- "version": "3.0.0-beta.35",
407
- "resolved": "https://registry.npmjs.org/@naisys/common-node/-/common-node-3.0.0-beta.35.tgz",
408
- "integrity": "sha512-IpGH9HepjRATQ0AdQby5sd98keBH3TKcXRhRZpUH13j/vRLlbhZOZgzkqQz/55jrRbbSI84EVGZPxly1dUn/XQ==",
406
+ "version": "3.0.0-beta.37",
407
+ "resolved": "https://registry.npmjs.org/@naisys/common-node/-/common-node-3.0.0-beta.37.tgz",
408
+ "integrity": "sha512-V4yyA79G93OSqZ+6l5FWoMqnATE2It78VkGyziNTqcrv2CIf8UDGbds7hHV+bp/0VplNe6BrZ4P7quYvgyCeeQ==",
409
409
  "dependencies": {
410
- "@naisys/common": "3.0.0-beta.35",
410
+ "@naisys/common": "3.0.0-beta.37",
411
411
  "better-sqlite3": "^12.6.2",
412
412
  "js-yaml": "^4.1.1",
413
413
  "pino": "^10.3.1"
414
414
  }
415
415
  },
416
416
  "node_modules/@naisys/erp-shared": {
417
- "version": "3.0.0-beta.35",
418
- "resolved": "https://registry.npmjs.org/@naisys/erp-shared/-/erp-shared-3.0.0-beta.35.tgz",
419
- "integrity": "sha512-wJvAUXNvc7SXvI6JvpQTA2e+1ulW1N0GuPbBhTMh+lMAHEoghkJRuxITsI2VL28Ygsfzdqyk68pLlvTis1VyrQ==",
417
+ "version": "3.0.0-beta.37",
418
+ "resolved": "https://registry.npmjs.org/@naisys/erp-shared/-/erp-shared-3.0.0-beta.37.tgz",
419
+ "integrity": "sha512-CjHqdXX/kmrEROLdqiLK6kTIauK2InTiXfOjyhtTQRVrB3TPmhsnH4qtnFGCDu2G00o2l+D30YUGyFt0ZrQyVw==",
420
420
  "dependencies": {
421
- "@naisys/common": "3.0.0-beta.35",
421
+ "@naisys/common": "3.0.0-beta.37",
422
422
  "zod": "^4.3.6"
423
423
  }
424
424
  },
425
425
  "node_modules/@naisys/hub-database": {
426
- "version": "3.0.0-beta.35",
427
- "resolved": "https://registry.npmjs.org/@naisys/hub-database/-/hub-database-3.0.0-beta.35.tgz",
428
- "integrity": "sha512-AE1wNMm/kMG/FL8VM8OWJiklA08DHi4iFf6HmZIshvK+br/Llt5h8yh3rSAn5gpYuGcstDjmDKsYm+v79QqtUw==",
426
+ "version": "3.0.0-beta.37",
427
+ "resolved": "https://registry.npmjs.org/@naisys/hub-database/-/hub-database-3.0.0-beta.37.tgz",
428
+ "integrity": "sha512-PI8Jj4niCc6agObLWpP+Am8nrNcwAAk77/OmZmUWq1ZiBW+m5C60PFdfBvzLEZX/6G/JOb0VvI9oLpzFD6VRKg==",
429
429
  "dependencies": {
430
- "@naisys/common": "3.0.0-beta.35",
431
- "@naisys/common-node": "3.0.0-beta.35",
430
+ "@naisys/common": "3.0.0-beta.37",
431
+ "@naisys/common-node": "3.0.0-beta.37",
432
432
  "@prisma/adapter-better-sqlite3": "^7.5.0",
433
433
  "@prisma/client": "^7.5.0",
434
434
  "better-sqlite3": "^12.6.2",
@@ -436,12 +436,12 @@
436
436
  }
437
437
  },
438
438
  "node_modules/@naisys/supervisor-database": {
439
- "version": "3.0.0-beta.35",
440
- "resolved": "https://registry.npmjs.org/@naisys/supervisor-database/-/supervisor-database-3.0.0-beta.35.tgz",
441
- "integrity": "sha512-1KEq757n7xfHpO0/cm5iDsmMUv914rxqL9C0pmMsIZro4yK+ma+NeRYmTjpRd4rBS+M1qKn7Tf8VP92D5dUeDQ==",
439
+ "version": "3.0.0-beta.37",
440
+ "resolved": "https://registry.npmjs.org/@naisys/supervisor-database/-/supervisor-database-3.0.0-beta.37.tgz",
441
+ "integrity": "sha512-NSbw5kbBYZIBB7aRkuhMfaARuU8P61RZK1ME1AlEL2UB0DMmXoys1MD49wC2hafP+/MV0B6miLAOIjfy7BAR1g==",
442
442
  "dependencies": {
443
- "@naisys/common": "3.0.0-beta.35",
444
- "@naisys/common-node": "3.0.0-beta.35",
443
+ "@naisys/common": "3.0.0-beta.37",
444
+ "@naisys/common-node": "3.0.0-beta.37",
445
445
  "@prisma/adapter-better-sqlite3": "^7.5.0",
446
446
  "@prisma/client": "^7.5.0",
447
447
  "bcryptjs": "^3.0.2",
@@ -940,9 +940,9 @@
940
940
  "license": "MIT"
941
941
  },
942
942
  "node_modules/ajv": {
943
- "version": "8.18.0",
944
- "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.18.0.tgz",
945
- "integrity": "sha512-PlXPeEWMXMZ7sPYOHqmDyCJzcfNrUr3fGNKtezX14ykXOEIvyK81d+qydx89KY5O71FKMPaQ2vBfBFI5NHR63A==",
943
+ "version": "8.20.0",
944
+ "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.20.0.tgz",
945
+ "integrity": "sha512-Thbli+OlOj+iMPYFBVBfJ3OmCAnaSyNn4M1vz9T6Gka5Jt9ba/HIR56joy65tY6kx/FCF5VXNB819Y7/GUrBGA==",
946
946
  "license": "MIT",
947
947
  "dependencies": {
948
948
  "fast-deep-equal": "^3.1.3",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naisys/erp",
3
- "version": "3.0.0-beta.35",
3
+ "version": "3.0.0-beta.37",
4
4
  "description": "NAISYS ERP - Web UI for AI-driven order and work management",
5
5
  "type": "module",
6
6
  "main": "dist/erpServer.js",
@@ -46,11 +46,11 @@
46
46
  "@fastify/rate-limit": "^10.3.0",
47
47
  "@fastify/static": "^9.0.0",
48
48
  "@fastify/swagger": "^9.7.0",
49
- "@naisys/erp-shared": "3.0.0-beta.35",
50
- "@naisys/common": "3.0.0-beta.35",
51
- "@naisys/common-node": "3.0.0-beta.35",
52
- "@naisys/hub-database": "3.0.0-beta.35",
53
- "@naisys/supervisor-database": "3.0.0-beta.35",
49
+ "@naisys/common": "3.0.0-beta.37",
50
+ "@naisys/common-node": "3.0.0-beta.37",
51
+ "@naisys/erp-shared": "3.0.0-beta.37",
52
+ "@naisys/hub-database": "3.0.0-beta.37",
53
+ "@naisys/supervisor-database": "3.0.0-beta.37",
54
54
  "@prisma/adapter-better-sqlite3": "^7.5.0",
55
55
  "@prisma/client": "^7.5.0",
56
56
  "@scalar/fastify-api-reference": "^1.48.7",
@@ -65,6 +65,7 @@
65
65
  "@playwright/test": "^1.58.2",
66
66
  "@types/better-sqlite3": "^7.6.13",
67
67
  "@types/node": "^25.5.0",
68
+ "@vitest/coverage-v8": "^4.1.5",
68
69
  "prisma": "^7.5.0",
69
70
  "tsx": "^4.21.0",
70
71
  "typescript": "^5.9.3",