@sleep2agi/commhub-server 0.5.0-preview.35 → 0.5.0-preview.36
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 +1 -1
- package/src/auth.ts +8 -15
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sleep2agi/commhub-server",
|
|
3
|
-
"version": "0.5.0-preview.
|
|
3
|
+
"version": "0.5.0-preview.36",
|
|
4
4
|
"description": "CommHub Server \u2014 AI Agent communication hub with MCP protocol, multi-network isolation, user auth, and 18 MCP tools.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.ts",
|
package/src/auth.ts
CHANGED
|
@@ -85,22 +85,15 @@ export function login(username: string, password: string): AuthResult {
|
|
|
85
85
|
if (!user) return { ok: false, error: "invalid username or password" };
|
|
86
86
|
if (user.password_hash !== hashPassword(password)) return { ok: false, error: "invalid username or password" };
|
|
87
87
|
|
|
88
|
-
//
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
user.user_id);
|
|
92
|
-
|
|
88
|
+
// Issue a NEW user token — do NOT rotate/invalidate existing ones. Each
|
|
89
|
+
// login (cli, dashboard, second machine) gets its own row so they don't
|
|
90
|
+
// kick each other out of session. Tokens can be revoked via /api/auth/tokens.
|
|
93
91
|
const userToken = generateUserToken();
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
db.run(
|
|
100
|
-
"INSERT INTO api_tokens (token_id, token_hash, user_id, network_id, name, scope) VALUES (?1, ?2, ?3, ?4, ?5, ?6)",
|
|
101
|
-
[tokenId, hashToken(userToken), user.user_id, null, "user-login", "user"]
|
|
102
|
-
);
|
|
103
|
-
}
|
|
92
|
+
const tokenId = generateId("tok");
|
|
93
|
+
db.run(
|
|
94
|
+
"INSERT INTO api_tokens (token_id, token_hash, user_id, network_id, name, scope) VALUES (?1, ?2, ?3, ?4, ?5, ?6)",
|
|
95
|
+
[tokenId, hashToken(userToken), user.user_id, null, "user-login", "user"]
|
|
96
|
+
);
|
|
104
97
|
|
|
105
98
|
// Find default network
|
|
106
99
|
const defaultNet = db.get<any>(
|