Affinidi CLI

Manage your projects and integration using command line interface.

Affinidi CLI is a developer tool to easily manage your projects and integrate with Affinidi services using the command line. It empowers developers to use simple commands to improve developer experience when interacting with our different services.

Before you begin
  1. Set up Affinidi Vault account. Follow the guide below if you haven’t set it up yet.
Set up Affinidi Vault

Set up an Affinidi Vault account using the Web Vault or install the Mobile Vault (for Android).

The same setup steps for Mobile Vault.

  1. Click on Get started if you are creating a new account, or click on Restore from Backup if you have an existing backup of your Affinidi Vault. Provide the Passphrase to secure your Affinidi Vault.

You have the option to enable Biometrics to unlock your Affinidi Vault easily instead of using Passphrase.

Affinidi Vault Setup
  1. Enter your email address to register with the Affinidi Vault. An OTP will be sent to this email for verification.
Affinidi Vault Passphrase
  1. Enter the OTP sent to the email you have provided for verification to complete the setup.
Affinidi Vault Email Verification

After successfully providing the OTP, you are redirected to the Affinidi Vault dashboard.

  1. Install NodeJS v18 or higher on your machine.

  2. Install Git to generate a reference app using affinidi generate app command.

Installation

How do I use Affinidi CLI?

Accessing most Affinidi CLI features, like creating a Login Configuration, requires you to authenticate to Affinidi using Affinidi Vault. To do this, you can execute the following command:

affinidi start

If you received a session expired error, just run the same command to refresh your session.

Understanding Commands

Commands in Affinidi CLI have the following structure:

affinidi <topic> <command> [flags]
  1. All commands start with the keyword affinidi.
  2. Topics typically correspond to Affinidi services or domains.
  3. Commands correspond to the actions to perform.
  4. Flags are a way to provide the parameters required by the command.
  5. Use affinidi help <topic|command> to show the helpful details.

Help

All commands and topics have a help document with usage, descriptions, flags and examples.

View it with the help flag: affinidi login create-config --help

With the help root command: affinidi help login create-config

Or by searching and selecting a command: affinidi search

Flags

All commands have some global flags at their disposal.

--help Prints the command’s help information.

--json Enforce printing the output in json format. Useful for programmatic usage of CLI.

--no-color Disables color in the output. Useful if you have trouble distinguishing colors.

--no-input Disables all the interactive prompts. Useful for automation anc ci.

You can input flags in multiple ways. All of the following will work:

affinidi login create-config --file="config.json"
affinidi login create-config --file "config.json"
affinidi login create-config --file=config.json
affinidi login create-config --file config.json
affinidi login create-config -f "config.json"
affinidi login create-config -f="config.json"
affinidi login create-config -f"config.json"
affinidi login create-config -f config.json
affinidi login create-config -f=config.json
affinidi login create-config -fconfig.json

Active Project

Affinidi CLI introduces a local concept of “Active Project” for convenience. Commands under the login and iam topics perform actions under the active project. In order to not have to ask for the project and create the necessary credentials each time you call one of these commands, we ask you to define the CLI’s working project once.

To check what is the current active project use the command affinidi project get-active-project

To switch the active project use the command affinidi project select-project

Session and Configuration Files

When you authenticate to Affinidi with affinidi start the CLI will create a folder with a credentials file in your home directory.

~/.affinidi/credentials-v2.json - Stores your current session credentials. Keep it secret as this allows you to call Affinidi services.

When you run affinidi stop your session information is deleted.

Affinidi CLI Project

The Affinidi CLI is an open-sourced project on GitHub. Explore the GitHub repo to learn more on how you can contribute to the project, provide your feedback, or to report an issue.

Changelog

To view the latest changes to the Affinidi TDK, visit the Affinidi CLI Changelog page.

Explore CLI Topics and Commands


Basic Commands

Useful basic commands available to access Affinidi services.

Manage Projects

Manage projects and switch between them to create related resources.

Manage Login

Manage your Login Configuration, and user groups to integrate Affinidi Login.

Manage Token

Manage your Personal Access Token (PAT) to connect and perform actions on Affinidi services on the user’s behalf.

Manage IAM

Manage your IAM policies to grant access to users and Personal Access Tokens (PATs).

Manage Iota

Manage Affinidi Iota Framework configurations and data request queries.

Manage Issuance

Manage Credential Issuance configurations and integration.

Manage Wallets

Manage Affinidi Wallets for signing credentials and request token.

Generate App

Generate sample apps using different programming languages, frameworks, and IAM solutions.