revbits-cip-integration
v1.0.30
Published
This package will integrate CIP with any product
Downloads
71
Maintainers
Readme
RevBits - CIP Integration
Description
The revbits-cip-integration
npm package is a comprehensive toolkit designed to streamline and enhance your integration with the CIP (Cyber Intelligence Platform)
API. This powerful package empowers developers by providing a range of robust functionalities to interact with user management, role-based access control, permission management, and notifications within the CIP
ecosystem.
With revbits-cip-integration
, you can seamlessly retrieve, create, update, and delete user data, enabling smooth synchronization between your application and the CIP
system. Effortlessly manage roles and permissions, granting or revoking access rights with ease. Stay on top of crucial events and notifications by leveraging the package's capabilities to send, receive, and process notifications, ensuring timely and efficient communication within your application.
Additionally, the revbits-cip-integration
package offers a powerful event-based mechanism that allows you to monitor data changes on the CIP
side. Whenever there are changes to user data, such as updates to user profiles or role assignments, the package provides event notifications, enabling you to respond dynamically and keep your application's data in sync with the latest changes in the CIP
system.
The revbits-cip-integration
npm package is meticulously designed to offer a user-friendly and intuitive interface, reducing development complexity and allowing developers to focus on building exceptional integrations. It serves as a valuable tool for integrating your application with the CIP
API, enabling you to leverage the full potential of the CIP
platform and deliver a seamless experience to your users.
By leveraging the revbits-cip-integration
npm package, you can harness the power of the CIP
API effortlessly, unlocking a world of possibilities for your application while ensuring secure and efficient data management within the CIP
system.
Table of Contents
Requirements
- It requires Node.js v16+ to run.
- You must have CIP Product.
Installation
npm install revbits-cip-integration
Once the package is installed, you can import the CIP
library by using
const { CIP } = require('revbits-cip-integration');
Usage
To use revbits-cip-integration
, follow these steps:
- Import the
CIP
class from the package:
const { CIP } = require('revbits-cip-integration');
- Create a new instance of
CIP
by providing the necessary configuration options:
const privKey = fs.readFileSync(PRIVATE_KEY_PATH, { encoding: 'utf-8' });
// Create a new instance of CIP with the specified parameters
const cip = new CIP(
CIP_BASE_URL,
SOCKET_POSTFIX,
PLATFORM,
privKey,
{
tlsRejectUnauthorized: false, // Set to `false` if you need to use self-signed certificates on CIP
timeout: 5000, // Specify the API timeout in milliseconds
},
(event) => {
console.log(event); // This will log Socket Events triggered when there are data changes on CIP
},
);
- CIP Library prints some logs, like socket connection & reconnection, To enhance your experience with the CIP Library, you have the flexibility to disable the generation of logs
set HIDE_CIP_LOGS=true
in .env
HIDE_CIP_LOGS=true
or in your code before using library
process.env.HIDE_CIP_LOGS = 'true';
Available Methods
Available Methods for cip
instance
The CIP Library automatically includes the platform information in every request, so there is no need for you to explicitly pass the platform parameter each time.
| Method | Description | Definition | | --------------------------------------- | ----------------------------------------------- | ------------------------------------------------------------------------- | | getUsers | To Get Paginated Users | cip.getUsers(?OPTIONS) | | getUser | To Get Single User | cip.getUser(USER_ID) | | getUserByUsername | To Get User by username/email | cip.getUserByUsername(USER_NAME) | | createUser | To Create a User on CIP | cip.createUser({ user: USER_ATTRIBUTES }, ?ACTOR) | | createBulkUsers | To Create Bulk Users on CIP | cip.createBulkUsers({ users: [USERS_ATTRIBUTES] }, ?ACTOR) | | updateUser | To Update a User on CIP | cip.updateUser({ id: USER_ID, user: { ...UPDATED_ATTRIBUTES } }, ?ACTOR) | | uploadAvatar | To upload User Avatar on CIP | cip.uploadAvatar(AVATAR_PATH, ACTOR) | | deleteUser | To Delete User | cip.deleteUser(USER_ID, ?ACTOR) | | restoreUser | To Restore User | cip.restoreUser(USER_ID, ?ACTOR) | | logout | To Logout | cip.logout(ACTOR) | | updateDashboard | To Update Dashboard | cip.updateDashboard(ACTOR) | | checkUsersExistenceByUsernames | To Check Users Existence using usernames | cip.checkUsersExistenceByUsernames([...USERNAMES], ?ACTOR) | | checkUsersExistenceByIds | To Check Users Existence using IDs | cip.checkUsersExistenceByIds([...IDS], ?ACTOR) | | getRoles | To Get Paginated Roles | cip.getRoles(?OPTIONS) | | getRole | To Get a Single Role | cip.getRole(ROLE_ID) | | createRole | To Create a Role on CIP | cip.createRole({ role: ROLE_ATTRIBUTES }, ?ACTOR) | | createBulkRoles | To Create Bulk Roles on CIP | cip.createBulkRoles({ users: [ROLES_ATTRIBUTES] }, ?ACTOR) | | updateRole | To Update Role on CIP | cip.updateRole({ id: ROLE_ID, role: { ...UPDATED_ATTRIBUTES } }, ?ACTOR) | | checkRolesExistenceByNames | To Check Roles Existence using names | cip.checkRolesExistenceByNames([...NAMES], ?ACTOR) | | checkRolesExistenceByIds | To Check Roles Existence using IDs | cip.checkRolesExistenceByIds([...IDS], ?ACTOR) | | deleteRole | To Delete Role from CIP | cip.deleteRole(ROLE_ID, ?ACTOR) | | getPermissions | To Get Permissions | cip.getPermissions() | | getPermission | To Get a Single Permission | cip.getPermission(PERMISSION_KEY) | | syncPermissions | To Sync Permissions on CIP | cip.syncPermissions({ permissions: PERMISSIONS_ATTRIBUTES }, ?ACTOR) | | deletePermission | To Delete Permission from CIP | cip.deletePermission(PERMISSION_KEY, ?ACTOR) | | deletePlatformPermissions | To Delete All Platform Permissions from CIP | cip.deletePlatformPermissions(?ACTOR) | | getNotifications | To Get Paginated Notifications | cip.getNotifications(?OPTIONS) | | getNotification | To Get Single Notifications | cip.getNotification(PLATFORM_NOTIFICATION_ID) | | createNotification | To Create Notification | cip.createNotification({ notification: NOTIFICATION_ATTRIBUTES }, ?ACTOR) | | createBulkNotifications | To Create Bulk Notifications | cip.createBulkNotifications({ notifications: NOTIFICATIONS }, ?ACTOR) | | updateBulkNotificationsData | To Update Bulk Notifications Attributes | cip.updateBulkNotificationsData({ notifications: NOTIFICATIONS }, ?ACTOR) | | readNotification | To Read Notification | cip.readNotification(PLATFORM_NOTIFICATION_ID, APP_NAME, ACTOR) | | deleteNotification | To Delete Notifications | cip.deleteNotification(PLATFORM_NOTIFICATION_ID, APP_NAME, ?ACTOR) | | getAllPlatformsNotifications | To Get All Platforms Notifications | cip.getAllPlatformsNotifications() | | getAllPlatformsUnreadNotificationsCount | To Get All Platforms Unread Notifications Count | cip.getAllPlatformsUnreadNotificationsCount() | | getPlatformsConfig | To Get Platforms Configurations | cip.getPlatformsConfig(ACTOR) | | getUserAccessConfig | To Get User Access Configurations | cip.getUserAccessConfig(ACTOR) | | getCipUrlsConfig | To Get CIP URL Configurations | cip.getCipUrlsConfig (ACTOR) | | createInventory | To Create Inventory | cip.createInventory (DATA, ACTOR) |
For methods that require
audit logs
, you have the flexibility to pass anactor
as an argument. In case you don't provide anactor
, the default option is to use theCIP BOT
as theactor
in the audit logs on theCIP
platform.
Sample Actor (it must contain username
)
const actor = { username: '[email protected]' };
Users Usage
To Retrieve a list of users (Paginated Results)
cip.getUsers(?OPTIONS)
.then(result => console.log(result))
.catch(err => console.error(err));
To Retrieve single User
cip
.getUser(USER_ID)
.then((result) => console.log(result))
.catch((err) => console.error(err));
To Retrieve single User by username/email
cip
.getUserByUsername(USER_NAME)
.then((result) => console.log(result))
.catch((err) => console.error(err));
To Create User
cip.createUser({ user: USER_ATTRIBUTES }, ?ACTOR)
.then(result => console.log(result))
.catch(err => console.error(err));
To Create Bulk Users
To adhere to the maximum limit of 50 records per request, you need to ensure that if you have more than 50 records, you split them into smaller chunks of 50. Then, you can call the createBulkUsers function for each chunk separately.
cip.createBulkUsers({ users: [USER_ATTRIBUTES] }, ?ACTOR)
.then(result => console.log(result))
.catch(err => console.error(err));
To Update User
cip.updateUser({ id: USER_ID, user: { ...UPDATED_ATTRIBUTES } }, ?ACTOR)
.then(result => console.log(result))
.catch(err => console.error(err));
To Upload User Avatar
NOTE: Actor is required.
Avatar Path should be
Absolute Path
cip
.uploadAvatar(AVATAR_PATH, ACTOR)
.then((result) => console.log(result))
.catch((err) => console.error(err));
To Delete User
cip.deleteUser(USER_ID, ?ACTOR)
.then(result => console.log(result))
.catch(err => console.error(err));
To Restore User
cip.restoreUser(USER_ID, ?ACTOR)
.then(result => console.log(result))
.catch(err => console.error(err));
To Logout
cip
.logout(ACTOR)
.then((result) => console.log(result))
.catch((err) => console.error(err));
To Check Users Existence using Usernames
cip
.checkUsersExistenceByUsernames([...USERNAMES])
.then((result) => console.log(result))
.catch((err) => console.error(err));
To Check Users Existence using IDs
cip
.checkUsersExistenceByIds([...IDS])
.then((result) => console.log(result))
.catch((err) => console.error(err));
Roles Usage
To Retrieve a list of roles (Paginated Results)
cip.getRoles(?OPTIONS)
.then(result => console.log(result))
.catch(err => console.error(err));
To Retrieve single Role
cip
.getRole(ROLE_ID)
.then((result) => console.log(result))
.catch((err) => console.error(err));
To Create Role
cip.createRole({ role: ROLE_ATTRIBUTES }, ?ACTOR)
.then(result => console.log(result))
.catch(err => console.error(err));
To Create Bulk Roles
To adhere to the maximum limit of 50 records per request, you need to ensure that if you have more than 50 records, you split them into smaller chunks of 50. Then, you can call the createBulkUsers function for each chunk separately.
cip.createBulkRoles({ roles: [ROLES_ATTRIBUTES] }, ?ACTOR)
.then(result => console.log(result))
.catch(err => console.error(err));
To Update Role
cip.updateRole({ id: ROLE_ID, role: { ...UPDATED_ATTRIBUTES } }, ?ACTOR)
.then(result => console.log(result))
.catch(err => console.error(err));
To Delete Role
cip.deleteRole(ROLE_ID, ?ACTOR)
.then(result => console.log(result))
.catch(err => console.error(err));
To Check Roles Existence using Names
cip
.checkRolesExistenceByNames([...NAMES])
.then((result) => console.log(result))
.catch((err) => console.error(err));
To Check Roles Existence using IDs
cip
.checkRolesExistenceByIds([...IDS])
.then((result) => console.log(result))
.catch((err) => console.error(err));
Permissions Usage
To Retrieve a list of permissions
cip
.getPermissions()
.then((result) => console.log(result))
.catch((err) => console.error(err));
To Retrieve single Permission
cip
.getPermission(PERMISSION_KEY)
.then((result) => console.log(result))
.catch((err) => console.error(err));
To sync permissions
cip.syncPermissions({ permissions: PERMISSIONS }, ?ACTOR)
.then(result => console.log(result))
.catch(err => console.error(err));
To delete Permission
cip.deletePermission(PERMISSION_KEY, ?ACTOR)
.then(result => console.log(result))
.catch(err => console.error(err));
To delete all platform Permissions
cip.deletePlatformPermissions(?ACTOR)
.then(result => console.log(result))
.catch(err => console.error(err));
Notifications Usage
To Retrieve a list of notifications (Paginated Results)
cip.getNotifications(?OPTIONS)
.then(result => console.log(result))
.catch(err => console.error(err));
To retrieve single Notification
cip
.getNotification(PLATFORM_NOTIFICATION_ID)
.then((result) => console.log(result))
.catch((err) => console.error(err));
To create Notification
cip.createNotification({ notification: NOTIFICATION_ATTRIBUTES }, ?ACTOR)
.then(result => console.log(result))
.catch(err => console.error(err));
To create bulk notifications
cip.createBulkNotifications({notifications: NOTIFICATIONS}, ?ACTOR)
.then(result => console.log(result))
.catch(err => console.error(err));
To read bulk notifications
cip.updateBulkNotificationsData({ids: NOTIFICATION_IDS, userIds: USER_IDS}, ?ACTOR)
.then(result => console.log(result))
.catch(err => console.error(err));
To read Notification
NOTE: Actor is required to Read Notification
cip
.readNotification(PLATFORM_NOTIFICATION_ID, APP_NAME, ACTOR)
.then((result) => console.log(result))
.catch((err) => console.error(err));
To delete notification
cip.deleteNotification(PLATFORM_NOTIFICATION_ID, APP_NAME, ?ACTOR)
.then(result => console.log(result))
.catch(err => console.error(err));
To get all platforms notifications
cip
.getAllPlatformsNotifications()
.then((result) => console.log(result))
.catch((err) => console.error(err));
To get all platforms unread notifications count
cip
.getAllPlatformsUnreadNotificationsCount()
.then((result) => console.log(result))
.catch((err) => console.error(err));
Configurations Usage
To get platforms configurations
cip
.getPlatformsConfig(ACTOR)
.then((result) => console.log(result))
.catch((err) => console.error(err));
To get user access configurations
cip
.getUserAccessConfig(ACTOR)
.then((result) => console.log(result))
.catch((err) => console.error(err));
To get CIP URLs Configurations
cip
.getCipUrlsConfig(ACTOR)
.then((result) => console.log(result))
.catch((err) => console.error(err));
To Update Dashboard
cip
.updateDashboard(ACTOR)
.then((result) => console.log(result))
.catch((err) => console.error(err));
To Create Inventory
cip
.createInventory(DATA, ACTOR)
.then((result) => console.log(result))
.catch((err) => console.error(err));
Example
Here are some sample requests for you to try out. Feel free to log the responses if you want to examine them further. You can refer to the interfaces provided to understand the structure of the requests and responses.
CIP Example
You can create an instance of CIP by passing necessary configurations options:
NOTE: Please ensure that you create an instance of the CIP class asynchronously on your server-side. This is important because the operation can block the execution of code when listening to socket events in the callback. If you use the await keyword during the initialization of the CIP instance, your code will be blocked at that point. To avoid this, make sure to handle the initialization asynchronously using async/await or by using promises. This allows your code to continue executing other tasks while the CIP instance is being created in the background.
const baseUrl = 'https://revbits-cip-server.net'; // The base URL of the CIP platform (excluding api/v2)
const socketPostfix = ':8889'; // The postfix for the socket connection (e.g., '/pws' for Cloud CIP)
const platform = 'pam'; // The platform identifier (e.g., pam, eps, ztn, es, dt, pp or any other CIP registered Platform)
const privKey = fs.readFileSync('jwt-keys/cip/private.key', { encoding: 'utf-8' }); // CIP Provided Platform Private Key for JWT Signing
// Create a new instance of CIP with the specified parameters
const cip = new CIP(
baseUrl,
socketPostfix,
platform,
privKey,
{
tlsRejectUnauthorized: false, // Set to `true` if you want to reject self-signed certificates (default: false)
timeout: 20000, // The API timeout in milliseconds (default: 10000)
},
(_event) => {
// The callback function for socket events on data changes is not mandatory. If you prefer not to listen to these events, you can simply omit passing this callback function.
console.log(_event); // Log Socket Events triggered when there are data changes on CIP
// Sample Event
// {
// cipEvent: {
// action: 'created',
// model: 'user',
// id: '3b6d6a1e-cbb2-4599-8ccf-972128393a9b',
// ...
// },
// event: 'updated-user',
// data: User | Role | Permission | Notification
// }
// You can apply conditions here when event is received
// for example, an event receives, `updated-user`, then you will update that user in your database
if (_event.event === 'updated-user') {
const latestUser = _event.data; // Upon the occurrence of an event trigger, the CIP Library will automatically make a call to the CIP Server to retrieve the latest data associated with that event.
// Update latest user in DB
UserModel.findAndUpdate(latestUser, {
where: { id: latestUser.id },
});
}
},
);
When using any of the APIs listed below, it is crucial to implement proper error handling. Neglecting to do so could result in server crashes.
Users Example
To retrieve list of users
// You can use below options in getUsers (These are optional)
const options = {
page?: number; // You will need to pass page to get paginated results (Default: 1)
sort?: string; // if you want to sort by some column like username
direction?: string; // Specify direction asc, desc for sorting
perPage?: number; // Specifiy how many records you need per page (Default: 250)
query?: { // You can use this if you need advance search
usernames?: Array<string>;
ids?: Array<string>;
notIds?: Array<string>;
username?: string;
firstname?: string;
lastname?: string;
verified?: boolean;
active?: boolean;
};
};
cip.getUsers(options)
.then(result => console.log(result))
.catch(err => console.error(err));
To retrieve single user
const user_id = 'ef7a4a52-83c3-4a13-8a18-130fa23ea821';
cip
.getUser(user_id)
.then((result) => console.log(result))
.catch((err) => console.error(err));
To Retrieve single User by username/email
const username = '[email protected]';
cip
.getUserByUsername(username)
.then((result) => console.log(result))
.catch((err) => console.error(err));
To create user
const UserPlatformAccess = {
dt_enabled: boolean;
es_enabled: boolean;
pp_enabled: boolean;
up_enabled: boolean;
eps_enabled: boolean;
pam_enabled: boolean;
};
const data = {
user: {
firstname: string;
lastname: string;
username: string;
password: string;
usersalt: string;
roles: UserRoles;
logonname?: string;
is_active?: boolean;
is_verified?: boolean;
platform_access?: UserPlatformAccess;
deviceId?: string;
deviceType?: string;
phoneNumber?: string;
smsEnabled?: boolean;
azureAdUserId?: string;
verification_random?: string;
forgotpass_token?: string;
twofactor_stat?: number;
twofactor_secret?: string;
notes?: string;
key_stack?: string;
activation_time?: Date;
verification_time?: Date;
activatedAt?: Date;
verifiedAt?: Date;
smsSecret?: string;
twoFactorPriority?: Array<string>;
otpEnabled?: boolean;
otpSecret?: string;
securityKeyData?: Array<any>;
securityKeyChallenge?: string;
mblEnabled?: boolean;
smsOtpRetries?: number;
isSamlEnabled?: boolean;
};
};
// The user performing the action is optional, with the default value being set as the "CIP BOT."
const actor = { username: "[email protected]" };
cip.createUser(data, actor)
.then(result => console.log(result))
.catch(err => console.error(err));
To Create Bulk Users
To adhere to the maximum limit of 50 records per request, you need to ensure that if you have more than 50 records, you split them into smaller chunks of 50. Then, you can call the createBulkUsers function for each chunk separately.
const UserPlatformAccess = {
dt_enabled: boolean;
es_enabled: boolean;
pp_enabled: boolean;
up_enabled: boolean;
eps_enabled: boolean;
pam_enabled: boolean;
};
const data = {
users: [
{
firstname: string;
lastname: string;
username: string;
password: string;
usersalt: string;
roles: UserRoles;
logonname?: string;
is_active?: boolean;
is_verified?: boolean;
platform_access?: UserPlatformAccess;
deviceId?: string;
deviceType?: string;
phoneNumber?: string;
smsEnabled?: boolean;
azureAdUserId?: string;
verification_random?: string;
forgotpass_token?: string;
twofactor_stat?: number;
twofactor_secret?: string;
notes?: string;
key_stack?: string;
activation_time?: Date;
verification_time?: Date;
activatedAt?: Date;
verifiedAt?: Date;
smsSecret?: string;
twoFactorPriority?: Array<string>;
otpEnabled?: boolean;
otpSecret?: string;
securityKeyData?: Array<any>;
securityKeyChallenge?: string;
mblEnabled?: boolean;
smsOtpRetries?: number;
isSamlEnabled?: boolean;
}
];
};
// The user performing the action is optional, with the default value being set as the "CIP BOT."
const actor = { username: "[email protected]" };
cip.createBulkUsers(data, actor)
.then(result => console.log(result))
.catch(err => console.error(err));
To update user
const UserPlatformAccess = {
dt_enabled: boolean;
es_enabled: boolean;
pp_enabled: boolean;
up_enabled: boolean;
eps_enabled: boolean;
pam_enabled: boolean;
};
const data = {
id: string;
user: {
firstname?: string;
lastname?: string;
username?: string;
password?: string;
usersalt?: string;
roles?: UserRoles;
logonname?: string;
is_active?: boolean;
is_verified?: boolean;
platform_access?: UserPlatformAccess;
deviceId?: string;
deviceType?: string;
phoneNumber?: string;
smsEnabled?: boolean;
azureAdUserId?: string;
verification_random?: string;
forgotpass_token?: string;
twofactor_stat?: number;
twofactor_secret?: string;
notes?: string;
key_stack?: string;
activation_time?: Date;
verification_time?: Date;
activatedAt?: Date;
verifiedAt?: Date;
smsSecret?: string;
twoFactorPriority?: Array<string>;
otpEnabled?: boolean;
otpSecret?: string;
securityKeyData?: Array<any>;
securityKeyChallenge?: string;
mblEnabled?: boolean;
smsOtpRetries?: number;
isSamlEnabled?: boolean;
};
};
// The user performing the action is optional, with the default value being set as the "CIP BOT."
const actor = { username: "[email protected]" };
cip.updateUser(data, actor)
.then(result => console.log(result))
.catch(err => console.error(err));
To Upload User Avatar
NOTE: Actor is required.
Avatar Path should be
Absolute Path
const actor = { username: '[email protected]' }; // The actor represents the user who is uploading their avatar.
cip
.uploadAvatar('/home/path/to/avatar/file.png', actor)
.then((result) => console.log(result))
.catch((err) => console.error(err));
To Delete User
// The user performing the action is optional, with the default value being set as the "CIP BOT."
const actor = { username: '[email protected]' };
const user_id = 'ef7a4a52-83c3-4a13-8a18-130fa23ea821';
cip
.deleteUser(user_id, actor)
.then((result) => console.log(result))
.catch((err) => console.error(err));
To Restore User
// The user performing the action is optional, with the default value being set as the "CIP BOT."
const actor = { username: '[email protected]' };
const user_id = 'ef7a4a52-83c3-4a13-8a18-130fa23ea821';
cip
.restoreUser(user_id, actor)
.then((result) => console.log(result))
.catch((err) => console.error(err));
To Logout
const actor = { username: '[email protected]' };
cip
.logout(actor)
.then((result) => console.log(result))
.catch((err) => console.error(err));
To Check Users Existence using Usernames
cip
.checkUsersExistenceByUsernames(['[email protected]', '[email protected]', '[email protected]'])
.then((result) => console.log(result))
.catch((err) => console.error(err));
To Check Users Existence using IDs
cip
.checkUsersExistenceByIds(['b3300c56-97d1-4258-8ba0-cb423221f8d8', 'b3300c56-97d1-4258-8ba0-cb423221f8d1'])
.then((result) => console.log(result))
.catch((err) => console.error(err));
Roles Example
To retrieve list of roles
// You can use below options in getRoles (These are optional)
const options = {
page?: number; // You will need to page to get paginated results (Default: 1)
sort?: string; // if you want to sort by some column like username
direction?: string; // Specify direction asc, desc for sorting
perPage?: number; // Specifiy how many records you need per page (Default: 250)
query?: { // You can use this if you need advance search
names?: Array<string>;
ids?: Array<string>;
notIds?: Array<string>;
name?: string;
descripion?: string;
};
};
cip.getRoles(options)
.then(result => console.log(result))
.catch(err => console.error(err));
To retrieve single role
const role_id = 'ef7a4a52-83c3-4a13-8a18-130fa23ea821';
cip
.getRole(role_id)
.then((result) => console.log(result))
.catch((err) => console.error(err));
To create role
const data = {
role: {
name: string;
description?: string | null;
permissions: {
[key: string]: boolean;
};
isDeletable?: boolean;
};
};
// The user performing the action is optional, with the default value being set as the "CIP BOT."
const actor = { username: "[email protected]" };
cip.createRole(data, actor)
.then(result => console.log(result))
.catch(err => console.error(err));
To Create Bulk Roles
To adhere to the maximum limit of 50 records per request, you need to ensure that if you have more than 50 records, you split them into smaller chunks of 50. Then, you can call the createBulkUsers function for each chunk separately.
const data = {
roles: [
{
name: string;
description?: string | null;
permissions: {
[key: string]: boolean;
};
isDeletable?: boolean;
}
]
};
// The user performing the action is optional, with the default value being set as the "CIP BOT."
const actor = { username: "[email protected]" };
cip.createBulkRoles(data, actor)
.then(result => console.log(result))
.catch(err => console.error(err));
To update role
const data = {
id: string;
role: {
name?: string;
description?: string | null;
permissions?: {
[key: string]: boolean;
};
isDeletable?: boolean;
};
};
// The user performing the action is optional, with the default value being set as the "CIP BOT."
const actor = { username: "[email protected]" };
cip.updateRole(data, actor)
.then(result => console.log(result))
.catch(err => console.error(err));
To delete role
const role_id =
// The user performing the action is optional, with the default value being set as the "CIP BOT." "3b6d6a1e-cbb2-4599-8ccf-972128393a9b";
const actor = { username: "[email protected]" };
cip.deleteRole(role_id, actor)
.then(result => console.log(result))
.catch(err => console.error(err));
To Check Roles Existence using Names
cip
.checkRolesExistenceByNames(['Admin', 'User', 'Business Admin'])
.then((result) => console.log(result))
.catch((err) => console.error(err));
To Check Roles Existence using IDs
cip
.checkRolesExistenceByIds(['b3300c56-97d1-4258-8ba0-cb423221f8d8', 'b3300c56-97d1-4258-8ba0-cb423221f8d1'])
.then((result) => console.log(result))
.catch((err) => console.error(err));
Permissions Example
To retrieve list of permissions
cip
.getPermissions()
.then((result) => console.log(result))
.catch((err) => console.error(err));
To retrieve single permission
const permission_key = 'pam-view-personal-session-logs';
cip
.getPermission(permission_key)
.then((result) => console.log(result))
.catch((err) => console.error(err));
To sync permissions
Please note that you should include all the permissions you want to retain when making this request. Any permissions not included in this request will be removed from CIP.
const permissions = [
{
"type": "user",
"key": "audit-log",
"level": 30,
"name": "Audit Log 2",
"module": "user"
},
{
"type": "pam",
"key": "credman-personal-containers",
"level": 1,
"name": "Credentials Management Personal Containers",
"module": "enpast"
},
...
// all other permissions
];
// The user performing the action is optional, with the default value being set as the "CIP BOT."
const actor = { username: "[email protected]" };
cip.syncPermissions({ permissions: permissions }, actor)
.then(result => console.log(result))
.catch(err => console.error(err));
To delete Permission
// The user performing the action is optional, with the default value being set as the "CIP BOT."
const actor = { username: '[email protected]' };
const permission_key = 'pam-view-personal-session-logs';
cip
.deletePermission(permission_key, actor)
.then((result) => console.log(result))
.catch((err) => console.error(err));
To delete all platform Permissions
NOTE: Be Careful doing this action, it will delete all permissions of the platform from CIP
// The user performing the action is optional, with the default value being set as the "CIP BOT."
const actor = { username: '[email protected]' };
cip
.deletePlatformPermissions(actor)
.then((result) => console.log(result))
.catch((err) => console.error(err));
Notifications Example
To retrieve list of notifications
// You can use below options in getNotifications (These are optional)
const options = {
page?: number; // You will need to pass page to get paginated results (Default: 1)
sort?: string; // if you want to sort by some column like username
direction?: string; // Specify direction asc, desc for sorting
perPage?: number; // Specifiy how many records you need per page (Default: 250)
query?: {
startDate?: Date; // Filter to get notification after specified date
endDate?: Date; // Filter to get notification before specified date
severity?: ['critical', 'medium', 'high', 'low', 'note']; // Filter to get notification against specified severity (can be multiple using array syntax)
platformType?: PLATFORM_UPPER_CASE; // Filter to get notification against specified platform (e.g., PAM)
type?: 'read' | 'unread'; // Filter to get notification against specified type (e.g., read)
userIds?: Array<string>; // Filter to get Notifications against only specified user IDs (e.g., ["5da09c6a-7d1d-4562-b9cc-69a8eccc98ad", "ef7a4a52-83c3-4a13-8a18-130fa23ea823"])
filterText?: string; // Filter to get notification against specified text
};
};
cip.getNotifications(options)
.then(result => console.log(result))
.catch(err => console.error(err));
To retrieve single notification
const platform_notification_id = 'dbdb7813-a9c8-4128-834a-09f4980676d4';
cip
.getNotification(platform_notification_id)
.then((result) => console.log(result))
.catch((err) => console.error(err));
To create Notification
const data = {
notification: {
id: string;
event: string;
entityId: string;
sourceId: string | null | undefined;
entityName: string;
entityType: string;
severity: string;
notificationType: string;
notification: string;
actionBy: string;
deletedAt: Date | null | undefined;
receivers: Array<string>;
pageUrl: string;
platform: 'PAM' | 'EPS' | ...;
createdAt: Date | null | undefined;
};
};
// The user performing the action is optional, with the default value being set as the "CIP BOT."
const actor = { username: "[email protected]" };
cip.createNotification(data, ?ACTOR)
.then(result => console.log(result))
.catch(err => console.error(err));
To create bulk notifications
const data = {
notifications: [{
id: string;
event: string;
entityId: string;
sourceId: string | null | undefined;
entityName: string;
entityType: string;
severity: string;
notificationType: string;
notification: string;
actionBy: string;
deletedAt: Date | null | undefined;
receivers: Array<string>;
pageUrl: string;
platform: 'PAM' | 'EPS' | ...;
createdAt: Date | null | undefined;
}];
};
// The user performing the action is optional, with the default value being set as the "CIP BOT."
const actor = { username: '[email protected]' };
cip
.createBulkNotifications(data, actor)
.then((result) => console.log(result))
.catch((err) => console.error(err));
To read bulk notifications
cip
.updateBulkNotificationsData({
ids: ['dbdb7813-a9c8-4128-834a-09f4980676d4'],
userIds: ['dbdb7813-a9c8-4128-834a-09f4980676d4'],
})
.then((result) => console.log(result))
.catch((err) => console.error(err));
To read Notification
NOTE: Actor is required to Read Notification
Please remember that the actor should be the person who received the notification, as they need to be able to read it.
// It is mandatory to specify the user who is reading the notification.
const actor = { username: '[email protected]' };
const platform_notification_id = 'dbdb7813-a9c8-4128-834a-09f4980676d4';
cip
.readNotification(platform_notification_id, 'pam', actor)
.then((result) => console.log(result))
.catch((err) => console.error(err));
To delete notification
// The user performing the action is optional, with the default value being set as the "CIP BOT."
const actor = { username: '[email protected]' };
const platform_notification_id = 'dbdb7813-a9c8-4128-834a-09f4980676d4';
cip
.deleteNotification(platform_notification_id, 'pam', actor)
.then((result) => console.log(result))
.catch((err) => console.error(err));
To get all platforms notifications
cip
.getAllPlatformsNotifications()
.then((result) => console.log(result))
.catch((err) => console.error(err));
To get all platforms unread notifications count
cip
.getAllPlatformsUnreadNotificationsCount()
.then((result) => console.log(result))
.catch((err) => console.error(err));
Configurations Example
To get platforms configurations
const actor = { username: '[email protected]' };
cip
.getPlatformsConfig(actor)
.then((result) => console.log(result))
.catch((err) => console.error(err));
To get user access configurations
const actor = { username: '[email protected]' };
cip
.getUserAccessConfig(actor)
.then((result) => console.log(result))
.catch((err) => console.error(err));
To get CIP URLs Configurations
const actor = { username: '[email protected]' };
cip
.getCipUrlsConfig(actor)
.then((result) => console.log(result))
.catch((err) => console.error(err));
To Update Dashboard
const actor = { username: '[email protected]' };
cip
.updateDashboard(actor)
.then((result) => console.log(result))
.catch((err) => console.error(err));
To Create Inventory
const actor = { username: '[email protected]' };
cip
.createInventory({}, actor)
.then((result) => console.log(result))
.catch((err) => console.error(err));