npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

truiam-rbac

v3.0.4

Published

[![npm](https://img.shields.io/npm/v/truiam-rbac.svg?style=flat)](https://www.npmjs.com/package/truiam-rbac) ![Downloads](https://img.shields.io/npm/dw/truiam-rbac) [![License](https://img.shields.io/:license-mit-blue.svg?style=flat)](https://opensource

Downloads

129

Readme

RBAC MODULE

npm Downloads License

Installation

Using npm

npm install truiam-rbac

RBAC Functions

TRUIAM Functions

Authentication Functions

Admin Functions


Initialize User

// Parameters:
// - token: STRING (Token for user initialization)
const initializeUserParams = {
  token: 'STRING'
};
const initializeUserResult = await initializeUser(initializeUserParams);

Check Permission

/* Parameters:
 - resourceName: STRING (Name of the resource)
 - accessType: STRING (Access type defined in TRUIAM ACCESS TYPE)
 - token: STRING (Access token)
 - roleName : STRING (optional) (WILL BE ADDED LATER - Name of the role for which you want to retrieve the
 info)

 */
const checkPermissionParams = {
  resourceName: 'STRING',
  accessType: 'STRING',
  token: 'STRING'
};
const checkPermissionResult = await checkPermission(checkPermissionParams);

User Profile

// Parameters:
// - token: STRING (User token)
const userProfileParams = {
  token: 'STRING'
};
const userProfileResult = await userProfile(userProfileParams);

Get Organization Detail

// Parameters:
// - orgId: STRING (ID of the organization)
// - token: STRING (User token)
const getOrgDetailParams = {
  orgId: '19',
  token: 'STRING'
};
const getOrgDetailResult = await getOrgDetail(getOrgDetailParams);

Get Organization by Token

// Parameters:
// - token: STRING (User token)
const getOrgByTokenParams = {
  token: 'STRING'
};
const getOrgByTokenResult = await getOrgByToken(getOrgByTokenParams);

Get Role by ID

// Parameters:
// - roleId: STRING (ID of the role)
// - orgId: STRING (ID of the organization)
const getRoleByIdParams = {
  roleId: '41',
  orgId: '38'
};
const getRoleByIdResult = await getRoleById(getRoleByIdParams);

Get Attached Policy

// Parameters:
// -

 roleId: STRING (ID of the role)
// - orgId: STRING (ID of the organization)
const getAttachedPolicyParams = {
  roleId: '41',
  orgId: '38'
};
const getAttachedPolicyResult = await getAttachedPolicy(getAttachedPolicyParams);

Get Policy by ID

// Parameters:
// - policyId: STRING (ID of the policy)
// - orgId: STRING (ID of the organization)
const getPolicyByIdParams = {
  policyId: '11',
  orgId: '38'
};
const getPolicyByIdResult = await getPolicyById(getPolicyByIdParams);

Get Attached Service

// Parameters:
// - policyId: STRING (ID of the policy)
// - orgId: STRING (ID of the organization)
const getAttachedServiceParams = {
  policyId: '11',
  orgId: '38'
};
const getAttachedServiceResult = await getAttachedService(getAttachedServiceParams);

Get Service by ID

// Parameters:
// - serviceId: STRING (ID of the service)
const getServiceByIdParams = {
  serviceId: 'SERVICE_ID'
};
const getServiceByIdResult = await getServiceById(getServiceByIdParams);

Get Attached Access

// Parameters:
// - serviceId: STRING (ID of the service)
// - orgId: STRING (ID of the organization)
const getAttachedAccessParams = {
  serviceId: 'SERVICE_ID',
  orgId: 'ORG_ID'
};
const getAttachedAccessResult = await getAttachedAccess(getAttachedAccessParams);

Get Access by ID

// Parameters:
// - accessId: STRING (ID of the access)
const getAccessByIdParams = {
  accessId: 'ACCESS_ID'
};
const getAccessByIdResult = await getAccessById(getAccessByIdParams);

Get Attached Resource

// Parameters:
// - accessId: STRING (ID of the access)
// - orgId: STRING (ID of the organization)
const getAttachedResourceParams = {
  accessId: 'ACCESS_ID',
  orgId: 'ORG_ID'
};
const getAttachedResourceResult = await getAttachedResource(getAttachedResourceParams);

Check Permission

// Parameters:
// - resourceName: STRING (Name of the resource)
// - accessType: STRING (Access type defined in TRUIAM ACCESS TYPE)
// - token: STRING (Access token)
// - roleName : STRING (optional) (name of role for which you want to check permission).
// NOTE -
const checkPermissionParams = {
  resourceName: 'YOUR_RESOURCE_NAME',
  accessType: 'YOUR_ACCESS_TYPE',
  token: 'YOUR_TOKEN'
};
const checkPermissionResult = await checkPermission(checkPermissionParams);

Confirm Email Sign-Up Code

// Parameters

// `email`: STRING (Email address)
// `clientId`: STRING (Client ID)
// `domain`: STRING (Domain)
// `code`: NUMBER (Sign-up code)

const confirmEmailSignUpCodeParams = {
  email: 'YOUR_EMAIL',
  clientId: 'YOUR_CLIENT_ID',
  domain: 'YOUR_DOMAIN',
  code: YOUR_CODE
};
const confirmEmailSignUpCodeResult = await confirmEmailSignUpCode(confirmEmailSignUpCodeParams);

Resend Email Sign-Up Code

// ##### Parameters

// - `email`: STRING (Email address)
// - `clientId`: STRING (Client ID)
// - `domain`: STRING (Domain)
// - `code`: NUMBER (Sign-up code)


const resendEmailSignUpCodeParams = {
  email: 'YOUR_EMAIL',
  clientId: 'YOUR_CLIENT_ID',
  domain: 'YOUR_DOMAIN',
  code: YOUR_CODE
};
const resendEmailSignUpCodeResult = await resendEmailSignUpCode(resendEmailSignUpCodeParams);

Execute Sign-In

// ##### Parameters

// - `email`: STRING (Email address)
// - `password`: STRING (Password)
// - `clientId`: STRING (Client ID)
// - `callbackurl`: STRING (Callback URL)
// - `domain`: STRING (Domain)


const executeSignInParams = {
  email: 'YOUR_EMAIL',
  password: 'YOUR_PASSWORD',
  clientId: 'YOUR_CLIENT_ID',
  callbackurl: 'YOUR_CALLBACK_URL',
  domain: 'YOUR_DOMAIN'
};
const executeSignInResult = await executeSignIn(executeSignInParams);

Execute Sign-Up

// ##### Parameters

// - `clientId`: STRING (Client ID)
// - `email`: STRING (Email address)
// - `password`: STRING (Password)
// - `domain`: STRING (Domain)


const executeSignUpParams = {
  clientId: 'YOUR_CLIENT_ID',
  email: 'YOUR_EMAIL',
  password: 'YOUR_PASSWORD',
}

const result = await rbac.executeSignUp(executeSignUpParams);

Execute Logout

// ##### Parameters

// - `clientId`: STRING (Client ID)
// - `refreshToken`: STRING (USER REFRESH TOKEN)


const params = {
  clientId: 'YOUR_CLIENT_ID',
  refreshToken: 'YOUR_REFRESH_TOKEN'
}

const result = await rbac.executeLogoutUser(params);

Get Refreshed Access Token

// ##### Parameters

// - `clientId`: STRING (Client ID)
// - `domain`: STRING (Domain)
// - `refreshToken`: STRING (USER REFRESH TOKEN)



const params = {
  clientId: 'YOUR_CLIENT_ID',
  domain: 'YOUR_DOMAIN',
  refreshToken: 'YOUR_REFRESH_TOKEN'
}

const result = await rbac.refreshAccessToken(params);

Get DNS Detail

Parameters
  • clientId: STRING (Client ID)
  • domain: STRING (Domain)
  • callbackurl: STRING (Callback URL)
const getDnsDetailParams = {
  clientId: 'YOUR_CLIENT_ID',
  callbackurl: 'YOUR_CALLBACK_URL',
  domain: 'YOUR_DOMAIN'
};
const getDnsDetailResult = await getDnsDetail(getDnsDetailParams);

Update Password

Updates the user's password.

Parameters

  • domain: STRING (Domain)
  • email: STRING (Email address)
  • newPassword: STRING (New password)
  • callbackurl: STRING (Callback URL)
  • clientId: STRING (Client ID)

Example

const updatePasswordParams = {
  domain: 'YOUR_DOMAIN',
  email: 'YOUR_EMAIL',
  newPassword: 'YOUR_NEW_PASSWORD',
  callbackurl: 'YOUR_CALLBACK_URL',
  clientId: 'YOUR_CLIENT_ID',
};
const updatePasswordResult = await updatePassword(updatePasswordParams);

Forgot Password

Initiates the forgot password process.

Parameters

  • domain: STRING (Domain)
  • email: STRING (Email address)
  • clientId: STRING (Client ID)

Example

const forgotPasswordParams = {
  domain: 'YOUR_DOMAIN',
  email: 'YOUR_EMAIL',
  clientId: 'YOUR_CLIENT_ID',
};
const forgotPasswordResult = await forgotPassword(forgotPasswordParams);

Reset Password

Resets the user's password using a code.

Parameters

  • domain: STRING (Domain)
  • email: STRING (Email address)
  • newPassword: STRING (New password)
  • code: STRING | NUMBER (Reset code)
  • clientId: STRING (Client ID)

Example

const resetPasswordParams = {
  domain: 'YOUR_DOMAIN',
  email: 'YOUR_EMAIL',
  newPassword: 'YOUR_NEW_PASSWORD',
  code: 'YOUR_RESET_CODE',
  clientId: 'YOUR_CLIENT_ID',
};
const resetPasswordResult = await resetPassword(resetPasswordParams);

Verify Access Token

Verifies the provided access token.

Parameters

  • token: STRING (Access Token to be verified)

Example

const verifyTokenParams = {
  token: 'YOUR_ACCESS_TOKEN',
};
const verifyTokenResult = await verifyToken(verifyTokenParams);

Exchange Code for tokens

Retrieves tokens using a code.

Parameters

  • code: STRING (Code to exchange for tokens)
  • callbackurl: STRING (Callback URL)
  • clientId: STRING (Client ID)

Example

const getTokenFromCodeParams = {
  code: 'YOUR_CODE',
  callbackurl: 'YOUR_CALLBACK_URL',
  clientId: 'YOUR_CLIENT_ID',
};
const getTokenFromCodeResult = await getTokenFromCode(getTokenFromCodeParams);



## Unlock User


#### Parameters:
 - `domain`: STRING (Domain)
 - `idp`: STRING (IDP)
 - `accessToken`: STRING (Access token)
 - `userId`: NUMBER (User ID)
```javascript
const params = {
  domain: 'YOUR_DOMAIN',
  idp: 'YOUR_IDP',
  accessToken: 'YOUR_ACCESS_TOKEN',
  userId: USER ID
};
const result = await rbac.unlockUser(params);

Delete User

// Parameters:
// - domain: STRING (Domain)
// - idp: STRING (IDP)
// - accessToken: STRING (Access token)
// - userId: NUMBER (User ID)
const params = {
  domain: 'YOUR_DOMAIN',
  idp: 'YOUR_IDP',
  accessToken: 'YOUR_ACCESS_TOKEN',
  userId: USER ID
};
const result = await rbac.deleteUser(params);

Create User

// Parameters:
// - domain: STRING (Domain)
// - idp: STRING (IDP)
// - accessToken: STRING (Access token)
// - data: OBJECT (User data containing email and password)
const params = {
  domain: 'YOUR_DOMAIN',
  idp: 'YOUR_IDP',
  accessToken: 'YOUR_ACCESS_TOKEN',
  data: {
    email: 'user@user',
    password: 'password'
  }
};
const result = await rbac.createUser(params);

Profile Fields

// Parameters:
// - domain: STRING (Domain)
// - idp: STRING (IDP)
// - accessToken: STRING (Access token)
const params = {
  domain: 'YOUR_DOMAIN',
  idp: 'YOUR_IDP',
  accessToken: 'YOUR_ACCESS_TOKEN'
};
const result = await rbac.profileFields(params);

User Account Action

// Parameters:
// - domain: STRING (Domain)
// - idp: STRING (IDP)
// - accessToken: STRING (Access token)
// - userId: STRING (User ID)
// - action: STRING (Action to perform on user account)
const params = {
  domain: 'YOUR_DOMAIN',
  idp: 'YOUR_IDP',
  accessToken: 'YOUR_ACCESS_TOKEN',
  userId: USER ID,
  action: 'disable' | 'enable'
};
const result = await rbac.userAccountAction(params);

Toggle MFA

// Parameters:
// - domain: STRING (Domain)
// - idp: STRING (IDP)
// - accessToken: STRING (Access token)
// - userId: STRING (User ID)
// - enable: BOOLEAN (Flag to enable/disable MFA)
const params = {
  domain: 'YOUR_DOMAIN',
  idp: 'YOUR_IDP',
  accessToken: 'YOUR_ACCESS_TOKEN',
  userId: USER ID,
  enable: false|true
};
const result = await rbac.toggleMfa(params);

Get User

// Parameters:
// - domain: STRING (Domain)
// - idp: STRING (IDP)
// - accessToken: STRING (Access token)
// - userId: STRING (User ID)
const params = {
  domain: 'YOUR_DOMAIN',
  idp: 'YOUR_IDP',
  accessToken: 'YOUR_ACCESS_TOKEN',
  userId: USER ID
};
const result = await rbac.getUser(params);

Get All Users

// Parameters:
// - domain: STRING (Domain)
// - idp: STRING (IDP)
// - accessToken: STRING (Access token)
const params = {
  domain: 'YOUR_DOMAIN',
  idp: 'YOUR_IDP',
  accessToken: 'YOUR_ACCESS_TOKEN'
};
const result = await rbac.getAllUser(params);