@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 CHANGED
@@ -1,5 +1,15 @@
1
1
  # @canopy-io/node
2
2
 
3
+ ## 0.18.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 4a092d0: `CANOPY_BASE_URL` sets the Canopy origin for the whole process: `Canopy` and `CanopyClient` call it instead of the hosted API, and `TokenVerifier` resolves `environmentId` to an issuer under it. A self-hosted instance, a proxy or a test stack sets the one variable and keeps the code it would write for hosted Canopy. An explicit `baseUrl` or `issuer` still wins. Read through `globalThis`, so browsers, Workers and Deno are unaffected.
8
+
9
+ ### Patch Changes
10
+
11
+ - 056f64d: Generated types follow the API as Canopy now publishes it: an audit event carries `channel` (`"mcp"` for a change an AI assistant made through the account MCP server, `null` for a direct call), the audit event list takes a `channel` filter, and the API key scope list matches the current catalogue.
12
+
3
13
  ## 0.17.0
4
14
 
5
15
  ### Minor Changes
package/README.md CHANGED
@@ -169,6 +169,11 @@ On a custom auth domain or a self-hosted instance, set `issuer` instead
169
169
  throws with neither. Getting it wrong fails closed: tokens are rejected, never
170
170
  mistakenly accepted.
171
171
 
172
+ A self-hosted instance can instead set `CANOPY_BASE_URL` once for the process:
173
+ the client calls it and `environmentId` resolves to an issuer under it, so the
174
+ code stays what it is on hosted Canopy. An explicit `baseUrl` or `issuer` still
175
+ wins.
176
+
172
177
  With an Environment's **organizations** container on, an identity token also
173
178
  names the organization the session is acting in and the roles held at that
174
179
  organization's node, by name and by id. Read them through `orgContext` rather
package/dist/index.cjs CHANGED
@@ -95,11 +95,18 @@ function withoutTrailingSlashes(value) {
95
95
  return value.slice(0, end);
96
96
  }
97
97
 
98
+ // src/origin.ts
99
+ var HOSTED_ORIGIN = "https://auth.canopy-io.com";
100
+ function hostedOrigin() {
101
+ const env = globalThis.process?.env;
102
+ const configured = env?.["CANOPY_BASE_URL"]?.trim();
103
+ return withoutTrailingSlashes(configured || HOSTED_ORIGIN);
104
+ }
105
+
98
106
  // src/client.ts
99
107
  function isCursorPagination(pagination) {
100
108
  return "next_cursor" in pagination;
101
109
  }
102
- var DEFAULT_BASE_URL = "https://auth.canopy-io.com";
103
110
  var DEFAULT_TIMEOUT_MS = 3e4;
104
111
  var DEFAULT_MAX_RETRIES = 2;
105
112
  var DEFAULT_MAX_BACKOFF_MS = 3e4;
@@ -119,7 +126,7 @@ var CanopyClient = class {
119
126
  "CanopyClient requires either `apiKey` (server-to-server) or `accessToken` (a user or identity JWT)."
120
127
  );
121
128
  }
122
- this.baseUrl = withoutTrailingSlashes(options.baseUrl ?? DEFAULT_BASE_URL);
129
+ this.baseUrl = withoutTrailingSlashes(options.baseUrl ?? hostedOrigin());
123
130
  this.timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
124
131
  this.maxRetries = options.maxRetries ?? DEFAULT_MAX_RETRIES;
125
132
  this.maxBackoffMs = options.maxBackoffMs ?? DEFAULT_MAX_BACKOFF_MS;
@@ -2203,7 +2210,6 @@ function authorizationErrorStatus(error) {
2203
2210
  }
2204
2211
 
2205
2212
  // src/verify.ts
2206
- var HOSTED_ORIGIN = "https://auth.canopy-io.com";
2207
2213
  var DEFAULT_JWKS_CACHE_MAX_AGE_MS = 10 * 60 * 1e3;
2208
2214
  var DEFAULT_JWKS_MIN_REFETCH_INTERVAL_MS = 30 * 1e3;
2209
2215
  var DEFAULT_JWKS_TIMEOUT_MS = 5e3;
@@ -2226,7 +2232,7 @@ function resolveIssuer(options) {
2226
2232
  return withoutTrailingSlashes(issuer);
2227
2233
  }
2228
2234
  if (environmentId) {
2229
- return `${HOSTED_ORIGIN}/environments/${environmentId}`;
2235
+ return `${hostedOrigin()}/environments/${environmentId}`;
2230
2236
  }
2231
2237
  throw new TypeError(
2232
2238
  "TokenVerifier needs environmentId (the Environment your tokens come from) or, on a custom auth domain or self-hosted instance, issuer."