/trustdidweb-py

Primary LanguagePythonApache License 2.0Apache-2.0

Trust DID Web - Python

This repository includes Python libraries for working with did:tdw (Trust DID Web) DID documents and the underlying log format. Methods are provided for provisioning and updating DID documents as well as a resolving existing did:tdw DIDs.

Prerequisites

This library requires Python 3.10 or later. Dependencies are listed in requirements.txt and can be installed via:

pip3 install -r requirements.txt

Usage

A new did:tdw DID can be minted using the provision command. This will create a new Askar keystore for handling the signing key.

python3 -m did_tdw.provision --auto "domain.example:{SCID}"

This will output a new directory named after the new DID, containing did.jsonl (the DID log) and did.json (the current state of the document).

To automatically update the DID, edit did.json and execute the update command (use the identifier output from the provision command):

python3 -m did_tdw.update --auto "did:tdw:domain.example:7ksi6mjn5ttpo7gw2ihz43dapmnl"

DID Resolution

The resolver script may be invoked via the command line, and supports dereferencing of fragments and paths:

python3 -m did_tdw.resolver "did:tdw:domain.example:26nkkrdjqpcfc5zgw6lgsgsgscrg"
python3 -m did_tdw.resolver "did:tdw:domain.example:26nkkrdjqpcfc5zgw6lgsgsgscrg#key-1"
python3 -m did_tdw.resolver "did:tdw:domain.example:26nkkrdjqpcfc5zgw6lgsgsgscrg/myresource.json"

For testing, this script also accepts the path to the local DID history file:

python3 -m did_tdw.resolver -f did.jsonl "did:tdw:domain.example:26nkkrdjqpcfc5zgw6lgsgsgscrg"

Demo

For testing purposes, a new DID can be minted along with a series of test updates applied using the included demo script:

python3 demo.py domain.example

Contributing

Pull requests are welcome! Please read our contributions guide and submit your PRs. We enforce developer certificate of origin (DCO) commit signing — guidance on this is available. We also welcome issues submitted about problems you encounter in using Trust DID Web - Python.

License

Apache License Version 2.0