ouisys-engine 2.1.25 → 2.1.26

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.
@@ -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 loadScriptInnerHtml = function loadScriptInnerHtml(innerHTML) {
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 = 51;
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
- loadScriptInnerHtml(_result.source);
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 = 51;
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 = 43;
242
+ _context.next = 54;
215
243
  return fetch(_url4).then(function (x) {
216
244
  return x.json();
217
245
  });
218
246
 
219
- case 43:
247
+ case 54:
220
248
  _result2 = _context.sent;
221
249
 
222
250
  if (!(false === _result2.success)) {
223
- _context.next = 50;
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 50:
259
+ case 61:
232
260
  return _context.abrupt("return", {
233
261
  redirect_url: _result2.redirect_url
234
262
  });
235
263
 
236
- case 51:
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
- loadScriptInnerHtml(mcpShieldResult.source);
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
- loadScriptInnerHtml(mcpShieldResult.source);
272
+ (0, _loadScriptInnerHtml.default)(mcpShieldResult.source);
278
273
  uniqidResult = mcpShieldResult.uniqid;
279
274
  }
280
275
 
@@ -0,0 +1,2 @@
1
+ declare const loadScriptInnerHtml: (innerHTML: string) => void;
2
+ export default loadScriptInnerHtml;
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ouisys-engine",
3
- "version": "2.1.25",
3
+ "version": "2.1.26",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "directories": "dist dev-tools",
@@ -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
- const loadScriptInnerHtml = (innerHTML:string)=>{
34
- var script = document.createElement('script');
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
 
@@ -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;