ouisys-engine 4.6.2 → 4.7.0-alpha.1
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/dist/RemoteDataState-CwHLI23e.js +75 -0
- package/dist/RemoteDataState-CwHLI23e.js.map +1 -0
- package/dist/bupperizeCountry-CCDIOHP6.js +4 -0
- package/dist/bupperizeCountry-CCDIOHP6.js.map +1 -0
- package/dist/checkSubscriptionByRockmanIdOnly-C89Ph9cV.js +27 -0
- package/dist/checkSubscriptionByRockmanIdOnly-C89Ph9cV.js.map +1 -0
- package/dist/checkSubscriptionHander.js +53 -0
- package/dist/checkSubscriptionHander.js.map +1 -0
- package/dist/click2smsFlow.js +246 -0
- package/dist/click2smsFlow.js.map +1 -0
- package/dist/creditCardFlow.js +248 -0
- package/dist/creditCardFlow.js.map +1 -0
- package/dist/getConfig.js +14 -0
- package/dist/getConfig.js.map +1 -0
- package/dist/handleClickChainFlow.js +32 -0
- package/dist/handleClickChainFlow.js.map +1 -0
- package/dist/handleSubmitNumber.js +65 -0
- package/dist/handleSubmitNumber.js.map +1 -0
- package/dist/helpers-J_h-ZgxH.js +29 -0
- package/dist/helpers-J_h-ZgxH.js.map +1 -0
- package/dist/loadScriptInnerHtml-DPcoY467.js +26 -0
- package/dist/loadScriptInnerHtml-DPcoY467.js.map +1 -0
- package/dist/moFlow.js +275 -0
- package/dist/moFlow.js.map +1 -0
- package/dist/moRedirFlow.js +225 -0
- package/dist/moRedirFlow.js.map +1 -0
- package/dist/oneClickFlow.js +464 -0
- package/dist/oneClickFlow.js.map +1 -0
- package/dist/pinFlow.js +697 -0
- package/dist/pinFlow.js.map +1 -0
- package/dist/searchToObject.js +19 -0
- package/dist/searchToObject.js.map +1 -0
- package/dist/storeMsisdn-ChiBh8mI.js +58 -0
- package/dist/storeMsisdn-ChiBh8mI.js.map +1 -0
- package/dist/strategy.js +50 -0
- package/dist/strategy.js.map +1 -0
- package/dist/strategySlice-bF74rxDK.js +842 -0
- package/dist/strategySlice-bF74rxDK.js.map +1 -0
- package/dist/tracker-B_zsMRN2.js +79 -0
- package/dist/tracker-B_zsMRN2.js.map +1 -0
- package/dist/tracker.js +5 -0
- package/dist/tracker.js.map +1 -0
- package/dist/tryGetIPRangeName-C69HEG5W.js +42 -0
- package/dist/tryGetIPRangeName-C69HEG5W.js.map +1 -0
- package/dist/types/CreditCardTypes-B-IT-l6I.d.ts +72 -0
- package/dist/types/IHash-0OgZ_1ij.d.ts +5 -0
- package/dist/types/MoRedirTypes-4tEJjT1g.d.ts +31 -0
- package/dist/types/MoTypes-D-UK92gs.d.ts +45 -0
- package/dist/types/OneClickTypes-DF0jodl-.d.ts +69 -0
- package/dist/types/PinTypes-BLJDBZe6.d.ts +128 -0
- package/dist/types/RemoteDataState-D1aFrz8W.d.ts +61 -0
- package/dist/types/StrategyTypes-BEIYqoJV.d.ts +325 -0
- package/dist/types/UssdTypes-C7QlIW11.d.ts +34 -0
- package/dist/types/checkSubscriptionHander.d.ts +8 -0
- package/dist/types/click2smsFlow.d.ts +37 -0
- package/dist/types/creditCardFlow.d.ts +37 -0
- package/dist/types/getConfig.d.ts +38 -0
- package/dist/types/handleClickChainFlow.d.ts +6 -0
- package/dist/types/handleSubmitNumber.d.ts +26 -0
- package/dist/types/moFlow.d.ts +70 -0
- package/dist/types/moRedirFlow.d.ts +82 -0
- package/dist/types/oneClickFlow.d.ts +56 -0
- package/dist/types/pinFlow.d.ts +179 -0
- package/dist/types/searchToObject.d.ts +3 -0
- package/dist/types/strategy.d.ts +86 -0
- package/dist/types/tracker.d.ts +5 -0
- package/dist/types/ussdFlow.d.ts +84 -0
- package/dist/ussdFlow.js +211 -0
- package/dist/ussdFlow.js.map +1 -0
- package/package.json +85 -9
- package/.babelrc +0 -30
- package/.browserslistrc +0 -6
- package/.eslintrc.js +0 -3
- package/.nvmrc +0 -1
- package/.prettierignore +0 -4
- package/dist/@types/react-tracker.d.js +0 -1
- package/dist/@types/redux-cli-logger.d.js +0 -1
- package/dist/@types/tiny-async-pool.d.js +0 -1
- package/dist/@types/window.d.js +0 -1
- package/dist/api/index.d.ts +0 -43
- package/dist/api/index.js +0 -1
- package/dist/common-types/AppThunk.d.ts +0 -13
- package/dist/common-types/AppThunk.js +0 -1
- package/dist/common-types/Either.d.ts +0 -8
- package/dist/common-types/Either.js +0 -1
- package/dist/common-types/IError.d.ts +0 -3
- package/dist/common-types/IError.js +0 -1
- package/dist/common-types/IOptInFlowName.d.ts +0 -1
- package/dist/common-types/IOptInFlowName.js +0 -1
- package/dist/common-types/ITracker.d.ts +0 -9
- package/dist/common-types/ITracker.js +0 -1
- package/dist/common-types/IVisitor.d.ts +0 -14
- package/dist/common-types/IVisitor.js +0 -1
- package/dist/common-types/RemoteDataState.d.ts +0 -38
- package/dist/common-types/RemoteDataState.js +0 -1
- package/dist/custom-hooks/useOneClickRedirectUrl.d.ts +0 -3
- package/dist/custom-hooks/useOneClickRedirectUrl.js +0 -1
- package/dist/custom-hooks/usePinEntryState.d.ts +0 -8
- package/dist/custom-hooks/usePinEntryState.js +0 -1
- package/dist/custom-hooks/useStrategyConfig.d.ts +0 -4
- package/dist/custom-hooks/useStrategyConfig.js +0 -1
- package/dist/flows/click2smsFlow.d.ts +0 -6
- package/dist/flows/click2smsFlow.js +0 -1
- package/dist/flows/creditCardFlow.d.ts +0 -6
- package/dist/flows/creditCardFlow.js +0 -1
- package/dist/flows/moFlow.d.ts +0 -6
- package/dist/flows/moFlow.js +0 -1
- package/dist/flows/moRedirFlow.d.ts +0 -6
- package/dist/flows/moRedirFlow.js +0 -1
- package/dist/flows/oneClickFlow.d.ts +0 -7
- package/dist/flows/oneClickFlow.js +0 -1
- package/dist/flows/pinFlow.d.ts +0 -7
- package/dist/flows/pinFlow.js +0 -1
- package/dist/flows/strategy.d.ts +0 -14
- package/dist/flows/strategy.js +0 -1
- package/dist/flows/ussdFlow.d.ts +0 -6
- package/dist/flows/ussdFlow.js +0 -1
- package/dist/index.d.ts +0 -0
- package/dist/index.js +0 -1
- package/dist/ips/tryGetIPRangeName.d.ts +0 -2
- package/dist/ips/tryGetIPRangeName.js +0 -1
- package/dist/jest.config.js +0 -194
- package/dist/pacman/index.d.ts +0 -6
- package/dist/pacman/index.js +0 -1
- package/dist/pacman/queryString.d.ts +0 -3
- package/dist/pacman/queryString.js +0 -1
- package/dist/reducers/click2smsFlow/Click2smsTypes.d.ts +0 -76
- package/dist/reducers/click2smsFlow/Click2smsTypes.js +0 -1
- package/dist/reducers/click2smsFlow/IClick2smsConstants.d.ts +0 -2
- package/dist/reducers/click2smsFlow/IClick2smsConstants.js +0 -1
- package/dist/reducers/click2smsFlow/index.d.ts +0 -5
- package/dist/reducers/click2smsFlow/index.js +0 -1
- package/dist/reducers/click2smsFlow/utils.d.ts +0 -4
- package/dist/reducers/click2smsFlow/utils.js +0 -1
- package/dist/reducers/creditCardFlow/CreditCardTypes.d.ts +0 -79
- package/dist/reducers/creditCardFlow/CreditCardTypes.js +0 -1
- package/dist/reducers/creditCardFlow/ICreditCardConstants.d.ts +0 -2
- package/dist/reducers/creditCardFlow/ICreditCardConstants.js +0 -1
- package/dist/reducers/creditCardFlow/index.d.ts +0 -5
- package/dist/reducers/creditCardFlow/index.js +0 -1
- package/dist/reducers/creditCardFlow/utils.d.ts +0 -8
- package/dist/reducers/creditCardFlow/utils.js +0 -1
- package/dist/reducers/moFlow/IMoConstants.d.ts +0 -2
- package/dist/reducers/moFlow/IMoConstants.js +0 -1
- package/dist/reducers/moFlow/MoTypes.d.ts +0 -88
- package/dist/reducers/moFlow/MoTypes.js +0 -1
- package/dist/reducers/moFlow/index.d.ts +0 -16
- package/dist/reducers/moFlow/index.js +0 -1
- package/dist/reducers/moFlow/utils.d.ts +0 -12
- package/dist/reducers/moFlow/utils.js +0 -1
- package/dist/reducers/moRedirFlow/IMoRedirConstants.d.ts +0 -2
- package/dist/reducers/moRedirFlow/IMoRedirConstants.js +0 -1
- package/dist/reducers/moRedirFlow/MoRedirTypes.d.ts +0 -64
- package/dist/reducers/moRedirFlow/MoRedirTypes.js +0 -1
- package/dist/reducers/moRedirFlow/index.d.ts +0 -14
- package/dist/reducers/moRedirFlow/index.js +0 -1
- package/dist/reducers/moRedirFlow/utils.d.ts +0 -10
- package/dist/reducers/moRedirFlow/utils.js +0 -1
- package/dist/reducers/oneClickFlow/IOneClickConstants.d.ts +0 -2
- package/dist/reducers/oneClickFlow/IOneClickConstants.js +0 -1
- package/dist/reducers/oneClickFlow/OneClickTypes.d.ts +0 -85
- package/dist/reducers/oneClickFlow/OneClickTypes.js +0 -1
- package/dist/reducers/oneClickFlow/index.d.ts +0 -13
- package/dist/reducers/oneClickFlow/index.js +0 -1
- package/dist/reducers/oneClickFlow/utils.d.ts +0 -16
- package/dist/reducers/oneClickFlow/utils.js +0 -1
- package/dist/reducers/pinFlow/IPinConstants.d.ts +0 -2
- package/dist/reducers/pinFlow/IPinConstants.js +0 -1
- package/dist/reducers/pinFlow/PinTypes.d.ts +0 -156
- package/dist/reducers/pinFlow/PinTypes.js +0 -1
- package/dist/reducers/pinFlow/index.d.ts +0 -19
- package/dist/reducers/pinFlow/index.js +0 -1
- package/dist/reducers/pinFlow/utils.d.ts +0 -11
- package/dist/reducers/pinFlow/utils.js +0 -1
- package/dist/reducers/strategy/IStategyActionContants.d.ts +0 -2
- package/dist/reducers/strategy/IStategyActionContants.js +0 -1
- package/dist/reducers/strategy/StrategyTypes.d.ts +0 -248
- package/dist/reducers/strategy/StrategyTypes.js +0 -1
- package/dist/reducers/strategy/index.d.ts +0 -13
- package/dist/reducers/strategy/index.js +0 -1
- package/dist/reducers/strategy/strategies/ask_mobile_number.d.ts +0 -15
- package/dist/reducers/strategy/strategies/ask_mobile_number.js +0 -1
- package/dist/reducers/strategy/strategies/ask_operator.d.ts +0 -5
- package/dist/reducers/strategy/strategies/ask_operator.js +0 -1
- package/dist/reducers/strategy/strategies/detect_operator_by_ip.d.ts +0 -10
- package/dist/reducers/strategy/strategies/detect_operator_by_ip.js +0 -1
- package/dist/reducers/strategy/strategies/header_enrichment.d.ts +0 -7
- package/dist/reducers/strategy/strategies/header_enrichment.js +0 -1
- package/dist/reducers/strategy/strategies/injectHeaderEnrichmentScript.d.ts +0 -7
- package/dist/reducers/strategy/strategies/injectHeaderEnrichmentScript.js +0 -1
- package/dist/reducers/strategy/utils.d.ts +0 -30
- package/dist/reducers/strategy/utils.js +0 -1
- package/dist/reducers/ussdFlow/IUssdConstants.d.ts +0 -2
- package/dist/reducers/ussdFlow/IUssdConstants.js +0 -1
- package/dist/reducers/ussdFlow/UssdTypes.d.ts +0 -77
- package/dist/reducers/ussdFlow/UssdTypes.js +0 -1
- package/dist/reducers/ussdFlow/index.d.ts +0 -14
- package/dist/reducers/ussdFlow/index.js +0 -1
- package/dist/reducers/ussdFlow/utils.d.ts +0 -11
- package/dist/reducers/ussdFlow/utils.js +0 -1
- package/dist/store/index.d.ts +0 -14
- package/dist/store/index.js +0 -1
- package/dist/store/reducers.d.ts +0 -20
- package/dist/store/reducers.js +0 -1
- package/dist/utilities/addEmpelloToken.d.ts +0 -4
- package/dist/utilities/addEmpelloToken.js +0 -1
- package/dist/utilities/handleSubmitNumber.d.ts +0 -21
- package/dist/utilities/handleSubmitNumber.js +0 -1
- package/dist/utilities/index.d.ts +0 -17
- package/dist/utilities/index.js +0 -1
- package/dist/utilities/loadScriptInnerHtml.d.ts +0 -2
- package/dist/utilities/loadScriptInnerHtml.js +0 -1
- package/dist/utilities/loadScriptSrc.d.ts +0 -8
- package/dist/utilities/loadScriptSrc.js +0 -1
- package/dist/utilities/replaceUrlParam.d.ts +0 -1
- package/dist/utilities/replaceUrlParam.js +0 -1
- package/dist/utilities/storeMsisdn.d.ts +0 -3
- package/dist/utilities/storeMsisdn.js +0 -1
- package/index.html +0 -49
- package/mockData/config.json +0 -28
- package/setupJest.js +0 -6
- package/tsconfig.json +0 -28
package/dist/pinFlow.js
ADDED
|
@@ -0,0 +1,697 @@
|
|
|
1
|
+
import { __awaiter, __generator, __read, __assign } from 'tslib';
|
|
2
|
+
import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
|
|
3
|
+
import PhoneNumber from 'awesome-phonenumber';
|
|
4
|
+
import { N as NothingYet, S as Success, L as Loading, F as Failure } from './RemoteDataState-CwHLI23e.js';
|
|
5
|
+
import { c as setStrategyExtraData, P as PossibleTypes } from './strategySlice-bF74rxDK.js';
|
|
6
|
+
import { s as storeMsisdn } from './storeMsisdn-ChiBh8mI.js';
|
|
7
|
+
import { t as tracker } from './tracker-B_zsMRN2.js';
|
|
8
|
+
import { b as bupperizeCountry } from './bupperizeCountry-CCDIOHP6.js';
|
|
9
|
+
import { l as left, r as right, a as loop } from './helpers-J_h-ZgxH.js';
|
|
10
|
+
import { l as loadScriptInnerHtml } from './loadScriptInnerHtml-DPcoY467.js';
|
|
11
|
+
import { searchToObject } from './searchToObject.js';
|
|
12
|
+
import './getConfig.js';
|
|
13
|
+
import './tryGetIPRangeName-C69HEG5W.js';
|
|
14
|
+
import 'pacman-client';
|
|
15
|
+
import 'uuid';
|
|
16
|
+
|
|
17
|
+
var usePinFlowState = function (useSelector) {
|
|
18
|
+
var currentState = useSelector(function (state) { return state.pinFlow.currentState; });
|
|
19
|
+
return currentState;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
function pinFlowMatch(_a) {
|
|
23
|
+
var msisdnEntry = _a.msisdnEntry, pinEntry = _a.pinEntry;
|
|
24
|
+
return function (state) {
|
|
25
|
+
switch (state.type) {
|
|
26
|
+
case 'MSISDNEntry':
|
|
27
|
+
return msisdnEntry(state.result);
|
|
28
|
+
case 'PINEntry':
|
|
29
|
+
return pinEntry(state.result, state.data);
|
|
30
|
+
default:
|
|
31
|
+
throw new Error('Invalid State');
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
var checkSubscription = function (_a) {
|
|
37
|
+
var window = _a.window, country = _a.country, slug = _a.slug, device = _a.device, offer = _a.offer, rockmanId = _a.rockmanId;
|
|
38
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
39
|
+
var params, queryString, host, url;
|
|
40
|
+
return __generator(this, function (_b) {
|
|
41
|
+
params = {
|
|
42
|
+
action: 'check-subscription',
|
|
43
|
+
country: bupperizeCountry(country),
|
|
44
|
+
slug: slug,
|
|
45
|
+
device: device,
|
|
46
|
+
offerId: offer,
|
|
47
|
+
rockman_id: rockmanId
|
|
48
|
+
};
|
|
49
|
+
queryString = Object.entries(params)
|
|
50
|
+
.filter(function (_a) {
|
|
51
|
+
var _b = __read(_a, 2); _b[0]; var value = _b[1];
|
|
52
|
+
return value !== undefined && value !== null;
|
|
53
|
+
})
|
|
54
|
+
.map(function (_a) {
|
|
55
|
+
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
56
|
+
return "".concat(key, "=").concat(encodeURIComponent(value));
|
|
57
|
+
})
|
|
58
|
+
.join('&');
|
|
59
|
+
host = window.DEV_BASE_URL || '';
|
|
60
|
+
url = "".concat(host, "/tallyman/v1/?").concat(queryString);
|
|
61
|
+
return [2 /*return*/, fetch(url).then(function (response) { return response.json(); })];
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
var checkIsCleanTraffic = function (country) {
|
|
67
|
+
if (country === 'be') {
|
|
68
|
+
if (typeof window !== 'undefined' && window.shouldBlock === true) {
|
|
69
|
+
return '&is-clean-traffic=false';
|
|
70
|
+
}
|
|
71
|
+
return '&is-clean-traffic=true';
|
|
72
|
+
}
|
|
73
|
+
return '';
|
|
74
|
+
};
|
|
75
|
+
var triggerPin = function (_a) {
|
|
76
|
+
var window = _a.window, country = _a.country, slug = _a.slug, device = _a.device, offer = _a.offer, msisdn = _a.msisdn, rockmanId = _a.rockmanId, extraParams = _a.extraParams, search = _a.search, uniqid = _a.uniqid, evinaTid = _a.evinaTid;
|
|
77
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
78
|
+
var cleanTrafficString, extraParamsQs, params, queryString, host, url;
|
|
79
|
+
var _b;
|
|
80
|
+
return __generator(this, function (_c) {
|
|
81
|
+
cleanTrafficString = checkIsCleanTraffic(country);
|
|
82
|
+
extraParamsQs = "&".concat(Object.keys(extraParams)
|
|
83
|
+
.map(function (k) { return "".concat(k, "=").concat(extraParams[k]); })
|
|
84
|
+
.join('&'));
|
|
85
|
+
params = {
|
|
86
|
+
action: 'trigger-pin',
|
|
87
|
+
country: country,
|
|
88
|
+
slug: slug,
|
|
89
|
+
device: device,
|
|
90
|
+
offerId: offer,
|
|
91
|
+
msisdn: msisdn,
|
|
92
|
+
rockman_id: rockmanId,
|
|
93
|
+
sam_evina_tid: evinaTid,
|
|
94
|
+
page: encodeURIComponent((_b = window === null || window === void 0 ? void 0 : window.location) === null || _b === void 0 ? void 0 : _b.href),
|
|
95
|
+
language_code: window.languageCode || '',
|
|
96
|
+
antifraud_id: window.antifraud_id || '',
|
|
97
|
+
partner_transaction_id: window.partner_transaction_id || '',
|
|
98
|
+
partner_timestamp: window.partner_timestamp || '',
|
|
99
|
+
partner_cid: window.partner_cid || '',
|
|
100
|
+
uniqid: uniqid || ''
|
|
101
|
+
};
|
|
102
|
+
queryString = Object.entries(params)
|
|
103
|
+
.filter(function (_a) {
|
|
104
|
+
var _b = __read(_a, 2); _b[0]; var value = _b[1];
|
|
105
|
+
return value;
|
|
106
|
+
})
|
|
107
|
+
.map(function (_a) {
|
|
108
|
+
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
109
|
+
return "".concat(key, "=").concat(value);
|
|
110
|
+
})
|
|
111
|
+
.join('&');
|
|
112
|
+
host = window.DEV_BASE_URL || '';
|
|
113
|
+
url = "".concat(host, "/tallyman/v1/?").concat(queryString).concat(cleanTrafficString).concat(extraParamsQs, "&").concat(search);
|
|
114
|
+
return [2 /*return*/, fetch(url).then(function (x) { return x.json(); })];
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
var verifyPin = function (_a) {
|
|
119
|
+
var window = _a.window, country = _a.country, slug = _a.slug, device = _a.device, offer = _a.offer, rockmanId = _a.rockmanId, pin = _a.pin, extraParams = _a.extraParams, uniqid = _a.uniqid, evinaTid = _a.evinaTid;
|
|
120
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
121
|
+
var cleanTrafficString, extraParamsQs, params, queryString, host, url;
|
|
122
|
+
var _b;
|
|
123
|
+
return __generator(this, function (_c) {
|
|
124
|
+
cleanTrafficString = checkIsCleanTraffic(country);
|
|
125
|
+
extraParamsQs = "&".concat(Object.keys(extraParams)
|
|
126
|
+
.map(function (k) { return "".concat(k, "=").concat(extraParams[k]); })
|
|
127
|
+
.join('&'));
|
|
128
|
+
params = {
|
|
129
|
+
action: 'verify-pin',
|
|
130
|
+
country: bupperizeCountry(country),
|
|
131
|
+
slug: slug,
|
|
132
|
+
device: device,
|
|
133
|
+
offerId: offer,
|
|
134
|
+
rockman_id: rockmanId,
|
|
135
|
+
pin: pin,
|
|
136
|
+
page: encodeURIComponent((_b = window === null || window === void 0 ? void 0 : window.location) === null || _b === void 0 ? void 0 : _b.href),
|
|
137
|
+
language_code: window.languageCode || '',
|
|
138
|
+
antifraud_id: window.antifraud_id || '',
|
|
139
|
+
ClickID: window.antifraud_click_id || '',
|
|
140
|
+
partner_cid: window.partner_cid || '',
|
|
141
|
+
sam_evina_tid: evinaTid,
|
|
142
|
+
uniqid: uniqid
|
|
143
|
+
};
|
|
144
|
+
queryString = Object.entries(params)
|
|
145
|
+
.filter(function (_a) {
|
|
146
|
+
var _b = __read(_a, 2); _b[0]; var value = _b[1];
|
|
147
|
+
return value;
|
|
148
|
+
})
|
|
149
|
+
.map(function (_a) {
|
|
150
|
+
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
151
|
+
return "".concat(key, "=").concat(value);
|
|
152
|
+
})
|
|
153
|
+
.join('&');
|
|
154
|
+
host = window.DEV_BASE_URL || '';
|
|
155
|
+
url = "".concat(host, "/tallyman/v1/?").concat(queryString).concat(cleanTrafficString).concat(extraParamsQs);
|
|
156
|
+
return [2 /*return*/, fetch(url).then(function (x) { return x.json(); })];
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
};
|
|
160
|
+
var mcpShield = function (_a) {
|
|
161
|
+
var window = _a.window, country = _a.country, slug = _a.slug, device = _a.device, offer = _a.offer, rockmanId = _a.rockmanId, operator = _a.operator, uniqid = _a.uniqid;
|
|
162
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
163
|
+
var pageUrl, ipAdd, params, host, url;
|
|
164
|
+
return __generator(this, function (_b) {
|
|
165
|
+
pageUrl = window.location.href;
|
|
166
|
+
ipAdd = window.pac_analytics.visitor.ip;
|
|
167
|
+
params = new URLSearchParams(__assign(__assign({ action: 'mcp-shield', country: country, slug: slug, device: device, offerId: offer.toString(), rockman_id: rockmanId, client_lpu: pageUrl }, (operator && { operator: operator })), (uniqid && { uniqid: uniqid })));
|
|
168
|
+
// Conditionally add client_ip if it exists
|
|
169
|
+
if (ipAdd) {
|
|
170
|
+
params.append('client_ip', ipAdd);
|
|
171
|
+
}
|
|
172
|
+
host = window.DEV_BASE_URL || '';
|
|
173
|
+
url = "".concat(host, "/tallyman/v1/?").concat(params.toString());
|
|
174
|
+
return [2 /*return*/, fetch(url).then(function (x) { return x.json(); })];
|
|
175
|
+
});
|
|
176
|
+
});
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
function submitMSISDN(window, maybeConfig, internationalMSISDN, extraParams) {
|
|
180
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
181
|
+
var config;
|
|
182
|
+
return __generator(this, function (_a) {
|
|
183
|
+
config = __assign({ offer: window.pac_analytics.visitor.offer }, (maybeConfig || {}));
|
|
184
|
+
if (config.automaticallySubmitAllOperators === true && !!config.operators && config.operators.length > 0) {
|
|
185
|
+
return [2 /*return*/, submitMSISDNForMultipleOperators(window, config, internationalMSISDN, config.operators, extraParams)];
|
|
186
|
+
}
|
|
187
|
+
return [2 /*return*/, submitMSISDNOnce(window, config, internationalMSISDN, extraParams)];
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
var uniqidResult = '';
|
|
192
|
+
function submitMSISDNOnce(window, config, internationalMSISDN, extraParams) {
|
|
193
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
194
|
+
var submissionError, newExtraParams, isSkipValidation, searchObj, msisdn, rockmanId, slug, country, device, offer, search, uniqid, evinaTid, result, error, codesWithMcpShied, mcpShieldResult, err_2;
|
|
195
|
+
return __generator(this, function (_a) {
|
|
196
|
+
switch (_a.label) {
|
|
197
|
+
case 0:
|
|
198
|
+
if (!internationalMSISDN) {
|
|
199
|
+
submissionError = new Error("Error in submitMSISDN() trigger-pin action");
|
|
200
|
+
submissionError.type = 'InvalidMSISDN';
|
|
201
|
+
throw submissionError;
|
|
202
|
+
}
|
|
203
|
+
newExtraParams = extraParams || {};
|
|
204
|
+
isSkipValidation = false;
|
|
205
|
+
searchObj = searchToObject(window);
|
|
206
|
+
if ((searchObj === null || searchObj === void 0 ? void 0 : searchObj.success) === 'true' && searchObj['msisdn-alias'] === '1') {
|
|
207
|
+
// Search param is set to 1 for header enrichment when the msisdn is masked
|
|
208
|
+
newExtraParams['skip-validation'] = '1';
|
|
209
|
+
}
|
|
210
|
+
if (newExtraParams['skip-validation'] === '1') {
|
|
211
|
+
isSkipValidation = true;
|
|
212
|
+
}
|
|
213
|
+
msisdn = isSkipValidation ? internationalMSISDN : internationalMSISDN.match(/\d+/gi).join('');
|
|
214
|
+
rockmanId = window.pac_analytics.visitor.rockmanId;
|
|
215
|
+
slug = config.slug, country = config.country, device = config.device, offer = config.offer;
|
|
216
|
+
search = window.location.search.indexOf('redirect-back=1') === -1 ? window.location.search.substr(1) || '' : '';
|
|
217
|
+
uniqid = !!uniqidResult && uniqidResult !== '' ? "&mcpUniqid=".concat(uniqidResult) : '';
|
|
218
|
+
evinaTid = typeof window !== 'undefined' && window.tid ? window.tid : '';
|
|
219
|
+
return [4 /*yield*/, triggerPin({
|
|
220
|
+
window: window,
|
|
221
|
+
country: country,
|
|
222
|
+
slug: slug,
|
|
223
|
+
device: device,
|
|
224
|
+
offer: offer,
|
|
225
|
+
msisdn: msisdn,
|
|
226
|
+
rockmanId: rockmanId,
|
|
227
|
+
extraParams: newExtraParams,
|
|
228
|
+
search: search,
|
|
229
|
+
uniqid: uniqid,
|
|
230
|
+
evinaTid: evinaTid
|
|
231
|
+
})];
|
|
232
|
+
case 1:
|
|
233
|
+
result = _a.sent();
|
|
234
|
+
if (!(result.success === false)) return [3 /*break*/, 2];
|
|
235
|
+
error = new Error("Error in submitMSISDN() trigger-pin action:\n".concat(result.message));
|
|
236
|
+
switch (result.message) {
|
|
237
|
+
case 'ALREADY SUBSCRIBED':
|
|
238
|
+
error.type = 'AlreadySubscribed';
|
|
239
|
+
break;
|
|
240
|
+
case 'INVALID MSISDN':
|
|
241
|
+
error.type = 'InvalidMSISDN';
|
|
242
|
+
break;
|
|
243
|
+
default:
|
|
244
|
+
error.type = null;
|
|
245
|
+
}
|
|
246
|
+
// error.type = result.message === 'ALREADY SUBSCRIBED' ? 'AlreadySubscribed' : 'InvalidMSISDN';
|
|
247
|
+
error.productUrl = result.product_url ? result.product_url : '';
|
|
248
|
+
console.error(error);
|
|
249
|
+
throw error;
|
|
250
|
+
case 2:
|
|
251
|
+
window.operator = result.operator; // currently used on server for KW_STC if present dont call empello for Shemaroo
|
|
252
|
+
codesWithMcpShied = {
|
|
253
|
+
kw: {
|
|
254
|
+
kw_viva: 'kw_viva'
|
|
255
|
+
},
|
|
256
|
+
k2: {
|
|
257
|
+
k2_viva: 'k2_viva'
|
|
258
|
+
},
|
|
259
|
+
bh: {
|
|
260
|
+
bh_viva: 'bh_viva'
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
if (!(country &&
|
|
264
|
+
result.operator &&
|
|
265
|
+
((codesWithMcpShied[country.toLowerCase()] &&
|
|
266
|
+
codesWithMcpShied[country.toLowerCase()][result.operator.toLowerCase()]) ||
|
|
267
|
+
country.toLowerCase() === 'iq') &&
|
|
268
|
+
!window.isCallBlockApi &&
|
|
269
|
+
!window.Empello) // set on server https://www.notion.so/sammedia/KW-Agency-Shemaroo-STC-integration-1a114991683d4af79eb01a4d96789f30
|
|
270
|
+
) return [3 /*break*/, 6]; // set on server https://www.notion.so/sammedia/KW-Agency-Shemaroo-STC-integration-1a114991683d4af79eb01a4d96789f30
|
|
271
|
+
_a.label = 3;
|
|
272
|
+
case 3:
|
|
273
|
+
_a.trys.push([3, 5, , 6]);
|
|
274
|
+
return [4 /*yield*/, mcpShield({
|
|
275
|
+
window: window,
|
|
276
|
+
country: country,
|
|
277
|
+
slug: slug,
|
|
278
|
+
device: device,
|
|
279
|
+
offer: offer,
|
|
280
|
+
rockmanId: rockmanId,
|
|
281
|
+
operator: result.operator,
|
|
282
|
+
uniqid: uniqid
|
|
283
|
+
})];
|
|
284
|
+
case 4:
|
|
285
|
+
mcpShieldResult = _a.sent();
|
|
286
|
+
if (mcpShieldResult.success === false) {
|
|
287
|
+
console.warn(mcpShieldResult.message);
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
loadScriptInnerHtml(mcpShieldResult.source);
|
|
291
|
+
uniqidResult = mcpShieldResult.uniqid;
|
|
292
|
+
}
|
|
293
|
+
return [3 /*break*/, 6];
|
|
294
|
+
case 5:
|
|
295
|
+
err_2 = _a.sent();
|
|
296
|
+
console.warn(err_2);
|
|
297
|
+
return [3 /*break*/, 6];
|
|
298
|
+
case 6:
|
|
299
|
+
if (result.javascript) {
|
|
300
|
+
loadScriptInnerHtml(result.javascript);
|
|
301
|
+
}
|
|
302
|
+
return [2 /*return*/, {
|
|
303
|
+
type: 'SingleMSISDNSubmissionResult',
|
|
304
|
+
pin: result.pin,
|
|
305
|
+
uniqidResult: uniqidResult,
|
|
306
|
+
operator: result.operator,
|
|
307
|
+
redirectUrl: result === null || result === void 0 ? void 0 : result.redirect_to_url // For pin redirect empello
|
|
308
|
+
}];
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
function submitMSISDNForMultipleOperators(window, config, internationalMSISDN, operators, extraParams) {
|
|
314
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
315
|
+
var results, alreadySubscribed;
|
|
316
|
+
var _this = this;
|
|
317
|
+
return __generator(this, function (_a) {
|
|
318
|
+
switch (_a.label) {
|
|
319
|
+
case 0: return [4 /*yield*/, Promise.all(operators.map(function (o) { return __awaiter(_this, void 0, void 0, function () {
|
|
320
|
+
var singleResult, error_1;
|
|
321
|
+
return __generator(this, function (_a) {
|
|
322
|
+
switch (_a.label) {
|
|
323
|
+
case 0:
|
|
324
|
+
_a.trys.push([0, 2, , 3]);
|
|
325
|
+
return [4 /*yield*/, submitMSISDNOnce(window, config, internationalMSISDN, __assign(__assign({}, extraParams), { operator: o }))];
|
|
326
|
+
case 1:
|
|
327
|
+
singleResult = _a.sent();
|
|
328
|
+
return [2 /*return*/, right(__assign(__assign({}, singleResult), { operator: o }))];
|
|
329
|
+
case 2:
|
|
330
|
+
error_1 = _a.sent();
|
|
331
|
+
return [2 /*return*/, left(error_1)];
|
|
332
|
+
case 3: return [2 /*return*/];
|
|
333
|
+
}
|
|
334
|
+
});
|
|
335
|
+
}); }))];
|
|
336
|
+
case 1:
|
|
337
|
+
results = _a.sent();
|
|
338
|
+
alreadySubscribed = results.find(function (r) { var _a; return r.type === 'left' && ((_a = r.value) === null || _a === void 0 ? void 0 : _a.type) === 'AlreadySubscribed'; });
|
|
339
|
+
if (results.every(function (r) { return r.type === 'left'; })) {
|
|
340
|
+
// no submission worked
|
|
341
|
+
throw results[0].value;
|
|
342
|
+
}
|
|
343
|
+
else if (alreadySubscribed) {
|
|
344
|
+
throw alreadySubscribed.value;
|
|
345
|
+
}
|
|
346
|
+
else {
|
|
347
|
+
return [2 /*return*/, {
|
|
348
|
+
type: 'MultiOperatorMSISDNSubmissionResult'
|
|
349
|
+
}];
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
function submitPIN(window, pin, config, extraParams) {
|
|
356
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
357
|
+
var slug, country, device, offer, newExtraParams, searchObj, rockmanId, emptyPinError, uniqid, evinaTid, pinResult, pinErrorTypeMap, errorMessage, pinError, check, checkResult, isAlreadySubscribed, pinError, isAlreadySubscribed;
|
|
358
|
+
return __generator(this, function (_a) {
|
|
359
|
+
switch (_a.label) {
|
|
360
|
+
case 0:
|
|
361
|
+
if (window.hostCountry && window.hostSlug) {
|
|
362
|
+
config.country = window.hostCountry;
|
|
363
|
+
config.slug = window.hostSlug;
|
|
364
|
+
}
|
|
365
|
+
slug = config.slug, country = config.country, device = config.device;
|
|
366
|
+
offer = window.pac_analytics.visitor.offer;
|
|
367
|
+
newExtraParams = extraParams || {};
|
|
368
|
+
searchObj = searchToObject(window);
|
|
369
|
+
if ((searchObj === null || searchObj === void 0 ? void 0 : searchObj.success) === 'true' && searchObj['msisdn-alias'] === '1') {
|
|
370
|
+
newExtraParams['skip-validation'] = '1';
|
|
371
|
+
}
|
|
372
|
+
rockmanId = window.pac_analytics.visitor.rockmanId;
|
|
373
|
+
if (!pin) {
|
|
374
|
+
emptyPinError = new Error("Error in submitMSISDN() verify-pin action:\n Pin Cannot Be Empty");
|
|
375
|
+
emptyPinError.type = 'InvalidPIN';
|
|
376
|
+
throw emptyPinError;
|
|
377
|
+
}
|
|
378
|
+
uniqid = uniqidResult !== '' ? "&mcpUniqid=".concat(uniqidResult) : '';
|
|
379
|
+
evinaTid = typeof window !== 'undefined' && window.tid ? window.tid : '';
|
|
380
|
+
return [4 /*yield*/, verifyPin({
|
|
381
|
+
window: window,
|
|
382
|
+
country: country,
|
|
383
|
+
slug: slug,
|
|
384
|
+
device: device,
|
|
385
|
+
offer: offer,
|
|
386
|
+
rockmanId: rockmanId,
|
|
387
|
+
pin: pin,
|
|
388
|
+
extraParams: newExtraParams,
|
|
389
|
+
uniqid: uniqid,
|
|
390
|
+
evinaTid: evinaTid
|
|
391
|
+
})];
|
|
392
|
+
case 1:
|
|
393
|
+
pinResult = _a.sent();
|
|
394
|
+
if (!(pinResult.success === false)) return [3 /*break*/, 2];
|
|
395
|
+
pinErrorTypeMap = {
|
|
396
|
+
'pin does not match': 'InvalidPIN',
|
|
397
|
+
'mcp blocked': 'SessionBlocked'
|
|
398
|
+
};
|
|
399
|
+
errorMessage = pinErrorTypeMap[pinResult.message];
|
|
400
|
+
pinError = new Error("Error in submitMSISDN() verify-pin action:\n".concat(errorMessage));
|
|
401
|
+
pinError.type = errorMessage || 'InvalidPIN';
|
|
402
|
+
throw pinError;
|
|
403
|
+
case 2:
|
|
404
|
+
if (!(pinResult.async === true)) return [3 /*break*/, 4];
|
|
405
|
+
// Needed for ES https://www.notion.so/sammedia/ES-OnMobile-Movistar-Direct-Ouisys-Integration-XR-Academy-ca60b176b0ea40a7b170e5d9e7deb491
|
|
406
|
+
if (pinResult.product_url && pinResult.product_url !== '' && (country === null || country === void 0 ? void 0 : country.toLowerCase()) === 'es') {
|
|
407
|
+
return [2 /*return*/, { gatewayRedirectUrl: pinResult.product_url }];
|
|
408
|
+
}
|
|
409
|
+
check = function () {
|
|
410
|
+
return checkSubscription({ window: window, country: country, slug: slug, device: device, offer: offer, rockmanId: rockmanId, extraParams: extraParams });
|
|
411
|
+
};
|
|
412
|
+
return [4 /*yield*/, loop(check, 100, function (r) { return r.success; }, 0)];
|
|
413
|
+
case 3:
|
|
414
|
+
checkResult = _a.sent();
|
|
415
|
+
if (checkResult.success === true) {
|
|
416
|
+
isAlreadySubscribed = pinResult.message === 'ALREADY SUBSCRIBED';
|
|
417
|
+
return [2 /*return*/, { productUrl: checkResult.product_url || null, isAlreadySubscribed: isAlreadySubscribed }];
|
|
418
|
+
}
|
|
419
|
+
pinError = new Error("Error in submitMSISDN() verify-pin action:\n".concat(checkResult.message));
|
|
420
|
+
pinError.type = 'InvalidPIN';
|
|
421
|
+
throw pinError;
|
|
422
|
+
case 4:
|
|
423
|
+
isAlreadySubscribed = pinResult.message === 'ALREADY SUBSCRIBED';
|
|
424
|
+
return [2 /*return*/, { productUrl: pinResult.product_url || null, isAlreadySubscribed: isAlreadySubscribed }];
|
|
425
|
+
}
|
|
426
|
+
});
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
// Define the initial state
|
|
431
|
+
var initialState = {
|
|
432
|
+
currentState: {
|
|
433
|
+
type: 'MSISDNEntry',
|
|
434
|
+
result: NothingYet()
|
|
435
|
+
}
|
|
436
|
+
};
|
|
437
|
+
var submitMSISDNAction = createAsyncThunk('pinFlow/submitMSISDNAction', function (_a, _b) {
|
|
438
|
+
var window = _a.window, msisdn = _a.msisdn, extraParams = _a.extraParams;
|
|
439
|
+
var getState = _b.getState, dispatch = _b.dispatch, rejectWithValue = _b.rejectWithValue;
|
|
440
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
441
|
+
var state, _c, config, isHeaderEnrichmentSuccess, pinFlowCurrentState, prefix, msisdnSubmissionResult, operator, pinMaxLengthByOp, pinPageEvent, ex_1, errorType;
|
|
442
|
+
var _d;
|
|
443
|
+
return __generator(this, function (_e) {
|
|
444
|
+
switch (_e.label) {
|
|
445
|
+
case 0:
|
|
446
|
+
state = getState();
|
|
447
|
+
_c = state.strategy.currentState.data, config = _c.config, isHeaderEnrichmentSuccess = _c.isHeaderEnrichmentSuccess;
|
|
448
|
+
pinFlowCurrentState = (_d = state.pinFlow) === null || _d === void 0 ? void 0 : _d.currentState;
|
|
449
|
+
_e.label = 1;
|
|
450
|
+
case 1:
|
|
451
|
+
_e.trys.push([1, 5, , 6]);
|
|
452
|
+
/**
|
|
453
|
+
* Palestine calling code is +970
|
|
454
|
+
* But there was a request to have it as +972 only for gateway shemaroo
|
|
455
|
+
*/
|
|
456
|
+
// Start PS Calling code temp fix
|
|
457
|
+
if ((config === null || config === void 0 ? void 0 : config.country.toLowerCase()) === 'ps' && (config === null || config === void 0 ? void 0 : config.slug.includes('shemaroo'))) {
|
|
458
|
+
prefix = getInputValuePrefix(config === null || config === void 0 ? void 0 : config.country, msisdn);
|
|
459
|
+
if (prefix === '+970') {
|
|
460
|
+
msisdn = msisdn.replace('970', '972');
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
// END PS Calling code temp fix
|
|
464
|
+
// Start Trigger Pin
|
|
465
|
+
tracker.advancedInFlow('tallyman.v1-pin', 'msisdn-submitted', { msisdn: msisdn });
|
|
466
|
+
return [4 /*yield*/, submitMSISDN(window, config, msisdn)];
|
|
467
|
+
case 2:
|
|
468
|
+
msisdnSubmissionResult = _e.sent();
|
|
469
|
+
tracker.advancedInFlow('tallyman.v1-pin', 'msisdn-submission-success', { msisdn: msisdn });
|
|
470
|
+
// End Trigger Pin
|
|
471
|
+
/**
|
|
472
|
+
* Some flows require us to redirect to a url after trigger pin to check for fraud
|
|
473
|
+
* The url will then do some processing and return back to ouisys with
|
|
474
|
+
* extra param in the url that will tell us to show pin entry step or error
|
|
475
|
+
*/
|
|
476
|
+
// Start Pin Redirect
|
|
477
|
+
if (msisdnSubmissionResult.type === 'SingleMSISDNSubmissionResult' && msisdnSubmissionResult.redirectUrl) {
|
|
478
|
+
tracker.advancedInFlow('tallyman.v1-pin', 'msisdn-submission-success', { msisdn: msisdn });
|
|
479
|
+
tracker.customEvent('Flow', 'advance-auto', 'msisdn-redirect', {
|
|
480
|
+
redirectUrl: msisdnSubmissionResult.redirectUrl
|
|
481
|
+
});
|
|
482
|
+
window.location.href = msisdnSubmissionResult.redirectUrl;
|
|
483
|
+
}
|
|
484
|
+
if (!(extraParams && extraParams.storeMsisdn && extraParams.storeMsisdn === 'true')) return [3 /*break*/, 4];
|
|
485
|
+
return [4 /*yield*/, storeMsisdn(msisdn)
|
|
486
|
+
.then(function (data) {
|
|
487
|
+
if (data && data.data && data.data.success) {
|
|
488
|
+
tracker.customEvent('Flow', 'advance-auto', 'msisdn-stored-success');
|
|
489
|
+
}
|
|
490
|
+
else {
|
|
491
|
+
tracker.customEvent('Flow', 'advance-auto', 'msisdn-stored-failed');
|
|
492
|
+
}
|
|
493
|
+
})
|
|
494
|
+
.catch(function (error) {
|
|
495
|
+
tracker.customEvent('Flow', 'advance-auto', 'msisdn-stored-error', error);
|
|
496
|
+
})];
|
|
497
|
+
case 3:
|
|
498
|
+
_e.sent();
|
|
499
|
+
_e.label = 4;
|
|
500
|
+
case 4:
|
|
501
|
+
operator = msisdnSubmissionResult.type === 'SingleMSISDNSubmissionResult' ? msisdnSubmissionResult.operator : '';
|
|
502
|
+
pinMaxLengthByOp = {
|
|
503
|
+
SA_MOBILY: 6,
|
|
504
|
+
SA_STC: 4,
|
|
505
|
+
SA_ZAIN: 4
|
|
506
|
+
};
|
|
507
|
+
pinPageEvent = new Event('onPinPage');
|
|
508
|
+
window === null || window === void 0 ? void 0 : window.dispatchEvent(pinPageEvent);
|
|
509
|
+
return [2 /*return*/, __assign(__assign({}, pinFlowCurrentState), { type: 'PINEntry', result: NothingYet(), data: {
|
|
510
|
+
actualPIN: msisdnSubmissionResult.type === 'SingleMSISDNSubmissionResult' ? msisdnSubmissionResult.pin : null,
|
|
511
|
+
msisdn: msisdn,
|
|
512
|
+
operator: operator,
|
|
513
|
+
pinMaxLength: operator !== '' && pinMaxLengthByOp[operator] ? pinMaxLengthByOp[operator] : null,
|
|
514
|
+
isHeaderEnrichmentSuccess: isHeaderEnrichmentSuccess
|
|
515
|
+
} })];
|
|
516
|
+
case 5:
|
|
517
|
+
ex_1 = _e.sent();
|
|
518
|
+
console.warn(ex_1);
|
|
519
|
+
errorType = void 0;
|
|
520
|
+
switch (ex_1.type) {
|
|
521
|
+
case 'AlreadySubscribed':
|
|
522
|
+
errorType = 'AlreadySubscribed';
|
|
523
|
+
break;
|
|
524
|
+
case 'InvalidMSISDN':
|
|
525
|
+
errorType = 'InvalidMSISDN';
|
|
526
|
+
break;
|
|
527
|
+
default:
|
|
528
|
+
errorType = 'UnknownError';
|
|
529
|
+
}
|
|
530
|
+
tracker.recedeInFlow('tallyman.v1-pin', 'msisdn-submission-failure', {
|
|
531
|
+
msisdn: msisdn,
|
|
532
|
+
errorType: errorType,
|
|
533
|
+
error: ex_1.toString()
|
|
534
|
+
});
|
|
535
|
+
if (isHeaderEnrichmentSuccess) {
|
|
536
|
+
dispatch(setStrategyExtraData({
|
|
537
|
+
type: PossibleTypes.PIN,
|
|
538
|
+
data: {
|
|
539
|
+
isHeaderEnrichmentSuccess: isHeaderEnrichmentSuccess
|
|
540
|
+
}
|
|
541
|
+
}));
|
|
542
|
+
}
|
|
543
|
+
return [2 /*return*/, rejectWithValue({
|
|
544
|
+
errorType: errorType,
|
|
545
|
+
error: ex_1.toString(),
|
|
546
|
+
productUrl: ex_1.productUrl
|
|
547
|
+
})];
|
|
548
|
+
case 6: return [2 /*return*/];
|
|
549
|
+
}
|
|
550
|
+
});
|
|
551
|
+
});
|
|
552
|
+
});
|
|
553
|
+
var submitPinAction = createAsyncThunk('pinFlow/submitPinAction', function (_a, _b) {
|
|
554
|
+
var window = _a.window, msisdn = _a.msisdn, pin = _a.pin, extraParams = _a.extraParams;
|
|
555
|
+
var getState = _b.getState, rejectWithValue = _b.rejectWithValue;
|
|
556
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
557
|
+
var state, config, pinFlowCurrentState, result, ex_2, errorType;
|
|
558
|
+
var _c;
|
|
559
|
+
return __generator(this, function (_d) {
|
|
560
|
+
switch (_d.label) {
|
|
561
|
+
case 0:
|
|
562
|
+
state = getState();
|
|
563
|
+
config = state.strategy.currentState.data.config;
|
|
564
|
+
pinFlowCurrentState = (_c = state.pinFlow) === null || _c === void 0 ? void 0 : _c.currentState;
|
|
565
|
+
_d.label = 1;
|
|
566
|
+
case 1:
|
|
567
|
+
_d.trys.push([1, 5, , 6]);
|
|
568
|
+
tracker.advancedInFlow('tallyman.v1-pin', 'pin-submitted', { msisdn: msisdn, pin: pin });
|
|
569
|
+
return [4 /*yield*/, submitPIN(window, pin, config, extraParams)];
|
|
570
|
+
case 2:
|
|
571
|
+
result = _d.sent();
|
|
572
|
+
tracker.advancedInFlow('tallyman.v1-pin', 'pin-submission-success', {
|
|
573
|
+
msisdn: msisdn,
|
|
574
|
+
pin: pin,
|
|
575
|
+
finalUrl: result.productUrl
|
|
576
|
+
});
|
|
577
|
+
/**
|
|
578
|
+
* Gateway redirect
|
|
579
|
+
* Value returned in this case is actually the gateway url instead of the product url
|
|
580
|
+
* More details on this ticket:
|
|
581
|
+
* https://www.notion.so/sammedia/ES-OnMobile-Movistar-Direct-Ouisys-Integration-XR-Academy-ca60b176b0ea40a7b170e5d9e7deb491
|
|
582
|
+
*/
|
|
583
|
+
// Start Gateway redirect
|
|
584
|
+
if (result.gatewayRedirectUrl && result.gatewayRedirectUrl !== '') {
|
|
585
|
+
tracker.advancedInFlow('tallyman.v1-pin', 'gateway-redirect', {
|
|
586
|
+
msisdn: msisdn,
|
|
587
|
+
pin: pin,
|
|
588
|
+
gatewayRedirectUrl: result.gatewayRedirectUrl
|
|
589
|
+
});
|
|
590
|
+
window.location.href = result.gatewayRedirectUrl;
|
|
591
|
+
}
|
|
592
|
+
if (!(extraParams && extraParams.storeMsisdn && extraParams.storeMsisdn === 'true')) return [3 /*break*/, 4];
|
|
593
|
+
return [4 /*yield*/, storeMsisdn(msisdn)
|
|
594
|
+
.then(function (data) {
|
|
595
|
+
if (data && data.data && data.data.success) {
|
|
596
|
+
tracker.customEvent('Flow', 'advance-auto', 'msisdn-stored-success');
|
|
597
|
+
}
|
|
598
|
+
else {
|
|
599
|
+
tracker.customEvent('Flow', 'advance-auto', 'msisdn-stored-failed');
|
|
600
|
+
}
|
|
601
|
+
})
|
|
602
|
+
.catch(function (error) {
|
|
603
|
+
tracker.customEvent('Flow', 'advance-auto', 'msisdn-stored-error', error);
|
|
604
|
+
})];
|
|
605
|
+
case 3:
|
|
606
|
+
_d.sent();
|
|
607
|
+
_d.label = 4;
|
|
608
|
+
case 4:
|
|
609
|
+
// End store msisdn
|
|
610
|
+
return [2 /*return*/, __assign(__assign({}, pinFlowCurrentState), { type: 'PINEntry', result: Success({
|
|
611
|
+
finalUrl: result.productUrl,
|
|
612
|
+
isAlreadySubscribed: result.isAlreadySubscribed || false
|
|
613
|
+
}) })];
|
|
614
|
+
case 5:
|
|
615
|
+
ex_2 = _d.sent();
|
|
616
|
+
console.warn(ex_2);
|
|
617
|
+
errorType = void 0;
|
|
618
|
+
switch (ex_2.type) {
|
|
619
|
+
case 'AlreadySubscribed':
|
|
620
|
+
errorType = 'AlreadySubscribed';
|
|
621
|
+
break;
|
|
622
|
+
case 'InvalidPIN':
|
|
623
|
+
errorType = 'InvalidPIN';
|
|
624
|
+
break;
|
|
625
|
+
case 'SessionBlocked':
|
|
626
|
+
errorType = 'SessionBlocked';
|
|
627
|
+
break;
|
|
628
|
+
default:
|
|
629
|
+
errorType = 'UnknownError';
|
|
630
|
+
}
|
|
631
|
+
tracker.recedeInFlow('tallyman.v1-pin', 'pin-submission-failure', {
|
|
632
|
+
msisdn: msisdn,
|
|
633
|
+
pin: pin,
|
|
634
|
+
error: ex_2.toString(),
|
|
635
|
+
errorType: errorType
|
|
636
|
+
});
|
|
637
|
+
// Redirect to the product url if returned in the exception
|
|
638
|
+
setTimeout(function () {
|
|
639
|
+
if (ex_2.productUrl) {
|
|
640
|
+
window.location.href = ex_2.productUrl;
|
|
641
|
+
}
|
|
642
|
+
}, 0);
|
|
643
|
+
return [2 /*return*/, rejectWithValue({
|
|
644
|
+
errorType: errorType,
|
|
645
|
+
productUrl: ex_2.productUrl
|
|
646
|
+
})];
|
|
647
|
+
case 6: return [2 /*return*/];
|
|
648
|
+
}
|
|
649
|
+
});
|
|
650
|
+
});
|
|
651
|
+
});
|
|
652
|
+
var getInputValuePrefix = function (country, international) {
|
|
653
|
+
// @ts-ignore
|
|
654
|
+
var pn = new PhoneNumber(international, country.toUpperCase());
|
|
655
|
+
return country && international ? "+".concat(pn.getCountryCode()) : '';
|
|
656
|
+
};
|
|
657
|
+
// Define your slice
|
|
658
|
+
var pinFlowSlice = createSlice({
|
|
659
|
+
name: 'pinFlow',
|
|
660
|
+
initialState: initialState,
|
|
661
|
+
reducers: {
|
|
662
|
+
backToStartAction: function (state) {
|
|
663
|
+
tracker.recedeInFlow('tallyman.v1-pin', 'pin-state', 'requested to change phone number');
|
|
664
|
+
// TODO GO BACK TO IDENTIFY BY MSISDN BASED ON STRATEGY
|
|
665
|
+
state.currentState = { type: 'MSISDNEntry', result: NothingYet() };
|
|
666
|
+
}
|
|
667
|
+
},
|
|
668
|
+
extraReducers: function (builder) {
|
|
669
|
+
builder
|
|
670
|
+
.addCase(submitMSISDNAction.pending, function (state) {
|
|
671
|
+
state.currentState = { type: 'MSISDNEntry', result: Loading() };
|
|
672
|
+
})
|
|
673
|
+
.addCase(submitMSISDNAction.fulfilled, function (state, action) {
|
|
674
|
+
state.currentState = action.payload;
|
|
675
|
+
})
|
|
676
|
+
.addCase(submitMSISDNAction.rejected, function (state, action) {
|
|
677
|
+
state.currentState = {
|
|
678
|
+
type: 'MSISDNEntry',
|
|
679
|
+
result: Failure(action.payload)
|
|
680
|
+
};
|
|
681
|
+
})
|
|
682
|
+
.addCase(submitPinAction.pending, function (state) {
|
|
683
|
+
state.currentState = { type: 'PINEntry', result: Loading() };
|
|
684
|
+
})
|
|
685
|
+
.addCase(submitPinAction.fulfilled, function (state, action) {
|
|
686
|
+
state.currentState = action.payload;
|
|
687
|
+
})
|
|
688
|
+
.addCase(submitPinAction.rejected, function (state, action) {
|
|
689
|
+
state.currentState = { type: 'PINEntry', result: Failure(action.payload) };
|
|
690
|
+
});
|
|
691
|
+
}
|
|
692
|
+
});
|
|
693
|
+
var pinFlowReducer = pinFlowSlice.reducer, pinFlowActions = pinFlowSlice.actions;
|
|
694
|
+
var backToStartAction = pinFlowActions.backToStartAction;
|
|
695
|
+
|
|
696
|
+
export { backToStartAction, pinFlowMatch, pinFlowReducer, submitMSISDNAction, submitPinAction, usePinFlowState };
|
|
697
|
+
//# sourceMappingURL=pinFlow.js.map
|