Skip to main content

Commands

Similar to Polykey, the CLI commands will be divided into 7 domains which reflect functions that can be performed within specific sections of the program.

There are 3 levels which indicate the personas that would use each command. The first level represents a new user who will not directly interact with encryption but rather will primarily use the vault system. The second and third levels indicate users who will use cryptography commands beyond the existing vault system.

The node path is optionally supplied to all commands and will indicate the polykey node to use. If no path is specified, the default path is used.

There are no 'lock' or 'unlock' commands. Polykey is unlocked through one of two methods. Each command will specify an optional password parameter. Entering a password directly into the CLI is insecure as the CLI history can reveal the password. Therefore a file containing the password must be supplied to the command. This will create a session with a timeout of 5 minutes. If no commands are entered within the 5 minute timer, then the session is destroyed and the password must be entered again. The other method for creating a session will occur when no session exists and a CLI command is executed. A prompt will appear for the password to be entered, which will create a session if entered successfully. A session with a Polykey Agent is a singleton, so only one session can be used with an Agent at anytime.

Bootstrap

The bootstrap subcommand solely deals with the construction of the state of polykey.

The supplied or assumed node path must exist and be empty for a successful execution, otherwise the command will exit with code [EX_USAGE (64)].

CommandDescriptionLevelInteraction
bootstrapInitializes a PolyKey node at a node path1Local

Agent

The agent subcommand allows control over the Polykey agent process.

CommandDescriptionLevelInteraction
startStarts the PolyKey Agent1Local
stopStops the PolyKey Agent1Local
statusGets the status of the PolyKey Agent1Local
unlockStarts a session for the current client1Local
lockLocks the current client session1Local
lockallLocks all active sessions on the agent1Local

Vaults

The vaults subcommand will deal with CRUD (Create, read, update and delete) operations on Polykey vaults.

CommandDescriptionLevelInteraction
createCreates a new vault1Local
deleteDeletes an existing vault1Local
listLists all existing vaults1Local
renameRenames an existing vault1Local
statsGets the stats of an existing vault1Local
shareShares vaults with a gestalt1Local
unshareUnshares vaults with a gestalt1Local
permissionsGets the permissions for a vault1Local
pullPulls a vault from another node1Agent-Agent
scanLists the vaults of another node1Agent-Agent
cloneClones a vault from another node1Agent-Agent

Secrets

The secrets subcommand will deal with CRUD (Create, read, update and delete) operations on secrets within a Polykey vault.

As secrets subcommands are performed within a single vault, paths are specified using the following notation <vaultName>:<secretPath>. As each vault maintains separate filesystems, secrets cannot be transferred across vaults.

CommandDescriptionLevelInteraction
createCreates a new secret1Local
deleteDeletes an existing secret1Local
editEdits an existing secret1Local
getGets the contents of an existing secret1Local
listLists the secrets within an existing vault1Local
mkdirMakes a directory inside an existing vault1Local
dirAdds a directory of secrets to an existing vault1Local
renameRenames an existing secret1Local
updateUpdates an existing secret with new content1Local
envInjects existing secrets into an environment2Local

Keys

The keys subcommand will deal with operations using the root keypair and root certificate.

Keys database is an internal implementation for storing keys from other domains and currently cannot be manipulated by users.

Encryption using the root keypair has a size limit depending on the size of the public key.

For signature and verification using the root keypair, the data and signature will be input and output separately. In the future, this will be done using a specific file format which allows the signature and data to be compiled into one file.

CommandDescriptionLevelInteraction
certGets the root certificate1Local
certchainGet the certificate chain1Local
rootGet the root keypair1Local
renewRenews the root keypair1Local
passwordChange the password of the root keypair1Local
resetResets the root keypair2Local
decryptDecrypts data using the root keypair2Local
encryptEncrypts data using the root keypair2Local
signSigns data using the root keypair3Local
verifyVerifies a signature using the root keypair3Local

Nodes

The node subcommand allows manipulation of Polykey's peer-to-peer system.

CommandDescriptionLevelInteraction
addAdds a node to the node graph1Local
delete(Removed)Deletes a node from the node graph1Local
get(Removed)Gets the node info for a particular node1Local
claimMakes a claim to a node1Agent-Agent
unclaimRemoves a claim to a ndoe1Agent-Agent
findAttempts to find a node in the DHT1Agent-Agent
pingPings a node to check if it is online1Agent-Agent

Identities

The identities subcommand allows control over the node's identity and its links with other social identities.

CommandDescriptionLevelInteraction
claimClaim an identity for this keynode1Local
authenticateAuthenticate a social identity provider (Github only)1Local
getGets the gestalt of a node or identity1Local
listLists the available gestalts1Local
trustTrusts a node id or identity1Local
untrustUntrusts a node id or identity1Local
searchSearches the provider for a connected identity1Local
allowSet a specific permission for a Node or Identity2Local
disallowRemove a Specific permission for a Node or Identity2Local
discoverStarts discovery process using Node or Identity as a starting point1Agent-Agent
permsGets the permisson for an node or identity1Local

Notifications

CommandDescriptionLevelInteraction
sendSends a notification to another node1Agent-Agent
readDisplays notifications and marks them as "read"1Local
clearClears all read and unread notifications1Local

CLI Commands Design and Style

  • Toggles should be -f -v flags that when used are true and when not used are false. These can be joined up together like -fv, but this may be confusing with the multiword options, and in which case I usually don't use the joined up versions. Flags should be sparing, users should not need to remember every flag they need to do something.
  • Options should ideally be optional --key value and -k value. In some cases they represent key-value parameters which are not optional. Make sure that multi-word options are like --multi-word and their short form is -mw.
  • Parameters should be positional so pk subcommand param1 param2, in that case they are usually not optional and are required, it is possible to have arbitrary arity of parameters so you can have 1, or many.
  • Exception is pk subcommand -k value -k2 value -k3 value, which is a key value parameters, this would not be optional, but in many cases if the commands are designed well, you should be able to have all values as parameters.

Make sure you're using the output formatting functions in the src/bin/utils.ts (or at least that's where I had them last). This ensures you have a consistent set outputs, whether it is a list, table, json or otherwise. We can have -f to indicate different output formats for these.

And for testing, try to use the main exported function, but I think as you said on slack there are new methods that make it easier to test these that might have been created by @DrFacepalm or @scottmmorris.

Finally make sure all your options/flags/parameters are consistent across all subcommands. In some cases we find better names we should switch to those.

Subcommands have better recall and discoverability:

  • Subcommands have full words which is easier to understand, and easier to remember, less ambiguity
  • Subcommands can be auto-suggested (because they have a deterministic position), flags cannot be
  • High level commands should always be subcommands, not hidden behind flags
  • Minimize optionality, increase conventionality, reduce user configuration headache, things should be as expected and intuitive as complexity allows