Skip to content

[Extension] Generate per-request backend JWT in @shared/api #2770

@piyalbasu

Description

@piyalbasu

Generate a fresh Ed25519 JWT per request to freighter-backend-v2 in @shared/api. Sign with the auth private key.

Claims per the design doc:

  • sub = hex auth pubkey (= user ID)
  • iss = "freighter-extension"
  • iat = now
  • exp = iat + 15s
  • bodyHash = SHA256 of raw request body (empty-byte hash e3b0c442... for GET)
  • methodAndPath = e.g., "PUT /api/v1/contacts"

See Cross-Platform Contact Sync design doc — Auth Flow + JWT claims table.

Depends on: #2769 (auth keypair derivation), and freighter-backend-v2#88 (JWT middleware) for the end-to-end round-trip test.

Acceptance:

  • Authenticated round-trip works end-to-end against freighter-backend-v2 (200 on valid request, 401 on tampered body / wrong key / expired token).
  • On 401: regenerate JWT and retry once before surfacing the error.
  • JWT is generated fresh per request, not cached.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions