@datadog/mobile-react-native 3.5.2 → 3.5.4

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 (79) hide show
  1. package/README.md +2 -2
  2. package/android/build.gradle +8 -7
  3. package/android/src/main/kotlin/com/datadog/reactnative/DdRumImplementation.kt +1 -0
  4. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfiguration.kt +0 -1
  5. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkImplementation.kt +10 -3
  6. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkReactNativePackage.kt +0 -1
  7. package/android/src/main/kotlin/com/datadog/reactnative/SdkVersion.kt +1 -1
  8. package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +124 -49
  9. package/ios/Sources/DdLogsImplementation.swift +2 -2
  10. package/ios/Sources/DdSdkConfiguration.swift +0 -1
  11. package/ios/Sources/SdkVersion.swift +1 -1
  12. package/lib/commonjs/flags/FlagsClient.js +268 -3
  13. package/lib/commonjs/flags/FlagsClient.js.map +1 -1
  14. package/lib/commonjs/flags/configuration/context.js +70 -0
  15. package/lib/commonjs/flags/configuration/context.js.map +1 -0
  16. package/lib/commonjs/flags/configuration/index.js +39 -0
  17. package/lib/commonjs/flags/configuration/index.js.map +1 -0
  18. package/lib/commonjs/flags/configuration/precomputed.js +172 -0
  19. package/lib/commonjs/flags/configuration/precomputed.js.map +1 -0
  20. package/lib/commonjs/flags/configuration/types.js +33 -0
  21. package/lib/commonjs/flags/configuration/types.js.map +1 -0
  22. package/lib/commonjs/flags/configuration/wire.js +19 -0
  23. package/lib/commonjs/flags/configuration/wire.js.map +1 -0
  24. package/lib/commonjs/flags/internal.js +7 -3
  25. package/lib/commonjs/flags/internal.js.map +1 -1
  26. package/lib/commonjs/index.js +13 -0
  27. package/lib/commonjs/index.js.map +1 -1
  28. package/lib/commonjs/version.js +1 -1
  29. package/lib/module/flags/FlagsClient.js +268 -3
  30. package/lib/module/flags/FlagsClient.js.map +1 -1
  31. package/lib/module/flags/configuration/context.js +62 -0
  32. package/lib/module/flags/configuration/context.js.map +1 -0
  33. package/lib/module/flags/configuration/index.js +18 -0
  34. package/lib/module/flags/configuration/index.js.map +1 -0
  35. package/lib/module/flags/configuration/precomputed.js +165 -0
  36. package/lib/module/flags/configuration/precomputed.js.map +1 -0
  37. package/lib/module/flags/configuration/types.js +27 -0
  38. package/lib/module/flags/configuration/types.js.map +1 -0
  39. package/lib/module/flags/configuration/wire.js +13 -0
  40. package/lib/module/flags/configuration/wire.js.map +1 -0
  41. package/lib/module/flags/internal.js +7 -3
  42. package/lib/module/flags/internal.js.map +1 -1
  43. package/lib/module/index.js +2 -1
  44. package/lib/module/index.js.map +1 -1
  45. package/lib/module/version.js +1 -1
  46. package/lib/typescript/flags/FlagsClient.d.ts +96 -0
  47. package/lib/typescript/flags/FlagsClient.d.ts.map +1 -1
  48. package/lib/typescript/flags/configuration/context.d.ts +20 -0
  49. package/lib/typescript/flags/configuration/context.d.ts.map +1 -0
  50. package/lib/typescript/flags/configuration/index.d.ts +5 -0
  51. package/lib/typescript/flags/configuration/index.d.ts.map +1 -0
  52. package/lib/typescript/flags/configuration/precomputed.d.ts +25 -0
  53. package/lib/typescript/flags/configuration/precomputed.d.ts.map +1 -0
  54. package/lib/typescript/flags/configuration/types.d.ts +24 -0
  55. package/lib/typescript/flags/configuration/types.d.ts.map +1 -0
  56. package/lib/typescript/flags/configuration/wire.d.ts +2 -0
  57. package/lib/typescript/flags/configuration/wire.d.ts.map +1 -0
  58. package/lib/typescript/flags/internal.d.ts.map +1 -1
  59. package/lib/typescript/flags/types.d.ts +1 -1
  60. package/lib/typescript/flags/types.d.ts.map +1 -1
  61. package/lib/typescript/index.d.ts +4 -2
  62. package/lib/typescript/index.d.ts.map +1 -1
  63. package/lib/typescript/version.d.ts +1 -1
  64. package/package.json +3 -2
  65. package/src/flags/FlagsClient.ts +305 -3
  66. package/src/flags/__tests__/FlagsClient.test.ts +596 -0
  67. package/src/flags/__tests__/internal.test.ts +45 -0
  68. package/src/flags/configuration/__tests__/context.test.ts +120 -0
  69. package/src/flags/configuration/__tests__/precomputed.test.ts +301 -0
  70. package/src/flags/configuration/__tests__/wire.test.ts +127 -0
  71. package/src/flags/configuration/context.ts +76 -0
  72. package/src/flags/configuration/index.ts +27 -0
  73. package/src/flags/configuration/precomputed.ts +215 -0
  74. package/src/flags/configuration/types.ts +47 -0
  75. package/src/flags/configuration/wire.ts +15 -0
  76. package/src/flags/internal.ts +6 -3
  77. package/src/flags/types.ts +3 -1
  78. package/src/index.tsx +8 -0
  79. package/src/version.ts +1 -1
@@ -6,6 +6,8 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.FlagsClient = void 0;
7
7
  var _InternalLog = require("../InternalLog");
8
8
  var _SdkVerbosity = require("../config/types/SdkVerbosity");
9
+ var _context = require("./configuration/context");
10
+ var _configuration = require("./configuration");
9
11
  var _internal = require("./internal");
10
12
  /*
11
13
  * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
@@ -13,11 +15,67 @@ var _internal = require("./internal");
13
15
  * Copyright 2016-Present Datadog, Inc.
14
16
  */
15
17
 
18
+ // Imported directly (not via the module index): context matching is an internal helper,
19
+ // used here only to detect a runtime context an offline precomputed configuration cannot honor.
20
+
21
+ /**
22
+ * Error codes an offline configuration result can carry:
23
+ * - `INVALID_CONTEXT`: the active context does not match the precomputed snapshot.
24
+ * - `PROVIDER_NOT_READY`: an offline operation ran with no configuration loaded.
25
+ * - `GENERAL`: the loaded configuration is unusable (malformed/unsupported/undecodable).
26
+ */
27
+
28
+ /**
29
+ * Outcome of loading a configuration or reconciling it against the active evaluation context,
30
+ * returned by the offline APIs ({@link FlagsClient.setConfiguration},
31
+ * {@link FlagsClient.setEvaluationContextWithoutFetching},
32
+ * {@link FlagsClient.resetEvaluationContextWithoutFetching}).
33
+ *
34
+ * `'ready'` means the configuration can be served against the active context; `'error'` carries
35
+ * the precise reason so the OpenFeature provider surfaces the correct code and evaluation returns
36
+ * that code with the coded default.
37
+ *
38
+ * @internal Consumers observe OpenFeature provider events/evaluation details, not this result.
39
+ */
40
+
41
+ /**
42
+ * The decoded outcome of the last loaded offline configuration. Load validity (`kind`) is stored
43
+ * separately from context compatibility so that later context changes reconcile against a decoded
44
+ * snapshot **without re-decoding** and can never promote an invalid load to a servable state.
45
+ *
46
+ * `'none'` = no offline configuration engaged (the online/fetch path, or nothing loaded yet).
47
+ */
48
+
16
49
  class FlagsClient {
17
50
  // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires
18
51
  nativeFlags = require('../specs/NativeDdFlags').default;
52
+ // The context the app explicitly set — the online fetch context, or the offline override via
53
+ // {@link setEvaluationContextWithoutFetching}. `undefined` means "no external override": an
54
+ // offline precomputed configuration is then served against its own embedded context. Tracked
55
+ // separately from {@link evaluationContext} so that adopting a configuration's embedded context
56
+ // is never mistaken for an app-set override (which would spuriously fail a later replacement).
57
+ externalContext = undefined;
58
+
59
+ // The effective context evaluation and exposure tracking run against: the external override
60
+ // when set, otherwise the loaded configuration's embedded context.
19
61
  evaluationContext = undefined;
20
- flagsCache = {};
62
+
63
+ // The servable flag cache. On the online path it holds the native-fetched flags; on the
64
+ // offline path it mirrors the decoded snapshot when the configuration is servable. A Map
65
+ // (not a plain object) so a flag keyed like an inherited property ("toString",
66
+ // "__proto__") is looked up as data via `.get()` and never resolves an `Object.prototype`
67
+ // member — important now the cache can be fed from untrusted wire data.
68
+ flagsCache = new Map();
69
+
70
+ // The decoded outcome of the last loaded offline configuration (see the type).
71
+ loadedConfiguration = {
72
+ kind: 'none'
73
+ };
74
+
75
+ // Internal serving status. `'none'` = online path (serve `flagsCache`); `'ready'` = serve
76
+ // the offline snapshot; `'error'` = serve coded defaults with `configurationError`.
77
+ configurationStatus = 'none';
78
+ configurationError = undefined;
21
79
  constructor(clientName = 'default') {
22
80
  this.clientName = clientName;
23
81
  }
@@ -48,17 +106,212 @@ class FlagsClient {
48
106
  setEvaluationContext = async context => {
49
107
  // Make sure to process the incoming context because we don't support nested object values in context.
50
108
  const processedContext = (0, _internal.processEvaluationContext)(context);
109
+
110
+ // Entering online mode drops any offline overlay *before* fetching, so a failed fetch falls
111
+ // back to coded defaults rather than continuing to serve a stale offline snapshot. Using one
112
+ // client for both online and offline is unsupported (give the offline provider its own
113
+ // `clientName`), so warn when an offline configuration is discarded here. Online-only clients
114
+ // have no overlay, so this does not touch their keep-last-known-flags-on-failure behavior.
115
+ if (this.loadedConfiguration.kind !== 'none') {
116
+ _InternalLog.InternalLog.log(`An offline configuration was loaded for '${this.clientName}' but an online fetch was requested; discarding it and serving default values on failure. Use a separate client for the offline provider.`, _SdkVerbosity.SdkVerbosity.WARN);
117
+ this.loadedConfiguration = {
118
+ kind: 'none'
119
+ };
120
+ this.configurationStatus = 'none';
121
+ this.configurationError = undefined;
122
+ this.flagsCache = new Map();
123
+ this.evaluationContext = undefined;
124
+ this.externalContext = undefined;
125
+ }
51
126
  try {
52
127
  const result = await this.nativeFlags.setEvaluationContext(this.clientName, processedContext.targetingKey, processedContext.attributes ?? {});
128
+ this.externalContext = processedContext;
53
129
  this.evaluationContext = processedContext;
54
- this.flagsCache = result;
130
+ this.flagsCache = new Map(Object.entries(result));
131
+
132
+ // A successful online fetch is authoritative: reset to the clean online state so a
133
+ // prior offline error status (e.g. PROVIDER_NOT_READY from an offline op with no
134
+ // configuration loaded) can't keep serving coded defaults over the fetched flags.
135
+ this.loadedConfiguration = {
136
+ kind: 'none'
137
+ };
138
+ this.configurationStatus = 'none';
139
+ this.configurationError = undefined;
55
140
  } catch (error) {
141
+ // A failed fetch leaves the previous online cache in place (keep-last-known); any offline
142
+ // overlay was already dropped above, so no stale offline snapshot is served.
56
143
  if (error instanceof Error) {
57
144
  _InternalLog.InternalLog.log(`Error setting flag evaluation context: ${error.message}`, _SdkVerbosity.SdkVerbosity.WARN);
58
145
  }
59
146
  throw error;
60
147
  }
61
148
  };
149
+
150
+ /**
151
+ * Set the evaluation context **without** fetching a configuration from the network, then
152
+ * reconcile the loaded configuration against it.
153
+ *
154
+ * The offline counterpart to {@link setEvaluationContext}: records the active context and
155
+ * reconciles with no native request. A precomputed configuration is single-subject, so a
156
+ * context that does not match the one it was computed for reconciles to an error
157
+ * (`INVALID_CONTEXT`) and evaluation serves defaults. With no configuration loaded the
158
+ * result is `PROVIDER_NOT_READY`. Intended for offline providers that own their
159
+ * configuration via `setConfiguration` and must not fetch on a context change.
160
+ *
161
+ * @param context The evaluation context to associate with the current client.
162
+ */
163
+ setEvaluationContextWithoutFetching = context => {
164
+ this.externalContext = (0, _internal.processEvaluationContext)(context);
165
+ return this.reconcile();
166
+ };
167
+
168
+ /**
169
+ * Clear any externally-set evaluation context and reconcile.
170
+ *
171
+ * This is the offline counterpart to clearing/omitting an OpenFeature context: it drops the
172
+ * external override so a loaded precomputed configuration is served against **its embedded
173
+ * context** again. Clearing the override (rather than skipping) matters so that a
174
+ * configuration loaded *after* a clear is not judged against a stale override. With no
175
+ * configuration loaded the result is `PROVIDER_NOT_READY`.
176
+ */
177
+ resetEvaluationContextWithoutFetching = () => {
178
+ this.externalContext = undefined;
179
+ return this.reconcile();
180
+ };
181
+
182
+ /**
183
+ * Load a configuration (parsed from a `ConfigurationWire` string via
184
+ * `configurationFromString`) into the client for offline evaluation, then reconcile it
185
+ * against the active context.
186
+ *
187
+ * For a precomputed configuration this decodes the snapshot once and adopts its embedded
188
+ * evaluation context when none is set — **no network request is made**. An unusable
189
+ * configuration reconciles to an error (`GENERAL`); a context mismatch to `INVALID_CONTEXT`.
190
+ *
191
+ * @param configuration The configuration to load.
192
+ *
193
+ * @example
194
+ * ```ts
195
+ * const configuration = configurationFromString(wire);
196
+ * flagsClient.setConfiguration(configuration);
197
+ *
198
+ * const value = flagsClient.getBooleanValue('new-feature', false);
199
+ * ```
200
+ */
201
+ setConfiguration = configuration => {
202
+ this.loadedConfiguration = this.loadConfiguration(configuration);
203
+ return this.reconcile();
204
+ };
205
+
206
+ /**
207
+ * Decode a supplied configuration into a {@link LoadedConfigurationState} **once**, capturing
208
+ * whether the load itself is valid (independent of the active context). Later context changes
209
+ * reconcile against this stored state without re-decoding, and can never turn an invalid load
210
+ * into a servable one.
211
+ *
212
+ * FORWARD-COMPAT SEAM: when a rules-based configuration is supported, it must be handled here
213
+ * BEFORE the precomputed guard — rules are context-agnostic and must NOT be classified invalid.
214
+ */
215
+ loadConfiguration = configuration => {
216
+ const precomputed = configuration?.precomputed;
217
+
218
+ // An empty configuration (a failed/lenient wire parse, or a wire with no precomputed
219
+ // branch) is unusable. `configurationFromString` collapses malformed input and
220
+ // unsupported versions to the same empty shape, so this is classified as `GENERAL`.
221
+ if (!precomputed) {
222
+ _InternalLog.InternalLog.log(`No usable precomputed configuration was provided for '${this.clientName}'.`, _SdkVerbosity.SdkVerbosity.WARN);
223
+ return {
224
+ kind: 'invalid',
225
+ errorCode: 'GENERAL'
226
+ };
227
+ }
228
+ try {
229
+ const flags = (0, _configuration.decodePrecomputedFlags)(precomputed.response);
230
+ return {
231
+ kind: 'precomputed',
232
+ configuration: precomputed,
233
+ flags
234
+ };
235
+ } catch (error) {
236
+ // Decoding rejects unsupported payloads (e.g. obfuscated) — an unsupported kind,
237
+ // classified as `GENERAL`.
238
+ if (error instanceof Error) {
239
+ _InternalLog.InternalLog.log(`Unsupported flags configuration for '${this.clientName}': ${error.message}`, _SdkVerbosity.SdkVerbosity.WARN);
240
+ }
241
+ return {
242
+ kind: 'invalid',
243
+ errorCode: 'GENERAL'
244
+ };
245
+ }
246
+ };
247
+
248
+ /**
249
+ * Reconcile the stored {@link LoadedConfigurationState} against the active evaluation context
250
+ * and (re)compute the servable flag cache and configuration status/result.
251
+ *
252
+ * The stored load validity is consulted **before** context compatibility, so a context change
253
+ * can never promote an invalid (or absent) load to `ready`.
254
+ */
255
+ reconcile = () => {
256
+ const loaded = this.loadedConfiguration;
257
+
258
+ // No offline configuration engaged: an offline operation with nothing loaded is not ready.
259
+ if (loaded.kind === 'none') {
260
+ return this.enterError('PROVIDER_NOT_READY', `The evaluation context is not usable for '${this.clientName}': no configuration is loaded. Provide a configuration via setConfiguration.`);
261
+ }
262
+
263
+ // The load itself failed (malformed/unsupported/undecodable) — independent of context.
264
+ if (loaded.kind === 'invalid') {
265
+ return this.enterError(loaded.errorCode, `The loaded configuration for '${this.clientName}' is not usable. Provide a valid precomputed configuration.`);
266
+ }
267
+ const {
268
+ configuration,
269
+ flags
270
+ } = loaded;
271
+
272
+ // A precomputed snapshot is bound to the subject it was computed for. If the app set an
273
+ // *external* context that does not match, it cannot be served (offline never fetches), so
274
+ // it is an error and evaluation serves coded defaults. Only an external override is checked
275
+ // here — the configuration's own embedded context (adopted below when no override is set)
276
+ // matches by construction, so replacing one snapshot with another for a different subject
277
+ // stays `ready`. The decoded snapshot is retained for a later matching context.
278
+ if (this.externalContext && !(0, _context.contextMatchesConfiguration)(configuration.context, this.externalContext)) {
279
+ return this.enterError('INVALID_CONTEXT', `The evaluation context does not match the precomputed configuration for '${this.clientName}'. Serving default values. Set a matching context, or use a rules-based configuration for per-context evaluation.`);
280
+ }
281
+
282
+ // Serve against the external override when set, otherwise the configuration's embedded
283
+ // context (a context-agnostic configuration falls back to an empty context).
284
+ this.evaluationContext = this.externalContext ?? this.embeddedContext(configuration);
285
+ this.flagsCache = flags;
286
+ this.configurationStatus = 'ready';
287
+ this.configurationError = undefined;
288
+ return {
289
+ status: 'ready'
290
+ };
291
+ };
292
+
293
+ /** The evaluation context a precomputed configuration was computed for (empty if agnostic). */
294
+ embeddedContext = configuration => {
295
+ return configuration.context ? (0, _configuration.normalizeWireContext)(configuration.context) : {
296
+ targetingKey: '',
297
+ attributes: {}
298
+ };
299
+ };
300
+
301
+ /** Record an error status + message, clear the servable cache, and return the result. */
302
+ enterError = (errorCode, errorMessage) => {
303
+ this.flagsCache = new Map();
304
+ this.configurationStatus = 'error';
305
+ this.configurationError = {
306
+ errorCode,
307
+ errorMessage
308
+ };
309
+ _InternalLog.InternalLog.log(errorMessage, _SdkVerbosity.SdkVerbosity.WARN);
310
+ return {
311
+ status: 'error',
312
+ errorCode
313
+ };
314
+ };
62
315
  track = (flag, context) => {
63
316
  // A non-blocking call; don't await this.
64
317
  this.nativeFlags.trackEvaluation(this.clientName, flag.key, flag, context.targetingKey, context.attributes ?? {}).catch(error => {
@@ -68,6 +321,18 @@ class FlagsClient {
68
321
  });
69
322
  };
70
323
  getDetails = (key, defaultValue, type) => {
324
+ // An offline configuration that cannot be served against the active context surfaces the
325
+ // precise error code (INVALID_CONTEXT / GENERAL / PROVIDER_NOT_READY) with the coded
326
+ // default. The OpenFeature provider maps this to a PROVIDER_ERROR / ERROR state.
327
+ if (this.configurationStatus === 'error' && this.configurationError) {
328
+ return {
329
+ key,
330
+ value: defaultValue,
331
+ reason: 'ERROR',
332
+ errorCode: this.configurationError.errorCode,
333
+ errorMessage: this.configurationError.errorMessage
334
+ };
335
+ }
71
336
  if (!this.evaluationContext) {
72
337
  return {
73
338
  key,
@@ -79,7 +344,7 @@ class FlagsClient {
79
344
  }
80
345
 
81
346
  // Retrieve the flag from the cache.
82
- const flag = this.flagsCache[key];
347
+ const flag = this.flagsCache.get(key);
83
348
  if (!flag) {
84
349
  return {
85
350
  key,
@@ -1 +1 @@
1
- {"version":3,"names":["_InternalLog","require","_SdkVerbosity","_internal","FlagsClient","nativeFlags","default","evaluationContext","undefined","flagsCache","constructor","clientName","setEvaluationContext","context","processedContext","processEvaluationContext","result","targetingKey","attributes","error","Error","InternalLog","log","message","SdkVerbosity","WARN","track","flag","trackEvaluation","key","catch","getDetails","defaultValue","type","value","reason","errorCode","errorMessage","actualType","details","variant","variationKey","allocationKey","getBooleanDetails","getStringDetails","getNumberDetails","getObjectDetails","getBooleanValue","getStringValue","getNumberValue","getObjectValue","exports"],"sourceRoot":"../../../src","sources":["flags/FlagsClient.ts"],"mappings":";;;;;;AAMA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AAGA,IAAAE,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pB,GAAW,EAAEG,YAAoB,KAAa;IAC5D,OAAO,IAAI,CAACa,gBAAgB,CAAChB,GAAG,EAAEG,YAAY,CAAC,CAACE,KAAK;EACzD,CAAC;;EAED;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACIgB,cAAc,GAAGA,CAAsBrB,GAAW,EAAEG,YAAe,KAAQ;IACvE,OAAO,IAAI,CAACc,gBAAgB,CAACjB,GAAG,EAAEG,YAAY,CAAC,CAACE,KAAK;EACzD,CAAC;AACL;AAACiB,OAAA,CAAA/C,WAAA,GAAAA,WAAA","ignoreList":[]}
1
+ {"version":3,"names":["_InternalLog","require","_SdkVerbosity","_context","_configuration","_internal","FlagsClient","nativeFlags","default","externalContext","undefined","evaluationContext","flagsCache","Map","loadedConfiguration","kind","configurationStatus","configurationError","constructor","clientName","setEvaluationContext","context","processedContext","processEvaluationContext","InternalLog","log","SdkVerbosity","WARN","result","targetingKey","attributes","Object","entries","error","Error","message","setEvaluationContextWithoutFetching","reconcile","resetEvaluationContextWithoutFetching","setConfiguration","configuration","loadConfiguration","precomputed","errorCode","flags","decodePrecomputedFlags","response","loaded","enterError","contextMatchesConfiguration","embeddedContext","status","normalizeWireContext","errorMessage","track","flag","trackEvaluation","key","catch","getDetails","defaultValue","type","value","reason","get","actualType","details","variant","variationKey","allocationKey","getBooleanDetails","getStringDetails","getNumberDetails","getObjectDetails","getBooleanValue","getStringValue","getNumberValue","getObjectValue","exports"],"sourceRoot":"../../../src","sources":["flags/FlagsClient.ts"],"mappings":";;;;;;AAMA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AAKA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,cAAA,GAAAH,OAAA;AAKA,IAAAI,SAAA,GAAAJ,OAAA;AAlBA;AACA;AACA;AACA;AACA;;AAMA;AACA;;AAWA;AACA;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A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G,EAAEG,YAAY,EAAE,QAAQ,CAAC;EACvD,CAAC;;EAED;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACIa,gBAAgB,GAAGA,CACfhB,GAAW,EACXG,YAAe,KACE;IACjB,OAAO,IAAI,CAACD,UAAU,CAACF,GAAG,EAAEG,YAAY,EAAE,QAAQ,CAAC;EACvD,CAAC;;EAED;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACIc,eAAe,GAAGA,CAACjB,GAAW,EAAEG,YAAqB,KAAc;IAC/D,OAAO,IAAI,CAACU,iBAAiB,CAACb,GAAG,EAAEG,YAAY,CAAC,CAACE,KAAK;EAC1D,CAAC;;EAED;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACIa,cAAc,GAAGA,CAAClB,GAAW,EAAEG,YAAoB,KAAa;IAC5D,OAAO,IAAI,CAACW,gBAAgB,CAACd,GAAG,EAAEG,YAAY,CAAC,CAACE,KAAK;EACzD,CAAC;;EAED;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACIc,cAAc,GAAGA,CAACnB,GAAW,EAAEG,YAAoB,KAAa;IAC5D,OAAO,IAAI,CAACY,gBAAgB,CAACf,GAAG,EAAEG,YAAY,CAAC,CAACE,KAAK;EACzD,CAAC;;EAED;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACIe,cAAc,GAAGA,CAAsBpB,GAAW,EAAEG,YAAe,KAAQ;IACvE,OAAO,IAAI,CAACa,gBAAgB,CAAChB,GAAG,EAAEG,YAAY,CAAC,CAACE,KAAK;EACzD,CAAC;AACL;AAACgB,OAAA,CAAAxE,WAAA,GAAAA,WAAA","ignoreList":[]}
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.normalizeWireContext = exports.contextMatchesConfiguration = void 0;
7
+ var _internal = require("../internal");
8
+ /*
9
+ * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
10
+ * This product includes software developed at Datadog (https://www.datadoghq.com/).
11
+ * Copyright 2016-Present Datadog, Inc.
12
+ */
13
+
14
+ /**
15
+ * Normalize a wire (OpenFeature-flat) evaluation context into the SDK's internal
16
+ * `{ targetingKey, attributes }` shape, applying the **same** processing the active
17
+ * context went through (`processEvaluationContext`) so the two are comparable — the
18
+ * flat wire shape and the internal shape are otherwise never equal.
19
+ */
20
+ const normalizeWireContext = wireContext => {
21
+ const {
22
+ targetingKey,
23
+ ...attributes
24
+ } = wireContext;
25
+ return (0, _internal.processEvaluationContext)({
26
+ // The wire is untrusted, so a non-string targetingKey is treated as absent.
27
+ targetingKey: typeof targetingKey === 'string' ? targetingKey : '',
28
+ // `processEvaluationContext` drops non-primitive attributes; casting here mirrors
29
+ // how the active context's attributes are typed before that same processing.
30
+ attributes: attributes
31
+ });
32
+ };
33
+
34
+ /**
35
+ * Whether a precomputed configuration's embedded context matches the active evaluation
36
+ * context.
37
+ *
38
+ * - A configuration with **no** embedded context is context-agnostic and matches any
39
+ * active context.
40
+ * - Otherwise the embedded context must match the active context exactly (after
41
+ * normalizing both through the same processing).
42
+ */
43
+ exports.normalizeWireContext = normalizeWireContext;
44
+ const contextMatchesConfiguration = (wireContext, activeContext) => {
45
+ if (!wireContext) {
46
+ return true;
47
+ }
48
+ return contextsEqual(normalizeWireContext(wireContext), activeContext);
49
+ };
50
+ exports.contextMatchesConfiguration = contextMatchesConfiguration;
51
+ const contextsEqual = (a, b) => {
52
+ if (a.targetingKey !== b.targetingKey) {
53
+ return false;
54
+ }
55
+ return attributesEqual(a.attributes ?? {}, b.attributes ?? {});
56
+ };
57
+
58
+ /**
59
+ * Compare two attribute maps. After `processEvaluationContext`, attribute values are
60
+ * primitives, so a key-set + strict-value comparison is sufficient.
61
+ */
62
+ const attributesEqual = (a, b) => {
63
+ const aKeys = Object.keys(a);
64
+ const bKeys = Object.keys(b);
65
+ if (aKeys.length !== bKeys.length) {
66
+ return false;
67
+ }
68
+ return aKeys.every(key => a[key] === b[key]);
69
+ };
70
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_internal","require","normalizeWireContext","wireContext","targetingKey","attributes","processEvaluationContext","exports","contextMatchesConfiguration","activeContext","contextsEqual","a","b","attributesEqual","aKeys","Object","keys","bKeys","length","every","key"],"sourceRoot":"../../../../src","sources":["flags/configuration/context.ts"],"mappings":";;;;;;AAMA,IAAAA,SAAA,GAAAC,OAAA;AANA;AACA;AACA;AACA;AACA;;AAOA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,oBAAoB,GAC7BC,WAAkC,IACd;EACpB,MAAM;IAAEC,YAAY;IAAE,GAAGC;EAAW,CAAC,GAAGF,WAAW;EAEnD,OAAO,IAAAG,kCAAwB,EAAC;IAC5B;IACAF,YAAY,EAAE,OAAOA,YAAY,KAAK,QAAQ,GAAGA,YAAY,GAAG,EAAE;IAClE;IACA;IACAC,UAAU,EAAEA;EAChB,CAAC,CAAC;AACN,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AARAE,OAAA,CAAAL,oBAAA,GAAAA,oBAAA;AASO,MAAMM,2BAA2B,GAAGA,CACvCL,WAA8C,EAC9CM,aAAgC,KACtB;EACV,IAAI,CAACN,WAAW,EAAE;IACd,OAAO,IAAI;EACf;EAEA,OAAOO,aAAa,CAACR,oBAAoB,CAACC,WAAW,CAAC,EAAEM,aAAa,CAAC;AAC1E,CAAC;AAACF,OAAA,CAAAC,2BAAA,GAAAA,2BAAA;AAEF,MAAME,aAAa,GAAGA,CAACC,CAAoB,EAAEC,CAAoB,KAAc;EAC3E,IAAID,CAAC,CAACP,YAAY,KAAKQ,CAAC,CAACR,YAAY,EAAE;IACnC,OAAO,KAAK;EAChB;EAEA,OAAOS,eAAe,CAACF,CAAC,CAACN,UAAU,IAAI,CAAC,CAAC,EAAEO,CAAC,CAACP,UAAU,IAAI,CAAC,CAAC,CAAC;AAClE,CAAC;;AAED;AACA;AACA;AACA;AACA,MAAMQ,eAAe,GAAGA,CACpBF,CAAiC,EACjCC,CAAiC,KACvB;EACV,MAAME,KAAK,GAAGC,MAAM,CAACC,IAAI,CAACL,CAAC,CAAC;EAC5B,MAAMM,KAAK,GAAGF,MAAM,CAACC,IAAI,CAACJ,CAAC,CAAC;EAE5B,IAAIE,KAAK,CAACI,MAAM,KAAKD,KAAK,CAACC,MAAM,EAAE;IAC/B,OAAO,KAAK;EAChB;EAEA,OAAOJ,KAAK,CAACK,KAAK,CAACC,GAAG,IAAIT,CAAC,CAACS,GAAG,CAAC,KAAKR,CAAC,CAACQ,GAAG,CAAC,CAAC;AAChD,CAAC","ignoreList":[]}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "UnsupportedConfigurationError", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _precomputed.UnsupportedConfigurationError;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "configurationFromString", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _wire.configurationFromString;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "configurationToString", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _wire.configurationToString;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "decodePrecomputedFlags", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _precomputed.decodePrecomputedFlags;
28
+ }
29
+ });
30
+ Object.defineProperty(exports, "normalizeWireContext", {
31
+ enumerable: true,
32
+ get: function () {
33
+ return _context.normalizeWireContext;
34
+ }
35
+ });
36
+ var _wire = require("./wire");
37
+ var _precomputed = require("./precomputed");
38
+ var _context = require("./context");
39
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_wire","require","_precomputed","_context"],"sourceRoot":"../../../../src","sources":["flags/configuration/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAMA,IAAAE,QAAA,GAAAF,OAAA","ignoreList":[]}
@@ -0,0 +1,172 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.decodePrecomputedFlags = exports.UnsupportedConfigurationError = void 0;
7
+ var _InternalLog = require("../../InternalLog");
8
+ var _SdkVerbosity = require("../../config/types/SdkVerbosity");
9
+ var _types = require("./types");
10
+ /*
11
+ * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
12
+ * This product includes software developed at Datadog (https://www.datadoghq.com/).
13
+ * Copyright 2016-Present Datadog, Inc.
14
+ */
15
+
16
+ /**
17
+ * Thrown when a configuration cannot be supported by this SDK (e.g. an obfuscated
18
+ * precomputed payload). Callers translate this into a provider error state rather
19
+ * than silently serving wrong data.
20
+ */
21
+ class UnsupportedConfigurationError extends Error {
22
+ constructor(message) {
23
+ super(message);
24
+ this.name = 'UnsupportedConfigurationError';
25
+ }
26
+ }
27
+
28
+ /**
29
+ * Decode a precomputed CDN response into the `FlagCacheEntry` map that `FlagsClient`
30
+ * caches and evaluates against — the same shape the native CDN fetch returns today.
31
+ *
32
+ * The mapping is ~1:1. Two transforms are applied per flag:
33
+ * - `value` is the typed `variationValue` as-is (`integer`/`float` are JS `number`s);
34
+ * - a string `variationValue` is derived (JSON for objects, `"true"/"false"` for
35
+ * booleans, `String(...)` otherwise) because native Android exposure tracking
36
+ * rebuilds the flag from the string form.
37
+ *
38
+ * @throws {UnsupportedConfigurationError} if the response is obfuscated, or its envelope is
39
+ * structurally malformed (missing/non-object `data.attributes.flags`).
40
+ */
41
+ exports.UnsupportedConfigurationError = UnsupportedConfigurationError;
42
+ const decodePrecomputedFlags = response => {
43
+ const attributes = response?.data?.attributes;
44
+
45
+ // `obfuscated` is not part of flagging-core's response type, but the CDN payload
46
+ // carries it. Read it defensively so obfuscated payloads are still rejected:
47
+ // de-hashing keys / decoding values is not implemented here, so fail predictably
48
+ // instead of mis-mapping hashed keys.
49
+ if (attributes?.obfuscated) {
50
+ throw new UnsupportedConfigurationError('Obfuscated precomputed configurations are not supported.');
51
+ }
52
+
53
+ // Validate the response envelope before trusting it. An untrusted wire can be JSON-valid yet
54
+ // structurally malformed (a null/non-object envelope, or a `flags` that is null or an array).
55
+ // Fail predictably so the caller classifies it as an error instead of silently decoding it to
56
+ // an empty — but "ready" — configuration. A genuinely empty `flags: {}` is still accepted.
57
+ const flags = attributes?.flags;
58
+ if (!isFlagsMap(flags)) {
59
+ throw new UnsupportedConfigurationError("Malformed precomputed configuration: 'data.attributes.flags' must be an object.");
60
+ }
61
+
62
+ // A Map (returned as-is) so a pathological flag keyed "__proto__" is stored as data
63
+ // and later looked up via `.get()` — never hitting the `Object.prototype` "__proto__"
64
+ // setter (on write) or the prototype chain (on read) the way a plain object would.
65
+ const cache = new Map();
66
+ for (const [key, flag] of Object.entries(flags)) {
67
+ const entry = toFlagCacheEntry(key, flag);
68
+ if (entry) {
69
+ cache.set(key, entry);
70
+ }
71
+ }
72
+ return cache;
73
+ };
74
+
75
+ // A well-formed flags container is a plain object (a possibly-empty map of flag key -> flag).
76
+ // `null`, arrays, and primitives are malformed envelopes.
77
+ exports.decodePrecomputedFlags = decodePrecomputedFlags;
78
+ const isFlagsMap = value => typeof value === 'object' && value !== null && !Array.isArray(value);
79
+ const toFlagCacheEntry = (key, flag) => {
80
+ // A malformed payload can carry a non-object flag (e.g. `flags: { "k": null }`).
81
+ // Skip the bad entry with a warning instead of throwing and aborting decoding of
82
+ // the whole configuration.
83
+ if (typeof flag !== 'object' || flag === null) {
84
+ _InternalLog.InternalLog.log(`Flag "${key}" is not an object. Omitting it from the configuration.`, _SdkVerbosity.SdkVerbosity.WARN);
85
+ return null;
86
+ }
87
+ const {
88
+ variationType,
89
+ variationValue,
90
+ variationKey,
91
+ allocationKey,
92
+ reason,
93
+ doLog,
94
+ extraLogging
95
+ } = flag;
96
+ if (typeof variationType !== 'string' || !_types.SUPPORTED_VARIATION_TYPES.has(variationType)) {
97
+ _InternalLog.InternalLog.log(`Flag "${key}" has an unsupported variation type "${String(variationType)}". Omitting it from the configuration.`, _SdkVerbosity.SdkVerbosity.WARN);
98
+ return null;
99
+ }
100
+ if (!valueMatchesVariationType(variationValue, variationType)) {
101
+ _InternalLog.InternalLog.log(`Flag "${key}" value does not match its variation type "${variationType}". Omitting it from the configuration.`, _SdkVerbosity.SdkVerbosity.WARN);
102
+ return null;
103
+ }
104
+
105
+ // The remaining fields feed evaluation and native exposure tracking. A corrupt
106
+ // payload could carry wrong types here, so validate before forwarding them.
107
+ if (typeof allocationKey !== 'string' || typeof variationKey !== 'string' || typeof reason !== 'string' || typeof doLog !== 'boolean' ||
108
+ // `extraLogging` must be a key/value map; an array (also `typeof === 'object'`) would
109
+ // break native exposure tracking that expects an object, so treat it as malformed.
110
+ extraLogging !== undefined && (typeof extraLogging !== 'object' || extraLogging === null || Array.isArray(extraLogging))) {
111
+ _InternalLog.InternalLog.log(`Flag "${key}" has malformed metadata. Omitting it from the configuration.`, _SdkVerbosity.SdkVerbosity.WARN);
112
+ return null;
113
+ }
114
+
115
+ // `serialId` is intentionally not propagated: `FlagCacheEntry` has no slot for it
116
+ // and the native CDN-fetched snapshot omits it too, so dropping it keeps
117
+ // offline/online parity.
118
+ return {
119
+ key,
120
+ value: variationValue,
121
+ allocationKey,
122
+ variationKey,
123
+ variationType,
124
+ variationValue: stringifyValue(variationValue),
125
+ reason,
126
+ doLog,
127
+ extraLogging: extraLogging ?? {}
128
+ };
129
+ };
130
+ const valueMatchesVariationType = (value, variationType) => {
131
+ switch (variationType) {
132
+ case 'boolean':
133
+ return typeof value === 'boolean';
134
+ case 'string':
135
+ return typeof value === 'string';
136
+ case 'number':
137
+ case 'float':
138
+ // Reject NaN/Infinity: native parsers can't round-trip them.
139
+ return typeof value === 'number' && Number.isFinite(value);
140
+ case 'integer':
141
+ // A fractional value under an integer flag would be truncated/mis-parsed
142
+ // natively, so require a whole number.
143
+ return Number.isInteger(value);
144
+ case 'object':
145
+ // The `object` variation type carries JSON. ffe-service enforces a top-level object at
146
+ // the API layer, so in practice the value is an object; that is not a storage
147
+ // constraint, so a malformed or hand-crafted payload could still carry any JSON value
148
+ // here. Accept it at decode (and stringify it for native tracking); a non-object value
149
+ // is then served the coded default with TYPE_MISMATCH at evaluation — see
150
+ // `FlagsClient.getObjectDetails`. So this only affects malformed wires, never the
151
+ // guaranteed-object values from a real Datadog config.
152
+ return true;
153
+ default:
154
+ return false;
155
+ }
156
+ };
157
+
158
+ /**
159
+ * Derive the string form of a flag value expected by native Android exposure tracking.
160
+ * Objects/arrays are JSON-encoded; everything else uses `String(...)`, which yields
161
+ * lowercase `"true"/"false"` for booleans.
162
+ */
163
+ const stringifyValue = value => {
164
+ if (value === null) {
165
+ return 'null';
166
+ }
167
+ if (typeof value === 'object') {
168
+ return JSON.stringify(value);
169
+ }
170
+ return String(value);
171
+ };
172
+ //# sourceMappingURL=precomputed.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_InternalLog","require","_SdkVerbosity","_types","UnsupportedConfigurationError","Error","constructor","message","name","exports","decodePrecomputedFlags","response","attributes","data","obfuscated","flags","isFlagsMap","cache","Map","key","flag","Object","entries","entry","toFlagCacheEntry","set","value","Array","isArray","InternalLog","log","SdkVerbosity","WARN","variationType","variationValue","variationKey","allocationKey","reason","doLog","extraLogging","SUPPORTED_VARIATION_TYPES","has","String","valueMatchesVariationType","undefined","stringifyValue","Number","isFinite","isInteger","JSON","stringify"],"sourceRoot":"../../../../src","sources":["flags/configuration/precomputed.ts"],"mappings":";;;;;;AAMA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AAOA,IAAAE,MAAA,GAAAF,OAAA;AAdA;AACA;AACA;AACA;AACA;;AAYA;AACA;AACA;AACA;AACA;AACO,MAAMG,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