@canopy-io/node 0.17.0 → 0.18.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 +10 -0
- package/README.md +5 -0
- package/dist/index.cjs +10 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +27 -5
- package/dist/index.d.ts +27 -5
- package/dist/index.js +10 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -67,7 +67,11 @@ interface CanopyClientOptions {
|
|
|
67
67
|
apiKey?: string;
|
|
68
68
|
/** Identity or portal JWT, sent as `Authorization: Bearer`. */
|
|
69
69
|
accessToken?: string;
|
|
70
|
-
/**
|
|
70
|
+
/**
|
|
71
|
+
* Defaults to Canopy's hosted API, or to `CANOPY_BASE_URL` when that
|
|
72
|
+
* environment variable is set. Set this, or the variable, for a self-hosted
|
|
73
|
+
* instance.
|
|
74
|
+
*/
|
|
71
75
|
baseUrl?: string;
|
|
72
76
|
/** Per-attempt deadline. Defaults to 30s; 0 disables. */
|
|
73
77
|
timeoutMs?: number;
|
|
@@ -669,7 +673,7 @@ interface paths {
|
|
|
669
673
|
get?: never;
|
|
670
674
|
put?: never;
|
|
671
675
|
/**
|
|
672
|
-
* Force-reset an identity's MFA
|
|
676
|
+
* Force-reset an identity's MFA, as an admin recovery action
|
|
673
677
|
* @description Force-resets an identity's MFA enrollment (server-to-server admin), clearing all enrolled factors across the Account so the identity must re-enroll on next sign-in. Gated by an Environment-scoped membership check and audited. Returns `204 No Content`; returns `404` when the identity has no membership in this Environment.
|
|
674
678
|
*/
|
|
675
679
|
post: operations["ApiIdentitiesController_resetIdentityMfa"];
|
|
@@ -5319,6 +5323,11 @@ interface components {
|
|
|
5319
5323
|
metadata: Record<string, unknown>;
|
|
5320
5324
|
/** Format: date-time */
|
|
5321
5325
|
created_at: string;
|
|
5326
|
+
/**
|
|
5327
|
+
* @description The channel the change came in through when it was not a direct call: `mcp` for a write an AI assistant made through the account MCP server, as the actor. NULL for a direct call.
|
|
5328
|
+
* @enum {string|null}
|
|
5329
|
+
*/
|
|
5330
|
+
channel?: "mcp" | null;
|
|
5322
5331
|
/** @description Snapshot label of the actor at write time (email for users / identities, label otherwise). NULL on rows written before the Slice 2 deploy. */
|
|
5323
5332
|
actor_label?: string | null;
|
|
5324
5333
|
/** @description Snapshot label of the affected resource at write time. NULL on rows written before the Slice 2 deploy. */
|
|
@@ -5405,6 +5414,11 @@ interface components {
|
|
|
5405
5414
|
severity?: "info" | "notice" | "warning" | "critical";
|
|
5406
5415
|
/** @enum {string} */
|
|
5407
5416
|
outcome?: "success" | "failure" | "denied";
|
|
5417
|
+
/**
|
|
5418
|
+
* @description Only rows written through this channel: `mcp` for changes an AI assistant made through the account MCP server.
|
|
5419
|
+
* @enum {string}
|
|
5420
|
+
*/
|
|
5421
|
+
channel?: "mcp";
|
|
5408
5422
|
/** Format: uuid */
|
|
5409
5423
|
actor_id?: string;
|
|
5410
5424
|
/** @description Free-form actor-type filter (e.g. `user`, `identity`). */
|
|
@@ -5447,6 +5461,11 @@ interface components {
|
|
|
5447
5461
|
metadata: Record<string, unknown>;
|
|
5448
5462
|
/** Format: date-time */
|
|
5449
5463
|
created_at: string;
|
|
5464
|
+
/**
|
|
5465
|
+
* @description The channel the change came in through when it was not a direct call: `mcp` for a write an AI assistant made through the account MCP server, as the actor. NULL for a direct call.
|
|
5466
|
+
* @enum {string|null}
|
|
5467
|
+
*/
|
|
5468
|
+
channel?: "mcp" | null;
|
|
5450
5469
|
/** @description Snapshot label of the actor at write time (email for users / identities, label otherwise). NULL on rows written before the Slice 2 deploy. */
|
|
5451
5470
|
actor_label?: string | null;
|
|
5452
5471
|
/** @description Snapshot label of the affected resource at write time. NULL on rows written before the Slice 2 deploy. */
|
|
@@ -5854,7 +5873,7 @@ interface components {
|
|
|
5854
5873
|
*/
|
|
5855
5874
|
access_mode: "scoped" | "full_access";
|
|
5856
5875
|
/** @description Permission scopes this key is authorized for, each one the platform offers (`GET .../api-keys/scopes`). Required and must be non-empty when `access_mode` is `scoped`. Must be omitted when `access_mode` is `full_access`. */
|
|
5857
|
-
scopes?: ("hierarchy.view" | "hierarchy.manage" | "rbac.view_roles" | "rbac.manage_roles" | "rbac.view_assignments" | "rbac.manage_assignments" | "permissions.evaluate" | "deny.view" | "deny.manage" | "identity.view" | "identity.manage" | "api_key.view" | "api_key.manage" | "webhook.view" | "webhook.manage" | "oauth_client.view" | "oauth_client.manage" | "branding.view" | "branding.manage")[];
|
|
5876
|
+
scopes?: ("hierarchy.view" | "hierarchy.manage" | "rbac.view_roles" | "rbac.manage_roles" | "rbac.view_assignments" | "rbac.manage_assignments" | "permissions.evaluate" | "deny.view" | "deny.manage" | "identity.view" | "identity.manage" | "api_key.view" | "api_key.manage" | "webhook.view" | "webhook.manage" | "oauth_client.view" | "oauth_client.manage" | "audit.view" | "branding.view" | "branding.manage")[];
|
|
5858
5877
|
/** @description Expiration date (ISO 8601). Omit for no expiration. */
|
|
5859
5878
|
expires_at?: string;
|
|
5860
5879
|
};
|
|
@@ -26538,6 +26557,8 @@ interface operations {
|
|
|
26538
26557
|
category?: "auth" | "identity" | "admin_user" | "tenancy" | "hierarchy" | "organization" | "rbac" | "authorization" | "api_keys" | "oauth" | "webhooks" | "invites" | "mfa" | "audit" | "billing" | "sso" | "unknown";
|
|
26539
26558
|
severity?: "info" | "notice" | "warning" | "critical";
|
|
26540
26559
|
outcome?: "success" | "failure" | "denied";
|
|
26560
|
+
/** @description Only rows written through this channel: `mcp` for changes an AI assistant made through the account MCP server. */
|
|
26561
|
+
channel?: "mcp";
|
|
26541
26562
|
actor_id?: string;
|
|
26542
26563
|
/** @description Free-form actor-type filter (e.g. `user`, `identity`). */
|
|
26543
26564
|
actor_type?: string;
|
|
@@ -31497,8 +31518,9 @@ interface TokenVerifierOptions {
|
|
|
31497
31518
|
/**
|
|
31498
31519
|
* The Environment whose tokens are accepted. Every Environment is its own
|
|
31499
31520
|
* issuer with its own signing keys, at
|
|
31500
|
-
* `https://auth.canopy-io.com/environments/<id
|
|
31501
|
-
*
|
|
31521
|
+
* `https://auth.canopy-io.com/environments/<id>` (or under `CANOPY_BASE_URL`
|
|
31522
|
+
* when that environment variable is set), so on hosted Canopy this is all
|
|
31523
|
+
* verification needs. A token from any other Environment fails.
|
|
31502
31524
|
*
|
|
31503
31525
|
* Set exactly one of `environmentId` and `issuer`; the constructor throws
|
|
31504
31526
|
* with neither or both.
|
package/dist/index.d.ts
CHANGED
|
@@ -67,7 +67,11 @@ interface CanopyClientOptions {
|
|
|
67
67
|
apiKey?: string;
|
|
68
68
|
/** Identity or portal JWT, sent as `Authorization: Bearer`. */
|
|
69
69
|
accessToken?: string;
|
|
70
|
-
/**
|
|
70
|
+
/**
|
|
71
|
+
* Defaults to Canopy's hosted API, or to `CANOPY_BASE_URL` when that
|
|
72
|
+
* environment variable is set. Set this, or the variable, for a self-hosted
|
|
73
|
+
* instance.
|
|
74
|
+
*/
|
|
71
75
|
baseUrl?: string;
|
|
72
76
|
/** Per-attempt deadline. Defaults to 30s; 0 disables. */
|
|
73
77
|
timeoutMs?: number;
|
|
@@ -669,7 +673,7 @@ interface paths {
|
|
|
669
673
|
get?: never;
|
|
670
674
|
put?: never;
|
|
671
675
|
/**
|
|
672
|
-
* Force-reset an identity's MFA
|
|
676
|
+
* Force-reset an identity's MFA, as an admin recovery action
|
|
673
677
|
* @description Force-resets an identity's MFA enrollment (server-to-server admin), clearing all enrolled factors across the Account so the identity must re-enroll on next sign-in. Gated by an Environment-scoped membership check and audited. Returns `204 No Content`; returns `404` when the identity has no membership in this Environment.
|
|
674
678
|
*/
|
|
675
679
|
post: operations["ApiIdentitiesController_resetIdentityMfa"];
|
|
@@ -5319,6 +5323,11 @@ interface components {
|
|
|
5319
5323
|
metadata: Record<string, unknown>;
|
|
5320
5324
|
/** Format: date-time */
|
|
5321
5325
|
created_at: string;
|
|
5326
|
+
/**
|
|
5327
|
+
* @description The channel the change came in through when it was not a direct call: `mcp` for a write an AI assistant made through the account MCP server, as the actor. NULL for a direct call.
|
|
5328
|
+
* @enum {string|null}
|
|
5329
|
+
*/
|
|
5330
|
+
channel?: "mcp" | null;
|
|
5322
5331
|
/** @description Snapshot label of the actor at write time (email for users / identities, label otherwise). NULL on rows written before the Slice 2 deploy. */
|
|
5323
5332
|
actor_label?: string | null;
|
|
5324
5333
|
/** @description Snapshot label of the affected resource at write time. NULL on rows written before the Slice 2 deploy. */
|
|
@@ -5405,6 +5414,11 @@ interface components {
|
|
|
5405
5414
|
severity?: "info" | "notice" | "warning" | "critical";
|
|
5406
5415
|
/** @enum {string} */
|
|
5407
5416
|
outcome?: "success" | "failure" | "denied";
|
|
5417
|
+
/**
|
|
5418
|
+
* @description Only rows written through this channel: `mcp` for changes an AI assistant made through the account MCP server.
|
|
5419
|
+
* @enum {string}
|
|
5420
|
+
*/
|
|
5421
|
+
channel?: "mcp";
|
|
5408
5422
|
/** Format: uuid */
|
|
5409
5423
|
actor_id?: string;
|
|
5410
5424
|
/** @description Free-form actor-type filter (e.g. `user`, `identity`). */
|
|
@@ -5447,6 +5461,11 @@ interface components {
|
|
|
5447
5461
|
metadata: Record<string, unknown>;
|
|
5448
5462
|
/** Format: date-time */
|
|
5449
5463
|
created_at: string;
|
|
5464
|
+
/**
|
|
5465
|
+
* @description The channel the change came in through when it was not a direct call: `mcp` for a write an AI assistant made through the account MCP server, as the actor. NULL for a direct call.
|
|
5466
|
+
* @enum {string|null}
|
|
5467
|
+
*/
|
|
5468
|
+
channel?: "mcp" | null;
|
|
5450
5469
|
/** @description Snapshot label of the actor at write time (email for users / identities, label otherwise). NULL on rows written before the Slice 2 deploy. */
|
|
5451
5470
|
actor_label?: string | null;
|
|
5452
5471
|
/** @description Snapshot label of the affected resource at write time. NULL on rows written before the Slice 2 deploy. */
|
|
@@ -5854,7 +5873,7 @@ interface components {
|
|
|
5854
5873
|
*/
|
|
5855
5874
|
access_mode: "scoped" | "full_access";
|
|
5856
5875
|
/** @description Permission scopes this key is authorized for, each one the platform offers (`GET .../api-keys/scopes`). Required and must be non-empty when `access_mode` is `scoped`. Must be omitted when `access_mode` is `full_access`. */
|
|
5857
|
-
scopes?: ("hierarchy.view" | "hierarchy.manage" | "rbac.view_roles" | "rbac.manage_roles" | "rbac.view_assignments" | "rbac.manage_assignments" | "permissions.evaluate" | "deny.view" | "deny.manage" | "identity.view" | "identity.manage" | "api_key.view" | "api_key.manage" | "webhook.view" | "webhook.manage" | "oauth_client.view" | "oauth_client.manage" | "branding.view" | "branding.manage")[];
|
|
5876
|
+
scopes?: ("hierarchy.view" | "hierarchy.manage" | "rbac.view_roles" | "rbac.manage_roles" | "rbac.view_assignments" | "rbac.manage_assignments" | "permissions.evaluate" | "deny.view" | "deny.manage" | "identity.view" | "identity.manage" | "api_key.view" | "api_key.manage" | "webhook.view" | "webhook.manage" | "oauth_client.view" | "oauth_client.manage" | "audit.view" | "branding.view" | "branding.manage")[];
|
|
5858
5877
|
/** @description Expiration date (ISO 8601). Omit for no expiration. */
|
|
5859
5878
|
expires_at?: string;
|
|
5860
5879
|
};
|
|
@@ -26538,6 +26557,8 @@ interface operations {
|
|
|
26538
26557
|
category?: "auth" | "identity" | "admin_user" | "tenancy" | "hierarchy" | "organization" | "rbac" | "authorization" | "api_keys" | "oauth" | "webhooks" | "invites" | "mfa" | "audit" | "billing" | "sso" | "unknown";
|
|
26539
26558
|
severity?: "info" | "notice" | "warning" | "critical";
|
|
26540
26559
|
outcome?: "success" | "failure" | "denied";
|
|
26560
|
+
/** @description Only rows written through this channel: `mcp` for changes an AI assistant made through the account MCP server. */
|
|
26561
|
+
channel?: "mcp";
|
|
26541
26562
|
actor_id?: string;
|
|
26542
26563
|
/** @description Free-form actor-type filter (e.g. `user`, `identity`). */
|
|
26543
26564
|
actor_type?: string;
|
|
@@ -31497,8 +31518,9 @@ interface TokenVerifierOptions {
|
|
|
31497
31518
|
/**
|
|
31498
31519
|
* The Environment whose tokens are accepted. Every Environment is its own
|
|
31499
31520
|
* issuer with its own signing keys, at
|
|
31500
|
-
* `https://auth.canopy-io.com/environments/<id
|
|
31501
|
-
*
|
|
31521
|
+
* `https://auth.canopy-io.com/environments/<id>` (or under `CANOPY_BASE_URL`
|
|
31522
|
+
* when that environment variable is set), so on hosted Canopy this is all
|
|
31523
|
+
* verification needs. A token from any other Environment fails.
|
|
31502
31524
|
*
|
|
31503
31525
|
* Set exactly one of `environmentId` and `issuer`; the constructor throws
|
|
31504
31526
|
* with neither or both.
|
package/dist/index.js
CHANGED
|
@@ -93,11 +93,18 @@ function withoutTrailingSlashes(value) {
|
|
|
93
93
|
return value.slice(0, end);
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
+
// src/origin.ts
|
|
97
|
+
var HOSTED_ORIGIN = "https://auth.canopy-io.com";
|
|
98
|
+
function hostedOrigin() {
|
|
99
|
+
const env = globalThis.process?.env;
|
|
100
|
+
const configured = env?.["CANOPY_BASE_URL"]?.trim();
|
|
101
|
+
return withoutTrailingSlashes(configured || HOSTED_ORIGIN);
|
|
102
|
+
}
|
|
103
|
+
|
|
96
104
|
// src/client.ts
|
|
97
105
|
function isCursorPagination(pagination) {
|
|
98
106
|
return "next_cursor" in pagination;
|
|
99
107
|
}
|
|
100
|
-
var DEFAULT_BASE_URL = "https://auth.canopy-io.com";
|
|
101
108
|
var DEFAULT_TIMEOUT_MS = 3e4;
|
|
102
109
|
var DEFAULT_MAX_RETRIES = 2;
|
|
103
110
|
var DEFAULT_MAX_BACKOFF_MS = 3e4;
|
|
@@ -117,7 +124,7 @@ var CanopyClient = class {
|
|
|
117
124
|
"CanopyClient requires either `apiKey` (server-to-server) or `accessToken` (a user or identity JWT)."
|
|
118
125
|
);
|
|
119
126
|
}
|
|
120
|
-
this.baseUrl = withoutTrailingSlashes(options.baseUrl ??
|
|
127
|
+
this.baseUrl = withoutTrailingSlashes(options.baseUrl ?? hostedOrigin());
|
|
121
128
|
this.timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
122
129
|
this.maxRetries = options.maxRetries ?? DEFAULT_MAX_RETRIES;
|
|
123
130
|
this.maxBackoffMs = options.maxBackoffMs ?? DEFAULT_MAX_BACKOFF_MS;
|
|
@@ -2201,7 +2208,6 @@ function authorizationErrorStatus(error) {
|
|
|
2201
2208
|
}
|
|
2202
2209
|
|
|
2203
2210
|
// src/verify.ts
|
|
2204
|
-
var HOSTED_ORIGIN = "https://auth.canopy-io.com";
|
|
2205
2211
|
var DEFAULT_JWKS_CACHE_MAX_AGE_MS = 10 * 60 * 1e3;
|
|
2206
2212
|
var DEFAULT_JWKS_MIN_REFETCH_INTERVAL_MS = 30 * 1e3;
|
|
2207
2213
|
var DEFAULT_JWKS_TIMEOUT_MS = 5e3;
|
|
@@ -2224,7 +2230,7 @@ function resolveIssuer(options) {
|
|
|
2224
2230
|
return withoutTrailingSlashes(issuer);
|
|
2225
2231
|
}
|
|
2226
2232
|
if (environmentId) {
|
|
2227
|
-
return `${
|
|
2233
|
+
return `${hostedOrigin()}/environments/${environmentId}`;
|
|
2228
2234
|
}
|
|
2229
2235
|
throw new TypeError(
|
|
2230
2236
|
"TokenVerifier needs environmentId (the Environment your tokens come from) or, on a custom auth domain or self-hosted instance, issuer."
|