@ikonintegration/reactnative-idmclient
v5.1.14
Published
IDM Client for React native
Downloads
12
Readme
idm-client-react-native
IDM Client for React native
Overall
Opts
{
//General Configs
apiEndpoint: 'https://api.auth-dev.AA-AA.ca',
cookiesEndpoint: 'https://auth-dev.AA-AA.ca',
//disable client logs to console
disableLogs?: false,
//if false it will add 10 minutes gap to JWT expiration to make sure we renew it before actually using it.
jwtAPIMode?: false,
//auto enrol role, can be an array of roles. After login, client will auto enroll user into specified roles (if not present on logged JWT) and will return login response only after enrollement.
autoEnrollRole?: 'AAA',
//External auth mode
externalAuth: true, //should use external authentication (redirect)
externalAuthDomain?: 'auth-dev.AA-AA.ca',
externalAuthPath?: '/login',
externalValidatePath?: '/validate',
externalRegistrationPath?: '/register',
externalProfilePath?: '/profile',
//Faciliatators
//Roles mapping
roles?: { //Optional roles
USER: 'AA-AA',
},
//Partitions mapping
partitions?: { //Optional partitions mapping
PROFESSIONAL: 'AA',
},
}
Configure Cookies Hub on the website
Create separated build process
- `mkdir cookiesHub && cd cookiesHub && npm init -y && npm install --save-dev webpack webpack-cli babel-loader @babel/core @babel/preset-env @babel/runtime @babel/plugin-transform-runtime @babel/plugin-proposal-decorators @babel/plugin-proposal-class-properties && npm i -S cross-storage`
- Add into `cookiesHub/package.json`
```
"scripts": {
"clean": "rm ../public/hub/index.js",
"build-dev": "webpack --mode development",
"build": "webpack --mode production"
},
```
Setup Hub build
- Add into
cookiesHub/babel.config.js
module.exports = function (api) {
api.cache(false);
const presets = [
[ "@babel/preset-typescript"],
[
"@babel/preset-env",
{
"corejs": { "version": 3 },
"useBuiltIns": "usage",
"targets": { "edge": "17", "firefox": "60", "chrome": "67", "safari": "11.1", "ie": "11" }
}
]
];
const plugins = [
["@babel/plugin-proposal-decorators",{"decoratorsBeforeExport":true}],
["@babel/plugin-proposal-class-properties"],
["@babel/transform-runtime"]
];
return { presets, plugins };
};
- Add into
cookiesHub/webpack.config.js
const webpack = require('webpack');
const path = require('path');
const config = {
entry: './index.js',
output: {
path: path.resolve(__dirname, '../public/hub'),
filename: 'index.js'
},
module: {
rules: [
{
test: /\.js$/,
use: 'babel-loader',
exclude: /node_modules/
}
]
}
};
module.exports = config;
Create hub source
- Create index.html at
public/hub/index.html
with the following content:
<!DOCTYPE html>
<html lang="en"><head> </head> <body> <script src="./index.js"> </script> </body> </html>
- Create
index.js
atcookiesHub/index.js
with the following contents :
import "core-js/stable";
//Config
const config = require('../src/app/config/config');
//Hub
const CrossStorageHub = require('cross-storage').CrossStorageHub;
const DefaultCookiesHubPermissioning = ['get', 'set', 'del'];
/* Private helper */
function _transformDomainToHubFormat(domainsList) {
return domainsList.map((domain) => {
if (domain.includes('*')) return `\.${domain}$`;
else return `:\/\/(www\.)?${domain}$`;
}).map((regex) => {
return { origin: new RegExp(regex), allow: DefaultCookiesHubPermissioning };
});
}
//Open hub
const allowedDomains = _transformDomainToHubFormat(Object.keys(config.ThemeDomainsMapping));
CrossStorageHub.init(allowedDomains);
Modify your build
- Add
cd cookiesHub && npm i && npm run build
as a npm script. (build-hub
) - Add
npm run build-hub
to the start of your build instructions. (Example package.json:scripts:build) - Also add
npm run build-hub
to start of youstart
script to allow local usage. - This will generate the
/public/hub/index.js
at build time, so include it on.gitignore
- Add the following to your
buildspec.yml
fileaws s3 cp --acl public-read --cache-control="max-age=0, no-cache, no-store, must-revalidate" ./hub/index.html s3://${DEPLOY_BUCKET}/hub
aws s3 cp --acl public-read --cache-control="max-age=0, no-cache, no-store, must-revalidate" ./hub/index.js s3://${DEPLOY_BUCKET}/hub
- Add
/hub/*
to your cloud front invalidation onbuildpsec.yml