@canopy-io/node 0.17.0 → 0.18.1

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,21 @@
1
1
  # @canopy-io/node
2
2
 
3
+ ## 0.18.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 9413c1c: `LocalAuthorizer.applyEvent` treats `identity.social_link.added` and `identity.social_link.removed` as changes that move no one's access. Before, they were unknown events and emptied the whole cache, which a social sign-up, linking an account every time, did on every delivery. The agent skill now covers social sign-in on both sign-in shapes, linked accounts on the Direct API, and the social refusals.
8
+
9
+ ## 0.18.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 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.
14
+
15
+ ### Patch Changes
16
+
17
+ - 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.
18
+
3
19
  ## 0.17.0
4
20
 
5
21
  ### 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;
@@ -1205,6 +1212,9 @@ var NO_ACCESS_CHANGE = /* @__PURE__ */ new Set([
1205
1212
  "organization.policy.updated",
1206
1213
  "organization.sso_connection.bound",
1207
1214
  "organization.sso_connection.unbound",
1215
+ // How an identity signs in, not what it may do.
1216
+ "identity.social_link.added",
1217
+ "identity.social_link.removed",
1208
1218
  // A pushed group grants nothing until it is mapped, which is its own event.
1209
1219
  "scim.group.created"
1210
1220
  ]);
@@ -2203,7 +2213,6 @@ function authorizationErrorStatus(error) {
2203
2213
  }
2204
2214
 
2205
2215
  // src/verify.ts
2206
- var HOSTED_ORIGIN = "https://auth.canopy-io.com";
2207
2216
  var DEFAULT_JWKS_CACHE_MAX_AGE_MS = 10 * 60 * 1e3;
2208
2217
  var DEFAULT_JWKS_MIN_REFETCH_INTERVAL_MS = 30 * 1e3;
2209
2218
  var DEFAULT_JWKS_TIMEOUT_MS = 5e3;
@@ -2226,7 +2235,7 @@ function resolveIssuer(options) {
2226
2235
  return withoutTrailingSlashes(issuer);
2227
2236
  }
2228
2237
  if (environmentId) {
2229
- return `${HOSTED_ORIGIN}/environments/${environmentId}`;
2238
+ return `${hostedOrigin()}/environments/${environmentId}`;
2230
2239
  }
2231
2240
  throw new TypeError(
2232
2241
  "TokenVerifier needs environmentId (the Environment your tokens come from) or, on a custom auth domain or self-hosted instance, issuer."