@kameleoon/javascript-sdk-core 0.0.3 → 1.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.
- package/LICENSE.md +6 -0
- package/README.md +7 -3
- package/dist/campaignConfiguration/campaignConfiguration.d.ts +46 -0
- package/dist/campaignConfiguration/campaignConfiguration.js +217 -0
- package/dist/campaignConfiguration/campaignConfiguration.js.map +1 -0
- package/dist/campaignConfiguration/constants.d.ts +18 -0
- package/dist/campaignConfiguration/constants.js +23 -0
- package/dist/campaignConfiguration/constants.js.map +1 -0
- package/dist/campaignConfiguration/index.d.ts +2 -0
- package/dist/campaignConfiguration/index.js +8 -0
- package/dist/campaignConfiguration/index.js.map +1 -0
- package/dist/campaignConfiguration/types.d.ts +126 -0
- package/dist/campaignConfiguration/types.js +47 -0
- package/dist/campaignConfiguration/types.js.map +1 -0
- package/dist/clientSettings/clientSettings.d.ts +12 -0
- package/dist/clientSettings/clientSettings.js +29 -0
- package/dist/clientSettings/clientSettings.js.map +1 -0
- package/dist/clientSettings/index.d.ts +2 -0
- package/dist/clientSettings/index.js +6 -0
- package/dist/clientSettings/index.js.map +1 -0
- package/dist/clientSettings/types.d.ts +6 -0
- package/dist/{interfaces/interfaces.js → clientSettings/types.js} +1 -1
- package/dist/clientSettings/types.js.map +1 -0
- package/dist/constants.d.ts +10 -16
- package/dist/constants.js +13 -20
- package/dist/constants.js.map +1 -1
- package/dist/eventSource/constants.d.ts +1 -0
- package/dist/eventSource/constants.js +5 -0
- package/dist/eventSource/constants.js.map +1 -0
- package/dist/eventSource/externalEventSource.d.ts +12 -0
- package/dist/eventSource/externalEventSource.js +26 -0
- package/dist/eventSource/externalEventSource.js.map +1 -0
- package/dist/eventSource/index.d.ts +3 -0
- package/dist/eventSource/index.js +8 -0
- package/dist/eventSource/index.js.map +1 -0
- package/dist/eventSource/types.d.ts +47 -0
- package/dist/eventSource/types.js +3 -0
- package/dist/eventSource/types.js.map +1 -0
- package/dist/hasher/constants.d.ts +1 -0
- package/dist/hasher/constants.js +5 -0
- package/dist/hasher/constants.js.map +1 -0
- package/dist/hasher/hasher.d.ts +6 -0
- package/dist/hasher/hasher.js +34 -0
- package/dist/hasher/hasher.js.map +1 -0
- package/dist/hasher/index.d.ts +1 -0
- package/dist/hasher/index.js +6 -0
- package/dist/hasher/index.js.map +1 -0
- package/dist/hasher/types.d.ts +12 -0
- package/dist/hasher/types.js +3 -0
- package/dist/hasher/types.js.map +1 -0
- package/dist/index.d.ts +10 -3
- package/dist/index.js +25 -7
- package/dist/index.js.map +1 -1
- package/dist/kameleoonClient.d.ts +189 -100
- package/dist/kameleoonClient.js +238 -701
- package/dist/kameleoonClient.js.map +1 -1
- package/dist/kameleoonData/browser.d.ts +21 -0
- package/dist/kameleoonData/browser.js +41 -0
- package/dist/kameleoonData/browser.js.map +1 -0
- package/dist/kameleoonData/constants.d.ts +1 -0
- package/dist/kameleoonData/constants.js +5 -0
- package/dist/kameleoonData/constants.js.map +1 -0
- package/dist/kameleoonData/conversion.d.ts +23 -0
- package/dist/kameleoonData/conversion.js +49 -0
- package/dist/kameleoonData/conversion.js.map +1 -0
- package/dist/kameleoonData/customData.d.ts +33 -0
- package/dist/kameleoonData/customData.js +68 -0
- package/dist/kameleoonData/customData.js.map +1 -0
- package/dist/kameleoonData/device.d.ts +21 -0
- package/dist/kameleoonData/device.js +41 -0
- package/dist/kameleoonData/device.js.map +1 -0
- package/dist/kameleoonData/index.d.ts +7 -0
- package/dist/kameleoonData/index.js +20 -0
- package/dist/kameleoonData/index.js.map +1 -0
- package/dist/kameleoonData/nonce.d.ts +5 -0
- package/dist/kameleoonData/nonce.js +20 -0
- package/dist/kameleoonData/nonce.js.map +1 -0
- package/dist/kameleoonData/pageView.d.ts +24 -0
- package/dist/kameleoonData/pageView.js +54 -0
- package/dist/kameleoonData/pageView.js.map +1 -0
- package/dist/kameleoonData/types.d.ts +100 -0
- package/dist/kameleoonData/types.js +36 -0
- package/dist/kameleoonData/types.js.map +1 -0
- package/dist/kameleoonData/userAgent.d.ts +18 -0
- package/dist/kameleoonData/userAgent.js +33 -0
- package/dist/kameleoonData/userAgent.js.map +1 -0
- package/dist/kameleoonError/constants.d.ts +22 -0
- package/dist/kameleoonError/constants.js +25 -0
- package/dist/kameleoonError/constants.js.map +1 -0
- package/dist/kameleoonError/helpers.d.ts +1 -0
- package/dist/kameleoonError/helpers.js +8 -0
- package/dist/kameleoonError/helpers.js.map +1 -0
- package/dist/kameleoonError/index.d.ts +3 -0
- package/dist/kameleoonError/index.js +10 -0
- package/dist/kameleoonError/index.js.map +1 -0
- package/dist/kameleoonError/kameleoonError.d.ts +24 -0
- package/dist/kameleoonError/kameleoonError.js +64 -0
- package/dist/kameleoonError/kameleoonError.js.map +1 -0
- package/dist/kameleoonError/types.d.ts +20 -0
- package/dist/kameleoonError/types.js +25 -0
- package/dist/kameleoonError/types.js.map +1 -0
- package/dist/kameleoonUtils.d.ts +11 -10
- package/dist/kameleoonUtils.js +42 -128
- package/dist/kameleoonUtils.js.map +1 -1
- package/dist/requester/constants.d.ts +15 -0
- package/dist/requester/constants.js +53 -0
- package/dist/requester/constants.js.map +1 -0
- package/dist/requester/index.d.ts +3 -0
- package/dist/requester/index.js +10 -0
- package/dist/requester/index.js.map +1 -0
- package/dist/requester/requester.d.ts +23 -0
- package/dist/requester/requester.js +121 -0
- package/dist/requester/requester.js.map +1 -0
- package/dist/requester/types.d.ts +43 -0
- package/dist/requester/types.js +39 -0
- package/dist/requester/types.js.map +1 -0
- package/dist/storage/constants.d.ts +9 -0
- package/dist/storage/constants.js +14 -0
- package/dist/storage/constants.js.map +1 -0
- package/dist/storage/externalStorage.d.ts +11 -0
- package/dist/storage/externalStorage.js +34 -0
- package/dist/storage/externalStorage.js.map +1 -0
- package/dist/storage/index.d.ts +3 -0
- package/dist/storage/index.js +8 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/types.d.ts +52 -11
- package/dist/targeting/conditions/conditionFactory.d.ts +6 -0
- package/dist/targeting/conditions/conditionFactory.js +26 -0
- package/dist/targeting/conditions/conditionFactory.js.map +1 -0
- package/dist/targeting/conditions/customDataCondition.d.ts +16 -0
- package/dist/targeting/conditions/customDataCondition.js +99 -0
- package/dist/targeting/conditions/customDataCondition.js.map +1 -0
- package/dist/targeting/conditions/exclusiveExperimentCondition.d.ts +9 -0
- package/dist/targeting/conditions/exclusiveExperimentCondition.js +21 -0
- package/dist/targeting/conditions/exclusiveExperimentCondition.js.map +1 -0
- package/dist/targeting/conditions/index.d.ts +5 -0
- package/dist/targeting/conditions/index.js +12 -0
- package/dist/targeting/conditions/index.js.map +1 -0
- package/dist/targeting/conditions/targetExperimentCondition.d.ts +13 -0
- package/dist/targeting/conditions/targetExperimentCondition.js +42 -0
- package/dist/targeting/conditions/targetExperimentCondition.js.map +1 -0
- package/dist/targeting/conditions/types.d.ts +22 -11
- package/dist/targeting/index.d.ts +3 -0
- package/dist/targeting/index.js +15 -0
- package/dist/targeting/index.js.map +1 -0
- package/dist/targeting/targetingNode.d.ts +21 -0
- package/dist/targeting/targetingNode.js +40 -0
- package/dist/targeting/targetingNode.js.map +1 -0
- package/dist/targeting/targetingTree.d.ts +16 -8
- package/dist/targeting/targetingTree.js +112 -10
- package/dist/targeting/targetingTree.js.map +1 -1
- package/dist/targeting/types.d.ts +127 -0
- package/dist/targeting/types.js +93 -0
- package/dist/targeting/types.js.map +1 -0
- package/dist/types.d.ts +135 -5
- package/dist/types.js +28 -0
- package/dist/types.js.map +1 -1
- package/dist/utilities/constants.d.ts +1 -0
- package/dist/utilities/constants.js +5 -0
- package/dist/utilities/constants.js.map +1 -0
- package/dist/utilities/index.d.ts +1 -0
- package/dist/utilities/index.js +6 -0
- package/dist/utilities/index.js.map +1 -0
- package/dist/utilities/types.d.ts +18 -0
- package/dist/utilities/types.js +3 -0
- package/dist/utilities/types.js.map +1 -0
- package/dist/utilities/utilities.d.ts +13 -0
- package/dist/utilities/utilities.js +119 -0
- package/dist/utilities/utilities.js.map +1 -0
- package/dist/variationConfiguration/index.d.ts +2 -0
- package/dist/variationConfiguration/index.js +6 -0
- package/dist/variationConfiguration/index.js.map +1 -0
- package/dist/variationConfiguration/types.d.ts +25 -0
- package/dist/variationConfiguration/types.js +3 -0
- package/dist/variationConfiguration/types.js.map +1 -0
- package/dist/variationConfiguration/variation.d.ts +13 -0
- package/dist/variationConfiguration/variation.js +38 -0
- package/dist/variationConfiguration/variation.js.map +1 -0
- package/dist/variationConfiguration/variationConfiguration.d.ts +36 -0
- package/dist/variationConfiguration/variationConfiguration.js +248 -0
- package/dist/variationConfiguration/variationConfiguration.js.map +1 -0
- package/package.json +19 -9
- package/dist/configurations/configuration.d.ts +0 -15
- package/dist/configurations/configuration.js +0 -31
- package/dist/configurations/configuration.js.map +0 -1
- package/dist/configurations/experiment.d.ts +0 -13
- package/dist/configurations/experiment.js +0 -54
- package/dist/configurations/experiment.js.map +0 -1
- package/dist/configurations/featureFlag.d.ts +0 -23
- package/dist/configurations/featureFlag.js +0 -105
- package/dist/configurations/featureFlag.js.map +0 -1
- package/dist/configurations/variation.d.ts +0 -15
- package/dist/configurations/variation.js +0 -14
- package/dist/configurations/variation.js.map +0 -1
- package/dist/data.d.ts +0 -67
- package/dist/data.js +0 -127
- package/dist/data.js.map +0 -1
- package/dist/exceptions/credentialsNotFound.d.ts +0 -6
- package/dist/exceptions/credentialsNotFound.js +0 -29
- package/dist/exceptions/credentialsNotFound.js.map +0 -1
- package/dist/exceptions/experimentConfigurationNotFound.d.ts +0 -6
- package/dist/exceptions/experimentConfigurationNotFound.js +0 -29
- package/dist/exceptions/experimentConfigurationNotFound.js.map +0 -1
- package/dist/exceptions/featureConfigurationNotFound.d.ts +0 -6
- package/dist/exceptions/featureConfigurationNotFound.js +0 -29
- package/dist/exceptions/featureConfigurationNotFound.js.map +0 -1
- package/dist/exceptions/notActivated.d.ts +0 -6
- package/dist/exceptions/notActivated.js +0 -29
- package/dist/exceptions/notActivated.js.map +0 -1
- package/dist/exceptions/notTargeted.d.ts +0 -6
- package/dist/exceptions/notTargeted.js +0 -29
- package/dist/exceptions/notTargeted.js.map +0 -1
- package/dist/exceptions/siteCodeDisabled.d.ts +0 -5
- package/dist/exceptions/siteCodeDisabled.js +0 -30
- package/dist/exceptions/siteCodeDisabled.js.map +0 -1
- package/dist/exceptions/variationConfigurationNotFound.d.ts +0 -6
- package/dist/exceptions/variationConfigurationNotFound.js +0 -29
- package/dist/exceptions/variationConfigurationNotFound.js.map +0 -1
- package/dist/exceptions/visitorCodeNotValid.d.ts +0 -5
- package/dist/exceptions/visitorCodeNotValid.js +0 -30
- package/dist/exceptions/visitorCodeNotValid.js.map +0 -1
- package/dist/interfaces/interfaces.d.ts +0 -81
- package/dist/interfaces/interfaces.js.map +0 -1
- package/dist/nonce.d.ts +0 -1
- package/dist/nonce.js +0 -16
- package/dist/nonce.js.map +0 -1
- package/dist/realTimeConfigurationService.d.ts +0 -12
- package/dist/realTimeConfigurationService.js +0 -24
- package/dist/realTimeConfigurationService.js.map +0 -1
- package/dist/storage/variationStorage.d.ts +0 -11
- package/dist/storage/variationStorage.js +0 -159
- package/dist/storage/variationStorage.js.map +0 -1
- package/dist/storage/visitorVariation.d.ts +0 -9
- package/dist/storage/visitorVariation.js +0 -22
- package/dist/storage/visitorVariation.js.map +0 -1
- package/dist/targeting/conditions/customDatum.d.ts +0 -12
- package/dist/targeting/conditions/customDatum.js +0 -129
- package/dist/targeting/conditions/customDatum.js.map +0 -1
- package/dist/targeting/conditions/exclusiveExperiment.d.ts +0 -9
- package/dist/targeting/conditions/exclusiveExperiment.js +0 -45
- package/dist/targeting/conditions/exclusiveExperiment.js.map +0 -1
- package/dist/targeting/conditions/targetExperiment.d.ts +0 -14
- package/dist/targeting/conditions/targetExperiment.js +0 -57
- package/dist/targeting/conditions/targetExperiment.js.map +0 -1
- package/dist/targeting/targetingCondition.d.ts +0 -7
- package/dist/targeting/targetingCondition.js +0 -9
- package/dist/targeting/targetingCondition.js.map +0 -1
- package/dist/targeting/targetingConditionsFactory.d.ts +0 -7
- package/dist/targeting/targetingConditionsFactory.js +0 -30
- package/dist/targeting/targetingConditionsFactory.js.map +0 -1
- package/dist/targeting/targetingData.d.ts +0 -7
- package/dist/targeting/targetingData.js +0 -11
- package/dist/targeting/targetingData.js.map +0 -1
- package/dist/targeting/targetingEngine.d.ts +0 -6
- package/dist/targeting/targetingEngine.js +0 -130
- package/dist/targeting/targetingEngine.js.map +0 -1
- package/dist/targeting/targetingSegment.d.ts +0 -5
- package/dist/targeting/targetingSegment.js +0 -9
- package/dist/targeting/targetingSegment.js.map +0 -1
- package/dist/targeting/targetingTreeBuilder.d.ts +0 -8
- package/dist/targeting/targetingTreeBuilder.js +0 -127
- package/dist/targeting/targetingTreeBuilder.js.map +0 -1
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BrowserType = exports.DeviceType = exports.KameleoonData = void 0;
|
|
4
|
+
var KameleoonData;
|
|
5
|
+
(function (KameleoonData) {
|
|
6
|
+
KameleoonData["CustomData"] = "customData";
|
|
7
|
+
KameleoonData["PageView"] = "pageView";
|
|
8
|
+
KameleoonData["Browser"] = "browser";
|
|
9
|
+
KameleoonData["Conversion"] = "conversion";
|
|
10
|
+
KameleoonData["Device"] = "device";
|
|
11
|
+
KameleoonData["UserAgent"] = "userAgent";
|
|
12
|
+
})(KameleoonData = exports.KameleoonData || (exports.KameleoonData = {}));
|
|
13
|
+
/**
|
|
14
|
+
* @readonly
|
|
15
|
+
* @enum {string} an Enum containing all possible variants for device type
|
|
16
|
+
* */
|
|
17
|
+
var DeviceType;
|
|
18
|
+
(function (DeviceType) {
|
|
19
|
+
DeviceType["Phone"] = "PHONE";
|
|
20
|
+
DeviceType["Tablet"] = "TABLET";
|
|
21
|
+
DeviceType["Desktop"] = "DESKTOP";
|
|
22
|
+
})(DeviceType = exports.DeviceType || (exports.DeviceType = {}));
|
|
23
|
+
/**
|
|
24
|
+
* @readonly
|
|
25
|
+
* @enum {number} an Enum containing all possible variants for browser type
|
|
26
|
+
* */
|
|
27
|
+
var BrowserType;
|
|
28
|
+
(function (BrowserType) {
|
|
29
|
+
BrowserType[BrowserType["Chrome"] = 0] = "Chrome";
|
|
30
|
+
BrowserType[BrowserType["InternetExplorer"] = 1] = "InternetExplorer";
|
|
31
|
+
BrowserType[BrowserType["Firefox"] = 2] = "Firefox";
|
|
32
|
+
BrowserType[BrowserType["Safari"] = 3] = "Safari";
|
|
33
|
+
BrowserType[BrowserType["Opera"] = 4] = "Opera";
|
|
34
|
+
BrowserType[BrowserType["Other"] = 5] = "Other";
|
|
35
|
+
})(BrowserType = exports.BrowserType || (exports.BrowserType = {}));
|
|
36
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/kameleoonData/types.ts"],"names":[],"mappings":";;;AAuCA,IAAY,aAOX;AAPD,WAAY,aAAa;IACvB,0CAAyB,CAAA;IACzB,sCAAqB,CAAA;IACrB,oCAAmB,CAAA;IACnB,0CAAyB,CAAA;IACzB,kCAAiB,CAAA;IACjB,wCAAuB,CAAA;AACzB,CAAC,EAPW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAOxB;AAiED;;;KAGK;AACL,IAAY,UAIX;AAJD,WAAY,UAAU;IACpB,6BAAe,CAAA;IACf,+BAAiB,CAAA;IACjB,iCAAmB,CAAA;AACrB,CAAC,EAJW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAIrB;AAED;;;KAGK;AACL,IAAY,WAOX;AAPD,WAAY,WAAW;IACrB,iDAAM,CAAA;IACN,qEAAgB,CAAA;IAChB,mDAAO,CAAA;IACP,iDAAM,CAAA;IACN,+CAAK,CAAA;IACL,+CAAK,CAAA;AACP,CAAC,EAPW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAOtB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Nonce } from './nonce';
|
|
2
|
+
import { UserAgentDataType, IKameleoonData } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* @class
|
|
5
|
+
* UserAgent - a class for creating an instance for user agent
|
|
6
|
+
* */
|
|
7
|
+
export declare class UserAgent extends Nonce implements IKameleoonData {
|
|
8
|
+
private value;
|
|
9
|
+
constructor(value: string);
|
|
10
|
+
/**
|
|
11
|
+
* @property url - url for the current data type used for events tracking
|
|
12
|
+
* */
|
|
13
|
+
get url(): string;
|
|
14
|
+
/**
|
|
15
|
+
* @property data - data of the current class instance
|
|
16
|
+
* */
|
|
17
|
+
get data(): UserAgentDataType;
|
|
18
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UserAgent = void 0;
|
|
4
|
+
const nonce_1 = require("./nonce");
|
|
5
|
+
const types_1 = require("./types");
|
|
6
|
+
/**
|
|
7
|
+
* @class
|
|
8
|
+
* UserAgent - a class for creating an instance for user agent
|
|
9
|
+
* */
|
|
10
|
+
class UserAgent extends nonce_1.Nonce {
|
|
11
|
+
constructor(value) {
|
|
12
|
+
super();
|
|
13
|
+
this.value = value;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* @property url - url for the current data type used for events tracking
|
|
17
|
+
* */
|
|
18
|
+
get url() {
|
|
19
|
+
return '';
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* @property data - data of the current class instance
|
|
23
|
+
* */
|
|
24
|
+
get data() {
|
|
25
|
+
return {
|
|
26
|
+
value: this.value,
|
|
27
|
+
type: types_1.KameleoonData.UserAgent,
|
|
28
|
+
nonce: this.nonce,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.UserAgent = UserAgent;
|
|
33
|
+
//# sourceMappingURL=userAgent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"userAgent.js","sourceRoot":"","sources":["../../src/kameleoonData/userAgent.ts"],"names":[],"mappings":";;;AAAA,mCAAgC;AAChC,mCAA2E;AAE3E;;;KAGK;AACL,MAAa,SAAU,SAAQ,aAAK;IAGlC,YAAY,KAAa;QACvB,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED;;SAEK;IACL,IAAI,GAAG;QACL,OAAO,EAAE,CAAC;IACZ,CAAC;IAED;;SAEK;IACL,IAAI,IAAI;QACN,OAAO;YACL,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,IAAI,EAAE,qBAAa,CAAC,SAAS;YAC7B,KAAK,EAAE,IAAI,CAAC,KAAK;SAClB,CAAC;IACJ,CAAC;CACF;AA1BD,8BA0BC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { KameleoonStorageKey } from '../storage';
|
|
2
|
+
import { TargetingType } from '../targeting';
|
|
3
|
+
export declare const ERROR_MESSAGES: {
|
|
4
|
+
JSONParse: (err: unknown) => string;
|
|
5
|
+
NumberParse: (value: string) => string;
|
|
6
|
+
Initialization: () => string;
|
|
7
|
+
StorageInitialization: () => string;
|
|
8
|
+
EventSourceInitialization: () => string;
|
|
9
|
+
DataInconsistency: () => string;
|
|
10
|
+
FeatureFlagConfigurationNotFound: (featureKey: string, visitorCode: string) => string;
|
|
11
|
+
ExperimentConfigurationNotFound: (experimentId: number, visitorCode: string) => string;
|
|
12
|
+
NotTargeted: (visitorCode: string) => string;
|
|
13
|
+
NotAllocated: (visitorCode: string) => string;
|
|
14
|
+
VisitorCodeMaxLength: () => string;
|
|
15
|
+
StorageWrite: (err: unknown) => string;
|
|
16
|
+
StorageRead: (key: KameleoonStorageKey) => string;
|
|
17
|
+
StorageParse: (err: unknown, key: KameleoonStorageKey) => string;
|
|
18
|
+
ClientConfiguration: () => string;
|
|
19
|
+
TargetingCondition: (targetingType: TargetingType) => string;
|
|
20
|
+
AmongValuesCheck: (err: unknown, value: string) => string;
|
|
21
|
+
RemoteData: () => string;
|
|
22
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ERROR_MESSAGES = void 0;
|
|
4
|
+
const types_1 = require("./types");
|
|
5
|
+
exports.ERROR_MESSAGES = {
|
|
6
|
+
[types_1.KameleoonException.JSONParse]: (err) => `Couldn't parse JSON variable: ${err}`,
|
|
7
|
+
[types_1.KameleoonException.NumberParse]: (value) => `It's not possible to parse value ${value} to Number`,
|
|
8
|
+
[types_1.KameleoonException.Initialization]: () => "It seems that the client wasn't properly initialized, make sure to run `initialize` method before invoking other methods",
|
|
9
|
+
[types_1.KameleoonException.StorageInitialization]: () => "There was an error while initializing React Native SDK storage, it seems that the storage library dependency wasn't installed",
|
|
10
|
+
[types_1.KameleoonException.EventSourceInitialization]: () => "There was an error while initializing Real Time Update service, it seems that the event source library dependency wasn't installed",
|
|
11
|
+
[types_1.KameleoonException.DataInconsistency]: () => "Variation was found in the storage, but the server data doesn't contain corresponding variation, try to reload the client",
|
|
12
|
+
[types_1.KameleoonException.FeatureFlagConfigurationNotFound]: (featureKey, visitorCode) => `No feature flag with key ${featureKey} was found for ${visitorCode} visitorCode.`,
|
|
13
|
+
[types_1.KameleoonException.ExperimentConfigurationNotFound]: (experimentId, visitorCode) => `No experiment with id ${experimentId} was found for ${visitorCode} visitorCode.`,
|
|
14
|
+
[types_1.KameleoonException.NotTargeted]: (visitorCode) => `Visitor code ${visitorCode} is not targeted`,
|
|
15
|
+
[types_1.KameleoonException.NotAllocated]: (visitorCode) => `Visitor with visitor code ${visitorCode} is in unallocated traffic, there is no variation id to be assigned to the visitor.`,
|
|
16
|
+
[types_1.KameleoonException.VisitorCodeMaxLength]: () => 'Visitor code can not be more than 255 characters long',
|
|
17
|
+
[types_1.KameleoonException.StorageWrite]: (err) => `Couldn't update storage for kameleoonClient: ${err}`,
|
|
18
|
+
[types_1.KameleoonException.StorageRead]: (key) => `No data found in storage under ${key} key`,
|
|
19
|
+
[types_1.KameleoonException.StorageParse]: (err, key) => `Couldn't parse ${key} storage data, the data may be corrupted. Error: ${err}`,
|
|
20
|
+
[types_1.KameleoonException.ClientConfiguration]: () => "Couldn't retrieve client configuration from Kameleoon Api",
|
|
21
|
+
[types_1.KameleoonException.TargetingCondition]: (targetingType) => `${targetingType} targeting condition is not yet supported.`,
|
|
22
|
+
[types_1.KameleoonException.AmongValuesCheck]: (err, value) => `Couldn't parse value "${value}": ${err}`,
|
|
23
|
+
[types_1.KameleoonException.RemoteData]: () => `Couldn't retrieve data from Kameleoon server`,
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/kameleoonError/constants.ts"],"names":[],"mappings":";;;AAEA,mCAA6C;AAEhC,QAAA,cAAc,GAAG;IAC5B,CAAC,0BAAkB,CAAC,SAAS,CAAC,EAAE,CAAC,GAAY,EAAE,EAAE,CAC/C,iCAAiC,GAAG,EAAE;IACxC,CAAC,0BAAkB,CAAC,WAAW,CAAC,EAAE,CAAC,KAAa,EAAE,EAAE,CAClD,oCAAoC,KAAK,YAAY;IACvD,CAAC,0BAAkB,CAAC,cAAc,CAAC,EAAE,GAAG,EAAE,CACxC,0HAA0H;IAC5H,CAAC,0BAAkB,CAAC,qBAAqB,CAAC,EAAE,GAAG,EAAE,CAC/C,+HAA+H;IACjI,CAAC,0BAAkB,CAAC,yBAAyB,CAAC,EAAE,GAAG,EAAE,CACnD,oIAAoI;IACtI,CAAC,0BAAkB,CAAC,iBAAiB,CAAC,EAAE,GAAG,EAAE,CAC3C,2HAA2H;IAC7H,CAAC,0BAAkB,CAAC,gCAAgC,CAAC,EAAE,CACrD,UAAkB,EAClB,WAAmB,EACnB,EAAE,CACF,4BAA4B,UAAU,kBAAkB,WAAW,eAAe;IAC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esModule", { value: true });
|
|
3
|
+
exports.exhaustCheck = void 0;
|
|
4
|
+
function exhaustCheck(option) {
|
|
5
|
+
throw new Error(`Reaching an impossible state because of ${option}`);
|
|
6
|
+
}
|
|
7
|
+
exports.exhaustCheck = exhaustCheck;
|
|
8
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/kameleoonError/helpers.ts"],"names":[],"mappings":";;;AAAA,SAAgB,YAAY,CAAC,MAAa;IACxC,MAAM,IAAI,KAAK,CAAC,2CAA2C,MAAM,EAAE,CAAC,CAAC;AACvE,CAAC;AAFD,oCAEC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.exhaustCheck = exports.KameleoonException = exports.KameleoonError = void 0;
|
|
4
|
+
var kameleoonError_1 = require("./kameleoonError");
|
|
5
|
+
Object.defineProperty(exports, "KameleoonError", { enumerable: true, get: function () { return kameleoonError_1.KameleoonError; } });
|
|
6
|
+
var types_1 = require("./types");
|
|
7
|
+
Object.defineProperty(exports, "KameleoonException", { enumerable: true, get: function () { return types_1.KameleoonException; } });
|
|
8
|
+
var helpers_1 = require("./helpers");
|
|
9
|
+
Object.defineProperty(exports, "exhaustCheck", { enumerable: true, get: function () { return helpers_1.exhaustCheck; } });
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/kameleoonError/index.ts"],"names":[],"mappings":";;;AAAA,mDAAkD;AAAzC,gHAAA,cAAc,OAAA;AACvB,iCAA6C;AAApC,2GAAA,kBAAkB,OAAA;AAC3B,qCAAyC;AAAhC,uGAAA,YAAY,OAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { KameleoonStorageKey } from '../storage';
|
|
2
|
+
import { TargetingType } from '../targeting';
|
|
3
|
+
import { KameleoonException } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* @class
|
|
6
|
+
* KameleoonError - extends standard `Error` by adding custom `type` property with the type of `KameleoonException`
|
|
7
|
+
* */
|
|
8
|
+
export declare class KameleoonError extends Error {
|
|
9
|
+
private errorType;
|
|
10
|
+
/**
|
|
11
|
+
* @param {KameleoonException} type - type of KameleoonError represented by `KameleoonException` enum
|
|
12
|
+
* */
|
|
13
|
+
constructor(type: KameleoonException.Initialization | KameleoonException.ClientConfiguration | KameleoonException.VisitorCodeMaxLength | KameleoonException.DataInconsistency | KameleoonException.StorageInitialization | KameleoonException.EventSourceInitialization | KameleoonException.RemoteData);
|
|
14
|
+
constructor(type: KameleoonException.FeatureFlagConfigurationNotFound, featureKey: string, visitorCode: string);
|
|
15
|
+
constructor(type: KameleoonException.NotTargeted | KameleoonException.NotAllocated, visitorCode: string);
|
|
16
|
+
constructor(type: KameleoonException.ExperimentConfigurationNotFound, experimentId: number, visitorCode: string);
|
|
17
|
+
constructor(type: KameleoonException.StorageWrite | KameleoonException.JSONParse, err: unknown);
|
|
18
|
+
constructor(type: KameleoonException.StorageRead, storageKey: string);
|
|
19
|
+
constructor(type: KameleoonException.StorageParse, err: unknown, key: KameleoonStorageKey);
|
|
20
|
+
constructor(type: KameleoonException.TargetingCondition, targetingType: TargetingType);
|
|
21
|
+
constructor(type: KameleoonException.AmongValuesCheck, err: unknown, value: string);
|
|
22
|
+
constructor(type: KameleoonException.NumberParse, value: string);
|
|
23
|
+
get type(): KameleoonException;
|
|
24
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.KameleoonError = void 0;
|
|
4
|
+
const constants_1 = require("./constants");
|
|
5
|
+
const helpers_1 = require("./helpers");
|
|
6
|
+
const types_1 = require("./types");
|
|
7
|
+
/**
|
|
8
|
+
* @class
|
|
9
|
+
* KameleoonError - extends standard `Error` by adding custom `type` property with the type of `KameleoonException`
|
|
10
|
+
* */
|
|
11
|
+
class KameleoonError extends Error {
|
|
12
|
+
constructor(type, secondParam, thirdParam) {
|
|
13
|
+
super(`Error: ${type}`);
|
|
14
|
+
this.name = 'KameleoonError';
|
|
15
|
+
this.errorType = type;
|
|
16
|
+
switch (type) {
|
|
17
|
+
case types_1.KameleoonException.Initialization:
|
|
18
|
+
case types_1.KameleoonException.ClientConfiguration:
|
|
19
|
+
case types_1.KameleoonException.VisitorCodeMaxLength:
|
|
20
|
+
case types_1.KameleoonException.DataInconsistency:
|
|
21
|
+
case types_1.KameleoonException.StorageInitialization:
|
|
22
|
+
case types_1.KameleoonException.EventSourceInitialization:
|
|
23
|
+
case types_1.KameleoonException.RemoteData:
|
|
24
|
+
this.message = constants_1.ERROR_MESSAGES[type]();
|
|
25
|
+
break;
|
|
26
|
+
case types_1.KameleoonException.NotAllocated:
|
|
27
|
+
case types_1.KameleoonException.NotTargeted:
|
|
28
|
+
this.message = constants_1.ERROR_MESSAGES[type](secondParam);
|
|
29
|
+
break;
|
|
30
|
+
case types_1.KameleoonException.ExperimentConfigurationNotFound:
|
|
31
|
+
this.message = constants_1.ERROR_MESSAGES[type](secondParam, thirdParam);
|
|
32
|
+
break;
|
|
33
|
+
case types_1.KameleoonException.FeatureFlagConfigurationNotFound:
|
|
34
|
+
this.message = constants_1.ERROR_MESSAGES[type](secondParam, thirdParam);
|
|
35
|
+
break;
|
|
36
|
+
case types_1.KameleoonException.StorageWrite:
|
|
37
|
+
case types_1.KameleoonException.JSONParse:
|
|
38
|
+
this.message = constants_1.ERROR_MESSAGES[type](secondParam);
|
|
39
|
+
break;
|
|
40
|
+
case types_1.KameleoonException.StorageRead:
|
|
41
|
+
this.message = constants_1.ERROR_MESSAGES[type](secondParam);
|
|
42
|
+
break;
|
|
43
|
+
case types_1.KameleoonException.StorageParse:
|
|
44
|
+
this.message = constants_1.ERROR_MESSAGES[type](secondParam, thirdParam);
|
|
45
|
+
break;
|
|
46
|
+
case types_1.KameleoonException.TargetingCondition:
|
|
47
|
+
this.message = constants_1.ERROR_MESSAGES[type](secondParam);
|
|
48
|
+
break;
|
|
49
|
+
case types_1.KameleoonException.NumberParse:
|
|
50
|
+
this.message = constants_1.ERROR_MESSAGES[type](secondParam);
|
|
51
|
+
break;
|
|
52
|
+
case types_1.KameleoonException.AmongValuesCheck:
|
|
53
|
+
this.message = constants_1.ERROR_MESSAGES[type](secondParam, thirdParam);
|
|
54
|
+
break;
|
|
55
|
+
default:
|
|
56
|
+
(0, helpers_1.exhaustCheck)(type);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
get type() {
|
|
60
|
+
return this.errorType;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.KameleoonError = KameleoonError;
|
|
64
|
+
//# sourceMappingURL=kameleoonError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kameleoonError.js","sourceRoot":"","sources":["../../src/kameleoonError/kameleoonError.ts"],"names":[],"mappings":";;;AAEA,2CAA6C;AAC7C,uCAAyC;AACzC,mCAA6C;AAE7C;;;KAGK;AACL,MAAa,cAAe,SAAQ,KAAK;IAkDvC,YACE,IAAwB,EACxB,WAKiB,EACjB,UAAyC;QAEzC,KAAK,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC;QAExB,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;QAC7B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QAEtB,QAAQ,IAAI,EAAE;YACZ,KAAK,0BAAkB,CAAC,cAAc,CAAC;YACvC,KAAK,0BAAkB,CAAC,mBAAmB,CAAC;YAC5C,KAAK,0BAAkB,CAAC,oBAAoB,CAAC;YAC7C,KAAK,0BAAkB,CAAC,iBAAiB,CAAC;YAC1C,KAAK,0BAAkB,CAAC,qBAAqB,CAAC;YAC9C,KAAK,0BAAkB,CAAC,yBAAyB,CAAC;YAClD,KAAK,0BAAkB,C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K,0BAAkB,CAAC,gBAAgB;gBACtC,IAAI,CAAC,OAAO,GAAG,0BAAc,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,UAAoB,CAAC,CAAC;gBACvE,MAAM;YACR;gBACE,IAAA,sBAAY,EAAC,IAAI,CAAC,CAAC;SACtB;IACH,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;CACF;AAzHD,wCAyHC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare enum KameleoonException {
|
|
2
|
+
ExperimentConfigurationNotFound = "ExperimentConfigurationNotFound",
|
|
3
|
+
EventSourceInitialization = "EventSourceInitialization",
|
|
4
|
+
FeatureFlagConfigurationNotFound = "FeatureFlagConfigurationNotFound",
|
|
5
|
+
NotTargeted = "NotTargeted",
|
|
6
|
+
NotAllocated = "NotAllocated",
|
|
7
|
+
VisitorCodeMaxLength = "VisitorCodeMaxLength",
|
|
8
|
+
StorageInitialization = "StorageInitialization",
|
|
9
|
+
StorageWrite = "StorageWrite",
|
|
10
|
+
StorageRead = "StorageRead",
|
|
11
|
+
StorageParse = "StorageParse",
|
|
12
|
+
ClientConfiguration = "ClientConfiguration",
|
|
13
|
+
TargetingCondition = "TargetingCondition",
|
|
14
|
+
AmongValuesCheck = "AmongValuesCheck",
|
|
15
|
+
Initialization = "Initialization",
|
|
16
|
+
DataInconsistency = "DataInconsistency",
|
|
17
|
+
JSONParse = "JSONParse",
|
|
18
|
+
NumberParse = "NumberParse",
|
|
19
|
+
RemoteData = "RemoteData"
|
|
20
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.KameleoonException = void 0;
|
|
4
|
+
var KameleoonException;
|
|
5
|
+
(function (KameleoonException) {
|
|
6
|
+
KameleoonException["ExperimentConfigurationNotFound"] = "ExperimentConfigurationNotFound";
|
|
7
|
+
KameleoonException["EventSourceInitialization"] = "EventSourceInitialization";
|
|
8
|
+
KameleoonException["FeatureFlagConfigurationNotFound"] = "FeatureFlagConfigurationNotFound";
|
|
9
|
+
KameleoonException["NotTargeted"] = "NotTargeted";
|
|
10
|
+
KameleoonException["NotAllocated"] = "NotAllocated";
|
|
11
|
+
KameleoonException["VisitorCodeMaxLength"] = "VisitorCodeMaxLength";
|
|
12
|
+
KameleoonException["StorageInitialization"] = "StorageInitialization";
|
|
13
|
+
KameleoonException["StorageWrite"] = "StorageWrite";
|
|
14
|
+
KameleoonException["StorageRead"] = "StorageRead";
|
|
15
|
+
KameleoonException["StorageParse"] = "StorageParse";
|
|
16
|
+
KameleoonException["ClientConfiguration"] = "ClientConfiguration";
|
|
17
|
+
KameleoonException["TargetingCondition"] = "TargetingCondition";
|
|
18
|
+
KameleoonException["AmongValuesCheck"] = "AmongValuesCheck";
|
|
19
|
+
KameleoonException["Initialization"] = "Initialization";
|
|
20
|
+
KameleoonException["DataInconsistency"] = "DataInconsistency";
|
|
21
|
+
KameleoonException["JSONParse"] = "JSONParse";
|
|
22
|
+
KameleoonException["NumberParse"] = "NumberParse";
|
|
23
|
+
KameleoonException["RemoteData"] = "RemoteData";
|
|
24
|
+
})(KameleoonException = exports.KameleoonException || (exports.KameleoonException = {}));
|
|
25
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/kameleoonError/types.ts"],"names":[],"mappings":";;;AAAA,IAAY,kBAmBX;AAnBD,WAAY,kBAAkB;IAC5B,yFAAmE,CAAA;IACnE,6EAAuD,CAAA;IACvD,2FAAqE,CAAA;IACrE,iDAA2B,CAAA;IAC3B,mDAA6B,CAAA;IAC7B,mEAA6C,CAAA;IAC7C,qEAA+C,CAAA;IAC/C,mDAA6B,CAAA;IAC7B,iDAA2B,CAAA;IAC3B,mDAA6B,CAAA;IAC7B,iEAA2C,CAAA;IAC3C,+DAAyC,CAAA;IACzC,2DAAqC,CAAA;IACrC,uDAAiC,CAAA;IACjC,6DAAuC,CAAA;IACvC,6CAAuB,CAAA;IACvB,iDAA2B,CAAA;IAC3B,+CAAyB,CAAA;AAC3B,CAAC,EAnBW,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAmB7B"}
|
package/dist/kameleoonUtils.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { Result } from 'ts-res';
|
|
2
|
+
import { GetResultCookieParametersType, ClientGetVisitorCodeParametersType, ServerGetVisitorCodeParametersType, MobileGetVisitorCodeParametersType } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* @abstract
|
|
5
|
+
* KameleoonUtils - an abstract class for extending kameleoon utils with pre-defined method signatures
|
|
6
|
+
* */
|
|
7
|
+
export declare abstract class KameleoonUtils {
|
|
8
|
+
abstract getVisitorCode(param: ClientGetVisitorCodeParametersType | ServerGetVisitorCodeParametersType | MobileGetVisitorCodeParametersType): string;
|
|
9
|
+
protected generateRandomString(length: number): string;
|
|
10
|
+
protected getCookieVisitorCode(cookie: string): Result<string, void>;
|
|
11
|
+
protected getResultCookie({ domain, visitorCode, }: GetResultCookieParametersType): string;
|
|
5
12
|
}
|
|
6
|
-
export declare enum HttpMethod {
|
|
7
|
-
GET = "GET",
|
|
8
|
-
POST = "POST"
|
|
9
|
-
}
|
|
10
|
-
declare const _default: KameleoonUtils;
|
|
11
|
-
export default _default;
|
package/dist/kameleoonUtils.js
CHANGED
|
@@ -1,132 +1,46 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
});
|
|
41
|
-
(0, node_fetch_1.default)(eventRequest)
|
|
42
|
-
.then(function (response) { return response.text(); })
|
|
43
|
-
.then(function (responseText) { return callback && callback(responseText); })
|
|
44
|
-
.catch(function (err) { return console.log(err); });
|
|
45
|
-
};
|
|
46
|
-
this.computeStringSha256 = function (string) {
|
|
47
|
-
var i = 1, j;
|
|
48
|
-
var K = [], H = [];
|
|
49
|
-
while (++i < 18) {
|
|
50
|
-
for (j = i * i; j < 312; j += i) {
|
|
51
|
-
K[j] = 1;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
function x(num, root) {
|
|
55
|
-
return ((Math.pow(num, 1 / root) % 1) * 4294967296) | 0;
|
|
56
|
-
}
|
|
57
|
-
for (i = 1, j = 0; i < 313;) {
|
|
58
|
-
if (!K[++i]) {
|
|
59
|
-
H[j] = x(i, 2);
|
|
60
|
-
K[j++] = x(i, 3);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
function S(X, n) {
|
|
64
|
-
return (X >>> n) | (X << (32 - n));
|
|
65
|
-
}
|
|
66
|
-
var HASH = H.slice((i = 0)), W = [], m = [];
|
|
67
|
-
var s = _this.encodeUTF8(string), l = s.length, a, y, z;
|
|
68
|
-
for (; i < l;)
|
|
69
|
-
m[i >> 2] |= (s.charCodeAt(i) & 0xff) << (8 * (3 - (i++ % 4)));
|
|
70
|
-
l *= 8;
|
|
71
|
-
m[l >> 5] |= 0x80 << (24 - (l % 32));
|
|
72
|
-
m[(z = ((l + 64) >> 5) | 15)] = l;
|
|
73
|
-
for (i = 0; i < z; i += 16) {
|
|
74
|
-
a = HASH.slice((j = 0), 8);
|
|
75
|
-
for (; j < 64; a[4] += y) {
|
|
76
|
-
if (j < 16) {
|
|
77
|
-
W[j] = m[j + i];
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
W[j] =
|
|
81
|
-
(S((y = W[j - 2]), 17) ^ S(y, 19) ^ (y >>> 10)) +
|
|
82
|
-
(W[j - 7] | 0) +
|
|
83
|
-
(S((y = W[j - 15]), 7) ^ S(y, 18) ^ (y >>> 3)) +
|
|
84
|
-
(W[j - 16] | 0);
|
|
85
|
-
}
|
|
86
|
-
var b = void 0;
|
|
87
|
-
a.unshift((y =
|
|
88
|
-
((a.pop() +
|
|
89
|
-
(S((b = a[4]), 6) ^ S(b, 11) ^ S(b, 25)) +
|
|
90
|
-
(((b & a[5]) ^ (~b & a[6])) + K[j])) |
|
|
91
|
-
0) +
|
|
92
|
-
(W[j++] | 0)) +
|
|
93
|
-
(S((l = a[0]), 2) ^ S(l, 13) ^ S(l, 22)) +
|
|
94
|
-
((l & a[1]) ^ (a[1] & a[2]) ^ (a[2] & l)));
|
|
95
|
-
}
|
|
96
|
-
for (j = 8; j--;)
|
|
97
|
-
HASH[j] = a[j] + HASH[j];
|
|
98
|
-
}
|
|
99
|
-
for (s = ''; j < 63;)
|
|
100
|
-
s += ((HASH[++j >> 3] >> (4 * (7 - (j % 8)))) & 15).toString(16);
|
|
101
|
-
return s;
|
|
102
|
-
};
|
|
103
|
-
this.encodeUTF8 = function (string) {
|
|
104
|
-
string = string.replace(/\r\n/g, '\n');
|
|
105
|
-
var utftext = '';
|
|
106
|
-
for (var n = 0; n < string.length; n++) {
|
|
107
|
-
var c = string.charCodeAt(n);
|
|
108
|
-
if (c < 128) {
|
|
109
|
-
utftext += String.fromCharCode(c);
|
|
110
|
-
}
|
|
111
|
-
else if (c > 127 && c < 2048) {
|
|
112
|
-
utftext += String.fromCharCode((c >> 6) | 192);
|
|
113
|
-
utftext += String.fromCharCode((c & 63) | 128);
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
utftext += String.fromCharCode((c >> 12) | 224);
|
|
117
|
-
utftext += String.fromCharCode(((c >> 6) & 63) | 128);
|
|
118
|
-
utftext += String.fromCharCode((c & 63) | 128);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
return utftext;
|
|
122
|
-
};
|
|
3
|
+
exports.KameleoonUtils = void 0;
|
|
4
|
+
const ts_res_1 = require("ts-res");
|
|
5
|
+
const constants_1 = require("./constants");
|
|
6
|
+
/**
|
|
7
|
+
* @abstract
|
|
8
|
+
* KameleoonUtils - an abstract class for extending kameleoon utils with pre-defined method signatures
|
|
9
|
+
* */
|
|
10
|
+
class KameleoonUtils {
|
|
11
|
+
generateRandomString(length) {
|
|
12
|
+
const characters = 'abcdefghijklmnopqrstuvwxyz0123456789';
|
|
13
|
+
let randomString = '';
|
|
14
|
+
if (length < 0) {
|
|
15
|
+
return randomString;
|
|
16
|
+
}
|
|
17
|
+
for (let i = 0; i < length; i++) {
|
|
18
|
+
randomString += characters[Math.floor(Math.random() * characters.length)];
|
|
19
|
+
}
|
|
20
|
+
return randomString;
|
|
123
21
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
22
|
+
getCookieVisitorCode(cookie) {
|
|
23
|
+
const pairs = cookie.split(constants_1.Cookie.PairsDelimiter);
|
|
24
|
+
const pair = pairs === null || pairs === void 0 ? void 0 : pairs.find((pair) => {
|
|
25
|
+
const [key, _] = pair.split(constants_1.Cookie.KeyValueDelimiter);
|
|
26
|
+
return key === constants_1.KAMELEOON_COOKIE_KEY;
|
|
27
|
+
});
|
|
28
|
+
if (pair) {
|
|
29
|
+
const [_, value] = pair.split(constants_1.Cookie.KeyValueDelimiter);
|
|
30
|
+
return (0, ts_res_1.Ok)(value);
|
|
31
|
+
}
|
|
32
|
+
return (0, ts_res_1.Err)();
|
|
33
|
+
}
|
|
34
|
+
getResultCookie({ domain, visitorCode, }) {
|
|
35
|
+
const yearSeconds = 60 * 60 * 24 * 365;
|
|
36
|
+
const cookieArray = [
|
|
37
|
+
constants_1.KAMELEOON_COOKIE_KEY + constants_1.Cookie.KeyValueDelimiter + visitorCode,
|
|
38
|
+
constants_1.Cookie.MaxAge + constants_1.Cookie.KeyValueDelimiter + yearSeconds,
|
|
39
|
+
constants_1.Cookie.Path + constants_1.Cookie.KeyValueDelimiter + '/',
|
|
40
|
+
constants_1.Cookie.Domain + constants_1.Cookie.KeyValueDelimiter + domain,
|
|
41
|
+
];
|
|
42
|
+
return cookieArray.join(constants_1.Cookie.PairsDelimiter);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.KameleoonUtils = KameleoonUtils;
|
|
132
46
|
//# sourceMappingURL=kameleoonUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kameleoonUtils.js","sourceRoot":"","sources":["../src/kameleoonUtils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"kameleoonUtils.js","sourceRoot":"","sources":["../src/kameleoonUtils.ts"],"names":[],"mappings":";;;AAAA,mCAAyC;AACzC,2CAA2D;AAQ3D;;;KAG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WAAW;YAC7D,kBAAM,CAAC,MAAM,GAAG,kBAAM,CAAC,iBAAiB,GAAG,WAAW;YACtD,kBAAM,CAAC,IAAI,GAAG,kBAAM,CAAC,iBAAiB,GAAG,GAAG;YAC5C,kBAAM,CAAC,MAAM,GAAG,kBAAM,CAAC,iBAAiB,GAAG,MAAM;SAClD,CAAC;QAEF,OAAO,WAAW,CAAC,IAAI,CAAC,kBAAM,CAAC,cAAc,CAAC,CAAC;IACjD,CAAC;CACF;AAtDD,wCAsDC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { EventType, ParameterType, QueryType, StrictEventTypeRecord, StrictParameterRecord, StrictQueryRecord, StrictTrackingRecord, TrackingType } from './types';
|
|
2
|
+
export declare enum Header {
|
|
3
|
+
KameleoonClient = "Kameleoon-Client",
|
|
4
|
+
UserAgent = "User-Agent"
|
|
5
|
+
}
|
|
6
|
+
export declare const URL: {
|
|
7
|
+
EVENTS: string;
|
|
8
|
+
API_SSX: string;
|
|
9
|
+
API_DATA: string;
|
|
10
|
+
CLIENT_CONFIGURATION: string;
|
|
11
|
+
};
|
|
12
|
+
export declare const UrlEventType: StrictEventTypeRecord<EventType>;
|
|
13
|
+
export declare const UrlParameter: StrictParameterRecord<ParameterType>;
|
|
14
|
+
export declare const UrlQuery: StrictQueryRecord<QueryType>;
|
|
15
|
+
export declare const UrlTracking: StrictTrackingRecord<TrackingType>;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UrlTracking = exports.UrlQuery = exports.UrlParameter = exports.UrlEventType = exports.URL = exports.Header = void 0;
|
|
4
|
+
var Header;
|
|
5
|
+
(function (Header) {
|
|
6
|
+
Header["KameleoonClient"] = "Kameleoon-Client";
|
|
7
|
+
Header["UserAgent"] = "User-Agent";
|
|
8
|
+
})(Header = exports.Header || (exports.Header = {}));
|
|
9
|
+
const topLevelDomain = process.env.NODE_ENV === 'test' ? 'net' : 'com';
|
|
10
|
+
exports.URL = {
|
|
11
|
+
EVENTS: `https://events.kameleoon.${topLevelDomain}:8110/`,
|
|
12
|
+
API_SSX: `https://api-ssx.kameleoon.${topLevelDomain}/`,
|
|
13
|
+
API_DATA: `https://api-data.kameleoon.${topLevelDomain}/`,
|
|
14
|
+
CLIENT_CONFIGURATION: `https://client-config.kameleoon.${topLevelDomain}/`,
|
|
15
|
+
};
|
|
16
|
+
exports.UrlEventType = {
|
|
17
|
+
CustomData: 'eventType=customData',
|
|
18
|
+
StaticData: 'eventType=staticData',
|
|
19
|
+
Page: 'eventType=page',
|
|
20
|
+
Conversion: 'eventType=conversion',
|
|
21
|
+
};
|
|
22
|
+
exports.UrlParameter = {
|
|
23
|
+
ValueToCount: '&valueToCount=',
|
|
24
|
+
Nonce: '&nonce=',
|
|
25
|
+
Title: '&title=',
|
|
26
|
+
ReferrersIndices: '&referrersIndices=',
|
|
27
|
+
Negative: '&negative=',
|
|
28
|
+
Revenue: '&revenue=',
|
|
29
|
+
Overwrite: '&overwrite=',
|
|
30
|
+
Index: '&index=',
|
|
31
|
+
BrowserIndex: '&browserIndex=',
|
|
32
|
+
Href: '&href=',
|
|
33
|
+
DeviceType: '&deviceType=',
|
|
34
|
+
SiteCode: '&siteCode=',
|
|
35
|
+
GoalId: '&goalId=',
|
|
36
|
+
VisitorCode: '&visitorCode=',
|
|
37
|
+
ExperimentId: '&experimentId=',
|
|
38
|
+
Environment: '&environment=',
|
|
39
|
+
VariationId: '&variationId=',
|
|
40
|
+
NoneVariation: '&noneVariation=',
|
|
41
|
+
Ts: '&ts=',
|
|
42
|
+
Key: '&key=',
|
|
43
|
+
};
|
|
44
|
+
exports.UrlQuery = {
|
|
45
|
+
Data: 'data?siteCode=',
|
|
46
|
+
Sse: 'sse?siteCode=',
|
|
47
|
+
Mobile: 'mobile?siteCode=',
|
|
48
|
+
};
|
|
49
|
+
exports.UrlTracking = {
|
|
50
|
+
Experiment: 'experimentTracking?',
|
|
51
|
+
Data: 'dataTracking?',
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=constants.js.map
|