NuID Node.js CLI


The NuID CLI is a command line interface for interacting with our Client Web SDK.

It's primary purpose is to ease integration with other non-JavaScript languages for integration testing. We encourage you to open an issue or pull request if you have any issues or suggestions.

Installation


Install the package from npm.

$ npm install --save-dev @nuid/cli
# or
$ yarn add -D @nuid/cli

Usage


After you've installed the package, you can invoke it from your local ./node_modules/bin directory, or simply add that directory to your $PATH environment.

Since argument finagling is problematic on the shell, we require that you JSON-encode the argument vector for any given command you are invoking.

$ ./node_modules/.bin/nuid-cli --help

# Or add the bin directory to your $PATH
$ export PATH=$PATH:./node_modules/.bin

# Print a list of top-level commands
$ nuid-cli --help

# Print a list of available sub-commands for zk
$ nuid-cli zk --help

# Returns a JSON-encoded verified credential
# Note the JSON-encoded argument vector
$ nuid-cli zk verifiableFromSecret '["my secret"]'

With this CLI available, you can now write full integration tests with NuID crypto material in languages other than JavaScript or Clojure. For example, in Ruby:

require 'nuid/sdk'

class MyApiTest < ::Minitest::Test
  def test_credential_create
    api = ::NuID::SDK::API::Auth.new(ENV['NUID_API_KEY'])
    verified = zk('verifiableFromSecret', 'super secret password')
    res = api.credential_create(verified)
    assert_equal(201, res.code)
    nuid = res.parsed_response['nu/id']
    credential = res.parsed_response['nuid/credential']
    # ...
  end

  private

  def zk(command, *args)
    JSON.parse(%x{./node_modules/.bin/nuid-cli zk #{command} '#{args.to_json}'})
  end
end

You can see working examples of the @nuid/cli in our Ruby SDK integration tests or Go SDK integration tests.

Docs


As this package is just a shell interface to the @nuid/zk package, you can view the function documentation for that package in our Client Web SDK.

$ nuid-cli -h
Usage: nuid-cli [options] [command]

Options:
  -V, --version   output the version number
  -h, --help      display help for command

Commands:
  zk              CLI interface to the @nuid/zk package
  help [command]  display help for command
$ nuid-cli zk -h
Usage: nuid-cli [options] [command]

Options:
  -h, --help                                       display help for command

Commands:
  verifiableFromSecret [jsonArgsArray]
  isVerified [jsonArgsArray]
  credentialFromVerifiable [jsonArgsArray]
  defaultChallengeFromCredential [jsonArgsArray]
  proofFromSecretAndChallenge [jsonArgsArray]
  verifiableFromProofAndChallenge [jsonArgsArray]
  help [command]                                   display help for command