Get Started
This page assumes you know what a ward and a guardian are. If you don't, read the guide first.
What you need
- Node.js 18 or later, and npm.
- The
@did-guardian/clicommand-line tool.
Install it:
npm install -g @did-guardian/cli
To build it from a clone of the repository instead, run npm install, npm run build --workspace=packages/lib and npm run build --workspace=packages/cli, then npm link it from packages/cli.
Quickstart
1. Register an identity
did-guardian register alice --registrar guardianspec.org
Created did:guardian:guardianspec.org:alice
Login secret (shown once -- save it now):
<secret>
This identity has no guardian yet -- register a guardian the same way, log in as them, and run "did-guardian guardian adopt did:guardian:guardianspec.org:alice" ...
The registrar now holds the key for alice. Save the login secret. The registrar shows it once. If you lose it, the guardians of alice can recover the identity, and the registrar then issues a new login secret. See Recover after a lost key.
2. Resolve it
Resolution needs no login. Anyone can run it:
did-guardian resolve did:guardian:guardianspec.org:alice
First resolution of did:guardian:guardianspec.org:alice -- pinned anchor <anchor>, version <version>.
{ "...": "a W3C DID Core document" }
No guardians or successor -- fully self-governing.
The CLI records the anchor and version of each log it fetches (REQ-11-3). A later fetch with a different anchor is reported as a different identity. A log that no longer contains the recorded version is reported as rolled back or forked (REQ-11-4). In either case the command prints no document and exits non-zero.
3. Add a guardian
Adding a guardian takes two steps. The guardian accepts the ward first. Then the ward approves the guardian.
Register the guardian, log in as it, and accept alice as its ward:
did-guardian register bob --registrar guardianspec.org
did-guardian login did:guardian:guardianspec.org:bob --login-secret <bob's secret>
did-guardian guardian adopt did:guardian:guardianspec.org:alice
did:guardian:guardianspec.org:bob has accepted did:guardian:guardianspec.org:alice as its own ward.
Waiting on did:guardian:guardianspec.org:alice's own approval to finish adding did:guardian:guardianspec.org:bob as its guardian -- whoever controls did:guardian:guardianspec.org:alice should now log in as it and run:
did-guardian guardian confirm-adopt did:guardian:guardianspec.org:alice <pending id>
Log in as alice and run the command it printed. The CLI keeps one session at a time, so this login replaces the session for bob:
did-guardian login did:guardian:guardianspec.org:alice --login-secret <alice's secret>
did-guardian guardian confirm-adopt did:guardian:guardianspec.org:alice <pending id>
The command shows which guardian it adds and the full operation, then asks Add did:guardian:guardianspec.org:bob as your guardian? [y/N]. Answer y, or pass -y to skip the question.
Done -- did:guardian:guardianspec.org:alice now has did:guardian:guardianspec.org:bob as a guardian.
Run did-guardian resolve did:guardian:guardianspec.org:alice again. The report now lists bob as a guardian.
register and resolve take --json for machine-readable output. The registrar API doc lists the HTTP request behind each command.
Hold the key yourself
After the quickstart, the registrar holds the key for alice. To hold it yourself, log in as alice and take custody:
did-guardian login did:guardian:guardianspec.org:alice --login-secret <alice's secret>
did-guardian key take-custody did:guardian:guardianspec.org:alice
The command refuses to run unless you are logged in as the identity it names. It asks for confirmation. Pass -y to skip the question. It generates a new key and saves it under <ward-did>-self-held-<timestamp>. Pass --new-key <label> to use a key you already saved.
did:guardian:guardianspec.org:alice now holds its key (saved as "<label>"). This registrar can no longer sign on its behalf.
This step cannot be undone. The registrar deletes the key it held. Every session and the login secret for alice stop working. From now on, sign operations for alice with your key and submit them with did-guardian operation propose. A proposal finalizes at once if your signature is enough.
If alice is a guardian of another ward, take care before you run this. That ward's entry for alice still lists the old key, so the entry loses standing (REQ-10-6). You cannot fix the entry in advance: an updateGuardian naming the new key is rejected until the new key is in the log of alice (REQ-10-7). Afterward, the ward re-seats the entry with one of its current keys and one other guardian (REQ-7-6). A ward whose only guardian is alice cannot do this.
Create a self-held identity
To start with a key you hold, skip register and use create:
did-guardian create alice --registrar guardianspec.org
The CLI generates a key, saves it, signs the create operation, and submits it. The registrar never receives the private key.
create alice --domain guardianspec.org builds the same operation offline and prints it as a draft. No registrar accepts the draft, because it has no registrar attestation (REQ-7-7). Re-run with --registrar to publish it.
Next steps
The CLI README lists every command. It covers verify to check a saved log offline against Section 8, and operation propose and operation sign for operations that need more than one signer.
The how-to guides in the sidebar each walk through one task from start to finish.