@haventec/user-management-sdk
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

Haventec User Management Node.js SDK

Your backend service can use this SDK to manage users and devices in the Haventec Identity Platform.

This project contains a demo app explained in the section "Demo application" on this README file.

Prerequisites

  • Run the native-ux-adapter-sdk to activate or login the user.
    • Refer to the README.md file in native-ux-adapter-nodejs-sdk to understand how to activate a user by calling the 'activateUserOrDevice' method or how to log in a user by calling the 'loginPinDevice' method.
    • Fetch 'iamUserJwt' and 'deviceUuid' from the response of the above method and mention those against iam.user.jwt and haventec.device.uuid respectively in the 'config.properties' file.

Requirements

  • Node.js

  • Typescript (tsc) : version 4.1.5

Type the following command to install tsc as a dev dependency.

npm install --save-dev typescript@4.1.5

Installation

Install user-management-sdk dependency by following below command.

npm install @haventec/user-management-sdk@1.0.0

Usage

Instantiate the class "HaventecManagement" with your environment variables at your platform by adding it in config.properties:

Note: Please refer to the keycloak documentation: https://docs.haventec.com/docs/authenticate/v1.2/integrations/keycloak-iam to understand how to create the realm, idp and idp alias.

  • iam.realm: The name of your company Realm at the Haventec IAM e.g.: xyzCorp
  • iam.admin.client: The Haventec IAM client in the iam.realm with 'Access Type' : confidential
  • iam.admin.client.secret: The Haventec IAM client secret is the value beside the 'Secret' label on the 'Credentials' tab of the iam.admin.client
  • iam.idp.alias: The identity provider alias at the Haventec IAM e.g.: oidc
  • iam.base.url: The URL of the Identity Access Management (IAM). Demo Haventec IAM is found at:
  • iam.user.jwt The IAM JWT of the user once the user is successfully activated or logged-in, as explained in the 'Prerequisites' section on this README file.
  • haventec.app.client.id: The client ID of the application in Haventec Console. e.g.: 13f9d956-9bcc-447f-b7c1-7719cb53901d
  • haventec.app.apikey: The API Key of the application in Haventec Console. e.g.: 9dc54gg8-abc5-4abc-a1bc-d6d7abc42cb
  • haventec.authenticate.url: The URL of the Haventec Authenticate Demo is found at:
  • haventec.device.uuid The device uuid of the activated or logged-in user, as explained in the 'Prerequisites' section on this README file. e.g.: 250f7812-4258-4c11-98dc-96258a215368

and then you can start using any of the methods within the SDK:

  • lockDevice: Lock a device

    accessToken : string;
    deviceUuid : string;
    
  • unlockDevice: UnLock a device

    accessToken : string;
    deviceUuid : string;
    
  • updateDevice: Update a device

    accessToken : string;
    deviceUuid : string;
    deviceName : string;
    
  • deleteDevice: Delete a device

    accessToken : string;
    deviceUuid : string;
    
  • getUserDetails: Get user details

    accessToken : string;
    deviceUuid : string;
    

    UserDetailsResponse

    userUuid: string;
    username: string;
    email: string;
    active: boolean;
    locked: boolean;
    dateCreated: number;
    lastLogin: number;
    mobileNumber: string;
    forbidAddingDevices: boolean;
    
  • getDevices: Get all devices for a user

    accessToken : string;
    

    UserDevicesResponse

    devices: Array<DeviceResponse>;
    

Demo application

The demo application guides you manage user and device to demonstrate the different user flows.

  1. Access the demo folder and create a personal config.properties file based on the template:
cd demo
cp config.properties.template config.properties
  1. Fill in the environment variables described on the previous section.

  2. Run the demo

npm run demo1

License

This code is available under the MIT license. A copy of the license can be found in the LICENSE file included with the distribution.

Readme

Keywords

none

Package Sidebar

Install

npm i @haventec/user-management-sdk

Weekly Downloads

0

Version

1.0.0

License

ISC

Unpacked Size

143 kB

Total Files

53

Last publish

Collaborators

  • haventec_bamboo
  • vpmurdoch
  • jcrosbie
  • luke_hornibrook