@zeniai/client-epic-state 5.0.31 → 5.0.32-betaRD2

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.
Files changed (35) hide show
  1. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  2. package/lib/entity/snackbar/snackbarTypes.js +2 -0
  3. package/lib/entity/tenant/clearAllEpic.d.ts +2 -1
  4. package/lib/entity/tenant/clearAllEpic.js +2 -0
  5. package/lib/entity/transaction/payloadTypes/transactionLinePayload.js +1 -1
  6. package/lib/epic.d.ts +2 -1
  7. package/lib/epic.js +2 -1
  8. package/lib/esm/entity/snackbar/snackbarTypes.js +2 -0
  9. package/lib/esm/entity/tenant/clearAllEpic.js +2 -0
  10. package/lib/esm/entity/transaction/payloadTypes/transactionLinePayload.js +1 -1
  11. package/lib/esm/epic.js +2 -1
  12. package/lib/esm/index.js +4 -0
  13. package/lib/esm/reducer.js +3 -0
  14. package/lib/esm/view/zeniOAuthView/epics/approveOAuthConsentEpic.js +60 -0
  15. package/lib/esm/view/zeniOAuthView/zeniOAuthParamsParser.js +41 -0
  16. package/lib/esm/view/zeniOAuthView/zeniOAuthReducer.js +49 -0
  17. package/lib/esm/view/zeniOAuthView/zeniOAuthSelector.js +3 -0
  18. package/lib/esm/view/zeniOAuthView/zeniOAuthState.js +1 -0
  19. package/lib/index.d.ts +5 -0
  20. package/lib/index.js +16 -4
  21. package/lib/reducer.d.ts +3 -0
  22. package/lib/reducer.js +3 -0
  23. package/lib/tsconfig.typecheck.tsbuildinfo +1 -1
  24. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  25. package/lib/view/zeniOAuthView/epics/approveOAuthConsentEpic.d.ts +27 -0
  26. package/lib/view/zeniOAuthView/epics/approveOAuthConsentEpic.js +64 -0
  27. package/lib/view/zeniOAuthView/zeniOAuthParamsParser.d.ts +16 -0
  28. package/lib/view/zeniOAuthView/zeniOAuthParamsParser.js +44 -0
  29. package/lib/view/zeniOAuthView/zeniOAuthReducer.d.ts +29 -0
  30. package/lib/view/zeniOAuthView/zeniOAuthReducer.js +53 -0
  31. package/lib/view/zeniOAuthView/zeniOAuthSelector.d.ts +5 -0
  32. package/lib/view/zeniOAuthView/zeniOAuthSelector.js +9 -0
  33. package/lib/view/zeniOAuthView/zeniOAuthState.d.ts +4 -0
  34. package/lib/view/zeniOAuthView/zeniOAuthState.js +2 -0
  35. package/package.json +1 -1
@@ -37,7 +37,7 @@ export declare const getLineItemsByTransactionsIdsFromResponse: (transactions: S
37
37
  export declare const getLineItemsByTransactionIdsFromLocalData: (transactionLocalData: TransactionReviewLocalDataSelectorView[], selectedTab: TransactionsTab) => Record<ID, string[]>;
38
38
  export declare const mergeTabSpecificLineItems: (currentTabSpecificLineItems: TabSpecificLineItems, selectedTab: TransactionsTab, newLineItems: TabSpecificLineItems) => TabSpecificLineItems;
39
39
  export declare const getSnackbarMessageForTransactionReview: (updatedCount: number, failedCount: number, categorizedCount: number) => {
40
- messageSection: "common" | "transactionDetails_updatingPastTransactions" | "transactionDetails_transactionUpdated" | "cockpit_month_end_email_sent" | "cockpit_month_end_email_save" | "cockpit_month_end_email_attachment_upload" | "je_bill_link" | "je_posted" | "audit_score_updated" | "people_invite_people" | "people_invite_multiple_people" | "people_delete_person" | "people_update_person" | "reimbursement_updated" | "reimbursement_deleted" | "reimbursement_cancelled_deleted" | "reimbursement_cancelled" | "reimbursement_approved" | "reimbursement_rejected" | "reimbursement_sent_for_approval" | "account_added" | "business_verification_save" | "business_verification_submit" | "business_verification_from_bills_submit" | "plaid_connection" | "unlink_deposit_account" | "reimbursement_setup" | "reimbursement_approval_create" | "reimbursement_duplicate_approval_create" | "reimbursement_approval_update" | "reimbursement_duplicate_approval_update" | "reimbursement_approval_delete" | "reimbursement_create_mileage" | "reimbursement_update_mileage" | "reimbursement_accept_term" | "reimbursement_accept_employee_term" | "reimbursement_bulk_submit" | "reimbursement_bulk_processed" | "bill_pay_setup" | "zeni_accounts_setup" | "bill_pay_approval_create" | "bill_pay_duplicate_approval_create" | "bill_pay_approval_update" | "bill_pay_duplicate_approval_update" | "bill_pay_approval_delete" | "bill_pay_updated" | "bill_pay_deleted" | "bill_pay_cancelled_deleted" | "bill_pay_cancelled" | "bill_pay_approved" | "real_time_approver_added" | "bill_pay_rejected" | "bill_pay_sent_for_approval" | "bill_pay_accept_term" | "bill_pay_bulk_submit" | "bill_pay_bulk_processed" | "bill_pay_refund" | "bill_pay_retry" | "bill_pay_marked_as_paid" | "zeni_account_accept_term" | "update_vendor" | "data_refresh_update" | "delete_bank_account" | "create_bank_account" | "create_bank_account_ach" | "create_bank_account_wire" | "create_bank_account_international" | "transfer_money" | "update_zeni_account_nickname" | "create_checking_account" | "deposit_check" | "create_vendor" | "onboarding_customer_view" | "onboarding_customer_view_complete" | "onboarding_customer_identity_verification_save" | "onboarding_customer_identity_verification_submit" | "onboarding_customer_business_verification_save" | "onboarding_customer_business_verification_submit" | "retry_bank_account_connection" | "dashboard_invite_sent" | "onboarding_info_saved" | "approve_original_merchant" | "approve_global_merchant" | "reject_global_merchant" | "create_global_merchant" | "fetch_global_merchant_no_recommendation" | "save_vendor_renamed" | "save_vendor_sent_for_review" | "save_vendor_marked_as_employee" | "save_vendor_marked_as_local_contractor" | "charge_card_setup" | "charge_card_accept_term" | "charge_card_receipt_upload" | "charge_card_resend_invite" | "charge_card_revoke_invite" | "charge_card_update_limit" | "charge_cards_update_limit" | "close_charge_card" | "lock_charge_card" | "lock_charge_card_card_user" | "lock_charge_cards" | "unlock_charge_card" | "unlock_charge_card_card_user" | "unlock_charge_cards" | "close_charge_cards" | "revoke_invite_charge_cards" | "charge_card_express_interest" | "create_schedule" | "save_schedule" | "delete_schedule" | "ignore_schedule" | "save_task_detail" | "fetch_task_detail" | "delete_task" | "archive_task" | "snooze_task" | "unsnooze_task" | "create_tag" | "delete_tag" | "update_charge_card" | "update_charge_card_name" | "update_charge_card_name_card_user" | "issue_charge_card" | "issue_charge_cards" | "notification_settings_saved" | "referral_invite_sent" | "notification_mark_as_read" | "mark_as_complete_schedule" | "cancel_journal_entry" | "settings_accounting_accounts_updated" | "create_card_setup" | "confirm_card_setup" | "add_card_payment_source" | "fetch_payment_sources" | "task_assigned_toast_notification" | "task_due_tomorrow_toast_notification" | "task_deleted_toast_notification" | "task_archived_toast_notification" | "task_overdue_toast_notification" | "task_overdue_toast_notification_creator" | "task_notification_count" | "task_activities_toast_notification" | "task_created_toast_notification" | "task_group_creation_success" | "task_group_deletion_success" | "task_group_update_success" | "primary_funding_account_updated" | "task_time_spent_validation" | "missing_receipts_attachment" | "flux_analysis_unreviewed" | "flux_analysis_reviewed" | "receipt_match" | "receipts_upload" | "receipts_bulk_match" | "billing_address_view" | "express_pay_submit" | "exclude_transaction" | "reconcile" | "save_reconcile_for_later" | "recon_transaction_categorize" | "recon_transaction_match" | "update_debit_card_pin_attempt" | "set_debit_card_pin" | "ai_cfo_create_session_and_submit" | "ai_cfo_chat_session_deleted" | "charge_card_auto_pay_enable" | "charge_card_auto_pay_disable" | "treasury_setup" | "treasury_accept_term" | "treasury_transfer_money" | "treasury_transfer_money_failed" | "auto_transfer_rule_create" | "auto_transfer_rule_update" | "auto_transfer_rule_delete" | "auto_transfer_rule_pause" | "auto_transfer_rule_resume" | "treasury_update_portfolio_allocation" | "send_email_magic_link_to_user" | "complete_profile_done" | "reports_resync" | "invalid_phone_number" | "transactions_categorized_updated_failed" | "transaction_categorized_updated_failed" | "transactionsCategorized_transactionsUpdated" | "transactionsCategorized_transactionUpdated" | "transactionCategorized_transactionsUpdated" | "transactionCategorized_transactionUpdated" | "transactionsCategorized_transactionsFailed" | "transactionsCategorized_transactionFailed" | "transactionCategorized_transactionsFailed" | "transactionCategorized_transactionFailed" | "transactionsUpdated_transactionsFailed" | "transactionsUpdated_transactionFailed" | "transactionUpdated_transactionsFailed" | "transactionUpdated_transactionFailed" | "transactionsCategorized_transactionsUpdated_transactionsFailed" | "transactionsCategorized_transactionsUpdated_transactionFailed" | "transactionsCategorized_transactionUpdated_transactionsFailed" | "transactionCategorized_transactionsUpdated_transactionsFailed" | "transactionsCategorized_transactionUpdated_transactionFailed" | "transactionCategorized_transactionsUpdated_transactionFailed" | "transactionCategorized_transactionUpdated_transactionsFailed" | "transactionCategorized_transactionUpdated_transactionFailed" | "accounting_classes_enabled_update" | "account_excluded_from_reconciliation" | "account_included_in_reconciliation" | "ai_accountant_trigger_job";
40
+ messageSection: "common" | "transactionDetails_updatingPastTransactions" | "transactionDetails_transactionUpdated" | "cockpit_month_end_email_sent" | "cockpit_month_end_email_save" | "cockpit_month_end_email_attachment_upload" | "je_bill_link" | "je_posted" | "audit_score_updated" | "people_invite_people" | "people_invite_multiple_people" | "people_delete_person" | "people_update_person" | "reimbursement_updated" | "reimbursement_deleted" | "reimbursement_cancelled_deleted" | "reimbursement_cancelled" | "reimbursement_approved" | "reimbursement_rejected" | "reimbursement_sent_for_approval" | "account_added" | "business_verification_save" | "business_verification_submit" | "business_verification_from_bills_submit" | "plaid_connection" | "unlink_deposit_account" | "reimbursement_setup" | "reimbursement_approval_create" | "reimbursement_duplicate_approval_create" | "reimbursement_approval_update" | "reimbursement_duplicate_approval_update" | "reimbursement_approval_delete" | "reimbursement_create_mileage" | "reimbursement_update_mileage" | "reimbursement_accept_term" | "reimbursement_accept_employee_term" | "reimbursement_bulk_submit" | "reimbursement_bulk_processed" | "bill_pay_setup" | "zeni_accounts_setup" | "bill_pay_approval_create" | "bill_pay_duplicate_approval_create" | "bill_pay_approval_update" | "bill_pay_duplicate_approval_update" | "bill_pay_approval_delete" | "bill_pay_updated" | "bill_pay_deleted" | "bill_pay_cancelled_deleted" | "bill_pay_cancelled" | "bill_pay_approved" | "real_time_approver_added" | "bill_pay_rejected" | "bill_pay_sent_for_approval" | "bill_pay_accept_term" | "bill_pay_bulk_submit" | "bill_pay_bulk_processed" | "bill_pay_refund" | "bill_pay_retry" | "bill_pay_marked_as_paid" | "zeni_account_accept_term" | "update_vendor" | "data_refresh_update" | "delete_bank_account" | "create_bank_account" | "create_bank_account_ach" | "create_bank_account_wire" | "create_bank_account_international" | "transfer_money" | "update_zeni_account_nickname" | "create_checking_account" | "deposit_check" | "create_vendor" | "onboarding_customer_view" | "onboarding_customer_view_complete" | "onboarding_customer_identity_verification_save" | "onboarding_customer_identity_verification_submit" | "onboarding_customer_business_verification_save" | "onboarding_customer_business_verification_submit" | "retry_bank_account_connection" | "dashboard_invite_sent" | "onboarding_info_saved" | "approve_original_merchant" | "approve_global_merchant" | "reject_global_merchant" | "create_global_merchant" | "fetch_global_merchant_no_recommendation" | "save_vendor_renamed" | "save_vendor_sent_for_review" | "save_vendor_marked_as_employee" | "save_vendor_marked_as_local_contractor" | "charge_card_setup" | "charge_card_accept_term" | "charge_card_receipt_upload" | "charge_card_resend_invite" | "charge_card_revoke_invite" | "charge_card_update_limit" | "charge_cards_update_limit" | "close_charge_card" | "lock_charge_card" | "lock_charge_card_card_user" | "lock_charge_cards" | "unlock_charge_card" | "unlock_charge_card_card_user" | "unlock_charge_cards" | "close_charge_cards" | "revoke_invite_charge_cards" | "charge_card_express_interest" | "create_schedule" | "save_schedule" | "delete_schedule" | "ignore_schedule" | "save_task_detail" | "fetch_task_detail" | "delete_task" | "archive_task" | "snooze_task" | "unsnooze_task" | "create_tag" | "delete_tag" | "update_charge_card" | "update_charge_card_name" | "update_charge_card_name_card_user" | "issue_charge_card" | "issue_charge_cards" | "notification_settings_saved" | "referral_invite_sent" | "notification_mark_as_read" | "mark_as_complete_schedule" | "cancel_journal_entry" | "settings_accounting_accounts_updated" | "create_card_setup" | "confirm_card_setup" | "add_card_payment_source" | "fetch_payment_sources" | "task_assigned_toast_notification" | "task_due_tomorrow_toast_notification" | "task_deleted_toast_notification" | "task_archived_toast_notification" | "task_overdue_toast_notification" | "task_overdue_toast_notification_creator" | "task_notification_count" | "task_activities_toast_notification" | "task_created_toast_notification" | "task_group_creation_success" | "task_group_deletion_success" | "task_group_update_success" | "primary_funding_account_updated" | "task_time_spent_validation" | "missing_receipts_attachment" | "flux_analysis_unreviewed" | "flux_analysis_reviewed" | "receipt_match" | "receipts_upload" | "receipts_bulk_match" | "billing_address_view" | "express_pay_submit" | "exclude_transaction" | "reconcile" | "save_reconcile_for_later" | "recon_transaction_categorize" | "recon_transaction_match" | "update_debit_card_pin_attempt" | "set_debit_card_pin" | "ai_cfo_create_session_and_submit" | "ai_cfo_chat_session_deleted" | "charge_card_auto_pay_enable" | "charge_card_auto_pay_disable" | "treasury_setup" | "treasury_accept_term" | "treasury_transfer_money" | "treasury_transfer_money_failed" | "auto_transfer_rule_create" | "auto_transfer_rule_update" | "auto_transfer_rule_delete" | "auto_transfer_rule_pause" | "auto_transfer_rule_resume" | "treasury_update_portfolio_allocation" | "send_email_magic_link_to_user" | "complete_profile_done" | "reports_resync" | "invalid_phone_number" | "transactions_categorized_updated_failed" | "transaction_categorized_updated_failed" | "transactionsCategorized_transactionsUpdated" | "transactionsCategorized_transactionUpdated" | "transactionCategorized_transactionsUpdated" | "transactionCategorized_transactionUpdated" | "transactionsCategorized_transactionsFailed" | "transactionsCategorized_transactionFailed" | "transactionCategorized_transactionsFailed" | "transactionCategorized_transactionFailed" | "transactionsUpdated_transactionsFailed" | "transactionsUpdated_transactionFailed" | "transactionUpdated_transactionsFailed" | "transactionUpdated_transactionFailed" | "transactionsCategorized_transactionsUpdated_transactionsFailed" | "transactionsCategorized_transactionsUpdated_transactionFailed" | "transactionsCategorized_transactionUpdated_transactionsFailed" | "transactionCategorized_transactionsUpdated_transactionsFailed" | "transactionsCategorized_transactionUpdated_transactionFailed" | "transactionCategorized_transactionsUpdated_transactionFailed" | "transactionCategorized_transactionUpdated_transactionsFailed" | "transactionCategorized_transactionUpdated_transactionFailed" | "accounting_classes_enabled_update" | "account_excluded_from_reconciliation" | "account_included_in_reconciliation" | "ai_accountant_trigger_job" | "oauth_consent_approve" | "oauth_consent_invalid_request";
41
41
  messageText: "notification" | "failed" | "success";
42
42
  type: "error" | "success" | "info";
43
43
  variables: {
@@ -0,0 +1,27 @@
1
+ import { ActionsObservable, StateObservable } from 'redux-observable';
2
+ import { openSnackbar } from '../../../entity/snackbar/snackbarReducer';
3
+ import { RootState } from '../../../reducer';
4
+ import { ZeniAPI } from '../../../zeniAPI';
5
+ import { approveOAuthConsent, approveOAuthConsentFailure, approveOAuthConsentSuccess } from '../zeniOAuthReducer';
6
+ export type ActionType = ReturnType<typeof approveOAuthConsent> | ReturnType<typeof approveOAuthConsentSuccess> | ReturnType<typeof approveOAuthConsentFailure> | ReturnType<typeof openSnackbar>;
7
+ export declare const approveOAuthConsentEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => import("rxjs").Observable<{
8
+ payload: {
9
+ messageSection: import("../../..").SnackbarMessageSections;
10
+ messageText: import("../../..").SnackbarMessageSectionTexts;
11
+ type: import("../../..").SnackbarMessageType;
12
+ showStatusIcon?: boolean;
13
+ variables?: {
14
+ variableName: string;
15
+ variableValue: string;
16
+ }[];
17
+ };
18
+ type: "snackbar/openSnackbar";
19
+ } | {
20
+ payload: {
21
+ redirectUrl: string;
22
+ };
23
+ type: "zeniOAuthView/approveOAuthConsentSuccess";
24
+ } | {
25
+ payload: import("../../../responsePayload").ZeniAPIStatus<Record<string, unknown>>;
26
+ type: "zeniOAuthView/approveOAuthConsentFailure";
27
+ }>;
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.approveOAuthConsentEpic = void 0;
4
+ const rxjs_1 = require("rxjs");
5
+ const operators_1 = require("rxjs/operators");
6
+ const snackbarReducer_1 = require("../../../entity/snackbar/snackbarReducer");
7
+ const responsePayload_1 = require("../../../responsePayload");
8
+ const zeniOAuthReducer_1 = require("../zeniOAuthReducer");
9
+ const failureSnackbar = (reason) => (0, snackbarReducer_1.openSnackbar)({
10
+ messageSection: 'oauth_consent_approve',
11
+ messageText: 'failed',
12
+ type: 'error',
13
+ variables: [{ variableName: '__reason__', variableValue: reason }],
14
+ });
15
+ const approveOAuthConsentEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(zeniOAuthReducer_1.approveOAuthConsent.match), (0, operators_1.switchMap)((action) => {
16
+ const { userId, zeniSessionId, tenantId, clientId, redirectUri, codeChallenge, codeChallengeMethod, state, responseType, } = action.payload;
17
+ const authHeaders = {
18
+ 'zeni-user-id': userId,
19
+ 'zeni-tenant-id': tenantId,
20
+ };
21
+ if (zeniSessionId != null) {
22
+ authHeaders['zeni-session-id'] = zeniSessionId;
23
+ }
24
+ return zeniAPI
25
+ .postJSON(`${zeniAPI.apiEndPoints.authMicroServiceBaseUrl}/oauth/authorize/approve`, {
26
+ client_id: clientId,
27
+ redirect_uri: redirectUri,
28
+ code_challenge: codeChallenge,
29
+ code_challenge_method: codeChallengeMethod,
30
+ state,
31
+ response_type: responseType,
32
+ tenant_id: tenantId,
33
+ }, authHeaders)
34
+ .pipe((0, operators_1.concatMap)((response) => (0, rxjs_1.from)(response.json()).pipe((0, operators_1.mergeMap)((responseJson) => {
35
+ if (!response.ok) {
36
+ const errBody = responseJson;
37
+ const errorMessage = errBody?.error ??
38
+ errBody?.message ??
39
+ errBody?.status?.message ??
40
+ `Authorization failed (${response.status})`;
41
+ return (0, rxjs_1.from)([
42
+ (0, zeniOAuthReducer_1.approveOAuthConsentFailure)((0, responsePayload_1.createZeniAPIStatus)(errorMessage)),
43
+ failureSnackbar(errorMessage),
44
+ ]);
45
+ }
46
+ const body = responseJson;
47
+ const redirectUrl = body?.redirect_url ?? body?.data?.redirect_url;
48
+ if (redirectUrl == null || redirectUrl === '') {
49
+ const noRedirectMessage = 'No redirect URL returned from authorization server';
50
+ return (0, rxjs_1.from)([
51
+ (0, zeniOAuthReducer_1.approveOAuthConsentFailure)((0, responsePayload_1.createZeniAPIStatus)(noRedirectMessage)),
52
+ failureSnackbar(noRedirectMessage),
53
+ ]);
54
+ }
55
+ return (0, rxjs_1.of)((0, zeniOAuthReducer_1.approveOAuthConsentSuccess)({ redirectUrl }));
56
+ }))), (0, operators_1.catchError)((error) => {
57
+ const networkErrorMessage = 'OAuth approve request failed: ' + JSON.stringify(error);
58
+ return (0, rxjs_1.from)([
59
+ (0, zeniOAuthReducer_1.approveOAuthConsentFailure)((0, responsePayload_1.createZeniAPIStatus)(networkErrorMessage)),
60
+ failureSnackbar(networkErrorMessage),
61
+ ]);
62
+ }));
63
+ }));
64
+ exports.approveOAuthConsentEpic = approveOAuthConsentEpic;
@@ -0,0 +1,16 @@
1
+ export interface OAuthParams {
2
+ clientId: string;
3
+ codeChallenge: string;
4
+ codeChallengeMethod: string;
5
+ redirectUri: string;
6
+ responseType: string;
7
+ state: string;
8
+ }
9
+ export type ParseOAuthParamsResult = {
10
+ error: null;
11
+ params: OAuthParams;
12
+ } | {
13
+ error: string;
14
+ params: null;
15
+ };
16
+ export declare function parseOAuthParams(search: string): ParseOAuthParamsResult;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseOAuthParams = parseOAuthParams;
4
+ function parseOAuthParams(search) {
5
+ const searchParams = new URLSearchParams(search);
6
+ const clientId = searchParams.get('client_id');
7
+ const redirectUri = searchParams.get('redirect_uri');
8
+ const codeChallenge = searchParams.get('code_challenge');
9
+ const codeChallengeMethod = searchParams.get('code_challenge_method') ?? 'S256';
10
+ const state = searchParams.get('state');
11
+ const responseType = searchParams.get('response_type') ?? 'code';
12
+ if (clientId == null || clientId === '') {
13
+ return { params: null, error: 'Missing client_id parameter' };
14
+ }
15
+ if (redirectUri == null || redirectUri === '') {
16
+ return { params: null, error: 'Missing redirect_uri parameter' };
17
+ }
18
+ try {
19
+ void new URL(redirectUri);
20
+ }
21
+ catch {
22
+ return { params: null, error: 'Invalid redirect_uri parameter' };
23
+ }
24
+ if (codeChallenge == null || codeChallenge === '') {
25
+ return {
26
+ params: null,
27
+ error: 'Missing code_challenge parameter (PKCE required)',
28
+ };
29
+ }
30
+ if (state == null || state === '') {
31
+ return { params: null, error: 'Missing state parameter' };
32
+ }
33
+ return {
34
+ params: {
35
+ clientId,
36
+ redirectUri,
37
+ codeChallenge,
38
+ codeChallengeMethod,
39
+ state,
40
+ responseType,
41
+ },
42
+ error: null,
43
+ };
44
+ }
@@ -0,0 +1,29 @@
1
+ import { ZeniAPIStatus } from '../../responsePayload';
2
+ import { ZeniOAuthViewState } from './zeniOAuthState';
3
+ export declare const initialState: ZeniOAuthViewState;
4
+ export interface ApproveOAuthConsentPayload {
5
+ clientId: string;
6
+ codeChallenge: string;
7
+ codeChallengeMethod: string;
8
+ redirectUri: string;
9
+ responseType: string;
10
+ state: string;
11
+ tenantId: string;
12
+ userId: string;
13
+ zeniSessionId: string | undefined;
14
+ }
15
+ export declare const approveOAuthConsent: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[userId: string, zeniSessionId: string | undefined, tenantId: string, clientId: string, redirectUri: string, codeChallenge: string, codeChallengeMethod: string, state: string, responseType: string], {
16
+ userId: string;
17
+ zeniSessionId: string | undefined;
18
+ tenantId: string;
19
+ clientId: string;
20
+ redirectUri: string;
21
+ codeChallenge: string;
22
+ codeChallengeMethod: string;
23
+ state: string;
24
+ responseType: string;
25
+ }, "zeniOAuthView/approveOAuthConsent", never, never>, approveOAuthConsentSuccess: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
26
+ redirectUrl: string;
27
+ }, "zeniOAuthView/approveOAuthConsentSuccess">, approveOAuthConsentFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "zeniOAuthView/approveOAuthConsentFailure">, clearZeniOAuthView: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"zeniOAuthView/clearZeniOAuthView">;
28
+ declare const _default: import("redux").Reducer<ZeniOAuthViewState>;
29
+ export default _default;
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ var _a;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.clearZeniOAuthView = exports.approveOAuthConsentFailure = exports.approveOAuthConsentSuccess = exports.approveOAuthConsent = exports.initialState = void 0;
5
+ const toolkit_1 = require("@reduxjs/toolkit");
6
+ exports.initialState = {
7
+ fetchState: 'Not-Started',
8
+ error: undefined,
9
+ approveRedirectUrl: undefined,
10
+ };
11
+ const zeniOAuthView = (0, toolkit_1.createSlice)({
12
+ name: 'zeniOAuthView',
13
+ initialState: exports.initialState,
14
+ reducers: {
15
+ approveOAuthConsent: {
16
+ prepare(userId, zeniSessionId, tenantId, clientId, redirectUri, codeChallenge, codeChallengeMethod, state, responseType) {
17
+ return {
18
+ payload: {
19
+ userId,
20
+ zeniSessionId,
21
+ tenantId,
22
+ clientId,
23
+ redirectUri,
24
+ codeChallenge,
25
+ codeChallengeMethod,
26
+ state,
27
+ responseType,
28
+ },
29
+ };
30
+ },
31
+ reducer(draft) {
32
+ draft.fetchState = 'In-Progress';
33
+ draft.error = undefined;
34
+ draft.approveRedirectUrl = undefined;
35
+ },
36
+ },
37
+ approveOAuthConsentSuccess(draft, action) {
38
+ draft.fetchState = 'Completed';
39
+ draft.error = undefined;
40
+ draft.approveRedirectUrl = action.payload.redirectUrl;
41
+ },
42
+ approveOAuthConsentFailure(draft, action) {
43
+ draft.fetchState = 'Error';
44
+ draft.error = action.payload;
45
+ draft.approveRedirectUrl = undefined;
46
+ },
47
+ clearZeniOAuthView() {
48
+ return exports.initialState;
49
+ },
50
+ },
51
+ });
52
+ _a = zeniOAuthView.actions, exports.approveOAuthConsent = _a.approveOAuthConsent, exports.approveOAuthConsentSuccess = _a.approveOAuthConsentSuccess, exports.approveOAuthConsentFailure = _a.approveOAuthConsentFailure, exports.clearZeniOAuthView = _a.clearZeniOAuthView;
53
+ exports.default = zeniOAuthView.reducer;
@@ -0,0 +1,5 @@
1
+ import { RootState } from '../../reducer';
2
+ import { FetchState } from '../../commonStateTypes/common';
3
+ export declare const getZeniOAuthApproveFetchState: (state: RootState) => FetchState;
4
+ export declare const getZeniOAuthApproveRedirectUrl: (state: RootState) => string | undefined;
5
+ export declare const getZeniOAuthApproveError: (state: RootState) => string | null;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getZeniOAuthApproveError = exports.getZeniOAuthApproveRedirectUrl = exports.getZeniOAuthApproveFetchState = void 0;
4
+ const getZeniOAuthApproveFetchState = (state) => state.zeniOAuthViewState.fetchState;
5
+ exports.getZeniOAuthApproveFetchState = getZeniOAuthApproveFetchState;
6
+ const getZeniOAuthApproveRedirectUrl = (state) => state.zeniOAuthViewState.approveRedirectUrl;
7
+ exports.getZeniOAuthApproveRedirectUrl = getZeniOAuthApproveRedirectUrl;
8
+ const getZeniOAuthApproveError = (state) => state.zeniOAuthViewState.error?.message ?? null;
9
+ exports.getZeniOAuthApproveError = getZeniOAuthApproveError;
@@ -0,0 +1,4 @@
1
+ import { FetchStateAndError } from '../../commonStateTypes/common';
2
+ export interface ZeniOAuthViewState extends FetchStateAndError {
3
+ approveRedirectUrl?: string;
4
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "5.0.31",
3
+ "version": "5.0.32-betaRD2",
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
  "module": "lib/esm/index.js",