22
33![ NPM version badge] ( https://img.shields.io/npm/v/@payid-org/payid-cli )
44
5- PayID CLI for creating, fetching, signing and verifying PayIDs. Based on the Typescript PayID Utils library.
5+ Command-line interface for creating, fetching, signing and verifying PayIDs.
6+ Based on the Typescript PayID [ Utils] ( https://github.com/payid-org/utils ) library.
67
78## Prerequisites
89
9- In order to use the CLI, both [ node] ( https://nodejs.org/en/download/ ) and
10- [ npm] ( https://docs.npmjs.com/downloading-and-installing-packages-locally ) must be installed first.
10+ In order to use the CLI, both [ node] ( https://nodejs.org/en/download/ ) and
11+ [ npm] ( https://docs.npmjs.com/downloading-and-installing-packages-locally ) must be installed first.
1112
1213## Installation
1314
14- To install the PayID CLI, run the command
15+ To install the PayID CLI, run the command:
16+
1517```
1618npm install -g @payid-org/payid-cli
1719```
1820
1921## Interactive vs single command mode
2022
21- CLI can be run in interactive mode or as a single command mode.
22- In interactive mode, a prompt is shown where multiple commands can be run until the exit command is run.
23+ CLI can be run in interactive mode or non-interactive (single command) mode.
24+ In interactive mode, a prompt is shown where multiple commands can be run until the ` exit ` command is run.
25+ Interactive mode retains a history of commands run which can be accessed using the up arrow key. Command completion
26+ is available using the tab key.
27+
28+ In non-interactive mode, a single command is run (based on supplied command line arguments) and then the CLI exits.
29+ No prompt is shown in this mode. This mode is useful for running commands from a script as well as chaining the results
30+ of multiple commands together.
2331
24- In single command mode, a single command is run and then the CLI exits. No prompt is shown in this mode.
25- This mode is useful for running commands from a script, or from a shell where multiple commands can be
26- chained together or to pipe output to another application.
32+ To run the CLI in interactive mode, run ` payid ` .
2733
28- To run the CLI in interactive mode , run ``` payid ``` .
34+ To run the CLI in non- interactive, run ` payid <command> <arguments> ` . Examples:
2935
30- To run the CLI in single command mode, run ``` payid <command> <arguments> ``` . Example:
3136```
3237payid load 'nhartner$xpring.money'
3338```
34- _ note: when passing a PayID as an argument in single command mode, the PayID needs to be quoted
35- if run in a Linux shell (to avoid the '$' being interpolated as a variable by the Linux shell).
39+
40+ Or to run multiple commands:
41+
42+ ```
43+ payid init 'my$pay.id' && payid crypto-address add btc mainnet notARealAddress && payid save
44+ ```
45+
46+ _ Note_ : when passing a PayID as an argument in non-interactive mode, the PayID needs to be escaped or quoted
47+ to avoid the '\$ ' being interpolated as a variable by the shell.
3648
3749## Commands
3850
39- A list of available commands can be found run running the ` help ` command.
51+ The following commands are available:
52+
53+ ```
54+ help [command...] Provides help for a given command.
55+ exit Exits application.
56+ clear clear the terminal
57+ crypto-address add <paymentNetwork> <environment> <address> [tag] start building a new PayID
58+ crypto-address remove <address> remove an address from the current PayID
59+ keys clear clears all loaded keys
60+ keys generate generates and saves a new identity key
61+ keys list lists keys that have been loaded
62+ keys load <filePath> load identity-key from file
63+ keys print print keys that have been loaded in pem format
64+ init <payid> initializes a new PayID
65+ inspect [payId] Inspect signatures on the loaded PayID or from an optionally specified PayID
66+ load <payId> loads a PayID from PayID server
67+ show Shows the currently loaded PayID
68+ sign sign the loaded PayID with the loaded signing keys
69+ verify [payId] Verify the loaded PayID or an optionally specified PayID
70+ save Save the currently loaded PayID
71+ from-url <url> convert a URL to a PayID
72+ to-url <payId> converts PayID to url
73+
74+ ```
4075
4176## Use Cases
4277
4378### Loading a PayID
79+
4480The following command can be used to load an existing PayID from a remote server:
81+
4582```
4683load nhartner$xpring
4784```
85+
4886This will fetch all the PayID address mappings for the given PayID from the remote
4987server and displays the resulting JSON.
5088
@@ -59,6 +97,7 @@ crypto-address add xrpl mainnet rP3t3JStqWPYd8H88WfBYh3v84qqYzbHQ6 12345
5997crypto-address add btc mainnet 3M2CH71P6uZTra1PsjiEhNFB7kCENShCgt
6098save
6199```
100+
62101The end result should be a PayID json representation being saved to the local filesystem as
63102example.json.
64103
@@ -72,9 +111,11 @@ To remove all loaded keys from the CLI's local storage, use the `keys clear` com
72111The ` keys list ` command will show you all keys currently loaded into the CLI.
73112
74113To generate new key run:
114+
75115```
76116keys generate
77117```
118+
78119This will generate a new key and save it to a file named ` identity-key.pem ` . To load a previously
79120created identity key, run ` keys load </path/to/pem/file> ` .
80121
@@ -93,5 +134,18 @@ command can be used to save your PayID, with signed addresses, to file.
93134
94135Two commands are available to verify a PayID's verified addresses.
95136
96- - ``` verify ``` - checks if all the verified addresses have valid signatures
97- - ``` insepct ``` - displays details information about each verified address and signatures.
137+ - ` verify ` - checks if all the verified addresses have valid signatures.
138+ - ` inspect ` - displays details information about each verified address and signatures.
139+
140+ ## Creating, Signing and Inspecting a PayID
141+
142+ Bringing all the above commands together, we can create a PayID, add an address mapping, generate an identity key,
143+ sign our PayID address mapping and then inspect the final result.
144+
145+ ```
146+ init example$mypayid.com
147+ crypto-address add xrpl mainnet rP3t3JStqWPYd8H88WfBYh3v84qqYzbHQ6
148+ keys generate
149+ sign
150+ inspect
151+ ```
0 commit comments