ibm-bluepages-js

A node.js module to interact with the IBM Bluepages API.


Keywords
ibm, bluepages, nodejs, promises, api, ldap, async, async-await, ibm-bluemix, ibm-bluepages, ibm-bluepages-js, ibm-cloud, ibm-cloud-functions, ibm-developer-technology-cloud, ibm-watson-services, ibmcode, ldap-authentication, module, node
License
IPL-1.0
Install
npm install ibm-bluepages-js@1.2.2

Documentation

IBM Bluepages JS

David

GitHub code size in bytes

npm

NPM

GitHub contributors

This module provides a set of functions to help IBM Developers working on internal projects to authenticate and access user directory data available on IBM Bluepages using Javascript promises.

Requirements (MacOS/Windows)

  • Node.js
    • Minimum: v10.x
    • Recommended: v16.x
  • npm
    • Tested on: v8.2.x
  • Python
    • Tested on: v2.7

Note: Depending on your Windows setup windows-build-tools may need to be installed first. Also, for MacOS users, you should have xcode-select or entire Xcode App package installed.

Install

$ npm install ibm-bluepages-js

Uninstall

$ npm uninstall ibm-bluepages-js

Change Log

This shows only the latest version.

  • 2.2.0
    • Updated to latest APIs
    • Fixed tests with new IDs
    • Updated node-fetch
    • Added new getJobRolesByW3ID function

Older versions please check this change log.

Usage

Perform an action based on location:

const bluePages = require('ibm-bluepages-js');

async function doSomethingBasedOnLocation() {
  let location = await bluePages.getEmployeeLocationByW3ID('rod.anami@br.ibm.com');

  if(location.countryAlphaCode === 'br') {
    // if true code
  } else {
    // if else code
  }
}

Define a function to return employee information:

const bluePages = require('ibm-bluepages-js');

const userProfile = function(id) {
  return bluePages.getEmployeeInfoByW3ID(id).then(function(result){
    return result;
  }).catch(function(error){
    return error;
  });
};

Authenticate an account:

const bluePages = require('ibm-bluepages-js');

async function doAccountAuthentication() {
  let success = await bluePages.authenticate('aromeroh@cr.ibm.com', '********');

  if(success) {
    // if true code
  } else {
    // if else code
  }
}

Render an employee photo with Express and EJS:

app.get('/profile', async (req, res) => {
  let photo = await bluePages.getPhotoByW3ID('aromeroh@cr.ibm.com');

  res.render('profile.ejs', {
      photo: photo
  });
});
<% if (photo) { %>
  <img src="<%= photo %>" alt="User Photo" height="240" width="320">
<% } %>

List of functions available

  • authenticate(W3ID, password)
  • employeeExists(W3ID)
  • getConferenceInfoByW3ID(W3ID)
  • getDirectReportsByW3ID(W3ID)
  • getDirectAndIndirectReportsByW3ID(W3ID)
  • getEmployeeInfoByUID(UID)
  • getEmployeeInfoByW3ID(W3ID)
  • getEmployeeLocationByW3ID(W3ID)
  • getEmployeeMobileByW3ID(W3ID)
  • getEmployeePhoneByW3ID(W3ID)
  • getGlobalManagerUIDByW3ID(W3ID)
  • getJobFunctionByW3ID(W3ID)
  • getManagerUIDByEmployeeW3ID(W3ID)
  • getNameByW3ID(W3ID)
  • getPhotoByW3ID(W3ID)
  • getSlackInfoByW3ID(W3ID)
  • getUIDByW3ID(W3ID)
  • getW3IDByUID(UID)
  • isManager(W3ID)

Functions' interfaces

  • authenticate(W3ID, password)
/**
* @param {String} W3ID
* @param {String} password
* @returns {Promise<boolean>}
*/
  • employeeExists(W3ID)
/**
* @param {String} W3ID
* @returns {Promise<boolean>}
*/
  • getConferenceInfoByW3ID(W3ID)
/**
* @param {String} W3ID
* @returns {Promise<string>}
*/

Note: it uses the new experimental API

  • getDirectReportsByW3ID(W3ID)
/**
* @param {String} W3ID
* @returns {Promise<Array<Object>>}
*/
  • getDirectAndIndirectReportsByW3ID(W3ID)
/**
* @param {String} W3ID
* @returns {Promise<Array<Object>>}
*/
  • getEmployeeInfoByUID(UID)
/**
* @param {String} UID
* @returns {Promise<Object>}
*/
  • getEmployeeInfoByW3ID(W3ID)
/**
* @param {String} W3ID
* @returns {Promise<Object>}
*/
  • getEmployeeLocationByW3ID(W3ID)
/**
* @param {String} W3ID
* @returns {Promise<Object>}
*/
  • getEmployeeMobileByW3ID(W3ID)
/**
* @param {String} W3ID
* @returns {Promise<string>}
*/
  • getEmployeePhoneByW3ID(W3ID)
/**
* @param {String} W3ID
* @returns {Promise<string>}
*/
  • getGlobalManagerUIDByW3ID(W3ID)
/**
* @param {String} W3ID
* @returns {Promise<string>}
*/
  • getJobFunctionByW3ID(W3ID)
/**
* @param {String} W3ID
* @returns {Promise<string>}
*/
  • getManagerUIDByEmployeeW3ID(W3ID)
/**
* @param {String} W3ID
* @returns {Promise<string>}
*/
  • getNameByW3ID(W3ID)
/**
* @param {String} W3ID
* @returns {Promise<string>}
*/
  • getPhotoByW3ID(W3ID)
/**
* @param {String} W3ID
* @returns {Promise<string>}
*/
  • getSlackInfoByW3ID(W3ID)
/**
* @param {String} W3ID
* @returns {Promise<string>}
*/

Note: it uses the new experimental API

  • getUIDByW3ID(W3ID)
/**
* @param {String} W3ID
* @returns {Promise<string>}
*/
  • getW3IDByUID(UID)
/**
* @param {String} W3ID
* @returns {Promise<string>}
*/
  • isManager(W3ID)
/**
* @param {String} W3ID
* @returns {Promise<boolean>}
*/

Other Information

Package security

  • It's designed to only work within the IBM Blue Zone network (Secure Network).
  • It's designed to use LDAPS as the main authentication method which makes traffic confidential and secure by using Transport Layer Security (TLS).

Contributing

If you want to contribute to the module and make it better, your help is very welcome. You can do so submitting a Pull Request.

Authors

License

This project is licensed under the IBM Public License 1.0. Copyright (c) 2021 IBM