@datadog/openfeature-node-server 2.6.0 → 2.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +220 -1
- package/cjs/configuration/client-fingerprint.d.ts +3 -0
- package/cjs/configuration/client-fingerprint.d.ts.map +1 -0
- package/cjs/configuration/client-fingerprint.js +30 -0
- package/cjs/configuration/client-fingerprint.js.map +1 -0
- package/cjs/configuration/configuration-fetch.d.ts +21 -0
- package/cjs/configuration/configuration-fetch.d.ts.map +1 -0
- package/cjs/configuration/configuration-fetch.js +125 -0
- package/cjs/configuration/configuration-fetch.js.map +1 -0
- package/cjs/configuration/evaluation.d.ts +1 -1
- package/cjs/configuration/evaluation.d.ts.map +1 -1
- package/cjs/configuration/evaluation.js +2 -2
- package/cjs/configuration/evaluation.js.map +1 -1
- package/cjs/configuration/fetch-precomputed-configuration.d.ts +28 -0
- package/cjs/configuration/fetch-precomputed-configuration.d.ts.map +1 -0
- package/cjs/configuration/fetch-precomputed-configuration.js +192 -0
- package/cjs/configuration/fetch-precomputed-configuration.js.map +1 -0
- package/cjs/configuration/fetch-rules-configuration.d.ts +3 -9
- package/cjs/configuration/fetch-rules-configuration.d.ts.map +1 -1
- package/cjs/configuration/fetch-rules-configuration.js +65 -126
- package/cjs/configuration/fetch-rules-configuration.js.map +1 -1
- package/cjs/configuration/flag-selection.d.ts +17 -0
- package/cjs/configuration/flag-selection.d.ts.map +1 -0
- package/cjs/configuration/flag-selection.js +29 -0
- package/cjs/configuration/flag-selection.js.map +1 -0
- package/cjs/configuration/precompute-configuration.d.ts +10 -0
- package/cjs/configuration/precompute-configuration.d.ts.map +1 -0
- package/cjs/configuration/precompute-configuration.js +38 -0
- package/cjs/configuration/precompute-configuration.js.map +1 -0
- package/cjs/experimentation-opt-out.d.ts +6 -0
- package/cjs/experimentation-opt-out.d.ts.map +1 -0
- package/cjs/experimentation-opt-out.js +17 -0
- package/cjs/experimentation-opt-out.js.map +1 -0
- package/cjs/index.d.ts +6 -0
- package/cjs/index.d.ts.map +1 -1
- package/cjs/index.js +12 -1
- package/cjs/index.js.map +1 -1
- package/cjs/provider.d.ts +59 -2
- package/cjs/provider.d.ts.map +1 -1
- package/cjs/provider.js +334 -34
- package/cjs/provider.js.map +1 -1
- package/cjs/rules-based.d.ts +4 -2
- package/cjs/rules-based.d.ts.map +1 -1
- package/cjs/rules-based.js +6 -1
- package/cjs/rules-based.js.map +1 -1
- package/cjs/sdk-diagnostics.d.ts +65 -0
- package/cjs/sdk-diagnostics.d.ts.map +1 -0
- package/cjs/sdk-diagnostics.js +123 -0
- package/cjs/sdk-diagnostics.js.map +1 -0
- package/esm/configuration/client-fingerprint.d.ts +3 -0
- package/esm/configuration/client-fingerprint.d.ts.map +1 -0
- package/esm/configuration/client-fingerprint.js +27 -0
- package/esm/configuration/client-fingerprint.js.map +1 -0
- package/esm/configuration/configuration-fetch.d.ts +21 -0
- package/esm/configuration/configuration-fetch.d.ts.map +1 -0
- package/esm/configuration/configuration-fetch.js +117 -0
- package/esm/configuration/configuration-fetch.js.map +1 -0
- package/esm/configuration/evaluation.d.ts +1 -1
- package/esm/configuration/evaluation.d.ts.map +1 -1
- package/esm/configuration/evaluation.js +1 -1
- package/esm/configuration/evaluation.js.map +1 -1
- package/esm/configuration/fetch-precomputed-configuration.d.ts +28 -0
- package/esm/configuration/fetch-precomputed-configuration.d.ts.map +1 -0
- package/esm/configuration/fetch-precomputed-configuration.js +189 -0
- package/esm/configuration/fetch-precomputed-configuration.js.map +1 -0
- package/esm/configuration/fetch-rules-configuration.d.ts +3 -9
- package/esm/configuration/fetch-rules-configuration.d.ts.map +1 -1
- package/esm/configuration/fetch-rules-configuration.js +56 -117
- package/esm/configuration/fetch-rules-configuration.js.map +1 -1
- package/esm/configuration/flag-selection.d.ts +17 -0
- package/esm/configuration/flag-selection.d.ts.map +1 -0
- package/esm/configuration/flag-selection.js +25 -0
- package/esm/configuration/flag-selection.js.map +1 -0
- package/esm/configuration/precompute-configuration.d.ts +10 -0
- package/esm/configuration/precompute-configuration.d.ts.map +1 -0
- package/esm/configuration/precompute-configuration.js +35 -0
- package/esm/configuration/precompute-configuration.js.map +1 -0
- package/esm/experimentation-opt-out.d.ts +6 -0
- package/esm/experimentation-opt-out.d.ts.map +1 -0
- package/esm/experimentation-opt-out.js +13 -0
- package/esm/experimentation-opt-out.js.map +1 -0
- package/esm/index.d.ts +6 -0
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +5 -1
- package/esm/index.js.map +1 -1
- package/esm/provider.d.ts +59 -2
- package/esm/provider.d.ts.map +1 -1
- package/esm/provider.js +333 -34
- package/esm/provider.js.map +1 -1
- package/esm/rules-based.d.ts +4 -2
- package/esm/rules-based.d.ts.map +1 -1
- package/esm/rules-based.js +3 -1
- package/esm/rules-based.js.map +1 -1
- package/esm/sdk-diagnostics.d.ts +65 -0
- package/esm/sdk-diagnostics.d.ts.map +1 -0
- package/esm/sdk-diagnostics.js +119 -0
- package/esm/sdk-diagnostics.js.map +1 -0
- package/index.d.ts +1172 -9
- package/package.json +2 -2
- package/rules-based.d.ts +248 -8
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fetchPrecomputedConfiguration = fetchPrecomputedConfiguration;
|
|
4
|
+
const flagging_core_1 = require("@datadog/flagging-core");
|
|
5
|
+
const client_fingerprint_1 = require("./client-fingerprint");
|
|
6
|
+
const configuration_fetch_1 = require("./configuration-fetch");
|
|
7
|
+
const flag_selection_1 = require("./flag-selection");
|
|
8
|
+
/** Fetch assignments for one client context, without initializing a provider or emitting tracking events. */
|
|
9
|
+
async function fetchPrecomputedConfiguration(options) {
|
|
10
|
+
let validated;
|
|
11
|
+
try {
|
|
12
|
+
validated = validateOptions(options);
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
if (error instanceof configuration_fetch_1.ConfigurationFetchError)
|
|
16
|
+
throw error;
|
|
17
|
+
throw (0, configuration_fetch_1.invalidOption)('precomputed configuration');
|
|
18
|
+
}
|
|
19
|
+
const { url, clientToken, applicationId, env, context, capabilities, optOut, flagSelection, logger, requestFetch, timeoutMs, signal, } = validated;
|
|
20
|
+
const body = JSON.stringify({
|
|
21
|
+
data: {
|
|
22
|
+
type: 'precompute-assignments-request',
|
|
23
|
+
attributes: {
|
|
24
|
+
env: { dd_env: env },
|
|
25
|
+
source: { sdk_name: 'nodejs', sdk_version: "2.8.0" },
|
|
26
|
+
...(optOut && { evaluation_options: { experimentation_opt_out_mode: optOut.mode } }),
|
|
27
|
+
...(flagSelection && {
|
|
28
|
+
flag_selection: { tags: flagSelection.tags, key_patterns: flagSelection.keyPatterns },
|
|
29
|
+
}),
|
|
30
|
+
subject: {
|
|
31
|
+
targeting_key: context.targetingKey || '',
|
|
32
|
+
targeting_attributes: Object.fromEntries(Object.entries(context).map(([key, value]) => [
|
|
33
|
+
key,
|
|
34
|
+
typeof value === 'string' ? value : JSON.stringify(value),
|
|
35
|
+
])),
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
return (0, configuration_fetch_1.requestConfiguration)(url.toString(), {
|
|
41
|
+
method: 'POST',
|
|
42
|
+
headers: {
|
|
43
|
+
Accept: 'application/vnd.api+json',
|
|
44
|
+
'Content-Type': 'application/vnd.api+json',
|
|
45
|
+
'dd-client-token': clientToken,
|
|
46
|
+
...(applicationId !== undefined && { 'dd-application-id': applicationId }),
|
|
47
|
+
},
|
|
48
|
+
body,
|
|
49
|
+
}, { fetch: requestFetch, timeoutMs, signal }, async (response, fetchedAt, checkAborted) => {
|
|
50
|
+
var _a;
|
|
51
|
+
if (flagSelection)
|
|
52
|
+
(0, flag_selection_1.reportIgnoredFlagSelection)(logger, response);
|
|
53
|
+
const contentType = (_a = response.headers.get('content-type')) === null || _a === void 0 ? void 0 : _a.split(';')[0].trim().toLowerCase();
|
|
54
|
+
if (contentType !== 'application/json' && contentType !== 'application/vnd.api+json') {
|
|
55
|
+
throw new configuration_fetch_1.ConfigurationFetchError('invalid_response', 'Expected a JSON configuration response');
|
|
56
|
+
}
|
|
57
|
+
let text;
|
|
58
|
+
try {
|
|
59
|
+
text = await response.text();
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
throw (0, configuration_fetch_1.transportError)('Configuration response could not be read', error);
|
|
63
|
+
}
|
|
64
|
+
checkAborted();
|
|
65
|
+
let json;
|
|
66
|
+
try {
|
|
67
|
+
json = JSON.parse(text);
|
|
68
|
+
}
|
|
69
|
+
catch (_b) {
|
|
70
|
+
throw new configuration_fetch_1.ConfigurationFetchError('decode', 'Configuration JSON could not be decoded');
|
|
71
|
+
}
|
|
72
|
+
const parsed = (0, flagging_core_1.parsePrecomputedConfigurationResponse)(json);
|
|
73
|
+
if ('error' in parsed)
|
|
74
|
+
throw new configuration_fetch_1.ConfigurationFetchError('decode', 'Invalid precomputed configuration response');
|
|
75
|
+
if (!(0, flagging_core_1.acknowledgesExperimentationOptOut)({ precomputed: parsed }, optOut)) {
|
|
76
|
+
throw new configuration_fetch_1.ConfigurationFetchError('decode', 'The assignment response did not acknowledge experimentation opt-out');
|
|
77
|
+
}
|
|
78
|
+
if (parsed.response.data.attributes.obfuscated === true && !capabilities.includes(flagging_core_1.FLAG_KEY_SHA256_CAPABILITY)) {
|
|
79
|
+
throw new configuration_fetch_1.ConfigurationFetchError('decode', 'Configuration encoding was not advertised by the target client');
|
|
80
|
+
}
|
|
81
|
+
const etag = response.headers.get('etag');
|
|
82
|
+
return { precomputed: { ...parsed, context, fetchedAt, ...(etag !== null && { etag }) } };
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
function validateOptions(options) {
|
|
86
|
+
const { distributionChannel, clientToken, apiKey, env, site = 'datadoghq.com', applicationId, context: inputContext, clientFingerprint, experimentationOptOutMode = 'disabled', flagSelection: inputSelection, logger = console, timeoutMs = 5000, signal, fetch: requestFetch = globalThis.fetch, } = options !== null && options !== void 0 ? options : {};
|
|
87
|
+
if (distributionChannel !== 'client')
|
|
88
|
+
throw (0, configuration_fetch_1.invalidOption)('distributionChannel');
|
|
89
|
+
if (apiKey !== undefined)
|
|
90
|
+
throw (0, configuration_fetch_1.invalidOption)('apiKey with client distribution channel');
|
|
91
|
+
if (experimentationOptOutMode !== 'disabled' &&
|
|
92
|
+
experimentationOptOutMode !== 'immediate' &&
|
|
93
|
+
experimentationOptOutMode !== 'future_experiments_only') {
|
|
94
|
+
throw (0, configuration_fetch_1.invalidOption)('experimentationOptOutMode');
|
|
95
|
+
}
|
|
96
|
+
if (typeof clientToken !== 'string' || !clientToken.trim() || /[\r\n]/.test(clientToken))
|
|
97
|
+
throw (0, configuration_fetch_1.invalidOption)('clientToken');
|
|
98
|
+
if (typeof env !== 'string' || !env.trim())
|
|
99
|
+
throw (0, configuration_fetch_1.invalidOption)('env');
|
|
100
|
+
if (applicationId !== undefined &&
|
|
101
|
+
(typeof applicationId !== 'string' || !applicationId.trim() || /[\r\n]/.test(applicationId))) {
|
|
102
|
+
throw (0, configuration_fetch_1.invalidOption)('applicationId');
|
|
103
|
+
}
|
|
104
|
+
(0, configuration_fetch_1.validateTransportOptions)(timeoutMs, signal, requestFetch);
|
|
105
|
+
if (!logger || typeof logger.error !== 'function')
|
|
106
|
+
throw (0, configuration_fetch_1.invalidOption)('logger');
|
|
107
|
+
let host;
|
|
108
|
+
try {
|
|
109
|
+
host = (0, flagging_core_1.buildEndpointHost)(site, 'preview');
|
|
110
|
+
}
|
|
111
|
+
catch (_a) {
|
|
112
|
+
throw (0, configuration_fetch_1.invalidOption)('site');
|
|
113
|
+
}
|
|
114
|
+
let capabilities;
|
|
115
|
+
try {
|
|
116
|
+
capabilities = (0, client_fingerprint_1.readPrecomputedCapabilities)(clientFingerprint);
|
|
117
|
+
}
|
|
118
|
+
catch (_b) {
|
|
119
|
+
throw (0, configuration_fetch_1.invalidOption)('clientFingerprint');
|
|
120
|
+
}
|
|
121
|
+
let context;
|
|
122
|
+
try {
|
|
123
|
+
if (!isRecord(inputContext))
|
|
124
|
+
throw new Error('Invalid context');
|
|
125
|
+
context = cloneJson(inputContext);
|
|
126
|
+
}
|
|
127
|
+
catch (_c) {
|
|
128
|
+
throw (0, configuration_fetch_1.invalidOption)('context (must contain only plain JSON values; convert dates to strings)');
|
|
129
|
+
}
|
|
130
|
+
if (context.targetingKey !== undefined && typeof context.targetingKey !== 'string')
|
|
131
|
+
throw (0, configuration_fetch_1.invalidOption)('context.targetingKey (must be a string)');
|
|
132
|
+
const optOut = (0, flagging_core_1.experimentationOptOutPolicy)(context, experimentationOptOutMode);
|
|
133
|
+
if (optOut === undefined)
|
|
134
|
+
throw (0, configuration_fetch_1.invalidOption)('context.dd_experimentation_opt_out_at');
|
|
135
|
+
let flagSelection;
|
|
136
|
+
try {
|
|
137
|
+
const { selection, error } = (0, flagging_core_1.canonicalizeFlagSelection)(inputSelection);
|
|
138
|
+
if (error)
|
|
139
|
+
(0, flag_selection_1.reportDroppedFlagSelection)(logger, error);
|
|
140
|
+
else
|
|
141
|
+
flagSelection = selection;
|
|
142
|
+
}
|
|
143
|
+
catch (_d) {
|
|
144
|
+
// Getters and proxies can expose caller data through raw errors.
|
|
145
|
+
(0, flag_selection_1.reportDroppedFlagSelection)(logger, 'malformed_selection');
|
|
146
|
+
}
|
|
147
|
+
const url = new URL(`https://${host}/precompute-assignments`);
|
|
148
|
+
url.searchParams.set('dd_env', env);
|
|
149
|
+
if (capabilities.includes(flagging_core_1.DEPENDENT_FLAG_VARIANT_KEY_CAPABILITY)) {
|
|
150
|
+
url.searchParams.set('cap_dependent-flags-variant-key', 'v1');
|
|
151
|
+
}
|
|
152
|
+
return {
|
|
153
|
+
url,
|
|
154
|
+
clientToken,
|
|
155
|
+
applicationId,
|
|
156
|
+
env,
|
|
157
|
+
context,
|
|
158
|
+
capabilities,
|
|
159
|
+
optOut,
|
|
160
|
+
flagSelection,
|
|
161
|
+
logger,
|
|
162
|
+
requestFetch,
|
|
163
|
+
timeoutMs,
|
|
164
|
+
signal,
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
function isRecord(value) {
|
|
168
|
+
return (typeof value === 'object' &&
|
|
169
|
+
value !== null &&
|
|
170
|
+
(Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null));
|
|
171
|
+
}
|
|
172
|
+
// Detach the request context so later caller mutations cannot relabel the returned assignments.
|
|
173
|
+
function cloneJson(value, ancestors = new Set()) {
|
|
174
|
+
if (value === null || typeof value === 'string' || typeof value === 'boolean')
|
|
175
|
+
return value;
|
|
176
|
+
if (typeof value === 'number' && Number.isFinite(value))
|
|
177
|
+
return value;
|
|
178
|
+
if (typeof value !== 'object' || value === null || ancestors.has(value))
|
|
179
|
+
throw new Error('Invalid JSON value');
|
|
180
|
+
ancestors.add(value);
|
|
181
|
+
try {
|
|
182
|
+
if (Array.isArray(value))
|
|
183
|
+
return Array.from(value, (entry) => cloneJson(entry, ancestors));
|
|
184
|
+
if (isRecord(value))
|
|
185
|
+
return Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, cloneJson(entry, ancestors)]));
|
|
186
|
+
throw new Error('Invalid JSON value');
|
|
187
|
+
}
|
|
188
|
+
finally {
|
|
189
|
+
ancestors.delete(value);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
//# sourceMappingURL=fetch-precomputed-configuration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch-precomputed-configuration.js","sourceRoot":"","sources":["../../src/configuration/fetch-precomputed-configuration.ts"],"names":[],"mappings":";;AAqDA,sEA6FC;AAlJD,0DAY+B;AAE/B,6DAAkE;AAClE,+DAO8B;AAC9B,qDAIyB;AAyBzB,6GAA6G;AACtG,KAAK,UAAU,6BAA6B,CACjD,OAA6C;IAE7C,IAAI,SAA6C,CAAA;IACjD,IAAI,CAAC;QACH,SAAS,GAAG,eAAe,CAAC,OAAO,CAAC,CAAA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,CAAC,CAAC,CAAA;QAC1F,IAAI,QAAQ,CAAC,KAAK,CAAC;YACjB,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,CAAA;QAC5G,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAA;IACvC,CAAC;YAAS,CAAC;QACT,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IACzB,CAAC;AACH,CAAC"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { type FlagsConfiguration } from '@datadog/flagging-core';
|
|
2
|
-
|
|
2
|
+
import { type ConfigurationSelectionOptions } from './flag-selection';
|
|
3
|
+
export { ConfigurationFetchError, type ConfigurationFetchErrorCode } from './configuration-fetch';
|
|
4
|
+
interface ConfigurationFetchOptions extends ConfigurationSelectionOptions {
|
|
3
5
|
env: string;
|
|
4
6
|
/** Datadog site. Defaults to datadoghq.com. */
|
|
5
7
|
site?: string;
|
|
@@ -18,17 +20,9 @@ export type RulesConfigurationFetchOptions = ConfigurationFetchOptions & ({
|
|
|
18
20
|
clientToken: string;
|
|
19
21
|
apiKey?: never;
|
|
20
22
|
});
|
|
21
|
-
export type ConfigurationFetchErrorCode = 'invalid_options' | 'http' | 'invalid_response' | 'decode' | 'transport' | 'cancelled' | 'timeout';
|
|
22
|
-
/** A configuration-loading failure, not an OpenFeature evaluation error. */
|
|
23
|
-
export declare class ConfigurationFetchError extends Error {
|
|
24
|
-
readonly code: ConfigurationFetchErrorCode;
|
|
25
|
-
readonly status?: number | undefined;
|
|
26
|
-
constructor(code: ConfigurationFetchErrorCode, message: string, status?: number | undefined);
|
|
27
|
-
}
|
|
28
23
|
/**
|
|
29
24
|
* Fetch and parse context-independent rules without initializing a provider or tracer.
|
|
30
25
|
* Only client-distributed configurations are suitable for forwarding to a browser.
|
|
31
26
|
*/
|
|
32
27
|
export declare function fetchRulesConfiguration(options: RulesConfigurationFetchOptions): Promise<FlagsConfiguration>;
|
|
33
|
-
export {};
|
|
34
28
|
//# sourceMappingURL=fetch-rules-configuration.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch-rules-configuration.d.ts","sourceRoot":"","sources":["../../src/configuration/fetch-rules-configuration.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"fetch-rules-configuration.d.ts","sourceRoot":"","sources":["../../src/configuration/fetch-rules-configuration.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,kBAAkB,EACxB,MAAM,wBAAwB,CAAA;AAS/B,OAAO,EACL,KAAK,6BAA6B,EAGnC,MAAM,kBAAkB,CAAA;AAEzB,OAAO,EAAE,uBAAuB,EAAE,KAAK,2BAA2B,EAAE,MAAM,uBAAuB,CAAA;AAEjG,UAAU,yBAA0B,SAAQ,6BAA6B;IACvE,GAAG,EAAE,MAAM,CAAA;IACX,+CAA+C;IAC/C,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,4EAA4E;IAC5E,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,sFAAsF;IACtF,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAA;CAChC;AAED,MAAM,MAAM,8BAA8B,GAAG,yBAAyB,GACpE,CACI;IAAE,mBAAmB,CAAC,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,KAAK,CAAA;CAAE,GACvE;IAAE,mBAAmB,EAAE,QAAQ,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,KAAK,CAAA;CAAE,CACzE,CAAA;AAyCH;;;GAGG;AACH,wBAAsB,uBAAuB,CAAC,OAAO,EAAE,8BAA8B,GAAG,OAAO,CAAC,kBAAkB,CAAC,CA8ElH"}
|
|
@@ -4,142 +4,108 @@ exports.ConfigurationFetchError = void 0;
|
|
|
4
4
|
exports.fetchRulesConfiguration = fetchRulesConfiguration;
|
|
5
5
|
const flagging_core_1 = require("@datadog/flagging-core");
|
|
6
6
|
const rules_based_1 = require("@datadog/flagging-core/rules-based");
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
const configuration_fetch_1 = require("./configuration-fetch");
|
|
8
|
+
const flag_selection_1 = require("./flag-selection");
|
|
9
|
+
var configuration_fetch_2 = require("./configuration-fetch");
|
|
10
|
+
Object.defineProperty(exports, "ConfigurationFetchError", { enumerable: true, get: function () { return configuration_fetch_2.ConfigurationFetchError; } });
|
|
11
|
+
// Fastly answers URLs over 8 KB with 414 URI Too Long: https://docs.fastly.com/products/network-services-resource-limits
|
|
12
|
+
// Keep URL encoding and this limit in sync with packages/browser/src/transport/flagSelection.ts.
|
|
13
|
+
const MAX_RULES_URL_BYTES = 8192;
|
|
14
|
+
function applyFlagSelection(url, input, logger) {
|
|
15
|
+
const drop = (reason, limit) => {
|
|
16
|
+
(0, flag_selection_1.reportDroppedFlagSelection)(logger, reason, limit);
|
|
17
|
+
return { url, selected: false };
|
|
18
|
+
};
|
|
19
|
+
try {
|
|
20
|
+
const { selection, error } = (0, flagging_core_1.canonicalizeFlagSelection)(input);
|
|
21
|
+
if (error)
|
|
22
|
+
return drop(error);
|
|
23
|
+
if (!selection)
|
|
24
|
+
return { url, selected: false };
|
|
25
|
+
const params = [
|
|
26
|
+
...selection.tags.map((tag) => `selected_flag_tags=${encodeQueryValue(tag)}`),
|
|
27
|
+
...selection.keyPatterns.map((pattern) => `selected_flag_key_patterns=${encodeQueryValue(pattern)}`),
|
|
28
|
+
];
|
|
29
|
+
const selectedUrl = new URL(url.toString());
|
|
30
|
+
selectedUrl.search = [selectedUrl.search.slice(1), ...params].filter(Boolean).join('&');
|
|
31
|
+
// Percent-encoding makes the serialized URL ASCII, so its length is its byte length.
|
|
32
|
+
if (selectedUrl.toString().length > MAX_RULES_URL_BYTES) {
|
|
33
|
+
return drop('too_many_values', `the request URL is at most ${MAX_RULES_URL_BYTES} bytes`);
|
|
34
|
+
}
|
|
35
|
+
return { url: selectedUrl, selected: true };
|
|
36
|
+
}
|
|
37
|
+
catch (_a) {
|
|
38
|
+
// Getters, proxies, and encoding failures can expose caller data through raw errors.
|
|
39
|
+
return drop('malformed_selection');
|
|
14
40
|
}
|
|
15
41
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
var _a;
|
|
19
|
-
return ((_a = signal === null || signal === void 0 ? void 0 : signal.reason) === null || _a === void 0 ? void 0 : _a.name) === 'TimeoutError'
|
|
20
|
-
? new ConfigurationFetchError('timeout', 'Configuration fetch timed out')
|
|
21
|
-
: new ConfigurationFetchError('cancelled', 'Configuration fetch cancelled');
|
|
22
|
-
}
|
|
23
|
-
// Raw errors can contain credentials or response bytes. Copy only a fixed diagnostic code.
|
|
24
|
-
const TRANSPORT_CODES = new Set([
|
|
25
|
-
'ENOTFOUND',
|
|
26
|
-
'EAI_AGAIN',
|
|
27
|
-
'ECONNREFUSED',
|
|
28
|
-
'ECONNRESET',
|
|
29
|
-
'ETIMEDOUT',
|
|
30
|
-
'EHOSTUNREACH',
|
|
31
|
-
'ENETUNREACH',
|
|
32
|
-
'EPIPE',
|
|
33
|
-
'UND_ERR_CONNECT_TIMEOUT',
|
|
34
|
-
'UND_ERR_HEADERS_TIMEOUT',
|
|
35
|
-
'UND_ERR_BODY_TIMEOUT',
|
|
36
|
-
'UND_ERR_SOCKET',
|
|
37
|
-
'UND_ERR_CLOSED',
|
|
38
|
-
'CERT_HAS_EXPIRED',
|
|
39
|
-
'DEPTH_ZERO_SELF_SIGNED_CERT',
|
|
40
|
-
'SELF_SIGNED_CERT_IN_CHAIN',
|
|
41
|
-
'UNABLE_TO_GET_ISSUER_CERT_LOCALLY',
|
|
42
|
-
'UNABLE_TO_VERIFY_LEAF_SIGNATURE',
|
|
43
|
-
'ERR_TLS_CERT_ALTNAME_INVALID',
|
|
44
|
-
]);
|
|
45
|
-
function transportError(message, error) {
|
|
46
|
-
const { code, cause } = (error !== null && error !== void 0 ? error : {});
|
|
47
|
-
const known = [cause === null || cause === void 0 ? void 0 : cause.code, code].find((value) => typeof value === 'string' && TRANSPORT_CODES.has(value));
|
|
48
|
-
return new ConfigurationFetchError('transport', known ? `${message} (${known})` : message);
|
|
49
|
-
}
|
|
50
|
-
function invalidOption(option) {
|
|
51
|
-
return new ConfigurationFetchError('invalid_options', `Invalid configuration fetch options: ${option}`);
|
|
42
|
+
function encodeQueryValue(value) {
|
|
43
|
+
return encodeURIComponent(value).replace(/[!'()*]/g, (char) => `%${char.charCodeAt(0).toString(16).toUpperCase()}`);
|
|
52
44
|
}
|
|
53
45
|
/**
|
|
54
46
|
* Fetch and parse context-independent rules without initializing a provider or tracer.
|
|
55
47
|
* Only client-distributed configurations are suitable for forwarding to a browser.
|
|
56
48
|
*/
|
|
57
49
|
async function fetchRulesConfiguration(options) {
|
|
58
|
-
|
|
59
|
-
const { distributionChannel = 'server', apiKey, clientToken, env, site = 'datadoghq.com', timeoutMs = 5000, signal, fetch: requestFetch = globalThis.fetch, } = options !== null && options !== void 0 ? options : {};
|
|
50
|
+
const { distributionChannel = 'server', apiKey, clientToken, env, site = 'datadoghq.com', flagSelection, logger = console, timeoutMs = 5000, signal, fetch: requestFetch = globalThis.fetch, } = options !== null && options !== void 0 ? options : {};
|
|
60
51
|
if (!['server', 'client'].includes(distributionChannel))
|
|
61
|
-
throw invalidOption('distributionChannel');
|
|
52
|
+
throw (0, configuration_fetch_1.invalidOption)('distributionChannel');
|
|
62
53
|
if (distributionChannel === 'client' ? apiKey !== undefined : clientToken !== undefined) {
|
|
63
|
-
throw invalidOption(distributionChannel === 'client'
|
|
54
|
+
throw (0, configuration_fetch_1.invalidOption)(distributionChannel === 'client'
|
|
64
55
|
? 'apiKey with client distribution channel'
|
|
65
56
|
: 'clientToken with server distribution channel');
|
|
66
57
|
}
|
|
67
58
|
const credential = distributionChannel === 'client' ? clientToken : apiKey;
|
|
68
59
|
if (typeof credential !== 'string' || !credential.trim() || /[\r\n]/.test(credential)) {
|
|
69
|
-
throw invalidOption(distributionChannel === 'client' ? 'clientToken' : 'apiKey');
|
|
60
|
+
throw (0, configuration_fetch_1.invalidOption)(distributionChannel === 'client' ? 'clientToken' : 'apiKey');
|
|
70
61
|
}
|
|
71
62
|
if (typeof env !== 'string' || !env.trim())
|
|
72
|
-
throw invalidOption('env');
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
throw invalidOption('fetch');
|
|
77
|
-
if (signal !== undefined &&
|
|
78
|
-
(signal === null ||
|
|
79
|
-
typeof signal.aborted !== 'boolean' ||
|
|
80
|
-
typeof signal.addEventListener !== 'function' ||
|
|
81
|
-
typeof signal.removeEventListener !== 'function')) {
|
|
82
|
-
throw invalidOption('signal');
|
|
83
|
-
}
|
|
63
|
+
throw (0, configuration_fetch_1.invalidOption)('env');
|
|
64
|
+
(0, configuration_fetch_1.validateTransportOptions)(timeoutMs, signal, requestFetch);
|
|
65
|
+
if (!logger || typeof logger.error !== 'function')
|
|
66
|
+
throw (0, configuration_fetch_1.invalidOption)('logger');
|
|
84
67
|
let host;
|
|
85
68
|
try {
|
|
86
69
|
host = (0, flagging_core_1.buildEndpointHost)(site, `ufc-${distributionChannel}`);
|
|
87
70
|
}
|
|
88
|
-
catch (
|
|
89
|
-
throw invalidOption('site');
|
|
71
|
+
catch (_a) {
|
|
72
|
+
throw (0, configuration_fetch_1.invalidOption)('site');
|
|
90
73
|
}
|
|
91
|
-
if (signal === null || signal === void 0 ? void 0 : signal.aborted)
|
|
92
|
-
throw abortError(signal);
|
|
93
74
|
const url = new URL(`https://${host}/api/v2/feature-flagging/config/rules-based/${distributionChannel}`);
|
|
94
75
|
url.searchParams.set('dd_env', env);
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
'DD-Client-Library-Language': 'nodejs',
|
|
109
|
-
'DD-Client-Library-Version': "2.6.0",
|
|
110
|
-
},
|
|
111
|
-
signal: controller.signal,
|
|
112
|
-
// Never forward a credential to a redirect destination.
|
|
113
|
-
redirect: 'manual',
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
catch (error) {
|
|
117
|
-
throw transportError('Configuration request failed', error);
|
|
118
|
-
}
|
|
119
|
-
controller.signal.throwIfAborted();
|
|
120
|
-
if (response.status !== 200) {
|
|
121
|
-
throw new ConfigurationFetchError('http', `Configuration fetch returned HTTP ${response.status}`, response.status);
|
|
122
|
-
}
|
|
76
|
+
const { url: requestUrl, selected } = applyFlagSelection(url, flagSelection, logger);
|
|
77
|
+
return (0, configuration_fetch_1.requestConfiguration)(requestUrl.toString(), {
|
|
78
|
+
method: 'GET',
|
|
79
|
+
headers: {
|
|
80
|
+
Accept: 'application/protobuf',
|
|
81
|
+
[distributionChannel === 'client' ? 'dd-client-token' : 'dd-api-key']: credential,
|
|
82
|
+
'DD-Client-Library-Language': 'nodejs',
|
|
83
|
+
'DD-Client-Library-Version': "2.8.0",
|
|
84
|
+
},
|
|
85
|
+
}, { fetch: requestFetch, timeoutMs, signal }, async (response, fetchedAt, checkAborted) => {
|
|
86
|
+
var _a;
|
|
87
|
+
if (selected)
|
|
88
|
+
(0, flag_selection_1.reportIgnoredFlagSelection)(logger, response);
|
|
123
89
|
const contentType = (_a = response.headers.get('content-type')) === null || _a === void 0 ? void 0 : _a.split(';')[0].trim().toLowerCase();
|
|
124
90
|
if (contentType !== 'application/protobuf') {
|
|
125
|
-
throw new ConfigurationFetchError('invalid_response', 'Expected a protobuf configuration response');
|
|
91
|
+
throw new configuration_fetch_1.ConfigurationFetchError('invalid_response', 'Expected a protobuf configuration response');
|
|
126
92
|
}
|
|
127
93
|
let bytes;
|
|
128
94
|
try {
|
|
129
95
|
bytes = new Uint8Array(await response.arrayBuffer());
|
|
130
96
|
}
|
|
131
97
|
catch (error) {
|
|
132
|
-
throw transportError('Configuration response could not be read', error);
|
|
98
|
+
throw (0, configuration_fetch_1.transportError)('Configuration response could not be read', error);
|
|
133
99
|
}
|
|
134
|
-
|
|
100
|
+
checkAborted();
|
|
135
101
|
if (bytes.length === 0)
|
|
136
|
-
throw new ConfigurationFetchError('invalid_response', 'Configuration response was empty');
|
|
102
|
+
throw new configuration_fetch_1.ConfigurationFetchError('invalid_response', 'Configuration response was empty');
|
|
137
103
|
let configuration;
|
|
138
104
|
try {
|
|
139
105
|
configuration = (0, rules_based_1.configurationFromRulesBinary)(bytes);
|
|
140
106
|
}
|
|
141
|
-
catch (
|
|
142
|
-
throw new ConfigurationFetchError('decode', 'Configuration protobuf could not be decoded');
|
|
107
|
+
catch (_b) {
|
|
108
|
+
throw new configuration_fetch_1.ConfigurationFetchError('decode', 'Configuration protobuf could not be decoded');
|
|
143
109
|
}
|
|
144
110
|
if (configuration.rules) {
|
|
145
111
|
configuration.rules.fetchedAt = fetchedAt;
|
|
@@ -148,33 +114,6 @@ async function fetchRulesConfiguration(options) {
|
|
|
148
114
|
configuration.rules.etag = etag;
|
|
149
115
|
}
|
|
150
116
|
return configuration;
|
|
151
|
-
}
|
|
152
|
-
catch (error) {
|
|
153
|
-
if (controller.signal.aborted)
|
|
154
|
-
throw controller.signal.reason;
|
|
155
|
-
if (error instanceof ConfigurationFetchError)
|
|
156
|
-
throw error;
|
|
157
|
-
throw transportError('Configuration request failed', error);
|
|
158
|
-
}
|
|
159
|
-
finally {
|
|
160
|
-
clearTimeout(timeout);
|
|
161
|
-
signal === null || signal === void 0 ? void 0 : signal.removeEventListener('abort', cancel);
|
|
162
|
-
// Aborting also releases an unfinished response after a validation failure.
|
|
163
|
-
controller.abort();
|
|
164
|
-
// Custom transports can use Web streams or Node streams (for example, node-fetch).
|
|
165
|
-
// Cleanup must not replace the result or delay it if cancellation never settles.
|
|
166
|
-
try {
|
|
167
|
-
const body = response === null || response === void 0 ? void 0 : response.body;
|
|
168
|
-
if (body && !(response === null || response === void 0 ? void 0 : response.bodyUsed)) {
|
|
169
|
-
if (typeof body.cancel === 'function')
|
|
170
|
-
void body.cancel().catch(() => { });
|
|
171
|
-
else
|
|
172
|
-
(_b = body.destroy) === null || _b === void 0 ? void 0 : _b.call(body);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
catch (_e) {
|
|
176
|
-
// Ignore synchronous cleanup failures from custom transports as well.
|
|
177
|
-
}
|
|
178
|
-
}
|
|
117
|
+
});
|
|
179
118
|
}
|
|
180
119
|
//# sourceMappingURL=fetch-rules-configuration.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch-rules-configuration.js","sourceRoot":"","sources":["../../src/configuration/fetch-rules-configuration.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"fetch-rules-configuration.js","sourceRoot":"","sources":["../../src/configuration/fetch-rules-configuration.ts"],"names":[],"mappings":";;;AAmFA,0DA8EC;AAjKD,0DAM+B;AAC/B,oEAAiF;AACjF,+DAM8B;AAC9B,qDAIyB;AAEzB,6DAAiG;AAAxF,8HAAA,uBAAuB,OAAA;AAmBhC,yHAAyH;AACzH,iGAAiG;AACjG,MAAM,mBAAmB,GAAG,IAAI,CAAA;AAEhC,SAAS,kBAAkB,CACzB,GAAQ,EACR,KAAgC,EAChC,MAAwD;IAExD,MAAM,IAAI,GAAG,CAAC,MAA0B,EAAE,KAAc,EAAE,EAAE;QAC1D,IAAA,2CAA0B,EAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,CAAA;QACjD,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAA;IACjC,CAAC,C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AA;IACtB,CAAC,CACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type FlagSelection, type FlagSelectionError } from '@datadog/flagging-core';
|
|
2
|
+
export interface ConfigurationSelectionOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Request flags matching any of these tags or key patterns.
|
|
5
|
+
* Best-effort: an invalid or over-limit selection is not sent.
|
|
6
|
+
*/
|
|
7
|
+
flagSelection?: FlagSelection;
|
|
8
|
+
/** Reports dropped or server-ignored selections. Defaults to console. */
|
|
9
|
+
logger?: {
|
|
10
|
+
error(message: string): void;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
type SelectionLogger = NonNullable<ConfigurationSelectionOptions['logger']>;
|
|
14
|
+
export declare function reportDroppedFlagSelection(logger: SelectionLogger, reason: FlagSelectionError, limit?: string): void;
|
|
15
|
+
export declare function reportIgnoredFlagSelection(logger: SelectionLogger, response: Response): void;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=flag-selection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flag-selection.d.ts","sourceRoot":"","sources":["../../src/configuration/flag-selection.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,kBAAkB,EAIxB,MAAM,wBAAwB,CAAA;AAE/B,MAAM,WAAW,6BAA6B;IAC5C;;;OAGG;IACH,aAAa,CAAC,EAAE,aAAa,CAAA;IAC7B,yEAAyE;IACzE,MAAM,CAAC,EAAE;QAAE,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAA;CAC1C;AAED,KAAK,eAAe,GAAG,WAAW,CAAC,6BAA6B,CAAC,QAAQ,CAAC,CAAC,CAAA;AAS3E,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,eAAe,EACvB,MAAM,EAAE,kBAAkB,EAC1B,KAAK,SAAuC,GAC3C,IAAI,CAEN;AAED,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,eAAe,EAAE,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAQ5F"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.reportDroppedFlagSelection = reportDroppedFlagSelection;
|
|
4
|
+
exports.reportIgnoredFlagSelection = reportIgnoredFlagSelection;
|
|
5
|
+
const flagging_core_1 = require("@datadog/flagging-core");
|
|
6
|
+
const SELECTION_LIMIT_DESCRIPTIONS = {
|
|
7
|
+
malformed_selection: 'flagSelection must be an object with optional tags and keyPatterns string arrays',
|
|
8
|
+
too_many_values: `each list accepts at most ${flagging_core_1.MAX_FLAG_SELECTION_VALUES} values`,
|
|
9
|
+
invalid_key_pattern: `each key pattern is at most ${flagging_core_1.MAX_FLAG_SELECTION_KEY_PATTERN_BYTES} UTF-8 bytes`,
|
|
10
|
+
invalid_tag: `each tag is at most ${flagging_core_1.MAX_FLAG_SELECTION_TAG_BYTES} UTF-8 bytes`,
|
|
11
|
+
};
|
|
12
|
+
function reportDroppedFlagSelection(logger, reason, limit = SELECTION_LIMIT_DESCRIPTIONS[reason]) {
|
|
13
|
+
reportSelectionError(logger, `flagSelection was not sent (${reason}: ${limit}). Loading the full flag configuration.`);
|
|
14
|
+
}
|
|
15
|
+
function reportIgnoredFlagSelection(logger, response) {
|
|
16
|
+
const reason = response.headers.get('DD-Flag-Selection-Ignored');
|
|
17
|
+
if (reason) {
|
|
18
|
+
reportSelectionError(logger, `flagSelection was ignored by the server (${reason}). Loaded the full flag configuration.`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function reportSelectionError(logger, message) {
|
|
22
|
+
try {
|
|
23
|
+
logger.error(message);
|
|
24
|
+
}
|
|
25
|
+
catch (_a) {
|
|
26
|
+
// Diagnostics must not prevent configuration loading or replace a fetch error.
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=flag-selection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flag-selection.js","sourceRoot":"","sources":["../../src/configuration/flag-selection.ts"],"names":[],"mappings":";;AA2BA,gEAMC;AAED,gEAQC;AA3CD,0DAM+B;AAc/B,MAAM,4BAA4B,GAAuC;IACvE,mBAAmB,EAAE,kFAAkF;IACvG,eAAe,EAAE,6BAA6B,yCAAyB,SAAS;IAChF,mBAAmB,EAAE,+BAA+B,oDAAoC,cAAc;IACtG,WAAW,EAAE,uBAAuB,4CAA4B,cAAc;CAC/E,CAAA;AAED,SAAgB,0BAA0B,CACxC,MAAuB,EACvB,MAA0B,EAC1B,KAAK,GAAG,4BAA4B,CAAC,MAAM,CAAC;IAE5C,oBAAoB,CAAC,MAAM,EAAE,+BAA+B,MAAM,KAAK,KAAK,yCAAyC,CAAC,CAAA;AACxH,CAAC;AAED,SAAgB,0BAA0B,CAAC,MAAuB,EAAE,QAAkB;IACpF,MAAM,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAA;IAChE,IAAI,MAAM,EAAE,CAAC;QACX,oBAAoB,CAClB,MAAM,EACN,4CAA4C,MAAM,wCAAwC,CAC3F,CAAA;IACH,CAAC;AACH,CAAC;AAED,SAAS,oBAAoB,CAAC,MAAuB,EAAE,OAAe;IACpE,IAAI,CAAC;QACH,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;IACvB,CAAC;IAAC,WAAM,CAAC;QACP,+EAA+E;IACjF,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ClientFingerprint, type FlagsConfiguration } from '@datadog/flagging-core';
|
|
2
|
+
import { type PrecomputeConfigurationOptions as CorePrecomputeConfigurationOptions } from '@datadog/flagging-core/rules-based';
|
|
3
|
+
import type { EvaluationContext } from '@openfeature/core';
|
|
4
|
+
export type PrecomputeConfigurationOptions = Omit<CorePrecomputeConfigurationOptions, 'obfuscation'> & {
|
|
5
|
+
/** Opaque target SDK fingerprint. Forward unchanged from its getter; omission preserves plaintext keys. */
|
|
6
|
+
clientFingerprint?: ClientFingerprint;
|
|
7
|
+
};
|
|
8
|
+
/** Resolve rules locally for one context, then encode keys for the target client without tracking or fetching. */
|
|
9
|
+
export declare function precomputeConfiguration(configuration: FlagsConfiguration, context: EvaluationContext, options?: PrecomputeConfigurationOptions): FlagsConfiguration;
|
|
10
|
+
//# sourceMappingURL=precompute-configuration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"precompute-configuration.d.ts","sourceRoot":"","sources":["../../src/configuration/precompute-configuration.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,iBAAiB,EAA8B,KAAK,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AACpH,OAAO,EAEL,KAAK,8BAA8B,IAAI,kCAAkC,EAI1E,MAAM,oCAAoC,CAAA;AAC3C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAG1D,MAAM,MAAM,8BAA8B,GAAG,IAAI,CAAC,kCAAkC,EAAE,aAAa,CAAC,GAAG;IACrG,2GAA2G;IAC3G,iBAAiB,CAAC,EAAE,iBAAiB,CAAA;CACtC,CAAA;AAED,kHAAkH;AAClH,wBAAgB,uBAAuB,CACrC,aAAa,EAAE,kBAAkB,EACjC,OAAO,EAAE,iBAAiB,EAC1B,OAAO,GAAE,8BAAmC,GAC3C,kBAAkB,CAyBpB"}
|