zh-web-sdk 2.12.2 → 2.12.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.
@@ -0,0 +1,13 @@
1
+ export interface IBankTransferLinkState {
2
+ jwt: string;
3
+ isAppLoaded: boolean;
4
+ isAppActive: boolean;
5
+ }
6
+ export interface IBankTransferLinkAction {
7
+ type: string;
8
+ jwt?: string;
9
+ isAppActive?: boolean;
10
+ isAppLoaded?: boolean;
11
+ }
12
+ declare const bankTransferReducer: (state: IBankTransferLinkState | undefined, action: IBankTransferLinkAction) => IBankTransferLinkState;
13
+ export default bankTransferReducer;
@@ -14,6 +14,6 @@ declare const rootReducer: import("redux").Reducer<import("redux").CombinedState
14
14
  "crypto-account-link-payouts": import("./crypto-account-link-payouts").ICryptoAccountLinkPayoutsState;
15
15
  payouts: import("./payouts").IPayoutsState;
16
16
  pay: import("./pay").IPayState;
17
- "fiat-account-link": import("./fiat-account-link").IFiatAccountLinkState;
17
+ "bank-transfer": import("./bank-transfer").IBankTransferLinkState;
18
18
  }>, import("./crypto-withdrawals").ICryptoWithdrawalsAction | import("./onboarding").IOnboardingAction | import("./crypto-buy").ICryptoBuyAction>;
19
19
  export default rootReducer;
@@ -16,7 +16,7 @@ declare const store: import("redux").Store<import("redux").EmptyObject & {
16
16
  "crypto-account-link-payouts": import("../reducers/crypto-account-link-payouts").ICryptoAccountLinkPayoutsState;
17
17
  payouts: import("../reducers/payouts").IPayoutsState;
18
18
  pay: import("../reducers/pay").IPayState;
19
- "fiat-account-link": import("../reducers/fiat-account-link").IFiatAccountLinkState;
19
+ "bank-transfer": import("../reducers/bank-transfer").IBankTransferLinkState;
20
20
  }, import("../reducers/crypto-withdrawals").ICryptoWithdrawalsAction | import("../reducers/onboarding").IOnboardingAction | import("../reducers/crypto-buy").ICryptoBuyAction>;
21
21
  export default store;
22
22
  export type RootState = ReturnType<typeof rootReducer>;
package/dist/types.d.ts CHANGED
@@ -110,11 +110,11 @@ export interface IInitializeParameters {
110
110
  */
111
111
  payJWT?: string;
112
112
  /**
113
- * fiatAccountLinkJWT is the JWT that you received from
113
+ * bankTransferJWT is the JWT that you received from
114
114
  * the ZeroHash HTTP API and have specific permissions to
115
115
  * create a new Fiat Account.
116
116
  */
117
- fiatAccountLinkJWT?: string;
117
+ bankTransferJWT?: string;
118
118
  /**
119
119
  * zeroHashAppsURL is the base URL for all our Apps.
120
120
  * It defaults to https://web-sdk.zerohash.com/ and will
@@ -383,25 +383,25 @@ export declare enum IncomingMessageType {
383
383
  */
384
384
  PayFailed = "PAY_FAILED",
385
385
  /**
386
- * FiatAccountLinkAppLoaded is received when the Fiat Account Link
386
+ * BankTransferLinkAppLoaded is received when the Bank transfer
387
387
  * app has initialized.
388
388
  */
389
- FiatAccountLinkAppLoaded = "FIAT_ACCOUNT_LINK_APP_LOADED",
389
+ BankTransferLinkAppLoaded = "BANK_TRANSFER_APP_LOADED",
390
390
  /**
391
- * FiatAccountLinkCloseButtonClicked is received when the close button
392
- * has been clicked in the Fiat Account Link app
391
+ * BankTransferLinkCloseButtonClicked is received when the close button
392
+ * has been clicked in the Bank transfer app
393
393
  */
394
- FiatAccountLinkCloseButtonClicked = "FIAT_ACCOUNT_LINK_CLOSE_BUTTON_CLICKED",
394
+ BankTransferLinkCloseButtonClicked = "BANK_TRANSFER_CLOSE_BUTTON_CLICKED",
395
395
  /**
396
- * FiatAccountLinkFailed is received when the
397
- * Fiat Account Link flow has failed.
396
+ * BankTransferLinkFailed is received when the
397
+ * Bank transfer flow has failed.
398
398
  */
399
- FiatAccountLinkFailed = "FIAT_ACCOUNT_LINK_FAILED",
399
+ BankTransferLinkFailed = "BANK_TRANSFER_FAILED",
400
400
  /**
401
- * FiatAccountLinkCompleted is received when the
402
- * Fiat Account Link flow is completed.
401
+ * BankTransferLinkCompleted is received when the
402
+ * Bank transfer flow is completed.
403
403
  */
404
- FiatAccountLinkCompleted = "FIAT_ACCOUNT_LINK_COMPLETED"
404
+ BankTransferLinkCompleted = "BANK_TRANSFER_COMPLETED"
405
405
  }
406
406
  /**
407
407
  * IncomingMessage defines the structure of an incoming
@@ -449,7 +449,7 @@ export declare enum AppIdentifier {
449
449
  CRYPTO_ACCOUNT_LINK_PAYOUTS = "crypto-account-link-payouts",
450
450
  PAYOUTS = "payouts",
451
451
  PAY = "pay",
452
- FIAT_ACCOUNT_LINK = "fiat-account-link"
452
+ BANK_TRANSFER = "bank-transfer"
453
453
  }
454
454
  /**
455
455
  * 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.12.2",
3
+ "version": "2.12.3",
4
4
  "private": false,
5
5
  "description": "ZeroHash Web SDK",
6
6
  "homepage": "https://github.com/seedcx/zh-web-sdk",
@@ -129,7 +129,7 @@ interface AppContainerMappedProps {
129
129
  jwt: string;
130
130
  filters?: Filters;
131
131
  };
132
- [AppIdentifier.FIAT_ACCOUNT_LINK]: {
132
+ [AppIdentifier.BANK_TRANSFER]: {
133
133
  isAppActive: boolean;
134
134
  isAppLoaded: boolean;
135
135
  jwt: string;
@@ -155,7 +155,7 @@ const mapAppToTitle = {
155
155
  [AppIdentifier.CRYPTO_ACCOUNT_LINK_PAYOUTS]: "Crypto Account Link Payouts",
156
156
  [AppIdentifier.PAYOUTS]: "Payouts",
157
157
  [AppIdentifier.PAY]: "Pay",
158
- [AppIdentifier.FIAT_ACCOUNT_LINK]: "Fiat Account Link",
158
+ [AppIdentifier.BANK_TRANSFER]: "Bank transfer",
159
159
  };
160
160
 
161
161
  const AppContainer = ({
@@ -19,7 +19,7 @@ describe("AppContainer", () => {
19
19
  [AppIdentifier.CRYPTO_ACCOUNT_LINK_PAYOUTS, "Crypto Account Link Payouts"],
20
20
  [AppIdentifier.PAYOUTS, "Payouts"],
21
21
  [AppIdentifier.PAY, "Pay"],
22
- [AppIdentifier.FIAT_ACCOUNT_LINK, "Fiat Account Link"],
22
+ [AppIdentifier.BANK_TRANSFER, "Bank transfer"],
23
23
  ])(
24
24
  "should render AppContainer correctly for %s",
25
25
  async (appIdentifier, title) => {
package/src/index.tsx CHANGED
@@ -200,18 +200,18 @@ const appsMessageHandlers: {
200
200
  [IncomingMessageType.PayFailed]: () => {
201
201
  appFailed(AppIdentifier.PAY);
202
202
  },
203
- // Fiat Account Link message handlers
204
- [IncomingMessageType.FiatAccountLinkAppLoaded]: () => {
205
- appLoaded(AppIdentifier.FIAT_ACCOUNT_LINK);
203
+ // Bank transfer message handlers
204
+ [IncomingMessageType.BankTransferLinkAppLoaded]: () => {
205
+ appLoaded(AppIdentifier.BANK_TRANSFER);
206
206
  },
207
- [IncomingMessageType.FiatAccountLinkCloseButtonClicked]: () => {
208
- closeModal(AppIdentifier.FIAT_ACCOUNT_LINK);
207
+ [IncomingMessageType.BankTransferLinkCloseButtonClicked]: () => {
208
+ closeModal(AppIdentifier.BANK_TRANSFER);
209
209
  },
210
- [IncomingMessageType.FiatAccountLinkCompleted]: () => {
211
- appCompleted(AppIdentifier.FIAT_ACCOUNT_LINK);
210
+ [IncomingMessageType.BankTransferLinkCompleted]: () => {
211
+ appCompleted(AppIdentifier.BANK_TRANSFER);
212
212
  },
213
- [IncomingMessageType.FiatAccountLinkFailed]: () => {
214
- appFailed(AppIdentifier.FIAT_ACCOUNT_LINK);
213
+ [IncomingMessageType.BankTransferLinkFailed]: () => {
214
+ appFailed(AppIdentifier.BANK_TRANSFER);
215
215
  },
216
216
  };
217
217
 
@@ -257,7 +257,7 @@ export class ZeroHashSDK implements IZeroHashSDK {
257
257
  [AppIdentifier.CRYPTO_ACCOUNT_LINK_PAYOUTS, false],
258
258
  [AppIdentifier.PAYOUTS, false],
259
259
  [AppIdentifier.PAY, false],
260
- [AppIdentifier.FIAT_ACCOUNT_LINK, false],
260
+ [AppIdentifier.BANK_TRANSFER, false],
261
261
  ]);
262
262
 
263
263
  /**
@@ -280,7 +280,7 @@ export class ZeroHashSDK implements IZeroHashSDK {
280
280
  cryptoAccountLinkPayoutsJWT,
281
281
  payoutsJWT,
282
282
  payJWT,
283
- fiatAccountLinkJWT,
283
+ bankTransferJWT,
284
284
  zeroHashAppsURL,
285
285
  }: IInitializeParameters) {
286
286
  // The || is for backwards compatibility
@@ -366,10 +366,10 @@ export class ZeroHashSDK implements IZeroHashSDK {
366
366
  appIdentifier: AppIdentifier.PAY,
367
367
  });
368
368
  }
369
- if (fiatAccountLinkJWT) {
369
+ if (bankTransferJWT) {
370
370
  this.setJWT({
371
- jwt: fiatAccountLinkJWT,
372
- appIdentifier: AppIdentifier.FIAT_ACCOUNT_LINK,
371
+ jwt: bankTransferJWT,
372
+ appIdentifier: AppIdentifier.BANK_TRANSFER,
373
373
  });
374
374
  }
375
375
  }
@@ -0,0 +1,60 @@
1
+ import { AppIdentifier, appIdentifierToActionPrefixMap } from "../../types";
2
+ import { ACTION_APP_LOADED, ACTION_SET_JWT, ACTION_SET_MODAL_STATE } from "./constants";
3
+
4
+ export interface IBankTransferLinkState {
5
+ jwt: string;
6
+ isAppLoaded: boolean;
7
+ isAppActive: boolean;
8
+ }
9
+
10
+ export interface IBankTransferLinkAction {
11
+ type: string;
12
+ jwt?: string;
13
+ isAppActive?: boolean;
14
+ isAppLoaded?: boolean;
15
+ }
16
+
17
+ const INITIAL_STATE: IBankTransferLinkState = {
18
+ jwt: "",
19
+ isAppActive: false,
20
+ isAppLoaded: false
21
+ }
22
+
23
+ const applySetIsAppActive = (state: IBankTransferLinkState, action: IBankTransferLinkAction): IBankTransferLinkState => {
24
+ return {
25
+ ...state,
26
+ isAppActive: !!action.isAppActive,
27
+ }
28
+ }
29
+
30
+ const applySetSendJWTToApp = (state: IBankTransferLinkState, action: IBankTransferLinkAction): IBankTransferLinkState => {
31
+ return {
32
+ ...state,
33
+ isAppLoaded: !!action.isAppLoaded,
34
+ }
35
+ }
36
+
37
+ const applySetJWT = (state: IBankTransferLinkState, action: IBankTransferLinkAction): IBankTransferLinkState => {
38
+ return {
39
+ ...state,
40
+ jwt: action.jwt as string,
41
+ }
42
+ }
43
+
44
+ const reducerMap: {
45
+ [actionType: string]: (state: IBankTransferLinkState, action: IBankTransferLinkAction) => IBankTransferLinkState
46
+ } = {
47
+ [`${appIdentifierToActionPrefixMap.get(AppIdentifier.BANK_TRANSFER)}${ACTION_SET_JWT}`]: applySetJWT,
48
+ [`${appIdentifierToActionPrefixMap.get(AppIdentifier.BANK_TRANSFER)}${ACTION_SET_MODAL_STATE}`]: applySetIsAppActive,
49
+ [`${appIdentifierToActionPrefixMap.get(AppIdentifier.BANK_TRANSFER)}${ACTION_APP_LOADED}`]: applySetSendJWTToApp,
50
+ };
51
+
52
+ const bankTransferReducer = (state = INITIAL_STATE, action: IBankTransferLinkAction) => {
53
+ if (!!action.type && !!reducerMap[action.type]) {
54
+ return reducerMap[action.type](state, action);
55
+ } else {
56
+ return state;
57
+ }
58
+ }
59
+
60
+ export default bankTransferReducer;
@@ -11,7 +11,7 @@ import cryptoAccountLinkReducer from "./crypto-account-link";
11
11
  import cryptoAccountLinkPayoutsReducer from "./crypto-account-link-payouts";
12
12
  import payoutsReducer from "./payouts";
13
13
  import payReducer from "./pay";
14
- import fiatAccountLinkReducer from "./fiat-account-link";
14
+ import bankTransferReducer from "./bank-transfer";
15
15
 
16
16
  const rootReducer = combineReducers({
17
17
  ["crypto-withdrawals"]: cryptoWithdrawalsReducer,
@@ -29,7 +29,7 @@ const rootReducer = combineReducers({
29
29
  ["crypto-account-link-payouts"]: cryptoAccountLinkPayoutsReducer,
30
30
  ["payouts"]: payoutsReducer,
31
31
  ["pay"]: payReducer,
32
- ["fiat-account-link"]: fiatAccountLinkReducer,
32
+ ["bank-transfer"]: bankTransferReducer,
33
33
  });
34
34
 
35
35
  export default rootReducer;
package/src/types.ts CHANGED
@@ -113,11 +113,11 @@ export interface IInitializeParameters {
113
113
  */
114
114
  payJWT?: string
115
115
  /**
116
- * fiatAccountLinkJWT is the JWT that you received from
116
+ * bankTransferJWT is the JWT that you received from
117
117
  * the ZeroHash HTTP API and have specific permissions to
118
118
  * create a new Fiat Account.
119
119
  */
120
- fiatAccountLinkJWT?: string
120
+ bankTransferJWT?: string
121
121
  /**
122
122
  * zeroHashAppsURL is the base URL for all our Apps.
123
123
  * It defaults to https://web-sdk.zerohash.com/ and will
@@ -389,25 +389,25 @@ export enum IncomingMessageType {
389
389
  */
390
390
  PayFailed = "PAY_FAILED",
391
391
  /**
392
- * FiatAccountLinkAppLoaded is received when the Fiat Account Link
392
+ * BankTransferLinkAppLoaded is received when the Bank transfer
393
393
  * app has initialized.
394
394
  */
395
- FiatAccountLinkAppLoaded = "FIAT_ACCOUNT_LINK_APP_LOADED",
395
+ BankTransferLinkAppLoaded = "BANK_TRANSFER_APP_LOADED",
396
396
  /**
397
- * FiatAccountLinkCloseButtonClicked is received when the close button
398
- * has been clicked in the Fiat Account Link app
397
+ * BankTransferLinkCloseButtonClicked is received when the close button
398
+ * has been clicked in the Bank transfer app
399
399
  */
400
- FiatAccountLinkCloseButtonClicked = "FIAT_ACCOUNT_LINK_CLOSE_BUTTON_CLICKED",
400
+ BankTransferLinkCloseButtonClicked = "BANK_TRANSFER_CLOSE_BUTTON_CLICKED",
401
401
  /**
402
- * FiatAccountLinkFailed is received when the
403
- * Fiat Account Link flow has failed.
402
+ * BankTransferLinkFailed is received when the
403
+ * Bank transfer flow has failed.
404
404
  */
405
- FiatAccountLinkFailed = "FIAT_ACCOUNT_LINK_FAILED",
405
+ BankTransferLinkFailed = "BANK_TRANSFER_FAILED",
406
406
  /**
407
- * FiatAccountLinkCompleted is received when the
408
- * Fiat Account Link flow is completed.
407
+ * BankTransferLinkCompleted is received when the
408
+ * Bank transfer flow is completed.
409
409
  */
410
- FiatAccountLinkCompleted = "FIAT_ACCOUNT_LINK_COMPLETED",
410
+ BankTransferLinkCompleted = "BANK_TRANSFER_COMPLETED",
411
411
  }
412
412
 
413
413
  /**
@@ -459,7 +459,7 @@ export enum AppIdentifier {
459
459
  CRYPTO_ACCOUNT_LINK_PAYOUTS = "crypto-account-link-payouts",
460
460
  PAYOUTS = "payouts",
461
461
  PAY = "pay",
462
- FIAT_ACCOUNT_LINK = "fiat-account-link"
462
+ BANK_TRANSFER = "bank-transfer"
463
463
  }
464
464
 
465
465
  /**
@@ -483,7 +483,7 @@ export const appIdentifierToActionPrefixMap = new Map(
483
483
  [AppIdentifier.CRYPTO_ACCOUNT_LINK_PAYOUTS, "CRYPTO_ACCOUNT_LINK_PAYOUTS_"],
484
484
  [AppIdentifier.PAYOUTS, "PAYOUTS_"],
485
485
  [AppIdentifier.PAY, "PAY_"],
486
- [AppIdentifier.FIAT_ACCOUNT_LINK, "FIAT_ACCOUNT_LINK_"]
486
+ [AppIdentifier.BANK_TRANSFER, "BANK_TRANSFER_"]
487
487
  ])
488
488
 
489
489
  export interface ISetJWTParameters {
@@ -1,13 +0,0 @@
1
- export interface IFiatAccountLinkState {
2
- jwt: string;
3
- isAppLoaded: boolean;
4
- isAppActive: boolean;
5
- }
6
- export interface IFiatAccountLinkAction {
7
- type: string;
8
- jwt?: string;
9
- isAppActive?: boolean;
10
- isAppLoaded?: boolean;
11
- }
12
- declare const fiatAccountLinkReducer: (state: IFiatAccountLinkState | undefined, action: IFiatAccountLinkAction) => IFiatAccountLinkState;
13
- export default fiatAccountLinkReducer;
@@ -1,60 +0,0 @@
1
- import { AppIdentifier, appIdentifierToActionPrefixMap } from "../../types";
2
- import { ACTION_APP_LOADED, ACTION_SET_JWT, ACTION_SET_MODAL_STATE } from "./constants";
3
-
4
- export interface IFiatAccountLinkState {
5
- jwt: string;
6
- isAppLoaded: boolean;
7
- isAppActive: boolean;
8
- }
9
-
10
- export interface IFiatAccountLinkAction {
11
- type: string;
12
- jwt?: string;
13
- isAppActive?: boolean;
14
- isAppLoaded?: boolean;
15
- }
16
-
17
- const INITIAL_STATE: IFiatAccountLinkState = {
18
- jwt: "",
19
- isAppActive: false,
20
- isAppLoaded: false
21
- }
22
-
23
- const applySetIsAppActive = (state: IFiatAccountLinkState, action: IFiatAccountLinkAction): IFiatAccountLinkState => {
24
- return {
25
- ...state,
26
- isAppActive: !!action.isAppActive,
27
- }
28
- }
29
-
30
- const applySetSendJWTToApp = (state: IFiatAccountLinkState, action: IFiatAccountLinkAction): IFiatAccountLinkState => {
31
- return {
32
- ...state,
33
- isAppLoaded: !!action.isAppLoaded,
34
- }
35
- }
36
-
37
- const applySetJWT = (state: IFiatAccountLinkState, action: IFiatAccountLinkAction): IFiatAccountLinkState => {
38
- return {
39
- ...state,
40
- jwt: action.jwt as string,
41
- }
42
- }
43
-
44
- const reducerMap: {
45
- [actionType: string]: (state: IFiatAccountLinkState, action: IFiatAccountLinkAction) => IFiatAccountLinkState
46
- } = {
47
- [`${appIdentifierToActionPrefixMap.get(AppIdentifier.FIAT_ACCOUNT_LINK)}${ACTION_SET_JWT}`]: applySetJWT,
48
- [`${appIdentifierToActionPrefixMap.get(AppIdentifier.FIAT_ACCOUNT_LINK)}${ACTION_SET_MODAL_STATE}`]: applySetIsAppActive,
49
- [`${appIdentifierToActionPrefixMap.get(AppIdentifier.FIAT_ACCOUNT_LINK)}${ACTION_APP_LOADED}`]: applySetSendJWTToApp,
50
- };
51
-
52
- const fiatAccountLinkReducer = (state = INITIAL_STATE, action: IFiatAccountLinkAction) => {
53
- if (!!action.type && !!reducerMap[action.type]) {
54
- return reducerMap[action.type](state, action);
55
- } else {
56
- return state;
57
- }
58
- }
59
-
60
- export default fiatAccountLinkReducer;