Skip to content
This repository has been archived by the owner on Mar 8, 2024. It is now read-only.

Commit

Permalink
Merge pull request #5 from PayString/nh/payid-to-paystring
Browse files Browse the repository at this point in the history
rebrand PayID to PayString
  • Loading branch information
nhartner authored Dec 15, 2020
2 parents 6f3a651 + 20edcd2 commit 89ab213
Show file tree
Hide file tree
Showing 25 changed files with 241 additions and 238 deletions.
14 changes: 7 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FROM node:12-alpine

ADD . / payid-cli/
ADD . / paystring-cli/

RUN cd payid-cli/ &&\
RUN cd paystring-cli/ &&\
npm set unsafe-perm true &&\
npm cache clean --force &&\
npm install &&\
Expand All @@ -11,11 +11,11 @@ RUN cd payid-cli/ &&\

FROM node:12-alpine

RUN mkdir /opt/payid-cli
RUN mkdir /opt/paystring-cli

WORKDIR /opt/payid-cli
WORKDIR /opt/paystring-cli

COPY --from=0 /payid-cli/dist /opt/payid-cli/dist
COPY --from=0 /payid-cli/node_modules /opt/payid-cli/node_modules
COPY --from=0 /paystring-cli/dist /opt/paystring-cli/dist
COPY --from=0 /paystring-cli/node_modules /opt/paystring-cli/node_modules

ENTRYPOINT ["node", "/opt/payid-cli/dist/cli.js"]
ENTRYPOINT ["node", "/opt/paystring-cli/dist/cli.js"]
110 changes: 55 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
# `@payid-org/payid-cli`
# `@paystring/paystring-cli`

![NPM version badge](https://img.shields.io/npm/v/@payid-org/payid-cli)
![NPM version badge](https://img.shields.io/npm/v/@paystring/paystring-cli)

Command-line interface to create, fetch, sign, and verify PayIDs.
Based on the Typescript PayID [Utils](https://github.com/payid-org/utils) library.
Command-line interface to create, fetch, sign, and verify PayStrings.
Based on the Typescript PayString [Utils](https://github.com/paystring/utils) library.

## Prerequisites

Before you install PayID CLI locally, ensure that both [node](https://nodejs.org/en/download/) and
Before you install PayString CLI locally, ensure that both [node](https://nodejs.org/en/download/) and
[npm](https://docs.npmjs.com/downloading-and-installing-packages-locally) are installed locally.

You can also run PayID CLI as a Docker container. If you run commands that cause information to be stored locally, that information only persists for the duration of the container.
You can also run PayString CLI as a Docker container. If you run commands that cause information to be stored locally, that information only persists for the duration of the container.

## Installation

To install PayID CLI, run the command:
To install PayString CLI, run the command:

```
npm install -g @payid-org/payid-cli
npm install -g @paystring/paystring-cli
```

This command installs PayID CLI as a global npm module and links it as a `payid` executable
(typically under /usr/local/bin/payid).
This command installs PayString CLI as a global npm module and links it as a `paystring` executable
(typically under /usr/local/bin/paystring).

Alternatively, install and run via Docker:

```
docker run xpring/payid-cli
docker run xpring/paystring-cli
```

## Interactive vs. single command mode

You can run PayID CLI in either interactive mode or non-interactive (single command) mode.
You can run PayString CLI in either interactive mode or non-interactive (single command) mode.
In interactive mode, a prompt is displayed, and you can run multiple commands from this prompt. Run the `exit` command to leave interactive mode.

Interactive mode retains a history of executed commands that you can access by with the up arrow key. Use the <Tab> key for command completion.
Expand All @@ -40,25 +40,25 @@ In non-interactive mode, you run a single command, based on supplied command lin
No prompt is displayed in this mode. Non-interactive mode is useful for running commands from a script, or to chain the results
of multiple commands together.

To run the CLI in interactive mode, run `payid`. You can now enter `<command> arguments` for each command you want to run.
To run the CLI in interactive mode, run `paystring`. You can now enter `<command> arguments` for each command you want to run.

To run the CLI in non-interactive mode, run `payid <command> <arguments>`.
To run the CLI in non-interactive mode, run `paystring <command> <arguments>`.

Examples of non-interactive mode:

The following command lists information about the specified PayID.
The following command lists information about the specified PayString.

```
payid load 'nhartner$xpring.money'
paystring load 'nhartner$xpring.money'
```

You can run multiple commands chained together. This set of commands initializes a new or existing PayID, associates a specified crypto-address for the specified currency and network, and then saves the PayID with this information.
You can run multiple commands chained together. This set of commands initializes a new or existing PayString, associates a specified crypto-address for the specified currency and network, and then saves the PayString with this information.

```
payid init 'my$pay.id' && payid crypto-address add btc mainnet notARealAddress && payid save
paystring init 'my$paystring.com' && paystring crypto-address add btc mainnet notARealAddress && paystring save
```

_Note_: when passing a PayID as an argument in non-interactive mode, the PayID must be escaped or quoted
_Note_: when passing a PayString as an argument in non-interactive mode, the PayString must be escaped or quoted
to avoid the '\$' being interpolated as a variable by the shell.

## Commands
Expand All @@ -69,62 +69,62 @@ The following commands are available:
help [command...] Provides help for a given command.
exit Exits application.
clear Clears the terminal.
crypto-address add <paymentNetwork> <environment> <address> [tag] Starts building a new PayID.
crypto-address remove <address> Removes an address from the current PayID.
crypto-address add <paymentNetwork> <environment> <address> [tag] Starts building a new PayString.
crypto-address remove <address> Removes an address from the current PayString.
keys clear Clears all loaded keys.
keys generate Generates and saves a new identity key.
keys list Lists keys that have been loaded.
keys load <filePath> Loads identity-key from file.
keys print Prints keys that have been loaded in pem format.
init <payid> Initializes a new PayID.
inspect [payId] Inspects signatures on the loaded PayID or from an optionally specified PayID.
load <payId> Loads a PayID from PayID server.
show Shows the currently loaded PayID.
sign Signs the loaded PayID with the loaded signing keys.
verify [payId] Verifies the loaded PayID or an optionally specified PayID.
save Saves the currently loaded PayID.
from-url <url> Converts a URL to a PayID.
to-url <payId> Converts a PayID to a URL.
init <paystring> Initializes a new PayString.
inspect [paystring] Inspects signatures on the loaded PayString or from an optionally specified PayString.
load <paystring> Loads a PayString from PayString server.
show Shows the currently loaded PayString.
sign Signs the loaded PayString with the loaded signing keys.
verify [paystring] Verifies the loaded PayString or an optionally specified PayString.
save Saves the currently loaded PayString.
from-url <url> Converts a URL to a PayString.
to-url <paystring> Converts a PayString to a URL.
```

## Use Cases

### Load a PayID
### Load a PayString

Load an existing PayID from a remote server:
Load an existing PayString from a remote server:

```
load nhartner$xpring.money
```

This command fetches all the PayID address mappings for the given PayID from the remote
This command fetches all the PayString address mappings for the given PayString from the remote
server and displays the resulting JSON.

### Create a new PayID
### Create a new PayString

The following set of commands demonstrates how to create a new PayID, attach multiple
The following set of commands demonstrates how to create a new PayString, attach multiple
address mappings, and save the result to a JSON file.

```
init example$mypayid.com
init example$mypaystring.com
crypto-address add xrpl mainnet rP3t3JStqWPYd8H88WfBYh3v84qqYzbHQ6 12345
crypto-address add btc mainnet 3M2CH71P6uZTra1PsjiEhNFB7kCENShCgt
save
```

The PayID JSON representation specified here is saved to the local filesystem as example.json.
The PayString JSON representation specified here is saved to the local filesystem as example.json.

### Identity Keys

The PayID protocol supports signing address mappings using one or more cryptographic keys.
PayID CLI provides several commands to generate and load keys. Once a key is generated
or loaded by PayID CLI, it is retained in PayID CLI's local storage for use when you sign your PayID.
The PayString protocol supports signing address mappings using one or more cryptographic keys.
PayString CLI provides several commands to generate and load keys. Once a key is generated
or loaded by PayString CLI, it is retained in PayString CLI's local storage for use when you sign your PayString.

You can generate multiple identity keys by using the `keys generate` and `keys load` commands.

To remove all loaded keys from the CLI's local storage, use the `keys clear` command.
To see all keys currently loaded into PayID CLI, use the `keys list` command.
To see all keys currently loaded into PayString CLI, use the `keys list` command.

To generate a new key run:

Expand All @@ -135,34 +135,34 @@ keys generate
This generates a new key and saves it to a file named `identity-key.pem`. To load a previously
created identity key, run `keys load </path/to/pem/file>`.

### Sign a PayID
### Sign a PayString

Before you sign an PayID, you must either load the PayID using the `load` command, or create a PayID using the
`init` command, and you must execute commands so that the PayID one or more crypto-addresses.
Before you sign an PayString, you must either load the PayString using the `load` command, or create a PayString using the
`init` command, and you must execute commands so that the PayString one or more crypto-addresses.

Once a PayID has been initialized or loaded, you can sign it using an [identity key](#identity-keys). You must either generate a new key, or load an existing one. Once your PayID has been loaded or initialized, and your identity key has been generated or loaded,
you can sign the PayID using `sign` command. The `sign` command signs each of your PayID address
mappings using the loaded identity keys, and outputs the resulting PayID with a `verifiedAddress` field.
Once a PayString has been initialized or loaded, you can sign it using an [identity key](#identity-keys). You must either generate a new key, or load an existing one. Once your PayString has been loaded or initialized, and your identity key has been generated or loaded,
you can sign the PayString using `sign` command. The `sign` command signs each of your PayString address
mappings using the loaded identity keys, and outputs the resulting PayString with a `verifiedAddress` field.

By default, the sign command clears the unsigned `addresses` from the results. If you wish to
retain unsigned addresses after signing, use `sign --keep-addresses` or `sign -k` instead.

Finally, run the `save` command to save your PayID, with signed addresses, to file.
Finally, run the `save` command to save your PayString, with signed addresses, to file.

### Inspect a Verified PayID
### Inspect a Verified PayString

Two commands are available to verify a PayID's verified addresses.
Two commands are available to verify a PayString's verified addresses.

- `verify` - checks if all the verified addresses have valid signatures.
- `inspect` - displays details information about each verified address and signatures.

## Create, sign, and inspect a PayID
## Create, sign, and inspect a PayString

With a combination of commands, you can create a PayID, add an address mapping, generate an identity key,
sign your PayID address mapping, and then inspect the final result.
With a combination of commands, you can create a PayString, add an address mapping, generate an identity key,
sign your PayString address mapping, and then inspect the final result.

```
init example$mypayid.com
init example$mypaystring.com
crypto-address add xrpl mainnet rP3t3JStqWPYd8H88WfBYh3v84qqYzbHQ6
keys generate
sign
Expand All @@ -171,4 +171,4 @@ inspect

## Legal

By using, reproducing, or distributing this code, you agree to the terms and conditions for use (including the Limitation of Liability) in the [Apache License 2.0](https://github.com/payid-org/payid-cli/blob/master/LICENSE). If you do not agree, you may not use, reproduce, or distribute the code. **This code is not authorised for download in Australia. Any persons located in Australia are expressly prohibited from downloading, using, reproducing or distributing the code.** This code is not owned by, or associated with, NPP Australia Limited, and has no sponsorship, affiliation or other connection with the "Pay ID" service operated by NPP Australia Limited in Australia.
By using, reproducing, or distributing this code, you agree to the terms and conditions for use (including the Limitation of Liability) in the [Apache License 2.0](https://github.com/paystring/payid-cli/blob/master/LICENSE). If you do not agree, you may not use, reproduce, or distribute the code. **This code is not authorised for download in Australia. Any persons located in Australia are expressly prohibited from downloading, using, reproducing or distributing the code.**
17 changes: 8 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
{
"name": "@payid-org/payid-cli",
"name": "@paystring/paystring-cli",
"version": "1.0.4",
"description": "CLI for PayID",
"homepage": "https://github.com/payid-org/payid-cli#readme",
"description": "CLI for PayString",
"homepage": "https://github.com/paystring/paystring-cli#readme",
"bugs": {
"url": "https://github.com/payid-org/payid-cli/issues"
"url": "https://github.com/paystring/paystring-cli/issues"
},
"repository": {
"type": "git",
"url": "git+https://github.com/payid-org/payid-cli.git"
"url": "git+https://github.com/paystring/paystring-cli.git"
},
"license": "Apache-2.0",
"author": "",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"bin": {
"payid": "./dist/cli.js"
"paystring": "./dist/cli.js"
},
"files": [
"dist/*"
Expand All @@ -28,11 +28,11 @@
"test": "nyc mocha 'test/**/*.test.ts'"
},
"dependencies": {
"@payid-org/utils": "^1.2.0",
"@paystring/utils": "^1.3.0",
"axios": "^0.19.2",
"beautify-json": "^1.0.1",
"jose": "^1.27.3",
"node-forge": "^0.9.1",
"node-forge": "^0.10.0",
"vorpal": "^1.12.0"
},
"devDependencies": {
Expand Down
24 changes: 12 additions & 12 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import * as cmd from './commands'
const vorpal = new Vorpal()

// This enables command history within the CLI similar to bash.
vorpal.history('payid')
vorpal.history('payString')

const localStorage = new cmd.LocalStorage('payid', vorpal)
const localStorage = new cmd.LocalStorage('payString', vorpal)
new cmd.ClearCommand(vorpal, localStorage).setup()
new cmd.AddCryptoAddressCommand(vorpal, localStorage).setup()
new cmd.RemoveCryptoAddressCommand(vorpal, localStorage).setup()
Expand All @@ -18,18 +18,18 @@ new cmd.GenerateIdentityKeyCommand(vorpal, localStorage).setup()
new cmd.ListKeysCommand(vorpal, localStorage).setup()
new cmd.LoadIdentityKeyCommand(vorpal, localStorage).setup()
new cmd.PrintKeysCommand(vorpal, localStorage).setup()
new cmd.InitPayIdCommand(vorpal, localStorage).setup()
new cmd.InspectPayIdCommand(vorpal, localStorage).setup()
new cmd.LoadPayIdCommand(vorpal, localStorage).setup()
new cmd.ShowPayIdCommand(vorpal, localStorage).setup()
new cmd.SignPayIdCommand(vorpal, localStorage).setup()
new cmd.VerifyPayIdCommand(vorpal, localStorage).setup()
new cmd.SavePayIdCommand(vorpal, localStorage).setup()
new cmd.UrlToPayIdCommand(vorpal, localStorage).setup()
new cmd.PayIdToUrlCommand(vorpal, localStorage).setup()
new cmd.InitPayStringCommand(vorpal, localStorage).setup()
new cmd.InspectPayStringCommand(vorpal, localStorage).setup()
new cmd.LoadPayStringCommand(vorpal, localStorage).setup()
new cmd.ShowPayStringCommand(vorpal, localStorage).setup()
new cmd.SignPayStringCommand(vorpal, localStorage).setup()
new cmd.VerifyPayStringCommand(vorpal, localStorage).setup()
new cmd.SavePayStringCommand(vorpal, localStorage).setup()
new cmd.UrlToPayStringCommand(vorpal, localStorage).setup()
new cmd.PayStringToUrlCommand(vorpal, localStorage).setup()

// The CLI can be run in interactive mode or to run a single command and terminate.
// For CLI mode, process.argv will have 2 values (e.g. node dist/cli.js) even if using the alias 'payid-utils'.
// For CLI mode, process.argv will have 2 values (e.g. node dist/cli.js) even if using the alias 'paystring-utils'.
// For single command mode there will be additional arguments for the single command.
if (process.argv.length > 2) {
vorpal.parse(process.argv)
Expand Down
Loading

0 comments on commit 89ab213

Please sign in to comment.