flags 0.2.1 → 3.1.1

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.
Files changed (55) hide show
  1. package/CHANGELOG.md +428 -0
  2. package/LICENSE.md +21 -0
  3. package/README.md +44 -93
  4. package/dist/analytics.cjs +7 -0
  5. package/dist/analytics.cjs.map +1 -0
  6. package/dist/analytics.d.cts +8 -0
  7. package/dist/analytics.d.ts +8 -0
  8. package/dist/analytics.js +7 -0
  9. package/dist/analytics.js.map +1 -0
  10. package/dist/chunk-2UDLZC33.js +9 -0
  11. package/dist/chunk-2UDLZC33.js.map +1 -0
  12. package/dist/chunk-AVMIIWOF.cjs +21 -0
  13. package/dist/chunk-AVMIIWOF.cjs.map +1 -0
  14. package/dist/chunk-D2GBVCQQ.cjs +406 -0
  15. package/dist/chunk-D2GBVCQQ.cjs.map +1 -0
  16. package/dist/chunk-MEG7RDX7.cjs +9 -0
  17. package/dist/chunk-MEG7RDX7.cjs.map +1 -0
  18. package/dist/chunk-OQHOV3IB.js +406 -0
  19. package/dist/chunk-OQHOV3IB.js.map +1 -0
  20. package/dist/chunk-ZNKTXALY.js +21 -0
  21. package/dist/chunk-ZNKTXALY.js.map +1 -0
  22. package/dist/index.cjs +25 -0
  23. package/dist/index.cjs.map +1 -0
  24. package/dist/index.d.cts +89 -0
  25. package/dist/index.d.ts +89 -0
  26. package/dist/index.js +25 -0
  27. package/dist/index.js.map +1 -0
  28. package/dist/next.cjs +611 -0
  29. package/dist/next.cjs.map +1 -0
  30. package/dist/next.d.cts +191 -0
  31. package/dist/next.d.ts +191 -0
  32. package/dist/next.js +611 -0
  33. package/dist/next.js.map +1 -0
  34. package/dist/react.cjs +39 -0
  35. package/dist/react.cjs.map +1 -0
  36. package/dist/react.d.cts +20 -0
  37. package/dist/react.d.ts +20 -0
  38. package/dist/react.js +39 -0
  39. package/dist/react.js.map +1 -0
  40. package/dist/sveltekit.cjs +171 -0
  41. package/dist/sveltekit.cjs.map +1 -0
  42. package/dist/sveltekit.d.cts +42 -0
  43. package/dist/sveltekit.d.ts +42 -0
  44. package/dist/sveltekit.js +171 -0
  45. package/dist/sveltekit.js.map +1 -0
  46. package/dist/types-swW0-Ony.d.cts +236 -0
  47. package/dist/types-swW0-Ony.d.ts +236 -0
  48. package/package.json +112 -28
  49. package/LICENSE +0 -9
  50. package/dist/flags.cjs +0 -366
  51. package/dist/flags.cjs.map +0 -1
  52. package/dist/flags.d.cts +0 -84
  53. package/dist/flags.d.ts +0 -84
  54. package/dist/flags.js +0 -330
  55. package/dist/flags.js.map +0 -1
@@ -0,0 +1,89 @@
1
+ import { TracerProvider } from '@opentelemetry/api';
2
+ import { P as ProviderData } from './types-swW0-Ony.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-swW0-Ony.js';
4
+ import 'http';
5
+ import '@edge-runtime/cookies';
6
+
7
+ /**
8
+ * Allows setting the `@opentelemetry/api` tracer provider to generate traces
9
+ * for `flags` operations.
10
+ */
11
+ declare function setTracerProvider(tracer: TracerProvider): void;
12
+
13
+ /**
14
+ * Converts a JavaScript value to a JavaScript Object Notation (JSON) string.
15
+ *
16
+ * This function is just like JSON.stringify but also escapes the resulting string to prevent XSS.
17
+ *
18
+ * @see https://pragmaticwebsecurity.com/articles/spasecurity/json-stringify-xss
19
+ * @param value A JavaScript value, usually an object or array, to be converted.
20
+ * @param replacer A function that transforms the results.
21
+ * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
22
+ */
23
+ declare function safeJsonStringify(value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string;
24
+ /**
25
+ * Converts a JavaScript value to a JavaScript Object Notation (JSON) string.
26
+ *
27
+ * This function is just like JSON.stringify but also escapes the resulting string to prevent XSS.
28
+ *
29
+ * @see https://pragmaticwebsecurity.com/articles/spasecurity/json-stringify-xss
30
+ * @param value A JavaScript value, usually an object or array, to be converted.
31
+ * @param replacer An array of strings and numbers that acts as an approved list for selecting the object properties that will be stringified.
32
+ * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
33
+ */
34
+ declare function safeJsonStringify(value: any, replacer?: (number | string)[] | null, space?: string | number): string;
35
+
36
+ /**
37
+ * Function to encrypt overrides, values, definitions, and API data.
38
+ */
39
+ declare function encrypt<T extends object>(value: T, secret?: string | undefined): Promise<string>;
40
+ /**
41
+ * Function to decrypt overrides, values, definitions, and API data.
42
+ */
43
+ declare function decrypt<T extends object>(encryptedData: string, secret?: string | undefined): Promise<T | undefined>;
44
+
45
+ /**
46
+ * This function lets you verify whether a request to your application's .well-known/vercel/flags endpoint was made by the toolbar.
47
+ * You can use verifyAccess to keep this endpoint private, to avoid public access of your feature flag definitions through that endpoint.
48
+ *
49
+ * @example Using verifyAccess in .well-known/vercel/flags to verify access and respond with unencrypted data.
50
+ * ```
51
+ * import { type NextRequest, NextResponse } from "next/server";
52
+ * import { verifyAccess } from "flags";
53
+ *
54
+ * export async function GET(request: NextRequest) {
55
+ * const access = await verifyAccess(request.headers.get("Authorization"));
56
+ * if (!access) return NextResponse.json(null, { status: 401 });
57
+ *
58
+ * return NextResponse.json({ definitions: {} })
59
+ * }
60
+ * ```
61
+ * @param authHeader the Authorization header to check
62
+ * @param secret the FLAGS_SECRET
63
+ * @returns True when the authorization header was valid
64
+ */
65
+ declare const verifyAccess: (authHeader: string | null | undefined, secret?: string | undefined) => Promise<boolean>;
66
+
67
+ /**
68
+ * 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.
69
+ * 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.
70
+ *
71
+ * @example Using `reportValue` to report a flag value.
72
+ * ```
73
+ * import { type NextRequest, NextResponse } from "next/server";
74
+ * import { reportValue } from 'flags';
75
+ *
76
+ * export async function GET(request: NextRequest) {
77
+ * reportValue('my-flag', true);
78
+ * return NextResponse.json({});
79
+ * }
80
+ * ```
81
+ *
82
+ * @param key the name of the flag
83
+ * @param value the resolved value of the flag
84
+ */
85
+ declare function reportValue(key: string, value: unknown): void;
86
+
87
+ declare function mergeProviderData(itemsPromises: (Promise<ProviderData> | ProviderData)[]): Promise<ProviderData>;
88
+
89
+ export { ProviderData, decrypt, encrypt, mergeProviderData, reportValue, safeJsonStringify, setTracerProvider, verifyAccess };
package/dist/index.js ADDED
@@ -0,0 +1,25 @@
1
+ import {
2
+ HeadersAdapter,
3
+ RequestCookiesAdapter,
4
+ decrypt,
5
+ encrypt,
6
+ mergeProviderData,
7
+ reportValue,
8
+ setTracerProvider,
9
+ verifyAccess
10
+ } from "./chunk-OQHOV3IB.js";
11
+ import {
12
+ safeJsonStringify
13
+ } from "./chunk-2UDLZC33.js";
14
+ export {
15
+ HeadersAdapter,
16
+ RequestCookiesAdapter,
17
+ decrypt,
18
+ encrypt,
19
+ mergeProviderData,
20
+ reportValue,
21
+ safeJsonStringify,
22
+ setTracerProvider,
23
+ verifyAccess
24
+ };
25
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}