ouisys-engine 2.1.25 → 2.1.29
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/reducers/oneClickFlow/index.d.ts +5 -1
- package/dist/reducers/oneClickFlow/index.js +10 -5
- package/dist/reducers/oneClickFlow/utils.js +46 -18
- package/dist/reducers/pinFlow/utils.js +25 -25
- package/dist/utilities/loadScriptInnerHtml.d.ts +2 -0
- package/dist/utilities/loadScriptInnerHtml.js +18 -0
- package/package.json +1 -1
- package/src/reducers/oneClickFlow/index.ts +1 -1
- package/src/reducers/oneClickFlow/utils.ts +76 -10
- package/src/reducers/pinFlow/utils.ts +8 -10
- package/src/utilities/loadScriptInnerHtml.ts +10 -0
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { IOneClickFlowReducerState, IOneClickActions, IOneClickFlowActionMaps, ILinkExtraParams, IMockOneClickFlowStates } from "./OneClickTypes";
|
|
2
2
|
import { AppThunk } from "../../common-types/AppThunk";
|
|
3
3
|
import { IHash } from "../strategy/StrategyTypes";
|
|
4
|
-
export declare function getRedirectUrlAction(extraParams
|
|
4
|
+
export declare function getRedirectUrlAction({ extraParams, autoRedirect, isGetRedirectBupperWay }: {
|
|
5
|
+
extraParams?: ILinkExtraParams;
|
|
6
|
+
autoRedirect?: boolean;
|
|
7
|
+
isGetRedirectBupperWay?: boolean;
|
|
8
|
+
}): AppThunk;
|
|
5
9
|
export declare function subscribeUrlAction(autoRedirect?: boolean, extraParams?: IHash): AppThunk;
|
|
6
10
|
export declare function mockOneClickFlow(mockState: IMockOneClickFlowStates): AppThunk;
|
|
7
11
|
export declare const OneClickFlowActionMaps: IOneClickFlowActionMaps;
|
|
@@ -64,9 +64,14 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
|
|
|
64
64
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
65
65
|
|
|
66
66
|
//ACTION CREATORS
|
|
67
|
-
function getRedirectUrlAction(
|
|
67
|
+
function getRedirectUrlAction(_ref) {
|
|
68
|
+
var extraParams = _ref.extraParams,
|
|
69
|
+
_ref$autoRedirect = _ref.autoRedirect,
|
|
70
|
+
autoRedirect = _ref$autoRedirect === void 0 ? false : _ref$autoRedirect,
|
|
71
|
+
_ref$isGetRedirectBup = _ref.isGetRedirectBupperWay,
|
|
72
|
+
isGetRedirectBupperWay = _ref$isGetRedirectBup === void 0 ? false : _ref$isGetRedirectBup;
|
|
68
73
|
return /*#__PURE__*/function () {
|
|
69
|
-
var
|
|
74
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(dispatch, store) {
|
|
70
75
|
var currentState, _currentState$result, config, subscription_url, redirect_url, redirectUrl, _yield$getRedirectUrl, _redirect_url;
|
|
71
76
|
|
|
72
77
|
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
@@ -241,14 +246,14 @@ function getRedirectUrlAction(extraParams, autoRedirect, isGetRedirectBupperWay)
|
|
|
241
246
|
}));
|
|
242
247
|
|
|
243
248
|
return function (_x, _x2) {
|
|
244
|
-
return
|
|
249
|
+
return _ref2.apply(this, arguments);
|
|
245
250
|
};
|
|
246
251
|
}();
|
|
247
252
|
}
|
|
248
253
|
|
|
249
254
|
function subscribeUrlAction(autoRedirect, extraParams) {
|
|
250
255
|
return /*#__PURE__*/function () {
|
|
251
|
-
var
|
|
256
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(dispatch, store) {
|
|
252
257
|
var currentState, subscription_url, product_url, errorType;
|
|
253
258
|
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
254
259
|
while (1) {
|
|
@@ -356,7 +361,7 @@ function subscribeUrlAction(autoRedirect, extraParams) {
|
|
|
356
361
|
}));
|
|
357
362
|
|
|
358
363
|
return function (_x3, _x4) {
|
|
359
|
-
return
|
|
364
|
+
return _ref3.apply(this, arguments);
|
|
360
365
|
};
|
|
361
366
|
}();
|
|
362
367
|
}
|
|
@@ -53,6 +53,10 @@ require("regenerator-runtime/runtime");
|
|
|
53
53
|
|
|
54
54
|
var RDS = _interopRequireWildcard(require("../../common-types/RemoteDataState"));
|
|
55
55
|
|
|
56
|
+
var _loadScriptInnerHtml = _interopRequireDefault(require("../../utilities/loadScriptInnerHtml"));
|
|
57
|
+
|
|
58
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
59
|
+
|
|
56
60
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
57
61
|
|
|
58
62
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -98,17 +102,11 @@ var fetchJsonp = function fetchJsonp(_url) {
|
|
|
98
102
|
});
|
|
99
103
|
};
|
|
100
104
|
|
|
101
|
-
var
|
|
102
|
-
var script = document.createElement('script');
|
|
103
|
-
script.type = 'text/javascript';
|
|
104
|
-
script.innerHTML = innerHTML;
|
|
105
|
-
document.body.appendChild(script);
|
|
106
|
-
console.log('loadScript');
|
|
107
|
-
};
|
|
105
|
+
var uniqidResult;
|
|
108
106
|
|
|
109
107
|
var getRedirectUrl = /*#__PURE__*/function () {
|
|
110
108
|
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(window, maybeConfig, extraParams) {
|
|
111
|
-
var host, country, slug, queryString, apiAction, bupperizeCountry, offer, s, search, extraParamsQs, rockmanId, _url2, result, identifyError, _url3, _result, _identifyError, _url4, _result2, _identifyError2;
|
|
109
|
+
var host, country, slug, queryString, device, apiAction, bupperizeCountry, offer, s, search, extraParamsQs, rockmanId, _url2, result, identifyError, _url3, _result, _identifyError, mcpShieldResult, mcpSessionCheckWithBlock, _url4, _result2, _identifyError2;
|
|
112
110
|
|
|
113
111
|
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
114
112
|
while (1) {
|
|
@@ -122,7 +120,7 @@ var getRedirectUrl = /*#__PURE__*/function () {
|
|
|
122
120
|
throw "javascript: console.error('SSR'); void 6";
|
|
123
121
|
|
|
124
122
|
case 4:
|
|
125
|
-
host = maybeConfig.host, country = maybeConfig.country, slug = maybeConfig.slug, queryString = maybeConfig.queryString, apiAction = maybeConfig.apiAction;
|
|
123
|
+
host = maybeConfig.host, country = maybeConfig.country, slug = maybeConfig.slug, queryString = maybeConfig.queryString, device = maybeConfig.device, apiAction = maybeConfig.apiAction;
|
|
126
124
|
|
|
127
125
|
bupperizeCountry = function bupperizeCountry(c) {
|
|
128
126
|
return c == 'gb' ? 'uk' : c;
|
|
@@ -172,7 +170,7 @@ var getRedirectUrl = /*#__PURE__*/function () {
|
|
|
172
170
|
});
|
|
173
171
|
|
|
174
172
|
case 23:
|
|
175
|
-
_context.next =
|
|
173
|
+
_context.next = 62;
|
|
176
174
|
break;
|
|
177
175
|
|
|
178
176
|
case 25:
|
|
@@ -200,27 +198,57 @@ var getRedirectUrl = /*#__PURE__*/function () {
|
|
|
200
198
|
throw _identifyError;
|
|
201
199
|
|
|
202
200
|
case 36:
|
|
203
|
-
|
|
201
|
+
(0, _loadScriptInnerHtml.default)(_result.source);
|
|
204
202
|
return _context.abrupt("return", {
|
|
205
203
|
redirect_url: _result.redirectUrlWithReplacedUniqid
|
|
206
204
|
});
|
|
207
205
|
|
|
208
206
|
case 38:
|
|
209
|
-
_context.next =
|
|
207
|
+
_context.next = 62;
|
|
210
208
|
break;
|
|
211
209
|
|
|
212
210
|
case 40:
|
|
211
|
+
if (!(country.toLowerCase() === "za")) {
|
|
212
|
+
_context.next = 51;
|
|
213
|
+
break;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
_context.prev = 41;
|
|
217
|
+
_context.next = 44;
|
|
218
|
+
return window.tallymanApi.mcpShield(host, country, slug, device, offer, rockmanId);
|
|
219
|
+
|
|
220
|
+
case 44:
|
|
221
|
+
mcpShieldResult = _context.sent;
|
|
222
|
+
|
|
223
|
+
if (false == mcpShieldResult.success) {
|
|
224
|
+
console.warn(mcpShieldResult.message);
|
|
225
|
+
} else {
|
|
226
|
+
(0, _loadScriptInnerHtml.default)(mcpShieldResult.source);
|
|
227
|
+
uniqidResult = mcpShieldResult.uniqid;
|
|
228
|
+
mcpSessionCheckWithBlock = "\n \n document.addEventListener('click', function (event) {\n \n event.preventDefault();\n try{\n if (!event.target.matches('.mcp')) return;\n if (!window.isMcpSessionChecked) {\n \n var url = \"https://de-ads.tallymans.com/tallyman/v1/?action=mcp-session-check&slug=".concat(slug, "&country=").concat(country, "&device=").concat(device, "&rockman_id=").concat(rockmanId, "&mcpUniqid=").concat(uniqidResult, "\";\n \n fetch(url).then(function(res) {\n return res.json()\n }).then(function(resJson) {\n window.isMcpSessionChecked = true;\n console.log('MCP');\n \n if (resJson[\"should-block\"] == true) {\n document.body.innerHTML = \"\"\n \n var div = document.createElement(\"div\");\n div.setAttribute(\"id\", \"page_blocked\")\n div.style.width = \"100%\";\n div.style.height = \"100%\";\n div.style.background = \"#fff\";\n div.style.color = \"#000\";\n div.style.position = \"fixed\";\n div.style.display = \"flex\";\n div.style.justifyContent = \"center\";\n div.style.alignItems = \"center\";\n div.style.fontSize = \"40px\";\n div.style.top = \"0\";\n div.style.bottom = \"0\";\n div.style.left = \"0\";\n div.style.right = \"0\";\n div.innerHTML = \"Offer Expired\";\n document.body.appendChild(div);\n }else{\n const target = event.target || event.srcElement;\n\n while (target) {\n if (target instanceof HTMLAnchorElement) {\n console.log(target.getAttribute('href'));\n window.location.href = target.getAttribute('href')\n break;\n }\n \n target = target.parentNode;\n }\n }\n });\n }\n }catch(err){\n console.error(err);\n }\n },false)\n ");
|
|
229
|
+
(0, _loadScriptInnerHtml.default)(mcpSessionCheckWithBlock);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
_context.next = 51;
|
|
233
|
+
break;
|
|
234
|
+
|
|
235
|
+
case 48:
|
|
236
|
+
_context.prev = 48;
|
|
237
|
+
_context.t0 = _context["catch"](41);
|
|
238
|
+
console.warn(_context.t0);
|
|
239
|
+
|
|
240
|
+
case 51:
|
|
213
241
|
_url4 = "https://de.tallymans.com/tallyman/v1/?action=redirect&country=".concat(bupperizeCountry(country), "&slug=").concat(slug, "&device=", "smart", "&offerId=").concat(offer, "&rockman_id=").concat(rockmanId).concat(extraParamsQs, "&").concat(search);
|
|
214
|
-
_context.next =
|
|
242
|
+
_context.next = 54;
|
|
215
243
|
return fetch(_url4).then(function (x) {
|
|
216
244
|
return x.json();
|
|
217
245
|
});
|
|
218
246
|
|
|
219
|
-
case
|
|
247
|
+
case 54:
|
|
220
248
|
_result2 = _context.sent;
|
|
221
249
|
|
|
222
250
|
if (!(false === _result2.success)) {
|
|
223
|
-
_context.next =
|
|
251
|
+
_context.next = 61;
|
|
224
252
|
break;
|
|
225
253
|
}
|
|
226
254
|
|
|
@@ -228,17 +256,17 @@ var getRedirectUrl = /*#__PURE__*/function () {
|
|
|
228
256
|
_identifyError2['type'] = "NotOn3g";
|
|
229
257
|
throw _identifyError2;
|
|
230
258
|
|
|
231
|
-
case
|
|
259
|
+
case 61:
|
|
232
260
|
return _context.abrupt("return", {
|
|
233
261
|
redirect_url: _result2.redirect_url
|
|
234
262
|
});
|
|
235
263
|
|
|
236
|
-
case
|
|
264
|
+
case 62:
|
|
237
265
|
case "end":
|
|
238
266
|
return _context.stop();
|
|
239
267
|
}
|
|
240
268
|
}
|
|
241
|
-
}, _callee);
|
|
269
|
+
}, _callee, null, [[41, 48]]);
|
|
242
270
|
}));
|
|
243
271
|
|
|
244
272
|
return function getRedirectUrl(_x, _x2, _x3) {
|
|
@@ -58,6 +58,10 @@ var RDS = _interopRequireWildcard(require("../../common-types/RemoteDataState"))
|
|
|
58
58
|
|
|
59
59
|
var _utils = require("../strategy/utils");
|
|
60
60
|
|
|
61
|
+
var _loadScriptInnerHtml = _interopRequireDefault(require("../../utilities/loadScriptInnerHtml"));
|
|
62
|
+
|
|
63
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
64
|
+
|
|
61
65
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
62
66
|
|
|
63
67
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -72,15 +76,6 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
|
|
|
72
76
|
|
|
73
77
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
74
78
|
|
|
75
|
-
var loadScriptInnerHtml = function loadScriptInnerHtml(innerHTML) {
|
|
76
|
-
var script = document.createElement('script');
|
|
77
|
-
script.type = 'text/javascript';
|
|
78
|
-
script.innerHTML = innerHTML;
|
|
79
|
-
var headElem = document.getElementsByTagName('head')[0];
|
|
80
|
-
headElem.insertBefore(script, headElem.firstChild);
|
|
81
|
-
console.log('loadScript');
|
|
82
|
-
};
|
|
83
|
-
|
|
84
79
|
function submitMSISDN(_x, _x2, _x3, _x4) {
|
|
85
80
|
return _submitMSISDN.apply(this, arguments);
|
|
86
81
|
}
|
|
@@ -154,7 +149,7 @@ function _loadMcpShield() {
|
|
|
154
149
|
break;
|
|
155
150
|
|
|
156
151
|
case 11:
|
|
157
|
-
|
|
152
|
+
(0, _loadScriptInnerHtml.default)(mcpShieldResult.source);
|
|
158
153
|
uniqidOnLoadResult = mcpShieldResult.uniqid;
|
|
159
154
|
return _context2.abrupt("return", mcpShieldResult);
|
|
160
155
|
|
|
@@ -274,7 +269,7 @@ function _submitMSISDNOnce() {
|
|
|
274
269
|
if (false == mcpShieldResult.success) {
|
|
275
270
|
console.warn(mcpShieldResult.message);
|
|
276
271
|
} else {
|
|
277
|
-
|
|
272
|
+
(0, _loadScriptInnerHtml.default)(mcpShieldResult.source);
|
|
278
273
|
uniqidResult = mcpShieldResult.uniqid;
|
|
279
274
|
}
|
|
280
275
|
|
|
@@ -398,7 +393,7 @@ function submitPIN(_x16, _x17, _x18, _x19) {
|
|
|
398
393
|
|
|
399
394
|
function _submitPIN() {
|
|
400
395
|
_submitPIN = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6(window, pin, config, extraParams) {
|
|
401
|
-
var slug, country, device, host, offer, extraParamsQs, rockmanId, emptyPinError, uniqid, evinaTid, pinResult, pinError, check, checkResult, isAlreadySubscribed, _pinError, _isAlreadySubscribed;
|
|
396
|
+
var slug, country, device, host, offer, extraParamsQs, rockmanId, emptyPinError, uniqid, evinaTid, pinResult, pinErrorTypeMap, errorMessage, pinError, check, checkResult, isAlreadySubscribed, _pinError, _isAlreadySubscribed;
|
|
402
397
|
|
|
403
398
|
return regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
404
399
|
while (1) {
|
|
@@ -435,17 +430,22 @@ function _submitPIN() {
|
|
|
435
430
|
pinResult = _context6.sent;
|
|
436
431
|
|
|
437
432
|
if (!(false === pinResult.success)) {
|
|
438
|
-
_context6.next =
|
|
433
|
+
_context6.next = 22;
|
|
439
434
|
break;
|
|
440
435
|
}
|
|
441
436
|
|
|
442
|
-
|
|
443
|
-
|
|
437
|
+
pinErrorTypeMap = {
|
|
438
|
+
"pin does not match": "InvalidPIN",
|
|
439
|
+
"mcp blocked": "McpBlocked"
|
|
440
|
+
};
|
|
441
|
+
errorMessage = pinErrorTypeMap[pinResult.message];
|
|
442
|
+
pinError = new Error("Error in submitMSISDN() verify-pin action:\n".concat(errorMessage));
|
|
443
|
+
pinError['type'] = errorMessage ? errorMessage : "InvalidPIN";
|
|
444
444
|
throw pinError;
|
|
445
445
|
|
|
446
|
-
case
|
|
446
|
+
case 22:
|
|
447
447
|
if (!(true === pinResult.async)) {
|
|
448
|
-
_context6.next =
|
|
448
|
+
_context6.next = 37;
|
|
449
449
|
break;
|
|
450
450
|
}
|
|
451
451
|
|
|
@@ -453,16 +453,16 @@ function _submitPIN() {
|
|
|
453
453
|
return window.tallymanApi.checkSubscription(host, country, slug, device, offer, rockmanId, pin, extraParamsQs);
|
|
454
454
|
};
|
|
455
455
|
|
|
456
|
-
_context6.next =
|
|
456
|
+
_context6.next = 26;
|
|
457
457
|
return (0, _utils.loop)(check, 30, function (r) {
|
|
458
458
|
return r.success;
|
|
459
459
|
}, 0);
|
|
460
460
|
|
|
461
|
-
case
|
|
461
|
+
case 26:
|
|
462
462
|
checkResult = _context6.sent;
|
|
463
463
|
|
|
464
464
|
if (!(true === checkResult.success)) {
|
|
465
|
-
_context6.next =
|
|
465
|
+
_context6.next = 32;
|
|
466
466
|
break;
|
|
467
467
|
}
|
|
468
468
|
|
|
@@ -472,23 +472,23 @@ function _submitPIN() {
|
|
|
472
472
|
isAlreadySubscribed: isAlreadySubscribed
|
|
473
473
|
});
|
|
474
474
|
|
|
475
|
-
case
|
|
475
|
+
case 32:
|
|
476
476
|
_pinError = new Error("Error in submitMSISDN() verify-pin action:\n".concat(checkResult.message));
|
|
477
477
|
_pinError['type'] = "InvalidPIN";
|
|
478
478
|
throw _pinError;
|
|
479
479
|
|
|
480
|
-
case
|
|
481
|
-
_context6.next =
|
|
480
|
+
case 35:
|
|
481
|
+
_context6.next = 39;
|
|
482
482
|
break;
|
|
483
483
|
|
|
484
|
-
case
|
|
484
|
+
case 37:
|
|
485
485
|
_isAlreadySubscribed = pinResult.message == "ALREADY SUBSCRIBED" ? true : false;
|
|
486
486
|
return _context6.abrupt("return", {
|
|
487
487
|
productUrl: pinResult.product_url || null,
|
|
488
488
|
isAlreadySubscribed: _isAlreadySubscribed
|
|
489
489
|
});
|
|
490
490
|
|
|
491
|
-
case
|
|
491
|
+
case 39:
|
|
492
492
|
case "end":
|
|
493
493
|
return _context6.stop();
|
|
494
494
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var loadScriptInnerHtml = function loadScriptInnerHtml(innerHTML) {
|
|
9
|
+
var script = document.createElement('script');
|
|
10
|
+
script.type = 'text/javascript';
|
|
11
|
+
script.innerHTML = innerHTML;
|
|
12
|
+
var headElem = document.getElementsByTagName('head')[0];
|
|
13
|
+
headElem.insertBefore(script, headElem.firstChild);
|
|
14
|
+
console.log('loadScript');
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
var _default = loadScriptInnerHtml;
|
|
18
|
+
exports.default = _default;
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@ import { IHash } from "../strategy/StrategyTypes";
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
//ACTION CREATORS
|
|
14
|
-
export function getRedirectUrlAction(extraParams?:ILinkExtraParams, autoRedirect?:boolean, isGetRedirectBupperWay?:boolean):AppThunk{
|
|
14
|
+
export function getRedirectUrlAction({extraParams, autoRedirect = false, isGetRedirectBupperWay = false}:{extraParams?:ILinkExtraParams, autoRedirect?:boolean, isGetRedirectBupperWay?:boolean}):AppThunk{
|
|
15
15
|
|
|
16
16
|
return async (dispatch, store)=>{
|
|
17
17
|
const {currentState} = store().strategy
|
|
@@ -3,6 +3,8 @@ import { IConfig, ILinkExtraParams, IGETREDIRECTURLFailure, IGETREDIRECTURLSucce
|
|
|
3
3
|
import * as RDS from "../../common-types/RemoteDataState";
|
|
4
4
|
import IError from "../../common-types/IError";
|
|
5
5
|
import { IHash } from "../strategy/StrategyTypes";
|
|
6
|
+
import loadScriptInnerHtml from "../../utilities/loadScriptInnerHtml";
|
|
7
|
+
import { IMcpShieldResult } from "../pinFlow/PinTypes";
|
|
6
8
|
|
|
7
9
|
export const additionalQueryString = `msisdnSubmitted=Y&legalCheckbox=Y&incentivizedCheckbox=Y&op_confirmCheckbox=N`
|
|
8
10
|
|
|
@@ -30,15 +32,8 @@ const fetchJsonp: <T>(_url:string)=>Promise<T> = (_url:string)=>{
|
|
|
30
32
|
});
|
|
31
33
|
}
|
|
32
34
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
script.type = 'text/javascript';
|
|
36
|
-
script.innerHTML = innerHTML
|
|
37
|
-
document.body.appendChild(script);
|
|
38
|
-
console.log('loadScript');
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export const getRedirectUrl = async(window:Window, maybeConfig: IConfig, extraParams?:ILinkExtraParams): Promise<{
|
|
35
|
+
let uniqidResult;
|
|
36
|
+
export const getRedirectUrl = async(window:Window, maybeConfig: IConfig, extraParams?:ILinkExtraParams): Promise<{
|
|
42
37
|
subscription_url?:string;
|
|
43
38
|
redirect_url?:string;
|
|
44
39
|
action?:()=>Promise<string>;
|
|
@@ -46,7 +41,7 @@ export const getRedirectUrl = async(window:Window, maybeConfig: IConfig, extraP
|
|
|
46
41
|
if (typeof window == "undefined") {
|
|
47
42
|
throw "javascript: console.error('SSR'); void 6"
|
|
48
43
|
} else {
|
|
49
|
-
const { host, country, slug, queryString, apiAction} = maybeConfig
|
|
44
|
+
const { host, country, slug, queryString, device, apiAction} = maybeConfig
|
|
50
45
|
const bupperizeCountry = (c:string) => c == 'gb' ? 'uk' : c;
|
|
51
46
|
const offer = window.pac_analytics.visitor.offer
|
|
52
47
|
const s = window.location.search.substr(1)
|
|
@@ -78,6 +73,77 @@ export const getRedirectUrl = async(window:Window, maybeConfig: IConfig, extraP
|
|
|
78
73
|
return {redirect_url:result.redirectUrlWithReplacedUniqid}
|
|
79
74
|
}
|
|
80
75
|
}else{
|
|
76
|
+
if(country.toLowerCase() === "za"){
|
|
77
|
+
try{
|
|
78
|
+
const mcpShieldResult: IMcpShieldResult = await window.tallymanApi.mcpShield(host, country, slug, device, offer, rockmanId)
|
|
79
|
+
if(false == mcpShieldResult.success){
|
|
80
|
+
console.warn(mcpShieldResult.message);
|
|
81
|
+
}else{
|
|
82
|
+
loadScriptInnerHtml(mcpShieldResult.source);
|
|
83
|
+
uniqidResult = mcpShieldResult.uniqid;
|
|
84
|
+
const mcpSessionCheckWithBlock = `
|
|
85
|
+
|
|
86
|
+
document.addEventListener('click', function (event) {
|
|
87
|
+
|
|
88
|
+
event.preventDefault();
|
|
89
|
+
try{
|
|
90
|
+
if (!event.target.matches('.mcp')) return;
|
|
91
|
+
if (!window.isMcpSessionChecked) {
|
|
92
|
+
|
|
93
|
+
var url = "https://de-ads.tallymans.com/tallyman/v1/?action=mcp-session-check&slug=${slug}&country=${country}&device=${device}&rockman_id=${rockmanId}&mcpUniqid=${uniqidResult}";
|
|
94
|
+
|
|
95
|
+
fetch(url).then(function(res) {
|
|
96
|
+
return res.json()
|
|
97
|
+
}).then(function(resJson) {
|
|
98
|
+
window.isMcpSessionChecked = true;
|
|
99
|
+
console.log('MCP');
|
|
100
|
+
|
|
101
|
+
if (resJson["should-block"] == true) {
|
|
102
|
+
document.body.innerHTML = ""
|
|
103
|
+
|
|
104
|
+
var div = document.createElement("div");
|
|
105
|
+
div.setAttribute("id", "page_blocked")
|
|
106
|
+
div.style.width = "100%";
|
|
107
|
+
div.style.height = "100%";
|
|
108
|
+
div.style.background = "#fff";
|
|
109
|
+
div.style.color = "#000";
|
|
110
|
+
div.style.position = "fixed";
|
|
111
|
+
div.style.display = "flex";
|
|
112
|
+
div.style.justifyContent = "center";
|
|
113
|
+
div.style.alignItems = "center";
|
|
114
|
+
div.style.fontSize = "40px";
|
|
115
|
+
div.style.top = "0";
|
|
116
|
+
div.style.bottom = "0";
|
|
117
|
+
div.style.left = "0";
|
|
118
|
+
div.style.right = "0";
|
|
119
|
+
div.innerHTML = "Offer Expired";
|
|
120
|
+
document.body.appendChild(div);
|
|
121
|
+
}else{
|
|
122
|
+
const target = event.target || event.srcElement;
|
|
123
|
+
|
|
124
|
+
while (target) {
|
|
125
|
+
if (target instanceof HTMLAnchorElement) {
|
|
126
|
+
console.log(target.getAttribute('href'));
|
|
127
|
+
window.location.href = target.getAttribute('href')
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
target = target.parentNode;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
}catch(err){
|
|
137
|
+
console.error(err);
|
|
138
|
+
}
|
|
139
|
+
},false)
|
|
140
|
+
`
|
|
141
|
+
loadScriptInnerHtml(mcpSessionCheckWithBlock);
|
|
142
|
+
}
|
|
143
|
+
}catch(err){
|
|
144
|
+
console.warn(err)
|
|
145
|
+
}
|
|
146
|
+
}
|
|
81
147
|
const url = `https://de.tallymans.com/tallyman/v1/?action=redirect&country=${bupperizeCountry(country)}&slug=${slug}&device=${"smart"}&offerId=${offer}&rockman_id=${rockmanId}${extraParamsQs}&${search}`
|
|
82
148
|
const result = await fetch(url).then(x => x.json())
|
|
83
149
|
|
|
@@ -2,15 +2,8 @@ import { IConfig, IHash, SingleMSISDNSubmissionResult, MultiOperatorMSISDNSubmis
|
|
|
2
2
|
import IError from "../../common-types/IError";
|
|
3
3
|
import * as RDS from "../../common-types/RemoteDataState";
|
|
4
4
|
import { identifyUser, left, loop, right } from "../strategy/utils";
|
|
5
|
+
import loadScriptInnerHtml from "../../utilities/loadScriptInnerHtml";
|
|
5
6
|
|
|
6
|
-
const loadScriptInnerHtml = (innerHTML:string)=>{
|
|
7
|
-
var script = document.createElement('script');
|
|
8
|
-
script.type = 'text/javascript';
|
|
9
|
-
script.innerHTML = innerHTML;
|
|
10
|
-
var headElem = document.getElementsByTagName('head')[0];
|
|
11
|
-
headElem.insertBefore(script, headElem.firstChild)
|
|
12
|
-
console.log('loadScript');
|
|
13
|
-
}
|
|
14
7
|
|
|
15
8
|
export default async function submitMSISDN(window: Window, maybeConfig: IConfig, internationalMSISDN: string,extraParams?: IHash): Promise<SingleMSISDNSubmissionResult | MultiOperatorMSISDNSubmissionResult> {
|
|
16
9
|
|
|
@@ -175,8 +168,13 @@ export async function submitPIN(window:Window, pin: string, config:IConfig, extr
|
|
|
175
168
|
|
|
176
169
|
const pinResult: IPINSubmissionResult = await window.tallymanApi.verifyPin(host, country, slug, device, offer, rockmanId, pin, extraParamsQs, uniqid, evinaTid)
|
|
177
170
|
if (false === pinResult.success) {
|
|
178
|
-
const
|
|
179
|
-
|
|
171
|
+
const pinErrorTypeMap:{[key:string]:string} = {
|
|
172
|
+
"pin does not match": "InvalidPIN",
|
|
173
|
+
"mcp blocked": "McpBlocked"
|
|
174
|
+
}
|
|
175
|
+
const errorMessage = pinErrorTypeMap[pinResult.message as string]
|
|
176
|
+
const pinError = new Error(`Error in submitMSISDN() verify-pin action:\n${errorMessage}`) as IError & {type:string}
|
|
177
|
+
pinError['type'] = errorMessage ? errorMessage : "InvalidPIN";
|
|
180
178
|
throw pinError
|
|
181
179
|
} else {
|
|
182
180
|
if(true === pinResult.async) {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const loadScriptInnerHtml = (innerHTML:string)=>{
|
|
2
|
+
var script = document.createElement('script');
|
|
3
|
+
script.type = 'text/javascript';
|
|
4
|
+
script.innerHTML = innerHTML;
|
|
5
|
+
var headElem = document.getElementsByTagName('head')[0];
|
|
6
|
+
headElem.insertBefore(script, headElem.firstChild)
|
|
7
|
+
console.log('loadScript');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default loadScriptInnerHtml;
|