Skip to content

PassportClient SDK: add revocation check method with caching #119

Description

@leocagli

Context

PR#116 (pending) adds a PassportClient to the SDK with typed credential verification. A common SDK use-case is checking whether a passport has been revoked — this should be efficient and cache-friendly to avoid hammering the API.

What to implement

Method: PassportClient.isRevoked(passportId)

async isRevoked(passportId: string): Promise<boolean>

Caching

  • Cache the result per passportId for 60 seconds (configurable via cacheMs option)
  • On cache hit: return cached result
  • On cache miss: call GET /api/protocol/passport/:id and check status === 'revoked'
  • Revocation is permanent — once true, cache indefinitely

Constructor option

new PassportClient({ baseUrl, apiKey, revocationCacheMs: 60_000 })

Acceptance criteria

  • isRevoked('active-id')false
  • isRevoked('revoked-id')true
  • Second call within cacheMs → returns cached result without network call
  • Once revoked, cached forever (no TTL expiry for true results)
  • Unit test: verify only 1 HTTP call made on 3 successive checks within cache window

🎁 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