@canopy-io/node 0.16.0 → 0.17.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/dist/index.d.cts CHANGED
@@ -422,7 +422,7 @@ interface paths {
422
422
  put?: never;
423
423
  /**
424
424
  * Create an identity
425
- * @description Creates a single identity in the active Application's current Environment, optionally assigning an initial role at a node in the same request (`role_id` + `node_id`). Email is normalized (lower-cased, trimmed) and must be unique within the Account — a duplicate returns `409`; passwords are hashed with argon2id and screened against HaveIBeenPwned, so a breached password returns `400`. Returns the created identity with profile metadata only (the password is never echoed).
425
+ * @description Creates a single identity in the active Application's current Environment, optionally assigning an initial role at a node in the same request (`role_id` + `node_id`). Email is normalized (lower-cased, trimmed) and must be unique within the Account — a duplicate returns `409`; passwords are hashed with argon2id and screened against HaveIBeenPwned, so a breached password returns `400`. On the public API a `password_hash` from another system (`password_hash_algorithm`: `bcrypt`, `argon2id`, `pbkdf2_sha256` or `scrypt`) is stored as it is and verified that way at sign-in; the first sign-in that proves it re-hashes to argon2id and runs the breach check, sending a breached password to reset. Returns the created identity with profile metadata only (the password is never echoed).
426
426
  */
427
427
  post: operations["ApiIdentitiesController_createIdentity"];
428
428
  delete?: never;
@@ -1086,7 +1086,7 @@ interface paths {
1086
1086
  put?: never;
1087
1087
  /**
1088
1088
  * Preview moving a node
1089
- * @description Reports what moving the node under `parent_node_id` would change, without moving it. `blockers` lists what would refuse the move, with the code and message the move answers `400` with (the schema's parent and child types, depth, a cycle, an organization boundary); when any is listed nothing else is resolved. Otherwise: `subtree_size`, the node and every node beneath it; `identities_gaining`, `identities_losing` and `permissions`, the counts per key, over everyone; `people`, one page of the holders whose access at the node changes (and so beneath it, since grants inside the subtree travel with it), one row per person by name, with the keys `gained` and `lost` and `via`, the grants behind them, and `pagination`. The query narrows the page and never the counts: `q` (name or email), `direction` (`gains` or `loses`), `permission` (one key), `page` and `take` (up to 5000, so a client can export every change in a few reads); and `invites` and `directory_groups`, the pending invitations and directory groups at nodes in the subtree, which move with it. People are named only for a reader who may see the Environment's people (`people_named`: `env_identities.view` in the Console, and `production_identities.access` in a production Environment; `identity.view` for an API key; access administration at the node for a tenant's administrator); anyone else gets the counts and an empty page, whatever the query. Resolved by the rules `evaluate` applies. Read-only. Send `version` as `If-Match` and `parent_version` in the body on the move, so it applies only to the node and the destination previewed. Gated as the move is: `hierarchy.manage` on the node and on the new parent. Returns `404` when the node or the parent is not found in this Environment.
1089
+ * @description Reports what moving the node under `parent_node_id` would change, without moving it. `blockers` lists what would refuse the move, with the code and message the move answers `400` with (the schema's parent and child types, depth, a cycle, an organization boundary); when any is listed nothing else is resolved. Otherwise: `subtree_size`, the node and every node beneath it; `identities_gaining`, `identities_losing` and `permissions`, the counts per key, over everyone; and `invites` and `directory_groups`, the pending invitations and directory groups at nodes in the subtree, which move with it. People are named only for a reader who may see the Environment's people (`people_named`: `env_identities.view` in the Console, and `production_identities.access` in a production Environment; `identity.view` for an API key; access administration at the node for a tenant's administrator); anyone else gets the counts, and an empty page from the people route. The preview is kept under `id` until `expires_at`: read the holders whose access at the node changes (and so beneath it, since grants inside the subtree travel with it), one row per person by name with the keys `gained` and `lost` and `via`, the grants behind them, from `GET /api/v1/access-previews/{previewId}/people`, narrowed by `q`, `direction`, `permission`, `page` and `take`, and as a file from `…/people.csv`. Resolved by the rules `evaluate` applies. Read-only. Send `version` as `If-Match` and `parent_version` in the body on the move, so it applies only to the node and the destination previewed. Gated as the move is: `hierarchy.manage` on the node and on the new parent. Returns `404` when the node or the parent is not found in this Environment.
1090
1090
  */
1091
1091
  post: operations["ApiNodesController_previewMoveNode"];
1092
1092
  delete?: never;
@@ -1106,7 +1106,7 @@ interface paths {
1106
1106
  put?: never;
1107
1107
  /**
1108
1108
  * Preview deleting a node
1109
- * @description Reports what deleting the node would remove, without deleting it. `blockers` lists what would refuse the delete (the root node, or an organization node, which is deleted through the organizations API); when any is listed nothing else is counted. Otherwise: `subtree_size`, the node and every node beneath it; `roles`, the role assignments made in the subtree counted by role, and `assignments_total`; `identities_affected`, and `identities_losing_all_access`, those holding no assignment anywhere else in the Environment; `invites`, the pending invitations there, by email; and `directory_groups`, the directory groups mapped there, by name. The same sets the delete removes. `people` is one page of the holders whose assignments go, one row per person by name, with `via`, their assignments that go as role at node, and `pagination`; `q` (name or email), `role_id`, `page` and `take` (up to 5000) narrow the page and never the counts. People are named only for a reader who may see the Environment's people (`people_named`: `env_identities.view` in the Console, and `production_identities.access` in a production Environment; `identity.view` for an API key; access administration at the node for a tenant's administrator); anyone else gets the counts and an empty page, whatever the query. Read-only. Send `version` as `If-Match` on the delete. Gated as the delete is: `hierarchy.manage` on the node. Returns `404` when the node is not found in this Environment.
1109
+ * @description Reports what deleting the node would remove, without deleting it. `blockers` lists what would refuse the delete (the root node, or an organization node, which is deleted through the organizations API); when any is listed nothing else is counted. Otherwise: `subtree_size`, the node and every node beneath it; `roles`, the role assignments made in the subtree counted by role, and `assignments_total`; `identities_affected`, and `identities_losing_all_access`, those holding no assignment anywhere else in the Environment; `invites`, the pending invitations there, by email; and `directory_groups`, the directory groups mapped there, by name. The same sets the delete removes. People are named only for a reader who may see the Environment's people (`people_named`: `env_identities.view` in the Console, and `production_identities.access` in a production Environment; `identity.view` for an API key; access administration at the node for a tenant's administrator); anyone else gets the counts, and an empty page from the people route. The preview is kept under `id` until `expires_at`: read the holders whose assignments go, one row per person by name with `via`, their assignments as role at node, from `GET /api/v1/access-previews/{previewId}/people`, narrowed by `q`, `role_id`, `page` and `take`, and as a file from `…/people.csv`. Read-only. Send `version` as `If-Match` on the delete. Gated as the delete is: `hierarchy.manage` on the node. Returns `404` when the node is not found in this Environment.
1110
1110
  */
1111
1111
  post: operations["ApiNodesController_previewDeleteNode"];
1112
1112
  delete?: never;
@@ -1438,7 +1438,7 @@ interface paths {
1438
1438
  put?: never;
1439
1439
  /**
1440
1440
  * Preview moving a node inside an organization
1441
- * @description Reports what moving the node beneath `parent_node_id` would change, without moving it: the same answer as `POST /nodes/{id}/move/preview` (`blockers`, `subtree_size`, the counts per key and a page of the holders gaining and losing keys at the node, with the same query, and the invitations and directory groups that move with the subtree), authorized as the move is. Read-only.
1441
+ * @description Reports what moving the node beneath `parent_node_id` would change, without moving it: the same answer as `POST /nodes/{id}/move/preview` (`blockers`, `subtree_size`, the counts per key, with the holders gaining and losing keys paged from the stored preview by its `id`, and the invitations and directory groups that move with the subtree), authorized as the move is. Read-only.
1442
1442
  */
1443
1443
  post: operations["ApiOrganizationStructureController_previewMoveNode"];
1444
1444
  delete?: never;
@@ -1478,7 +1478,7 @@ interface paths {
1478
1478
  put?: never;
1479
1479
  /**
1480
1480
  * Preview deleting a node inside an organization
1481
- * @description Reports what deleting the node would remove, without deleting it: the same answer as `POST /nodes/{id}/delete/preview` (`blockers`, `subtree_size`, the assignments that go by role and who is left with no access, a page of the people whose assignments go, with the same query, the invitations revoked and the directory groups unmapped), authorized as the delete is. Read-only.
1481
+ * @description Reports what deleting the node would remove, without deleting it: the same answer as `POST /nodes/{id}/delete/preview` (`blockers`, `subtree_size`, the assignments that go by role and who is left with no access, with the people whose assignments go paged from the stored preview by its `id`, the invitations revoked and the directory groups unmapped), authorized as the delete is. Read-only.
1482
1482
  */
1483
1483
  post: operations["ApiOrganizationStructureController_previewDeleteNode"];
1484
1484
  delete?: never;
@@ -2554,7 +2554,7 @@ interface paths {
2554
2554
  put?: never;
2555
2555
  /**
2556
2556
  * Preview replacing a role's permissions
2557
- * @description Reports what replacing the role's permissions with `permission_keys` would change, without changing them: `added` and `removed`, and `blockers`, what would refuse the write, with the code and message it answers (`organization.last_admin`, `rbac.roles_manage_below_organization`); when any is listed no access is resolved. Otherwise, wherever the role is held now: `holders`, the identities it grants something to; `identities_gaining`, `identities_losing` and `permissions`, the counts per key, over everyone; and `people`, one page of the holders whose access changes, one row per person by name (a holder of the role at several nodes is one row), with the keys `gained` and `lost` once their other grants on each lineage are counted, `via`, the role at each node behind them, and `pagination`. The query narrows the page and never the counts: `q` (name or email), `direction` (`gains` or `loses`), `permission` (one key), `page` and `take` (up to 5000). People are named only for a reader who may see the Environment's people (`people_named`: `env_identities.view` in the Console, and `production_identities.access` in a production Environment; `identity.view` for an API key; access administration at the node for a tenant's administrator); anyone else gets the counts and an empty page, whatever the query. A disabled role (`role_active: false`) grants nothing either way. Resolved by the rules `evaluate` applies. Read-only. A key not in the Environment's catalog returns `404`, as on the write. Send `version` as `If-Match` on the write. Requires the `rbac.manage_roles` permission.
2557
+ * @description Reports what replacing the role's permissions with `permission_keys` would change, without changing them: `added` and `removed`, and `blockers`, what would refuse the write, with the code and message it answers (`organization.last_admin`, `rbac.roles_manage_below_organization`); when any is listed no access is resolved. Otherwise, wherever the role is held now: `holders`, the identities it grants something to; `identities_gaining`, `identities_losing` and `permissions`, the counts per key, over everyone. People are named only for a reader who may see the Environment's people (`people_named`: `env_identities.view` in the Console, and `production_identities.access` in a production Environment; `identity.view` for an API key; access administration at the node for a tenant's administrator); anyone else gets the counts, and an empty page from the people route. The preview is kept under `id` until `expires_at`: read the holders whose access changes, one row per person by name (a holder of the role at several nodes is one row) with the keys `gained` and `lost` once their other grants on each lineage are counted and `via`, the role at each node behind them, from `GET /api/v1/access-previews/{previewId}/people`, narrowed by `q`, `direction`, `permission`, `page` and `take`, and as a file from `…/people.csv`. A disabled role (`role_active: false`) grants nothing either way. Resolved by the rules `evaluate` applies. Read-only. A key not in the Environment's catalog returns `404`, as on the write. Send `version` as `If-Match` on the write. Requires the `rbac.manage_roles` permission.
2558
2558
  */
2559
2559
  post: operations["ApiRolesController_previewRolePermissions"];
2560
2560
  delete?: never;
@@ -2651,6 +2651,46 @@ interface paths {
2651
2651
  patch?: never;
2652
2652
  trace?: never;
2653
2653
  };
2654
+ "/api/v1/access-previews/{previewId}/people": {
2655
+ parameters: {
2656
+ query?: never;
2657
+ header?: never;
2658
+ path?: never;
2659
+ cookie?: never;
2660
+ };
2661
+ /**
2662
+ * List the people a stored access preview reaches
2663
+ * @description One page of the people a stored access preview reaches, by name, one row per person: for a move or a permissions preview the keys `gained` and `lost` with `via`, the grants behind them; for a delete preview `via`, their assignments that go. The preview is the one its id names, made by `POST …/move/preview`, `…/delete/preview` or `…/permissions/preview`; it is read only by the principal that made it, in the Environment it was made in, and only until its `expires_at`, so anyone else's, an expired one and an unknown id all answer `404`. Each read resolves the change again, under the gate its creation passed, and answers `409` `version_mismatch` once the node, its destination or the role has changed since the preview: preview the change again. The query narrows the page and never the preview's counts: `q` (name or email), `direction` (`gains` or `loses`) and `permission` (one key) on a change preview, `role_id` on a delete preview, `page` and `take` (up to 5000). A reader who may not see the Environment's people (`people_named` false on the preview) gets an empty page, whatever the query.
2664
+ */
2665
+ get: operations["ApiAccessPreviewsController_listPeople"];
2666
+ put?: never;
2667
+ post?: never;
2668
+ delete?: never;
2669
+ options?: never;
2670
+ head?: never;
2671
+ patch?: never;
2672
+ trace?: never;
2673
+ };
2674
+ "/api/v1/access-previews/{previewId}/people.csv": {
2675
+ parameters: {
2676
+ query?: never;
2677
+ header?: never;
2678
+ path?: never;
2679
+ cookie?: never;
2680
+ };
2681
+ /**
2682
+ * Export the people a stored access preview reaches
2683
+ * @description Every person the stored preview reaches, as a CSV file: for a move or a permissions preview one line per key gained or lost (`Name`, `Email`, `Change`, `Permission`, `Through`), for a delete preview one line per assignment that goes (`Name`, `Email`, `Role`, `Node`). Cells are neutralised against spreadsheet formula injection. Read under the same rules as the people route: the preview's maker only, in its Environment, until `expires_at` (`404` otherwise), and `409` once what it read has changed. A reader who may not see the Environment's people gets a file with the header line only.
2684
+ */
2685
+ get: operations["ApiAccessPreviewsController_exportPeople"];
2686
+ put?: never;
2687
+ post?: never;
2688
+ delete?: never;
2689
+ options?: never;
2690
+ head?: never;
2691
+ patch?: never;
2692
+ trace?: never;
2693
+ };
2654
2694
  "/api/v1/assignments/app-wide": {
2655
2695
  parameters: {
2656
2696
  query?: never;
@@ -3480,7 +3520,7 @@ interface components {
3480
3520
  assigned_count: number;
3481
3521
  unassigned_count: number;
3482
3522
  };
3483
- CreateIdentityDto: {
3523
+ ApiCreateIdentityDto: {
3484
3524
  email: string;
3485
3525
  first_name: string;
3486
3526
  last_name: string;
@@ -3492,9 +3532,16 @@ interface components {
3492
3532
  role_id?: string;
3493
3533
  /** @description Node for an initial assignment — required if role_id is provided */
3494
3534
  node_id?: string;
3535
+ /** @description An existing password hash to import instead of `password`, written the way `password_hash_algorithm` writes one. The identity signs in with its original password; after the first sign-in that proves it, Canopy replaces the hash with its own argon2id hash and runs the breach check, sending a breached password to reset. */
3536
+ password_hash?: string;
3537
+ /**
3538
+ * @description The algorithm `password_hash` is in. `bcrypt` is the modular crypt string (`$2a$`, `$2b$` or `$2y$`); `argon2id` the PHC string; `pbkdf2_sha256` Django's `pbkdf2_sha256$iterations$salt$hash`; `scrypt` Django's `scrypt$N$salt$r$p$hash`. Required with `password_hash`.
3539
+ * @enum {string}
3540
+ */
3541
+ password_hash_algorithm?: "bcrypt" | "argon2id" | "pbkdf2_sha256" | "scrypt";
3495
3542
  };
3496
- BulkCreateIdentitiesDto: {
3497
- identities: components["schemas"]["CreateIdentityDto"][];
3543
+ ApiBulkCreateIdentitiesDto: {
3544
+ identities: components["schemas"]["ApiCreateIdentityDto"][];
3498
3545
  };
3499
3546
  IdentityDetailResponseDto: {
3500
3547
  id: string;
@@ -3920,69 +3967,30 @@ interface components {
3920
3967
  gaining: number;
3921
3968
  losing: number;
3922
3969
  };
3923
- AssignmentIdentityDto: {
3924
- id: string;
3925
- first_name: string;
3926
- last_name: string;
3927
- name: string;
3928
- email: string;
3929
- avatar_url?: string | null;
3930
- };
3931
- PreviewNodeDto: {
3932
- id: string;
3933
- name: string;
3934
- };
3935
- PreviewGrantDto: {
3936
- /** @description The role */
3937
- role: components["schemas"]["PreviewNodeDto"];
3938
- /** @description Where it is held */
3939
- node: components["schemas"]["PreviewNodeDto"];
3940
- };
3941
- AccessChangeDto: {
3942
- identity: components["schemas"]["AssignmentIdentityDto"];
3943
- /** @description Keys the person gains */
3944
- gained: string[];
3945
- /** @description Keys the person loses */
3946
- lost: string[];
3947
- /** @description The grants that give the keys gained, or gave the keys lost */
3948
- via: components["schemas"]["PreviewGrantDto"][];
3949
- };
3950
- PreviewPageMetaDto: {
3951
- /** @description Current page number (1-based) */
3952
- page: number;
3953
- /** @description People per page */
3954
- take: number;
3955
- /** @description People matching the query */
3956
- item_count: number;
3957
- /** @description Total number of pages */
3958
- page_count: number;
3959
- /** @description Whether a previous page exists */
3960
- has_previous_page: boolean;
3961
- /** @description Whether a next page exists */
3962
- has_next_page: boolean;
3963
- };
3964
- AccessChangePageDto: {
3965
- /** @description One row per person, by name (none unless `people_named`) */
3966
- items: components["schemas"]["AccessChangeDto"][];
3967
- /** @description Paging over the people matching `q`, `direction` and `permission` */
3968
- pagination: components["schemas"]["PreviewPageMetaDto"];
3969
- };
3970
3970
  NamedSampleDto: {
3971
3971
  total: number;
3972
3972
  names: string[];
3973
3973
  };
3974
3974
  NodeMovePreviewDto: {
3975
+ /**
3976
+ * Format: uuid
3977
+ * @description The preview's id: read its people from `GET …/access-previews/:previewId/people`, and as a file from `…/people.csv`, until `expires_at`
3978
+ */
3979
+ id: string;
3980
+ /**
3981
+ * Format: date-time
3982
+ * @description When the preview stops being readable
3983
+ */
3984
+ expires_at: string;
3975
3985
  /** @description What would refuse the change. When any is listed, nothing below is resolved */
3976
3986
  blockers: components["schemas"]["PreviewBlockerDto"][];
3977
- /** @description Whether people are named: false for a reader who may not see the Environment's people, who gets the counts and no list */
3987
+ /** @description Whether people are named: false for a reader who may not see the Environment's people, who gets the counts and an empty people page */
3978
3988
  people_named: boolean;
3979
3989
  /** @description Holders who gain at least one permission */
3980
3990
  identities_gaining: number;
3981
3991
  /** @description Holders who lose at least one permission */
3982
3992
  identities_losing: number;
3983
3993
  permissions: components["schemas"]["PermissionChangeCountDto"][];
3984
- /** @description One page of the people the change reaches. The counts above cover everyone; the page follows the query */
3985
- people: components["schemas"]["AccessChangePageDto"];
3986
3994
  node_id: string;
3987
3995
  parent_node_id: string;
3988
3996
  /** @description The node's version now: send it as `If-Match` on the move */
@@ -3996,27 +4004,30 @@ interface components {
3996
4004
  /** @description Directory groups mapped to nodes in the subtree, which move with it, by name */
3997
4005
  directory_groups: components["schemas"]["NamedSampleDto"];
3998
4006
  };
4007
+ PreviewNodeDto: {
4008
+ id: string;
4009
+ name: string;
4010
+ };
3999
4011
  RoleRemovalCountDto: {
4000
4012
  role: components["schemas"]["PreviewNodeDto"];
4001
4013
  assignments: number;
4002
4014
  identities: number;
4003
4015
  };
4004
- PersonRemovalDto: {
4005
- identity: components["schemas"]["AssignmentIdentityDto"];
4006
- /** @description Their assignments that go, as role at node */
4007
- via: components["schemas"]["PreviewGrantDto"][];
4008
- };
4009
- PersonRemovalPageDto: {
4010
- /** @description One row per person, by name (none unless `people_named`) */
4011
- items: components["schemas"]["PersonRemovalDto"][];
4012
- /** @description Paging over the people matching `q` and `role_id` */
4013
- pagination: components["schemas"]["PreviewPageMetaDto"];
4014
- };
4015
4016
  NodeDeletePreviewDto: {
4017
+ /**
4018
+ * Format: uuid
4019
+ * @description The preview's id: read its people from `GET …/access-previews/:previewId/people`, and as a file from `…/people.csv`, until `expires_at`
4020
+ */
4021
+ id: string;
4022
+ /**
4023
+ * Format: date-time
4024
+ * @description When the preview stops being readable
4025
+ */
4026
+ expires_at: string;
4016
4027
  node_id: string;
4017
4028
  /** @description The node's version now: send it as `If-Match` on the delete */
4018
4029
  version: number;
4019
- /** @description Whether people are named: false for a reader who may not see the Environment's people */
4030
+ /** @description Whether people are named: false for a reader who may not see the Environment's people, who gets the counts and an empty people page */
4020
4031
  people_named: boolean;
4021
4032
  /** @description What would refuse the delete. When any is listed, nothing below is counted */
4022
4033
  blockers: components["schemas"]["PreviewBlockerDto"][];
@@ -4030,13 +4041,19 @@ interface components {
4030
4041
  roles: components["schemas"]["RoleRemovalCountDto"][];
4031
4042
  /** @description How many assignments go in all */
4032
4043
  assignments_total: number;
4033
- /** @description One page of the people whose assignments go. The counts above cover everyone; the page follows the query */
4034
- people: components["schemas"]["PersonRemovalPageDto"];
4035
4044
  /** @description Pending invitations revoked, by email (none listed unless `people_named`) */
4036
4045
  invites: components["schemas"]["NamedSampleDto"];
4037
4046
  /** @description Directory groups unmapped, by name */
4038
4047
  directory_groups: components["schemas"]["NamedSampleDto"];
4039
4048
  };
4049
+ AssignmentIdentityDto: {
4050
+ id: string;
4051
+ first_name: string;
4052
+ last_name: string;
4053
+ name: string;
4054
+ email: string;
4055
+ avatar_url?: string | null;
4056
+ };
4040
4057
  AssignmentRoleDto: {
4041
4058
  id: string;
4042
4059
  name: string;
@@ -5077,17 +5094,25 @@ interface components {
5077
5094
  message: string;
5078
5095
  };
5079
5096
  RolePermissionsPreviewDto: {
5097
+ /**
5098
+ * Format: uuid
5099
+ * @description The preview's id: read its people from `GET …/access-previews/:previewId/people`, and as a file from `…/people.csv`, until `expires_at`
5100
+ */
5101
+ id: string;
5102
+ /**
5103
+ * Format: date-time
5104
+ * @description When the preview stops being readable
5105
+ */
5106
+ expires_at: string;
5080
5107
  /** @description What would refuse the change. When any is listed, nothing below is resolved */
5081
5108
  blockers: components["schemas"]["PreviewBlockerDto"][];
5082
- /** @description Whether people are named: false for a reader who may not see the Environment's people, who gets the counts and no list */
5109
+ /** @description Whether people are named: false for a reader who may not see the Environment's people, who gets the counts and an empty people page */
5083
5110
  people_named: boolean;
5084
5111
  /** @description Holders who gain at least one permission */
5085
5112
  identities_gaining: number;
5086
5113
  /** @description Holders who lose at least one permission */
5087
5114
  identities_losing: number;
5088
5115
  permissions: components["schemas"]["PermissionChangeCountDto"][];
5089
- /** @description One page of the people the change reaches. The counts above cover everyone; the page follows the query */
5090
- people: components["schemas"]["AccessChangePageDto"];
5091
5116
  role_id: string;
5092
5117
  /** @description The role's version now: send it as `If-Match` on the permissions write */
5093
5118
  version: number;
@@ -5192,6 +5217,20 @@ interface components {
5192
5217
  /** @description The deny's permissions this one would lose. */
5193
5218
  loses: string[];
5194
5219
  };
5220
+ PreviewPageMetaDto: {
5221
+ /** @description Current page number (1-based) */
5222
+ page: number;
5223
+ /** @description People per page */
5224
+ take: number;
5225
+ /** @description People matching the query */
5226
+ item_count: number;
5227
+ /** @description Total number of pages */
5228
+ page_count: number;
5229
+ /** @description Whether a previous page exists */
5230
+ has_previous_page: boolean;
5231
+ /** @description Whether a next page exists */
5232
+ has_next_page: boolean;
5233
+ };
5195
5234
  DenyPreviewPeoplePageDto: {
5196
5235
  /** @description One row per person or machine client losing access, by name; machine clients only unless `people_named` */
5197
5236
  items: components["schemas"]["DenyPreviewPersonDto"][];
@@ -5221,6 +5260,21 @@ interface components {
5221
5260
  /** @description Up to 20 of those an exception role spares. */
5222
5261
  kept: components["schemas"]["DenyPreviewKeptDto"][];
5223
5262
  };
5263
+ PreviewGrantDto: {
5264
+ /** @description The role */
5265
+ role: components["schemas"]["PreviewNodeDto"];
5266
+ /** @description Where it is held */
5267
+ node: components["schemas"]["PreviewNodeDto"];
5268
+ };
5269
+ PreviewPersonDto: {
5270
+ identity: components["schemas"]["AssignmentIdentityDto"];
5271
+ /** @description Keys the person gains (a move or a permissions preview) */
5272
+ gained?: string[];
5273
+ /** @description Keys the person loses (a move or a permissions preview) */
5274
+ lost?: string[];
5275
+ /** @description The grants that give the keys gained or gave the keys lost; on a delete preview, the person's assignments that go */
5276
+ via: components["schemas"]["PreviewGrantDto"][];
5277
+ };
5224
5278
  AssignmentsSummaryDto: {
5225
5279
  active_count: number;
5226
5280
  scheduled_count: number;
@@ -8378,7 +8432,7 @@ interface operations {
8378
8432
  };
8379
8433
  requestBody: {
8380
8434
  content: {
8381
- "application/json": components["schemas"]["CreateIdentityDto"];
8435
+ "application/json": components["schemas"]["ApiCreateIdentityDto"];
8382
8436
  };
8383
8437
  };
8384
8438
  responses: {
@@ -8393,7 +8447,7 @@ interface operations {
8393
8447
  };
8394
8448
  };
8395
8449
  };
8396
- /** @description The request failed validation, the password appears in a known data breach (HaveIBeenPwned check), or the role named for the initial assignment is a system role that cannot be assigned or an organization's own role placed outside that organization (`rbac.role_outside_organization`), or a role carrying `canopy:roles.manage` is placed beneath the organization node (`rbac.roles_manage_below_organization`); or the request sent both an `X-API-Key` and an `Authorization` header */
8450
+ /** @description The request failed validation, the password appears in a known data breach (HaveIBeenPwned check), `password_hash` is not written the way `password_hash_algorithm` writes one (`identity.password_hash_invalid`), both `password` and `password_hash` were sent (`identity.password_and_hash_exclusive`), or the role named for the initial assignment is a system role that cannot be assigned or an organization's own role placed outside that organization (`rbac.role_outside_organization`), or a role carrying `canopy:roles.manage` is placed beneath the organization node (`rbac.roles_manage_below_organization`); or the request sent both an `X-API-Key` and an `Authorization` header */
8397
8451
  400: {
8398
8452
  headers: {
8399
8453
  [name: string]: unknown;
@@ -8404,7 +8458,7 @@ interface operations {
8404
8458
  * "error": {
8405
8459
  * "statusCode": 400,
8406
8460
  * "code": null,
8407
- * "message": "The request failed validation, the password appears in a known data breach (HaveIBeenPwned check), or the role named for the initial assignment is a system role that cannot be assigned or an organization's own role placed outside that organization (`rbac.role_outside_organization`), or a role carrying `canopy:roles.manage` is placed beneath the organization node (`rbac.roles_manage_below_organization`); or the request sent both an `X-API-Key` and an `Authorization` header",
8461
+ * "message": "The request failed validation, the password appears in a known data breach (HaveIBeenPwned check), `password_hash` is not written the way `password_hash_algorithm` writes one (`identity.password_hash_invalid`), both `password` and `password_hash` were sent (`identity.password_and_hash_exclusive`), or the role named for the initial assignment is a system role that cannot be assigned or an organization's own role placed outside that organization (`rbac.role_outside_organization`), or a role carrying `canopy:roles.manage` is placed beneath the organization node (`rbac.roles_manage_below_organization`); or the request sent both an `X-API-Key` and an `Authorization` header",
8408
8462
  * "timestamp": "2026-04-20T12:00:00.000Z",
8409
8463
  * "path": "/api/v1/identities",
8410
8464
  * "method": "POST"
@@ -8698,7 +8752,7 @@ interface operations {
8698
8752
  };
8699
8753
  requestBody: {
8700
8754
  content: {
8701
- "application/json": components["schemas"]["BulkCreateIdentitiesDto"];
8755
+ "application/json": components["schemas"]["ApiBulkCreateIdentitiesDto"];
8702
8756
  };
8703
8757
  };
8704
8758
  responses: {
@@ -12605,18 +12659,7 @@ interface operations {
12605
12659
  };
12606
12660
  ApiNodesController_previewMoveNode: {
12607
12661
  parameters: {
12608
- query?: {
12609
- /** @description Page of people (1-based) */
12610
- page?: number;
12611
- /** @description People per page (1-5000, default 20) */
12612
- take?: number;
12613
- /** @description Only people whose name or email contains this, ignoring case */
12614
- q?: string;
12615
- /** @description Only the people gaining access, or only those losing it */
12616
- direction?: "gains" | "loses";
12617
- /** @description Only the people gaining or losing this permission key (with `direction`, only that side) */
12618
- permission?: string;
12619
- };
12662
+ query?: never;
12620
12663
  header?: never;
12621
12664
  path: {
12622
12665
  id: string;
@@ -12728,16 +12771,7 @@ interface operations {
12728
12771
  };
12729
12772
  ApiNodesController_previewDeleteNode: {
12730
12773
  parameters: {
12731
- query?: {
12732
- /** @description Page of people (1-based) */
12733
- page?: number;
12734
- /** @description People per page (1-5000, default 20) */
12735
- take?: number;
12736
- /** @description Only people whose name or email contains this, ignoring case */
12737
- q?: string;
12738
- /** @description Only the people holding this role in the subtree */
12739
- role_id?: string;
12740
- };
12774
+ query?: never;
12741
12775
  header?: never;
12742
12776
  path: {
12743
12777
  id: string;
@@ -15021,18 +15055,7 @@ interface operations {
15021
15055
  };
15022
15056
  ApiOrganizationStructureController_previewMoveNode: {
15023
15057
  parameters: {
15024
- query?: {
15025
- /** @description Page of people (1-based) */
15026
- page?: number;
15027
- /** @description People per page (1-5000, default 20) */
15028
- take?: number;
15029
- /** @description Only people whose name or email contains this, ignoring case */
15030
- q?: string;
15031
- /** @description Only the people gaining access, or only those losing it */
15032
- direction?: "gains" | "loses";
15033
- /** @description Only the people gaining or losing this permission key (with `direction`, only that side) */
15034
- permission?: string;
15035
- };
15058
+ query?: never;
15036
15059
  header?: never;
15037
15060
  path: {
15038
15061
  id: string;
@@ -15282,16 +15305,7 @@ interface operations {
15282
15305
  };
15283
15306
  ApiOrganizationStructureController_previewDeleteNode: {
15284
15307
  parameters: {
15285
- query?: {
15286
- /** @description Page of people (1-based) */
15287
- page?: number;
15288
- /** @description People per page (1-5000, default 20) */
15289
- take?: number;
15290
- /** @description Only people whose name or email contains this, ignoring case */
15291
- q?: string;
15292
- /** @description Only the people holding this role in the subtree */
15293
- role_id?: string;
15294
- };
15308
+ query?: never;
15295
15309
  header?: never;
15296
15310
  path: {
15297
15311
  id: string;
@@ -24517,18 +24531,7 @@ interface operations {
24517
24531
  };
24518
24532
  ApiRolesController_previewRolePermissions: {
24519
24533
  parameters: {
24520
- query?: {
24521
- /** @description Page of people (1-based) */
24522
- page?: number;
24523
- /** @description People per page (1-5000, default 20) */
24524
- take?: number;
24525
- /** @description Only people whose name or email contains this, ignoring case */
24526
- q?: string;
24527
- /** @description Only the people gaining access, or only those losing it */
24528
- direction?: "gains" | "loses";
24529
- /** @description Only the people gaining or losing this permission key (with `direction`, only that side) */
24530
- permission?: string;
24531
- };
24534
+ query?: never;
24532
24535
  header?: never;
24533
24536
  path: {
24534
24537
  id: string;
@@ -25273,6 +25276,276 @@ interface operations {
25273
25276
  };
25274
25277
  };
25275
25278
  };
25279
+ ApiAccessPreviewsController_listPeople: {
25280
+ parameters: {
25281
+ query?: {
25282
+ /** @description Page of people (1-based) */
25283
+ page?: number;
25284
+ /** @description People per page (1-5000, default 20) */
25285
+ take?: number;
25286
+ /** @description Only people whose name or email contains this, ignoring case */
25287
+ q?: string;
25288
+ /** @description Change previews: only the people gaining access, or only those losing it */
25289
+ direction?: "gains" | "loses";
25290
+ /** @description Change previews: only the people gaining or losing this permission key (with `direction`, only that side) */
25291
+ permission?: string;
25292
+ /** @description Delete previews: only the people holding this role in the subtree */
25293
+ role_id?: string;
25294
+ };
25295
+ header?: never;
25296
+ path: {
25297
+ previewId: string;
25298
+ };
25299
+ cookie?: never;
25300
+ };
25301
+ requestBody?: never;
25302
+ responses: {
25303
+ /** @description One page of the people the preview reaches */
25304
+ 200: {
25305
+ headers: {
25306
+ [name: string]: unknown;
25307
+ };
25308
+ content: {
25309
+ "application/json": {
25310
+ items: components["schemas"]["PreviewPersonDto"][];
25311
+ pagination: components["schemas"]["PageMetaDto"];
25312
+ };
25313
+ };
25314
+ };
25315
+ /** @description The preview id is not a UUID or the query failed validation (`direction` other than `gains` or `loses`, `take` above 5000, `role_id` not a UUID); or the request sent both an `X-API-Key` and an `Authorization` header */
25316
+ 400: {
25317
+ headers: {
25318
+ [name: string]: unknown;
25319
+ };
25320
+ content: {
25321
+ /**
25322
+ * @example {
25323
+ * "error": {
25324
+ * "statusCode": 400,
25325
+ * "code": null,
25326
+ * "message": "The preview id is not a UUID or the query failed validation (`direction` other than `gains` or `loses`, `take` above 5000, `role_id` not a UUID); or the request sent both an `X-API-Key` and an `Authorization` header",
25327
+ * "timestamp": "2026-04-20T12:00:00.000Z",
25328
+ * "path": "/api/v1/access-previews/{previewId}/people",
25329
+ * "method": "GET"
25330
+ * }
25331
+ * }
25332
+ */
25333
+ "application/json": components["schemas"]["ErrorResponseDto"];
25334
+ };
25335
+ };
25336
+ /** @description Invalid or expired token */
25337
+ 401: {
25338
+ headers: {
25339
+ [name: string]: unknown;
25340
+ };
25341
+ content: {
25342
+ /**
25343
+ * @example {
25344
+ * "error": {
25345
+ * "statusCode": 401,
25346
+ * "code": null,
25347
+ * "message": "Invalid or expired token",
25348
+ * "timestamp": "2026-04-20T12:00:00.000Z",
25349
+ * "path": "/api/v1/access-previews/{previewId}/people",
25350
+ * "method": "GET"
25351
+ * }
25352
+ * }
25353
+ */
25354
+ "application/json": components["schemas"]["ErrorResponseDto"];
25355
+ };
25356
+ };
25357
+ /** @description The bearer token is not an admin or platform token, or the caller lacks the permission this operation checks: a scoped API key without that scope, an admin without the Account capability that covers it, or, for a node-scoped check, a node outside this Environment */
25358
+ 403: {
25359
+ headers: {
25360
+ [name: string]: unknown;
25361
+ };
25362
+ content: {
25363
+ /**
25364
+ * @example {
25365
+ * "error": {
25366
+ * "statusCode": 403,
25367
+ * "code": null,
25368
+ * "message": "The bearer token is not an admin or platform token, or the caller lacks the permission this operation checks: a scoped API key without that scope, an admin without the Account capability that covers it, or, for a node-scoped check, a node outside this Environment",
25369
+ * "timestamp": "2026-04-20T12:00:00.000Z",
25370
+ * "path": "/api/v1/access-previews/{previewId}/people",
25371
+ * "method": "GET"
25372
+ * }
25373
+ * }
25374
+ */
25375
+ "application/json": components["schemas"]["ErrorResponseDto"];
25376
+ };
25377
+ };
25378
+ /** @description No stored preview with this id was made by this principal in this Environment, or it has expired (`access_preview.not_found`); the node, its destination, the organization or the role the preview read no longer exists; or a resource the path names does not exist. Preview the change again */
25379
+ 404: {
25380
+ headers: {
25381
+ [name: string]: unknown;
25382
+ };
25383
+ content: {
25384
+ /**
25385
+ * @example {
25386
+ * "error": {
25387
+ * "statusCode": 404,
25388
+ * "code": null,
25389
+ * "message": "No stored preview with this id was made by this principal in this Environment, or it has expired (`access_preview.not_found`); the node, its destination, the organization or the role the preview read no longer exists; or a resource the path names does not exist. Preview the change again",
25390
+ * "timestamp": "2026-04-20T12:00:00.000Z",
25391
+ * "path": "/api/v1/access-previews/{previewId}/people",
25392
+ * "method": "GET"
25393
+ * }
25394
+ * }
25395
+ */
25396
+ "application/json": components["schemas"]["ErrorResponseDto"];
25397
+ };
25398
+ };
25399
+ /** @description The node, its destination or the role has changed since the preview was made (`version_mismatch`); preview the change again */
25400
+ 409: {
25401
+ headers: {
25402
+ [name: string]: unknown;
25403
+ };
25404
+ content: {
25405
+ /**
25406
+ * @example {
25407
+ * "error": {
25408
+ * "statusCode": 409,
25409
+ * "code": null,
25410
+ * "message": "The node, its destination or the role has changed since the preview was made (`version_mismatch`); preview the change again",
25411
+ * "timestamp": "2026-04-20T12:00:00.000Z",
25412
+ * "path": "/api/v1/access-previews/{previewId}/people",
25413
+ * "method": "GET"
25414
+ * }
25415
+ * }
25416
+ */
25417
+ "application/json": components["schemas"]["ErrorResponseDto"];
25418
+ };
25419
+ };
25420
+ };
25421
+ };
25422
+ ApiAccessPreviewsController_exportPeople: {
25423
+ parameters: {
25424
+ query?: never;
25425
+ header?: never;
25426
+ path: {
25427
+ previewId: string;
25428
+ };
25429
+ cookie?: never;
25430
+ };
25431
+ requestBody?: never;
25432
+ responses: {
25433
+ /** @description The people as a CSV file */
25434
+ 200: {
25435
+ headers: {
25436
+ [name: string]: unknown;
25437
+ };
25438
+ content: {
25439
+ "text/csv": string;
25440
+ };
25441
+ };
25442
+ /** @description The preview id is not a UUID; or the request sent both an `X-API-Key` and an `Authorization` header */
25443
+ 400: {
25444
+ headers: {
25445
+ [name: string]: unknown;
25446
+ };
25447
+ content: {
25448
+ /**
25449
+ * @example {
25450
+ * "error": {
25451
+ * "statusCode": 400,
25452
+ * "code": null,
25453
+ * "message": "The preview id is not a UUID; or the request sent both an `X-API-Key` and an `Authorization` header",
25454
+ * "timestamp": "2026-04-20T12:00:00.000Z",
25455
+ * "path": "/api/v1/access-previews/{previewId}/people.csv",
25456
+ * "method": "GET"
25457
+ * }
25458
+ * }
25459
+ */
25460
+ "application/json": components["schemas"]["ErrorResponseDto"];
25461
+ };
25462
+ };
25463
+ /** @description Invalid or expired token */
25464
+ 401: {
25465
+ headers: {
25466
+ [name: string]: unknown;
25467
+ };
25468
+ content: {
25469
+ /**
25470
+ * @example {
25471
+ * "error": {
25472
+ * "statusCode": 401,
25473
+ * "code": null,
25474
+ * "message": "Invalid or expired token",
25475
+ * "timestamp": "2026-04-20T12:00:00.000Z",
25476
+ * "path": "/api/v1/access-previews/{previewId}/people",
25477
+ * "method": "GET"
25478
+ * }
25479
+ * }
25480
+ */
25481
+ "application/json": components["schemas"]["ErrorResponseDto"];
25482
+ };
25483
+ };
25484
+ /** @description The bearer token is not an admin or platform token, or the caller lacks the permission this operation checks: a scoped API key without that scope, an admin without the Account capability that covers it, or, for a node-scoped check, a node outside this Environment */
25485
+ 403: {
25486
+ headers: {
25487
+ [name: string]: unknown;
25488
+ };
25489
+ content: {
25490
+ /**
25491
+ * @example {
25492
+ * "error": {
25493
+ * "statusCode": 403,
25494
+ * "code": null,
25495
+ * "message": "The bearer token is not an admin or platform token, or the caller lacks the permission this operation checks: a scoped API key without that scope, an admin without the Account capability that covers it, or, for a node-scoped check, a node outside this Environment",
25496
+ * "timestamp": "2026-04-20T12:00:00.000Z",
25497
+ * "path": "/api/v1/access-previews/{previewId}/people",
25498
+ * "method": "GET"
25499
+ * }
25500
+ * }
25501
+ */
25502
+ "application/json": components["schemas"]["ErrorResponseDto"];
25503
+ };
25504
+ };
25505
+ /** @description No stored preview with this id was made by this principal in this Environment, or it has expired (`access_preview.not_found`); the node, its destination, the organization or the role the preview read no longer exists; or a resource the path names does not exist. Preview the change again */
25506
+ 404: {
25507
+ headers: {
25508
+ [name: string]: unknown;
25509
+ };
25510
+ content: {
25511
+ /**
25512
+ * @example {
25513
+ * "error": {
25514
+ * "statusCode": 404,
25515
+ * "code": null,
25516
+ * "message": "No stored preview with this id was made by this principal in this Environment, or it has expired (`access_preview.not_found`); the node, its destination, the organization or the role the preview read no longer exists; or a resource the path names does not exist. Preview the change again",
25517
+ * "timestamp": "2026-04-20T12:00:00.000Z",
25518
+ * "path": "/api/v1/access-previews/{previewId}/people.csv",
25519
+ * "method": "GET"
25520
+ * }
25521
+ * }
25522
+ */
25523
+ "application/json": components["schemas"]["ErrorResponseDto"];
25524
+ };
25525
+ };
25526
+ /** @description The node, its destination or the role has changed since the preview was made (`version_mismatch`); preview the change again */
25527
+ 409: {
25528
+ headers: {
25529
+ [name: string]: unknown;
25530
+ };
25531
+ content: {
25532
+ /**
25533
+ * @example {
25534
+ * "error": {
25535
+ * "statusCode": 409,
25536
+ * "code": null,
25537
+ * "message": "The node, its destination or the role has changed since the preview was made (`version_mismatch`); preview the change again",
25538
+ * "timestamp": "2026-04-20T12:00:00.000Z",
25539
+ * "path": "/api/v1/access-previews/{previewId}/people.csv",
25540
+ * "method": "GET"
25541
+ * }
25542
+ * }
25543
+ */
25544
+ "application/json": components["schemas"]["ErrorResponseDto"];
25545
+ };
25546
+ };
25547
+ };
25548
+ };
25276
25549
  ApiAssignmentsController_listAppWideAssignments: {
25277
25550
  parameters: {
25278
25551
  query?: {
@@ -30565,6 +30838,48 @@ declare class Canopy {
30565
30838
  constructor(options: CanopyClientOptions);
30566
30839
  }
30567
30840
 
30841
+ /**
30842
+ * Which of a {@link LocalAuthorizer}'s cached answers a change makes stale.
30843
+ *
30844
+ * A webhook delivery and a change-feed entry share one shape, `{ event, data }`,
30845
+ * so both are read here. The rule is the narrowest invalidation that is still
30846
+ * correct: a change that names whose access moved drops those subjects' grants
30847
+ * and nothing else; a change whose reach the event cannot name (a role's
30848
+ * permissions, the hierarchy, a deny on every holder of a role) drops
30849
+ * everything; a change that moves no one's access drops nothing.
30850
+ *
30851
+ * An event this SDK does not know drops everything. A newer Canopy can send
30852
+ * events an older SDK has never seen, and guessing that one is harmless would
30853
+ * be the unsafe direction: a cache cleared for nothing costs one read per
30854
+ * subject, a cache kept past a revocation costs a wrong allow.
30855
+ */
30856
+ /** A change as it arrives: a webhook delivery or a change-feed entry. */
30857
+ interface AuthorizationChange {
30858
+ event: string;
30859
+ data: {
30860
+ resource_type?: string | null;
30861
+ resource_id?: string | null;
30862
+ metadata?: Record<string, unknown> | null;
30863
+ };
30864
+ }
30865
+ /** A principal whose cached grants a change dropped. */
30866
+ interface InvalidatedSubject {
30867
+ principalType: PrincipalType;
30868
+ id: string;
30869
+ }
30870
+ /** What applying one change did to the cache. */
30871
+ type AppliedChange = {
30872
+ event: string;
30873
+ invalidated: "none";
30874
+ } | {
30875
+ event: string;
30876
+ invalidated: "subjects";
30877
+ subjects: InvalidatedSubject[];
30878
+ } | {
30879
+ event: string;
30880
+ invalidated: "all";
30881
+ };
30882
+
30568
30883
  /**
30569
30884
  * The longest a held answer may be kept: five minutes. `ttlMs` is the delay
30570
30885
  * between an access change and it taking effect, and Canopy promises that
@@ -30724,6 +31039,27 @@ interface LocalAuthorizerStats {
30724
31039
  /** Revalidations the server answered `304`, so no tree was transferred. */
30725
31040
  treeNotModified: number;
30726
31041
  }
31042
+ interface ReplayChangesOptions {
31043
+ /**
31044
+ * Where the last replay stopped: the `cursor` it returned. Omit it the
31045
+ * first time, and the replay starts at the oldest change Canopy still
31046
+ * retains.
31047
+ */
31048
+ cursor?: string | null;
31049
+ }
31050
+ interface ReplayChangesResult {
31051
+ /**
31052
+ * Where this replay stopped. Keep it, and pass it to the next replay;
31053
+ * `null` only when the feed has never held a change.
31054
+ */
31055
+ cursor: string | null;
31056
+ /** How many changes were read and applied. */
31057
+ changes: number;
31058
+ /** Whether any change dropped the whole cache. */
31059
+ invalidatedAll: boolean;
31060
+ /** How many subjects' grants were dropped one at a time. */
31061
+ subjectsInvalidated: number;
31062
+ }
30727
31063
  declare class LocalAuthorizer {
30728
31064
  private readonly client;
30729
31065
  private readonly ttlMs;
@@ -30744,6 +31080,13 @@ declare class LocalAuthorizer {
30744
31080
  */
30745
31081
  private readonly pendingGrants;
30746
31082
  private pendingTree;
31083
+ /**
31084
+ * Bumped by every full invalidation. A hierarchy read that began before
31085
+ * the bump answers the caller that was waiting on it but is not kept, so
31086
+ * a read already in flight when a change lands cannot cache what the
31087
+ * change replaced. Grants use the pending map for the same purpose.
31088
+ */
31089
+ private treeGeneration;
30747
31090
  private stats;
30748
31091
  constructor(client: CanopyClient, options?: LocalAuthorizerOptions);
30749
31092
  /**
@@ -30879,6 +31222,41 @@ declare class LocalAuthorizer {
30879
31222
  * top of it — size the TTL to the revocation latency you can promise.
30880
31223
  */
30881
31224
  invalidate(identityId?: string, subject?: SubjectOptions): void;
31225
+ /**
31226
+ * Drop what one change makes stale, from a webhook delivery or a
31227
+ * change-feed entry (the two share one shape). Answers what it dropped.
31228
+ *
31229
+ * A change naming whose access moved (an assignment, an Environment or
31230
+ * organization membership, an identity's status, a deny on one person,
31231
+ * a machine client disabled or deleted) drops those subjects' grants and
31232
+ * keeps everyone else's and the hierarchy warm. A change whose reach it
31233
+ * cannot name (a role, a permission, a node, the hierarchy schema, an
31234
+ * organization created or deleted, a deny on a role or a machine client,
31235
+ * a directory group mapped) drops everything. A change that moves no
31236
+ * one's access (a profile edit, a sign-in policy, a session revoked)
31237
+ * drops nothing. An event this SDK does not know drops everything.
31238
+ *
31239
+ * Check the delivery's signature first (`verifyWebhookSignature`): this
31240
+ * trusts what it is given. Like {@link invalidate}, it reaches this
31241
+ * process only; see there for what that means across several instances.
31242
+ */
31243
+ applyEvent(change: AuthorizationChange): AppliedChange;
31244
+ /**
31245
+ * Read `GET /api/v1/changes` from `cursor` to the newest change and apply
31246
+ * each one, as {@link applyEvent} would a webhook. Answers the cursor to
31247
+ * resume from next time.
31248
+ *
31249
+ * Two uses. After a restart, to catch up on deliveries a process missed
31250
+ * while it was down, before it serves from a cache warmed elsewhere. And
31251
+ * in place of webhooks: every instance polling on an interval shorter
31252
+ * than `ttlMs` sees every change, which a webhook (delivered to one
31253
+ * instance) does not give a fleet.
31254
+ *
31255
+ * The feed holds what the audit log retains, so a cursor older than that
31256
+ * resumes at the oldest change still held. Each page is one request; a
31257
+ * replay with no cursor walks the whole retained window once.
31258
+ */
31259
+ replayChanges(options?: ReplayChangesOptions): Promise<ReplayChangesResult>;
30882
31260
  /** Fire the decision hooks, after the verdict and without waiting on them. */
30883
31261
  private announce;
30884
31262
  /** The node and its ancestors, from the tree this client can read. */
@@ -31437,5 +31815,66 @@ type WebhookEventData<Name extends WebhookEventName> = WebhookEvent<Name>["data"
31437
31815
  * event's `metadata` without a cast.
31438
31816
  */
31439
31817
  declare function isWebhookEvent<Name extends WebhookEventName>(delivery: WebhookDelivery, name: Name): delivery is WebhookEvent<Name>;
31818
+ /** The headers a delivery carries, in any of the shapes a server hands them over. */
31819
+ type WebhookHeaders = Headers | Record<string, string | string[] | undefined>;
31820
+ interface VerifyWebhookSignatureInput {
31821
+ /** The request's headers: Node's `req.headers`, a Fetch `Headers`, or a plain record. */
31822
+ headers: WebhookHeaders;
31823
+ /**
31824
+ * The request body exactly as it arrived. Parsing and re-serializing the
31825
+ * JSON changes spacing or key order, and the signature no longer matches.
31826
+ */
31827
+ rawBody: string | Uint8Array;
31828
+ /**
31829
+ * The subscription's signing secret. Pass the old and the new while you
31830
+ * roll a rotated secret out: a delivery signed by either verifies.
31831
+ */
31832
+ secret: string | readonly string[];
31833
+ /**
31834
+ * How far `X-Canopy-Timestamp` may be from this machine's clock, in
31835
+ * seconds, before the delivery is refused as a replay. Default 300. Each
31836
+ * retry is signed again with its own timestamp, so a retried delivery is
31837
+ * never refused for its age.
31838
+ */
31839
+ toleranceSeconds?: number;
31840
+ /** The current time in milliseconds, for tests. Default `Date.now`. */
31841
+ now?: () => number;
31842
+ }
31843
+ /** The default replay window: five minutes either side of this machine's clock. */
31844
+ declare const WEBHOOK_TIMESTAMP_TOLERANCE_SECONDS = 300;
31845
+ /**
31846
+ * Whether a webhook delivery is Canopy's, unaltered and recent.
31847
+ *
31848
+ * Canopy signs `{X-Canopy-Webhook-Id}.{X-Canopy-Timestamp}.{raw body}` with
31849
+ * HMAC-SHA256 under the subscription's signing secret and sends it in
31850
+ * `X-Canopy-Signature` as `v1,<hex>`. For a while after a secret rotation
31851
+ * the header carries two values, the new secret's first; the delivery is
31852
+ * accepted when any value matches any secret given. The comparison is the
31853
+ * Web Crypto HMAC verify, which runs in constant time, so this works in
31854
+ * Node, Deno, Bun and edge workers alike.
31855
+ *
31856
+ * Resolves `false`, never rejects, for a missing header, a timestamp outside
31857
+ * the tolerance, or no match, so a handler refuses with one status:
31858
+ *
31859
+ * app.post(
31860
+ * "/webhooks/canopy",
31861
+ * express.raw({ type: "application/json" }),
31862
+ * async (req, res) => {
31863
+ * const valid = await verifyWebhookSignature({
31864
+ * headers: req.headers,
31865
+ * rawBody: req.body,
31866
+ * secret: process.env.CANOPY_WEBHOOK_SECRET,
31867
+ * });
31868
+ *
31869
+ * if (!valid) {
31870
+ * return res.sendStatus(401);
31871
+ * }
31872
+ *
31873
+ * const delivery = JSON.parse(req.body.toString()) as WebhookDelivery;
31874
+ * // …
31875
+ * },
31876
+ * );
31877
+ */
31878
+ declare function verifyWebhookSignature(input: VerifyWebhookSignatureInput): Promise<boolean>;
31440
31879
 
31441
- export { type AccessibleNodes, type AssignmentItem, Assignments, 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 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 RequestBody, type RequestOptions, type ResponseBody, type RoleItem, Roles, type Schema, type SubjectOptions, TokenVerifier, type TokenVerifierOptions, type VerifyCallOptions, type WebhookDelivery, type WebhookEvent, type WebhookEventData, type WebhookEventName, authorizationErrorStatus, type components, isCanopyAuthorizerError, isCanopyConnectionError, isCanopyError, isCanopyTokenError, isCursorPagination, isWebhookEvent, type operations, orgContext, paginate, type paths, tokenErrorStatus, withConcurrency };
31880
+ 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 };