ouisys-engine 4.7.0-alpha.1 → 4.7.0-alpha.11
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-lcf8PfJd.js +2 -0
- package/dist/{RemoteDataState-CwHLI23e.js.map → RemoteDataState-lcf8PfJd.js.map} +1 -1
- package/dist/bupperizeCountry-CEtt0MKz.js +2 -0
- package/dist/bupperizeCountry-CEtt0MKz.js.map +1 -0
- package/dist/checkSubscriptionByRockmanIdOnly-BwR1un1L.js +2 -0
- package/dist/{checkSubscriptionByRockmanIdOnly-C89Ph9cV.js.map → checkSubscriptionByRockmanIdOnly-BwR1un1L.js.map} +1 -1
- package/dist/checkSubscriptionHander.js +1 -52
- package/dist/checkSubscriptionHander.js.map +1 -1
- package/dist/click2smsFlow.js +1 -245
- package/dist/click2smsFlow.js.map +1 -1
- package/dist/creditCardFlow.js +1 -247
- package/dist/creditCardFlow.js.map +1 -1
- package/dist/getConfig.js +1 -13
- package/dist/getConfig.js.map +1 -1
- package/dist/handleClickChainFlow.js +1 -31
- package/dist/handleClickChainFlow.js.map +1 -1
- package/dist/handleSubmitNumber.js +1 -64
- package/dist/handleSubmitNumber.js.map +1 -1
- package/dist/helpers-xPhGBX-B.js +2 -0
- package/dist/helpers-xPhGBX-B.js.map +1 -0
- package/dist/loadScriptInnerHtml-BzQm-AFb.js +2 -0
- package/dist/loadScriptInnerHtml-BzQm-AFb.js.map +1 -0
- package/dist/loadScriptSrc-Da4autZd.js +2 -0
- package/dist/loadScriptSrc-Da4autZd.js.map +1 -0
- package/dist/moFlow.js +1 -274
- package/dist/moFlow.js.map +1 -1
- package/dist/moRedirFlow.js +1 -224
- package/dist/moRedirFlow.js.map +1 -1
- package/dist/oneClickFlow.js +1 -463
- package/dist/oneClickFlow.js.map +1 -1
- package/dist/pinFlow.js +1 -696
- package/dist/pinFlow.js.map +1 -1
- package/dist/searchToObject.js +1 -18
- package/dist/searchToObject.js.map +1 -1
- package/dist/storeMsisdn-Cjq8_qYH.js +2 -0
- package/dist/{storeMsisdn-ChiBh8mI.js.map → storeMsisdn-Cjq8_qYH.js.map} +1 -1
- package/dist/strategy.js +1 -49
- package/dist/strategy.js.map +1 -1
- package/dist/strategySlice-Dw14E22-.js +2 -0
- package/dist/strategySlice-Dw14E22-.js.map +1 -0
- package/dist/tracker-DaaILhEr.js +2 -0
- package/dist/tracker-DaaILhEr.js.map +1 -0
- package/dist/tracker.js +1 -4
- package/dist/tracker.js.map +1 -1
- package/dist/tryGetIPRangeName-QW-9NgzE.js +2 -0
- package/dist/tryGetIPRangeName-QW-9NgzE.js.map +1 -0
- package/dist/types/{OneClickTypes-DF0jodl-.d.ts → OneClickTypes-DjOesaHp.d.ts} +1 -1
- package/dist/types/{StrategyTypes-BEIYqoJV.d.ts → StrategyTypes-CbOgk0N4.d.ts} +3 -2
- package/dist/types/click2smsFlow.d.ts +3 -3
- package/dist/types/handleSubmitNumber.d.ts +3 -3
- package/dist/types/oneClickFlow.d.ts +2 -2
- package/dist/types/strategy.d.ts +12 -4
- package/dist/ussdFlow.js +1 -210
- package/dist/ussdFlow.js.map +1 -1
- package/package.json +6 -6
- package/dist/RemoteDataState-CwHLI23e.js +0 -75
- package/dist/bupperizeCountry-CCDIOHP6.js +0 -4
- package/dist/bupperizeCountry-CCDIOHP6.js.map +0 -1
- package/dist/checkSubscriptionByRockmanIdOnly-C89Ph9cV.js +0 -27
- package/dist/helpers-J_h-ZgxH.js +0 -29
- package/dist/helpers-J_h-ZgxH.js.map +0 -1
- package/dist/loadScriptInnerHtml-DPcoY467.js +0 -26
- package/dist/loadScriptInnerHtml-DPcoY467.js.map +0 -1
- package/dist/storeMsisdn-ChiBh8mI.js +0 -58
- package/dist/strategySlice-bF74rxDK.js +0 -842
- package/dist/strategySlice-bF74rxDK.js.map +0 -1
- package/dist/tracker-B_zsMRN2.js +0 -79
- package/dist/tracker-B_zsMRN2.js.map +0 -1
- package/dist/tryGetIPRangeName-C69HEG5W.js +0 -42
- package/dist/tryGetIPRangeName-C69HEG5W.js.map +0 -1
package/dist/pinFlow.js
CHANGED
|
@@ -1,697 +1,2 @@
|
|
|
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 };
|
|
1
|
+
import{__awaiter as t,__generator as r,__read as e,__assign as n}from"tslib";import{createAsyncThunk as i,createSlice as a}from"@reduxjs/toolkit";import{N as o,S as c,L as s,F as u}from"./RemoteDataState-lcf8PfJd.js";import{c as d,P as l}from"./strategySlice-Dw14E22-.js";import{searchToObject as p}from"./searchToObject.js";import{s as v}from"./storeMsisdn-Cjq8_qYH.js";import{t as f}from"./tracker-DaaILhEr.js";import{b as m}from"./bupperizeCountry-CEtt0MKz.js";import{l as y,r as S,a as w}from"./helpers-xPhGBX-B.js";import{l as h}from"./loadScriptInnerHtml-BzQm-AFb.js";import"./getConfig.js";import"./tryGetIPRangeName-QW-9NgzE.js";import"./loadScriptSrc-Da4autZd.js";import"pacman-client";import"uuid";var I=function(t){return t((function(t){return t.pinFlow.currentState}))};function g(t){var r=t.msisdnEntry,e=t.pinEntry;return function(t){switch(t.type){case"MSISDNEntry":return r(t.result);case"PINEntry":return e(t.result,t.data);default:throw new Error("Invalid State")}}}var b=function(t){return"be"===t?"undefined"!=typeof window&&!0===window.shouldBlock?"&is-clean-traffic=false":"&is-clean-traffic=true":""},_=function(n){var i=n.window,a=n.country,o=n.slug,c=n.device,s=n.offer,u=n.msisdn,d=n.rockmanId,l=n.extraParams,p=n.search,v=n.uniqid,f=n.evinaTid;return t(void 0,void 0,void 0,(function(){var t,n,m,y,S,w,h;return r(this,(function(r){return t=b(a),n="&".concat(Object.keys(l).map((function(t){return"".concat(t,"=").concat(l[t])})).join("&")),m={action:"trigger-pin",country:a,slug:o,device:c,offerId:s,msisdn:u,rockman_id:d,sam_evina_tid:f,page:encodeURIComponent(null===(h=null==i?void 0:i.location)||void 0===h?void 0:h.href),language_code:i.languageCode||"",antifraud_id:i.antifraud_id||"",partner_transaction_id:i.partner_transaction_id||"",partner_timestamp:i.partner_timestamp||"",partner_cid:i.partner_cid||"",uniqid:v||""},y=Object.entries(m).filter((function(t){var r=e(t,2);return r[0],r[1]})).map((function(t){var r=e(t,2),n=r[0],i=r[1];return"".concat(n,"=").concat(i)})).join("&"),S=i.DEV_BASE_URL||"",w="".concat(S,"/tallyman/v1/?").concat(y).concat(t).concat(n,"&").concat(p),[2,fetch(w).then((function(t){return t.json()}))]}))}))},E=function(n){var i=n.window,a=n.country,o=n.slug,c=n.device,s=n.offer,u=n.rockmanId,d=n.pin,l=n.extraParams,p=n.uniqid,v=n.evinaTid;return t(void 0,void 0,void 0,(function(){var t,n,f,y,S,w,h;return r(this,(function(r){return t=b(a),n="&".concat(Object.keys(l).map((function(t){return"".concat(t,"=").concat(l[t])})).join("&")),f={action:"verify-pin",country:m(a),slug:o,device:c,offerId:s,rockman_id:u,pin:d,page:encodeURIComponent(null===(h=null==i?void 0:i.location)||void 0===h?void 0:h.href),language_code:i.languageCode||"",antifraud_id:i.antifraud_id||"",ClickID:i.antifraud_click_id||"",partner_cid:i.partner_cid||"",sam_evina_tid:v,uniqid:p},y=Object.entries(f).filter((function(t){var r=e(t,2);return r[0],r[1]})).map((function(t){var r=e(t,2),n=r[0],i=r[1];return"".concat(n,"=").concat(i)})).join("&"),S=i.DEV_BASE_URL||"",w="".concat(S,"/tallyman/v1/?").concat(y).concat(t).concat(n),[2,fetch(w).then((function(t){return t.json()}))]}))}))},k=function(e){var i=e.window,a=e.country,o=e.slug,c=e.device,s=e.offer,u=e.rockmanId,d=e.operator,l=e.uniqid;return t(void 0,void 0,void 0,(function(){var t,e,p,v,f;return r(this,(function(r){return t=i.location.href,e=i.pac_analytics.visitor.ip,p=new URLSearchParams(n(n({action:"mcp-shield",country:a,slug:o,device:c,offerId:s.toString(),rockman_id:u,client_lpu:t},d&&{operator:d}),l&&{uniqid:l})),e&&p.append("client_ip",e),v=i.DEV_BASE_URL||"",f="".concat(v,"/tallyman/v1/?").concat(p.toString()),[2,fetch(f).then((function(t){return t.json()}))]}))}))};function N(e,i,a,o){return t(this,void 0,void 0,(function(){var t;return r(this,(function(r){return!0===(t=n({offer:e.pac_analytics.visitor.offer},i||{})).automaticallySubmitAllOperators&&t.operators&&t.operators.length>0?[2,M(e,t,a,t.operators,o)]:[2,D(e,t,a,o)]}))}))}var U="";function D(e,n,i,a){return t(this,void 0,void 0,(function(){var t,o,c,s,u,d,l,v,f,m,y,S,w,I,g,b,E,N;return r(this,(function(r){switch(r.label){case 0:if(!i)throw(t=new Error("Error in submitMSISDN() trigger-pin action")).type="InvalidMSISDN",t;return o=a||{},c=!1,"true"===(null==(s=p(e))?void 0:s.success)&&"1"===s["msisdn-alias"]&&(o["skip-validation"]="1"),"1"===o["skip-validation"]&&(c=!0),u=c?i:i.match(/\d+/gi).join(""),d=e.pac_analytics.visitor.rockmanId,l=n.slug,v=n.country,f=n.device,m=n.offer,y=-1===e.location.search.indexOf("redirect-back=1")&&e.location.search.substr(1)||"",S=U&&""!==U?"&mcpUniqid=".concat(U):"",w=void 0!==e&&e.tid?e.tid:"",[4,_({window:e,country:v,slug:l,device:f,offer:m,msisdn:u,rockmanId:d,extraParams:o,search:y,uniqid:S,evinaTid:w})];case 1:if(!1!==(I=r.sent()).success)return[3,2];switch(g=new Error("Error in submitMSISDN() trigger-pin action:\n".concat(I.message)),I.message){case"ALREADY SUBSCRIBED":g.type="AlreadySubscribed";break;case"INVALID MSISDN":g.type="InvalidMSISDN";break;default:g.type=null}throw g.productUrl=I.product_url?I.product_url:"",console.error(g),g;case 2:if(e.operator=I.operator,b={kw:{kw_viva:"kw_viva"},k2:{k2_viva:"k2_viva"},bh:{bh_viva:"bh_viva"}},!(v&&I.operator&&(b[v.toLowerCase()]&&b[v.toLowerCase()][I.operator.toLowerCase()]||"iq"===v.toLowerCase()))||e.isCallBlockApi||e.Empello)return[3,6];r.label=3;case 3:return r.trys.push([3,5,,6]),[4,k({window:e,country:v,slug:l,device:f,offer:m,rockmanId:d,operator:I.operator,uniqid:S})];case 4:return!1===(E=r.sent()).success?console.warn(E.message):(h(E.source),U=E.uniqid),[3,6];case 5:return N=r.sent(),console.warn(N),[3,6];case 6:return I.javascript&&h(I.javascript),[2,{type:"SingleMSISDNSubmissionResult",pin:I.pin,uniqidResult:U,operator:I.operator,redirectUrl:null==I?void 0:I.redirect_to_url}]}}))}))}function M(e,i,a,o,c){return t(this,void 0,void 0,(function(){var s,u,d=this;return r(this,(function(l){switch(l.label){case 0:return[4,Promise.all(o.map((function(o){return t(d,void 0,void 0,(function(){var t,s;return r(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,D(e,i,a,n(n({},c),{operator:o}))];case 1:return t=r.sent(),[2,S(n(n({},t),{operator:o}))];case 2:return s=r.sent(),[2,y(s)];case 3:return[2]}}))}))})))];case 1:if(s=l.sent(),u=s.find((function(t){var r;return"left"===t.type&&"AlreadySubscribed"===(null===(r=t.value)||void 0===r?void 0:r.type)})),s.every((function(t){return"left"===t.type})))throw s[0].value;if(u)throw u.value;return[2,{type:"MultiOperatorMSISDNSubmissionResult"}]}}))}))}function P(n,i,a,o){return t(this,void 0,void 0,(function(){var c,s,u,d,l,v,f,y,S,h,I,g,b,_,k,N;return r(this,(function(D){switch(D.label){case 0:if(n.hostCountry&&n.hostSlug&&(a.country=n.hostCountry,a.slug=n.hostSlug),c=a.slug,s=a.country,u=a.device,d=n.pac_analytics.visitor.offer,l=o||{},"true"===(null==(v=p(n))?void 0:v.success)&&"1"===v["msisdn-alias"]&&(l["skip-validation"]="1"),f=n.pac_analytics.visitor.rockmanId,!i)throw(y=new Error("Error in submitMSISDN() verify-pin action:\n Pin Cannot Be Empty")).type="InvalidPIN",y;return S=""!==U?"&mcpUniqid=".concat(U):"",h=void 0!==n&&n.tid?n.tid:"",[4,E({window:n,country:s,slug:c,device:u,offer:d,rockmanId:f,pin:i,extraParams:l,uniqid:S,evinaTid:h})];case 1:if(!1!==(I=D.sent()).success)return[3,2];throw g={"pin does not match":"InvalidPIN","mcp blocked":"SessionBlocked"}[I.message],(k=new Error("Error in submitMSISDN() verify-pin action:\n".concat(g))).type=g||"InvalidPIN",k;case 2:return!0!==I.async?[3,4]:I.product_url&&""!==I.product_url&&"es"===(null==s?void 0:s.toLowerCase())?[2,{gatewayRedirectUrl:I.product_url}]:(b=function(){return function(n){var i=n.window,a=n.country,o=n.slug,c=n.device,s=n.offer,u=n.rockmanId;return t(void 0,void 0,void 0,(function(){var t,n,d,l;return r(this,(function(r){return t={action:"check-subscription",country:m(a),slug:o,device:c,offerId:s,rockman_id:u},n=Object.entries(t).filter((function(t){var r=e(t,2);return r[0],null!=r[1]})).map((function(t){var r=e(t,2),n=r[0],i=r[1];return"".concat(n,"=").concat(encodeURIComponent(i))})).join("&"),d=i.DEV_BASE_URL||"",l="".concat(d,"/tallyman/v1/?").concat(n),[2,fetch(l).then((function(t){return t.json()}))]}))}))}({window:n,country:s,slug:c,device:u,offer:d,rockmanId:f,extraParams:o})},[4,w(b,100,(function(t){return t.success}),0)]);case 3:if(!0===(_=D.sent()).success)return N="ALREADY SUBSCRIBED"===I.message,[2,{productUrl:_.product_url||null,isAlreadySubscribed:N}];throw(k=new Error("Error in submitMSISDN() verify-pin action:\n".concat(_.message))).type="InvalidPIN",k;case 4:return N="ALREADY SUBSCRIBED"===I.message,[2,{productUrl:I.product_url||null,isAlreadySubscribed:N}]}}))}))}var j={currentState:{type:"PINEntry",result:o(),data:{actualPIN:"",msisdn:"",operator:"",pinMaxLength:4}}},A={currentState:{type:"PINEntry",result:c({finalUrl:"/product"}),data:{actualPIN:"",msisdn:"",operator:"",pinMaxLength:4}}},C={currentState:{type:"MSISDNEntry",result:u({errorType:"InvalidMSISDN",error:"Invalid Mobile Number"})}},R={currentState:{type:"MSISDNEntry",result:o()}},F=function(t){var r=p(t),e=new Event("onPinPage");if(!r["mock-flow"])return R;switch(r["current-state"]){case"msisdn-failure-state":return C;case"pin-state":return null==t||t.dispatchEvent(e),j;case"completed-state":return A;default:return console.error("Mock Flow not supported"),R}}(window),L=i("pinFlow/submitMSISDNAction",(function(e,i){var a=e.window,c=e.msisdn,s=e.extraParams,u=i.getState,p=i.dispatch,m=i.rejectWithValue;return t(void 0,void 0,void 0,(function(){var t,e,i,y,S,w,h,I,g,b,_,E,k,U,D;return r(this,(function(r){switch(r.label){case 0:if(t=u(),!(null===(U=null===(k=null===(E=null==t?void 0:t.strategy)||void 0===E?void 0:E.currentState)||void 0===k?void 0:k.data)||void 0===U?void 0:U.config))return[2,m({errorType:"UnexpectedState"})];e=t.strategy.currentState.data,i=e.config,y=e.isHeaderEnrichmentSuccess,S=null===(D=t.pinFlow)||void 0===D?void 0:D.currentState,r.label=1;case 1:return r.trys.push([1,5,,6]),"ps"===(null==i?void 0:i.country.toLowerCase())&&(null==i?void 0:i.slug.includes("shemaroo"))&&"+970"===T(null==i?void 0:i.country,c)&&(c=c.replace("970","972")),f.advancedInFlow("tallyman.v1-pin","msisdn-submitted",{msisdn:c}),[4,N(a,i,c)];case 2:return w=r.sent(),f.advancedInFlow("tallyman.v1-pin","msisdn-submission-success",{msisdn:c}),"SingleMSISDNSubmissionResult"===w.type&&w.redirectUrl&&(f.advancedInFlow("tallyman.v1-pin","msisdn-submission-success",{msisdn:c}),f.customEvent("Flow","advance-auto","msisdn-redirect",{redirectUrl:w.redirectUrl}),a.location.href=w.redirectUrl),s&&s.storeMsisdn&&"true"===s.storeMsisdn?[4,v(c).then((function(t){t&&t.data&&t.data.success?f.customEvent("Flow","advance-auto","msisdn-stored-success"):f.customEvent("Flow","advance-auto","msisdn-stored-failed")})).catch((function(t){f.customEvent("Flow","advance-auto","msisdn-stored-error",t)}))]:[3,4];case 3:r.sent(),r.label=4;case 4:return h="SingleMSISDNSubmissionResult"===w.type?w.operator:"",I={SA_MOBILY:6,SA_STC:4,SA_ZAIN:4},g=new Event("onPinPage"),null==a||a.dispatchEvent(g),[2,n(n({},S),{type:"PINEntry",result:o(),data:{actualPIN:"SingleMSISDNSubmissionResult"===w.type?w.pin:null,msisdn:c,operator:h,pinMaxLength:""!==h&&I[h]?I[h]:null,isHeaderEnrichmentSuccess:y}})];case 5:switch(b=r.sent(),console.warn(b),_=void 0,b.type){case"AlreadySubscribed":_="AlreadySubscribed";break;case"InvalidMSISDN":_="InvalidMSISDN";break;default:_="UnknownError"}return f.recedeInFlow("tallyman.v1-pin","msisdn-submission-failure",{msisdn:c,errorType:_,error:b.toString()}),y&&p(d({type:l.PIN,data:{isHeaderEnrichmentSuccess:y}})),[2,m({errorType:_,error:b.toString(),productUrl:b.productUrl})];case 6:return[2]}}))}))})),B=i("pinFlow/submitPinAction",(function(e,i){var a=e.window,o=e.msisdn,s=e.pin,u=e.extraParams,d=i.getState,l=i.rejectWithValue;return t(void 0,void 0,void 0,(function(){var t,e,i,p,m,y,S,w,h,I;return r(this,(function(r){switch(r.label){case 0:if(t=d(),!(null===(h=null===(w=null===(S=null==t?void 0:t.strategy)||void 0===S?void 0:S.currentState)||void 0===w?void 0:w.data)||void 0===h?void 0:h.config))return[2,l({errorType:"UnexpectedState"})];e=t.strategy.currentState.data.config,i=null===(I=t.pinFlow)||void 0===I?void 0:I.currentState,r.label=1;case 1:return r.trys.push([1,5,,6]),f.advancedInFlow("tallyman.v1-pin","pin-submitted",{msisdn:o,pin:s}),[4,P(a,s,e,u)];case 2:return p=r.sent(),f.advancedInFlow("tallyman.v1-pin","pin-submission-success",{msisdn:o,pin:s,finalUrl:p.productUrl}),p.gatewayRedirectUrl&&""!==p.gatewayRedirectUrl&&(f.advancedInFlow("tallyman.v1-pin","gateway-redirect",{msisdn:o,pin:s,gatewayRedirectUrl:p.gatewayRedirectUrl}),a.location.href=p.gatewayRedirectUrl),u&&u.storeMsisdn&&"true"===u.storeMsisdn?[4,v(o).then((function(t){t&&t.data&&t.data.success?f.customEvent("Flow","advance-auto","msisdn-stored-success"):f.customEvent("Flow","advance-auto","msisdn-stored-failed")})).catch((function(t){f.customEvent("Flow","advance-auto","msisdn-stored-error",t)}))]:[3,4];case 3:r.sent(),r.label=4;case 4:return[2,n(n({},i),{type:"PINEntry",result:c({finalUrl:p.productUrl,isAlreadySubscribed:p.isAlreadySubscribed||!1})})];case 5:switch(m=r.sent(),console.warn(m),y=void 0,m.type){case"AlreadySubscribed":y="AlreadySubscribed";break;case"InvalidPIN":y="InvalidPIN";break;case"SessionBlocked":y="SessionBlocked";break;default:y="UnknownError"}return f.recedeInFlow("tallyman.v1-pin","pin-submission-failure",{msisdn:o,pin:s,error:m.toString(),errorType:y}),setTimeout((function(){m.productUrl&&(a.location.href=m.productUrl)}),0),[2,l({errorType:y,productUrl:m.productUrl})];case 6:return[2]}}))}))})),x={PS:"970"},T=function(t,r){if(!t||!r)return"";var e=t.toUpperCase(),n=x[e];return n?"+".concat(n):(console.error("Country code not found for",t),"")},q=a({name:"pinFlow",initialState:F,reducers:{backToStartAction:function(t){f.recedeInFlow("tallyman.v1-pin","pin-state","requested to change phone number"),t.currentState={type:"MSISDNEntry",result:o()}}},extraReducers:function(t){t.addCase(L.pending,(function(t){t.currentState={type:"MSISDNEntry",result:s(),data:t.currentState.data}})).addCase(L.fulfilled,(function(t,r){t.currentState=r.payload})).addCase(L.rejected,(function(t,r){t.currentState={type:"MSISDNEntry",result:u(r.payload),data:t.currentState.data}})).addCase(B.pending,(function(t){t.currentState={type:"PINEntry",result:s(),data:t.currentState.data}})).addCase(B.fulfilled,(function(t,r){t.currentState=r.payload})).addCase(B.rejected,(function(t,r){t.currentState={type:"PINEntry",result:u(r.payload),data:t.currentState.data}}))}}),O=q.reducer,V=q.actions.backToStartAction;export{V as backToStartAction,g as pinFlowMatch,O as pinFlowReducer,L as submitMSISDNAction,B as submitPinAction,I as usePinFlowState};
|
|
697
2
|
//# sourceMappingURL=pinFlow.js.map
|