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.
@@ -7,8 +7,8 @@ export type { ConfigSyncPayload, DeltaConfigPayload, DeltasCatchUpPayload, FullC
7
7
  export { performAslHandshake } from './handshake';
8
8
  export type { AslHandshakeSuccess } from './handshake';
9
9
  export { evaluateSdkFlag, evaluateAllSdkFlags, coerceType, prepareContextForEvaluator, prepareContextForLocalEval, mapToRecord, } from './evaluateSdkFlag';
10
- export { PII_VALUE_ENCODING, normalizePiiString, hashPiiValue, isPiiAttribute, piiWireOptionsFromPayload, applyPiiHashToFlatContext, } from './piiHash';
11
- export type { PiiWireOptions } from './piiHash';
10
+ export { PII_VALUE_ENCODING, normalizePiiString, hashPiiValue, isPiiAttribute, payloadHasExplicitPiiFields, piiWireOptionsFromPayload, resolvePiiWireForDelta, applyPiiHashToFlatContext, } from './piiHash';
11
+ export type { PiiWireOptions, ApplyPiiHashMode } from './piiHash';
12
12
  export { evaluateRule, evaluateKillSwitch, evaluateOnVariation, evaluateFlagWithTargetingRules, applyRolloutStrategy, applyPercentageRollout, applyVariantRollout, applyGradualRollout, computeCurrentPercentage, defaultHash, getContextAttribute, } from './flagEvaluator';
13
13
  export type { ExpectedFlagType, FlagEvaluationResult, Condition, TargetingRule, Rollout, Variation, Segment, EvaluationDeps, } from './flagEvaluator';
14
14
  export { flattenContext, flattenEvaluationContext } from './flattenContext';
@@ -8,6 +8,14 @@ export type PiiWireOptions = {
8
8
  piiSalt: string;
9
9
  piiValueEncoding?: typeof PII_VALUE_ENCODING | string;
10
10
  };
11
+ /**
12
+ * Extra apply options. Prefer plaintext context; only set `alreadyHashed`
13
+ * when callers intentionally supply wire digests (do not infer from hex shape).
14
+ */
15
+ export type ApplyPiiHashMode = {
16
+ /** When true, leave PII string fields unchanged (caller supplied digests). */
17
+ alreadyHashed?: boolean;
18
+ };
11
19
  /**
12
20
  * Normalize a string before PII hashing (trim + lowercase).
13
21
  * Must match FF-EU `normalizePiiString`.
@@ -31,23 +39,49 @@ export declare function hashPiiValue(value: string, salt: string): string;
31
39
  * @param piiAttributes Keys from signed config
32
40
  */
33
41
  export declare function isPiiAttribute(attribute: string | undefined | null, piiAttributes: readonly string[]): boolean;
42
+ /** Payload fields that carry PII wire metadata. */
43
+ export type PiiWirePayloadFields = {
44
+ piiAttributes?: unknown;
45
+ piiSalt?: unknown;
46
+ piiValueEncoding?: unknown;
47
+ };
48
+ /**
49
+ * Whether a payload explicitly includes any PII wire field (vs omitting all).
50
+ * Used so deltas that omit PII metadata keep the previous options, while
51
+ * deltas that send unusable fields clear them.
52
+ *
53
+ * @param payload Signed fullConfig / delta fields
54
+ */
55
+ export declare function payloadHasExplicitPiiFields(payload: PiiWirePayloadFields | null | undefined): boolean;
34
56
  /**
35
57
  * Parse PII wire options from a config-sync payload body.
36
58
  *
37
59
  * @param payload Signed fullConfig / delta fields
38
60
  * @returns Options when salt + encoding are usable; otherwise null
39
61
  */
40
- export declare function piiWireOptionsFromPayload(payload: {
41
- piiAttributes?: unknown;
42
- piiSalt?: unknown;
43
- piiValueEncoding?: unknown;
44
- } | null | undefined): PiiWireOptions | null;
62
+ export declare function piiWireOptionsFromPayload(payload: PiiWirePayloadFields | null | undefined): PiiWireOptions | null;
63
+ /**
64
+ * Resolve PII wire options for a delta: keep prior when all PII fields are
65
+ * absent; otherwise parse after merging omitted fields from `previous`.
66
+ *
67
+ * FF-EU `piiMetadata` always emits the full triple (or nothing). Merge is
68
+ * defensive so a salt-only / attrs-only delta cannot wipe the other fields.
69
+ * Explicit empty salt or unknown encoding still clears to null.
70
+ *
71
+ * @param previous Current store options
72
+ * @param action Delta (or similar) payload fields
73
+ */
74
+ export declare function resolvePiiWireForDelta(previous: PiiWireOptions | null, action: PiiWirePayloadFields | null | undefined): PiiWireOptions | null;
45
75
  /**
46
76
  * Hash PII string fields on a flat evaluation context so they match hashed
47
77
  * rule values on the wire.
48
78
  *
79
+ * Always hashes plaintext strings (including values that look like 64-char hex).
80
+ * Pass `{ alreadyHashed: true }` only when the caller already supplied digests.
81
+ *
49
82
  * @param context Flat context map (after prepare / flatten)
50
83
  * @param options PII options from the rules store
84
+ * @param mode Optional apply mode (`alreadyHashed` skips hashing)
51
85
  * @returns New context object with PII strings hashed (or the input if no-op)
52
86
  */
53
- export declare function applyPiiHashToFlatContext(context: Record<string, unknown>, options: PiiWireOptions | null | undefined): Record<string, unknown>;
87
+ export declare function applyPiiHashToFlatContext(context: Record<string, unknown>, options: PiiWireOptions | null | undefined, mode?: ApplyPiiHashMode): Record<string, unknown>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flagmint-js-sdk",
3
- "version": "2.2.2-rc.0",
3
+ "version": "2.2.2",
4
4
  "description": "Framework-agnostic JavaScript SDK for managing feature flags in Flagmint applications.",
5
5
  "author": "Flagmint Team",
6
6
  "license": "BSD 3-Clause",