Releases: indykite/indykite-sdk-node
0.1.2
0.1.2
- [Actions] Add automated release pipeline
- [Actions] Remove duplicate step in publish flow
v0.1.1
[FIX] - Fixed method for consent verifier token creation (createConsentVerifier
). Now it accepts list of scopes, list of audiences, session details and details for remembering the authorization.
v0.1.0 - Initial Release
IndyKite Client Libraries for Node.js
IndyKite is a cloud identity platform built to secure and manage human & non-person (IoT) identities and their data. This repository containts the JavaScript Library packages for IndyKite Platform Client SDK.
Examples of functionality available in SDK:
- Token Introspection
- CRUD Operations on Digital Twins
- Change Password
- Limited Configuration Management
In order to access to the platform you must obtain an API key first. This key can be obtained either from the Admin Console or request one from your point of contact at IndyKite.
Terminology
Definition | Description |
---|---|
Digital Twin | A digital twin is the digital identity of a physical entity on/in a software/identity system |
Application Space ID | ID of the application where the digital twin belongs to |
Application Agent ID | ID of the agent which makes the application available for the different calls |
Tenant ID | ID of the tenant where the digital twin belongs to. The tenant is belong to an application space |
Private Key and Settings | The secret which required to reach the system. Indykite provides the necessary secrets |
Property | The digital twin's property (eg.: email, name) |
JWT | JSON Web Tokens |
Introspect | A process used to validate the token and to retrieve properties assigned to the token |
Patch property | Add, change or delete a property of a digital twin |
Documentation
Visit the IndyKite One Developer Community site for official IndyKite documentation and to find out how to use the entire platform for your project.
Installation
npm i @indykiteone/jarvis-sdk-node
Getting Started
Trial
For a trial please contact IndyKite to setup and
configure the platform.
Config
The IndyKite SDK reads config properties from a JSON formatted configuration file. The path to this file is provided to your application via an environment variable Once you have the config information (After you've registered and setup an application space) then you need to create the json file (you can find an example here: example_config.json) then create the INDYKITE_APPLICATION_CREDENTIALS_FILE
environment variable which will contain the path to the json configuration file (see the example below).
export INDYKITE_APPLICATION_CREDENTIALS_FILE=<path_to_config_file>/config.json
Import the SDK into your application
import { IdentityClient, TokenInfo } from '@indykiteone/jarvis-sdk-node';
import { Property } from '@indykiteone/jarvis-sdk-node';
Creating a new client connection & reading the user token from env
async function getConnection() {
console.log("Starting Get Connection");
const sdk = await IdentityClient.createInstance();
return sdk;
}
To introspect a user token
async function tokenIntrospect(sdk:IdentityClient) {
console.log("Starting tokenIntrospect");
const tokenInfo = await sdk.introspectToken(userToken);
console.log('Token introspection', JSON.stringify(tokenInfo, null, 2))
console.log('Token Active: ', tokenInfo.active);
console.log('Token appSpaceId: ', tokenInfo.appSpaceId);
console.log('Token applicationId: ', tokenInfo.applicationId);
console.log('Token authenticationTime: ', tokenInfo.authenticationTime);
console.log('Token customerId: ', tokenInfo.customerId);
console.log('Token expireTime: ', tokenInfo.expireTime);
console.log('Token impersonated: ', tokenInfo.impersonated);
console.log('Token issueTime: ', tokenInfo.issueTime);
console.log('Token providerInfo: ', tokenInfo.providerInfo);
console.log('Token subject: ', tokenInfo.subject);
return tokenInfo;
}
The tokeninfo object has several methods that can be used to get a variety of details related to the introspected token.
tokenInfo.active: boolean (true/false) - will return true if the token is still active
tokenInfo.subject.id: The UUID formated id that identifies the subject of the token
tokenInfo.customerId: The UUID formatted id that identifies the customer subscription
tokenInfo.subject.tenantId: The UUID formatted id that identifies the tenant that the subject belongs to
tokenInfo.appSpaceId: The UUID formatted id that identifies the Customer Application Space
tokenInfo.applicationId: The UUID formatted id that identifies the application profile that was created for the application that you are developing.
tokenInfo.authenticationTime: The time that the subject initially authenticated
tokenInfo.expireTime: The time that the token will expire.
tokenInfo.impersonated:
tokenInfo.issueTime: The time that the token was initially issued
tokenInfo.providerInfo: The token provider url
Retrieving a Digital Twin using a token
async function getDT(sdk:IdentityClient) {
console.log("Starting getDT");
const dtByToken = await sdk.getDigitalTwinByToken(userToken, ['email']);
return dtByToken;
}
Implementing Forgot Password
async function forgotPassword(sdk:IdentityClient) {
console.log("Starting forgetPassword");
// startForgottenPasswordFlow(digitalTwinId: Buffer, tenantId: Buffer): Promise<StartForgottenPasswordFlowResponse>
const digitalTwin = getDT(sdk);
const dt = (await digitalTwin).digitalTwin;
if (!dt) {
console.log('Missing DigitalTwin?');
return;
}
const digitalTwinID = dt.id;
const digitalTwinTenantID = dt.tenantId;
const forgotPasswordResponse = await sdk.startForgottenPasswordFlow(Utils.uuidToString(digitalTwinID), Utils.uuidToString(digitalTwinTenantID));
}
Changing DT passwords
async function changePass(sdk:IdentityClient) {
// changePassword(digitaltwinid, tenantid, password)
// changePasswordByToken
console.log("Starting changePass()");
const digitalTwin = getDT(sdk);
const dt = (await digitalTwin).digitalTwin;
if (!dt) {
console.log('Missing DigitalTwin?');
return;
}
const digitalTwinID = dt.id
const digitalTwinTenantID = dt.tenantId;
var newPassword = 'MyNewPassword';
// changePassword(digitaltwinid, tenantid, password)
console.log("Digital Twin ID: ", digitalTwinID);
console.log("Tenant ID: ", digitalTwinTenantID);
console.log("Password: ", newPassword);
console.log("changePassword() function called");
const changePasswordResponse = await sdk.changePassword(digitalTwinID, digitalTwinTenantID, newPassword);
console.log("Change Password Resp: ", changePasswordResponse);
}
Fetch DT properties using a token
async function getProperty(sdk:IdentityClient) {
console.log("Starting Get Property");
// TODO:
// getDigitalTwin(digitalTwinId, tenantId, properties)
// Get Digital Twin using token
const digitaltwin = getDT(sdk);
const dt = (await digitaltwin).digitalTwin;
console.log('Digital Twin By Token:', JSON.stringify(dt, null, 2));
if (!dt) {
console.log('Missing DigitalTwin?');
return;
}
// Examples of getting properties
console.log('Get email property:', dt.getProperty('email'));
console.log('Get email value:', dt.getPropertyValue('email'));
console.log('Get email value:', dt.getProperty('email')?.value);
console.log('Get all email properties:', dt.getProperties('email'));
}
Add properties to a DT
async function addProperty(sdk:IdentityClient) {
console.log("Starting add Property");
const digitaltwin = getDT(sdk);
const dt = (await digitaltwin).digitalTwin;
if (!dt) {
console.log('Missing DigitalTwin?');
return;
}
const tid = dt.tenantId;
const email = getRandomEmail();
dt.addProperty(new Property('email').withValue(email));
Patching the database after adding a new property
// patchProperties()
console.log("PatchProperties(): ");
const patch = await sdk.patchProperties(dt.id, tid, dt);
console.log('Patch Response: ', JSON.stringify(patch, null, 2));
// or
// patchPropertiesByToken to save the changes to the remote database
console.log("patchPropertiesByToken(): ")
console.log("Get Patch Operation: " + JSON.stringify(dt.getPatchOperation(), null, 2));
const patchByToken = await sdk.patchPropertiesByToken(userToken, dt);
console.log('Patch by token response:', JSON.stringify(patchByToken, null, 2));
Updating existing DT properties
async function updateProp(sdk:IdentityClient) {
console.log("Starting updateProperty()");
const digitalTwin = getDT(sdk);
const dt = (await digitalTwin).digitalTwin;
if (!dt) {
console.log('Missing DigitalTwin?');
return;
}
const digitalTwinID = dt.id
const digitalTwinTenantID = dt.tenantId;
const email = '[email protected]';
console.log("Update the DT with this email: ", email);
dt.updatePropertyValue(new Property('email'), email);
console.log("Get Patch Operation: " + JSON.stringify(dt.getPatchOperation(), null, 2));
const patch = await sdk.patchProperties(digitalTwinID, digitalTwinTenantID, dt);
console.log('Ge...