@kameleoon/javascript-sdk-core 1.1.1 → 2.1.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.
Files changed (157) hide show
  1. package/dist/cacheManager/cacheManager.d.ts +38 -0
  2. package/dist/cacheManager/cacheManager.js +74 -0
  3. package/dist/cacheManager/cacheManager.js.map +1 -0
  4. package/dist/cacheManager/index.d.ts +2 -0
  5. package/dist/cacheManager/index.js +20 -0
  6. package/dist/cacheManager/index.js.map +1 -0
  7. package/dist/cacheManager/types.d.ts +14 -0
  8. package/dist/cacheManager/types.js +6 -0
  9. package/dist/cacheManager/types.js.map +1 -0
  10. package/dist/campaignConfiguration/campaignConfiguration.d.ts +2 -1
  11. package/dist/campaignConfiguration/campaignConfiguration.js +243 -196
  12. package/dist/campaignConfiguration/campaignConfiguration.js.map +1 -1
  13. package/dist/campaignConfiguration/constants.d.ts +3 -3
  14. package/dist/campaignConfiguration/constants.js +22 -16
  15. package/dist/campaignConfiguration/constants.js.map +1 -1
  16. package/dist/campaignConfiguration/index.d.ts +1 -0
  17. package/dist/campaignConfiguration/index.js +85 -6
  18. package/dist/campaignConfiguration/index.js.map +1 -1
  19. package/dist/campaignConfiguration/types.d.ts +7 -3
  20. package/dist/campaignConfiguration/types.js +53 -45
  21. package/dist/campaignConfiguration/types.js.map +1 -1
  22. package/dist/clientSettings/clientSettings.d.ts +1 -1
  23. package/dist/clientSettings/clientSettings.js +28 -21
  24. package/dist/clientSettings/clientSettings.js.map +1 -1
  25. package/dist/clientSettings/index.js +18 -4
  26. package/dist/clientSettings/index.js.map +1 -1
  27. package/dist/clientSettings/types.d.ts +1 -1
  28. package/dist/clientSettings/types.js +4 -1
  29. package/dist/clientSettings/types.js.map +1 -1
  30. package/dist/constants.d.ts +11 -0
  31. package/dist/constants.js +37 -14
  32. package/dist/constants.js.map +1 -1
  33. package/dist/eventSource/constants.js +6 -2
  34. package/dist/eventSource/constants.js.map +1 -1
  35. package/dist/eventSource/externalEventSource.js +28 -20
  36. package/dist/eventSource/externalEventSource.js.map +1 -1
  37. package/dist/eventSource/index.js +49 -6
  38. package/dist/eventSource/index.js.map +1 -1
  39. package/dist/eventSource/types.d.ts +1 -1
  40. package/dist/eventSource/types.js +4 -1
  41. package/dist/eventSource/types.js.map +1 -1
  42. package/dist/hasher/hasher.d.ts +1 -1
  43. package/dist/hasher/hasher.js +37 -26
  44. package/dist/hasher/hasher.js.map +1 -1
  45. package/dist/hasher/index.js +11 -4
  46. package/dist/hasher/index.js.map +1 -1
  47. package/dist/hasher/types.d.ts +1 -1
  48. package/dist/hasher/types.js +4 -1
  49. package/dist/hasher/types.js.map +1 -1
  50. package/dist/index.d.ts +4 -2
  51. package/dist/index.js +309 -28
  52. package/dist/index.js.map +1 -1
  53. package/dist/kameleoonClient.d.ts +32 -19
  54. package/dist/kameleoonClient.js +353 -235
  55. package/dist/kameleoonClient.js.map +1 -1
  56. package/dist/kameleoonData/browser.js +37 -32
  57. package/dist/kameleoonData/browser.js.map +1 -1
  58. package/dist/kameleoonData/constants.js +6 -2
  59. package/dist/kameleoonData/constants.js.map +1 -1
  60. package/dist/kameleoonData/conversion.js +47 -40
  61. package/dist/kameleoonData/conversion.js.map +1 -1
  62. package/dist/kameleoonData/customData.js +62 -58
  63. package/dist/kameleoonData/customData.js.map +1 -1
  64. package/dist/kameleoonData/device.js +37 -32
  65. package/dist/kameleoonData/device.js.map +1 -1
  66. package/dist/kameleoonData/index.js +101 -18
  67. package/dist/kameleoonData/index.js.map +1 -1
  68. package/dist/kameleoonData/nonce.js +25 -13
  69. package/dist/kameleoonData/nonce.js.map +1 -1
  70. package/dist/kameleoonData/pageView.js +52 -44
  71. package/dist/kameleoonData/pageView.js.map +1 -1
  72. package/dist/kameleoonData/types.js +41 -26
  73. package/dist/kameleoonData/types.js.map +1 -1
  74. package/dist/kameleoonData/userAgent.js +33 -24
  75. package/dist/kameleoonData/userAgent.js.map +1 -1
  76. package/dist/kameleoonError/constants.d.ts +1 -1
  77. package/dist/kameleoonError/constants.js +25 -21
  78. package/dist/kameleoonError/constants.js.map +1 -1
  79. package/dist/kameleoonError/helpers.js +6 -4
  80. package/dist/kameleoonError/helpers.js.map +1 -1
  81. package/dist/kameleoonError/index.js +25 -8
  82. package/dist/kameleoonError/index.js.map +1 -1
  83. package/dist/kameleoonError/kameleoonError.d.ts +1 -1
  84. package/dist/kameleoonError/kameleoonError.js +64 -53
  85. package/dist/kameleoonError/kameleoonError.js.map +1 -1
  86. package/dist/kameleoonError/types.d.ts +1 -1
  87. package/dist/kameleoonError/types.js +26 -22
  88. package/dist/kameleoonError/types.js.map +1 -1
  89. package/dist/kameleoonUtils.js +34 -33
  90. package/dist/kameleoonUtils.js.map +1 -1
  91. package/dist/requester/constants.d.ts +6 -7
  92. package/dist/requester/constants.js +58 -45
  93. package/dist/requester/constants.js.map +1 -1
  94. package/dist/requester/index.d.ts +2 -2
  95. package/dist/requester/index.js +67 -8
  96. package/dist/requester/index.js.map +1 -1
  97. package/dist/requester/requester.d.ts +7 -7
  98. package/dist/requester/requester.js +90 -113
  99. package/dist/requester/requester.js.map +1 -1
  100. package/dist/requester/types.d.ts +38 -10
  101. package/dist/requester/types.js +14 -36
  102. package/dist/requester/types.js.map +1 -1
  103. package/dist/storage/constants.js +11 -7
  104. package/dist/storage/constants.js.map +1 -1
  105. package/dist/storage/externalStorage.js +33 -26
  106. package/dist/storage/externalStorage.js.map +1 -1
  107. package/dist/storage/index.js +55 -6
  108. package/dist/storage/index.js.map +1 -1
  109. package/dist/storage/types.js +4 -1
  110. package/dist/storage/types.js.map +1 -1
  111. package/dist/targeting/conditions/conditionFactory.js +24 -19
  112. package/dist/targeting/conditions/conditionFactory.js.map +1 -1
  113. package/dist/targeting/conditions/customDataCondition.js +99 -88
  114. package/dist/targeting/conditions/customDataCondition.js.map +1 -1
  115. package/dist/targeting/conditions/exclusiveExperimentCondition.js +27 -15
  116. package/dist/targeting/conditions/exclusiveExperimentCondition.js.map +1 -1
  117. package/dist/targeting/conditions/index.js +45 -10
  118. package/dist/targeting/conditions/index.js.map +1 -1
  119. package/dist/targeting/conditions/targetExperimentCondition.js +54 -32
  120. package/dist/targeting/conditions/targetExperimentCondition.js.map +1 -1
  121. package/dist/targeting/conditions/types.js +4 -1
  122. package/dist/targeting/conditions/types.js.map +1 -1
  123. package/dist/targeting/index.js +79 -13
  124. package/dist/targeting/index.js.map +1 -1
  125. package/dist/targeting/targetingNode.js +41 -33
  126. package/dist/targeting/targetingNode.js.map +1 -1
  127. package/dist/targeting/targetingTree.js +125 -104
  128. package/dist/targeting/targetingTree.js.map +1 -1
  129. package/dist/targeting/types.js +99 -91
  130. package/dist/targeting/types.js.map +1 -1
  131. package/dist/types.d.ts +34 -2
  132. package/dist/types.js +58 -21
  133. package/dist/types.js.map +1 -1
  134. package/dist/utilities/constants.js +6 -2
  135. package/dist/utilities/constants.js.map +1 -1
  136. package/dist/utilities/index.js +11 -4
  137. package/dist/utilities/index.js.map +1 -1
  138. package/dist/utilities/types.d.ts +9 -1
  139. package/dist/utilities/types.js +4 -1
  140. package/dist/utilities/types.js.map +1 -1
  141. package/dist/utilities/utilities.d.ts +6 -3
  142. package/dist/utilities/utilities.js +171 -105
  143. package/dist/utilities/utilities.js.map +1 -1
  144. package/dist/variationConfiguration/index.js +24 -4
  145. package/dist/variationConfiguration/index.js.map +1 -1
  146. package/dist/variationConfiguration/types.d.ts +1 -1
  147. package/dist/variationConfiguration/types.js +4 -1
  148. package/dist/variationConfiguration/types.js.map +1 -1
  149. package/dist/variationConfiguration/variation.js +35 -28
  150. package/dist/variationConfiguration/variation.js.map +1 -1
  151. package/dist/variationConfiguration/variationConfiguration.d.ts +5 -6
  152. package/dist/variationConfiguration/variationConfiguration.js +263 -230
  153. package/dist/variationConfiguration/variationConfiguration.js.map +1 -1
  154. package/package.json +6 -4
  155. package/dist/hasher/constants.d.ts +0 -1
  156. package/dist/hasher/constants.js +0 -5
  157. package/dist/hasher/constants.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,wBAAwB,GAAG,CAAC,CAAC;AAC7B,QAAA,iBAAiB,GAAG,KAAK,CAAC;AAC1B,QAAA,oBAAoB,GAAG,sBAAsB,CAAC;AAC9C,QAAA,mBAAmB,GAAG,EAAE,CAAC;AAEtC,IAAY,MAMX;AAND,WAAY,MAAM;IAChB,+BAAqB,CAAA;IACrB,iCAAuB,CAAA;IACvB,2BAAiB,CAAA;IACjB,uBAAa,CAAA;IACb,2BAAiB,CAAA;AACnB,CAAC,EANW,MAAM,GAAN,cAAM,KAAN,cAAM,QAMjB"}
1
+ {"version":3,"file":"constants.js","names":["UNALLOCATED_VARIATION_ID","exports","OFF_VARIATION_KEY","KAMELEOON_COOKIE_KEY","VISITOR_CODE_LENGTH","CACHE_CLEANUP_TIMEOUT","CACHE_ITEM_LIFETIME","Cookie","SDKType"],"sources":["../src/constants.ts"],"sourcesContent":["export const UNALLOCATED_VARIATION_ID = 0;\nexport const OFF_VARIATION_KEY = 'off';\nexport const KAMELEOON_COOKIE_KEY = 'kameleoonVisitorCode';\nexport const VISITOR_CODE_LENGTH = 16;\nexport const CACHE_CLEANUP_TIMEOUT = 10;\nexport const CACHE_ITEM_LIFETIME = 5;\n\nexport enum Cookie {\n PairsDelimiter = '; ',\n KeyValueDelimiter = '=',\n MaxAge = 'MaxAge',\n Path = 'Path',\n Domain = 'Domain',\n}\n\n/**\n * @readonly\n * @enum {string} an Enum of all the possible Kameleoon SDK types\n * */\nexport enum SDKType {\n NodeJS = 'nodejs',\n JavaScript = 'javascript',\n React = 'react',\n}\n"],"mappings":";;;;;;AAAO,MAAMA,wBAAwB,GAAG,CAAC;AAACC,OAAA,CAAAD,wBAAA,GAAAA,wBAAA;AACnC,MAAME,iBAAiB,GAAG,KAAK;AAACD,OAAA,CAAAC,iBAAA,GAAAA,iBAAA;AAChC,MAAMC,oBAAoB,GAAG,sBAAsB;AAACF,OAAA,CAAAE,oBAAA,GAAAA,oBAAA;AACpD,MAAMC,mBAAmB,GAAG,EAAE;AAACH,OAAA,CAAAG,mBAAA,GAAAA,mBAAA;AAC/B,MAAMC,qBAAqB,GAAG,EAAE;AAACJ,OAAA,CAAAI,qBAAA,GAAAA,qBAAA;AACjC,MAAMC,mBAAmB,GAAG,CAAC;AAACL,OAAA,CAAAK,mBAAA,GAAAA,mBAAA;AAAA,IAEzBC,MAAM,0BAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAAA,OAANA,MAAM;AAAA;AAQlB;AACA;AACA;AACA;AAHAN,OAAA,CAAAM,MAAA,GAAAA,MAAA;AAAA,IAIYC,OAAO,0BAAPA,OAAO;EAAPA,OAAO;EAAPA,OAAO;EAAPA,OAAO;EAAA,OAAPA,OAAO;AAAA;AAAAP,OAAA,CAAAO,OAAA,GAAAA,OAAA"}
@@ -1,5 +1,9 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
3
6
  exports.REAL_TIME_EVENT = void 0;
4
- exports.REAL_TIME_EVENT = 'configuration-update-event';
7
+ const REAL_TIME_EVENT = 'configuration-update-event';
8
+ exports.REAL_TIME_EVENT = REAL_TIME_EVENT;
5
9
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/eventSource/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG,4BAA4B,CAAC"}
1
+ {"version":3,"file":"constants.js","names":["REAL_TIME_EVENT","exports"],"sources":["../../src/eventSource/constants.ts"],"sourcesContent":["export const REAL_TIME_EVENT = 'configuration-update-event';\n"],"mappings":";;;;;;AAAO,MAAMA,eAAe,GAAG,4BAA4B;AAACC,OAAA,CAAAD,eAAA,GAAAA,eAAA"}
@@ -1,26 +1,34 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
3
6
  exports.ExternalEventSource = void 0;
4
- const requester_1 = require("../requester");
5
- const constants_1 = require("../requester/constants");
6
- const constants_2 = require("./constants");
7
+ var _requester = require("../requester");
8
+ var _constants = require("../requester/constants");
9
+ var _constants2 = require("./constants");
10
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
11
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
12
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
7
13
  class ExternalEventSource {
8
- constructor(siteCode, externalEventSource) {
9
- const url = requester_1.URL.EVENTS + constants_1.UrlQuery.Sse + siteCode;
10
- const eventSource = externalEventSource.initialize(url);
11
- this.eventSource = eventSource;
12
- this.siteCode = siteCode;
13
- }
14
- open(onEvent) {
15
- this.eventSource.open({
16
- onEvent,
17
- siteCode: this.siteCode,
18
- eventType: constants_2.REAL_TIME_EVENT,
19
- });
20
- }
21
- close() {
22
- this.eventSource.close();
23
- }
14
+ constructor(siteCode, externalEventSource) {
15
+ _defineProperty(this, "eventSource", void 0);
16
+ _defineProperty(this, "siteCode", void 0);
17
+ const url = _requester.URL.EVENTS + _constants.UrlQuery.Sse + siteCode;
18
+ const eventSource = externalEventSource.initialize(url);
19
+ this.eventSource = eventSource;
20
+ this.siteCode = siteCode;
21
+ }
22
+ open(onEvent) {
23
+ this.eventSource.open({
24
+ onEvent,
25
+ siteCode: this.siteCode,
26
+ eventType: _constants2.REAL_TIME_EVENT
27
+ });
28
+ }
29
+ close() {
30
+ this.eventSource.close();
31
+ }
24
32
  }
25
33
  exports.ExternalEventSource = ExternalEventSource;
26
34
  //# sourceMappingURL=externalEventSource.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"externalEventSource.js","sourceRoot":"","sources":["../../src/eventSource/externalEventSource.ts"],"names":[],"mappings":";;;AAAA,4CAAmC;AACnC,sDAAkD;AAClD,2CAA8C;AAQ9C,MAAa,mBAAmB;IAI9B,YACE,QAAgB,EAChB,mBAAoD;QAEpD,MAAM,GAAG,GAAG,eAAG,CAAC,MAAM,GAAG,oBAAQ,CAAC,GAAG,GAAG,QAAQ,CAAC;QACjD,MAAM,WAAW,GAAG,mBAAmB,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QAExD,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAEM,IAAI,CAAC,OAAoC;QAC9C,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;YACpB,OAAO;YACP,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,SAAS,EAAE,2BAAe;SAC3B,CAAC,CAAC;IACL,CAAC;IAEM,KAAK;QACV,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;IAC3B,CAAC;CACF;AA1BD,kDA0BC"}
1
+ {"version":3,"file":"externalEventSource.js","names":["_requester","require","_constants","_constants2","_defineProperty","obj","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","ExternalEventSource","constructor","siteCode","externalEventSource","url","URL","EVENTS","UrlQuery","Sse","eventSource","initialize","open","onEvent","eventType","REAL_TIME_EVENT","close","exports"],"sources":["../../src/eventSource/externalEventSource.ts"],"sourcesContent":["import { URL } from '../requester';\nimport { UrlQuery } from '../requester/constants';\nimport { REAL_TIME_EVENT } from './constants';\nimport { IExternalEventSource, IExternalEventSourceConstructor } from './types';\n\nexport interface IEventSource {\n open: (onEvent: (timestamp: number) => void) => void;\n close: () => void;\n}\n\nexport class ExternalEventSource implements IEventSource {\n private eventSource: IExternalEventSource;\n private siteCode: string;\n\n constructor(\n siteCode: string,\n externalEventSource: IExternalEventSourceConstructor,\n ) {\n const url = URL.EVENTS + UrlQuery.Sse + siteCode;\n const eventSource = externalEventSource.initialize(url);\n\n this.eventSource = eventSource;\n this.siteCode = siteCode;\n }\n\n public open(onEvent: (timestamp: number) => void): void {\n this.eventSource.open({\n onEvent,\n siteCode: this.siteCode,\n eventType: REAL_TIME_EVENT,\n });\n }\n\n public close(): void {\n this.eventSource.close();\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAA8C,SAAAG,gBAAAC,GAAA,EAAAC,GAAA,EAAAC,KAAA,IAAAD,GAAA,GAAAE,cAAA,CAAAF,GAAA,OAAAA,GAAA,IAAAD,GAAA,IAAAI,MAAA,CAAAC,cAAA,CAAAL,GAAA,EAAAC,GAAA,IAAAC,KAAA,EAAAA,KAAA,EAAAI,UAAA,QAAAC,YAAA,QAAAC,QAAA,oBAAAR,GAAA,CAAAC,GAAA,IAAAC,KAAA,WAAAF,GAAA;AAAA,SAAAG,eAAAM,GAAA,QAAAR,GAAA,GAAAS,YAAA,CAAAD,GAAA,2BAAAR,GAAA,gBAAAA,GAAA,GAAAU,MAAA,CAAAV,GAAA;AAAA,SAAAS,aAAAE,KAAA,EAAAC,IAAA,eAAAD,KAAA,iBAAAA,KAAA,kBAAAA,KAAA,MAAAE,IAAA,GAAAF,KAAA,CAAAG,MAAA,CAAAC,WAAA,OAAAF,IAAA,KAAAG,SAAA,QAAAC,GAAA,GAAAJ,IAAA,CAAAK,IAAA,CAAAP,KAAA,EAAAC,IAAA,2BAAAK,GAAA,sBAAAA,GAAA,YAAAE,SAAA,4DAAAP,IAAA,gBAAAF,MAAA,GAAAU,MAAA,EAAAT,KAAA;AAQvC,MAAMU,mBAAmB,CAAyB;EAIvDC,WAAWA,CACTC,QAAgB,EAChBC,mBAAoD,EACpD;IAAA1B,eAAA;IAAAA,eAAA;IACA,MAAM2B,GAAG,GAAGC,cAAG,CAACC,MAAM,GAAGC,mBAAQ,CAACC,GAAG,GAAGN,QAAQ;IAChD,MAAMO,WAAW,GAAGN,mBAAmB,CAACO,UAAU,CAACN,GAAG,CAAC;IAEvD,IAAI,CAACK,WAAW,GAAGA,WAAW;IAC9B,IAAI,CAACP,QAAQ,GAAGA,QAAQ;EAC1B;EAEOS,IAAIA,CAACC,OAAoC,EAAQ;IACtD,IAAI,CAACH,WAAW,CAACE,IAAI,CAAC;MACpBC,OAAO;MACPV,QAAQ,EAAE,IAAI,CAACA,QAAQ;MACvBW,SAAS,EAAEC;IACb,CAAC,CAAC;EACJ;EAEOC,KAAKA,CAAA,EAAS;IACnB,IAAI,CAACN,WAAW,CAACM,KAAK,EAAE;EAC1B;AACF;AAACC,OAAA,CAAAhB,mBAAA,GAAAA,mBAAA"}
@@ -1,8 +1,51 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.REAL_TIME_EVENT = exports.ExternalEventSource = void 0;
4
- var externalEventSource_1 = require("./externalEventSource");
5
- Object.defineProperty(exports, "ExternalEventSource", { enumerable: true, get: function () { return externalEventSource_1.ExternalEventSource; } });
6
- var constants_1 = require("./constants");
7
- Object.defineProperty(exports, "REAL_TIME_EVENT", { enumerable: true, get: function () { return constants_1.REAL_TIME_EVENT; } });
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "EventSourceOpenParametersType", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _types.EventSourceOpenParametersType;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "ExternalEventSource", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _externalEventSource.ExternalEventSource;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "IEventSource", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _externalEventSource.IEventSource;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "IExternalEventSource", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _types.IExternalEventSource;
28
+ }
29
+ });
30
+ Object.defineProperty(exports, "IExternalEventSourceConstructor", {
31
+ enumerable: true,
32
+ get: function () {
33
+ return _types.IExternalEventSourceConstructor;
34
+ }
35
+ });
36
+ Object.defineProperty(exports, "REAL_TIME_EVENT", {
37
+ enumerable: true,
38
+ get: function () {
39
+ return _constants.REAL_TIME_EVENT;
40
+ }
41
+ });
42
+ Object.defineProperty(exports, "RealTimeEventType", {
43
+ enumerable: true,
44
+ get: function () {
45
+ return _types.RealTimeEventType;
46
+ }
47
+ });
48
+ var _types = require("./types");
49
+ var _externalEventSource = require("./externalEventSource");
50
+ var _constants = require("./constants");
8
51
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/eventSource/index.ts"],"names":[],"mappings":";;;AAMA,6DAA0E;AAAjE,0HAAA,mBAAmB,OAAA;AAC5B,yCAA8C;AAArC,4GAAA,eAAe,OAAA"}
1
+ {"version":3,"file":"index.js","names":["_types","require","_externalEventSource","_constants"],"sources":["../../src/eventSource/index.ts"],"sourcesContent":["export {\n IExternalEventSourceConstructor,\n EventSourceOpenParametersType,\n IExternalEventSource,\n RealTimeEventType,\n} from './types';\nexport { ExternalEventSource, IEventSource } from './externalEventSource';\nexport { REAL_TIME_EVENT } from './constants';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAMA,IAAAC,oBAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA"}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @interface an interface of External Constructor for Extrnal Event Source which must be implemented by the wrapper constructor to initialize new `IExternalEventSource` in order to pass the necessary `url` parameter
2
+ * @interface an interface of External Constructor for External Event Source which must be implemented by the wrapper constructor to initialize new `IExternalEventSource` in order to pass the necessary `url` parameter
3
3
  * */
4
4
  export interface IExternalEventSourceConstructor {
5
5
  /**
@@ -1,3 +1,6 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
3
6
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/eventSource/types.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../src/eventSource/types.ts"],"sourcesContent":["/**\n * @interface an interface of External Constructor for External Event Source which must be implemented by the wrapper constructor to initialize new `IExternalEventSource` in order to pass the necessary `url` parameter\n * */\nexport interface IExternalEventSourceConstructor {\n /**\n * @method initialize - creates and instance of `IExternalEventSource` and returns it\n * @param {string} url - url of server sent event server which will be pasted by consumer\n * @returns {IExternalEventSource} an initialized instance of `IExternalEventSource`\n * */\n initialize: (url: string) => IExternalEventSource;\n}\n\n/**\n * @param {string} siteCode - site code from the event\n * @param {string} eventType - type of event to be listened for\n * @param {(timestamp: number) => void} onEvent - callback to be executed upon event if the site code from event matches the site code of EvenetSource\n * */\nexport type EventSourceOpenParametersType = {\n siteCode: string;\n eventType: string;\n onEvent: (timestamp: number) => void;\n};\n\n/**\n * @interface an interface of External Event Source which will be used in server sent events operations\n * */\nexport interface IExternalEventSource {\n /**\n * @method open - opens event source live connection\n * @param {(timestamp: number) => void} callback - callback function that will be executed on each obtainment of server event\n * */\n open: ({\n siteCode,\n eventType,\n onEvent,\n }: EventSourceOpenParametersType) => void;\n /**\n * @method close - closes event source live connection\n * */\n close: () => void;\n}\n\n/**\n * @param {string} siteCode - site code from the event\n * @param {number} ts - timestamp of when the event has happened\n * */\nexport type RealTimeEventType = {\n siteCode: string;\n ts: number;\n};\n\nexport type CreateEventSourceParamsType = {\n siteCode: string;\n externalEventSource?: IExternalEventSourceConstructor;\n};\n"],"mappings":""}
@@ -1,6 +1,6 @@
1
1
  import { ObtainExperimentHashDoubleParamsType, ObtainFeatureFlagHashDoubleParamsType } from './types';
2
2
  export declare class Hasher {
3
3
  static obtainExperimentHashDouble({ visitorCode, campaignId, respoolTime, }: ObtainExperimentHashDoubleParamsType): number;
4
- static obtainFeatureFlagHashDouble({ visitorCode, campaignId, reShuffle, }: ObtainFeatureFlagHashDoubleParamsType): number;
4
+ static obtainFeatureFlagHashDouble({ visitorCode, campaignId, respoolTime, }: ObtainFeatureFlagHashDoubleParamsType): number;
5
5
  static calculateHash(seed: string): number;
6
6
  }
@@ -1,34 +1,45 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
3
6
  exports.Hasher = void 0;
4
- const crypto_js_1 = require("crypto-js");
5
- const constants_1 = require("./constants");
7
+ var _cryptoJs = require("crypto-js");
6
8
  class Hasher {
7
- static obtainExperimentHashDouble({ visitorCode, campaignId, respoolTime, }) {
8
- let respoolTimeString = '';
9
- if (respoolTime.length) {
10
- respoolTime.forEach((respoolObject) => {
11
- respoolTimeString += String(respoolObject.value);
12
- });
13
- }
14
- return this.calculateHash(visitorCode + campaignId + respoolTimeString);
9
+ static obtainExperimentHashDouble({
10
+ visitorCode,
11
+ campaignId,
12
+ respoolTime
13
+ }) {
14
+ let respoolTimeString = '';
15
+ if (respoolTime.length) {
16
+ respoolTime.forEach(respoolObject => {
17
+ respoolTimeString += String(respoolObject.value);
18
+ });
15
19
  }
16
- static obtainFeatureFlagHashDouble({ visitorCode, campaignId,
17
- // --- Note ---
18
- // For some cases of feature flag rules we need to obtain `hashDouble` twice
19
- // in a row, but the second `hashDouble` should be different (yet still predictable)
20
- reShuffle = false, }) {
21
- return this.calculateHash(visitorCode + campaignId + (reShuffle ? constants_1.RESHUFFLE_SUFFIX : ''));
22
- }
23
- // --- Note ---
24
- // `hashDouble` is a seeded pseudo-random number between 0 and 1
25
- // used for deciding what variation to assign
26
- // `calculateHash` algorythm is consistent between every SDK
27
- // and will always provide same pseudo-random value for the same input parameters
28
- static calculateHash(seed) {
29
- const hashDigest = (0, crypto_js_1.SHA256)(seed).toString();
30
- return parseInt(hashDigest, 16) / Math.pow(2, 256);
20
+ return this.calculateHash(visitorCode + campaignId + respoolTimeString);
21
+ }
22
+ static obtainFeatureFlagHashDouble({
23
+ visitorCode,
24
+ campaignId,
25
+ respoolTime
26
+ }) {
27
+ let suffix = '';
28
+ if (respoolTime) {
29
+ suffix += String(respoolTime);
31
30
  }
31
+ return this.calculateHash(visitorCode + campaignId + suffix);
32
+ }
33
+
34
+ // --- Note ---
35
+ // `hashDouble` is a seeded pseudo-random number between 0 and 1
36
+ // used for deciding what variation to assign
37
+ // `calculateHash` algorithm is consistent between every SDK
38
+ // and will always provide same pseudo-random value for the same input parameters
39
+ static calculateHash(seed) {
40
+ const hashDigest = (0, _cryptoJs.SHA256)(seed).toString();
41
+ return parseInt(hashDigest, 16) / Math.pow(2, 256);
42
+ }
32
43
  }
33
44
  exports.Hasher = Hasher;
34
45
  //# sourceMappingURL=hasher.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"hasher.js","sourceRoot":"","sources":["../../src/hasher/hasher.ts"],"names":[],"mappings":";;;AAAA,yCAAmC;AACnC,2CAA+C;AAM/C,MAAa,MAAM;IACjB,MAAM,CAAC,0BAA0B,CAAC,EAChC,WAAW,EACX,UAAU,EACV,WAAW,GAC0B;QACrC,IAAI,iBAAiB,GAAG,EAAE,CAAC;QAE3B,IAAI,WAAW,CAAC,MAAM,EAAE;YACtB,WAAW,CAAC,OAAO,CAAC,CAAC,aAAa,EAAE,EAAE;gBACpC,iBAAiB,IAAI,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;YACnD,CAAC,CAAC,CAAC;SACJ;QAED,OAAO,IAAI,CAAC,aAAa,CAAC,WAAW,GAAG,UAAU,GAAG,iBAAiB,CAAC,CAAC;IAC1E,CAAC;IAED,MAAM,CAAC,2BAA2B,CAAC,EACjC,WAAW,EACX,UAAU;IACV,eAAe;IACf,4EAA4E;IAC5E,oFAAoF;IACpF,SAAS,GAAG,KAAK,GACqB;QACtC,OAAO,IAAI,CAAC,aAAa,CACvB,WAAW,GAAG,UAAU,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,4BAAgB,CAAC,CAAC,CAAC,EAAE,CAAC,CAC/D,CAAC;IACJ,CAAC;IAED,eAAe;IACf,gEAAgE;IAChE,6CAA6C;IAC7C,4DAA4D;IAC5D,iFAAiF;IACjF,MAAM,CAAC,aAAa,CAAC,IAAY;QAC/B,MAAM,UAAU,GAAG,IAAA,kBAAM,EAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC;QAE3C,OAAO,QAAQ,CAAC,UAAU,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IACrD,CAAC;CACF;AAxCD,wBAwCC"}
1
+ {"version":3,"file":"hasher.js","names":["_cryptoJs","require","Hasher","obtainExperimentHashDouble","visitorCode","campaignId","respoolTime","respoolTimeString","length","forEach","respoolObject","String","value","calculateHash","obtainFeatureFlagHashDouble","suffix","seed","hashDigest","SHA256","toString","parseInt","Math","pow","exports"],"sources":["../../src/hasher/hasher.ts"],"sourcesContent":["import { SHA256 } from 'crypto-js';\nimport {\n ObtainExperimentHashDoubleParamsType,\n ObtainFeatureFlagHashDoubleParamsType,\n} from './types';\n\nexport class Hasher {\n static obtainExperimentHashDouble({\n visitorCode,\n campaignId,\n respoolTime,\n }: ObtainExperimentHashDoubleParamsType): number {\n let respoolTimeString = '';\n\n if (respoolTime.length) {\n respoolTime.forEach((respoolObject) => {\n respoolTimeString += String(respoolObject.value);\n });\n }\n\n return this.calculateHash(visitorCode + campaignId + respoolTimeString);\n }\n\n static obtainFeatureFlagHashDouble({\n visitorCode,\n campaignId,\n respoolTime,\n }: ObtainFeatureFlagHashDoubleParamsType): number {\n let suffix = '';\n\n if (respoolTime) {\n suffix += String(respoolTime);\n }\n\n return this.calculateHash(visitorCode + campaignId + suffix);\n }\n\n // --- Note ---\n // `hashDouble` is a seeded pseudo-random number between 0 and 1\n // used for deciding what variation to assign\n // `calculateHash` algorithm is consistent between every SDK\n // and will always provide same pseudo-random value for the same input parameters\n static calculateHash(seed: string): number {\n const hashDigest = SHA256(seed).toString();\n\n return parseInt(hashDigest, 16) / Math.pow(2, 256);\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AAMO,MAAMC,MAAM,CAAC;EAClB,OAAOC,0BAA0BA,CAAC;IAChCC,WAAW;IACXC,UAAU;IACVC;EACoC,CAAC,EAAU;IAC/C,IAAIC,iBAAiB,GAAG,EAAE;IAE1B,IAAID,WAAW,CAACE,MAAM,EAAE;MACtBF,WAAW,CAACG,OAAO,CAAEC,aAAa,IAAK;QACrCH,iBAAiB,IAAII,MAAM,CAACD,aAAa,CAACE,KAAK,CAAC;MAClD,CAAC,CAAC;IACJ;IAEA,OAAO,IAAI,CAACC,aAAa,CAACT,WAAW,GAAGC,UAAU,GAAGE,iBAAiB,CAAC;EACzE;EAEA,OAAOO,2BAA2BA,CAAC;IACjCV,WAAW;IACXC,UAAU;IACVC;EACqC,CAAC,EAAU;IAChD,IAAIS,MAAM,GAAG,EAAE;IAEf,IAAIT,WAAW,EAAE;MACfS,MAAM,IAAIJ,MAAM,CAACL,WAAW,CAAC;IAC/B;IAEA,OAAO,IAAI,CAACO,aAAa,CAACT,WAAW,GAAGC,UAAU,GAAGU,MAAM,CAAC;EAC9D;;EAEA;EACA;EACA;EACA;EACA;EACA,OAAOF,aAAaA,CAACG,IAAY,EAAU;IACzC,MAAMC,UAAU,GAAG,IAAAC,gBAAM,EAACF,IAAI,CAAC,CAACG,QAAQ,EAAE;IAE1C,OAAOC,QAAQ,CAACH,UAAU,EAAE,EAAE,CAAC,GAAGI,IAAI,CAACC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC;EACpD;AACF;AAACC,OAAA,CAAArB,MAAA,GAAAA,MAAA"}
@@ -1,6 +1,13 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Hasher = void 0;
4
- var hasher_1 = require("./hasher");
5
- Object.defineProperty(exports, "Hasher", { enumerable: true, get: function () { return hasher_1.Hasher; } });
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "Hasher", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _hasher.Hasher;
10
+ }
11
+ });
12
+ var _hasher = require("./hasher");
6
13
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hasher/index.ts"],"names":[],"mappings":";;;AAAA,mCAAkC;AAAzB,gGAAA,MAAM,OAAA"}
1
+ {"version":3,"file":"index.js","names":["_hasher","require"],"sources":["../../src/hasher/index.ts"],"sourcesContent":["export { Hasher } from './hasher';\n"],"mappings":";;;;;;;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA"}
@@ -7,6 +7,6 @@ export type ObtainExperimentHashDoubleParamsType = ObtainHashDoubleParamsType &
7
7
  respoolTime: RespoolTimeType[];
8
8
  };
9
9
  export type ObtainFeatureFlagHashDoubleParamsType = ObtainHashDoubleParamsType & {
10
- reShuffle?: boolean;
10
+ respoolTime: number | null;
11
11
  };
12
12
  export {};
@@ -1,3 +1,6 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
3
6
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/hasher/types.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../src/hasher/types.ts"],"sourcesContent":["import { RespoolTimeType } from '../campaignConfiguration/types';\n\ntype ObtainHashDoubleParamsType = {\n visitorCode: string;\n campaignId: string;\n};\n\nexport type ObtainExperimentHashDoubleParamsType =\n ObtainHashDoubleParamsType & {\n respoolTime: RespoolTimeType[];\n };\n\nexport type ObtainFeatureFlagHashDoubleParamsType =\n ObtainHashDoubleParamsType & {\n respoolTime: number | null;\n };\n"],"mappings":""}
package/dist/index.d.ts CHANGED
@@ -2,9 +2,11 @@ export { KameleoonClient as KameleoonCore, IKameleoonClient as IKameleoonCore, }
2
2
  export { KameleoonUtils as KameleoonCoreUtils } from './kameleoonUtils';
3
3
  export { KameleoonException, KameleoonError } from './kameleoonError';
4
4
  export { KameleoonStorageKey, IExternalStorage, IExternalStorageConstructor, } from './storage';
5
- export { Cookie, VISITOR_CODE_LENGTH } from './constants';
5
+ export { Cookie, VISITOR_CODE_LENGTH, SDKType } from './constants';
6
+ export { CLEANUP_TARGETING_DATA_INTERVAL } from './campaignConfiguration';
6
7
  export { JSONType } from './campaignConfiguration';
7
8
  export { Ok, Result, Err } from 'ts-res';
8
- export { Environment, VariableType, ExperimentType, FeatureFlagType, SDKCoreParameters, SDKConfigurationType, TrackConversionParamsType, FeatureVariableResultType, InternalSDKConfigurationType, GetFeatureFlagVariableParamsType, ServerGetVisitorCodeParametersType, ClientGetVisitorCodeParametersType, MobileGetVisitorCodeParametersType, } from './types';
9
+ export { Environment, VariableType, ExperimentType, FeatureFlagType, SDKCoreParameters, SDKConfigurationType, ExternalPackageInfoType, TrackConversionParamsType, FeatureVariableResultType, InternalSDKConfigurationType, GetFeatureFlagVariableParamsType, ServerGetVisitorCodeParametersType, ClientGetVisitorCodeParametersType, MobileGetVisitorCodeParametersType, } from './types';
9
10
  export { CustomData, Conversion, Device, Browser, DeviceType, BrowserType, PageView, KameleoonDataType, PageViewParametersType, ConversionParametersType, } from './kameleoonData';
10
11
  export { RealTimeEventType, IExternalEventSource, EventSourceOpenParametersType, IExternalEventSourceConstructor, } from './eventSource';
12
+ export { Header, HttpMethod, TrackParametersType, IExternalRequestDispatcher, GetClientConfigurationResultType, } from './requester';