zh-web-sdk 2.1.0 → 2.1.4
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 +9 -2
- package/dist/iframe-container/constants.d.ts +2 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -6
- package/dist/index.js.map +4 -4
- package/dist/redux/reducers/ach-deposits.d.ts +13 -0
- package/dist/redux/reducers/index.d.ts +1 -0
- package/dist/redux/store/index.d.ts +1 -0
- package/dist/styles.d.ts +1 -0
- package/dist/types.d.ts +19 -2
- package/package.json +1 -1
- package/src/iframe-container/AppContainer.tsx +23 -3
- package/src/iframe-container/constants.ts +7 -2
- package/src/index.tsx +15 -0
- package/src/redux/reducers/ach-deposits.ts +64 -0
- package/src/redux/reducers/index.ts +2 -0
- package/src/styles.ts +7 -3
- package/src/types.ts +19 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface IAchDepositsState {
|
|
2
|
+
jwt: string;
|
|
3
|
+
isAppLoaded: boolean;
|
|
4
|
+
isAppActive: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface IAchDepositsAction {
|
|
7
|
+
type: string;
|
|
8
|
+
jwt?: string;
|
|
9
|
+
isAppActive?: boolean;
|
|
10
|
+
isAppLoaded?: boolean;
|
|
11
|
+
}
|
|
12
|
+
declare const achDepositsReducer: (state: IAchDepositsState | undefined, action: IAchDepositsAction) => IAchDepositsState;
|
|
13
|
+
export default achDepositsReducer;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
declare const rootReducer: import("redux").Reducer<import("redux").CombinedState<{
|
|
2
2
|
"crypto-withdrawals": import("./crypto-withdrawals").ICryptoWithdrawalsState;
|
|
3
3
|
onboarding: import("./onboarding").IOnboardingState;
|
|
4
|
+
"ach-deposits": import("./ach-deposits").IAchDepositsState;
|
|
4
5
|
}>, import("./crypto-withdrawals").ICryptoWithdrawalsAction>;
|
|
5
6
|
export default rootReducer;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
declare const store: import("redux").Store<import("redux").EmptyObject & {
|
|
2
2
|
"crypto-withdrawals": import("../reducers/crypto-withdrawals").ICryptoWithdrawalsState;
|
|
3
3
|
onboarding: import("../reducers/onboarding").IOnboardingState;
|
|
4
|
+
"ach-deposits": import("../reducers/ach-deposits").IAchDepositsState;
|
|
4
5
|
}, import("../reducers/crypto-withdrawals").ICryptoWithdrawalsAction>;
|
|
5
6
|
export default store;
|
package/dist/styles.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export declare const containerMediaStyles: {
|
|
|
9
9
|
[id: string]: CSSProperties;
|
|
10
10
|
};
|
|
11
11
|
export declare const appWrapperStyle: CSSProperties;
|
|
12
|
+
export declare const height: CSSProperties;
|
|
12
13
|
export declare const appWrapperHiddenStyle: CSSProperties;
|
|
13
14
|
export declare const modalStyle: CSSProperties;
|
|
14
15
|
export declare const iframeWrapperStyle: CSSProperties;
|
package/dist/types.d.ts
CHANGED
|
@@ -42,6 +42,12 @@ export interface IInitializeParameters {
|
|
|
42
42
|
* perform crypto withdrawals.
|
|
43
43
|
*/
|
|
44
44
|
cryptoWithdrawalsJWT?: string;
|
|
45
|
+
/**
|
|
46
|
+
* achDepositsJWT is the JWT that you received from
|
|
47
|
+
* the ZeroHash HTTP API and have specific permissions to
|
|
48
|
+
* perform ACH Deposits.
|
|
49
|
+
*/
|
|
50
|
+
achDepositsJWT?: string;
|
|
45
51
|
/**
|
|
46
52
|
* zeroHashAppsURL is the base URL for all our Apps.
|
|
47
53
|
* It defaults to https://web-sdk.zerohash.com/ and will
|
|
@@ -94,7 +100,17 @@ export declare enum IncomingMessageType {
|
|
|
94
100
|
* CryptoWithdrawalsCloseButtonClicked is received when the close button
|
|
95
101
|
* has been clicked in the Crypto Withdrawals app
|
|
96
102
|
*/
|
|
97
|
-
CryptoWithdrawalsCloseButtonClicked = "CRYPTO_WITHDRAWALS_CLOSE_BUTTON_CLICKED"
|
|
103
|
+
CryptoWithdrawalsCloseButtonClicked = "CRYPTO_WITHDRAWALS_CLOSE_BUTTON_CLICKED",
|
|
104
|
+
/**
|
|
105
|
+
* AchDepositsAppLoaded is received when the crypto
|
|
106
|
+
* withdrawals app has initialized.
|
|
107
|
+
*/
|
|
108
|
+
AchDepositsAppLoaded = "ACH_DEPOSITS_APP_LOADED",
|
|
109
|
+
/**
|
|
110
|
+
* AchDepositsCloseButtonClicked is received when the close button
|
|
111
|
+
* has been clicked in the ACH Deposits app
|
|
112
|
+
*/
|
|
113
|
+
AchDepositsCloseButtonClicked = "ACH_DEPOSITS_CLOSE_BUTTON_CLICKED"
|
|
98
114
|
}
|
|
99
115
|
/**
|
|
100
116
|
* IncomingMessage defines the structure of an incoming
|
|
@@ -128,7 +144,8 @@ export interface IZeroHashSDK {
|
|
|
128
144
|
*/
|
|
129
145
|
export declare enum AppIdentifier {
|
|
130
146
|
ONBOARDING = "onboarding",
|
|
131
|
-
CRYPTO_WITHDRAWALS = "crypto-withdrawals"
|
|
147
|
+
CRYPTO_WITHDRAWALS = "crypto-withdrawals",
|
|
148
|
+
ACH_DEPOSITS = "ach-deposits"
|
|
132
149
|
}
|
|
133
150
|
/**
|
|
134
151
|
* Map that maps the app AppIdentifier to the redux action prefix
|
package/package.json
CHANGED
|
@@ -11,9 +11,11 @@ import {
|
|
|
11
11
|
modalStyle,
|
|
12
12
|
screenSizes,
|
|
13
13
|
appWrapperHiddenStyle,
|
|
14
|
+
height
|
|
14
15
|
} from "../styles";
|
|
15
16
|
import {
|
|
16
|
-
|
|
17
|
+
MESSAGE_TYPE_SEND_JWT_TOKEN_ACH_DEPOSITS,
|
|
18
|
+
MESSAGE_TYPE_SEND_JWT_TOKEN_ONBOARDING,
|
|
17
19
|
MESSAGE_TYPE_SEND_JWT_TOKEN_WITHDRAWALS,
|
|
18
20
|
} from "./constants";
|
|
19
21
|
import { closeModal } from "../redux/actions";
|
|
@@ -38,6 +40,11 @@ interface AppContainerMappedProps {
|
|
|
38
40
|
isAppLoaded: boolean;
|
|
39
41
|
jwt: string;
|
|
40
42
|
};
|
|
43
|
+
[AppIdentifier.ACH_DEPOSITS]: {
|
|
44
|
+
isAppActive: boolean;
|
|
45
|
+
isAppLoaded: boolean;
|
|
46
|
+
jwt: string;
|
|
47
|
+
};
|
|
41
48
|
}
|
|
42
49
|
|
|
43
50
|
const appLoadTime = Date.now();
|
|
@@ -45,6 +52,7 @@ const appLoadTime = Date.now();
|
|
|
45
52
|
const mapAppToTitle = {
|
|
46
53
|
[AppIdentifier.ONBOARDING]: "Onboarding",
|
|
47
54
|
[AppIdentifier.CRYPTO_WITHDRAWALS]: "Crypto Withdrawals",
|
|
55
|
+
[AppIdentifier.ACH_DEPOSITS]: "ACH Deposits",
|
|
48
56
|
};
|
|
49
57
|
|
|
50
58
|
const AppContainer = ({
|
|
@@ -93,12 +101,21 @@ const AppContainer = ({
|
|
|
93
101
|
case AppIdentifier.ONBOARDING:
|
|
94
102
|
iRef.current.contentWindow.postMessage(
|
|
95
103
|
{
|
|
96
|
-
type:
|
|
104
|
+
type: MESSAGE_TYPE_SEND_JWT_TOKEN_ONBOARDING,
|
|
97
105
|
userOnboardingJWT: jwt,
|
|
98
106
|
},
|
|
99
107
|
zeroHashAppURL
|
|
100
108
|
);
|
|
101
109
|
break;
|
|
110
|
+
case AppIdentifier.ACH_DEPOSITS:
|
|
111
|
+
iRef.current.contentWindow.postMessage(
|
|
112
|
+
{
|
|
113
|
+
type: MESSAGE_TYPE_SEND_JWT_TOKEN_ACH_DEPOSITS,
|
|
114
|
+
achDepositsJWT: jwt,
|
|
115
|
+
},
|
|
116
|
+
zeroHashAppURL
|
|
117
|
+
);
|
|
118
|
+
break;
|
|
102
119
|
default:
|
|
103
120
|
break;
|
|
104
121
|
}
|
|
@@ -130,7 +147,10 @@ const AppContainer = ({
|
|
|
130
147
|
}
|
|
131
148
|
return (
|
|
132
149
|
<div
|
|
133
|
-
style={isAppActive ?
|
|
150
|
+
style={isAppActive ? {
|
|
151
|
+
...appWrapperStyle,
|
|
152
|
+
...height
|
|
153
|
+
} : appWrapperHiddenStyle}
|
|
134
154
|
onClick={() => closeModal(appIdentifier)}
|
|
135
155
|
>
|
|
136
156
|
<div
|
|
@@ -3,6 +3,11 @@ import { appIdentifierToActionPrefixMap } from "../types"
|
|
|
3
3
|
|
|
4
4
|
const ONBOARDING_MESSAGE_TYPE_PREFIX = appIdentifierToActionPrefixMap.get(AppIdentifier.ONBOARDING)
|
|
5
5
|
const CRYPTO_WITHDRAWALS_MESSAGE_TYPE_PREFIX = appIdentifierToActionPrefixMap.get(AppIdentifier.CRYPTO_WITHDRAWALS)
|
|
6
|
+
const ACH_DEPOSITS_MESSAGE_TYPE_PREFIX = appIdentifierToActionPrefixMap.get(AppIdentifier.ACH_DEPOSITS)
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
const SEND_JWT_TOKEN = "SEND_JWT_TOKEN"
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
export const MESSAGE_TYPE_SEND_JWT_TOKEN_ONBOARDING = ONBOARDING_MESSAGE_TYPE_PREFIX + SEND_JWT_TOKEN
|
|
12
|
+
export const MESSAGE_TYPE_SEND_JWT_TOKEN_WITHDRAWALS = CRYPTO_WITHDRAWALS_MESSAGE_TYPE_PREFIX + SEND_JWT_TOKEN
|
|
13
|
+
export const MESSAGE_TYPE_SEND_JWT_TOKEN_ACH_DEPOSITS = ACH_DEPOSITS_MESSAGE_TYPE_PREFIX + SEND_JWT_TOKEN
|
package/src/index.tsx
CHANGED
|
@@ -45,6 +45,13 @@ const appsMessageHandlers: {
|
|
|
45
45
|
[IncomingMessageType.CryptoWithdrawalsAppLoaded]: () => {
|
|
46
46
|
appLoaded(AppIdentifier.CRYPTO_WITHDRAWALS);
|
|
47
47
|
},
|
|
48
|
+
// ACH Deposits message handlers
|
|
49
|
+
[IncomingMessageType.AchDepositsCloseButtonClicked]: () => {
|
|
50
|
+
closeModal(AppIdentifier.ACH_DEPOSITS);
|
|
51
|
+
},
|
|
52
|
+
[IncomingMessageType.AchDepositsAppLoaded]: () => {
|
|
53
|
+
appLoaded(AppIdentifier.ACH_DEPOSITS);
|
|
54
|
+
},
|
|
48
55
|
};
|
|
49
56
|
|
|
50
57
|
/**
|
|
@@ -79,6 +86,7 @@ export class ZeroHashSDK implements IZeroHashSDK {
|
|
|
79
86
|
private initializedApps: Map<AppIdentifier, boolean> = new Map([
|
|
80
87
|
[AppIdentifier.CRYPTO_WITHDRAWALS, false],
|
|
81
88
|
[AppIdentifier.ONBOARDING, false],
|
|
89
|
+
[AppIdentifier.ACH_DEPOSITS, false],
|
|
82
90
|
]);
|
|
83
91
|
|
|
84
92
|
/**
|
|
@@ -91,6 +99,7 @@ export class ZeroHashSDK implements IZeroHashSDK {
|
|
|
91
99
|
rootQuerySelector,
|
|
92
100
|
userOnboardingJWT,
|
|
93
101
|
cryptoWithdrawalsJWT,
|
|
102
|
+
achDepositsJWT,
|
|
94
103
|
zeroHashAppsURL,
|
|
95
104
|
}: IInitializeParameters) {
|
|
96
105
|
// The || is for backwards compatibility
|
|
@@ -116,6 +125,12 @@ export class ZeroHashSDK implements IZeroHashSDK {
|
|
|
116
125
|
appIdentifier: AppIdentifier.CRYPTO_WITHDRAWALS,
|
|
117
126
|
});
|
|
118
127
|
}
|
|
128
|
+
if (achDepositsJWT) {
|
|
129
|
+
this.setJWT({
|
|
130
|
+
jwt: achDepositsJWT,
|
|
131
|
+
appIdentifier: AppIdentifier.ACH_DEPOSITS,
|
|
132
|
+
});
|
|
133
|
+
}
|
|
119
134
|
}
|
|
120
135
|
|
|
121
136
|
/**
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { AppIdentifier } from "../../types";
|
|
2
|
+
import { appIdentifierToActionPrefixMap } from "../../types";
|
|
3
|
+
import {
|
|
4
|
+
ACTION_SET_JWT,
|
|
5
|
+
ACTION_SET_MODAL_STATE,
|
|
6
|
+
ACTION_APP_LOADED
|
|
7
|
+
} from "./constants";
|
|
8
|
+
|
|
9
|
+
export interface IAchDepositsState {
|
|
10
|
+
jwt: string;
|
|
11
|
+
isAppLoaded: boolean;
|
|
12
|
+
isAppActive: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface IAchDepositsAction {
|
|
16
|
+
type: string;
|
|
17
|
+
jwt?: string;
|
|
18
|
+
isAppActive?: boolean;
|
|
19
|
+
isAppLoaded?: boolean;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const INITIAL_STATE: IAchDepositsState = {
|
|
23
|
+
jwt: "",
|
|
24
|
+
isAppActive: false,
|
|
25
|
+
isAppLoaded: false
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const applySetIsAppActive = (state: IAchDepositsState, action: IAchDepositsAction) : IAchDepositsState => {
|
|
29
|
+
return {
|
|
30
|
+
...state,
|
|
31
|
+
isAppActive: !!action.isAppActive,
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const applySetSendJWTToApp = (state: IAchDepositsState, action: IAchDepositsAction) : IAchDepositsState => {
|
|
36
|
+
return {
|
|
37
|
+
...state,
|
|
38
|
+
isAppLoaded: !!action.isAppLoaded,
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const applySetJWT = (state: IAchDepositsState, action: IAchDepositsAction) : IAchDepositsState => {
|
|
43
|
+
return {
|
|
44
|
+
...state,
|
|
45
|
+
jwt: action.jwt as string,
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const reducerMap: { [actionType: string]: (state: IAchDepositsState, action: IAchDepositsAction) => IAchDepositsState } = {
|
|
50
|
+
// ACH Deposits reducer
|
|
51
|
+
[`${appIdentifierToActionPrefixMap.get(AppIdentifier.ACH_DEPOSITS)}${ACTION_SET_JWT}`]: applySetJWT,
|
|
52
|
+
[`${appIdentifierToActionPrefixMap.get(AppIdentifier.ACH_DEPOSITS)}${ACTION_SET_MODAL_STATE}`]: applySetIsAppActive,
|
|
53
|
+
[`${appIdentifierToActionPrefixMap.get(AppIdentifier.ACH_DEPOSITS)}${ACTION_APP_LOADED}`]: applySetSendJWTToApp,
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const achDepositsReducer = (state = INITIAL_STATE, action: IAchDepositsAction) => {
|
|
57
|
+
if (!!action.type && !!reducerMap[action.type]) {
|
|
58
|
+
return reducerMap[action.type](state, action);
|
|
59
|
+
} else {
|
|
60
|
+
return state;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export default achDepositsReducer;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import {combineReducers} from "redux";
|
|
2
2
|
import cryptoWithdrawalsReducer from './crypto-withdrawals'
|
|
3
3
|
import onboardingReducer from "./onboarding";
|
|
4
|
+
import achDepositsReducer from "./ach-deposits";
|
|
4
5
|
|
|
5
6
|
const rootReducer = combineReducers({
|
|
6
7
|
["crypto-withdrawals"]: cryptoWithdrawalsReducer,
|
|
7
8
|
["onboarding"]: onboardingReducer,
|
|
9
|
+
["ach-deposits"]: achDepositsReducer,
|
|
8
10
|
});
|
|
9
11
|
|
|
10
12
|
export default rootReducer;
|
package/src/styles.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {CSSProperties} from "react";
|
|
1
|
+
import { CSSProperties } from "react";
|
|
2
2
|
|
|
3
3
|
const MTE_SM = 540;
|
|
4
4
|
|
|
@@ -11,7 +11,7 @@ export const screenSizes: { id: string, size: number }[] = [
|
|
|
11
11
|
|
|
12
12
|
export const minWidthMatcher = (): string => {
|
|
13
13
|
for (let i = 0; i < screenSizes.length; i++) {
|
|
14
|
-
const {id, size} = screenSizes[i];
|
|
14
|
+
const { id, size } = screenSizes[i];
|
|
15
15
|
if (window.matchMedia(`(min-width: ${size}px`).matches) {
|
|
16
16
|
return id
|
|
17
17
|
}
|
|
@@ -53,6 +53,10 @@ export const appWrapperStyle: CSSProperties = {
|
|
|
53
53
|
cursor: "pointer",
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
export const height: CSSProperties = {
|
|
57
|
+
height: "100dvh",
|
|
58
|
+
}
|
|
59
|
+
|
|
56
60
|
export const appWrapperHiddenStyle: CSSProperties = {
|
|
57
61
|
display: "none",
|
|
58
62
|
width: 0,
|
|
@@ -82,4 +86,4 @@ export const iframeStyle: CSSProperties = {
|
|
|
82
86
|
padding: 0,
|
|
83
87
|
overflow: "hidden",
|
|
84
88
|
borderRadius: "0 0 15px 15px"
|
|
85
|
-
};
|
|
89
|
+
};
|
package/src/types.ts
CHANGED
|
@@ -44,6 +44,12 @@ export interface IInitializeParameters {
|
|
|
44
44
|
* perform crypto withdrawals.
|
|
45
45
|
*/
|
|
46
46
|
cryptoWithdrawalsJWT?: string
|
|
47
|
+
/**
|
|
48
|
+
* achDepositsJWT is the JWT that you received from
|
|
49
|
+
* the ZeroHash HTTP API and have specific permissions to
|
|
50
|
+
* perform ACH Deposits.
|
|
51
|
+
*/
|
|
52
|
+
achDepositsJWT?: string
|
|
47
53
|
/**
|
|
48
54
|
* zeroHashAppsURL is the base URL for all our Apps.
|
|
49
55
|
* It defaults to https://web-sdk.zerohash.com/ and will
|
|
@@ -100,6 +106,16 @@ export enum IncomingMessageType {
|
|
|
100
106
|
* has been clicked in the Crypto Withdrawals app
|
|
101
107
|
*/
|
|
102
108
|
CryptoWithdrawalsCloseButtonClicked = "CRYPTO_WITHDRAWALS_CLOSE_BUTTON_CLICKED",
|
|
109
|
+
/**
|
|
110
|
+
* AchDepositsAppLoaded is received when the crypto
|
|
111
|
+
* withdrawals app has initialized.
|
|
112
|
+
*/
|
|
113
|
+
AchDepositsAppLoaded = "ACH_DEPOSITS_APP_LOADED",
|
|
114
|
+
/**
|
|
115
|
+
* AchDepositsCloseButtonClicked is received when the close button
|
|
116
|
+
* has been clicked in the ACH Deposits app
|
|
117
|
+
*/
|
|
118
|
+
AchDepositsCloseButtonClicked = "ACH_DEPOSITS_CLOSE_BUTTON_CLICKED",
|
|
103
119
|
}
|
|
104
120
|
|
|
105
121
|
/**
|
|
@@ -138,6 +154,7 @@ export interface IZeroHashSDK {
|
|
|
138
154
|
export enum AppIdentifier {
|
|
139
155
|
ONBOARDING = "onboarding",
|
|
140
156
|
CRYPTO_WITHDRAWALS = "crypto-withdrawals",
|
|
157
|
+
ACH_DEPOSITS = "ach-deposits",
|
|
141
158
|
}
|
|
142
159
|
|
|
143
160
|
/**
|
|
@@ -146,7 +163,8 @@ export enum AppIdentifier {
|
|
|
146
163
|
export const appIdentifierToActionPrefixMap = new Map(
|
|
147
164
|
[
|
|
148
165
|
[AppIdentifier.ONBOARDING, "ONBOARDING_"],
|
|
149
|
-
[AppIdentifier.CRYPTO_WITHDRAWALS, "CRYPTO_WITHDRAWALS_"]
|
|
166
|
+
[AppIdentifier.CRYPTO_WITHDRAWALS, "CRYPTO_WITHDRAWALS_"],
|
|
167
|
+
[AppIdentifier.ACH_DEPOSITS, "ACH_DEPOSITS_"],
|
|
150
168
|
])
|
|
151
169
|
|
|
152
170
|
export interface ISetJWTParameters {
|