Affinidi CLI
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
- Set up Affinidi Vault account. Follow the guide below if you haven’t set it up yet.
Install NodeJS v18 or higher on your machine.
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]
- All commands start with the keyword
affinidi
. - Topics typically correspond to Affinidi services or domains.
- Commands correspond to the actions to perform.
- Flags are a way to provide the parameters required by the command.
- 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
Glad to hear it! Please tell us how we can improve more.
Sorry to hear that. Please tell us how we can improve.
Thank you for sharing your feedback so we can improve your experience.