Node.js client library for the Permit.io full-stack permissions platform.
npm install permitio
- Update the version in
package.json - Execute
yarn run build - Execute
yarn docs ; git add docs/ ; git commit -m "update tsdoc"to update the auto generated docs - Execute
yarn publish --access public
The SDK includes built-in retry support for transient failures. Retries are opt-in:
they are off unless you pass a retry config (or retry: { enabled: true }).
When enabled, the defaults are:
- 3 retries (up to 4 total attempts) with exponential backoff
- Retries on network errors and status codes:
408,429,500,502,503,504 - Respects
Retry-Afterheaders for rate limiting (429)
maxRetries is the number of retries after the initial request, so the default of 3 means up to 4 total requests.
Behavioral note
- Retries are opt-in — providing a
retryconfig object turns them on; omitting it (or passingretry: false) leaves them off.- When enabled, PDP/OPA calls additionally retry
POSTbecause check operations are idempotent. The REST API does not retryPOST, so non-idempotent writes are never repeated.- A custom
axiosInstanceapplies to the REST API only; PDP and OPA calls use dedicated internal axios instances.
import { Permit } from 'permitio';
// Retries are off by default (opt-in)
const permitDefault = new Permit({ token: 'your-api-key' });
// Enable with custom retry configuration
const permitCustom = new Permit({
token: 'your-api-key',
retry: {
maxRetries: 5,
retryDelay: 500, // Initial delay in ms
backoffMultiplier: 2, // Exponential backoff multiplier
maxDelay: 30000, // Maximum delay cap
},
});
// Explicitly disable retry
const permitNoRetry = new Permit({
token: 'your-api-key',
retry: false,
});
// Different config for PDP vs REST API
const permitPdp = new Permit({
token: 'your-api-key',
retry: { maxRetries: 3 },
pdpRetry: { maxRetries: 5 },
});