import assert from "node:assert/strict"; import { readFileSync } from "node:fs"; import path from "node:path"; const root = process.cwd(); const source = readFileSync(path.join(root, "src/services/api.js"), "utf8"); assert.match(source, /\/auth\/login-key/, "login should fetch the backend public key before submitting"); assert.match(source, /password_ciphertext/, "login payload should submit encrypted password ciphertext"); assert.match(source, /login_key_id/, "login payload should include the public key id used for encryption"); assert.doesNotMatch( source, /JSON\.stringify\(\{\s*username,\s*password\s*\}\)/, "login must not serialize the plaintext password field" ); assert.doesNotMatch(source, /password:\s*password/, "login payload must not include plaintext password"); console.log("login password encryption checks passed");