From c225980bd9f3511862086b3c6f78f3e4f298770f Mon Sep 17 00:00:00 2001 From: pstlouis Date: Thu, 9 Jan 2025 14:55:42 -0500 Subject: [PATCH] log registration and demo update Signed-off-by: pstlouis --- demo/README.md | 221 ++++++++++++------------------ demo/register.sh | 79 +++++++++++ server/app/__init__.py | 3 +- server/app/models/did_document.py | 2 +- server/app/routers/identifiers.py | 54 ++++++-- server/app/routers/resolvers.py | 25 ---- server/pyproject.toml | 1 + 7 files changed, 206 insertions(+), 179 deletions(-) create mode 100755 demo/register.sh delete mode 100644 server/app/routers/resolvers.py diff --git a/demo/README.md b/demo/README.md index ccbb017..7096e0a 100644 --- a/demo/README.md +++ b/demo/README.md @@ -16,8 +16,8 @@ You will need a docker installation, curl, jq and a bash shell. Once this is all checked, you can clone the repo, move to the demo repository and start the services: ```bash -git clone https://github.com/OpSecId/trustdidweb-server-py.git -cd trustdidweb-server-py/demo/ && ./manage start +git clone https://github.com/identity-foundation/didwebvh-server-py.git +cd didwebvh-server-py/demo/ && ./manage start ``` @@ -32,7 +32,7 @@ curl -H Host:agent.docker.localhost \ ``` *You can visit the following pages in your browser* -- http://agent.docker.localhost +- http://agent.docker.localhost/api/doc - http://server.docker.localhost/docs ## Create a DID @@ -43,153 +43,78 @@ DID web requires a public endpoint to be globally resolveable. For this demo, we This demo also serves as an introduction to Data Integrity proof sets. +At any time, you can reset this demo with the `./manage restart` command. + ### Request a did namespace and identifier ```bash -namespace='demo' -identifier='issuer' -curl -H Host:server.docker.localhost \ - http://127.0.0.1?namespace=$namespace&identifier=$identifier | jq . -``` -```json -{ - "document": { - "@context": [ - "https://www.w3.org/ns/did/v1" - ], - "id": "did:web:server.docker.localhost:demo:issuer" - }, - "options": { - "type": "DataIntegrityProof", - "cryptosuite": "eddsa-jcs-2022", - "proofPurpose": "authentication", - "created": "2024-09-06T20:57:52+00:00", - "expires": "2024-09-06T21:07:52+00:00", - "domain": "server.docker.localhost", - "challenge": "de96aa5e-3c6d-55d7-9ef7-77dd98cabf96" - } -} +DID_REQUEST=$(curl -H Host:server.docker.localhost \ + 'http://127.0.0.1?namespace=demo&identifier=issuer' | jq .) + +DID_DOCUMENT=$(echo $DID_REQUEST | jq .didDocument) +PROOF_OPTIONS=$(echo $DID_REQUEST | jq .proofOptions) + ``` -From this point on, you have 10 minutes to complete the rest of this demo before the proof configuration is expired. You can restart at any moment with the `./manage restart` command. -## Create a new verification Method -Open the browser and register a new verification method with the agent. -- http://issuer.docker.localhost/api/doc#/wallet/post_keys +The proof options generated have a 10 minutes validity period, after which you will need to request a new set of options. -Here's a sample request you can copy into the OpenAPI interface. +## Create an update key for this did +```bash +# http://agent.docker.localhost/api/doc#/wallet/post_wallet_keys -```json -{ - "kid": "did:web:server.docker.localhost:demo:issuer#key-01" -} -``` +UPDATE_KEY=$(curl -X 'POST' -H Host:agent.docker.localhost \ + 'http://127.0.0.1/wallet/keys' \ + -d '{}' | jq -r .multikey) +CONTROLLER_VERIFICATION_METHOD="did:key:$UPDATE_KEY#$UPDATE_KEY" -## Create and sign the did document -Create your DID document, adding the verification method created at the previous step. Also add an `authentication` and `assertionMethod` relationship to this verification method. -```json -{ - "@context": [ - "https://www.w3.org/ns/did/v1" - ], - "id": "did:web:server.docker.localhost:demo:issuer", - "authentication": ["did:web:server.docker.localhost:demo:issuer#key-01"], - "assertionMethod": ["did:web:server.docker.localhost:demo:issuer#key-01"], - "verificationMethod": [ - { - "id": "did:web:server.docker.localhost:demo:issuer#key-01", - "type": "MultiKey", - "controller": "did:web:server.docker.localhost:demo:issuer", - "publicKeyMultibase": "z6MkgKA7yrw5kYSiDuQFcye4bMaJpcfHFry3Bx45pdWh3s8i" - } - ], -} ``` + +## Sign the did document +You can optionally add information to your did document containing the content you want to publish. Refer to the did core spec to get familiar with such features. For this demo, we will leave it as is. + Sign with the proof options obtained from step 1. -- http://issuer.docker.localhost/api/doc#/wallet/post_wallet_di_add_proof - -See below for a template to use as your request body. -- *You will need to use the options you obtained since there's an expiration of 10 minutes and a unique challenge was created.* -- *Also, you will need to add the verificationMethod you created.* -```json -{ - "document": { - "@context": [ - "https://www.w3.org/ns/did/v1" - ], - "id": "did:web:server.docker.localhost:demo:issuer", - "authentication": ["did:web:server.docker.localhost:demo:issuer#key-01"], - "assertionMethod": ["did:web:server.docker.localhost:demo:issuer#key-01"], - "verificationMethod": [ - { - "id": "did:web:server.docker.localhost:demo:issuer#key-01", - "type": "MultiKey", - "controller": "did:web:server.docker.localhost:demo:issuer", - "publicKeyMultibase": "z6MkgKA7yrw5kYSiDuQFcye4bMaJpcfHFry3Bx45pdWh3s8i" - } - ] - }, - "options": { - "type": "DataIntegrityProof", - "cryptosuite": "eddsa-jcs-2022", - "proofPurpose": "authentication", - "created": "⚠️", - "expires": "⚠️", - "domain": "server.docker.localhost", - "challenge": "⚠️", - "verificationMethod": "did:key:⚠️#⚠️" - } -} +```bash +# http://issuer.docker.localhost/api/doc#/wallet/post_wallet_di_add_proof + +# Add verificationMethod to the proof options +CONTROLLER_PROOF_OPTIONS=$(jq '. += {"verificationMethod": "'"$CONTROLLER_VERIFICATION_METHOD"'"}' <<< "$PROOF_OPTIONS") + +# Construct the payload for the request +PAYLOAD=$(cat <