@vercel/flags-core 1.10.2 → 1.10.3
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 +6 -0
- package/dist/{chunk-LGS6CVED.js → chunk-2P2UTT7O.js} +42 -21
- package/dist/chunk-2P2UTT7O.js.map +1 -0
- package/dist/{chunk-POAWPAE3.cjs → chunk-BEQ3MX7Z.cjs} +53 -32
- package/dist/chunk-BEQ3MX7Z.cjs.map +1 -0
- package/dist/{chunk-WVS63L4A.cjs → chunk-EGGUENXP.cjs} +54 -33
- package/dist/chunk-EGGUENXP.cjs.map +1 -0
- package/dist/{chunk-7A7RG7ST.js → chunk-OIOT7N7A.js} +42 -21
- package/dist/chunk-OIOT7N7A.js.map +1 -0
- package/dist/index.default.cjs +2 -2
- package/dist/index.default.d.cts +3 -2
- package/dist/index.default.d.ts +3 -2
- package/dist/index.default.js +1 -1
- package/dist/index.next-js.cjs +2 -2
- package/dist/index.next-js.d.cts +3 -2
- package/dist/index.next-js.d.ts +3 -2
- package/dist/index.next-js.js +1 -1
- package/dist/openfeature.default.cjs +2 -2
- package/dist/openfeature.default.js +1 -1
- package/dist/openfeature.next-js.cjs +2 -2
- package/dist/openfeature.next-js.js +1 -1
- package/package.json +3 -3
- package/dist/chunk-7A7RG7ST.js.map +0 -1
- package/dist/chunk-LGS6CVED.js.map +0 -1
- package/dist/chunk-POAWPAE3.cjs.map +0 -1
- package/dist/chunk-WVS63L4A.cjs.map +0 -1
|
@@ -559,7 +559,7 @@ function bulkEvaluate(flags, shared) {
|
|
|
559
559
|
}
|
|
560
560
|
|
|
561
561
|
// package.json
|
|
562
|
-
var version = "1.10.
|
|
562
|
+
var version = "1.10.3";
|
|
563
563
|
|
|
564
564
|
// src/lib/report-value.ts
|
|
565
565
|
function internalReportValue(key, value, data) {
|
|
@@ -1089,17 +1089,26 @@ function unauthorizedMessage(sourceProjectId) {
|
|
|
1089
1089
|
}
|
|
1090
1090
|
return `unauthorized (401): this deployment is not allowed to read the flags of project "${sourceProjectId}". Check that the project is connected. See https://vercel.com/docs/flags/vercel-flags/project-connections`;
|
|
1091
1091
|
}
|
|
1092
|
+
var oidcTokenMessage = [
|
|
1093
|
+
"@vercel/flags-core: Failed to get OIDC token.",
|
|
1094
|
+
"Are you running in a Vercel Environment where OIDC tokens are available?",
|
|
1095
|
+
"Did you mean to use an SDK Key instead? Use the environment variable FLAGS or pass it directly to the client."
|
|
1096
|
+
].join(" ");
|
|
1097
|
+
var missingCredentials = /`vc link|vercel login|^The 'x-vercel-oidc-token' header is missing from the request\.$/;
|
|
1098
|
+
var OidcTokenError = class extends Error {
|
|
1099
|
+
constructor(cause) {
|
|
1100
|
+
super(oidcTokenMessage, { cause });
|
|
1101
|
+
this.name = "OidcTokenError";
|
|
1102
|
+
}
|
|
1103
|
+
};
|
|
1092
1104
|
async function getOidcToken() {
|
|
1093
1105
|
try {
|
|
1094
1106
|
return await _oidc.getVercelOidcToken.call(void 0, );
|
|
1095
|
-
} catch (
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
"Did you mean to use an SDK Key instead? Use the environment variable FLAGS or pass it directly to the client."
|
|
1101
|
-
].join(" ")
|
|
1102
|
-
);
|
|
1107
|
+
} catch (error) {
|
|
1108
|
+
if (error instanceof Error && missingCredentials.test(error.message)) {
|
|
1109
|
+
throw new OidcTokenError(error);
|
|
1110
|
+
}
|
|
1111
|
+
throw new Error(oidcTokenMessage, { cause: error });
|
|
1103
1112
|
}
|
|
1104
1113
|
}
|
|
1105
1114
|
function getProjectIdFromOidcToken(oidcToken) {
|
|
@@ -1229,7 +1238,7 @@ function getRuntimeIngest() {
|
|
|
1229
1238
|
try {
|
|
1230
1239
|
const context = globalThis[FLAGS_CONTEXT_SYMBOL];
|
|
1231
1240
|
return typeof _optionalChain([context, 'optionalAccess', _34 => _34.ingest]) === "function" ? context.ingest : void 0;
|
|
1232
|
-
} catch (
|
|
1241
|
+
} catch (e7) {
|
|
1233
1242
|
return void 0;
|
|
1234
1243
|
}
|
|
1235
1244
|
}
|
|
@@ -1247,7 +1256,7 @@ async function getEvaluatingOidcToken(auth) {
|
|
|
1247
1256
|
if (!auth.sdkKey) return void 0;
|
|
1248
1257
|
try {
|
|
1249
1258
|
return await _oidc.getVercelOidcToken.call(void 0, );
|
|
1250
|
-
} catch (
|
|
1259
|
+
} catch (e8) {
|
|
1251
1260
|
return void 0;
|
|
1252
1261
|
}
|
|
1253
1262
|
}
|
|
@@ -1359,7 +1368,7 @@ var Scheduler = (_class = class {
|
|
|
1359
1368
|
})();
|
|
1360
1369
|
try {
|
|
1361
1370
|
this.scheduleTask(this.pending);
|
|
1362
|
-
} catch (
|
|
1371
|
+
} catch (e9) {
|
|
1363
1372
|
}
|
|
1364
1373
|
this.maxTimeout = setTimeout(
|
|
1365
1374
|
() => this.resolveScheduledFlush("max_timeout"),
|
|
@@ -1586,7 +1595,7 @@ var UsageTracker = (_class4 = class {
|
|
|
1586
1595
|
void flush.finally(() => this.inflightFlushes.delete(flush));
|
|
1587
1596
|
try {
|
|
1588
1597
|
_optionalChain([this, 'access', _37 => _37.waitUntil, 'optionalCall', _38 => _38(flush)]);
|
|
1589
|
-
} catch (
|
|
1598
|
+
} catch (e10) {
|
|
1590
1599
|
}
|
|
1591
1600
|
} else {
|
|
1592
1601
|
this.scheduler.scheduleFlush();
|
|
@@ -1691,7 +1700,7 @@ function debug(clientName, event, details) {
|
|
|
1691
1700
|
}
|
|
1692
1701
|
try {
|
|
1693
1702
|
console.debug("@vercel/flags-core", { event, clientName, ..._optionalChain([details, 'optionalCall', _40 => _40()]) });
|
|
1694
|
-
} catch (
|
|
1703
|
+
} catch (e11) {
|
|
1695
1704
|
}
|
|
1696
1705
|
}
|
|
1697
1706
|
|
|
@@ -2030,7 +2039,7 @@ var DatafileCache = (_class5 = class {
|
|
|
2030
2039
|
});
|
|
2031
2040
|
try {
|
|
2032
2041
|
this.waitUntil(background);
|
|
2033
|
-
} catch (
|
|
2042
|
+
} catch (e12) {
|
|
2034
2043
|
}
|
|
2035
2044
|
}
|
|
2036
2045
|
/** Resets storage, age, and the failure deadline so a restarted client begins clean. */
|
|
@@ -2143,7 +2152,8 @@ async function fetchDatafile(options) {
|
|
|
2143
2152
|
return await Promise.race([fetchAttempt(attempt + 1), aborted]);
|
|
2144
2153
|
} catch (error) {
|
|
2145
2154
|
signal.throwIfAborted();
|
|
2146
|
-
if (attempt === maxAttempts - 1 || error instanceof DatafileHttpError && !error.retryable
|
|
2155
|
+
if (attempt === maxAttempts - 1 || error instanceof DatafileHttpError && !error.retryable || // Retrying will not produce a token that is not there.
|
|
2156
|
+
error instanceof OidcTokenError) {
|
|
2147
2157
|
throw error instanceof Error ? error : new Error("Unknown fetch error");
|
|
2148
2158
|
}
|
|
2149
2159
|
debug(options.clientName, "datafile.fetch.retry", () => ({
|
|
@@ -2561,7 +2571,7 @@ async function connectStream(config, callbacks) {
|
|
|
2561
2571
|
rejectInit(error);
|
|
2562
2572
|
}
|
|
2563
2573
|
_optionalChain([onDisconnect, 'optionalCall', _97 => _97()]);
|
|
2564
|
-
abortController.abort();
|
|
2574
|
+
abortController.abort(error);
|
|
2565
2575
|
break;
|
|
2566
2576
|
}
|
|
2567
2577
|
if (!response.ok) {
|
|
@@ -2597,7 +2607,7 @@ async function connectStream(config, callbacks) {
|
|
|
2597
2607
|
let message;
|
|
2598
2608
|
try {
|
|
2599
2609
|
message = JSON.parse(line);
|
|
2600
|
-
} catch (
|
|
2610
|
+
} catch (e13) {
|
|
2601
2611
|
console.warn(
|
|
2602
2612
|
"@vercel/flags-core: Failed to parse stream message, skipping"
|
|
2603
2613
|
);
|
|
@@ -2663,7 +2673,7 @@ async function connectStream(config, callbacks) {
|
|
|
2663
2673
|
}
|
|
2664
2674
|
if (error instanceof TokenResolutionError && !initialDataReceived) {
|
|
2665
2675
|
rejectInit(error.cause);
|
|
2666
|
-
abortController.abort();
|
|
2676
|
+
abortController.abort(error.cause);
|
|
2667
2677
|
break;
|
|
2668
2678
|
}
|
|
2669
2679
|
if (connectionAbort.signal.reason !== PING_TIMEOUT) {
|
|
@@ -2737,7 +2747,7 @@ var StreamSource = (_class9 = class extends TypedEmitter {
|
|
|
2737
2747
|
if (this.abortController === abortController) {
|
|
2738
2748
|
this.promise = void 0;
|
|
2739
2749
|
this.abortController = void 0;
|
|
2740
|
-
this.emit("exhausted");
|
|
2750
|
+
this.emit("exhausted", abortController.signal.reason);
|
|
2741
2751
|
}
|
|
2742
2752
|
},
|
|
2743
2753
|
{ once: true }
|
|
@@ -2798,7 +2808,7 @@ var UNKNOWN_FRESHNESS = {
|
|
|
2798
2808
|
assess: () => ({ status: "unknown" })
|
|
2799
2809
|
};
|
|
2800
2810
|
function isUnauthorizedError(error) {
|
|
2801
|
-
if (error instanceof UnauthorizedError) {
|
|
2811
|
+
if (error instanceof UnauthorizedError || error instanceof OidcTokenError) {
|
|
2802
2812
|
return true;
|
|
2803
2813
|
}
|
|
2804
2814
|
if (!(error instanceof Error)) {
|
|
@@ -2833,8 +2843,9 @@ var Controller = (_class10 = class {
|
|
|
2833
2843
|
// Build-step deduplication
|
|
2834
2844
|
__init23() {this.buildDataPromise = null}
|
|
2835
2845
|
__init24() {this.buildReadTracked = false}
|
|
2836
|
-
// Suppresses usage tracking while the credential is rejected
|
|
2837
|
-
//
|
|
2846
|
+
// Suppresses usage tracking while the credential is rejected or no OIDC
|
|
2847
|
+
// token is available. Set on an auth failure from any source, cleared as
|
|
2848
|
+
// soon as a source delivers data again.
|
|
2838
2849
|
__init25() {this.unauthorized = false}
|
|
2839
2850
|
constructor(options) {;_class10.prototype.__init18.call(this);_class10.prototype.__init19.call(this);_class10.prototype.__init20.call(this);_class10.prototype.__init21.call(this);_class10.prototype.__init22.call(this);_class10.prototype.__init23.call(this);_class10.prototype.__init24.call(this);_class10.prototype.__init25.call(this);_class10.prototype.__init26.call(this);_class10.prototype.__init27.call(this);_class10.prototype.__init28.call(this);_class10.prototype.__init29.call(this);_class10.prototype.__init30.call(this);_class10.prototype.__init31.call(this);_class10.prototype.__init32.call(this);_class10.prototype.__init33.call(this);_class10.prototype.__init34.call(this);
|
|
2840
2851
|
this.options = normalizeOptions(options);
|
|
@@ -2930,10 +2941,16 @@ var Controller = (_class10 = class {
|
|
|
2930
2941
|
this.transition("degraded", "stream-disconnected");
|
|
2931
2942
|
}
|
|
2932
2943
|
}}
|
|
2933
|
-
__init31() {this.onStreamExhausted = () => {
|
|
2944
|
+
__init31() {this.onStreamExhausted = (reason) => {
|
|
2934
2945
|
if (this.state !== "streaming" && this.state !== "degraded") {
|
|
2935
2946
|
return;
|
|
2936
2947
|
}
|
|
2948
|
+
if (isUnauthorizedError(reason)) {
|
|
2949
|
+
if (this.state === "streaming") {
|
|
2950
|
+
this.transition("degraded", "stream-auth-failed");
|
|
2951
|
+
}
|
|
2952
|
+
return;
|
|
2953
|
+
}
|
|
2937
2954
|
void this.activateFallbackSource().catch(() => {
|
|
2938
2955
|
});
|
|
2939
2956
|
}}
|
|
@@ -2945,7 +2962,7 @@ var Controller = (_class10 = class {
|
|
|
2945
2962
|
this.onSourceError(error);
|
|
2946
2963
|
if (this.state === "polling" && isUnauthorizedError(error)) {
|
|
2947
2964
|
this.pollingSource.stop();
|
|
2948
|
-
this.transition("degraded", "polling-
|
|
2965
|
+
this.transition("degraded", "polling-auth-failed");
|
|
2949
2966
|
}
|
|
2950
2967
|
}}
|
|
2951
2968
|
// ---------------------------------------------------------------------------
|
|
@@ -3074,7 +3091,7 @@ var Controller = (_class10 = class {
|
|
|
3074
3091
|
try {
|
|
3075
3092
|
const bundled = await this.bundledSource.tryLoad();
|
|
3076
3093
|
if (bundled) this.cache.seed(tagData({ ...bundled }, "bundled"));
|
|
3077
|
-
} catch (
|
|
3094
|
+
} catch (e14) {
|
|
3078
3095
|
}
|
|
3079
3096
|
}
|
|
3080
3097
|
if (this.headerSource.isEnabled()) {
|
|
@@ -3259,7 +3276,7 @@ var Controller = (_class10 = class {
|
|
|
3259
3276
|
}
|
|
3260
3277
|
try {
|
|
3261
3278
|
await this.cache.refresh();
|
|
3262
|
-
} catch (
|
|
3279
|
+
} catch (e15) {
|
|
3263
3280
|
throw this.noDefinitionsError(
|
|
3264
3281
|
". Initialize the client or provide a datafile."
|
|
3265
3282
|
);
|
|
@@ -3355,6 +3372,10 @@ var Controller = (_class10 = class {
|
|
|
3355
3372
|
this.transition("degraded", "stream-still-connecting");
|
|
3356
3373
|
return;
|
|
3357
3374
|
}
|
|
3375
|
+
if (outcome === "auth-failed") {
|
|
3376
|
+
this.transition("degraded", "stream-auth-failed");
|
|
3377
|
+
return;
|
|
3378
|
+
}
|
|
3358
3379
|
}
|
|
3359
3380
|
if (this.options.polling.enabled) {
|
|
3360
3381
|
if (this.state !== "polling") {
|
|
@@ -3387,7 +3408,7 @@ var Controller = (_class10 = class {
|
|
|
3387
3408
|
return "connected";
|
|
3388
3409
|
} catch (error) {
|
|
3389
3410
|
this.noteUnauthorized(error);
|
|
3390
|
-
return "failed";
|
|
3411
|
+
return isUnauthorizedError(error) ? "auth-failed" : "failed";
|
|
3391
3412
|
}
|
|
3392
3413
|
}
|
|
3393
3414
|
let timeoutId;
|
|
@@ -3421,7 +3442,7 @@ var Controller = (_class10 = class {
|
|
|
3421
3442
|
} catch (error) {
|
|
3422
3443
|
clearTimeout(timeoutId);
|
|
3423
3444
|
this.noteUnauthorized(error);
|
|
3424
|
-
return "failed";
|
|
3445
|
+
return isUnauthorizedError(error) ? "auth-failed" : "failed";
|
|
3425
3446
|
}
|
|
3426
3447
|
}
|
|
3427
3448
|
// ---------------------------------------------------------------------------
|
|
@@ -3572,7 +3593,7 @@ var Controller = (_class10 = class {
|
|
|
3572
3593
|
this.acceptLastResortFetch(await this.fetchOnce());
|
|
3573
3594
|
this.transition("degraded", "fetched-fallback");
|
|
3574
3595
|
return;
|
|
3575
|
-
} catch (
|
|
3596
|
+
} catch (e16) {
|
|
3576
3597
|
}
|
|
3577
3598
|
}
|
|
3578
3599
|
throw this.noDefinitionsError(". Bundled definitions not found.");
|
|
@@ -3617,7 +3638,7 @@ var Controller = (_class10 = class {
|
|
|
3617
3638
|
let fetched;
|
|
3618
3639
|
try {
|
|
3619
3640
|
fetched = await this.fetchOnce();
|
|
3620
|
-
} catch (
|
|
3641
|
+
} catch (e17) {
|
|
3621
3642
|
}
|
|
3622
3643
|
if (fetched) {
|
|
3623
3644
|
const remote = this.acceptLastResortFetch(fetched);
|
|
@@ -3725,7 +3746,7 @@ function setCacheLife() {
|
|
|
3725
3746
|
try {
|
|
3726
3747
|
_cache.cacheLife.call(void 0, { revalidate: 0, expire: 0 });
|
|
3727
3748
|
_cache.cacheLife.call(void 0, { stale: 60 });
|
|
3728
|
-
} catch (
|
|
3749
|
+
} catch (e18) {
|
|
3729
3750
|
}
|
|
3730
3751
|
}
|
|
3731
3752
|
var cachedFns = {
|
|
@@ -3775,4 +3796,4 @@ var { flagsClient, resetDefaultFlagsClient, createClient } = make(
|
|
|
3775
3796
|
|
|
3776
3797
|
|
|
3777
3798
|
exports.ResolutionReason = ResolutionReason; exports.evaluate = evaluate; exports.FallbackNotFoundError = FallbackNotFoundError; exports.FallbackEntryNotFoundError = FallbackEntryNotFoundError; exports.Controller = Controller; exports.flagsClient = flagsClient; exports.resetDefaultFlagsClient = resetDefaultFlagsClient; exports.createClient = createClient;
|
|
3778
|
-
//# sourceMappingURL=chunk-
|
|
3799
|
+
//# sourceMappingURL=chunk-EGGUENXP.cjs.map
|