Socket
Socket
Sign inDemoInstall

@ndustrial/contxt-sdk

Package Overview
Dependencies
Maintainers
15
Versions
123
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ndustrial/contxt-sdk - npm Package Compare versions

Comparing version 0.0.49 to 0.0.50

docs/Roles.md

7

CHANGELOG.md

@@ -0,1 +1,8 @@

## [v0.0.50](http://github.com/ndustrialio/contxt-sdk-js/tree/v0.0.50) (2019-05-14)
**Added**
- Added Roles Module `coordinator.roles`
- Added `Roles#getByOrganizationId` for getting all roles belonging to an organization
## [v0.0.49](http://github.com/ndustrialio/contxt-sdk-js/tree/v0.0.49) (2019-04-22)

@@ -2,0 +9,0 @@

@@ -99,2 +99,5 @@ ## Classes

<dd></dd>
<dt><a href="./Roles.md">Roles</a></dt>
<dd><p>Module that provides access to contxt roles</p>
</dd>
<dt><a href="./WebSocketConnection.md">WebSocketConnection</a></dt>

@@ -148,2 +151,6 @@ <dd><p>Module that wraps the websocket connection to the message bus

<dd></dd>
<dt><a href="./Typedefs.md#ContxtRole">ContxtRole</a> : <code>Object</code></dt>
<dd></dd>
<dt><a href="./Typedefs.md#ContxtStack">ContxtStack</a> : <code>Object</code></dt>
<dd></dd>
<dt><a href="./Typedefs.md#ContxtUser">ContxtUser</a> : <code>Object</code></dt>

@@ -150,0 +157,0 @@ <dd></dd>

@@ -269,2 +269,41 @@ <a name="Asset"></a>

<a name="ContxtRole"></a>
## ContxtRole : <code>Object</code>
**Kind**: global typedef
**Properties**
| Name | Type | Description |
| --- | --- | --- |
| applications | [<code>Array.&lt;ContxtApplication&gt;</code>](#ContxtApplication) | |
| createdAt | <code>string</code> | ISO 8601 Extended Format date/time string |
| description | <code>string</code> | |
| id | <code>string</code> | |
| name | <code>string</code> | |
| organizationId | <code>string</code> | |
| stacks | [<code>Array.&lt;ContxtStack&gt;</code>](#ContxtStack) | |
| updatedAt | <code>string</code> | ISO 8601 Extended Format date/time string |
<a name="ContxtStack"></a>
## ContxtStack : <code>Object</code>
**Kind**: global typedef
**Properties**
| Name | Type | Description |
| --- | --- | --- |
| clientId | <code>string</code> | |
| clusterId | <code>string</code> | |
| createdAt | <code>string</code> | ISO 8601 Extended Format date/time string |
| currentVersionId | <code>string</code> | |
| description | <code>string</code> | |
| documentationUrl | <code>string</code> | |
| icon | <code>string</code> | |
| id | <code>number</code> | |
| name | <code>string</code> | |
| organizationId | <code>string</code> | |
| ownerId | <code>string</code> | |
| type | <code>string</code> | |
| updatedAt | <code>string</code> | ISO 8601 Extended Format date/time string |
<a name="ContxtUser"></a>

@@ -271,0 +310,0 @@

188

lib/coordinator/index.js

@@ -97,5 +97,5 @@ 'use strict';

/**
* Adds an application to the current user's list of favorited applications
* Activates a new user
*
* API Endpoint: '/applications/:applicationId/favorites'
* API Endpoint: '/users/:userId/activate'
* Method: POST

@@ -105,12 +105,20 @@ *

*
* @param {number} applicationId The ID of the application
* @param {string} userId The ID of the user to activate
* @param {Object} user
* @param {string} user.email The email address of the user
* @param {string} user.password The password to set for the user
* @param {string} user.userToken The JWT token provided by the invite link
*
* @returns {Promise}
* @fulfill {ContxtUserFavoriteApplication} Information about the contxt application favorite
* @fulfill {undefined}
* @reject {Error}
*
* @example
* contxtSdk.coordinator
* .createFavoriteApplication(25)
* .then((favoriteApplication) => console.log(favoriteApplication))
* contxtSdk.coordinator.
* .activateNewUser('7bb79bdf-7492-45c2-8640-2dde63535827', {
* email: 'bob.sagat56@gmail.com',
* password: 'ds32jX32jaMM1Nr',
* userToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c'
* })
* .then(() => console.log("User Activated"))
* .catch((err) => console.log(err));

@@ -121,2 +129,45 @@ */

_createClass(Coordinator, [{
key: 'activateNewUser',
value: function activateNewUser(userId) {
var user = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
if (!userId) {
return Promise.reject(new Error('A user ID is required for activating a user'));
}
var requiredFields = ['email', 'password', 'userToken'];
for (var i = 0; requiredFields.length > i; i++) {
var field = requiredFields[i];
if (!user[field]) {
return Promise.reject(new Error('A ' + field + ' is required to activate a user.'));
}
}
return this._request.post(this._baseUrl + '/users/' + userId + '/activate', (0, _objects.toSnakeCase)(user));
}
/**
* Adds an application to the current user's list of favorited applications
*
* API Endpoint: '/applications/:applicationId/favorites'
* Method: POST
*
* Note: Only valid for web users using auth0WebAuth session type
*
* @param {number} applicationId The ID of the application
*
* @returns {Promise}
* @fulfill {ContxtUserFavoriteApplication} Information about the contxt application favorite
* @reject {Error}
*
* @example
* contxtSdk.coordinator
* .createFavoriteApplication(25)
* .then((favoriteApplication) => console.log(favoriteApplication))
* .catch((err) => console.log(err));
*/
}, {
key: 'createFavoriteApplication',

@@ -309,2 +360,33 @@ value: function createFavoriteApplication(applicationId) {

/**
* Gets a list of users for a contxt organization
*
* API Endpoint: '/organizations/:organizationId/users'
* Method: GET
*
* @param {string} organizationId The ID of the organization
*
* @returns {Promise}
* @fulfill {ContxtUser[]} List of users for a contxt organization
* @reject {Error}
*
* @example
* contxtSdk.coordinator
* .getUsersByOrganization('36b8421a-cc4a-4204-b839-1397374fb16b')
* .then((orgUsers) => console.log(orgUsers))
* .catch((err) => console.log(err));
*/
}, {
key: 'getUsersByOrganization',
value: function getUsersByOrganization(organizationId) {
if (!organizationId) {
return Promise.reject(new Error('An organization ID is required for getting a list of users for an organization'));
}
return this._request.get(this._baseUrl + '/organizations/' + organizationId + '/users').then(function (orgUsers) {
return (0, _objects.toCamelCase)(orgUsers);
});
}
/**
* Gets information about a contxt user

@@ -373,2 +455,94 @@ *

}
/**
* Creates a new contxt user, adds them to an organization, and
* sends them an email invite link to do final account setup.
*
* API Endpoint: '/organizations/:organizationId/users'
* Method: POST
*
* Note: Only valid for web users using auth0WebAuth session type
*
* @param {string} organizationId The ID of the organization
* @param {Object} user
* @param {string} user.email The email address of the new user
* @param {string} user.firstName The first name of the new user
* @param {string} user.lastName The last name of the new user
* @param {string} user.redirectUrl The url that the user will be redirected
* to after using the invite email link. Typically this is an /activate
* endpoint that accepts url query params userToken and userId and uses them
* to do final activation on the user's account.
*
* @returns {Promise}
* @fulfill {ContxtUser} The new user
* @reject {Error}
*
* @example
* contxtSdk.coordinator.
* .inviteNewUserToOrganization('fdf01507-a26a-4dfe-89a2-bc91861169b8', {
* email: 'bob.sagat56@gmail.com',
* firstName: 'Bob',
* lastName: 'Sagat',
* redirectUrl: 'https://contxt.ndustrial.io/activate'
* })
* .then((newUser) => console.log(newUser))
* .catch((err) => console.log(err));
*/
}, {
key: 'inviteNewUserToOrganization',
value: function inviteNewUserToOrganization(organizationId) {
var user = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
if (!organizationId) {
return Promise.reject(new Error('An organization ID is required for inviting a new user'));
}
var requiredFields = ['email', 'firstName', 'lastName', 'redirectUrl'];
for (var i = 0; requiredFields.length > i; i++) {
var field = requiredFields[i];
if (!user[field]) {
return Promise.reject(new Error('A ' + field + ' is required to create a new user.'));
}
}
return this._request.post(this._baseUrl + '/organizations/' + organizationId + '/users', (0, _objects.toSnakeCase)(user)).then(function (response) {
return (0, _objects.toCamelCase)(response);
});
}
/**
* Removes a user from an organization
*
* API Endpoint: '/organizations/:organizationId/users/:userId'
* Method: DELETE
*
* @param {string} organizationId The ID of the organization
* @param {string} userId The ID of the user
*
* @returns {Promise}
* @fulfill {undefined}
* @reject {Error}
*
* @example
* contxtSdk.coordinator
* .removeUserFromOrganization('ed2e8e24-79ef-4404-bf5f-995ef31b2298', '4a577e87-7437-4342-b183-00c18ec26d52')
* .catch((err) => console.log(err));
*/
}, {
key: 'removeUserFromOrganization',
value: function removeUserFromOrganization(organizationId, userId) {
if (!organizationId) {
return Promise.reject(new Error('An organization ID is required for removing a user from an organization'));
}
if (!userId) {
return Promise.reject(new Error('A user ID is required for removing a user from an organization'));
}
return this._request.delete(this._baseUrl + '/organizations/' + organizationId + '/users/' + userId);
}
}]);

@@ -375,0 +549,0 @@

2

package.json
{
"name": "@ndustrial/contxt-sdk",
"version": "0.0.49",
"version": "0.0.50",
"description": "",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

import EdgeNodes from './edgeNodes';
import Roles from './roles';
import { toCamelCase, toSnakeCase } from '../utils/objects';

@@ -38,2 +39,19 @@

/**
* @typedef {Object} ContxtStack
* @property {string} clientId
* @property {string} clusterId
* @property {string} createdAt ISO 8601 Extended Format date/time string
* @property {string} currentVersionId
* @property {string} description
* @property {string} documentationUrl
* @property {string} icon
* @property {number} id
* @property {string} name
* @property {string} organizationId
* @property {string} ownerId
* @property {string} type
* @property {string} updatedAt ISO 8601 Extended Format date/time string
*/
/**
* @typedef {Object} ContxtUser

@@ -78,2 +96,3 @@ * @property {string} createdAt ISO 8601 Extended Format date/time string

this.edgeNodes = new EdgeNodes(sdk, request, baseUrl);
this.roles = new Roles(sdk, request, baseUrl);
}

@@ -80,0 +99,0 @@

@@ -16,2 +16,4 @@ 'use strict';

require('./contxtOrganizationFeaturedApplication');
require('./contxtRole');
require('./contxtStack');
require('./contxtUser');

@@ -18,0 +20,0 @@ require('./contxtUserFavoriteApplication');

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc