@vercel/flags-core 1.10.1 → 1.10.2

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,13 @@
1
1
  # @vercel/flags-core
2
2
 
3
+ ## 1.10.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#567](https://github.com/vercel/flags/pull/567) [`5f738f0`](https://github.com/vercel/flags/commit/5f738f08f182838d0efb13fd3efb89751d48cb0a) Thanks [@vincent-derks](https://github.com/vincent-derks)! - Improve guidance for authorization errors.
8
+
9
+ - [#573](https://github.com/vercel/flags/pull/573) [`e2a1a39`](https://github.com/vercel/flags/commit/e2a1a394e3de4b271c8305bae6cbcf053814ab70) Thanks [@luismeyer](https://github.com/luismeyer)! - Read embedded flag definitions when the client is created, using the SDK key or `VERCEL_PROJECT_ID` in OIDC mode.
10
+
3
11
  ## 1.10.1
4
12
 
5
13
  ### Patch Changes
@@ -559,7 +559,7 @@ function bulkEvaluate(flags, shared) {
559
559
  }
560
560
 
561
561
  // package.json
562
- var version = "1.10.1";
562
+ var version = "1.10.2";
563
563
 
564
564
  // src/lib/report-value.ts
565
565
  function internalReportValue(key, value, data) {
@@ -1087,7 +1087,7 @@ function unauthorizedMessage(sourceProjectId) {
1087
1087
  if (!sourceProjectId) {
1088
1088
  return "unauthorized (401)";
1089
1089
  }
1090
- return `unauthorized (401): this deployment is not allowed to read the flags of project "${sourceProjectId}". Check that the project is connected.`;
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
1092
  async function getOidcToken() {
1093
1093
  try {
@@ -1142,13 +1142,24 @@ var Authentication = class {
1142
1142
  }
1143
1143
  return await getOidcToken();
1144
1144
  }
1145
- async resolveBundledDefinitionsLookup() {
1145
+ getStaticBundledDefinitionsLookup() {
1146
1146
  if (this.sdkKey) {
1147
1147
  return { type: "sdk-key", sdkKey: this.sdkKey };
1148
1148
  }
1149
1149
  if (this.sourceProjectId) {
1150
1150
  return { type: "project-id", projectId: this.sourceProjectId };
1151
1151
  }
1152
+ const projectId = process.env.VERCEL_PROJECT_ID;
1153
+ if (projectId) {
1154
+ return { type: "project-id", projectId };
1155
+ }
1156
+ return void 0;
1157
+ }
1158
+ async resolveBundledDefinitionsLookup() {
1159
+ const lookup = this.getStaticBundledDefinitionsLookup();
1160
+ if (lookup) {
1161
+ return lookup;
1162
+ }
1152
1163
  const oidcToken = await this.resolveToken();
1153
1164
  return {
1154
1165
  type: "project-id",
@@ -1658,6 +1669,13 @@ var BundledSource = class {
1658
1669
  }
1659
1670
  return void 0;
1660
1671
  }
1672
+ /**
1673
+ * Starts reading bundled definitions without waiting for the result.
1674
+ */
1675
+ preload() {
1676
+ this.getResult().catch(() => {
1677
+ });
1678
+ }
1661
1679
  getResult() {
1662
1680
  if (!this.promise) {
1663
1681
  this.promise = this.options.readBundledDefinitions(this.options.auth);
@@ -2853,6 +2871,9 @@ var Controller = class {
2853
2871
  auth: this.options.auth,
2854
2872
  readBundledDefinitions
2855
2873
  });
2874
+ if (!this.options.datafile && this.options.auth.getStaticBundledDefinitionsLookup()) {
2875
+ this.bundledSource.preload();
2876
+ }
2856
2877
  this.wireSourceEvents();
2857
2878
  if (this.options.datafile) {
2858
2879
  this.cache.seed(tagData({ ...this.options.datafile }, "provided"));
@@ -3754,4 +3775,4 @@ export {
3754
3775
  resetDefaultFlagsClient,
3755
3776
  createClient
3756
3777
  };
3757
- //# sourceMappingURL=chunk-ZY7CHPJG.js.map
3778
+ //# sourceMappingURL=chunk-7A7RG7ST.js.map