zh-web-sdk 2.3.4 → 2.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,3 +2,6 @@ import { AppIdentifier } from "../../types";
2
2
  export declare const openModal: (appIdentifier: AppIdentifier) => void;
3
3
  export declare const closeModal: (appIdentifier: AppIdentifier) => void;
4
4
  export declare const appLoaded: (appIdentifier: AppIdentifier) => void;
5
+ export declare const appPendingApproval: (appIdentifier: AppIdentifier) => void;
6
+ export declare const appCompleted: (appIdentifier: AppIdentifier) => void;
7
+ export declare const appFailed: (appIdentifier: AppIdentifier) => void;
@@ -1,3 +1,6 @@
1
1
  export declare const ACTION_SET_MODAL_STATE = "SET_MODAL_STATE";
2
2
  export declare const ACTION_SET_JWT = "SET_JWT";
3
3
  export declare const ACTION_APP_LOADED = "APP_LOADED";
4
+ export declare const ACTION_PENDING_APPROVAL = "PENDING_APPROVAL";
5
+ export declare const ACTION_COMPLETED = "COMPLETED";
6
+ export declare const ACTION_FAILED = "FAILED";
@@ -5,5 +5,6 @@ declare const rootReducer: import("redux").Reducer<import("redux").CombinedState
5
5
  "fiat-withdrawals": import("./fiat-withdrawals").IFiatWithdrawalsState;
6
6
  "crypto-buy": import("./crypto-buy").ICryptoBuyState;
7
7
  "crypto-sell": import("./crypto-sell").ICryptoSellState;
8
+ "csp-crypto-withdrawals": import("./crypto-withdrawals").ICryptoWithdrawalsState;
8
9
  }>, import("./crypto-withdrawals").ICryptoWithdrawalsAction>;
9
10
  export default rootReducer;
@@ -5,5 +5,6 @@ declare const store: import("redux").Store<import("redux").EmptyObject & {
5
5
  "fiat-withdrawals": import("../reducers/fiat-withdrawals").IFiatWithdrawalsState;
6
6
  "crypto-buy": import("../reducers/crypto-buy").ICryptoBuyState;
7
7
  "crypto-sell": import("../reducers/crypto-sell").ICryptoSellState;
8
+ "csp-crypto-withdrawals": import("../reducers/crypto-withdrawals").ICryptoWithdrawalsState;
8
9
  }, import("../reducers/crypto-withdrawals").ICryptoWithdrawalsAction>;
9
10
  export default store;
package/dist/types.d.ts CHANGED
@@ -109,6 +109,21 @@ export declare enum IncomingMessageType {
109
109
  * has been clicked in the onboarding app
110
110
  */
111
111
  OnboardingCloseButtonClicked = "ONBOARDING_CLOSE_BUTTON_CLICKED",
112
+ /**
113
+ * OnboardingCompleted is received when the onboarding flow has completed
114
+ * successfully with participant approved and webview can be closed.
115
+ */
116
+ OnboardingCompleted = "ONBOARDING_COMPLETED",
117
+ /**
118
+ * OnboardingFailed is received when the onboarding
119
+ * flow has failed.
120
+ */
121
+ OnboardingFailed = "ONBOARDING_FAILED",
122
+ /**
123
+ * OnboardingPendingApproval is received when the onboarding
124
+ * flow has completed successfully but the participant is pending approval.
125
+ */
126
+ OnboardingPendingApproval = "ONBOARDING_PENDING_APPROVAL",
112
127
  /**
113
128
  * CryptoWithdrawalsAppLoaded is received when the crypto
114
129
  * withdrawals app has initialized.
@@ -119,6 +134,16 @@ export declare enum IncomingMessageType {
119
134
  * has been clicked in the Crypto Withdrawals app
120
135
  */
121
136
  CryptoWithdrawalsCloseButtonClicked = "CRYPTO_WITHDRAWALS_CLOSE_BUTTON_CLICKED",
137
+ /**
138
+ * CryptoWithdrawalsCompleted is received when the Crypto
139
+ * withdrawals flow has completed successfully.
140
+ */
141
+ CryptoWithdrawalsCompleted = "CRYPTO_WITHDRAWALS_COMPLETED",
142
+ /**
143
+ * CryptoWithdrawalsFailed is received when the Crypto
144
+ * withdrawals flow has failed.
145
+ */
146
+ CryptoWithdrawalsFailed = "CRYPTO_WITHDRAWALS_FAILED",
122
147
  /**
123
148
  * FiatDepositsAppLoaded is received when the Fiat
124
149
  * deposits app has initialized.
@@ -129,6 +154,16 @@ export declare enum IncomingMessageType {
129
154
  * has been clicked in the Fiat Deposits app
130
155
  */
131
156
  FiatDepositsCloseButtonClicked = "FIAT_DEPOSITS_CLOSE_BUTTON_CLICKED",
157
+ /**
158
+ * FiatDepositsCompleted is received when the Fiat
159
+ * deposits flow has completed successfully.
160
+ */
161
+ FiatDepositsCompleted = "FIAT_DEPOSITS_COMPLETED",
162
+ /**
163
+ * FiatDepositsFailed is received when the Fiat
164
+ * deposits flow has failed.
165
+ */
166
+ FiatDepositsFailed = "FIAT_DEPOSITS_FAILED",
132
167
  /**
133
168
  * FiatWithdrawalsAppLoaded is received when the Fiat
134
169
  * withdrawals app has initialized.
@@ -139,6 +174,16 @@ export declare enum IncomingMessageType {
139
174
  * has been clicked in the Fiat Withdrawals app
140
175
  */
141
176
  FiatWithdrawalsCloseButtonClicked = "FIAT_WITHDRAWALS_CLOSE_BUTTON_CLICKED",
177
+ /**
178
+ * FiatWithdrawalsCompleted is received when the Fiat
179
+ * withdrawals flow has completed successfully.
180
+ */
181
+ FiatWithdrawalsCompleted = "FIAT_WITHDRAWALS_COMPLETED",
182
+ /**
183
+ * FiatWithdrawalsFailed is received when the Fiat
184
+ * withdrawals flow has failed.
185
+ */
186
+ FiatWithdrawalsFailed = "FIAT_WITHDRAWALS_FAILED",
142
187
  /**
143
188
  * CryptoBuyAppLoaded is received when the Crypto
144
189
  * buy app has initialized.
@@ -149,6 +194,16 @@ export declare enum IncomingMessageType {
149
194
  * has been clicked in the Crypto buy app
150
195
  */
151
196
  CryptoBuyCloseButtonClicked = "CRYPTO_BUY_CLOSE_BUTTON_CLICKED",
197
+ /**
198
+ * CryptoBuyCompleted is received when the Crypto
199
+ * buy flow flow has completed successfully.
200
+ */
201
+ CryptoBuyCompleted = "CRYPTO_BUY_COMPLETED",
202
+ /**
203
+ * CryptoBuyFailed is received when the Crypto
204
+ * buy flow has failed.
205
+ */
206
+ CryptoBuyFailed = "CRYPTO_BUY_FAILED",
152
207
  /**
153
208
  * CryptoSellAppLoaded is received when the Crypto
154
209
  * sell app has initialized.
@@ -158,7 +213,17 @@ export declare enum IncomingMessageType {
158
213
  * CryptoSellCloseButtonClicked is received when the close button
159
214
  * has been clicked in the Crypto sell app
160
215
  */
161
- CryptoSellCloseButtonClicked = "CRYPTO_SELL_CLOSE_BUTTON_CLICKED"
216
+ CryptoSellCloseButtonClicked = "CRYPTO_SELL_CLOSE_BUTTON_CLICKED",
217
+ /**
218
+ * CryptoSellCompleted is received when the Crypto
219
+ * sell flow has completed successfully.
220
+ */
221
+ CryptoSellCompleted = "CRYPTO_SELL_COMPLETED",
222
+ /**
223
+ * CryptoSellFailed is received when the Crypto
224
+ * sell flow has failed.
225
+ */
226
+ CryptoSellFailed = "CRYPTO_SELL_FAILED"
162
227
  }
163
228
  /**
164
229
  * IncomingMessage defines the structure of an incoming
@@ -196,7 +261,8 @@ export declare enum AppIdentifier {
196
261
  FIAT_DEPOSITS = "fiat-deposits",
197
262
  FIAT_WITHDRAWALS = "fiat-withdrawals",
198
263
  CRYPTO_BUY = "crypto-buy",
199
- CRYPTO_SELL = "crypto-sell"
264
+ CRYPTO_SELL = "crypto-sell",
265
+ CSP_CRYPTO_WITHDRAWALS = "csp-crypto-withdrawals"
200
266
  }
201
267
  /**
202
268
  * Map that maps the app AppIdentifier to the redux action prefix
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zh-web-sdk",
3
- "version": "2.3.4",
3
+ "version": "2.4.1",
4
4
  "private": false,
5
5
  "description": "ZeroHash Web SDK",
6
6
  "homepage": "https://github.com/seedcx/zh-web-sdk",
@@ -54,6 +54,11 @@ interface AppContainerMappedProps {
54
54
  isAppLoaded: boolean;
55
55
  jwt: string;
56
56
  };
57
+ [AppIdentifier.CSP_CRYPTO_WITHDRAWALS]: {
58
+ isAppActive: boolean;
59
+ isAppLoaded: boolean;
60
+ jwt: string;
61
+ };
57
62
  }
58
63
 
59
64
  const appLoadTime = Date.now();
@@ -65,6 +70,7 @@ const mapAppToTitle = {
65
70
  [AppIdentifier.FIAT_WITHDRAWALS]: "Fiat Withdrawals",
66
71
  [AppIdentifier.CRYPTO_BUY]: "Crypto Buy",
67
72
  [AppIdentifier.CRYPTO_SELL]: "Crypto Sell",
73
+ [AppIdentifier.CSP_CRYPTO_WITHDRAWALS]: "CBP Crypto Withdrawals"
68
74
  };
69
75
 
70
76
  const AppContainer = ({
package/src/index.tsx CHANGED
@@ -18,7 +18,7 @@ import AppContainer from "./iframe-container/AppContainer";
18
18
  import { Provider } from "react-redux";
19
19
  import store from "./redux/store";
20
20
  import { ACTION_SET_JWT } from "./redux/reducers/constants";
21
- import { appLoaded, closeModal, openModal } from "./redux/actions";
21
+ import { appCompleted, appFailed, appLoaded, appPendingApproval, closeModal, openModal } from "./redux/actions";
22
22
 
23
23
  let _zeroHashAppsURL: string = DEFAULT_ZH_APPS_URL;
24
24
  let _zeroHashAppsOrigin: string = "";
@@ -38,6 +38,15 @@ const appsMessageHandlers: {
38
38
  [IncomingMessageType.OnboardingCloseButtonClicked]: () => {
39
39
  closeModal(AppIdentifier.ONBOARDING);
40
40
  },
41
+ [IncomingMessageType.OnboardingPendingApproval]: () => {
42
+ appPendingApproval(AppIdentifier.ONBOARDING);
43
+ },
44
+ [IncomingMessageType.OnboardingCompleted]: () => {
45
+ appCompleted(AppIdentifier.ONBOARDING);
46
+ },
47
+ [IncomingMessageType.OnboardingFailed]: () => {
48
+ appFailed(AppIdentifier.ONBOARDING);
49
+ },
41
50
  // Crypto Withdrawals message handlers
42
51
  [IncomingMessageType.CryptoWithdrawalsCloseButtonClicked]: () => {
43
52
  closeModal(AppIdentifier.CRYPTO_WITHDRAWALS);
@@ -45,6 +54,12 @@ const appsMessageHandlers: {
45
54
  [IncomingMessageType.CryptoWithdrawalsAppLoaded]: () => {
46
55
  appLoaded(AppIdentifier.CRYPTO_WITHDRAWALS);
47
56
  },
57
+ [IncomingMessageType.CryptoWithdrawalsCompleted]: () => {
58
+ appCompleted(AppIdentifier.CRYPTO_WITHDRAWALS);
59
+ },
60
+ [IncomingMessageType.CryptoWithdrawalsFailed]: () => {
61
+ appFailed(AppIdentifier.CRYPTO_WITHDRAWALS);
62
+ },
48
63
  // Fiat Deposits message handlers
49
64
  [IncomingMessageType.FiatDepositsCloseButtonClicked]: () => {
50
65
  closeModal(AppIdentifier.FIAT_DEPOSITS);
@@ -52,6 +67,12 @@ const appsMessageHandlers: {
52
67
  [IncomingMessageType.FiatDepositsAppLoaded]: () => {
53
68
  appLoaded(AppIdentifier.FIAT_DEPOSITS);
54
69
  },
70
+ [IncomingMessageType.FiatDepositsCompleted]: () => {
71
+ appCompleted(AppIdentifier.FIAT_DEPOSITS);
72
+ },
73
+ [IncomingMessageType.FiatDepositsFailed]: () => {
74
+ appFailed(AppIdentifier.FIAT_DEPOSITS);
75
+ },
55
76
  // Fiat Withdrawals message handlers
56
77
  [IncomingMessageType.FiatWithdrawalsCloseButtonClicked]: () => {
57
78
  closeModal(AppIdentifier.FIAT_WITHDRAWALS);
@@ -59,6 +80,12 @@ const appsMessageHandlers: {
59
80
  [IncomingMessageType.FiatWithdrawalsAppLoaded]: () => {
60
81
  appLoaded(AppIdentifier.FIAT_WITHDRAWALS);
61
82
  },
83
+ [IncomingMessageType.FiatWithdrawalsCompleted]: () => {
84
+ appCompleted(AppIdentifier.FIAT_WITHDRAWALS);
85
+ },
86
+ [IncomingMessageType.FiatWithdrawalsFailed]: () => {
87
+ appFailed(AppIdentifier.FIAT_WITHDRAWALS);
88
+ },
62
89
  // Crypto buy message handlers
63
90
  [IncomingMessageType.CryptoBuyCloseButtonClicked]: () => {
64
91
  closeModal(AppIdentifier.CRYPTO_BUY);
@@ -66,6 +93,12 @@ const appsMessageHandlers: {
66
93
  [IncomingMessageType.CryptoBuyAppLoaded]: () => {
67
94
  appLoaded(AppIdentifier.CRYPTO_BUY);
68
95
  },
96
+ [IncomingMessageType.CryptoBuyCompleted]: () => {
97
+ appCompleted(AppIdentifier.CRYPTO_BUY);
98
+ },
99
+ [IncomingMessageType.CryptoBuyFailed]: () => {
100
+ appFailed(AppIdentifier.CRYPTO_BUY);
101
+ },
69
102
  // Crypto sell message handlers
70
103
  [IncomingMessageType.CryptoSellCloseButtonClicked]: () => {
71
104
  closeModal(AppIdentifier.CRYPTO_SELL);
@@ -73,6 +106,12 @@ const appsMessageHandlers: {
73
106
  [IncomingMessageType.CryptoSellAppLoaded]: () => {
74
107
  appLoaded(AppIdentifier.CRYPTO_SELL);
75
108
  },
109
+ [IncomingMessageType.CryptoSellCompleted]: () => {
110
+ appCompleted(AppIdentifier.CRYPTO_SELL);
111
+ },
112
+ [IncomingMessageType.CryptoSellFailed]: () => {
113
+ appFailed(AppIdentifier.CRYPTO_SELL);
114
+ },
76
115
  };
77
116
 
78
117
  /**
@@ -1,4 +1,4 @@
1
- import { ACTION_APP_LOADED, ACTION_SET_MODAL_STATE } from "../reducers/constants";
1
+ import { ACTION_APP_LOADED, ACTION_COMPLETED, ACTION_FAILED, ACTION_PENDING_APPROVAL, ACTION_SET_MODAL_STATE } from "../reducers/constants";
2
2
  import { AppIdentifier } from "../../types";
3
3
  import { dispatchActionBasedOnAppIdentifier } from "../../utils";
4
4
 
@@ -13,3 +13,15 @@ export const closeModal = (appIdentifier: AppIdentifier) => {
13
13
  export const appLoaded = (appIdentifier: AppIdentifier) => {
14
14
  dispatchActionBasedOnAppIdentifier(appIdentifier, ACTION_APP_LOADED, { isAppLoaded: true })
15
15
  }
16
+
17
+ export const appPendingApproval = (appIdentifier: AppIdentifier) => {
18
+ dispatchActionBasedOnAppIdentifier(appIdentifier, ACTION_PENDING_APPROVAL, {})
19
+ }
20
+
21
+ export const appCompleted = (appIdentifier: AppIdentifier) => {
22
+ dispatchActionBasedOnAppIdentifier(appIdentifier, ACTION_COMPLETED, {})
23
+ }
24
+
25
+ export const appFailed = (appIdentifier: AppIdentifier) => {
26
+ dispatchActionBasedOnAppIdentifier(appIdentifier, ACTION_FAILED, {})
27
+ }
@@ -2,3 +2,6 @@
2
2
  export const ACTION_SET_MODAL_STATE = "SET_MODAL_STATE"
3
3
  export const ACTION_SET_JWT = "SET_JWT"
4
4
  export const ACTION_APP_LOADED = "APP_LOADED"
5
+ export const ACTION_PENDING_APPROVAL = "PENDING_APPROVAL"
6
+ export const ACTION_COMPLETED = "COMPLETED"
7
+ export const ACTION_FAILED = "FAILED"
@@ -13,6 +13,7 @@ const rootReducer = combineReducers({
13
13
  ["fiat-withdrawals"]: fiatWithdrawalsReducer,
14
14
  ["crypto-buy"]: cryptoBuyReducer,
15
15
  ["crypto-sell"]: cryptoSellReducer,
16
+ ["csp-crypto-withdrawals"]: cryptoWithdrawalsReducer,
16
17
  });
17
18
 
18
19
  export default rootReducer;
package/src/types.ts CHANGED
@@ -114,6 +114,21 @@ export enum IncomingMessageType {
114
114
  * has been clicked in the onboarding app
115
115
  */
116
116
  OnboardingCloseButtonClicked = "ONBOARDING_CLOSE_BUTTON_CLICKED",
117
+ /**
118
+ * OnboardingCompleted is received when the onboarding flow has completed
119
+ * successfully with participant approved and webview can be closed.
120
+ */
121
+ OnboardingCompleted = "ONBOARDING_COMPLETED",
122
+ /**
123
+ * OnboardingFailed is received when the onboarding
124
+ * flow has failed.
125
+ */
126
+ OnboardingFailed = "ONBOARDING_FAILED",
127
+ /**
128
+ * OnboardingPendingApproval is received when the onboarding
129
+ * flow has completed successfully but the participant is pending approval.
130
+ */
131
+ OnboardingPendingApproval = "ONBOARDING_PENDING_APPROVAL",
117
132
  /**
118
133
  * CryptoWithdrawalsAppLoaded is received when the crypto
119
134
  * withdrawals app has initialized.
@@ -124,6 +139,16 @@ export enum IncomingMessageType {
124
139
  * has been clicked in the Crypto Withdrawals app
125
140
  */
126
141
  CryptoWithdrawalsCloseButtonClicked = "CRYPTO_WITHDRAWALS_CLOSE_BUTTON_CLICKED",
142
+ /**
143
+ * CryptoWithdrawalsCompleted is received when the Crypto
144
+ * withdrawals flow has completed successfully.
145
+ */
146
+ CryptoWithdrawalsCompleted = "CRYPTO_WITHDRAWALS_COMPLETED",
147
+ /**
148
+ * CryptoWithdrawalsFailed is received when the Crypto
149
+ * withdrawals flow has failed.
150
+ */
151
+ CryptoWithdrawalsFailed = "CRYPTO_WITHDRAWALS_FAILED",
127
152
  /**
128
153
  * FiatDepositsAppLoaded is received when the Fiat
129
154
  * deposits app has initialized.
@@ -134,6 +159,16 @@ export enum IncomingMessageType {
134
159
  * has been clicked in the Fiat Deposits app
135
160
  */
136
161
  FiatDepositsCloseButtonClicked = "FIAT_DEPOSITS_CLOSE_BUTTON_CLICKED",
162
+ /**
163
+ * FiatDepositsCompleted is received when the Fiat
164
+ * deposits flow has completed successfully.
165
+ */
166
+ FiatDepositsCompleted = "FIAT_DEPOSITS_COMPLETED",
167
+ /**
168
+ * FiatDepositsFailed is received when the Fiat
169
+ * deposits flow has failed.
170
+ */
171
+ FiatDepositsFailed = "FIAT_DEPOSITS_FAILED",
137
172
  /**
138
173
  * FiatWithdrawalsAppLoaded is received when the Fiat
139
174
  * withdrawals app has initialized.
@@ -144,6 +179,16 @@ export enum IncomingMessageType {
144
179
  * has been clicked in the Fiat Withdrawals app
145
180
  */
146
181
  FiatWithdrawalsCloseButtonClicked = "FIAT_WITHDRAWALS_CLOSE_BUTTON_CLICKED",
182
+ /**
183
+ * FiatWithdrawalsCompleted is received when the Fiat
184
+ * withdrawals flow has completed successfully.
185
+ */
186
+ FiatWithdrawalsCompleted = "FIAT_WITHDRAWALS_COMPLETED",
187
+ /**
188
+ * FiatWithdrawalsFailed is received when the Fiat
189
+ * withdrawals flow has failed.
190
+ */
191
+ FiatWithdrawalsFailed = "FIAT_WITHDRAWALS_FAILED",
147
192
  /**
148
193
  * CryptoBuyAppLoaded is received when the Crypto
149
194
  * buy app has initialized.
@@ -154,6 +199,16 @@ export enum IncomingMessageType {
154
199
  * has been clicked in the Crypto buy app
155
200
  */
156
201
  CryptoBuyCloseButtonClicked = "CRYPTO_BUY_CLOSE_BUTTON_CLICKED",
202
+ /**
203
+ * CryptoBuyCompleted is received when the Crypto
204
+ * buy flow flow has completed successfully.
205
+ */
206
+ CryptoBuyCompleted = "CRYPTO_BUY_COMPLETED",
207
+ /**
208
+ * CryptoBuyFailed is received when the Crypto
209
+ * buy flow has failed.
210
+ */
211
+ CryptoBuyFailed = "CRYPTO_BUY_FAILED",
157
212
  /**
158
213
  * CryptoSellAppLoaded is received when the Crypto
159
214
  * sell app has initialized.
@@ -164,6 +219,16 @@ export enum IncomingMessageType {
164
219
  * has been clicked in the Crypto sell app
165
220
  */
166
221
  CryptoSellCloseButtonClicked = "CRYPTO_SELL_CLOSE_BUTTON_CLICKED",
222
+ /**
223
+ * CryptoSellCompleted is received when the Crypto
224
+ * sell flow has completed successfully.
225
+ */
226
+ CryptoSellCompleted = "CRYPTO_SELL_COMPLETED",
227
+ /**
228
+ * CryptoSellFailed is received when the Crypto
229
+ * sell flow has failed.
230
+ */
231
+ CryptoSellFailed = "CRYPTO_SELL_FAILED",
167
232
  }
168
233
 
169
234
  /**
@@ -206,6 +271,7 @@ export enum AppIdentifier {
206
271
  FIAT_WITHDRAWALS = "fiat-withdrawals",
207
272
  CRYPTO_BUY = "crypto-buy",
208
273
  CRYPTO_SELL = "crypto-sell",
274
+ CSP_CRYPTO_WITHDRAWALS = "csp-crypto-withdrawals",
209
275
  }
210
276
 
211
277
  /**
@@ -219,6 +285,7 @@ export const appIdentifierToActionPrefixMap = new Map(
219
285
  [AppIdentifier.FIAT_WITHDRAWALS, "FIAT_WITHDRAWALS_"],
220
286
  [AppIdentifier.CRYPTO_BUY, "CRYPTO_BUY_"],
221
287
  [AppIdentifier.CRYPTO_SELL, "CRYPTO_SELL_"],
288
+ [AppIdentifier.CSP_CRYPTO_WITHDRAWALS, "CRYPTO_WITHDRAWALS_"] // CSP apps uses the same events as "regular" flow
222
289
  ])
223
290
 
224
291
  export interface ISetJWTParameters {