@canopy-io/node 0.18.2 → 0.20.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,17 @@
1
1
  # @canopy-io/node
2
2
 
3
+ ## 0.20.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 1326269: `TokenVerifier.verify<TCustom>()` returns `CanopyTokenClaims & TCustom`, so an Environment's custom claims (a `plan` mapped from metadata, say) read typed off the verified token: `verify<{ plan?: "free" | "pro" }>(token)`. `custom_claims_overflow` is named on the claims: true when the mapped claims did not all fit, in which case a missing one is unknown rather than unset. The generated types cover `GET` and `PUT /api/v1/token-claims`, the Environment's mapping (`token_claims.view` / `token_claims.manage`).
8
+
9
+ ## 0.19.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 7acc0ca: OAuth client types now carry public clients: `client_type` (`confidential` or `public`) and `token_endpoint_auth_method` (`client_secret_basic` or `none`) on every client, `client_type` on create, and `client_secret` in the create response is `string | null`, null for a public client, which has none. Code that reads `client_secret` from a create response now has to handle null. Rotating a public client's secret answers `409 oauth.client_public_has_no_secret`.
14
+
3
15
  ## 0.18.2
4
16
 
5
17
  ### Patch Changes
package/README.md CHANGED
@@ -216,6 +216,14 @@ Tokens also carry `amr`, how the session was proven (`pwd`, `otp` or `sso`,
216
216
  plus `mfa` once a second factor was verified), so a backend can insist on
217
217
  `claims.amr?.includes("mfa")` before a sensitive action.
218
218
 
219
+ An Environment can map custom claims onto the token (a `plan` copied from the
220
+ identity's or organization's metadata). Name them to `verify` to read them
221
+ typed, each optional: `verifier.verify<{ plan?: "free" | "pro" }>(token)`. A
222
+ value that is not stored is left off the token, and so is one that did not fit
223
+ the token's size limit, which `claims.custom_claims_overflow` reports; treat an
224
+ absent claim as not set, and read the value from the API when the token says
225
+ it overflowed.
226
+
219
227
  The organizations themselves are wrapped on the client: provision a tenant,
220
228
  manage its members and invitations, tighten its sign-in policy, bind its
221
229
  identity provider, and set up its directory sync.
package/dist/index.cjs CHANGED
@@ -2319,6 +2319,12 @@ var TokenVerifier = class {
2319
2319
  *
2320
2320
  * Order matters: the signature is checked before any claim is believed, so
2321
2321
  * nothing downstream ever reads an unverified payload.
2322
+ *
2323
+ * `TCustom` names the Environment's custom claims, so they read typed off
2324
+ * the result: `verify<{ plan?: "free" | "pro" }>(token)`. It is a
2325
+ * declaration, not a check: a custom claim is absent when its value is not
2326
+ * stored, or when it did not fit (`custom_claims_overflow`), so keep each
2327
+ * one optional.
2322
2328
  */
2323
2329
  async verify(token, options = {}) {
2324
2330
  const parts = token.split(".");