Skip to main content
Version: v5.0

Installing the npm package

Install the platform JavaScript APIs from the following npm repository: npm.twinit.dev.

Important: To access the repository, you must use Passport Service User Access Keys. For more information, see User Access Keys.

User Access Keys#

To create your User Access Keys, see User Access Keys.

Important: Ensure you copy your keys when they display - keys are not accessible after you close the dialogue.

Note: Set your keys as environment variables for easier and more secure access and use.

Environment Configuration#

Add your email and User Access Keys as environment variables on your system. Please note that these keys are generated from app.invicara.com, otherwise it will not work. The variables must be named as follows:

  • DTPLATFORM_KEY - Enter your platform access key
  • DTPLATFORM_SECRET - Enter your platform secret key
  • DTPLATFORM_SECRET_BASE64 - Enter your platform secret key with base64 encoding and no line breaks. You can generate the encoding with a command line script.
  • DTPLATFORM_EMAIL - The email address you registered on the platform

macOS#

To set the environment variables on macOS edit ~/.bash_profile and set the following using appropriate values for your user.

In macOS, this presumes you are using the default POSIX-based base64 utility installed (and NOT the GNU-based utility ... see the Linux below if you are using the GNU coreutils on macOS.)

DTPLATFORM_KEY=ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFDTPLATFORM_SECRET=aBcdefgHIJklMNOpQRStUVWxyZ0129456aBcdefgHIJklMNOpQRStUVWxyZ01294DTPLATFORM_SECRET_BASE64=$(echo -n "${DTPLATFORM_SECRET}" | base64)[email protected]export DTPLATFORM_KEY DTPLATFORM_SECRET DTPLATFORM_SECRET_BASE64 DTPLATFORM_EMAIL

Linux#

To set the environment variables on Linux edit your ~/.bash_profile and set the following using appropriate values for your user.

In Linux, this presumes you have the GNU base64 utility installed.

DTPLATFORM_KEY=ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFDTPLATFORM_SECRET=aBcdefgHIJklMNOpQRStUVWxyZ0129456aBcdefgHIJklMNOpQRStUVWxyZ01294DTPLATFORM_SECRET_BASE64=$(echo -n "${DTPLATFORM_SECRET}" | base64 -w0)[email protected]export DTPLATFORM_KEY DTPLATFORM_SECRET DTPLATFORM_SECRET_BASE64 DTPLATFORM_EMAIL

Windows#

For Windows, you need to encode the secret to base64 before you create the environment variable. There are several options to do this.

Using the node REPL, you can do the following (replace the example string with your secret):

C:\> node -e "console.log(Buffer.from('aBcdefgHIJklMNOpQRStUVWxyZ0129456aBcdefgHIJklMNOpQRStUVWxyZ01294').toString('base64'))"
YUJjZGVmZ0hJSmtsTU5PcFFSU3RVVld4eVowMTI5NDU2YUJjZGVmZ0hJSmtsTU5PcFFSU3RVVld4eVowMTI5NA==

In Powershell, you can do the following (replace the example string with your secret):

PS C:\ > [Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes('aBcdefgHIJklMNOpQRStUVWxyZ0129456aBcdefgHIJklMNOpQRStUVWxyZ01294')) 
YUJjZGVmZ0hJSmtsTU5PcFFSU3RVVld4eVowMTI5NDU2YUJjZGVmZ0hJSmtsTU5PcFFSU3RVVld4eVowMTI5NA== 

Use the output for the value of DTPLATFORM_SECRET_BASE64.

Adding the variables to your system required adding the values in Control Panel:

  1. Open System from the Control Panel
  2. Click the Advanced system settings link
  3. Click Environment Variables.
  4. In the User Variables section, click New and enter the name and value for the environment variable. Add the first variable and value. For each of the variables defined above using the output of the base64 command for DTPLATFORM_SECRET_BASE64.

Configuring your platform project#

To fetch the platform JavaScript packages, you'll need to configure an .npmrc file. You can set your user-level file at ~/.npmrc (or %USERPROFILE%\.npmrc on Windows) or at the project-level as simply .npmrc. The platform specific contents of the file should look like this:

@dtplatform:registry=https://npm.twinit.dev///npm.twinit.dev/:username=${DTPLATFORM_KEY}//npm.twinit.dev/:_password=${DTPLATFORM_SECRET_BASE64}//npm.twinit.dev/:email=${DTPLATFORM_EMAIL}//npm.twinit.dev/:always-auth=true

Add Packages#

Once the above is complete you can add packages to your project with:

npm install @dtplatform/platform-api