flags 4.0.1 → 4.0.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,11 @@
1
1
  # @vercel/flags
2
2
 
3
+ ## 4.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 5f3757a: drop tsconfig dependency
8
+
3
9
  ## 4.0.1
4
10
 
5
11
  ### Patch Changes
@@ -46,22 +52,22 @@
46
52
  This is handy when you declare feature flags in code, and want to extend those definitions with data loaded from your feature flag provider.
47
53
 
48
54
  ```ts
49
- import { verifyAccess, mergeProviderData, type ApiData } from '@vercel/flags';
50
- import { getProviderData } from '@vercel/flags/next';
51
- import { NextResponse, type NextRequest } from 'next/server';
52
- import { getProviderData as getStatsigProviderData } from '@flags-sdk/statsig';
53
- import * as flagsA from '../../../../flags-a'; // your feature flags file(s)
54
- import * as flagsB from '../../../../flags-b'; // your feature flags file(s)
55
+ import { verifyAccess, mergeProviderData, type ApiData } from "@vercel/flags";
56
+ import { getProviderData } from "@vercel/flags/next";
57
+ import { NextResponse, type NextRequest } from "next/server";
58
+ import { getProviderData as getStatsigProviderData } from "@flags-sdk/statsig";
59
+ import * as flagsA from "../../../../flags-a"; // your feature flags file(s)
60
+ import * as flagsB from "../../../../flags-b"; // your feature flags file(s)
55
61
 
56
62
  export async function GET(request: NextRequest) {
57
- const access = await verifyAccess(request.headers.get('Authorization'));
63
+ const access = await verifyAccess(request.headers.get("Authorization"));
58
64
  if (!access) return NextResponse.json(null, { status: 401 });
59
65
 
60
66
  const providerData = await mergeProviderData([
61
67
  // expose flags declared in code first
62
68
  getProviderData({ ...flagsA, ...flagsB }),
63
69
  // then enhance them with metadata from your flag provider
64
- getStatsigProviderData({ consoleApiKey: '', projectId: '' }),
70
+ getStatsigProviderData({ consoleApiKey: "", projectId: "" }),
65
71
  ]);
66
72
 
67
73
  return NextResponse.json<ApiData>(providerData);
@@ -120,7 +126,7 @@
120
126
  `dedupe` is a middleware-friendly version of `React.cache`. It allows ensuring a function only ever runs once per request.
121
127
 
122
128
  ```ts
123
- import { dedupe } from '@vercel/flags/next';
129
+ import { dedupe } from "@vercel/flags/next";
124
130
 
125
131
  let i = 0;
126
132
  const runOnce = dedupe(async () => {
@@ -136,21 +142,21 @@
136
142
  `dedupe` is also useful to optimistically generate a random visitor id to be set in a cookie, while also allowing each feature flag to access the id. You can call a dedupe'd function to generate the random id within your Edge Middleware and also within your feature flag's `decide` functions. The function will return a consistent id.
137
143
 
138
144
  ```ts
139
- import { nanoid } from 'nanoid';
140
- import { cookies, headers } from 'next/headers';
141
- import { dedupe } from '@vercel/flags/next';
145
+ import { nanoid } from "nanoid";
146
+ import { cookies, headers } from "next/headers";
147
+ import { dedupe } from "@vercel/flags/next";
142
148
 
143
149
  /**
144
150
  * Reads the visitor id from a cookie or returns a new visitor id
145
151
  */
146
152
  export const getOrGenerateVisitorId = dedupe(
147
153
  async (): Promise<{ value: string; fresh: boolean }> => {
148
- const visitorIdCookie = (await cookies()).get('visitor-id')?.value;
154
+ const visitorIdCookie = (await cookies()).get("visitor-id")?.value;
149
155
 
150
156
  return visitorIdCookie
151
157
  ? { value: visitorIdCookie, fresh: false }
152
158
  : { value: nanoid(), fresh: true };
153
- },
159
+ }
154
160
  );
155
161
  ```
156
162
 
@@ -180,27 +186,27 @@
180
186
  **Precomputed usage example**
181
187
 
182
188
  ```ts
183
- import { bannerFlags, showFreeDeliveryBannerFlag } from './flags';
189
+ import { bannerFlags, showFreeDeliveryBannerFlag } from "./flags";
184
190
  import type {
185
191
  GetStaticPaths,
186
192
  GetStaticProps,
187
193
  InferGetStaticPropsType,
188
- } from 'next';
189
- import { unstable_generatePermutations as generatePermutations } from '@vercel/flags/next';
194
+ } from "next";
195
+ import { unstable_generatePermutations as generatePermutations } from "@vercel/flags/next";
190
196
 
191
197
  export const getStaticPaths = (async () => {
192
198
  const codes = await generatePermutations(bannerFlags);
193
199
 
194
200
  return {
195
201
  paths: codes.map((code) => ({ params: { code } })),
196
- fallback: 'blocking',
202
+ fallback: "blocking",
197
203
  };
198
204
  }) satisfies GetStaticPaths;
199
205
 
200
206
  export const getStaticProps = (async (context) => {
201
207
  const showFreeDeliveryBanner = await showFreeDeliveryBannerFlag(
202
208
  context.params!.code as string,
203
- bannerFlags,
209
+ bannerFlags
204
210
  );
205
211
 
206
212
  return { props: { showFreeDeliveryBanner } };
@@ -383,7 +389,6 @@
383
389
  ### Major Changes
384
390
 
385
391
  - c1e29ea: BREAKING CHANGE: `VERCEL_FLAGS_SECRET` env var has been renamed to `FLAGS_SECRET`
386
-
387
392
  - Rename your `VERCEL_FLAGS_SECRET` environment variable to `FLAGS_SECRET` in your project settings on vercel.com
388
393
  - Pull down the latest environment variables using `vercel env pull .env.local`
389
394
 
package/README.md CHANGED
@@ -40,10 +40,10 @@ Create a file called flags.ts in your project and declare your first feature fla
40
40
 
41
41
  ```ts
42
42
  // app/flags.tsx
43
- import { flag } from 'flags/next';
43
+ import { flag } from "flags/next";
44
44
 
45
45
  export const exampleFlag = flag<boolean>({
46
- key: 'example-flag',
46
+ key: "example-flag",
47
47
  decide() {
48
48
  return true;
49
49
  },
@@ -54,11 +54,11 @@ Call your feature flag in a React Server Component:
54
54
 
55
55
  ```tsx
56
56
  // app/page.tsx
57
- import { exampleFlag } from './flags';
57
+ import { exampleFlag } from "./flags";
58
58
 
59
59
  export default async function Page() {
60
60
  const example = await exampleFlag();
61
- return <div>{example ? 'Flag is on' : 'Flag is off'}</div>;
61
+ return <div>{example ? "Flag is on" : "Flag is off"}</div>;
62
62
  }
63
63
  ```
64
64
 
@@ -25,7 +25,9 @@ function memoizeOne(fn, isEqual, { cachePromiseRejection = false } = {}) {
25
25
  return lastResult;
26
26
  lastResult = fn.apply(this, newArgs);
27
27
  if (!cachePromiseRejection && lastResult.catch) {
28
- lastResult.catch(() => calledOnce = false);
28
+ lastResult.catch(() => {
29
+ calledOnce = false;
30
+ });
29
31
  }
30
32
  calledOnce = true;
31
33
  oldArgs = newArgs;
@@ -35,7 +37,7 @@ function memoizeOne(fn, isEqual, { cachePromiseRejection = false } = {}) {
35
37
  }
36
38
 
37
39
  // src/lib/serialization.ts
38
- import { CompactSign, base64url, compactVerify } from "jose";
40
+ import { base64url, CompactSign, compactVerify } from "jose";
39
41
  var memoizedVerify = memoizeOne(
40
42
  (code, secret) => compactVerify(code, base64url.decode(secret), {
41
43
  algorithms: ["HS256"]
@@ -93,7 +95,7 @@ async function deserialize(code, flags, secret) {
93
95
  {}
94
96
  );
95
97
  }
96
- var matchIndex = /* @__PURE__ */ function() {
98
+ var matchIndex = /* @__PURE__ */ (() => {
97
99
  const stringifiedOptionsCache = /* @__PURE__ */ new Map();
98
100
  return function matchIndex2(options, value) {
99
101
  const t = typeof value;
@@ -106,11 +108,9 @@ var matchIndex = /* @__PURE__ */ function() {
106
108
  stringifiedOptions = options.map((o) => JSON.stringify(o.value));
107
109
  stringifiedOptionsCache.set(options, stringifiedOptions);
108
110
  }
109
- return stringifiedOptions.findIndex(
110
- (stringifiedOption) => stringifiedOption === stringifiedValue
111
- );
111
+ return stringifiedOptions.indexOf(stringifiedValue);
112
112
  };
113
- }();
113
+ })();
114
114
  function joinUint8Arrays(array1, array2) {
115
115
  const combined = new Uint8Array(array1.length + array2.length);
116
116
  combined.set(array1);
@@ -123,7 +123,7 @@ async function serialize(flagSet, flags, secret) {
123
123
  flags.map((flag) => {
124
124
  const options = Array.isArray(flag.options) ? flag.options : [];
125
125
  const value = flagSet[flag.key];
126
- if (!Object.prototype.hasOwnProperty.call(flagSet, flag.key) || value === void 0) {
126
+ if (!Object.hasOwn(flagSet, flag.key) || value === void 0) {
127
127
  throw new Error(`flags: Missing value for flag "${flag.key}"`);
128
128
  }
129
129
  switch (value) {
@@ -156,9 +156,9 @@ async function serialize(flagSet, flags, secret) {
156
156
  }
157
157
 
158
158
  export {
159
- memoizeOne,
160
159
  normalizeOptions,
160
+ memoizeOne,
161
161
  deserialize,
162
162
  serialize
163
163
  };
164
- //# sourceMappingURL=chunk-O6VYPARG.js.map
164
+ //# sourceMappingURL=chunk-CIQRIQPS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lib/normalize-options.ts","../src/lib/async-memoize-one.ts","../src/lib/serialization.ts"],"sourcesContent":["import type { FlagOption, GenerousOption } from '../types';\n\nexport function normalizeOptions<T>(\n flagOptions: GenerousOption<T>[] | undefined,\n): FlagOption<T>[] | undefined {\n if (!Array.isArray(flagOptions)) return flagOptions;\n\n return flagOptions.map((option) => {\n if (typeof option === 'boolean') return { value: option };\n if (typeof option === 'number') return { value: option };\n if (typeof option === 'string') return { value: option };\n if (option === null) return { value: option };\n\n return option;\n }) as FlagOption<T>[];\n}\n","// adapted from https://github.com/microlinkhq/async-memoize-one\n// and https://github.com/alexreardon/memoize-one\n\ntype MemoizeOneOptions = {\n cachePromiseRejection?: boolean;\n};\n\ntype MemoizedFn<TFunc extends (this: any, ...args: any[]) => any> = (\n this: ThisParameterType<TFunc>,\n ...args: Parameters<TFunc>\n) => ReturnType<TFunc>;\n\n/**\n * Memoizes an async function, but only keeps the latest result\n */\nexport function memoizeOne<TFunc extends (this: any, ...newArgs: any[]) => any>(\n fn: TFunc,\n isEqual: (a: Parameters<TFunc>, b: Parameters<TFunc>) => boolean,\n { cachePromiseRejection = false }: MemoizeOneOptions = {},\n): MemoizedFn<TFunc> {\n let calledOnce = false;\n let oldArgs: Parameters<TFunc>;\n let lastResult: any;\n\n function memoized(\n this: ThisParameterType<TFunc>,\n ...newArgs: Parameters<TFunc>\n ) {\n if (calledOnce && isEqual(newArgs, oldArgs)) return lastResult;\n\n lastResult = fn.apply(this, newArgs);\n\n if (!cachePromiseRejection && lastResult.catch) {\n lastResult.catch(() => {\n calledOnce = false;\n });\n }\n\n calledOnce = true;\n oldArgs = newArgs;\n\n return lastResult;\n }\n\n return memoized;\n}\n","import { base64url, CompactSign, compactVerify } from 'jose';\nimport type { JsonValue } from '..';\nimport type { FlagOption } from '../types';\nimport { memoizeOne } from './async-memoize-one';\n\n// 252 max options length allows storing index 0 to 251,\n// so 252 is the first SPECIAL_INTEGER\nexport const MAX_OPTION_LENGTH = 252;\n\nenum SPECIAL_INTEGERS {\n /** Signals that the returned value is not listed in the flag's options */\n NULL = 252,\n BOOLEAN_FALSE = 253,\n BOOLEAN_TRUE = 254,\n UNLISTED_VALUE = 255,\n}\n\nconst memoizedVerify = memoizeOne(\n (code: string, secret: string) =>\n compactVerify(code, base64url.decode(secret), {\n algorithms: ['HS256'],\n }),\n (a, b) => a[0] === b[0] && a[1] === b[1], // only first two args matter\n { cachePromiseRejection: true },\n);\n\nconst memoizedSign = memoizeOne(\n (uint8Array: Uint8Array, secret) =>\n new CompactSign(uint8Array)\n .setProtectedHeader({ alg: 'HS256' })\n .sign(base64url.decode(secret)),\n (a, b) =>\n // matchedIndices array must be equal\n a[0].length === b[0].length &&\n a[0].every((v, i) => b[0][i] === v) &&\n // secrets must be equal\n a[1] === b[1],\n { cachePromiseRejection: true },\n);\n\nfunction splitUint8Array(\n array: Uint8Array,\n index: number,\n): [Uint8Array, Uint8Array] {\n const firstHalf = array.slice(0, index);\n const secondHalf = array.slice(index);\n return [firstHalf, secondHalf];\n}\n\n/**\n * Common subset of the flag type used in here\n */\ntype Flag = {\n key: string;\n options?: FlagOption<any>[];\n};\n\nexport async function deserialize(\n code: string,\n flags: readonly Flag[],\n secret: string,\n): Promise<Record<string, JsonValue>> {\n // TODO what happens when verification fails?\n const { payload } = await memoizedVerify(code, secret);\n\n const [matchedIndicesArray, valuesUint8Array] =\n payload.length === flags.length\n ? [payload]\n : splitUint8Array(payload, flags.length);\n\n const valuesArray = valuesUint8Array\n ? // re-add opening and closing brackets since we remove them when serializing\n JSON.parse(`[${new TextDecoder().decode(valuesUint8Array)}]`)\n : null;\n\n let spilled = 0;\n return matchedIndicesArray.reduce<Record<string, JsonValue>>(\n (acc, valueIndex, index) => {\n const flag = flags[index];\n\n if (!flag) {\n throw new Error(`flags: No flag at index ${index}`);\n }\n\n switch (valueIndex) {\n case SPECIAL_INTEGERS.BOOLEAN_FALSE:\n acc[flag.key] = false;\n break;\n case SPECIAL_INTEGERS.BOOLEAN_TRUE:\n acc[flag.key] = true;\n break;\n case SPECIAL_INTEGERS.UNLISTED_VALUE:\n acc[flag.key] = valuesArray[spilled++];\n break;\n case SPECIAL_INTEGERS.NULL:\n acc[flag.key] = null;\n break;\n default:\n acc[flag.key] = flag.options?.[valueIndex]?.value as JsonValue;\n }\n\n return acc;\n },\n {},\n );\n}\n\n/**\n * When serializing flags we find the matching option index for each evaluated value.\n *\n * This means we potentially need to iterate through all options of all flags.\n *\n * When the value we're trying to match is a literal (bool, string, number)\n * we look for it using referntial equality.\n *\n * When the value is an array or object we stringify the value and we stringify\n * the options of each flag and then we search for it by string comparison.\n *\n * This is faster than doing a deep equality check and also allows us not to\n * use any external library.\n *\n * We also cache the result of stringifying all options so in a Map so we only\n * ever need to stringify them once.\n */\nconst matchIndex = (() => {\n const stringifiedOptionsCache = new Map<FlagOption<any>[], string[]>();\n return function matchIndex(options: FlagOption<any>[], value: JsonValue) {\n const t = typeof value;\n\n // we're looking for a literal value, so we can check using referntial equality\n if (value === null || t === 'boolean' || t === 'string' || t === 'number') {\n return options.findIndex((v) => v.value === value);\n }\n\n // we're looking for an array or object, so we should check stringified\n const stringifiedValue = JSON.stringify(value);\n let stringifiedOptions = stringifiedOptionsCache.get(options);\n if (!stringifiedOptions) {\n stringifiedOptions = options.map((o) => JSON.stringify(o.value));\n stringifiedOptionsCache.set(options, stringifiedOptions);\n }\n\n return stringifiedOptions.indexOf(stringifiedValue);\n };\n})();\n\nfunction joinUint8Arrays(array1: Uint8Array, array2: Uint8Array): Uint8Array {\n const combined = new Uint8Array(array1.length + array2.length);\n combined.set(array1);\n combined.set(array2, array1.length);\n return combined;\n}\nexport async function serialize(\n flagSet: Record<Flag['key'], JsonValue>,\n flags: readonly Flag[],\n secret: string,\n) {\n const unlistedValues: JsonValue[] = [];\n\n const matchedIndices = new Uint8Array(\n flags.map((flag) => {\n const options = Array.isArray(flag.options) ? flag.options : [];\n\n const value = flagSet[flag.key];\n if (!Object.hasOwn(flagSet, flag.key) || value === undefined) {\n throw new Error(`flags: Missing value for flag \"${flag.key}\"`);\n }\n\n // avoid searching for common values\n // and ensure they can always be compressed, even if not listed in options\n switch (value) {\n case null:\n return SPECIAL_INTEGERS.NULL;\n case false:\n return SPECIAL_INTEGERS.BOOLEAN_FALSE;\n case true:\n return SPECIAL_INTEGERS.BOOLEAN_TRUE;\n }\n\n const matchedIndex = matchIndex(options, value);\n if (matchedIndex > -1) return matchedIndex;\n\n // value was not listed in options, so we need to\n // transport it using JSON.stringify(). we return 255 to\n // indicate this value is stringified.\n // stringified values will be placed at the end of the\n // indices array\n unlistedValues.push(value);\n return SPECIAL_INTEGERS.UNLISTED_VALUE;\n }),\n );\n\n let joined: Uint8Array;\n // there were unlisted values, so we need to join arrays\n if (unlistedValues.length > 0) {\n const jsonArray = new TextEncoder().encode(\n // slicing removes opening and closing array brackets as they'll always be\n // there and we can re-add them when deserializing\n JSON.stringify(unlistedValues).slice(1, -1),\n );\n joined = joinUint8Arrays(matchedIndices, jsonArray);\n } else {\n joined = matchedIndices;\n }\n\n return memoizedSign(joined, secret);\n}\n"],"mappings":";AAEO,SAAS,iBACd,aAC6B;AAC7B,MAAI,CAAC,MAAM,QAAQ,WAAW;AAAG,WAAO;AAExC,SAAO,YAAY,IAAI,CAAC,WAAW;AACjC,QAAI,OAAO,WAAW;AAAW,aAAO,EAAE,OAAO,OAAO;AACxD,QAAI,OAAO,WAAW;AAAU,aAAO,EAAE,OAAO,OAAO;AACvD,QAAI,OAAO,WAAW;AAAU,aAAO,EAAE,OAAO,OAAO;AACvD,QAAI,WAAW;AAAM,aAAO,EAAE,OAAO,OAAO;AAE5C,WAAO;AAAA,EACT,CAAC;AACH;;;ACAO,SAAS,WACd,IACA,SACA,EAAE,wBAAwB,MAAM,IAAuB,CAAC,GACrC;AACnB,MA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, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// package.json
2
2
  var name = "flags";
3
- var version = "4.0.1";
3
+ var version = "4.0.2";
4
+
5
+ // src/lib/crypto.ts
6
+ var _jose = require('jose');
7
+ var hasPurpose = (pur, expectedPurpose) => {
8
+ return Array.isArray(pur) ? pur.includes(expectedPurpose) : pur === expectedPurpose;
9
+ };
10
+ async function encryptJwe(payload, secret, expirationTime) {
11
+ const encodedSecret = _jose.base64url.decode(secret);
12
+ if (encodedSecret.length !== 32) {
13
+ throw new Error(
14
+ "flags: Invalid secret, it must be a 256-bit key (32 bytes)"
15
+ );
16
+ }
17
+ return new (0, _jose.EncryptJWT)(payload).setExpirationTime(expirationTime).setProtectedHeader({ alg: "dir", enc: "A256GCM" }).encrypt(encodedSecret);
18
+ }
19
+ async function decryptJwe(text, verify, secret) {
20
+ if (typeof text !== "string")
21
+ return;
22
+ const encodedSecret = _jose.base64url.decode(secret);
23
+ if (encodedSecret.length !== 32) {
24
+ throw new Error(
25
+ "flags: Invalid secret, it must be a 256-bit key (32 bytes)"
26
+ );
27
+ }
28
+ try {
29
+ const { payload } = await _jose.jwtDecrypt.call(void 0, text, encodedSecret);
30
+ const decoded = payload;
31
+ return verify(decoded) ? decoded : void 0;
32
+ } catch (e) {
33
+ return void 0;
34
+ }
35
+ }
36
+ async function encryptOverrides(overrides, secret = _optionalChain([process, 'optionalAccess', _ => _.env, 'optionalAccess', _2 => _2.FLAGS_SECRET]), expirationTime = "1y") {
37
+ if (!secret)
38
+ throw new Error("flags: Missing FLAGS_SECRET");
39
+ return encryptJwe({ o: overrides, pur: "overrides" }, secret, expirationTime);
40
+ }
41
+ async function decryptOverrides(encryptedData, secret = _optionalChain([process, 'optionalAccess', _3 => _3.env, 'optionalAccess', _4 => _4.FLAGS_SECRET])) {
42
+ if (!secret)
43
+ throw new Error("flags: Missing FLAGS_SECRET");
44
+ const contents = await decryptJwe(
45
+ encryptedData,
46
+ (data) => hasPurpose(data.pur, "overrides") && Object.hasOwn(data, "o"),
47
+ secret
48
+ );
49
+ return _optionalChain([contents, 'optionalAccess', _5 => _5.o]);
50
+ }
51
+ async function encryptFlagValues(flagValues, secret = _optionalChain([process, 'optionalAccess', _6 => _6.env, 'optionalAccess', _7 => _7.FLAGS_SECRET]), expirationTime = "1y") {
52
+ if (!secret)
53
+ throw new Error("flags: Missing FLAGS_SECRET");
54
+ return encryptJwe({ v: flagValues, pur: "values" }, secret, expirationTime);
55
+ }
56
+ async function decryptFlagValues(encryptedData, secret = _optionalChain([process, 'optionalAccess', _8 => _8.env, 'optionalAccess', _9 => _9.FLAGS_SECRET])) {
57
+ if (!secret)
58
+ throw new Error("flags: Missing FLAGS_SECRET");
59
+ const contents = await decryptJwe(
60
+ encryptedData,
61
+ (data) => hasPurpose(data.pur, "values") && Object.hasOwn(data, "v"),
62
+ secret
63
+ );
64
+ return _optionalChain([contents, 'optionalAccess', _10 => _10.v]);
65
+ }
66
+ async function encryptFlagDefinitions(flagDefinitions, secret = _optionalChain([process, 'optionalAccess', _11 => _11.env, 'optionalAccess', _12 => _12.FLAGS_SECRET]), expirationTime = "1y") {
67
+ if (!secret)
68
+ throw new Error("flags: Missing FLAGS_SECRET");
69
+ return encryptJwe(
70
+ { d: flagDefinitions, pur: "definitions" },
71
+ secret,
72
+ expirationTime
73
+ );
74
+ }
75
+ async function decryptFlagDefinitions(encryptedData, secret = _optionalChain([process, 'optionalAccess', _13 => _13.env, 'optionalAccess', _14 => _14.FLAGS_SECRET])) {
76
+ if (!secret)
77
+ throw new Error("flags: Missing FLAGS_SECRET");
78
+ const contents = await decryptJwe(
79
+ encryptedData,
80
+ (data) => data.pur === "definitions" && Object.hasOwn(data, "d"),
81
+ secret
82
+ );
83
+ return _optionalChain([contents, 'optionalAccess', _15 => _15.d]);
84
+ }
85
+ async function createAccessProof(secret = _optionalChain([process, 'optionalAccess', _16 => _16.env, 'optionalAccess', _17 => _17.FLAGS_SECRET]), expirationTime = "1y") {
86
+ if (!secret)
87
+ throw new Error("flags: Missing FLAGS_SECRET");
88
+ return encryptJwe({ pur: "proof" }, secret, expirationTime);
89
+ }
90
+ async function verifyAccessProof(encryptedData, secret = _optionalChain([process, 'optionalAccess', _18 => _18.env, 'optionalAccess', _19 => _19.FLAGS_SECRET])) {
91
+ if (!secret)
92
+ throw new Error("flags: Missing FLAGS_SECRET");
93
+ const contents = await decryptJwe(encryptedData, (data) => hasPurpose(data.pur, "proof"), secret);
94
+ return Boolean(contents);
95
+ }
96
+
97
+ // src/lib/merge-provider-data.ts
98
+ async function mergeProviderData(itemsPromises) {
99
+ const items = await Promise.all(
100
+ itemsPromises.map((p) => Promise.resolve(p).catch(() => null))
101
+ );
102
+ return items.filter((item) => Boolean(item)).reduce(
103
+ (acc, item) => {
104
+ Object.entries(item.definitions).forEach(([key, definition]) => {
105
+ if (!acc.definitions[key])
106
+ acc.definitions[key] = {};
107
+ Object.assign(acc.definitions[key], definition);
108
+ });
109
+ if (Array.isArray(item.hints))
110
+ acc.hints.push(...item.hints);
111
+ return acc;
112
+ },
113
+ { definitions: {}, hints: [] }
114
+ );
115
+ }
116
+
117
+ // src/lib/report-value.ts
118
+ function reportValue(key, value) {
119
+ const symbol = Symbol.for("@vercel/request-context");
120
+ const ctx = _optionalChain([Reflect, 'access', _20 => _20.get, 'call', _21 => _21(globalThis, symbol), 'optionalAccess', _22 => _22.get, 'call', _23 => _23()]);
121
+ _optionalChain([ctx, 'optionalAccess', _24 => _24.flags, 'optionalAccess', _25 => _25.reportValue, 'call', _26 => _26(key, value, {
122
+ sdkVersion: version
123
+ })]);
124
+ }
125
+ function internalReportValue(key, value, data) {
126
+ const symbol = Symbol.for("@vercel/request-context");
127
+ const ctx = _optionalChain([Reflect, 'access', _27 => _27.get, 'call', _28 => _28(globalThis, symbol), 'optionalAccess', _29 => _29.get, 'call', _30 => _30()]);
128
+ _optionalChain([ctx, 'optionalAccess', _31 => _31.flags, 'optionalAccess', _32 => _32.reportValue, 'call', _33 => _33(key, value, {
129
+ sdkVersion: version,
130
+ ...data
131
+ })]);
132
+ }
4
133
 
5
134
  // src/lib/tracing.ts
6
135
  var _async_hooks = require('async_hooks');
@@ -10,14 +139,14 @@ function setTracerProvider(tracer) {
10
139
  }
11
140
  function getTracer() {
12
141
  const maybeTraceApi = Reflect.get(globalThis, vercelFlagsTraceSymbol);
13
- return _optionalChain([maybeTraceApi, 'optionalAccess', _ => _.getTracer, 'call', _2 => _2(name, version)]);
142
+ return _optionalChain([maybeTraceApi, 'optionalAccess', _34 => _34.getTracer, 'call', _35 => _35(name, version)]);
14
143
  }
15
144
  function isPromise(p) {
16
145
  return p !== null && typeof p === "object" && "then" in p && typeof p.then === "function";
17
146
  }
18
147
  var spanContext = new (0, _async_hooks.AsyncLocalStorage)();
19
148
  function setSpanAttribute(name2, value) {
20
- _optionalChain([spanContext, 'access', _3 => _3.getStore, 'call', _4 => _4(), 'optionalAccess', _5 => _5.set, 'call', _6 => _6(name2, value)]);
149
+ _optionalChain([spanContext, 'access', _36 => _36.getStore, 'call', _37 => _37(), 'optionalAccess', _38 => _38.set, 'call', _39 => _39(name2, value)]);
21
150
  }
22
151
  function trace(fn, options = {
23
152
  name: fn.name
@@ -45,7 +174,7 @@ function trace(fn, options = {
45
174
  )
46
175
  );
47
176
  }
48
- _optionalChain([spanContext, 'access', _7 => _7.getStore, 'call', _8 => _8(), 'optionalAccess', _9 => _9.forEach, 'call', _10 => _10((value2, key) => {
177
+ _optionalChain([spanContext, 'access', _40 => _40.getStore, 'call', _41 => _41(), 'optionalAccess', _42 => _42.forEach, 'call', _43 => _43((value2, key) => {
49
178
  span.setAttribute(key, value2);
50
179
  })]);
51
180
  span.setStatus({ code: 1 });
@@ -59,7 +188,7 @@ function trace(fn, options = {
59
188
  // 2 = Error
60
189
  message: error instanceof Error ? error.message : void 0
61
190
  });
62
- _optionalChain([spanContext, 'access', _11 => _11.getStore, 'call', _12 => _12(), 'optionalAccess', _13 => _13.forEach, 'call', _14 => _14((value, key) => {
191
+ _optionalChain([spanContext, 'access', _44 => _44.getStore, 'call', _45 => _45(), 'optionalAccess', _46 => _46.forEach, 'call', _47 => _47((value, key) => {
63
192
  span.setAttribute(key, value);
64
193
  })]);
65
194
  span.end();
@@ -68,7 +197,7 @@ function trace(fn, options = {
68
197
  if (options.attributesSuccess) {
69
198
  span.setAttributes(options.attributesSuccess(result));
70
199
  }
71
- _optionalChain([spanContext, 'access', _15 => _15.getStore, 'call', _16 => _16(), 'optionalAccess', _17 => _17.forEach, 'call', _18 => _18((value, key) => {
200
+ _optionalChain([spanContext, 'access', _48 => _48.getStore, 'call', _49 => _49(), 'optionalAccess', _50 => _50.forEach, 'call', _51 => _51((value, key) => {
72
201
  span.setAttribute(key, value);
73
202
  })]);
74
203
  span.setStatus({ code: 1 });
@@ -84,7 +213,7 @@ function trace(fn, options = {
84
213
  // 2 = Error
85
214
  message: error instanceof Error ? error.message : void 0
86
215
  });
87
- _optionalChain([spanContext, 'access', _19 => _19.getStore, 'call', _20 => _20(), 'optionalAccess', _21 => _21.forEach, 'call', _22 => _22((value, key) => {
216
+ _optionalChain([spanContext, 'access', _52 => _52.getStore, 'call', _53 => _53(), 'optionalAccess', _54 => _54.forEach, 'call', _55 => _55((value, key) => {
88
217
  span.setAttribute(key, value);
89
218
  })]);
90
219
  span.end();
@@ -96,101 +225,9 @@ function trace(fn, options = {
96
225
  return traced;
97
226
  }
98
227
 
99
- // src/lib/crypto.ts
100
- var _jose = require('jose');
101
- var hasPurpose = (pur, expectedPurpose) => {
102
- return Array.isArray(pur) ? pur.includes(expectedPurpose) : pur === expectedPurpose;
103
- };
104
- async function encryptJwe(payload, secret, expirationTime) {
105
- const encodedSecret = _jose.base64url.decode(secret);
106
- if (encodedSecret.length !== 32) {
107
- throw new Error(
108
- "flags: Invalid secret, it must be a 256-bit key (32 bytes)"
109
- );
110
- }
111
- return new (0, _jose.EncryptJWT)(payload).setExpirationTime(expirationTime).setProtectedHeader({ alg: "dir", enc: "A256GCM" }).encrypt(encodedSecret);
112
- }
113
- async function decryptJwe(text, verify, secret) {
114
- if (typeof text !== "string")
115
- return;
116
- const encodedSecret = _jose.base64url.decode(secret);
117
- if (encodedSecret.length !== 32) {
118
- throw new Error(
119
- "flags: Invalid secret, it must be a 256-bit key (32 bytes)"
120
- );
121
- }
122
- try {
123
- const { payload } = await _jose.jwtDecrypt.call(void 0, text, encodedSecret);
124
- const decoded = payload;
125
- return verify(decoded) ? decoded : void 0;
126
- } catch (e) {
127
- return void 0;
128
- }
129
- }
130
- async function encryptOverrides(overrides, secret = _optionalChain([process, 'optionalAccess', _23 => _23.env, 'optionalAccess', _24 => _24.FLAGS_SECRET]), expirationTime = "1y") {
131
- if (!secret)
132
- throw new Error("flags: Missing FLAGS_SECRET");
133
- return encryptJwe({ o: overrides, pur: "overrides" }, secret, expirationTime);
134
- }
135
- async function decryptOverrides(encryptedData, secret = _optionalChain([process, 'optionalAccess', _25 => _25.env, 'optionalAccess', _26 => _26.FLAGS_SECRET])) {
136
- if (!secret)
137
- throw new Error("flags: Missing FLAGS_SECRET");
138
- const contents = await decryptJwe(
139
- encryptedData,
140
- (data) => hasPurpose(data.pur, "overrides") && Object.hasOwn(data, "o"),
141
- secret
142
- );
143
- return _optionalChain([contents, 'optionalAccess', _27 => _27.o]);
144
- }
145
- async function encryptFlagValues(flagValues, secret = _optionalChain([process, 'optionalAccess', _28 => _28.env, 'optionalAccess', _29 => _29.FLAGS_SECRET]), expirationTime = "1y") {
146
- if (!secret)
147
- throw new Error("flags: Missing FLAGS_SECRET");
148
- return encryptJwe({ v: flagValues, pur: "values" }, secret, expirationTime);
149
- }
150
- async function decryptFlagValues(encryptedData, secret = _optionalChain([process, 'optionalAccess', _30 => _30.env, 'optionalAccess', _31 => _31.FLAGS_SECRET])) {
151
- if (!secret)
152
- throw new Error("flags: Missing FLAGS_SECRET");
153
- const contents = await decryptJwe(
154
- encryptedData,
155
- (data) => hasPurpose(data.pur, "values") && Object.hasOwn(data, "v"),
156
- secret
157
- );
158
- return _optionalChain([contents, 'optionalAccess', _32 => _32.v]);
159
- }
160
- async function encryptFlagDefinitions(flagDefinitions, secret = _optionalChain([process, 'optionalAccess', _33 => _33.env, 'optionalAccess', _34 => _34.FLAGS_SECRET]), expirationTime = "1y") {
161
- if (!secret)
162
- throw new Error("flags: Missing FLAGS_SECRET");
163
- return encryptJwe(
164
- { d: flagDefinitions, pur: "definitions" },
165
- secret,
166
- expirationTime
167
- );
168
- }
169
- async function decryptFlagDefinitions(encryptedData, secret = _optionalChain([process, 'optionalAccess', _35 => _35.env, 'optionalAccess', _36 => _36.FLAGS_SECRET])) {
170
- if (!secret)
171
- throw new Error("flags: Missing FLAGS_SECRET");
172
- const contents = await decryptJwe(
173
- encryptedData,
174
- (data) => data.pur === "definitions" && Object.hasOwn(data, "d"),
175
- secret
176
- );
177
- return _optionalChain([contents, 'optionalAccess', _37 => _37.d]);
178
- }
179
- async function createAccessProof(secret = _optionalChain([process, 'optionalAccess', _38 => _38.env, 'optionalAccess', _39 => _39.FLAGS_SECRET]), expirationTime = "1y") {
180
- if (!secret)
181
- throw new Error("flags: Missing FLAGS_SECRET");
182
- return encryptJwe({ pur: "proof" }, secret, expirationTime);
183
- }
184
- async function verifyAccessProof(encryptedData, secret = _optionalChain([process, 'optionalAccess', _40 => _40.env, 'optionalAccess', _41 => _41.FLAGS_SECRET])) {
185
- if (!secret)
186
- throw new Error("flags: Missing FLAGS_SECRET");
187
- const contents = await decryptJwe(encryptedData, (data) => hasPurpose(data.pur, "proof"), secret);
188
- return Boolean(contents);
189
- }
190
-
191
228
  // src/lib/verify-access.ts
192
229
  var verifyAccess = trace(
193
- async function verifyAccess2(authHeader, secret = _optionalChain([process, 'optionalAccess', _42 => _42.env, 'optionalAccess', _43 => _43.FLAGS_SECRET])) {
230
+ async function verifyAccess2(authHeader, secret = _optionalChain([process, 'optionalAccess', _56 => _56.env, 'optionalAccess', _57 => _57.FLAGS_SECRET])) {
194
231
  if (!authHeader)
195
232
  return false;
196
233
  if (!secret)
@@ -209,23 +246,6 @@ var verifyAccess = trace(
209
246
  }
210
247
  );
211
248
 
212
- // src/lib/report-value.ts
213
- function reportValue(key, value) {
214
- const symbol = Symbol.for("@vercel/request-context");
215
- const ctx = _optionalChain([Reflect, 'access', _44 => _44.get, 'call', _45 => _45(globalThis, symbol), 'optionalAccess', _46 => _46.get, 'call', _47 => _47()]);
216
- _optionalChain([ctx, 'optionalAccess', _48 => _48.flags, 'optionalAccess', _49 => _49.reportValue, 'call', _50 => _50(key, value, {
217
- sdkVersion: version
218
- })]);
219
- }
220
- function internalReportValue(key, value, data) {
221
- const symbol = Symbol.for("@vercel/request-context");
222
- const ctx = _optionalChain([Reflect, 'access', _51 => _51.get, 'call', _52 => _52(globalThis, symbol), 'optionalAccess', _53 => _53.get, 'call', _54 => _54()]);
223
- _optionalChain([ctx, 'optionalAccess', _55 => _55.flags, 'optionalAccess', _56 => _56.reportValue, 'call', _57 => _57(key, value, {
224
- sdkVersion: version,
225
- ...data
226
- })]);
227
- }
228
-
229
249
  // src/spec-extension/adapters/reflect.ts
230
250
  var ReflectAdapter = class {
231
251
  static get(target, prop, receiver) {
@@ -431,26 +451,6 @@ var RequestCookiesAdapter = class {
431
451
  };
432
452
  var SYMBOL_MODIFY_COOKIE_VALUES = Symbol.for("next.mutated.cookies");
433
453
 
434
- // src/lib/merge-provider-data.ts
435
- async function mergeProviderData(itemsPromises) {
436
- const items = await Promise.all(
437
- itemsPromises.map((p) => Promise.resolve(p).catch(() => null))
438
- );
439
- return items.filter((item) => Boolean(item)).reduce(
440
- (acc, item) => {
441
- Object.entries(item.definitions).forEach(([key, definition]) => {
442
- if (!acc.definitions[key])
443
- acc.definitions[key] = {};
444
- Object.assign(acc.definitions[key], definition);
445
- });
446
- if (Array.isArray(item.hints))
447
- acc.hints.push(...item.hints);
448
- return acc;
449
- },
450
- { definitions: {}, hints: [] }
451
- );
452
- }
453
-
454
454
 
455
455
 
456
456
 
@@ -470,5 +470,5 @@ async function mergeProviderData(itemsPromises) {
470
470
 
471
471
 
472
472
 
473
- exports.version = version; exports.setTracerProvider = setTracerProvider; exports.setSpanAttribute = setSpanAttribute; exports.trace = trace; exports.encryptOverrides = encryptOverrides; exports.decryptOverrides = decryptOverrides; exports.encryptFlagValues = encryptFlagValues; exports.decryptFlagValues = decryptFlagValues; exports.encryptFlagDefinitions = encryptFlagDefinitions; exports.decryptFlagDefinitions = decryptFlagDefinitions; exports.createAccessProof = createAccessProof; exports.verifyAccessProof = verifyAccessProof; exports.verifyAccess = verifyAccess; exports.reportValue = reportValue; exports.internalReportValue = internalReportValue; exports.HeadersAdapter = HeadersAdapter; exports.RequestCookiesAdapter = RequestCookiesAdapter; exports.mergeProviderData = mergeProviderData;
474
- //# sourceMappingURL=chunk-RIRV5SST.cjs.map
473
+ exports.version = version; exports.encryptOverrides = encryptOverrides; exports.decryptOverrides = decryptOverrides; exports.encryptFlagValues = encryptFlagValues; exports.decryptFlagValues = decryptFlagValues; exports.encryptFlagDefinitions = encryptFlagDefinitions; exports.decryptFlagDefinitions = decryptFlagDefinitions; exports.createAccessProof = createAccessProof; exports.verifyAccessProof = verifyAccessProof; exports.mergeProviderData = mergeProviderData; exports.reportValue = reportValue; exports.internalReportValue = internalReportValue; exports.setTracerProvider = setTracerProvider; exports.setSpanAttribute = setSpanAttribute; exports.trace = trace; exports.verifyAccess = verifyAccess; exports.HeadersAdapter = HeadersAdapter; exports.RequestCookiesAdapter = RequestCookiesAdapter;
474
+ //# sourceMappingURL=chunk-JUWXY2C3.cjs.map