flags 3.1.1 → 3.1.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 +6 -0
- package/README.md +2 -2
- package/dist/{chunk-OQHOV3IB.js → chunk-7EGZDBDN.js} +2 -2
- package/dist/{chunk-OQHOV3IB.js.map → chunk-7EGZDBDN.js.map} +1 -1
- package/dist/{chunk-D2GBVCQQ.cjs → chunk-IGXYQW6R.cjs} +2 -2
- package/dist/{chunk-D2GBVCQQ.cjs.map → chunk-IGXYQW6R.cjs.map} +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/next.cjs +16 -14
- package/dist/next.cjs.map +1 -1
- package/dist/next.d.cts +1 -1
- package/dist/next.d.ts +1 -1
- package/dist/next.js +3 -1
- package/dist/next.js.map +1 -1
- package/dist/react.d.cts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/sveltekit.cjs +8 -8
- package/dist/sveltekit.d.cts +1 -1
- package/dist/sveltekit.d.ts +1 -1
- package/dist/sveltekit.js +1 -1
- package/dist/{types-swW0-Ony.d.cts → types-CGpl9epN.d.cts} +1 -0
- package/dist/{types-swW0-Ony.d.ts → types-CGpl9epN.d.ts} +1 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ From the creators of Next.js, the Flags SDK is a free open-source library that g
|
|
|
10
10
|
- Compatible with App Router, Pages Router, and Edge Middleware
|
|
11
11
|
- Built for feature flags and experimentation
|
|
12
12
|
|
|
13
|
-
See [flags-sdk.
|
|
13
|
+
See [flags-sdk.dev](https://flags-sdk.dev/) for full docs and examples.
|
|
14
14
|
|
|
15
15
|
## Installation
|
|
16
16
|
|
|
@@ -70,4 +70,4 @@ The Flags SDK has adapters for popular feature flag providers including LaunchDa
|
|
|
70
70
|
|
|
71
71
|
There is a lot more to the Flags SDK than shown in the example above.
|
|
72
72
|
|
|
73
|
-
See the full documentation and examples on [flags-sdk.
|
|
73
|
+
See the full documentation and examples on [flags-sdk.dev](https://flags-sdk.dev/).
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// package.json
|
|
2
2
|
var name = "flags";
|
|
3
|
-
var version = "3.1.
|
|
3
|
+
var version = "3.1.2";
|
|
4
4
|
|
|
5
5
|
// src/lib/tracing.ts
|
|
6
6
|
import { AsyncLocalStorage } from "async_hooks";
|
|
@@ -403,4 +403,4 @@ export {
|
|
|
403
403
|
RequestCookiesAdapter,
|
|
404
404
|
mergeProviderData
|
|
405
405
|
};
|
|
406
|
-
//# sourceMappingURL=chunk-
|
|
406
|
+
//# sourceMappingURL=chunk-7EGZDBDN.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../package.json","../src/lib/tracing.ts","../src/lib/crypto.ts","../src/lib/verify-access.ts","../src/lib/report-value.ts","../src/spec-extension/adapters/reflect.ts","../src/spec-extension/adapters/headers.ts","../src/spec-extension/adapters/request-cookies.ts","../src/lib/merge-provider-data.ts"],"sourcesContent":["{\n \"name\": \"flags\",\n \"version\": \"3.1.1\",\n \"description\": \"Flags SDK by Vercel - The feature flags toolkit for Next.js and SvelteKit\",\n \"keywords\": [\n \"feature flags\",\n \"Next.js\",\n \"react\",\n \"toolbar\",\n \"overrides\",\n \"SvelteKit\"\n ],\n \"homepage\": \"https://flags-sdk.dev\",\n \"bugs\": {\n \"url\": \"https://github.com/vercel/flags/issues\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/vercel/flags.git\"\n },\n \"license\": \"MIT\",\n \"sideEffects\": false,\n \"type\": \"module\",\n \"exports\": {\n \".\": {\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\"\n },\n \"./next\": {\n \"import\": \"./dist/next.js\",\n \"require\": \"./dist/next.cjs\"\n },\n \"./analytics\": {\n \"import\": \"./dist/analytics.js\",\n \"require\": \"./dist/analytics.cjs\"\n },\n \"./react\": {\n \"import\": \"./dist/react.js\",\n \"require\": \"./dist/react.cjs\"\n },\n \"./sveltekit\": {\n \"import\": \"./dist/sveltekit.js\",\n \"require\": \"./dist/sveltekit.cjs\"\n }\n },\n \"typesVersions\": {\n \"*\": {\n \"*\": [\n \"dist/*.d.ts\",\n \"dist/*.d.cts\"\n ],\n \"next\": [\n \"dist/next.d.ts\",\n \"dist/next.d.cts\"\n ],\n \"react\": [\n \"dist/react.d.ts\",\n \"dist/react.d.cts\"\n ],\n \"sveltekit\": [\n \"dist/sveltekit.d.ts\",\n \"dist/sveltekit.d.cts\"\n ]\n }\n },\n \"files\": [\n \"dist\",\n \"CHANGELOG.md\"\n ],\n \"scripts\": {\n \"attw\": \"attw --pack .\",\n \"build\": \"tsup\",\n \"dev\": \"tsup --watch --clean=false\",\n \"eslint\": \"eslint-runner\",\n \"eslint:fix\": \"eslint-runner --fix\",\n \"test\": \"vitest --run\",\n \"test:watch\": \"vitest\",\n \"type-check\": \"tsc --noEmit\"\n },\n \"dependencies\": {\n \"@edge-runtime/cookies\": \"^5.0.2\",\n \"jose\": \"^5.2.1\"\n },\n \"devDependencies\": {\n \"@arethetypeswrong/cli\": \"0.17.3\",\n \"@types/node\": \"20.11.17\",\n \"@types/react\": \"18.2.55\",\n \"@vitejs/plugin-react\": \"4.2.1\",\n \"eslint-config-custom\": \"workspace:*\",\n \"msw\": \"2.6.4\",\n \"next\": \"15.1.4\",\n \"react\": \"canary\",\n \"tsconfig\": \"workspace:*\",\n \"tsup\": \"8.0.1\",\n \"typescript\": \"5.6.3\",\n \"vite\": \"5.1.1\",\n \"vitest\": \"1.4.0\"\n },\n \"peerDependencies\": {\n \"@opentelemetry/api\": \"^1.7.0\",\n \"@sveltejs/kit\": \"*\",\n \"next\": \"*\",\n \"react\": \"*\",\n \"react-dom\": \"*\"\n },\n \"peerDependenciesMeta\": {\n \"@opentelemetry/api\": {\n \"optional\": true\n },\n \"@sveltejs/kit\": {\n \"optional\": true\n },\n \"next\": {\n \"optional\": true\n },\n \"react\": {\n \"optional\": true\n },\n \"react-dom\": {\n \"optional\": true\n }\n },\n \"publishConfig\": {\n \"access\": \"public\"\n }\n}\n","import type {\n Tracer,\n Attributes,\n TracerProvider,\n AttributeValue,\n} from '@opentelemetry/api';\nimport { name as pkgName, version } from '../../package.json';\nimport { AsyncLocalStorage } from 'async_hooks';\n\n// Use a symbol to avoid having global variable that is scoped to this file,\n// as it can lead to issues with cjs and mjs being used at the same time.\nconst vercelFlagsTraceSymbol = Symbol.for('flags:global-trace');\n\n/**\n * Allows setting the `@opentelemetry/api` tracer provider to generate traces\n * for `flags` operations.\n */\nexport function setTracerProvider(tracer: TracerProvider): void {\n Reflect.set(globalThis, vercelFlagsTraceSymbol, tracer);\n}\n\nfunction getTracer(): Tracer | undefined {\n const maybeTraceApi = Reflect.get(globalThis, vercelFlagsTraceSymbol) as\n | undefined\n | TracerProvider;\n return maybeTraceApi?.getTracer(pkgName, version);\n}\n\nfunction isPromise<T>(p: unknown): p is Promise<T> {\n return (\n p !== null &&\n typeof p === 'object' &&\n 'then' in p &&\n typeof p.then === 'function'\n );\n}\n\nconst spanContext = new AsyncLocalStorage<Map<string, AttributeValue>>();\n\nexport function setSpanAttribute(name: string, value: AttributeValue) {\n spanContext.getStore()?.set(name, value);\n}\n\n/* eslint-disable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any -- bc */\nexport function trace<F extends (...args: any) => any>(\n fn: F,\n options: {\n name: string;\n /** Defaults to `true`. If set to `false`, it'll trace regardless of `VERCEL_FLAGS_TRACE_VERBOSE`. */\n isVerboseTrace?: boolean;\n attributes?: Attributes;\n attributesSuccess?: (\n result: ReturnType<F> extends PromiseLike<infer U> ? U : ReturnType<F>,\n ) => Attributes;\n attributesError?: (error: Error) => Attributes;\n } = {\n name: fn.name,\n },\n): F {\n const traced = function (this: unknown, ...args: unknown[]): unknown {\n const tracer = getTracer();\n if (!tracer) return fn.apply(this, args);\n\n const shouldTrace =\n process.env.VERCEL_FLAGS_TRACE_VERBOSE === 'true' ||\n options.isVerboseTrace === false;\n if (!shouldTrace) return fn.apply(this, args);\n\n return spanContext.run(new Map(), () =>\n tracer.startActiveSpan(options.name, (span) => {\n if (options.attributes) span.setAttributes(options.attributes);\n\n try {\n const result = fn.apply(this, args);\n\n if (isPromise(result)) {\n result\n .then((value) => {\n if (options.attributesSuccess) {\n span.setAttributes(\n options.attributesSuccess(\n value as ReturnType<F> extends PromiseLike<infer U>\n ? U\n : ReturnType<F>,\n ),\n );\n }\n\n spanContext.getStore()?.forEach((value, key) => {\n span.setAttribute(key, value);\n });\n\n span.setStatus({ code: 1 }); // 1 = Ok\n span.end();\n })\n .catch((error) => {\n if (options.attributesError) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument -- k\n span.setAttributes(options.attributesError(error));\n }\n\n span.setStatus({\n code: 2, // 2 = Error\n message: error instanceof Error ? error.message : undefined,\n });\n\n spanContext.getStore()?.forEach((value, key) => {\n span.setAttribute(key, value);\n });\n\n span.end();\n });\n } else {\n if (options.attributesSuccess) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument -- k\n span.setAttributes(options.attributesSuccess(result));\n }\n\n spanContext.getStore()?.forEach((value, key) => {\n span.setAttribute(key, value);\n });\n\n span.setStatus({ code: 1 }); // 1 = Ok\n span.end();\n }\n\n return result as unknown;\n } catch (error: any) {\n if (options.attributesError) {\n span.setAttributes(options.attributesError(error as Error));\n }\n\n span.setStatus({\n code: 2, // 2 = Error\n message: error instanceof Error ? error.message : undefined,\n });\n\n spanContext.getStore()?.forEach((value, key) => {\n span.setAttribute(key, value);\n });\n\n span.end();\n\n throw error;\n }\n }),\n );\n };\n\n return traced as unknown as F;\n}\n/* eslint-enable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any -- k */\n","import { jwtDecrypt, base64url, EncryptJWT } from 'jose';\n\nexport async function encryptJWT<T extends object = Record<string, unknown>>(\n payload: T,\n expirationTime: string,\n secret: string,\n): Promise<string> {\n return new EncryptJWT(payload as Record<string, unknown>)\n .setExpirationTime(expirationTime)\n .setProtectedHeader({ alg: 'dir', enc: 'A256GCM' })\n .encrypt(base64url.decode(secret));\n}\n\nexport async function decryptJWT<\n T extends string | object = Record<string, unknown>,\n>(\n cookie: string,\n verify: undefined | null | ((payload: T) => boolean),\n secret: string,\n): Promise<T | undefined> {\n if (typeof cookie !== 'string') return;\n\n try {\n const { payload } = await jwtDecrypt(cookie, base64url.decode(secret));\n const decoded = payload as T;\n\n if (!verify || verify(decoded)) {\n // @ts-expect-error jwt field\n delete decoded.iat;\n // @ts-expect-error jwt field\n delete decoded.exp;\n return decoded;\n }\n } catch {\n // Do nothing\n }\n}\n\n/**\n * Function to encrypt overrides, values, definitions, and API data.\n */\nexport async function encrypt<T extends object>(\n value: T,\n secret: string | undefined = process?.env?.FLAGS_SECRET,\n): Promise<string> {\n if (!secret) throw new Error('Missing FLAGS_SECRET');\n // Encapsule the data within the `c` (content) property to avoid conflicts\n // with other JWT properties like `iat` and `exp`.\n return encryptJWT({ c: value }, '1y', secret);\n}\n\n/**\n * Function to decrypt overrides, values, definitions, and API data.\n */\nexport async function decrypt<T extends object>(\n encryptedData: string,\n secret: string | undefined = process?.env?.FLAGS_SECRET,\n): Promise<T | undefined> {\n if (!secret) throw new Error('Missing FLAGS_SECRET');\n const content = await decryptJWT<{ c: T }>(encryptedData, null, secret);\n return content?.c;\n}\n","import { decrypt } from './crypto';\nimport { trace } from './tracing';\n\n/**\n * This function lets you verify whether a request to your application's .well-known/vercel/flags endpoint was made by the toolbar.\n * You can use verifyAccess to keep this endpoint private, to avoid public access of your feature flag definitions through that endpoint.\n *\n * @example Using verifyAccess in .well-known/vercel/flags to verify access and respond with unencrypted data.\n * ```\n * import { type NextRequest, NextResponse } from \"next/server\";\n * import { verifyAccess } from \"flags\";\n *\n * export async function GET(request: NextRequest) {\n * const access = await verifyAccess(request.headers.get(\"Authorization\"));\n * if (!access) return NextResponse.json(null, { status: 401 });\n *\n * return NextResponse.json({ definitions: {} })\n * }\n * ```\n * @param authHeader the Authorization header to check\n * @param secret the FLAGS_SECRET\n * @returns True when the authorization header was valid\n */\nexport const verifyAccess = trace(\n async function verifyAccess(\n // App Router returns null when a header is not defined\n // Pages Router returns undefined when a header is not defined\n // We support both so the API is slim in both cases\n authHeader: string | null | undefined,\n secret: string | undefined = process?.env?.FLAGS_SECRET,\n ) {\n if (!authHeader) return false;\n if (!secret)\n throw new Error(\n 'flags: verifyAccess was called without a secret. Please set FLAGS_SECRET environment variable.',\n );\n\n const data = await decrypt<{}>(\n authHeader?.replace(/^Bearer /i, ''),\n secret,\n );\n return data !== undefined;\n },\n {\n isVerboseTrace: false,\n name: 'verifyAccess',\n },\n);\n","import { version } from '../../package.json';\n\n/**\n * This function lets you report the value of a resolved flag, which will make it available when viewing Monitoring, Logs, Analytics and Speed Insights on Vercel.\n * It's important to note that this only has effects when running on Vercel in a preview or production environments, but not during local development.\n *\n * @example Using `reportValue` to report a flag value.\n * ```\n * import { type NextRequest, NextResponse } from \"next/server\";\n * import { reportValue } from 'flags';\n *\n * export async function GET(request: NextRequest) {\n * reportValue('my-flag', true);\n * return NextResponse.json({});\n * }\n * ```\n *\n * @param key the name of the flag\n * @param value the resolved value of the flag\n */\nexport function reportValue(key: string, value: unknown) {\n const symbol = Symbol.for('@vercel/request-context');\n const ctx = Reflect.get(globalThis, symbol)?.get();\n ctx?.flags?.reportValue(key, value, {\n sdkVersion: version,\n });\n}\n\n/**\n * Only used interally for now.\n */\nexport function internalReportValue(\n key: string,\n value: unknown,\n data: {\n originProjectId?: string;\n originProvider?: 'vercel';\n reason?: 'override';\n },\n) {\n const symbol = Symbol.for('@vercel/request-context');\n const ctx = Reflect.get(globalThis, symbol)?.get();\n ctx?.flags?.reportValue(key, value, {\n sdkVersion: version,\n ...data,\n });\n}\n","// copied from Next.js, and reduced\n// https://github.com/vercel/next.js/tree/canary/packages/next/src/server/web/spec-extension\nexport class ReflectAdapter {\n static get<T extends object>(\n target: T,\n prop: string | symbol,\n receiver: unknown,\n ): any {\n const value = Reflect.get(target, prop, receiver);\n if (typeof value === 'function') {\n return value.bind(target);\n }\n\n return value;\n }\n\n static set<T extends object>(\n target: T,\n prop: string | symbol,\n value: any,\n receiver: any,\n ): boolean {\n return Reflect.set(target, prop, value, receiver);\n }\n\n static has<T extends object>(target: T, prop: string | symbol): boolean {\n return Reflect.has(target, prop);\n }\n\n static deleteProperty<T extends object>(\n target: T,\n prop: string | symbol,\n ): boolean {\n return Reflect.deleteProperty(target, prop);\n }\n}\n","// copied from Next.js, and reduced\n// https://github.com/vercel/next.js/tree/canary/packages/next/src/server/web/spec-extension\nimport type { IncomingHttpHeaders } from 'http';\n\nimport { ReflectAdapter } from './reflect';\n\n/**\n * @internal\n */\nclass ReadonlyHeadersError extends Error {\n constructor() {\n super(\n 'Headers cannot be modified. Read more: https://nextjs.org/docs/app/api-reference/functions/headers',\n );\n }\n\n public static callable() {\n throw new ReadonlyHeadersError();\n }\n}\n\nexport type ReadonlyHeaders = Headers & {\n /** @deprecated Method unavailable on `ReadonlyHeaders`. Read more: https://nextjs.org/docs/app/api-reference/functions/headers */\n append(...args: any[]): void;\n /** @deprecated Method unavailable on `ReadonlyHeaders`. Read more: https://nextjs.org/docs/app/api-reference/functions/headers */\n set(...args: any[]): void;\n /** @deprecated Method unavailable on `ReadonlyHeaders`. Read more: https://nextjs.org/docs/app/api-reference/functions/headers */\n delete(...args: any[]): void;\n};\nexport class HeadersAdapter extends Headers {\n private readonly headers: IncomingHttpHeaders;\n\n constructor(headers: IncomingHttpHeaders) {\n // We've already overridden the methods that would be called, so we're just\n // calling the super constructor to ensure that the instanceof check works.\n super();\n\n this.headers = new Proxy(headers, {\n get(target, prop, receiver) {\n // Because this is just an object, we expect that all \"get\" operations\n // are for properties. If it's a \"get\" for a symbol, we'll just return\n // the symbol.\n if (typeof prop === 'symbol') {\n return ReflectAdapter.get(target, prop, receiver);\n }\n\n const lowercased = prop.toLowerCase();\n\n // Let's find the original casing of the key. This assumes that there is\n // no mixed case keys (e.g. \"Content-Type\" and \"content-type\") in the\n // headers object.\n const original = Object.keys(headers).find(\n (o) => o.toLowerCase() === lowercased,\n );\n\n // If the original casing doesn't exist, return undefined.\n if (typeof original === 'undefined') return;\n\n // If the original casing exists, return the value.\n return ReflectAdapter.get(target, original, receiver);\n },\n set(target, prop, value, receiver) {\n if (typeof prop === 'symbol') {\n return ReflectAdapter.set(target, prop, value, receiver);\n }\n\n const lowercased = prop.toLowerCase();\n\n // Let's find the original casing of the key. This assumes that there is\n // no mixed case keys (e.g. \"Content-Type\" and \"content-type\") in the\n // headers object.\n const original = Object.keys(headers).find(\n (o) => o.toLowerCase() === lowercased,\n );\n\n // If the original casing doesn't exist, use the prop as the key.\n return ReflectAdapter.set(target, original ?? prop, value, receiver);\n },\n has(target, prop) {\n if (typeof prop === 'symbol') return ReflectAdapter.has(target, prop);\n\n const lowercased = prop.toLowerCase();\n\n // Let's find the original casing of the key. This assumes that there is\n // no mixed case keys (e.g. \"Content-Type\" and \"content-type\") in the\n // headers object.\n const original = Object.keys(headers).find(\n (o) => o.toLowerCase() === lowercased,\n );\n\n // If the original casing doesn't exist, return false.\n if (typeof original === 'undefined') return false;\n\n // If the original casing exists, return true.\n return ReflectAdapter.has(target, original);\n },\n deleteProperty(target, prop) {\n if (typeof prop === 'symbol')\n return ReflectAdapter.deleteProperty(target, prop);\n\n const lowercased = prop.toLowerCase();\n\n // Let's find the original casing of the key. This assumes that there is\n // no mixed case keys (e.g. \"Content-Type\" and \"content-type\") in the\n // headers object.\n const original = Object.keys(headers).find(\n (o) => o.toLowerCase() === lowercased,\n );\n\n // If the original casing doesn't exist, return true.\n if (typeof original === 'undefined') return true;\n\n // If the original casing exists, delete the property.\n return ReflectAdapter.deleteProperty(target, original);\n },\n });\n }\n\n /**\n * Seals a Headers instance to prevent modification by throwing an error when\n * any mutating method is called.\n */\n public static seal(headers: Headers): ReadonlyHeaders {\n return new Proxy<ReadonlyHeaders>(headers, {\n get(target, prop, receiver) {\n switch (prop) {\n case 'append':\n case 'delete':\n case 'set':\n return ReadonlyHeadersError.callable;\n default:\n return ReflectAdapter.get(target, prop, receiver);\n }\n },\n });\n }\n\n /**\n * Merges a header value into a string. This stores multiple values as an\n * array, so we need to merge them into a string.\n *\n * @param value a header value\n * @returns a merged header value (a string)\n */\n private merge(value: string | string[]): string {\n if (Array.isArray(value)) return value.join(', ');\n\n return value;\n }\n\n /**\n * Creates a Headers instance from a plain object or a Headers instance.\n *\n * @param headers a plain object or a Headers instance\n * @returns a headers instance\n */\n public static from(headers: IncomingHttpHeaders | Headers): Headers {\n if (headers instanceof Headers) return headers;\n\n return new HeadersAdapter(headers);\n }\n\n public append(name: string, value: string): void {\n const existing = this.headers[name];\n if (typeof existing === 'string') {\n this.headers[name] = [existing, value];\n } else if (Array.isArray(existing)) {\n existing.push(value);\n } else {\n this.headers[name] = value;\n }\n }\n\n public delete(name: string): void {\n delete this.headers[name];\n }\n\n public get(name: string): string | null {\n const value = this.headers[name];\n if (typeof value !== 'undefined') return this.merge(value);\n\n return null;\n }\n\n public has(name: string): boolean {\n return typeof this.headers[name] !== 'undefined';\n }\n\n public set(name: string, value: string): void {\n this.headers[name] = value;\n }\n\n public forEach(\n callbackfn: (value: string, name: string, parent: Headers) => void,\n thisArg?: any,\n ): void {\n for (const [name, value] of this.entries()) {\n callbackfn.call(thisArg, value, name, this);\n }\n }\n\n public *entries(): HeadersIterator<[string, string]> {\n for (const key of Object.keys(this.headers)) {\n const name = key.toLowerCase();\n // We assert here that this is a string because we got it from the\n // Object.keys() call above.\n const value = this.get(name) as string;\n\n yield [name, value] as [string, string];\n }\n }\n\n public *keys(): HeadersIterator<string> {\n for (const key of Object.keys(this.headers)) {\n const name = key.toLowerCase();\n yield name;\n }\n }\n\n public *values(): HeadersIterator<string> {\n for (const key of Object.keys(this.headers)) {\n // We assert here that this is a string because we got it from the\n // Object.keys() call above.\n const value = this.get(key) as string;\n\n yield value;\n }\n }\n\n public [Symbol.iterator](): HeadersIterator<[string, string]> {\n return this.entries();\n }\n}\n","// copied from Next.js, and reduced\n// https://github.com/vercel/next.js/tree/canary/packages/next/src/server/web/spec-extension\nimport { RequestCookies } from '../cookies';\nimport { ResponseCookies } from '../cookies';\nimport { ReflectAdapter } from './reflect';\n\n/**\n * @internal\n */\nexport class ReadonlyRequestCookiesError extends Error {\n constructor() {\n super(\n 'Cookies can only be modified in a Server Action or Route Handler. Read more: https://nextjs.org/docs/app/api-reference/functions/cookies#options',\n );\n }\n\n public static callable() {\n throw new ReadonlyRequestCookiesError();\n }\n}\n\n// We use this to type some APIs but we don't construct instances directly\nexport type { ResponseCookies };\n\n// The `cookies()` API is a mix of request and response cookies. For `.get()` methods,\n// we want to return the request cookie if it exists. For mutative methods like `.set()`,\n// we want to return the response cookie.\nexport type ReadonlyRequestCookies = Omit<\n RequestCookies,\n 'set' | 'clear' | 'delete'\n> &\n Pick<ResponseCookies, 'set' | 'delete'>;\n\nexport class RequestCookiesAdapter {\n public static seal(cookies: RequestCookies): ReadonlyRequestCookies {\n return new Proxy(cookies as any, {\n get(target, prop, receiver) {\n switch (prop) {\n case 'clear':\n case 'delete':\n case 'set':\n return ReadonlyRequestCookiesError.callable;\n default:\n return ReflectAdapter.get(target, prop, receiver);\n }\n },\n });\n }\n}\n\nconst SYMBOL_MODIFY_COOKIE_VALUES = Symbol.for('next.mutated.cookies');\n\nexport function getModifiedCookieValues(\n cookies: ResponseCookies,\n): ResponseCookie[] {\n const modified: ResponseCookie[] | undefined = (cookies as unknown as any)[\n SYMBOL_MODIFY_COOKIE_VALUES\n ];\n if (!modified || !Array.isArray(modified) || modified.length === 0) {\n return [];\n }\n\n return modified;\n}\n\ntype SetCookieArgs =\n | [key: string, value: string, cookie?: Partial<ResponseCookie>]\n | [options: ResponseCookie];\n\nexport function appendMutableCookies(\n headers: Headers,\n mutableCookies: ResponseCookies,\n): boolean {\n const modifiedCookieValues = getModifiedCookieValues(mutableCookies);\n if (modifiedCookieValues.length === 0) {\n return false;\n }\n\n // Return a new response that extends the response with\n // the modified cookies as fallbacks. `res` cookies\n // will still take precedence.\n const resCookies = new ResponseCookies(headers);\n const returnedCookies = resCookies.getAll();\n\n // Set the modified cookies as fallbacks.\n for (const cookie of modifiedCookieValues) {\n resCookies.set(cookie);\n }\n\n // Set the original cookies as the final values.\n for (const cookie of returnedCookies) {\n resCookies.set(cookie);\n }\n\n return true;\n}\n\ntype ResponseCookie = NonNullable<\n ReturnType<InstanceType<typeof ResponseCookies>['get']>\n>;\n","import { ProviderData } from '../types';\n\nexport async function mergeProviderData(\n itemsPromises: (Promise<ProviderData> | ProviderData)[],\n): Promise<ProviderData> {\n const items = await Promise.all(\n itemsPromises.map((p) => Promise.resolve(p).catch(() => null)),\n );\n\n return items\n .filter((item): item is ProviderData => Boolean(item))\n .reduce<ProviderData>(\n (acc, item) => {\n Object.entries(item.definitions).forEach(([key, definition]) => {\n if (!acc.definitions[key]) acc.definitions[key] = {};\n Object.assign(acc.definitions[key], definition);\n });\n\n if (Array.isArray(item.hints)) acc.hints.push(...item.hints);\n\n return acc;\n },\n { definitions: {}, hints: [] },\n );\n}\n"],"mappings":";AACE,WAAQ;AACR,cAAW;;;ACKb,SAAS,yBAAyB;AAIlC,IAAM,yBAAyB,OAAO,IAAI,oBAAoB;AAMvD,SAAS,kBAAkB,QAA8B;AAC9D,UAAQ,IAAI,YAAY,wBAAwB,MAAM;AACxD;AAEA,SAAS,YAAgC;AACvC,QAAM,gBAAgB,QAAQ,IAAI,YAAY,sBAAsB;AAGpE,SAAO,eAAe,UAAU,MAAS,OAAO;AAClD;AAEA,SAAS,UAAa,GAA6B;AACjD,SACE,MAAM,QACN,OAAO,MAAM,YACb,UAAU,KACV,OAAO,EAAE,SAAS;AAEtB;AAEA,IAAM,cAAc,IAAI,kBAA+C;AAEhE,SAAS,iBAAiBA,OAAc,OAAuB;AACpE,cAAY,SAAS,GAAG,IAAIA,O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,IAAI,CAAC;AACnD,eAAO,OAAO,IAAI,YAAY,GAAG,GAAG,UAAU;AAAA,MAChD,CAAC;AAED,UAAI,MAAM,QAAQ,KAAK,KAAK;AAAG,YAAI,MAAM,KAAK,GAAG,KAAK,KAAK;AAE3D,aAAO;AAAA,IACT;AAAA,IACA,EAAE,aAAa,CAAC,GAAG,OAAO,CAAC,EAAE;AAAA,EAC/B;AACJ;","names":["name","value","verifyAccess","name"]}
|
|
1
|
+
{"version":3,"sources":["../package.json","../src/lib/tracing.ts","../src/lib/crypto.ts","../src/lib/verify-access.ts","../src/lib/report-value.ts","../src/spec-extension/adapters/reflect.ts","../src/spec-extension/adapters/headers.ts","../src/spec-extension/adapters/request-cookies.ts","../src/lib/merge-provider-data.ts"],"sourcesContent":["{\n \"name\": \"flags\",\n \"version\": \"3.1.2\",\n \"description\": \"Flags SDK by Vercel - The feature flags toolkit for Next.js and SvelteKit\",\n \"keywords\": [\n \"feature flags\",\n \"Next.js\",\n \"react\",\n \"toolbar\",\n \"overrides\",\n \"SvelteKit\"\n ],\n \"homepage\": \"https://flags-sdk.dev\",\n \"bugs\": {\n \"url\": \"https://github.com/vercel/flags/issues\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/vercel/flags.git\"\n },\n \"license\": \"MIT\",\n \"sideEffects\": false,\n \"type\": \"module\",\n \"exports\": {\n \".\": {\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\"\n },\n \"./next\": {\n \"import\": \"./dist/next.js\",\n \"require\": \"./dist/next.cjs\"\n },\n \"./analytics\": {\n \"import\": \"./dist/analytics.js\",\n \"require\": \"./dist/analytics.cjs\"\n },\n \"./react\": {\n \"import\": \"./dist/react.js\",\n \"require\": \"./dist/react.cjs\"\n },\n \"./sveltekit\": {\n \"import\": \"./dist/sveltekit.js\",\n \"require\": \"./dist/sveltekit.cjs\"\n }\n },\n \"typesVersions\": {\n \"*\": {\n \"*\": [\n \"dist/*.d.ts\",\n \"dist/*.d.cts\"\n ],\n \"next\": [\n \"dist/next.d.ts\",\n \"dist/next.d.cts\"\n ],\n \"react\": [\n \"dist/react.d.ts\",\n \"dist/react.d.cts\"\n ],\n \"sveltekit\": [\n \"dist/sveltekit.d.ts\",\n \"dist/sveltekit.d.cts\"\n ]\n }\n },\n \"files\": [\n \"dist\",\n \"CHANGELOG.md\"\n ],\n \"scripts\": {\n \"attw\": \"attw --pack .\",\n \"build\": \"tsup\",\n \"dev\": \"tsup --watch --clean=false\",\n \"eslint\": \"eslint-runner\",\n \"eslint:fix\": \"eslint-runner --fix\",\n \"test\": \"vitest --run\",\n \"test:watch\": \"vitest\",\n \"type-check\": \"tsc --noEmit\"\n },\n \"dependencies\": {\n \"@edge-runtime/cookies\": \"^5.0.2\",\n \"jose\": \"^5.2.1\"\n },\n \"devDependencies\": {\n \"@arethetypeswrong/cli\": \"0.17.3\",\n \"@types/node\": \"20.11.17\",\n \"@types/react\": \"18.2.55\",\n \"@vitejs/plugin-react\": \"4.2.1\",\n \"eslint-config-custom\": \"workspace:*\",\n \"msw\": \"2.6.4\",\n \"next\": \"15.1.4\",\n \"react\": \"canary\",\n \"tsconfig\": \"workspace:*\",\n \"tsup\": \"8.0.1\",\n \"typescript\": \"5.6.3\",\n \"vite\": \"5.1.1\",\n \"vitest\": \"1.4.0\"\n },\n \"peerDependencies\": {\n \"@opentelemetry/api\": \"^1.7.0\",\n \"@sveltejs/kit\": \"*\",\n \"next\": \"*\",\n \"react\": \"*\",\n \"react-dom\": \"*\"\n },\n \"peerDependenciesMeta\": {\n \"@opentelemetry/api\": {\n \"optional\": true\n },\n \"@sveltejs/kit\": {\n \"optional\": true\n },\n \"next\": {\n \"optional\": true\n },\n \"react\": {\n \"optional\": true\n },\n \"react-dom\": {\n \"optional\": true\n }\n },\n \"publishConfig\": {\n \"access\": \"public\"\n }\n}\n","import type {\n Tracer,\n Attributes,\n TracerProvider,\n AttributeValue,\n} from '@opentelemetry/api';\nimport { name as pkgName, version } from '../../package.json';\nimport { AsyncLocalStorage } from 'async_hooks';\n\n// Use a symbol to avoid having global variable that is scoped to this file,\n// as it can lead to issues with cjs and mjs being used at the same time.\nconst vercelFlagsTraceSymbol = Symbol.for('flags:global-trace');\n\n/**\n * Allows setting the `@opentelemetry/api` tracer provider to generate traces\n * for `flags` operations.\n */\nexport function setTracerProvider(tracer: TracerProvider): void {\n Reflect.set(globalThis, vercelFlagsTraceSymbol, tracer);\n}\n\nfunction getTracer(): Tracer | undefined {\n const maybeTraceApi = Reflect.get(globalThis, vercelFlagsTraceSymbol) as\n | undefined\n | TracerProvider;\n return maybeTraceApi?.getTracer(pkgName, version);\n}\n\nfunction isPromise<T>(p: unknown): p is Promise<T> {\n return (\n p !== null &&\n typeof p === 'object' &&\n 'then' in p &&\n typeof p.then === 'function'\n );\n}\n\nconst spanContext = new AsyncLocalStorage<Map<string, AttributeValue>>();\n\nexport function setSpanAttribute(name: string, value: AttributeValue) {\n spanContext.getStore()?.set(name, value);\n}\n\n/* eslint-disable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any -- bc */\nexport function trace<F extends (...args: any) => any>(\n fn: F,\n options: {\n name: string;\n /** Defaults to `true`. If set to `false`, it'll trace regardless of `VERCEL_FLAGS_TRACE_VERBOSE`. */\n isVerboseTrace?: boolean;\n attributes?: Attributes;\n attributesSuccess?: (\n result: ReturnType<F> extends PromiseLike<infer U> ? U : ReturnType<F>,\n ) => Attributes;\n attributesError?: (error: Error) => Attributes;\n } = {\n name: fn.name,\n },\n): F {\n const traced = function (this: unknown, ...args: unknown[]): unknown {\n const tracer = getTracer();\n if (!tracer) return fn.apply(this, args);\n\n const shouldTrace =\n process.env.VERCEL_FLAGS_TRACE_VERBOSE === 'true' ||\n options.isVerboseTrace === false;\n if (!shouldTrace) return fn.apply(this, args);\n\n return spanContext.run(new Map(), () =>\n tracer.startActiveSpan(options.name, (span) => {\n if (options.attributes) span.setAttributes(options.attributes);\n\n try {\n const result = fn.apply(this, args);\n\n if (isPromise(result)) {\n result\n .then((value) => {\n if (options.attributesSuccess) {\n span.setAttributes(\n options.attributesSuccess(\n value as ReturnType<F> extends PromiseLike<infer U>\n ? U\n : ReturnType<F>,\n ),\n );\n }\n\n spanContext.getStore()?.forEach((value, key) => {\n span.setAttribute(key, value);\n });\n\n span.setStatus({ code: 1 }); // 1 = Ok\n span.end();\n })\n .catch((error) => {\n if (options.attributesError) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument -- k\n span.setAttributes(options.attributesError(error));\n }\n\n span.setStatus({\n code: 2, // 2 = Error\n message: error instanceof Error ? error.message : undefined,\n });\n\n spanContext.getStore()?.forEach((value, key) => {\n span.setAttribute(key, value);\n });\n\n span.end();\n });\n } else {\n if (options.attributesSuccess) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument -- k\n span.setAttributes(options.attributesSuccess(result));\n }\n\n spanContext.getStore()?.forEach((value, key) => {\n span.setAttribute(key, value);\n });\n\n span.setStatus({ code: 1 }); // 1 = Ok\n span.end();\n }\n\n return result as unknown;\n } catch (error: any) {\n if (options.attributesError) {\n span.setAttributes(options.attributesError(error as Error));\n }\n\n span.setStatus({\n code: 2, // 2 = Error\n message: error instanceof Error ? error.message : undefined,\n });\n\n spanContext.getStore()?.forEach((value, key) => {\n span.setAttribute(key, value);\n });\n\n span.end();\n\n throw error;\n }\n }),\n );\n };\n\n return traced as unknown as F;\n}\n/* eslint-enable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any -- k */\n","import { jwtDecrypt, base64url, EncryptJWT } from 'jose';\n\nexport async function encryptJWT<T extends object = Record<string, unknown>>(\n payload: T,\n expirationTime: string,\n secret: string,\n): Promise<string> {\n return new EncryptJWT(payload as Record<string, unknown>)\n .setExpirationTime(expirationTime)\n .setProtectedHeader({ alg: 'dir', enc: 'A256GCM' })\n .encrypt(base64url.decode(secret));\n}\n\nexport async function decryptJWT<\n T extends string | object = Record<string, unknown>,\n>(\n cookie: string,\n verify: undefined | null | ((payload: T) => boolean),\n secret: string,\n): Promise<T | undefined> {\n if (typeof cookie !== 'string') return;\n\n try {\n const { payload } = await jwtDecrypt(cookie, base64url.decode(secret));\n const decoded = payload as T;\n\n if (!verify || verify(decoded)) {\n // @ts-expect-error jwt field\n delete decoded.iat;\n // @ts-expect-error jwt field\n delete decoded.exp;\n return decoded;\n }\n } catch {\n // Do nothing\n }\n}\n\n/**\n * Function to encrypt overrides, values, definitions, and API data.\n */\nexport async function encrypt<T extends object>(\n value: T,\n secret: string | undefined = process?.env?.FLAGS_SECRET,\n): Promise<string> {\n if (!secret) throw new Error('Missing FLAGS_SECRET');\n // Encapsule the data within the `c` (content) property to avoid conflicts\n // with other JWT properties like `iat` and `exp`.\n return encryptJWT({ c: value }, '1y', secret);\n}\n\n/**\n * Function to decrypt overrides, values, definitions, and API data.\n */\nexport async function decrypt<T extends object>(\n encryptedData: string,\n secret: string | undefined = process?.env?.FLAGS_SECRET,\n): Promise<T | undefined> {\n if (!secret) throw new Error('Missing FLAGS_SECRET');\n const content = await decryptJWT<{ c: T }>(encryptedData, null, secret);\n return content?.c;\n}\n","import { decrypt } from './crypto';\nimport { trace } from './tracing';\n\n/**\n * This function lets you verify whether a request to your application's .well-known/vercel/flags endpoint was made by the toolbar.\n * You can use verifyAccess to keep this endpoint private, to avoid public access of your feature flag definitions through that endpoint.\n *\n * @example Using verifyAccess in .well-known/vercel/flags to verify access and respond with unencrypted data.\n * ```\n * import { type NextRequest, NextResponse } from \"next/server\";\n * import { verifyAccess } from \"flags\";\n *\n * export async function GET(request: NextRequest) {\n * const access = await verifyAccess(request.headers.get(\"Authorization\"));\n * if (!access) return NextResponse.json(null, { status: 401 });\n *\n * return NextResponse.json({ definitions: {} })\n * }\n * ```\n * @param authHeader the Authorization header to check\n * @param secret the FLAGS_SECRET\n * @returns True when the authorization header was valid\n */\nexport const verifyAccess = trace(\n async function verifyAccess(\n // App Router returns null when a header is not defined\n // Pages Router returns undefined when a header is not defined\n // We support both so the API is slim in both cases\n authHeader: string | null | undefined,\n secret: string | undefined = process?.env?.FLAGS_SECRET,\n ) {\n if (!authHeader) return false;\n if (!secret)\n throw new Error(\n 'flags: verifyAccess was called without a secret. Please set FLAGS_SECRET environment variable.',\n );\n\n const data = await decrypt<{}>(\n authHeader?.replace(/^Bearer /i, ''),\n secret,\n );\n return data !== undefined;\n },\n {\n isVerboseTrace: false,\n name: 'verifyAccess',\n },\n);\n","import { version } from '../../package.json';\n\n/**\n * This function lets you report the value of a resolved flag, which will make it available when viewing Monitoring, Logs, Analytics and Speed Insights on Vercel.\n * It's important to note that this only has effects when running on Vercel in a preview or production environments, but not during local development.\n *\n * @example Using `reportValue` to report a flag value.\n * ```\n * import { type NextRequest, NextResponse } from \"next/server\";\n * import { reportValue } from 'flags';\n *\n * export async function GET(request: NextRequest) {\n * reportValue('my-flag', true);\n * return NextResponse.json({});\n * }\n * ```\n *\n * @param key the name of the flag\n * @param value the resolved value of the flag\n */\nexport function reportValue(key: string, value: unknown) {\n const symbol = Symbol.for('@vercel/request-context');\n const ctx = Reflect.get(globalThis, symbol)?.get();\n ctx?.flags?.reportValue(key, value, {\n sdkVersion: version,\n });\n}\n\n/**\n * Only used interally for now.\n */\nexport function internalReportValue(\n key: string,\n value: unknown,\n data: {\n originProjectId?: string;\n originProvider?: 'vercel';\n reason?: 'override';\n },\n) {\n const symbol = Symbol.for('@vercel/request-context');\n const ctx = Reflect.get(globalThis, symbol)?.get();\n ctx?.flags?.reportValue(key, value, {\n sdkVersion: version,\n ...data,\n });\n}\n","// copied from Next.js, and reduced\n// https://github.com/vercel/next.js/tree/canary/packages/next/src/server/web/spec-extension\nexport class ReflectAdapter {\n static get<T extends object>(\n target: T,\n prop: string | symbol,\n receiver: unknown,\n ): any {\n const value = Reflect.get(target, prop, receiver);\n if (typeof value === 'function') {\n return value.bind(target);\n }\n\n return value;\n }\n\n static set<T extends object>(\n target: T,\n prop: string | symbol,\n value: any,\n receiver: any,\n ): boolean {\n return Reflect.set(target, prop, value, receiver);\n }\n\n static has<T extends object>(target: T, prop: string | symbol): boolean {\n return Reflect.has(target, prop);\n }\n\n static deleteProperty<T extends object>(\n target: T,\n prop: string | symbol,\n ): boolean {\n return Reflect.deleteProperty(target, prop);\n }\n}\n","// copied from Next.js, and reduced\n// https://github.com/vercel/next.js/tree/canary/packages/next/src/server/web/spec-extension\nimport type { IncomingHttpHeaders } from 'http';\n\nimport { ReflectAdapter } from './reflect';\n\n/**\n * @internal\n */\nclass ReadonlyHeadersError extends Error {\n constructor() {\n super(\n 'Headers cannot be modified. Read more: https://nextjs.org/docs/app/api-reference/functions/headers',\n );\n }\n\n public static callable() {\n throw new ReadonlyHeadersError();\n }\n}\n\nexport type ReadonlyHeaders = Headers & {\n /** @deprecated Method unavailable on `ReadonlyHeaders`. Read more: https://nextjs.org/docs/app/api-reference/functions/headers */\n append(...args: any[]): void;\n /** @deprecated Method unavailable on `ReadonlyHeaders`. Read more: https://nextjs.org/docs/app/api-reference/functions/headers */\n set(...args: any[]): void;\n /** @deprecated Method unavailable on `ReadonlyHeaders`. Read more: https://nextjs.org/docs/app/api-reference/functions/headers */\n delete(...args: any[]): void;\n};\nexport class HeadersAdapter extends Headers {\n private readonly headers: IncomingHttpHeaders;\n\n constructor(headers: IncomingHttpHeaders) {\n // We've already overridden the methods that would be called, so we're just\n // calling the super constructor to ensure that the instanceof check works.\n super();\n\n this.headers = new Proxy(headers, {\n get(target, prop, receiver) {\n // Because this is just an object, we expect that all \"get\" operations\n // are for properties. If it's a \"get\" for a symbol, we'll just return\n // the symbol.\n if (typeof prop === 'symbol') {\n return ReflectAdapter.get(target, prop, receiver);\n }\n\n const lowercased = prop.toLowerCase();\n\n // Let's find the original casing of the key. This assumes that there is\n // no mixed case keys (e.g. \"Content-Type\" and \"content-type\") in the\n // headers object.\n const original = Object.keys(headers).find(\n (o) => o.toLowerCase() === lowercased,\n );\n\n // If the original casing doesn't exist, return undefined.\n if (typeof original === 'undefined') return;\n\n // If the original casing exists, return the value.\n return ReflectAdapter.get(target, original, receiver);\n },\n set(target, prop, value, receiver) {\n if (typeof prop === 'symbol') {\n return ReflectAdapter.set(target, prop, value, receiver);\n }\n\n const lowercased = prop.toLowerCase();\n\n // Let's find the original casing of the key. This assumes that there is\n // no mixed case keys (e.g. \"Content-Type\" and \"content-type\") in the\n // headers object.\n const original = Object.keys(headers).find(\n (o) => o.toLowerCase() === lowercased,\n );\n\n // If the original casing doesn't exist, use the prop as the key.\n return ReflectAdapter.set(target, original ?? prop, value, receiver);\n },\n has(target, prop) {\n if (typeof prop === 'symbol') return ReflectAdapter.has(target, prop);\n\n const lowercased = prop.toLowerCase();\n\n // Let's find the original casing of the key. This assumes that there is\n // no mixed case keys (e.g. \"Content-Type\" and \"content-type\") in the\n // headers object.\n const original = Object.keys(headers).find(\n (o) => o.toLowerCase() === lowercased,\n );\n\n // If the original casing doesn't exist, return false.\n if (typeof original === 'undefined') return false;\n\n // If the original casing exists, return true.\n return ReflectAdapter.has(target, original);\n },\n deleteProperty(target, prop) {\n if (typeof prop === 'symbol')\n return ReflectAdapter.deleteProperty(target, prop);\n\n const lowercased = prop.toLowerCase();\n\n // Let's find the original casing of the key. This assumes that there is\n // no mixed case keys (e.g. \"Content-Type\" and \"content-type\") in the\n // headers object.\n const original = Object.keys(headers).find(\n (o) => o.toLowerCase() === lowercased,\n );\n\n // If the original casing doesn't exist, return true.\n if (typeof original === 'undefined') return true;\n\n // If the original casing exists, delete the property.\n return ReflectAdapter.deleteProperty(target, original);\n },\n });\n }\n\n /**\n * Seals a Headers instance to prevent modification by throwing an error when\n * any mutating method is called.\n */\n public static seal(headers: Headers): ReadonlyHeaders {\n return new Proxy<ReadonlyHeaders>(headers, {\n get(target, prop, receiver) {\n switch (prop) {\n case 'append':\n case 'delete':\n case 'set':\n return ReadonlyHeadersError.callable;\n default:\n return ReflectAdapter.get(target, prop, receiver);\n }\n },\n });\n }\n\n /**\n * Merges a header value into a string. This stores multiple values as an\n * array, so we need to merge them into a string.\n *\n * @param value a header value\n * @returns a merged header value (a string)\n */\n private merge(value: string | string[]): string {\n if (Array.isArray(value)) return value.join(', ');\n\n return value;\n }\n\n /**\n * Creates a Headers instance from a plain object or a Headers instance.\n *\n * @param headers a plain object or a Headers instance\n * @returns a headers instance\n */\n public static from(headers: IncomingHttpHeaders | Headers): Headers {\n if (headers instanceof Headers) return headers;\n\n return new HeadersAdapter(headers);\n }\n\n public append(name: string, value: string): void {\n const existing = this.headers[name];\n if (typeof existing === 'string') {\n this.headers[name] = [existing, value];\n } else if (Array.isArray(existing)) {\n existing.push(value);\n } else {\n this.headers[name] = value;\n }\n }\n\n public delete(name: string): void {\n delete this.headers[name];\n }\n\n public get(name: string): string | null {\n const value = this.headers[name];\n if (typeof value !== 'undefined') return this.merge(value);\n\n return null;\n }\n\n public has(name: string): boolean {\n return typeof this.headers[name] !== 'undefined';\n }\n\n public set(name: string, value: string): void {\n this.headers[name] = value;\n }\n\n public forEach(\n callbackfn: (value: string, name: string, parent: Headers) => void,\n thisArg?: any,\n ): void {\n for (const [name, value] of this.entries()) {\n callbackfn.call(thisArg, value, name, this);\n }\n }\n\n public *entries(): HeadersIterator<[string, string]> {\n for (const key of Object.keys(this.headers)) {\n const name = key.toLowerCase();\n // We assert here that this is a string because we got it from the\n // Object.keys() call above.\n const value = this.get(name) as string;\n\n yield [name, value] as [string, string];\n }\n }\n\n public *keys(): HeadersIterator<string> {\n for (const key of Object.keys(this.headers)) {\n const name = key.toLowerCase();\n yield name;\n }\n }\n\n public *values(): HeadersIterator<string> {\n for (const key of Object.keys(this.headers)) {\n // We assert here that this is a string because we got it from the\n // Object.keys() call above.\n const value = this.get(key) as string;\n\n yield value;\n }\n }\n\n public [Symbol.iterator](): HeadersIterator<[string, string]> {\n return this.entries();\n }\n}\n","// copied from Next.js, and reduced\n// https://github.com/vercel/next.js/tree/canary/packages/next/src/server/web/spec-extension\nimport { RequestCookies } from '../cookies';\nimport { ResponseCookies } from '../cookies';\nimport { ReflectAdapter } from './reflect';\n\n/**\n * @internal\n */\nexport class ReadonlyRequestCookiesError extends Error {\n constructor() {\n super(\n 'Cookies can only be modified in a Server Action or Route Handler. Read more: https://nextjs.org/docs/app/api-reference/functions/cookies#options',\n );\n }\n\n public static callable() {\n throw new ReadonlyRequestCookiesError();\n }\n}\n\n// We use this to type some APIs but we don't construct instances directly\nexport type { ResponseCookies };\n\n// The `cookies()` API is a mix of request and response cookies. For `.get()` methods,\n// we want to return the request cookie if it exists. For mutative methods like `.set()`,\n// we want to return the response cookie.\nexport type ReadonlyRequestCookies = Omit<\n RequestCookies,\n 'set' | 'clear' | 'delete'\n> &\n Pick<ResponseCookies, 'set' | 'delete'>;\n\nexport class RequestCookiesAdapter {\n public static seal(cookies: RequestCookies): ReadonlyRequestCookies {\n return new Proxy(cookies as any, {\n get(target, prop, receiver) {\n switch (prop) {\n case 'clear':\n case 'delete':\n case 'set':\n return ReadonlyRequestCookiesError.callable;\n default:\n return ReflectAdapter.get(target, prop, receiver);\n }\n },\n });\n }\n}\n\nconst SYMBOL_MODIFY_COOKIE_VALUES = Symbol.for('next.mutated.cookies');\n\nexport function getModifiedCookieValues(\n cookies: ResponseCookies,\n): ResponseCookie[] {\n const modified: ResponseCookie[] | undefined = (cookies as unknown as any)[\n SYMBOL_MODIFY_COOKIE_VALUES\n ];\n if (!modified || !Array.isArray(modified) || modified.length === 0) {\n return [];\n }\n\n return modified;\n}\n\ntype SetCookieArgs =\n | [key: string, value: string, cookie?: Partial<ResponseCookie>]\n | [options: ResponseCookie];\n\nexport function appendMutableCookies(\n headers: Headers,\n mutableCookies: ResponseCookies,\n): boolean {\n const modifiedCookieValues = getModifiedCookieValues(mutableCookies);\n if (modifiedCookieValues.length === 0) {\n return false;\n }\n\n // Return a new response that extends the response with\n // the modified cookies as fallbacks. `res` cookies\n // will still take precedence.\n const resCookies = new ResponseCookies(headers);\n const returnedCookies = resCookies.getAll();\n\n // Set the modified cookies as fallbacks.\n for (const cookie of modifiedCookieValues) {\n resCookies.set(cookie);\n }\n\n // Set the original cookies as the final values.\n for (const cookie of returnedCookies) {\n resCookies.set(cookie);\n }\n\n return true;\n}\n\ntype ResponseCookie = NonNullable<\n ReturnType<InstanceType<typeof ResponseCookies>['get']>\n>;\n","import { ProviderData } from '../types';\n\nexport async function mergeProviderData(\n itemsPromises: (Promise<ProviderData> | ProviderData)[],\n): Promise<ProviderData> {\n const items = await Promise.all(\n itemsPromises.map((p) => Promise.resolve(p).catch(() => null)),\n );\n\n return items\n .filter((item): item is ProviderData => Boolean(item))\n .reduce<ProviderData>(\n (acc, item) => {\n Object.entries(item.definitions).forEach(([key, definition]) => {\n if (!acc.definitions[key]) acc.definitions[key] = {};\n Object.assign(acc.definitions[key], definition);\n });\n\n if (Array.isArray(item.hints)) acc.hints.push(...item.hints);\n\n return acc;\n },\n { definitions: {}, hints: [] },\n );\n}\n"],"mappings":";AACE,WAAQ;AACR,cAAW;;;ACKb,SAAS,yBAAyB;AAIlC,IAAM,yBAAyB,OAAO,IAAI,oBAAoB;AAMvD,SAAS,kBAAkB,QAA8B;AAC9D,UAAQ,IAAI,YAAY,wBAAwB,MAAM;AACxD;AAEA,SAAS,YAAgC;AACvC,QAAM,gBAAgB,QAAQ,IAAI,YAAY,sBAAsB;AAGpE,SAAO,eAAe,UAAU,MAAS,OAAO;AAClD;AAEA,SAAS,UAAa,GAA6B;AACjD,SACE,MAAM,QACN,OAAO,MAAM,YACb,UAAU,KACV,OAAO,EAAE,SAAS;AAEtB;AAEA,IAAM,cAAc,IAAI,kBAA+C;AAEhE,SAAS,iBAAiBA,OAAc,OAAuB;AACpE,cAAY,SAAS,GAAG,IAAIA,OAAM,KAAK;AACzC;AAGO,SAAS,MACd,IACA,UASI;AAAA,EACF,MAAM,GAAG;AACX,GACG;AACH,QAAM,SAAS,YAA4B,MAA0B;AACnE,UAAM,SAAS,UAAU;AACzB,QAAI,CAAC;AAAQ,aAAO,GAAG,MAAM,MAAM,IAAI;AAEvC,UAAM,cACJ,QAAQ,IAAI,+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O,CAAC,EAAE;AAAA,EAC/B;AACJ;","names":["name","value","verifyAccess","name"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__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 = "3.1.
|
|
3
|
+
var version = "3.1.2";
|
|
4
4
|
|
|
5
5
|
// src/lib/tracing.ts
|
|
6
6
|
var _async_hooks = require('async_hooks');
|
|
@@ -403,4 +403,4 @@ async function mergeProviderData(itemsPromises) {
|
|
|
403
403
|
|
|
404
404
|
|
|
405
405
|
exports.setTracerProvider = setTracerProvider; exports.setSpanAttribute = setSpanAttribute; exports.trace = trace; exports.encrypt = encrypt; exports.decrypt = decrypt; exports.verifyAccess = verifyAccess; exports.reportValue = reportValue; exports.internalReportValue = internalReportValue; exports.HeadersAdapter = HeadersAdapter; exports.RequestCookiesAdapter = RequestCookiesAdapter; exports.mergeProviderData = mergeProviderData;
|
|
406
|
-
//# sourceMappingURL=chunk-
|
|
406
|
+
//# sourceMappingURL=chunk-IGXYQW6R.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../package.json","../src/lib/tracing.ts","../src/lib/crypto.ts","../src/lib/verify-access.ts","../src/lib/report-value.ts","../src/spec-extension/adapters/reflect.ts","../src/spec-extension/adapters/headers.ts","../src/spec-extension/adapters/request-cookies.ts","../src/lib/merge-provider-data.ts"],"names":["name","value","verifyAccess"],"m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,QACpD;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH;AACF;AAEA,IAAM,8BAA8B,OAAO,IAAI,sBAAsB;;;AChDrE,eAAsB,kBACpB,eACuB;AACvB,QAAM,QAAQ,MAAM,QAAQ;AAAA,IAC1B,cAAc,IAAI,CAAC,MAAM,QAAQ,QAAQ,CAAC,EAAE,MAAM,MAAM,IAAI,CAAC;AAAA,EAC/D;AAEA,SAAO,MACJ,OAAO,CAAC,SAA+B,QAAQ,IAAI,CAAC,EACpD;AAAA,IACC,CAAC,KAAK,SAAS;AACb,aAAO,QAAQ,KAAK,WAAW,EAAE,QAAQ,CAAC,CAAC,KAAK,UAAU,MAAM;AAC9D,YAAI,CAAC,IAAI,YAAY,GAAG;AAAG,cAAI,YAAY,GAAG,IAAI,CAAC;AACnD,eAAO,OAAO,IAAI,YAAY,GAAG,GAAG,UAAU;AAAA,MAChD,CAAC;AAED,UAAI,MAAM,QAAQ,KAAK,KAAK;AAAG,YAAI,MAAM,KAAK,GAAG,KAAK,KAAK;AAE3D,aAAO;AAAA,IACT;AAAA,IACA,EAAE,aAAa,CAAC,GAAG,OAAO,CAAC,EAAE;AAAA,EAC/B;AACJ","sourcesContent":["{\n \"name\": \"flags\",\n \"version\": \"3.1.1\",\n \"description\": \"Flags SDK by Vercel - The feature flags toolkit for Next.js and SvelteKit\",\n \"keywords\": [\n \"feature flags\",\n \"Next.js\",\n \"react\",\n \"toolbar\",\n \"overrides\",\n \"SvelteKit\"\n ],\n \"homepage\": \"https://flags-sdk.dev\",\n \"bugs\": {\n \"url\": \"https://github.com/vercel/flags/issues\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/vercel/flags.git\"\n },\n \"license\": \"MIT\",\n \"sideEffects\": false,\n \"type\": \"module\",\n \"exports\": {\n \".\": {\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\"\n },\n \"./next\": {\n \"import\": \"./dist/next.js\",\n \"require\": \"./dist/next.cjs\"\n },\n \"./analytics\": {\n \"import\": \"./dist/analytics.js\",\n \"require\": \"./dist/analytics.cjs\"\n },\n \"./react\": {\n \"import\": \"./dist/react.js\",\n \"require\": \"./dist/react.cjs\"\n },\n \"./sveltekit\": {\n \"import\": \"./dist/sveltekit.js\",\n \"require\": \"./dist/sveltekit.cjs\"\n }\n },\n \"typesVersions\": {\n \"*\": {\n \"*\": [\n \"dist/*.d.ts\",\n \"dist/*.d.cts\"\n ],\n \"next\": [\n \"dist/next.d.ts\",\n \"dist/next.d.cts\"\n ],\n \"react\": [\n \"dist/react.d.ts\",\n \"dist/react.d.cts\"\n ],\n \"sveltekit\": [\n \"dist/sveltekit.d.ts\",\n \"dist/sveltekit.d.cts\"\n ]\n }\n },\n \"files\": [\n \"dist\",\n \"CHANGELOG.md\"\n ],\n \"scripts\": {\n \"attw\": \"attw --pack .\",\n \"build\": \"tsup\",\n \"dev\": \"tsup --watch --clean=false\",\n \"eslint\": \"eslint-runner\",\n \"eslint:fix\": \"eslint-runner --fix\",\n \"test\": \"vitest --run\",\n \"test:watch\": \"vitest\",\n \"type-check\": \"tsc --noEmit\"\n },\n \"dependencies\": {\n \"@edge-runtime/cookies\": \"^5.0.2\",\n \"jose\": \"^5.2.1\"\n },\n \"devDependencies\": {\n \"@arethetypeswrong/cli\": \"0.17.3\",\n \"@types/node\": \"20.11.17\",\n \"@types/react\": \"18.2.55\",\n \"@vitejs/plugin-react\": \"4.2.1\",\n \"eslint-config-custom\": \"workspace:*\",\n \"msw\": \"2.6.4\",\n \"next\": \"15.1.4\",\n \"react\": \"canary\",\n \"tsconfig\": \"workspace:*\",\n \"tsup\": \"8.0.1\",\n \"typescript\": \"5.6.3\",\n \"vite\": \"5.1.1\",\n \"vitest\": \"1.4.0\"\n },\n \"peerDependencies\": {\n \"@opentelemetry/api\": \"^1.7.0\",\n \"@sveltejs/kit\": \"*\",\n \"next\": \"*\",\n \"react\": \"*\",\n \"react-dom\": \"*\"\n },\n \"peerDependenciesMeta\": {\n \"@opentelemetry/api\": {\n \"optional\": true\n },\n \"@sveltejs/kit\": {\n \"optional\": true\n },\n \"next\": {\n \"optional\": true\n },\n \"react\": {\n \"optional\": true\n },\n \"react-dom\": {\n \"optional\": true\n }\n },\n \"publishConfig\": {\n \"access\": \"public\"\n }\n}\n","import type {\n Tracer,\n Attributes,\n TracerProvider,\n AttributeValue,\n} from '@opentelemetry/api';\nimport { name as pkgName, version } from '../../package.json';\nimport { AsyncLocalStorage } from 'async_hooks';\n\n// Use a symbol to avoid having global variable that is scoped to this file,\n// as it can lead to issues with cjs and mjs being used at the same time.\nconst vercelFlagsTraceSymbol = Symbol.for('flags:global-trace');\n\n/**\n * Allows setting the `@opentelemetry/api` tracer provider to generate traces\n * for `flags` operations.\n */\nexport function setTracerProvider(tracer: TracerProvider): void {\n Reflect.set(globalThis, vercelFlagsTraceSymbol, tracer);\n}\n\nfunction getTracer(): Tracer | undefined {\n const maybeTraceApi = Reflect.get(globalThis, vercelFlagsTraceSymbol) as\n | undefined\n | TracerProvider;\n return maybeTraceApi?.getTracer(pkgName, version);\n}\n\nfunction isPromise<T>(p: unknown): p is Promise<T> {\n return (\n p !== null &&\n typeof p === 'object' &&\n 'then' in p &&\n typeof p.then === 'function'\n );\n}\n\nconst spanContext = new AsyncLocalStorage<Map<string, AttributeValue>>();\n\nexport function setSpanAttribute(name: string, value: AttributeValue) {\n spanContext.getStore()?.set(name, value);\n}\n\n/* eslint-disable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any -- bc */\nexport function trace<F extends (...args: any) => any>(\n fn: F,\n options: {\n name: string;\n /** Defaults to `true`. If set to `false`, it'll trace regardless of `VERCEL_FLAGS_TRACE_VERBOSE`. */\n isVerboseTrace?: boolean;\n attributes?: Attributes;\n attributesSuccess?: (\n result: ReturnType<F> extends PromiseLike<infer U> ? U : ReturnType<F>,\n ) => Attributes;\n attributesError?: (error: Error) => Attributes;\n } = {\n name: fn.name,\n },\n): F {\n const traced = function (this: unknown, ...args: unknown[]): unknown {\n const tracer = getTracer();\n if (!tracer) return fn.apply(this, args);\n\n const shouldTrace =\n process.env.VERCEL_FLAGS_TRACE_VERBOSE === 'true' ||\n options.isVerboseTrace === false;\n if (!shouldTrace) return fn.apply(this, args);\n\n return spanContext.run(new Map(), () =>\n tracer.startActiveSpan(options.name, (span) => {\n if (options.attributes) span.setAttributes(options.attributes);\n\n try {\n const result = fn.apply(this, args);\n\n if (isPromise(result)) {\n result\n .then((value) => {\n if (options.attributesSuccess) {\n span.setAttributes(\n options.attributesSuccess(\n value as ReturnType<F> extends PromiseLike<infer U>\n ? U\n : ReturnType<F>,\n ),\n );\n }\n\n spanContext.getStore()?.forEach((value, key) => {\n span.setAttribute(key, value);\n });\n\n span.setStatus({ code: 1 }); // 1 = Ok\n span.end();\n })\n .catch((error) => {\n if (options.attributesError) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument -- k\n span.setAttributes(options.attributesError(error));\n }\n\n span.setStatus({\n code: 2, // 2 = Error\n message: error instanceof Error ? error.message : undefined,\n });\n\n spanContext.getStore()?.forEach((value, key) => {\n span.setAttribute(key, value);\n });\n\n span.end();\n });\n } else {\n if (options.attributesSuccess) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument -- k\n span.setAttributes(options.attributesSuccess(result));\n }\n\n spanContext.getStore()?.forEach((value, key) => {\n span.setAttribute(key, value);\n });\n\n span.setStatus({ code: 1 }); // 1 = Ok\n span.end();\n }\n\n return result as unknown;\n } catch (error: any) {\n if (options.attributesError) {\n span.setAttributes(options.attributesError(error as Error));\n }\n\n span.setStatus({\n code: 2, // 2 = Error\n message: error instanceof Error ? error.message : undefined,\n });\n\n spanContext.getStore()?.forEach((value, key) => {\n span.setAttribute(key, value);\n });\n\n span.end();\n\n throw error;\n }\n }),\n );\n };\n\n return traced as unknown as F;\n}\n/* eslint-enable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any -- k */\n","import { jwtDecrypt, base64url, EncryptJWT } from 'jose';\n\nexport async function encryptJWT<T extends object = Record<string, unknown>>(\n payload: T,\n expirationTime: string,\n secret: string,\n): Promise<string> {\n return new EncryptJWT(payload as Record<string, unknown>)\n .setExpirationTime(expirationTime)\n .setProtectedHeader({ alg: 'dir', enc: 'A256GCM' })\n .encrypt(base64url.decode(secret));\n}\n\nexport async function decryptJWT<\n T extends string | object = Record<string, unknown>,\n>(\n cookie: string,\n verify: undefined | null | ((payload: T) => boolean),\n secret: string,\n): Promise<T | undefined> {\n if (typeof cookie !== 'string') return;\n\n try {\n const { payload } = await jwtDecrypt(cookie, base64url.decode(secret));\n const decoded = payload as T;\n\n if (!verify || verify(decoded)) {\n // @ts-expect-error jwt field\n delete decoded.iat;\n // @ts-expect-error jwt field\n delete decoded.exp;\n return decoded;\n }\n } catch {\n // Do nothing\n }\n}\n\n/**\n * Function to encrypt overrides, values, definitions, and API data.\n */\nexport async function encrypt<T extends object>(\n value: T,\n secret: string | undefined = process?.env?.FLAGS_SECRET,\n): Promise<string> {\n if (!secret) throw new Error('Missing FLAGS_SECRET');\n // Encapsule the data within the `c` (content) property to avoid conflicts\n // with other JWT properties like `iat` and `exp`.\n return encryptJWT({ c: value }, '1y', secret);\n}\n\n/**\n * Function to decrypt overrides, values, definitions, and API data.\n */\nexport async function decrypt<T extends object>(\n encryptedData: string,\n secret: string | undefined = process?.env?.FLAGS_SECRET,\n): Promise<T | undefined> {\n if (!secret) throw new Error('Missing FLAGS_SECRET');\n const content = await decryptJWT<{ c: T }>(encryptedData, null, secret);\n return content?.c;\n}\n","import { decrypt } from './crypto';\nimport { trace } from './tracing';\n\n/**\n * This function lets you verify whether a request to your application's .well-known/vercel/flags endpoint was made by the toolbar.\n * You can use verifyAccess to keep this endpoint private, to avoid public access of your feature flag definitions through that endpoint.\n *\n * @example Using verifyAccess in .well-known/vercel/flags to verify access and respond with unencrypted data.\n * ```\n * import { type NextRequest, NextResponse } from \"next/server\";\n * import { verifyAccess } from \"flags\";\n *\n * export async function GET(request: NextRequest) {\n * const access = await verifyAccess(request.headers.get(\"Authorization\"));\n * if (!access) return NextResponse.json(null, { status: 401 });\n *\n * return NextResponse.json({ definitions: {} })\n * }\n * ```\n * @param authHeader the Authorization header to check\n * @param secret the FLAGS_SECRET\n * @returns True when the authorization header was valid\n */\nexport const verifyAccess = trace(\n async function verifyAccess(\n // App Router returns null when a header is not defined\n // Pages Router returns undefined when a header is not defined\n // We support both so the API is slim in both cases\n authHeader: string | null | undefined,\n secret: string | undefined = process?.env?.FLAGS_SECRET,\n ) {\n if (!authHeader) return false;\n if (!secret)\n throw new Error(\n 'flags: verifyAccess was called without a secret. Please set FLAGS_SECRET environment variable.',\n );\n\n const data = await decrypt<{}>(\n authHeader?.replace(/^Bearer /i, ''),\n secret,\n );\n return data !== undefined;\n },\n {\n isVerboseTrace: false,\n name: 'verifyAccess',\n },\n);\n","import { version } from '../../package.json';\n\n/**\n * This function lets you report the value of a resolved flag, which will make it available when viewing Monitoring, Logs, Analytics and Speed Insights on Vercel.\n * It's important to note that this only has effects when running on Vercel in a preview or production environments, but not during local development.\n *\n * @example Using `reportValue` to report a flag value.\n * ```\n * import { type NextRequest, NextResponse } from \"next/server\";\n * import { reportValue } from 'flags';\n *\n * export async function GET(request: NextRequest) {\n * reportValue('my-flag', true);\n * return NextResponse.json({});\n * }\n * ```\n *\n * @param key the name of the flag\n * @param value the resolved value of the flag\n */\nexport function reportValue(key: string, value: unknown) {\n const symbol = Symbol.for('@vercel/request-context');\n const ctx = Reflect.get(globalThis, symbol)?.get();\n ctx?.flags?.reportValue(key, value, {\n sdkVersion: version,\n });\n}\n\n/**\n * Only used interally for now.\n */\nexport function internalReportValue(\n key: string,\n value: unknown,\n data: {\n originProjectId?: string;\n originProvider?: 'vercel';\n reason?: 'override';\n },\n) {\n const symbol = Symbol.for('@vercel/request-context');\n const ctx = Reflect.get(globalThis, symbol)?.get();\n ctx?.flags?.reportValue(key, value, {\n sdkVersion: version,\n ...data,\n });\n}\n","// copied from Next.js, and reduced\n// https://github.com/vercel/next.js/tree/canary/packages/next/src/server/web/spec-extension\nexport class ReflectAdapter {\n static get<T extends object>(\n target: T,\n prop: string | symbol,\n receiver: unknown,\n ): any {\n const value = Reflect.get(target, prop, receiver);\n if (typeof value === 'function') {\n return value.bind(target);\n }\n\n return value;\n }\n\n static set<T extends object>(\n target: T,\n prop: string | symbol,\n value: any,\n receiver: any,\n ): boolean {\n return Reflect.set(target, prop, value, receiver);\n }\n\n static has<T extends object>(target: T, prop: string | symbol): boolean {\n return Reflect.has(target, prop);\n }\n\n static deleteProperty<T extends object>(\n target: T,\n prop: string | symbol,\n ): boolean {\n return Reflect.deleteProperty(target, prop);\n }\n}\n","// copied from Next.js, and reduced\n// https://github.com/vercel/next.js/tree/canary/packages/next/src/server/web/spec-extension\nimport type { IncomingHttpHeaders } from 'http';\n\nimport { ReflectAdapter } from './reflect';\n\n/**\n * @internal\n */\nclass ReadonlyHeadersError extends Error {\n constructor() {\n super(\n 'Headers cannot be modified. Read more: https://nextjs.org/docs/app/api-reference/functions/headers',\n );\n }\n\n public static callable() {\n throw new ReadonlyHeadersError();\n }\n}\n\nexport type ReadonlyHeaders = Headers & {\n /** @deprecated Method unavailable on `ReadonlyHeaders`. Read more: https://nextjs.org/docs/app/api-reference/functions/headers */\n append(...args: any[]): void;\n /** @deprecated Method unavailable on `ReadonlyHeaders`. Read more: https://nextjs.org/docs/app/api-reference/functions/headers */\n set(...args: any[]): void;\n /** @deprecated Method unavailable on `ReadonlyHeaders`. Read more: https://nextjs.org/docs/app/api-reference/functions/headers */\n delete(...args: any[]): void;\n};\nexport class HeadersAdapter extends Headers {\n private readonly headers: IncomingHttpHeaders;\n\n constructor(headers: IncomingHttpHeaders) {\n // We've already overridden the methods that would be called, so we're just\n // calling the super constructor to ensure that the instanceof check works.\n super();\n\n this.headers = new Proxy(headers, {\n get(target, prop, receiver) {\n // Because this is just an object, we expect that all \"get\" operations\n // are for properties. If it's a \"get\" for a symbol, we'll just return\n // the symbol.\n if (typeof prop === 'symbol') {\n return ReflectAdapter.get(target, prop, receiver);\n }\n\n const lowercased = prop.toLowerCase();\n\n // Let's find the original casing of the key. This assumes that there is\n // no mixed case keys (e.g. \"Content-Type\" and \"content-type\") in the\n // headers object.\n const original = Object.keys(headers).find(\n (o) => o.toLowerCase() === lowercased,\n );\n\n // If the original casing doesn't exist, return undefined.\n if (typeof original === 'undefined') return;\n\n // If the original casing exists, return the value.\n return ReflectAdapter.get(target, original, receiver);\n },\n set(target, prop, value, receiver) {\n if (typeof prop === 'symbol') {\n return ReflectAdapter.set(target, prop, value, receiver);\n }\n\n const lowercased = prop.toLowerCase();\n\n // Let's find the original casing of the key. This assumes that there is\n // no mixed case keys (e.g. \"Content-Type\" and \"content-type\") in the\n // headers object.\n const original = Object.keys(headers).find(\n (o) => o.toLowerCase() === lowercased,\n );\n\n // If the original casing doesn't exist, use the prop as the key.\n return ReflectAdapter.set(target, original ?? prop, value, receiver);\n },\n has(target, prop) {\n if (typeof prop === 'symbol') return ReflectAdapter.has(target, prop);\n\n const lowercased = prop.toLowerCase();\n\n // Let's find the original casing of the key. This assumes that there is\n // no mixed case keys (e.g. \"Content-Type\" and \"content-type\") in the\n // headers object.\n const original = Object.keys(headers).find(\n (o) => o.toLowerCase() === lowercased,\n );\n\n // If the original casing doesn't exist, return false.\n if (typeof original === 'undefined') return false;\n\n // If the original casing exists, return true.\n return ReflectAdapter.has(target, original);\n },\n deleteProperty(target, prop) {\n if (typeof prop === 'symbol')\n return ReflectAdapter.deleteProperty(target, prop);\n\n const lowercased = prop.toLowerCase();\n\n // Let's find the original casing of the key. This assumes that there is\n // no mixed case keys (e.g. \"Content-Type\" and \"content-type\") in the\n // headers object.\n const original = Object.keys(headers).find(\n (o) => o.toLowerCase() === lowercased,\n );\n\n // If the original casing doesn't exist, return true.\n if (typeof original === 'undefined') return true;\n\n // If the original casing exists, delete the property.\n return ReflectAdapter.deleteProperty(target, original);\n },\n });\n }\n\n /**\n * Seals a Headers instance to prevent modification by throwing an error when\n * any mutating method is called.\n */\n public static seal(headers: Headers): ReadonlyHeaders {\n return new Proxy<ReadonlyHeaders>(headers, {\n get(target, prop, receiver) {\n switch (prop) {\n case 'append':\n case 'delete':\n case 'set':\n return ReadonlyHeadersError.callable;\n default:\n return ReflectAdapter.get(target, prop, receiver);\n }\n },\n });\n }\n\n /**\n * Merges a header value into a string. This stores multiple values as an\n * array, so we need to merge them into a string.\n *\n * @param value a header value\n * @returns a merged header value (a string)\n */\n private merge(value: string | string[]): string {\n if (Array.isArray(value)) return value.join(', ');\n\n return value;\n }\n\n /**\n * Creates a Headers instance from a plain object or a Headers instance.\n *\n * @param headers a plain object or a Headers instance\n * @returns a headers instance\n */\n public static from(headers: IncomingHttpHeaders | Headers): Headers {\n if (headers instanceof Headers) return headers;\n\n return new HeadersAdapter(headers);\n }\n\n public append(name: string, value: string): void {\n const existing = this.headers[name];\n if (typeof existing === 'string') {\n this.headers[name] = [existing, value];\n } else if (Array.isArray(existing)) {\n existing.push(value);\n } else {\n this.headers[name] = value;\n }\n }\n\n public delete(name: string): void {\n delete this.headers[name];\n }\n\n public get(name: string): string | null {\n const value = this.headers[name];\n if (typeof value !== 'undefined') return this.merge(value);\n\n return null;\n }\n\n public has(name: string): boolean {\n return typeof this.headers[name] !== 'undefined';\n }\n\n public set(name: string, value: string): void {\n this.headers[name] = value;\n }\n\n public forEach(\n callbackfn: (value: string, name: string, parent: Headers) => void,\n thisArg?: any,\n ): void {\n for (const [name, value] of this.entries()) {\n callbackfn.call(thisArg, value, name, this);\n }\n }\n\n public *entries(): HeadersIterator<[string, string]> {\n for (const key of Object.keys(this.headers)) {\n const name = key.toLowerCase();\n // We assert here that this is a string because we got it from the\n // Object.keys() call above.\n const value = this.get(name) as string;\n\n yield [name, value] as [string, string];\n }\n }\n\n public *keys(): HeadersIterator<string> {\n for (const key of Object.keys(this.headers)) {\n const name = key.toLowerCase();\n yield name;\n }\n }\n\n public *values(): HeadersIterator<string> {\n for (const key of Object.keys(this.headers)) {\n // We assert here that this is a string because we got it from the\n // Object.keys() call above.\n const value = this.get(key) as string;\n\n yield value;\n }\n }\n\n public [Symbol.iterator](): HeadersIterator<[string, string]> {\n return this.entries();\n }\n}\n","// copied from Next.js, and reduced\n// https://github.com/vercel/next.js/tree/canary/packages/next/src/server/web/spec-extension\nimport { RequestCookies } from '../cookies';\nimport { ResponseCookies } from '../cookies';\nimport { ReflectAdapter } from './reflect';\n\n/**\n * @internal\n */\nexport class ReadonlyRequestCookiesError extends Error {\n constructor() {\n super(\n 'Cookies can only be modified in a Server Action or Route Handler. Read more: https://nextjs.org/docs/app/api-reference/functions/cookies#options',\n );\n }\n\n public static callable() {\n throw new ReadonlyRequestCookiesError();\n }\n}\n\n// We use this to type some APIs but we don't construct instances directly\nexport type { ResponseCookies };\n\n// The `cookies()` API is a mix of request and response cookies. For `.get()` methods,\n// we want to return the request cookie if it exists. For mutative methods like `.set()`,\n// we want to return the response cookie.\nexport type ReadonlyRequestCookies = Omit<\n RequestCookies,\n 'set' | 'clear' | 'delete'\n> &\n Pick<ResponseCookies, 'set' | 'delete'>;\n\nexport class RequestCookiesAdapter {\n public static seal(cookies: RequestCookies): ReadonlyRequestCookies {\n return new Proxy(cookies as any, {\n get(target, prop, receiver) {\n switch (prop) {\n case 'clear':\n case 'delete':\n case 'set':\n return ReadonlyRequestCookiesError.callable;\n default:\n return ReflectAdapter.get(target, prop, receiver);\n }\n },\n });\n }\n}\n\nconst SYMBOL_MODIFY_COOKIE_VALUES = Symbol.for('next.mutated.cookies');\n\nexport function getModifiedCookieValues(\n cookies: ResponseCookies,\n): ResponseCookie[] {\n const modified: ResponseCookie[] | undefined = (cookies as unknown as any)[\n SYMBOL_MODIFY_COOKIE_VALUES\n ];\n if (!modified || !Array.isArray(modified) || modified.length === 0) {\n return [];\n }\n\n return modified;\n}\n\ntype SetCookieArgs =\n | [key: string, value: string, cookie?: Partial<ResponseCookie>]\n | [options: ResponseCookie];\n\nexport function appendMutableCookies(\n headers: Headers,\n mutableCookies: ResponseCookies,\n): boolean {\n const modifiedCookieValues = getModifiedCookieValues(mutableCookies);\n if (modifiedCookieValues.length === 0) {\n return false;\n }\n\n // Return a new response that extends the response with\n // the modified cookies as fallbacks. `res` cookies\n // will still take precedence.\n const resCookies = new ResponseCookies(headers);\n const returnedCookies = resCookies.getAll();\n\n // Set the modified cookies as fallbacks.\n for (const cookie of modifiedCookieValues) {\n resCookies.set(cookie);\n }\n\n // Set the original cookies as the final values.\n for (const cookie of returnedCookies) {\n resCookies.set(cookie);\n }\n\n return true;\n}\n\ntype ResponseCookie = NonNullable<\n ReturnType<InstanceType<typeof ResponseCookies>['get']>\n>;\n","import { ProviderData } from '../types';\n\nexport async function mergeProviderData(\n itemsPromises: (Promise<ProviderData> | ProviderData)[],\n): Promise<ProviderData> {\n const items = await Promise.all(\n itemsPromises.map((p) => Promise.resolve(p).catch(() => null)),\n );\n\n return items\n .filter((item): item is ProviderData => Boolean(item))\n .reduce<ProviderData>(\n (acc, item) => {\n Object.entries(item.definitions).forEach(([key, definition]) => {\n if (!acc.definitions[key]) acc.definitions[key] = {};\n Object.assign(acc.definitions[key], definition);\n });\n\n if (Array.isArray(item.hints)) acc.hints.push(...item.hints);\n\n return acc;\n },\n { definitions: {}, hints: [] },\n );\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../package.json","../src/lib/tracing.ts","../src/lib/crypto.ts","../src/lib/verify-access.ts","../src/lib/report-value.ts","../src/spec-extension/adapters/reflect.ts","../src/spec-extension/adapters/headers.ts","../src/spec-extension/adapters/request-cookies.ts","../src/lib/merge-provider-data.ts"],"names":["name","value","verifyAccess"],"mappings":";AACE,WAAQ;AACR,cAAW;;;ACKb,SAAS,yBAAyB;AAIlC,IAAM,yBAAyB,OAAO,IAAI,oBAAoB;AAMvD,SAAS,kBAAkB,QAA8B;AAC9D,UAAQ,IAAI,YAAY,wBAAwB,MAAM;AACxD;AAEA,SAAS,YAAgC;AACvC,QAAM,gBAAgB,QAAQ,IAAI,YA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MAAM,IAAI,CAAC;AAAA,EAC/D;AAEA,SAAO,MACJ,OAAO,CAAC,SAA+B,QAAQ,IAAI,CAAC,EACpD;AAAA,IACC,CAAC,KAAK,SAAS;AACb,aAAO,QAAQ,KAAK,WAAW,EAAE,QAAQ,CAAC,CAAC,KAAK,UAAU,MAAM;AAC9D,YAAI,CAAC,IAAI,YAAY,GAAG;AAAG,cAAI,YAAY,GAAG,IAAI,CAAC;AACnD,eAAO,OAAO,IAAI,YAAY,GAAG,GAAG,UAAU;AAAA,MAChD,CAAC;AAED,UAAI,MAAM,QAAQ,KAAK,KAAK;AAAG,YAAI,MAAM,KAAK,GAAG,KAAK,KAAK;AAE3D,aAAO;AAAA,IACT;AAAA,IACA,EAAE,aAAa,CAAC,GAAG,OAAO,CAAC,EAAE;AAAA,EAC/B;AACJ","sourcesContent":["{\n \"name\": \"flags\",\n \"version\": \"3.1.2\",\n \"description\": \"Flags SDK by Vercel - The feature flags toolkit for Next.js and SvelteKit\",\n \"keywords\": [\n \"feature flags\",\n \"Next.js\",\n \"react\",\n \"toolbar\",\n \"overrides\",\n \"SvelteKit\"\n ],\n \"homepage\": \"https://flags-sdk.dev\",\n \"bugs\": {\n \"url\": \"https://github.com/vercel/flags/issues\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/vercel/flags.git\"\n },\n \"license\": \"MIT\",\n \"sideEffects\": false,\n \"type\": \"module\",\n \"exports\": {\n \".\": {\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\"\n },\n \"./next\": {\n \"import\": \"./dist/next.js\",\n \"require\": \"./dist/next.cjs\"\n },\n \"./analytics\": {\n \"import\": \"./dist/analytics.js\",\n \"require\": \"./dist/analytics.cjs\"\n },\n \"./react\": {\n \"import\": \"./dist/react.js\",\n \"require\": \"./dist/react.cjs\"\n },\n \"./sveltekit\": {\n \"import\": \"./dist/sveltekit.js\",\n \"require\": \"./dist/sveltekit.cjs\"\n }\n },\n \"typesVersions\": {\n \"*\": {\n \"*\": [\n \"dist/*.d.ts\",\n \"dist/*.d.cts\"\n ],\n \"next\": [\n \"dist/next.d.ts\",\n \"dist/next.d.cts\"\n ],\n \"react\": [\n \"dist/react.d.ts\",\n \"dist/react.d.cts\"\n ],\n \"sveltekit\": [\n \"dist/sveltekit.d.ts\",\n \"dist/sveltekit.d.cts\"\n ]\n }\n },\n \"files\": [\n \"dist\",\n \"CHANGELOG.md\"\n ],\n \"scripts\": {\n \"attw\": \"attw --pack .\",\n \"build\": \"tsup\",\n \"dev\": \"tsup --watch --clean=false\",\n \"eslint\": \"eslint-runner\",\n \"eslint:fix\": \"eslint-runner --fix\",\n \"test\": \"vitest --run\",\n \"test:watch\": \"vitest\",\n \"type-check\": \"tsc --noEmit\"\n },\n \"dependencies\": {\n \"@edge-runtime/cookies\": \"^5.0.2\",\n \"jose\": \"^5.2.1\"\n },\n \"devDependencies\": {\n \"@arethetypeswrong/cli\": \"0.17.3\",\n \"@types/node\": \"20.11.17\",\n \"@types/react\": \"18.2.55\",\n \"@vitejs/plugin-react\": \"4.2.1\",\n \"eslint-config-custom\": \"workspace:*\",\n \"msw\": \"2.6.4\",\n \"next\": \"15.1.4\",\n \"react\": \"canary\",\n \"tsconfig\": \"workspace:*\",\n \"tsup\": \"8.0.1\",\n \"typescript\": \"5.6.3\",\n \"vite\": \"5.1.1\",\n \"vitest\": \"1.4.0\"\n },\n \"peerDependencies\": {\n \"@opentelemetry/api\": \"^1.7.0\",\n \"@sveltejs/kit\": \"*\",\n \"next\": \"*\",\n \"react\": \"*\",\n \"react-dom\": \"*\"\n },\n \"peerDependenciesMeta\": {\n \"@opentelemetry/api\": {\n \"optional\": true\n },\n \"@sveltejs/kit\": {\n \"optional\": true\n },\n \"next\": {\n \"optional\": true\n },\n \"react\": {\n \"optional\": true\n },\n \"react-dom\": {\n \"optional\": true\n }\n },\n \"publishConfig\": {\n \"access\": \"public\"\n }\n}\n","import type {\n Tracer,\n Attributes,\n TracerProvider,\n AttributeValue,\n} from '@opentelemetry/api';\nimport { name as pkgName, version } from '../../package.json';\nimport { AsyncLocalStorage } from 'async_hooks';\n\n// Use a symbol to avoid having global variable that is scoped to this file,\n// as it can lead to issues with cjs and mjs being used at the same time.\nconst vercelFlagsTraceSymbol = Symbol.for('flags:global-trace');\n\n/**\n * Allows setting the `@opentelemetry/api` tracer provider to generate traces\n * for `flags` operations.\n */\nexport function setTracerProvider(tracer: TracerProvider): void {\n Reflect.set(globalThis, vercelFlagsTraceSymbol, tracer);\n}\n\nfunction getTracer(): Tracer | undefined {\n const maybeTraceApi = Reflect.get(globalThis, vercelFlagsTraceSymbol) as\n | undefined\n | TracerProvider;\n return maybeTraceApi?.getTracer(pkgName, version);\n}\n\nfunction isPromise<T>(p: unknown): p is Promise<T> {\n return (\n p !== null &&\n typeof p === 'object' &&\n 'then' in p &&\n typeof p.then === 'function'\n );\n}\n\nconst spanContext = new AsyncLocalStorage<Map<string, AttributeValue>>();\n\nexport function setSpanAttribute(name: string, value: AttributeValue) {\n spanContext.getStore()?.set(name, value);\n}\n\n/* eslint-disable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any -- bc */\nexport function trace<F extends (...args: any) => any>(\n fn: F,\n options: {\n name: string;\n /** Defaults to `true`. If set to `false`, it'll trace regardless of `VERCEL_FLAGS_TRACE_VERBOSE`. */\n isVerboseTrace?: boolean;\n attributes?: Attributes;\n attributesSuccess?: (\n result: ReturnType<F> extends PromiseLike<infer U> ? U : ReturnType<F>,\n ) => Attributes;\n attributesError?: (error: Error) => Attributes;\n } = {\n name: fn.name,\n },\n): F {\n const traced = function (this: unknown, ...args: unknown[]): unknown {\n const tracer = getTracer();\n if (!tracer) return fn.apply(this, args);\n\n const shouldTrace =\n process.env.VERCEL_FLAGS_TRACE_VERBOSE === 'true' ||\n options.isVerboseTrace === false;\n if (!shouldTrace) return fn.apply(this, args);\n\n return spanContext.run(new Map(), () =>\n tracer.startActiveSpan(options.name, (span) => {\n if (options.attributes) span.setAttributes(options.attributes);\n\n try {\n const result = fn.apply(this, args);\n\n if (isPromise(result)) {\n result\n .then((value) => {\n if (options.attributesSuccess) {\n span.setAttributes(\n options.attributesSuccess(\n value as ReturnType<F> extends PromiseLike<infer U>\n ? U\n : ReturnType<F>,\n ),\n );\n }\n\n spanContext.getStore()?.forEach((value, key) => {\n span.setAttribute(key, value);\n });\n\n span.setStatus({ code: 1 }); // 1 = Ok\n span.end();\n })\n .catch((error) => {\n if (options.attributesError) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument -- k\n span.setAttributes(options.attributesError(error));\n }\n\n span.setStatus({\n code: 2, // 2 = Error\n message: error instanceof Error ? error.message : undefined,\n });\n\n spanContext.getStore()?.forEach((value, key) => {\n span.setAttribute(key, value);\n });\n\n span.end();\n });\n } else {\n if (options.attributesSuccess) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument -- k\n span.setAttributes(options.attributesSuccess(result));\n }\n\n spanContext.getStore()?.forEach((value, key) => {\n span.setAttribute(key, value);\n });\n\n span.setStatus({ code: 1 }); // 1 = Ok\n span.end();\n }\n\n return result as unknown;\n } catch (error: any) {\n if (options.attributesError) {\n span.setAttributes(options.attributesError(error as Error));\n }\n\n span.setStatus({\n code: 2, // 2 = Error\n message: error instanceof Error ? error.message : undefined,\n });\n\n spanContext.getStore()?.forEach((value, key) => {\n span.setAttribute(key, value);\n });\n\n span.end();\n\n throw error;\n }\n }),\n );\n };\n\n return traced as unknown as F;\n}\n/* eslint-enable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any -- k */\n","import { jwtDecrypt, base64url, EncryptJWT } from 'jose';\n\nexport async function encryptJWT<T extends object = Record<string, unknown>>(\n payload: T,\n expirationTime: string,\n secret: string,\n): Promise<string> {\n return new EncryptJWT(payload as Record<string, unknown>)\n .setExpirationTime(expirationTime)\n .setProtectedHeader({ alg: 'dir', enc: 'A256GCM' })\n .encrypt(base64url.decode(secret));\n}\n\nexport async function decryptJWT<\n T extends string | object = Record<string, unknown>,\n>(\n cookie: string,\n verify: undefined | null | ((payload: T) => boolean),\n secret: string,\n): Promise<T | undefined> {\n if (typeof cookie !== 'string') return;\n\n try {\n const { payload } = await jwtDecrypt(cookie, base64url.decode(secret));\n const decoded = payload as T;\n\n if (!verify || verify(decoded)) {\n // @ts-expect-error jwt field\n delete decoded.iat;\n // @ts-expect-error jwt field\n delete decoded.exp;\n return decoded;\n }\n } catch {\n // Do nothing\n }\n}\n\n/**\n * Function to encrypt overrides, values, definitions, and API data.\n */\nexport async function encrypt<T extends object>(\n value: T,\n secret: string | undefined = process?.env?.FLAGS_SECRET,\n): Promise<string> {\n if (!secret) throw new Error('Missing FLAGS_SECRET');\n // Encapsule the data within the `c` (content) property to avoid conflicts\n // with other JWT properties like `iat` and `exp`.\n return encryptJWT({ c: value }, '1y', secret);\n}\n\n/**\n * Function to decrypt overrides, values, definitions, and API data.\n */\nexport async function decrypt<T extends object>(\n encryptedData: string,\n secret: string | undefined = process?.env?.FLAGS_SECRET,\n): Promise<T | undefined> {\n if (!secret) throw new Error('Missing FLAGS_SECRET');\n const content = await decryptJWT<{ c: T }>(encryptedData, null, secret);\n return content?.c;\n}\n","import { decrypt } from './crypto';\nimport { trace } from './tracing';\n\n/**\n * This function lets you verify whether a request to your application's .well-known/vercel/flags endpoint was made by the toolbar.\n * You can use verifyAccess to keep this endpoint private, to avoid public access of your feature flag definitions through that endpoint.\n *\n * @example Using verifyAccess in .well-known/vercel/flags to verify access and respond with unencrypted data.\n * ```\n * import { type NextRequest, NextResponse } from \"next/server\";\n * import { verifyAccess } from \"flags\";\n *\n * export async function GET(request: NextRequest) {\n * const access = await verifyAccess(request.headers.get(\"Authorization\"));\n * if (!access) return NextResponse.json(null, { status: 401 });\n *\n * return NextResponse.json({ definitions: {} })\n * }\n * ```\n * @param authHeader the Authorization header to check\n * @param secret the FLAGS_SECRET\n * @returns True when the authorization header was valid\n */\nexport const verifyAccess = trace(\n async function verifyAccess(\n // App Router returns null when a header is not defined\n // Pages Router returns undefined when a header is not defined\n // We support both so the API is slim in both cases\n authHeader: string | null | undefined,\n secret: string | undefined = process?.env?.FLAGS_SECRET,\n ) {\n if (!authHeader) return false;\n if (!secret)\n throw new Error(\n 'flags: verifyAccess was called without a secret. Please set FLAGS_SECRET environment variable.',\n );\n\n const data = await decrypt<{}>(\n authHeader?.replace(/^Bearer /i, ''),\n secret,\n );\n return data !== undefined;\n },\n {\n isVerboseTrace: false,\n name: 'verifyAccess',\n },\n);\n","import { version } from '../../package.json';\n\n/**\n * This function lets you report the value of a resolved flag, which will make it available when viewing Monitoring, Logs, Analytics and Speed Insights on Vercel.\n * It's important to note that this only has effects when running on Vercel in a preview or production environments, but not during local development.\n *\n * @example Using `reportValue` to report a flag value.\n * ```\n * import { type NextRequest, NextResponse } from \"next/server\";\n * import { reportValue } from 'flags';\n *\n * export async function GET(request: NextRequest) {\n * reportValue('my-flag', true);\n * return NextResponse.json({});\n * }\n * ```\n *\n * @param key the name of the flag\n * @param value the resolved value of the flag\n */\nexport function reportValue(key: string, value: unknown) {\n const symbol = Symbol.for('@vercel/request-context');\n const ctx = Reflect.get(globalThis, symbol)?.get();\n ctx?.flags?.reportValue(key, value, {\n sdkVersion: version,\n });\n}\n\n/**\n * Only used interally for now.\n */\nexport function internalReportValue(\n key: string,\n value: unknown,\n data: {\n originProjectId?: string;\n originProvider?: 'vercel';\n reason?: 'override';\n },\n) {\n const symbol = Symbol.for('@vercel/request-context');\n const ctx = Reflect.get(globalThis, symbol)?.get();\n ctx?.flags?.reportValue(key, value, {\n sdkVersion: version,\n ...data,\n });\n}\n","// copied from Next.js, and reduced\n// https://github.com/vercel/next.js/tree/canary/packages/next/src/server/web/spec-extension\nexport class ReflectAdapter {\n static get<T extends object>(\n target: T,\n prop: string | symbol,\n receiver: unknown,\n ): any {\n const value = Reflect.get(target, prop, receiver);\n if (typeof value === 'function') {\n return value.bind(target);\n }\n\n return value;\n }\n\n static set<T extends object>(\n target: T,\n prop: string | symbol,\n value: any,\n receiver: any,\n ): boolean {\n return Reflect.set(target, prop, value, receiver);\n }\n\n static has<T extends object>(target: T, prop: string | symbol): boolean {\n return Reflect.has(target, prop);\n }\n\n static deleteProperty<T extends object>(\n target: T,\n prop: string | symbol,\n ): boolean {\n return Reflect.deleteProperty(target, prop);\n }\n}\n","// copied from Next.js, and reduced\n// https://github.com/vercel/next.js/tree/canary/packages/next/src/server/web/spec-extension\nimport type { IncomingHttpHeaders } from 'http';\n\nimport { ReflectAdapter } from './reflect';\n\n/**\n * @internal\n */\nclass ReadonlyHeadersError extends Error {\n constructor() {\n super(\n 'Headers cannot be modified. Read more: https://nextjs.org/docs/app/api-reference/functions/headers',\n );\n }\n\n public static callable() {\n throw new ReadonlyHeadersError();\n }\n}\n\nexport type ReadonlyHeaders = Headers & {\n /** @deprecated Method unavailable on `ReadonlyHeaders`. Read more: https://nextjs.org/docs/app/api-reference/functions/headers */\n append(...args: any[]): void;\n /** @deprecated Method unavailable on `ReadonlyHeaders`. Read more: https://nextjs.org/docs/app/api-reference/functions/headers */\n set(...args: any[]): void;\n /** @deprecated Method unavailable on `ReadonlyHeaders`. Read more: https://nextjs.org/docs/app/api-reference/functions/headers */\n delete(...args: any[]): void;\n};\nexport class HeadersAdapter extends Headers {\n private readonly headers: IncomingHttpHeaders;\n\n constructor(headers: IncomingHttpHeaders) {\n // We've already overridden the methods that would be called, so we're just\n // calling the super constructor to ensure that the instanceof check works.\n super();\n\n this.headers = new Proxy(headers, {\n get(target, prop, receiver) {\n // Because this is just an object, we expect that all \"get\" operations\n // are for properties. If it's a \"get\" for a symbol, we'll just return\n // the symbol.\n if (typeof prop === 'symbol') {\n return ReflectAdapter.get(target, prop, receiver);\n }\n\n const lowercased = prop.toLowerCase();\n\n // Let's find the original casing of the key. This assumes that there is\n // no mixed case keys (e.g. \"Content-Type\" and \"content-type\") in the\n // headers object.\n const original = Object.keys(headers).find(\n (o) => o.toLowerCase() === lowercased,\n );\n\n // If the original casing doesn't exist, return undefined.\n if (typeof original === 'undefined') return;\n\n // If the original casing exists, return the value.\n return ReflectAdapter.get(target, original, receiver);\n },\n set(target, prop, value, receiver) {\n if (typeof prop === 'symbol') {\n return ReflectAdapter.set(target, prop, value, receiver);\n }\n\n const lowercased = prop.toLowerCase();\n\n // Let's find the original casing of the key. This assumes that there is\n // no mixed case keys (e.g. \"Content-Type\" and \"content-type\") in the\n // headers object.\n const original = Object.keys(headers).find(\n (o) => o.toLowerCase() === lowercased,\n );\n\n // If the original casing doesn't exist, use the prop as the key.\n return ReflectAdapter.set(target, original ?? prop, value, receiver);\n },\n has(target, prop) {\n if (typeof prop === 'symbol') return ReflectAdapter.has(target, prop);\n\n const lowercased = prop.toLowerCase();\n\n // Let's find the original casing of the key. This assumes that there is\n // no mixed case keys (e.g. \"Content-Type\" and \"content-type\") in the\n // headers object.\n const original = Object.keys(headers).find(\n (o) => o.toLowerCase() === lowercased,\n );\n\n // If the original casing doesn't exist, return false.\n if (typeof original === 'undefined') return false;\n\n // If the original casing exists, return true.\n return ReflectAdapter.has(target, original);\n },\n deleteProperty(target, prop) {\n if (typeof prop === 'symbol')\n return ReflectAdapter.deleteProperty(target, prop);\n\n const lowercased = prop.toLowerCase();\n\n // Let's find the original casing of the key. This assumes that there is\n // no mixed case keys (e.g. \"Content-Type\" and \"content-type\") in the\n // headers object.\n const original = Object.keys(headers).find(\n (o) => o.toLowerCase() === lowercased,\n );\n\n // If the original casing doesn't exist, return true.\n if (typeof original === 'undefined') return true;\n\n // If the original casing exists, delete the property.\n return ReflectAdapter.deleteProperty(target, original);\n },\n });\n }\n\n /**\n * Seals a Headers instance to prevent modification by throwing an error when\n * any mutating method is called.\n */\n public static seal(headers: Headers): ReadonlyHeaders {\n return new Proxy<ReadonlyHeaders>(headers, {\n get(target, prop, receiver) {\n switch (prop) {\n case 'append':\n case 'delete':\n case 'set':\n return ReadonlyHeadersError.callable;\n default:\n return ReflectAdapter.get(target, prop, receiver);\n }\n },\n });\n }\n\n /**\n * Merges a header value into a string. This stores multiple values as an\n * array, so we need to merge them into a string.\n *\n * @param value a header value\n * @returns a merged header value (a string)\n */\n private merge(value: string | string[]): string {\n if (Array.isArray(value)) return value.join(', ');\n\n return value;\n }\n\n /**\n * Creates a Headers instance from a plain object or a Headers instance.\n *\n * @param headers a plain object or a Headers instance\n * @returns a headers instance\n */\n public static from(headers: IncomingHttpHeaders | Headers): Headers {\n if (headers instanceof Headers) return headers;\n\n return new HeadersAdapter(headers);\n }\n\n public append(name: string, value: string): void {\n const existing = this.headers[name];\n if (typeof existing === 'string') {\n this.headers[name] = [existing, value];\n } else if (Array.isArray(existing)) {\n existing.push(value);\n } else {\n this.headers[name] = value;\n }\n }\n\n public delete(name: string): void {\n delete this.headers[name];\n }\n\n public get(name: string): string | null {\n const value = this.headers[name];\n if (typeof value !== 'undefined') return this.merge(value);\n\n return null;\n }\n\n public has(name: string): boolean {\n return typeof this.headers[name] !== 'undefined';\n }\n\n public set(name: string, value: string): void {\n this.headers[name] = value;\n }\n\n public forEach(\n callbackfn: (value: string, name: string, parent: Headers) => void,\n thisArg?: any,\n ): void {\n for (const [name, value] of this.entries()) {\n callbackfn.call(thisArg, value, name, this);\n }\n }\n\n public *entries(): HeadersIterator<[string, string]> {\n for (const key of Object.keys(this.headers)) {\n const name = key.toLowerCase();\n // We assert here that this is a string because we got it from the\n // Object.keys() call above.\n const value = this.get(name) as string;\n\n yield [name, value] as [string, string];\n }\n }\n\n public *keys(): HeadersIterator<string> {\n for (const key of Object.keys(this.headers)) {\n const name = key.toLowerCase();\n yield name;\n }\n }\n\n public *values(): HeadersIterator<string> {\n for (const key of Object.keys(this.headers)) {\n // We assert here that this is a string because we got it from the\n // Object.keys() call above.\n const value = this.get(key) as string;\n\n yield value;\n }\n }\n\n public [Symbol.iterator](): HeadersIterator<[string, string]> {\n return this.entries();\n }\n}\n","// copied from Next.js, and reduced\n// https://github.com/vercel/next.js/tree/canary/packages/next/src/server/web/spec-extension\nimport { RequestCookies } from '../cookies';\nimport { ResponseCookies } from '../cookies';\nimport { ReflectAdapter } from './reflect';\n\n/**\n * @internal\n */\nexport class ReadonlyRequestCookiesError extends Error {\n constructor() {\n super(\n 'Cookies can only be modified in a Server Action or Route Handler. Read more: https://nextjs.org/docs/app/api-reference/functions/cookies#options',\n );\n }\n\n public static callable() {\n throw new ReadonlyRequestCookiesError();\n }\n}\n\n// We use this to type some APIs but we don't construct instances directly\nexport type { ResponseCookies };\n\n// The `cookies()` API is a mix of request and response cookies. For `.get()` methods,\n// we want to return the request cookie if it exists. For mutative methods like `.set()`,\n// we want to return the response cookie.\nexport type ReadonlyRequestCookies = Omit<\n RequestCookies,\n 'set' | 'clear' | 'delete'\n> &\n Pick<ResponseCookies, 'set' | 'delete'>;\n\nexport class RequestCookiesAdapter {\n public static seal(cookies: RequestCookies): ReadonlyRequestCookies {\n return new Proxy(cookies as any, {\n get(target, prop, receiver) {\n switch (prop) {\n case 'clear':\n case 'delete':\n case 'set':\n return ReadonlyRequestCookiesError.callable;\n default:\n return ReflectAdapter.get(target, prop, receiver);\n }\n },\n });\n }\n}\n\nconst SYMBOL_MODIFY_COOKIE_VALUES = Symbol.for('next.mutated.cookies');\n\nexport function getModifiedCookieValues(\n cookies: ResponseCookies,\n): ResponseCookie[] {\n const modified: ResponseCookie[] | undefined = (cookies as unknown as any)[\n SYMBOL_MODIFY_COOKIE_VALUES\n ];\n if (!modified || !Array.isArray(modified) || modified.length === 0) {\n return [];\n }\n\n return modified;\n}\n\ntype SetCookieArgs =\n | [key: string, value: string, cookie?: Partial<ResponseCookie>]\n | [options: ResponseCookie];\n\nexport function appendMutableCookies(\n headers: Headers,\n mutableCookies: ResponseCookies,\n): boolean {\n const modifiedCookieValues = getModifiedCookieValues(mutableCookies);\n if (modifiedCookieValues.length === 0) {\n return false;\n }\n\n // Return a new response that extends the response with\n // the modified cookies as fallbacks. `res` cookies\n // will still take precedence.\n const resCookies = new ResponseCookies(headers);\n const returnedCookies = resCookies.getAll();\n\n // Set the modified cookies as fallbacks.\n for (const cookie of modifiedCookieValues) {\n resCookies.set(cookie);\n }\n\n // Set the original cookies as the final values.\n for (const cookie of returnedCookies) {\n resCookies.set(cookie);\n }\n\n return true;\n}\n\ntype ResponseCookie = NonNullable<\n ReturnType<InstanceType<typeof ResponseCookies>['get']>\n>;\n","import { ProviderData } from '../types';\n\nexport async function mergeProviderData(\n itemsPromises: (Promise<ProviderData> | ProviderData)[],\n): Promise<ProviderData> {\n const items = await Promise.all(\n itemsPromises.map((p) => Promise.resolve(p).catch(() => null)),\n );\n\n return items\n .filter((item): item is ProviderData => Boolean(item))\n .reduce<ProviderData>(\n (acc, item) => {\n Object.entries(item.definitions).forEach(([key, definition]) => {\n if (!acc.definitions[key]) acc.definitions[key] = {};\n Object.assign(acc.definitions[key], definition);\n });\n\n if (Array.isArray(item.hints)) acc.hints.push(...item.hints);\n\n return acc;\n },\n { definitions: {}, hints: [] },\n );\n}\n"]}
|
package/dist/index.cjs
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkIGXYQW6Rcjs = require('./chunk-IGXYQW6R.cjs');
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
var _chunkMEG7RDX7cjs = require('./chunk-MEG7RDX7.cjs');
|
|
@@ -21,5 +21,5 @@ var _chunkMEG7RDX7cjs = require('./chunk-MEG7RDX7.cjs');
|
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
|
|
24
|
-
exports.HeadersAdapter =
|
|
24
|
+
exports.HeadersAdapter = _chunkIGXYQW6Rcjs.HeadersAdapter; exports.RequestCookiesAdapter = _chunkIGXYQW6Rcjs.RequestCookiesAdapter; exports.decrypt = _chunkIGXYQW6Rcjs.decrypt; exports.encrypt = _chunkIGXYQW6Rcjs.encrypt; exports.mergeProviderData = _chunkIGXYQW6Rcjs.mergeProviderData; exports.reportValue = _chunkIGXYQW6Rcjs.reportValue; exports.safeJsonStringify = _chunkMEG7RDX7cjs.safeJsonStringify; exports.setTracerProvider = _chunkIGXYQW6Rcjs.setTracerProvider; exports.verifyAccess = _chunkIGXYQW6Rcjs.verifyAccess;
|
|
25
25
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TracerProvider } from '@opentelemetry/api';
|
|
2
|
-
import { P as ProviderData } from './types-
|
|
3
|
-
export { A as Adapter, a as ApiData, D as Decide, f as FlagDeclaration, b as FlagDefinitionType, c as FlagDefinitionsType, F as FlagOptionType, e as FlagOverridesType, d as FlagValuesType, G as GenerousOption, H as HeadersAdapter, I as Identify, J as JsonValue, O as Origin, R as ReadonlyHeaders, g as ReadonlyRequestCookies, h as RequestCookiesAdapter } from './types-
|
|
2
|
+
import { P as ProviderData } from './types-CGpl9epN.cjs';
|
|
3
|
+
export { A as Adapter, a as ApiData, D as Decide, f as FlagDeclaration, b as FlagDefinitionType, c as FlagDefinitionsType, F as FlagOptionType, e as FlagOverridesType, d as FlagValuesType, G as GenerousOption, H as HeadersAdapter, I as Identify, J as JsonValue, O as Origin, R as ReadonlyHeaders, g as ReadonlyRequestCookies, h as RequestCookiesAdapter } from './types-CGpl9epN.cjs';
|
|
4
4
|
import 'http';
|
|
5
5
|
import '@edge-runtime/cookies';
|
|
6
6
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TracerProvider } from '@opentelemetry/api';
|
|
2
|
-
import { P as ProviderData } from './types-
|
|
3
|
-
export { A as Adapter, a as ApiData, D as Decide, f as FlagDeclaration, b as FlagDefinitionType, c as FlagDefinitionsType, F as FlagOptionType, e as FlagOverridesType, d as FlagValuesType, G as GenerousOption, H as HeadersAdapter, I as Identify, J as JsonValue, O as Origin, R as ReadonlyHeaders, g as ReadonlyRequestCookies, h as RequestCookiesAdapter } from './types-
|
|
2
|
+
import { P as ProviderData } from './types-CGpl9epN.js';
|
|
3
|
+
export { A as Adapter, a as ApiData, D as Decide, f as FlagDeclaration, b as FlagDefinitionType, c as FlagDefinitionsType, F as FlagOptionType, e as FlagOverridesType, d as FlagValuesType, G as GenerousOption, H as HeadersAdapter, I as Identify, J as JsonValue, O as Origin, R as ReadonlyHeaders, g as ReadonlyRequestCookies, h as RequestCookiesAdapter } from './types-CGpl9epN.js';
|
|
4
4
|
import 'http';
|
|
5
5
|
import '@edge-runtime/cookies';
|
|
6
6
|
|
package/dist/index.js
CHANGED
package/dist/next.cjs
CHANGED
|
@@ -9,7 +9,7 @@ var _chunkAVMIIWOFcjs = require('./chunk-AVMIIWOF.cjs');
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _chunkIGXYQW6Rcjs = require('./chunk-IGXYQW6R.cjs');
|
|
13
13
|
require('./chunk-MEG7RDX7.cjs');
|
|
14
14
|
|
|
15
15
|
// src/next/index.ts
|
|
@@ -36,7 +36,7 @@ function memoizeOne(fn, isEqual, { cachePromiseRejection = false } = {}) {
|
|
|
36
36
|
|
|
37
37
|
// src/next/overrides.ts
|
|
38
38
|
var memoizedDecrypt = memoizeOne(
|
|
39
|
-
(text) =>
|
|
39
|
+
(text) => _chunkIGXYQW6Rcjs.decrypt.call(void 0, text),
|
|
40
40
|
(a, b) => a[0] === b[0],
|
|
41
41
|
// only the first argument gets compared
|
|
42
42
|
{ cachePromiseRejection: true }
|
|
@@ -366,7 +366,7 @@ function sealHeaders(headers) {
|
|
|
366
366
|
const cached = headersMap.get(headers);
|
|
367
367
|
if (cached !== void 0)
|
|
368
368
|
return cached;
|
|
369
|
-
const sealed =
|
|
369
|
+
const sealed = _chunkIGXYQW6Rcjs.HeadersAdapter.seal(headers);
|
|
370
370
|
headersMap.set(headers, sealed);
|
|
371
371
|
return sealed;
|
|
372
372
|
}
|
|
@@ -374,7 +374,7 @@ function sealCookies(headers) {
|
|
|
374
374
|
const cached = cookiesMap.get(headers);
|
|
375
375
|
if (cached !== void 0)
|
|
376
376
|
return cached;
|
|
377
|
-
const sealed =
|
|
377
|
+
const sealed = _chunkIGXYQW6Rcjs.RequestCookiesAdapter.seal(new (0, _cookies.RequestCookies)(headers));
|
|
378
378
|
cookiesMap.set(headers, sealed);
|
|
379
379
|
return sealed;
|
|
380
380
|
}
|
|
@@ -453,12 +453,12 @@ function getRun(definition, decide) {
|
|
|
453
453
|
entitiesKey
|
|
454
454
|
);
|
|
455
455
|
if (cachedValue !== void 0) {
|
|
456
|
-
|
|
456
|
+
_chunkIGXYQW6Rcjs.setSpanAttribute.call(void 0, "method", "cached");
|
|
457
457
|
const value = await cachedValue;
|
|
458
458
|
return value;
|
|
459
459
|
}
|
|
460
460
|
if (overrides && overrides[definition.key] !== void 0) {
|
|
461
|
-
|
|
461
|
+
_chunkIGXYQW6Rcjs.setSpanAttribute.call(void 0, "method", "override");
|
|
462
462
|
const decision2 = overrides[definition.key];
|
|
463
463
|
setCachedValuePromise(
|
|
464
464
|
readonlyHeaders,
|
|
@@ -466,13 +466,15 @@ function getRun(definition, decide) {
|
|
|
466
466
|
entitiesKey,
|
|
467
467
|
Promise.resolve(decision2)
|
|
468
468
|
);
|
|
469
|
-
|
|
469
|
+
_chunkIGXYQW6Rcjs.internalReportValue.call(void 0, definition.key, decision2, {
|
|
470
470
|
reason: "override"
|
|
471
471
|
});
|
|
472
472
|
return decision2;
|
|
473
473
|
}
|
|
474
474
|
const decisionPromise = (async () => {
|
|
475
475
|
return decide({
|
|
476
|
+
// @ts-expect-error TypeScript will not be able to process `getPrecomputed` when added to `Decide`. It is, however, part of the `Adapter` type
|
|
477
|
+
defaultValue: definition.defaultValue,
|
|
476
478
|
headers: readonlyHeaders,
|
|
477
479
|
cookies: readonlyCookies,
|
|
478
480
|
entities
|
|
@@ -517,7 +519,7 @@ function getRun(definition, decide) {
|
|
|
517
519
|
);
|
|
518
520
|
const decision = await decisionPromise;
|
|
519
521
|
if (_optionalChain([definition, 'access', _15 => _15.config, 'optionalAccess', _16 => _16.reportValue]) !== false) {
|
|
520
|
-
|
|
522
|
+
_chunkIGXYQW6Rcjs.reportValue.call(void 0, definition.key, decision);
|
|
521
523
|
}
|
|
522
524
|
return decision;
|
|
523
525
|
};
|
|
@@ -534,13 +536,13 @@ function flag(definition) {
|
|
|
534
536
|
const identify = getIdentify(definition);
|
|
535
537
|
const run = getRun(definition, decide);
|
|
536
538
|
const origin = getOrigin(definition);
|
|
537
|
-
const flag2 =
|
|
539
|
+
const flag2 = _chunkIGXYQW6Rcjs.trace.call(void 0,
|
|
538
540
|
async (...args) => {
|
|
539
|
-
|
|
541
|
+
_chunkIGXYQW6Rcjs.setSpanAttribute.call(void 0, "method", "decided");
|
|
540
542
|
if (typeof args[0] === "string" && Array.isArray(args[1])) {
|
|
541
543
|
const [precomputedCode, precomputedGroup, secret] = args;
|
|
542
544
|
if (precomputedCode && precomputedGroup) {
|
|
543
|
-
|
|
545
|
+
_chunkIGXYQW6Rcjs.setSpanAttribute.call(void 0, "method", "precomputed");
|
|
544
546
|
return getPrecomputed(
|
|
545
547
|
flag2,
|
|
546
548
|
precomputedGroup,
|
|
@@ -566,17 +568,17 @@ function flag(definition) {
|
|
|
566
568
|
flag2.origin = origin;
|
|
567
569
|
flag2.options = _chunkAVMIIWOFcjs.normalizeOptions.call(void 0, definition.options);
|
|
568
570
|
flag2.description = definition.description;
|
|
569
|
-
flag2.identify = identify ?
|
|
571
|
+
flag2.identify = identify ? _chunkIGXYQW6Rcjs.trace.call(void 0, identify, {
|
|
570
572
|
isVerboseTrace: false,
|
|
571
573
|
name: "identify",
|
|
572
574
|
attributes: { key: definition.key }
|
|
573
575
|
}) : identify;
|
|
574
|
-
flag2.decide =
|
|
576
|
+
flag2.decide = _chunkIGXYQW6Rcjs.trace.call(void 0, decide, {
|
|
575
577
|
isVerboseTrace: false,
|
|
576
578
|
name: "decide",
|
|
577
579
|
attributes: { key: definition.key }
|
|
578
580
|
});
|
|
579
|
-
flag2.run =
|
|
581
|
+
flag2.run = _chunkIGXYQW6Rcjs.trace.call(void 0, run, {
|
|
580
582
|
isVerboseTrace: false,
|
|
581
583
|
name: "run",
|
|
582
584
|
attributes: { key: definition.key }
|