This repository provides a simple yet powerful tool to generate and manage DID documents using the did:web
method. It creates a new elliptic curve key pair and a corresponding DID document that you can host on GitHub Pages. It is based on this project
Once published, your DID will have the form:
did:web:USERNAME.github.io
(for user site repos)did:web:USERNAME.github.io:PROJECT
(for other repositories)did:web:USERNAME.github.io:PROJECT:FOLDER
(for subfolders within project)git clone https://github.com/YOUR_USERNAME/YOUR_REPO
cd YOUR_REPO
Ensure Poetry is installed:
curl -sSL https://install.python-poetry.org | python3 -
Then install dependencies:
poetry install
Activate the virtual environment:
poetry shell
python generate.py
python generate.py my-did-folder
python generate.py did:web:example.com:device-1
git push
Change the setting of the repository to βUse GitHub Pages websiteβ
.nojekyll
FileGitHub Pages uses Jekyll by default, which ignores files and folders that start with a dot (.
) β including .well-known
, which is essential for some did:web
resolutions.
To ensure your DID documents are publicly accessible (especially if youβre using nested or dot-prefixed folders), you must disable Jekyll by adding a .nojekyll
file to the root of your repository.
βββ did.json # DID Document (public)
βββ private_key.pem # EC private key (keep secret!)
βββ generate.py # Generator script
βββ my-did-folder/
β βββ did.json
β βββ private_key.pem
βββ generate.py
private_key.pem
..gitignore
includes *.pem
.After pushing to GitHub:
Verify your DID at:
π§ͺ Direct fetch:
curl https://USERNAME.github.io/device-1/did.json
JsonWebKey2020
did.json
file to the repoβ DID not resolving?
did.json
β βCould not infer DID from gitβ
git remote -v
and confirm GitHub originβ Wrong DID returned?
id
in did.json
exactly matches the requested DID (path, case-sensitive)This generator adheres to:
Contributions are welcome! To propose improvements: