React HOC for Helixa SSO
npm install hx-with-sso-hocThe withSSO hoc can be used to wrap any Helixa react application that needs SSO auth.
the HOC handles all the redirects and tokens needed in order to auth the hosting application.
See React HOC
> A higher-order component (HOC) is an advanced technique in React for reusing component logic. HOCs are not part of the React API, per se. They are a pattern that emerges from React’s compositional nature.
----
#### Install the package
npm i hx-with-sso-hoc --save
#### Then import the HOC
``javascript`
import withSSO from 'hx-with-sso-hoc'
Then the current app needs to be wrapped with needed parameters.
Es:
`javascript
class App extends React.Component {
render() {
const { logged, singleSignOff } = this.props;
return(
{logged}
)
}
}
export default withSSO({
appID: process.env.REACT_APP_APP_ID,
idServerBase: process.env.REACT_APP_ID_SERVER_BASE,
idServerBaseSignIn: process.env.REACT_APP_ID_SERVER_AUTH,
idTokenKey: 'HELIXA_ID_TOKEN',
accessTokenKey: 'HELIXA_ACCESS_TOKEN',
})(App);
``
Config example of the envs: ``
REACT_APP_ID_SERVER_BASE=//accounts.helixa.ai
REACT_APP_ID_SERVER_AUTH=//accounts.helixa.ai/login
REACT_APP_APP_ID=hx-engine-ui