ouisys-engine 4.3.0-alpha.0 → 4.4.0-alpha.0

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 (158) hide show
  1. package/dist/@types/window.d.js +1 -1
  2. package/dist/api/index.d.ts +43 -0
  3. package/dist/api/index.js +1 -728
  4. package/dist/common-types/AppThunk.d.ts +13 -0
  5. package/dist/common-types/AppThunk.js +1 -1
  6. package/dist/common-types/Either.d.ts +8 -0
  7. package/dist/common-types/Either.js +1 -1
  8. package/dist/common-types/IError.d.ts +3 -0
  9. package/dist/common-types/IError.js +1 -1
  10. package/dist/common-types/IOptInFlowName.d.ts +1 -0
  11. package/dist/common-types/ITracker.d.ts +9 -0
  12. package/dist/common-types/ITracker.js +1 -3
  13. package/dist/common-types/IVisitor.d.ts +14 -0
  14. package/dist/common-types/IVisitor.js +1 -1
  15. package/dist/common-types/RemoteDataState.d.ts +38 -0
  16. package/dist/common-types/RemoteDataState.js +1 -135
  17. package/dist/custom-hooks/useOneClickRedirectUrl.d.ts +3 -0
  18. package/dist/custom-hooks/useOneClickRedirectUrl.js +1 -0
  19. package/dist/custom-hooks/usePinEntryState.d.ts +8 -0
  20. package/dist/custom-hooks/usePinEntryState.js +1 -0
  21. package/dist/custom-hooks/useStrategyConfig.d.ts +4 -0
  22. package/dist/custom-hooks/useStrategyConfig.js +1 -0
  23. package/dist/flows/click2smsFlow.d.ts +6 -0
  24. package/dist/flows/click2smsFlow.js +1 -19
  25. package/dist/flows/creditCardFlow.d.ts +6 -0
  26. package/dist/flows/creditCardFlow.js +1 -0
  27. package/dist/flows/moFlow.d.ts +6 -0
  28. package/dist/flows/moFlow.js +1 -19
  29. package/dist/flows/moRedirFlow.d.ts +6 -0
  30. package/dist/flows/moRedirFlow.js +1 -19
  31. package/dist/flows/oneClickFlow.d.ts +7 -0
  32. package/dist/flows/oneClickFlow.js +1 -23
  33. package/dist/flows/pinFlow.d.ts +7 -0
  34. package/dist/flows/pinFlow.js +1 -23
  35. package/dist/flows/strategy.d.ts +14 -0
  36. package/dist/flows/strategy.js +1 -53
  37. package/dist/flows/ussdFlow.d.ts +6 -0
  38. package/dist/flows/ussdFlow.js +1 -19
  39. package/dist/index.d.ts +0 -0
  40. package/dist/index.js +0 -2
  41. package/dist/ips/tryGetIPRangeName.d.ts +2 -0
  42. package/dist/ips/tryGetIPRangeName.js +1 -74
  43. package/dist/jest.config.js +194 -0
  44. package/dist/pacman/index.d.ts +6 -0
  45. package/dist/pacman/index.js +1 -108
  46. package/dist/pacman/queryString.d.ts +3 -0
  47. package/dist/pacman/queryString.js +1 -45
  48. package/dist/reducers/click2smsFlow/Click2smsTypes.d.ts +76 -0
  49. package/dist/reducers/click2smsFlow/Click2smsTypes.js +1 -1
  50. package/dist/reducers/click2smsFlow/IClick2smsConstants.d.ts +2 -0
  51. package/dist/reducers/click2smsFlow/IClick2smsConstants.js +1 -1
  52. package/dist/reducers/click2smsFlow/index.d.ts +5 -0
  53. package/dist/reducers/click2smsFlow/index.js +1 -183
  54. package/dist/reducers/click2smsFlow/utils.d.ts +4 -0
  55. package/dist/reducers/click2smsFlow/utils.js +1 -357
  56. package/dist/reducers/creditCardFlow/CreditCardTypes.d.ts +79 -0
  57. package/dist/reducers/creditCardFlow/CreditCardTypes.js +1 -0
  58. package/dist/reducers/creditCardFlow/ICreditCardConstants.d.ts +2 -0
  59. package/dist/reducers/creditCardFlow/ICreditCardConstants.js +1 -0
  60. package/dist/reducers/creditCardFlow/index.d.ts +5 -0
  61. package/dist/reducers/creditCardFlow/index.js +1 -0
  62. package/dist/reducers/creditCardFlow/utils.d.ts +8 -0
  63. package/dist/reducers/creditCardFlow/utils.js +1 -0
  64. package/dist/reducers/moFlow/IMoConstants.d.ts +2 -0
  65. package/dist/reducers/moFlow/IMoConstants.js +1 -1
  66. package/dist/reducers/moFlow/MoTypes.d.ts +88 -0
  67. package/dist/reducers/moFlow/MoTypes.js +1 -1
  68. package/dist/reducers/moFlow/index.d.ts +16 -0
  69. package/dist/reducers/moFlow/index.js +1 -251
  70. package/dist/reducers/moFlow/utils.d.ts +12 -0
  71. package/dist/reducers/moFlow/utils.js +1 -284
  72. package/dist/reducers/moRedirFlow/IMoRedirConstants.d.ts +2 -0
  73. package/dist/reducers/moRedirFlow/IMoRedirConstants.js +1 -1
  74. package/dist/reducers/moRedirFlow/MoRedirTypes.d.ts +64 -0
  75. package/dist/reducers/moRedirFlow/MoRedirTypes.js +1 -1
  76. package/dist/reducers/moRedirFlow/index.d.ts +14 -0
  77. package/dist/reducers/moRedirFlow/index.js +1 -226
  78. package/dist/reducers/moRedirFlow/utils.d.ts +10 -0
  79. package/dist/reducers/moRedirFlow/utils.js +1 -186
  80. package/dist/reducers/oneClickFlow/IOneClickConstants.d.ts +2 -0
  81. package/dist/reducers/oneClickFlow/IOneClickConstants.js +1 -1
  82. package/dist/reducers/oneClickFlow/OneClickTypes.d.ts +85 -0
  83. package/dist/reducers/oneClickFlow/OneClickTypes.js +1 -1
  84. package/dist/reducers/oneClickFlow/index.d.ts +13 -0
  85. package/dist/reducers/oneClickFlow/index.js +1 -409
  86. package/dist/reducers/oneClickFlow/utils.d.ts +16 -0
  87. package/dist/reducers/oneClickFlow/utils.js +1 -366
  88. package/dist/reducers/pinFlow/IPinConstants.d.ts +2 -0
  89. package/dist/reducers/pinFlow/IPinConstants.js +1 -1
  90. package/dist/reducers/pinFlow/PinTypes.d.ts +156 -0
  91. package/dist/reducers/pinFlow/PinTypes.js +1 -1
  92. package/dist/reducers/pinFlow/index.d.ts +19 -0
  93. package/dist/reducers/pinFlow/index.js +1 -514
  94. package/dist/reducers/pinFlow/utils.d.ts +11 -0
  95. package/dist/reducers/pinFlow/utils.js +1 -494
  96. package/dist/reducers/strategy/IStategyActionContants.d.ts +2 -0
  97. package/dist/reducers/strategy/IStategyActionContants.js +1 -1
  98. package/dist/reducers/strategy/StrategyTypes.d.ts +248 -0
  99. package/dist/reducers/strategy/StrategyTypes.js +1 -1
  100. package/dist/reducers/strategy/index.d.ts +13 -0
  101. package/dist/reducers/strategy/index.js +1 -389
  102. package/dist/reducers/strategy/strategies/ask_mobile_number.d.ts +15 -0
  103. package/dist/reducers/strategy/strategies/ask_mobile_number.js +1 -403
  104. package/dist/reducers/strategy/strategies/ask_operator.d.ts +5 -0
  105. package/dist/reducers/strategy/strategies/ask_operator.js +1 -305
  106. package/dist/reducers/strategy/strategies/detect_operator_by_ip.d.ts +10 -0
  107. package/dist/reducers/strategy/strategies/detect_operator_by_ip.js +1 -459
  108. package/dist/reducers/strategy/strategies/header_enrichment.d.ts +7 -0
  109. package/dist/reducers/strategy/strategies/header_enrichment.js +1 -783
  110. package/dist/reducers/strategy/strategies/injectHeaderEnrichmentScript.d.ts +2 -0
  111. package/dist/reducers/strategy/strategies/injectHeaderEnrichmentScript.js +1 -0
  112. package/dist/reducers/strategy/utils.d.ts +30 -0
  113. package/dist/reducers/strategy/utils.js +1 -702
  114. package/dist/reducers/ussdFlow/IUssdConstants.d.ts +2 -0
  115. package/dist/reducers/ussdFlow/IUssdConstants.js +1 -1
  116. package/dist/reducers/ussdFlow/UssdTypes.d.ts +77 -0
  117. package/dist/reducers/ussdFlow/UssdTypes.js +1 -1
  118. package/dist/reducers/ussdFlow/index.d.ts +14 -0
  119. package/dist/reducers/ussdFlow/index.js +1 -251
  120. package/dist/reducers/ussdFlow/utils.d.ts +11 -0
  121. package/dist/reducers/ussdFlow/utils.js +1 -225
  122. package/dist/store/index.d.ts +14 -0
  123. package/dist/store/index.js +1 -177
  124. package/dist/store/reducers.d.ts +20 -0
  125. package/dist/store/reducers.js +1 -41
  126. package/dist/utilities/addEmpelloToken.d.ts +4 -0
  127. package/dist/utilities/addEmpelloToken.js +1 -0
  128. package/dist/utilities/handleSubmitNumber.d.ts +21 -0
  129. package/dist/utilities/handleSubmitNumber.js +1 -59
  130. package/dist/utilities/index.d.ts +14 -0
  131. package/dist/utilities/index.js +1 -0
  132. package/dist/utilities/loadScriptInnerHtml.d.ts +2 -0
  133. package/dist/utilities/loadScriptInnerHtml.js +1 -0
  134. package/dist/utilities/loadScriptSrc.d.ts +8 -0
  135. package/dist/utilities/loadScriptSrc.js +1 -0
  136. package/dist/utilities/replaceUrlParam.d.ts +1 -0
  137. package/dist/utilities/replaceUrlParam.js +1 -0
  138. package/dist/utilities/storeMsisdn.d.ts +3 -0
  139. package/dist/utilities/storeMsisdn.js +1 -0
  140. package/package.json +1 -1
  141. package/dist/app/store.js +0 -20
  142. package/dist/features/strategies/categories/askMobileNumber.js +0 -388
  143. package/dist/features/strategies/categories/askOperator.js +0 -313
  144. package/dist/features/strategies/categories/detectOperatorByIp.js +0 -599
  145. package/dist/features/strategies/categories/headerEnrichment.js +0 -665
  146. package/dist/features/strategies/categories/singleFlows/pin.js +0 -1
  147. package/dist/features/strategies/identifySlice.js +0 -355
  148. package/dist/features/strategies/pinFlowSlice.js +0 -338
  149. package/dist/flows/tpayHeFlow.js +0 -23
  150. package/dist/mockServer/browser.js +0 -48
  151. package/dist/mockServer/handlers.js +0 -22
  152. package/dist/mockServer/server.js +0 -48
  153. package/dist/reducers/tpayHeFlow/ITpayHeConstants.js +0 -1
  154. package/dist/reducers/tpayHeFlow/TpayHeTypes.js +0 -1
  155. package/dist/reducers/tpayHeFlow/index.js +0 -331
  156. package/dist/reducers/tpayHeFlow/utils.js +0 -510
  157. package/dist/test/setup.js +0 -24
  158. package/dist/test/test-utils.js +0 -51
@@ -1,514 +1 @@
1
- "use strict";
2
-
3
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _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.filter");
12
-
13
- require("core-js/modules/es.array.iterator");
14
-
15
- require("core-js/modules/es.object.get-own-property-descriptor");
16
-
17
- require("core-js/modules/es.object.get-own-property-descriptors");
18
-
19
- require("core-js/modules/es.object.keys");
20
-
21
- require("core-js/modules/es.object.to-string");
22
-
23
- require("core-js/modules/es.promise");
24
-
25
- require("core-js/modules/es.string.iterator");
26
-
27
- require("core-js/modules/es.weak-map");
28
-
29
- require("core-js/modules/web.dom-collections.for-each");
30
-
31
- require("core-js/modules/web.dom-collections.iterator");
32
-
33
- Object.defineProperty(exports, "__esModule", {
34
- value: true
35
- });
36
- exports.submitMSISDNAction = submitMSISDNAction;
37
- exports.reSubmitMSISDNAction = reSubmitMSISDNAction;
38
- exports.submitPinAction = submitPinAction;
39
- exports.mockPinFlow = mockPinFlow;
40
- exports.backToStart = backToStart;
41
- exports.default = PinFlowReducer;
42
- exports.PinFlowActionMaps = void 0;
43
-
44
- require("regenerator-runtime/runtime");
45
-
46
- var RDS = _interopRequireWildcard(require("../../common-types/RemoteDataState"));
47
-
48
- var _utils = _interopRequireWildcard(require("./utils"));
49
-
50
- var _strategy = require("../strategy");
51
-
52
- function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
53
-
54
- 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; }
55
-
56
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
57
-
58
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
59
-
60
- 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; }
61
-
62
- 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); } }
63
-
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
-
66
- //ACTION CREATORS
67
- function submitMSISDNAction(msisdn, extraParams) {
68
- return /*#__PURE__*/function () {
69
- var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(dispatch, store) {
70
- var currentState, pinFlowCurrentState, config, pinMaxLengthByOp, msisdnSubmissionResult, operator, errorType;
71
- return regeneratorRuntime.wrap(function _callee$(_context) {
72
- while (1) {
73
- switch (_context.prev = _context.next) {
74
- case 0:
75
- currentState = store().strategy.currentState;
76
- pinFlowCurrentState = store().pinFlow.currentState;
77
-
78
- if (!(currentState.type === "PIN")) {
79
- _context.next = 25;
80
- break;
81
- }
82
-
83
- config = currentState.result.config;
84
- pinMaxLengthByOp = {
85
- "SA_MOBILY": 6,
86
- "SA_STC": 4,
87
- "SA_ZAIN": 6
88
- };
89
- _context.prev = 5;
90
- dispatch({
91
- type: "PIN_FLOW_MSISDN_SUBMIT",
92
- payload: _objectSpread(_objectSpread({}, pinFlowCurrentState), {}, {
93
- type: "MSISDNEntry",
94
- result: RDS.Loading()
95
- })
96
- });
97
-
98
- _strategy.tracker.advancedInFlow('tallyman.v1-pin', 'msisdn-submitted', {
99
- msisdn: msisdn
100
- });
101
-
102
- _context.next = 10;
103
- return (0, _utils.default)(window, config, msisdn, extraParams);
104
-
105
- case 10:
106
- msisdnSubmissionResult = _context.sent;
107
- operator = msisdnSubmissionResult.type == "SingleMSISDNSubmissionResult" ? msisdnSubmissionResult.operator : "";
108
- dispatch({
109
- type: "PIN_FLOW_MSISDN_SUBMIT",
110
- payload: _objectSpread(_objectSpread({}, pinFlowCurrentState), {}, {
111
- type: "MSISDNEntry",
112
- result: RDS.Success({})
113
- })
114
- });
115
-
116
- _strategy.tracker.advancedInFlow('tallyman.v1-pin', 'msisdn-submission-success', {
117
- msisdn: msisdn
118
- });
119
-
120
- dispatch({
121
- type: "PIN_FLOW_MSISDN_SUBMIT",
122
- payload: _objectSpread(_objectSpread({}, pinFlowCurrentState), {}, {
123
- type: "PINEntry",
124
- result: RDS.NothingYet(),
125
- data: {
126
- actualPIN: msisdnSubmissionResult.type == "SingleMSISDNSubmissionResult" ? msisdnSubmissionResult.pin : null,
127
- nextAction: "submitPinAction",
128
- msisdn: msisdn,
129
- operator: operator,
130
- pinMaxLength: operator != "" && pinMaxLengthByOp[operator] ? pinMaxLengthByOp[operator] : null
131
- }
132
- })
133
- });
134
- _context.next = 23;
135
- break;
136
-
137
- case 17:
138
- _context.prev = 17;
139
- _context.t0 = _context["catch"](5);
140
- console.warn(_context.t0);
141
- errorType = "AlreadySubscribed" === _context.t0.type ? "AlreadySubscribed" : "InvalidMSISDN" === _context.t0.type ? "InvalidMSISDN" : "UnknownError";
142
-
143
- _strategy.tracker.recedeInFlow('tallyman.v1-pin', 'msisdn-submission-failure', {
144
- msisdn: msisdn,
145
- errorType: errorType || 'UnknownError'
146
- });
147
-
148
- dispatch({
149
- type: "PIN_FLOW_MSISDN_SUBMIT_ERROR",
150
- payload: _objectSpread(_objectSpread({}, pinFlowCurrentState), {}, {
151
- type: "MSISDNEntry",
152
- result: RDS.Failure({
153
- errorType: errorType,
154
- error: _context.t0,
155
- productUrl: _context.t0.productUrl
156
- })
157
- })
158
- });
159
-
160
- case 23:
161
- _context.next = 28;
162
- break;
163
-
164
- case 25:
165
- dispatch({
166
- type: "PIN_FLOW_MSISDN_SUBMIT_ERROR",
167
- payload: _objectSpread(_objectSpread({}, pinFlowCurrentState), {}, {
168
- type: "MSISDNEntry",
169
- result: RDS.Failure({
170
- errorType: "UnknownError",
171
- error: null
172
- })
173
- })
174
- });
175
-
176
- _strategy.tracker.recedeInFlow('tallyman.v1-pin', 'msisdn-submission-failure', {
177
- msisdn: msisdn,
178
- errorType: 'UnexpectedState'
179
- });
180
-
181
- throw "Unexpected state";
182
-
183
- case 28:
184
- case "end":
185
- return _context.stop();
186
- }
187
- }
188
- }, _callee, null, [[5, 17]]);
189
- }));
190
-
191
- return function (_x, _x2) {
192
- return _ref.apply(this, arguments);
193
- };
194
- }();
195
- }
196
-
197
- function reSubmitMSISDNAction(msisdn, extraParams) {
198
- return /*#__PURE__*/function () {
199
- var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(dispatch, store) {
200
- var currentState, pinFlowCurrentState, config, msisdnSubmissionResult, errorType;
201
- return regeneratorRuntime.wrap(function _callee2$(_context2) {
202
- while (1) {
203
- switch (_context2.prev = _context2.next) {
204
- case 0:
205
- currentState = store().strategy.currentState;
206
- pinFlowCurrentState = store().pinFlow.currentState;
207
-
208
- if (!(currentState.type === "PIN")) {
209
- _context2.next = 23;
210
- break;
211
- }
212
-
213
- config = currentState.result.config;
214
- _context2.prev = 4;
215
-
216
- // dispatch({
217
- // type: "PIN_FLOW_MSISDN_SUBMIT",
218
- // payload:{
219
- // type: "MSISDNEntry",
220
- // result: RDS.Loading()
221
- // }
222
- // });
223
- _strategy.tracker.recedeInFlow('tallyman.v1-pin', 'msisdn-resubmission', {
224
- msisdn: msisdn
225
- });
226
-
227
- _strategy.tracker.advancedInFlow('tallyman.v1-pin', 'msisdn-submitted', {
228
- msisdn: msisdn
229
- });
230
-
231
- _context2.next = 9;
232
- return (0, _utils.default)(window, config, msisdn, extraParams);
233
-
234
- case 9:
235
- msisdnSubmissionResult = _context2.sent;
236
- dispatch({
237
- type: "PIN_FLOW_MSISDN_SUBMIT",
238
- payload: _objectSpread(_objectSpread({}, pinFlowCurrentState), {}, {
239
- type: "MSISDNEntry",
240
- result: RDS.Success({})
241
- })
242
- });
243
-
244
- _strategy.tracker.advancedInFlow('tallyman.v1-pin', 'msisdn-submission-success', {
245
- msisdn: msisdn
246
- });
247
-
248
- dispatch({
249
- type: "PIN_FLOW_MSISDN_SUBMIT",
250
- payload: _objectSpread(_objectSpread({}, pinFlowCurrentState), {}, {
251
- type: "PINEntry",
252
- result: RDS.NothingYet(),
253
- data: {
254
- actualPIN: msisdnSubmissionResult.type == "SingleMSISDNSubmissionResult" ? msisdnSubmissionResult.pin : null,
255
- nextAction: "submitPinAction",
256
- msisdn: msisdn
257
- }
258
- })
259
- });
260
- _context2.next = 21;
261
- break;
262
-
263
- case 15:
264
- _context2.prev = 15;
265
- _context2.t0 = _context2["catch"](4);
266
- console.warn(_context2.t0);
267
- errorType = "AlreadySubscribed" === _context2.t0.type ? "AlreadySubscribed" : "InvalidMSISDN" === _context2.t0.type ? "InvalidMSISDN" : "UnknownError";
268
-
269
- _strategy.tracker.recedeInFlow('tallyman.v1-pin', 'msisdn-submission-failure', {
270
- msisdn: msisdn,
271
- errorType: errorType || 'UnknownError'
272
- });
273
-
274
- dispatch({
275
- type: "PIN_FLOW_MSISDN_SUBMIT_ERROR",
276
- payload: _objectSpread(_objectSpread({}, pinFlowCurrentState), {}, {
277
- type: "MSISDNEntry",
278
- result: RDS.Failure({
279
- errorType: errorType,
280
- error: _context2.t0,
281
- productUrl: _context2.t0.productUrl
282
- })
283
- })
284
- });
285
-
286
- case 21:
287
- _context2.next = 26;
288
- break;
289
-
290
- case 23:
291
- dispatch({
292
- type: "PIN_FLOW_MSISDN_SUBMIT_ERROR",
293
- payload: _objectSpread(_objectSpread({}, pinFlowCurrentState), {}, {
294
- type: "MSISDNEntry",
295
- result: RDS.Failure({
296
- errorType: "UnknownError",
297
- error: null
298
- })
299
- })
300
- });
301
-
302
- _strategy.tracker.recedeInFlow('tallyman.v1-pin', 'msisdn-submission-failure', {
303
- msisdn: msisdn,
304
- errorType: 'UnexpectedState'
305
- });
306
-
307
- throw "Unexpected state";
308
-
309
- case 26:
310
- case "end":
311
- return _context2.stop();
312
- }
313
- }
314
- }, _callee2, null, [[4, 15]]);
315
- }));
316
-
317
- return function (_x3, _x4) {
318
- return _ref2.apply(this, arguments);
319
- };
320
- }();
321
- }
322
-
323
- function submitPinAction(msisdn, pin, extraParams) {
324
- return /*#__PURE__*/function () {
325
- var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(dispatch, store) {
326
- var currentState, pinFlowCurrentState, config, result, errorType;
327
- return regeneratorRuntime.wrap(function _callee3$(_context3) {
328
- while (1) {
329
- switch (_context3.prev = _context3.next) {
330
- case 0:
331
- currentState = store().strategy.currentState;
332
- pinFlowCurrentState = store().pinFlow.currentState;
333
- _context3.prev = 2;
334
- dispatch({
335
- type: "PIN_SUBMIT",
336
- payload: _objectSpread(_objectSpread({}, pinFlowCurrentState), {}, {
337
- type: "PINEntry",
338
- result: RDS.Loading()
339
- })
340
- });
341
-
342
- _strategy.tracker.advancedInFlow('tallyman.v1-pin', 'pin-submitted', {
343
- msisdn: msisdn,
344
- pin: pin
345
- });
346
-
347
- if (!(currentState.type === "PIN")) {
348
- _context3.next = 14;
349
- break;
350
- }
351
-
352
- config = currentState.result.config;
353
- _context3.next = 9;
354
- return (0, _utils.submitPIN)(window, pin, config, extraParams);
355
-
356
- case 9:
357
- result = _context3.sent;
358
-
359
- _strategy.tracker.advancedInFlow('tallyman.v1-pin', 'pin-submission-success', {
360
- msisdn: msisdn,
361
- pin: pin,
362
- finalUrl: result
363
- });
364
-
365
- dispatch({
366
- type: "PIN_SUBMIT",
367
- payload: _objectSpread(_objectSpread({}, pinFlowCurrentState), {}, {
368
- type: "PINEntry",
369
- result: RDS.Success({
370
- finalUrl: result.productUrl,
371
- isAlreadySubscribed: result.isAlreadySubscribed || false
372
- })
373
- })
374
- });
375
- _context3.next = 17;
376
- break;
377
-
378
- case 14:
379
- _strategy.tracker.recedeInFlow('tallyman.v1-pin', 'pin-submission-failure', {
380
- msisdn: msisdn,
381
- pin: pin
382
- });
383
-
384
- dispatch({
385
- type: "PIN_SUBMIT_ERROR",
386
- payload: _objectSpread(_objectSpread({}, pinFlowCurrentState), {}, {
387
- type: "PINEntry",
388
- result: RDS.Failure({
389
- errorType: "UnexpectedState"
390
- })
391
- })
392
- });
393
- throw "Unexpected state";
394
-
395
- case 17:
396
- _context3.next = 25;
397
- break;
398
-
399
- case 19:
400
- _context3.prev = 19;
401
- _context3.t0 = _context3["catch"](2);
402
- console.error(_context3.t0);
403
- errorType = "InvalidPIN" === _context3.t0.type ? "InvalidPIN" : "UnknownError";
404
-
405
- _strategy.tracker.recedeInFlow('tallyman.v1-pin', 'pin-submission-failure', {
406
- msisdn: msisdn,
407
- pin: pin
408
- });
409
-
410
- dispatch({
411
- type: "PIN_SUBMIT_ERROR",
412
- payload: _objectSpread(_objectSpread({}, pinFlowCurrentState), {}, {
413
- type: "PINEntry",
414
- result: RDS.Failure({
415
- errorType: errorType
416
- })
417
- })
418
- });
419
-
420
- case 25:
421
- case "end":
422
- return _context3.stop();
423
- }
424
- }
425
- }, _callee3, null, [[2, 19]]);
426
- }));
427
-
428
- return function (_x5, _x6) {
429
- return _ref3.apply(this, arguments);
430
- };
431
- }();
432
- }
433
-
434
- function mockPinFlow(mockState) {
435
- return function (dispatch) {
436
- if (mockState !== undefined) {
437
- switch (mockState) {
438
- case "msisdn-failure-state":
439
- return dispatch({
440
- type: "MOCK_PIN_FLOW_STATE",
441
- payload: _utils.mockedMSISDNEntryFailure.currentState
442
- });
443
-
444
- case "pin-state":
445
- return dispatch({
446
- type: "MOCK_PIN_FLOW_STATE",
447
- payload: _utils.mockedPINState.currentState
448
- });
449
-
450
- case "completed-state":
451
- return dispatch({
452
- type: "MOCK_PIN_FLOW_STATE",
453
- payload: _utils.mockedCompletedState.currentState
454
- });
455
-
456
- default:
457
- throw "Mock Flow not supported";
458
- }
459
- }
460
- };
461
- }
462
-
463
- function backToStart() {
464
- _strategy.tracker.recedeInFlow("tallyman.v1-pin", "pin-submission-backtostart", "requested to change phone number");
465
-
466
- return {
467
- type: "BACK_TO_START",
468
- payload: _objectSpread(_objectSpread({}, pinFlowCurrentState), {}, {
469
- type: "MSISDNEntry",
470
- result: RDS.NothingYet()
471
- })
472
- };
473
- }
474
-
475
- var initialState = {
476
- currentState: {
477
- type: "MSISDNEntry",
478
- result: RDS.NothingYet()
479
- }
480
- };
481
- var PinFlowActionMaps = {
482
- submitMSISDNAction: submitMSISDNAction,
483
- submitPinAction: submitPinAction
484
- };
485
- exports.PinFlowActionMaps = PinFlowActionMaps;
486
-
487
- function PinFlowReducer() {
488
- var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState;
489
- var action = arguments.length > 1 ? arguments[1] : undefined;
490
-
491
- switch (action.type) {
492
- case "PIN_FLOW_MSISDN_SUBMIT":
493
- return (0, _strategy.genericHandler)(state, action.payload);
494
-
495
- case "PIN_FLOW_MSISDN_SUBMIT_ERROR":
496
- return (0, _strategy.genericHandler)(state, action.payload);
497
-
498
- case "PIN_SUBMIT":
499
- return (0, _strategy.genericHandler)(state, action.payload);
500
-
501
- case "BACK_TO_START":
502
- return (0, _strategy.genericHandler)(state, action.payload);
503
-
504
- case "PIN_SUBMIT_ERROR":
505
- return (0, _strategy.genericHandler)(state, action.payload);
506
-
507
- case "MOCK_PIN_FLOW_STATE":
508
- //@ts-ignore
509
- return (0, _strategy.genericHandler)(state, action.payload);
510
-
511
- default:
512
- return state;
513
- }
514
- }
1
+ "use strict";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)}require("core-js/modules/es.object.keys.js"),require("core-js/modules/es.symbol.js"),require("core-js/modules/es.array.filter.js"),require("core-js/modules/es.object.get-own-property-descriptor.js"),require("core-js/modules/web.dom-collections.for-each.js"),require("core-js/modules/es.object.get-own-property-descriptors.js"),require("core-js/modules/es.symbol.description.js"),require("core-js/modules/es.symbol.iterator.js"),require("core-js/modules/es.array.iterator.js"),require("core-js/modules/es.string.iterator.js"),require("core-js/modules/web.dom-collections.iterator.js"),require("core-js/modules/es.symbol.async-iterator.js"),require("core-js/modules/es.symbol.to-string-tag.js"),require("core-js/modules/es.json.to-string-tag.js"),require("core-js/modules/es.math.to-string-tag.js"),require("core-js/modules/es.object.get-prototype-of.js"),require("core-js/modules/es.function.name.js"),require("core-js/modules/es.object.set-prototype-of.js"),require("core-js/modules/es.array.slice.js"),require("core-js/modules/es.weak-map.js"),Object.defineProperty(exports,"__esModule",{value:!0}),exports.PinFlowActionMaps=void 0,exports.backToStart=backToStart,exports.checkLoadingAction=checkLoadingAction,exports.default=PinFlowReducer,exports.mockPinFlow=mockPinFlow,exports.reSubmitMSISDNAction=reSubmitMSISDNAction,exports.submitMSISDNAction=submitMSISDNAction,exports.submitPinAction=submitPinAction,require("core-js/modules/es.array.includes.js"),require("core-js/modules/es.string.includes.js"),require("core-js/modules/es.regexp.exec.js"),require("core-js/modules/es.string.replace.js"),require("core-js/modules/es.object.to-string.js"),require("core-js/modules/es.promise.js");var _awesomePhonenumber=_interopRequireDefault(require("awesome-phonenumber")),RDS=_interopRequireWildcard(require("../../common-types/RemoteDataState")),_utilities=require("../../utilities"),_storeMsisdn=require("../../utilities/storeMsisdn"),_strategy=require("../strategy"),_utils=require("../strategy/utils"),_utils2=_interopRequireWildcard(require("./utils"));function _getRequireWildcardCache(nodeInterop){if("function"!=typeof WeakMap)return null;var cacheBabelInterop=new WeakMap,cacheNodeInterop=new WeakMap;return(_getRequireWildcardCache=function(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop})(nodeInterop)}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule)return obj;if(null===obj||"object"!==_typeof(obj)&&"function"!=typeof obj)return{default:obj};var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj))return cache.get(obj);var newObj={},hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj)if("default"!=key&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;desc&&(desc.get||desc.set)?Object.defineProperty(newObj,key,desc):newObj[key]=obj[key]}return newObj.default=obj,cache&&cache.set(obj,newObj),newObj}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _regeneratorRuntime(){"use strict";function define(obj,key,value){return Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}),obj[key]}function wrap(innerFn,outerFn,self,tryLocsList){var protoGenerator=outerFn&&outerFn.prototype instanceof Generator?outerFn:Generator,generator=Object.create(protoGenerator.prototype),context=new Context(tryLocsList||[]);return generator._invoke=function(innerFn,self,context){var state="suspendedStart";return function(method,arg){if("executing"===state)throw new Error("Generator is already running");if("completed"===state){if("throw"===method)throw arg;return doneResult()}for(context.method=method,context.arg=arg;;){var delegate=context.delegate;if(delegate){var delegateResult=maybeInvokeDelegate(delegate,context);if(delegateResult){if(delegateResult===ContinueSentinel)continue;return delegateResult}}if("next"===context.method)context.sent=context._sent=context.arg;else if("throw"===context.method){if("suspendedStart"===state)throw state="completed",context.arg;context.dispatchException(context.arg)}else"return"===context.method&&context.abrupt("return",context.arg);state="executing";var record=tryCatch(innerFn,self,context);if("normal"===record.type){if(state=context.done?"completed":"suspendedYield",record.arg===ContinueSentinel)continue;return{value:record.arg,done:context.done}}"throw"===record.type&&(state="completed",context.method="throw",context.arg=record.arg)}}}(innerFn,self,context),generator}function tryCatch(fn,obj,arg){try{return{type:"normal",arg:fn.call(obj,arg)}}catch(err){return{type:"throw",arg:err}}}function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}function defineIteratorMethods(prototype){["next","throw","return"].forEach(function(method){define(prototype,method,function(arg){return this._invoke(method,arg)})})}function AsyncIterator(generator,PromiseImpl){function invoke(method,arg,resolve,reject){var record=tryCatch(generator[method],generator,arg);if("throw"!==record.type){var result=record.arg,value=result.value;return value&&"object"==_typeof(value)&&hasOwn.call(value,"__await")?PromiseImpl.resolve(value.__await).then(function(value){invoke("next",value,resolve,reject)},function(err){invoke("throw",err,resolve,reject)}):PromiseImpl.resolve(value).then(function(unwrapped){result.value=unwrapped,resolve(result)},function(error){return invoke("throw",error,resolve,reject)})}reject(record.arg)}var previousPromise;this._invoke=function(method,arg){function callInvokeWithMethodAndArg(){return new PromiseImpl(function(resolve,reject){invoke(method,arg,resolve,reject)})}return previousPromise=previousPromise?previousPromise.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(delegate,context){var method=delegate.iterator[context.method];if(void 0===method){if(context.delegate=null,"throw"===context.method){if(delegate.iterator.return&&(context.method="return",context.arg=void 0,maybeInvokeDelegate(delegate,context),"throw"===context.method))return ContinueSentinel;context.method="throw",context.arg=new TypeError("The iterator does not provide a 'throw' method")}return ContinueSentinel}var record=tryCatch(method,delegate.iterator,context.arg);if("throw"===record.type)return context.method="throw",context.arg=record.arg,context.delegate=null,ContinueSentinel;var info=record.arg;return info?info.done?(context[delegate.resultName]=info.value,context.next=delegate.nextLoc,"return"!==context.method&&(context.method="next",context.arg=void 0),context.delegate=null,ContinueSentinel):info:(context.method="throw",context.arg=new TypeError("iterator result is not an object"),context.delegate=null,ContinueSentinel)}function pushTryEntry(locs){var entry={tryLoc:locs[0]};1 in locs&&(entry.catchLoc=locs[1]),2 in locs&&(entry.finallyLoc=locs[2],entry.afterLoc=locs[3]),this.tryEntries.push(entry)}function resetTryEntry(entry){var record=entry.completion||{};record.type="normal",delete record.arg,entry.completion=record}function Context(tryLocsList){this.tryEntries=[{tryLoc:"root"}],tryLocsList.forEach(pushTryEntry,this),this.reset(!0)}function values(iterable){if(iterable){var iteratorMethod=iterable[iteratorSymbol];if(iteratorMethod)return iteratorMethod.call(iterable);if("function"==typeof iterable.next)return iterable;if(!isNaN(iterable.length)){var i=-1,next=function next(){for(;++i<iterable.length;)if(hasOwn.call(iterable,i))return next.value=iterable[i],next.done=!1,next;return next.value=void 0,next.done=!0,next};return next.next=next}}return{next:doneResult}}function doneResult(){return{value:void 0,done:!0}}_regeneratorRuntime=function(){return exports};var exports={},Op=Object.prototype,hasOwn=Op.hasOwnProperty,$Symbol="function"==typeof Symbol?Symbol:{},iteratorSymbol=$Symbol.iterator||"@@iterator",asyncIteratorSymbol=$Symbol.asyncIterator||"@@asyncIterator",toStringTagSymbol=$Symbol.toStringTag||"@@toStringTag";try{define({},"")}catch(err){define=function(obj,key,value){return obj[key]=value}}exports.wrap=wrap;var ContinueSentinel={},IteratorPrototype={};define(IteratorPrototype,iteratorSymbol,function(){return this});var getProto=Object.getPrototypeOf,NativeIteratorPrototype=getProto&&getProto(getProto(values([])));NativeIteratorPrototype&&NativeIteratorPrototype!==Op&&hasOwn.call(NativeIteratorPrototype,iteratorSymbol)&&(IteratorPrototype=NativeIteratorPrototype);var Gp=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(IteratorPrototype);return GeneratorFunction.prototype=GeneratorFunctionPrototype,define(Gp,"constructor",GeneratorFunctionPrototype),define(GeneratorFunctionPrototype,"constructor",GeneratorFunction),GeneratorFunction.displayName=define(GeneratorFunctionPrototype,toStringTagSymbol,"GeneratorFunction"),exports.isGeneratorFunction=function(genFun){var ctor="function"==typeof genFun&&genFun.constructor;return!!ctor&&(ctor===GeneratorFunction||"GeneratorFunction"===(ctor.displayName||ctor.name))},exports.mark=function(genFun){return Object.setPrototypeOf?Object.setPrototypeOf(genFun,GeneratorFunctionPrototype):(genFun.__proto__=GeneratorFunctionPrototype,define(genFun,toStringTagSymbol,"GeneratorFunction")),genFun.prototype=Object.create(Gp),genFun},exports.awrap=function(arg){return{__await:arg}},defineIteratorMethods(AsyncIterator.prototype),define(AsyncIterator.prototype,asyncIteratorSymbol,function(){return this}),exports.AsyncIterator=AsyncIterator,exports.async=function(innerFn,outerFn,self,tryLocsList,PromiseImpl){void 0===PromiseImpl&&(PromiseImpl=Promise);var iter=new AsyncIterator(wrap(innerFn,outerFn,self,tryLocsList),PromiseImpl);return exports.isGeneratorFunction(outerFn)?iter:iter.next().then(function(result){return result.done?result.value:iter.next()})},defineIteratorMethods(Gp),define(Gp,toStringTagSymbol,"Generator"),define(Gp,iteratorSymbol,function(){return this}),define(Gp,"toString",function(){return"[object Generator]"}),exports.keys=function(object){var keys=[];for(var key in object)keys.push(key);return keys.reverse(),function next(){for(;keys.length;){var key=keys.pop();if(key in object)return next.value=key,next.done=!1,next}return next.done=!0,next}},exports.values=values,Context.prototype={constructor:Context,reset:function reset(skipTempReset){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(resetTryEntry),!skipTempReset)for(var name in this)"t"===name.charAt(0)&&hasOwn.call(this,name)&&!isNaN(+name.slice(1))&&(this[name]=void 0)},stop:function stop(){this.done=!0;var rootRecord=this.tryEntries[0].completion;if("throw"===rootRecord.type)throw rootRecord.arg;return this.rval},dispatchException:function dispatchException(exception){function handle(loc,caught){return record.type="throw",record.arg=exception,context.next=loc,caught&&(context.method="next",context.arg=void 0),!!caught}if(this.done)throw exception;for(var context=this,i=this.tryEntries.length-1;0<=i;--i){var entry=this.tryEntries[i],record=entry.completion;if("root"===entry.tryLoc)return handle("end");if(entry.tryLoc<=this.prev){var hasCatch=hasOwn.call(entry,"catchLoc"),hasFinally=hasOwn.call(entry,"finallyLoc");if(hasCatch&&hasFinally){if(this.prev<entry.catchLoc)return handle(entry.catchLoc,!0);if(this.prev<entry.finallyLoc)return handle(entry.finallyLoc)}else if(!hasCatch){if(!hasFinally)throw new Error("try statement without catch or finally");if(this.prev<entry.finallyLoc)return handle(entry.finallyLoc)}else if(this.prev<entry.catchLoc)return handle(entry.catchLoc,!0)}}},abrupt:function abrupt(type,arg){for(var entry,i=this.tryEntries.length-1;0<=i;--i)if(entry=this.tryEntries[i],entry.tryLoc<=this.prev&&hasOwn.call(entry,"finallyLoc")&&this.prev<entry.finallyLoc){var finallyEntry=entry;break}finallyEntry&&("break"===type||"continue"===type)&&finallyEntry.tryLoc<=arg&&arg<=finallyEntry.finallyLoc&&(finallyEntry=null);var record=finallyEntry?finallyEntry.completion:{};return record.type=type,record.arg=arg,finallyEntry?(this.method="next",this.next=finallyEntry.finallyLoc,ContinueSentinel):this.complete(record)},complete:function complete(record,afterLoc){if("throw"===record.type)throw record.arg;return"break"===record.type||"continue"===record.type?this.next=record.arg:"return"===record.type?(this.rval=this.arg=record.arg,this.method="return",this.next="end"):"normal"===record.type&&afterLoc&&(this.next=afterLoc),ContinueSentinel},finish:function finish(finallyLoc){for(var entry,i=this.tryEntries.length-1;0<=i;--i)if(entry=this.tryEntries[i],entry.finallyLoc===finallyLoc)return this.complete(entry.completion,entry.afterLoc),resetTryEntry(entry),ContinueSentinel},catch:function _catch(tryLoc){for(var entry,i=this.tryEntries.length-1;0<=i;--i)if(entry=this.tryEntries[i],entry.tryLoc===tryLoc){var record=entry.completion;if("throw"===record.type){var thrown=record.arg;resetTryEntry(entry)}return thrown}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(iterable,resultName,nextLoc){return this.delegate={iterator:values(iterable),resultName:resultName,nextLoc:nextLoc},"next"===this.method&&(this.arg=void 0),ContinueSentinel}},exports}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}function _objectSpread(target){for(var source,i=1;i<arguments.length;i++)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}function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg),value=info.value}catch(error){return void reject(error)}info.done?resolve(value):Promise.resolve(value).then(_next,_throw)}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value)}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err)}var gen=fn.apply(self,args);_next(void 0)})}}var getConfigByMsisdnPrefix=function(msisdn){var operatorByPrefix=(0,_utilities.getSAOperatorByMsisdnPrefix)(msisdn),flowObj=(0,_utils.determineFlowByOperator)(operatorByPrefix);return flowObj.flowConfig},getInputValuePrefix=function(country,international){var pn=new _awesomePhonenumber.default(international,country.toUpperCase());return country&&international?"+".concat(pn.getCountryCode()):""};function submitMSISDNAction(msisdn,extraParams){return function(){var _ref=_asyncToGenerator(_regeneratorRuntime().mark(function _callee(dispatch,store){var currentState,pinFlowCurrentState,_currentState$result,configByStrategy,isUseMsisdnPrefix,isHeaderEnrichmentSuccess,config,prefix,_window,msisdnSubmissionResult,operatorResult,operator,pinMaxLengthByOp,pinPageEvent,errorType;return _regeneratorRuntime().wrap(function _callee$(_context){for(;1;)switch(_context.prev=_context.next){case 0:if(currentState=store().strategy.currentState,pinFlowCurrentState=store().pinFlow.currentState,"PIN"!==currentState.type){_context.next=39;break}return _currentState$result=currentState.result,configByStrategy=_currentState$result.config,isUseMsisdnPrefix=_currentState$result.isUseMsisdnPrefix,isHeaderEnrichmentSuccess=_currentState$result.isHeaderEnrichmentSuccess,config=isUseMsisdnPrefix?getConfigByMsisdnPrefix(msisdn):configByStrategy,"ps"===(null===config||void 0===config?void 0:config.country.toLowerCase())&&null!==config&&void 0!==config&&config.slug.includes("shemaroo")&&(prefix=getInputValuePrefix(null===config||void 0===config?void 0:config.country,msisdn),"+970"===prefix&&(msisdn=msisdn.replace("970","972"))),_context.prev=6,dispatch({type:"PIN_FLOW_MSISDN_SUBMIT",payload:_objectSpread(_objectSpread({},pinFlowCurrentState),{},{type:"MSISDNEntry",result:RDS.Loading()})}),_strategy.tracker.advancedInFlow("tallyman.v1-pin","msisdn-submitted",{msisdn:msisdn}),_context.next=11,(0,_utils2.default)(window,config,msisdn,extraParams);case 11:if(msisdnSubmissionResult=_context.sent,!("SingleMSISDNSubmissionResult"===msisdnSubmissionResult.type&&msisdnSubmissionResult.redirectUrl)){_context.next=16;break}return _strategy.tracker.advancedInFlow("tallyman.v1-pin","msisdn-submission-success",{msisdn:msisdn}),_strategy.tracker.customEvent("Flow","advance-auto","msisdn-redirect",{redirectUrl:msisdnSubmissionResult.redirectUrl}),_context.abrupt("return",window.location.href=msisdnSubmissionResult.redirectUrl);case 16:if(operatorResult="SingleMSISDNSubmissionResult"===msisdnSubmissionResult.type?msisdnSubmissionResult.operator:"",operator=(0,_utilities.hasNumber)(operatorResult)?(0,_utilities.getKeyByValue)(_utilities.mapAgencyOperator,operatorResult):operatorResult,!(extraParams&&extraParams.storeMsisdn&&"true"===extraParams.storeMsisdn)){_context.next=21;break}return _context.next=21,(0,_storeMsisdn.storeMsisdn)(msisdn).then(function(data){data&&data.data&&data.data.success?_strategy.tracker.customEvent("Flow","advance-auto","msisdn-stored-success"):_strategy.tracker.customEvent("Flow","advance-auto","msisdn-stored-failed")}).catch(function(error){_strategy.tracker.customEvent("Flow","advance-auto","msisdn-stored-error",error)});case 21:pinMaxLengthByOp={SA_MOBILY:6,SA_STC:4,SA_ZAIN:4},dispatch({type:"PIN_FLOW_MSISDN_SUBMIT",payload:_objectSpread(_objectSpread({},pinFlowCurrentState),{},{type:"MSISDNEntry",result:RDS.Success({})})}),_strategy.tracker.advancedInFlow("tallyman.v1-pin","msisdn-submission-success",{msisdn:msisdn}),dispatch({type:"PIN_FLOW_MSISDN_SUBMIT",payload:_objectSpread(_objectSpread({},pinFlowCurrentState),{},{type:"PINEntry",result:RDS.NothingYet(),data:{actualPIN:"SingleMSISDNSubmissionResult"===msisdnSubmissionResult.type?msisdnSubmissionResult.pin:null,nextAction:"submitPinAction",msisdn:msisdn,operator:operator,pinMaxLength:""!==operator&&pinMaxLengthByOp[operator]?pinMaxLengthByOp[operator]:null}})}),pinPageEvent=new Event("onPinPage"),null===(_window=window)||void 0===_window?void 0:_window.dispatchEvent(pinPageEvent),_context.next=37;break;case 29:if(_context.prev=29,_context.t0=_context["catch"](6),console.warn(_context.t0),errorType="AlreadySubscribed"===_context.t0.type?"AlreadySubscribed":"InvalidMSISDN"===_context.t0.type?"InvalidMSISDN":"UnknownError",_strategy.tracker.recedeInFlow("tallyman.v1-pin","msisdn-submission-failure",{msisdn:msisdn,errorType:errorType||"UnknownError"}),dispatch({type:"PIN_FLOW_MSISDN_SUBMIT_ERROR",payload:_objectSpread(_objectSpread({},pinFlowCurrentState),{},{type:"MSISDNEntry",result:RDS.Failure({errorType:errorType,error:_context.t0,productUrl:_context.t0.productUrl})})}),!isHeaderEnrichmentSuccess){_context.next=37;break}return _context.abrupt("return",dispatch({type:"IDENTIFY_FLOW_BY_MSISDN_SUBMIT",payload:{type:"PIN",result:{nextAction:"submitMSISDNAction",config:configByStrategy,msisdn:msisdn,isHeaderEnrichmentSuccess:!1}}}));case 37:_context.next=42;break;case 39:throw dispatch({type:"PIN_FLOW_MSISDN_SUBMIT_ERROR",payload:_objectSpread(_objectSpread({},pinFlowCurrentState),{},{type:"MSISDNEntry",result:RDS.Failure({errorType:"UnknownError",error:null})})}),_strategy.tracker.recedeInFlow("tallyman.v1-pin","msisdn-submission-failure",{msisdn:msisdn,errorType:"UnexpectedState"}),new Error("Unexpected state");case 42:case"end":return _context.stop();}},_callee,null,[[6,29]])}));return function(_x,_x2){return _ref.apply(this,arguments)}}()}function checkLoadingAction(){return function(){var _ref2=_asyncToGenerator(_regeneratorRuntime().mark(function _callee2(dispatch,store){var pinFlowCurrentState,checkIsLoading,intervalId;return _regeneratorRuntime().wrap(function _callee2$(_context2){for(;1;)switch(_context2.prev=_context2.next){case 0:checkIsLoading=function _checkIsLoading(){if(!0===window.isLoading)console.log("isLoading is true");else{console.log("isLoading is false"),clearInterval(intervalId),console.log("Stopped checking isLoading.");var productUrl=(0,_utilities.getCookie)("product_url");if(productUrl){var errorType="AlreadySubscribed";_strategy.tracker.recedeInFlow("tallyman.v1-pin","already-subscribed",{errorType:errorType,product_url:productUrl}),dispatch({type:"PIN_FLOW_MSISDN_SUBMIT_ERROR",payload:_objectSpread(_objectSpread({},pinFlowCurrentState),{},{type:"MSISDNEntry",result:RDS.Failure({errorType:errorType,error:"AlreadySubscribed",productUrl:productUrl})})})}else dispatch({type:"PIN_FLOW_MSISDN_SUBMIT_ERROR",payload:{type:"MSISDNEntry",result:RDS.NothingYet()}})}},pinFlowCurrentState=store().pinFlow.currentState,dispatch({type:"PIN_FLOW_MSISDN_SUBMIT",payload:_objectSpread(_objectSpread({},pinFlowCurrentState),{},{type:"MSISDNEntry",result:RDS.Loading()})}),intervalId=setInterval(checkIsLoading,1e3);try{checkIsLoading()}catch(error){console.warn(error),dispatch({type:"PIN_FLOW_MSISDN_SUBMIT_ERROR",payload:{type:"MSISDNEntry",result:RDS.NothingYet()}})}case 5:case"end":return _context2.stop();}},_callee2)}));return function(_x3,_x4){return _ref2.apply(this,arguments)}}()}function reSubmitMSISDNAction(msisdn,extraParams){return function(){var _ref3=_asyncToGenerator(_regeneratorRuntime().mark(function _callee3(dispatch,store){var currentState,pinFlowCurrentState,config,msisdnSubmissionResult,errorType;return _regeneratorRuntime().wrap(function _callee3$(_context3){for(;1;)switch(_context3.prev=_context3.next){case 0:if(currentState=store().strategy.currentState,pinFlowCurrentState=store().pinFlow.currentState,"PIN"!==currentState.type){_context3.next=23;break}return config=currentState.result.config,_context3.prev=4,_strategy.tracker.recedeInFlow("tallyman.v1-pin","msisdn-resubmission",{msisdn:msisdn}),_strategy.tracker.advancedInFlow("tallyman.v1-pin","msisdn-submitted",{msisdn:msisdn}),_context3.next=9,(0,_utils2.default)(window,config,msisdn,extraParams);case 9:msisdnSubmissionResult=_context3.sent,dispatch({type:"PIN_FLOW_MSISDN_SUBMIT",payload:_objectSpread(_objectSpread({},pinFlowCurrentState),{},{type:"MSISDNEntry",result:RDS.Success({})})}),_strategy.tracker.advancedInFlow("tallyman.v1-pin","msisdn-submission-success",{msisdn:msisdn}),dispatch({type:"PIN_FLOW_MSISDN_SUBMIT",payload:_objectSpread(_objectSpread({},pinFlowCurrentState),{},{type:"PINEntry",result:RDS.NothingYet(),data:{actualPIN:"SingleMSISDNSubmissionResult"===msisdnSubmissionResult.type?msisdnSubmissionResult.pin:null,nextAction:"submitPinAction",msisdn:msisdn}})}),_context3.next=21;break;case 15:_context3.prev=15,_context3.t0=_context3["catch"](4),console.warn(_context3.t0),errorType="AlreadySubscribed"===_context3.t0.type?"AlreadySubscribed":"InvalidMSISDN"===_context3.t0.type?"InvalidMSISDN":"UnknownError",_strategy.tracker.recedeInFlow("tallyman.v1-pin","msisdn-submission-failure",{msisdn:msisdn,errorType:errorType||"UnknownError"}),dispatch({type:"PIN_FLOW_MSISDN_SUBMIT_ERROR",payload:_objectSpread(_objectSpread({},pinFlowCurrentState),{},{type:"MSISDNEntry",result:RDS.Failure({errorType:errorType,error:_context3.t0,productUrl:_context3.t0.productUrl})})});case 21:_context3.next=26;break;case 23:throw dispatch({type:"PIN_FLOW_MSISDN_SUBMIT_ERROR",payload:_objectSpread(_objectSpread({},pinFlowCurrentState),{},{type:"MSISDNEntry",result:RDS.Failure({errorType:"UnknownError",error:null})})}),_strategy.tracker.recedeInFlow("tallyman.v1-pin","msisdn-submission-failure",{msisdn:msisdn,errorType:"UnexpectedState"}),new Error("Unexpected state");case 26:case"end":return _context3.stop();}},_callee3,null,[[4,15]])}));return function(_x5,_x6){return _ref3.apply(this,arguments)}}()}function submitPinAction(msisdn,pin,extraParams){return function(){var _ref4=_asyncToGenerator(_regeneratorRuntime().mark(function _callee4(dispatch,store){var currentState,pinFlowCurrentState,config,result,errorType;return _regeneratorRuntime().wrap(function _callee4$(_context4){for(;1;)switch(_context4.prev=_context4.next){case 0:if(currentState=store().strategy.currentState,pinFlowCurrentState=store().pinFlow.currentState,_context4.prev=2,dispatch({type:"PIN_SUBMIT",payload:_objectSpread(_objectSpread({},pinFlowCurrentState),{},{type:"PINEntry",result:RDS.Loading()})}),_strategy.tracker.advancedInFlow("tallyman.v1-pin","pin-submitted",{msisdn:msisdn,pin:pin}),"PIN"!==currentState.type){_context4.next=18;break}return config=currentState.result.config,_context4.next=9,(0,_utils2.submitPIN)(window,pin,config,extraParams);case 9:if(result=_context4.sent,_strategy.tracker.advancedInFlow("tallyman.v1-pin","pin-submission-success",{msisdn:msisdn,pin:pin,finalUrl:result.productUrl}),result.gatewayRedirectUrl&&""!==result.gatewayRedirectUrl&&(_strategy.tracker.advancedInFlow("tallyman.v1-pin","gateway-redirect",{msisdn:msisdn,pin:pin,gatewayRedirectUrl:result.gatewayRedirectUrl}),window.location.href=result.gatewayRedirectUrl),!(extraParams&&extraParams.storeMsisdn&&"true"===extraParams.storeMsisdn)){_context4.next=15;break}return _context4.next=15,(0,_storeMsisdn.storeMsisdn)(msisdn).then(function(data){data&&data.data&&data.data.success?_strategy.tracker.customEvent("Flow","advance-auto","msisdn-stored-success"):_strategy.tracker.customEvent("Flow","advance-auto","msisdn-stored-failed")}).catch(function(error){_strategy.tracker.customEvent("Flow","advance-auto","msisdn-stored-error",error)});case 15:dispatch({type:"PIN_SUBMIT",payload:_objectSpread(_objectSpread({},pinFlowCurrentState),{},{type:"PINEntry",result:RDS.Success({finalUrl:result.productUrl,isAlreadySubscribed:result.isAlreadySubscribed||!1})})}),_context4.next=21;break;case 18:throw _strategy.tracker.recedeInFlow("tallyman.v1-pin","pin-submission-failure",{msisdn:msisdn,pin:pin}),dispatch({type:"PIN_SUBMIT_ERROR",payload:_objectSpread(_objectSpread({},pinFlowCurrentState),{},{type:"PINEntry",result:RDS.Failure({errorType:"UnexpectedState"})})}),new Error("Unexpected state");case 21:_context4.next=30;break;case 23:_context4.prev=23,_context4.t0=_context4["catch"](2),console.error(_context4.t0),errorType=_context4.t0.type||"UnknownError",_strategy.tracker.recedeInFlow("tallyman.v1-pin","pin-submission-failure",{msisdn:msisdn,pin:pin,productUrl:_context4.t0.productUrl}),dispatch({type:"PIN_SUBMIT_ERROR",payload:_objectSpread(_objectSpread({},pinFlowCurrentState),{},{type:"PINEntry",result:RDS.Failure({errorType:errorType,productUrl:_context4.t0.productUrl})})}),setTimeout(function(){_context4.t0.productUrl&&(window.location.href=_context4.t0.productUrl)},0);case 30:case"end":return _context4.stop();}},_callee4,null,[[2,23]])}));return function(_x7,_x8){return _ref4.apply(this,arguments)}}()}function mockPinFlow(mockState){return function(dispatch){var _window2,pinPageEvent=new Event("onPinPage");if(mockState!==void 0)switch(mockState){case"msisdn-failure-state":return dispatch({type:"MOCK_PIN_FLOW_STATE",payload:_utils2.mockedMSISDNEntryFailure.currentState});case"pin-state":return null===(_window2=window)||void 0===_window2?void 0:_window2.dispatchEvent(pinPageEvent),dispatch({type:"MOCK_PIN_FLOW_STATE",payload:_utils2.mockedPINState.currentState});case"completed-state":return dispatch({type:"MOCK_PIN_FLOW_STATE",payload:_utils2.mockedCompletedState.currentState});default:throw new Error("Mock Flow not supported");}}}function backToStart(){return _strategy.tracker.recedeInFlow("tallyman.v1-pin","pin-submission-backtostart","requested to change phone number"),{type:"BACK_TO_START",payload:{type:"MSISDNEntry",result:RDS.NothingYet()}}}var getInitialState=function getInitialState(){var search=(0,_utils.searchToObject)(),isPinEntryStep=search["show-pin-entry"]&&"1"===search["show-pin-entry"],isShowThankYouStep=search["show-thank-you"]&&"1"===search["show-thank-you"],isShowCustomError=search.show_custom_error&&"1"===search.show_custom_error,initialStateDefault={currentState:{type:"MSISDNEntry",result:RDS.NothingYet()}},msisdnError={currentState:{type:"MSISDNEntry",result:RDS.Failure({errorType:"SomethingWentWrong",error:null})}},thankYouState={currentState:{type:"PINEntry",result:RDS.Success({finalUrl:(null===search||void 0===search?void 0:search.product_url)||""}),data:{nextAction:"submitPinAction",msisdn:(null===search||void 0===search?void 0:search.msisdn)||"",operator:(null===search||void 0===search?void 0:search.operator)||""}}},initalPinEntryState={currentState:{type:"PINEntry",result:RDS.NothingYet(),data:{nextAction:"submitPinAction",msisdn:(null===search||void 0===search?void 0:search.msisdn)||"",operator:(null===search||void 0===search?void 0:search.operator)||""}}};return isPinEntryStep?initalPinEntryState:isShowThankYouStep?thankYouState:isShowCustomError?msisdnError:initialStateDefault},initialState=getInitialState(),PinFlowActionMaps={submitMSISDNAction:submitMSISDNAction,submitPinAction:submitPinAction};exports.PinFlowActionMaps=PinFlowActionMaps;function PinFlowReducer(){var state=0<arguments.length&&arguments[0]!==void 0?arguments[0]:initialState,action=1<arguments.length?arguments[1]:void 0;switch(action.type){case"PIN_FLOW_MSISDN_SUBMIT":return(0,_strategy.genericHandler)(state,action.payload);case"PIN_FLOW_MSISDN_SUBMIT_ERROR":return(0,_strategy.genericHandler)(state,action.payload);case"PIN_SUBMIT":return(0,_strategy.genericHandler)(state,action.payload);case"BACK_TO_START":return(0,_strategy.genericHandler)(state,action.payload);case"PIN_SUBMIT_ERROR":return(0,_strategy.genericHandler)(state,action.payload);case"MOCK_PIN_FLOW_STATE":return(0,_strategy.genericHandler)(state,action.payload);default:return state;}}
@@ -0,0 +1,11 @@
1
+ import { IConfig, IHash, IMcpShieldResult, IPinFlowReducerState, MultiOperatorMSISDNSubmissionResult, SingleMSISDNSubmissionResult } from './PinTypes';
2
+ export default function submitMSISDN(window: Window, maybeConfig: IConfig, internationalMSISDN: string, extraParams?: IHash): Promise<SingleMSISDNSubmissionResult | MultiOperatorMSISDNSubmissionResult>;
3
+ export declare function loadMcpShield(window: Window, config: IConfig): Promise<IMcpShieldResult>;
4
+ export declare function submitPIN(window: Window, pin: string, config: IConfig, extraParams: IHash): Promise<{
5
+ productUrl?: string;
6
+ isAlreadySubscribed?: boolean;
7
+ gatewayRedirectUrl?: string;
8
+ }>;
9
+ export declare const mockedPINState: IPinFlowReducerState;
10
+ export declare const mockedCompletedState: IPinFlowReducerState;
11
+ export declare const mockedMSISDNEntryFailure: IPinFlowReducerState;