ouisys-engine 3.0.1 → 3.0.5

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.
Files changed (195) hide show
  1. package/.babelrc +4 -8
  2. package/.eslintrc.js +1 -1
  3. package/.husky/pre-commit +4 -0
  4. package/.nvmrc +1 -1
  5. package/.prettierignore +2 -1
  6. package/.vscode/settings.json +1 -1
  7. package/README.md +2 -4
  8. package/dist/api/index.d.ts +5 -5
  9. package/dist/api/index.js +76 -76
  10. package/dist/common-types/AppThunk.d.ts +11 -12
  11. package/dist/common-types/IOptInFlowName.d.ts +1 -1
  12. package/dist/common-types/ITracker.js +1 -2
  13. package/dist/common-types/RemoteDataState.d.ts +4 -4
  14. package/dist/common-types/RemoteDataState.js +17 -17
  15. package/dist/flows/click2smsFlow.d.ts +2 -2
  16. package/dist/flows/moFlow.d.ts +2 -2
  17. package/dist/flows/moRedirFlow.d.ts +2 -2
  18. package/dist/flows/oneClickFlow.d.ts +2 -2
  19. package/dist/flows/pinFlow.d.ts +2 -2
  20. package/dist/flows/pinFlow.js +2 -0
  21. package/dist/flows/strategy.d.ts +8 -8
  22. package/dist/flows/ussdFlow.d.ts +2 -2
  23. package/dist/ips/tryGetIPRangeName.d.ts +1 -1
  24. package/dist/ips/tryGetIPRangeName.js +7 -5
  25. package/dist/jest.config.js +1 -1
  26. package/dist/pacman/index.d.ts +2 -2
  27. package/dist/pacman/index.js +41 -41
  28. package/dist/pacman/queryString.js +11 -9
  29. package/dist/reducers/click2smsFlow/Click2smsTypes.d.ts +19 -19
  30. package/dist/reducers/click2smsFlow/IClick2smsConstants.d.ts +1 -1
  31. package/dist/reducers/click2smsFlow/index.d.ts +2 -2
  32. package/dist/reducers/click2smsFlow/index.js +24 -24
  33. package/dist/reducers/click2smsFlow/utils.d.ts +1 -1
  34. package/dist/reducers/click2smsFlow/utils.js +30 -30
  35. package/dist/reducers/moFlow/IMoConstants.d.ts +1 -1
  36. package/dist/reducers/moFlow/MoTypes.d.ts +13 -13
  37. package/dist/reducers/moFlow/index.d.ts +3 -3
  38. package/dist/reducers/moFlow/index.js +27 -27
  39. package/dist/reducers/moFlow/utils.d.ts +1 -2
  40. package/dist/reducers/moFlow/utils.js +28 -26
  41. package/dist/reducers/moRedirFlow/IMoRedirConstants.d.ts +1 -1
  42. package/dist/reducers/moRedirFlow/MoRedirTypes.d.ts +13 -13
  43. package/dist/reducers/moRedirFlow/index.d.ts +3 -3
  44. package/dist/reducers/moRedirFlow/index.js +27 -27
  45. package/dist/reducers/moRedirFlow/utils.d.ts +1 -1
  46. package/dist/reducers/moRedirFlow/utils.js +17 -17
  47. package/dist/reducers/oneClickFlow/IOneClickConstants.d.ts +1 -1
  48. package/dist/reducers/oneClickFlow/OneClickTypes.d.ts +10 -10
  49. package/dist/reducers/oneClickFlow/index.d.ts +3 -3
  50. package/dist/reducers/oneClickFlow/index.js +75 -68
  51. package/dist/reducers/oneClickFlow/utils.d.ts +2 -2
  52. package/dist/reducers/oneClickFlow/utils.js +70 -69
  53. package/dist/reducers/pinFlow/IPinConstants.d.ts +1 -1
  54. package/dist/reducers/pinFlow/PinTypes.d.ts +24 -23
  55. package/dist/reducers/pinFlow/index.d.ts +3 -3
  56. package/dist/reducers/pinFlow/index.js +76 -76
  57. package/dist/reducers/pinFlow/utils.d.ts +1 -1
  58. package/dist/reducers/pinFlow/utils.js +61 -65
  59. package/dist/reducers/strategy/IStategyActionContants.d.ts +1 -1
  60. package/dist/reducers/strategy/StrategyTypes.d.ts +56 -56
  61. package/dist/reducers/strategy/index.d.ts +2 -2
  62. package/dist/reducers/strategy/index.js +99 -99
  63. package/dist/reducers/strategy/strategies/ask_mobile_number.d.ts +3 -2
  64. package/dist/reducers/strategy/strategies/ask_mobile_number.js +132 -74
  65. package/dist/reducers/strategy/strategies/ask_operator.d.ts +2 -2
  66. package/dist/reducers/strategy/strategies/ask_operator.js +64 -68
  67. package/dist/reducers/strategy/strategies/detect_operator_by_ip.d.ts +2 -2
  68. package/dist/reducers/strategy/strategies/detect_operator_by_ip.js +97 -97
  69. package/dist/reducers/strategy/strategies/header_enrichment.d.ts +2 -2
  70. package/dist/reducers/strategy/strategies/header_enrichment.js +116 -120
  71. package/dist/reducers/strategy/utils.d.ts +3 -3
  72. package/dist/reducers/strategy/utils.js +115 -111
  73. package/dist/reducers/ussdFlow/IUssdConstants.d.ts +1 -1
  74. package/dist/reducers/ussdFlow/UssdTypes.d.ts +13 -13
  75. package/dist/reducers/ussdFlow/index.d.ts +3 -3
  76. package/dist/reducers/ussdFlow/index.js +27 -27
  77. package/dist/reducers/ussdFlow/utils.d.ts +1 -2
  78. package/dist/reducers/ussdFlow/utils.js +19 -17
  79. package/dist/store/index.d.ts +8 -8
  80. package/dist/store/index.js +87 -83
  81. package/dist/store/reducers.d.ts +7 -7
  82. package/dist/store/reducers.js +4 -4
  83. package/dist/utilities/handleSubmitNumber.d.ts +7 -3
  84. package/dist/utilities/handleSubmitNumber.js +15 -18
  85. package/dist/utilities/index.d.ts +1 -1
  86. package/dist/utilities/index.js +13 -11
  87. package/dist/utilities/loadScriptInnerHtml.js +0 -1
  88. package/index.html +21 -28
  89. package/mockData/config.json +1 -1
  90. package/package.json +23 -15
  91. package/setupJest.js +1 -1
  92. package/tsconfig.json +2 -2
  93. package/dist/api/click2sms.js +0 -357
  94. package/dist/api/mo.js +0 -274
  95. package/dist/api/moRedir.js +0 -186
  96. package/dist/api/oneClick.js +0 -366
  97. package/dist/api/pin.js +0 -493
  98. package/dist/api/strategies.js +0 -704
  99. package/dist/api/ussd.js +0 -1
  100. package/dist/app/store.js +0 -35
  101. package/dist/features/strategies/categories/askMobileNumber.js +0 -395
  102. package/dist/features/strategies/categories/askOperator.js +0 -311
  103. package/dist/features/strategies/categories/detectOperatorByIp.js +0 -606
  104. package/dist/features/strategies/categories/headerEnrichment.js +0 -670
  105. package/dist/features/strategies/categories/typings/click2smsSliceTypes.js +0 -12
  106. package/dist/features/strategies/categories/typings/identifySliceTypes.js +0 -22
  107. package/dist/features/strategies/categories/typings/moFlowSliceTypes.js +0 -22
  108. package/dist/features/strategies/categories/typings/moRedirFlowSliceTypes.js +0 -21
  109. package/dist/features/strategies/categories/typings/oneClickSliceTypes.js +0 -13
  110. package/dist/features/strategies/categories/typings/pinFlowSliceTypes.js +0 -13
  111. package/dist/features/strategies/click2smsFlowSlice.js +0 -172
  112. package/dist/features/strategies/identifySlice.js +0 -455
  113. package/dist/features/strategies/moFlowSlice.js +0 -196
  114. package/dist/features/strategies/moRedirFlowSlice.js +0 -190
  115. package/dist/features/strategies/oneClickFlowSlice.js +0 -277
  116. package/dist/features/strategies/pinFlowSlice.js +0 -313
  117. package/dist/features/strategies/ussdFlowSlice.js +0 -1
  118. package/dist/flows/tpayHeFlow.d.ts +0 -7
  119. package/dist/flows/tpayHeFlow.js +0 -23
  120. package/dist/mockServer/browser.js +0 -48
  121. package/dist/mockServer/handlers.js +0 -22
  122. package/dist/mockServer/server.js +0 -48
  123. package/dist/reducers/tpayHeFlow/ITpayHeConstants.d.ts +0 -2
  124. package/dist/reducers/tpayHeFlow/ITpayHeConstants.js +0 -1
  125. package/dist/reducers/tpayHeFlow/TpayHeTypes.d.ts +0 -114
  126. package/dist/reducers/tpayHeFlow/TpayHeTypes.js +0 -1
  127. package/dist/reducers/tpayHeFlow/index.d.ts +0 -7
  128. package/dist/reducers/tpayHeFlow/index.js +0 -331
  129. package/dist/reducers/tpayHeFlow/utils.d.ts +0 -20
  130. package/dist/reducers/tpayHeFlow/utils.js +0 -510
  131. package/dist/test/setup.js +0 -24
  132. package/dist/test/test-utils.js +0 -51
  133. package/prettier.config.js +0 -7
  134. package/src/@types/react-tracker.d.ts +0 -16
  135. package/src/@types/redux-cli-logger.d.ts +0 -1
  136. package/src/@types/tiny-async-pool.d.ts +0 -3
  137. package/src/@types/window.d.ts +0 -74
  138. package/src/api/index.ts +0 -225
  139. package/src/common-types/AppThunk.ts +0 -19
  140. package/src/common-types/Either.ts +0 -3
  141. package/src/common-types/IError.ts +0 -5
  142. package/src/common-types/IOptInFlowName.ts +0 -1
  143. package/src/common-types/ITracker.ts +0 -10
  144. package/src/common-types/IVisitor.ts +0 -16
  145. package/src/common-types/RemoteDataState.ts +0 -88
  146. package/src/flows/click2smsFlow.ts +0 -18
  147. package/src/flows/moFlow.ts +0 -20
  148. package/src/flows/moRedirFlow.ts +0 -20
  149. package/src/flows/oneClickFlow.ts +0 -20
  150. package/src/flows/pinFlow.ts +0 -25
  151. package/src/flows/strategy.ts +0 -51
  152. package/src/flows/ussdFlow.ts +0 -20
  153. package/src/index.ts +0 -3
  154. package/src/ips/tryGetIPRangeName.ts +0 -22
  155. package/src/jest.config.js +0 -194
  156. package/src/pacman/index.ts +0 -71
  157. package/src/pacman/queryString.ts +0 -24
  158. package/src/reducers/click2smsFlow/Click2smsTypes.ts +0 -93
  159. package/src/reducers/click2smsFlow/IClick2smsConstants.ts +0 -4
  160. package/src/reducers/click2smsFlow/index.ts +0 -105
  161. package/src/reducers/click2smsFlow/utils.ts +0 -126
  162. package/src/reducers/moFlow/IMoConstants.ts +0 -7
  163. package/src/reducers/moFlow/MoTypes.ts +0 -125
  164. package/src/reducers/moFlow/index.ts +0 -150
  165. package/src/reducers/moFlow/utils.ts +0 -135
  166. package/src/reducers/moRedirFlow/IMoRedirConstants.ts +0 -7
  167. package/src/reducers/moRedirFlow/MoRedirTypes.ts +0 -99
  168. package/src/reducers/moRedirFlow/index.ts +0 -137
  169. package/src/reducers/moRedirFlow/utils.ts +0 -78
  170. package/src/reducers/oneClickFlow/IOneClickConstants.ts +0 -3
  171. package/src/reducers/oneClickFlow/OneClickTypes.ts +0 -108
  172. package/src/reducers/oneClickFlow/index.ts +0 -268
  173. package/src/reducers/oneClickFlow/utils.ts +0 -217
  174. package/src/reducers/pinFlow/IPinConstants.ts +0 -9
  175. package/src/reducers/pinFlow/PinTypes.ts +0 -189
  176. package/src/reducers/pinFlow/index.ts +0 -331
  177. package/src/reducers/pinFlow/utils.ts +0 -232
  178. package/src/reducers/strategy/IStategyActionContants.ts +0 -17
  179. package/src/reducers/strategy/StrategyTypes.ts +0 -375
  180. package/src/reducers/strategy/index.ts +0 -321
  181. package/src/reducers/strategy/strategies/ask_mobile_number.ts +0 -316
  182. package/src/reducers/strategy/strategies/ask_operator.ts +0 -195
  183. package/src/reducers/strategy/strategies/detect_operator_by_ip.ts +0 -414
  184. package/src/reducers/strategy/strategies/header_enrichment.ts +0 -489
  185. package/src/reducers/strategy/utils.ts +0 -357
  186. package/src/reducers/ussdFlow/IUssdConstants.ts +0 -7
  187. package/src/reducers/ussdFlow/UssdTypes.ts +0 -112
  188. package/src/reducers/ussdFlow/index.ts +0 -146
  189. package/src/reducers/ussdFlow/utils.ts +0 -88
  190. package/src/store/index.ts +0 -150
  191. package/src/store/reducers.ts +0 -37
  192. package/src/utilities/handleSubmitNumber.ts +0 -65
  193. package/src/utilities/index.ts +0 -114
  194. package/src/utilities/loadScriptInnerHtml.ts +0 -14
  195. package/src/utilities/loadScriptSrc.ts +0 -26
package/dist/api/pin.js DELETED
@@ -1,493 +0,0 @@
1
- "use strict";
2
-
3
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
-
5
- require("core-js/modules/es.symbol");
6
-
7
- require("core-js/modules/es.symbol.description");
8
-
9
- require("core-js/modules/es.symbol.iterator");
10
-
11
- require("core-js/modules/es.array.concat");
12
-
13
- require("core-js/modules/es.array.filter");
14
-
15
- require("core-js/modules/es.array.find");
16
-
17
- require("core-js/modules/es.array.iterator");
18
-
19
- require("core-js/modules/es.array.join");
20
-
21
- require("core-js/modules/es.array.map");
22
-
23
- require("core-js/modules/es.object.get-own-property-descriptor");
24
-
25
- require("core-js/modules/es.object.get-own-property-descriptors");
26
-
27
- require("core-js/modules/es.object.keys");
28
-
29
- require("core-js/modules/es.object.to-string");
30
-
31
- require("core-js/modules/es.promise");
32
-
33
- require("core-js/modules/es.regexp.exec");
34
-
35
- require("core-js/modules/es.string.iterator");
36
-
37
- require("core-js/modules/es.string.match");
38
-
39
- require("core-js/modules/es.string.search");
40
-
41
- require("core-js/modules/es.weak-map");
42
-
43
- require("core-js/modules/web.dom-collections.for-each");
44
-
45
- require("core-js/modules/web.dom-collections.iterator");
46
-
47
- Object.defineProperty(exports, "__esModule", {
48
- value: true
49
- });
50
- exports.default = submitMSISDN;
51
- exports.loadMcpShield = loadMcpShield;
52
- exports.mockedPINState = exports.mockedMSISDNEntryFailure = exports.mockedCompletedState = void 0;
53
- exports.submitPIN = submitPIN;
54
-
55
- require("regenerator-runtime/runtime");
56
-
57
- var RDS = _interopRequireWildcard(require("../common-types/RemoteDataState"));
58
-
59
- var _strategies = require("./strategies");
60
-
61
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
62
-
63
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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; }
64
-
65
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
66
-
67
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
68
-
69
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
70
-
71
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
72
-
73
- 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
-
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
- };
82
-
83
- function submitMSISDN(_x, _x2, _x3, _x4) {
84
- return _submitMSISDN.apply(this, arguments);
85
- }
86
-
87
- function _submitMSISDN() {
88
- _submitMSISDN = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(window, maybeConfig, internationalMSISDN, extraParams) {
89
- var config;
90
- return regeneratorRuntime.wrap(function _callee$(_context) {
91
- while (1) {
92
- switch (_context.prev = _context.next) {
93
- case 0:
94
- config = _objectSpread({
95
- offer: window.pac_analytics.visitor.offer
96
- }, maybeConfig || {});
97
-
98
- if (!(config.automaticallySubmitAllOperators == true && !!config.operators && config.operators.length > 0)) {
99
- _context.next = 3;
100
- break;
101
- }
102
-
103
- return _context.abrupt("return", submitMSISDNForMultipleOperators(window, config, internationalMSISDN, config.operators, extraParams));
104
-
105
- case 3:
106
- return _context.abrupt("return", submitMSISDNOnce(window, config, internationalMSISDN, extraParams));
107
-
108
- case 4:
109
- case "end":
110
- return _context.stop();
111
- }
112
- }
113
- }, _callee);
114
- }));
115
- return _submitMSISDN.apply(this, arguments);
116
- }
117
-
118
- var bupperizeCountry = function bupperizeCountry(c) {
119
- return c == 'gb' ? 'uk' : c;
120
- };
121
-
122
- var uniqidResult = '';
123
- var uniqidOnLoadResult = '';
124
-
125
- function loadMcpShield(_x5, _x6) {
126
- return _loadMcpShield.apply(this, arguments);
127
- }
128
-
129
- function _loadMcpShield() {
130
- _loadMcpShield = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(window, config) {
131
- var slug, country, device, host, offer, rockmanId, mcpShieldResult;
132
- return regeneratorRuntime.wrap(function _callee2$(_context2) {
133
- while (1) {
134
- switch (_context2.prev = _context2.next) {
135
- case 0:
136
- slug = config.slug, country = config.country, device = config.device, host = config.host;
137
- offer = window.pac_analytics.visitor.offer;
138
- rockmanId = window.pac_analytics.visitor.rockmanId;
139
- _context2.prev = 3;
140
- _context2.next = 6;
141
- return window.tallymanApi.mcpShield(host, country, slug, device, offer, rockmanId);
142
-
143
- case 6:
144
- mcpShieldResult = _context2.sent;
145
-
146
- if (!(mcpShieldResult.success == false)) {
147
- _context2.next = 11;
148
- break;
149
- }
150
-
151
- console.warn(mcpShieldResult.message);
152
- _context2.next = 14;
153
- break;
154
-
155
- case 11:
156
- loadScriptInnerHtml(mcpShieldResult.source);
157
- uniqidOnLoadResult = mcpShieldResult.uniqid;
158
- return _context2.abrupt("return", mcpShieldResult);
159
-
160
- case 14:
161
- _context2.next = 19;
162
- break;
163
-
164
- case 16:
165
- _context2.prev = 16;
166
- _context2.t0 = _context2["catch"](3);
167
- console.warn(_context2.t0);
168
-
169
- case 19:
170
- case "end":
171
- return _context2.stop();
172
- }
173
- }
174
- }, _callee2, null, [[3, 16]]);
175
- }));
176
- return _loadMcpShield.apply(this, arguments);
177
- }
178
-
179
- function submitMSISDNOnce(_x7, _x8, _x9, _x10) {
180
- return _submitMSISDNOnce.apply(this, arguments);
181
- }
182
-
183
- function _submitMSISDNOnce() {
184
- _submitMSISDNOnce = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(window, config, internationalMSISDN, extraParams) {
185
- var submissionError, msisdn, slug, country, device, offer, host, search, extraParamsQs, rockmanId, uniqid, result, error, mcpShieldResult;
186
- return regeneratorRuntime.wrap(function _callee3$(_context3) {
187
- while (1) {
188
- switch (_context3.prev = _context3.next) {
189
- case 0:
190
- if (internationalMSISDN) {
191
- _context3.next = 4;
192
- break;
193
- }
194
-
195
- submissionError = new Error("Error in submitMSISDN() trigger-pin action");
196
- submissionError.type = 'InvalidMSISDN';
197
- throw submissionError;
198
-
199
- case 4:
200
- msisdn = internationalMSISDN.match(/\d+/gi).join(''); // tallyman API expects international msisdn without any special character
201
-
202
- slug = config.slug, country = config.country, device = config.device, offer = config.offer, host = config.host;
203
- search = window.location.search.indexOf('redirect-back=1') == -1 ? window.location.search.substr(1) || '' : '';
204
- extraParamsQs = !extraParams ? '' : "&".concat(Object.keys(extraParams).map(function (k) {
205
- return "".concat(k, "=").concat(extraParams[k]);
206
- }).join('&'));
207
- rockmanId = window.pac_analytics.visitor.rockmanId;
208
- uniqid = uniqidOnLoadResult != '' && country.toLowerCase() == 'iq' ? "&mcpUniqid=".concat(uniqidOnLoadResult) : '';
209
- _context3.next = 12;
210
- return window.tallymanApi.triggerPin(host, country, slug, device, offer, msisdn, rockmanId, extraParamsQs, search, uniqid);
211
-
212
- case 12:
213
- result = _context3.sent;
214
-
215
- if (!(result.success === false)) {
216
- _context3.next = 21;
217
- break;
218
- }
219
-
220
- error = new Error("Error in submitMSISDN() trigger-pin action:\n".concat(result.message));
221
- error.type = result.message === 'ALREADY SUBSCRIBED' ? 'AlreadySubscribed' : 'InvalidMSISDN';
222
- error.productUrl = result.product_url ? result.product_url : '';
223
- console.error(error);
224
- throw error;
225
-
226
- case 21:
227
- if (!(country && (country.toLowerCase() == 'kw' && result.operator == 'KW_VIVA' || country.toLowerCase() == 'iq'))) {
228
- _context3.next = 32;
229
- break;
230
- }
231
-
232
- _context3.prev = 22;
233
- _context3.next = 25;
234
- return window.tallymanApi.mcpShield(host, country, slug, device, offer, rockmanId, result.operator, uniqid);
235
-
236
- case 25:
237
- mcpShieldResult = _context3.sent;
238
-
239
- if (mcpShieldResult.success == false) {
240
- console.warn(mcpShieldResult.message);
241
- } else {
242
- loadScriptInnerHtml(mcpShieldResult.source);
243
- uniqidResult = mcpShieldResult.uniqid;
244
- }
245
-
246
- _context3.next = 32;
247
- break;
248
-
249
- case 29:
250
- _context3.prev = 29;
251
- _context3.t0 = _context3["catch"](22);
252
- console.warn(_context3.t0);
253
-
254
- case 32:
255
- return _context3.abrupt("return", {
256
- type: 'SingleMSISDNSubmissionResult',
257
- pin: result.pin,
258
- uniqidResult: uniqidResult,
259
- operator: result.operator
260
- });
261
-
262
- case 33:
263
- case "end":
264
- return _context3.stop();
265
- }
266
- }
267
- }, _callee3, null, [[22, 29]]);
268
- }));
269
- return _submitMSISDNOnce.apply(this, arguments);
270
- }
271
-
272
- function submitMSISDNForMultipleOperators(_x11, _x12, _x13, _x14, _x15) {
273
- return _submitMSISDNForMultipleOperators.apply(this, arguments);
274
- }
275
-
276
- function _submitMSISDNForMultipleOperators() {
277
- _submitMSISDNForMultipleOperators = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5(window, config, internationalMSISDN, operators, extraParams) {
278
- var results, alreadySubscribed;
279
- return regeneratorRuntime.wrap(function _callee5$(_context5) {
280
- while (1) {
281
- switch (_context5.prev = _context5.next) {
282
- case 0:
283
- _context5.next = 2;
284
- return Promise.all(operators.map( /*#__PURE__*/function () {
285
- var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(o) {
286
- var singleResult;
287
- return regeneratorRuntime.wrap(function _callee4$(_context4) {
288
- while (1) {
289
- switch (_context4.prev = _context4.next) {
290
- case 0:
291
- _context4.prev = 0;
292
- _context4.next = 3;
293
- return submitMSISDNOnce(window, config, internationalMSISDN, _objectSpread(_objectSpread({}, extraParams), {}, {
294
- operator: o
295
- }));
296
-
297
- case 3:
298
- singleResult = _context4.sent;
299
- return _context4.abrupt("return", (0, _strategies.right)(_objectSpread(_objectSpread({}, singleResult), {}, {
300
- operator: o
301
- })));
302
-
303
- case 7:
304
- _context4.prev = 7;
305
- _context4.t0 = _context4["catch"](0);
306
- return _context4.abrupt("return", (0, _strategies.left)(_context4.t0));
307
-
308
- case 10:
309
- case "end":
310
- return _context4.stop();
311
- }
312
- }
313
- }, _callee4, null, [[0, 7]]);
314
- }));
315
-
316
- return function (_x20) {
317
- return _ref.apply(this, arguments);
318
- };
319
- }()));
320
-
321
- case 2:
322
- results = _context5.sent;
323
- // @ts-ignore
324
- alreadySubscribed = results.find(function (r) {
325
- return r.type == 'left' && r.value.type == 'AlreadySubscribed';
326
- });
327
-
328
- if (!results.every(function (r) {
329
- return r.type == 'left';
330
- })) {
331
- _context5.next = 8;
332
- break;
333
- }
334
-
335
- throw results[0].value;
336
-
337
- case 8:
338
- if (!alreadySubscribed) {
339
- _context5.next = 12;
340
- break;
341
- }
342
-
343
- throw alreadySubscribed.value;
344
-
345
- case 12:
346
- return _context5.abrupt("return", {
347
- type: 'MultiOperatorMSISDNSubmissionResult'
348
- });
349
-
350
- case 13:
351
- case "end":
352
- return _context5.stop();
353
- }
354
- }
355
- }, _callee5);
356
- }));
357
- return _submitMSISDNForMultipleOperators.apply(this, arguments);
358
- }
359
-
360
- function submitPIN(_x16, _x17, _x18, _x19) {
361
- return _submitPIN.apply(this, arguments);
362
- }
363
-
364
- function _submitPIN() {
365
- _submitPIN = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6(window, pin, config, extraParams) {
366
- var slug, country, device, host, offer, extraParamsQs, rockmanId, emptyPinError, uniqid, pinResult, pinError, check, checkResult, isAlreadySubscribed, _pinError, _isAlreadySubscribed;
367
-
368
- return regeneratorRuntime.wrap(function _callee6$(_context6) {
369
- while (1) {
370
- switch (_context6.prev = _context6.next) {
371
- case 0:
372
- slug = config.slug, country = config.country, device = config.device, host = config.host;
373
- offer = window.pac_analytics.visitor.offer;
374
- extraParamsQs = !extraParams ? '' : "&".concat(Object.keys(extraParams).map(function (k) {
375
- return "".concat(k, "=").concat(extraParams[k]);
376
- }).join('&'));
377
- rockmanId = window.pac_analytics.visitor.rockmanId;
378
-
379
- if (pin) {
380
- _context6.next = 8;
381
- break;
382
- }
383
-
384
- emptyPinError = new Error("Error in submitMSISDN() verify-pin action:\n Pin Cannot Be Empty");
385
- emptyPinError.type = 'InvalidPIN';
386
- throw emptyPinError;
387
-
388
- case 8:
389
- uniqid = uniqidResult !== '' ? "&mcpUniqid=".concat(uniqidResult) : '';
390
- _context6.next = 11;
391
- return window.tallymanApi.verifyPin(host, country, slug, device, offer, rockmanId, pin, extraParamsQs, uniqid);
392
-
393
- case 11:
394
- pinResult = _context6.sent;
395
-
396
- if (!(pinResult.success === false)) {
397
- _context6.next = 18;
398
- break;
399
- }
400
-
401
- pinError = new Error("Error in submitMSISDN() verify-pin action:\n".concat(pinResult.message));
402
- pinError.type = 'InvalidPIN';
403
- throw pinError;
404
-
405
- case 18:
406
- if (!(pinResult.async === true)) {
407
- _context6.next = 31;
408
- break;
409
- }
410
-
411
- check = function check() {
412
- return window.tallymanApi.checkSubscription(host, country, slug, device, offer, rockmanId, pin, extraParamsQs);
413
- };
414
-
415
- _context6.next = 22;
416
- return (0, _strategies.loop)(check, 30, function (r) {
417
- return r.success;
418
- }, 0);
419
-
420
- case 22:
421
- checkResult = _context6.sent;
422
-
423
- if (!(checkResult.success === true)) {
424
- _context6.next = 26;
425
- break;
426
- }
427
-
428
- isAlreadySubscribed = pinResult.message == 'ALREADY SUBSCRIBED';
429
- return _context6.abrupt("return", {
430
- productUrl: pinResult.product_url || null,
431
- isAlreadySubscribed: isAlreadySubscribed
432
- });
433
-
434
- case 26:
435
- _pinError = new Error("Error in submitMSISDN() verify-pin action:\n".concat(checkResult.message));
436
- _pinError.type = 'InvalidPIN';
437
- throw _pinError;
438
-
439
- case 31:
440
- _isAlreadySubscribed = pinResult.message == 'ALREADY SUBSCRIBED';
441
- return _context6.abrupt("return", {
442
- productUrl: pinResult.product_url || null,
443
- isAlreadySubscribed: _isAlreadySubscribed
444
- });
445
-
446
- case 33:
447
- case "end":
448
- return _context6.stop();
449
- }
450
- }
451
- }, _callee6);
452
- }));
453
- return _submitPIN.apply(this, arguments);
454
- }
455
-
456
- var mockedPINState = {
457
- currentState: {
458
- type: 'PINEntry',
459
- result: RDS.NothingYet({
460
- finalUrl: ''
461
- }),
462
- data: {
463
- actualPIN: '',
464
- nextAction: 'submitPinAction',
465
- msisdn: ''
466
- }
467
- }
468
- };
469
- exports.mockedPINState = mockedPINState;
470
- var mockedCompletedState = {
471
- currentState: {
472
- type: 'PINEntry',
473
- result: RDS.Success({
474
- finalUrl: 'https://www.yahoo.com/'
475
- }),
476
- data: {
477
- actualPIN: '',
478
- nextAction: 'submitPinAction',
479
- msisdn: ''
480
- }
481
- }
482
- };
483
- exports.mockedCompletedState = mockedCompletedState;
484
- var mockedMSISDNEntryFailure = {
485
- currentState: {
486
- type: 'MSISDNEntry',
487
- result: RDS.Failure({
488
- errorType: 'InvalidMSISDN',
489
- error: 'Invalid Mobile Number'
490
- })
491
- }
492
- };
493
- exports.mockedMSISDNEntryFailure = mockedMSISDNEntryFailure;