Overview
@grantex/adapters provides pre-built adapters for popular APIs — Google Calendar, Gmail, Stripe, and Slack. Each adapter verifies grant tokens offline (JWKS), checks scopes, enforces constraints, and calls the upstream API.
Google Calendar
Scopes:calendar:read, calendar:write
Gmail
Scopes:email:read, email:send
Stripe
Scopes:payments:read, payments:initiate
Supports constraint enforcement — payments:initiate:max_500 limits payments to $500.
Slack
Scopes:notifications:send, notifications:read
Constraint Enforcement
Scopes can include constraints that adapters enforce automatically:| Constraint | Meaning | Example |
|---|---|---|
max_N | Value must be <= N | payments:initiate:max_500 — max $500 |
min_N | Value must be >= N | payments:initiate:min_10 — min $10 |
limit_N | Count must be <= N | api:calls:limit_1000 — max 1000 calls |
Dynamic Credentials
Pass an async function instead of a static string:Audit Logging
Connect adapters to Grantex audit:Building Custom Adapters
ExtendBaseAdapter to integrate any API:
Error Codes
| Code | Meaning |
|---|---|
TOKEN_INVALID | Grant token verification failed |
SCOPE_MISSING | Grant doesn’t include required scope |
CONSTRAINT_VIOLATED | Value exceeds scope constraint |
UPSTREAM_ERROR | Upstream API returned an error |
CREDENTIAL_ERROR | Failed to resolve credentials |