@canopy-io/node 0.19.0 → 0.21.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 +12 -0
- package/README.md +8 -0
- package/dist/index.cjs +12 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +23190 -9294
- package/dist/index.d.ts +23190 -9294
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -117,6 +117,7 @@ var CanopyClient = class {
|
|
|
117
117
|
maxBackoffMs;
|
|
118
118
|
authHeaders;
|
|
119
119
|
extraHeaders;
|
|
120
|
+
environmentId;
|
|
120
121
|
fetchImpl;
|
|
121
122
|
constructor(options = {}) {
|
|
122
123
|
if (!options.apiKey && !options.accessToken) {
|
|
@@ -129,6 +130,7 @@ var CanopyClient = class {
|
|
|
129
130
|
this.maxRetries = options.maxRetries ?? DEFAULT_MAX_RETRIES;
|
|
130
131
|
this.maxBackoffMs = options.maxBackoffMs ?? DEFAULT_MAX_BACKOFF_MS;
|
|
131
132
|
this.extraHeaders = options.headers ?? {};
|
|
133
|
+
this.environmentId = options.environmentId;
|
|
132
134
|
this.fetchImpl = options.fetch ?? globalThis.fetch;
|
|
133
135
|
if (typeof this.fetchImpl !== "function") {
|
|
134
136
|
throw new TypeError(
|
|
@@ -262,6 +264,10 @@ var CanopyClient = class {
|
|
|
262
264
|
if (options.body !== void 0) {
|
|
263
265
|
headers["Content-Type"] = "application/json";
|
|
264
266
|
}
|
|
267
|
+
const environmentId = options.environmentId === void 0 ? this.environmentId : options.environmentId;
|
|
268
|
+
if (environmentId) {
|
|
269
|
+
headers["X-Canopy-Environment"] = environmentId;
|
|
270
|
+
}
|
|
265
271
|
Object.assign(headers, options.headers, this.authHeaders);
|
|
266
272
|
const init = { method, headers, signal: controller.signal };
|
|
267
273
|
if (options.body !== void 0) {
|
|
@@ -2317,6 +2323,12 @@ var TokenVerifier = class {
|
|
|
2317
2323
|
*
|
|
2318
2324
|
* Order matters: the signature is checked before any claim is believed, so
|
|
2319
2325
|
* nothing downstream ever reads an unverified payload.
|
|
2326
|
+
*
|
|
2327
|
+
* `TCustom` names the Environment's custom claims, so they read typed off
|
|
2328
|
+
* the result: `verify<{ plan?: "free" | "pro" }>(token)`. It is a
|
|
2329
|
+
* declaration, not a check: a custom claim is absent when its value is not
|
|
2330
|
+
* stored, or when it did not fit (`custom_claims_overflow`), so keep each
|
|
2331
|
+
* one optional.
|
|
2320
2332
|
*/
|
|
2321
2333
|
async verify(token, options = {}) {
|
|
2322
2334
|
const parts = token.split(".");
|