mirror of
https://github.com/shuaiplus/nodewarden.git
synced 2026-11-04 02:40:20 +00:00
fix(auth): align API keys and exclude device trust backups
This commit is contained in:
1 parent
19de8d6e57
commit
299eda597f
7 files changed
+320
-61
No files matched your search
@@ -29,7 +29,13 @@ export async function hashApiKey(apiKey: string): Promise<string> {
|
||||
|
||||
export async function verifyApiKey(apiKey: string, storedApiKey: string | null | undefined): Promise<boolean> {
|
||||
const stored = String(storedApiKey || '').trim();
|
||||
if (!isStoredApiKeyHash(stored)) return false;
|
||||
if (!stored) return false;
|
||||
|
||||
// Legacy NodeWarden rows stored a one-way hash. Keep them usable until the
|
||||
// user explicitly rotates once into the Bitwarden-compatible readable form.
|
||||
if (!isStoredApiKeyHash(stored)) {
|
||||
return constantTimeEquals(apiKey, stored);
|
||||
}
|
||||
|
||||
const hashed = await hashApiKey(apiKey);
|
||||
return constantTimeEquals(hashed, stored);
|
||||
|
||||
Reference in new issue
Block a user