@datadog/flagging-core 0.1.0-preview.9 → 0.2.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/LICENSE +201 -0
- package/README.md +5 -0
- package/cjs/cache/abstract-assignment-cache.d.ts +39 -0
- package/cjs/cache/abstract-assignment-cache.d.ts.map +1 -0
- package/cjs/cache/abstract-assignment-cache.js +59 -0
- package/cjs/cache/abstract-assignment-cache.js.map +1 -0
- package/cjs/cache/index.d.ts +4 -0
- package/cjs/cache/index.d.ts.map +1 -0
- package/cjs/cache/index.js +20 -0
- package/cjs/cache/index.js.map +1 -0
- package/cjs/cache/lru-cache.d.ts +31 -0
- package/cjs/cache/lru-cache.d.ts.map +1 -0
- package/cjs/cache/lru-cache.js +85 -0
- package/cjs/cache/lru-cache.js.map +1 -0
- package/cjs/cache/lru-in-memory-assignment-cache.d.ts +16 -0
- package/cjs/cache/lru-in-memory-assignment-cache.d.ts.map +1 -0
- package/cjs/cache/lru-in-memory-assignment-cache.js +22 -0
- package/cjs/cache/lru-in-memory-assignment-cache.js.map +1 -0
- package/cjs/cache/non-expiring-in-memory-cache-assignment.d.ts +11 -0
- package/cjs/cache/non-expiring-in-memory-cache-assignment.d.ts.map +1 -0
- package/cjs/cache/non-expiring-in-memory-cache-assignment.js +17 -0
- package/cjs/cache/non-expiring-in-memory-cache-assignment.js.map +1 -0
- package/cjs/configuration/configuration.d.ts +1 -1
- package/cjs/configuration/exposureEvent.d.ts.map +1 -1
- package/cjs/configuration/exposureEvent.js +0 -1
- package/cjs/configuration/exposureEvent.js.map +1 -1
- package/cjs/configuration/exposureEvent.types.d.ts +13 -2
- package/cjs/configuration/exposureEvent.types.d.ts.map +1 -1
- package/cjs/index.d.ts +2 -0
- package/cjs/index.d.ts.map +1 -1
- package/cjs/index.js +2 -0
- package/cjs/index.js.map +1 -1
- package/cjs/obfuscation.d.ts +9 -0
- package/cjs/obfuscation.d.ts.map +1 -0
- package/cjs/obfuscation.js +23 -0
- package/cjs/obfuscation.js.map +1 -0
- package/esm/cache/abstract-assignment-cache.d.ts +39 -0
- package/esm/cache/abstract-assignment-cache.d.ts.map +1 -0
- package/esm/cache/abstract-assignment-cache.js +53 -0
- package/esm/cache/abstract-assignment-cache.js.map +1 -0
- package/esm/cache/index.d.ts +4 -0
- package/esm/cache/index.d.ts.map +1 -0
- package/esm/cache/index.js +4 -0
- package/esm/cache/index.js.map +1 -0
- package/esm/cache/lru-cache.d.ts +31 -0
- package/esm/cache/lru-cache.d.ts.map +1 -0
- package/esm/cache/lru-cache.js +81 -0
- package/esm/cache/lru-cache.js.map +1 -0
- package/esm/cache/lru-in-memory-assignment-cache.d.ts +16 -0
- package/esm/cache/lru-in-memory-assignment-cache.d.ts.map +1 -0
- package/esm/cache/lru-in-memory-assignment-cache.js +18 -0
- package/esm/cache/lru-in-memory-assignment-cache.js.map +1 -0
- package/esm/cache/non-expiring-in-memory-cache-assignment.d.ts +11 -0
- package/esm/cache/non-expiring-in-memory-cache-assignment.d.ts.map +1 -0
- package/esm/cache/non-expiring-in-memory-cache-assignment.js +13 -0
- package/esm/cache/non-expiring-in-memory-cache-assignment.js.map +1 -0
- package/esm/configuration/configuration.d.ts +1 -1
- package/esm/configuration/exposureEvent.d.ts.map +1 -1
- package/esm/configuration/exposureEvent.js +0 -1
- package/esm/configuration/exposureEvent.js.map +1 -1
- package/esm/configuration/exposureEvent.types.d.ts +13 -2
- package/esm/configuration/exposureEvent.types.d.ts.map +1 -1
- package/esm/index.d.ts +2 -0
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +2 -0
- package/esm/index.js.map +1 -1
- package/esm/obfuscation.d.ts +9 -0
- package/esm/obfuscation.d.ts.map +1 -0
- package/esm/obfuscation.js +16 -0
- package/esm/obfuscation.js.map +1 -0
- package/package.json +15 -2
package/cjs/index.js
CHANGED
|
@@ -14,7 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./cache"), exports);
|
|
17
18
|
__exportStar(require("./configuration"), exports);
|
|
19
|
+
__exportStar(require("./obfuscation"), exports);
|
|
18
20
|
// Build environment placeholder for testing
|
|
19
21
|
const _SDK_VERSION = "dev";
|
|
20
22
|
//# sourceMappingURL=index.js.map
|
package/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAA+B;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAuB;AACvB,kDAA+B;AAC/B,gDAA6B;AAE7B,4CAA4C;AAC5C,MAAM,YAAY,GAAG,0BAA0B,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare function getMD5Hash(input: string, salt?: string): string;
|
|
2
|
+
/**
|
|
3
|
+
* Builds a storage key suffix from an API key.
|
|
4
|
+
* @param apiKey - The API key to build the suffix from
|
|
5
|
+
* @returns A string suffix for storage keys
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export declare function buildStorageKeySuffix(apiKey: string): string;
|
|
9
|
+
//# sourceMappingURL=obfuscation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"obfuscation.d.ts","sourceRoot":"","sources":["../src/obfuscation.ts"],"names":[],"mappings":"AAEA,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,SAAK,GAAG,MAAM,CAE3D;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAI5D"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getMD5Hash = getMD5Hash;
|
|
7
|
+
exports.buildStorageKeySuffix = buildStorageKeySuffix;
|
|
8
|
+
const spark_md5_1 = __importDefault(require("spark-md5"));
|
|
9
|
+
function getMD5Hash(input, salt = '') {
|
|
10
|
+
return new spark_md5_1.default().append(salt).append(input).end();
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Builds a storage key suffix from an API key.
|
|
14
|
+
* @param apiKey - The API key to build the suffix from
|
|
15
|
+
* @returns A string suffix for storage keys
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
function buildStorageKeySuffix(apiKey) {
|
|
19
|
+
// Note that we hash the API key and use the first 16 characters of the digest.
|
|
20
|
+
const hashed = getMD5Hash(apiKey);
|
|
21
|
+
return hashed.slice(0, 16);
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=obfuscation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"obfuscation.js","sourceRoot":"","sources":["../src/obfuscation.ts"],"names":[],"mappings":";;;;;AAEA,gCAEC;AAQD,sDAIC;AAhBD,0DAAgC;AAEhC,SAAgB,UAAU,CAAC,KAAa,EAAE,IAAI,GAAG,EAAE;IACjD,OAAO,IAAI,mBAAQ,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,CAAA;AACxD,CAAC;AAED;;;;;GAKG;AACH,SAAgB,qBAAqB,CAAC,MAAc;IAClD,+EAA+E;IAC/E,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC,CAAA;IACjC,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;AAC5B,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ExposureEvent } from '../configuration';
|
|
2
|
+
export type AssignmentCacheKey = Pick<ExposureEvent, 'flag' | 'subject'>;
|
|
3
|
+
export type AssignmentCacheEntry = ExposureEvent;
|
|
4
|
+
/** Converts an {@link AssignmentCacheKey} to a string. */
|
|
5
|
+
export declare function assignmentCacheKeyToString(exposureEvent: AssignmentCacheKey | ExposureEvent): string;
|
|
6
|
+
/** Converts an {@link AssignmentCacheValue} to a string. */
|
|
7
|
+
export declare function assignmentCacheValueToString(cacheValue: AssignmentCacheEntry): string;
|
|
8
|
+
export interface AsyncMap<K, V> {
|
|
9
|
+
get(key: K): Promise<V | undefined>;
|
|
10
|
+
set(key: K, value: V): Promise<void>;
|
|
11
|
+
has(key: K): Promise<boolean>;
|
|
12
|
+
}
|
|
13
|
+
export interface AssignmentCache {
|
|
14
|
+
init(): Promise<void>;
|
|
15
|
+
set(key: AssignmentCacheEntry): void;
|
|
16
|
+
has(key: AssignmentCacheEntry): boolean;
|
|
17
|
+
clear(): Promise<void> | void;
|
|
18
|
+
}
|
|
19
|
+
export declare abstract class AbstractAssignmentCache<T extends Map<string, string>> implements AssignmentCache {
|
|
20
|
+
protected readonly delegate: T;
|
|
21
|
+
protected constructor(delegate: T);
|
|
22
|
+
init(): Promise<void>;
|
|
23
|
+
/** Returns whether the provided {@link AssignmentCacheEntry} is present in the cache. */
|
|
24
|
+
has(entry: AssignmentCacheEntry): boolean;
|
|
25
|
+
get(key: AssignmentCacheKey): string | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Stores the provided {@link AssignmentCacheEntry} in the cache. If the key already exists, it
|
|
28
|
+
* will be overwritten.
|
|
29
|
+
*/
|
|
30
|
+
set(entry: AssignmentCacheEntry): void;
|
|
31
|
+
/**
|
|
32
|
+
* Returns an array with all {@link AssignmentCacheEntry} entries in the cache as an array of
|
|
33
|
+
* {@link string}s.
|
|
34
|
+
*/
|
|
35
|
+
entries(): IterableIterator<[string, string]>;
|
|
36
|
+
/** Clears all entries from the cache. */
|
|
37
|
+
clear(): void;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=abstract-assignment-cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abstract-assignment-cache.d.ts","sourceRoot":"","sources":["../../src/cache/abstract-assignment-cache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAGrD,MAAM,MAAM,kBAAkB,GAAG,IAAI,CAAC,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC,CAAA;AACxE,MAAM,MAAM,oBAAoB,GAAG,aAAa,CAAA;AAEhD,0DAA0D;AAC1D,wBAAgB,0BAA0B,CAAC,aAAa,EAAE,kBAAkB,GAAG,aAAa,GAAG,MAAM,CAWpG;AAED,4DAA4D;AAC5D,wBAAgB,4BAA4B,CAAC,UAAU,EAAE,oBAAoB,GAAG,MAAM,CAErF;AAED,MAAM,WAAW,QAAQ,CAAC,CAAC,EAAE,CAAC;IAC5B,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAAA;IAEnC,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAEpC,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;CAC9B;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IAErB,GAAG,CAAC,GAAG,EAAE,oBAAoB,GAAG,IAAI,CAAA;IAEpC,GAAG,CAAC,GAAG,EAAE,oBAAoB,GAAG,OAAO,CAAA;IAEvC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;CAC9B;AAED,8BAAsB,uBAAuB,CAAC,CAAC,SAAS,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAE,YAAW,eAAe;IAE/E,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;IAApD,SAAS,aAAgC,QAAQ,EAAE,CAAC;IAEpD,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAIrB,yFAAyF;IACzF,GAAG,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO;IAIzC,GAAG,CAAC,GAAG,EAAE,kBAAkB,GAAG,MAAM,GAAG,SAAS;IAIhD;;;OAGG;IACH,GAAG,CAAC,KAAK,EAAE,oBAAoB,GAAG,IAAI;IAItC;;;OAGG;IACH,OAAO,IAAI,gBAAgB,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAI7C,yCAAyC;IACzC,KAAK,IAAI,IAAI;CAGd"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { getMD5Hash } from '../obfuscation';
|
|
2
|
+
/** Converts an {@link AssignmentCacheKey} to a string. */
|
|
3
|
+
export function assignmentCacheKeyToString(exposureEvent) {
|
|
4
|
+
const key = {
|
|
5
|
+
flag: {
|
|
6
|
+
key: exposureEvent.flag.key,
|
|
7
|
+
},
|
|
8
|
+
subject: {
|
|
9
|
+
id: exposureEvent.subject.id,
|
|
10
|
+
attributes: exposureEvent.subject.attributes,
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
return getMD5Hash(JSON.stringify(key));
|
|
14
|
+
}
|
|
15
|
+
/** Converts an {@link AssignmentCacheValue} to a string. */
|
|
16
|
+
export function assignmentCacheValueToString(cacheValue) {
|
|
17
|
+
return getMD5Hash(JSON.stringify(cacheValue));
|
|
18
|
+
}
|
|
19
|
+
export class AbstractAssignmentCache {
|
|
20
|
+
// key -> variation value hash
|
|
21
|
+
constructor(delegate) {
|
|
22
|
+
this.delegate = delegate;
|
|
23
|
+
}
|
|
24
|
+
init() {
|
|
25
|
+
return Promise.resolve();
|
|
26
|
+
}
|
|
27
|
+
/** Returns whether the provided {@link AssignmentCacheEntry} is present in the cache. */
|
|
28
|
+
has(entry) {
|
|
29
|
+
return this.get(entry) === assignmentCacheValueToString(entry);
|
|
30
|
+
}
|
|
31
|
+
get(key) {
|
|
32
|
+
return this.delegate.get(assignmentCacheKeyToString(key));
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Stores the provided {@link AssignmentCacheEntry} in the cache. If the key already exists, it
|
|
36
|
+
* will be overwritten.
|
|
37
|
+
*/
|
|
38
|
+
set(entry) {
|
|
39
|
+
this.delegate.set(assignmentCacheKeyToString(entry), assignmentCacheValueToString(entry));
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Returns an array with all {@link AssignmentCacheEntry} entries in the cache as an array of
|
|
43
|
+
* {@link string}s.
|
|
44
|
+
*/
|
|
45
|
+
entries() {
|
|
46
|
+
return this.delegate.entries();
|
|
47
|
+
}
|
|
48
|
+
/** Clears all entries from the cache. */
|
|
49
|
+
clear() {
|
|
50
|
+
this.delegate.clear();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=abstract-assignment-cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abstract-assignment-cache.js","sourceRoot":"","sources":["../../src/cache/abstract-assignment-cache.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAK3C,0DAA0D;AAC1D,MAAM,UAAU,0BAA0B,CAAC,aAAiD;IAC1F,MAAM,GAAG,GAAuB;QAC9B,IAAI,EAAE;YACJ,GAAG,EAAE,aAAa,CAAC,IAAI,CAAC,GAAG;SAC5B;QACD,OAAO,EAAE;YACP,EAAE,EAAE,aAAa,CAAC,OAAO,CAAC,EAAE;YAC5B,UAAU,EAAE,aAAa,CAAC,OAAO,CAAC,UAAU;SAC7C;KACF,CAAA;IACD,OAAO,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAA;AACxC,CAAC;AAED,4DAA4D;AAC5D,MAAM,UAAU,4BAA4B,CAAC,UAAgC;IAC3E,OAAO,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAA;AAC/C,CAAC;AAoBD,MAAM,OAAgB,uBAAuB;IAC3C,8BAA8B;IAC9B,YAAyC,QAAW;QAAX,aAAQ,GAAR,QAAQ,CAAG;IAAG,CAAC;IAExD,IAAI;QACF,OAAO,OAAO,CAAC,OAAO,EAAE,CAAA;IAC1B,CAAC;IAED,yFAAyF;IACzF,GAAG,CAAC,KAA2B;QAC7B,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,4BAA4B,CAAC,KAAK,CAAC,CAAA;IAChE,CAAC;IAED,GAAG,CAAC,GAAuB;QACzB,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,0BAA0B,CAAC,GAAG,CAAC,CAAC,CAAA;IAC3D,CAAC;IAED;;;OAGG;IACH,GAAG,CAAC,KAA2B;QAC7B,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,0BAA0B,CAAC,KAAK,CAAC,EAAE,4BAA4B,CAAC,KAAK,CAAC,CAAC,CAAA;IAC3F,CAAC;IAED;;;OAGG;IACH,OAAO;QACL,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAA;IAChC,CAAC;IAED,yCAAyC;IACzC,KAAK;QACH,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAA;IACvB,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cache/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAA;AAC3C,cAAc,kCAAkC,CAAA;AAChD,cAAc,2CAA2C,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cache/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAA;AAC3C,cAAc,kCAAkC,CAAA;AAChD,cAAc,2CAA2C,CAAA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LRUCache is a simple implementation of a Least Recently Used (LRU) cache.
|
|
3
|
+
*
|
|
4
|
+
* Old items are evicted when the cache reaches its capacity.
|
|
5
|
+
*
|
|
6
|
+
* The cache is implemented as a Map, which maintains insertion order:
|
|
7
|
+
* ```
|
|
8
|
+
* Iteration happens in insertion order, which corresponds to the order in which each key-value pair
|
|
9
|
+
* was first inserted into the map by the set() method (that is, there wasn't a key with the same
|
|
10
|
+
* value already in the map when set() was called).
|
|
11
|
+
* ```
|
|
12
|
+
* Source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map
|
|
13
|
+
*/
|
|
14
|
+
export declare class LRUCache implements Map<string, string> {
|
|
15
|
+
protected readonly capacity: number;
|
|
16
|
+
protected readonly cache: Map<string, string>;
|
|
17
|
+
[Symbol.toStringTag]: string;
|
|
18
|
+
constructor(capacity: number);
|
|
19
|
+
[Symbol.iterator](): IterableIterator<[string, string]>;
|
|
20
|
+
forEach(callbackFn: (value: string, key: string, map: Map<string, string>) => void): void;
|
|
21
|
+
readonly size: number;
|
|
22
|
+
entries(): IterableIterator<[string, string]>;
|
|
23
|
+
clear(): void;
|
|
24
|
+
delete(key: string): boolean;
|
|
25
|
+
keys(): IterableIterator<string>;
|
|
26
|
+
values(): IterableIterator<string>;
|
|
27
|
+
has(key: string): boolean;
|
|
28
|
+
get(key: string): string | undefined;
|
|
29
|
+
set(key: string, value: string): this;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=lru-cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lru-cache.d.ts","sourceRoot":"","sources":["../../src/cache/lru-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,qBAAa,QAAS,YAAW,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IAMtC,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM;IAL/C,SAAS,CAAC,QAAQ,CAAC,KAAK,sBAA6B;IAGrD,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,MAAM,CAAA;gBAEG,QAAQ,EAAE,MAAM;IAE/C,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,gBAAgB,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAIvD,OAAO,CAAC,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,IAAI,GAAG,IAAI;IAIzF,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAkB;IAEvC,OAAO,IAAI,gBAAgB,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAI7C,KAAK;IAIL,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAI5B,IAAI,IAAI,gBAAgB,CAAC,MAAM,CAAC;IAIhC,MAAM,IAAI,gBAAgB,CAAC,MAAM,CAAC;IAIlC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAIzB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAoBpC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;CAqBtC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LRUCache is a simple implementation of a Least Recently Used (LRU) cache.
|
|
3
|
+
*
|
|
4
|
+
* Old items are evicted when the cache reaches its capacity.
|
|
5
|
+
*
|
|
6
|
+
* The cache is implemented as a Map, which maintains insertion order:
|
|
7
|
+
* ```
|
|
8
|
+
* Iteration happens in insertion order, which corresponds to the order in which each key-value pair
|
|
9
|
+
* was first inserted into the map by the set() method (that is, there wasn't a key with the same
|
|
10
|
+
* value already in the map when set() was called).
|
|
11
|
+
* ```
|
|
12
|
+
* Source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map
|
|
13
|
+
*/
|
|
14
|
+
export class LRUCache {
|
|
15
|
+
constructor(capacity) {
|
|
16
|
+
this.capacity = capacity;
|
|
17
|
+
this.cache = new Map();
|
|
18
|
+
this.size = this.cache.size;
|
|
19
|
+
}
|
|
20
|
+
[(Symbol.toStringTag, Symbol.iterator)]() {
|
|
21
|
+
return this.cache[Symbol.iterator]();
|
|
22
|
+
}
|
|
23
|
+
forEach(callbackFn) {
|
|
24
|
+
this.cache.forEach(callbackFn);
|
|
25
|
+
}
|
|
26
|
+
entries() {
|
|
27
|
+
return this.cache.entries();
|
|
28
|
+
}
|
|
29
|
+
clear() {
|
|
30
|
+
this.cache.clear();
|
|
31
|
+
}
|
|
32
|
+
delete(key) {
|
|
33
|
+
return this.cache.delete(key);
|
|
34
|
+
}
|
|
35
|
+
keys() {
|
|
36
|
+
return this.cache.keys();
|
|
37
|
+
}
|
|
38
|
+
values() {
|
|
39
|
+
return this.cache.values();
|
|
40
|
+
}
|
|
41
|
+
has(key) {
|
|
42
|
+
return this.cache.has(key);
|
|
43
|
+
}
|
|
44
|
+
get(key) {
|
|
45
|
+
if (!this.has(key)) {
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
const value = this.cache.get(key);
|
|
49
|
+
if (value !== undefined) {
|
|
50
|
+
// the delete and set operations are used together to ensure that the most recently accessed
|
|
51
|
+
// or added item is always considered the "newest" in terms of access order.
|
|
52
|
+
// This is crucial for maintaining the correct order of elements in the cache,
|
|
53
|
+
// which directly impacts which item is considered the least recently used (LRU) and
|
|
54
|
+
// thus eligible for eviction when the cache reaches its capacity.
|
|
55
|
+
this.delete(key);
|
|
56
|
+
this.cache.set(key, value);
|
|
57
|
+
}
|
|
58
|
+
return value;
|
|
59
|
+
}
|
|
60
|
+
set(key, value) {
|
|
61
|
+
if (this.capacity === 0) {
|
|
62
|
+
return this;
|
|
63
|
+
}
|
|
64
|
+
if (this.cache.has(key)) {
|
|
65
|
+
this.cache.delete(key);
|
|
66
|
+
}
|
|
67
|
+
else if (this.cache.size >= this.capacity) {
|
|
68
|
+
// To evict the least recently used (LRU) item, we retrieve the first key in the Map.
|
|
69
|
+
// This is possible because the Map object in JavaScript maintains the insertion order of the keys.
|
|
70
|
+
// Therefore, the first key represents the oldest entry, which is the least recently used item in our cache.
|
|
71
|
+
// We use Map.prototype.keys().next().value to obtain this oldest key and then delete it from the cache.
|
|
72
|
+
const oldestKey = this.cache.keys().next().value;
|
|
73
|
+
if (oldestKey) {
|
|
74
|
+
this.delete(oldestKey);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
this.cache.set(key, value);
|
|
78
|
+
return this;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=lru-cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lru-cache.js","sourceRoot":"","sources":["../../src/cache/lru-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,QAAQ;IAMnB,YAA+B,QAAgB;QAAhB,aAAQ,GAAR,QAAQ,CAAQ;QAL5B,UAAK,GAAG,IAAI,GAAG,EAAkB,CAAC;QAe5C,SAAI,GAAW,IAAI,CAAC,KAAK,CAAC,IAAI,CAAA;IAVW,CAAC;IAEnD,EAJC,MAAM,CAAC,WAAW,EAIlB,MAAM,CAAC,QAAQ,EAAC;QACf,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAA;IACtC,CAAC;IAED,OAAO,CAAC,UAA0E;QAChF,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;IAChC,CAAC;IAID,OAAO;QACL,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAA;IAC7B,CAAC;IAED,KAAK;QACH,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;IACpB,CAAC;IAED,MAAM,CAAC,GAAW;QAChB,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;IAC/B,CAAC;IAED,IAAI;QACF,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAA;IAC1B,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAA;IAC5B,CAAC;IAED,GAAG,CAAC,GAAW;QACb,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IAC5B,CAAC;IAED,GAAG,CAAC,GAAW;QACb,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YACnB,OAAO,SAAS,CAAA;QAClB,CAAC;QAED,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QAEjC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,4FAA4F;YAC5F,4EAA4E;YAC5E,8EAA8E;YAC9E,oFAAoF;YACpF,kEAAkE;YAClE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;YAChB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;QAC5B,CAAC;QAED,OAAO,KAAK,CAAA;IACd,CAAC;IAED,GAAG,CAAC,GAAW,EAAE,KAAa;QAC5B,IAAI,IAAI,CAAC,QAAQ,KAAK,CAAC,EAAE,CAAC;YACxB,OAAO,IAAI,CAAA;QACb,CAAC;QAED,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YACxB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;QACxB,CAAC;aAAM,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC5C,qFAAqF;YACrF,mGAAmG;YACnG,4GAA4G;YAC5G,wGAAwG;YACxG,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAA;YAChD,IAAI,SAAS,EAAE,CAAC;gBACd,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;YACxB,CAAC;QACH,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;QAC1B,OAAO,IAAI,CAAA;IACb,CAAC;CACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AbstractAssignmentCache } from './abstract-assignment-cache';
|
|
2
|
+
import { LRUCache } from './lru-cache';
|
|
3
|
+
/**
|
|
4
|
+
* A cache that uses the LRU algorithm to evict the least recently used items.
|
|
5
|
+
*
|
|
6
|
+
* It is used to limit the size of the cache.
|
|
7
|
+
*
|
|
8
|
+
* The primary use case is for server-side SDKs, where the cache is shared across
|
|
9
|
+
* multiple users. In this case, the cache size should be set to the maximum number
|
|
10
|
+
* of users that can be active at the same time.
|
|
11
|
+
* @param {number} maxSize - Maximum cache size
|
|
12
|
+
*/
|
|
13
|
+
export declare class LRUInMemoryAssignmentCache extends AbstractAssignmentCache<LRUCache> {
|
|
14
|
+
constructor(maxSize: number);
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=lru-in-memory-assignment-cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lru-in-memory-assignment-cache.d.ts","sourceRoot":"","sources":["../../src/cache/lru-in-memory-assignment-cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAA;AACrE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAEtC;;;;;;;;;GASG;AACH,qBAAa,0BAA2B,SAAQ,uBAAuB,CAAC,QAAQ,CAAC;gBACnE,OAAO,EAAE,MAAM;CAG5B"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AbstractAssignmentCache } from './abstract-assignment-cache';
|
|
2
|
+
import { LRUCache } from './lru-cache';
|
|
3
|
+
/**
|
|
4
|
+
* A cache that uses the LRU algorithm to evict the least recently used items.
|
|
5
|
+
*
|
|
6
|
+
* It is used to limit the size of the cache.
|
|
7
|
+
*
|
|
8
|
+
* The primary use case is for server-side SDKs, where the cache is shared across
|
|
9
|
+
* multiple users. In this case, the cache size should be set to the maximum number
|
|
10
|
+
* of users that can be active at the same time.
|
|
11
|
+
* @param {number} maxSize - Maximum cache size
|
|
12
|
+
*/
|
|
13
|
+
export class LRUInMemoryAssignmentCache extends AbstractAssignmentCache {
|
|
14
|
+
constructor(maxSize) {
|
|
15
|
+
super(new LRUCache(maxSize));
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=lru-in-memory-assignment-cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lru-in-memory-assignment-cache.js","sourceRoot":"","sources":["../../src/cache/lru-in-memory-assignment-cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAA;AACrE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAEtC;;;;;;;;;GASG;AACH,MAAM,OAAO,0BAA2B,SAAQ,uBAAiC;IAC/E,YAAY,OAAe;QACzB,KAAK,CAAC,IAAI,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAA;IAC9B,CAAC;CACF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AbstractAssignmentCache } from './abstract-assignment-cache';
|
|
2
|
+
/**
|
|
3
|
+
* A cache that never expires.
|
|
4
|
+
*
|
|
5
|
+
* The primary use case is for client-side SDKs, where the cache is only used
|
|
6
|
+
* for a single user.
|
|
7
|
+
*/
|
|
8
|
+
export declare class NonExpiringInMemoryAssignmentCache extends AbstractAssignmentCache<Map<string, string>> {
|
|
9
|
+
constructor(store?: Map<string, string>);
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=non-expiring-in-memory-cache-assignment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"non-expiring-in-memory-cache-assignment.d.ts","sourceRoot":"","sources":["../../src/cache/non-expiring-in-memory-cache-assignment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAA;AAErE;;;;;GAKG;AACH,qBAAa,kCAAmC,SAAQ,uBAAuB,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;gBACtF,KAAK,sBAA4B;CAG9C"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AbstractAssignmentCache } from './abstract-assignment-cache';
|
|
2
|
+
/**
|
|
3
|
+
* A cache that never expires.
|
|
4
|
+
*
|
|
5
|
+
* The primary use case is for client-side SDKs, where the cache is only used
|
|
6
|
+
* for a single user.
|
|
7
|
+
*/
|
|
8
|
+
export class NonExpiringInMemoryAssignmentCache extends AbstractAssignmentCache {
|
|
9
|
+
constructor(store = new Map()) {
|
|
10
|
+
super(store);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=non-expiring-in-memory-cache-assignment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"non-expiring-in-memory-cache-assignment.js","sourceRoot":"","sources":["../../src/cache/non-expiring-in-memory-cache-assignment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAA;AAErE;;;;;GAKG;AACH,MAAM,OAAO,kCAAmC,SAAQ,uBAA4C;IAClG,YAAY,QAAQ,IAAI,GAAG,EAAkB;QAC3C,KAAK,CAAC,KAAK,CAAC,CAAA;IACd,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exposureEvent.d.ts","sourceRoot":"","sources":["../../src/configuration/exposureEvent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AACxF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAE1D,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,SAAS,EACrD,OAAO,EAAE,iBAAiB,EAC1B,OAAO,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAC5B,aAAa,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"exposureEvent.d.ts","sourceRoot":"","sources":["../../src/configuration/exposureEvent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AACxF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAE1D,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,SAAS,EACrD,OAAO,EAAE,iBAAiB,EAC1B,OAAO,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAC5B,aAAa,GAAG,SAAS,CA8B3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exposureEvent.js","sourceRoot":"","sources":["../../src/configuration/exposureEvent.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,mBAAmB,CACjC,OAA0B,EAC1B,OAA6B;;IAE7B,iCAAiC;IACjC,IAAI,CAAC,CAAA,MAAA,OAAO,CAAC,YAAY,0CAAE,KAAK,CAAA,EAAE,CAAC;QACjC,OAAM;IACR,CAAC;IAED,kFAAkF;IAClF,MAAM,aAAa,GAAG,MAAA,OAAO,CAAC,YAAY,0CAAE,aAAuB,CAAA;IACnE,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAA;IAClC,IAAI,CAAC,aAAa,IAAI,CAAC,UAAU,EAAE,CAAC;QAClC,OAAM;IACR,CAAC;IAED,MAAM,EAAE,YAAY,EAAE,EAAE,GAAG,EAAE,EAAE,GAAG,UAAU,EAAE,GAAG,OAAO,CAAA;IAExD,OAAO;QACL,
|
|
1
|
+
{"version":3,"file":"exposureEvent.js","sourceRoot":"","sources":["../../src/configuration/exposureEvent.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,mBAAmB,CACjC,OAA0B,EAC1B,OAA6B;;IAE7B,iCAAiC;IACjC,IAAI,CAAC,CAAA,MAAA,OAAO,CAAC,YAAY,0CAAE,KAAK,CAAA,EAAE,CAAC;QACjC,OAAM;IACR,CAAC;IAED,kFAAkF;IAClF,MAAM,aAAa,GAAG,MAAA,OAAO,CAAC,YAAY,0CAAE,aAAuB,CAAA;IACnE,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAA;IAClC,IAAI,CAAC,aAAa,IAAI,CAAC,UAAU,EAAE,CAAC;QAClC,OAAM;IACR,CAAC;IAED,MAAM,EAAE,YAAY,EAAE,EAAE,GAAG,EAAE,EAAE,GAAG,UAAU,EAAE,GAAG,OAAO,CAAA;IAExD,OAAO;QACL,UAAU,EAAE;YACV,GAAG,EAAE,aAAa;SACnB;QACD,IAAI,EAAE;YACJ,GAAG,EAAE,OAAO,CAAC,OAAO;SACrB;QACD,OAAO,EAAE;YACP,GAAG,EAAE,UAAU;SAChB;QACD,OAAO,EAAE;YACP,EAAE;YACF,UAAU;SACX;KACsB,CAAA;AAC3B,CAAC"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import type { EvaluationContext } from '@openfeature/core';
|
|
2
2
|
export interface ExposureEvent {
|
|
3
|
-
/** Unix timestamp in milliseconds */
|
|
4
|
-
timestamp: number;
|
|
5
3
|
allocation: {
|
|
6
4
|
key: string;
|
|
7
5
|
};
|
|
@@ -15,5 +13,18 @@ export interface ExposureEvent {
|
|
|
15
13
|
id: string;
|
|
16
14
|
attributes: EvaluationContext;
|
|
17
15
|
};
|
|
16
|
+
service?: string;
|
|
17
|
+
rum?: {
|
|
18
|
+
application?: {
|
|
19
|
+
id?: string;
|
|
20
|
+
};
|
|
21
|
+
view?: {
|
|
22
|
+
url?: string;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export interface ExposureEventWithTimestamp extends ExposureEvent {
|
|
27
|
+
/** Unix timestamp in milliseconds */
|
|
28
|
+
timestamp: number;
|
|
18
29
|
}
|
|
19
30
|
//# sourceMappingURL=exposureEvent.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exposureEvent.types.d.ts","sourceRoot":"","sources":["../../src/configuration/exposureEvent.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAE1D,MAAM,WAAW,aAAa;IAC5B,
|
|
1
|
+
{"version":3,"file":"exposureEvent.types.d.ts","sourceRoot":"","sources":["../../src/configuration/exposureEvent.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAE1D,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE;QACV,GAAG,EAAE,MAAM,CAAA;KACZ,CAAA;IACD,IAAI,EAAE;QACJ,GAAG,EAAE,MAAM,CAAA;KACZ,CAAA;IACD,OAAO,EAAE;QACP,GAAG,EAAE,MAAM,CAAA;KACZ,CAAA;IACD,OAAO,EAAE;QACP,EAAE,EAAE,MAAM,CAAA;QACV,UAAU,EAAE,iBAAiB,CAAA;KAC9B,CAAA;IACD,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,GAAG,CAAC,EAAE;QACJ,WAAW,CAAC,EAAE;YACZ,EAAE,CAAC,EAAE,MAAM,CAAA;SACZ,CAAA;QACD,IAAI,CAAC,EAAE;YACL,GAAG,CAAC,EAAE,MAAM,CAAA;SACb,CAAA;KACF,CAAA;CACF;AAED,MAAM,WAAW,0BAA2B,SAAQ,aAAa;IAC/D,qCAAqC;IACrC,SAAS,EAAE,MAAM,CAAA;CAClB"}
|
package/esm/index.d.ts
CHANGED
package/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,iBAAiB,CAAA;AAC/B,cAAc,eAAe,CAAA"}
|
package/esm/index.js
CHANGED
package/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,iBAAiB,CAAA;AAC/B,cAAc,eAAe,CAAA;AAE7B,4CAA4C;AAC5C,MAAM,YAAY,GAAG,0BAA0B,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare function getMD5Hash(input: string, salt?: string): string;
|
|
2
|
+
/**
|
|
3
|
+
* Builds a storage key suffix from an API key.
|
|
4
|
+
* @param apiKey - The API key to build the suffix from
|
|
5
|
+
* @returns A string suffix for storage keys
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export declare function buildStorageKeySuffix(apiKey: string): string;
|
|
9
|
+
//# sourceMappingURL=obfuscation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"obfuscation.d.ts","sourceRoot":"","sources":["../src/obfuscation.ts"],"names":[],"mappings":"AAEA,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,SAAK,GAAG,MAAM,CAE3D;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAI5D"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import SparkMD5 from 'spark-md5';
|
|
2
|
+
export function getMD5Hash(input, salt = '') {
|
|
3
|
+
return new SparkMD5().append(salt).append(input).end();
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Builds a storage key suffix from an API key.
|
|
7
|
+
* @param apiKey - The API key to build the suffix from
|
|
8
|
+
* @returns A string suffix for storage keys
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
export function buildStorageKeySuffix(apiKey) {
|
|
12
|
+
// Note that we hash the API key and use the first 16 characters of the digest.
|
|
13
|
+
const hashed = getMD5Hash(apiKey);
|
|
14
|
+
return hashed.slice(0, 16);
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=obfuscation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"obfuscation.js","sourceRoot":"","sources":["../src/obfuscation.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,WAAW,CAAA;AAEhC,MAAM,UAAU,UAAU,CAAC,KAAa,EAAE,IAAI,GAAG,EAAE;IACjD,OAAO,IAAI,QAAQ,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,CAAA;AACxD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAAc;IAClD,+EAA+E;IAC/E,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC,CAAA;IACjC,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;AAC5B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datadog/flagging-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Runtime-agnostic flag-evaluation logic for Datadog Flagging",
|
|
5
|
-
"license": "
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "https://github.com/DataDog/openfeature-js-client.git",
|
|
@@ -20,6 +20,15 @@
|
|
|
20
20
|
"main": "cjs/index.js",
|
|
21
21
|
"module": "esm/index.js",
|
|
22
22
|
"types": "cjs/index.d.ts",
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"types": "./cjs/index.d.ts",
|
|
26
|
+
"import": "./esm/index.js",
|
|
27
|
+
"require": "./cjs/index.js",
|
|
28
|
+
"default": "./esm/index.js"
|
|
29
|
+
},
|
|
30
|
+
"./package.json": "./package.json"
|
|
31
|
+
},
|
|
23
32
|
"scripts": {
|
|
24
33
|
"prepack": "yarn build",
|
|
25
34
|
"pack": "yarn pack",
|
|
@@ -35,6 +44,7 @@
|
|
|
35
44
|
"@openfeature/core": "^1.8.1",
|
|
36
45
|
"@types/jest": "^29.4.0",
|
|
37
46
|
"@types/node": "^18.0.0",
|
|
47
|
+
"@types/spark-md5": "^3.0.5",
|
|
38
48
|
"jest": "^30.0.4",
|
|
39
49
|
"npm-run-all": "^4.1.5",
|
|
40
50
|
"ts-jest": "^29.4.0",
|
|
@@ -43,5 +53,8 @@
|
|
|
43
53
|
},
|
|
44
54
|
"peerDependencies": {
|
|
45
55
|
"@openfeature/core": "^1.8.1"
|
|
56
|
+
},
|
|
57
|
+
"dependencies": {
|
|
58
|
+
"spark-md5": "^3.0.2"
|
|
46
59
|
}
|
|
47
60
|
}
|