@canopy-io/node 0.21.0 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +39 -0
- package/dist/index.cjs +127 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +186 -42
- package/dist/index.d.ts +186 -42
- package/dist/index.js +124 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -3965,7 +3965,7 @@ interface paths {
|
|
|
3965
3965
|
put?: never;
|
|
3966
3966
|
/**
|
|
3967
3967
|
* Create an operational-administrator role
|
|
3968
|
-
* @description Creates an active custom administrator role (`is_system` false) with the given `scope` (`account` or `environment`), which cannot be changed later. Duplicate keys in `capabilities` are removed. Every key must be a catalog capability that a role may carry (owner-only keys are refused) and must match the role's `scope`, otherwise the request answers `400`. The name must be unique in the Account (`409`). Requires `admin_governance.manage`, and the creation is recorded in the audit log. An Account holds at most 50 administrator roles (`409`, `admin_role.limit`). An API key may only put in a role, or grant a role carrying, capabilities its own scopes cover; anything beyond answers `403` (`admin_role.capability_beyond_key`) naming them in `error.data.capabilities`. Two capabilities are beyond every key whatever it holds, because the person given one hands out authority without the key's bound: `admin_governance.manage` (any role) and `api_keys.manage` (a full-access Environment key).
|
|
3968
|
+
* @description Creates an active custom administrator role (`is_system` false) with the given `scope` (`account` or `environment`), which cannot be changed later. Duplicate keys in `capabilities` are removed. Every key must be a catalog capability that a role may carry (owner-only keys are refused) and must match the role's `scope`, otherwise the request answers `400`. The name must be unique in the Account (`409`). Requires `admin_governance.manage`, and the creation is recorded in the audit log. An Account holds at most 50 administrator roles (`409`, `admin_role.limit`). An API key may only put in a role, or grant a role carrying, capabilities its own scopes cover; anything beyond answers `403` (`admin_role.capability_beyond_key`) naming them in `error.data.capabilities`. Two capabilities are beyond every key whatever it holds, because the person given one hands out authority without the key's bound: `admin_governance.manage` (any role) and `api_keys.manage` (a full-access Environment key). A developer's MCP client, when its approval names only some capabilities, is held to them the same way, and never hands out those two (`403`, `admin_role.capability_beyond_mcp_grant`).
|
|
3969
3969
|
*/
|
|
3970
3970
|
post: operations["ApiAdminRolesController_create"];
|
|
3971
3971
|
delete?: never;
|
|
@@ -4017,7 +4017,7 @@ interface paths {
|
|
|
4017
4017
|
head?: never;
|
|
4018
4018
|
/**
|
|
4019
4019
|
* Update an operational-administrator role
|
|
4020
|
-
* @description Changes a custom role's `name`, `description` or `is_active`, or replaces its whole `capabilities` set. New capabilities are checked against the catalog and the role's existing `scope`, which cannot change. System roles answer `403`, and a name already used by another role in the Account answers `409`. Send the role's `version` in `If-Match` to refuse a stale edit: a mismatch answers `409` with the current role in `error.data.current`, and without the header the check is skipped. Requires `admin_governance.manage`, and the change is recorded in the audit log. An API key changes only a role within its own ceiling, and may only give it, capabilities its own scopes cover; anything beyond answers `403` (`admin_role.capability_beyond_key`) naming them in `error.data.capabilities`. Two capabilities are beyond every key whatever it holds, because the person given one hands out authority without the key's bound: `admin_governance.manage` (any role) and `api_keys.manage` (a full-access Environment key).
|
|
4020
|
+
* @description Changes a custom role's `name`, `description` or `is_active`, or replaces its whole `capabilities` set. New capabilities are checked against the catalog and the role's existing `scope`, which cannot change. System roles answer `403`, and a name already used by another role in the Account answers `409`. Send the role's `version` in `If-Match` to refuse a stale edit: a mismatch answers `409` with the current role in `error.data.current`, and without the header the check is skipped. Requires `admin_governance.manage`, and the change is recorded in the audit log. An API key changes only a role within its own ceiling, and may only give it, capabilities its own scopes cover; anything beyond answers `403` (`admin_role.capability_beyond_key`) naming them in `error.data.capabilities`. Two capabilities are beyond every key whatever it holds, because the person given one hands out authority without the key's bound: `admin_governance.manage` (any role) and `api_keys.manage` (a full-access Environment key). A developer's MCP client, when its approval names only some capabilities, is held to them the same way, and never hands out those two (`403`, `admin_role.capability_beyond_mcp_grant`).
|
|
4021
4021
|
*/
|
|
4022
4022
|
patch: operations["ApiAdminRolesController_update"];
|
|
4023
4023
|
trace?: never;
|
|
@@ -4036,7 +4036,7 @@ interface paths {
|
|
|
4036
4036
|
get: operations["ApiAdminRolesController_listGrantableRoles"];
|
|
4037
4037
|
/**
|
|
4038
4038
|
* Set the identity roles an administrator role may grant in an Environment
|
|
4039
|
-
* @description Replaces the full list of identity roles that this administrator role may grant in one Environment, and returns the stored IDs with duplicates removed. Sending an empty `roleIds` clears the list. Every ID must be a role in that Environment (`400`), and both the administrator role and the Environment must belong to the Account (`404`). Requires `admin_governance.manage`, and the change is recorded in the audit log with the roles added and removed. An API key changes this only on a role within its own ceiling (`403`, `admin_role.capability_beyond_key`).
|
|
4039
|
+
* @description Replaces the full list of identity roles that this administrator role may grant in one Environment, and returns the stored IDs with duplicates removed. Sending an empty `roleIds` clears the list. Every ID must be a role in that Environment (`400`), and both the administrator role and the Environment must belong to the Account (`404`). Requires `admin_governance.manage`, and the change is recorded in the audit log with the roles added and removed. An API key changes this only on a role within its own ceiling (`403`, `admin_role.capability_beyond_key`), and a bounded MCP client only on one within its approval (`admin_role.capability_beyond_mcp_grant`).
|
|
4040
4040
|
*/
|
|
4041
4041
|
put: operations["ApiAdminRolesController_setGrantableRoles"];
|
|
4042
4042
|
post?: never;
|
|
@@ -4061,7 +4061,7 @@ interface paths {
|
|
|
4061
4061
|
put?: never;
|
|
4062
4062
|
/**
|
|
4063
4063
|
* Grant an operational administrator
|
|
4064
|
-
* @description Grants an administrator role to a user who must be an active member of the Account (`400` otherwise). The grant must match the role's scope: an `account` role needs `scopeType` `account` with no `environmentId` or `nodeId`, and an `environment` role needs an `environmentId` with `scopeType` `environment`, or `node` plus a `nodeId` in that Environment. Answers `404` when the role, Environment or node is not in the Account, `400` when `effectiveFrom` is not before `effectiveTo`, and `409` when the same grant is already live in an overlapping window. Requires `admin_governance.manage`, and the grant is recorded in the audit log. An API key may only put in a role, or grant a role carrying, capabilities its own scopes cover; anything beyond answers `403` (`admin_role.capability_beyond_key`) naming them in `error.data.capabilities`. Two capabilities are beyond every key whatever it holds, because the person given one hands out authority without the key's bound: `admin_governance.manage` (any role) and `api_keys.manage` (a full-access Environment key).
|
|
4064
|
+
* @description Grants an administrator role to a user who must be an active member of the Account (`400` otherwise). The grant must match the role's scope: an `account` role needs `scopeType` `account` with no `environmentId` or `nodeId`, and an `environment` role needs an `environmentId` with `scopeType` `environment`, or `node` plus a `nodeId` in that Environment. Answers `404` when the role, Environment or node is not in the Account, `400` when `effectiveFrom` is not before `effectiveTo`, and `409` when the same grant is already live in an overlapping window. Requires `admin_governance.manage`, and the grant is recorded in the audit log. An API key may only put in a role, or grant a role carrying, capabilities its own scopes cover; anything beyond answers `403` (`admin_role.capability_beyond_key`) naming them in `error.data.capabilities`. Two capabilities are beyond every key whatever it holds, because the person given one hands out authority without the key's bound: `admin_governance.manage` (any role) and `api_keys.manage` (a full-access Environment key). A developer's MCP client, when its approval names only some capabilities, is held to them the same way, and never hands out those two (`403`, `admin_role.capability_beyond_mcp_grant`).
|
|
4065
4065
|
*/
|
|
4066
4066
|
post: operations["ApiAdminAssignmentsController_create"];
|
|
4067
4067
|
delete?: never;
|
|
@@ -4313,7 +4313,7 @@ interface paths {
|
|
|
4313
4313
|
head?: never;
|
|
4314
4314
|
/**
|
|
4315
4315
|
* Update OAuth client
|
|
4316
|
-
* @description Updates an OAuth client's mutable fields (`name`, `redirect_uris`, `post_logout_redirect_uris`, `backchannel_logout_uri`, `scopes`, `is_active`, `invite_redirect_url`, `initiate_login_uri`), scoped to the current Environment. A `scopes` value outside `openid`, `profile`, `email`, `org` and `permissions` is refused with `400` (`oauth.client_scope_unknown`). Returns the updated client, or `404` when the client is not found in this Environment. Send `If-Match` with the client's `version` to refuse a stale write (`409 version_mismatch`). The secret is not rotated here.
|
|
4316
|
+
* @description Updates an OAuth client's mutable fields (`name`, `redirect_uris`, `post_logout_redirect_uris`, `backchannel_logout_uri`, `scopes`, `is_active`, `invite_redirect_url`, `initiate_login_uri`; for a machine client `allowed_audiences` and `token_exchange`, which adds or removes the token-exchange grant in its `grant_types`), scoped to the current Environment. A `scopes` value outside `openid`, `profile`, `email`, `org` and `permissions` is refused with `400` (`oauth.client_scope_unknown`). Returns the updated client, or `404` when the client is not found in this Environment. Send `If-Match` with the client's `version` to refuse a stale write (`409 version_mismatch`). The secret is not rotated here.
|
|
4317
4317
|
*/
|
|
4318
4318
|
patch: operations["ApiOAuthClientsController_update"];
|
|
4319
4319
|
trace?: never;
|
|
@@ -4839,10 +4839,12 @@ interface components {
|
|
|
4839
4839
|
effective_node_id?: string | null;
|
|
4840
4840
|
/** @description Ids of the roles whose assignments produced a node-scoped allow. Always empty for `scope_evaluated: "app_wide"`, whose answer is not tied to a node, and for a deny. */
|
|
4841
4841
|
granting_roles: string[];
|
|
4842
|
-
/** @description Why the check was refused: `NO_ROLE_ASSIGNMENT`, `PERMISSION_NOT_GRANTED`, `NODE_SCOPE_VIOLATION`, `ROLE_EXPIRED`, `IDENTITY_INACTIVE`, `IDENTITY_NOT_ENV_MEMBER`, `ORGANIZATION_MEMBERSHIP_INACTIVE` (assignments sit on the lineage inside an organization the identity's membership in is deactivated, so none count),
|
|
4842
|
+
/** @description Why the check was refused: `NO_ROLE_ASSIGNMENT`, `PERMISSION_NOT_GRANTED`, `NODE_SCOPE_VIOLATION`, `ROLE_EXPIRED`, `IDENTITY_INACTIVE`, `IDENTITY_NOT_ENV_MEMBER`, `ORGANIZATION_MEMBERSHIP_INACTIVE` (assignments sit on the lineage inside an organization the identity's membership in is deactivated, so none count), `DENIED` (a deny at the node or above it refuses the permission, whatever grants allow), `ACTING_CLIENT_INACTIVE` (`acting_client_id` names no active machine client of this Environment) or `ACTING_CLIENT_NOT_GRANTED` (the identity holds the permission there but the acting client does not). Null on an allow. */
|
|
4843
4843
|
denial_reason?: string | null;
|
|
4844
4844
|
/** @description The deny that refused, when `denial_reason` is `DENIED`; null otherwise. */
|
|
4845
4845
|
deny_id?: string | null;
|
|
4846
|
+
/** @description Whether the acting client holds the permission there, when the check named `acting_client_id`; null otherwise. `allowed` is true only when the identity and the client both allow. */
|
|
4847
|
+
acting_client_allowed?: boolean | null;
|
|
4846
4848
|
};
|
|
4847
4849
|
EvaluatePermissionDto: {
|
|
4848
4850
|
/** @description Identity ID (from the `identities` table — the end user being evaluated, not an admin). */
|
|
@@ -4855,6 +4857,8 @@ interface components {
|
|
|
4855
4857
|
scope: "node" | "app_wide";
|
|
4856
4858
|
/** @description Required when `scope` is `node`; must be omitted when `scope` is `app_wide`. */
|
|
4857
4859
|
node_id?: string;
|
|
4860
|
+
/** @description The `client_id` of the machine client acting for the identity, from a delegated token's `act.sub`. When set, the check allows only when the identity and the client both hold the permission there; `acting_client_allowed` carries the client's half. */
|
|
4861
|
+
acting_client_id?: string;
|
|
4858
4862
|
};
|
|
4859
4863
|
EvaluateCheckDto: {
|
|
4860
4864
|
/** @description Identity ID (from the `identities` table — the end user being evaluated, not an admin). */
|
|
@@ -4867,6 +4871,8 @@ interface components {
|
|
|
4867
4871
|
scope: "node" | "app_wide";
|
|
4868
4872
|
/** @description Required when `scope` is `node`; must be omitted when `scope` is `app_wide`. */
|
|
4869
4873
|
node_id?: string;
|
|
4874
|
+
/** @description The `client_id` of the machine client acting for the identity, from a delegated token's `act.sub`. When set, the check allows only when the identity and the client both hold the permission there; `acting_client_allowed` carries the client's half. */
|
|
4875
|
+
acting_client_id?: string;
|
|
4870
4876
|
};
|
|
4871
4877
|
BulkEvaluatePermissionDto: {
|
|
4872
4878
|
/** @description Between 1 and 100 checks. More is refused with a 400. */
|
|
@@ -6840,6 +6846,12 @@ interface components {
|
|
|
6840
6846
|
* @enum {string|null}
|
|
6841
6847
|
*/
|
|
6842
6848
|
channel?: "mcp" | null;
|
|
6849
|
+
/** @description The MCP client a developer approved, when it made the change for the actor through the account MCP server. NULL otherwise, including a change made through MCP with an API key, which acts as the key. */
|
|
6850
|
+
mcp_client_id?: string | null;
|
|
6851
|
+
/** @description That client's name as it gave it when the change was made. Unverified. */
|
|
6852
|
+
mcp_client_name?: string | null;
|
|
6853
|
+
/** @description The developer's approval of that client the change was made under. */
|
|
6854
|
+
mcp_grant_id?: string | null;
|
|
6843
6855
|
/** @description Snapshot label of the actor at write time (email for users / identities, label otherwise). NULL on rows written before the Slice 2 deploy. */
|
|
6844
6856
|
actor_label?: string | null;
|
|
6845
6857
|
/** @description Snapshot label of the affected resource at write time. NULL on rows written before the Slice 2 deploy. */
|
|
@@ -6978,6 +6990,12 @@ interface components {
|
|
|
6978
6990
|
* @enum {string|null}
|
|
6979
6991
|
*/
|
|
6980
6992
|
channel?: "mcp" | null;
|
|
6993
|
+
/** @description The MCP client a developer approved, when it made the change for the actor through the account MCP server. NULL otherwise, including a change made through MCP with an API key, which acts as the key. */
|
|
6994
|
+
mcp_client_id?: string | null;
|
|
6995
|
+
/** @description That client's name as it gave it when the change was made. Unverified. */
|
|
6996
|
+
mcp_client_name?: string | null;
|
|
6997
|
+
/** @description The developer's approval of that client the change was made under. */
|
|
6998
|
+
mcp_grant_id?: string | null;
|
|
6981
6999
|
/** @description Snapshot label of the actor at write time (email for users / identities, label otherwise). NULL on rows written before the Slice 2 deploy. */
|
|
6982
7000
|
actor_label?: string | null;
|
|
6983
7001
|
/** @description Snapshot label of the affected resource at write time. NULL on rows written before the Slice 2 deploy. */
|
|
@@ -8267,6 +8285,8 @@ interface components {
|
|
|
8267
8285
|
is_active?: boolean;
|
|
8268
8286
|
/** @description A machine client's audiences, replaced whole. A web client takes none (`400 oauth.web_client_audiences_invalid`). */
|
|
8269
8287
|
allowed_audiences?: string[];
|
|
8288
|
+
/** @description Machine clients only: whether the client may exchange a person's access token for one it acts for them with (`urn:ietf:params:oauth:grant-type:token-exchange`). Off until turned on. */
|
|
8289
|
+
token_exchange?: boolean;
|
|
8270
8290
|
/** @description Where Canopy delivers a signed logout token when a session this client issued tokens for ends. `null` stops the notifications. */
|
|
8271
8291
|
backchannel_logout_uri?: string | null;
|
|
8272
8292
|
invite_redirect_url?: string | null;
|
|
@@ -38284,7 +38304,7 @@ interface operations {
|
|
|
38284
38304
|
"application/json": components["schemas"]["ErrorResponseDto"];
|
|
38285
38305
|
};
|
|
38286
38306
|
};
|
|
38287
|
-
/** @description An API key's scopes do not cover every capability the role carries (`admin_role.capability_beyond_key`, `error.data.capabilities` naming them), or the caller lacks the permission this operation checks */
|
|
38307
|
+
/** @description An API key's scopes, or a bounded MCP client's approval, do not cover every capability the role carries (`admin_role.capability_beyond_key`, `admin_role.capability_beyond_mcp_grant`, `error.data.capabilities` naming them), or the caller lacks the permission this operation checks */
|
|
38288
38308
|
403: {
|
|
38289
38309
|
headers: {
|
|
38290
38310
|
[name: string]: unknown;
|
|
@@ -38295,7 +38315,7 @@ interface operations {
|
|
|
38295
38315
|
* "error": {
|
|
38296
38316
|
* "statusCode": 403,
|
|
38297
38317
|
* "code": null,
|
|
38298
|
-
* "message": "An API key's scopes do not cover every capability the role carries (`admin_role.capability_beyond_key`, `error.data.capabilities` naming them), or the caller lacks the permission this operation checks",
|
|
38318
|
+
* "message": "An API key's scopes, or a bounded MCP client's approval, do not cover every capability the role carries (`admin_role.capability_beyond_key`, `admin_role.capability_beyond_mcp_grant`, `error.data.capabilities` naming them), or the caller lacks the permission this operation checks",
|
|
38299
38319
|
* "timestamp": "2026-04-20T12:00:00.000Z",
|
|
38300
38320
|
* "path": "/api/v1/admin-roles",
|
|
38301
38321
|
* "method": "POST"
|
|
@@ -38719,7 +38739,7 @@ interface operations {
|
|
|
38719
38739
|
"application/json": components["schemas"]["ErrorResponseDto"];
|
|
38720
38740
|
};
|
|
38721
38741
|
};
|
|
38722
|
-
/** @description The role is a system administrator role, which cannot be modified, or an API key's scopes do not cover every capability the role carries or would carry (`admin_role.capability_beyond_key`), or the caller lacks the permission this operation checks */
|
|
38742
|
+
/** @description The role is a system administrator role, which cannot be modified, or an API key's scopes, or a bounded MCP client's approval, do not cover every capability the role carries or would carry (`admin_role.capability_beyond_key`, `admin_role.capability_beyond_mcp_grant`), or the caller lacks the permission this operation checks */
|
|
38723
38743
|
403: {
|
|
38724
38744
|
headers: {
|
|
38725
38745
|
[name: string]: unknown;
|
|
@@ -38730,7 +38750,7 @@ interface operations {
|
|
|
38730
38750
|
* "error": {
|
|
38731
38751
|
* "statusCode": 403,
|
|
38732
38752
|
* "code": null,
|
|
38733
|
-
* "message": "The role is a system administrator role, which cannot be modified, or an API key's scopes do not cover every capability the role carries or would carry (`admin_role.capability_beyond_key`), or the caller lacks the permission this operation checks",
|
|
38753
|
+
* "message": "The role is a system administrator role, which cannot be modified, or an API key's scopes, or a bounded MCP client's approval, do not cover every capability the role carries or would carry (`admin_role.capability_beyond_key`, `admin_role.capability_beyond_mcp_grant`), or the caller lacks the permission this operation checks",
|
|
38734
38754
|
* "timestamp": "2026-04-20T12:00:00.000Z",
|
|
38735
38755
|
* "path": "/api/v1/admin-roles/{adminRoleId}",
|
|
38736
38756
|
* "method": "PATCH"
|
|
@@ -38963,7 +38983,7 @@ interface operations {
|
|
|
38963
38983
|
"application/json": components["schemas"]["ErrorResponseDto"];
|
|
38964
38984
|
};
|
|
38965
38985
|
};
|
|
38966
|
-
/** @description An API key's scopes do not cover every capability the role carries (`admin_role.capability_beyond_key`, `error.data.capabilities` naming them), or the caller lacks the permission this operation checks */
|
|
38986
|
+
/** @description An API key's scopes, or a bounded MCP client's approval, do not cover every capability the role carries (`admin_role.capability_beyond_key`, `admin_role.capability_beyond_mcp_grant`, `error.data.capabilities` naming them), or the caller lacks the permission this operation checks */
|
|
38967
38987
|
403: {
|
|
38968
38988
|
headers: {
|
|
38969
38989
|
[name: string]: unknown;
|
|
@@ -38974,7 +38994,7 @@ interface operations {
|
|
|
38974
38994
|
* "error": {
|
|
38975
38995
|
* "statusCode": 403,
|
|
38976
38996
|
* "code": null,
|
|
38977
|
-
* "message": "An API key's scopes do not cover every capability the role carries (`admin_role.capability_beyond_key`, `error.data.capabilities` naming them), or the caller lacks the permission this operation checks",
|
|
38997
|
+
* "message": "An API key's scopes, or a bounded MCP client's approval, do not cover every capability the role carries (`admin_role.capability_beyond_key`, `admin_role.capability_beyond_mcp_grant`, `error.data.capabilities` naming them), or the caller lacks the permission this operation checks",
|
|
38978
38998
|
* "timestamp": "2026-04-20T12:00:00.000Z",
|
|
38979
38999
|
* "path": "/api/v1/admin-roles/{adminRoleId}/grantable-roles",
|
|
38980
39000
|
* "method": "PUT"
|
|
@@ -39176,7 +39196,7 @@ interface operations {
|
|
|
39176
39196
|
"application/json": components["schemas"]["ErrorResponseDto"];
|
|
39177
39197
|
};
|
|
39178
39198
|
};
|
|
39179
|
-
/** @description An API key's scopes do not cover every capability the role carries (`admin_role.capability_beyond_key`, `error.data.capabilities` naming them), or the caller lacks the permission this operation checks */
|
|
39199
|
+
/** @description An API key's scopes, or a bounded MCP client's approval, do not cover every capability the role carries (`admin_role.capability_beyond_key`, `admin_role.capability_beyond_mcp_grant`, `error.data.capabilities` naming them), or the caller lacks the permission this operation checks */
|
|
39180
39200
|
403: {
|
|
39181
39201
|
headers: {
|
|
39182
39202
|
[name: string]: unknown;
|
|
@@ -39187,7 +39207,7 @@ interface operations {
|
|
|
39187
39207
|
* "error": {
|
|
39188
39208
|
* "statusCode": 403,
|
|
39189
39209
|
* "code": null,
|
|
39190
|
-
* "message": "An API key's scopes do not cover every capability the role carries (`admin_role.capability_beyond_key`, `error.data.capabilities` naming them), or the caller lacks the permission this operation checks",
|
|
39210
|
+
* "message": "An API key's scopes, or a bounded MCP client's approval, do not cover every capability the role carries (`admin_role.capability_beyond_key`, `admin_role.capability_beyond_mcp_grant`, `error.data.capabilities` naming them), or the caller lacks the permission this operation checks",
|
|
39191
39211
|
* "timestamp": "2026-04-20T12:00:00.000Z",
|
|
39192
39212
|
* "path": "/api/v1/admin-assignments",
|
|
39193
39213
|
* "method": "POST"
|
|
@@ -40659,7 +40679,7 @@ interface operations {
|
|
|
40659
40679
|
};
|
|
40660
40680
|
};
|
|
40661
40681
|
};
|
|
40662
|
-
/** @description The request failed validation: a body field, a query parameter or an id in the path is missing, malformed or out of range, `backchannel_logout_uri` names an address Canopy's servers will not call, `initiate_login_uri` is malformed or not `https` (loopback hosts excepted), `scopes` names a scope Canopy does not issue (`oauth.client_scope_unknown`), a machine client names an `organization_node_id` that is not a live organization of this Environment (`oauth.client_organization_invalid`), takes a web client's field or a scope other than `permissions` (`oauth.machine_client_fields_invalid`) or is asked to be public (`oauth.machine_client_public_invalid`), a web client sends `allowed_audiences` (`oauth.web_client_audiences_invalid`), or a confidential client registers a private-use scheme redirect (`oauth.redirect_uri_not_allowed_for_client`); or the request sent both an `X-API-Key` and an `Authorization` header, or its `X-Canopy-Environment` header is missing for an account key, names no Environment of the key's Account, or names another Environment than an Environment key's own */
|
|
40682
|
+
/** @description The request failed validation: a body field, a query parameter or an id in the path is missing, malformed or out of range, `backchannel_logout_uri` names an address Canopy's servers will not call, `initiate_login_uri` is malformed or not `https` (loopback hosts excepted), `scopes` names a scope Canopy does not issue (`oauth.client_scope_unknown`), a machine client names an `organization_node_id` that is not a live organization of this Environment (`oauth.client_organization_invalid`), takes a web client's field or a scope other than `permissions` (`oauth.machine_client_fields_invalid`) or is asked to be public (`oauth.machine_client_public_invalid`), a web client sends `allowed_audiences` (`oauth.web_client_audiences_invalid`) or `token_exchange` (`oauth.web_client_token_exchange_invalid`), or a confidential client registers a private-use scheme redirect (`oauth.redirect_uri_not_allowed_for_client`); or the request sent both an `X-API-Key` and an `Authorization` header, or its `X-Canopy-Environment` header is missing for an account key, names no Environment of the key's Account, or names another Environment than an Environment key's own */
|
|
40663
40683
|
400: {
|
|
40664
40684
|
headers: {
|
|
40665
40685
|
[name: string]: unknown;
|
|
@@ -40670,7 +40690,7 @@ interface operations {
|
|
|
40670
40690
|
* "error": {
|
|
40671
40691
|
* "statusCode": 400,
|
|
40672
40692
|
* "code": null,
|
|
40673
|
-
* "message": "The request failed validation: a body field, a query parameter or an id in the path is missing, malformed or out of range, `backchannel_logout_uri` names an address Canopy's servers will not call, `initiate_login_uri` is malformed or not `https` (loopback hosts excepted), `scopes` names a scope Canopy does not issue (`oauth.client_scope_unknown`), a machine client names an `organization_node_id` that is not a live organization of this Environment (`oauth.client_organization_invalid`), takes a web client's field or a scope other than `permissions` (`oauth.machine_client_fields_invalid`) or is asked to be public (`oauth.machine_client_public_invalid`), a web client sends `allowed_audiences` (`oauth.web_client_audiences_invalid`), or a confidential client registers a private-use scheme redirect (`oauth.redirect_uri_not_allowed_for_client`); or the request sent both an `X-API-Key` and an `Authorization` header, or its `X-Canopy-Environment` header is missing for an account key, names no Environment of the key's Account, or names another Environment than an Environment key's own",
|
|
40693
|
+
* "message": "The request failed validation: a body field, a query parameter or an id in the path is missing, malformed or out of range, `backchannel_logout_uri` names an address Canopy's servers will not call, `initiate_login_uri` is malformed or not `https` (loopback hosts excepted), `scopes` names a scope Canopy does not issue (`oauth.client_scope_unknown`), a machine client names an `organization_node_id` that is not a live organization of this Environment (`oauth.client_organization_invalid`), takes a web client's field or a scope other than `permissions` (`oauth.machine_client_fields_invalid`) or is asked to be public (`oauth.machine_client_public_invalid`), a web client sends `allowed_audiences` (`oauth.web_client_audiences_invalid`) or `token_exchange` (`oauth.web_client_token_exchange_invalid`), or a confidential client registers a private-use scheme redirect (`oauth.redirect_uri_not_allowed_for_client`); or the request sent both an `X-API-Key` and an `Authorization` header, or its `X-Canopy-Environment` header is missing for an account key, names no Environment of the key's Account, or names another Environment than an Environment key's own",
|
|
40674
40694
|
* "timestamp": "2026-04-20T12:00:00.000Z",
|
|
40675
40695
|
* "path": "/api/v1/oauth-clients",
|
|
40676
40696
|
* "method": "POST"
|
|
@@ -41108,7 +41128,7 @@ interface operations {
|
|
|
41108
41128
|
};
|
|
41109
41129
|
};
|
|
41110
41130
|
};
|
|
41111
|
-
/** @description The request failed validation: a body field, a query parameter or an id in the path is missing, malformed or out of range, `backchannel_logout_uri` names an address Canopy's servers will not call, `initiate_login_uri` is malformed or not `https` (loopback hosts excepted), `scopes` names a scope Canopy does not issue (`oauth.client_scope_unknown`), a machine client names an `organization_node_id` that is not a live organization of this Environment (`oauth.client_organization_invalid`), takes a web client's field or a scope other than `permissions` (`oauth.machine_client_fields_invalid`) or is asked to be public (`oauth.machine_client_public_invalid`), a web client sends `allowed_audiences` (`oauth.web_client_audiences_invalid`), or a confidential client registers a private-use scheme redirect (`oauth.redirect_uri_not_allowed_for_client`); or the request sent both an `X-API-Key` and an `Authorization` header, or its `X-Canopy-Environment` header is missing for an account key, names no Environment of the key's Account, or names another Environment than an Environment key's own; or its `If-Match` header names no version (`if_match.invalid`) */
|
|
41131
|
+
/** @description The request failed validation: a body field, a query parameter or an id in the path is missing, malformed or out of range, `backchannel_logout_uri` names an address Canopy's servers will not call, `initiate_login_uri` is malformed or not `https` (loopback hosts excepted), `scopes` names a scope Canopy does not issue (`oauth.client_scope_unknown`), a machine client names an `organization_node_id` that is not a live organization of this Environment (`oauth.client_organization_invalid`), takes a web client's field or a scope other than `permissions` (`oauth.machine_client_fields_invalid`) or is asked to be public (`oauth.machine_client_public_invalid`), a web client sends `allowed_audiences` (`oauth.web_client_audiences_invalid`) or `token_exchange` (`oauth.web_client_token_exchange_invalid`), or a confidential client registers a private-use scheme redirect (`oauth.redirect_uri_not_allowed_for_client`); or the request sent both an `X-API-Key` and an `Authorization` header, or its `X-Canopy-Environment` header is missing for an account key, names no Environment of the key's Account, or names another Environment than an Environment key's own; or its `If-Match` header names no version (`if_match.invalid`) */
|
|
41112
41132
|
400: {
|
|
41113
41133
|
headers: {
|
|
41114
41134
|
[name: string]: unknown;
|
|
@@ -41119,7 +41139,7 @@ interface operations {
|
|
|
41119
41139
|
* "error": {
|
|
41120
41140
|
* "statusCode": 400,
|
|
41121
41141
|
* "code": null,
|
|
41122
|
-
* "message": "The request failed validation: a body field, a query parameter or an id in the path is missing, malformed or out of range, `backchannel_logout_uri` names an address Canopy's servers will not call, `initiate_login_uri` is malformed or not `https` (loopback hosts excepted), `scopes` names a scope Canopy does not issue (`oauth.client_scope_unknown`), a machine client names an `organization_node_id` that is not a live organization of this Environment (`oauth.client_organization_invalid`), takes a web client's field or a scope other than `permissions` (`oauth.machine_client_fields_invalid`) or is asked to be public (`oauth.machine_client_public_invalid`), a web client sends `allowed_audiences` (`oauth.web_client_audiences_invalid`), or a confidential client registers a private-use scheme redirect (`oauth.redirect_uri_not_allowed_for_client`); or the request sent both an `X-API-Key` and an `Authorization` header, or its `X-Canopy-Environment` header is missing for an account key, names no Environment of the key's Account, or names another Environment than an Environment key's own; or its `If-Match` header names no version (`if_match.invalid`)",
|
|
41142
|
+
* "message": "The request failed validation: a body field, a query parameter or an id in the path is missing, malformed or out of range, `backchannel_logout_uri` names an address Canopy's servers will not call, `initiate_login_uri` is malformed or not `https` (loopback hosts excepted), `scopes` names a scope Canopy does not issue (`oauth.client_scope_unknown`), a machine client names an `organization_node_id` that is not a live organization of this Environment (`oauth.client_organization_invalid`), takes a web client's field or a scope other than `permissions` (`oauth.machine_client_fields_invalid`) or is asked to be public (`oauth.machine_client_public_invalid`), a web client sends `allowed_audiences` (`oauth.web_client_audiences_invalid`) or `token_exchange` (`oauth.web_client_token_exchange_invalid`), or a confidential client registers a private-use scheme redirect (`oauth.redirect_uri_not_allowed_for_client`); or the request sent both an `X-API-Key` and an `Authorization` header, or its `X-Canopy-Environment` header is missing for an account key, names no Environment of the key's Account, or names another Environment than an Environment key's own; or its `If-Match` header names no version (`if_match.invalid`)",
|
|
41123
41143
|
* "timestamp": "2026-04-20T12:00:00.000Z",
|
|
41124
41144
|
* "path": "/api/v1/oauth-clients/{id}",
|
|
41125
41145
|
* "method": "PATCH"
|
|
@@ -42191,7 +42211,7 @@ interface operations {
|
|
|
42191
42211
|
"application/json": components["schemas"]["ErrorResponseDto"];
|
|
42192
42212
|
};
|
|
42193
42213
|
};
|
|
42194
|
-
/** @description The caller lacks `api_key.manage` (a scoped API key without that scope, or an admin without the Account capability that covers it), or is a scoped API key asking for more than it holds: `full_access`, or a scope outside its own (`api_key.access_exceeds_caller`) */
|
|
42214
|
+
/** @description The caller lacks `api_key.manage` (a scoped API key without that scope, or an admin without the Account capability that covers it), or is a scoped API key asking for more than it holds: `full_access`, or a scope outside its own (`api_key.access_exceeds_caller`), or is an MCP client whose approval names only some capabilities asking for `full_access` or a scope that approval does not cover (`api_key.access_exceeds_mcp_grant`) */
|
|
42195
42215
|
403: {
|
|
42196
42216
|
headers: {
|
|
42197
42217
|
[name: string]: unknown;
|
|
@@ -42202,7 +42222,7 @@ interface operations {
|
|
|
42202
42222
|
* "error": {
|
|
42203
42223
|
* "statusCode": 403,
|
|
42204
42224
|
* "code": null,
|
|
42205
|
-
* "message": "The caller lacks `api_key.manage` (a scoped API key without that scope, or an admin without the Account capability that covers it), or is a scoped API key asking for more than it holds: `full_access`, or a scope outside its own (`api_key.access_exceeds_caller`)",
|
|
42225
|
+
* "message": "The caller lacks `api_key.manage` (a scoped API key without that scope, or an admin without the Account capability that covers it), or is a scoped API key asking for more than it holds: `full_access`, or a scope outside its own (`api_key.access_exceeds_caller`), or is an MCP client whose approval names only some capabilities asking for `full_access` or a scope that approval does not cover (`api_key.access_exceeds_mcp_grant`)",
|
|
42206
42226
|
* "timestamp": "2026-04-20T12:00:00.000Z",
|
|
42207
42227
|
* "path": "/api/v1/api-keys",
|
|
42208
42228
|
* "method": "POST"
|
|
@@ -42340,7 +42360,7 @@ interface operations {
|
|
|
42340
42360
|
"application/json": components["schemas"]["ErrorResponseDto"];
|
|
42341
42361
|
};
|
|
42342
42362
|
};
|
|
42343
|
-
/** @description The caller lacks `api_key.manage` (a scoped API key without that scope, or an admin without the Account capability that covers it), or is a scoped API key acting on a key with more access than its own: a `full_access` key, or one holding a scope outside its own (`api_key.access_exceeds_caller`) */
|
|
42363
|
+
/** @description The caller lacks `api_key.manage` (a scoped API key without that scope, or an admin without the Account capability that covers it), or is a scoped API key acting on a key with more access than its own: a `full_access` key, or one holding a scope outside its own (`api_key.access_exceeds_caller`), or is an MCP client whose approval names only some capabilities acting on a `full_access` key or one holding a scope that approval does not cover (`api_key.access_exceeds_mcp_grant`) */
|
|
42344
42364
|
403: {
|
|
42345
42365
|
headers: {
|
|
42346
42366
|
[name: string]: unknown;
|
|
@@ -42351,7 +42371,7 @@ interface operations {
|
|
|
42351
42371
|
* "error": {
|
|
42352
42372
|
* "statusCode": 403,
|
|
42353
42373
|
* "code": null,
|
|
42354
|
-
* "message": "The caller lacks `api_key.manage` (a scoped API key without that scope, or an admin without the Account capability that covers it), or is a scoped API key acting on a key with more access than its own: a `full_access` key, or one holding a scope outside its own (`api_key.access_exceeds_caller`)",
|
|
42374
|
+
* "message": "The caller lacks `api_key.manage` (a scoped API key without that scope, or an admin without the Account capability that covers it), or is a scoped API key acting on a key with more access than its own: a `full_access` key, or one holding a scope outside its own (`api_key.access_exceeds_caller`), or is an MCP client whose approval names only some capabilities acting on a `full_access` key or one holding a scope that approval does not cover (`api_key.access_exceeds_mcp_grant`)",
|
|
42355
42375
|
* "timestamp": "2026-04-20T12:00:00.000Z",
|
|
42356
42376
|
* "path": "/api/v1/api-keys/{id}",
|
|
42357
42377
|
* "method": "DELETE"
|
|
@@ -42455,7 +42475,7 @@ interface operations {
|
|
|
42455
42475
|
"application/json": components["schemas"]["ErrorResponseDto"];
|
|
42456
42476
|
};
|
|
42457
42477
|
};
|
|
42458
|
-
/** @description The caller lacks `api_key.manage` (a scoped API key without that scope, or an admin without the Account capability that covers it), or is a scoped API key acting on a key with more access than its own: a `full_access` key, or one holding a scope outside its own (`api_key.access_exceeds_caller`) */
|
|
42478
|
+
/** @description The caller lacks `api_key.manage` (a scoped API key without that scope, or an admin without the Account capability that covers it), or is a scoped API key acting on a key with more access than its own: a `full_access` key, or one holding a scope outside its own (`api_key.access_exceeds_caller`), or is an MCP client whose approval names only some capabilities acting on a `full_access` key or one holding a scope that approval does not cover (`api_key.access_exceeds_mcp_grant`) */
|
|
42459
42479
|
403: {
|
|
42460
42480
|
headers: {
|
|
42461
42481
|
[name: string]: unknown;
|
|
@@ -42466,7 +42486,7 @@ interface operations {
|
|
|
42466
42486
|
* "error": {
|
|
42467
42487
|
* "statusCode": 403,
|
|
42468
42488
|
* "code": null,
|
|
42469
|
-
* "message": "The caller lacks `api_key.manage` (a scoped API key without that scope, or an admin without the Account capability that covers it), or is a scoped API key acting on a key with more access than its own: a `full_access` key, or one holding a scope outside its own (`api_key.access_exceeds_caller`)",
|
|
42489
|
+
* "message": "The caller lacks `api_key.manage` (a scoped API key without that scope, or an admin without the Account capability that covers it), or is a scoped API key acting on a key with more access than its own: a `full_access` key, or one holding a scope outside its own (`api_key.access_exceeds_caller`), or is an MCP client whose approval names only some capabilities acting on a `full_access` key or one holding a scope that approval does not cover (`api_key.access_exceeds_mcp_grant`)",
|
|
42470
42490
|
* "timestamp": "2026-04-20T12:00:00.000Z",
|
|
42471
42491
|
* "path": "/api/v1/api-keys/{id}",
|
|
42472
42492
|
* "method": "PATCH"
|
|
@@ -42566,7 +42586,7 @@ interface operations {
|
|
|
42566
42586
|
"application/json": components["schemas"]["ErrorResponseDto"];
|
|
42567
42587
|
};
|
|
42568
42588
|
};
|
|
42569
|
-
/** @description The caller lacks `api_key.manage` (a scoped API key without that scope, or an admin without the Account capability that covers it), or is a scoped API key acting on a key with more access than its own: a `full_access` key, or one holding a scope outside its own (`api_key.access_exceeds_caller`) */
|
|
42589
|
+
/** @description The caller lacks `api_key.manage` (a scoped API key without that scope, or an admin without the Account capability that covers it), or is a scoped API key acting on a key with more access than its own: a `full_access` key, or one holding a scope outside its own (`api_key.access_exceeds_caller`), or is an MCP client whose approval names only some capabilities acting on a `full_access` key or one holding a scope that approval does not cover (`api_key.access_exceeds_mcp_grant`) */
|
|
42570
42590
|
403: {
|
|
42571
42591
|
headers: {
|
|
42572
42592
|
[name: string]: unknown;
|
|
@@ -42577,7 +42597,7 @@ interface operations {
|
|
|
42577
42597
|
* "error": {
|
|
42578
42598
|
* "statusCode": 403,
|
|
42579
42599
|
* "code": null,
|
|
42580
|
-
* "message": "The caller lacks `api_key.manage` (a scoped API key without that scope, or an admin without the Account capability that covers it), or is a scoped API key acting on a key with more access than its own: a `full_access` key, or one holding a scope outside its own (`api_key.access_exceeds_caller`)",
|
|
42600
|
+
* "message": "The caller lacks `api_key.manage` (a scoped API key without that scope, or an admin without the Account capability that covers it), or is a scoped API key acting on a key with more access than its own: a `full_access` key, or one holding a scope outside its own (`api_key.access_exceeds_caller`), or is an MCP client whose approval names only some capabilities acting on a `full_access` key or one holding a scope that approval does not cover (`api_key.access_exceeds_mcp_grant`)",
|
|
42581
42601
|
* "timestamp": "2026-04-20T12:00:00.000Z",
|
|
42582
42602
|
* "path": "/api/v1/api-keys/{id}/rotate-secret",
|
|
42583
42603
|
* "method": "POST"
|
|
@@ -44940,8 +44960,11 @@ declare const DEFAULT_MAX_NODES = 10000;
|
|
|
44940
44960
|
* - `denied`: a deny refuses the permission, at the node or above it, or,
|
|
44941
44961
|
* for `app_wide`, over every grant in effect. No grant beneath a deny
|
|
44942
44962
|
* undoes it.
|
|
44963
|
+
* - `acting_client_not_granted`: the identity holds the permission, but the
|
|
44964
|
+
* machine client acting for it (`acting_client_id`) does not. A delegated
|
|
44965
|
+
* token reaches only what both hold.
|
|
44943
44966
|
*/
|
|
44944
|
-
type LocalDenialReason = "permission_not_held" | "outside_grants" | "expired" | "not_yet_effective" | "node_missing" | "denied";
|
|
44967
|
+
type LocalDenialReason = "permission_not_held" | "outside_grants" | "expired" | "not_yet_effective" | "node_missing" | "denied" | "acting_client_not_granted";
|
|
44945
44968
|
/** The answer to a check: the verdict, and why when it is no. */
|
|
44946
44969
|
interface LocalDecision {
|
|
44947
44970
|
allowed: boolean;
|
|
@@ -45023,6 +45046,13 @@ interface LocalAuthorizationQuery {
|
|
|
45023
45046
|
* the verified token's `type` claim, never off the request.
|
|
45024
45047
|
*/
|
|
45025
45048
|
principal_type?: PrincipalType;
|
|
45049
|
+
/**
|
|
45050
|
+
* The machine client acting for the identity, from a verified `delegated`
|
|
45051
|
+
* token's `act.sub` (its `client_id`; see `delegation()`). When set, the
|
|
45052
|
+
* check allows only when the identity and the client both hold the
|
|
45053
|
+
* permission there. Read it off the verified token, never off the request.
|
|
45054
|
+
*/
|
|
45055
|
+
acting_client_id?: string;
|
|
45026
45056
|
permission: string;
|
|
45027
45057
|
/** Defaults to `node`, which is the strict question. */
|
|
45028
45058
|
scope?: "node" | "app_wide";
|
|
@@ -45219,6 +45249,7 @@ declare class LocalAuthorizer {
|
|
|
45219
45249
|
*/
|
|
45220
45250
|
permissionsAtMany(identityId: string, nodeIds: readonly string[], subject?: SubjectOptions): Promise<Map<string, string[]>>;
|
|
45221
45251
|
private decide;
|
|
45252
|
+
private decideFor;
|
|
45222
45253
|
/**
|
|
45223
45254
|
* Whether one of the grants stands clear of every deny root: none at its
|
|
45224
45255
|
* node or above it. A grant with a deny strictly beneath it still reaches
|
|
@@ -45525,6 +45556,77 @@ declare function tokenErrorStatus(error: unknown): FailureStatus;
|
|
|
45525
45556
|
*/
|
|
45526
45557
|
declare function authorizationErrorStatus(error: unknown): FailureStatus;
|
|
45527
45558
|
|
|
45559
|
+
/** The RFC 8693 grant a machine client exchanges a person's token with. */
|
|
45560
|
+
declare const TOKEN_EXCHANGE_GRANT = "urn:ietf:params:oauth:grant-type:token-exchange";
|
|
45561
|
+
/** The only token type Canopy exchanges, and the only one it issues. */
|
|
45562
|
+
declare const ACCESS_TOKEN_TYPE = "urn:ietf:params:oauth:token-type:access_token";
|
|
45563
|
+
interface ExchangeTokenOptions {
|
|
45564
|
+
/** The machine client's `client_id`. Its token exchange switch must be on. */
|
|
45565
|
+
clientId: string;
|
|
45566
|
+
/** The machine client's secret. Keep it on the server; never in a browser. */
|
|
45567
|
+
clientSecret: string;
|
|
45568
|
+
/**
|
|
45569
|
+
* The signed-in person's access token, issued by the same Environment. The
|
|
45570
|
+
* person must still be signed in and a member, and, for a client pinned to
|
|
45571
|
+
* an organization, inside that organization.
|
|
45572
|
+
*/
|
|
45573
|
+
subjectToken: string;
|
|
45574
|
+
/**
|
|
45575
|
+
* The API the new token is for: the Environment's default audience when
|
|
45576
|
+
* omitted, or one in the client's allowed audiences.
|
|
45577
|
+
*/
|
|
45578
|
+
audience?: string;
|
|
45579
|
+
/** Space-separated scopes, from the client's own. */
|
|
45580
|
+
scope?: string;
|
|
45581
|
+
/**
|
|
45582
|
+
* The origin that serves the Environment's token endpoint: Canopy's hosted
|
|
45583
|
+
* origin (or `CANOPY_BASE_URL`) by default, or your custom auth domain
|
|
45584
|
+
* when the Environment has one.
|
|
45585
|
+
*/
|
|
45586
|
+
baseUrl?: string;
|
|
45587
|
+
signal?: AbortSignal;
|
|
45588
|
+
/** Injectable for tests and for runtimes with a non-global fetch. */
|
|
45589
|
+
fetch?: typeof globalThis.fetch;
|
|
45590
|
+
}
|
|
45591
|
+
/** A delegated token, ready to send as `Authorization: Bearer`. */
|
|
45592
|
+
interface ExchangedToken {
|
|
45593
|
+
accessToken: string;
|
|
45594
|
+
tokenType: "Bearer";
|
|
45595
|
+
/** Seconds until it expires: the machine-token lifetime or the person's remaining time, whichever is shorter. */
|
|
45596
|
+
expiresIn: number;
|
|
45597
|
+
/** The scopes it was granted, space-separated, when any were. */
|
|
45598
|
+
scope?: string;
|
|
45599
|
+
/** Always `urn:ietf:params:oauth:token-type:access_token`. */
|
|
45600
|
+
issuedTokenType: string;
|
|
45601
|
+
}
|
|
45602
|
+
/**
|
|
45603
|
+
* Exchange a signed-in person's access token for one that lets a machine
|
|
45604
|
+
* client act for them (RFC 8693 token exchange).
|
|
45605
|
+
*
|
|
45606
|
+
* The token that comes back is `delegated`: `sub` is the person, `act.sub`
|
|
45607
|
+
* the client, and it reaches only what both hold. It has no refresh token;
|
|
45608
|
+
* exchange again when it expires. Canopy's own API refuses it: it is for your
|
|
45609
|
+
* API, which verifies it with `alsoAllow: ["delegated"]` and authorizes it
|
|
45610
|
+
* with both principals (`acting_client_id`).
|
|
45611
|
+
*
|
|
45612
|
+
* ```ts
|
|
45613
|
+
* const { accessToken } = await exchangeToken({
|
|
45614
|
+
* clientId: process.env.AGENT_CLIENT_ID!,
|
|
45615
|
+
* clientSecret: process.env.AGENT_CLIENT_SECRET!,
|
|
45616
|
+
* subjectToken: personAccessToken,
|
|
45617
|
+
* audience: "https://api.example.com",
|
|
45618
|
+
* });
|
|
45619
|
+
* ```
|
|
45620
|
+
*
|
|
45621
|
+
* A refusal throws `CanopyError` with the OAuth error as its code
|
|
45622
|
+
* (`oauth.invalid_grant` when the person signed out or is no longer a
|
|
45623
|
+
* member, `oauth.unauthorized_client` when the client's token exchange
|
|
45624
|
+
* switch is off, `oauth.invalid_request` with `retryAfterMs` when it asked
|
|
45625
|
+
* too often). A request that never got an answer throws
|
|
45626
|
+
* `CanopyConnectionError`.
|
|
45627
|
+
*/
|
|
45628
|
+
declare function exchangeToken(options: ExchangeTokenOptions): Promise<ExchangedToken>;
|
|
45629
|
+
|
|
45528
45630
|
interface TokenVerifierOptions {
|
|
45529
45631
|
/**
|
|
45530
45632
|
* The Environment whose tokens are accepted. Every Environment is its own
|
|
@@ -45556,12 +45658,13 @@ interface TokenVerifierOptions {
|
|
|
45556
45658
|
*/
|
|
45557
45659
|
audience?: string;
|
|
45558
45660
|
/**
|
|
45559
|
-
* The audience a machine client's
|
|
45560
|
-
* identifier your API answers to
|
|
45561
|
-
*
|
|
45661
|
+
* The audience a machine client's token must name, `service` or
|
|
45662
|
+
* `delegated`: the identifier your API answers to
|
|
45663
|
+
* (`https://api.example.com`), the one the client asked for with
|
|
45664
|
+
* `audience` or the Environment's default audience.
|
|
45562
45665
|
*
|
|
45563
|
-
* A
|
|
45564
|
-
* client, so `audience` never applies to it. Admitting
|
|
45666
|
+
* A machine client's token always carries `aud`, and it names the API
|
|
45667
|
+
* rather than a client, so `audience` never applies to it. Admitting one
|
|
45565
45668
|
* without this throws `token.audience_unverified`, so a token minted for
|
|
45566
45669
|
* another of your APIs is never accepted by accident.
|
|
45567
45670
|
*/
|
|
@@ -45599,7 +45702,8 @@ interface TokenVerifierOptions {
|
|
|
45599
45702
|
* `["identity"]`: the people who sign in to your application.
|
|
45600
45703
|
*
|
|
45601
45704
|
* Canopy also signs tokens for machine clients (`service`, obtained with
|
|
45602
|
-
* the `client_credentials` grant
|
|
45705
|
+
* the `client_credentials` grant, and `delegated`, a client acting for a
|
|
45706
|
+
* person after a token exchange), its own administrators (`user`), its
|
|
45603
45707
|
* staff (`platform`) and, for some flows, API keys (`api_key`), all with the
|
|
45604
45708
|
* same keys and issuer. A backend that serves your end users should accept
|
|
45605
45709
|
* none of them, so they are refused unless you name them here, or admit
|
|
@@ -45621,16 +45725,27 @@ interface TokenVerifierOptions {
|
|
|
45621
45725
|
interface CanopyTokenClaims {
|
|
45622
45726
|
/**
|
|
45623
45727
|
* The principal this token acts as: an identity's id, or, on a `service`
|
|
45624
|
-
* token, the machine client's `client_id`.
|
|
45728
|
+
* token, the machine client's `client_id`. On a `delegated` token it is
|
|
45729
|
+
* the person the client acts for; the client is `act.sub`.
|
|
45625
45730
|
*/
|
|
45626
45731
|
sub: string;
|
|
45627
|
-
/** Which kind of principal `sub` is. */
|
|
45628
|
-
type: "user" | "identity" | "service" | "api_key" | "platform";
|
|
45732
|
+
/** Which kind of principal `sub` is, or `delegated` for a client acting for one. */
|
|
45733
|
+
type: "user" | "identity" | "service" | "delegated" | "api_key" | "platform";
|
|
45734
|
+
/**
|
|
45735
|
+
* How a machine client's token was obtained: `client_credentials` on a
|
|
45736
|
+
* `service` token, `token-exchange` on a `delegated` one. Absent on every
|
|
45737
|
+
* other type.
|
|
45738
|
+
*/
|
|
45739
|
+
gty?: "client_credentials" | "token-exchange";
|
|
45629
45740
|
/**
|
|
45630
|
-
*
|
|
45631
|
-
*
|
|
45741
|
+
* On a `delegated` token, the machine client acting for `sub`: its
|
|
45742
|
+
* `client_id`. A delegated token reaches only what both hold, so authorize
|
|
45743
|
+
* it with both (`acting_client_id` on an evaluate); read the pair through
|
|
45744
|
+
* {@link delegation}.
|
|
45632
45745
|
*/
|
|
45633
|
-
|
|
45746
|
+
act?: {
|
|
45747
|
+
sub: string;
|
|
45748
|
+
};
|
|
45634
45749
|
/** The OAuth client the token was issued to; on a `service` token, `sub`. */
|
|
45635
45750
|
client_id?: string;
|
|
45636
45751
|
iss: string;
|
|
@@ -45749,6 +45864,34 @@ interface CanopyOrgContext {
|
|
|
45749
45864
|
* ```
|
|
45750
45865
|
*/
|
|
45751
45866
|
declare function orgContext(claims: CanopyTokenClaims): CanopyOrgContext | null;
|
|
45867
|
+
/** Who a `delegated` token names: the person, and the client acting for them. */
|
|
45868
|
+
interface CanopyDelegation {
|
|
45869
|
+
/** The identity the client acts for: the token's `sub`. */
|
|
45870
|
+
identityId: string;
|
|
45871
|
+
/** The machine client acting for them: its `client_id`, the token's `act.sub`. */
|
|
45872
|
+
actingClientId: string;
|
|
45873
|
+
}
|
|
45874
|
+
/**
|
|
45875
|
+
* The two principals a verified `delegated` token names, or `null` for any
|
|
45876
|
+
* other token.
|
|
45877
|
+
*
|
|
45878
|
+
* A machine client obtains a delegated token by exchanging a signed-in
|
|
45879
|
+
* person's access token. It reaches only what both hold, so authorize it with
|
|
45880
|
+
* both: pass `actingClientId` as `acting_client_id` to
|
|
45881
|
+
* {@link LocalAuthorizer.evaluate} or to the API's evaluate.
|
|
45882
|
+
*
|
|
45883
|
+
* ```ts
|
|
45884
|
+
* const claims = await verifier.verify(token, { alsoAllow: ["delegated"] });
|
|
45885
|
+
* const acting = delegation(claims);
|
|
45886
|
+
* const decision = await authorizer.evaluate({
|
|
45887
|
+
* identity_id: claims.sub,
|
|
45888
|
+
* permission: "deals.read",
|
|
45889
|
+
* node_id: dealNodeId,
|
|
45890
|
+
* ...(acting ? { acting_client_id: acting.actingClientId } : {}),
|
|
45891
|
+
* });
|
|
45892
|
+
* ```
|
|
45893
|
+
*/
|
|
45894
|
+
declare function delegation(claims: CanopyTokenClaims): CanopyDelegation | null;
|
|
45752
45895
|
declare class TokenVerifier {
|
|
45753
45896
|
private readonly issuer;
|
|
45754
45897
|
private readonly audience;
|
|
@@ -45795,8 +45938,9 @@ declare class TokenVerifier {
|
|
|
45795
45938
|
* ignoring it would accept a token minted for a different client. So it
|
|
45796
45939
|
* throws and names the option.
|
|
45797
45940
|
*
|
|
45798
|
-
* A
|
|
45799
|
-
* is held to `serviceAudience` alone,
|
|
45941
|
+
* A machine client's token (`service` or `delegated`) names the API it was
|
|
45942
|
+
* minted for, never a client, so it is held to `serviceAudience` alone,
|
|
45943
|
+
* which it must name.
|
|
45800
45944
|
*/
|
|
45801
45945
|
private assertAudience;
|
|
45802
45946
|
/**
|
|
@@ -45927,4 +46071,4 @@ declare const WEBHOOK_TIMESTAMP_TOLERANCE_SECONDS = 300;
|
|
|
45927
46071
|
*/
|
|
45928
46072
|
declare function verifyWebhookSignature(input: VerifyWebhookSignatureInput): Promise<boolean>;
|
|
45929
46073
|
|
|
45930
|
-
export { type AccessibleNodes, type AppliedChange, type AssignmentItem, Assignments, type AuthorizationChange, type CallOptions, Canopy, CanopyAuthorizerError, CanopyClient, type CanopyClientOptions, CanopyConnectionError, CanopyError, type CanopyErrorBody, type CanopyOrgContext, type CanopyTokenClaims, CanopyTokenError, type Collection, type ConcurrencyOptions, type ConditionalResult, type CursorPagination, DEFAULT_MAX_NODES, type FailureStatus, Identities, type IdentityAssignmentItem, type IdentityItem, type IdentitySessionItem, type InvalidatedSubject, type LocalAuthorizationQuery, LocalAuthorizer, type LocalAuthorizerOptions, type LocalAuthorizerStats, type LocalDecision, type LocalDecisionEvent, type LocalDenialReason, MAX_TTL_MS, type OffsetPagination, type OperationId, type OrganizationDirectoryGroupItem, type OrganizationInviteItem, type OrganizationItem, type OrganizationMemberItem, type OrganizationStaffActivityItem, Organizations, type PageFetcher, type PageParams, type PaginateOptions, type Pagination, Paginator, type PartialSuccess, type PermissionItem, Permissions, type PrincipalType, type QueryParams, type ReplayChangesOptions, type ReplayChangesResult, type RequestBody, type RequestOptions, type ResponseBody, type RoleItem, Roles, type Schema, type SubjectOptions, TokenVerifier, type TokenVerifierOptions, type VerifyCallOptions, type VerifyWebhookSignatureInput, WEBHOOK_TIMESTAMP_TOLERANCE_SECONDS, type WebhookDelivery, type WebhookEvent, type WebhookEventData, type WebhookEventName, type WebhookHeaders, authorizationErrorStatus, type components, isCanopyAuthorizerError, isCanopyConnectionError, isCanopyError, isCanopyTokenError, isCursorPagination, isWebhookEvent, type operations, orgContext, paginate, type paths, tokenErrorStatus, verifyWebhookSignature, withConcurrency };
|
|
46074
|
+
export { ACCESS_TOKEN_TYPE, type AccessibleNodes, type AppliedChange, type AssignmentItem, Assignments, type AuthorizationChange, type CallOptions, Canopy, CanopyAuthorizerError, CanopyClient, type CanopyClientOptions, CanopyConnectionError, type CanopyDelegation, CanopyError, type CanopyErrorBody, type CanopyOrgContext, type CanopyTokenClaims, CanopyTokenError, type Collection, type ConcurrencyOptions, type ConditionalResult, type CursorPagination, DEFAULT_MAX_NODES, type ExchangeTokenOptions, type ExchangedToken, type FailureStatus, Identities, type IdentityAssignmentItem, type IdentityItem, type IdentitySessionItem, type InvalidatedSubject, type LocalAuthorizationQuery, LocalAuthorizer, type LocalAuthorizerOptions, type LocalAuthorizerStats, type LocalDecision, type LocalDecisionEvent, type LocalDenialReason, MAX_TTL_MS, type OffsetPagination, type OperationId, type OrganizationDirectoryGroupItem, type OrganizationInviteItem, type OrganizationItem, type OrganizationMemberItem, type OrganizationStaffActivityItem, Organizations, type PageFetcher, type PageParams, type PaginateOptions, type Pagination, Paginator, type PartialSuccess, type PermissionItem, Permissions, type PrincipalType, type QueryParams, type ReplayChangesOptions, type ReplayChangesResult, type RequestBody, type RequestOptions, type ResponseBody, type RoleItem, Roles, type Schema, type SubjectOptions, TOKEN_EXCHANGE_GRANT, TokenVerifier, type TokenVerifierOptions, type VerifyCallOptions, type VerifyWebhookSignatureInput, WEBHOOK_TIMESTAMP_TOLERANCE_SECONDS, type WebhookDelivery, type WebhookEvent, type WebhookEventData, type WebhookEventName, type WebhookHeaders, authorizationErrorStatus, type components, delegation, exchangeToken, isCanopyAuthorizerError, isCanopyConnectionError, isCanopyError, isCanopyTokenError, isCursorPagination, isWebhookEvent, type operations, orgContext, paginate, type paths, tokenErrorStatus, verifyWebhookSignature, withConcurrency };
|