Setup Your Environment

Setup Your Environment
info

The PhoneCheck, SubscriberCheck, and SIMCheck products are all mobile-first products. The purpose of the "Setup Your Environment" guide is to provide you with everything needed before creating one of the three Checks.

tru.ID CLI

The tru.ID CLI enables developers to control their projects via command line, they're also able to build integrations into existing development workflows, via scripts without the need for an IDE.

With Node.js installed you install the tru.ID CLI as follows:

npm install -g @tru_id/cli

Once the tru command is installed, setup the CLI with your Workspace credentials which you'll find within the tru.ID console, you'll also need to define the data_residency which can either be EU (Europe) or IN (India).

tru setup:credentials {client_id} {client_secret} {data_residency}

Create a Project

Projects are configuration containers within the tru.ID platform and you'll normally have a one-to-one mapping of a tru.ID project to an application that you are developing (though you may also create a project per environment: dev, staging and prod). A key piece of configuration are the project credentials which contain a client_id`` and client_secret` that you use to authenticate interactions with the tru.ID APIs.

You create projects using the CLI:

tru projects:create "My Project"

And you'll see output such as:

Creating Project "My Project"
Project configuration saved to "~/my_project/tru.json".

The tru.json file contains your project configuration including the project credentials. This file should not be commited to your version control!

With a project created you can cd my_project so the CLI can read the tru.json file from the cwd and you have everything you need to fully utilise the tru.ID CLI.

The Demo Development server

The development server is an example server written in Node.js to provide a working example for developers to create PhoneCheck or SubscriberCheck with minimal configuration. This server has been created only for demonstration purposes and should not be adopted for release into production for your product. The purpose of a backend server such as the functionality shown in the demo server is to:

  • Allow communication between the mobile device and the server itself
  • Make requests to tru.ID's APIs in a secure manner for the mobile device, such as create a PhoneCheck using your Project's credentials without the risk of these credentials being intercepted

Set up via CLI

The dev-server can be installed as a plugin for the tru.ID CLI, if you want to read more about this plugin here is the dev-server plugin repository. It is installed in the CLI with the following command:

tru plugins:install @tru_id/cli-plugin-dev-server

To run the server now you'll need to make sure you are in the same directory in your Terminal, where ever you have stored your tru.json config file, which is the file containing your project's configuration.

Then run:

tru server

Set up Direct Download

The dev-server can be cloned directly from the tru.ID GitHub repository, in your Terminal running the following command:

git clone git@github.com:tru-ID/dev-server.git

Then in your Terminal navigate into the dev-server directory and run the following command:

npm install
# or
yarn install

You can currently provide your Project's credentials in one of two ways:

  • Rename .env.example to .env, and update the TRU_ID_CLIENT_ID and TRU_ID_CLIENT_SECRET values to be your own Project's values.
  • or move the tru.json file into the dev-server directory.

Note: it is bad security practice to commit your credentials into your repository, whether it's a .env, a tru.json file or hard coded into your project.

To run the dev-server you can run the following command in your Terminal:

npm start
# or
yarn start
Download our Developer Console mobile app
Made withacross the 🌍
© 2022 4Auth Limited. All rights reserved. tru.ID is the trading name of 4Auth Limited.