1.0.30 • Published 9 months ago

revbits-cip-integration v1.0.30

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

RevBits - CIP Integration

Downloads npm version install size Known Vulnerabilities

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:

  1. Import the CIP class from the package:
const { CIP } = require('revbits-cip-integration');
  1. 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
  },
);
  1. 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.

MethodDescriptionDefinition
getUsersTo Get Paginated Userscip.getUsers(?OPTIONS)
getUserTo Get Single Usercip.getUser(USER_ID)
getUserByUsernameTo Get User by username/emailcip.getUserByUsername(USER_NAME)
createUserTo Create a User on CIPcip.createUser({ user: USER_ATTRIBUTES }, ?ACTOR)
createBulkUsersTo Create Bulk Users on CIPcip.createBulkUsers({ users: USERS_ATTRIBUTES }, ?ACTOR)
updateUserTo Update a User on CIPcip.updateUser({ id: USER_ID, user: { ...UPDATED_ATTRIBUTES } }, ?ACTOR)
uploadAvatarTo upload User Avatar on CIPcip.uploadAvatar(AVATAR_PATH, ACTOR)
deleteUserTo Delete Usercip.deleteUser(USER_ID, ?ACTOR)
restoreUserTo Restore Usercip.restoreUser(USER_ID, ?ACTOR)
logoutTo Logoutcip.logout(ACTOR)
updateDashboardTo Update Dashboardcip.updateDashboard(ACTOR)
checkUsersExistenceByUsernamesTo Check Users Existence using usernamescip.checkUsersExistenceByUsernames(...USERNAMES, ?ACTOR)
checkUsersExistenceByIdsTo Check Users Existence using IDscip.checkUsersExistenceByIds(...IDS, ?ACTOR)
getRolesTo Get Paginated Rolescip.getRoles(?OPTIONS)
getRoleTo Get a Single Rolecip.getRole(ROLE_ID)
createRoleTo Create a Role on CIPcip.createRole({ role: ROLE_ATTRIBUTES }, ?ACTOR)
createBulkRolesTo Create Bulk Roles on CIPcip.createBulkRoles({ users: ROLES_ATTRIBUTES }, ?ACTOR)
updateRoleTo Update Role on CIPcip.updateRole({ id: ROLE_ID, role: { ...UPDATED_ATTRIBUTES } }, ?ACTOR)
checkRolesExistenceByNamesTo Check Roles Existence using namescip.checkRolesExistenceByNames(...NAMES, ?ACTOR)
checkRolesExistenceByIdsTo Check Roles Existence using IDscip.checkRolesExistenceByIds(...IDS, ?ACTOR)
deleteRoleTo Delete Role from CIPcip.deleteRole(ROLE_ID, ?ACTOR)
getPermissionsTo Get Permissionscip.getPermissions()
getPermissionTo Get a Single Permissioncip.getPermission(PERMISSION_KEY)
syncPermissionsTo Sync Permissions on CIPcip.syncPermissions({ permissions: PERMISSIONS_ATTRIBUTES }, ?ACTOR)
deletePermissionTo Delete Permission from CIPcip.deletePermission(PERMISSION_KEY, ?ACTOR)
deletePlatformPermissionsTo Delete All Platform Permissions from CIPcip.deletePlatformPermissions(?ACTOR)
getNotificationsTo Get Paginated Notificationscip.getNotifications(?OPTIONS)
getNotificationTo Get Single Notificationscip.getNotification(PLATFORM_NOTIFICATION_ID)
createNotificationTo Create Notificationcip.createNotification({ notification: NOTIFICATION_ATTRIBUTES }, ?ACTOR)
createBulkNotificationsTo Create Bulk Notificationscip.createBulkNotifications({ notifications: NOTIFICATIONS }, ?ACTOR)
updateBulkNotificationsDataTo Update Bulk Notifications Attributescip.updateBulkNotificationsData({ notifications: NOTIFICATIONS }, ?ACTOR)
readNotificationTo Read Notificationcip.readNotification(PLATFORM_NOTIFICATION_ID, APP_NAME, ACTOR)
deleteNotificationTo Delete Notificationscip.deleteNotification(PLATFORM_NOTIFICATION_ID, APP_NAME, ?ACTOR)
getAllPlatformsNotificationsTo Get All Platforms Notificationscip.getAllPlatformsNotifications()
getAllPlatformsUnreadNotificationsCountTo Get All Platforms Unread Notifications Countcip.getAllPlatformsUnreadNotificationsCount()
getPlatformsConfigTo Get Platforms Configurationscip.getPlatformsConfig(ACTOR)
getUserAccessConfigTo Get User Access Configurationscip.getUserAccessConfig(ACTOR)
getCipUrlsConfigTo Get CIP URL Configurationscip.getCipUrlsConfig (ACTOR)
createInventoryTo Create Inventorycip.createInventory (DATA, ACTOR)

For methods that require audit logs, you have the flexibility to pass an actor as an argument. In case you don't provide an actor, the default option is to use the CIP BOT as the actor in the audit logs on the CIP platform.

Sample Actor (it must contain username)

const actor = { username: 'username@org.com' };

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 = 'user@org.com';
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: "username@org.com" };
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: "username@org.com" };
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: "username@org.com" };
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: 'username@org.com' }; // 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: 'username@org.com' };
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: 'username@org.com' };
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: 'username@org.com' };
cip
  .logout(actor)
  .then((result) => console.log(result))
  .catch((err) => console.error(err));

To Check Users Existence using Usernames

cip
  .checkUsersExistenceByUsernames(['user1@org.com', 'user2@org.com', 'user3@org.com'])
  .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: "username@org.com" };
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: "username@org.com" };
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: "username@org.com" };
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: "username@org.com" };
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: "username@org.com" };
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: 'username@org.com' };
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: 'username@org.com' };
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: "username@org.com" };
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: 'username@org.com' };
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: 'username@org.com' };
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: 'username@org.com' };
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: 'username@org.com' };
cip
  .getPlatformsConfig(actor)
  .then((result) => console.log(result))
  .catch((err) => console.error(err));

To get user access configurations

const actor = { username: 'username@org.com' };
cip
  .getUserAccessConfig(actor)
  .then((result) => console.log(result))
  .catch((err) => console.error(err));

To get CIP URLs Configurations

const actor = { username: 'username@org.com' };
cip
  .getCipUrlsConfig(actor)
  .then((result) => console.log(result))
  .catch((err) => console.error(err));

To Update Dashboard

const actor = { username: 'username@org.com' };
cip
  .updateDashboard(actor)
  .then((result) => console.log(result))
  .catch((err) => console.error(err));

To Create Inventory

const actor = { username: 'username@org.com' };
cip
  .createInventory({}, actor)
  .then((result) => console.log(result))
  .catch((err) => console.error(err));

License

MIT

1.0.30

9 months ago

1.0.29

9 months ago

1.0.28

9 months ago

1.0.27

10 months ago

1.0.26

11 months ago

1.0.25

11 months ago

1.0.24

11 months ago

1.0.23

11 months ago

1.0.22

11 months ago

1.0.21

11 months ago

1.0.20

11 months ago

1.0.19

11 months ago

1.0.18

11 months ago

1.0.17

11 months ago

1.0.16

11 months ago

1.0.15

11 months ago

1.0.14

11 months ago

1.0.13

11 months ago

1.0.12

11 months ago

1.0.11

11 months ago

1.0.10

11 months ago

1.0.9

11 months ago

1.0.8

11 months ago

1.0.7

11 months ago

1.0.6

11 months ago

1.0.5

11 months ago

1.0.4

11 months ago

1.0.3

11 months ago

1.0.2

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago