6.4.3 • Published 2 months ago
@ikonintegration/idmclient
Licence
—
Version
6.4.3
Deps
9
Size
110 kB
Vulns
0
Weekly
0
IDM-client 
IDM browser & nodejs API client
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',
//enable sso code to redirect URIs (on CB URL impersonate feature)
enableSSOCodeOnRedirects: false,
//disable impersonate feature (can be enabled on the sender and receiver)
disableImpersonatingApp: true,
//External auth mode
externalAuth: true, //should use external authentication (redirect)
externalAuthDomain?: 'auth-dev.AA-AA.ca',
externalAuthPath?: '/login',
externalValidatePath?: '/validate',
externalRegistrationPath?: '/register',
externalProfilePath?: '/profile',
//Facilitators
//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.htmlwith the following content:
<!DOCTYPE html>
<html lang="en"><head> </head> <body> <script src="./index.js"> </script> </body> </html>
- Create
index.jsatcookiesHub/index.jswith 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}IDM-client 
IDM browser & nodejs API client
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',
//enable sso code to redirect URIs (on CB URL impersonate feature)
enableSSOCodeOnRedirects: false,
//disable impersonate feature (can be enabled on the sender and receiver)
disableImpersonatingApp: true,
//External auth mode
externalAuth: true, //should use external authentication (redirect)
externalAuthDomain?: 'auth-dev.AA-AA.ca',
externalAuthPath?: '/login',
externalValidatePath?: '/validate',
externalRegistrationPath?: '/register',
externalProfilePath?: '/profile',
//Facilitators
//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 __INLINE_CODE_0__
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 __INLINE_CODE_1__
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 __INLINE_CODE_2__ with the following content:
<!DOCTYPE html>
<html lang="en"><head> </head> <body> <script src="./index.js"> </script> </body> </html>
- Create __INLINE_CODE_3__ at __INLINE_CODE_4__ with the following contents :
;
else return `:\/\/(www\.)?${domain}IDM-client 
IDM browser & nodejs API client
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',
//enable sso code to redirect URIs (on CB URL impersonate feature)
enableSSOCodeOnRedirects: false,
//disable impersonate feature (can be enabled on the sender and receiver)
disableImpersonatingApp: true,
//External auth mode
externalAuth: true, //should use external authentication (redirect)
externalAuthDomain?: 'auth-dev.AA-AA.ca',
externalAuthPath?: '/login',
externalValidatePath?: '/validate',
externalRegistrationPath?: '/register',
externalProfilePath?: '/profile',
//Facilitators
//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 __INLINE_CODE_0__
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 __INLINE_CODE_1__
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 __INLINE_CODE_2__ with the following content:
<!DOCTYPE html>
<html lang="en"><head> </head> <body> <script src="./index.js"> </script> </body> </html>
- Create __INLINE_CODE_3__ at __INLINE_CODE_4__ with the following contents :
;
}).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 buildas a npm script. (build-hub) - Add
npm run build-hubto the start of your build instructions. (Example package.jsonbuild) - Also add
npm run build-hubto start of youstartscript to allow local usage. - This will generate the
/public/hub/index.jsat build time, so include it on.gitignore - Add the following to your
buildspec.ymlfileaws s3 cp --acl public-read --cache-control="max-age=0, no-cache, no-store, must-revalidate" ./hub/index.html s3://${DEPLOY_BUCKET}/hubaws 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