flags 4.0.1 → 4.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -20
- package/README.md +4 -4
- package/dist/{chunk-O6VYPARG.js → chunk-CIQRIQPS.js} +10 -10
- package/dist/chunk-CIQRIQPS.js.map +1 -0
- package/dist/{chunk-RIRV5SST.cjs → chunk-JUWXY2C3.cjs} +139 -139
- package/dist/chunk-JUWXY2C3.cjs.map +1 -0
- package/dist/{chunk-QLJ65HXQ.cjs → chunk-RGAQJSYN.cjs} +9 -9
- package/dist/chunk-RGAQJSYN.cjs.map +1 -0
- package/dist/{chunk-ISCGLTLL.js → chunk-SLBSERE6.js} +137 -137
- package/dist/chunk-SLBSERE6.js.map +1 -0
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +54 -54
- package/dist/index.d.ts +54 -54
- package/dist/index.js +1 -1
- package/dist/next.cjs +57 -55
- package/dist/next.cjs.map +1 -1
- package/dist/next.d.cts +14 -16
- package/dist/next.d.ts +14 -16
- package/dist/next.js +39 -37
- package/dist/next.js.map +1 -1
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js.map +1 -1
- package/dist/sveltekit.cjs +47 -47
- package/dist/sveltekit.cjs.map +1 -1
- package/dist/sveltekit.d.cts +1 -1
- package/dist/sveltekit.d.ts +1 -1
- package/dist/sveltekit.js +26 -26
- package/dist/sveltekit.js.map +1 -1
- package/dist/{types-CisDd6Kq.d.ts → types-lxHzenVJ.d.cts} +1 -1
- package/dist/{types-CisDd6Kq.d.cts → types-lxHzenVJ.d.ts} +1 -1
- package/package.json +3 -6
- package/dist/chunk-ISCGLTLL.js.map +0 -1
- package/dist/chunk-O6VYPARG.js.map +0 -1
- package/dist/chunk-QLJ65HXQ.cjs.map +0 -1
- package/dist/chunk-RIRV5SST.cjs.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,39 +1,10 @@
|
|
|
1
|
+
import { F as FlagDefinitionsType, a as FlagValuesType, b as FlagOverridesType, P as ProviderData } from './types-lxHzenVJ.cjs';
|
|
2
|
+
export { A as Adapter, e as ApiData, D as Decide, f as FlagDeclaration, g as FlagDefinitionType, h as FlagOptionType, G as GenerousOption, H as HeadersAdapter, I as Identify, J as JsonValue, O as Origin, R as ReadonlyHeaders, c as ReadonlyRequestCookies, d as RequestCookiesAdapter } from './types-lxHzenVJ.cjs';
|
|
1
3
|
import { TracerProvider } from '@opentelemetry/api';
|
|
2
|
-
import { F as FlagOverridesType, a as FlagValuesType, b as FlagDefinitionsType, P as ProviderData } from './types-CisDd6Kq.cjs';
|
|
3
|
-
export { A as Adapter, c as ApiData, D as Decide, f as FlagDeclaration, e as FlagDefinitionType, d as FlagOptionType, 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-CisDd6Kq.cjs';
|
|
4
4
|
import 'http';
|
|
5
5
|
import '@edge-runtime/cookies';
|
|
6
6
|
|
|
7
|
-
var version = "4.0.
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Allows setting the `@opentelemetry/api` tracer provider to generate traces
|
|
11
|
-
* for `flags` operations.
|
|
12
|
-
*/
|
|
13
|
-
declare function setTracerProvider(tracer: TracerProvider): void;
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Converts a JavaScript value to a JavaScript Object Notation (JSON) string.
|
|
17
|
-
*
|
|
18
|
-
* This function is just like JSON.stringify but also escapes the resulting string to prevent XSS.
|
|
19
|
-
*
|
|
20
|
-
* @see https://pragmaticwebsecurity.com/articles/spasecurity/json-stringify-xss
|
|
21
|
-
* @param value A JavaScript value, usually an object or array, to be converted.
|
|
22
|
-
* @param replacer A function that transforms the results.
|
|
23
|
-
* @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
|
|
24
|
-
*/
|
|
25
|
-
declare function safeJsonStringify(value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string;
|
|
26
|
-
/**
|
|
27
|
-
* Converts a JavaScript value to a JavaScript Object Notation (JSON) string.
|
|
28
|
-
*
|
|
29
|
-
* This function is just like JSON.stringify but also escapes the resulting string to prevent XSS.
|
|
30
|
-
*
|
|
31
|
-
* @see https://pragmaticwebsecurity.com/articles/spasecurity/json-stringify-xss
|
|
32
|
-
* @param value A JavaScript value, usually an object or array, to be converted.
|
|
33
|
-
* @param replacer An array of strings and numbers that acts as an approved list for selecting the object properties that will be stringified.
|
|
34
|
-
* @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
|
|
35
|
-
*/
|
|
36
|
-
declare function safeJsonStringify(value: any, replacer?: (number | string)[] | null, space?: string | number): string;
|
|
7
|
+
var version = "4.0.2";
|
|
37
8
|
|
|
38
9
|
type ExpirationTime = string | number | Date;
|
|
39
10
|
/**
|
|
@@ -112,27 +83,7 @@ declare function createAccessProof(secret?: string | undefined, expirationTime?:
|
|
|
112
83
|
*/
|
|
113
84
|
declare function verifyAccessProof(encryptedData: string, secret?: string | undefined): Promise<boolean>;
|
|
114
85
|
|
|
115
|
-
|
|
116
|
-
* This function lets you verify whether a request to your application's .well-known/vercel/flags endpoint was made by the toolbar.
|
|
117
|
-
* You can use verifyAccess to keep this endpoint private, to avoid public access of your feature flag definitions through that endpoint.
|
|
118
|
-
*
|
|
119
|
-
* @example Using verifyAccess in .well-known/vercel/flags to verify access and respond with unencrypted data.
|
|
120
|
-
* ```
|
|
121
|
-
* import { type NextRequest, NextResponse } from "next/server";
|
|
122
|
-
* import { verifyAccess } from "flags";
|
|
123
|
-
*
|
|
124
|
-
* export async function GET(request: NextRequest) {
|
|
125
|
-
* const access = await verifyAccess(request.headers.get("Authorization"));
|
|
126
|
-
* if (!access) return NextResponse.json(null, { status: 401 });
|
|
127
|
-
*
|
|
128
|
-
* return NextResponse.json({ definitions: {} })
|
|
129
|
-
* }
|
|
130
|
-
* ```
|
|
131
|
-
* @param authHeader the Authorization header to check
|
|
132
|
-
* @param secret the FLAGS_SECRET
|
|
133
|
-
* @returns True when the authorization header was valid
|
|
134
|
-
*/
|
|
135
|
-
declare const verifyAccess: (authHeader: string | null | undefined, secret?: string | undefined) => Promise<boolean>;
|
|
86
|
+
declare function mergeProviderData(itemsPromises: (Promise<ProviderData> | ProviderData)[]): Promise<ProviderData>;
|
|
136
87
|
|
|
137
88
|
/**
|
|
138
89
|
* 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.
|
|
@@ -154,6 +105,55 @@ declare const verifyAccess: (authHeader: string | null | undefined, secret?: str
|
|
|
154
105
|
*/
|
|
155
106
|
declare function reportValue(key: string, value: unknown): void;
|
|
156
107
|
|
|
157
|
-
|
|
108
|
+
/**
|
|
109
|
+
* Converts a JavaScript value to a JavaScript Object Notation (JSON) string.
|
|
110
|
+
*
|
|
111
|
+
* This function is just like JSON.stringify but also escapes the resulting string to prevent XSS.
|
|
112
|
+
*
|
|
113
|
+
* @see https://pragmaticwebsecurity.com/articles/spasecurity/json-stringify-xss
|
|
114
|
+
* @param value A JavaScript value, usually an object or array, to be converted.
|
|
115
|
+
* @param replacer A function that transforms the results.
|
|
116
|
+
* @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
|
|
117
|
+
*/
|
|
118
|
+
declare function safeJsonStringify(value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string;
|
|
119
|
+
/**
|
|
120
|
+
* Converts a JavaScript value to a JavaScript Object Notation (JSON) string.
|
|
121
|
+
*
|
|
122
|
+
* This function is just like JSON.stringify but also escapes the resulting string to prevent XSS.
|
|
123
|
+
*
|
|
124
|
+
* @see https://pragmaticwebsecurity.com/articles/spasecurity/json-stringify-xss
|
|
125
|
+
* @param value A JavaScript value, usually an object or array, to be converted.
|
|
126
|
+
* @param replacer An array of strings and numbers that acts as an approved list for selecting the object properties that will be stringified.
|
|
127
|
+
* @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
|
|
128
|
+
*/
|
|
129
|
+
declare function safeJsonStringify(value: any, replacer?: (number | string)[] | null, space?: string | number): string;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Allows setting the `@opentelemetry/api` tracer provider to generate traces
|
|
133
|
+
* for `flags` operations.
|
|
134
|
+
*/
|
|
135
|
+
declare function setTracerProvider(tracer: TracerProvider): void;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* This function lets you verify whether a request to your application's .well-known/vercel/flags endpoint was made by the toolbar.
|
|
139
|
+
* You can use verifyAccess to keep this endpoint private, to avoid public access of your feature flag definitions through that endpoint.
|
|
140
|
+
*
|
|
141
|
+
* @example Using verifyAccess in .well-known/vercel/flags to verify access and respond with unencrypted data.
|
|
142
|
+
* ```
|
|
143
|
+
* import { type NextRequest, NextResponse } from "next/server";
|
|
144
|
+
* import { verifyAccess } from "flags";
|
|
145
|
+
*
|
|
146
|
+
* export async function GET(request: NextRequest) {
|
|
147
|
+
* const access = await verifyAccess(request.headers.get("Authorization"));
|
|
148
|
+
* if (!access) return NextResponse.json(null, { status: 401 });
|
|
149
|
+
*
|
|
150
|
+
* return NextResponse.json({ definitions: {} })
|
|
151
|
+
* }
|
|
152
|
+
* ```
|
|
153
|
+
* @param authHeader the Authorization header to check
|
|
154
|
+
* @param secret the FLAGS_SECRET
|
|
155
|
+
* @returns True when the authorization header was valid
|
|
156
|
+
*/
|
|
157
|
+
declare const verifyAccess: (authHeader: string | null | undefined, secret?: string | undefined) => Promise<boolean>;
|
|
158
158
|
|
|
159
159
|
export { FlagDefinitionsType, FlagOverridesType, FlagValuesType, ProviderData, createAccessProof, decryptFlagDefinitions, decryptFlagValues, decryptOverrides, encryptFlagDefinitions, encryptFlagValues, encryptOverrides, mergeProviderData, reportValue, safeJsonStringify, setTracerProvider, verifyAccess, verifyAccessProof, version };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,39 +1,10 @@
|
|
|
1
|
+
import { F as FlagDefinitionsType, a as FlagValuesType, b as FlagOverridesType, P as ProviderData } from './types-lxHzenVJ.js';
|
|
2
|
+
export { A as Adapter, e as ApiData, D as Decide, f as FlagDeclaration, g as FlagDefinitionType, h as FlagOptionType, G as GenerousOption, H as HeadersAdapter, I as Identify, J as JsonValue, O as Origin, R as ReadonlyHeaders, c as ReadonlyRequestCookies, d as RequestCookiesAdapter } from './types-lxHzenVJ.js';
|
|
1
3
|
import { TracerProvider } from '@opentelemetry/api';
|
|
2
|
-
import { F as FlagOverridesType, a as FlagValuesType, b as FlagDefinitionsType, P as ProviderData } from './types-CisDd6Kq.js';
|
|
3
|
-
export { A as Adapter, c as ApiData, D as Decide, f as FlagDeclaration, e as FlagDefinitionType, d as FlagOptionType, 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-CisDd6Kq.js';
|
|
4
4
|
import 'http';
|
|
5
5
|
import '@edge-runtime/cookies';
|
|
6
6
|
|
|
7
|
-
var version = "4.0.
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Allows setting the `@opentelemetry/api` tracer provider to generate traces
|
|
11
|
-
* for `flags` operations.
|
|
12
|
-
*/
|
|
13
|
-
declare function setTracerProvider(tracer: TracerProvider): void;
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Converts a JavaScript value to a JavaScript Object Notation (JSON) string.
|
|
17
|
-
*
|
|
18
|
-
* This function is just like JSON.stringify but also escapes the resulting string to prevent XSS.
|
|
19
|
-
*
|
|
20
|
-
* @see https://pragmaticwebsecurity.com/articles/spasecurity/json-stringify-xss
|
|
21
|
-
* @param value A JavaScript value, usually an object or array, to be converted.
|
|
22
|
-
* @param replacer A function that transforms the results.
|
|
23
|
-
* @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
|
|
24
|
-
*/
|
|
25
|
-
declare function safeJsonStringify(value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string;
|
|
26
|
-
/**
|
|
27
|
-
* Converts a JavaScript value to a JavaScript Object Notation (JSON) string.
|
|
28
|
-
*
|
|
29
|
-
* This function is just like JSON.stringify but also escapes the resulting string to prevent XSS.
|
|
30
|
-
*
|
|
31
|
-
* @see https://pragmaticwebsecurity.com/articles/spasecurity/json-stringify-xss
|
|
32
|
-
* @param value A JavaScript value, usually an object or array, to be converted.
|
|
33
|
-
* @param replacer An array of strings and numbers that acts as an approved list for selecting the object properties that will be stringified.
|
|
34
|
-
* @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
|
|
35
|
-
*/
|
|
36
|
-
declare function safeJsonStringify(value: any, replacer?: (number | string)[] | null, space?: string | number): string;
|
|
7
|
+
var version = "4.0.2";
|
|
37
8
|
|
|
38
9
|
type ExpirationTime = string | number | Date;
|
|
39
10
|
/**
|
|
@@ -112,27 +83,7 @@ declare function createAccessProof(secret?: string | undefined, expirationTime?:
|
|
|
112
83
|
*/
|
|
113
84
|
declare function verifyAccessProof(encryptedData: string, secret?: string | undefined): Promise<boolean>;
|
|
114
85
|
|
|
115
|
-
|
|
116
|
-
* This function lets you verify whether a request to your application's .well-known/vercel/flags endpoint was made by the toolbar.
|
|
117
|
-
* You can use verifyAccess to keep this endpoint private, to avoid public access of your feature flag definitions through that endpoint.
|
|
118
|
-
*
|
|
119
|
-
* @example Using verifyAccess in .well-known/vercel/flags to verify access and respond with unencrypted data.
|
|
120
|
-
* ```
|
|
121
|
-
* import { type NextRequest, NextResponse } from "next/server";
|
|
122
|
-
* import { verifyAccess } from "flags";
|
|
123
|
-
*
|
|
124
|
-
* export async function GET(request: NextRequest) {
|
|
125
|
-
* const access = await verifyAccess(request.headers.get("Authorization"));
|
|
126
|
-
* if (!access) return NextResponse.json(null, { status: 401 });
|
|
127
|
-
*
|
|
128
|
-
* return NextResponse.json({ definitions: {} })
|
|
129
|
-
* }
|
|
130
|
-
* ```
|
|
131
|
-
* @param authHeader the Authorization header to check
|
|
132
|
-
* @param secret the FLAGS_SECRET
|
|
133
|
-
* @returns True when the authorization header was valid
|
|
134
|
-
*/
|
|
135
|
-
declare const verifyAccess: (authHeader: string | null | undefined, secret?: string | undefined) => Promise<boolean>;
|
|
86
|
+
declare function mergeProviderData(itemsPromises: (Promise<ProviderData> | ProviderData)[]): Promise<ProviderData>;
|
|
136
87
|
|
|
137
88
|
/**
|
|
138
89
|
* 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.
|
|
@@ -154,6 +105,55 @@ declare const verifyAccess: (authHeader: string | null | undefined, secret?: str
|
|
|
154
105
|
*/
|
|
155
106
|
declare function reportValue(key: string, value: unknown): void;
|
|
156
107
|
|
|
157
|
-
|
|
108
|
+
/**
|
|
109
|
+
* Converts a JavaScript value to a JavaScript Object Notation (JSON) string.
|
|
110
|
+
*
|
|
111
|
+
* This function is just like JSON.stringify but also escapes the resulting string to prevent XSS.
|
|
112
|
+
*
|
|
113
|
+
* @see https://pragmaticwebsecurity.com/articles/spasecurity/json-stringify-xss
|
|
114
|
+
* @param value A JavaScript value, usually an object or array, to be converted.
|
|
115
|
+
* @param replacer A function that transforms the results.
|
|
116
|
+
* @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
|
|
117
|
+
*/
|
|
118
|
+
declare function safeJsonStringify(value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string;
|
|
119
|
+
/**
|
|
120
|
+
* Converts a JavaScript value to a JavaScript Object Notation (JSON) string.
|
|
121
|
+
*
|
|
122
|
+
* This function is just like JSON.stringify but also escapes the resulting string to prevent XSS.
|
|
123
|
+
*
|
|
124
|
+
* @see https://pragmaticwebsecurity.com/articles/spasecurity/json-stringify-xss
|
|
125
|
+
* @param value A JavaScript value, usually an object or array, to be converted.
|
|
126
|
+
* @param replacer An array of strings and numbers that acts as an approved list for selecting the object properties that will be stringified.
|
|
127
|
+
* @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
|
|
128
|
+
*/
|
|
129
|
+
declare function safeJsonStringify(value: any, replacer?: (number | string)[] | null, space?: string | number): string;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Allows setting the `@opentelemetry/api` tracer provider to generate traces
|
|
133
|
+
* for `flags` operations.
|
|
134
|
+
*/
|
|
135
|
+
declare function setTracerProvider(tracer: TracerProvider): void;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* This function lets you verify whether a request to your application's .well-known/vercel/flags endpoint was made by the toolbar.
|
|
139
|
+
* You can use verifyAccess to keep this endpoint private, to avoid public access of your feature flag definitions through that endpoint.
|
|
140
|
+
*
|
|
141
|
+
* @example Using verifyAccess in .well-known/vercel/flags to verify access and respond with unencrypted data.
|
|
142
|
+
* ```
|
|
143
|
+
* import { type NextRequest, NextResponse } from "next/server";
|
|
144
|
+
* import { verifyAccess } from "flags";
|
|
145
|
+
*
|
|
146
|
+
* export async function GET(request: NextRequest) {
|
|
147
|
+
* const access = await verifyAccess(request.headers.get("Authorization"));
|
|
148
|
+
* if (!access) return NextResponse.json(null, { status: 401 });
|
|
149
|
+
*
|
|
150
|
+
* return NextResponse.json({ definitions: {} })
|
|
151
|
+
* }
|
|
152
|
+
* ```
|
|
153
|
+
* @param authHeader the Authorization header to check
|
|
154
|
+
* @param secret the FLAGS_SECRET
|
|
155
|
+
* @returns True when the authorization header was valid
|
|
156
|
+
*/
|
|
157
|
+
declare const verifyAccess: (authHeader: string | null | undefined, secret?: string | undefined) => Promise<boolean>;
|
|
158
158
|
|
|
159
159
|
export { FlagDefinitionsType, FlagOverridesType, FlagValuesType, ProviderData, createAccessProof, decryptFlagDefinitions, decryptFlagValues, decryptOverrides, encryptFlagDefinitions, encryptFlagValues, encryptOverrides, mergeProviderData, reportValue, safeJsonStringify, setTracerProvider, verifyAccess, verifyAccessProof, version };
|
package/dist/index.js
CHANGED
package/dist/next.cjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkRGAQJSYNcjs = require('./chunk-RGAQJSYN.cjs');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
@@ -14,15 +14,30 @@ var _chunkQLJ65HXQcjs = require('./chunk-QLJ65HXQ.cjs');
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
var
|
|
17
|
+
var _chunkJUWXY2C3cjs = require('./chunk-JUWXY2C3.cjs');
|
|
18
18
|
require('./chunk-MEG7RDX7.cjs');
|
|
19
19
|
|
|
20
20
|
// src/next/index.ts
|
|
21
21
|
var _cookies = require('@edge-runtime/cookies');
|
|
22
22
|
|
|
23
|
+
// src/next/is-internal-next-error.ts
|
|
24
|
+
var REACT_POSTPONE_TYPE = Symbol.for("react.postpone");
|
|
25
|
+
function isPostpone(error) {
|
|
26
|
+
return typeof error === "object" && error !== null && "$$typeof" in error && error.$$typeof === REACT_POSTPONE_TYPE;
|
|
27
|
+
}
|
|
28
|
+
function isInternalNextError(error) {
|
|
29
|
+
if (isPostpone(error))
|
|
30
|
+
return true;
|
|
31
|
+
if (typeof error !== "object" || error === null || !("digest" in error) || typeof error.digest !== "string") {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
const errorCode = error.digest.split(";")[0];
|
|
35
|
+
return errorCode === "NEXT_REDIRECT" || errorCode === "DYNAMIC_SERVER_USAGE" || errorCode === "BAILOUT_TO_CLIENT_SIDE_RENDERING" || errorCode === "NEXT_NOT_FOUND";
|
|
36
|
+
}
|
|
37
|
+
|
|
23
38
|
// src/next/overrides.ts
|
|
24
|
-
var memoizedDecrypt =
|
|
25
|
-
(text) =>
|
|
39
|
+
var memoizedDecrypt = _chunkRGAQJSYNcjs.memoizeOne.call(void 0,
|
|
40
|
+
(text) => _chunkJUWXY2C3cjs.decryptOverrides.call(void 0, text),
|
|
26
41
|
(a, b) => a[0] === b[0],
|
|
27
42
|
// only the first argument gets compared
|
|
28
43
|
{ cachePromiseRejection: true }
|
|
@@ -50,13 +65,13 @@ async function serialize2(flags, values, secret = process.env.FLAGS_SECRET) {
|
|
|
50
65
|
if (!secret) {
|
|
51
66
|
throw new Error("flags: Can not serialize due to missing secret");
|
|
52
67
|
}
|
|
53
|
-
return
|
|
68
|
+
return _chunkRGAQJSYNcjs.serialize.call(void 0, combine(flags, values), flags, secret);
|
|
54
69
|
}
|
|
55
70
|
async function deserialize2(flags, code, secret = process.env.FLAGS_SECRET) {
|
|
56
71
|
if (!secret) {
|
|
57
72
|
throw new Error("flags: Can not serialize due to missing secret");
|
|
58
73
|
}
|
|
59
|
-
return
|
|
74
|
+
return _chunkRGAQJSYNcjs.deserialize.call(void 0, code, flags, secret);
|
|
60
75
|
}
|
|
61
76
|
async function getPrecomputed(flagOrFlags, precomputeFlags, code, secret = process.env.FLAGS_SECRET) {
|
|
62
77
|
if (!secret) {
|
|
@@ -73,8 +88,8 @@ async function getPrecomputed(flagOrFlags, precomputeFlags, code, secret = proce
|
|
|
73
88
|
}
|
|
74
89
|
function* cartesianIterator(items) {
|
|
75
90
|
const remainder = items.length > 1 ? cartesianIterator(items.slice(1)) : [[]];
|
|
76
|
-
for (
|
|
77
|
-
for (
|
|
91
|
+
for (const r of remainder)
|
|
92
|
+
for (const h of items.at(0))
|
|
78
93
|
yield [h, ...r];
|
|
79
94
|
}
|
|
80
95
|
async function generatePermutations(flags, filter = null, secret = process.env.FLAGS_SECRET) {
|
|
@@ -100,22 +115,26 @@ async function generatePermutations(flags, filter = null, secret = process.env.F
|
|
|
100
115
|
if (!filter || filter(permObject))
|
|
101
116
|
list.push(permObject);
|
|
102
117
|
}
|
|
103
|
-
return Promise.all(list.map((values) =>
|
|
118
|
+
return Promise.all(list.map((values) => _chunkRGAQJSYNcjs.serialize.call(void 0, values, flags, secret)));
|
|
104
119
|
}
|
|
105
120
|
|
|
106
|
-
// src/next/
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
121
|
+
// src/next/create-flags-discovery-endpoint.ts
|
|
122
|
+
function createFlagsDiscoveryEndpoint(getApiData, options) {
|
|
123
|
+
return async (request) => {
|
|
124
|
+
const access = await _chunkJUWXY2C3cjs.verifyAccess.call(void 0,
|
|
125
|
+
request.headers.get("Authorization"),
|
|
126
|
+
_optionalChain([options, 'optionalAccess', _ => _.secret])
|
|
127
|
+
);
|
|
128
|
+
if (!access)
|
|
129
|
+
return Response.json(null, { status: 401 });
|
|
130
|
+
const apiData = await getApiData(request);
|
|
131
|
+
return new Response(JSON.stringify(apiData), {
|
|
132
|
+
headers: {
|
|
133
|
+
"x-flags-sdk-version": _chunkJUWXY2C3cjs.version,
|
|
134
|
+
"content-type": "application/json"
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
};
|
|
119
138
|
}
|
|
120
139
|
|
|
121
140
|
// src/next/dedupe.ts
|
|
@@ -199,25 +218,6 @@ async function clearDedupeCacheForCurrentRequest(dedupedFn) {
|
|
|
199
218
|
return requestStore.delete(h);
|
|
200
219
|
}
|
|
201
220
|
|
|
202
|
-
// src/next/create-flags-discovery-endpoint.ts
|
|
203
|
-
function createFlagsDiscoveryEndpoint(getApiData, options) {
|
|
204
|
-
return async (request) => {
|
|
205
|
-
const access = await _chunkRIRV5SSTcjs.verifyAccess.call(void 0,
|
|
206
|
-
request.headers.get("Authorization"),
|
|
207
|
-
_optionalChain([options, 'optionalAccess', _ => _.secret])
|
|
208
|
-
);
|
|
209
|
-
if (!access)
|
|
210
|
-
return Response.json(null, { status: 401 });
|
|
211
|
-
const apiData = await getApiData(request);
|
|
212
|
-
return new Response(JSON.stringify(apiData), {
|
|
213
|
-
headers: {
|
|
214
|
-
"x-flags-sdk-version": _chunkRIRV5SSTcjs.version,
|
|
215
|
-
"content-type": "application/json"
|
|
216
|
-
}
|
|
217
|
-
});
|
|
218
|
-
};
|
|
219
|
-
}
|
|
220
|
-
|
|
221
221
|
// src/next/index.ts
|
|
222
222
|
var evaluationCache = /* @__PURE__ */ new WeakMap();
|
|
223
223
|
function getCachedValuePromise(headers, flagKey, entitiesKey) {
|
|
@@ -253,7 +253,9 @@ function transformToHeaders(incomingHeaders) {
|
|
|
253
253
|
const headers = new Headers();
|
|
254
254
|
for (const [key, value] of Object.entries(incomingHeaders)) {
|
|
255
255
|
if (Array.isArray(value)) {
|
|
256
|
-
value.forEach((item) =>
|
|
256
|
+
value.forEach((item) => {
|
|
257
|
+
headers.append(key, item);
|
|
258
|
+
});
|
|
257
259
|
} else if (value !== void 0) {
|
|
258
260
|
headers.append(key, value);
|
|
259
261
|
}
|
|
@@ -265,7 +267,7 @@ function sealHeaders(headers) {
|
|
|
265
267
|
const cached = headersMap.get(headers);
|
|
266
268
|
if (cached !== void 0)
|
|
267
269
|
return cached;
|
|
268
|
-
const sealed =
|
|
270
|
+
const sealed = _chunkJUWXY2C3cjs.HeadersAdapter.seal(headers);
|
|
269
271
|
headersMap.set(headers, sealed);
|
|
270
272
|
return sealed;
|
|
271
273
|
}
|
|
@@ -273,7 +275,7 @@ function sealCookies(headers) {
|
|
|
273
275
|
const cached = cookiesMap.get(headers);
|
|
274
276
|
if (cached !== void 0)
|
|
275
277
|
return cached;
|
|
276
|
-
const sealed =
|
|
278
|
+
const sealed = _chunkJUWXY2C3cjs.RequestCookiesAdapter.seal(new (0, _cookies.RequestCookies)(headers));
|
|
277
279
|
cookiesMap.set(headers, sealed);
|
|
278
280
|
return sealed;
|
|
279
281
|
}
|
|
@@ -352,12 +354,12 @@ function getRun(definition, decide) {
|
|
|
352
354
|
entitiesKey
|
|
353
355
|
);
|
|
354
356
|
if (cachedValue !== void 0) {
|
|
355
|
-
|
|
357
|
+
_chunkJUWXY2C3cjs.setSpanAttribute.call(void 0, "method", "cached");
|
|
356
358
|
const value = await cachedValue;
|
|
357
359
|
return value;
|
|
358
360
|
}
|
|
359
361
|
if (overrides && overrides[definition.key] !== void 0) {
|
|
360
|
-
|
|
362
|
+
_chunkJUWXY2C3cjs.setSpanAttribute.call(void 0, "method", "override");
|
|
361
363
|
const decision2 = overrides[definition.key];
|
|
362
364
|
setCachedValuePromise(
|
|
363
365
|
readonlyHeaders,
|
|
@@ -365,7 +367,7 @@ function getRun(definition, decide) {
|
|
|
365
367
|
entitiesKey,
|
|
366
368
|
Promise.resolve(decision2)
|
|
367
369
|
);
|
|
368
|
-
|
|
370
|
+
_chunkJUWXY2C3cjs.internalReportValue.call(void 0, definition.key, decision2, {
|
|
369
371
|
reason: "override"
|
|
370
372
|
});
|
|
371
373
|
return decision2;
|
|
@@ -418,7 +420,7 @@ function getRun(definition, decide) {
|
|
|
418
420
|
);
|
|
419
421
|
const decision = await decisionPromise;
|
|
420
422
|
if (_optionalChain([definition, 'access', _13 => _13.config, 'optionalAccess', _14 => _14.reportValue]) !== false) {
|
|
421
|
-
|
|
423
|
+
_chunkJUWXY2C3cjs.reportValue.call(void 0, definition.key, decision);
|
|
422
424
|
}
|
|
423
425
|
return decision;
|
|
424
426
|
};
|
|
@@ -435,13 +437,13 @@ function flag(definition) {
|
|
|
435
437
|
const identify = getIdentify(definition);
|
|
436
438
|
const run = getRun(definition, decide);
|
|
437
439
|
const origin = getOrigin(definition);
|
|
438
|
-
const flag2 =
|
|
440
|
+
const flag2 = _chunkJUWXY2C3cjs.trace.call(void 0,
|
|
439
441
|
async (...args) => {
|
|
440
|
-
|
|
442
|
+
_chunkJUWXY2C3cjs.setSpanAttribute.call(void 0, "method", "decided");
|
|
441
443
|
if (typeof args[0] === "string" && Array.isArray(args[1])) {
|
|
442
444
|
const [precomputedCode, precomputedGroup, secret] = args;
|
|
443
445
|
if (precomputedCode && precomputedGroup) {
|
|
444
|
-
|
|
446
|
+
_chunkJUWXY2C3cjs.setSpanAttribute.call(void 0, "method", "precomputed");
|
|
445
447
|
return getPrecomputed(
|
|
446
448
|
flag2,
|
|
447
449
|
precomputedGroup,
|
|
@@ -465,19 +467,19 @@ function flag(definition) {
|
|
|
465
467
|
flag2.key = definition.key;
|
|
466
468
|
flag2.defaultValue = definition.defaultValue;
|
|
467
469
|
flag2.origin = origin;
|
|
468
|
-
flag2.options =
|
|
470
|
+
flag2.options = _chunkRGAQJSYNcjs.normalizeOptions.call(void 0, definition.options);
|
|
469
471
|
flag2.description = definition.description;
|
|
470
|
-
flag2.identify = identify ?
|
|
472
|
+
flag2.identify = identify ? _chunkJUWXY2C3cjs.trace.call(void 0, identify, {
|
|
471
473
|
isVerboseTrace: false,
|
|
472
474
|
name: "identify",
|
|
473
475
|
attributes: { key: definition.key }
|
|
474
476
|
}) : identify;
|
|
475
|
-
flag2.decide =
|
|
477
|
+
flag2.decide = _chunkJUWXY2C3cjs.trace.call(void 0, decide, {
|
|
476
478
|
isVerboseTrace: false,
|
|
477
479
|
name: "decide",
|
|
478
480
|
attributes: { key: definition.key }
|
|
479
481
|
});
|
|
480
|
-
flag2.run =
|
|
482
|
+
flag2.run = _chunkJUWXY2C3cjs.trace.call(void 0, run, {
|
|
481
483
|
isVerboseTrace: false,
|
|
482
484
|
name: "run",
|
|
483
485
|
attributes: { key: definition.key }
|