ouisys-engine 3.0.0 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/reducers/pinFlow/index.js +28 -16
- package/dist/reducers/strategy/StrategyTypes.d.ts +4 -2
- package/dist/reducers/strategy/index.js +23 -21
- package/dist/utilities/index.d.ts +2 -0
- package/dist/utilities/index.js +24 -2
- package/package.json +1 -1
- package/src/reducers/pinFlow/index.ts +12 -1
- package/src/reducers/strategy/StrategyTypes.ts +4 -2
- package/src/reducers/strategy/index.ts +3 -1
- package/src/utilities/index.ts +87 -0
|
@@ -63,6 +63,10 @@ var _utils = _interopRequireWildcard(require("./utils"));
|
|
|
63
63
|
|
|
64
64
|
var _strategy = require("../strategy");
|
|
65
65
|
|
|
66
|
+
var _utilities = require("../../utilities");
|
|
67
|
+
|
|
68
|
+
var _utils2 = require("../strategy/utils");
|
|
69
|
+
|
|
66
70
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
67
71
|
|
|
68
72
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -79,11 +83,18 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
|
|
|
79
83
|
|
|
80
84
|
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); }); }; }
|
|
81
85
|
|
|
82
|
-
|
|
86
|
+
var getConfigByMsisdnPrefix = function getConfigByMsisdnPrefix(msisdn) {
|
|
87
|
+
var operatorByPrefix = (0, _utilities.getSAOperatorByMsisdnPrefix)(msisdn);
|
|
88
|
+
var flowObj = (0, _utils2.determineFlowByOperator)(operatorByPrefix);
|
|
89
|
+
return flowObj.flowConfig;
|
|
90
|
+
}; //ACTION CREATORS
|
|
91
|
+
|
|
92
|
+
|
|
83
93
|
function submitMSISDNAction(msisdn, extraParams) {
|
|
84
94
|
return /*#__PURE__*/function () {
|
|
85
95
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(dispatch, store) {
|
|
86
|
-
var currentState, pinFlowCurrentState, config, pinMaxLengthByOp, msisdnSubmissionResult, operator, errorType;
|
|
96
|
+
var currentState, pinFlowCurrentState, _currentState$result, configByStrategy, isUseMsisdnPrefix, config, pinMaxLengthByOp, msisdnSubmissionResult, operator, errorType;
|
|
97
|
+
|
|
87
98
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
88
99
|
while (1) {
|
|
89
100
|
switch (_context.prev = _context.next) {
|
|
@@ -92,17 +103,18 @@ function submitMSISDNAction(msisdn, extraParams) {
|
|
|
92
103
|
pinFlowCurrentState = store().pinFlow.currentState;
|
|
93
104
|
|
|
94
105
|
if (!(currentState.type === "PIN")) {
|
|
95
|
-
_context.next =
|
|
106
|
+
_context.next = 26;
|
|
96
107
|
break;
|
|
97
108
|
}
|
|
98
109
|
|
|
99
|
-
|
|
110
|
+
_currentState$result = currentState.result, configByStrategy = _currentState$result.config, isUseMsisdnPrefix = _currentState$result.isUseMsisdnPrefix;
|
|
111
|
+
config = isUseMsisdnPrefix ? getConfigByMsisdnPrefix(msisdn) : configByStrategy;
|
|
100
112
|
pinMaxLengthByOp = {
|
|
101
113
|
"SA_MOBILY": 6,
|
|
102
114
|
"SA_STC": 4,
|
|
103
115
|
"SA_ZAIN": 6
|
|
104
116
|
};
|
|
105
|
-
_context.prev =
|
|
117
|
+
_context.prev = 6;
|
|
106
118
|
dispatch({
|
|
107
119
|
type: "PIN_FLOW_MSISDN_SUBMIT",
|
|
108
120
|
payload: _objectSpread(_objectSpread({}, pinFlowCurrentState), {}, {
|
|
@@ -115,10 +127,10 @@ function submitMSISDNAction(msisdn, extraParams) {
|
|
|
115
127
|
msisdn: msisdn
|
|
116
128
|
});
|
|
117
129
|
|
|
118
|
-
_context.next =
|
|
130
|
+
_context.next = 11;
|
|
119
131
|
return (0, _utils.default)(window, config, msisdn, extraParams);
|
|
120
132
|
|
|
121
|
-
case
|
|
133
|
+
case 11:
|
|
122
134
|
msisdnSubmissionResult = _context.sent;
|
|
123
135
|
operator = msisdnSubmissionResult.type == "SingleMSISDNSubmissionResult" ? msisdnSubmissionResult.operator : "";
|
|
124
136
|
dispatch({
|
|
@@ -147,12 +159,12 @@ function submitMSISDNAction(msisdn, extraParams) {
|
|
|
147
159
|
}
|
|
148
160
|
})
|
|
149
161
|
});
|
|
150
|
-
_context.next =
|
|
162
|
+
_context.next = 24;
|
|
151
163
|
break;
|
|
152
164
|
|
|
153
|
-
case
|
|
154
|
-
_context.prev =
|
|
155
|
-
_context.t0 = _context["catch"](
|
|
165
|
+
case 18:
|
|
166
|
+
_context.prev = 18;
|
|
167
|
+
_context.t0 = _context["catch"](6);
|
|
156
168
|
console.warn(_context.t0);
|
|
157
169
|
errorType = "AlreadySubscribed" === _context.t0.type ? "AlreadySubscribed" : "InvalidMSISDN" === _context.t0.type ? "InvalidMSISDN" : "UnknownError";
|
|
158
170
|
|
|
@@ -173,11 +185,11 @@ function submitMSISDNAction(msisdn, extraParams) {
|
|
|
173
185
|
})
|
|
174
186
|
});
|
|
175
187
|
|
|
176
|
-
case
|
|
177
|
-
_context.next =
|
|
188
|
+
case 24:
|
|
189
|
+
_context.next = 29;
|
|
178
190
|
break;
|
|
179
191
|
|
|
180
|
-
case
|
|
192
|
+
case 26:
|
|
181
193
|
dispatch({
|
|
182
194
|
type: "PIN_FLOW_MSISDN_SUBMIT_ERROR",
|
|
183
195
|
payload: _objectSpread(_objectSpread({}, pinFlowCurrentState), {}, {
|
|
@@ -196,12 +208,12 @@ function submitMSISDNAction(msisdn, extraParams) {
|
|
|
196
208
|
|
|
197
209
|
throw "Unexpected state";
|
|
198
210
|
|
|
199
|
-
case
|
|
211
|
+
case 29:
|
|
200
212
|
case "end":
|
|
201
213
|
return _context.stop();
|
|
202
214
|
}
|
|
203
215
|
}
|
|
204
|
-
}, _callee, null, [[
|
|
216
|
+
}, _callee, null, [[6, 18]]);
|
|
205
217
|
}));
|
|
206
218
|
|
|
207
219
|
return function (_x, _x2) {
|
|
@@ -2,9 +2,9 @@ import * as RDS from "../../common-types/RemoteDataState";
|
|
|
2
2
|
import { AppThunk } from "../../common-types/AppThunk";
|
|
3
3
|
export declare type IIdentifyResult = {
|
|
4
4
|
operator: string;
|
|
5
|
-
flow
|
|
5
|
+
flow?: string;
|
|
6
6
|
success: boolean;
|
|
7
|
-
rockman_id
|
|
7
|
+
rockman_id?: string;
|
|
8
8
|
message?: string;
|
|
9
9
|
};
|
|
10
10
|
export declare type ConfigDetails = {
|
|
@@ -40,6 +40,7 @@ export declare type StrategyConfig = {
|
|
|
40
40
|
[key: string]: IFlow;
|
|
41
41
|
};
|
|
42
42
|
default: IFlow;
|
|
43
|
+
isUseMsisdnPrefix?: boolean;
|
|
43
44
|
};
|
|
44
45
|
export declare type IStrategy = {
|
|
45
46
|
strategy: IStrategyNames;
|
|
@@ -65,6 +66,7 @@ export declare type IdentifyFlowOptionsResult<F> = {
|
|
|
65
66
|
rockman_id?: string;
|
|
66
67
|
isHeaderEnrichmentSuccess?: boolean;
|
|
67
68
|
autoRedirect?: boolean;
|
|
69
|
+
isUseMsisdnPrefix?: boolean;
|
|
68
70
|
};
|
|
69
71
|
export declare type IDENTIFYMSISDNEntrySuccess = {};
|
|
70
72
|
export declare type OPERATORSelectFailure = {};
|
|
@@ -161,45 +161,46 @@ function mockStrategyStateByUrlParam() {
|
|
|
161
161
|
function identifyStrategy() {
|
|
162
162
|
return /*#__PURE__*/function () {
|
|
163
163
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(dispatch) {
|
|
164
|
-
var _getConfig, strategy, strategyConfigs, search;
|
|
164
|
+
var _getConfig, strategy, strategyConfigs, isUseMsisdnPrefix, search;
|
|
165
165
|
|
|
166
166
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
167
167
|
while (1) {
|
|
168
168
|
switch (_context.prev = _context.next) {
|
|
169
169
|
case 0:
|
|
170
170
|
_getConfig = (0, _utils.getConfig)(), strategy = _getConfig.strategy, strategyConfigs = _getConfig.strategyConfigs;
|
|
171
|
+
isUseMsisdnPrefix = strategyConfigs.isUseMsisdnPrefix;
|
|
171
172
|
search = (0, _utils.searchToObject)();
|
|
172
173
|
|
|
173
174
|
if (!(search["mock-flow"] !== undefined)) {
|
|
174
|
-
_context.next =
|
|
175
|
+
_context.next = 7;
|
|
175
176
|
break;
|
|
176
177
|
}
|
|
177
178
|
|
|
178
179
|
dispatch(mockStrategyStateByUrlParam());
|
|
179
|
-
_context.next =
|
|
180
|
+
_context.next = 32;
|
|
180
181
|
break;
|
|
181
182
|
|
|
182
|
-
case
|
|
183
|
+
case 7:
|
|
183
184
|
_context.t0 = strategy;
|
|
184
|
-
_context.next = _context.t0 === "pin-mo-ask-operator" ?
|
|
185
|
+
_context.next = _context.t0 === "pin-mo-ask-operator" ? 10 : _context.t0 === "pin-mo-redir-ask-mobile-number" ? 11 : _context.t0 === "pin-mo-ask-mobile-number" ? 11 : _context.t0 === "pin-one-click-detect-operator-by-ip" ? 12 : _context.t0 === "one-click-mo-pin-detect-operator-by-ip-or-msisdn" ? 12 : _context.t0 === "mo-redir-one-click-detect-operator-by-ip" ? 12 : _context.t0 === "mo-one-click-detect-operator-by-ip" ? 12 : _context.t0 === "click2sms-one-click-detect-operator-by-ip" ? 12 : _context.t0 === "pin-mo-detect-operator-by-ip" ? 12 : _context.t0 === "pin-click2sms-ask-operator" ? 13 : _context.t0 === "he-pin-one-click-ask-operator" ? 13 : _context.t0 === "click2sms-one-click-ask-operator" ? 13 : _context.t0 === "pin-one-click-ask-operator" ? 13 : _context.t0 === "pin-header-enrichment" ? 14 : _context.t0 === "he-pin-mo-redir-header-enrichment" ? 14 : _context.t0 === "he-pin-one-click-header-enrichment" ? 14 : _context.t0 === "he-mo-redir-one-click-header-enrichment" ? 14 : _context.t0 === "pin" ? 15 : _context.t0 === "mo" ? 17 : _context.t0 === "mo-redir" ? 19 : _context.t0 === "one-click" ? 21 : _context.t0 === "tallyman-one-click" ? 23 : _context.t0 === "click2sms" ? 25 : _context.t0 === "ussd" ? 27 : _context.t0 === "tpay-he" ? 29 : 31;
|
|
185
186
|
break;
|
|
186
187
|
|
|
187
|
-
case
|
|
188
|
+
case 10:
|
|
188
189
|
return _context.abrupt("return", dispatch((0, _ask_operator.default)()));
|
|
189
190
|
|
|
190
|
-
case
|
|
191
|
+
case 11:
|
|
191
192
|
return _context.abrupt("return", dispatch((0, _ask_mobile_number.default)()));
|
|
192
193
|
|
|
193
|
-
case
|
|
194
|
+
case 12:
|
|
194
195
|
return _context.abrupt("return", dispatch((0, _detect_operator_by_ip.default)()));
|
|
195
196
|
|
|
196
|
-
case
|
|
197
|
+
case 13:
|
|
197
198
|
return _context.abrupt("return", dispatch((0, _ask_operator.default)()));
|
|
198
199
|
|
|
199
|
-
case
|
|
200
|
+
case 14:
|
|
200
201
|
return _context.abrupt("return", dispatch((0, _header_enrichment.default)()));
|
|
201
202
|
|
|
202
|
-
case
|
|
203
|
+
case 15:
|
|
203
204
|
tracker.sendOptInFlowEvent("Pin");
|
|
204
205
|
return _context.abrupt("return", dispatch({
|
|
205
206
|
type: "IDENTIFY_STRATEGY",
|
|
@@ -207,12 +208,13 @@ function identifyStrategy() {
|
|
|
207
208
|
type: "PIN",
|
|
208
209
|
result: {
|
|
209
210
|
nextAction: "submitMSISDNAction",
|
|
210
|
-
config: strategyConfigs.default.flowConfig
|
|
211
|
+
config: strategyConfigs.default.flowConfig,
|
|
212
|
+
isUseMsisdnPrefix: isUseMsisdnPrefix
|
|
211
213
|
}
|
|
212
214
|
}
|
|
213
215
|
}));
|
|
214
216
|
|
|
215
|
-
case
|
|
217
|
+
case 17:
|
|
216
218
|
tracker.sendOptInFlowEvent("Msisdn to sms");
|
|
217
219
|
return _context.abrupt("return", dispatch({
|
|
218
220
|
type: "IDENTIFY_STRATEGY",
|
|
@@ -225,7 +227,7 @@ function identifyStrategy() {
|
|
|
225
227
|
}
|
|
226
228
|
}));
|
|
227
229
|
|
|
228
|
-
case
|
|
230
|
+
case 19:
|
|
229
231
|
tracker.sendOptInFlowEvent("Redirect");
|
|
230
232
|
return _context.abrupt("return", dispatch({
|
|
231
233
|
type: "IDENTIFY_STRATEGY",
|
|
@@ -238,7 +240,7 @@ function identifyStrategy() {
|
|
|
238
240
|
}
|
|
239
241
|
}));
|
|
240
242
|
|
|
241
|
-
case
|
|
243
|
+
case 21:
|
|
242
244
|
tracker.sendOptInFlowEvent("3G click");
|
|
243
245
|
return _context.abrupt("return", dispatch({
|
|
244
246
|
type: "IDENTIFY_STRATEGY",
|
|
@@ -251,7 +253,7 @@ function identifyStrategy() {
|
|
|
251
253
|
}
|
|
252
254
|
}));
|
|
253
255
|
|
|
254
|
-
case
|
|
256
|
+
case 23:
|
|
255
257
|
tracker.sendOptInFlowEvent("3G click");
|
|
256
258
|
return _context.abrupt("return", dispatch({
|
|
257
259
|
type: "IDENTIFY_STRATEGY",
|
|
@@ -264,7 +266,7 @@ function identifyStrategy() {
|
|
|
264
266
|
}
|
|
265
267
|
}));
|
|
266
268
|
|
|
267
|
-
case
|
|
269
|
+
case 25:
|
|
268
270
|
tracker.sendOptInFlowEvent("Click to sms");
|
|
269
271
|
return _context.abrupt("return", dispatch({
|
|
270
272
|
type: "IDENTIFY_STRATEGY",
|
|
@@ -277,7 +279,7 @@ function identifyStrategy() {
|
|
|
277
279
|
}
|
|
278
280
|
}));
|
|
279
281
|
|
|
280
|
-
case
|
|
282
|
+
case 27:
|
|
281
283
|
tracker.sendOptInFlowEvent("Msisdn to sms");
|
|
282
284
|
return _context.abrupt("return", dispatch({
|
|
283
285
|
type: "IDENTIFY_STRATEGY",
|
|
@@ -290,7 +292,7 @@ function identifyStrategy() {
|
|
|
290
292
|
}
|
|
291
293
|
}));
|
|
292
294
|
|
|
293
|
-
case
|
|
295
|
+
case 29:
|
|
294
296
|
tracker.sendOptInFlowEvent("Hybrid Pin");
|
|
295
297
|
return _context.abrupt("return", dispatch({
|
|
296
298
|
type: "IDENTIFY_STRATEGY",
|
|
@@ -303,10 +305,10 @@ function identifyStrategy() {
|
|
|
303
305
|
}
|
|
304
306
|
}));
|
|
305
307
|
|
|
306
|
-
case
|
|
308
|
+
case 31:
|
|
307
309
|
throw "Strategy not supported";
|
|
308
310
|
|
|
309
|
-
case
|
|
311
|
+
case 32:
|
|
310
312
|
case "end":
|
|
311
313
|
return _context.stop();
|
|
312
314
|
}
|
|
@@ -4,3 +4,5 @@ export declare const getHost: ({ host }: {
|
|
|
4
4
|
host: string;
|
|
5
5
|
}) => string;
|
|
6
6
|
export declare const setOnLoadUtilities: (config: IConfig) => void;
|
|
7
|
+
export declare type SAOperators = 'SA_VIRGIN' | 'SA_MOBILY' | 'SA_STC' | 'SA_ZAIN';
|
|
8
|
+
export declare function getSAOperatorByMsisdnPrefix(msisdn: string): SAOperators | undefined;
|
package/dist/utilities/index.js
CHANGED
|
@@ -3,7 +3,19 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.getHost = void 0;
|
|
7
|
+
exports.getSAOperatorByMsisdnPrefix = getSAOperatorByMsisdnPrefix;
|
|
8
|
+
exports.setOnLoadUtilities = exports.isDMBCheck = void 0;
|
|
9
|
+
|
|
10
|
+
require("core-js/modules/es.array.iterator.js");
|
|
11
|
+
|
|
12
|
+
require("core-js/modules/es.map.js");
|
|
13
|
+
|
|
14
|
+
require("core-js/modules/es.object.to-string.js");
|
|
15
|
+
|
|
16
|
+
require("core-js/modules/es.string.iterator.js");
|
|
17
|
+
|
|
18
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
|
7
19
|
|
|
8
20
|
var _utils = require("../reducers/moFlow/utils");
|
|
9
21
|
|
|
@@ -41,4 +53,14 @@ var setOnLoadUtilities = function setOnLoadUtilities(config) {
|
|
|
41
53
|
}
|
|
42
54
|
};
|
|
43
55
|
|
|
44
|
-
exports.setOnLoadUtilities = setOnLoadUtilities;
|
|
56
|
+
exports.setOnLoadUtilities = setOnLoadUtilities;
|
|
57
|
+
var sa_prefix_operator_map = new Map([['966571', 'SA_VIRGIN'], ['966500', 'SA_STC'], ['966501', 'SA_STC'], ['966502', 'SA_STC'], ['966503', 'SA_STC'], ['966504', 'SA_STC'], ['966505', 'SA_STC'], ['966506', 'SA_STC'], ['966507', 'SA_STC'], ['966508', 'SA_STC'], ['966509', 'SA_STC'], ['966512', 'SA_STC'], ['966514', 'SA_STC'], ['966515', 'SA_STC'], ['966517', 'SA_STC'], ['966530', 'SA_STC'], ['966531', 'SA_STC'], ['966532', 'SA_STC'], ['966533', 'SA_STC'], ['966534', 'SA_STC'], ['966535', 'SA_STC'], ['966536', 'SA_STC'], ['966537', 'SA_STC'], ['966538', 'SA_STC'], ['966539', 'SA_STC'], ['966540', 'SA_MOBILY'], ['966541', 'SA_MOBILY'], ['966542', 'SA_MOBILY'], ['966543', 'SA_MOBILY'], ['966544', 'SA_MOBILY'], ['966545', 'SA_MOBILY'], ['966546', 'SA_MOBILY'], ['966547', 'SA_MOBILY'], ['966548', 'SA_MOBILY'], ['966549', 'SA_MOBILY'], ['966550', 'SA_STC'], ['966551', 'SA_STC'], ['966552', 'SA_STC'], ['966553', 'SA_STC'], ['966554', 'SA_STC'], ['966555', 'SA_STC'], ['966556', 'SA_STC'], ['966557', 'SA_STC'], ['966558', 'SA_STC'], ['966559', 'SA_STC'], ['966560', 'SA_MOBILY'], ['966561', 'SA_MOBILY'], ['966562', 'SA_MOBILY'], ['966563', 'SA_MOBILY'], ['966564', 'SA_MOBILY'], ['966565', 'SA_MOBILY'], ['966566', 'SA_MOBILY'], ['966567', 'SA_MOBILY'], ['966568', 'SA_MOBILY'], ['966569', 'SA_MOBILY'], ['966570', 'SA_VIRGIN'], ['966572', 'SA_VIRGIN'], ['966573', 'SA_VIRGIN'], ['966580', 'SA_ZAIN'], ['966581', 'SA_ZAIN'], ['966582', 'SA_ZAIN'], ['966583', 'SA_ZAIN'], ['966586', 'SA_ZAIN'], ['966588', 'SA_ZAIN'], ['966589', 'SA_ZAIN'], ['966590', 'SA_ZAIN'], ['966591', 'SA_ZAIN'], ['966592', 'SA_ZAIN'], ['966593', 'SA_ZAIN'], ['966594', 'SA_ZAIN'], ['966595', 'SA_ZAIN'], ['966596', 'SA_ZAIN'], ['966597', 'SA_ZAIN'], ['966598', 'SA_ZAIN'], ['966599', 'SA_ZAIN']]);
|
|
58
|
+
|
|
59
|
+
function getSAOperatorByMsisdnPrefix(msisdn) {
|
|
60
|
+
if (msisdn[0] === "0") {
|
|
61
|
+
msisdn = "966" + msisdn.substring(1);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
var prefix = msisdn.substring(0, 6);
|
|
65
|
+
return sa_prefix_operator_map.get(prefix);
|
|
66
|
+
}
|
package/package.json
CHANGED
|
@@ -5,15 +5,26 @@ import { MSISDNEntryFailure, MSISDNEntryErrorTypes, PINEntryFailure, PINEntrySuc
|
|
|
5
5
|
import { AppThunk } from "../../common-types/AppThunk";
|
|
6
6
|
import submitMSISDN, { mockedCompletedState, mockedMSISDNEntryFailure, mockedPINState, submitPIN } from "./utils";
|
|
7
7
|
import { genericHandler, tracker } from "../strategy";
|
|
8
|
+
import { getSAOperatorByMsisdnPrefix } from "../../utilities";
|
|
9
|
+
import { determineFlowByOperator } from "../strategy/utils";
|
|
8
10
|
|
|
9
11
|
|
|
12
|
+
const getConfigByMsisdnPrefix = (msisdn:string)=>{
|
|
13
|
+
const operatorByPrefix = getSAOperatorByMsisdnPrefix(msisdn);
|
|
14
|
+
const flowObj = determineFlowByOperator(operatorByPrefix);
|
|
15
|
+
return flowObj.flowConfig;
|
|
16
|
+
}
|
|
17
|
+
|
|
10
18
|
//ACTION CREATORS
|
|
11
19
|
export function submitMSISDNAction(msisdn:string, extraParams?:IHash):AppThunk{
|
|
12
20
|
return async (dispatch, store)=>{
|
|
13
21
|
const {currentState} = store().strategy;
|
|
14
22
|
const pinFlowCurrentState = store().pinFlow.currentState;
|
|
15
23
|
if(currentState.type === "PIN"){
|
|
16
|
-
const config = currentState.result
|
|
24
|
+
const { config: configByStrategy, isUseMsisdnPrefix } = currentState.result;
|
|
25
|
+
|
|
26
|
+
const config = isUseMsisdnPrefix ? getConfigByMsisdnPrefix(msisdn) : configByStrategy;
|
|
27
|
+
|
|
17
28
|
const pinMaxLengthByOp:{[key:string]:number} = {
|
|
18
29
|
"SA_MOBILY":6,
|
|
19
30
|
"SA_STC":4,
|
|
@@ -4,9 +4,9 @@ import { AppThunk } from "../../common-types/AppThunk";
|
|
|
4
4
|
|
|
5
5
|
export type IIdentifyResult = {
|
|
6
6
|
operator: string;
|
|
7
|
-
flow
|
|
7
|
+
flow?: string;
|
|
8
8
|
success: boolean;
|
|
9
|
-
rockman_id
|
|
9
|
+
rockman_id?: string;
|
|
10
10
|
message?:string;
|
|
11
11
|
}
|
|
12
12
|
|
|
@@ -46,6 +46,7 @@ export type StrategyConfig = {
|
|
|
46
46
|
[key:string]:IFlow;
|
|
47
47
|
};
|
|
48
48
|
default:IFlow;
|
|
49
|
+
isUseMsisdnPrefix?:boolean;
|
|
49
50
|
}
|
|
50
51
|
// export type IStrategy = IPinStrategy | IMoStrategy;
|
|
51
52
|
|
|
@@ -111,6 +112,7 @@ export type IdentifyFlowOptionsResult<F> = {
|
|
|
111
112
|
rockman_id?:string;
|
|
112
113
|
isHeaderEnrichmentSuccess?:boolean;
|
|
113
114
|
autoRedirect?:boolean;
|
|
115
|
+
isUseMsisdnPrefix?: boolean;
|
|
114
116
|
}
|
|
115
117
|
|
|
116
118
|
|
|
@@ -100,6 +100,7 @@ export function mockStrategyStateByUrlParam():AppThunk {
|
|
|
100
100
|
export function identifyStrategy():AppThunk {
|
|
101
101
|
return async (dispatch)=>{
|
|
102
102
|
const { strategy, strategyConfigs } = getConfig();
|
|
103
|
+
const { isUseMsisdnPrefix } = strategyConfigs;
|
|
103
104
|
const search = searchToObject() as IMockFlowParams<IMockPinFlowStates>;
|
|
104
105
|
|
|
105
106
|
if(search["mock-flow"] !== undefined){
|
|
@@ -138,7 +139,8 @@ export function identifyStrategy():AppThunk {
|
|
|
138
139
|
type:"PIN",
|
|
139
140
|
result: {
|
|
140
141
|
nextAction:"submitMSISDNAction",
|
|
141
|
-
config:strategyConfigs.default.flowConfig
|
|
142
|
+
config:strategyConfigs.default.flowConfig,
|
|
143
|
+
isUseMsisdnPrefix
|
|
142
144
|
}
|
|
143
145
|
}
|
|
144
146
|
});
|
package/src/utilities/index.ts
CHANGED
|
@@ -24,4 +24,91 @@ export const setOnLoadUtilities = (config:IConfig)=>{
|
|
|
24
24
|
loadMcpShield(window, config);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export type SAOperators = 'SA_VIRGIN' | 'SA_MOBILY' | 'SA_STC' | 'SA_ZAIN';
|
|
30
|
+
const sa_prefix_operator_map = new Map<string, SAOperators>([
|
|
31
|
+
['966571', 'SA_VIRGIN']
|
|
32
|
+
, ['966500', 'SA_STC']
|
|
33
|
+
, ['966501', 'SA_STC']
|
|
34
|
+
, ['966502', 'SA_STC']
|
|
35
|
+
, ['966503', 'SA_STC']
|
|
36
|
+
, ['966504', 'SA_STC']
|
|
37
|
+
, ['966505', 'SA_STC']
|
|
38
|
+
, ['966506', 'SA_STC']
|
|
39
|
+
, ['966507', 'SA_STC']
|
|
40
|
+
, ['966508', 'SA_STC']
|
|
41
|
+
, ['966509', 'SA_STC']
|
|
42
|
+
, ['966512', 'SA_STC']
|
|
43
|
+
, ['966514', 'SA_STC']
|
|
44
|
+
, ['966515', 'SA_STC']
|
|
45
|
+
, ['966517', 'SA_STC']
|
|
46
|
+
, ['966530', 'SA_STC']
|
|
47
|
+
, ['966531', 'SA_STC']
|
|
48
|
+
, ['966532', 'SA_STC']
|
|
49
|
+
, ['966533', 'SA_STC']
|
|
50
|
+
, ['966534', 'SA_STC']
|
|
51
|
+
, ['966535', 'SA_STC']
|
|
52
|
+
, ['966536', 'SA_STC']
|
|
53
|
+
, ['966537', 'SA_STC']
|
|
54
|
+
, ['966538', 'SA_STC']
|
|
55
|
+
, ['966539', 'SA_STC']
|
|
56
|
+
, ['966540', 'SA_MOBILY']
|
|
57
|
+
, ['966541', 'SA_MOBILY']
|
|
58
|
+
, ['966542', 'SA_MOBILY']
|
|
59
|
+
, ['966543', 'SA_MOBILY']
|
|
60
|
+
, ['966544', 'SA_MOBILY']
|
|
61
|
+
, ['966545', 'SA_MOBILY']
|
|
62
|
+
, ['966546', 'SA_MOBILY']
|
|
63
|
+
, ['966547', 'SA_MOBILY']
|
|
64
|
+
, ['966548', 'SA_MOBILY']
|
|
65
|
+
, ['966549', 'SA_MOBILY']
|
|
66
|
+
, ['966550', 'SA_STC']
|
|
67
|
+
, ['966551', 'SA_STC']
|
|
68
|
+
, ['966552', 'SA_STC']
|
|
69
|
+
, ['966553', 'SA_STC']
|
|
70
|
+
, ['966554', 'SA_STC']
|
|
71
|
+
, ['966555', 'SA_STC']
|
|
72
|
+
, ['966556', 'SA_STC']
|
|
73
|
+
, ['966557', 'SA_STC']
|
|
74
|
+
, ['966558', 'SA_STC']
|
|
75
|
+
, ['966559', 'SA_STC']
|
|
76
|
+
, ['966560', 'SA_MOBILY']
|
|
77
|
+
, ['966561', 'SA_MOBILY']
|
|
78
|
+
, ['966562', 'SA_MOBILY']
|
|
79
|
+
, ['966563', 'SA_MOBILY']
|
|
80
|
+
, ['966564', 'SA_MOBILY']
|
|
81
|
+
, ['966565', 'SA_MOBILY']
|
|
82
|
+
, ['966566', 'SA_MOBILY']
|
|
83
|
+
, ['966567', 'SA_MOBILY']
|
|
84
|
+
, ['966568', 'SA_MOBILY']
|
|
85
|
+
, ['966569', 'SA_MOBILY']
|
|
86
|
+
, ['966570', 'SA_VIRGIN']
|
|
87
|
+
, ['966572', 'SA_VIRGIN']
|
|
88
|
+
, ['966573', 'SA_VIRGIN']
|
|
89
|
+
, ['966580', 'SA_ZAIN']
|
|
90
|
+
, ['966581', 'SA_ZAIN']
|
|
91
|
+
, ['966582', 'SA_ZAIN']
|
|
92
|
+
, ['966583', 'SA_ZAIN']
|
|
93
|
+
, ['966586', 'SA_ZAIN']
|
|
94
|
+
, ['966588', 'SA_ZAIN']
|
|
95
|
+
, ['966589', 'SA_ZAIN']
|
|
96
|
+
, ['966590', 'SA_ZAIN']
|
|
97
|
+
, ['966591', 'SA_ZAIN']
|
|
98
|
+
, ['966592', 'SA_ZAIN']
|
|
99
|
+
, ['966593', 'SA_ZAIN']
|
|
100
|
+
, ['966594', 'SA_ZAIN']
|
|
101
|
+
, ['966595', 'SA_ZAIN']
|
|
102
|
+
, ['966596', 'SA_ZAIN']
|
|
103
|
+
, ['966597', 'SA_ZAIN']
|
|
104
|
+
, ['966598', 'SA_ZAIN']
|
|
105
|
+
, ['966599', 'SA_ZAIN']
|
|
106
|
+
]);
|
|
107
|
+
|
|
108
|
+
export function getSAOperatorByMsisdnPrefix(msisdn: string) : SAOperators | undefined {
|
|
109
|
+
if(msisdn[0] === "0") {
|
|
110
|
+
msisdn = "966" + msisdn.substring(1);
|
|
111
|
+
}
|
|
112
|
+
const prefix = msisdn.substring(0, 6)
|
|
113
|
+
return sa_prefix_operator_map.get(prefix);
|
|
27
114
|
}
|