Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@cerbos/core

Package Overview
Dependencies
Maintainers
2
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cerbos/core - npm Package Compare versions

Comparing version 0.14.0 to 0.15.0

142

lib/client.d.ts

@@ -0,5 +1,6 @@

/// <reference types="node" />
import type { _RPC, _Request, _Response, _Service } from "./rpcs";
import type { AddOrUpdatePoliciesRequest, AddOrUpdateSchemasRequest, CheckResourceRequest, CheckResourcesRequest, CheckResourcesResponse, CheckResourcesResult, DeleteSchemasRequest, DeleteSchemasResponse, DisablePoliciesRequest, DisablePoliciesResponse, EnablePoliciesRequest, EnablePoliciesResponse, GetPoliciesRequest, GetPoliciesResponse, GetSchemasRequest, GetSchemasResponse, IsAllowedRequest, ListPoliciesRequest, ListPoliciesResponse, ListSchemasResponse, PlanResourcesRequest, PlanResourcesResponse, Policy, ReloadStoreRequest, Schema, ServerInfo, ValidationFailedCallback } from "./types/external";
/** @internal */
export type _Transport = <Service extends _Service, RPC extends _RPC<Service>>(service: Service, rpc: RPC, request: _Request<Service, RPC>, adminCredentials?: AdminCredentials, metadata?: Record<string, string>) => Promise<_Response<Service, RPC>>;
export type _Transport = <Service extends _Service, RPC extends _RPC<Service>>(service: Service, rpc: RPC, request: _Request<Service, RPC>, headers: Headers) => Promise<_Response<Service, RPC>>;
/** @internal */

@@ -12,2 +13,8 @@ export type _Instrumenter = (transport: _Transport) => _Transport;

/**
* HTTP headers from which to construct a {@link https://developer.mozilla.org/en-US/docs/Web/API/Headers | Headers} object.
*
* @public
*/
export type HeadersInit = [string, string][] | Record<string, string> | Headers;
/**
* Options for creating a new {@link Client}.

@@ -19,3 +26,3 @@ *

/**
* Credentials for the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api.html | admin API}.
* Credentials for the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api | admin API}.
*

@@ -26,2 +33,14 @@ * @defaultValue `undefined`

/**
* Headers to add to every request to the policy decision point.
*
* @remarks
* Headers can be included in the policy decision point's audit logs by setting the `includeMetadataKeys` or `excludeMetadataKeys` fields in the
* `audit` {@link https://docs.cerbos.dev/cerbos/latest/configuration/audit | configuration block}.
*
* The `User-Agent` header is set using {@link Options.userAgent}.
*
* @defaultValue `undefined`
*/
headers?: HeadersInit | (() => HeadersInit | Promise<HeadersInit>) | undefined;
/**
* Action to take when input fails schema validation.

@@ -47,5 +66,11 @@ *

playgroundInstance?: string | undefined;
/**
* Custom user agent to prepend to the built-in value.
*
* @defaultValue `undefined`
*/
userAgent?: string | undefined;
}
/**
* Credentials for the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api.html | admin API}.
* Credentials for the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api | admin API}.
*

@@ -65,2 +90,21 @@ * @public

/**
* Options for sending a request to the policy decision point.
*
* @public
*/
export interface RequestOptions {
/**
* Headers to add to the request.
*
* @remarks
* Headers can be included in the policy decision point's audit logs by setting the `includeMetadataKeys` or `excludeMetadataKeys` fields
* in the `audit` {@link https://docs.cerbos.dev/cerbos/latest/configuration/audit | configuration block}.
*
* The `User-Agent` header is set using {@link Options.userAgent}.
*
* @defaultValue `undefined`
*/
headers?: HeadersInit | undefined;
}
/**
* Base implementation of a client for interacting with the Cerbos policy decision point server.

@@ -71,4 +115,4 @@ *

export declare abstract class Client {
private readonly transport;
private readonly options;
private readonly transport;
/** @internal */

@@ -84,5 +128,5 @@ protected constructor(transport: _Transport, options: Options);

*
* - the Cerbos policy decision point server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api.html | admin API} enabled, and
* - the Cerbos policy decision point server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api | admin API} enabled, and
*
* - a dynamic {@link https://docs.cerbos.dev/cerbos/latest/configuration/storage.html | storage backend}.
* - a dynamic {@link https://docs.cerbos.dev/cerbos/latest/configuration/storage | storage backend}.
*

@@ -131,3 +175,3 @@ * @example

*/
addOrUpdatePolicies(request: AddOrUpdatePoliciesRequest): Promise<void>;
addOrUpdatePolicies(request: AddOrUpdatePoliciesRequest, options?: RequestOptions): Promise<void>;
/**

@@ -141,5 +185,5 @@ * Add schemas to be used for validating principal or resource attributes, or update existing schemas.

*
* - the Cerbos policy decision point server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api.html | admin API} enabled, and
* - the Cerbos policy decision point server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api | admin API} enabled, and
*
* - a dynamic {@link https://docs.cerbos.dev/cerbos/latest/configuration/storage.html | storage backend}.
* - a dynamic {@link https://docs.cerbos.dev/cerbos/latest/configuration/storage | storage backend}.
*

@@ -187,3 +231,3 @@ * @example

*/
addOrUpdateSchemas(request: AddOrUpdateSchemasRequest): Promise<void>;
addOrUpdateSchemas(request: AddOrUpdateSchemasRequest, options?: RequestOptions): Promise<void>;
/**

@@ -211,3 +255,3 @@ * Check a principal's permissions on a resource.

*/
checkResource(request: CheckResourceRequest): Promise<CheckResourcesResult>;
checkResource(request: CheckResourceRequest, options?: RequestOptions): Promise<CheckResourcesResult>;
/**

@@ -250,3 +294,3 @@ * Check a principal's permissions on a set of resources.

*/
checkResources(request: CheckResourcesRequest): Promise<CheckResourcesResponse>;
checkResources(request: CheckResourcesRequest, options?: RequestOptions): Promise<CheckResourcesResponse>;
/**

@@ -260,5 +304,5 @@ * Delete a schema.

*
* - the Cerbos policy decision point (PDP) server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api.html | admin API} enabled, and
* - the Cerbos policy decision point (PDP) server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api | admin API} enabled, and
*
* - a dynamic {@link https://docs.cerbos.dev/cerbos/latest/configuration/storage.html | storage backend}.
* - a dynamic {@link https://docs.cerbos.dev/cerbos/latest/configuration/storage | storage backend}.
*

@@ -274,3 +318,3 @@ * The way this method handles failure depends on the version of the connected PDP server.

*/
deleteSchema(id: string): Promise<boolean>;
deleteSchema(id: string, options?: RequestOptions): Promise<boolean>;
/**

@@ -284,5 +328,5 @@ * Delete multiple schemas.

*
* - the Cerbos policy decision point (PDP) server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api.html | admin API} enabled, and
* - the Cerbos policy decision point (PDP) server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api | admin API} enabled, and
*
* - a dynamic {@link https://docs.cerbos.dev/cerbos/latest/configuration/storage.html | storage backend}.
* - a dynamic {@link https://docs.cerbos.dev/cerbos/latest/configuration/storage | storage backend}.
*

@@ -300,3 +344,3 @@ * The way this method handles failure depends on the version of the connected PDP server.

*/
deleteSchemas(request: DeleteSchemasRequest): Promise<DeleteSchemasResponse>;
deleteSchemas(request: DeleteSchemasRequest, options?: RequestOptions): Promise<DeleteSchemasResponse>;
/**

@@ -310,5 +354,5 @@ * Disable multiple policies.

*
* - the Cerbos policy decision point server to be at least v0.25 and configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api.html | admin API} enabled, and
* - the Cerbos policy decision point server to be at least v0.25 and configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api | admin API} enabled, and
*
* - a dynamic {@link https://docs.cerbos.dev/cerbos/latest/configuration/storage.html | storage backend}.
* - a dynamic {@link https://docs.cerbos.dev/cerbos/latest/configuration/storage | storage backend}.
*

@@ -322,3 +366,3 @@ * @example

*/
disablePolicies(request: DisablePoliciesRequest): Promise<DisablePoliciesResponse>;
disablePolicies(request: DisablePoliciesRequest, options?: RequestOptions): Promise<DisablePoliciesResponse>;
/**

@@ -332,5 +376,5 @@ * Disable a policy.

*
* - the Cerbos policy decision point server to be at least v0.25 and configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api.html | admin API} enabled, and
* - the Cerbos policy decision point server to be at least v0.25 and configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api | admin API} enabled, and
*
* - a dynamic {@link https://docs.cerbos.dev/cerbos/latest/configuration/storage.html | storage backend}.
* - a dynamic {@link https://docs.cerbos.dev/cerbos/latest/configuration/storage | storage backend}.
*

@@ -342,3 +386,3 @@ * @example

*/
disablePolicy(id: string): Promise<boolean>;
disablePolicy(id: string, options?: RequestOptions): Promise<boolean>;
/**

@@ -352,5 +396,5 @@ * Enable multiple policies.

*
* - the Cerbos policy decision point server to be at least v0.26 and configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api.html | admin API} enabled, and
* - the Cerbos policy decision point server to be at least v0.26 and configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api | admin API} enabled, and
*
* - a dynamic {@link https://docs.cerbos.dev/cerbos/latest/configuration/storage.html | storage backend}.
* - a dynamic {@link https://docs.cerbos.dev/cerbos/latest/configuration/storage | storage backend}.
*

@@ -364,3 +408,3 @@ * @example

*/
enablePolicies(request: EnablePoliciesRequest): Promise<EnablePoliciesResponse>;
enablePolicies(request: EnablePoliciesRequest, options?: RequestOptions): Promise<EnablePoliciesResponse>;
/**

@@ -374,5 +418,5 @@ * Enable a policy.

*
* - the Cerbos policy decision point server to be at least v0.26 and configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api.html | admin API} enabled, and
* - the Cerbos policy decision point server to be at least v0.26 and configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api | admin API} enabled, and
*
* - a dynamic {@link https://docs.cerbos.dev/cerbos/latest/configuration/storage.html | storage backend}.
* - a dynamic {@link https://docs.cerbos.dev/cerbos/latest/configuration/storage | storage backend}.
*

@@ -384,3 +428,3 @@ * @example

*/
enablePolicy(id: string): Promise<boolean>;
enablePolicy(id: string, options?: RequestOptions): Promise<boolean>;
/**

@@ -394,3 +438,3 @@ * Fetch multiple policies by ID.

*
* - the Cerbos policy decision point server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api.html | admin API} enabled.
* - the Cerbos policy decision point server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api | admin API} enabled.
*

@@ -404,3 +448,3 @@ * @example

*/
getPolicies(request: GetPoliciesRequest): Promise<GetPoliciesResponse>;
getPolicies(request: GetPoliciesRequest, options?: RequestOptions): Promise<GetPoliciesResponse>;
/**

@@ -414,3 +458,3 @@ * Fetch a policy by ID.

*
* - the Cerbos policy decision point server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api.html | admin API} enabled.
* - the Cerbos policy decision point server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api | admin API} enabled.
*

@@ -422,3 +466,3 @@ * @example

*/
getPolicy(id: string): Promise<Policy | undefined>;
getPolicy(id: string, options?: RequestOptions): Promise<Policy | undefined>;
/**

@@ -432,3 +476,3 @@ * Fetch a schema by ID.

*
* - the Cerbos policy decision point server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api.html | admin API} enabled.
* - the Cerbos policy decision point server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api | admin API} enabled.
*

@@ -440,3 +484,3 @@ * @example

*/
getSchema(id: string): Promise<Schema | undefined>;
getSchema(id: string, options?: RequestOptions): Promise<Schema | undefined>;
/**

@@ -450,3 +494,3 @@ * Fetch multiple schemas by ID.

*
* - the Cerbos policy decision point server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api.html | admin API} enabled.
* - the Cerbos policy decision point server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api | admin API} enabled.
*

@@ -460,3 +504,3 @@ * @example

*/
getSchemas(request: GetSchemasRequest): Promise<GetSchemasResponse>;
getSchemas(request: GetSchemasRequest, options?: RequestOptions): Promise<GetSchemasResponse>;
/**

@@ -482,3 +526,3 @@ * Check if a principal is allowed to perform an action on a resource.

*/
isAllowed(request: IsAllowedRequest): Promise<boolean>;
isAllowed(request: IsAllowedRequest, options?: RequestOptions): Promise<boolean>;
/**

@@ -492,3 +536,3 @@ * List policies.

*
* - the Cerbos policy decision point server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api.html | admin API} enabled.
* - the Cerbos policy decision point server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api | admin API} enabled.
*

@@ -500,3 +544,3 @@ * @example

*/
listPolicies(request?: ListPoliciesRequest): Promise<ListPoliciesResponse>;
listPolicies(request?: ListPoliciesRequest, options?: RequestOptions): Promise<ListPoliciesResponse>;
/**

@@ -510,3 +554,3 @@ * List schemas.

*
* - the Cerbos policy decision point server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api.html | admin API} enabled.
* - the Cerbos policy decision point server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api | admin API} enabled.
*

@@ -518,3 +562,3 @@ * @example

*/
listSchemas(): Promise<ListSchemasResponse>;
listSchemas(options?: RequestOptions): Promise<ListSchemasResponse>;
/**

@@ -536,3 +580,3 @@ * Produce a query plan that can be used to obtain a list of resources on which a principal is allowed to perform a particular action.

*/
planResources(request: PlanResourcesRequest): Promise<PlanResourcesResponse>;
planResources(request: PlanResourcesRequest, options?: RequestOptions): Promise<PlanResourcesResponse>;
/**

@@ -546,5 +590,5 @@ * Reload the store.

*
* - the Cerbos policy decision point server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api.html | admin API}, and
* - the Cerbos policy decision point server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api | admin API}, and
*
* - a reloadable {@link https://docs.cerbos.dev/cerbos/latest/configuration/storage.html | storage backend}.
* - a reloadable {@link https://docs.cerbos.dev/cerbos/latest/configuration/storage | storage backend}.
*

@@ -556,11 +600,13 @@ * @example

*/
reloadStore(request: ReloadStoreRequest): Promise<void>;
reloadStore(request: ReloadStoreRequest, options?: RequestOptions): Promise<void>;
/**
* Retrieve information about the Cerbos policy decision point server.
*/
serverInfo(): Promise<ServerInfo>;
serverInfo(options?: RequestOptions): Promise<ServerInfo>;
private admin;
private cerbos;
private send;
private mergeHeaders;
private handleValidationErrors;
}
//# sourceMappingURL=client.d.ts.map

@@ -24,8 +24,8 @@ "use strict";

class Client {
transport;
options;
transport;
/** @internal */
constructor(transport, options) {
this.transport = transport;
this.options = options;
this.transport = transport;
for (const instrumenter of instrumenters) {

@@ -43,5 +43,5 @@ this.transport = instrumenter(this.transport);

*
* - the Cerbos policy decision point server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api.html | admin API} enabled, and
* - the Cerbos policy decision point server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api | admin API} enabled, and
*
* - a dynamic {@link https://docs.cerbos.dev/cerbos/latest/configuration/storage.html | storage backend}.
* - a dynamic {@link https://docs.cerbos.dev/cerbos/latest/configuration/storage | storage backend}.
*

@@ -90,4 +90,4 @@ * @example

*/
async addOrUpdatePolicies(request) {
await this.admin("addOrUpdatePolicy", (0, toProtobuf_1.addOrUpdatePoliciesRequestToProtobuf)(request));
async addOrUpdatePolicies(request, options) {
await this.admin("addOrUpdatePolicy", (0, toProtobuf_1.addOrUpdatePoliciesRequestToProtobuf)(request), options);
}

@@ -102,5 +102,5 @@ /**

*
* - the Cerbos policy decision point server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api.html | admin API} enabled, and
* - the Cerbos policy decision point server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api | admin API} enabled, and
*
* - a dynamic {@link https://docs.cerbos.dev/cerbos/latest/configuration/storage.html | storage backend}.
* - a dynamic {@link https://docs.cerbos.dev/cerbos/latest/configuration/storage | storage backend}.
*

@@ -148,4 +148,4 @@ * @example

*/
async addOrUpdateSchemas(request) {
await this.admin("addOrUpdateSchema", (0, toProtobuf_1.addOrUpdateSchemasRequestToProtobuf)(request));
async addOrUpdateSchemas(request, options) {
await this.admin("addOrUpdateSchema", (0, toProtobuf_1.addOrUpdateSchemasRequestToProtobuf)(request), options);
}

@@ -174,8 +174,5 @@ /**

*/
async checkResource(request) {
async checkResource(request, options) {
const { resource, actions, ...rest } = request;
const response = await this.checkResources({
resources: [{ resource, actions }],
...rest,
});
const response = await this.checkResources({ resources: [{ resource, actions }], ...rest }, options);
const result = response.findResult(resource);

@@ -224,4 +221,4 @@ if (!result) {

*/
async checkResources(request) {
const response = (0, fromProtobuf_1.checkResourcesResponseFromProtobuf)(await this.cerbos("checkResources", (0, toProtobuf_1.checkResourcesRequestToProtobuf)(request)));
async checkResources(request, options) {
const response = (0, fromProtobuf_1.checkResourcesResponseFromProtobuf)(await this.cerbos("checkResources", (0, toProtobuf_1.checkResourcesRequestToProtobuf)(request), options));
this.handleValidationErrors(response);

@@ -238,5 +235,5 @@ return response;

*
* - the Cerbos policy decision point (PDP) server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api.html | admin API} enabled, and
* - the Cerbos policy decision point (PDP) server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api | admin API} enabled, and
*
* - a dynamic {@link https://docs.cerbos.dev/cerbos/latest/configuration/storage.html | storage backend}.
* - a dynamic {@link https://docs.cerbos.dev/cerbos/latest/configuration/storage | storage backend}.
*

@@ -252,4 +249,4 @@ * The way this method handles failure depends on the version of the connected PDP server.

*/
async deleteSchema(id) {
const { deletedSchemas } = await this.deleteSchemas({ ids: [id] });
async deleteSchema(id, options) {
const { deletedSchemas } = await this.deleteSchemas({ ids: [id] }, options);
return deletedSchemas === 1;

@@ -265,5 +262,5 @@ }

*
* - the Cerbos policy decision point (PDP) server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api.html | admin API} enabled, and
* - the Cerbos policy decision point (PDP) server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api | admin API} enabled, and
*
* - a dynamic {@link https://docs.cerbos.dev/cerbos/latest/configuration/storage.html | storage backend}.
* - a dynamic {@link https://docs.cerbos.dev/cerbos/latest/configuration/storage | storage backend}.
*

@@ -281,4 +278,4 @@ * The way this method handles failure depends on the version of the connected PDP server.

*/
async deleteSchemas(request) {
return (0, fromProtobuf_1.deleteSchemasResponseFromProtobuf)(await this.admin("deleteSchema", (0, toProtobuf_1.deleteSchemasRequestToProtobuf)(request)));
async deleteSchemas(request, options) {
return (0, fromProtobuf_1.deleteSchemasResponseFromProtobuf)(await this.admin("deleteSchema", (0, toProtobuf_1.deleteSchemasRequestToProtobuf)(request), options));
}

@@ -293,5 +290,5 @@ /**

*
* - the Cerbos policy decision point server to be at least v0.25 and configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api.html | admin API} enabled, and
* - the Cerbos policy decision point server to be at least v0.25 and configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api | admin API} enabled, and
*
* - a dynamic {@link https://docs.cerbos.dev/cerbos/latest/configuration/storage.html | storage backend}.
* - a dynamic {@link https://docs.cerbos.dev/cerbos/latest/configuration/storage | storage backend}.
*

@@ -305,4 +302,4 @@ * @example

*/
async disablePolicies(request) {
return (0, fromProtobuf_1.disablePoliciesResponseFromProtobuf)(await this.admin("disablePolicy", (0, toProtobuf_1.disablePoliciesRequestToProtobuf)(request)));
async disablePolicies(request, options) {
return (0, fromProtobuf_1.disablePoliciesResponseFromProtobuf)(await this.admin("disablePolicy", (0, toProtobuf_1.disablePoliciesRequestToProtobuf)(request), options));
}

@@ -317,5 +314,5 @@ /**

*
* - the Cerbos policy decision point server to be at least v0.25 and configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api.html | admin API} enabled, and
* - the Cerbos policy decision point server to be at least v0.25 and configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api | admin API} enabled, and
*
* - a dynamic {@link https://docs.cerbos.dev/cerbos/latest/configuration/storage.html | storage backend}.
* - a dynamic {@link https://docs.cerbos.dev/cerbos/latest/configuration/storage | storage backend}.
*

@@ -327,4 +324,4 @@ * @example

*/
async disablePolicy(id) {
const { disabledPolicies } = await this.disablePolicies({ ids: [id] });
async disablePolicy(id, options) {
const { disabledPolicies } = await this.disablePolicies({ ids: [id] }, options);
return disabledPolicies === 1;

@@ -340,5 +337,5 @@ }

*
* - the Cerbos policy decision point server to be at least v0.26 and configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api.html | admin API} enabled, and
* - the Cerbos policy decision point server to be at least v0.26 and configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api | admin API} enabled, and
*
* - a dynamic {@link https://docs.cerbos.dev/cerbos/latest/configuration/storage.html | storage backend}.
* - a dynamic {@link https://docs.cerbos.dev/cerbos/latest/configuration/storage | storage backend}.
*

@@ -352,4 +349,4 @@ * @example

*/
async enablePolicies(request) {
return (0, fromProtobuf_1.enablePoliciesResponseFromProtobuf)(await this.admin("enablePolicy", (0, toProtobuf_1.enablePoliciesRequestToProtobuf)(request)));
async enablePolicies(request, options) {
return (0, fromProtobuf_1.enablePoliciesResponseFromProtobuf)(await this.admin("enablePolicy", (0, toProtobuf_1.enablePoliciesRequestToProtobuf)(request), options));
}

@@ -364,5 +361,5 @@ /**

*
* - the Cerbos policy decision point server to be at least v0.26 and configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api.html | admin API} enabled, and
* - the Cerbos policy decision point server to be at least v0.26 and configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api | admin API} enabled, and
*
* - a dynamic {@link https://docs.cerbos.dev/cerbos/latest/configuration/storage.html | storage backend}.
* - a dynamic {@link https://docs.cerbos.dev/cerbos/latest/configuration/storage | storage backend}.
*

@@ -374,4 +371,4 @@ * @example

*/
async enablePolicy(id) {
const { enabledPolicies } = await this.enablePolicies({ ids: [id] });
async enablePolicy(id, options) {
const { enabledPolicies } = await this.enablePolicies({ ids: [id] }, options);
return enabledPolicies === 1;

@@ -387,3 +384,3 @@ }

*
* - the Cerbos policy decision point server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api.html | admin API} enabled.
* - the Cerbos policy decision point server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api | admin API} enabled.
*

@@ -397,4 +394,4 @@ * @example

*/
async getPolicies(request) {
return (0, fromProtobuf_1.getPoliciesResponseFromProtobuf)(await this.admin("getPolicy", (0, toProtobuf_1.getPoliciesRequestToProtobuf)(request)));
async getPolicies(request, options) {
return (0, fromProtobuf_1.getPoliciesResponseFromProtobuf)(await this.admin("getPolicy", (0, toProtobuf_1.getPoliciesRequestToProtobuf)(request), options));
}

@@ -409,3 +406,3 @@ /**

*
* - the Cerbos policy decision point server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api.html | admin API} enabled.
* - the Cerbos policy decision point server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api | admin API} enabled.
*

@@ -417,4 +414,4 @@ * @example

*/
async getPolicy(id) {
const { policies: [policy], } = await this.getPolicies({ ids: [id] });
async getPolicy(id, options) {
const { policies: [policy], } = await this.getPolicies({ ids: [id] }, options);
return policy;

@@ -430,3 +427,3 @@ }

*
* - the Cerbos policy decision point server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api.html | admin API} enabled.
* - the Cerbos policy decision point server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api | admin API} enabled.
*

@@ -438,4 +435,4 @@ * @example

*/
async getSchema(id) {
const { schemas: [schema], } = await this.getSchemas({ ids: [id] });
async getSchema(id, options) {
const { schemas: [schema], } = await this.getSchemas({ ids: [id] }, options);
return schema;

@@ -451,3 +448,3 @@ }

*
* - the Cerbos policy decision point server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api.html | admin API} enabled.
* - the Cerbos policy decision point server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api | admin API} enabled.
*

@@ -461,4 +458,4 @@ * @example

*/
async getSchemas(request) {
return (0, fromProtobuf_1.getSchemasResponseFromProtobuf)(await this.admin("getSchema", (0, toProtobuf_1.getSchemasRequestToProtobuf)(request)));
async getSchemas(request, options) {
return (0, fromProtobuf_1.getSchemasResponseFromProtobuf)(await this.admin("getSchema", (0, toProtobuf_1.getSchemasRequestToProtobuf)(request), options));
}

@@ -485,5 +482,5 @@ /**

*/
async isAllowed(request) {
async isAllowed(request, options) {
const { action, ...rest } = request;
const result = await this.checkResource({ actions: [action], ...rest });
const result = await this.checkResource({ actions: [action], ...rest }, options);
const allowed = result.isAllowed(action);

@@ -503,3 +500,3 @@ if (allowed === undefined) {

*
* - the Cerbos policy decision point server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api.html | admin API} enabled.
* - the Cerbos policy decision point server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api | admin API} enabled.
*

@@ -511,4 +508,4 @@ * @example

*/
async listPolicies(request = {}) {
return (0, fromProtobuf_1.listPoliciesResponseFromProtobuf)(await this.admin("listPolicies", (0, toProtobuf_1.listPoliciesRequestToProtobuf)(request)));
async listPolicies(request = {}, options) {
return (0, fromProtobuf_1.listPoliciesResponseFromProtobuf)(await this.admin("listPolicies", (0, toProtobuf_1.listPoliciesRequestToProtobuf)(request), options));
}

@@ -523,3 +520,3 @@ /**

*
* - the Cerbos policy decision point server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api.html | admin API} enabled.
* - the Cerbos policy decision point server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api | admin API} enabled.
*

@@ -531,4 +528,4 @@ * @example

*/
async listSchemas() {
return (0, fromProtobuf_1.listSchemasResponseFromProtobuf)(await this.admin("listSchemas", {}));
async listSchemas(options) {
return (0, fromProtobuf_1.listSchemasResponseFromProtobuf)(await this.admin("listSchemas", {}, options));
}

@@ -551,4 +548,4 @@ /**

*/
async planResources(request) {
const response = (0, fromProtobuf_1.planResourcesResponseFromProtobuf)(await this.cerbos("planResources", (0, toProtobuf_1.planResourcesRequestToProtobuf)(request)));
async planResources(request, options) {
const response = (0, fromProtobuf_1.planResourcesResponseFromProtobuf)(await this.cerbos("planResources", (0, toProtobuf_1.planResourcesRequestToProtobuf)(request), options));
this.handleValidationErrors(response);

@@ -565,5 +562,5 @@ return response;

*
* - the Cerbos policy decision point server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api.html | admin API}, and
* - the Cerbos policy decision point server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api | admin API}, and
*
* - a reloadable {@link https://docs.cerbos.dev/cerbos/latest/configuration/storage.html | storage backend}.
* - a reloadable {@link https://docs.cerbos.dev/cerbos/latest/configuration/storage | storage backend}.
*

@@ -575,4 +572,4 @@ * @example

*/
async reloadStore(request) {
await this.admin("reloadStore", request);
async reloadStore(request, options) {
await this.admin("reloadStore", request, options);
}

@@ -582,11 +579,30 @@ /**

*/
async serverInfo() {
return await this.cerbos("serverInfo", {});
async serverInfo(options) {
return await this.cerbos("serverInfo", {}, options);
}
async admin(rpc, request) {
return await this.transport("admin", rpc, request, this.options.adminCredentials);
async admin(rpc, request, options) {
return await this.send("admin", rpc, request, this.options.adminCredentials, options);
}
async cerbos(rpc, request) {
return await this.transport("cerbos", rpc, request);
async cerbos(rpc, request, options) {
return await this.send("cerbos", rpc, request, undefined, options);
}
async send(service, rpc, request, adminCredentials, { headers } = {}) {
return await this.transport(service, rpc, request, await this.mergeHeaders(headers, adminCredentials));
}
async mergeHeaders(override, adminCredentials) {
const init = this.options.headers;
const headers = new Headers(typeof init === "function" ? await init() : init);
if (adminCredentials) {
headers.set("Authorization", `Basic ${btoa(`${adminCredentials.username}:${adminCredentials.password}`)}`);
}
if (this.options.playgroundInstance) {
headers.set("Playground-Instance", this.options.playgroundInstance);
}
if (override) {
for (const [name, value] of new Headers(override)) {
headers.set(name, value);
}
}
return headers;
}
handleValidationErrors({ validationErrors, }) {

@@ -593,0 +609,0 @@ const { onValidationError } = this.options;

/**
* Common types used by the {@link @cerbos/grpc# | gRPC} and {@link @cerbos/http# | HTTP} client libraries.
* Common types used by the {@link @cerbos/grpc# | gRPC}, {@link @cerbos/http# | HTTP}, and {@link @cerbos/embedded# | embedded} client libraries.
*

@@ -4,0 +4,0 @@ * @packageDocumentation

"use strict";
/**
* Common types used by the {@link @cerbos/grpc# | gRPC} and {@link @cerbos/http# | HTTP} client libraries.
* Common types used by the {@link @cerbos/grpc# | gRPC}, {@link @cerbos/http# | HTTP}, and {@link @cerbos/embedded# | embedded} client libraries.
*

@@ -5,0 +5,0 @@ * @packageDocumentation

export declare const protobufPackage = "google.protobuf";
export declare enum Edition {
EDITION_UNKNOWN = 0,
EDITION_PROTO2 = 998,
EDITION_PROTO3 = 999,
EDITION_2023 = 1000,
EDITION_1_TEST_ONLY = 1,
EDITION_2_TEST_ONLY = 2,
EDITION_99997_TEST_ONLY = 99997,
EDITION_99998_TEST_ONLY = 99998,
EDITION_99999_TEST_ONLY = 99999
}
export interface FileOptions {

@@ -23,2 +34,3 @@ javaPackage: string;

rubyPackage: string;
features: FeatureSet | undefined;
uninterpretedOption: UninterpretedOption[];

@@ -37,2 +49,3 @@ }

deprecatedLegacyJsonFieldConflicts: boolean;
features: FeatureSet | undefined;
uninterpretedOption: UninterpretedOption[];

@@ -50,3 +63,5 @@ }

retention: FieldOptions_OptionRetention;
target: FieldOptions_OptionTargetType;
targets: FieldOptions_OptionTargetType[];
editionDefaults: FieldOptions_EditionDefault[];
features: FeatureSet | undefined;
uninterpretedOption: UninterpretedOption[];

@@ -81,6 +96,12 @@ }

}
export interface FieldOptions_EditionDefault {
edition: Edition;
value: string;
}
export interface OneofOptions {
features: FeatureSet | undefined;
uninterpretedOption: UninterpretedOption[];
}
export interface ServiceOptions {
features: FeatureSet | undefined;
deprecated: boolean;

@@ -92,2 +113,3 @@ uninterpretedOption: UninterpretedOption[];

idempotencyLevel: MethodOptions_IdempotencyLevel;
features: FeatureSet | undefined;
uninterpretedOption: UninterpretedOption[];

@@ -113,2 +135,41 @@ }

}
export interface FeatureSet {
fieldPresence: FeatureSet_FieldPresence;
enumType: FeatureSet_EnumType;
repeatedFieldEncoding: FeatureSet_RepeatedFieldEncoding;
utf8Validation: FeatureSet_Utf8Validation;
messageEncoding: FeatureSet_MessageEncoding;
jsonFormat: FeatureSet_JsonFormat;
}
export declare enum FeatureSet_FieldPresence {
FIELD_PRESENCE_UNKNOWN = 0,
EXPLICIT = 1,
IMPLICIT = 2,
LEGACY_REQUIRED = 3
}
export declare enum FeatureSet_EnumType {
ENUM_TYPE_UNKNOWN = 0,
OPEN = 1,
CLOSED = 2
}
export declare enum FeatureSet_RepeatedFieldEncoding {
REPEATED_FIELD_ENCODING_UNKNOWN = 0,
PACKED = 1,
EXPANDED = 2
}
export declare enum FeatureSet_Utf8Validation {
UTF8_VALIDATION_UNKNOWN = 0,
NONE = 1,
VERIFY = 2
}
export declare enum FeatureSet_MessageEncoding {
MESSAGE_ENCODING_UNKNOWN = 0,
LENGTH_PREFIXED = 1,
DELIMITED = 2
}
export declare enum FeatureSet_JsonFormat {
JSON_FORMAT_UNKNOWN = 0,
ALLOW = 1,
LEGACY_BEST_EFFORT = 2
}
//# sourceMappingURL=descriptor.d.ts.map
"use strict";
/* eslint-disable */
Object.defineProperty(exports, "__esModule", { value: true });
exports.MethodOptions_IdempotencyLevel = exports.FieldOptions_OptionTargetType = exports.FieldOptions_OptionRetention = exports.FieldOptions_JSType = exports.FieldOptions_CType = exports.FileOptions_OptimizeMode = exports.protobufPackage = void 0;
exports.FeatureSet_JsonFormat = exports.FeatureSet_MessageEncoding = exports.FeatureSet_Utf8Validation = exports.FeatureSet_RepeatedFieldEncoding = exports.FeatureSet_EnumType = exports.FeatureSet_FieldPresence = exports.MethodOptions_IdempotencyLevel = exports.FieldOptions_OptionTargetType = exports.FieldOptions_OptionRetention = exports.FieldOptions_JSType = exports.FieldOptions_CType = exports.FileOptions_OptimizeMode = exports.Edition = exports.protobufPackage = void 0;
exports.protobufPackage = "google.protobuf";
var Edition;
(function (Edition) {
Edition[Edition["EDITION_UNKNOWN"] = 0] = "EDITION_UNKNOWN";
Edition[Edition["EDITION_PROTO2"] = 998] = "EDITION_PROTO2";
Edition[Edition["EDITION_PROTO3"] = 999] = "EDITION_PROTO3";
Edition[Edition["EDITION_2023"] = 1000] = "EDITION_2023";
Edition[Edition["EDITION_1_TEST_ONLY"] = 1] = "EDITION_1_TEST_ONLY";
Edition[Edition["EDITION_2_TEST_ONLY"] = 2] = "EDITION_2_TEST_ONLY";
Edition[Edition["EDITION_99997_TEST_ONLY"] = 99997] = "EDITION_99997_TEST_ONLY";
Edition[Edition["EDITION_99998_TEST_ONLY"] = 99998] = "EDITION_99998_TEST_ONLY";
Edition[Edition["EDITION_99999_TEST_ONLY"] = 99999] = "EDITION_99999_TEST_ONLY";
})(Edition || (exports.Edition = Edition = {}));
var FileOptions_OptimizeMode;

@@ -49,2 +61,39 @@ (function (FileOptions_OptimizeMode) {

})(MethodOptions_IdempotencyLevel || (exports.MethodOptions_IdempotencyLevel = MethodOptions_IdempotencyLevel = {}));
var FeatureSet_FieldPresence;
(function (FeatureSet_FieldPresence) {
FeatureSet_FieldPresence[FeatureSet_FieldPresence["FIELD_PRESENCE_UNKNOWN"] = 0] = "FIELD_PRESENCE_UNKNOWN";
FeatureSet_FieldPresence[FeatureSet_FieldPresence["EXPLICIT"] = 1] = "EXPLICIT";
FeatureSet_FieldPresence[FeatureSet_FieldPresence["IMPLICIT"] = 2] = "IMPLICIT";
FeatureSet_FieldPresence[FeatureSet_FieldPresence["LEGACY_REQUIRED"] = 3] = "LEGACY_REQUIRED";
})(FeatureSet_FieldPresence || (exports.FeatureSet_FieldPresence = FeatureSet_FieldPresence = {}));
var FeatureSet_EnumType;
(function (FeatureSet_EnumType) {
FeatureSet_EnumType[FeatureSet_EnumType["ENUM_TYPE_UNKNOWN"] = 0] = "ENUM_TYPE_UNKNOWN";
FeatureSet_EnumType[FeatureSet_EnumType["OPEN"] = 1] = "OPEN";
FeatureSet_EnumType[FeatureSet_EnumType["CLOSED"] = 2] = "CLOSED";
})(FeatureSet_EnumType || (exports.FeatureSet_EnumType = FeatureSet_EnumType = {}));
var FeatureSet_RepeatedFieldEncoding;
(function (FeatureSet_RepeatedFieldEncoding) {
FeatureSet_RepeatedFieldEncoding[FeatureSet_RepeatedFieldEncoding["REPEATED_FIELD_ENCODING_UNKNOWN"] = 0] = "REPEATED_FIELD_ENCODING_UNKNOWN";
FeatureSet_RepeatedFieldEncoding[FeatureSet_RepeatedFieldEncoding["PACKED"] = 1] = "PACKED";
FeatureSet_RepeatedFieldEncoding[FeatureSet_RepeatedFieldEncoding["EXPANDED"] = 2] = "EXPANDED";
})(FeatureSet_RepeatedFieldEncoding || (exports.FeatureSet_RepeatedFieldEncoding = FeatureSet_RepeatedFieldEncoding = {}));
var FeatureSet_Utf8Validation;
(function (FeatureSet_Utf8Validation) {
FeatureSet_Utf8Validation[FeatureSet_Utf8Validation["UTF8_VALIDATION_UNKNOWN"] = 0] = "UTF8_VALIDATION_UNKNOWN";
FeatureSet_Utf8Validation[FeatureSet_Utf8Validation["NONE"] = 1] = "NONE";
FeatureSet_Utf8Validation[FeatureSet_Utf8Validation["VERIFY"] = 2] = "VERIFY";
})(FeatureSet_Utf8Validation || (exports.FeatureSet_Utf8Validation = FeatureSet_Utf8Validation = {}));
var FeatureSet_MessageEncoding;
(function (FeatureSet_MessageEncoding) {
FeatureSet_MessageEncoding[FeatureSet_MessageEncoding["MESSAGE_ENCODING_UNKNOWN"] = 0] = "MESSAGE_ENCODING_UNKNOWN";
FeatureSet_MessageEncoding[FeatureSet_MessageEncoding["LENGTH_PREFIXED"] = 1] = "LENGTH_PREFIXED";
FeatureSet_MessageEncoding[FeatureSet_MessageEncoding["DELIMITED"] = 2] = "DELIMITED";
})(FeatureSet_MessageEncoding || (exports.FeatureSet_MessageEncoding = FeatureSet_MessageEncoding = {}));
var FeatureSet_JsonFormat;
(function (FeatureSet_JsonFormat) {
FeatureSet_JsonFormat[FeatureSet_JsonFormat["JSON_FORMAT_UNKNOWN"] = 0] = "JSON_FORMAT_UNKNOWN";
FeatureSet_JsonFormat[FeatureSet_JsonFormat["ALLOW"] = 1] = "ALLOW";
FeatureSet_JsonFormat[FeatureSet_JsonFormat["LEGACY_BEST_EFFORT"] = 2] = "LEGACY_BEST_EFFORT";
})(FeatureSet_JsonFormat || (exports.FeatureSet_JsonFormat = FeatureSet_JsonFormat = {}));
//# sourceMappingURL=descriptor.js.map

@@ -13,3 +13,3 @@ import type { CheckResourcesResultMetadataEffect } from "./CheckResourcesResultMetadataEffect";

/**
* The {@link https://docs.cerbos.dev/cerbos/latest/policies/derived_roles.html | derived roles} that were applied to the principal for the resource.
* The {@link https://docs.cerbos.dev/cerbos/latest/policies/derived_roles | derived roles} that were applied to the principal for the resource.
*/

@@ -16,0 +16,0 @@ effectiveDerivedRoles: string[];

@@ -12,3 +12,3 @@ /**

/**
* The {@link https://docs.cerbos.dev/cerbos/latest/policies/scoped_policies.html | policy scope} that was used to make the decision.
* The {@link https://docs.cerbos.dev/cerbos/latest/policies/scoped_policies | policy scope} that was used to make the decision.
*/

@@ -15,0 +15,0 @@ matchedScope: string;

@@ -20,3 +20,3 @@ /**

/**
* The {@link https://docs.cerbos.dev/cerbos/latest/policies/scoped_policies.html | policy scope} against which the check was performed.
* The {@link https://docs.cerbos.dev/cerbos/latest/policies/scoped_policies | policy scope} against which the check was performed.
*/

@@ -23,0 +23,0 @@ scope: string;

import type { Condition } from "./Condition";
/**
* The definition of a {@link https://docs.cerbos.dev/cerbos/latest/policies/derived_roles.html | derived role}.
* The definition of a {@link https://docs.cerbos.dev/cerbos/latest/policies/derived_roles | derived role}.
*

@@ -5,0 +5,0 @@ * @public

import type { DerivedRolesBody } from "./DerivedRolesBody";
import type { PolicyBase } from "./PolicyBase";
/**
* A set of {@link https://docs.cerbos.dev/cerbos/latest/policies/derived_roles.html | derived roles}
* A set of {@link https://docs.cerbos.dev/cerbos/latest/policies/derived_roles | derived roles}
* to augment static RBAC roles with contextual data to provide more fine-grained control at runtime.

@@ -6,0 +6,0 @@ *

import type { DerivedRoleDefinition } from "./DerivedRoleDefinition";
import type { Variables } from "./Variables";
/**
* A set of {@link https://docs.cerbos.dev/cerbos/latest/policies/derived_roles.html | derived roles}
* A set of {@link https://docs.cerbos.dev/cerbos/latest/policies/derived_roles | derived roles}
* to augment static RBAC roles with contextual data to provide more fine-grained control at runtime.

@@ -19,3 +19,3 @@ *

/**
* {@link https://docs.cerbos.dev/cerbos/latest/policies/variables.html | Variables} defined for use in conditions.
* {@link https://docs.cerbos.dev/cerbos/latest/policies/variables | Variables} defined for use in conditions.
*

@@ -22,0 +22,0 @@ * @remarks

import type { ExportVariablesBody } from "./ExportVariablesBody";
import type { PolicyBase } from "./PolicyBase";
/**
* A set of {@link https://docs.cerbos.dev/cerbos/latest/policies/variables.html#export | exported variables}
* A set of {@link https://docs.cerbos.dev/cerbos/latest/policies/variables#export | exported variables}
* to be reused in other policies.

@@ -6,0 +6,0 @@ *

/**
* A set of {@link https://docs.cerbos.dev/cerbos/latest/policies/variables.html#export | exported variables}
* A set of {@link https://docs.cerbos.dev/cerbos/latest/policies/variables#export | exported variables}
* to be reused in other policies.

@@ -4,0 +4,0 @@ *

/**
* A JSON Web Token to use as an auxiliary data source, which will be verified against the Cerbos policy decision point (PDP) server's {@link https://docs.cerbos.dev/cerbos/latest/configuration/auxdata.html#_jwt | configured JSON Web Key Sets (JWKS)} unless verification is disabled on the server.
* A JSON Web Token to use as an auxiliary data source, which will be verified against the Cerbos policy decision point (PDP) server's {@link https://docs.cerbos.dev/cerbos/latest/configuration/auxdata#_jwt | configured JSON Web Key Sets (JWKS)} unless verification is disabled on the server.
*

@@ -4,0 +4,0 @@ * @public

@@ -8,3 +8,3 @@ /**

/**
* A {@link https://docs.cerbos.dev/cerbos/latest/policies/conditions.html | Common Expression Language} expression to evaluate.
* A {@link https://docs.cerbos.dev/cerbos/latest/policies/conditions | Common Expression Language} expression to evaluate.
*/

@@ -11,0 +11,0 @@ expr: string;

@@ -8,3 +8,3 @@ /**

/**
* A {@link https://docs.cerbos.dev/cerbos/latest/policies/conditions.html | Common Expression Language} expression to evaluate.
* A {@link https://docs.cerbos.dev/cerbos/latest/policies/conditions | Common Expression Language} expression to evaluate.
*/

@@ -11,0 +11,0 @@ expr: string;

@@ -12,3 +12,3 @@ /**

/**
* The {@link https://docs.cerbos.dev/cerbos/latest/policies/scoped_policies.html | policy scope} that was used to plan the query.
* The {@link https://docs.cerbos.dev/cerbos/latest/policies/scoped_policies | policy scope} that was used to plan the query.
*/

@@ -15,0 +15,0 @@ matchedScope: string;

@@ -6,3 +6,3 @@ import type { DerivedRoles } from "./DerivedRoles";

/**
* A {@link https://docs.cerbos.dev/cerbos/latest/policies/index.html | policy} definition.
* A {@link https://docs.cerbos.dev/cerbos/latest/policies/ | policy} definition.
*

@@ -9,0 +9,0 @@ * @public

@@ -36,3 +36,3 @@ import type { Value } from "./Value";

/**
* The {@link https://docs.cerbos.dev/cerbos/latest/policies/scoped_policies.html | policy scope} to use when authorizing the principal.
* The {@link https://docs.cerbos.dev/cerbos/latest/policies/scoped_policies | policy scope} to use when authorizing the principal.
*

@@ -39,0 +39,0 @@ * @defaultValue `""`

import type { PolicyBase } from "./PolicyBase";
import type { PrincipalPolicyBody } from "./PrincipalPolicyBody";
/**
* A {@link https://docs.cerbos.dev/cerbos/latest/policies/principal_policies.html | policy} defining overrides for a specific user.
* A {@link https://docs.cerbos.dev/cerbos/latest/policies/principal_policies | policy} defining overrides for a specific user.
*

@@ -6,0 +6,0 @@ * @public

import type { PrincipalRule } from "./PrincipalRule";
import type { Variables } from "./Variables";
/**
* A {@link https://docs.cerbos.dev/cerbos/latest/policies/principal_policies.html | policy} defining overrides for a specific user.
* A {@link https://docs.cerbos.dev/cerbos/latest/policies/principal_policies | policy} defining overrides for a specific user.
*

@@ -27,7 +27,7 @@ * @public

/**
* {@link https://docs.cerbos.dev/cerbos/latest/policies/scoped_policies.html | Scope} of the policy.
* {@link https://docs.cerbos.dev/cerbos/latest/policies/scoped_policies | Scope} of the policy.
*/
scope?: string;
/**
* {@link https://docs.cerbos.dev/cerbos/latest/policies/variables.html | Variables} defined for use in conditions.
* {@link https://docs.cerbos.dev/cerbos/latest/policies/variables | Variables} defined for use in conditions.
*

@@ -34,0 +34,0 @@ * @remarks

@@ -36,3 +36,3 @@ import type { Value } from "./Value";

/**
* The {@link https://docs.cerbos.dev/cerbos/latest/policies/scoped_policies.html | policy scope} to use when checking the principal's permissions on the resource.
* The {@link https://docs.cerbos.dev/cerbos/latest/policies/scoped_policies | policy scope} to use when checking the principal's permissions on the resource.
*

@@ -39,0 +39,0 @@ * @defaultValue `""`

import type { PolicyBase } from "./PolicyBase";
import type { ResourcePolicyBody } from "./ResourcePolicyBody";
/**
* A {@link https://docs.cerbos.dev/cerbos/latest/policies/resource_policies.html | policy} defining rules for actions that can be performed on a given resource.
* A {@link https://docs.cerbos.dev/cerbos/latest/policies/resource_policies | policy} defining rules for actions that can be performed on a given resource.
*

@@ -6,0 +6,0 @@ * @public

@@ -5,3 +5,3 @@ import type { ResourceRule } from "./ResourceRule";

/**
* A {@link https://docs.cerbos.dev/cerbos/latest/policies/resource_policies.html | policy} defining rules for actions that can be performed on a given resource.
* A {@link https://docs.cerbos.dev/cerbos/latest/policies/resource_policies | policy} defining rules for actions that can be performed on a given resource.
*

@@ -25,3 +25,3 @@ * @public

/**
* Name of a set of {@link https://docs.cerbos.dev/cerbos/latest/policies/derived_roles.html | derived roles} to import.
* Name of a set of {@link https://docs.cerbos.dev/cerbos/latest/policies/derived_roles | derived roles} to import.
*/

@@ -34,11 +34,11 @@ importDerivedRoles?: string[];

/**
* {@link https://docs.cerbos.dev/cerbos/latest/policies/scoped_policies.html | Scope} of the policy.
* {@link https://docs.cerbos.dev/cerbos/latest/policies/scoped_policies | Scope} of the policy.
*/
scope?: string;
/**
* {@link https://docs.cerbos.dev/cerbos/latest/policies/schemas.html | Schemas} for principal and resource attributes.
* {@link https://docs.cerbos.dev/cerbos/latest/policies/schemas | Schemas} for principal and resource attributes.
*/
schemas?: SchemaRefs | undefined;
/**
* {@link https://docs.cerbos.dev/cerbos/latest/policies/variables.html | Variables} defined for use in conditions.
* {@link https://docs.cerbos.dev/cerbos/latest/policies/variables | Variables} defined for use in conditions.
*

@@ -45,0 +45,0 @@ * @remarks

/**
* {@link https://docs.cerbos.dev/cerbos/latest/policies/variables.html | Variables} defined for use in policy conditions.
* {@link https://docs.cerbos.dev/cerbos/latest/policies/variables | Variables} defined for use in policy conditions.
*

@@ -4,0 +4,0 @@ * @public

{
"name": "@cerbos/core",
"version": "0.14.0",
"description": "Common types used by the @cerbos/grpc and @cerbos/http client libraries",
"version": "0.15.0",
"description": "Common types used by the @cerbos/grpc, @cerbos/http, and @cerbos/embedded client libraries",
"repository": {

@@ -32,4 +32,4 @@ "type": "git",

"devDependencies": {
"@types/uuid": "9.0.4"
"@types/uuid": "9.0.7"
}
}

@@ -5,3 +5,3 @@ # @cerbos/core

Common types used by the [gRPC](../grpc/README.md) and [HTTP](../http/README.md) client libraries.
Common types used by the [gRPC](../grpc/README.md), [HTTP](../http/README.md), and [embedded](../embedded/README.md) client libraries.

@@ -8,0 +8,0 @@ ## Further reading

@@ -62,4 +62,3 @@ import {

request: _Request<Service, RPC>,
adminCredentials?: AdminCredentials,
metadata?: Record<string, string>,
headers: Headers,
) => Promise<_Response<Service, RPC>>;

@@ -83,2 +82,9 @@

/**
* HTTP headers from which to construct a {@link https://developer.mozilla.org/en-US/docs/Web/API/Headers | Headers} object.
*
* @public
*/
export type HeadersInit = [string, string][] | Record<string, string> | Headers;
/**
* Options for creating a new {@link Client}.

@@ -90,3 +96,3 @@ *

/**
* Credentials for the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api.html | admin API}.
* Credentials for the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api | admin API}.
*

@@ -98,2 +104,18 @@ * @defaultValue `undefined`

/**
* Headers to add to every request to the policy decision point.
*
* @remarks
* Headers can be included in the policy decision point's audit logs by setting the `includeMetadataKeys` or `excludeMetadataKeys` fields in the
* `audit` {@link https://docs.cerbos.dev/cerbos/latest/configuration/audit | configuration block}.
*
* The `User-Agent` header is set using {@link Options.userAgent}.
*
* @defaultValue `undefined`
*/
headers?:
| HeadersInit
| (() => HeadersInit | Promise<HeadersInit>)
| undefined;
/**
* Action to take when input fails schema validation.

@@ -120,6 +142,13 @@ *

playgroundInstance?: string | undefined;
/**
* Custom user agent to prepend to the built-in value.
*
* @defaultValue `undefined`
*/
userAgent?: string | undefined;
}
/**
* Credentials for the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api.html | admin API}.
* Credentials for the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api | admin API}.
*

@@ -141,2 +170,22 @@ * @public

/**
* Options for sending a request to the policy decision point.
*
* @public
*/
export interface RequestOptions {
/**
* Headers to add to the request.
*
* @remarks
* Headers can be included in the policy decision point's audit logs by setting the `includeMetadataKeys` or `excludeMetadataKeys` fields
* in the `audit` {@link https://docs.cerbos.dev/cerbos/latest/configuration/audit | configuration block}.
*
* The `User-Agent` header is set using {@link Options.userAgent}.
*
* @defaultValue `undefined`
*/
headers?: HeadersInit | undefined;
}
/**
* Base implementation of a client for interacting with the Cerbos policy decision point server.

@@ -147,10 +196,7 @@ *

export abstract class Client {
private readonly transport: _Transport;
/** @internal */
protected constructor(
transport: _Transport,
private readonly transport: _Transport,
private readonly options: Options,
) {
this.transport = transport;
for (const instrumenter of instrumenters) {

@@ -169,5 +215,5 @@ this.transport = instrumenter(this.transport);

*
* - the Cerbos policy decision point server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api.html | admin API} enabled, and
* - the Cerbos policy decision point server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api | admin API} enabled, and
*
* - a dynamic {@link https://docs.cerbos.dev/cerbos/latest/configuration/storage.html | storage backend}.
* - a dynamic {@link https://docs.cerbos.dev/cerbos/latest/configuration/storage | storage backend}.
*

@@ -218,2 +264,3 @@ * @example

request: AddOrUpdatePoliciesRequest,
options?: RequestOptions,
): Promise<void> {

@@ -223,2 +270,3 @@ await this.admin(

addOrUpdatePoliciesRequestToProtobuf(request),
options,
);

@@ -235,5 +283,5 @@ }

*
* - the Cerbos policy decision point server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api.html | admin API} enabled, and
* - the Cerbos policy decision point server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api | admin API} enabled, and
*
* - a dynamic {@link https://docs.cerbos.dev/cerbos/latest/configuration/storage.html | storage backend}.
* - a dynamic {@link https://docs.cerbos.dev/cerbos/latest/configuration/storage | storage backend}.
*

@@ -283,2 +331,3 @@ * @example

request: AddOrUpdateSchemasRequest,
options?: RequestOptions,
): Promise<void> {

@@ -288,2 +337,3 @@ await this.admin(

addOrUpdateSchemasRequestToProtobuf(request),
options,
);

@@ -316,9 +366,10 @@ }

request: CheckResourceRequest,
options?: RequestOptions,
): Promise<CheckResourcesResult> {
const { resource, actions, ...rest } = request;
const response = await this.checkResources({
resources: [{ resource, actions }],
...rest,
});
const response = await this.checkResources(
{ resources: [{ resource, actions }], ...rest },
options,
);

@@ -372,2 +423,3 @@ const result = response.findResult(resource);

request: CheckResourcesRequest,
options?: RequestOptions,
): Promise<CheckResourcesResponse> {

@@ -378,2 +430,3 @@ const response = checkResourcesResponseFromProtobuf(

checkResourcesRequestToProtobuf(request),
options,
),

@@ -395,5 +448,5 @@ );

*
* - the Cerbos policy decision point (PDP) server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api.html | admin API} enabled, and
* - the Cerbos policy decision point (PDP) server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api | admin API} enabled, and
*
* - a dynamic {@link https://docs.cerbos.dev/cerbos/latest/configuration/storage.html | storage backend}.
* - a dynamic {@link https://docs.cerbos.dev/cerbos/latest/configuration/storage | storage backend}.
*

@@ -409,4 +462,7 @@ * The way this method handles failure depends on the version of the connected PDP server.

*/
public async deleteSchema(id: string): Promise<boolean> {
const { deletedSchemas } = await this.deleteSchemas({ ids: [id] });
public async deleteSchema(
id: string,
options?: RequestOptions,
): Promise<boolean> {
const { deletedSchemas } = await this.deleteSchemas({ ids: [id] }, options);
return deletedSchemas === 1;

@@ -423,5 +479,5 @@ }

*
* - the Cerbos policy decision point (PDP) server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api.html | admin API} enabled, and
* - the Cerbos policy decision point (PDP) server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api | admin API} enabled, and
*
* - a dynamic {@link https://docs.cerbos.dev/cerbos/latest/configuration/storage.html | storage backend}.
* - a dynamic {@link https://docs.cerbos.dev/cerbos/latest/configuration/storage | storage backend}.
*

@@ -441,5 +497,10 @@ * The way this method handles failure depends on the version of the connected PDP server.

request: DeleteSchemasRequest,
options?: RequestOptions,
): Promise<DeleteSchemasResponse> {
return deleteSchemasResponseFromProtobuf(
await this.admin("deleteSchema", deleteSchemasRequestToProtobuf(request)),
await this.admin(
"deleteSchema",
deleteSchemasRequestToProtobuf(request),
options,
),
);

@@ -456,5 +517,5 @@ }

*
* - the Cerbos policy decision point server to be at least v0.25 and configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api.html | admin API} enabled, and
* - the Cerbos policy decision point server to be at least v0.25 and configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api | admin API} enabled, and
*
* - a dynamic {@link https://docs.cerbos.dev/cerbos/latest/configuration/storage.html | storage backend}.
* - a dynamic {@link https://docs.cerbos.dev/cerbos/latest/configuration/storage | storage backend}.
*

@@ -470,2 +531,3 @@ * @example

request: DisablePoliciesRequest,
options?: RequestOptions,
): Promise<DisablePoliciesResponse> {

@@ -476,2 +538,3 @@ return disablePoliciesResponseFromProtobuf(

disablePoliciesRequestToProtobuf(request),
options,
),

@@ -489,5 +552,5 @@ );

*
* - the Cerbos policy decision point server to be at least v0.25 and configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api.html | admin API} enabled, and
* - the Cerbos policy decision point server to be at least v0.25 and configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api | admin API} enabled, and
*
* - a dynamic {@link https://docs.cerbos.dev/cerbos/latest/configuration/storage.html | storage backend}.
* - a dynamic {@link https://docs.cerbos.dev/cerbos/latest/configuration/storage | storage backend}.
*

@@ -499,4 +562,11 @@ * @example

*/
public async disablePolicy(id: string): Promise<boolean> {
const { disabledPolicies } = await this.disablePolicies({ ids: [id] });
public async disablePolicy(
id: string,
options?: RequestOptions,
): Promise<boolean> {
const { disabledPolicies } = await this.disablePolicies(
{ ids: [id] },
options,
);
return disabledPolicies === 1;

@@ -513,5 +583,5 @@ }

*
* - the Cerbos policy decision point server to be at least v0.26 and configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api.html | admin API} enabled, and
* - the Cerbos policy decision point server to be at least v0.26 and configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api | admin API} enabled, and
*
* - a dynamic {@link https://docs.cerbos.dev/cerbos/latest/configuration/storage.html | storage backend}.
* - a dynamic {@link https://docs.cerbos.dev/cerbos/latest/configuration/storage | storage backend}.
*

@@ -527,2 +597,3 @@ * @example

request: EnablePoliciesRequest,
options?: RequestOptions,
): Promise<EnablePoliciesResponse> {

@@ -533,2 +604,3 @@ return enablePoliciesResponseFromProtobuf(

enablePoliciesRequestToProtobuf(request),
options,
),

@@ -546,5 +618,5 @@ );

*
* - the Cerbos policy decision point server to be at least v0.26 and configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api.html | admin API} enabled, and
* - the Cerbos policy decision point server to be at least v0.26 and configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api | admin API} enabled, and
*
* - a dynamic {@link https://docs.cerbos.dev/cerbos/latest/configuration/storage.html | storage backend}.
* - a dynamic {@link https://docs.cerbos.dev/cerbos/latest/configuration/storage | storage backend}.
*

@@ -556,4 +628,11 @@ * @example

*/
public async enablePolicy(id: string): Promise<boolean> {
const { enabledPolicies } = await this.enablePolicies({ ids: [id] });
public async enablePolicy(
id: string,
options?: RequestOptions,
): Promise<boolean> {
const { enabledPolicies } = await this.enablePolicies(
{ ids: [id] },
options,
);
return enabledPolicies === 1;

@@ -570,3 +649,3 @@ }

*
* - the Cerbos policy decision point server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api.html | admin API} enabled.
* - the Cerbos policy decision point server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api | admin API} enabled.
*

@@ -582,5 +661,10 @@ * @example

request: GetPoliciesRequest,
options?: RequestOptions,
): Promise<GetPoliciesResponse> {
return getPoliciesResponseFromProtobuf(
await this.admin("getPolicy", getPoliciesRequestToProtobuf(request)),
await this.admin(
"getPolicy",
getPoliciesRequestToProtobuf(request),
options,
),
);

@@ -597,3 +681,3 @@ }

*
* - the Cerbos policy decision point server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api.html | admin API} enabled.
* - the Cerbos policy decision point server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api | admin API} enabled.
*

@@ -605,6 +689,9 @@ * @example

*/
public async getPolicy(id: string): Promise<Policy | undefined> {
public async getPolicy(
id: string,
options?: RequestOptions,
): Promise<Policy | undefined> {
const {
policies: [policy],
} = await this.getPolicies({ ids: [id] });
} = await this.getPolicies({ ids: [id] }, options);

@@ -622,3 +709,3 @@ return policy;

*
* - the Cerbos policy decision point server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api.html | admin API} enabled.
* - the Cerbos policy decision point server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api | admin API} enabled.
*

@@ -630,6 +717,9 @@ * @example

*/
public async getSchema(id: string): Promise<Schema | undefined> {
public async getSchema(
id: string,
options?: RequestOptions,
): Promise<Schema | undefined> {
const {
schemas: [schema],
} = await this.getSchemas({ ids: [id] });
} = await this.getSchemas({ ids: [id] }, options);

@@ -647,3 +737,3 @@ return schema;

*
* - the Cerbos policy decision point server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api.html | admin API} enabled.
* - the Cerbos policy decision point server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api | admin API} enabled.
*

@@ -659,5 +749,10 @@ * @example

request: GetSchemasRequest,
options?: RequestOptions,
): Promise<GetSchemasResponse> {
return getSchemasResponseFromProtobuf(
await this.admin("getSchema", getSchemasRequestToProtobuf(request)),
await this.admin(
"getSchema",
getSchemasRequestToProtobuf(request),
options,
),
);

@@ -686,5 +781,11 @@ }

*/
public async isAllowed(request: IsAllowedRequest): Promise<boolean> {
public async isAllowed(
request: IsAllowedRequest,
options?: RequestOptions,
): Promise<boolean> {
const { action, ...rest } = request;
const result = await this.checkResource({ actions: [action], ...rest });
const result = await this.checkResource(
{ actions: [action], ...rest },
options,
);

@@ -707,3 +808,3 @@ const allowed = result.isAllowed(action);

*
* - the Cerbos policy decision point server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api.html | admin API} enabled.
* - the Cerbos policy decision point server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api | admin API} enabled.
*

@@ -717,5 +818,10 @@ * @example

request: ListPoliciesRequest = {},
options?: RequestOptions,
): Promise<ListPoliciesResponse> {
return listPoliciesResponseFromProtobuf(
await this.admin("listPolicies", listPoliciesRequestToProtobuf(request)),
await this.admin(
"listPolicies",
listPoliciesRequestToProtobuf(request),
options,
),
);

@@ -732,3 +838,3 @@ }

*
* - the Cerbos policy decision point server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api.html | admin API} enabled.
* - the Cerbos policy decision point server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api | admin API} enabled.
*

@@ -740,4 +846,8 @@ * @example

*/
public async listSchemas(): Promise<ListSchemasResponse> {
return listSchemasResponseFromProtobuf(await this.admin("listSchemas", {}));
public async listSchemas(
options?: RequestOptions,
): Promise<ListSchemasResponse> {
return listSchemasResponseFromProtobuf(
await this.admin("listSchemas", {}, options),
);
}

@@ -763,2 +873,3 @@

request: PlanResourcesRequest,
options?: RequestOptions,
): Promise<PlanResourcesResponse> {

@@ -769,2 +880,3 @@ const response = planResourcesResponseFromProtobuf(

planResourcesRequestToProtobuf(request),
options,
),

@@ -786,5 +898,5 @@ );

*
* - the Cerbos policy decision point server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api.html | admin API}, and
* - the Cerbos policy decision point server to be configured with the {@link https://docs.cerbos.dev/cerbos/latest/api/admin_api | admin API}, and
*
* - a reloadable {@link https://docs.cerbos.dev/cerbos/latest/configuration/storage.html | storage backend}.
* - a reloadable {@link https://docs.cerbos.dev/cerbos/latest/configuration/storage | storage backend}.
*

@@ -796,4 +908,7 @@ * @example

*/
public async reloadStore(request: ReloadStoreRequest): Promise<void> {
await this.admin("reloadStore", request);
public async reloadStore(
request: ReloadStoreRequest,
options?: RequestOptions,
): Promise<void> {
await this.admin("reloadStore", request, options);
}

@@ -804,4 +919,4 @@

*/
public async serverInfo(): Promise<ServerInfo> {
return await this.cerbos("serverInfo", {});
public async serverInfo(options?: RequestOptions): Promise<ServerInfo> {
return await this.cerbos("serverInfo", {}, options);
}

@@ -812,4 +927,5 @@

request: _Request<"admin", RPC>,
options: RequestOptions | undefined,
): Promise<_Response<"admin", RPC>> {
return await this.transport(
return await this.send(
"admin",

@@ -819,2 +935,3 @@ rpc,

this.options.adminCredentials,
options,
);

@@ -826,6 +943,54 @@ }

request: _Request<"cerbos", RPC>,
options: RequestOptions | undefined,
): Promise<_Response<"cerbos", RPC>> {
return await this.transport("cerbos", rpc, request);
return await this.send("cerbos", rpc, request, undefined, options);
}
private async send<Service extends _Service, RPC extends _RPC<Service>>(
service: Service,
rpc: RPC,
request: _Request<Service, RPC>,
adminCredentials: AdminCredentials | undefined,
{ headers }: RequestOptions = {},
): Promise<_Response<Service, RPC>> {
return await this.transport(
service,
rpc,
request,
await this.mergeHeaders(headers, adminCredentials),
);
}
private async mergeHeaders(
override: HeadersInit | undefined,
adminCredentials: AdminCredentials | undefined,
): Promise<Headers> {
const init = this.options.headers;
const headers = new Headers(
typeof init === "function" ? await init() : init,
);
if (adminCredentials) {
headers.set(
"Authorization",
`Basic ${btoa(
`${adminCredentials.username}:${adminCredentials.password}`,
)}`,
);
}
if (this.options.playgroundInstance) {
headers.set("Playground-Instance", this.options.playgroundInstance);
}
if (override) {
for (const [name, value] of new Headers(override)) {
headers.set(name, value);
}
}
return headers;
}
private handleValidationErrors({

@@ -832,0 +997,0 @@ validationErrors,

/**
* Common types used by the {@link @cerbos/grpc# | gRPC} and {@link @cerbos/http# | HTTP} client libraries.
* Common types used by the {@link @cerbos/grpc# | gRPC}, {@link @cerbos/http# | HTTP}, and {@link @cerbos/embedded# | embedded} client libraries.
*

@@ -4,0 +4,0 @@ * @packageDocumentation

@@ -5,2 +5,14 @@ /* eslint-disable */

export enum Edition {
EDITION_UNKNOWN = 0,
EDITION_PROTO2 = 998,
EDITION_PROTO3 = 999,
EDITION_2023 = 1000,
EDITION_1_TEST_ONLY = 1,
EDITION_2_TEST_ONLY = 2,
EDITION_99997_TEST_ONLY = 99997,
EDITION_99998_TEST_ONLY = 99998,
EDITION_99999_TEST_ONLY = 99999,
}
export interface FileOptions {

@@ -27,2 +39,3 @@ javaPackage: string;

rubyPackage: string;
features: FeatureSet | undefined;
uninterpretedOption: UninterpretedOption[];

@@ -43,2 +56,3 @@ }

deprecatedLegacyJsonFieldConflicts: boolean;
features: FeatureSet | undefined;
uninterpretedOption: UninterpretedOption[];

@@ -57,3 +71,5 @@ }

retention: FieldOptions_OptionRetention;
target: FieldOptions_OptionTargetType;
targets: FieldOptions_OptionTargetType[];
editionDefaults: FieldOptions_EditionDefault[];
features: FeatureSet | undefined;
uninterpretedOption: UninterpretedOption[];

@@ -93,3 +109,9 @@ }

export interface FieldOptions_EditionDefault {
edition: Edition;
value: string;
}
export interface OneofOptions {
features: FeatureSet | undefined;
uninterpretedOption: UninterpretedOption[];

@@ -99,2 +121,3 @@ }

export interface ServiceOptions {
features: FeatureSet | undefined;
deprecated: boolean;

@@ -107,2 +130,3 @@ uninterpretedOption: UninterpretedOption[];

idempotencyLevel: MethodOptions_IdempotencyLevel;
features: FeatureSet | undefined;
uninterpretedOption: UninterpretedOption[];

@@ -131,1 +155,47 @@ }

}
export interface FeatureSet {
fieldPresence: FeatureSet_FieldPresence;
enumType: FeatureSet_EnumType;
repeatedFieldEncoding: FeatureSet_RepeatedFieldEncoding;
utf8Validation: FeatureSet_Utf8Validation;
messageEncoding: FeatureSet_MessageEncoding;
jsonFormat: FeatureSet_JsonFormat;
}
export enum FeatureSet_FieldPresence {
FIELD_PRESENCE_UNKNOWN = 0,
EXPLICIT = 1,
IMPLICIT = 2,
LEGACY_REQUIRED = 3,
}
export enum FeatureSet_EnumType {
ENUM_TYPE_UNKNOWN = 0,
OPEN = 1,
CLOSED = 2,
}
export enum FeatureSet_RepeatedFieldEncoding {
REPEATED_FIELD_ENCODING_UNKNOWN = 0,
PACKED = 1,
EXPANDED = 2,
}
export enum FeatureSet_Utf8Validation {
UTF8_VALIDATION_UNKNOWN = 0,
NONE = 1,
VERIFY = 2,
}
export enum FeatureSet_MessageEncoding {
MESSAGE_ENCODING_UNKNOWN = 0,
LENGTH_PREFIXED = 1,
DELIMITED = 2,
}
export enum FeatureSet_JsonFormat {
JSON_FORMAT_UNKNOWN = 0,
ALLOW = 1,
LEGACY_BEST_EFFORT = 2,
}

@@ -15,5 +15,5 @@ import type { CheckResourcesResultMetadataEffect } from "./CheckResourcesResultMetadataEffect";

/**
* The {@link https://docs.cerbos.dev/cerbos/latest/policies/derived_roles.html | derived roles} that were applied to the principal for the resource.
* The {@link https://docs.cerbos.dev/cerbos/latest/policies/derived_roles | derived roles} that were applied to the principal for the resource.
*/
effectiveDerivedRoles: string[];
}

@@ -13,5 +13,5 @@ /**

/**
* The {@link https://docs.cerbos.dev/cerbos/latest/policies/scoped_policies.html | policy scope} that was used to make the decision.
* The {@link https://docs.cerbos.dev/cerbos/latest/policies/scoped_policies | policy scope} that was used to make the decision.
*/
matchedScope: string;
}

@@ -23,5 +23,5 @@ /**

/**
* The {@link https://docs.cerbos.dev/cerbos/latest/policies/scoped_policies.html | policy scope} against which the check was performed.
* The {@link https://docs.cerbos.dev/cerbos/latest/policies/scoped_policies | policy scope} against which the check was performed.
*/
scope: string;
}
import type { Condition } from "./Condition";
/**
* The definition of a {@link https://docs.cerbos.dev/cerbos/latest/policies/derived_roles.html | derived role}.
* The definition of a {@link https://docs.cerbos.dev/cerbos/latest/policies/derived_roles | derived role}.
*

@@ -6,0 +6,0 @@ * @public

@@ -5,3 +5,3 @@ import type { DerivedRolesBody } from "./DerivedRolesBody";

/**
* A set of {@link https://docs.cerbos.dev/cerbos/latest/policies/derived_roles.html | derived roles}
* A set of {@link https://docs.cerbos.dev/cerbos/latest/policies/derived_roles | derived roles}
* to augment static RBAC roles with contextual data to provide more fine-grained control at runtime.

@@ -8,0 +8,0 @@ *

@@ -5,3 +5,3 @@ import type { DerivedRoleDefinition } from "./DerivedRoleDefinition";

/**
* A set of {@link https://docs.cerbos.dev/cerbos/latest/policies/derived_roles.html | derived roles}
* A set of {@link https://docs.cerbos.dev/cerbos/latest/policies/derived_roles | derived roles}
* to augment static RBAC roles with contextual data to provide more fine-grained control at runtime.

@@ -23,3 +23,3 @@ *

/**
* {@link https://docs.cerbos.dev/cerbos/latest/policies/variables.html | Variables} defined for use in conditions.
* {@link https://docs.cerbos.dev/cerbos/latest/policies/variables | Variables} defined for use in conditions.
*

@@ -26,0 +26,0 @@ * @remarks

@@ -5,3 +5,3 @@ import type { ExportVariablesBody } from "./ExportVariablesBody";

/**
* A set of {@link https://docs.cerbos.dev/cerbos/latest/policies/variables.html#export | exported variables}
* A set of {@link https://docs.cerbos.dev/cerbos/latest/policies/variables#export | exported variables}
* to be reused in other policies.

@@ -8,0 +8,0 @@ *

/**
* A set of {@link https://docs.cerbos.dev/cerbos/latest/policies/variables.html#export | exported variables}
* A set of {@link https://docs.cerbos.dev/cerbos/latest/policies/variables#export | exported variables}
* to be reused in other policies.

@@ -4,0 +4,0 @@ *

/**
* A JSON Web Token to use as an auxiliary data source, which will be verified against the Cerbos policy decision point (PDP) server's {@link https://docs.cerbos.dev/cerbos/latest/configuration/auxdata.html#_jwt | configured JSON Web Key Sets (JWKS)} unless verification is disabled on the server.
* A JSON Web Token to use as an auxiliary data source, which will be verified against the Cerbos policy decision point (PDP) server's {@link https://docs.cerbos.dev/cerbos/latest/configuration/auxdata#_jwt | configured JSON Web Key Sets (JWKS)} unless verification is disabled on the server.
*

@@ -4,0 +4,0 @@ * @public

@@ -8,5 +8,5 @@ /**

/**
* A {@link https://docs.cerbos.dev/cerbos/latest/policies/conditions.html | Common Expression Language} expression to evaluate.
* A {@link https://docs.cerbos.dev/cerbos/latest/policies/conditions | Common Expression Language} expression to evaluate.
*/
expr: string;
}

@@ -8,5 +8,5 @@ /**

/**
* A {@link https://docs.cerbos.dev/cerbos/latest/policies/conditions.html | Common Expression Language} expression to evaluate.
* A {@link https://docs.cerbos.dev/cerbos/latest/policies/conditions | Common Expression Language} expression to evaluate.
*/
expr: string;
}

@@ -13,5 +13,5 @@ /**

/**
* The {@link https://docs.cerbos.dev/cerbos/latest/policies/scoped_policies.html | policy scope} that was used to plan the query.
* The {@link https://docs.cerbos.dev/cerbos/latest/policies/scoped_policies | policy scope} that was used to plan the query.
*/
matchedScope: string;
}

@@ -7,3 +7,3 @@ import type { DerivedRoles } from "./DerivedRoles";

/**
* A {@link https://docs.cerbos.dev/cerbos/latest/policies/index.html | policy} definition.
* A {@link https://docs.cerbos.dev/cerbos/latest/policies/ | policy} definition.
*

@@ -10,0 +10,0 @@ * @public

@@ -42,3 +42,3 @@ import type { Value } from "./Value";

/**
* The {@link https://docs.cerbos.dev/cerbos/latest/policies/scoped_policies.html | policy scope} to use when authorizing the principal.
* The {@link https://docs.cerbos.dev/cerbos/latest/policies/scoped_policies | policy scope} to use when authorizing the principal.
*

@@ -45,0 +45,0 @@ * @defaultValue `""`

@@ -5,3 +5,3 @@ import type { PolicyBase } from "./PolicyBase";

/**
* A {@link https://docs.cerbos.dev/cerbos/latest/policies/principal_policies.html | policy} defining overrides for a specific user.
* A {@link https://docs.cerbos.dev/cerbos/latest/policies/principal_policies | policy} defining overrides for a specific user.
*

@@ -8,0 +8,0 @@ * @public

@@ -5,3 +5,3 @@ import type { PrincipalRule } from "./PrincipalRule";

/**
* A {@link https://docs.cerbos.dev/cerbos/latest/policies/principal_policies.html | policy} defining overrides for a specific user.
* A {@link https://docs.cerbos.dev/cerbos/latest/policies/principal_policies | policy} defining overrides for a specific user.
*

@@ -32,3 +32,3 @@ * @public

/**
* {@link https://docs.cerbos.dev/cerbos/latest/policies/scoped_policies.html | Scope} of the policy.
* {@link https://docs.cerbos.dev/cerbos/latest/policies/scoped_policies | Scope} of the policy.
*/

@@ -38,3 +38,3 @@ scope?: string;

/**
* {@link https://docs.cerbos.dev/cerbos/latest/policies/variables.html | Variables} defined for use in conditions.
* {@link https://docs.cerbos.dev/cerbos/latest/policies/variables | Variables} defined for use in conditions.
*

@@ -41,0 +41,0 @@ * @remarks

@@ -42,3 +42,3 @@ import type { Value } from "./Value";

/**
* The {@link https://docs.cerbos.dev/cerbos/latest/policies/scoped_policies.html | policy scope} to use when checking the principal's permissions on the resource.
* The {@link https://docs.cerbos.dev/cerbos/latest/policies/scoped_policies | policy scope} to use when checking the principal's permissions on the resource.
*

@@ -45,0 +45,0 @@ * @defaultValue `""`

@@ -5,3 +5,3 @@ import type { PolicyBase } from "./PolicyBase";

/**
* A {@link https://docs.cerbos.dev/cerbos/latest/policies/resource_policies.html | policy} defining rules for actions that can be performed on a given resource.
* A {@link https://docs.cerbos.dev/cerbos/latest/policies/resource_policies | policy} defining rules for actions that can be performed on a given resource.
*

@@ -8,0 +8,0 @@ * @public

@@ -6,3 +6,3 @@ import type { ResourceRule } from "./ResourceRule";

/**
* A {@link https://docs.cerbos.dev/cerbos/latest/policies/resource_policies.html | policy} defining rules for actions that can be performed on a given resource.
* A {@link https://docs.cerbos.dev/cerbos/latest/policies/resource_policies | policy} defining rules for actions that can be performed on a given resource.
*

@@ -28,3 +28,3 @@ * @public

/**
* Name of a set of {@link https://docs.cerbos.dev/cerbos/latest/policies/derived_roles.html | derived roles} to import.
* Name of a set of {@link https://docs.cerbos.dev/cerbos/latest/policies/derived_roles | derived roles} to import.
*/

@@ -39,3 +39,3 @@ importDerivedRoles?: string[];

/**
* {@link https://docs.cerbos.dev/cerbos/latest/policies/scoped_policies.html | Scope} of the policy.
* {@link https://docs.cerbos.dev/cerbos/latest/policies/scoped_policies | Scope} of the policy.
*/

@@ -45,3 +45,3 @@ scope?: string;

/**
* {@link https://docs.cerbos.dev/cerbos/latest/policies/schemas.html | Schemas} for principal and resource attributes.
* {@link https://docs.cerbos.dev/cerbos/latest/policies/schemas | Schemas} for principal and resource attributes.
*/

@@ -51,3 +51,3 @@ schemas?: SchemaRefs | undefined;

/**
* {@link https://docs.cerbos.dev/cerbos/latest/policies/variables.html | Variables} defined for use in conditions.
* {@link https://docs.cerbos.dev/cerbos/latest/policies/variables | Variables} defined for use in conditions.
*

@@ -54,0 +54,0 @@ * @remarks

/**
* {@link https://docs.cerbos.dev/cerbos/latest/policies/variables.html | Variables} defined for use in policy conditions.
* {@link https://docs.cerbos.dev/cerbos/latest/policies/variables | Variables} defined for use in policy conditions.
*

@@ -4,0 +4,0 @@ * @public

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc