uae-frontend-auth1
v1.0.20
Published
Makes use of the following APIs: - **/user/device** for device uuid creation - **/user/visit** for visit creation - **/user/ip** for session verification and ip data retrieval - **/user/enquiries** for enquiry data retrieval
Downloads
15
Readme
✨ URL, Enquiry, Device, Visit and IP verification
Makes use of the following APIs:
- /user/device for device uuid creation
- /user/visit for visit creation
- /user/ip for session verification and ip data retrieval
- /user/enquiries for enquiry data retrieval
🚀 Installation
$ npm install uae-frontend-auth
🔧 Usage
import { AuthProvider } from 'uae-frontend-auth';
const App = () => {
return (
<AuthProvider>
<BeforeAnyApplicationLogic/>
</AuthProvider>
);
};
For accessing the deviceUuid
, visitId
, ip data, countryProductId
and enquiry data, you can use the following hook:
import { useAuth } from 'uae-frontend-auth';
const {
enquiryId, // string, enquiry id; null if not available or loading is true
enquiries, // array of objects, enquiry data; empty array if not available or loading is true
countryProductId, // number, country product id; null if not available or loading is true
deviceUuid, // string, device uuid; null if not available or loading is true
visitId, // number, visit id; null if not available or loading is true
IPData, // object containing ip data; empty object if not available or loading is true
loading, // boolean, true if authentication is in progress
} = useAuth();
enquiryId
, deviceUuid
, visitId
, countryProductId
and sourceId
are also stored in the local storage.
You can access them directly from the local storage as well.
visitId
key in the local storage is
"visitId_${countryProductId}"
Others are stored as it is.
📝 Note
- Three events are fired during the lifecycle of enquiry API:
ENQUIRY_API_INITIATED
when the API is initiatedENQUIRY_API_SUCCESS
when the API is successfulENQUIRY_API_FAILURE
when the API fails
- The following environment variables are required (if not present, the application will not start):
REACT_APP_ENV
REACT_APP_ENQUIRY_ENCRYPTION_IV_NEW
REACT_APP_ENQUIRY_ENCRYPTION_KEY_NEW