Skip to content
CredentialEnginePublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Credential Engine CLI (ce)

A command-line tool for managing Credential Engine platform resources.

Requirements

  • Python 3.11 or later
  • pip

Installation

Recommended: install inside a virtual environment. This avoids file-permission errors, PATH conflicts, and "invalid distribution" warnings from previous installs.

Option 1: Install from source with a virtual environment (recommended)

macOS / Linux:

git clone https://github.com/CredentialEngine/ce-cli.git
cd ce-cli

python3 -m venv .venv
source .venv/bin/activate

pip install -e .

Windows (PowerShell):

git clone https://github.com/CredentialEngine/ce-cli.git
cd ce-cli

python -m venv .venv
.venv\Scripts\activate

pip install -e .

When the venv is active you'll see (.venv) in your prompt, and ce is automatically on PATH. To leave the venv, run deactivate. To re-enter it next time, run the activate command above from the project folder.

Option 2: Install from a release

  1. Download the .whl from the Releases page.
  2. Install it (inside a venv is still recommended):
    pip install ce_cli-<version>-py3-none-any.whl

Upgrading

From a release .whl:

pip install --upgrade ce_cli-<version>-py3-none-any.whl

From source: git pull and re-run pip install -e . inside your venv.

Option 3: Install from source without a venv

git clone https://github.com/CredentialEngine/ce-cli.git
cd ce-cli
pip install -e .

This puts the ce command on your $PATH. On Windows, see the Windows PATH note below if ce isn't found.

Verify the installation

ce --help

You should see the top-level command list.

Windows PATH note

When you install on Windows without a venv, pip often drops ce.exe into your user Scripts folder, which Windows doesn't put on PATH by default:

C:\Users\<you>\AppData\Roaming\Python\Python310\Scripts

If ce --help fails after install, either use a venv (recommended) or add that folder to your User PATH:

[Environment]::SetEnvironmentVariable(
  "Path",
  $env:Path + ";C:\Users\$env:USERNAME\AppData\Roaming\Python\Python310\Scripts",
  "User"
)

Then close and reopen PowerShell existing windows won't pick up the new PATH.

Quick start

# Pick an environment, then sign in
ce env list
ce env use dev
ce login
ce whoami

Command reference

Account (ce)

Command Description
ce login Sign in via Keycloak device authorization
ce logout Sign out and revoke tokens
ce whoami Show who you're signed in as

Each environment has its own session (tokens-<environment>.json in the config folder), so signing in to one environment never signs you in to another; ce login --env <name> signs in to an environment other than the active one. The access token is renewed silently. When the sign-in service ends the session you are told "Your session has expired" and sign in again; when it cannot be reached your session is kept and the command says so. ce logout ends the session at the sign-in service as well as on this machine.

Environments (ce env)

Environments let you switch between dev, test, sandbox, and prod. Built-in API and OIDC settings are defined in ce/config/context.py (DEFAULT_ENVIRONMENTS). Only the selected environment is persisted.

Command Description
ce env list List the four valid environment names
ce env use <name> Switch to a different environment
ce env show Show the active environment name
ce env show --verbose Show detailed environment configuration
ce env list
ce env use dev

IIR — Issuer Identity Registry (ce iir)

IIR commands are grouped by the noun they operate on:

  • ce iir challenge ... — sign challenges (single or bulk)
  • ce iir issuer-did ... — publish signed issuers to the registry
Command Login required Description
ce iir challenge sign No Sign a single CE challenge JSON file and produce a Proof JWT
ce iir challenge bulk-sign Yes Bulk-validate and sign challenges from a CSV
ce iir issuer-did publish Yes Publish signed issuers to the IIR registry

Sign a single challenge (ce iir challenge sign)

Signs a CE-generated challenge JSON file and verifies the resulting JWT against the public key resolved from the DID in the payload. --algorithm picks the key type. No login required: offline for did:key, a single HTTPS fetch for did:web.

--algorithm JWT alg Key in the DID DIDs
Ed25519 EdDSA Multikey (publicKeyMultibase, z...) did:key, did:web
RS256 RS256 JsonWebKey2020 (publicKeyJwk, kty: RSA) did:web only for now
ce iir challenge sign --algorithm Ed25519 --private-key z3u2en... --challenge-file challenge.json --output signed-challenge.jwt

ce iir challenge sign --algorithm RS256 --private-key rsa-private-key.pem --challenge-file challenge.json --output signed-challenge.jwt
Flag Required Description
--algorithm Yes Ed25519 or RS256 (exact spelling)
--private-key Yes Ed25519: private seed, multibase base58btc (starts with z). RS256: path to an unencrypted PEM key file (BEGIN PRIVATE KEY or BEGIN RSA PRIVATE KEY), the PEM text, or the bare base64 key
--challenge-file Yes Path to the challenge JSON produced by CE
--output, -o No Write the JWT to this file. If omitted, the JWT is printed to stdout

RSA keys must be at least 2048 bits. For RS256 the DID document must list the key under authentication. RSA did:key is not supported yet: use a did:web with a JsonWebKey2020 key. Giving an RSA key with --algorithm Ed25519, or an Ed25519 seed with --algorithm RS256, fails with a hint to use the other algorithm.

The challenge JSON must include did, challenge, aud, iat, and exp. The did field is used as the JWT header kid and to resolve the public key for verification (did:key resolves offline; did:web is fetched over HTTPS using the OS trust store).

Example challenge file:

{
  "did": "did:key:z6Mkh...#z6Mkh...",
  "challenge": "abc123-nonce",
  "aud": "https://credentialengine.org/iir",
  "iat": 1779317055,
  "exp": 1779317655
}

On success, the JWT is written (or printed) and a verification confirmation is shown on stderr:

Signature verification: OK (matches DID public key)
Wrote Proof JWT to: signed-challenge.jwt

Bulk DID upload

Register DIDs for multiple organizations in one go. The process has two phases.

Phase 1 — Sign challenges (ce iir challenge bulk-sign):

ce iir challenge bulk-sign --csv input.csv --output output.csv

Validates each row (algorithm, membership, registry lookup, DID resolution), creates challenges, signs JWTs with the provided private keys using each row's Algorithm, verifies them against the DID, and writes the results to an output CSV. If --output is omitted, defaults to Output-<stem>-<UTC>.csv. Failed rows are written to Errors-<stem>-<UTC>.csv (override with --errors).

Phase 2 — Publish to the IIR registry (ce iir issuer-did publish):

ce iir issuer-did publish --input output.csv

Verifies the JWT signatures and publishes each issuer to the IIR. Ed25519 and RS256 rows are handled the same way: the API reads the algorithm from the JWT. Pass --yes/-y to skip the confirmation prompt. Failed publishes are written to PublishErrors-<stem>-<UTC>.csv (override with --publish-errors).

Input CSV format

Column Required Description
CTID Yes The organization's CTID (must be published in the registry)
DID Yes did:key:... or did:web:...
VerificationMethod Yes Full verification method ID (e.g., did:key:z6Mk...#z6Mk...)
Algorithm Yes Ed25519 or RS256, on every row (did:web included)
PrivateKey Yes Ed25519: multibase seed (z...). RS256: PEM key file path, PEM text with literal \n line breaks, or bare base64
ValidFrom No Date when the issuer becomes valid (MM/DD/YYYY)
ValidUntil No Date when the issuer expires (MM/DD/YYYY)

Example:

CTID,DID,VerificationMethod,Algorithm,PrivateKey,ValidFrom,ValidUntil
ce-12345678-...,did:key:z6MkhaX...,did:key:z6MkhaX...#z6MkhaX...,Ed25519,z3u2en...,01/01/2024,12/31/2025
ce-87654321-...,did:web:example.com,did:web:example.com#key-1,Ed25519,z3u2en...,,
ce-87654321-...,did:web:example.com,did:web:example.com#key-2,RS256,keys\rsa-private-key.pem,,

ValidFrom and ValidUntil are optional.

Publisher — API publishing (ce publisher)

Publish to the Credential Registry through a project: create it, add files, validate them, fix what validation finds, then complete it. The Publisher has three kinds of project; ce-cli works with two:

  • Bulk upload (BU), the default and the standard project: BU template CSVs. The columns are the ones of the Publisher's BU templates, for example the Credentials template. One class of file per add. A CSV you upload with ce-cli is a BU project, the same project the Publisher UI makes.
  • API publishing, created with --jsonld: JSON-LD only, in the shape the CSV transform produces, an array of graphs, each with @context, @id and @graph. CSVs are refused.
  • Ruby Registry sync is made by the Ruby Registry when it uploads a changeset. ce publisher project list shows it; ce-cli adds no files to it, validates it or completes it.
Command Description
ce publisher project create --name <name> [--jsonld] Create a project. A BU project is the default; --jsonld makes an API publishing project
ce publisher project add --project-id <id> --file <file or folder> [--type <template>] Add files, or replace the files of the same name. A BU project needs --type, the BU template the files follow: credentials, learning-opportunities, assessments, jobs, … Repeat --file for several; --recursive for subfolders
ce publisher project validation run --project-id <id> Validate the latest iteration, including the CTIDs it refers to. A BU project starts validating when files are added, so this waits for it (--no-wait to return at once)
ce publisher project validation status show --project-id <id> How many files passed and how many have errors (--verbose lists each one)
ce publisher project validation errors show --project-id <id> The errors to fix
ce publisher project status show --project-id <id> The project, its latest iteration and each publishing stage
ce publisher project audit show --project-id <id> Who did what, oldest first
ce publisher project complete --project-id <id> Approve the project and publish it (--no-wait to return at once). Run again to retry a failed publish
ce publisher project list Your projects
ce publisher project abandon --project-id <id> Abandon a project that was not published

Every show command takes -o json.

ce publisher project create --name "Welding certificates"
ce publisher project add --project-id 23 --file credentials.csv --type credentials
ce publisher project validation run --project-id 23
ce publisher project validation errors show --project-id 23
ce publisher project add --project-id 23 --file fixed\credentials.csv --type credentials
ce publisher project validation run --project-id 23
ce publisher project complete --project-id 23
ce publisher project audit show --project-id 23

How it behaves:

  • Adding a CSV to a BU project starts validation at once. Adding a JSON-LD file to an API publishing project only stores it; run validation when you have added everything.
  • Validation checks the files and also looks up every CTID they refer to, with the same rules as the bulk upload.
  • A change after validation starts a new iteration, which begins as a copy of the last one. A file with the same name replaces the earlier one.
  • Completing needs a latest iteration that validated without errors. For a BU project it first transforms the CSV files to JSON-LD and makes you a reviewer, so you can approve; then it approves and publishes. Each step is recorded in the audit log.
  • Only you can change an API publishing project you created.
  • Exit status is 1 when a file was refused, validation found errors, or the project did not publish.

The Publisher API address comes from the environment (publisher_api_base); override it with --publisher-url or CE_PUBLISHER_API_URL. Your account needs the Publisher user role and a tenant on its profile.

The commands call the Publisher through a client generated from its Swagger document (src/sdks/publisher-api/generated-client/publisher_client, laid out as in ceops). src/sdks/publisher-api/README.md says how to regenerate it. The legacy Registry Assistant request format is a Publisher feature flag that is off by default; ce-cli does not offer it, and a client generated while it is off has no call for it.

Project structure

ce-cli/
├── pyproject.toml
└── ce/
    ├── main.py                    # Root CLI group
    ├── auth/
    │   ├── device_flow.py         # RFC 8628 Keycloak client
    │   └── token_manager.py       # Silent token refresh + require_login()
    ├── commands/
    │   ├── auth.py                # ce login / logout / whoami
    │   ├── env.py                 # ce env list / use / show
    │   ├── config.py              # ce config set / get / list / reset
    │   ├── iir.py                 # ce iir challenge bulk-sign, ce iir issuer-did publish
    │   └── resource.py            # ce resource list / show / create / delete
    ├── config/
    │   ├── settings.py            # OIDCSettings, token I/O, paths
    │   └── context.py             # Environment model, active-env helpers
    ├── iir/
    │   ├── challenge/
    │   │   └── sign.py            # ce iir challenge sign (--algorithm Ed25519 | RS256)
    │   ├── csv_processor.py       # Bulk DID upload (bulk-sign + publish)
    │   └── did_ops.py             # DID validation, challenges, IIR API calls
    ├── implementations/
    │   ├── iir_challenge_sign_ed25519.py  # Ed25519 (EdDSA) signing and verification
    │   ├── iir_challenge_sign_rs256.py    # RS256 signing and verification
    │   └── publisher/             # Behind ce publisher: client.py, service.py, cli.py (shared options and errors)
    ├── publisher/                 # ce publisher: a noun is a folder, a verb is a file that exposes `main`
    │   └── project/
    │       ├── create.py, add.py, list.py, complete.py, abandon.py
    │       ├── status/show.py, audit/show.py
    │       └── validation/run.py, status/show.py, errors/show.py
    └── utils/
        ├── http.py                # Authenticated httpx2 wrapper + APIError
        ├── display.py             # Plain consoles and tables (no boxes or colours)
        ├── output.py              # table/json/yaml/tsv renderer + @output_option
        └── errors.py              # @handle_api_errors decorator

Output is plain text: no boxes, no colours, no highlighting. Spinners are the only decoration. Use ce.utils.display (new_console, plain_table, print_pairs) for anything new; tests/test_plain_output.py fails if styling comes back.

Tests

pytest -m unit          # unit tests
pytest -m integration   # recorded tests: replay only, no server needed
pytest -m recorded      # only the Publisher record and replay scenarios

Tests that talk to the Publisher (tests/test_publisher_replay.py) are recorded once against a real server and replayed in CI. Each test is a scenario typed as the commands a user would type; its HTTP exchange is the JSON cassette tests/cassettes/publisher/<test name>.json.

To record a scenario, start a Publisher, sign in to it with ce login, then:

$env:CE_CLI_RECORD_CASSETTES = "true"
pytest tests/test_publisher_replay.py -k <test name>
Remove-Item Env:CE_CLI_RECORD_CASSETTES
pytest tests/test_publisher_replay.py     # replay: no server, no sign-in

Read the new cassette before you commit it. It holds project names and file contents. The recorder replaces e-mail addresses and the signed-in user's id, trims the project list to the projects the scenario created, and refuses to save a cassette that holds a token. A scenario that fails while recording writes no cassette and leaves an existing one alone. Replay fails if a command sends a request that differs from the recording, or fewer requests than were recorded. A scenario with no cassette is skipped on your machine, so a new test can be merged before it is recorded, and fails in CI (the CI variable is set), so a deleted or renamed cassette is never silent.

Registry downloads

The ce registry commands use the Consumer API. Its base URL (consumer_api_base) is defined in ce/config/environment.py and selected by ce env use. There are no URL overrides.

Environment Consumer API base URL
dev https://localhost:7079
test https://api.consumer.test.credentialengine.org
sandbox https://api.consumer.sandbox.credentialengine.org
prod https://api.consumer.credentialengine.org

The credentialengineregistry.org domain is used for resource and graph references, not as the Consumer API base URL.

ce env use dev
ce login
ce registry downloads show --version 2026-11-25
ce registry downloads get --version latest --class-name full --target-location ./exports
ce registry downloads get --class-name ceterms:Credential --class-name ceterms:Organization
ce registry downloads get --url "DOWNLOAD_URL"
ce registry downloads search show JOB_ID
ce registry downloads search get --url "DOWNLOAD_URL" --target-location ./exports

Registry show and get accept --version latest (the default) or --version YYYY-MM-DD.

Registry commands use the active environment's API URL, login and TLS settings. Both get commands accept --target-location (defaults to the current directory). Existing files are not replaced. Class subdirectories are used only if archive filenames collide. Registry show displays class labels, schema class names, counts and archive links. Download links are short-lived and one-time use; treat them as sensitive. Showing does not redeem the links. get --class (display label) or get --class-name (schema identifier) requests fresh links; get --url redeems the supplied one-time links directly. Repeat the chosen option for multiple files or classes; do not combine selectors. No selection means no download. For direct URLs, the version does not validate the archive provenance; the URL itself identifies the archive.

An interrupted download can be retried by obtaining fresh URLs. Existing files are not replaced. Downloads show bytes transferred, speed and elapsed time. Search job creation is available via ce registry search export. Search export show JOB_ID displays status and one-time links when completed; get --url redeems those links without a job ID.

Logging

Every CLI invocation displays ce, version <installed-version> on stderr, leaving stdout available for command results and JSON pipelines. ce --version prints the version once on stdout.

ce logging set log-level DEBUG
ce logging show
ce registry downloads show
ce logging set log-level WARNING

Levels are case-insensitive: DEBUG, INFO, WARNING (default), ERROR, CRITICAL. The selected level is saved for subsequent commands. Logs use UTC ISO-8601 timestamps with milliseconds and module, file, line and function information. LOG_FORMAT and LOG_DESTINATIONS work as in ceops (default: console). Optional CloudWatch and Azure destinations require pip install -e ".[cloudwatch]" or pip install -e ".[azure-logging]", respectively, and the same ceops environment variables (CLOUDWATCH_LOG_GROUP, CLOUDWATCH_LOG_STREAM_NAME, AWS_REGION, CLOUDWATCH_ENDPOINT_URL, APPLICATIONINSIGHTS_CONNECTION_STRING, AZURE_SDK_LOG_LEVEL). Transport debug logging stays restricted to avoid exposing tokens or signed archive URLs.

Registry search

ce registry search --query nursing --type ceterms:Credential --view Summary
ce registry search export --query nursing --type ceterms:Credential
ce registry downloads search show JOB_ID
ce registry downloads search get --url "DOWNLOAD_URL"
ce registry downloads get --class "All Registry Data"
ce registry downloads get --class-name ceterms:Credential

Search and export accept the same options: --query, --type, --language, --include-bnodes / --no-include-bnodes, --index-type, --index-id, --page, --view, and repeatable --filters (JSON object or array). Search prints CTID, Title and Description for one page by default. Use -o json or --output json to display JSON search results limited to @id, ceterms:ctid, ceterms:name, ceterms:description, and @type, with only the numeric total and results at the response level. Use -o tsv for tab-separated output with the same five column headers. Structured cell values are JSON encoded. Use qualified schema terms for --type, filter fields and @type filter values, not display labels. The CLI validates term syntax; the API resolves schema terms. The summary API normalizes names and descriptions across vocabularies; the CLI exposes those summary values under the common ceterms column names. Class identifiers are preserved exactly as returned by the API. Export submits a job, prints the returned job ID and status, and does not wait or download. The export worker controls pagination and JSON-LD output. Download selection requires exactly one of --url, --class or --class-name.

Registry point lookups

ce registry resources get ce-00000000-0000-0000-0000-000000000001
ce registry resources get 00000000-0000-0000-0000-000000000001
ce registry resources get _:00000000-0000-0000-0000-000000000001
ce registry graphs get ce-00000000-0000-0000-0000-000000000001 --depth 1
ce registry metadata get ce-00000000-0000-0000-0000-000000000001

Replace the example identifiers with real Registry identifiers. Resource lookups accept CTIDs or blank-node GUIDs (the _: prefix is stripped). The installed SDK only provides CTID lookups for graphs and metadata. Point lookup results are JSON. CLI-owned HTTP clients send User-Agent: ce-cli/<installed-version>.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages