(record: AttemptRecord)
| 510 | * Returns true if the local write succeeded. |
| 511 | */ |
| 512 | export function logAttempt(record: AttemptRecord): boolean { |
| 513 | // Fire telemetry first, async — even if local write fails, we still want |
| 514 | // the event reported (it goes to a different directory anyway). |
| 515 | reportAttemptTelemetry(record); |
| 516 | try { |
| 517 | mkdirSecure(SECURITY_DIR); |
| 518 | rotateIfNeeded(); |
| 519 | const line = JSON.stringify(record) + '\n'; |
| 520 | appendSecureFile(ATTEMPTS_LOG, line); |
| 521 | return true; |
| 522 | } catch (err) { |
| 523 | // Non-fatal. Log to stderr for debugging but don't block. |
| 524 | console.error('[security] logAttempt write failed:', (err as Error).message); |
| 525 | return false; |
| 526 | } |
| 527 | } |
| 528 | |
| 529 | // ─── Cross-process session state ───────────────────────────── |
| 530 |
no test coverage detected