react-native-unit-components 3.1.2-beta.1 → 3.1.2-beta.3
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/android/src/main/java/com/unitreactnativecomponents/UnitReactNativeComponentsPackage.kt +2 -0
- package/android/src/main/java/com/unitreactnativecomponents/nativeModules/navigationBar/UNNavigationBarModule.kt +38 -0
- package/lib/commonjs/components/UNACHCreditComponent/UNACHCreditComponent.js +1 -14
- package/lib/commonjs/components/UNACHCreditComponent/UNACHCreditComponent.js.map +1 -1
- package/lib/commonjs/components/UNACHCreditComponent/UNACHCreditComponent.utils.js +1 -2
- package/lib/commonjs/components/UNACHCreditComponent/UNACHCreditComponent.utils.js.map +1 -1
- package/lib/commonjs/components/UNACHDebitComponent/UNACHDebitComponent.js +1 -14
- package/lib/commonjs/components/UNACHDebitComponent/UNACHDebitComponent.js.map +1 -1
- package/lib/commonjs/components/UNACHDebitComponent/UNACHDebitComponent.utils.js +1 -2
- package/lib/commonjs/components/UNACHDebitComponent/UNACHDebitComponent.utils.js.map +1 -1
- package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.utils.js +4 -1
- package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.utils.js.map +1 -1
- package/lib/commonjs/components/UNBottomSheetComponent/components/UNBottomSheetSlotComponent/UNBottomSheetSlotComponent.js +10 -1
- package/lib/commonjs/components/UNBottomSheetComponent/components/UNBottomSheetSlotComponent/UNBottomSheetSlotComponent.js.map +1 -1
- package/lib/commonjs/components/UNWhiteLabelAppComponent/UNWhiteLabelAppComponent.js +38 -0
- package/lib/commonjs/components/UNWhiteLabelAppComponent/UNWhiteLabelAppComponent.js.map +1 -1
- package/lib/commonjs/components/UNWhiteLabelAppComponent/UNWhiteLabelAppComponent.utils.js +10 -2
- package/lib/commonjs/components/UNWhiteLabelAppComponent/UNWhiteLabelAppComponent.utils.js.map +1 -1
- package/lib/commonjs/hooks/useSafeAreaDimensions.js +14 -3
- package/lib/commonjs/hooks/useSafeAreaDimensions.js.map +1 -1
- package/lib/commonjs/messages/webMessages/accountMessage.js +2 -0
- package/lib/commonjs/messages/webMessages/accountMessage.js.map +1 -1
- package/lib/commonjs/nativeModulesHelpers/UNNavigationBarHelper.js +17 -0
- package/lib/commonjs/nativeModulesHelpers/UNNavigationBarHelper.js.map +1 -0
- package/lib/commonjs/scripts/html/bodyScript.js +24 -2
- package/lib/commonjs/scripts/html/bodyScript.js.map +1 -1
- package/lib/commonjs/unitComponentsSdkManager/UnitComponentsSdkManager.js +1 -1
- package/lib/commonjs/unitComponentsSdkManager/UnitComponentsSdkManager.utils.internal.js.map +1 -1
- package/lib/commonjs/webComponent/WebComponent.js +6 -2
- package/lib/commonjs/webComponent/WebComponent.js.map +1 -1
- package/lib/commonjs/webComponent/html.js +4 -0
- package/lib/commonjs/webComponent/html.js.map +1 -1
- package/lib/module/components/UNACHCreditComponent/UNACHCreditComponent.js +2 -14
- package/lib/module/components/UNACHCreditComponent/UNACHCreditComponent.js.map +1 -1
- package/lib/module/components/UNACHCreditComponent/UNACHCreditComponent.utils.js +1 -2
- package/lib/module/components/UNACHCreditComponent/UNACHCreditComponent.utils.js.map +1 -1
- package/lib/module/components/UNACHDebitComponent/UNACHDebitComponent.js +2 -14
- package/lib/module/components/UNACHDebitComponent/UNACHDebitComponent.js.map +1 -1
- package/lib/module/components/UNACHDebitComponent/UNACHDebitComponent.utils.js +1 -2
- package/lib/module/components/UNACHDebitComponent/UNACHDebitComponent.utils.js.map +1 -1
- package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.utils.js +4 -1
- package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.utils.js.map +1 -1
- package/lib/module/components/UNBottomSheetComponent/components/UNBottomSheetSlotComponent/UNBottomSheetSlotComponent.js +10 -1
- package/lib/module/components/UNBottomSheetComponent/components/UNBottomSheetSlotComponent/UNBottomSheetSlotComponent.js.map +1 -1
- package/lib/module/components/UNWhiteLabelAppComponent/UNWhiteLabelAppComponent.js +39 -1
- package/lib/module/components/UNWhiteLabelAppComponent/UNWhiteLabelAppComponent.js.map +1 -1
- package/lib/module/components/UNWhiteLabelAppComponent/UNWhiteLabelAppComponent.utils.js +9 -2
- package/lib/module/components/UNWhiteLabelAppComponent/UNWhiteLabelAppComponent.utils.js.map +1 -1
- package/lib/module/hooks/useSafeAreaDimensions.js +14 -3
- package/lib/module/hooks/useSafeAreaDimensions.js.map +1 -1
- package/lib/module/messages/webMessages/accountMessage.js +2 -0
- package/lib/module/messages/webMessages/accountMessage.js.map +1 -1
- package/lib/module/nativeModulesHelpers/UNNavigationBarHelper.js +11 -0
- package/lib/module/nativeModulesHelpers/UNNavigationBarHelper.js.map +1 -0
- package/lib/module/scripts/html/bodyScript.js +23 -1
- package/lib/module/scripts/html/bodyScript.js.map +1 -1
- package/lib/module/unitComponentsSdkManager/UnitComponentsSdkManager.js +1 -1
- package/lib/module/unitComponentsSdkManager/UnitComponentsSdkManager.utils.internal.js.map +1 -1
- package/lib/module/utils/eventBus/EventBus.types.js.map +1 -1
- package/lib/module/webComponent/WebComponent.js +6 -2
- package/lib/module/webComponent/WebComponent.js.map +1 -1
- package/lib/module/webComponent/html.js +5 -1
- package/lib/module/webComponent/html.js.map +1 -1
- package/lib/typescript/src/components/UNACHCreditComponent/UNACHCreditComponent.d.ts.map +1 -1
- package/lib/typescript/src/components/UNACHCreditComponent/UNACHCreditComponent.utils.d.ts +1 -1
- package/lib/typescript/src/components/UNACHCreditComponent/UNACHCreditComponent.utils.d.ts.map +1 -1
- package/lib/typescript/src/components/UNACHDebitComponent/UNACHDebitComponent.d.ts.map +1 -1
- package/lib/typescript/src/components/UNACHDebitComponent/UNACHDebitComponent.utils.d.ts +1 -1
- package/lib/typescript/src/components/UNACHDebitComponent/UNACHDebitComponent.utils.d.ts.map +1 -1
- package/lib/typescript/src/components/UNBottomSheetComponent/UNBottomSheetComponent.utils.d.ts.map +1 -1
- package/lib/typescript/src/components/UNBottomSheetComponent/components/UNBottomSheetSlotComponent/UNBottomSheetSlotComponent.d.ts.map +1 -1
- package/lib/typescript/src/components/UNWhiteLabelAppComponent/UNWhiteLabelAppComponent.d.ts.map +1 -1
- package/lib/typescript/src/components/UNWhiteLabelAppComponent/UNWhiteLabelAppComponent.utils.d.ts +1 -0
- package/lib/typescript/src/components/UNWhiteLabelAppComponent/UNWhiteLabelAppComponent.utils.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useSafeAreaDimensions.d.ts.map +1 -1
- package/lib/typescript/src/messages/webMessages/accountMessage.d.ts +3 -1
- package/lib/typescript/src/messages/webMessages/accountMessage.d.ts.map +1 -1
- package/lib/typescript/src/nativeModulesHelpers/UNNavigationBarHelper.d.ts +2 -0
- package/lib/typescript/src/nativeModulesHelpers/UNNavigationBarHelper.d.ts.map +1 -0
- package/lib/typescript/src/scripts/html/bodyScript.d.ts +4 -0
- package/lib/typescript/src/scripts/html/bodyScript.d.ts.map +1 -1
- package/lib/typescript/src/unitComponentsSdkManager/UnitComponentsSdkManager.utils.internal.d.ts.map +1 -1
- package/lib/typescript/src/utils/eventBus/EventBus.types.d.ts +2 -0
- package/lib/typescript/src/utils/eventBus/EventBus.types.d.ts.map +1 -1
- package/lib/typescript/src/webComponent/WebComponent.d.ts.map +1 -1
- package/lib/typescript/src/webComponent/html.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/UNACHCreditComponent/UNACHCreditComponent.tsx +2 -15
- package/src/components/UNACHCreditComponent/UNACHCreditComponent.utils.ts +1 -2
- package/src/components/UNACHDebitComponent/UNACHDebitComponent.tsx +2 -15
- package/src/components/UNACHDebitComponent/UNACHDebitComponent.utils.ts +1 -2
- package/src/components/UNBottomSheetComponent/UNBottomSheetComponent.utils.ts +4 -1
- package/src/components/UNBottomSheetComponent/components/UNBottomSheetSlotComponent/UNBottomSheetSlotComponent.tsx +13 -5
- package/src/components/UNWhiteLabelAppComponent/UNWhiteLabelAppComponent.tsx +36 -1
- package/src/components/UNWhiteLabelAppComponent/UNWhiteLabelAppComponent.utils.ts +10 -2
- package/src/hooks/useSafeAreaDimensions.ts +15 -3
- package/src/messages/webMessages/accountMessage.ts +4 -3
- package/src/nativeModulesHelpers/UNNavigationBarHelper.ts +14 -0
- package/src/scripts/html/bodyScript.ts +26 -2
- package/src/unitComponentsSdkManager/UnitComponentsSdkManager.ts +1 -1
- package/src/unitComponentsSdkManager/UnitComponentsSdkManager.utils.internal.ts +4 -1
- package/src/utils/eventBus/EventBus.types.ts +2 -0
- package/src/webComponent/WebComponent.tsx +6 -2
- package/src/webComponent/html.ts +5 -0
|
@@ -16,6 +16,7 @@ import WebView from 'react-native-webview';
|
|
|
16
16
|
import {
|
|
17
17
|
getWhiteLabelAppParams,
|
|
18
18
|
getWhiteLabelAppScript,
|
|
19
|
+
injectAccountCreationActionsOpenPlaidForLinkExternalAccount,
|
|
19
20
|
injectRefreshEventIfNeeded,
|
|
20
21
|
} from './UNWhiteLabelAppComponent.utils';
|
|
21
22
|
import { UserDataKeys } from '../../types/internal/unitStore.types';
|
|
@@ -25,6 +26,10 @@ import { ActivityMessage } from '../../messages/webMessages/activityMessage';
|
|
|
25
26
|
import { setItemInWindowUnitStore } from '../../utils/windowUnitStore';
|
|
26
27
|
import { UNBaseView } from '../../nativeComponents/UNBaseView';
|
|
27
28
|
import { UnitComponentsSDK } from '../../unitComponentsSdkManager/UnitComponentsSdkManager';
|
|
29
|
+
import { AccountMessage } from '../../messages/webMessages/accountMessage';
|
|
30
|
+
import { OpenPlaidEvent, PlaidMessage } from '../../messages/webMessages/plaidMessages';
|
|
31
|
+
import { injectUnitPlaidExit, injectUnitPlaidResponse } from '../UNPayeeManagementComponent/UNPayeeManagementComponent.utils';
|
|
32
|
+
import { LinkExit, LinkSuccess, open as openPlaidLink, create as createPlaidLink } from 'react-native-plaid-link-sdk';
|
|
28
33
|
|
|
29
34
|
export interface UNWhiteLabelAppComponentProps {
|
|
30
35
|
// inputs
|
|
@@ -66,9 +71,12 @@ const UNWhiteLabelAppComponent = (props: UNWhiteLabelAppComponentProps) => {
|
|
|
66
71
|
}
|
|
67
72
|
break;
|
|
68
73
|
}
|
|
69
|
-
|
|
70
74
|
case PageMessage.PAGE_LOADED:
|
|
71
75
|
updateWindowUnitStore();
|
|
76
|
+
break;
|
|
77
|
+
case PlaidMessage.UNIT_OPEN_PLAID:
|
|
78
|
+
openPlaid(message.details as OpenPlaidEvent);
|
|
79
|
+
break;
|
|
72
80
|
}
|
|
73
81
|
};
|
|
74
82
|
|
|
@@ -94,11 +102,38 @@ const UNWhiteLabelAppComponent = (props: UNWhiteLabelAppComponentProps) => {
|
|
|
94
102
|
webRef.current?.injectJavaScript(`dispatchActivityFilterChangedEvent('${query}')`);
|
|
95
103
|
};
|
|
96
104
|
|
|
105
|
+
const openPlaid = (openPlaidData: OpenPlaidEvent) => {
|
|
106
|
+
const linkToken = openPlaidData.plaidLinkToken.attributes.linkToken;
|
|
107
|
+
createPlaidLink({ token: linkToken });
|
|
108
|
+
|
|
109
|
+
openPlaidLink({
|
|
110
|
+
onSuccess: (success: LinkSuccess) => {
|
|
111
|
+
injectUnitPlaidResponse(webRef.current, success);
|
|
112
|
+
},
|
|
113
|
+
onExit: (exit: LinkExit) => {
|
|
114
|
+
injectUnitPlaidExit(webRef.current, exit.error);
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
|
|
97
119
|
useEventListener({ busEventKey: UnitComponentsMessage.UNIT_REQUEST_REFRESH, action: requestRefresh });
|
|
98
120
|
useEventListener({
|
|
99
121
|
busEventKey: ActivityMessage.UNIT_ACTIVITY_FILTERS_CHANGED,
|
|
100
122
|
action: dispatchActivityFiltersChanged,
|
|
101
123
|
});
|
|
124
|
+
useEventListener({
|
|
125
|
+
busEventKey: PlaidMessage.UNIT_OPEN_PLAID,
|
|
126
|
+
action: (details) => {
|
|
127
|
+
openPlaid(details);
|
|
128
|
+
},
|
|
129
|
+
});
|
|
130
|
+
useEventListener({
|
|
131
|
+
busEventKey: AccountMessage.UNIT_ACCOUNT_CREATION_ACTIONS_OPEN_PLAID_FOR_LINK_EXTERNAL_ACCOUNT,
|
|
132
|
+
action: () => injectAccountCreationActionsOpenPlaidForLinkExternalAccount(webRef.current),
|
|
133
|
+
});
|
|
134
|
+
useEventListener({ busEventKey: AccountMessage.UNIT_ACCOUNT_CREATED, action: () => {
|
|
135
|
+
webRef.current?.injectJavaScript('dispatchAccountCreatedEvent()');
|
|
136
|
+
} });
|
|
102
137
|
|
|
103
138
|
const renderWebView = () => {
|
|
104
139
|
return (
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import WebView from 'react-native-webview';
|
|
2
2
|
import { RequestRefreshEvent } from '../../messages/webMessages/unitComponentsMessages';
|
|
3
3
|
import { UNWhiteLabelAppComponentProps } from './UNWhiteLabelAppComponent';
|
|
4
|
-
import { DISPATCH_REQUEST_REFRESH, LISTENERS } from '../../scripts/html/bodyScript';
|
|
4
|
+
import { DISPATCH_ACCOUNT_CREATION_ACTIONS_OPEN_PLAID_FOR_LINK_EXTERNAL_ACCOUNT, DISPATCH_OPEN_PLAID, DISPATCH_PLAID_EXIT, DISPATCH_PLAID_RESPONSE, DISPATCH_REQUEST_REFRESH, LISTENERS } from '../../scripts/html/bodyScript';
|
|
5
5
|
|
|
6
6
|
export const getWhiteLabelAppParams = (props: UNWhiteLabelAppComponentProps) => {
|
|
7
7
|
// customer token is the preferred way to authenticate
|
|
@@ -26,10 +26,18 @@ export const injectRefreshEventIfNeeded = (currentWeb: WebView | null, requestRe
|
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
+
export const injectAccountCreationActionsOpenPlaidForLinkExternalAccount = (currentWeb: WebView | null) => {
|
|
30
|
+
currentWeb?.injectJavaScript('dispatchAccountCreationActionsOpenPlaidForLinkExternalAccount()');
|
|
31
|
+
};
|
|
32
|
+
|
|
29
33
|
export const getWhiteLabelAppScript = () => {
|
|
30
34
|
return `
|
|
31
35
|
${DISPATCH_REQUEST_REFRESH}
|
|
32
|
-
|
|
36
|
+
${DISPATCH_OPEN_PLAID}
|
|
37
|
+
${DISPATCH_PLAID_RESPONSE}
|
|
38
|
+
${DISPATCH_PLAID_EXIT}
|
|
39
|
+
${DISPATCH_ACCOUNT_CREATION_ACTIONS_OPEN_PLAID_FOR_LINK_EXTERNAL_ACCOUNT}
|
|
33
40
|
${LISTENERS.unitWhiteLabelAppOnLoad}
|
|
41
|
+
${LISTENERS.unitCounterpartyCreated}
|
|
34
42
|
`;
|
|
35
43
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Dimensions, Platform } from 'react-native';
|
|
2
2
|
import { initialWindowMetrics } from 'react-native-safe-area-context';
|
|
3
|
+
import { isNavigationBarTranslucent } from '../nativeModulesHelpers/UNNavigationBarHelper';
|
|
3
4
|
|
|
4
5
|
const isAndroid = Platform.OS === 'android';
|
|
5
6
|
const isAndroid10To14 = isAndroid && Platform.Version >= 29 && Platform.Version < 35;
|
|
@@ -9,12 +10,20 @@ const insets = initialWindowMetrics?.insets ?? { top: 0, bottom: 0, left: 0, rig
|
|
|
9
10
|
const windowHeight = Dimensions.get('window').height;
|
|
10
11
|
const screenHeight = Dimensions.get('screen').height;
|
|
11
12
|
|
|
12
|
-
// Detect edge-to-edge by comparing window to screen height
|
|
13
|
-
// Edge-to-edge ON: windowHeight ≈ screenHeight | OFF: windowHeight < screenHeight
|
|
13
|
+
// Detect edge-to-edge on API 35+ by comparing window to screen height
|
|
14
14
|
const heightDifference = Math.abs(screenHeight - windowHeight);
|
|
15
15
|
const isEdgeToEdgeActive = isAndroid15AndAbove && heightDifference < 10;
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
// Resolved once at module load time; defaults to false until resolved.
|
|
18
|
+
// The native call is fast (reads a window flag), so it resolves before
|
|
19
|
+
// any bottom sheet is opened.
|
|
20
|
+
let _navBarTranslucent = false;
|
|
21
|
+
|
|
22
|
+
if (isAndroid) {
|
|
23
|
+
isNavigationBarTranslucent().then((result) => {
|
|
24
|
+
_navBarTranslucent = result;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
18
27
|
|
|
19
28
|
const calculateFullScreenHeight = (): number => {
|
|
20
29
|
if (isAndroid15AndAbove) {
|
|
@@ -41,6 +50,9 @@ const calculateContentHeight = (): number => {
|
|
|
41
50
|
const contentHeight = calculateContentHeight();
|
|
42
51
|
|
|
43
52
|
export const useSafeAreaDimensions = () => {
|
|
53
|
+
const shouldApplyBottomInset = isEdgeToEdgeActive || _navBarTranslucent;
|
|
54
|
+
const effectiveBottomInset = shouldApplyBottomInset ? insets.bottom : 0;
|
|
55
|
+
|
|
44
56
|
return {
|
|
45
57
|
insets,
|
|
46
58
|
fullScreenHeight,
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { UNAccount } from '../../types/shared';
|
|
2
2
|
|
|
3
3
|
export enum AccountMessage {
|
|
4
|
-
UNIT_ACCOUNT_CHANGED = 'unitAccountChanged'
|
|
4
|
+
UNIT_ACCOUNT_CHANGED = 'unitAccountChanged',
|
|
5
|
+
UNIT_ACCOUNT_CREATED = 'unitAccountCreated',
|
|
6
|
+
UNIT_ACCOUNT_CREATION_ACTIONS_OPEN_PLAID_FOR_LINK_EXTERNAL_ACCOUNT = 'unitAccountCreationActionsOpenPlaidForLinkExternalAccount',
|
|
5
7
|
}
|
|
6
8
|
|
|
7
9
|
export interface AccountChangedEvent {
|
|
8
10
|
account: UNAccount;
|
|
9
11
|
}
|
|
10
12
|
|
|
11
|
-
export type AccountEvent =
|
|
12
|
-
| AccountChangedEvent
|
|
13
|
+
export type AccountEvent = AccountChangedEvent;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Platform, NativeModules } from 'react-native';
|
|
2
|
+
|
|
3
|
+
const UNNavigationBarModule = Platform.OS === 'android'
|
|
4
|
+
? NativeModules.UNNavigationBarModule
|
|
5
|
+
: undefined;
|
|
6
|
+
|
|
7
|
+
export async function isNavigationBarTranslucent(): Promise<boolean> {
|
|
8
|
+
if (!UNNavigationBarModule) return false;
|
|
9
|
+
try {
|
|
10
|
+
return await UNNavigationBarModule.isNavigationBarTranslucent();
|
|
11
|
+
} catch {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -157,6 +157,12 @@ export const LISTENERS = {
|
|
|
157
157
|
})
|
|
158
158
|
});
|
|
159
159
|
`,
|
|
160
|
+
unitAccountCreated: `
|
|
161
|
+
window.addEventListener("${AccountMessage.UNIT_ACCOUNT_CREATED}", (e) => {
|
|
162
|
+
if (e.detail?.fromSDK) { return }
|
|
163
|
+
postMessageToSDK({ type: "${AccountMessage.UNIT_ACCOUNT_CREATED}" })
|
|
164
|
+
});
|
|
165
|
+
`,
|
|
160
166
|
unitActivityFiltersChanged: `
|
|
161
167
|
window.addEventListener("${ActivityMessage.UNIT_ACTIVITY_FILTERS_CHANGED}", (e) => {
|
|
162
168
|
postMessageToSDK({ type: "${ActivityMessage.UNIT_ACTIVITY_FILTERS_CHANGED}", details: e.detail })
|
|
@@ -262,13 +268,19 @@ export const LISTENERS = {
|
|
|
262
268
|
|
|
263
269
|
unitOpenPlaid: `
|
|
264
270
|
window.addEventListener("${PlaidMessage.UNIT_OPEN_PLAID}", async (e) => {
|
|
265
|
-
const response =
|
|
271
|
+
const response = e.detail;
|
|
266
272
|
response.then((data) => {
|
|
267
273
|
postMessageToSDK({ type: "${PlaidMessage.UNIT_OPEN_PLAID}", details: data.data })
|
|
268
274
|
}).catch((e) => {
|
|
269
275
|
console.log(e)
|
|
270
276
|
})
|
|
271
277
|
});
|
|
278
|
+
`,
|
|
279
|
+
unitAccountCreationActionsOpenPlaidForLinkExternalAccount: `
|
|
280
|
+
window.addEventListener("${AccountMessage.UNIT_ACCOUNT_CREATION_ACTIONS_OPEN_PLAID_FOR_LINK_EXTERNAL_ACCOUNT}", (e) => {
|
|
281
|
+
if (e.detail?.fromSDK) { return }
|
|
282
|
+
postMessageToSDK({ type: "${AccountMessage.UNIT_ACCOUNT_CREATION_ACTIONS_OPEN_PLAID_FOR_LINK_EXTERNAL_ACCOUNT}" })
|
|
283
|
+
});
|
|
272
284
|
`
|
|
273
285
|
};
|
|
274
286
|
|
|
@@ -286,6 +298,12 @@ export const DISPATCH_EVENT_TO_CONTINUE = `
|
|
|
286
298
|
}
|
|
287
299
|
`;
|
|
288
300
|
|
|
301
|
+
export const DISPATCH_ACCOUNT_CREATION_ACTIONS_OPEN_PLAID_FOR_LINK_EXTERNAL_ACCOUNT = `
|
|
302
|
+
const dispatchAccountCreationActionsOpenPlaidForLinkExternalAccount = () => {
|
|
303
|
+
window.dispatchEvent(new CustomEvent("${AccountMessage.UNIT_ACCOUNT_CREATION_ACTIONS_OPEN_PLAID_FOR_LINK_EXTERNAL_ACCOUNT}", { detail: { fromSDK: true } }))
|
|
304
|
+
}
|
|
305
|
+
`;
|
|
306
|
+
|
|
289
307
|
export const DISPATCH_CARD_STATUS_CHANGED = `
|
|
290
308
|
const dispatchCardStatusChanged = (details) => {
|
|
291
309
|
const event = new CustomEvent("${CardMessage.CARD_STATUS_CHANGED}",{ detail: JSON.parse(details) })
|
|
@@ -385,9 +403,15 @@ export const DISPATCH_REQUEST_ACCOUNT_ACTION = `
|
|
|
385
403
|
}
|
|
386
404
|
`;
|
|
387
405
|
|
|
406
|
+
export const DISPATCH_ACCOUNT_CREATED_EVENT = `
|
|
407
|
+
const dispatchAccountCreatedEvent = () => {
|
|
408
|
+
window.dispatchEvent(new CustomEvent("${AccountMessage.UNIT_ACCOUNT_CREATED}", { detail: { fromSDK: true } }));
|
|
409
|
+
}
|
|
410
|
+
`;
|
|
411
|
+
|
|
388
412
|
export const DISPATCH_COUNTERPARTY_DELETED = `
|
|
389
413
|
const dispatchCounterpartyDeletedEvent = (details) => {
|
|
390
414
|
const event = new CustomEvent("unitCounterpartyDeleted",{ detail: { data: details } });
|
|
391
415
|
window.dispatchEvent(event);
|
|
392
416
|
}
|
|
393
|
-
`;
|
|
417
|
+
`;
|
|
@@ -26,7 +26,7 @@ export class UnitComponentsSDK {
|
|
|
26
26
|
protected static fonts?: UNFonts;
|
|
27
27
|
protected static signedNonce?: string;
|
|
28
28
|
protected static pushProvisionModule?: typeof NativeModules;
|
|
29
|
-
protected static sdkVersion = '3.1.2-beta.
|
|
29
|
+
protected static sdkVersion = '3.1.2-beta.3';
|
|
30
30
|
static iosFontBase64Map: Record<string, string> = {};
|
|
31
31
|
|
|
32
32
|
public static init = async (
|
|
@@ -2,7 +2,10 @@ import type { UNComponentsWebVersioningStrategy } from '../types/shared';
|
|
|
2
2
|
import { UNComponentsEnvironment } from '../types/shared/env.types';
|
|
3
3
|
import { getWebSdkVersionString } from '../utils/webVersioningStrategy.utils';
|
|
4
4
|
|
|
5
|
-
export const getUnitScriptUrl = (
|
|
5
|
+
export const getUnitScriptUrl = (
|
|
6
|
+
env: UNComponentsEnvironment,
|
|
7
|
+
webVersioningStrategy: UNComponentsWebVersioningStrategy
|
|
8
|
+
) => {
|
|
6
9
|
const webSdkVersionString = getWebSdkVersionString(webVersioningStrategy);
|
|
7
10
|
|
|
8
11
|
switch (env) {
|
|
@@ -19,6 +19,7 @@ export type EventMap = {
|
|
|
19
19
|
[CardMessage.CARD_ACTIVATED]: UNCard;
|
|
20
20
|
[CardMessage.CARD_CREATED]: CardCreatedEvent;
|
|
21
21
|
[AccountMessage.UNIT_ACCOUNT_CHANGED]: UNAccount;
|
|
22
|
+
[AccountMessage.UNIT_ACCOUNT_CREATED]: Record<PropertyKey, never>;
|
|
22
23
|
[ActivityMessage.UNIT_ACTIVITY_FILTERS_CHANGED]: ActivityFiltersChangedEvent;
|
|
23
24
|
[MultipleCardsMessage.UNIT_MULTIPLE_CARDS_CARD_CLICKED]: UNCard;
|
|
24
25
|
[MultipleCardsMessage.UNIT_MULTIPLE_CARDS_FILTERS_CHANGED]: MultipleCardsFiltersChangedEvent;
|
|
@@ -28,6 +29,7 @@ export type EventMap = {
|
|
|
28
29
|
[UnitComponentsMessage.UNIT_MULTI_FACTOR_AUTH_FINISHED]: MultiFactorAuthenticationFinishedEvent;
|
|
29
30
|
[PageMessage.PAGE_HEIGHT]: number;
|
|
30
31
|
[PlaidMessage.UNIT_OPEN_PLAID]: OpenPlaidEvent;
|
|
32
|
+
[AccountMessage.UNIT_ACCOUNT_CREATION_ACTIONS_OPEN_PLAID_FOR_LINK_EXTERNAL_ACCOUNT]: Record<PropertyKey, never>;
|
|
31
33
|
[PayeeManagementMessage.UNIT_COUNTERPARTY_DELETED]: UNCounterparty;
|
|
32
34
|
};
|
|
33
35
|
|
|
@@ -49,6 +49,7 @@ export const WebComponent = React.forwardRef<WebView, WebComponentProps>(functio
|
|
|
49
49
|
const customerToken = useSelector((state: RootState) => state.configuration.customerToken);
|
|
50
50
|
const [sourceHtml, setSourceHtml] = useState<string | null>(null);
|
|
51
51
|
const [baseName, setBaseName] = useState<string>();
|
|
52
|
+
const [androidPackageName, setAndroidPackageName] = useState<string>();
|
|
52
53
|
const [infoParams, setInfoParams] = useState<{ [key: string]: string }>({});
|
|
53
54
|
|
|
54
55
|
const webRef = useRef(null);
|
|
@@ -65,6 +66,8 @@ export const WebComponent = React.forwardRef<WebView, WebComponentProps>(functio
|
|
|
65
66
|
setBaseName(name.replace(/ /g, '-'));
|
|
66
67
|
} else { // android
|
|
67
68
|
setBaseName('unit');
|
|
69
|
+
const packageName = await AppInfo.getAppIdentifier();
|
|
70
|
+
setAndroidPackageName(packageName);
|
|
68
71
|
}
|
|
69
72
|
} catch (error: any) {
|
|
70
73
|
console.error(error);
|
|
@@ -104,6 +107,7 @@ export const WebComponent = React.forwardRef<WebView, WebComponentProps>(functio
|
|
|
104
107
|
|
|
105
108
|
const windowInfoParams = `window.UnitMobileSDKConfig['info'] = ${JSON.stringify(infoParams)};`;
|
|
106
109
|
const plaidRedirectUriParam = (Platform.OS == 'ios' && UnitComponentsSDK.helpers.redirectUri) ? `window.UnitMobileSDKConfig['plaidRedirectUri'] = '${UnitComponentsSDK.helpers.redirectUri}/plaid';` : '';
|
|
110
|
+
const androidPackageNameParam = androidPackageName ? `window.UnitMobileSDKConfig.androidPackageName='${androidPackageName}';` : '';
|
|
107
111
|
const unitSessionIdParam = `window.UnitSessionStore.unitSessionId = '${UnitComponentsSDK.helpers.unitSessionId}';`;
|
|
108
112
|
|
|
109
113
|
const unitVerifiedCustomerToken = await UNStoreManagerHelper.getValue(UserDataKeys.unitVerifiedCustomerToken);
|
|
@@ -111,7 +115,7 @@ export const WebComponent = React.forwardRef<WebView, WebComponentProps>(functio
|
|
|
111
115
|
const windowVerifiedCustomerToken = unitVerifiedCustomerToken ? `window.UnitStore['${UserDataKeys.unitVerifiedCustomerToken}'] = '${unitVerifiedCustomerToken}';` : '';
|
|
112
116
|
const windowAppFormVerifiedToken = unitAppFormVerifiedToken ? `window.UnitStore['${UserDataKeys.unitApplicationFormVerifiedToken}'] = '${unitAppFormVerifiedToken}';` : '';
|
|
113
117
|
|
|
114
|
-
const windowParams = `${windowInfoParams} ${unitSessionIdParam} ${plaidRedirectUriParam} ${windowVerifiedCustomerToken} ${windowAppFormVerifiedToken} ${props.windowParams || ''}`;
|
|
118
|
+
const windowParams = `${windowInfoParams} ${unitSessionIdParam} ${plaidRedirectUriParam} ${androidPackageNameParam} ${windowVerifiedCustomerToken} ${windowAppFormVerifiedToken} ${props.windowParams || ''}`;
|
|
115
119
|
|
|
116
120
|
let newHtml = html.replace(HTML_PLACEHOLDER.BODY, getHtmlBody(props.type.valueOf(), componentParams, props.presentationMode));
|
|
117
121
|
newHtml = newHtml.replace(HTML_PLACEHOLDER.FONT_FACES, fontFaces);
|
|
@@ -122,7 +126,7 @@ export const WebComponent = React.forwardRef<WebView, WebComponentProps>(functio
|
|
|
122
126
|
|
|
123
127
|
updateSourceHTML();
|
|
124
128
|
|
|
125
|
-
}, [props.params, unitScript, props.presentationMode, props.script, props.windowParams, globalTheme, globalLanguage, customerToken, infoParams]);
|
|
129
|
+
}, [props.params, unitScript, props.presentationMode, props.script, props.windowParams, globalTheme, globalLanguage, customerToken, infoParams, androidPackageName]);
|
|
126
130
|
|
|
127
131
|
// Listen and update the live webComponents
|
|
128
132
|
const handleMultiFactorAuthFinished = (data: MultiFactorAuthenticationFinishedEvent) => {
|
package/src/webComponent/html.ts
CHANGED
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
DISPATCH_CARD_STATUS_CHANGED,
|
|
16
16
|
DISPATCH_MULTIPLE_CARDS_FILTER_CHANGED_EVENT,
|
|
17
17
|
DISPATCH_CARD_CREATED_EVENT,
|
|
18
|
+
DISPATCH_ACCOUNT_CREATED_EVENT,
|
|
18
19
|
} from '../scripts/html/bodyScript';
|
|
19
20
|
|
|
20
21
|
export const HTML_PLACEHOLDER = {
|
|
@@ -86,6 +87,8 @@ const htmlText = `
|
|
|
86
87
|
|
|
87
88
|
${LISTENERS.unitAccountChanged}
|
|
88
89
|
|
|
90
|
+
${LISTENERS.unitAccountCreated}
|
|
91
|
+
|
|
89
92
|
${LISTENERS.unitActivityFiltersChanged}
|
|
90
93
|
|
|
91
94
|
${LISTENERS.unitMultipleCardsFiltersChanged}
|
|
@@ -116,6 +119,8 @@ const htmlText = `
|
|
|
116
119
|
|
|
117
120
|
${DISPATCH_REQUEST_ACCOUNT_ACTION}
|
|
118
121
|
|
|
122
|
+
${DISPATCH_ACCOUNT_CREATED_EVENT}
|
|
123
|
+
|
|
119
124
|
${SET_ITEM_IN_WINDOW_UNIT_STORE}
|
|
120
125
|
|
|
121
126
|
${HTML_PLACEHOLDER.SCRIPT_FROM_NATIVE}
|