Installation
Requirements
- Node.js 18+ (uses native
fetchandcrypto) - ESM only — the package ships as
"type": "module"with TypeScriptNodeNextresolution
Configuration
Options
Your Grantex API key. Falls back to the
GRANTEX_API_KEY environment variable if omitted.Base URL for the Grantex API. Override for self-hosted or local development.
Request timeout in milliseconds. The SDK uses
AbortController to enforce the deadline.Quick start
The complete authorization flow in one script:Available resources
TheGrantex client exposes the following sub-clients:
| Property | Description | Reference |
|---|---|---|
grantex.agents | Register, list, update, and delete agents | Agents |
grantex.tokens | Exchange, verify, and revoke tokens | Tokens |
grantex.grants | Manage grants, delegate to sub-agents | Grants |
grantex.audit | Log and query the tamper-evident audit trail | Audit |
grantex.webhooks | Create and manage webhook endpoints | Webhooks |
grantex.policies | Define authorization policies | Policies |
grantex.compliance | Compliance summaries, exports, evidence packs | Compliance |
grantex.anomalies | Detect and acknowledge anomalies | Anomalies |
grantex.billing | Subscription management via Stripe | Billing |
grantex.scim | SCIM 2.0 user provisioning | SCIM |
grantex.sso | OIDC single sign-on | SSO |
Standalone exports
These functions can be used without instantiating aGrantex client:
| Export | Description | Reference |
|---|---|---|
verifyGrantToken() | Offline JWT verification via JWKS | Offline Verification |
generatePkce() | Generate PKCE S256 challenge pairs | PKCE |
verifyWebhookSignature() | Verify webhook payload signatures | Webhooks |
Error handling
All errors extendGrantexError. See the Error Handling reference for the full hierarchy and usage patterns.