ouisys-engine 3.0.3 → 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 +38 -38
  53. package/dist/reducers/pinFlow/IPinConstants.d.ts +1 -1
  54. package/dist/reducers/pinFlow/PinTypes.d.ts +23 -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 +2 -2
  64. package/dist/reducers/strategy/strategies/ask_mobile_number.js +78 -78
  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 -219
  174. package/src/reducers/pinFlow/IPinConstants.ts +0 -9
  175. package/src/reducers/pinFlow/PinTypes.ts +0 -190
  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 -376
  180. package/src/reducers/strategy/index.ts +0 -322
  181. package/src/reducers/strategy/strategies/ask_mobile_number.ts +0 -366
  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
@@ -1,704 +0,0 @@
1
- "use strict";
2
-
3
- require("core-js/modules/es.symbol");
4
-
5
- require("core-js/modules/es.symbol.description");
6
-
7
- require("core-js/modules/es.symbol.iterator");
8
-
9
- require("core-js/modules/es.array.concat");
10
-
11
- require("core-js/modules/es.array.filter");
12
-
13
- require("core-js/modules/es.array.from");
14
-
15
- require("core-js/modules/es.array.iterator");
16
-
17
- require("core-js/modules/es.array.join");
18
-
19
- require("core-js/modules/es.array.map");
20
-
21
- require("core-js/modules/es.array.slice");
22
-
23
- require("core-js/modules/es.function.name");
24
-
25
- require("core-js/modules/es.object.get-own-property-descriptor");
26
-
27
- require("core-js/modules/es.object.get-own-property-descriptors");
28
-
29
- require("core-js/modules/es.object.keys");
30
-
31
- require("core-js/modules/es.object.to-string");
32
-
33
- require("core-js/modules/es.promise");
34
-
35
- require("core-js/modules/es.regexp.exec");
36
-
37
- require("core-js/modules/es.regexp.to-string");
38
-
39
- require("core-js/modules/es.string.iterator");
40
-
41
- require("core-js/modules/es.string.match");
42
-
43
- require("core-js/modules/es.string.replace");
44
-
45
- require("core-js/modules/es.string.search");
46
-
47
- require("core-js/modules/es.string.split");
48
-
49
- require("core-js/modules/web.dom-collections.for-each");
50
-
51
- require("core-js/modules/web.dom-collections.iterator");
52
-
53
- require("core-js/modules/web.url");
54
-
55
- Object.defineProperty(exports, "__esModule", {
56
- value: true
57
- });
58
- exports.default = void 0;
59
- exports.determineFlowByMsidn = determineFlowByMsidn;
60
- exports.determineFlowByOperator = determineFlowByOperator;
61
- exports.determineFlowByOperatorFromIp = determineFlowByOperatorFromIp;
62
- exports.getConfig = void 0;
63
- exports.getOperators = getOperators;
64
- exports.identifyUser = void 0;
65
- exports.left = left;
66
- exports.loop = void 0;
67
- exports.mockConfig = mockConfig;
68
- exports.right = right;
69
- exports.wait = exports.subscribe = exports.searchToObject = void 0;
70
-
71
- require("regenerator-runtime/runtime");
72
-
73
- var _tryGetIPRangeName = _interopRequireDefault(require("../ips/tryGetIPRangeName"));
74
-
75
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
76
-
77
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
78
-
79
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
80
-
81
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
82
-
83
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
84
-
85
- function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
86
-
87
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
88
-
89
- 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; }
90
-
91
- 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; }
92
-
93
- 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; }
94
-
95
- 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); } }
96
-
97
- 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); }); }; }
98
-
99
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
100
- // @ts-ignore
101
- var wait = function wait(ms) {
102
- return new Promise(function (resolve) {
103
- return setTimeout(function () {
104
- return resolve();
105
- }, ms);
106
- });
107
- }; // eslint-disable-next-line @typescript-eslint/ban-ts-comment
108
- // @ts-ignore
109
-
110
-
111
- exports.wait = wait;
112
-
113
- var loop = /*#__PURE__*/function () {
114
- var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(f, max, stop, i) {
115
- var r;
116
- return regeneratorRuntime.wrap(function _callee$(_context) {
117
- while (1) {
118
- switch (_context.prev = _context.next) {
119
- case 0:
120
- _context.next = 2;
121
- return f();
122
-
123
- case 2:
124
- r = _context.sent;
125
-
126
- if (!(stop(r) || i >= max)) {
127
- _context.next = 5;
128
- break;
129
- }
130
-
131
- return _context.abrupt("return", r);
132
-
133
- case 5:
134
- _context.next = 7;
135
- return wait(1000);
136
-
137
- case 7:
138
- return _context.abrupt("return", loop(f, max, stop, i + 1));
139
-
140
- case 8:
141
- case "end":
142
- return _context.stop();
143
- }
144
- }
145
- }, _callee);
146
- }));
147
-
148
- return function loop(_x, _x2, _x3, _x4) {
149
- return _ref.apply(this, arguments);
150
- };
151
- }();
152
-
153
- exports.loop = loop;
154
-
155
- function right(r) {
156
- return {
157
- type: 'right',
158
- value: r
159
- };
160
- }
161
-
162
- function left(l) {
163
- return {
164
- type: 'left',
165
- value: l
166
- };
167
- }
168
-
169
- var getConfig = function getConfig(configs) {
170
- if (configs) {
171
- return configs;
172
- }
173
-
174
- if (process.env.NODE_ENV === 'test') {
175
- // eslint-disable-next-line import/no-unresolved
176
- var pageConfigs = require('../../mockData/config.json');
177
-
178
- return pageConfigs || null;
179
- }
180
-
181
- try {
182
- // eslint-disable-next-line import/no-unresolved
183
- var _pageConfigs = require('../../../../config.json');
184
-
185
- return _pageConfigs || null;
186
- } catch (err) {
187
- return null;
188
- }
189
- };
190
-
191
- exports.getConfig = getConfig;
192
-
193
- var searchToObject = function searchToObject() {
194
- if (typeof window !== 'undefined') {
195
- return window.location.search.substring(1).split('&').filter(function (x) {
196
- return !!x && x.length > 0;
197
- }).map(function (kv) {
198
- return kv.split('=');
199
- }).reduce(function (a, b) {
200
- return _objectSpread(_objectSpread({}, a), {}, _defineProperty({}, b[0], b[1]));
201
- }, {});
202
- }
203
-
204
- return {};
205
- };
206
-
207
- exports.searchToObject = searchToObject;
208
-
209
- function determineFlowByMsidn(_x5) {
210
- return _determineFlowByMsidn.apply(this, arguments);
211
- }
212
-
213
- function _determineFlowByMsidn() {
214
- _determineFlowByMsidn = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5(_ref2) {
215
- var internationalMSISDN, configs, defaultFlowConfig, operatorsConfig, submissionError, msisdn, indentifyFlow, theResult, flow, cannotDetect, hlrError, _submissionError, flowObj, _flowObj, _submissionError2;
216
-
217
- return regeneratorRuntime.wrap(function _callee5$(_context5) {
218
- while (1) {
219
- switch (_context5.prev = _context5.next) {
220
- case 0:
221
- internationalMSISDN = _ref2.internationalMSISDN, configs = _ref2.configs;
222
- defaultFlowConfig = configs.strategyConfigs.default;
223
- operatorsConfig = configs.strategyConfigs.operators;
224
-
225
- if (internationalMSISDN) {
226
- _context5.next = 7;
227
- break;
228
- }
229
-
230
- submissionError = new Error("Error in submitMSISDN() trigger-pin action");
231
- submissionError.type = 'SEInvalidMSISDN';
232
- throw submissionError;
233
-
234
- case 7:
235
- msisdn = internationalMSISDN.match(/\d+/gi).join(''); // tallyman API expects international msisdn without any special character
236
-
237
- indentifyFlow = /*#__PURE__*/function () {
238
- var _ref12 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() {
239
- var config, slug, country, device, host, rockmanId, offer, flowOperatorResult;
240
- return regeneratorRuntime.wrap(function _callee4$(_context4) {
241
- while (1) {
242
- switch (_context4.prev = _context4.next) {
243
- case 0:
244
- config = defaultFlowConfig.flowConfig;
245
- slug = config.slug, country = config.country, device = config.device, host = config.host;
246
- rockmanId = window.pac_analytics.visitor.rockmanId;
247
- offer = window.pac_analytics.visitor.offer;
248
- _context4.next = 6;
249
- return window.tallymanApi.identify(host, slug, country, msisdn, device, offer, rockmanId);
250
-
251
- case 6:
252
- flowOperatorResult = _context4.sent;
253
- return _context4.abrupt("return", flowOperatorResult);
254
-
255
- case 8:
256
- case "end":
257
- return _context4.stop();
258
- }
259
- }
260
- }, _callee4);
261
- }));
262
-
263
- return function indentifyFlow() {
264
- return _ref12.apply(this, arguments);
265
- };
266
- }();
267
-
268
- _context5.next = 11;
269
- return indentifyFlow();
270
-
271
- case 11:
272
- theResult = _context5.sent;
273
- flow = operatorsConfig[theResult.operator] ? operatorsConfig[theResult.operator] : null;
274
- cannotDetect = theResult.success === false && theResult.message === 'Operator could not be found for the given MSISDN';
275
- hlrError = theResult.success === false && theResult.message.indexOf('HLR did not find the operator for given MSISDN') !== -1;
276
-
277
- if (!(cannotDetect || hlrError)) {
278
- _context5.next = 22;
279
- break;
280
- }
281
-
282
- _submissionError = new Error("Error in submitMSISDN() identify flow");
283
- _submissionError.type = 'FlowDetectFailed';
284
- _submissionError.msisdn = msisdn;
285
- throw _submissionError;
286
-
287
- case 22:
288
- if (!(flow !== null)) {
289
- _context5.next = 27;
290
- break;
291
- }
292
-
293
- flowObj = _objectSpread({
294
- operator: theResult.operator,
295
- default: defaultFlowConfig
296
- }, flow);
297
- return _context5.abrupt("return", flowObj);
298
-
299
- case 27:
300
- if (!(flow === null)) {
301
- _context5.next = 32;
302
- break;
303
- }
304
-
305
- _flowObj = _objectSpread({
306
- operator: theResult.operator
307
- }, defaultFlowConfig);
308
- return _context5.abrupt("return", _flowObj);
309
-
310
- case 32:
311
- _submissionError2 = new Error("Error in submitMSISDN() trigger-pin action");
312
- _submissionError2.type = 'SEInvalidMSISDN';
313
- throw _submissionError2;
314
-
315
- case 35:
316
- case "end":
317
- return _context5.stop();
318
- }
319
- }
320
- }, _callee5);
321
- }));
322
- return _determineFlowByMsidn.apply(this, arguments);
323
- }
324
-
325
- function determineFlowByOperator(_ref3) {
326
- var operator = _ref3.operator,
327
- configs = _ref3.configs;
328
- var defaultFlowConfig = configs.strategyConfigs.default;
329
- var operatorsConfig = configs.strategyConfigs.operators;
330
-
331
- var flowObj = _objectSpread({
332
- operator: operator,
333
- default: defaultFlowConfig
334
- }, operatorsConfig[operator]);
335
-
336
- return flowObj;
337
- }
338
-
339
- function determineFlowByOperatorFromIp(_x6) {
340
- return _determineFlowByOperatorFromIp.apply(this, arguments);
341
- } // if operator from server
342
- // no need for this
343
-
344
-
345
- function _determineFlowByOperatorFromIp() {
346
- _determineFlowByOperatorFromIp = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6(_ref4) {
347
- var configs, operator, flowObj;
348
- return regeneratorRuntime.wrap(function _callee6$(_context6) {
349
- while (1) {
350
- switch (_context6.prev = _context6.next) {
351
- case 0:
352
- configs = _ref4.configs;
353
- _context6.next = 3;
354
- return (0, _tryGetIPRangeName.default)(window.pac_analytics.visitor);
355
-
356
- case 3:
357
- operator = _context6.sent;
358
- flowObj = determineFlowByOperator({
359
- operator: operator ? operator.toUpperCase() : '',
360
- configs: configs
361
- });
362
- return _context6.abrupt("return", flowObj);
363
-
364
- case 6:
365
- case "end":
366
- return _context6.stop();
367
- }
368
- }
369
- }, _callee6);
370
- }));
371
- return _determineFlowByOperatorFromIp.apply(this, arguments);
372
- }
373
-
374
- function getOperators(_ref5) {
375
- var configs = _ref5.configs;
376
- var operatorsConfig = configs.strategyConfigs.operators;
377
- var operators = Object.keys(operatorsConfig);
378
- return operators;
379
- }
380
-
381
- var fetchJsonp = function fetchJsonp(_url) {
382
- var url = _url;
383
- var ouisysCallbackFunction = "ouisys_callback_function".concat(Math.floor(Math.random() * 10000));
384
- return new Promise(function (resolve, reject) {
385
- // @ts-ignore
386
- window[ouisys_callback_function] = function (arg) {
387
- resolve(arg);
388
- };
389
-
390
- url += url.indexOf('?') === -1 ? '?' : '&';
391
- url += "jsonp=".concat(ouisysCallbackFunction);
392
- var script = document.createElement('script');
393
- script.src = url;
394
- script.id = ouisysCallbackFunction;
395
- document.body.appendChild(script); // Caught if got 404/500
396
-
397
- script.onerror = function () {
398
- reject(new Error("JSONP request to ".concat(_url, " failed")));
399
- };
400
- });
401
- };
402
-
403
- var identifyUser = /*#__PURE__*/function () {
404
- var _ref7 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(_ref6) {
405
- var configs, extraParams, defaultFlowConfig, config, host, country, slug, queryString, device, bupperizeCountry, offer, rockmanId, s, search, extraParamsQs, isDMB, newHost, searchObj, isSuccess, identifyError, subscriptionUrl, _newUrl, _queryString2, _urlParams, _msisdn, _operator, url2, redirectUrl, _newUrl2, _queryString3, _urlParams2, _msisdn2, _operator2, newUrl, _queryString, urlParams, msisdn, operator, _url2, result, _identifyError;
406
-
407
- return regeneratorRuntime.wrap(function _callee2$(_context2) {
408
- while (1) {
409
- switch (_context2.prev = _context2.next) {
410
- case 0:
411
- configs = _ref6.configs, extraParams = _ref6.extraParams;
412
- defaultFlowConfig = configs.strategyConfigs.default;
413
-
414
- if (!(typeof window === 'undefined')) {
415
- _context2.next = 6;
416
- break;
417
- }
418
-
419
- throw "javascript: console.error('SSR'); void 6";
420
-
421
- case 6:
422
- config = defaultFlowConfig.flowConfig;
423
- host = config.host, country = config.country, slug = config.slug, queryString = config.queryString, device = config.device;
424
-
425
- bupperizeCountry = function bupperizeCountry(c) {
426
- return c == 'gb' ? 'uk' : c;
427
- };
428
-
429
- offer = window.pac_analytics.visitor.offer;
430
- rockmanId = window.pac_analytics.visitor.rockmanId;
431
- s = window.location.search.substr(1);
432
- search = (!!s && s.length > 0 ? [s] : []).concat((queryString || []).map(function (_ref8) {
433
- var _ref9 = _slicedToArray(_ref8, 2),
434
- k = _ref9[0],
435
- v = _ref9[1];
436
-
437
- return "".concat(k, "=").concat(v);
438
- })).join('&');
439
- extraParamsQs = !extraParams ? '' : "&".concat(Object.keys(extraParams).map(function (k) {
440
- return "".concat(k, "=").concat(extraParams[k]);
441
- }).join('&'));
442
- isDMB = !!(window.pac_analytics.visitor.xaid != null && (window.pac_analytics.visitor.xaid.toLowerCase().indexOf('dmb') != -1 || window.pac_analytics.visitor.xaid.toLowerCase().indexOf('amb')) != -1);
443
- newHost = isDMB ? 'de.tallymans.com' : host;
444
- searchObj = searchToObject();
445
-
446
- if (!(!!searchObj['redirect-back'] && searchObj['redirect-back'] == '1' && !!searchObj.success)) {
447
- _context2.next = 52;
448
- break;
449
- }
450
-
451
- isSuccess = searchObj.success === 'true';
452
-
453
- if (!(isSuccess == false)) {
454
- _context2.next = 25;
455
- break;
456
- }
457
-
458
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
459
- // @ts-ignore
460
- identifyError = new Error( // eslint-disable-next-line @typescript-eslint/ban-ts-comment
461
- // @ts-ignore
462
- "Error in getRedirectUrl() identify-user action:\n".concat(searchObj.message || 'NotOn3g') // eslint-disable-next-line @typescript-eslint/ban-ts-comment
463
- // @ts-ignore
464
- );
465
- identifyError.type = 'NotOn3g'; // identifyError['next_action'] = result.next_action;
466
-
467
- throw identifyError;
468
-
469
- case 25:
470
- if (!searchObj.subscription_url) {
471
- _context2.next = 33;
472
- break;
473
- }
474
-
475
- // eslint-disable-next-line camelcase
476
- subscriptionUrl = window.atob(searchObj.subscription_url);
477
- _newUrl = new URL(subscriptionUrl);
478
- _queryString2 = _newUrl.search;
479
- _urlParams = new URLSearchParams(_queryString2);
480
- _msisdn = _urlParams.get('msisdn') || null;
481
- _operator = _urlParams.get('operator') || null;
482
- return _context2.abrupt("return", {
483
- subscriptionUrl: subscriptionUrl,
484
- action: function action() {
485
- return subscribe(subscriptionUrl);
486
- },
487
- msisdn: _msisdn,
488
- operator: _operator
489
- });
490
-
491
- case 33:
492
- if (!searchObj.redirect_url) {
493
- _context2.next = 44;
494
- break;
495
- }
496
-
497
- url2 = "https://de.tallymans.com/tallyman/v1/?action=redirect&country=".concat(bupperizeCountry(country), "&slug=").concat(slug, "&device=", 'smart', "&offerId=").concat(offer, "&rockman_id=").concat(rockmanId, "&auto-redirect=1&").concat(extraParamsQs); // const result2 = await fetch(url2).then(x => x.json())
498
- // eslint-disable-next-line camelcase
499
-
500
- redirectUrl = window.atob(searchObj.redirect_url);
501
- _newUrl2 = new URL(redirectUrl);
502
- _queryString3 = _newUrl2.search;
503
- _urlParams2 = new URLSearchParams(_queryString3);
504
- _msisdn2 = _urlParams2.get('msisdn') || null;
505
- _operator2 = _urlParams2.get('operator') || null;
506
-
507
- if (!(_msisdn2 != null)) {
508
- _context2.next = 43;
509
- break;
510
- }
511
-
512
- return _context2.abrupt("return", {
513
- subscriptionUrl: url2,
514
- msisdn: _msisdn2,
515
- operator: _operator2
516
- });
517
-
518
- case 43:
519
- return _context2.abrupt("return", {
520
- redirectUrl: redirectUrl,
521
- msisdn: _msisdn2,
522
- operator: _operator2
523
- });
524
-
525
- case 44:
526
- newUrl = new URL(window.location.href); // eslint-disable-next-line @typescript-eslint/no-shadow
527
-
528
- _queryString = newUrl.search;
529
- urlParams = new URLSearchParams(_queryString);
530
- msisdn = urlParams.get('msisdn') || null;
531
- operator = urlParams.get('operator') || null;
532
- return _context2.abrupt("return", {
533
- msisdn: msisdn,
534
- operator: operator
535
- });
536
-
537
- case 50:
538
- _context2.next = 63;
539
- break;
540
-
541
- case 52:
542
- _url2 = "https://".concat(newHost, "/tallyman/v1/?action=identify-user&country=").concat(bupperizeCountry(country), "&slug=").concat(slug, "&device=").concat(device, "&offerId=").concat(offer, "&page=").concat(window.location.href, "&pixel_url=").concat(encodeURIComponent("http://c1.ouisys.com/pixels?xcid=".concat(window.location.pathname.replace('/', ''), "&xaid=").concat(window.pac_analytics.visitor.xaid, "&country=").concat(bupperizeCountry(country))), "&rockman_id=").concat(rockmanId).concat(extraParamsQs, "&").concat(search);
543
- _context2.next = 55;
544
- return fetchJsonp(_url2);
545
-
546
- case 55:
547
- result = _context2.sent;
548
-
549
- if (!(result.success === false)) {
550
- _context2.next = 62;
551
- break;
552
- }
553
-
554
- _identifyError = new Error("Error in getRedirectUrl() identify-user action:\n".concat(result.message));
555
- _identifyError.type = 'NotOn3g'; // identifyError['next_action'] = result.next_action;
556
-
557
- throw _identifyError;
558
-
559
- case 62:
560
- return _context2.abrupt("return", {
561
- subscriptionUrl: result.subscription_url || result.redirect_url,
562
- action: function action() {
563
- return subscribe(result.subscription_url);
564
- },
565
- msisdn: result.msisdn,
566
- operator: result.operator
567
- });
568
-
569
- case 63:
570
- case "end":
571
- return _context2.stop();
572
- }
573
- }
574
- }, _callee2);
575
- }));
576
-
577
- return function identifyUser(_x7) {
578
- return _ref7.apply(this, arguments);
579
- };
580
- }();
581
-
582
- exports.identifyUser = identifyUser;
583
-
584
- var subscribe = /*#__PURE__*/function () {
585
- var _ref10 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(url) {
586
- return regeneratorRuntime.wrap(function _callee3$(_context3) {
587
- while (1) {
588
- switch (_context3.prev = _context3.next) {
589
- case 0:
590
- return _context3.abrupt("return", // const result:ISubscribeResult = await fetch(url + "&operator=kw_viva").then((x)=>x.json())
591
- // if(false === result.success){
592
- // const subscribeError = new Error(`Error in subscribe() one-click-subscribe action:\n${result.message}`) as IError & {type:string;}
593
- // subscribeError['type'] = "SubscriptionError";
594
- // throw subscribeError
595
- // }else{
596
- 'www.yahoo.com');
597
-
598
- case 1:
599
- case "end":
600
- return _context3.stop();
601
- }
602
- }
603
- }, _callee3);
604
- }));
605
-
606
- return function subscribe(_x8) {
607
- return _ref10.apply(this, arguments);
608
- };
609
- }(); // }
610
-
611
-
612
- exports.subscribe = subscribe;
613
-
614
- function mockConfig(_ref11) {
615
- var flow = _ref11.flow,
616
- configs = _ref11.configs;
617
- var defaultFlowConfig = configs.strategyConfigs.default;
618
- var operatorsConfig = configs.strategyConfigs.operators;
619
- var opArr = Object.keys(operatorsConfig);
620
- var r = opArr.filter(function (o) {
621
- return operatorsConfig[o].flow === flow;
622
- });
623
- var operator = r[0];
624
-
625
- var flowObj = _objectSpread({
626
- offer: 1,
627
- operator: operator,
628
- default: defaultFlowConfig
629
- }, operatorsConfig[operator]);
630
-
631
- return flowObj;
632
- } // export const mockedPinFlow: IStrategyReducerState = {
633
- // currentState: {
634
- // type: 'PIN',
635
- // result: {
636
- // nextAction: 'submitMSISDNAction',
637
- // config: mockConfig('pin')
638
- // }
639
- // }
640
- // };
641
- // export const mockedMoFlow: IStrategyReducerState = {
642
- // currentState: {
643
- // type: 'MO',
644
- // result: {
645
- // nextAction: 'submitMSISDNAction',
646
- // config: mockConfig('mo')
647
- // }
648
- // }
649
- // };
650
- // export const mockedUssdFlow: IStrategyReducerState = {
651
- // currentState: {
652
- // type: 'USSD',
653
- // result: {
654
- // nextAction: 'submitMSISDNAction',
655
- // config: mockConfig('ussd')
656
- // }
657
- // }
658
- // };
659
- // export const mockedMoRdirFlow: IStrategyReducerState = {
660
- // currentState: {
661
- // type: 'MO_REDIR',
662
- // result: {
663
- // nextAction: 'submitMSISDNAction',
664
- // config: mockConfig('moRedir')
665
- // }
666
- // }
667
- // };
668
- // export const mockedClick2smsFlow: IStrategyReducerState = {
669
- // currentState: {
670
- // type: 'CLICK2SMS',
671
- // result: {
672
- // nextAction: 'loadOc2sms',
673
- // config: mockConfig('click2sms')
674
- // }
675
- // }
676
- // };
677
- // export const mockedOneClickFlow: IStrategyReducerState = {
678
- // currentState: {
679
- // type: 'ONE_CLICK',
680
- // result: {
681
- // nextAction: 'getRedirectUrlAction',
682
- // config: mockConfig('oneClick')
683
- // }
684
- // }
685
- // };
686
- // export const mockedTPayFlow: IStrategyReducerState = {
687
- // currentState: {
688
- // type: 'TPAY_HE',
689
- // result: {
690
- // nextAction: 'loadTpayAction',
691
- // config: mockConfig('tpayHe')
692
- // }
693
- // }
694
- // };
695
-
696
-
697
- var _default = {
698
- getConfig: getConfig
699
- }; // export const mockedMOFlow : State = { type: "MO", result:moFlow(mockTracker, mockConfig("mo"))}
700
- // export const mockedOneClickFlow : State = { type: "ONECLICK", result:oneClickFlow(mockTracker, mockConfig("oneClick"), {"testextraparams":"1"})}
701
- // export const mockedClick2smsFlow : State = { type: "CLICK2SMS", result:click2smsFlow(mockTracker, mockConfig("click2sms"))}
702
- // export const mockedMORedirFlow : State = { type: "MOREDIR", result:moRedirFlow(mockTracker, mockConfig("moRedir"))}
703
-
704
- exports.default = _default;