@vercel/flags-core 1.10.3 → 1.11.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.
@@ -576,7 +576,7 @@ function bulkEvaluate(flags, shared) {
576
576
  }
577
577
 
578
578
  // package.json
579
- var version = "1.10.3";
579
+ var version = "1.11.0";
580
580
 
581
581
  // src/lib/report-value.ts
582
582
  function internalReportValue(key, value, data) {
@@ -1080,6 +1080,10 @@ var _oidc = require('@vercel/oidc');
1080
1080
 
1081
1081
  // src/utils/sdk-keys.ts
1082
1082
  var SDK_KEY_REGEX = /^vf_(?:server|client)_/;
1083
+ var PROJECT_ID_REGEX = /^[A-Za-z0-9_]{1,64}$/;
1084
+ function isValidProjectId(value) {
1085
+ return PROJECT_ID_REGEX.test(value);
1086
+ }
1083
1087
  function parseSdkKeyFromFlagsConnectionString(text) {
1084
1088
  if (SDK_KEY_REGEX.test(text)) return text;
1085
1089
  try {
@@ -1146,7 +1150,21 @@ function getProjectIdFromOidcToken(oidcToken) {
1146
1150
  var Authentication = class {
1147
1151
 
1148
1152
 
1149
- constructor(sdkKeyOrConnectionString) {
1153
+ constructor(sdkKeyOrConnectionString, options = {}) {
1154
+ if (options.projectId !== void 0) {
1155
+ if (typeof options.projectId !== "string" || !isValidProjectId(options.projectId)) {
1156
+ throw new Error(
1157
+ `@vercel/flags-core: Invalid projectId "${options.projectId}". Expected a project id like "prj_\u2026" (letters, digits and underscores, up to 64 characters)`
1158
+ );
1159
+ }
1160
+ if (sdkKeyOrConnectionString !== void 0) {
1161
+ throw new Error(
1162
+ "@vercel/flags-core: projectId cannot be combined with an SDK key. Connected projects are read with the OIDC token of this deployment."
1163
+ );
1164
+ }
1165
+ this.sourceProjectId = options.projectId;
1166
+ return;
1167
+ }
1150
1168
  if (sdkKeyOrConnectionString !== void 0) {
1151
1169
  if (typeof sdkKeyOrConnectionString !== "string") {
1152
1170
  throw new Error(
@@ -3721,8 +3739,8 @@ function make(createRawClient, defaults) {
3721
3739
  const optionsOnly = typeof sdkKeyOrConnectionStringOrOptions === "object" && sdkKeyOrConnectionStringOrOptions !== null;
3722
3740
  const sdkKeyOrConnectionString = optionsOnly ? void 0 : sdkKeyOrConnectionStringOrOptions;
3723
3741
  const createClientOptions = optionsOnly ? sdkKeyOrConnectionStringOrOptions : options;
3724
- const { experimental_reportExposures, ...controllerOptions } = _nullishCoalesce(createClientOptions, () => ( {}));
3725
- const auth = new Authentication(sdkKeyOrConnectionString);
3742
+ const { experimental_reportExposures, projectId, ...controllerOptions } = _nullishCoalesce(createClientOptions, () => ( {}));
3743
+ const auth = new Authentication(sdkKeyOrConnectionString, { projectId });
3726
3744
  const waitUntil3 = _nullishCoalesce(controllerOptions.waitUntil, () => ( defaults.waitUntil));
3727
3745
  const controller = new Controller({
3728
3746
  auth,
@@ -3787,4 +3805,4 @@ var {
3787
3805
 
3788
3806
 
3789
3807
  exports.ResolutionReason = ResolutionReason; exports.evaluate = evaluate; exports.FallbackNotFoundError = FallbackNotFoundError; exports.FallbackEntryNotFoundError = FallbackEntryNotFoundError; exports.Controller = Controller; exports.flagsClient = flagsClient; exports.resetDefaultFlagsClient = resetDefaultFlagsClient; exports.createClient = createClient;
3790
- //# sourceMappingURL=chunk-BEQ3MX7Z.cjs.map
3808
+ //# sourceMappingURL=chunk-EMMJNPVW.cjs.map