@zeniai/client-epic-state 4.14.90 → 4.14.91

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/lib/index.d.ts CHANGED
@@ -513,7 +513,7 @@ import { clearTrendData, fetchExpenseTrend, fetchIncomeTrend } from './view/tren
513
513
  import { TrendView, getTrendForEntity } from './view/trend/trendSelector';
514
514
  import { clearTrendWithTransactions, fetchTransactionsForEntity, fetchTrendForEntity, updateSelectedTimeperiod } from './view/trendWithTransactions/trendWithTransactionsReducer';
515
515
  import { TrendWithTransactionsView, getEntityDetailUIStateByEntity, getLatestTimeFrameWithTransactionsForEntity, getTrendWithTransactions } from './view/trendWithTransactions/trendWithTransactionsSelector';
516
- import { CustomerToken } from './view/twoFactorAuthentication/twoFactorAuthentication';
516
+ import { Token } from './view/twoFactorAuthentication/twoFactorAuthentication';
517
517
  import { resendOtp, sendOtp, verifyOtp } from './view/twoFactorAuthentication/twoFactorAuthenticationReducer';
518
518
  import { TwoFactorAuthenticationView, getTwoFactorAuthenticationView } from './view/twoFactorAuthentication/twoFactorAuthenticationSelector';
519
519
  import { fetchUserFinancialAccount } from './view/userFinancialAccount/userFinancialAccountReducer';
@@ -705,7 +705,7 @@ export { MilageReimbursementLine, OutofPocketReimbursementLine, ReimbursementLin
705
705
  export { AccountListSelectorView, ClassListSelectorView, getClassList };
706
706
  export { BillTab, BillsSubTabType, SaveBillStageCode, BillPayReviewSelectorView, DuplicateBillsSelectorView, EditBillDetailSelectorView, LineItemRecommendationsLocalData, EditBillInitialDetails, BillableStatus, PaymentDetailsSection, BillListReport, BillListDownloadReport, WhatForSection, fetchBillList, fetchBillListPerTab, updateTab, updateSubTab, updateSelectedBillId, updateBillDetailSaveBillCode, fetchVendorByNameAndParseInvoice, saveBillUpdatesToLocalStore, discardBillUpdatesInLocalStore, saveBillDetail, approveOrRejectBill, updateApprovalStatusOnSuccess, deleteBill, cancelAndDeleteBill, retryOrRefundBill, getBillList, getBillDownloadList, BillDetailViewSelector, ActorActivityWithUser, BillActivity, StepWithStatus, getBillDetailView, checkApproveRejectBtnShowForBill, BillDetailView, getBillTransactionDetailKey, fetchBillDetail, fetchEditBillDetailPage, fetchAndUpdateVendorRecommendations, fetchDuplicateBill, clearBillPayReview, EditBillDetail, EditBillDetailViewState, getEditBillDetail, getReviewPageBillDetail, BillDetailLocalData, PaymentDetailsSectionView, fetchBillAndInitializeLocalStore, updateShowAutofill, saveVendorSuccessOrFailure, BillPaymentStatus, BillPaymentStatusCodeType, BillPaymentRefundStatus, BillPaymentRefundStatusCodeType, BillStatus, BillStatusCodeType, BillApprovalType, updateBillListUIState, BillListUIState, BillPayViewSortKey, BillPayFilters, BillPayFilterCategory, BillListViewFilterCategoryField, BILL_PAY_FILTER_CATEGORIES, updateVendorDetailLocalData, resetVendorDetailLocalData, resetVendorSaveStatus, updateContactsInVendorDetailLocalData, updateVendorTabDetailUIState, updateContactsInVendorTabDetailLocalData, updateBillUploadFetchState, updateBillListSearchResult, fetchUserDetails, verifyUser, updateVendorContact, PaymentToOption, toPaymentToOption, convertAmountToHomeCurrency, RecurringBillInstance, RecurringBillConfigLocalData, EditRecurringBillType, fetchVendorAndUpdateBillLocalData, markBillForRetry, };
707
707
  export { SpendManagementFiltersType, SpendManagementFilterEntityType, FilterCategoryType, BillPayFilterCategoryDropdownOption, ReimbursementFilterCategoryDropdownOption, TaskFilterCategoryDropdownOption, SpendManagementFilterCategoryDropdownOption, MatchingOperatorDropdownOption, CategoryCombinationOperator, hideCreatedByFilter, };
708
- export { BillPaySetupViewState, ZeniAccountSetupViewState, BillPaySetupViewLocalData, ZeniAccountSetupViewLocalData, PlaidAccountState, fetchBillPaySetupView, fetchZeniAccountSetupView, enableSetup, getPaymentAccounts, getPlaidLinkToken, updateSelectedCompanyOfficer, updateSetupViewLocalStoreData, updateBusinessVerificationDetails, updatePaymentAccount, updatePaymentAccountLoginStatus, updatePaymentAccountStatus, establishPlaidConnection, updateMappedCashAccount, updatePrimaryFundingAccount, acceptBillPayTerms, acceptZeniAccountTerms, acceptBillPayUpdatedTerms, saveSetupViewDataInLocalStore, saveCompnayOfficerPhoneInLocalStore, saveCompnayOfficerAdditionalDocumentsInLocalStore, saveIndustryAndIncDateInLocalStore, clearSetupViewDataInLocalStore, clearBillPaySetupView, clearZeniAccountSetupView, sendOtp, resendOtp, verifyOtp, CompanyDetails, CompanyOfficersDetails, BillPaySetupView, ZeniAccountSetupView, BillPayBusinessVerificationDetails, ZeniAccountBusinessVerificationDetails, SetupViewState, SetupViewLocalData, SetupView, BusinessVerificationDetails, getBillPaySetupViewDetails, getPlaidAccountDetails, getZeniAccountSetupViewDetails, getBusinessVerificationDetails, getBillPayBusinessVerificationDetails, getZeniAccountBusinessVerificationDetails, getCommonSetupViewDetails, PlaidConnectionDetails, PlaidLinkTokenType, PlaidAccountKeyType, CustomerToken, FundingAccount, getTwoFactorAuthenticationView, TwoFactorAuthenticationView, };
708
+ export { BillPaySetupViewState, ZeniAccountSetupViewState, BillPaySetupViewLocalData, ZeniAccountSetupViewLocalData, PlaidAccountState, fetchBillPaySetupView, fetchZeniAccountSetupView, enableSetup, getPaymentAccounts, getPlaidLinkToken, updateSelectedCompanyOfficer, updateSetupViewLocalStoreData, updateBusinessVerificationDetails, updatePaymentAccount, updatePaymentAccountLoginStatus, updatePaymentAccountStatus, establishPlaidConnection, updateMappedCashAccount, updatePrimaryFundingAccount, acceptBillPayTerms, acceptZeniAccountTerms, acceptBillPayUpdatedTerms, saveSetupViewDataInLocalStore, saveCompnayOfficerPhoneInLocalStore, saveCompnayOfficerAdditionalDocumentsInLocalStore, saveIndustryAndIncDateInLocalStore, clearSetupViewDataInLocalStore, clearBillPaySetupView, clearZeniAccountSetupView, sendOtp, resendOtp, verifyOtp, CompanyDetails, CompanyOfficersDetails, BillPaySetupView, ZeniAccountSetupView, BillPayBusinessVerificationDetails, ZeniAccountBusinessVerificationDetails, SetupViewState, SetupViewLocalData, SetupView, BusinessVerificationDetails, getBillPaySetupViewDetails, getPlaidAccountDetails, getZeniAccountSetupViewDetails, getBusinessVerificationDetails, getBillPayBusinessVerificationDetails, getZeniAccountBusinessVerificationDetails, getCommonSetupViewDetails, PlaidConnectionDetails, PlaidLinkTokenType, PlaidAccountKeyType, Token, FundingAccount, getTwoFactorAuthenticationView, TwoFactorAuthenticationView, };
709
709
  export { BankConnectionsSetupView, IntegrationsView, getApprovalRuleViewDetails, getBankConnectionsSetupViewDetails, getIntegrationsView, };
710
710
  export { fetchUserFinancialAccount };
711
711
  export { getUserFinancialAccount, UserFinancialAccountSelectorView };
@@ -16,12 +16,12 @@ export interface ChargeCardDetailSelectorView extends SelectorView {
16
16
  isViewReceiptClickedImmediatelyAfterUploadTransactionId: Record<ID, boolean>;
17
17
  uiState: ChargeCardDetailUiState;
18
18
  transactionListFetchState: FetchStateAndError;
19
- twoFAView: TwoFactorAuthenticationView;
20
19
  loggedInUserPhone: string;
21
20
  updateFetchState: FetchStateAndError;
22
21
  updatePhysicalChargeCardAttemptFetchState: FetchStateAndError;
23
22
  creditAccount: CreditAccount;
24
23
  updateChargeCardLimitFetchState: FetchStateAndError;
24
+ twoFAView: TwoFactorAuthenticationView;
25
25
  chargeCard?: ChargeCardWithUser;
26
26
  }
27
27
  export declare const getChargeCardDetailView: (state: RootState, chargeCardId: ID, includeCreditAccountInfo: boolean) => ChargeCardDetailSelectorView;
@@ -17,7 +17,7 @@ const chargeCardDetail_1 = require("./chargeCardDetail");
17
17
  const getChargeCardDetailView = (state, chargeCardId, includeCreditAccountInfo) => {
18
18
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
19
19
  const { tenantState, addressState, chargeCardDetailState, chargeCardState, classState, userState, userRoleState, chargeCardConfigState, chargeCardTransactionState, chargeCardListState, } = state;
20
- const twoFactorAuthenticationView = (0, twoFactorAuthenticationSelector_1.getTwoFactorAuthenticationView)(state);
20
+ const twoFactorAuthenticationView = (0, twoFactorAuthenticationSelector_1.getTwoFactorAuthenticationViewForCardDetail)(state, chargeCardId);
21
21
  const loggedInUserId = (_b = (_a = tenantState.loggedInUser) === null || _a === void 0 ? void 0 : _a.userId) !== null && _b !== void 0 ? _b : '';
22
22
  const loggedInUserPhone = (_e = (_c = twoFactorAuthenticationView.phone) !== null && _c !== void 0 ? _c : (_d = (0, userSelector_1.getUserByUserId)(userState, loggedInUserId)) === null || _d === void 0 ? void 0 : _d.phone) !== null && _e !== void 0 ? _e : '';
23
23
  let chargeCardWithUser = undefined;
@@ -13,7 +13,7 @@ const twoFactorAuthenticationReducer_1 = require("./twoFactorAuthenticationReduc
13
13
  const resendOtpEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(twoFactorAuthenticationReducer_1.resendOtp.match), (0, operators_1.mergeMap)((action) => {
14
14
  var _a;
15
15
  const resendOtpActions = [];
16
- const { otpChallenge, twoFASource } = action.payload;
16
+ const { otpChallenge, twoFASource, entityId } = action.payload;
17
17
  const tenantState = state$.value.tenantState;
18
18
  const companyState = state$.value.companyState;
19
19
  const { currentTenantId } = tenantState;
@@ -24,12 +24,22 @@ const resendOtpEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators
24
24
  ? companyState.companiesById[companyId].companyChargeCardInfo
25
25
  .isChargeCardEnabled
26
26
  : false;
27
- const payload = {
28
- otp_challenge: otpChallenge,
29
- is_for_charge_cards: twoFASource === 'ChargeCard' ||
30
- twoFASource === 'CardUserOnboarding' ||
31
- (twoFASource === 'MyProfile' && isCardsEnabled),
32
- };
27
+ let payload;
28
+ if (twoFASource === 'ChargeCardDetail' && entityId != null) {
29
+ const chargeCardProviderId = state$.value.chargeCardState.chargeCardByID[entityId].cardProviderID;
30
+ payload = {
31
+ charge_card_provider_id: chargeCardProviderId,
32
+ otp_challenge: otpChallenge,
33
+ };
34
+ }
35
+ else {
36
+ payload = {
37
+ otp_challenge: otpChallenge,
38
+ is_for_charge_cards: twoFASource === 'ChargeCard' ||
39
+ twoFASource === 'CardUserOnboarding' ||
40
+ (twoFASource === 'MyProfile' && isCardsEnabled),
41
+ };
42
+ }
33
43
  switch (twoFASource) {
34
44
  case 'SpendManagementSetup':
35
45
  resendOtpActions.push((0, setupViewReducer_1.resendOtpSpendManagementSetUp)());
@@ -52,7 +62,11 @@ const resendOtpEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators
52
62
  .pipe((0, operators_1.mergeMap)((response) => {
53
63
  if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
54
64
  const updateActions = [
55
- (0, twoFactorAuthenticationReducer_1.sendOtpSuccess)({ otpChallenge: response.data.otp_challenge }),
65
+ (0, twoFactorAuthenticationReducer_1.sendOtpSuccess)({
66
+ otpChallenge: response.data.otp_challenge,
67
+ twoFASource,
68
+ entityId,
69
+ }),
56
70
  ];
57
71
  switch (twoFASource) {
58
72
  case 'SpendManagementSetup':
@@ -85,7 +99,7 @@ const resendOtpEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators
85
99
  }
86
100
  else {
87
101
  const updateActions = [
88
- (0, twoFactorAuthenticationReducer_1.sendOtpFailure)(response.status),
102
+ (0, twoFactorAuthenticationReducer_1.sendOtpFailure)({ error: response.status, twoFASource, entityId }),
89
103
  ];
90
104
  switch (twoFASource) {
91
105
  case 'SpendManagementSetup':
@@ -108,7 +122,9 @@ const resendOtpEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators
108
122
  }
109
123
  }), (0, operators_1.catchError)((error) => {
110
124
  const zeniAPIStatus = (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Resend otp api errored out' + JSON.stringify(error));
111
- const updateActions = [(0, twoFactorAuthenticationReducer_1.sendOtpFailure)(zeniAPIStatus)];
125
+ const updateActions = [
126
+ (0, twoFactorAuthenticationReducer_1.sendOtpFailure)({ error: zeniAPIStatus, twoFASource, entityId }),
127
+ ];
112
128
  switch (twoFASource) {
113
129
  case 'SpendManagementSetup':
114
130
  updateActions.push((0, setupViewReducer_1.sendOtpFailureSpendManagementSetUp)(zeniAPIStatus));
@@ -13,7 +13,7 @@ const twoFactorAuthenticationReducer_1 = require("./twoFactorAuthenticationReduc
13
13
  const sendOtpEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(twoFactorAuthenticationReducer_1.sendOtp.match), (0, operators_1.mergeMap)((action) => {
14
14
  var _a;
15
15
  const sendOtpActions = [];
16
- const { phoneNumber, twoFASource } = action.payload;
16
+ const { phoneNumber, twoFASource, entityId } = action.payload;
17
17
  const tenantState = state$.value.tenantState;
18
18
  const companyState = state$.value.companyState;
19
19
  const { currentTenantId } = tenantState;
@@ -24,15 +24,20 @@ const sendOtpEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1
24
24
  ? companyState.companiesById[companyId].companyChargeCardInfo
25
25
  .isChargeCardEnabled
26
26
  : false;
27
- const queryPayload = {
27
+ let queryPayload = {
28
28
  channel_type: 'phone',
29
29
  channel_info: {
30
30
  phone_number: phoneNumber,
31
31
  },
32
32
  is_for_charge_cards: twoFASource === 'ChargeCard' ||
33
33
  twoFASource === 'CardUserOnboarding' ||
34
+ twoFASource === 'ChargeCardDetail' ||
34
35
  (twoFASource === 'MyProfile' && isCardsEnabled),
35
36
  };
37
+ if (twoFASource === 'ChargeCardDetail' && entityId != null) {
38
+ const chargeCardProviderId = state$.value.chargeCardState.chargeCardByID[entityId].cardProviderID;
39
+ queryPayload = Object.assign(Object.assign({}, queryPayload), { charge_card_provider_id: chargeCardProviderId });
40
+ }
36
41
  switch (twoFASource) {
37
42
  case 'SpendManagementSetup':
38
43
  sendOtpActions.push((0, setupViewReducer_1.sendOtpSpendManagementSetUp)());
@@ -55,7 +60,11 @@ const sendOtpEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1
55
60
  .pipe((0, operators_1.mergeMap)((response) => {
56
61
  if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
57
62
  const updateActions = [
58
- (0, twoFactorAuthenticationReducer_1.sendOtpSuccess)({ otpChallenge: response.data.otp_challenge }),
63
+ (0, twoFactorAuthenticationReducer_1.sendOtpSuccess)({
64
+ otpChallenge: response.data.otp_challenge,
65
+ twoFASource,
66
+ entityId,
67
+ }),
59
68
  ];
60
69
  switch (twoFASource) {
61
70
  case 'SpendManagementSetup':
@@ -88,7 +97,7 @@ const sendOtpEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1
88
97
  }
89
98
  else {
90
99
  const updateActions = [
91
- (0, twoFactorAuthenticationReducer_1.sendOtpFailure)(response.status),
100
+ (0, twoFactorAuthenticationReducer_1.sendOtpFailure)({ error: response.status, twoFASource, entityId }),
92
101
  ];
93
102
  switch (twoFASource) {
94
103
  case 'SpendManagementSetup':
@@ -111,7 +120,9 @@ const sendOtpEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1
111
120
  }
112
121
  }), (0, operators_1.catchError)((error) => {
113
122
  const zeniAPIStatus = (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Send otp api errored out' + JSON.stringify(error));
114
- const updateActions = [(0, twoFactorAuthenticationReducer_1.sendOtpFailure)(zeniAPIStatus)];
123
+ const updateActions = [
124
+ (0, twoFactorAuthenticationReducer_1.sendOtpFailure)({ error: zeniAPIStatus, twoFASource, entityId }),
125
+ ];
115
126
  switch (twoFASource) {
116
127
  case 'SpendManagementSetup':
117
128
  updateActions.push((0, setupViewReducer_1.sendOtpFailureSpendManagementSetUp)(zeniAPIStatus));
@@ -1,16 +1,27 @@
1
- import { FetchStateAndError } from '../../commonStateTypes/common';
1
+ import { FetchStateAndError, ID } from '../../commonStateTypes/common';
2
2
  import { ZeniDate } from '../../zeniDayJS';
3
- export interface TwoFactorAuthenticationState {
3
+ export interface TwoFactorAuthentication {
4
4
  sendOtpStatus: FetchStateAndError;
5
5
  otpVerificationStatus: FetchStateAndError;
6
- customerToken?: CustomerToken;
6
+ token?: Token;
7
7
  phone?: string;
8
8
  otpChallenge?: string;
9
9
  }
10
- export type TwoFASourceView = 'BillPayVendor' | 'ChargeCard' | 'SpendManagementSetup' | 'CardUserOnboarding' | 'MyProfile' | 'CustomerOnboarding';
11
- export interface CustomerToken {
10
+ export declare const defaultTwoFactorAuthenticationState: TwoFactorAuthentication;
11
+ export interface TwoFactorAuthenticationState {
12
+ twoFactorAuthenticationBySource: {
13
+ common: TwoFactorAuthentication;
14
+ chargeCardDetail: Record<ID, TwoFactorAuthentication>;
15
+ };
16
+ }
17
+ export declare const COMMON_TWO_FA_SOURCE: readonly ["BillPayVendor", "ChargeCard", "SpendManagementSetup", "CardUserOnboarding", "MyProfile", "CustomerOnboarding"];
18
+ export declare const toCommonTwoFASource: (v: string) => "CardUserOnboarding" | "MyProfile" | "BillPayVendor" | "ChargeCard" | "SpendManagementSetup" | "CustomerOnboarding";
19
+ export type CommonTwoFASource = ReturnType<typeof toCommonTwoFASource>;
20
+ export type TwoFASourceView = CommonTwoFASource | 'ChargeCardDetail';
21
+ export interface Token {
12
22
  provider: string;
13
23
  token: string;
14
24
  expiry: ZeniDate;
15
25
  message: string;
16
26
  }
27
+ export declare const initialTwoFactorAuthentication: TwoFactorAuthentication;
@@ -1,2 +1,37 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.initialTwoFactorAuthentication = exports.toCommonTwoFASource = exports.COMMON_TWO_FA_SOURCE = exports.defaultTwoFactorAuthenticationState = void 0;
4
+ const stringToUnion_1 = require("../../commonStateTypes/stringToUnion");
5
+ exports.defaultTwoFactorAuthenticationState = {
6
+ sendOtpStatus: {
7
+ fetchState: 'Not-Started',
8
+ error: undefined,
9
+ },
10
+ otpVerificationStatus: {
11
+ fetchState: 'Not-Started',
12
+ error: undefined,
13
+ },
14
+ };
15
+ exports.COMMON_TWO_FA_SOURCE = [
16
+ 'BillPayVendor',
17
+ 'ChargeCard',
18
+ 'SpendManagementSetup',
19
+ 'CardUserOnboarding',
20
+ 'MyProfile',
21
+ 'CustomerOnboarding',
22
+ ];
23
+ const toCommonTwoFASource = (v) => (0, stringToUnion_1.stringToUnion)(v, exports.COMMON_TWO_FA_SOURCE);
24
+ exports.toCommonTwoFASource = toCommonTwoFASource;
25
+ exports.initialTwoFactorAuthentication = {
26
+ sendOtpStatus: {
27
+ fetchState: 'Not-Started',
28
+ error: undefined,
29
+ },
30
+ otpVerificationStatus: {
31
+ fetchState: 'Not-Started',
32
+ error: undefined,
33
+ },
34
+ token: undefined,
35
+ phone: undefined,
36
+ otpChallenge: undefined,
37
+ };
@@ -1,5 +1,5 @@
1
1
  import { ZeniAPIResponse } from '../../responsePayload';
2
- import { CustomerToken } from './twoFactorAuthentication';
2
+ import { Token } from './twoFactorAuthentication';
3
3
  interface SendOtpPayload {
4
4
  otp_challenge: string;
5
5
  }
@@ -7,14 +7,14 @@ export type SendOtpResponse = ZeniAPIResponse<SendOtpPayload>;
7
7
  interface VerifyOtpPayload {
8
8
  is_verified: boolean;
9
9
  message: string;
10
- customer_token_info?: CustomerTokenPayload;
10
+ token_info?: TokenPayload;
11
11
  }
12
- export interface CustomerTokenPayload {
13
- customer_token_provider: string;
14
- customer_token: string;
15
- customer_token_expiration_time: string;
12
+ export interface TokenPayload {
13
+ token_provider: string;
14
+ token: string;
15
+ token_expiration_time: string;
16
16
  message: string;
17
17
  }
18
18
  export type VerifyOtpResponse = ZeniAPIResponse<VerifyOtpPayload>;
19
- export declare const toCustomerToken: (payload: CustomerTokenPayload) => CustomerToken;
19
+ export declare const toToken: (payload: TokenPayload) => Token;
20
20
  export {};
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toCustomerToken = void 0;
3
+ exports.toToken = void 0;
4
4
  const zeniDayJS_1 = require("../../zeniDayJS");
5
- const toCustomerToken = (payload) => ({
6
- provider: payload.customer_token_provider,
7
- token: payload.customer_token,
8
- expiry: (0, zeniDayJS_1.date)(payload.customer_token_expiration_time),
5
+ const toToken = (payload) => ({
6
+ provider: payload.token_provider,
7
+ token: payload.token,
8
+ expiry: (0, zeniDayJS_1.date)(payload.token_expiration_time),
9
9
  message: payload.message,
10
10
  });
11
- exports.toCustomerToken = toCustomerToken;
11
+ exports.toToken = toToken;
@@ -1,21 +1,37 @@
1
+ import { ID } from '../../commonStateTypes/common';
1
2
  import { ZeniAPIStatus } from '../../responsePayload';
2
3
  import { TwoFASourceView, TwoFactorAuthenticationState } from './twoFactorAuthentication';
3
- import { CustomerTokenPayload } from './twoFactorAuthenticationPayload';
4
+ import { TokenPayload } from './twoFactorAuthenticationPayload';
4
5
  export declare const initialState: TwoFactorAuthenticationState;
5
- export declare const sendOtp: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[phoneNumber: string, twoFASource: TwoFASourceView], {
6
+ export declare const sendOtp: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[phoneNumber: string, twoFASource: TwoFASourceView, entityId?: string | undefined], {
6
7
  phoneNumber: string;
7
8
  twoFASource: TwoFASourceView;
8
- }, "twoFactorAuthentication/sendOtp", never, never>, resendOtp: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[otpChallenge: string, twoFASource: TwoFASourceView], {
9
+ entityId: string | undefined;
10
+ }, "twoFactorAuthentication/sendOtp", never, never>, resendOtp: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[otpChallenge: string, twoFASource: TwoFASourceView, entityId?: string | undefined], {
9
11
  otpChallenge: string;
10
12
  twoFASource: TwoFASourceView;
13
+ entityId: string | undefined;
11
14
  }, "twoFactorAuthentication/resendOtp", never, never>, sendOtpSuccess: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
12
15
  otpChallenge: string;
13
- }, "twoFactorAuthentication/sendOtpSuccess">, sendOtpFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "twoFactorAuthentication/sendOtpFailure">, verifyOtp: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[otpCode: string, otpChallenge: string, twoFASource: TwoFASourceView], {
16
+ twoFASource: TwoFASourceView;
17
+ entityId?: ID;
18
+ }, "twoFactorAuthentication/sendOtpSuccess">, sendOtpFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
19
+ error: ZeniAPIStatus;
20
+ twoFASource: TwoFASourceView;
21
+ entityId?: ID;
22
+ }, "twoFactorAuthentication/sendOtpFailure">, verifyOtp: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[otpCode: string, otpChallenge: string, twoFASource: TwoFASourceView, entityId?: string | undefined], {
14
23
  otpCode: string;
15
24
  otpChallenge: string;
16
25
  twoFASource: TwoFASourceView;
26
+ entityId: string | undefined;
17
27
  }, "twoFactorAuthentication/verifyOtp", never, never>, verifyOtpSuccess: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
18
- customerTokenPayload: CustomerTokenPayload | undefined;
19
- }, "twoFactorAuthentication/verifyOtpSuccess">, verifyOtpFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "twoFactorAuthentication/verifyOtpFailure">, clearTwoFactorAuthentication: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"twoFactorAuthentication/clearTwoFactorAuthentication">;
28
+ twoFASource: TwoFASourceView;
29
+ entityId?: ID;
30
+ tokenPayload: TokenPayload | undefined;
31
+ }, "twoFactorAuthentication/verifyOtpSuccess">, verifyOtpFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
32
+ error: ZeniAPIStatus;
33
+ twoFASource: TwoFASourceView;
34
+ entityId?: ID;
35
+ }, "twoFactorAuthentication/verifyOtpFailure">, clearTwoFactorAuthentication: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"twoFactorAuthentication/clearTwoFactorAuthentication">;
20
36
  declare const _default: import("redux").Reducer<TwoFactorAuthenticationState>;
21
37
  export default _default;
@@ -3,19 +3,13 @@ var _a;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.clearTwoFactorAuthentication = exports.verifyOtpFailure = exports.verifyOtpSuccess = exports.verifyOtp = exports.sendOtpFailure = exports.sendOtpSuccess = exports.resendOtp = exports.sendOtp = exports.initialState = void 0;
5
5
  const toolkit_1 = require("@reduxjs/toolkit");
6
+ const twoFactorAuthentication_1 = require("./twoFactorAuthentication");
6
7
  const twoFactorAuthenticationPayload_1 = require("./twoFactorAuthenticationPayload");
7
8
  exports.initialState = {
8
- sendOtpStatus: {
9
- fetchState: 'Not-Started',
10
- error: undefined,
9
+ twoFactorAuthenticationBySource: {
10
+ common: twoFactorAuthentication_1.initialTwoFactorAuthentication,
11
+ chargeCardDetail: {},
11
12
  },
12
- otpVerificationStatus: {
13
- fetchState: 'Not-Started',
14
- error: undefined,
15
- },
16
- customerToken: undefined,
17
- phone: undefined,
18
- otpChallenge: undefined,
19
13
  };
20
14
  const twoFactorAuthentication = (0, toolkit_1.createSlice)({
21
15
  name: 'twoFactorAuthentication',
@@ -23,74 +17,147 @@ const twoFactorAuthentication = (0, toolkit_1.createSlice)({
23
17
  reducers: {
24
18
  sendOtp: {
25
19
  reducer(draft, action) {
26
- draft.phone = action.payload.phoneNumber;
27
- draft.sendOtpStatus = {
28
- fetchState: 'In-Progress',
29
- error: undefined,
30
- };
31
- draft.otpVerificationStatus = {
32
- fetchState: 'Not-Started',
33
- error: undefined,
34
- };
20
+ const { twoFASource, phoneNumber, entityId } = action.payload;
21
+ if (twoFASource === 'ChargeCardDetail' && entityId != null) {
22
+ draft.twoFactorAuthenticationBySource.chargeCardDetail[entityId] = Object.assign(Object.assign({}, draft.twoFactorAuthenticationBySource.chargeCardDetail[entityId]), { phone: phoneNumber, sendOtpStatus: {
23
+ fetchState: 'In-Progress',
24
+ error: undefined,
25
+ }, otpVerificationStatus: {
26
+ fetchState: 'Not-Started',
27
+ error: undefined,
28
+ } });
29
+ }
30
+ else {
31
+ draft.twoFactorAuthenticationBySource.common.phone = phoneNumber;
32
+ draft.twoFactorAuthenticationBySource.common.sendOtpStatus = {
33
+ fetchState: 'In-Progress',
34
+ error: undefined,
35
+ };
36
+ draft.twoFactorAuthenticationBySource.common.otpVerificationStatus = {
37
+ fetchState: 'Not-Started',
38
+ error: undefined,
39
+ };
40
+ }
35
41
  },
36
- prepare(phoneNumber, twoFASource) {
37
- return { payload: { phoneNumber, twoFASource } };
42
+ prepare(phoneNumber, twoFASource, entityId) {
43
+ return { payload: { phoneNumber, twoFASource, entityId } };
38
44
  },
39
45
  },
40
46
  resendOtp: {
41
- reducer(draft) {
42
- draft.sendOtpStatus = {
43
- fetchState: 'In-Progress',
44
- error: undefined,
45
- };
46
- draft.otpVerificationStatus = {
47
- fetchState: 'Not-Started',
48
- error: undefined,
49
- };
47
+ reducer(draft, action) {
48
+ const { twoFASource, entityId } = action.payload;
49
+ if (twoFASource === 'ChargeCardDetail' && entityId != null) {
50
+ draft.twoFactorAuthenticationBySource.chargeCardDetail[entityId] = Object.assign(Object.assign({}, draft.twoFactorAuthenticationBySource.chargeCardDetail[entityId]), { sendOtpStatus: {
51
+ fetchState: 'In-Progress',
52
+ error: undefined,
53
+ }, otpVerificationStatus: {
54
+ fetchState: 'Not-Started',
55
+ error: undefined,
56
+ } });
57
+ }
58
+ else {
59
+ draft.twoFactorAuthenticationBySource.common.sendOtpStatus = {
60
+ fetchState: 'In-Progress',
61
+ error: undefined,
62
+ };
63
+ draft.twoFactorAuthenticationBySource.common.otpVerificationStatus = {
64
+ fetchState: 'Not-Started',
65
+ error: undefined,
66
+ };
67
+ }
50
68
  },
51
- prepare(otpChallenge, twoFASource) {
52
- return { payload: { otpChallenge, twoFASource } };
69
+ prepare(otpChallenge, twoFASource, entityId) {
70
+ return { payload: { otpChallenge, twoFASource, entityId } };
53
71
  },
54
72
  },
55
73
  sendOtpSuccess(draft, action) {
56
- draft.otpChallenge = action.payload.otpChallenge;
57
- draft.sendOtpStatus = {
58
- fetchState: 'Completed',
59
- error: undefined,
60
- };
74
+ const { twoFASource, otpChallenge, entityId } = action.payload;
75
+ if (twoFASource === 'ChargeCardDetail' && entityId != null) {
76
+ draft.twoFactorAuthenticationBySource.chargeCardDetail[entityId] = Object.assign(Object.assign({}, draft.twoFactorAuthenticationBySource.chargeCardDetail[entityId]), { otpChallenge, sendOtpStatus: {
77
+ fetchState: 'Completed',
78
+ error: undefined,
79
+ } });
80
+ }
81
+ else {
82
+ draft.twoFactorAuthenticationBySource.common.otpChallenge =
83
+ otpChallenge;
84
+ draft.twoFactorAuthenticationBySource.common.sendOtpStatus = {
85
+ fetchState: 'Completed',
86
+ error: undefined,
87
+ };
88
+ }
61
89
  },
62
90
  sendOtpFailure(draft, action) {
63
- draft.sendOtpStatus = {
64
- fetchState: 'Error',
65
- error: action.payload,
66
- };
91
+ const { error, twoFASource, entityId } = action.payload;
92
+ if (twoFASource === 'ChargeCardDetail' && entityId != null) {
93
+ draft.twoFactorAuthenticationBySource.chargeCardDetail[entityId] = Object.assign(Object.assign({}, draft.twoFactorAuthenticationBySource.chargeCardDetail[entityId]), { sendOtpStatus: {
94
+ fetchState: 'Error',
95
+ error,
96
+ } });
97
+ }
98
+ else {
99
+ draft.twoFactorAuthenticationBySource.common.sendOtpStatus = {
100
+ fetchState: 'Error',
101
+ error,
102
+ };
103
+ }
67
104
  },
68
105
  verifyOtp: {
69
- reducer(draft) {
70
- draft.otpVerificationStatus = {
71
- fetchState: 'In-Progress',
72
- error: undefined,
73
- };
106
+ reducer(draft, action) {
107
+ const { twoFASource, entityId } = action.payload;
108
+ if (twoFASource === 'ChargeCardDetail' && entityId != null) {
109
+ draft.twoFactorAuthenticationBySource.chargeCardDetail[entityId] = Object.assign(Object.assign({}, draft.twoFactorAuthenticationBySource.chargeCardDetail[entityId]), { otpVerificationStatus: {
110
+ fetchState: 'In-Progress',
111
+ error: undefined,
112
+ } });
113
+ }
114
+ else {
115
+ draft.twoFactorAuthenticationBySource.common.otpVerificationStatus = {
116
+ fetchState: 'In-Progress',
117
+ error: undefined,
118
+ };
119
+ }
74
120
  },
75
- prepare(otpCode, otpChallenge, twoFASource) {
76
- return { payload: { otpCode, otpChallenge, twoFASource } };
121
+ prepare(otpCode, otpChallenge, twoFASource, entityId) {
122
+ return { payload: { otpCode, otpChallenge, twoFASource, entityId } };
77
123
  },
78
124
  },
79
125
  verifyOtpSuccess(draft, action) {
80
- const { customerTokenPayload } = action.payload;
81
- if (customerTokenPayload != null) {
82
- draft.customerToken = (0, twoFactorAuthenticationPayload_1.toCustomerToken)(customerTokenPayload);
126
+ const { tokenPayload, twoFASource, entityId } = action.payload;
127
+ if (twoFASource === 'ChargeCardDetail' && entityId != null) {
128
+ draft.twoFactorAuthenticationBySource.chargeCardDetail[entityId] = Object.assign(Object.assign({}, draft.twoFactorAuthenticationBySource.chargeCardDetail[entityId]), { otpVerificationStatus: {
129
+ fetchState: 'Completed',
130
+ error: undefined,
131
+ } });
132
+ if (tokenPayload != null) {
133
+ draft.twoFactorAuthenticationBySource.chargeCardDetail[entityId].token = (0, twoFactorAuthenticationPayload_1.toToken)(tokenPayload);
134
+ }
135
+ }
136
+ else {
137
+ if (tokenPayload != null) {
138
+ draft.twoFactorAuthenticationBySource.common.token =
139
+ (0, twoFactorAuthenticationPayload_1.toToken)(tokenPayload);
140
+ }
141
+ draft.twoFactorAuthenticationBySource.common.otpVerificationStatus = {
142
+ fetchState: 'Completed',
143
+ error: undefined,
144
+ };
83
145
  }
84
- draft.otpVerificationStatus = {
85
- fetchState: 'Completed',
86
- error: undefined,
87
- };
88
146
  },
89
147
  verifyOtpFailure(draft, action) {
90
- draft.otpVerificationStatus = {
91
- fetchState: 'Error',
92
- error: action.payload,
93
- };
148
+ const { error, twoFASource, entityId } = action.payload;
149
+ if (twoFASource === 'ChargeCardDetail' && entityId != null) {
150
+ draft.twoFactorAuthenticationBySource.chargeCardDetail[entityId].otpVerificationStatus = {
151
+ fetchState: 'Error',
152
+ error,
153
+ };
154
+ }
155
+ else {
156
+ draft.twoFactorAuthenticationBySource.common.otpVerificationStatus = {
157
+ fetchState: 'Error',
158
+ error,
159
+ };
160
+ }
94
161
  },
95
162
  clearTwoFactorAuthentication(draft) {
96
163
  Object.assign(draft, exports.initialState);
@@ -1,12 +1,13 @@
1
- import { FetchStateAndError } from '../../commonStateTypes/common';
1
+ import { FetchStateAndError, ID } from '../../commonStateTypes/common';
2
2
  import { View } from '../../commonStateTypes/viewAndReport/viewAndReport';
3
3
  import { RootState } from '../../reducer';
4
- import { CustomerToken } from './twoFactorAuthentication';
4
+ import { Token } from './twoFactorAuthentication';
5
5
  export interface TwoFactorAuthenticationView extends View {
6
6
  sendOtpStatus: FetchStateAndError;
7
7
  otpVerificationStatus: FetchStateAndError;
8
- customerToken?: CustomerToken;
8
+ token?: Token;
9
9
  phone?: string;
10
10
  otpChallenge?: string;
11
11
  }
12
12
  export declare const getTwoFactorAuthenticationView: (state: RootState) => TwoFactorAuthenticationView;
13
+ export declare const getTwoFactorAuthenticationViewForCardDetail: (state: RootState, cardId: ID) => TwoFactorAuthenticationView;
@@ -1,7 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getTwoFactorAuthenticationView = void 0;
3
+ exports.getTwoFactorAuthenticationViewForCardDetail = exports.getTwoFactorAuthenticationView = void 0;
4
4
  const toolkit_1 = require("@reduxjs/toolkit");
5
+ const twoFactorAuthentication_1 = require("./twoFactorAuthentication");
5
6
  exports.getTwoFactorAuthenticationView = (0, toolkit_1.createSelector)((state) => state.twoFactorAuthenticationState, (twoFAState) => {
6
- return Object.assign({}, twoFAState);
7
+ return Object.assign({}, twoFAState.twoFactorAuthenticationBySource.common);
7
8
  });
9
+ const getTwoFactorAuthenticationViewForCardDetail = (state, cardId) => {
10
+ var _a;
11
+ return (_a = state.twoFactorAuthenticationState.twoFactorAuthenticationBySource
12
+ .chargeCardDetail[cardId]) !== null && _a !== void 0 ? _a : twoFactorAuthentication_1.defaultTwoFactorAuthenticationState;
13
+ };
14
+ exports.getTwoFactorAuthenticationViewForCardDetail = getTwoFactorAuthenticationViewForCardDetail;
@@ -9,4 +9,4 @@ import { verifyOtpCardUserOnboarding, verifyOtpCardUserOnboardingFailure, verify
9
9
  import { verifyOtpFailureSpendManagementSetUp, verifyOtpSpendManagementSetUp, verifyOtpSuccessSpendManagementSetUp } from '../spendManagement/commonSetup/setupViewReducer';
10
10
  import { verifyOtp, verifyOtpFailure, verifyOtpSuccess } from './twoFactorAuthenticationReducer';
11
11
  export type ActionType = ReturnType<typeof verifyOtp> | ReturnType<typeof verifyOtpSuccess> | ReturnType<typeof verifyOtpFailure> | ReturnType<typeof verifyOtpSpendManagementSetUp> | ReturnType<typeof verifyOtpSuccessSpendManagementSetUp> | ReturnType<typeof verifyOtpFailureSpendManagementSetUp> | ReturnType<typeof verifyOtpVendorView> | ReturnType<typeof verifyOtpVendorViewSuccess> | ReturnType<typeof verifyOtpVendorViewFailure> | ReturnType<typeof verifyOnboardingOfficerOtp> | ReturnType<typeof verifyOnboardingOfficerOtpSuccess> | ReturnType<typeof verifyOnboardingOfficerOtpFailure> | ReturnType<typeof verifyOtpCardUserOnboarding> | ReturnType<typeof verifyOtpCardUserOnboardingSuccess> | ReturnType<typeof verifyOtpCardUserOnboardingFailure> | ReturnType<typeof verifyOtpMyProfile> | ReturnType<typeof verifyOtpMyProfileFailure> | ReturnType<typeof verifyOtpMyProfileSuccess>;
12
- export declare const verifyOtpEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
12
+ export declare const verifyOtpEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -10,13 +10,17 @@ const settingsViewReducer_1 = require("../settingsView/settingsViewReducer");
10
10
  const cardUserOnboardingReducer_1 = require("../spendManagement/chargeCards/cardUserOnboarding/cardUserOnboardingReducer");
11
11
  const setupViewReducer_1 = require("../spendManagement/commonSetup/setupViewReducer");
12
12
  const twoFactorAuthenticationReducer_1 = require("./twoFactorAuthenticationReducer");
13
- const verifyOtpEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(twoFactorAuthenticationReducer_1.verifyOtp.match), (0, operators_1.mergeMap)((action) => {
13
+ const verifyOtpEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(twoFactorAuthenticationReducer_1.verifyOtp.match), (0, operators_1.mergeMap)((action) => {
14
14
  const verifyOtpActions = [];
15
- const { otpCode, otpChallenge, twoFASource } = action.payload;
16
- const payload = {
15
+ const { otpCode, otpChallenge, twoFASource, entityId } = action.payload;
16
+ let payload = {
17
17
  otp_code: otpCode,
18
18
  otp_challenge: otpChallenge,
19
19
  };
20
+ if (twoFASource === 'ChargeCardDetail' && entityId != null) {
21
+ const chargeCardProviderId = state$.value.chargeCardState.chargeCardByID[entityId].cardProviderID;
22
+ payload = Object.assign(Object.assign({}, payload), { charge_card_provider_id: chargeCardProviderId });
23
+ }
20
24
  switch (twoFASource) {
21
25
  case 'SpendManagementSetup':
22
26
  verifyOtpActions.push((0, setupViewReducer_1.verifyOtpSpendManagementSetUp)());
@@ -42,7 +46,9 @@ const verifyOtpEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operator
42
46
  response.data.is_verified === true) {
43
47
  const updateActions = [
44
48
  (0, twoFactorAuthenticationReducer_1.verifyOtpSuccess)({
45
- customerTokenPayload: response.data.customer_token_info,
49
+ tokenPayload: response.data.token_info,
50
+ twoFASource,
51
+ entityId,
46
52
  }),
47
53
  ];
48
54
  switch (twoFASource) {
@@ -66,7 +72,11 @@ const verifyOtpEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operator
66
72
  }
67
73
  else {
68
74
  const updateActions = [
69
- (0, twoFactorAuthenticationReducer_1.verifyOtpFailure)(response.status),
75
+ (0, twoFactorAuthenticationReducer_1.verifyOtpFailure)({
76
+ error: response.status,
77
+ twoFASource,
78
+ entityId,
79
+ }),
70
80
  ];
71
81
  switch (twoFASource) {
72
82
  case 'SpendManagementSetup':
@@ -90,7 +100,7 @@ const verifyOtpEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operator
90
100
  }), (0, operators_1.catchError)((error) => {
91
101
  const zeniAPIStatus = (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Verify otp api errored out' + JSON.stringify(error));
92
102
  const updateActions = [
93
- (0, twoFactorAuthenticationReducer_1.verifyOtpFailure)(zeniAPIStatus),
103
+ (0, twoFactorAuthenticationReducer_1.verifyOtpFailure)({ error: zeniAPIStatus, twoFASource, entityId }),
94
104
  ];
95
105
  switch (twoFASource) {
96
106
  case 'SpendManagementSetup':
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "4.14.90",
3
+ "version": "4.14.91",
4
4
  "description": "Shared module between Web & Mobile containing required abstractions for state management, async network communication. ",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",