react-native-unit-components 1.2.1 → 1.3.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.
- package/README.md +133 -13
- package/lib/commonjs/components/UNACHCreditComponent/UNACHCreditComponent.js +24 -1
- package/lib/commonjs/components/UNACHCreditComponent/UNACHCreditComponent.js.map +1 -1
- package/lib/commonjs/components/UNACHDebitComponent/UNACHDebitComponent.js +24 -1
- package/lib/commonjs/components/UNACHDebitComponent/UNACHDebitComponent.js.map +1 -1
- package/lib/commonjs/components/UNAccountComponent/UNAccountComponent.js +25 -3
- package/lib/commonjs/components/UNAccountComponent/UNAccountComponent.js.map +1 -1
- package/lib/commonjs/components/UNAccountComponent/UNAccountComponent.utils.js +5 -1
- package/lib/commonjs/components/UNAccountComponent/UNAccountComponent.utils.js.map +1 -1
- package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.js +24 -1
- package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.js.map +1 -1
- package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.utils.js +2 -0
- package/lib/commonjs/components/UNActivityComponent/UNActivityComponent.utils.js.map +1 -1
- package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.js +18 -1
- package/lib/commonjs/components/UNBookPaymentComponent/UNBookPaymentComponent.js.map +1 -1
- package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.js +3 -0
- package/lib/commonjs/components/UNBottomSheetComponent/UNBottomSheetComponent.js.map +1 -1
- package/lib/commonjs/components/UNCardComponent/UNCardComponent.js +37 -3
- package/lib/commonjs/components/UNCardComponent/UNCardComponent.js.map +1 -1
- package/lib/commonjs/components/UNCardComponent/UNCardComponent.utils.js +9 -1
- package/lib/commonjs/components/UNCardComponent/UNCardComponent.utils.js.map +1 -1
- package/lib/commonjs/messages/webMessages/cardMessage.js +1 -0
- package/lib/commonjs/messages/webMessages/cardMessage.js.map +1 -1
- package/lib/commonjs/messages/webMessages/onLoadMessage.js +17 -0
- package/lib/commonjs/messages/webMessages/onLoadMessage.js.map +1 -0
- package/lib/commonjs/messages/webMessages/unitMessages.js.map +1 -1
- package/lib/commonjs/scripts/html/bodyScript.js +23 -1
- package/lib/commonjs/scripts/html/bodyScript.js.map +1 -1
- package/lib/commonjs/sharedTypes/account.types.js.map +1 -1
- package/lib/commonjs/sharedTypes/achCredit.types.js.map +1 -1
- package/lib/commonjs/sharedTypes/activity.types.js +6 -0
- package/lib/commonjs/sharedTypes/activity.types.js.map +1 -0
- package/lib/commonjs/sharedTypes/authorization.types.js +2 -0
- package/lib/commonjs/sharedTypes/authorization.types.js.map +1 -0
- package/lib/commonjs/sharedTypes/card.types.js +15 -0
- package/lib/commonjs/sharedTypes/card.types.js.map +1 -1
- package/lib/commonjs/sharedTypes/index.js.map +1 -1
- package/lib/commonjs/sharedTypes/onLoadResponse.types.js +0 -4
- package/lib/commonjs/sharedTypes/onLoadResponse.types.js.map +1 -1
- package/lib/commonjs/sharedTypes/transactions.types.js +52 -0
- package/lib/commonjs/sharedTypes/transactions.types.js.map +1 -0
- package/lib/commonjs/webComponent/WebComponent.js +2 -1
- package/lib/commonjs/webComponent/WebComponent.js.map +1 -1
- package/lib/commonjs/webComponent/html.js +6 -0
- package/lib/commonjs/webComponent/html.js.map +1 -1
- package/lib/module/components/UNACHCreditComponent/UNACHCreditComponent.js +24 -1
- package/lib/module/components/UNACHCreditComponent/UNACHCreditComponent.js.map +1 -1
- package/lib/module/components/UNACHDebitComponent/UNACHDebitComponent.js +24 -1
- package/lib/module/components/UNACHDebitComponent/UNACHDebitComponent.js.map +1 -1
- package/lib/module/components/UNAccountComponent/UNAccountComponent.js +27 -5
- package/lib/module/components/UNAccountComponent/UNAccountComponent.js.map +1 -1
- package/lib/module/components/UNAccountComponent/UNAccountComponent.utils.js +3 -0
- package/lib/module/components/UNAccountComponent/UNAccountComponent.utils.js.map +1 -1
- package/lib/module/components/UNActivityComponent/UNActivityComponent.js +24 -1
- package/lib/module/components/UNActivityComponent/UNActivityComponent.js.map +1 -1
- package/lib/module/components/UNActivityComponent/UNActivityComponent.utils.js +2 -0
- package/lib/module/components/UNActivityComponent/UNActivityComponent.utils.js.map +1 -1
- package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.js +18 -1
- package/lib/module/components/UNBookPaymentComponent/UNBookPaymentComponent.js.map +1 -1
- package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.js +3 -0
- package/lib/module/components/UNBottomSheetComponent/UNBottomSheetComponent.js.map +1 -1
- package/lib/module/components/UNCardComponent/UNCardComponent.js +39 -5
- package/lib/module/components/UNCardComponent/UNCardComponent.js.map +1 -1
- package/lib/module/components/UNCardComponent/UNCardComponent.utils.js +6 -0
- package/lib/module/components/UNCardComponent/UNCardComponent.utils.js.map +1 -1
- package/lib/module/messages/webMessages/cardMessage.js +1 -0
- package/lib/module/messages/webMessages/cardMessage.js.map +1 -1
- package/lib/module/messages/webMessages/onLoadMessage.js +10 -0
- package/lib/module/messages/webMessages/onLoadMessage.js.map +1 -0
- package/lib/module/messages/webMessages/unitMessages.js.map +1 -1
- package/lib/module/scripts/html/bodyScript.js +20 -0
- package/lib/module/scripts/html/bodyScript.js.map +1 -1
- package/lib/module/sharedTypes/account.types.js.map +1 -1
- package/lib/module/sharedTypes/achCredit.types.js.map +1 -1
- package/lib/module/sharedTypes/activity.types.js +2 -0
- package/lib/module/sharedTypes/activity.types.js.map +1 -0
- package/lib/module/sharedTypes/authorization.types.js +2 -0
- package/lib/module/sharedTypes/authorization.types.js.map +1 -0
- package/lib/module/sharedTypes/card.types.js +13 -1
- package/lib/module/sharedTypes/card.types.js.map +1 -1
- package/lib/module/sharedTypes/index.js +1 -1
- package/lib/module/sharedTypes/index.js.map +1 -1
- package/lib/module/sharedTypes/onLoadResponse.types.js +1 -1
- package/lib/module/sharedTypes/onLoadResponse.types.js.map +1 -1
- package/lib/module/sharedTypes/transactions.types.js +44 -0
- package/lib/module/sharedTypes/transactions.types.js.map +1 -0
- package/lib/module/webComponent/WebComponent.js +2 -1
- package/lib/module/webComponent/WebComponent.js.map +1 -1
- package/lib/module/webComponent/html.js +7 -1
- package/lib/module/webComponent/html.js.map +1 -1
- package/lib/typescript/components/UNACHCreditComponent/UNACHCreditComponent.d.ts +2 -2
- package/lib/typescript/components/UNACHDebitComponent/UNACHDebitComponent.d.ts +2 -2
- package/lib/typescript/components/UNAccountComponent/UNAccountComponent.d.ts +7 -3
- package/lib/typescript/components/UNAccountComponent/UNAccountComponent.utils.d.ts +1 -0
- package/lib/typescript/components/UNActivityComponent/UNActivityComponent.d.ts +4 -2
- package/lib/typescript/components/UNBookPaymentComponent/UNBookPaymentComponent.d.ts +2 -2
- package/lib/typescript/components/UNCardComponent/UNCardComponent.d.ts +9 -3
- package/lib/typescript/components/UNCardComponent/UNCardComponent.utils.d.ts +3 -0
- package/lib/typescript/messages/webMessages/cardMessage.d.ts +5 -1
- package/lib/typescript/messages/webMessages/onLoadMessage.d.ts +30 -0
- package/lib/typescript/messages/webMessages/unitMessages.d.ts +2 -2
- package/lib/typescript/scripts/html/bodyScript.d.ts +3 -0
- package/lib/typescript/sharedTypes/account.types.d.ts +13 -4
- package/lib/typescript/sharedTypes/achCredit.types.d.ts +6 -0
- package/lib/typescript/sharedTypes/activity.types.d.ts +7 -0
- package/lib/typescript/sharedTypes/authorization.types.d.ts +20 -0
- package/lib/typescript/sharedTypes/card.types.d.ts +12 -0
- package/lib/typescript/sharedTypes/index.d.ts +1 -1
- package/lib/typescript/sharedTypes/onLoadResponse.types.d.ts +12 -16
- package/lib/typescript/sharedTypes/transactions.types.d.ts +80 -0
- package/package.json +1 -1
- package/src/components/UNACHCreditComponent/UNACHCreditComponent.tsx +30 -3
- package/src/components/UNACHDebitComponent/UNACHDebitComponent.tsx +30 -3
- package/src/components/UNAccountComponent/UNAccountComponent.tsx +40 -9
- package/src/components/UNAccountComponent/UNAccountComponent.utils.ts +4 -0
- package/src/components/UNActivityComponent/UNActivityComponent.tsx +32 -3
- package/src/components/UNActivityComponent/UNActivityComponent.utils.ts +2 -0
- package/src/components/UNBookPaymentComponent/UNBookPaymentComponent.tsx +23 -3
- package/src/components/UNBottomSheetComponent/UNBottomSheetComponent.tsx +4 -1
- package/src/components/UNCardComponent/UNCardComponent.tsx +49 -7
- package/src/components/UNCardComponent/UNCardComponent.utils.ts +9 -0
- package/src/messages/webMessages/cardMessage.ts +6 -0
- package/src/messages/webMessages/onLoadMessage.ts +45 -0
- package/src/messages/webMessages/unitMessages.ts +2 -2
- package/src/scripts/html/bodyScript.ts +22 -0
- package/src/sharedTypes/account.types.ts +25 -17
- package/src/sharedTypes/achCredit.types.ts +7 -0
- package/src/sharedTypes/activity.types.ts +8 -0
- package/src/sharedTypes/authorization.types.ts +22 -0
- package/src/sharedTypes/card.types.ts +13 -0
- package/src/sharedTypes/index.ts +1 -1
- package/src/sharedTypes/onLoadResponse.types.ts +15 -23
- package/src/sharedTypes/transactions.types.ts +84 -0
- package/src/webComponent/WebComponent.tsx +3 -1
- package/src/webComponent/html.ts +7 -1
- package/android/src/main/res/values/themes.xml +0 -16
- package/android/src/main/res/values-night/themes.xml +0 -16
|
@@ -7,7 +7,7 @@ import BottomSheet from '../../helpers/BottomSheet/BottomSheet';
|
|
|
7
7
|
import EventBus from '../../helpers/EventBus';
|
|
8
8
|
import { HeightEvent, PageMessage } from '../../messages/webMessages/pageMessage';
|
|
9
9
|
import { RequestOpenLinkEvent, RequestRenderingEvent, UnitMessage } from '../../messages/webMessages/unitMessages';
|
|
10
|
-
import { CardMessage, CardStatusChangedEvent } from '../../messages/webMessages/cardMessage';
|
|
10
|
+
import { CardMessage, CardActivatedEvent, CardStatusChangedEvent } from '../../messages/webMessages/cardMessage';
|
|
11
11
|
import { useListenerToBus } from '../../hooks/listenerToBus';
|
|
12
12
|
import type { WebViewMessage } from '../../messages/webMessages';
|
|
13
13
|
import {
|
|
@@ -174,6 +174,9 @@ export const UNBottomSheetComponent = () => {
|
|
|
174
174
|
}
|
|
175
175
|
break;
|
|
176
176
|
}
|
|
177
|
+
case CardMessage.CARD_ACTIVATED:
|
|
178
|
+
EventBus.Instance.event(CardMessage.CARD_ACTIVATED, (message.details as CardActivatedEvent).card);
|
|
179
|
+
break;
|
|
177
180
|
case CardMessage.CARD_STATUS_CHANGED:
|
|
178
181
|
EventBus.Instance.event(CardMessage.CARD_STATUS_CHANGED, (message.details as CardStatusChangedEvent).card);
|
|
179
182
|
break;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useRef, useState } from 'react';
|
|
1
|
+
import React, { useImperativeHandle, useRef, useState } from 'react';
|
|
2
2
|
import { Dimensions, NativeModule, View } from 'react-native';
|
|
3
3
|
import type WebView from 'react-native-webview';
|
|
4
4
|
import { HeightEvent, PageMessage } from '../../messages/webMessages/pageMessage';
|
|
@@ -7,15 +7,16 @@ import EventBus from '../../helpers/EventBus';
|
|
|
7
7
|
import { WebComponent, WebComponentType } from '../../webComponent/WebComponent';
|
|
8
8
|
import { useListenerToBus } from '../../hooks/listenerToBus';
|
|
9
9
|
import type { WebViewMessage } from '../../messages/webMessages';
|
|
10
|
-
import { getCardParams, getCardScript, injectRefreshEventIfNeeded, launchStartCardProvisioning } from './UNCardComponent.utils';
|
|
10
|
+
import { getCardParams, getCardScript, injectRefreshEventIfNeeded, launchStartCardProvisioning, injectOpenActionsMenuScript, injectRequestCardActionScript } from './UNCardComponent.utils';
|
|
11
11
|
import { PresentationMode } from '../../scripts/html/bodyHtml';
|
|
12
|
-
import type {
|
|
12
|
+
import type { UNOnLoadResponse, UNCardData, UNError, UNCardMenuAction } from '../../sharedTypes';
|
|
13
13
|
import { CardMessage } from '../../messages/webMessages/cardMessage';
|
|
14
14
|
import { launchGetWallets } from './UNCardComponent.utils';
|
|
15
15
|
import type { NativeModules } from 'react-native';
|
|
16
16
|
import type { UNWallet } from 'src/sharedTypes/wallet.types';
|
|
17
17
|
import { CardAddToWalletErrors, UNCardAddToWalletStatusEvent, CardGetAddToWalletStatusEvent, CardNativeMessage, CardStartPushProvisioningEvent } from '../../messages/nativeMessages/cardMessage';
|
|
18
18
|
import type { BottomSheetSlotData } from '../UNBottomSheetComponent/UNBottomSheetComponent';
|
|
19
|
+
import { RESPONSE_KEYS, UnitOnLoadResponseEvent } from '../../messages/webMessages/onLoadMessage';
|
|
19
20
|
export interface UNCardComponentProps {
|
|
20
21
|
// inputs
|
|
21
22
|
cardId: string;
|
|
@@ -26,12 +27,17 @@ export interface UNCardComponentProps {
|
|
|
26
27
|
hideSensitiveDataButton?: boolean;
|
|
27
28
|
|
|
28
29
|
// events
|
|
29
|
-
onLoad?: (response:
|
|
30
|
+
onLoad?: (response: UNOnLoadResponse<UNCardData>) => void
|
|
30
31
|
onStatusChanged?: (card: UNCardData) => void;
|
|
32
|
+
onCardActivated?: (card: UNCardData) => void;
|
|
31
33
|
pushProvisioningModule?: typeof NativeModules;
|
|
32
34
|
}
|
|
35
|
+
export interface CardRef {
|
|
36
|
+
openActionsMenu: () => void;
|
|
37
|
+
openAction:(action: UNCardMenuAction) => void;
|
|
38
|
+
}
|
|
33
39
|
|
|
34
|
-
export const UNCardComponent = (props
|
|
40
|
+
export const UNCardComponent = React.forwardRef<CardRef, UNCardComponentProps>(function UNCardComponent (props, cardRef) {
|
|
35
41
|
const [height, setHeight] = useState(0);
|
|
36
42
|
const windowWidth = Dimensions.get('window').width;
|
|
37
43
|
|
|
@@ -41,12 +47,27 @@ export const UNCardComponent = (props: UNCardComponentProps) => {
|
|
|
41
47
|
|
|
42
48
|
const webRef = useRef<WebView>(null);
|
|
43
49
|
|
|
50
|
+
useImperativeHandle(cardRef, () => ({
|
|
51
|
+
openActionsMenu() {
|
|
52
|
+
injectOpenActionsMenuScript(webRef.current);
|
|
53
|
+
},
|
|
54
|
+
openAction(action: UNCardMenuAction) {
|
|
55
|
+
injectRequestCardActionScript(webRef.current, action);
|
|
56
|
+
}
|
|
57
|
+
}));
|
|
58
|
+
|
|
44
59
|
const cardStatusChanged = (card: UNCardData) => {
|
|
45
60
|
if (props.onStatusChanged) {
|
|
46
61
|
props.onStatusChanged(card);
|
|
47
62
|
}
|
|
48
63
|
};
|
|
49
64
|
|
|
65
|
+
const cardActivated = (card: UNCardData) => {
|
|
66
|
+
if (props.onCardActivated) {
|
|
67
|
+
props.onCardActivated(card);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
50
71
|
const requestRefresh = (data: RequestRefreshEvent) => {
|
|
51
72
|
injectRefreshEventIfNeeded(webRef.current, data, props.cardId);
|
|
52
73
|
};
|
|
@@ -61,8 +82,29 @@ export const UNCardComponent = (props: UNCardComponentProps) => {
|
|
|
61
82
|
getWallets();
|
|
62
83
|
};
|
|
63
84
|
|
|
85
|
+
const handleUnitOnLoad = (response: UnitOnLoadResponseEvent) => {
|
|
86
|
+
if (!props.onLoad) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (RESPONSE_KEYS.errors in response) {
|
|
91
|
+
props.onLoad(response as UNError);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (RESPONSE_KEYS.card in response) {
|
|
96
|
+
// CardOnLoadResponse
|
|
97
|
+
props.onLoad(response[RESPONSE_KEYS.card] as UNOnLoadResponse<UNCardData>);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
console.error('On Load Error: unexpected response type');
|
|
102
|
+
return;
|
|
103
|
+
};
|
|
104
|
+
|
|
64
105
|
useListenerToBus({ busEventKey: UnitMessage.UNIT_REQUEST_REFRESH, action: requestRefresh });
|
|
65
106
|
useListenerToBus({ busEventKey: CardMessage.CARD_STATUS_CHANGED, action: cardStatusChanged });
|
|
107
|
+
useListenerToBus({ busEventKey: CardMessage.CARD_ACTIVATED, action: cardActivated });
|
|
66
108
|
useListenerToBus({ busEventKey: CardNativeMessage.CARD_START_PUSH_PROVISIONING, action: startPushProvisioning });
|
|
67
109
|
useListenerToBus({ busEventKey: CardNativeMessage.CARD_GET_ADD_TO_WALLET_STATUS, action: getAddToWalletStatus });
|
|
68
110
|
|
|
@@ -83,7 +125,7 @@ export const UNCardComponent = (props: UNCardComponentProps) => {
|
|
|
83
125
|
setHeight((message.details as HeightEvent).height);
|
|
84
126
|
break;
|
|
85
127
|
case UnitMessage.UNIT_ON_LOAD:
|
|
86
|
-
|
|
128
|
+
handleUnitOnLoad(message.details as UnitOnLoadResponseEvent);
|
|
87
129
|
break;
|
|
88
130
|
}
|
|
89
131
|
};
|
|
@@ -132,4 +174,4 @@ export const UNCardComponent = (props: UNCardComponentProps) => {
|
|
|
132
174
|
/>
|
|
133
175
|
</View>
|
|
134
176
|
);
|
|
135
|
-
};
|
|
177
|
+
});
|
|
@@ -7,6 +7,7 @@ import { getMobileWalletPayload } from './networking/requests/UNWalletPayloadReq
|
|
|
7
7
|
import { UNWallet, UNWalletCode, UNWalletName } from '../../../src/sharedTypes/wallet.types';
|
|
8
8
|
import type { RequestRefreshEvent } from '../../messages/webMessages/unitMessages';
|
|
9
9
|
import { UnitSDK } from '../../unitSdkManager/UnitSdkManager';
|
|
10
|
+
import type { UNCardMenuAction } from '../../sharedTypes';
|
|
10
11
|
|
|
11
12
|
export const getCardParams = (props: UNCardComponentProps) => {
|
|
12
13
|
return `
|
|
@@ -23,6 +24,14 @@ export const getCardScript = () => {
|
|
|
23
24
|
return DISPATCH_REQUEST_REFRESH;
|
|
24
25
|
};
|
|
25
26
|
|
|
27
|
+
export const injectOpenActionsMenuScript = (currentWeb: WebView | null) => {
|
|
28
|
+
currentWeb?.injectJavaScript(`dispatchOpenActionsMenu('${WebComponentType.card}')`);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const injectRequestCardActionScript = (currentWeb: WebView | null, action: UNCardMenuAction) => {
|
|
32
|
+
currentWeb?.injectJavaScript(`dispatchRequestCardAction('${action}')`);
|
|
33
|
+
};
|
|
34
|
+
|
|
26
35
|
export const injectRefreshEventIfNeeded = (currentWeb: WebView | null, requestRefreshEvent: RequestRefreshEvent | null, cardId: string) => {
|
|
27
36
|
if (requestRefreshEvent && requestRefreshEvent.dependencies.includes(WebComponentType.card.valueOf()) && requestRefreshEvent.resourceId == cardId) {
|
|
28
37
|
currentWeb?.injectJavaScript(`dispatchRefreshEvent('${JSON.stringify(requestRefreshEvent)}')`);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { UNCardData } from '../../sharedTypes';
|
|
2
2
|
|
|
3
3
|
export enum CardMessage {
|
|
4
|
+
CARD_ACTIVATED = 'unitCardActivated',
|
|
4
5
|
CARD_STATUS_CHANGED = 'unitCardStatusChanged'
|
|
5
6
|
}
|
|
6
7
|
|
|
@@ -8,5 +9,10 @@ export interface CardStatusChangedEvent {
|
|
|
8
9
|
card: UNCardData;
|
|
9
10
|
}
|
|
10
11
|
|
|
12
|
+
export interface CardActivatedEvent {
|
|
13
|
+
card: UNCardData;
|
|
14
|
+
}
|
|
15
|
+
|
|
11
16
|
export type CardEvent =
|
|
12
17
|
| CardStatusChangedEvent
|
|
18
|
+
| CardActivatedEvent
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type {UNAccountData, UNCounterpartyAccountData, UNCardData, UNError, UNOnLoadResponseData } from '../../sharedTypes';
|
|
2
|
+
import type { UNAuthorizationData } from '../../sharedTypes/authorization.types';
|
|
3
|
+
import type { UNTransactionData } from '../../sharedTypes/transactions.types';
|
|
4
|
+
|
|
5
|
+
export enum RESPONSE_KEYS {
|
|
6
|
+
errors = 'errors',
|
|
7
|
+
card = 'cardResult',
|
|
8
|
+
account = 'accountResult',
|
|
9
|
+
counterpartyAccount = 'counterpartyResult',
|
|
10
|
+
transactions = 'transactionsResult',
|
|
11
|
+
authorization = 'authorizationResult'
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type CardOnLoadResponse = {
|
|
15
|
+
[RESPONSE_KEYS.card]: UNOnLoadResponseData<UNCardData>
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export type AccountOnLoadResponse = {
|
|
19
|
+
[RESPONSE_KEYS.account]: UNOnLoadResponseData<UNAccountData>
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type AccountsOnLoadResponse = {
|
|
23
|
+
[RESPONSE_KEYS.account]: UNOnLoadResponseData<[UNAccountData]>
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export type ACHOnLoadResponse = {
|
|
27
|
+
[RESPONSE_KEYS.account]: UNOnLoadResponseData<UNAccountData>,
|
|
28
|
+
[RESPONSE_KEYS.counterpartyAccount]: UNOnLoadResponseData<[UNCounterpartyAccountData]>
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export type ActivityOnLoadResponse = {
|
|
32
|
+
[RESPONSE_KEYS.authorization]: UNOnLoadResponseData<UNAuthorizationData>,
|
|
33
|
+
[RESPONSE_KEYS.transactions]: UNOnLoadResponseData<UNTransactionData>
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export type UnitOnLoadResponseSuccessData =
|
|
37
|
+
| CardOnLoadResponse
|
|
38
|
+
| ACHOnLoadResponse
|
|
39
|
+
| AccountsOnLoadResponse
|
|
40
|
+
| AccountOnLoadResponse
|
|
41
|
+
| ActivityOnLoadResponse
|
|
42
|
+
|
|
43
|
+
export type UnitOnLoadResponseEvent =
|
|
44
|
+
| UNError
|
|
45
|
+
| UnitOnLoadResponseSuccessData
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { UnitOnLoadResponseEvent } from './onLoadMessage';
|
|
2
2
|
|
|
3
3
|
export enum UnitMessage {
|
|
4
4
|
UNIT_REQUEST_RENDERING = 'unitRequestRendering',
|
|
@@ -63,7 +63,7 @@ export type UnitEvent =
|
|
|
63
63
|
| RequestRenderingEvent
|
|
64
64
|
| RequestRefreshEvent
|
|
65
65
|
| RequestOpenLinkEvent
|
|
66
|
-
|
|
|
66
|
+
| UnitOnLoadResponseEvent
|
|
67
67
|
| RequestDownloadEvent
|
|
68
68
|
| PlaidTokenCreatedEvent
|
|
69
69
|
| RequestExternalSdkEvent
|
|
@@ -59,6 +59,16 @@ export const LISTENERS = {
|
|
|
59
59
|
postMessageToSDK({ type: "${UnitMessage.UNIT_REQUEST_DOWNLOAD}", details: e.detail })
|
|
60
60
|
});
|
|
61
61
|
`,
|
|
62
|
+
cardActivated: `
|
|
63
|
+
window.addEventListener("${CardMessage.CARD_ACTIVATED}", (e) => {
|
|
64
|
+
const response = e.detail
|
|
65
|
+
response.then((data) => {
|
|
66
|
+
postMessageToSDK({ type: "${CardMessage.CARD_ACTIVATED}", details: { card: data.data }})
|
|
67
|
+
}).catch((e) => {
|
|
68
|
+
console.log(e)
|
|
69
|
+
})
|
|
70
|
+
});
|
|
71
|
+
`,
|
|
62
72
|
cardStatusChange: `
|
|
63
73
|
window.addEventListener("${CardMessage.CARD_STATUS_CHANGED}", (e) => {
|
|
64
74
|
const response = e.detail
|
|
@@ -116,3 +126,15 @@ export const DISPATCH_PLAID_RESPONSE = `
|
|
|
116
126
|
window.dispatchEvent(event)
|
|
117
127
|
}
|
|
118
128
|
`;
|
|
129
|
+
|
|
130
|
+
export const DISPATCH_OPEN_ACTIONS_MENU = `
|
|
131
|
+
const dispatchOpenActionsMenu = (componentName) => {
|
|
132
|
+
document.querySelector(componentName).dispatchEvent(new CustomEvent("unitRequestOpenActionsMenu"))
|
|
133
|
+
}
|
|
134
|
+
`;
|
|
135
|
+
|
|
136
|
+
export const DISPATCH_REQUEST_CARD_ACTION = `
|
|
137
|
+
const dispatchRequestCardAction = (action) => {
|
|
138
|
+
document.querySelector("unit-elements-card").dispatchEvent(new CustomEvent("unitRequestCardAction", {detail: {action: action}}))
|
|
139
|
+
}
|
|
140
|
+
`;
|
|
@@ -2,31 +2,39 @@ import type { UNRelationship, UNTags } from './types';
|
|
|
2
2
|
|
|
3
3
|
export type UNAccountData = UNDepositAccount | UNBatchAccount | UNCreditAccount
|
|
4
4
|
|
|
5
|
+
export type UNCounterpartyAccountData = {
|
|
6
|
+
id: string
|
|
7
|
+
attributes: {
|
|
8
|
+
name: string
|
|
9
|
+
tags?: {[key: string]: string}
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
5
13
|
enum UNAccountStatus {
|
|
6
|
-
Open =
|
|
7
|
-
Closed =
|
|
8
|
-
Frozen =
|
|
14
|
+
Open = 'Open',
|
|
15
|
+
Closed = 'Closed',
|
|
16
|
+
Frozen = 'Frozen',
|
|
9
17
|
}
|
|
10
18
|
|
|
11
19
|
export enum UNCloseReason {
|
|
12
|
-
Fraud =
|
|
13
|
-
ByCustomer =
|
|
20
|
+
Fraud = 'Fraud',
|
|
21
|
+
ByCustomer = 'ByCustomer',
|
|
14
22
|
}
|
|
15
23
|
|
|
16
24
|
export enum UNFraudReason {
|
|
17
|
-
ACHActivity =
|
|
18
|
-
CardActivity =
|
|
19
|
-
CheckActivity =
|
|
20
|
-
ApplicationHistory =
|
|
21
|
-
AccountActivity =
|
|
22
|
-
ClientIdentified =
|
|
23
|
-
IdentityTheft =
|
|
24
|
-
LinkedToFraudulentCustomer =
|
|
25
|
+
ACHActivity = 'ACHActivity',
|
|
26
|
+
CardActivity = 'CardActivity',
|
|
27
|
+
CheckActivity = 'CheckActivity',
|
|
28
|
+
ApplicationHistory = 'ApplicationHistory',
|
|
29
|
+
AccountActivity = 'AccountActivity',
|
|
30
|
+
ClientIdentified = 'ClientIdentified',
|
|
31
|
+
IdentityTheft = 'IdentityTheft',
|
|
32
|
+
LinkedToFraudulentCustomer = 'LinkedToFraudulentCustomer',
|
|
25
33
|
}
|
|
26
34
|
|
|
27
35
|
export type UNDepositAccount = {
|
|
28
36
|
id: string
|
|
29
|
-
type:
|
|
37
|
+
type: 'depositAccount'
|
|
30
38
|
attributes: {
|
|
31
39
|
createdAt: string
|
|
32
40
|
updatedAt?: string
|
|
@@ -63,7 +71,7 @@ export type UNDepositAccount = {
|
|
|
63
71
|
|
|
64
72
|
export type UNBatchAccount = {
|
|
65
73
|
id: string
|
|
66
|
-
type:
|
|
74
|
+
type: 'batchAccount'
|
|
67
75
|
attributes: {
|
|
68
76
|
createdAt: Date
|
|
69
77
|
updatedAt?: Date
|
|
@@ -77,7 +85,7 @@ export type UNBatchAccount = {
|
|
|
77
85
|
reserve: number
|
|
78
86
|
available: number
|
|
79
87
|
currency: string
|
|
80
|
-
status:
|
|
88
|
+
status: 'Open' | 'Closed'
|
|
81
89
|
closeReason?: string
|
|
82
90
|
fraudReason?: UNFraudReason
|
|
83
91
|
closeReasonText?: string
|
|
@@ -91,7 +99,7 @@ export type UNBatchAccount = {
|
|
|
91
99
|
|
|
92
100
|
export type UNCreditAccount = {
|
|
93
101
|
id: string
|
|
94
|
-
type:
|
|
102
|
+
type: 'creditAccount'
|
|
95
103
|
attributes: {
|
|
96
104
|
createdAt: Date
|
|
97
105
|
updatedAt?: Date
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
+
import type { RESPONSE_KEYS } from '../messages/webMessages/onLoadMessage';
|
|
2
|
+
import type { UNAccountData, UNCounterpartyAccountData } from './account.types';
|
|
1
3
|
import type { UNAchCounterparty, UNCounterpartyVerificationMethod, UNPaymentStatus } from './payments.types';
|
|
2
4
|
import type { UNTags, UNRelationship } from './types';
|
|
3
5
|
|
|
6
|
+
export type UNACHOnLoadData = {
|
|
7
|
+
[RESPONSE_KEYS.account]: UNAccountData,
|
|
8
|
+
[RESPONSE_KEYS.counterpartyAccount]: [UNCounterpartyAccountData]
|
|
9
|
+
}
|
|
10
|
+
|
|
4
11
|
export type UNACHData = {
|
|
5
12
|
type: 'achPayment',
|
|
6
13
|
id: string,
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { RESPONSE_KEYS } from '../messages/webMessages/onLoadMessage';
|
|
2
|
+
import type { UNAuthorizationData } from './authorization.types';
|
|
3
|
+
import type { UNTransactionData } from './transactions.types';
|
|
4
|
+
|
|
5
|
+
export type UNActivityOnLoadData = {
|
|
6
|
+
[RESPONSE_KEYS.authorization]: UNAuthorizationData,
|
|
7
|
+
[RESPONSE_KEYS.transactions]: UNTransactionData,
|
|
8
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type UNAuthorizationData = {
|
|
2
|
+
type: string,
|
|
3
|
+
id: string,
|
|
4
|
+
attributes: UNAuthorizationDetails
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export type UNAuthorizationDetails = {
|
|
8
|
+
cardNetwork: string,
|
|
9
|
+
createdAt: Date,
|
|
10
|
+
amount: string,
|
|
11
|
+
merchant?: UNAuthorizationMerchant,
|
|
12
|
+
cardLast4Digits: string,
|
|
13
|
+
recurring : boolean,
|
|
14
|
+
summary: string,
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type UNAuthorizationMerchant = {
|
|
18
|
+
name: string,
|
|
19
|
+
type: string,
|
|
20
|
+
category: string,
|
|
21
|
+
location?: string,
|
|
22
|
+
}
|
|
@@ -57,3 +57,16 @@ export type UNBusinessDebitCard = {
|
|
|
57
57
|
customer: UNRelationship
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
|
+
|
|
61
|
+
export enum UNCardMenuAction {
|
|
62
|
+
Freeze = 'Freeze',
|
|
63
|
+
ManagePin = 'ManagePin',
|
|
64
|
+
Replace = 'Replace',
|
|
65
|
+
Report = 'Report',
|
|
66
|
+
Close = 'Close',
|
|
67
|
+
Activate = 'Activate',
|
|
68
|
+
Unfreeze = 'Unfreeze',
|
|
69
|
+
ChangePin = 'ChangePin',
|
|
70
|
+
SetPin = 'SetPin',
|
|
71
|
+
AddToWallet = 'AddToWallet'
|
|
72
|
+
}
|
package/src/sharedTypes/index.ts
CHANGED
|
@@ -1,27 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export type UNOnLoadResponseData<T> = {
|
|
2
|
+
data: T,
|
|
3
|
+
}
|
|
3
4
|
|
|
4
|
-
export type
|
|
5
|
-
|
|
6
|
-
Object since the current response data types from 'Activities' and 'BookPayment' do not have documentation.
|
|
7
|
-
When things are determined, we may update it
|
|
8
|
-
*/
|
|
9
|
-
data: UNCardData | Object,
|
|
10
|
-
included: [Object],
|
|
11
|
-
errors: null
|
|
5
|
+
export type UNError = {
|
|
6
|
+
errors: UNErrorData[]
|
|
12
7
|
}
|
|
13
8
|
|
|
14
|
-
export type
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
details?: string,
|
|
21
|
-
meta?: Record<string, string>
|
|
22
|
-
}
|
|
23
|
-
]
|
|
9
|
+
export type UNErrorData = {
|
|
10
|
+
status: string,
|
|
11
|
+
title: string,
|
|
12
|
+
detail?: string,
|
|
13
|
+
details?: string,
|
|
14
|
+
meta?: Record<string, string>
|
|
24
15
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
|
16
|
+
|
|
17
|
+
export type UNOnLoadResponse<T> =
|
|
18
|
+
| UNOnLoadResponseData<T>
|
|
19
|
+
| UNError
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
export type UNTransactionData = {
|
|
2
|
+
type: UNTransactionType,
|
|
3
|
+
id: string,
|
|
4
|
+
attributes: UNATransactionAttributes,
|
|
5
|
+
relationships: UNTransactionRelationships
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export type UNATransactionAttributes = {
|
|
9
|
+
createdAt: Date,
|
|
10
|
+
amount: string,
|
|
11
|
+
direction?: UNDirection,
|
|
12
|
+
balance?: string,
|
|
13
|
+
summary?: string,
|
|
14
|
+
companyName?: string,
|
|
15
|
+
counterpartyName?: string,
|
|
16
|
+
counterpartyRoutingNumber?: string,
|
|
17
|
+
reason?: string,
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type UNTransactionRelationships = {
|
|
21
|
+
customer?: {
|
|
22
|
+
data: {
|
|
23
|
+
type: string
|
|
24
|
+
id: number
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
customers?: {
|
|
28
|
+
data: [
|
|
29
|
+
{
|
|
30
|
+
type: 'customer'
|
|
31
|
+
id: string
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
org?: {
|
|
36
|
+
data: {
|
|
37
|
+
type: string
|
|
38
|
+
id: number
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export enum UNDirection {
|
|
44
|
+
Debit = 'Debit',
|
|
45
|
+
Credit = 'Credit',
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export enum UNTransactionType {
|
|
49
|
+
ATM = 'atmTransaction',
|
|
50
|
+
Adjustment = 'adjustmentTransaction',
|
|
51
|
+
BillPay = 'billPayTransaction',
|
|
52
|
+
Book = 'bookTransaction',
|
|
53
|
+
Card = 'cardTransaction',
|
|
54
|
+
CardReversal = 'cardReverTransactionTypessalTransaction',
|
|
55
|
+
Chargeback = 'chargebackTransaction',
|
|
56
|
+
CheckDeposit = 'checkDepositTransaction',
|
|
57
|
+
DishonoredACH = 'dishonoredAchTransaction',
|
|
58
|
+
Dispute = 'disputeTransaction',
|
|
59
|
+
DisputeSettlement = 'disputeSettlementTransaction',
|
|
60
|
+
Fee = 'feeTransaction',
|
|
61
|
+
InterchangeShare = 'interchangeShareTransaction',
|
|
62
|
+
Interest = 'interestTransaction',
|
|
63
|
+
InterestShare = 'interestShareTransaction',
|
|
64
|
+
NegativeBalanceCoverage = 'negativeBalanceCoverageTransaction',
|
|
65
|
+
OriginatedACH = 'originatedAchTransaction',
|
|
66
|
+
PaymentAdvance = 'paymentAdvanceTransaction',
|
|
67
|
+
PaymentCanceled = 'paymentCanceledTransaction',
|
|
68
|
+
Purchase = 'purchaseTransaction',
|
|
69
|
+
ReceivedACH = 'receivedAchTransaction',
|
|
70
|
+
Release = 'releaseTransaction',
|
|
71
|
+
RepaidPaymentAdvance = 'repaidPaymentAdvanceTransaction',
|
|
72
|
+
ReturnedACH = 'returnedAchTransaction',
|
|
73
|
+
ReturnedCheckDeposit = 'returnedCheckDepositTransaction',
|
|
74
|
+
ReturnedReceivedACH = 'returnedReceivedAchTransaction',
|
|
75
|
+
Reward = 'rewardTransaction',
|
|
76
|
+
Settlement = 'settlementTransaction',
|
|
77
|
+
SponsoredInterest = 'sponsoredInterestTransaction',
|
|
78
|
+
Wire = 'wireTransaction',
|
|
79
|
+
AccountLowBalanceClosure = 'accountLowBalanceClosureTransaction',
|
|
80
|
+
CashDeposit = 'cashDepositTransaction',
|
|
81
|
+
BankRepayment = 'bankRepaymentTransaction',
|
|
82
|
+
CustomerRepayment = 'CustomerRepaymentTransaction',
|
|
83
|
+
CustomerRepaymentReturned = 'CustomerRepaymentReturnedTransaction',
|
|
84
|
+
}
|
|
@@ -103,6 +103,8 @@ export const WebComponent = React.forwardRef<WebView, WebComponentProps>(functio
|
|
|
103
103
|
injectedJavaScript={unitScript}
|
|
104
104
|
style={{ width: width, flex: 1, opacity: 0.99}}
|
|
105
105
|
source={{ html: sourceHtml }}
|
|
106
|
-
onMessage={onMessage}
|
|
106
|
+
onMessage={onMessage}
|
|
107
|
+
androidHardwareAccelerationDisabled
|
|
108
|
+
/>
|
|
107
109
|
);
|
|
108
110
|
});
|
package/src/webComponent/html.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Platform } from 'react-native';
|
|
2
|
-
import { DISPATCH_RENDERING_EVENT, LISTENERS, POST_MESSAGE_TO_SDK, POST_PAGE_HEIGHT } from '../scripts/html/bodyScript';
|
|
2
|
+
import { DISPATCH_RENDERING_EVENT, LISTENERS, POST_MESSAGE_TO_SDK, POST_PAGE_HEIGHT, DISPATCH_REQUEST_CARD_ACTION, DISPATCH_OPEN_ACTIONS_MENU } from '../scripts/html/bodyScript';
|
|
3
3
|
|
|
4
4
|
export const HTML_PLACEHOLDER = {
|
|
5
5
|
SCRIPT_UNIT: '<SCRIPT_UNIT>',
|
|
@@ -43,6 +43,8 @@ const htmlText = `
|
|
|
43
43
|
|
|
44
44
|
${LISTENERS.requestCloseFlow}
|
|
45
45
|
|
|
46
|
+
${LISTENERS.cardActivated}
|
|
47
|
+
|
|
46
48
|
${LISTENERS.cardStatusChange}
|
|
47
49
|
|
|
48
50
|
${LISTENERS.unitRequestExternalSdk}
|
|
@@ -51,6 +53,10 @@ const htmlText = `
|
|
|
51
53
|
|
|
52
54
|
${DISPATCH_RENDERING_EVENT}
|
|
53
55
|
|
|
56
|
+
${DISPATCH_OPEN_ACTIONS_MENU}
|
|
57
|
+
|
|
58
|
+
${DISPATCH_REQUEST_CARD_ACTION}
|
|
59
|
+
|
|
54
60
|
${HTML_PLACEHOLDER.SCRIPT_FROM_NATIVE}
|
|
55
61
|
</script>
|
|
56
62
|
</body>
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
<resources xmlns:tools="http://schemas.android.com/tools">
|
|
2
|
-
<!-- Base application theme. -->
|
|
3
|
-
<style name="Theme.UnitWalletDemo" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
|
4
|
-
<!-- Primary brand color. -->
|
|
5
|
-
<item name="colorPrimary">@color/purple_500</item>
|
|
6
|
-
<item name="colorPrimaryVariant">@color/purple_700</item>
|
|
7
|
-
<item name="colorOnPrimary">@color/white</item>
|
|
8
|
-
<!-- Secondary brand color. -->
|
|
9
|
-
<item name="colorSecondary">@color/teal_200</item>
|
|
10
|
-
<item name="colorSecondaryVariant">@color/teal_700</item>
|
|
11
|
-
<item name="colorOnSecondary">@color/black</item>
|
|
12
|
-
<!-- Status bar color. -->
|
|
13
|
-
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
|
|
14
|
-
<!-- Customize your theme here. -->
|
|
15
|
-
</style>
|
|
16
|
-
</resources>
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
<resources xmlns:tools="http://schemas.android.com/tools">
|
|
2
|
-
<!-- Base application theme. -->
|
|
3
|
-
<style name="Theme.UnitWalletDemo" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
|
4
|
-
<!-- Primary brand color. -->
|
|
5
|
-
<item name="colorPrimary">@color/purple_200</item>
|
|
6
|
-
<item name="colorPrimaryVariant">@color/purple_700</item>
|
|
7
|
-
<item name="colorOnPrimary">@color/black</item>
|
|
8
|
-
<!-- Secondary brand color. -->
|
|
9
|
-
<item name="colorSecondary">@color/teal_200</item>
|
|
10
|
-
<item name="colorSecondaryVariant">@color/teal_200</item>
|
|
11
|
-
<item name="colorOnSecondary">@color/black</item>
|
|
12
|
-
<!-- Status bar color. -->
|
|
13
|
-
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
|
|
14
|
-
<!-- Customize your theme here. -->
|
|
15
|
-
</style>
|
|
16
|
-
</resources>
|