Skip to content

Passport expiry warning webhook: emit event 7 days before credential expires #128

Description

@leocagli

Context

Passport #121 adds expiry notifications via webhook. This issue specifically covers the advance warning — emitting a passport.expiring_soon event 7 days before the expiry date so the agent has time to renew.

What to implement

Cron job: daily expiry scan

A scheduled job (same pattern as the existing health check cron) that runs daily and:

  1. Scans all active passports
  2. For each passport where expiresAt is within the next 7 days
  3. Emits a passport.expiring_soon webhook event (if not already emitted for this passport in the current 7-day window — dedupe by passport ID + week)

Webhook payload

{
  "event": "passport.expiring_soon",
  "passportId": "psp_abc",
  "agentId": "bot-1",
  "expiresAt": "2026-07-03T00:00:00Z",
  "daysRemaining": 6
}

Route: GET /api/cron/expiry-warnings (cron-compatible)

Returns { checked, warned, skipped } for monitoring.

Acceptance criteria

  • Passport expiring in 6 days triggers passport.expiring_soon event
  • Passport expiring in 8 days does NOT trigger (outside window)
  • Already-expired passport does NOT trigger (use passport.expired instead)
  • Same passport not warned twice in the same 7-day window
  • Unit tests: in-window, out-of-window, already-warned dedup, expired

🎁 Evidencia visual = reward extra

  • Si tu PR incluye video demo o capturas de pantalla mostrando la funcionalidad pedida funcionando end-to-end, va a ser considerado para rewards de GrantFox en esta issue. No es obligatorio, pero suma mucho para la evaluación.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions