flagmint-js-sdk 2.2.2-rc.0 → 2.2.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/README.md CHANGED
@@ -162,7 +162,7 @@ transportMode: 'long-polling' // POST evaluate on an interval
162
162
 
163
163
  # Connection sharing
164
164
 
165
- Used when the same app is embedded twice on one origin (for example two WeSeeDo iframes in a host page).
165
+ Used when the same app is embedded twice on one origin (for example two iframes in a host page).
166
166
 
167
167
  - **Leader** performs handshake and holds EventSource.
168
168
  - **Followers** receive flag snapshots over `BroadcastChannel` (`flagmint-share:<apiKey>`). Leadership is a `localStorage` lock (`flagmint_share_lock:<apiKey>`).
@@ -39093,7 +39093,7 @@ class SseTransport {
39093
39093
  this.connectPromise = new Promise((resolve, reject) => {
39094
39094
  this.connectResolve = resolve;
39095
39095
  this.connectReject = reject;
39096
- const sdkVersion = "2.2.2-rc.0";
39096
+ const sdkVersion = "2.2.2";
39097
39097
  const platform2 = typeof window !== "undefined" ? "browser" : "nodejs";
39098
39098
  const wrapperName = this.configOptions?.wrapper?.name || "native-js";
39099
39099
  const wrapperVersion = this.configOptions?.wrapper?.version || "none";
@@ -41873,7 +41873,6 @@ function isConfigPayloadExpired(expiresAt, now = Date.now()) {
41873
41873
  }
41874
41874
  const PII_VALUE_ENCODING = "hmac-v1";
41875
41875
  const textEncoder = new TextEncoder();
41876
- const HASH_HEX_PATTERN = /^[0-9a-f]{64}$/;
41877
41876
  function normalizePiiString(value) {
41878
41877
  return value.trim().toLowerCase();
41879
41878
  }
@@ -41901,6 +41900,11 @@ function isPiiAttribute(attribute, piiAttributes) {
41901
41900
  }
41902
41901
  return false;
41903
41902
  }
41903
+ function payloadHasExplicitPiiFields(payload) {
41904
+ if (!payload)
41905
+ return false;
41906
+ return payload.piiSalt !== void 0 || payload.piiAttributes !== void 0 || payload.piiValueEncoding !== void 0;
41907
+ }
41904
41908
  function piiWireOptionsFromPayload(payload) {
41905
41909
  if (!payload)
41906
41910
  return null;
@@ -41917,18 +41921,30 @@ function piiWireOptionsFromPayload(payload) {
41917
41921
  piiValueEncoding: PII_VALUE_ENCODING
41918
41922
  };
41919
41923
  }
41920
- function applyPiiHashToFlatContext(context, options) {
41924
+ function resolvePiiWireForDelta(previous, action) {
41925
+ if (!payloadHasExplicitPiiFields(action)) {
41926
+ return previous;
41927
+ }
41928
+ const merged = {
41929
+ piiSalt: action.piiSalt !== void 0 ? action.piiSalt : previous?.piiSalt,
41930
+ piiAttributes: action.piiAttributes !== void 0 ? action.piiAttributes : previous?.piiAttributes,
41931
+ piiValueEncoding: action.piiValueEncoding !== void 0 ? action.piiValueEncoding : previous?.piiValueEncoding
41932
+ };
41933
+ return piiWireOptionsFromPayload(merged);
41934
+ }
41935
+ function applyPiiHashToFlatContext(context, options, mode) {
41921
41936
  if (!options || !options.piiSalt || !options.piiAttributes.length || options.piiValueEncoding !== PII_VALUE_ENCODING) {
41922
41937
  return context;
41923
41938
  }
41939
+ if (mode?.alreadyHashed) {
41940
+ return context;
41941
+ }
41924
41942
  let changed = false;
41925
41943
  const out = { ...context };
41926
41944
  for (const [key2, value] of Object.entries(context)) {
41927
41945
  if (!isPiiAttribute(key2, options.piiAttributes))
41928
41946
  continue;
41929
41947
  if (typeof value === "string") {
41930
- if (HASH_HEX_PATTERN.test(value))
41931
- continue;
41932
41948
  out[key2] = hashPiiValue(value, options.piiSalt);
41933
41949
  changed = true;
41934
41950
  continue;
@@ -41938,8 +41954,6 @@ function applyPiiHashToFlatContext(context, options) {
41938
41954
  const next = value.map((entry) => {
41939
41955
  if (typeof entry !== "string")
41940
41956
  return entry;
41941
- if (HASH_HEX_PATTERN.test(entry))
41942
- return entry;
41943
41957
  arrayChanged = true;
41944
41958
  return hashPiiValue(entry, options.piiSalt);
41945
41959
  });
@@ -42020,7 +42034,7 @@ function applyPatch(state, action) {
42020
42034
  if (flag?.key)
42021
42035
  flags.set(flag.key, flag);
42022
42036
  }
42023
- const nextPii = piiWireOptionsFromPayload(action) ?? state.piiWire;
42037
+ const nextPii = resolvePiiWireForDelta(state.piiWire, action);
42024
42038
  return {
42025
42039
  version: action.toVersion,
42026
42040
  expiresAt: typeof action.expiresAt === "number" ? action.expiresAt : state.expiresAt,
@@ -42434,7 +42448,7 @@ function flattenEvaluationContext(context) {
42434
42448
  function toComparableString(value) {
42435
42449
  if (value === null || value === void 0)
42436
42450
  return "";
42437
- return String(value);
42451
+ return String(value).trim().toLowerCase();
42438
42452
  }
42439
42453
  function toComparableArray(value) {
42440
42454
  if (Array.isArray(value)) {