@finspringinnovations/fdsdk 0.0.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.
- package/README.md +184 -0
- package/lib/api/applicationApi.d.ts +1 -0
- package/lib/api/applicationApi.js +11 -0
- package/lib/api/bankApi.d.ts +352 -0
- package/lib/api/bankApi.js +54 -0
- package/lib/api/baseApi.d.ts +8 -0
- package/lib/api/baseApi.js +456 -0
- package/lib/api/customerApi.d.ts +855 -0
- package/lib/api/customerApi.js +213 -0
- package/lib/api/fdApi.d.ts +979 -0
- package/lib/api/fdApi.js +112 -0
- package/lib/api/fdCalculatorApi.d.ts +179 -0
- package/lib/api/fdCalculatorApi.js +36 -0
- package/lib/api/index.d.ts +14 -0
- package/lib/api/index.js +45 -0
- package/lib/api/interestRateApi.d.ts +585 -0
- package/lib/api/interestRateApi.js +101 -0
- package/lib/api/kycApi.d.ts +486 -0
- package/lib/api/kycApi.js +71 -0
- package/lib/api/masterDataApi.d.ts +158 -0
- package/lib/api/masterDataApi.js +32 -0
- package/lib/api/nomineeApi.d.ts +325 -0
- package/lib/api/nomineeApi.js +46 -0
- package/lib/api/onboardingApi.d.ts +192 -0
- package/lib/api/onboardingApi.js +41 -0
- package/lib/api/panApi.d.ts +0 -0
- package/lib/api/panApi.js +23 -0
- package/lib/api/paymentApi.d.ts +325 -0
- package/lib/api/paymentApi.js +46 -0
- package/lib/api/workflowApi.d.ts +654 -0
- package/lib/api/workflowApi.js +90 -0
- package/lib/assets/images/images.d.ts +4 -0
- package/lib/assets/images/images.js +10 -0
- package/lib/components/AadhaarInput.d.ts +13 -0
- package/lib/components/AadhaarInput.js +47 -0
- package/lib/components/ActionButton.d.ts +12 -0
- package/lib/components/ActionButton.js +87 -0
- package/lib/components/ActiveFDCard.d.ts +16 -0
- package/lib/components/ActiveFDCard.js +95 -0
- package/lib/components/AmountInput.d.ts +20 -0
- package/lib/components/AmountInput.js +144 -0
- package/lib/components/CheckboxOption.d.ts +11 -0
- package/lib/components/CheckboxOption.js +41 -0
- package/lib/components/CompanyHeader.d.ts +7 -0
- package/lib/components/CompanyHeader.js +57 -0
- package/lib/components/DropdownSelector.d.ts +9 -0
- package/lib/components/DropdownSelector.js +49 -0
- package/lib/components/EmptyState.d.ts +17 -0
- package/lib/components/EmptyState.js +44 -0
- package/lib/components/ErrorDisplay.d.ts +17 -0
- package/lib/components/ErrorDisplay.js +69 -0
- package/lib/components/FAQItem.d.ts +9 -0
- package/lib/components/FAQItem.js +52 -0
- package/lib/components/FDCard.d.ts +21 -0
- package/lib/components/FDCard.js +96 -0
- package/lib/components/FormDropdown.d.ts +18 -0
- package/lib/components/FormDropdown.js +155 -0
- package/lib/components/FormSection.d.ts +14 -0
- package/lib/components/FormSection.js +38 -0
- package/lib/components/Header.d.ts +14 -0
- package/lib/components/Header.js +52 -0
- package/lib/components/IFSCSearchResultCard.d.ts +13 -0
- package/lib/components/IFSCSearchResultCard.js +70 -0
- package/lib/components/InfoBox.d.ts +8 -0
- package/lib/components/InfoBox.js +39 -0
- package/lib/components/InterestRateCard.d.ts +8 -0
- package/lib/components/InterestRateCard.js +46 -0
- package/lib/components/LoadingIndicator.d.ts +12 -0
- package/lib/components/LoadingIndicator.js +30 -0
- package/lib/components/OTPInput.d.ts +17 -0
- package/lib/components/OTPInput.js +144 -0
- package/lib/components/PaymentDetailsCard.d.ts +20 -0
- package/lib/components/PaymentDetailsCard.js +68 -0
- package/lib/components/PendingFDBottomSheet.d.ts +18 -0
- package/lib/components/PendingFDBottomSheet.js +122 -0
- package/lib/components/SafeAreaWrapper.d.ts +13 -0
- package/lib/components/SafeAreaWrapper.js +41 -0
- package/lib/components/ScreenHeader.d.ts +11 -0
- package/lib/components/ScreenHeader.js +46 -0
- package/lib/components/StatusDisplay.d.ts +15 -0
- package/lib/components/StatusDisplay.js +88 -0
- package/lib/components/TextFieldWithLabel.d.ts +46 -0
- package/lib/components/TextFieldWithLabel.js +326 -0
- package/lib/components/TrustBox.d.ts +8 -0
- package/lib/components/TrustBox.js +45 -0
- package/lib/components/ValidationErrorAlert.d.ts +23 -0
- package/lib/components/ValidationErrorAlert.js +39 -0
- package/lib/components/ValidationMessage.d.ts +9 -0
- package/lib/components/ValidationMessage.js +98 -0
- package/lib/components/index.d.ts +35 -0
- package/lib/components/index.js +64 -0
- package/lib/config/apiConfig.d.ts +34 -0
- package/lib/config/apiConfig.js +158 -0
- package/lib/config/appDataConfig.d.ts +114 -0
- package/lib/config/appDataConfig.js +264 -0
- package/lib/config/encryptionConfig.d.ts +21 -0
- package/lib/config/encryptionConfig.js +61 -0
- package/lib/config/workflowConstants.d.ts +37 -0
- package/lib/config/workflowConstants.js +38 -0
- package/lib/constants/strings/bank.d.ts +72 -0
- package/lib/constants/strings/bank.js +86 -0
- package/lib/constants/strings/base64Images.d.ts +25 -0
- package/lib/constants/strings/base64Images.js +28 -0
- package/lib/constants/strings/common.d.ts +53 -0
- package/lib/constants/strings/common.js +62 -0
- package/lib/constants/strings/employee.d.ts +61 -0
- package/lib/constants/strings/employee.js +77 -0
- package/lib/constants/strings/faq.d.ts +14 -0
- package/lib/constants/strings/faq.js +20 -0
- package/lib/constants/strings/fd.d.ts +122 -0
- package/lib/constants/strings/fd.js +151 -0
- package/lib/constants/strings/home.d.ts +49 -0
- package/lib/constants/strings/home.js +62 -0
- package/lib/constants/strings/index.d.ts +16 -0
- package/lib/constants/strings/index.js +44 -0
- package/lib/constants/strings/kyc.d.ts +80 -0
- package/lib/constants/strings/kyc.js +94 -0
- package/lib/constants/strings/nominee.d.ts +64 -0
- package/lib/constants/strings/nominee.js +81 -0
- package/lib/hooks/useAuth.d.ts +25 -0
- package/lib/hooks/useAuth.js +39 -0
- package/lib/hooks/useFDData.d.ts +11 -0
- package/lib/hooks/useFDData.js +40 -0
- package/lib/index.d.ts +69 -0
- package/lib/index.js +182 -0
- package/lib/navigation/RootNavigator.d.ts +8 -0
- package/lib/navigation/RootNavigator.js +205 -0
- package/lib/navigation/SimpleNavigator.d.ts +11 -0
- package/lib/navigation/SimpleNavigator.js +107 -0
- package/lib/navigation/helpers.d.ts +11 -0
- package/lib/navigation/helpers.js +83 -0
- package/lib/navigation/index.d.ts +15 -0
- package/lib/navigation/index.js +42 -0
- package/lib/navigation/types.d.ts +113 -0
- package/lib/navigation/types.js +2 -0
- package/lib/navigation/workflowNavigator.d.ts +22 -0
- package/lib/navigation/workflowNavigator.js +104 -0
- package/lib/providers/ApiProvider.d.ts +7 -0
- package/lib/providers/ApiProvider.js +34 -0
- package/lib/providers/MasterDataProvider.d.ts +10 -0
- package/lib/providers/MasterDataProvider.js +54 -0
- package/lib/screens/AadhaarVerification.d.ts +7 -0
- package/lib/screens/AadhaarVerification.js +627 -0
- package/lib/screens/AddBankAccount.d.ts +22 -0
- package/lib/screens/AddBankAccount.js +381 -0
- package/lib/screens/BankDetail.d.ts +16 -0
- package/lib/screens/BankDetail.js +596 -0
- package/lib/screens/BookFD.d.ts +0 -0
- package/lib/screens/BookFD.js +315 -0
- package/lib/screens/Employee.d.ts +18 -0
- package/lib/screens/Employee.js +594 -0
- package/lib/screens/FDCalculator.d.ts +18 -0
- package/lib/screens/FDCalculator.js +759 -0
- package/lib/screens/FDList.d.ts +27 -0
- package/lib/screens/FDList.js +1008 -0
- package/lib/screens/FindIFSC.d.ts +16 -0
- package/lib/screens/FindIFSC.js +248 -0
- package/lib/screens/Home.d.ts +0 -0
- package/lib/screens/Home.js +143 -0
- package/lib/screens/NomineeDetail.d.ts +17 -0
- package/lib/screens/NomineeDetail.js +592 -0
- package/lib/screens/PayNow.d.ts +14 -0
- package/lib/screens/PayNow.js +230 -0
- package/lib/screens/Payment.d.ts +11 -0
- package/lib/screens/Payment.js +191 -0
- package/lib/screens/PaymentStatus.d.ts +16 -0
- package/lib/screens/PaymentStatus.js +397 -0
- package/lib/screens/ReviewKYC.d.ts +21 -0
- package/lib/screens/ReviewKYC.js +660 -0
- package/lib/state/paymentSession.d.ts +8 -0
- package/lib/state/paymentSession.js +13 -0
- package/lib/store/fdListSelectedSlice.d.ts +21 -0
- package/lib/store/fdListSelectedSlice.js +26 -0
- package/lib/store/hooks.d.ts +8 -0
- package/lib/store/hooks.js +31 -0
- package/lib/store/index.d.ts +3 -0
- package/lib/store/index.js +8 -0
- package/lib/store/onboardingSlice.d.ts +12 -0
- package/lib/store/onboardingSlice.js +32 -0
- package/lib/store/store.d.ts +13 -0
- package/lib/store/store.js +33 -0
- package/lib/theme/ThemeContext.d.ts +210 -0
- package/lib/theme/ThemeContext.js +90 -0
- package/lib/theme/colors.d.ts +80 -0
- package/lib/theme/colors.js +85 -0
- package/lib/theme/index.d.ts +34 -0
- package/lib/theme/index.js +69 -0
- package/lib/theme/shadows.d.ts +53 -0
- package/lib/theme/shadows.js +58 -0
- package/lib/theme/typography.d.ts +134 -0
- package/lib/theme/typography.js +143 -0
- package/lib/types/dataTypes.d.ts +34 -0
- package/lib/types/dataTypes.js +2 -0
- package/lib/types/workflowTypes.d.ts +2 -0
- package/lib/types/workflowTypes.js +2 -0
- package/lib/utils/apiLogger.d.ts +48 -0
- package/lib/utils/apiLogger.js +105 -0
- package/lib/utils/encryption.d.ts +28 -0
- package/lib/utils/encryption.js +113 -0
- package/lib/utils/getFDData.d.ts +48 -0
- package/lib/utils/getFDData.js +154 -0
- package/lib/utils/globalData.d.ts +2 -0
- package/lib/utils/globalData.js +10 -0
- package/package.json +76 -0
- package/src/api/applicationApi.ts +12 -0
- package/src/api/bankApi.ts +42 -0
- package/src/api/baseApi.ts +513 -0
- package/src/api/customerApi.ts +291 -0
- package/src/api/fdApi.ts +150 -0
- package/src/api/fdCalculatorApi.ts +41 -0
- package/src/api/index.ts +29 -0
- package/src/api/interestRateApi.ts +143 -0
- package/src/api/kycApi.ts +63 -0
- package/src/api/masterDataApi.ts +34 -0
- package/src/api/nomineeApi.ts +34 -0
- package/src/api/onboardingApi.ts +64 -0
- package/src/api/panApi.ts +25 -0
- package/src/api/paymentApi.ts +34 -0
- package/src/api/workflowApi.ts +94 -0
- package/src/assets/images/arrow-filled.png +0 -0
- package/src/assets/images/arrow-left.png +0 -0
- package/src/assets/images/backicon.png +0 -0
- package/src/assets/images/calendar.png +0 -0
- package/src/assets/images/chevron-down.png +0 -0
- package/src/assets/images/chevron-down@2x.png +0 -0
- package/src/assets/images/chevron-down@3x.png +0 -0
- package/src/assets/images/images.js +8 -0
- package/src/components/AadhaarInput.tsx +91 -0
- package/src/components/ActionButton.tsx +129 -0
- package/src/components/ActiveFDCard.tsx +158 -0
- package/src/components/AmountInput.tsx +217 -0
- package/src/components/CheckboxOption.tsx +93 -0
- package/src/components/CompanyHeader.tsx +78 -0
- package/src/components/DropdownSelector.tsx +77 -0
- package/src/components/EmptyState.tsx +109 -0
- package/src/components/ErrorDisplay.tsx +135 -0
- package/src/components/FAQItem.tsx +90 -0
- package/src/components/FDCard.tsx +165 -0
- package/src/components/FormDropdown.tsx +214 -0
- package/src/components/FormSection.tsx +86 -0
- package/src/components/Header.tsx +110 -0
- package/src/components/IFSCSearchResultCard.tsx +139 -0
- package/src/components/InfoBox.tsx +55 -0
- package/src/components/InterestRateCard.tsx +77 -0
- package/src/components/LoadingIndicator.tsx +63 -0
- package/src/components/OTPInput.tsx +213 -0
- package/src/components/PaymentDetailsCard.tsx +120 -0
- package/src/components/PendingFDBottomSheet.tsx +235 -0
- package/src/components/README.md +210 -0
- package/src/components/SafeAreaWrapper.tsx +68 -0
- package/src/components/ScreenHeader.tsx +83 -0
- package/src/components/StatusDisplay.tsx +139 -0
- package/src/components/TextFieldWithLabel.tsx +502 -0
- package/src/components/TrustBox.tsx +63 -0
- package/src/components/ValidationErrorAlert.tsx +57 -0
- package/src/components/ValidationMessage.tsx +134 -0
- package/src/components/index.tsx +47 -0
- package/src/config/apiConfig.ts +217 -0
- package/src/config/appDataConfig.ts +279 -0
- package/src/config/encryptionConfig.ts +65 -0
- package/src/config/workflowConstants.ts +43 -0
- package/src/constants/strings/README.md +146 -0
- package/src/constants/strings/bank.ts +92 -0
- package/src/constants/strings/base64Images.ts +29 -0
- package/src/constants/strings/common.ts +63 -0
- package/src/constants/strings/employee.ts +85 -0
- package/src/constants/strings/faq.ts +23 -0
- package/src/constants/strings/fd.ts +172 -0
- package/src/constants/strings/home.ts +67 -0
- package/src/constants/strings/index.ts +21 -0
- package/src/constants/strings/kyc.ts +100 -0
- package/src/constants/strings/nominee.ts +90 -0
- package/src/hooks/useAuth.ts +42 -0
- package/src/hooks/useFDData.ts +48 -0
- package/src/index.tsx +173 -0
- package/src/navigation/RootNavigator.tsx +352 -0
- package/src/navigation/SimpleNavigator.tsx +107 -0
- package/src/navigation/helpers.ts +85 -0
- package/src/navigation/index.tsx +81 -0
- package/src/navigation/types.ts +124 -0
- package/src/navigation/workflowNavigator.ts +131 -0
- package/src/providers/ApiProvider.tsx +43 -0
- package/src/providers/MasterDataProvider.tsx +30 -0
- package/src/screens/AadhaarVerification.tsx +809 -0
- package/src/screens/AddBankAccount.tsx +541 -0
- package/src/screens/BankDetail.tsx +826 -0
- package/src/screens/BookFD.tsx +330 -0
- package/src/screens/Employee.tsx +822 -0
- package/src/screens/FDCalculator.tsx +987 -0
- package/src/screens/FDList.tsx +1284 -0
- package/src/screens/FindIFSC.tsx +332 -0
- package/src/screens/Home.tsx +152 -0
- package/src/screens/NomineeDetail.tsx +800 -0
- package/src/screens/PayNow.tsx +282 -0
- package/src/screens/Payment.tsx +224 -0
- package/src/screens/PaymentStatus.tsx +561 -0
- package/src/screens/ReviewKYC.tsx +956 -0
- package/src/state/paymentSession.ts +13 -0
- package/src/store/fdListSelectedSlice.ts +42 -0
- package/src/store/hooks.ts +27 -0
- package/src/store/index.ts +3 -0
- package/src/store/onboardingSlice.ts +37 -0
- package/src/store/store.ts +35 -0
- package/src/theme/ThemeContext.tsx +82 -0
- package/src/theme/colors.ts +90 -0
- package/src/theme/index.ts +64 -0
- package/src/theme/shadows.ts +61 -0
- package/src/theme/typography.ts +151 -0
- package/src/types/dataTypes.ts +37 -0
- package/src/types/env.d.ts +93 -0
- package/src/types/workflowTypes.ts +12 -0
- package/src/utils/apiLogger.ts +166 -0
- package/src/utils/encryption.ts +159 -0
- package/src/utils/getFDData.ts +175 -0
- package/src/utils/globalData.ts +7 -0
|
@@ -0,0 +1,456 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react';
|
|
3
|
+
// import { encryptRequest, decryptResponse } from '../utils/encryption';
|
|
4
|
+
// import { getEncryptionConfig } from '../config/encryptionConfig';
|
|
5
|
+
// import { getApiConfig, getSecureHeaders, validateApiConfig } from '../config/apiConfig';
|
|
6
|
+
// import { apiLogger, RequestLogData, ResponseLogData } from '../utils/apiLogger';
|
|
7
|
+
// import type { BaseQueryFn, FetchArgs, FetchBaseQueryError } from '@reduxjs/toolkit/query';
|
|
8
|
+
// import { v4 as uuidv4 } from 'uuid';
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.usePrefetch = exports.baseApi = exports.getSDKStoreRef = exports.setSDKStoreRef = exports.getCurrentApiConfig = exports.isEncryptionEnabled = exports.toggleEncryption = void 0;
|
|
11
|
+
// // Get and validate API configuration
|
|
12
|
+
// const apiConfig = getApiConfig();
|
|
13
|
+
// if (!validateApiConfig(apiConfig)) {
|
|
14
|
+
// throw new Error('Invalid API configuration');
|
|
15
|
+
// }
|
|
16
|
+
// // Generate unique request ID
|
|
17
|
+
// const generateRequestId = (): string => {
|
|
18
|
+
// return uuidv4();
|
|
19
|
+
// };
|
|
20
|
+
// // Encryption toggle utilities - Enable encryption by default
|
|
21
|
+
// let currentEncryptionState = true; // Enable encryption by default
|
|
22
|
+
// export const toggleEncryption = (enable?: boolean): boolean => {
|
|
23
|
+
// if (!apiConfig.allowEncryptionToggle) {
|
|
24
|
+
// return currentEncryptionState;
|
|
25
|
+
// }
|
|
26
|
+
// if (enable !== undefined) {
|
|
27
|
+
// currentEncryptionState = enable;
|
|
28
|
+
// } else {
|
|
29
|
+
// currentEncryptionState = !currentEncryptionState;
|
|
30
|
+
// }
|
|
31
|
+
// return currentEncryptionState;
|
|
32
|
+
// };
|
|
33
|
+
// export const isEncryptionEnabled = (): boolean => {
|
|
34
|
+
// return currentEncryptionState;
|
|
35
|
+
// };
|
|
36
|
+
// export const getCurrentApiConfig = () => {
|
|
37
|
+
// return {
|
|
38
|
+
// ...apiConfig,
|
|
39
|
+
// enableEncryption: currentEncryptionState,
|
|
40
|
+
// };
|
|
41
|
+
// };
|
|
42
|
+
// // Custom base query with encryption support
|
|
43
|
+
// const baseQueryWithEncryption: BaseQueryFn<
|
|
44
|
+
// string | FetchArgs,
|
|
45
|
+
// unknown,
|
|
46
|
+
// FetchBaseQueryError
|
|
47
|
+
// > = async (args, api, extraOptions) => {
|
|
48
|
+
// const encryptionConfig = getEncryptionConfig();
|
|
49
|
+
// const requestId = generateRequestId();
|
|
50
|
+
// const timestamp = Date.now();
|
|
51
|
+
// // Handle request encryption BEFORE sending
|
|
52
|
+
// const url = typeof args === 'string' ? args : args.url;
|
|
53
|
+
// const method = typeof args === 'string' ? 'GET' : args.method || 'GET';
|
|
54
|
+
// let body = typeof args === 'string' ? undefined : args.body;
|
|
55
|
+
// // Log request details BEFORE any encryption
|
|
56
|
+
// try {
|
|
57
|
+
// const preEncryptionBody = body && typeof body === 'string' ? JSON.parse(body) : body;
|
|
58
|
+
// // eslint-disable-next-line no-console
|
|
59
|
+
// console.log('[ShriramSDK][API] Request BEFORE encryption', {
|
|
60
|
+
// method,
|
|
61
|
+
// url,
|
|
62
|
+
// baseUrl: apiConfig.baseUrl,
|
|
63
|
+
// body: preEncryptionBody,
|
|
64
|
+
// });
|
|
65
|
+
// } catch (_) {
|
|
66
|
+
// // eslint-disable-next-line no-console
|
|
67
|
+
// console.log('[ShriramSDK][API] Request BEFORE encryption (raw body)', {
|
|
68
|
+
// method,
|
|
69
|
+
// url,
|
|
70
|
+
// baseUrl: apiConfig.baseUrl,
|
|
71
|
+
// body,
|
|
72
|
+
// });
|
|
73
|
+
// }
|
|
74
|
+
// if (currentEncryptionState && body && typeof args !== 'string') {
|
|
75
|
+
// try {
|
|
76
|
+
// const originalBody = typeof body === 'string' ? JSON.parse(body) : body;
|
|
77
|
+
// const encryptedBody = encryptRequest(originalBody, encryptionConfig);
|
|
78
|
+
// args.body = JSON.stringify(encryptedBody);
|
|
79
|
+
// body = args.body;
|
|
80
|
+
// } catch (error) {
|
|
81
|
+
// }
|
|
82
|
+
// }
|
|
83
|
+
// // Prepare the base query
|
|
84
|
+
// const baseQuery = fetchBaseQuery({
|
|
85
|
+
// baseUrl: apiConfig.baseUrl,
|
|
86
|
+
// timeout: apiConfig.timeout,
|
|
87
|
+
// prepareHeaders: (headers, { getState, endpoint }) => {
|
|
88
|
+
// // Add authentication headers if needed
|
|
89
|
+
// const token = (getState() as any)?.auth?.token;
|
|
90
|
+
// if (token) {
|
|
91
|
+
// headers.set('authorization', `Bearer ${token}`);
|
|
92
|
+
// }
|
|
93
|
+
// // Add secure headers
|
|
94
|
+
// const secureHeaders = getSecureHeaders();
|
|
95
|
+
// Object.entries(secureHeaders).forEach(([key, value]) => {
|
|
96
|
+
// headers.set(key, value);
|
|
97
|
+
// });
|
|
98
|
+
// // Inject onboarding identifiers if present in store
|
|
99
|
+
// try {
|
|
100
|
+
// const state: any = getState();
|
|
101
|
+
// const onboarding = state?.onboarding;
|
|
102
|
+
// const wf = onboarding?.workflowInstanceId;
|
|
103
|
+
// const appId = onboarding?.applicationId;
|
|
104
|
+
// const entId = onboarding?.entityid;
|
|
105
|
+
// if (wf) headers.set('workflowInstanceId', wf);
|
|
106
|
+
// if (appId) headers.set('applicationId', appId);
|
|
107
|
+
// if (entId) headers.set('entityid', entId);
|
|
108
|
+
// } catch (e) {
|
|
109
|
+
// }
|
|
110
|
+
// // Add encryption header if enabled
|
|
111
|
+
// if (currentEncryptionState) {
|
|
112
|
+
// headers.set('X-Encrypted', 'true');
|
|
113
|
+
// }
|
|
114
|
+
// // Log all headers being sent
|
|
115
|
+
// const headerEntries = Array.from(headers.entries());
|
|
116
|
+
// // Check specifically for providerid header
|
|
117
|
+
// const providerId = headers.get('providerid');
|
|
118
|
+
// return headers;
|
|
119
|
+
// },
|
|
120
|
+
// });
|
|
121
|
+
// // Log request
|
|
122
|
+
// const requestLogData: RequestLogData = {
|
|
123
|
+
// method,
|
|
124
|
+
// url,
|
|
125
|
+
// baseUrl: apiConfig.baseUrl,
|
|
126
|
+
// headers: {},
|
|
127
|
+
// body,
|
|
128
|
+
// timestamp,
|
|
129
|
+
// requestId,
|
|
130
|
+
// isEncrypted: currentEncryptionState,
|
|
131
|
+
// };
|
|
132
|
+
// apiLogger.logRequest(requestLogData);
|
|
133
|
+
// // Make the actual request
|
|
134
|
+
// const result = await baseQuery(args, api, extraOptions);
|
|
135
|
+
// // Handle response decryption (both success and error responses)
|
|
136
|
+
// if (currentEncryptionState) {
|
|
137
|
+
// // Decrypt successful response data
|
|
138
|
+
// if (result.data) {
|
|
139
|
+
// try {
|
|
140
|
+
// const decryptedData = decryptResponse(result.data, encryptionConfig);
|
|
141
|
+
// result.data = decryptedData;
|
|
142
|
+
// // eslint-disable-next-line no-console
|
|
143
|
+
// console.log('[ShriramSDK][API] Response AFTER decryption', {
|
|
144
|
+
// url,
|
|
145
|
+
// baseUrl: apiConfig.baseUrl,
|
|
146
|
+
// status: result.meta?.response?.status || 200,
|
|
147
|
+
// data: decryptedData,
|
|
148
|
+
// });
|
|
149
|
+
// } catch (error) {
|
|
150
|
+
// }
|
|
151
|
+
// }
|
|
152
|
+
// // Decrypt error response data
|
|
153
|
+
// if (result.error && result.error.data) {
|
|
154
|
+
// try {
|
|
155
|
+
// const decryptedErrorData = decryptResponse(result.error.data, encryptionConfig);
|
|
156
|
+
// result.error.data = decryptedErrorData;
|
|
157
|
+
// // eslint-disable-next-line no-console
|
|
158
|
+
// console.log('[ShriramSDK][API] Error AFTER decryption', {
|
|
159
|
+
// url,
|
|
160
|
+
// baseUrl: apiConfig.baseUrl,
|
|
161
|
+
// status: result.meta?.response?.status,
|
|
162
|
+
// error: decryptedErrorData,
|
|
163
|
+
// });
|
|
164
|
+
// } catch (error) {
|
|
165
|
+
// }
|
|
166
|
+
// }
|
|
167
|
+
// }
|
|
168
|
+
// // Log response
|
|
169
|
+
// const responseLogData: ResponseLogData = {
|
|
170
|
+
// status: result.meta?.response?.status || 200,
|
|
171
|
+
// statusText: result.meta?.response?.statusText || 'OK',
|
|
172
|
+
// headers: {},
|
|
173
|
+
// data: result.data,
|
|
174
|
+
// timestamp: Date.now(),
|
|
175
|
+
// requestId,
|
|
176
|
+
// duration: Date.now() - timestamp,
|
|
177
|
+
// isEncrypted: currentEncryptionState,
|
|
178
|
+
// error: result.error,
|
|
179
|
+
// };
|
|
180
|
+
// apiLogger.logResponse(responseLogData);
|
|
181
|
+
// return result;
|
|
182
|
+
// };
|
|
183
|
+
// // Base API configuration
|
|
184
|
+
// export const baseApi = createApi({
|
|
185
|
+
// reducerPath: 'shriramApi',
|
|
186
|
+
// baseQuery: baseQueryWithEncryption,
|
|
187
|
+
// tagTypes: ['InterestRate'],
|
|
188
|
+
// endpoints: () => ({}),
|
|
189
|
+
// });
|
|
190
|
+
// // Export hooks for usage in functional components
|
|
191
|
+
// export const {
|
|
192
|
+
// usePrefetch,
|
|
193
|
+
// } = baseApi;
|
|
194
|
+
const react_1 = require("@reduxjs/toolkit/query/react");
|
|
195
|
+
const encryption_1 = require("../utils/encryption");
|
|
196
|
+
const encryptionConfig_1 = require("../config/encryptionConfig");
|
|
197
|
+
const apiConfig_1 = require("../config/apiConfig");
|
|
198
|
+
const apiLogger_1 = require("../utils/apiLogger");
|
|
199
|
+
const uuid_1 = require("uuid");
|
|
200
|
+
// ------------------------------
|
|
201
|
+
// Lazy API Config Loader
|
|
202
|
+
// ------------------------------
|
|
203
|
+
let apiConfig = null;
|
|
204
|
+
const ensureApiConfig = () => {
|
|
205
|
+
if (!apiConfig) {
|
|
206
|
+
apiConfig = (0, apiConfig_1.getApiConfig)();
|
|
207
|
+
if (!(0, apiConfig_1.validateApiConfig)(apiConfig)) {
|
|
208
|
+
throw new Error('Invalid API configuration');
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
return apiConfig;
|
|
212
|
+
};
|
|
213
|
+
// ------------------------------
|
|
214
|
+
// Encryption Toggle Utilities
|
|
215
|
+
// ------------------------------
|
|
216
|
+
let currentEncryptionState = true; // Enable encryption by default
|
|
217
|
+
const toggleEncryption = (enable) => {
|
|
218
|
+
const cfg = ensureApiConfig();
|
|
219
|
+
if (!cfg.allowEncryptionToggle)
|
|
220
|
+
return currentEncryptionState;
|
|
221
|
+
if (enable !== undefined)
|
|
222
|
+
currentEncryptionState = enable;
|
|
223
|
+
else
|
|
224
|
+
currentEncryptionState = !currentEncryptionState;
|
|
225
|
+
return currentEncryptionState;
|
|
226
|
+
};
|
|
227
|
+
exports.toggleEncryption = toggleEncryption;
|
|
228
|
+
const isEncryptionEnabled = () => currentEncryptionState;
|
|
229
|
+
exports.isEncryptionEnabled = isEncryptionEnabled;
|
|
230
|
+
const getCurrentApiConfig = () => (Object.assign(Object.assign({}, ensureApiConfig()), { enableEncryption: currentEncryptionState }));
|
|
231
|
+
exports.getCurrentApiConfig = getCurrentApiConfig;
|
|
232
|
+
// ------------------------------
|
|
233
|
+
// Utility Functions
|
|
234
|
+
// ------------------------------
|
|
235
|
+
const generateRequestId = () => (0, uuid_1.v4)();
|
|
236
|
+
// ------------------------------
|
|
237
|
+
// Custom Base Query with Encryption
|
|
238
|
+
// ------------------------------
|
|
239
|
+
const baseQueryWithEncryption = async (args, api, extraOptions) => {
|
|
240
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
241
|
+
const apiConfig = ensureApiConfig(); // 👈 Load config before first API call
|
|
242
|
+
const encryptionConfig = (0, encryptionConfig_1.getEncryptionConfig)();
|
|
243
|
+
const requestId = generateRequestId();
|
|
244
|
+
const timestamp = Date.now();
|
|
245
|
+
const url = typeof args === 'string' ? args : args.url;
|
|
246
|
+
const method = typeof args === 'string' ? 'GET' : args.method || 'GET';
|
|
247
|
+
let body = typeof args === 'string' ? undefined : args.body;
|
|
248
|
+
// Log request details in DEV mode (BEFORE encryption)
|
|
249
|
+
if (__DEV__) {
|
|
250
|
+
try {
|
|
251
|
+
const parsedBody = body && typeof body === 'string' ? JSON.parse(body) : body;
|
|
252
|
+
console.log('═══════════════════════════════════════════════════════════════');
|
|
253
|
+
console.log('🚀 [ShriramSDK] API REQUEST');
|
|
254
|
+
console.log('───────────────────────────────────────────────────────────────');
|
|
255
|
+
console.log('📍 Base URL:', apiConfig.baseUrl);
|
|
256
|
+
console.log('🔗 Endpoint:', url);
|
|
257
|
+
console.log('📌 Full URL:', `${apiConfig.baseUrl}${url}`);
|
|
258
|
+
console.log('🔧 Method:', method);
|
|
259
|
+
console.log('📦 Request Body:', parsedBody || 'No body');
|
|
260
|
+
console.log('🔐 Encryption:', currentEncryptionState ? 'Enabled' : 'Disabled');
|
|
261
|
+
console.log('🆔 Request ID:', requestId);
|
|
262
|
+
console.log('⏰ Timestamp:', new Date(timestamp).toISOString());
|
|
263
|
+
console.log('═══════════════════════════════════════════════════════════════');
|
|
264
|
+
}
|
|
265
|
+
catch (error) {
|
|
266
|
+
console.log('═══════════════════════════════════════════════════════════════');
|
|
267
|
+
console.log('🚀 [ShriramSDK] API REQUEST');
|
|
268
|
+
console.log('───────────────────────────────────────────────────────────────');
|
|
269
|
+
console.log('📍 Base URL:', apiConfig.baseUrl);
|
|
270
|
+
console.log('🔗 Endpoint:', url);
|
|
271
|
+
console.log('📌 Full URL:', `${apiConfig.baseUrl}${url}`);
|
|
272
|
+
console.log('🔧 Method:', method);
|
|
273
|
+
console.log('📦 Request Body (raw):', body || 'No body');
|
|
274
|
+
console.log('🔐 Encryption:', currentEncryptionState ? 'Enabled' : 'Disabled');
|
|
275
|
+
console.log('🆔 Request ID:', requestId);
|
|
276
|
+
console.log('⏰ Timestamp:', new Date(timestamp).toISOString());
|
|
277
|
+
console.log('═══════════════════════════════════════════════════════════════');
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
// Encrypt request body if enabled
|
|
281
|
+
if (currentEncryptionState && body && typeof args !== 'string') {
|
|
282
|
+
try {
|
|
283
|
+
const originalBody = typeof body === 'string' ? JSON.parse(body) : body;
|
|
284
|
+
const encryptedBody = await (0, encryption_1.encryptRequest)(originalBody, encryptionConfig);
|
|
285
|
+
args.body = JSON.stringify(encryptedBody);
|
|
286
|
+
body = args.body;
|
|
287
|
+
}
|
|
288
|
+
catch (error) {
|
|
289
|
+
// Handle encryption error silently
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
// Prepare base query
|
|
293
|
+
const baseQuery = (0, react_1.fetchBaseQuery)({
|
|
294
|
+
baseUrl: apiConfig.baseUrl,
|
|
295
|
+
timeout: apiConfig.timeout,
|
|
296
|
+
prepareHeaders: (headers, { getState }) => {
|
|
297
|
+
var _a, _b;
|
|
298
|
+
const token = (_b = (_a = getState()) === null || _a === void 0 ? void 0 : _a.auth) === null || _b === void 0 ? void 0 : _b.token;
|
|
299
|
+
if (token)
|
|
300
|
+
headers.set('authorization', `Bearer ${token}`);
|
|
301
|
+
const secureHeaders = (0, apiConfig_1.getSecureHeaders)();
|
|
302
|
+
Object.entries(secureHeaders).forEach(([key, value]) => {
|
|
303
|
+
headers.set(key, value);
|
|
304
|
+
});
|
|
305
|
+
// Inject onboarding identifiers
|
|
306
|
+
// ✅ FIX: Always use SDK's store state to prevent conflicts with parent app's store
|
|
307
|
+
try {
|
|
308
|
+
// First, try to get state from SDK's store (if available)
|
|
309
|
+
// This ensures we always use the SDK's store state, not the parent app's store
|
|
310
|
+
let state = null;
|
|
311
|
+
if (sdkStoreRef) {
|
|
312
|
+
state = sdkStoreRef.getState();
|
|
313
|
+
if (__DEV__) {
|
|
314
|
+
console.log('✅ [baseApi Interceptor] Using SDK store state for headers');
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
else {
|
|
318
|
+
// Fallback to middleware's getState() if SDK store ref not set
|
|
319
|
+
state = getState();
|
|
320
|
+
if (__DEV__) {
|
|
321
|
+
console.warn('⚠️ [baseApi Interceptor] SDK store ref not set, using middleware getState()');
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
const onboarding = state === null || state === void 0 ? void 0 : state.onboarding;
|
|
325
|
+
if (onboarding === null || onboarding === void 0 ? void 0 : onboarding.workflowInstanceId)
|
|
326
|
+
headers.set('workflowInstanceId', onboarding.workflowInstanceId);
|
|
327
|
+
if (onboarding === null || onboarding === void 0 ? void 0 : onboarding.applicationId)
|
|
328
|
+
headers.set('applicationId', onboarding.applicationId);
|
|
329
|
+
if (onboarding === null || onboarding === void 0 ? void 0 : onboarding.entityid) {
|
|
330
|
+
headers.set('entityid', onboarding.entityid);
|
|
331
|
+
if (__DEV__) {
|
|
332
|
+
console.log('✅ [baseApi Interceptor] entityId header set:', onboarding.entityid);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
else {
|
|
336
|
+
if (__DEV__) {
|
|
337
|
+
console.warn('⚠️ [baseApi Interceptor] entityId is missing from store state');
|
|
338
|
+
console.warn('Store state keys:', Object.keys(state || {}));
|
|
339
|
+
console.warn('Has onboarding?', 'onboarding' in (state || {}));
|
|
340
|
+
console.warn('onboarding state:', onboarding);
|
|
341
|
+
if (!sdkStoreRef) {
|
|
342
|
+
console.error('❌ [baseApi Interceptor] SDK store ref is not set! This may cause entityId to be missing.');
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
catch (error) {
|
|
348
|
+
if (__DEV__) {
|
|
349
|
+
console.error('❌ [baseApi Interceptor] Error getting onboarding state:', error);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
if (currentEncryptionState)
|
|
353
|
+
headers.set('X-Encrypted', 'true');
|
|
354
|
+
return headers;
|
|
355
|
+
},
|
|
356
|
+
});
|
|
357
|
+
// Log request
|
|
358
|
+
const requestLogData = {
|
|
359
|
+
method,
|
|
360
|
+
url,
|
|
361
|
+
baseUrl: apiConfig.baseUrl,
|
|
362
|
+
headers: {},
|
|
363
|
+
body,
|
|
364
|
+
timestamp,
|
|
365
|
+
requestId,
|
|
366
|
+
isEncrypted: currentEncryptionState,
|
|
367
|
+
};
|
|
368
|
+
apiLogger_1.apiLogger.logRequest(requestLogData);
|
|
369
|
+
// Execute the actual request
|
|
370
|
+
const result = await baseQuery(args, api, extraOptions);
|
|
371
|
+
// Handle decryption (success + error)
|
|
372
|
+
if (currentEncryptionState) {
|
|
373
|
+
if (result.data) {
|
|
374
|
+
try {
|
|
375
|
+
const decryptedData = await (0, encryption_1.decryptResponse)(result.data, encryptionConfig);
|
|
376
|
+
result.data = decryptedData;
|
|
377
|
+
}
|
|
378
|
+
catch (error) {
|
|
379
|
+
// Handle decryption error silently
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
if (result.error && result.error.data) {
|
|
383
|
+
try {
|
|
384
|
+
const decryptedErrorData = await (0, encryption_1.decryptResponse)(result.error.data, encryptionConfig);
|
|
385
|
+
result.error.data = decryptedErrorData;
|
|
386
|
+
}
|
|
387
|
+
catch (error) {
|
|
388
|
+
// Handle decryption error silently
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
// Log response
|
|
393
|
+
const duration = Date.now() - timestamp;
|
|
394
|
+
const responseLogData = {
|
|
395
|
+
status: ((_b = (_a = result.meta) === null || _a === void 0 ? void 0 : _a.response) === null || _b === void 0 ? void 0 : _b.status) || 200,
|
|
396
|
+
statusText: ((_d = (_c = result.meta) === null || _c === void 0 ? void 0 : _c.response) === null || _d === void 0 ? void 0 : _d.statusText) || 'OK',
|
|
397
|
+
headers: {},
|
|
398
|
+
data: result.data,
|
|
399
|
+
timestamp: Date.now(),
|
|
400
|
+
requestId,
|
|
401
|
+
duration,
|
|
402
|
+
isEncrypted: currentEncryptionState,
|
|
403
|
+
error: result.error,
|
|
404
|
+
};
|
|
405
|
+
apiLogger_1.apiLogger.logResponse(responseLogData);
|
|
406
|
+
// Log response details in DEV mode (AFTER decryption)
|
|
407
|
+
if (__DEV__) {
|
|
408
|
+
const status = ((_f = (_e = result.meta) === null || _e === void 0 ? void 0 : _e.response) === null || _f === void 0 ? void 0 : _f.status) || 200;
|
|
409
|
+
const isSuccess = status >= 200 && status < 300;
|
|
410
|
+
console.log('═══════════════════════════════════════════════════════════════');
|
|
411
|
+
console.log(isSuccess ? '✅ [ShriramSDK] API RESPONSE - SUCCESS' : '❌ [ShriramSDK] API RESPONSE - ERROR');
|
|
412
|
+
console.log('───────────────────────────────────────────────────────────────');
|
|
413
|
+
console.log('📍 Base URL:', apiConfig.baseUrl);
|
|
414
|
+
console.log('🔗 Endpoint:', url);
|
|
415
|
+
console.log('📌 Full URL:', `${apiConfig.baseUrl}${url}`);
|
|
416
|
+
console.log('🔧 Method:', method);
|
|
417
|
+
console.log('📊 Status:', status, ((_h = (_g = result.meta) === null || _g === void 0 ? void 0 : _g.response) === null || _h === void 0 ? void 0 : _h.statusText) || 'OK');
|
|
418
|
+
console.log('⏱️ Duration:', `${duration}ms`);
|
|
419
|
+
console.log('🔐 Encryption:', currentEncryptionState ? 'Enabled' : 'Disabled');
|
|
420
|
+
console.log('🆔 Request ID:', requestId);
|
|
421
|
+
if (result.data) {
|
|
422
|
+
console.log('📥 Response Data:', result.data);
|
|
423
|
+
}
|
|
424
|
+
if (result.error) {
|
|
425
|
+
console.log('⚠️ Error:', result.error);
|
|
426
|
+
}
|
|
427
|
+
console.log('═══════════════════════════════════════════════════════════════');
|
|
428
|
+
}
|
|
429
|
+
return result;
|
|
430
|
+
};
|
|
431
|
+
// ------------------------------
|
|
432
|
+
// SDK Store Reference
|
|
433
|
+
// ------------------------------
|
|
434
|
+
// Store reference to SDK's store to ensure interceptor always uses SDK's store state
|
|
435
|
+
// This prevents conflicts when parent app also uses baseApi.middleware
|
|
436
|
+
let sdkStoreRef = null;
|
|
437
|
+
const setSDKStoreRef = (store) => {
|
|
438
|
+
sdkStoreRef = store;
|
|
439
|
+
if (__DEV__) {
|
|
440
|
+
console.log('✅ [baseApi] SDK store reference set');
|
|
441
|
+
}
|
|
442
|
+
};
|
|
443
|
+
exports.setSDKStoreRef = setSDKStoreRef;
|
|
444
|
+
const getSDKStoreRef = () => sdkStoreRef;
|
|
445
|
+
exports.getSDKStoreRef = getSDKStoreRef;
|
|
446
|
+
// ------------------------------
|
|
447
|
+
// Base API Configuration
|
|
448
|
+
// ------------------------------
|
|
449
|
+
exports.baseApi = (0, react_1.createApi)({
|
|
450
|
+
reducerPath: 'shriramApi',
|
|
451
|
+
baseQuery: baseQueryWithEncryption,
|
|
452
|
+
tagTypes: ['InterestRate'],
|
|
453
|
+
endpoints: () => ({}),
|
|
454
|
+
});
|
|
455
|
+
// Export hooks
|
|
456
|
+
exports.usePrefetch = exports.baseApi.usePrefetch;
|