ouisys-engine 3.0.1 → 3.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc +4 -8
- package/.eslintrc.js +1 -1
- package/.husky/pre-commit +4 -0
- package/.nvmrc +1 -1
- package/.prettierignore +2 -1
- package/.vscode/settings.json +1 -1
- package/README.md +2 -4
- package/dist/api/index.d.ts +5 -5
- package/dist/api/index.js +76 -76
- package/dist/common-types/AppThunk.d.ts +11 -12
- package/dist/common-types/IOptInFlowName.d.ts +1 -1
- package/dist/common-types/ITracker.js +1 -2
- package/dist/common-types/RemoteDataState.d.ts +4 -4
- package/dist/common-types/RemoteDataState.js +17 -17
- package/dist/flows/click2smsFlow.d.ts +2 -2
- package/dist/flows/moFlow.d.ts +2 -2
- package/dist/flows/moRedirFlow.d.ts +2 -2
- package/dist/flows/oneClickFlow.d.ts +2 -2
- package/dist/flows/pinFlow.d.ts +2 -2
- package/dist/flows/pinFlow.js +2 -0
- package/dist/flows/strategy.d.ts +8 -8
- package/dist/flows/ussdFlow.d.ts +2 -2
- package/dist/ips/tryGetIPRangeName.d.ts +1 -1
- package/dist/ips/tryGetIPRangeName.js +7 -5
- package/dist/jest.config.js +1 -1
- package/dist/pacman/index.d.ts +2 -2
- package/dist/pacman/index.js +41 -41
- package/dist/pacman/queryString.js +11 -9
- package/dist/reducers/click2smsFlow/Click2smsTypes.d.ts +19 -19
- package/dist/reducers/click2smsFlow/IClick2smsConstants.d.ts +1 -1
- package/dist/reducers/click2smsFlow/index.d.ts +2 -2
- package/dist/reducers/click2smsFlow/index.js +24 -24
- package/dist/reducers/click2smsFlow/utils.d.ts +1 -1
- package/dist/reducers/click2smsFlow/utils.js +30 -30
- package/dist/reducers/moFlow/IMoConstants.d.ts +1 -1
- package/dist/reducers/moFlow/MoTypes.d.ts +13 -13
- package/dist/reducers/moFlow/index.d.ts +3 -3
- package/dist/reducers/moFlow/index.js +27 -27
- package/dist/reducers/moFlow/utils.d.ts +1 -2
- package/dist/reducers/moFlow/utils.js +28 -26
- package/dist/reducers/moRedirFlow/IMoRedirConstants.d.ts +1 -1
- package/dist/reducers/moRedirFlow/MoRedirTypes.d.ts +13 -13
- package/dist/reducers/moRedirFlow/index.d.ts +3 -3
- package/dist/reducers/moRedirFlow/index.js +27 -27
- package/dist/reducers/moRedirFlow/utils.d.ts +1 -1
- package/dist/reducers/moRedirFlow/utils.js +17 -17
- package/dist/reducers/oneClickFlow/IOneClickConstants.d.ts +1 -1
- package/dist/reducers/oneClickFlow/OneClickTypes.d.ts +10 -10
- package/dist/reducers/oneClickFlow/index.d.ts +3 -3
- package/dist/reducers/oneClickFlow/index.js +75 -68
- package/dist/reducers/oneClickFlow/utils.d.ts +2 -2
- package/dist/reducers/oneClickFlow/utils.js +70 -69
- package/dist/reducers/pinFlow/IPinConstants.d.ts +1 -1
- package/dist/reducers/pinFlow/PinTypes.d.ts +24 -23
- package/dist/reducers/pinFlow/index.d.ts +3 -3
- package/dist/reducers/pinFlow/index.js +76 -76
- package/dist/reducers/pinFlow/utils.d.ts +1 -1
- package/dist/reducers/pinFlow/utils.js +61 -65
- package/dist/reducers/strategy/IStategyActionContants.d.ts +1 -1
- package/dist/reducers/strategy/StrategyTypes.d.ts +56 -56
- package/dist/reducers/strategy/index.d.ts +2 -2
- package/dist/reducers/strategy/index.js +99 -99
- package/dist/reducers/strategy/strategies/ask_mobile_number.d.ts +3 -2
- package/dist/reducers/strategy/strategies/ask_mobile_number.js +132 -74
- package/dist/reducers/strategy/strategies/ask_operator.d.ts +2 -2
- package/dist/reducers/strategy/strategies/ask_operator.js +64 -68
- package/dist/reducers/strategy/strategies/detect_operator_by_ip.d.ts +2 -2
- package/dist/reducers/strategy/strategies/detect_operator_by_ip.js +97 -97
- package/dist/reducers/strategy/strategies/header_enrichment.d.ts +2 -2
- package/dist/reducers/strategy/strategies/header_enrichment.js +116 -120
- package/dist/reducers/strategy/utils.d.ts +3 -3
- package/dist/reducers/strategy/utils.js +115 -111
- package/dist/reducers/ussdFlow/IUssdConstants.d.ts +1 -1
- package/dist/reducers/ussdFlow/UssdTypes.d.ts +13 -13
- package/dist/reducers/ussdFlow/index.d.ts +3 -3
- package/dist/reducers/ussdFlow/index.js +27 -27
- package/dist/reducers/ussdFlow/utils.d.ts +1 -2
- package/dist/reducers/ussdFlow/utils.js +19 -17
- package/dist/store/index.d.ts +8 -8
- package/dist/store/index.js +87 -83
- package/dist/store/reducers.d.ts +7 -7
- package/dist/store/reducers.js +4 -4
- package/dist/utilities/handleSubmitNumber.d.ts +7 -3
- package/dist/utilities/handleSubmitNumber.js +15 -18
- package/dist/utilities/index.d.ts +1 -1
- package/dist/utilities/index.js +13 -11
- package/dist/utilities/loadScriptInnerHtml.js +0 -1
- package/index.html +21 -28
- package/mockData/config.json +1 -1
- package/package.json +23 -15
- package/setupJest.js +1 -1
- package/tsconfig.json +2 -2
- package/dist/api/click2sms.js +0 -357
- package/dist/api/mo.js +0 -274
- package/dist/api/moRedir.js +0 -186
- package/dist/api/oneClick.js +0 -366
- package/dist/api/pin.js +0 -493
- package/dist/api/strategies.js +0 -704
- package/dist/api/ussd.js +0 -1
- package/dist/app/store.js +0 -35
- package/dist/features/strategies/categories/askMobileNumber.js +0 -395
- package/dist/features/strategies/categories/askOperator.js +0 -311
- package/dist/features/strategies/categories/detectOperatorByIp.js +0 -606
- package/dist/features/strategies/categories/headerEnrichment.js +0 -670
- package/dist/features/strategies/categories/typings/click2smsSliceTypes.js +0 -12
- package/dist/features/strategies/categories/typings/identifySliceTypes.js +0 -22
- package/dist/features/strategies/categories/typings/moFlowSliceTypes.js +0 -22
- package/dist/features/strategies/categories/typings/moRedirFlowSliceTypes.js +0 -21
- package/dist/features/strategies/categories/typings/oneClickSliceTypes.js +0 -13
- package/dist/features/strategies/categories/typings/pinFlowSliceTypes.js +0 -13
- package/dist/features/strategies/click2smsFlowSlice.js +0 -172
- package/dist/features/strategies/identifySlice.js +0 -455
- package/dist/features/strategies/moFlowSlice.js +0 -196
- package/dist/features/strategies/moRedirFlowSlice.js +0 -190
- package/dist/features/strategies/oneClickFlowSlice.js +0 -277
- package/dist/features/strategies/pinFlowSlice.js +0 -313
- package/dist/features/strategies/ussdFlowSlice.js +0 -1
- package/dist/flows/tpayHeFlow.d.ts +0 -7
- package/dist/flows/tpayHeFlow.js +0 -23
- package/dist/mockServer/browser.js +0 -48
- package/dist/mockServer/handlers.js +0 -22
- package/dist/mockServer/server.js +0 -48
- package/dist/reducers/tpayHeFlow/ITpayHeConstants.d.ts +0 -2
- package/dist/reducers/tpayHeFlow/ITpayHeConstants.js +0 -1
- package/dist/reducers/tpayHeFlow/TpayHeTypes.d.ts +0 -114
- package/dist/reducers/tpayHeFlow/TpayHeTypes.js +0 -1
- package/dist/reducers/tpayHeFlow/index.d.ts +0 -7
- package/dist/reducers/tpayHeFlow/index.js +0 -331
- package/dist/reducers/tpayHeFlow/utils.d.ts +0 -20
- package/dist/reducers/tpayHeFlow/utils.js +0 -510
- package/dist/test/setup.js +0 -24
- package/dist/test/test-utils.js +0 -51
- package/prettier.config.js +0 -7
- package/src/@types/react-tracker.d.ts +0 -16
- package/src/@types/redux-cli-logger.d.ts +0 -1
- package/src/@types/tiny-async-pool.d.ts +0 -3
- package/src/@types/window.d.ts +0 -74
- package/src/api/index.ts +0 -225
- package/src/common-types/AppThunk.ts +0 -19
- package/src/common-types/Either.ts +0 -3
- package/src/common-types/IError.ts +0 -5
- package/src/common-types/IOptInFlowName.ts +0 -1
- package/src/common-types/ITracker.ts +0 -10
- package/src/common-types/IVisitor.ts +0 -16
- package/src/common-types/RemoteDataState.ts +0 -88
- package/src/flows/click2smsFlow.ts +0 -18
- package/src/flows/moFlow.ts +0 -20
- package/src/flows/moRedirFlow.ts +0 -20
- package/src/flows/oneClickFlow.ts +0 -20
- package/src/flows/pinFlow.ts +0 -25
- package/src/flows/strategy.ts +0 -51
- package/src/flows/ussdFlow.ts +0 -20
- package/src/index.ts +0 -3
- package/src/ips/tryGetIPRangeName.ts +0 -22
- package/src/jest.config.js +0 -194
- package/src/pacman/index.ts +0 -71
- package/src/pacman/queryString.ts +0 -24
- package/src/reducers/click2smsFlow/Click2smsTypes.ts +0 -93
- package/src/reducers/click2smsFlow/IClick2smsConstants.ts +0 -4
- package/src/reducers/click2smsFlow/index.ts +0 -105
- package/src/reducers/click2smsFlow/utils.ts +0 -126
- package/src/reducers/moFlow/IMoConstants.ts +0 -7
- package/src/reducers/moFlow/MoTypes.ts +0 -125
- package/src/reducers/moFlow/index.ts +0 -150
- package/src/reducers/moFlow/utils.ts +0 -135
- package/src/reducers/moRedirFlow/IMoRedirConstants.ts +0 -7
- package/src/reducers/moRedirFlow/MoRedirTypes.ts +0 -99
- package/src/reducers/moRedirFlow/index.ts +0 -137
- package/src/reducers/moRedirFlow/utils.ts +0 -78
- package/src/reducers/oneClickFlow/IOneClickConstants.ts +0 -3
- package/src/reducers/oneClickFlow/OneClickTypes.ts +0 -108
- package/src/reducers/oneClickFlow/index.ts +0 -268
- package/src/reducers/oneClickFlow/utils.ts +0 -217
- package/src/reducers/pinFlow/IPinConstants.ts +0 -9
- package/src/reducers/pinFlow/PinTypes.ts +0 -189
- package/src/reducers/pinFlow/index.ts +0 -331
- package/src/reducers/pinFlow/utils.ts +0 -232
- package/src/reducers/strategy/IStategyActionContants.ts +0 -17
- package/src/reducers/strategy/StrategyTypes.ts +0 -375
- package/src/reducers/strategy/index.ts +0 -321
- package/src/reducers/strategy/strategies/ask_mobile_number.ts +0 -316
- package/src/reducers/strategy/strategies/ask_operator.ts +0 -195
- package/src/reducers/strategy/strategies/detect_operator_by_ip.ts +0 -414
- package/src/reducers/strategy/strategies/header_enrichment.ts +0 -489
- package/src/reducers/strategy/utils.ts +0 -357
- package/src/reducers/ussdFlow/IUssdConstants.ts +0 -7
- package/src/reducers/ussdFlow/UssdTypes.ts +0 -112
- package/src/reducers/ussdFlow/index.ts +0 -146
- package/src/reducers/ussdFlow/utils.ts +0 -88
- package/src/store/index.ts +0 -150
- package/src/store/reducers.ts +0 -37
- package/src/utilities/handleSubmitNumber.ts +0 -65
- package/src/utilities/index.ts +0 -114
- package/src/utilities/loadScriptInnerHtml.ts +0 -14
- package/src/utilities/loadScriptSrc.ts +0 -26
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { IConfig, IMSISDNSubmissionResult, ICheckSubscriptionResult, IUssdFlowReducerState, MSISDNEntryFailure, MSISDNEntrySuccess } from "./UssdTypes";
|
|
2
|
-
import { IFlow, ConfigDetails } from "../strategy/StrategyTypes";
|
|
3
|
-
import IError from "../../common-types/IError";
|
|
4
|
-
import { IKeywordShortcode } from "./UssdTypes";
|
|
5
|
-
import * as RDS from "../../common-types/RemoteDataState";
|
|
6
|
-
import { loop } from "../strategy/utils";
|
|
7
|
-
|
|
8
|
-
export default async function submitMSISDN(window: Window, maybeConfig: IConfig, internationalMSISDN: string, extraParams?: {[key: string]: string}): Promise<IKeywordShortcode> {
|
|
9
|
-
const config: IConfig = {offer:window.pac_analytics.visitor.offer, ...(maybeConfig||{})}
|
|
10
|
-
return submitMSISDNWithConfig(window, config, internationalMSISDN, extraParams)
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export async function submitMSISDNWithConfig(window: Window, config: IConfig, internationalMSISDN: string, extraParams?: { [key: string]: string }): Promise<IKeywordShortcode> {
|
|
14
|
-
|
|
15
|
-
const { slug, country, device, offer, host } = config
|
|
16
|
-
const search = window.location.search.substr(1) || ''
|
|
17
|
-
const extraParamsQs = !extraParams ? '' : '&' + Object.keys(extraParams).map(k => `${k}=${extraParams[k]}`).join('&')
|
|
18
|
-
const msisdn = internationalMSISDN.match(/\d+/gi).join('')
|
|
19
|
-
const rockmanId = window.pac_analytics.visitor.rockmanId
|
|
20
|
-
const result: IMSISDNSubmissionResult = await window.tallymanApi.ussd(host, slug, country, msisdn, device, offer, rockmanId, search, extraParamsQs)
|
|
21
|
-
|
|
22
|
-
if (false === result.success) {
|
|
23
|
-
const type = result.message == 'ALREADY SUBSCRIBED' ? "AlreadySubscribed" : "InvalidMSISDN";
|
|
24
|
-
const error = new Error(`${type}:\n${result.message}`) as IError & {type:string}
|
|
25
|
-
error['type'] = type;
|
|
26
|
-
console.error(error)
|
|
27
|
-
throw error
|
|
28
|
-
} else {
|
|
29
|
-
return result
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
export async function checkSubscription(window: Window, maybeConfig: IConfig): Promise<string> {
|
|
36
|
-
const config: IConfig = {offer:window.pac_analytics.visitor.offer, ...(maybeConfig||{})}
|
|
37
|
-
|
|
38
|
-
const { host } = config
|
|
39
|
-
|
|
40
|
-
const rockmanId = window.pac_analytics.visitor.rockmanId
|
|
41
|
-
const check : () => Promise<ICheckSubscriptionResult> = () => window.tallymanApi.checkSubscriptionByRockmanIdOnly(host, rockmanId)
|
|
42
|
-
|
|
43
|
-
const checkResult: ICheckSubscriptionResult = await loop(
|
|
44
|
-
check,
|
|
45
|
-
60,
|
|
46
|
-
r => r.success,
|
|
47
|
-
0
|
|
48
|
-
)
|
|
49
|
-
|
|
50
|
-
if(true === checkResult.success) {
|
|
51
|
-
window.location.href = checkResult.product_url;
|
|
52
|
-
return checkResult.product_url || null
|
|
53
|
-
} else {
|
|
54
|
-
const error = new Error(`${"SubscriptionFailed"}:\n${checkResult.message}`) as IError & {type:string}
|
|
55
|
-
error['type'] = "SubscriptionFailed";
|
|
56
|
-
throw error
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
export const formatSMSLink = (keywordAndShortcode : IKeywordShortcode) =>
|
|
62
|
-
//@ts-ignore
|
|
63
|
-
(!!window.pac_analytics.visitor["x-requested-with"] && window.pac_analytics.visitor["x-requested-with"] !== null && window.pac_analytics.visitor["x-requested-with"].indexOf("com.facebook") !== -1)
|
|
64
|
-
?
|
|
65
|
-
`sms://${keywordAndShortcode.shortcode}?body=${keywordAndShortcode.keyword}`
|
|
66
|
-
:
|
|
67
|
-
(typeof navigator != "undefined" && (/iPhone/i.test(navigator.userAgent) || /Mac OS/i.test(navigator.userAgent)))
|
|
68
|
-
? `sms:${keywordAndShortcode.shortcode}&body=${keywordAndShortcode.keyword}`
|
|
69
|
-
: `sms:${keywordAndShortcode.shortcode}?body=${keywordAndShortcode.keyword}`
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
export const mockedMSISDNEntrySuccess : IUssdFlowReducerState = {
|
|
73
|
-
currentState:{
|
|
74
|
-
type: "MSISDNEntry",
|
|
75
|
-
result: RDS.Success<MSISDNEntryFailure, MSISDNEntrySuccess>({
|
|
76
|
-
keyword: 'TEST OK',
|
|
77
|
-
shortcode: '666'
|
|
78
|
-
})
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
export const mockedMSISDNEntryFailure : IUssdFlowReducerState = {
|
|
84
|
-
currentState:{
|
|
85
|
-
type: "MSISDNEntry",
|
|
86
|
-
result: RDS.Failure<MSISDNEntryFailure, MSISDNEntrySuccess>({ errorType: "InvalidMSISDN", error: "Invalid Mobile Number" })
|
|
87
|
-
}
|
|
88
|
-
}
|
package/src/store/index.ts
DELETED
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import * as RDS from "../common-types/RemoteDataState";
|
|
2
|
-
|
|
3
|
-
import { createStore, applyMiddleware, compose, Action } from "redux";
|
|
4
|
-
import { IPinActions } from "../reducers/pinFlow/PinTypes";
|
|
5
|
-
import { IStrategyActions, IStrategyCurrentState } from "../reducers/strategy/StrategyTypes";
|
|
6
|
-
import thunk, { ThunkMiddleware, ThunkAction } from "redux-thunk";
|
|
7
|
-
import makeRootReducer, { IApplicationState } from "./reducers";
|
|
8
|
-
import { createLogger } from "redux-logger";
|
|
9
|
-
import { IMoActions } from "../reducers/moFlow/MoTypes";
|
|
10
|
-
import { IUssdActions } from "../reducers/ussdFlow/UssdTypes";
|
|
11
|
-
|
|
12
|
-
import { IMoRedirActions } from "../reducers/moRedirFlow/MoRedirTypes";
|
|
13
|
-
import { IOneClickActions } from "../reducers/oneClickFlow/OneClickTypes";
|
|
14
|
-
import { RealTallyman, MockTallyman } from "../api";
|
|
15
|
-
import { IClick2SmsActions } from "../reducers/click2smsFlow/Click2smsTypes";
|
|
16
|
-
import { getConfig, getOperators } from "../reducers/strategy/utils";
|
|
17
|
-
|
|
18
|
-
export type IApplicationActions = IStrategyActions | IPinActions | IMoActions | IMoRedirActions | IOneClickActions | IClick2SmsActions | IUssdActions;
|
|
19
|
-
|
|
20
|
-
const log = createLogger({ diff: true, collapsed: true });
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
// ======================================================
|
|
24
|
-
// Store Enhancers
|
|
25
|
-
// ======================================================
|
|
26
|
-
//const enhancers = [];
|
|
27
|
-
|
|
28
|
-
// ======================================================
|
|
29
|
-
// Store Instantiation
|
|
30
|
-
// ======================================================
|
|
31
|
-
|
|
32
|
-
const strategyBasedInitialState = ():IStrategyCurrentState=>{
|
|
33
|
-
const { strategy, strategyConfigs } = getConfig();
|
|
34
|
-
|
|
35
|
-
if(strategy.includes("ask-operator")){
|
|
36
|
-
const operators = getOperators();
|
|
37
|
-
return {
|
|
38
|
-
type:"IDENTIFY_FLOW_BY_OPERATOR_SELECT",
|
|
39
|
-
result:{operators, nextAction:"selectOperator"}
|
|
40
|
-
}
|
|
41
|
-
}else if(strategy.includes("ask-mobile-number") || strategy.includes("header-enrichment")){
|
|
42
|
-
return {
|
|
43
|
-
type: "IDENTIFY_FLOW_BY_MSISDN",
|
|
44
|
-
result: RDS.NothingYet(),
|
|
45
|
-
nextData:{
|
|
46
|
-
nextAction:"submitMSISDNAction"
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}else if(strategy.includes("detect-operator-by-ip")){
|
|
50
|
-
return {
|
|
51
|
-
type:"DETECT_OPERATOR_BY_IP",
|
|
52
|
-
result:RDS.Loading()
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
}else{
|
|
56
|
-
switch (strategy) {
|
|
57
|
-
case "pin":
|
|
58
|
-
return {
|
|
59
|
-
type:"PIN",
|
|
60
|
-
result: {
|
|
61
|
-
nextAction:"submitMSISDNAction",
|
|
62
|
-
config:strategyConfigs.default.flowConfig
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
case "mo":
|
|
66
|
-
return {
|
|
67
|
-
type:"MO",
|
|
68
|
-
result: {
|
|
69
|
-
nextAction:"submitMSISDNAction",
|
|
70
|
-
config:strategyConfigs.default.flowConfig
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
case "mo-redir":
|
|
74
|
-
return {
|
|
75
|
-
type:"MO_REDIR",
|
|
76
|
-
result: {
|
|
77
|
-
nextAction:"submitMSISDNAction",
|
|
78
|
-
config:strategyConfigs.default.flowConfig
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
case "one-click":
|
|
82
|
-
return {
|
|
83
|
-
type:"ONE_CLICK",
|
|
84
|
-
result: {
|
|
85
|
-
nextAction:"getRedirectUrlAction",
|
|
86
|
-
config:strategyConfigs.default.flowConfig
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
case "click2sms":
|
|
91
|
-
return {
|
|
92
|
-
type:"CLICK2SMS",
|
|
93
|
-
result: {
|
|
94
|
-
nextAction:"loadOc2sms",
|
|
95
|
-
config:strategyConfigs.default.flowConfig
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
case "ussd":
|
|
99
|
-
return {
|
|
100
|
-
type:"USSD",
|
|
101
|
-
result: {
|
|
102
|
-
nextAction:"submitMSISDNAction",
|
|
103
|
-
config:strategyConfigs.default.flowConfig
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
default:
|
|
108
|
-
return {
|
|
109
|
-
type: "IDENTIFY_STRATEGY",
|
|
110
|
-
result:RDS.Loading()
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
console.log("NODE_ENV", process.env.NODE_ENV)
|
|
117
|
-
const store = createStore(
|
|
118
|
-
makeRootReducer(),
|
|
119
|
-
{
|
|
120
|
-
strategy:{
|
|
121
|
-
currentState: strategyBasedInitialState()
|
|
122
|
-
},
|
|
123
|
-
oneClickFlow:{
|
|
124
|
-
currentState: {
|
|
125
|
-
type: "GET_REDIRECT_URL",
|
|
126
|
-
result: {
|
|
127
|
-
type: "Success",
|
|
128
|
-
data: {
|
|
129
|
-
redirectUrl: "",
|
|
130
|
-
nextAction: "getRedirectUrlAction"
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
},
|
|
136
|
-
compose(
|
|
137
|
-
process.env.NODE_ENV == "development" ?
|
|
138
|
-
applyMiddleware(
|
|
139
|
-
thunk as ThunkMiddleware<IApplicationState, IApplicationActions>,
|
|
140
|
-
log
|
|
141
|
-
)
|
|
142
|
-
:
|
|
143
|
-
applyMiddleware(
|
|
144
|
-
thunk as ThunkMiddleware<IApplicationState, IApplicationActions>,
|
|
145
|
-
)
|
|
146
|
-
//...enhancers
|
|
147
|
-
)
|
|
148
|
-
);
|
|
149
|
-
|
|
150
|
-
export default store;
|
package/src/store/reducers.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import {combineReducers} from "redux";
|
|
2
|
-
|
|
3
|
-
import strategy from "../reducers/strategy";
|
|
4
|
-
import pinFlow from "../reducers/pinFlow";
|
|
5
|
-
import moFlow from "../reducers/moFlow";
|
|
6
|
-
import moRedirFlow from "../reducers/moRedirFlow";
|
|
7
|
-
import oneClickFlow from "../reducers/oneClickFlow";
|
|
8
|
-
import click2smsFlow from "../reducers/click2smsFlow";
|
|
9
|
-
import ussdFlow from "../reducers/ussdFlow";
|
|
10
|
-
|
|
11
|
-
import { IStrategyReducerState } from "../reducers/strategy/StrategyTypes";
|
|
12
|
-
import { IPinFlowReducerState } from "../reducers/pinFlow/PinTypes";
|
|
13
|
-
import { IMoFlowReducerState } from "../reducers/moFlow/MoTypes";
|
|
14
|
-
import { IMoRedirFlowReducerState } from "../reducers/moRedirFlow/MoRedirTypes";
|
|
15
|
-
import { IOneClickFlowReducerState } from "../reducers/oneClickFlow/OneClickTypes";
|
|
16
|
-
import { IClick2smsFlowReducerState } from "../reducers/click2smsFlow/Click2smsTypes";
|
|
17
|
-
import { IUssdFlowReducerState } from "../reducers/ussdFlow/UssdTypes";
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
export interface IApplicationState {
|
|
21
|
-
strategy:IStrategyReducerState;
|
|
22
|
-
pinFlow:IPinFlowReducerState;
|
|
23
|
-
moFlow:IMoFlowReducerState;
|
|
24
|
-
moRedirFlow:IMoRedirFlowReducerState;
|
|
25
|
-
oneClickFlow:IOneClickFlowReducerState;
|
|
26
|
-
click2smsFlow:IClick2smsFlowReducerState;
|
|
27
|
-
ussdFlow:IUssdFlowReducerState;
|
|
28
|
-
}
|
|
29
|
-
export default() => combineReducers<IApplicationState>({
|
|
30
|
-
strategy,
|
|
31
|
-
pinFlow,
|
|
32
|
-
moFlow,
|
|
33
|
-
moRedirFlow,
|
|
34
|
-
oneClickFlow,
|
|
35
|
-
click2smsFlow,
|
|
36
|
-
ussdFlow
|
|
37
|
-
});
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import PhoneNumber from "awesome-phonenumber"
|
|
2
|
-
import { IStrategyIDentifyUserResult } from "../reducers/strategy/StrategyTypes";
|
|
3
|
-
import { searchToObject } from "../reducers/strategy/utils";
|
|
4
|
-
|
|
5
|
-
export const handleAutoSubmitMsisdn = ({
|
|
6
|
-
msisdnValue,
|
|
7
|
-
dispatch,
|
|
8
|
-
submitMSISDNAction,
|
|
9
|
-
isHeaderEnrichmentSuccess,
|
|
10
|
-
setMsisdnValue
|
|
11
|
-
}:{msisdnValue:string,
|
|
12
|
-
dispatch:(submitMSISDNAction:(msisdnValue:string)=>void)=>void,
|
|
13
|
-
submitMSISDNAction:any,
|
|
14
|
-
isHeaderEnrichmentSuccess:boolean,
|
|
15
|
-
setMsisdnValue:(msisdnValue:string)=>void;
|
|
16
|
-
}) => {
|
|
17
|
-
if (msisdnValue && msisdnValue.length > 3 && isHeaderEnrichmentSuccess == false) {
|
|
18
|
-
const pn = new PhoneNumber("+" + msisdnValue, process.env.country.toUpperCase() );
|
|
19
|
-
if (pn.isValid()) {
|
|
20
|
-
dispatch(submitMSISDNAction(msisdnValue))
|
|
21
|
-
} else {
|
|
22
|
-
setMsisdnValue(pn.getCountryCode() + msisdnValue)
|
|
23
|
-
dispatch(submitMSISDNAction(pn.getCountryCode() + msisdnValue))
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export const handleFormSubmit = ({
|
|
29
|
-
isHeaderEnrichmentSuccess,
|
|
30
|
-
country,
|
|
31
|
-
setInternationalNumber,
|
|
32
|
-
onEnd,
|
|
33
|
-
internationalNumber
|
|
34
|
-
}:{
|
|
35
|
-
isHeaderEnrichmentSuccess:boolean,
|
|
36
|
-
country:string,
|
|
37
|
-
setInternationalNumber:(msisdn:string)=>void,
|
|
38
|
-
onEnd: (msisdn: string, extraParams?: { [key: string]: string }) => void,
|
|
39
|
-
internationalNumber:string
|
|
40
|
-
})=>{
|
|
41
|
-
const pn = new PhoneNumber("+" + internationalNumber, process.env.country.toUpperCase() );
|
|
42
|
-
const countryCode = pn.getCountryCode();
|
|
43
|
-
const networkType = isHeaderEnrichmentSuccess ? "mobile_data" : "wifi";
|
|
44
|
-
|
|
45
|
-
if(isHeaderEnrichmentSuccess == true && process.env.country == "kw" && internationalNumber != "" && !pn.isValid()){
|
|
46
|
-
setInternationalNumber(countryCode + internationalNumber)
|
|
47
|
-
const newNumber = countryCode + internationalNumber
|
|
48
|
-
onEnd(newNumber.match(/\d+/gi).join(''));
|
|
49
|
-
}else if(isHeaderEnrichmentSuccess == true && process.env.country == "ci"){
|
|
50
|
-
//Special case Digital Virgo sents encrypted msisdn we dont need to validate is
|
|
51
|
-
const searchObj = searchToObject() as IStrategyIDentifyUserResult;
|
|
52
|
-
if(searchObj.success && searchObj.msisdn){
|
|
53
|
-
const encryptedMsisdn = searchObj.msisdn
|
|
54
|
-
onEnd(encryptedMsisdn, { network_type:networkType, "skip-validation": "1" });
|
|
55
|
-
}
|
|
56
|
-
}else{
|
|
57
|
-
if(!!internationalNumber){
|
|
58
|
-
if(process.env.country == "ci"){
|
|
59
|
-
onEnd(internationalNumber.match(/\d+/gi).join(''), { network_type:networkType });
|
|
60
|
-
}else{
|
|
61
|
-
onEnd(internationalNumber.match(/\d+/gi).join(''));
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
package/src/utilities/index.ts
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import { getGoogleReCaptchaConfig } from "../reducers/moFlow/utils";
|
|
2
|
-
import { startEvinaAgency } from "../reducers/moRedirFlow/utils";
|
|
3
|
-
import { loadMcpShield } from "../reducers/pinFlow/utils";
|
|
4
|
-
import { IConfig } from "../reducers/strategy/StrategyTypes";
|
|
5
|
-
|
|
6
|
-
export const isDMBCheck = ()=>{
|
|
7
|
-
return (window.pac_analytics.visitor.xaid != null && (window.pac_analytics.visitor.xaid.toLowerCase().indexOf("dmb") != -1 || window.pac_analytics.visitor.xaid.toLowerCase().indexOf("amb")) != -1) ? true : false;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const getHost = ({host}:{host: string}): string=>{
|
|
11
|
-
const newHost = isDMBCheck() ? "de.tallymans.com" : host;
|
|
12
|
-
return newHost
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const setOnLoadUtilities = (config:IConfig)=>{
|
|
16
|
-
if(typeof window != "undefined"){
|
|
17
|
-
if(process.env.country.toLowerCase() === "cz"){
|
|
18
|
-
getGoogleReCaptchaConfig(config)
|
|
19
|
-
}
|
|
20
|
-
if(process.env.country.toLowerCase() === "a2" && process.env.NODE_ENV === "production"){
|
|
21
|
-
startEvinaAgency(config)
|
|
22
|
-
}
|
|
23
|
-
if(process.env.country.toLowerCase() === "sa" || process.env.country.toLowerCase() === "iq" || process.env.country.toLowerCase() === "k2"){
|
|
24
|
-
loadMcpShield(window, config);
|
|
25
|
-
}
|
|
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);
|
|
114
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
const loadScriptInnerHtml = (innerHTML:string, isBody?:boolean)=>{
|
|
2
|
-
var script = document.createElement('script');
|
|
3
|
-
script.type = 'text/javascript';
|
|
4
|
-
script.innerHTML = innerHTML;
|
|
5
|
-
if(isBody){
|
|
6
|
-
document.getElementsByTagName('body')[0].appendChild(script);
|
|
7
|
-
}else{
|
|
8
|
-
var headElem = document.getElementsByTagName('head')[0];
|
|
9
|
-
headElem.insertBefore(script, headElem.firstChild)
|
|
10
|
-
console.log('loadScript');
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export default loadScriptInnerHtml;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import loadScriptInnerHtml from "./loadScriptInnerHtml";
|
|
2
|
-
|
|
3
|
-
const loadScriptSrc = ({url, key, isRecaptcha = false}:{url:string, key?:string, isRecaptcha?: boolean})=>{
|
|
4
|
-
var script = document.createElement('script');
|
|
5
|
-
script.type = 'text/javascript';
|
|
6
|
-
script.src = url;
|
|
7
|
-
var headElem = document.getElementsByTagName('head')[0];
|
|
8
|
-
headElem.insertBefore(script, headElem.firstChild);
|
|
9
|
-
|
|
10
|
-
if(isRecaptcha){
|
|
11
|
-
script.onload = () => {
|
|
12
|
-
const scriptInner = `
|
|
13
|
-
grecaptcha.ready(function() {
|
|
14
|
-
grecaptcha.execute("${key}", {action: 'submit'}).then(function(token) {
|
|
15
|
-
// To be used by tallyman
|
|
16
|
-
window.reCaptchaToken = token;
|
|
17
|
-
console.log("-------" + token);
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
`;
|
|
21
|
-
loadScriptInnerHtml(scriptInner, true);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export default loadScriptSrc;
|