react-hfn-profile
Configuration Variables to be set in .env:
// firebase config for Profile auth
REACT_APP_FIREBASE_AUTH_CONFIG='{"apiKey":"XXXXXXXXXX","authDomain":"XXXXXXXXXXX","projectId":"XXXXX","messagingSenderId":"99999999999999","appId":"XXXXXXXXXXXXXXX"}'
// config for Profile API access
REACT_APP_MYSRCM_CONFIG='{"xClientId":"SSSSSSSSSSSSSS", "profileServer":"http://profile.XXXXXXXXXX"}'
// optional config for secondary firebase instance
REACT_APP_FIREBASE_DFLT_CONFIG='{"apiKey":"XXXXXXXXXX","authDomain":"XXXXXXXXXXX","databaseURL":"https://XXXXXXXXXXXX","projectId":"XXXXXXXXXXX","storageBucket":"XXXXXXXXXXXXX","messagingSenderId":"33333333333333333","appId":"XXXXXXXXXXXXXXXXXXXXXX"}'
// config for Reg Server - optional only if reg server apis are needed
REACT_APP_REG_SERVER="XXXXXXXXXXXXXXXX"
Exports
-
HfnFirebaseAuth - Wrapper on top of StyledFirebaseAuth with necessary plumbing for Profile APIs
-
signOut() - method for sign out
-
fetchProfileAPI(api, method="GET", extraHdrs={}, extraData={}) - Profile Server REST APIs wrapper
-
fetchProfileMe() - sugar for the api "/me"
-
getFirebaseApp() - firebase app (secondary) instance if REACT_APP_FIREBASE_DFLT_CONFIG variable is set
-
HfnAvatar - Component that displays the image/initial of the logged in user, with a dropdown menu for My Profile and Sign Out.
-
isSignedIn() - true or false based on whether the user is signed in or not
-
xUserId() - uid of the signed in user
-
xUserName() - user display name of the signed in user
-
xAbhyasiId() - abhyasi ID of the signed in user, if exists, or "" (empty string)
-
xUserPhoto() - photo url of the signed in user
-
xUserEmail() - email id of the signed in user
-
xIsPrefect() - is the signed user a prefect?
-
xMe() - /me info for the signed in user
-
authenticatedRequest(url, method = "GET", headers = {}, data = {}) - Wrapper on top of fetch request which adds the appropriate authorization headers
-
authenticatedCall(fn, onSuccessCallback) - calls the passed function fn with the parameters fn(uid, token, onSuccessCallback). The function gets passed the uid and token values. The function is expected to call onSuccessCallback(payload) with result.
-
EnsureHfnSignedIn - React Component decorator to render children components if signed in, otherwise HfnFirebaseAuth Component
-
fetchKanhaRegAPI(api, method, paramsDict) - REST API wrapper for Reg Server
Sugars for fetchKanhaRegAPI
getKanhaRegApi(api, payload = {}, extraHdrs = {}, extraData = {})
postKanhaRegApi = (api, payload, extraHdrs = {}, extraData = {})
putKanhaRegApi = (api, payload, extraHdrs = {}, extraData = {})
deleteKanhaRegApi = (api, payload, extraHdrs = {}, extraData = {})
getKanhaRegApiId = (api, id, payload = {}, extraHdrs = {}, extraData = {})
postKanhaRegApiId = (api, id, payload, extraHdrs = {}, extraData = {})
putKanhaRegApiId = (api, id, payload, extraHdrs = {}, extraData = {})
deleteKanhaRegApiId = (api, id, payload = {}, extraHdrs = {}, extraData = {})
getKanhaRegApiPk = (api, pk, payload = {}, extraHdrs = {}, extraData = {})
postKanhaRegApiPk = (api, pk, payload, extraHdrs = {}, extraData = {})
putKanhaRegApiPk = (api, pk, payload, extraHdrs = {}, extraData = {})
deleteKanhaRegApiPk = (api, pk, payload = {}, extraHdrs = {}, extraData = {})
Setup
# npm i @heartfulnessinstitute/react-hfn-profile -S