Constructs a new instance of the Permit class with the specified configuration.
The configuration for the Permit SDK.
Readonly apiAccess the Permit REST API using this property.
Usage example:
const permit = new Permit(config);
permit.api.roles.create(...);
Readonly configAccess the SDK configuration using this property. Once the SDK is initialized, the configuration is read-only.
Usage example:
const permit = new Permit(config);
const pdpUrl = permit.config.pdp;
Readonly elementsAccess the Permit Elements API using this property.
Usage example:
const permit = new Permit(config);
permit.elements.loginAs(user, tenant);
Checks multiple requests within the specified context.
The check requests.
Optional context: ContextThe context object representing the context in which the action is performed.
Optional config: CheckConfigarray containing true if the user is authorized, false otherwise for each check request.
PermitConnectionError if an error occurs while sending the authorization request to the PDP.
PermitPDPStatusError if received a response with unexpected status code from the PDP.
Checks if a user is authorized to perform an action on a resource within the specified context.
The user object representing the user.
The action to be performed on the resource.
The resource object representing the resource.
Optional context: ContextThe context object representing the context in which the action is performed.
Optional config: CheckConfigtrue if the user is authorized, false otherwise.
PermitConnectionError if an error occurs while sending the authorization request to the PDP.
PermitPDPStatusError if received a response with unexpected status code from the PDP.
Get all permissions for the specified user.
The user object representing the user.
Optional tenants: string[]The list of tenants to filter the permissions on ( given by roles ).
Optional resources: string[]The list of resources to filter the permissions on ( given by resource roles ).
Optional resource_types: string[]The list of resource types to filter the permissions on ( given by resource roles ).
Optional config: CheckConfigobject with key as the resource identifier and value as the resource details and permissions.
PermitConnectionError if an error occurs while sending the authorization request to the PDP.
PermitPDPStatusError if received a response with unexpected status code from the PDP.
Generated using TypeDoc
The
Permitclass represents the main entry point for interacting with the Permit.io SDK. The SDK constructor expects an object implementing the IPermitConfig interface.Example usage: