From faf40e9ed9704ba16adb2508cd83e38a9f48fe35 Mon Sep 17 00:00:00 2001 From: 2byrds <2byrds@gmail.com> Date: Fri, 15 Dec 2023 08:22:44 -0500 Subject: [PATCH 01/17] porting and extending Markus IIW tutorial from https://github.com/peacekeeper/did-webs-iiw-tutorial Signed-off-by: 2byrds <2byrds@gmail.com> --- GETTING_STARTED.md | 506 ++++++++++++++++++ README.md | 12 + docker-compose.yml | 31 +- src/dkr/app/cli/commands/did/webs/generate.py | 4 +- volume/dkr/did_json/.gitignore | 3 + volume/dkr/did_json/README.md | 3 + volume/dkr/examples/README.md | 41 ++ volume/dkr/examples/credential.json | 1 + .../examples/desig-aliases-attr-public.json | 1 + volume/dkr/examples/desig-aliases-public.json | 1 + .../examples/desig-aliases-rules-public.json | 1 + .../did.json | 1 + volume/dkr/examples/gen.sh | 1 + volume/dkr/examples/get_started.sh | 14 + .../keri.cesr | 0 volume/dkr/examples/local.sh | 21 + .../dkr/examples/my-scripts/incept-local.json | 13 + .../examples/my-scripts/keri/cf/config.json | 11 + .../examples/my-scripts/keri/cf/local.json | 11 + .../my-scripts/keri/cf/my-config.json | 0 volume/dkr/examples/my-scripts/my-incept.json | 9 + volume/dkr/examples/public.sh | 48 ++ .../examples/scripts/keri/cf/main/wan.json | 0 .../examples/scripts/keri/cf/main/wes.json | 0 .../examples/scripts/keri/cf/main/wil.json | 0 .../examples/scripts/keri/cf/main/wit.json | 0 .../examples/scripts/keri/cf/main/wub.json | 0 .../examples/scripts/keri/cf/main/wyz.json | 0 volume/dkr/keri_cesr/.gitignore | 3 + volume/dkr/keri_cesr/README.md | 3 + volume/dkr/my-scripts/keri/cf/my-agent.json | 2 + .../keri/cf/my-config-multi-fractions.json | 8 + .../my-scripts/keri/cf/my-config-multi.json | 8 + volume/dkr/my-scripts/keri/cf/my-config.json | 8 + .../my-scripts/my-incept-multi-fractions.json | 13 + volume/dkr/my-scripts/my-incept-multi.json | 13 + volume/dkr/my-scripts/my-incept.json | 13 + volume/dkr/my-scripts/my-rotate.json | 9 + .../keripy/scripts/keri/cf/main/wan.json | 9 + .../keripy/scripts/keri/cf/main/wes.json | 9 + .../keripy/scripts/keri/cf/main/wil.json | 9 + .../keripy/scripts/keri/cf/main/wit.json | 9 + .../keripy/scripts/keri/cf/main/wub.json | 9 + .../keripy/scripts/keri/cf/main/wyz.json | 9 + 44 files changed, 854 insertions(+), 13 deletions(-) create mode 100644 GETTING_STARTED.md create mode 100644 volume/dkr/did_json/.gitignore create mode 100644 volume/dkr/did_json/README.md create mode 100644 volume/dkr/examples/README.md create mode 100644 volume/dkr/examples/credential.json create mode 100644 volume/dkr/examples/desig-aliases-attr-public.json create mode 100644 volume/dkr/examples/desig-aliases-public.json create mode 100644 volume/dkr/examples/desig-aliases-rules-public.json create mode 100644 volume/dkr/examples/did_json/ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe/did.json create mode 100755 volume/dkr/examples/gen.sh create mode 100644 volume/dkr/examples/get_started.sh create mode 100644 volume/dkr/examples/keri_cesr/ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe/keri.cesr create mode 100755 volume/dkr/examples/local.sh create mode 100644 volume/dkr/examples/my-scripts/incept-local.json create mode 100755 volume/dkr/examples/my-scripts/keri/cf/config.json create mode 100755 volume/dkr/examples/my-scripts/keri/cf/local.json create mode 100755 volume/dkr/examples/my-scripts/keri/cf/my-config.json create mode 100644 volume/dkr/examples/my-scripts/my-incept.json create mode 100755 volume/dkr/examples/public.sh create mode 100755 volume/dkr/examples/scripts/keri/cf/main/wan.json create mode 100755 volume/dkr/examples/scripts/keri/cf/main/wes.json create mode 100755 volume/dkr/examples/scripts/keri/cf/main/wil.json create mode 100755 volume/dkr/examples/scripts/keri/cf/main/wit.json create mode 100755 volume/dkr/examples/scripts/keri/cf/main/wub.json create mode 100755 volume/dkr/examples/scripts/keri/cf/main/wyz.json create mode 100644 volume/dkr/keri_cesr/.gitignore create mode 100644 volume/dkr/keri_cesr/README.md create mode 100755 volume/dkr/my-scripts/keri/cf/my-agent.json create mode 100755 volume/dkr/my-scripts/keri/cf/my-config-multi-fractions.json create mode 100755 volume/dkr/my-scripts/keri/cf/my-config-multi.json create mode 100755 volume/dkr/my-scripts/keri/cf/my-config.json create mode 100644 volume/dkr/my-scripts/my-incept-multi-fractions.json create mode 100644 volume/dkr/my-scripts/my-incept-multi.json create mode 100644 volume/dkr/my-scripts/my-incept.json create mode 100644 volume/dkr/my-scripts/my-rotate.json create mode 100755 volume/witnesshost/keripy/scripts/keri/cf/main/wan.json create mode 100755 volume/witnesshost/keripy/scripts/keri/cf/main/wes.json create mode 100755 volume/witnesshost/keripy/scripts/keri/cf/main/wil.json create mode 100755 volume/witnesshost/keripy/scripts/keri/cf/main/wit.json create mode 100755 volume/witnesshost/keripy/scripts/keri/cf/main/wub.json create mode 100755 volume/witnesshost/keripy/scripts/keri/cf/main/wyz.json diff --git a/GETTING_STARTED.md b/GETTING_STARTED.md new file mode 100644 index 0000000..ac34371 --- /dev/null +++ b/GETTING_STARTED.md @@ -0,0 +1,506 @@ +# Developers - Getting Started + +Welcome to the `did:webs` reference implementation Getting Started guide. + +Thank you to Markus Sabadello @peacekeeper from DanubeTech who created the original guide for IIW37 [here](https://github.com/peacekeeper/did-webs-iiw-tutorial) + +If you're running into trouble in the process below, be sure to check the section [Trouble Shooting](#trouble-shooting) below. + +## Run Docker build +``` +docker compose build +``` + +## Run Docker containers for the keri witness network and `did:webs` generator and resolver + +``` +docker compose down +docker compose up -d +``` + +## Enter the docker environment command line to begin running keri, etc. commands + +``` +docker compose exec dkr /bin/bash +``` + +## (Optional) You can use the KERI cli (kli) to create a unique salt (seed) for your KERI AID private keys + +``` +kli salt +``` + +Example response: + +``` +0AAQmsjh-C7kAJZQEzdrzwB7 +``` + +Note: In our examples we will use this salt `0AAQmsjh-C7kAJZQEzdrzwB7` replace it when necessary + +## Provide your unique salt and configure your KERI AID + +You control this AID so lets call it `controller`. +The config-file in the container is at /keripy/my-scripts/my-config and contains the oobis of the witnesses that we'll use: +In this case they are available from the witness network that we started in the docker-compose. If you `cat` the config at `/keripy/my-scripts/keri/cf/my-config.json` you should see: + +`config` +```json +bash-5.1# cat /keripy/my-scripts/keri/cf/my-config.json +{ + "dt": "2022-01-20T12:57:59.823350+00:00", + "iurls": [ + "http://witnesshost:5642/oobi/BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha/controller", + "http://witnesshost:5644/oobi/BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX/controller", + "http://witnesshost:5643/oobi/BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM/controller" + ] +} +``` +Run the init command to prep your environment with the config: +``` +kli init --name controller --salt 0AAQmsjh-C7kAJZQEzdrzwB7 --nopasscode --config-dir "/keripy/my-scripts" --config-file my-config +``` + +`output` +``` +bash-5.1# kli init --name controller --salt 0AAQmsjh-C7kAJZQEzdrzwB7 --nopasscode --config-dir "/keripy/my-scripts" --config-file my-config +KERI Keystore created at: /usr/local/var/keri/ks/controller +KERI Database created at: /usr/local/var/keri/db/controller +KERI Credential Store created at: /usr/local/var/keri/reg/controller + +Loading 3 OOBIs... +http://witnesshost:5642/oobi/BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha/controller succeeded +http://witnesshost:5643/oobi/BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM/controller succeeded +http://witnesshost:5644/oobi/BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX/controller succeeded +``` + +## Create your KERI AID +Now that your environment is ready, create your AID (via an inception event) with inception configuration that contains your witnesses. It is a transferable AID (meaning you can rotate the keys, witnesses, etc): + +`config` +```json +bash-5.1# cat /keripy/my-scripts/my-incept.json +{ + "transferable": true, + "wits": [ + "BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha", + "BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM", + "BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX" + ]... +} +``` + +Run the incept command to create your AID: +``` +kli incept --name controller --alias controller --file "/keripy/my-scripts/my-incept.json" +``` + +`output` +``` +bash-5.1# kli incept --name controller --alias controller --file "/keripy/my-scripts/my-incept.json" +Waiting for witness receipts... +Prefix EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP + Public key 1: DHr0-I-mMN7h6cLMOTRJkkfPuMd0vgQPrOk4Y3edaHjr +``` + +Congrats! You have an AID `EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP` with one public key as the current key `DHr0-I-mMN7h6cLMOTRJkkfPuMd0vgQPrOk4Y3edaHjr` + +## (Optional) Perform more KERI operations + +Optionally use `kli` to perform additional KERI operations such as key rotation, threshold signatures, etc., see KERI docs for details. + +See [a key rotation example](#example-key-rotation) below. + + +## Decide your web address for did:webs + +Find a web address (domain, optional port, optional path) that you control. + +Example web address: + +``` +https://labs.hyperledger.org/did-webs-resolver/pages/ +``` + +## Generate did:webs files for AID + +Note: Replace with your actual web address and AID, convert to did:web(s) conformant identifier + +Be sure to execute the command in the root of your local `did-webs` repo (and in the Docker container) +``` +dkr did webs generate --name controller --did did:webs:labs.hyperledger.org:did-webs-resolver:pages:EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP --oobi http://witnesshost:5642/oobi/EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP/witness/BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha +``` + +This creates files: +- `did.json` under local path `./volume/dkr/did_json/` +- `keri.cesr` under local path `./volume/dkr/keri_cesr/` + +You can access these files either from within your Docker container or on your local computer filesystem. +- `/volume/dkr/` +- `/usr/local/var/did-keri-resolver/did_json/` (local path in the Docker container) + +and extend those paths with either `did_json/` or `keri_cesr/`. + + +## Upload did.json and keri.cesr to your web server + +E.g. using git, Github pages, FTP, SCP, etc. + +### Example WOT-terms install using git + +We choose `WOT-terms` as our [DESTINATION LOCAL REPO] + +``` +cd [PATH TO LOCAL SOURCE REPO did-webs-iiw37-tutorial]/volume/dkr/did_json/ENbWS51Pw1rmxz5QIfK5kp3ODaEeQcZjqQNrLpc6mMQq +cp did.json ~/apps/WOT-terms/ +cd ../../keri_cesr/ENbWS51Pw1rmxz5QIfK5kp3ODaEeQcZjqQNrLpc6mMQq +cp keri.cesr ~/apps/WOT-terms/ +``` + +Result in local WOT-terms repo +``` +[DESTINATION LOCAL REPO]: git status + +Untracked files: + (use "git add ..." to include in what will be committed) + did.json + keri.cesr + +git add . +git commit -m "prepare upload did:webs documents to WOT-terms" +git push upstream main +``` +If you get the expected output of the push action, the files are on the controlled webserver. + +## Check if files are available on your server + +Note: Replace with your actual web address and AID + +https://peacekeeper.github.io/did-webs-iiw37-tutorial/EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP/did.json + +https://peacekeeper.github.io/did-webs-iiw37-tutorial/EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP/keri.cesr + + +## (Optional) Resolve AID as did:keri using local resolver + +Optionally resolve the AID locally as did:keri, given an OOBI as resolution option. + +Note: Replace with your actual AID + +``` +dkr did keri resolve --name controller --did did:keri:EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP --oobi http://witnesshost:5642/oobi/EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP/witness/BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha +``` + +## (Optional) Resolve AID as did:webs using local resolver + +Optionally resolve the AID locally as did:webs. + +Note: Replace with your actual web address and AID + +``` +dkr did webs resolve --name controller --did did:webs:peacekeeper.github.io:did-webs-iiw37-tutorial:EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP +``` + +## Resolve as did:web using Universal Resolver + +https://dev.uniresolver.io/#did:web:peacekeeper.github.io:did-webs-iiw37-tutorial:EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP + +## Resolve as did:webs using Universal Resolver + +https://dev.uniresolver.io/#did:webs:peacekeeper.github.io:did-webs-iiw37-tutorial:EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP + +## Example key rotation + +Use the following two commands in your running Docker container. + +``` +kli rotate --name controller --alias controller +``` +Be sure to repeat the `dkr webs generate` command: +``` +dkr did webs generate --name controller --did did:webs:blockchainbird.org:did-webs:EG8GsKYdICKs-zI6odM6tvCmxRT2J-7UkZFqA77agtb8 --oobi http://witnesshost:5642/oobi/EG8GsKYdICKs-zI6odM6tvCmxRT2J-7UkZFqA77agtb8/witness/BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha +``` +Now upload the overwritten `did.json` and `keri.cesr` again to the public spot. + +### Result + +A diff comparison of the old (in green) and the new (in red) **did.json**: +![did.json new in red versus old in green](./images/diff-did-json.png) +A diff comparison of the old (right) and the new (left) **keri.cesr**; in blue the added part: +![keri.cesr new in red versus old in green](./images/diff-keri-cesr.png) + +## Trouble shooting + +### If you are using an Apple Silicon (M1) mac then you might need to: +* In Docker, select `Use Rosetta for x86/amd64 emulation on Apple Silicon` +* Before running docker compose `export DOCKER_DEFAULT_PLATFORM=linux/amd64` + +### Your docker container is already up- and running? + +#### Do you have a witness up for another identifier? +Then the `kli incept --name controller --alias controller --file "/keripy/my-scripts/my-incept.json"` command will give this response: + +`ERR: Already incepted pre=[Your prefix of another AID].` + +#### Solution +Various solutions if you're a Docker expert. If not, we'll go down the more rigorous path: + +1. Step out of the running container with `exit` +2. and then `docker compose down`. This should respond with: + +[+] Running 3/3 + ⠿ Container dkr Removed 0.0s + ⠿ Container witnesshost Removed 13.7s + ⠿ Network did-webs-iiw37-tutorial_default Removed 3.1s +Now you could continue with: +``` +docker compose up -d +docker compose exec dkr /bin/bash +``` +### Special attention Github Pages: web address +There's no problem that we know of when you use Github pages in a bare-bones manner. However, if you use static page generators to populate your github pages (e.g. Jekyll or Docusaurus) be sure to choose the right spot of your files and extract the right paths of the links needed to resolve: + +#### Example +This is the web address of the `docusaurus` directory: +https://weboftrust.github.io/WOT-terms/test/did-webs-iiw37-tutorial/ + +But the exact spot to extract the files as text would be something like: +``` +http://raw.githubusercontent.com/WOT-terms/test/did-webs-iiw37-tutorial/[your AID] +``` +The reason for this confusion is dat a static page generator like Docusaurus or Jekyll might interfere with the location, visibility and accessibility of your files on Github Pages. + +We advise to choose a simple public directory that you control and we won't go into more detail on how to deal with static site generators. + +Example: +``` +dkr did keri resolve --name dkr --did did:keri:EPaP4GgZsB6Ww-SeSO2gwNDMNpC7-DN51X5AqiJFWkw6 --oobi http://witnesshost:5642/oobi/EPaP4GgZsB6Ww-SeSO2gwNDMNpC7-DN51X5AqiJFWkw6/witness/BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha +``` + +``` + did:keri:123, oobi --------------------------------- --------------------- + O -----------------> | | | | + -|- <----------------- | dkr did keri resolve | <----> | KERI WATCHER POOL | + / \ diddoc, metadata | | | | + --------------------------------- --------------------- +``` + +### `dkr did keri resolver-service` + +**Expose did:keri resolver as an HTTP web service.** (Can be deployed as Universal Resolver driver) + +Example: +``` +dkr did keri resolver-service --name dkr --port 7678 +``` + +``` + --------------------------------- --------------------- + | | | | + | dkr did keri resolver-service | <----> | KERI WATCHER POOL | + | | | | + --------------------------------- --------------------- + HTTPS + HTTP GET ^ | 200 OK + did:keri:123 | | diddoc + oobi | v metadata + + o + -|- + / \ +``` + +## did:webs + +### `dkr did webs generate` + +**Generate a did:webs DID document and KEL/TEL file.** + +Example: +``` +dkr did webs generate --name dkr --did did:webs:danubetech.com:example:EPaP4GgZsB6Ww-SeSO2gwNDMNpC7-DN51X5AqiJFWkw6 +``` + +``` + --------------------------------- + did.json, keri.cesr | | + ---------------------> | ANY WEB SERVER /123/did.json | + | | /123/keri.cesr | + | UPLOAD --------------------------------- + | + | + did:webs:dom:123 --------------------------------- --------------------- + O -----------------> | | | | + -|- <----------------- | dkr did webs generate | <----> | KERI WATCHER POOL | + / \ did.json, keri.cesr | | | | + --------------------------------- --------------------- +``` + +### `dkr did webs service` + +**Launch web server capable of serving KERI AIDs as did:webs and did:web DIDs.** + +Example: +``` +dkr did webs service --name dkr --port 7676 +``` + +``` + --------------------------------- --------------------- + | | | | + | dkr did webs service | <----> | KERI WATCHER POOL | + | | | | + --------------------------------- --------------------- + HTTPS + HTTP GET ^ | 200 OK + /123/did.json | | did.json + /123/keri.cesr | v keri.cesr + + did:webs:dom:123 --------------------------------- + O -----------------> | | + -|- <----------------- | ANY DID:WEBS RESOLVER | <----- (verify did.json/keri.cesr) + / \ diddoc, metadata | | + --------------------------------- +``` + +``` + --------------------------------- --------------------- + | | | | + | dkr did webs service | <----> | KERI WATCHER POOL | + | | | | + --------------------------------- --------------------- + HTTPS + HTTP GET ^ | 200 OK + /123/did.json | | did.json + | v + + did:web:dom:123 --------------------------------- + O -----------------> | | + -|- <----------------- | ANY DID:WEB RESOLVER | + / \ diddoc | | + --------------------------------- +``` + +### `dkr did webs resolve` + +**Resolve a did:webs DID.** + +Example: +``` +dkr did webs resolve --name dkr --did did:webs:danubetech.com:example:EPaP4GgZsB6Ww-SeSO2gwNDMNpC7-DN51X5AqiJFWkw6 +``` + +``` + --------------------------------- --------------------- + | | | | + | dkr did webs service | <----> | KERI WATCHER POOL | + | | | | + --------------------------------- --------------------- + HTTPS + HTTP GET ^ | 200 OK + /123/did.json | | did.json + /123/keri.cesr | v keri.cesr + + did:webs:dom:123 --------------------------------- + O -----------------> | | + -|- <----------------- | dkr did webs resolve | <----- (verify did.json/keri.cesr) + / \ diddoc, metadata | | + --------------------------------- +``` + +``` + --------------------------------- + | | + | ANY WEB SERVER /123/did.json | + | /123/keri.cesr | + --------------------------------- + HTTPS + HTTP GET ^ | 200 OK + /123/did.json | | did.json + /123/keri.cesr | v keri.cesr + + did:webs:dom:123 --------------------------------- + O -----------------> | | + -|- <----------------- | dkr did webs resolve | <----- (verify did.json/keri.cesr) + / \ diddoc, metadata | | + --------------------------------- +``` + +``` + --------------------------------- + | | + | ANY WEB SERVER /123/did.json | + | /123/keri.cesr | + --------------------------------- + HTTPS + HTTP GET ^ | 200 OK + /123/did.json | | did.json + | v + + did:web:dom:123 --------------------------------- + O -----------------> | | + -|- <----------------- | ANY DID:WEB RESOLVER | + / \ diddoc | | + --------------------------------- +``` + +### `dkr did webs resolver-service` + +**Expose did:webs resolver as an HTTP web service.** (Can be deployed as Universal Resolver driver) + +Example: +``` +dkr did keri resolve --name dkr --port 7677 +``` + +``` + --------------------------------- --------------------- + | | | | + | dkr did webs service | <----> | KERI WATCHER POOL | + | | | | + --------------------------------- --------------------- + HTTPS + HTTP GET ^ | 200 OK + /123/did.json | | did.json + /123/keri.cesr | v keri.cesr + + --------------------------------- + | | + | dkr did webs resolver-service | <----- (verify did.json/keri.cesr) + | | + --------------------------------- + HTTPS + HTTP GET ^ | 200 OK + did:webs:123 | | diddoc + oobi | v metadata + + o + -|- + / \ +``` + +``` + --------------------------------- + | | + | ANY WEB SERVER /123/did.json | + | /123/keri.cesr | + --------------------------------- + HTTPS + HTTP GET ^ | 200 OK + /123/did.json | | did.json + /123/keri.cesr | v keri.cesr + + --------------------------------- + | | + | dkr did webs resolver-service | <----- (verify did.json/keri.cesr) + | | + --------------------------------- + HTTPS + HTTP GET ^ | 200 OK + did:webs:123 | | diddoc + | v metadata + + o + -|- + / \ +``` diff --git a/README.md b/README.md index fa71fc0..5f13f33 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,15 @@ +# Introduction + +Welcome to the `did:webs` reference implementation repository. See the did:webs [specification](https://trustoverip.github.io/tswg-did-method-webs-specification/) for more information. + +Thank you to Phil Feairheller @pfeairheller from GLEIF who started this work [here](https://github.com/WebOfTrust/did-keri-resolver) + +# Developers - Getting Started + +Developers who want to jump into using the `did:webs` reference implementation should follow the [Getting Started](./GETTING_STARTED.md) guide. + +Thank you to Markus Sabadello @peacekeeper from DanubeTech who started the original tutorial for IIW37 [here](https://github.com/peacekeeper/did-webs-iiw-tutorial) + # dkr did:keri/did:webs DID Resolver Reference Implementation diff --git a/docker-compose.yml b/docker-compose.yml index 3460d93..e6a0952 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,19 @@ version: "3" services: + witnesshost: + container_name: witnesshost + hostname: witnesshost + image: gleif/keri:latest + tty: true + volumes: + - ./volume/witnesshost/keripy/scripts/keri/cf/main/:/keripy/scripts/keri/cf/main/ + ports: + - 5642:5642 # witness + - 5643:5643 # witness + - 5644:5644 # witness + entrypoint: kli witness demo + dkr: container_name: dkr hostname: dkr @@ -9,6 +22,12 @@ services: dockerfile: ./images/dkr.dockerfile image: gleif/dkr:latest tty: true + volumes: + - ./volume/dkr/my-scripts/:/keripy/my-scripts/ + - ./volume/dkr/did_json/:/usr/local/var/did-keri-resolver/did_json/ + - ./volume/dkr/keri_cesr/:/usr/local/var/did-keri-resolver/keri_cesr/ + - ./volume/dkr/examples/:/usr/local/var/did-keri-resolver/examples/ + - ./volume/pages/:/pages/ did-webs-service: container_name: did-webs-service @@ -33,15 +52,3 @@ services: image: gleif/did-webs-resolver-service:latest ports: - 7677:7677 - - did-keri-resolver-service: - container_name: did-keri-resolver-service - hostname: did-keri-resolver-service - build: - context: . - dockerfile: ./images/did-keri-resolver-service.dockerfile - depends_on: - - dkr - image: gleif/did-keri-resolver-service:latest - ports: - - 7678:7678 diff --git a/src/dkr/app/cli/commands/did/webs/generate.py b/src/dkr/app/cli/commands/did/webs/generate.py index 3fb9e52..82a25b7 100644 --- a/src/dkr/app/cli/commands/did/webs/generate.py +++ b/src/dkr/app/cli/commands/did/webs/generate.py @@ -94,7 +94,9 @@ def generate(self, tymth, tock=0.0, **opts): # File path kc_file_path = os.path.join(kc_dir_path, f"{webbing.KERI_CESR}") kcf = open(kc_file_path, "w") - kcf.write(msgs.decode("utf-8")) + tmsg = msgs.decode("utf-8") + print(f"Writing CESR events to {kc_file_path}: \n{tmsg}") + kcf.write(tmsg) #generate did doc diddoc = didding.generateDIDDoc(self.hby, did=self.did, aid=aid, oobi=self.oobi, reg_name=self.da_reg) diff --git a/volume/dkr/did_json/.gitignore b/volume/dkr/did_json/.gitignore new file mode 100644 index 0000000..7c9d611 --- /dev/null +++ b/volume/dkr/did_json/.gitignore @@ -0,0 +1,3 @@ +* +!.gitignore +!README.md diff --git a/volume/dkr/did_json/README.md b/volume/dkr/did_json/README.md new file mode 100644 index 0000000..ee3d618 --- /dev/null +++ b/volume/dkr/did_json/README.md @@ -0,0 +1,3 @@ +# did.json + +This target path contains did.json files generated for did:webs identifiers. diff --git a/volume/dkr/examples/README.md b/volume/dkr/examples/README.md new file mode 100644 index 0000000..aca652f --- /dev/null +++ b/volume/dkr/examples/README.md @@ -0,0 +1,41 @@ +The public.sh script generates a public attestation of the designated aliases. +It requires a server running at 127.0.0.1:7723 that can serve the schema oobi. +The output will look like: +``` +examples $ ./public.sh +KERI Keystore created at: /usr/local/var/keri/ks/controller +KERI Database created at: /usr/local/var/keri/db/controller +KERI Credential Store created at: /usr/local/var/keri/reg/controller +Prefix ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe + Public key 1: DHr0-I-mMN7h6cLMOTRJkkfPuMd0vgQPrOk4Y3edaHjr + +Alias: controller +Identifier: ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe +Seq No: 0 + +Witnesses: +Count: 0 +Receipts: 0 +Threshold: 0 + +Public Keys: + 1. DHr0-I-mMN7h6cLMOTRJkkfPuMd0vgQPrOk4Y3edaHjr + +Waiting for TEL event witness receipts +Sending TEL events to witnesses +Registry: dAliases(EH6gJT1OQifVBTPsavF5YfkQRODoSAyrMzP4vCeOm0Af) + created for Identifier Prefix: ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe +Hit enter after you have added the registry SAID (and maybe attrs, rules, etc) to desig-aliases-public.json +http://127.0.0.1:7723/oobi/EN6Oh5XSD5_q2Hgu-aqpdfbVepdpYpFlgz6zvJL5b_r5 resolved +Waiting for TEL event witness receipts +Sending TEL events to witnesses +EMIXtMnh1vgYhSBLekbK-360MDcMU10QzejX3zl35q30 has been created. +Current issued credentials for controller (ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe): + +Credential #1: EMIXtMnh1vgYhSBLekbK-360MDcMU10QzejX3zl35q30 + Type: Designated Aliases Public Attestation + Status: Issued ✔ + Issued by ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe + Issued on 2023-11-13T17:41:37.710691+00:00 +{"v":"ACDC10JSON0004d5_","d":"EMIXtMnh1vgYhSBLekbK-360MDcMU10QzejX3zl35q30","i":"ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe","ri":"EH6gJT1OQifVBTPsavF5YfkQRODoSAyrMzP4vCeOm0Af","s":"EN6Oh5XSD5_q2Hgu-aqpdfbVepdpYpFlgz6zvJL5b_r5","a":{"d":"ENjmfq8MtWLYncKtb1LYhOdeSvoH6l4u-IJWC6RSmhF2","dt":"2023-11-13T17:41:37.710691+00:00","ids":["did:webs:example.org:ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe"]},"r":{"d":"EEVTx0jLLZDQq8a5bXrXgVP0JDP7j8iDym9Avfo8luLw","aliasDesignation":{"l":"The issuer of this ACDC designates the identifiers in the ids field as the only allowed namespaced aliases of the issuer's AID."},"usageDisclaimer":{"l":"This attestation only asserts designated aliases of the controller of the AID, that the AID controlled namespaced alias has been designated by the controller. It does not assert that the controller of this AID has control over the infrastructure or anything else related to the namespace other than the included AID."},"issuanceDisclaimer":{"l":"All information in a valid and non-revoked alias designation assertion is accurate as of the date specified."},"termsOfUse":{"l":"Designated aliases of the AID must only be used in a manner consistent with the expressed intent of the AID controller."}}} +``` \ No newline at end of file diff --git a/volume/dkr/examples/credential.json b/volume/dkr/examples/credential.json new file mode 100644 index 0000000..26cfaa5 --- /dev/null +++ b/volume/dkr/examples/credential.json @@ -0,0 +1 @@ +{"v": "ACDC10JSON000514_", "d": "EAxjBCqyqPmIeaZo2kUzdcpIUrooxaUqhal9ii7tLagG", "i": "ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe", "ri": "EFrgJK29VtqJYtKcfjJ-ig8yP37-Vwr84ANJJDv8YRXj", "s": "EN6Oh5XSD5_q2Hgu-aqpdfbVepdpYpFlgz6zvJL5b_r5", "a": {"d": "EHQgqNNSueVmVjlErrGtzjl-HJya9rMUiNadDSkZQ1kV", "dt": "2023-11-13T17:41:37.710691+00:00", "ids": ["did:webs:foo.com:ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe", "did:web:example.com:ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe"]}, "r": {"d": "EEVTx0jLLZDQq8a5bXrXgVP0JDP7j8iDym9Avfo8luLw", "aliasDesignation": {"l": "The issuer of this ACDC designates the identifiers in the ids field as the only allowed namespaced aliases of the issuer's AID."}, "usageDisclaimer": {"l": "This attestation only asserts designated aliases of the controller of the AID, that the AID controlled namespaced alias has been designated by the controller. It does not assert that the controller of this AID has control over the infrastructure or anything else related to the namespace other than the included AID."}, "issuanceDisclaimer": {"l": "All information in a valid and non-revoked alias designation assertion is accurate as of the date specified."}, "termsOfUse": {"l": "Designated aliases of the AID must only be used in a manner consistent with the expressed intent of the AID controller."}}} \ No newline at end of file diff --git a/volume/dkr/examples/desig-aliases-attr-public.json b/volume/dkr/examples/desig-aliases-attr-public.json new file mode 100644 index 0000000..acf8c55 --- /dev/null +++ b/volume/dkr/examples/desig-aliases-attr-public.json @@ -0,0 +1 @@ +{"d": "EHQgqNNSueVmVjlErrGtzjl-HJya9rMUiNadDSkZQ1kV", "dt": "2023-11-13T17:41:37.710691+00:00", "ids": ["did:webs:foo.com:ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe", "did:web:example.com:ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe"]} \ No newline at end of file diff --git a/volume/dkr/examples/desig-aliases-public.json b/volume/dkr/examples/desig-aliases-public.json new file mode 100644 index 0000000..063f2e7 --- /dev/null +++ b/volume/dkr/examples/desig-aliases-public.json @@ -0,0 +1 @@ +{"v": "ACDC10JSON000514_", "d": "EM1eYL8kmDMy9mLMAh9sSncMvlNSlHOHrAj0BpZxu3wj", "i": "ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe", "ri": "ELQoWO7vxvKLxAdwAi-o7lUBaYzplfKKwBt5oB3CtyB8", "s": "EN6Oh5XSD5_q2Hgu-aqpdfbVepdpYpFlgz6zvJL5b_r5", "a": {"d": "EHQgqNNSueVmVjlErrGtzjl-HJya9rMUiNadDSkZQ1kV", "dt": "2023-11-13T17:41:37.710691+00:00", "ids": ["did:webs:foo.com:ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe", "did:web:example.com:ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe"]}, "r": {"d": "EEVTx0jLLZDQq8a5bXrXgVP0JDP7j8iDym9Avfo8luLw", "aliasDesignation": {"l": "The issuer of this ACDC designates the identifiers in the ids field as the only allowed namespaced aliases of the issuer's AID."}, "usageDisclaimer": {"l": "This attestation only asserts designated aliases of the controller of the AID, that the AID controlled namespaced alias has been designated by the controller. It does not assert that the controller of this AID has control over the infrastructure or anything else related to the namespace other than the included AID."}, "issuanceDisclaimer": {"l": "All information in a valid and non-revoked alias designation assertion is accurate as of the date specified."}, "termsOfUse": {"l": "Designated aliases of the AID must only be used in a manner consistent with the expressed intent of the AID controller."}}} \ No newline at end of file diff --git a/volume/dkr/examples/desig-aliases-rules-public.json b/volume/dkr/examples/desig-aliases-rules-public.json new file mode 100644 index 0000000..7322b6b --- /dev/null +++ b/volume/dkr/examples/desig-aliases-rules-public.json @@ -0,0 +1 @@ +{"d": "EEVTx0jLLZDQq8a5bXrXgVP0JDP7j8iDym9Avfo8luLw", "aliasDesignation": {"l": "The issuer of this ACDC designates the identifiers in the ids field as the only allowed namespaced aliases of the issuer's AID."}, "usageDisclaimer": {"l": "This attestation only asserts designated aliases of the controller of the AID, that the AID controlled namespaced alias has been designated by the controller. It does not assert that the controller of this AID has control over the infrastructure or anything else related to the namespace other than the included AID."}, "issuanceDisclaimer": {"l": "All information in a valid and non-revoked alias designation assertion is accurate as of the date specified."}, "termsOfUse": {"l": "Designated aliases of the AID must only be used in a manner consistent with the expressed intent of the AID controller."}} \ No newline at end of file diff --git a/volume/dkr/examples/did_json/ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe/did.json b/volume/dkr/examples/did_json/ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe/did.json new file mode 100644 index 0000000..277958b --- /dev/null +++ b/volume/dkr/examples/did_json/ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe/did.json @@ -0,0 +1 @@ +{"id": "did:web:peacekeeper.github.io:did-webs-iiw37-tutorial:ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe", "verificationMethod": [{"id": "#DHr0-I-mMN7h6cLMOTRJkkfPuMd0vgQPrOk4Y3edaHjr", "type": "JsonWebKey", "controller": "did:web:peacekeeper.github.io:did-webs-iiw37-tutorial:ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe", "publicKeyJwk": {"kid": "DHr0-I-mMN7h6cLMOTRJkkfPuMd0vgQPrOk4Y3edaHjr", "kty": "OKP", "crv": "Ed25519", "x": "evT4j6Yw3uHpwsw5NEmSR8-4x3S-BA-s6Thjd51oeOs"}}], "service": [], "alsoKnownAs": ["did:web:example.com:ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe"]} \ No newline at end of file diff --git a/volume/dkr/examples/gen.sh b/volume/dkr/examples/gen.sh new file mode 100755 index 0000000..d06bce4 --- /dev/null +++ b/volume/dkr/examples/gen.sh @@ -0,0 +1 @@ +dkr did webs generate --name controller --did did:webs:labs.hyperledger.org:did-webs-resolver:pages:ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe \ No newline at end of file diff --git a/volume/dkr/examples/get_started.sh b/volume/dkr/examples/get_started.sh new file mode 100644 index 0000000..c4ab1c6 --- /dev/null +++ b/volume/dkr/examples/get_started.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +# init environment for controller AID +kli init --name controller --salt 0AAQmsjh-C7kAJZQEzdrzwB7 --nopasscode --config-dir "/keripy/my-scripts" --config-file my-config + +# inception for controller AID +kli incept --name controller --alias controller --file "/keripy/my-scripts/my-incept.json" + +# check witness oobi for our AID +curl http://witnesshost:5642/oobi/EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP/witness/BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha + +# generate controller did:webs for labs.hyperledger.org +dkr did webs generate --name controller --did did:webs:labs.hyperledger.org:did-webs-resolver:pages:EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP --oobi http://witnesshost:5642/oobi/EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP/witness/BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha +# dkr did webs generate --name controller --did did:webs:labs.hyperledger.org:did-webs-resolver:pages:EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP \ No newline at end of file diff --git a/volume/dkr/examples/keri_cesr/ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe/keri.cesr b/volume/dkr/examples/keri_cesr/ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe/keri.cesr new file mode 100644 index 0000000..e69de29 diff --git a/volume/dkr/examples/local.sh b/volume/dkr/examples/local.sh new file mode 100755 index 0000000..82c0120 --- /dev/null +++ b/volume/dkr/examples/local.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +# need to run witness network +rm -Rf /usr/local/var/keri/*;rm -Rf ~/.keri/*;kli witness demo & +wpid=$! +echo "witness pid: $wpid" + +# init environment for controller AID +kli init --name controller --salt 0AAQmsjh-C7kAJZQEzdrzwB7 --nopasscode --config-dir "./my-scripts" --config-file local + +# inception for controller AID +kli incept --name controller --alias controller --file "./my-scripts/incept-local.json" + +# check witness oobi for our AID +curl http://127.0.0.1:5642/oobi/EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP/witness/BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha + +# generate controller did:webs for labs.hyperledger.org +dkr did webs generate --name controller --did did:webs:labs.hyperledger.org:did-webs-resolver:pages:EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP --oobi http://127.0.0.1:5642/oobi/EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP/witness/BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha +# dkr did webs generate --name controller --did did:webs:labs.hyperledger.org:did-webs-resolver:pages:EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP + +kill $wpid \ No newline at end of file diff --git a/volume/dkr/examples/my-scripts/incept-local.json b/volume/dkr/examples/my-scripts/incept-local.json new file mode 100644 index 0000000..850aca0 --- /dev/null +++ b/volume/dkr/examples/my-scripts/incept-local.json @@ -0,0 +1,13 @@ +{ + "transferable": true, + "wits": [ + "BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha", + "BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM", + "BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX" + ], + "toad": 3, + "icount": 1, + "ncount": 1, + "isith": "1", + "nsith": "1" +} diff --git a/volume/dkr/examples/my-scripts/keri/cf/config.json b/volume/dkr/examples/my-scripts/keri/cf/config.json new file mode 100755 index 0000000..efeb96a --- /dev/null +++ b/volume/dkr/examples/my-scripts/keri/cf/config.json @@ -0,0 +1,11 @@ +{ + "dt": "2022-01-20T12:57:59.823350+00:00", + "iurls": [ + "http://witnesshost:5642/oobi/BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha/controller", + "http://witnesshost:5644/oobi/BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX/controller", + "http://witnesshost:5643/oobi/BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM/controller" + ], + "durls": [ + "https://weboftrust.github.io/oobi/EN6Oh5XSD5_q2Hgu-aqpdfbVepdpYpFlgz6zvJL5b_r5" + ] + } \ No newline at end of file diff --git a/volume/dkr/examples/my-scripts/keri/cf/local.json b/volume/dkr/examples/my-scripts/keri/cf/local.json new file mode 100755 index 0000000..f90c9c7 --- /dev/null +++ b/volume/dkr/examples/my-scripts/keri/cf/local.json @@ -0,0 +1,11 @@ +{ + "dt": "2022-01-20T12:57:59.823350+00:00", + "iurls": [ + "http://127.0.0.1:5642/oobi/BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha/controller", + "http://127.0.0.1:5644/oobi/BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX/controller", + "http://127.0.0.1:5643/oobi/BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM/controller" + ], + "durls": [ + "https://weboftrust.github.io/oobi/EN6Oh5XSD5_q2Hgu-aqpdfbVepdpYpFlgz6zvJL5b_r5" + ] + } \ No newline at end of file diff --git a/volume/dkr/examples/my-scripts/keri/cf/my-config.json b/volume/dkr/examples/my-scripts/keri/cf/my-config.json new file mode 100755 index 0000000..e69de29 diff --git a/volume/dkr/examples/my-scripts/my-incept.json b/volume/dkr/examples/my-scripts/my-incept.json new file mode 100644 index 0000000..faec18d --- /dev/null +++ b/volume/dkr/examples/my-scripts/my-incept.json @@ -0,0 +1,9 @@ +{ + "transferable": true, + "wits": [], + "toad": 0, + "icount": 1, + "ncount": 1, + "isith": "1", + "nsith": "1" +} \ No newline at end of file diff --git a/volume/dkr/examples/public.sh b/volume/dkr/examples/public.sh new file mode 100755 index 0000000..b57fbee --- /dev/null +++ b/volume/dkr/examples/public.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +# # updates the SAIDs of the schemas +# ../update.sh + +alias="controller" +reg_name="dAliases" +d_alias_schema="EN6Oh5XSD5_q2Hgu-aqpdfbVepdpYpFlgz6zvJL5b_r5" +# da_schema_oobi="http://127.0.0.1:7723/oobi/${d_alias_schema}" +da_schema_oobi="https://weboftrust.github.io/oobi/${d_alias_schema}" + +#clear state from previous runs +echo "Clearing state from previous runs for $alias" +find /usr/local/var/keri/* -name "$alias" -type d -exec rm -rf {} + 2>/dev/null +find /usr/local/var/keri/* -name "$reg_name" -type d -exec rm -rf {} + 2>/dev/null + +echo "Initializing $alias" +kli init --name "$alias" --salt 0AAQmsjh-C7kAJZQEzdrzwB7 --nopasscode --config-dir "./my-scripts" --config-file config +echo "Incepting $alias" +kli incept --name "$alias" --alias "$alias" --file "./my-scripts/my-incept.json" +echo "Getting $alias status" +kli status --name "$alias" --alias "$alias" + +echo "Creating registry $reg_name" +kli vc registry incept --name "$alias" --alias "$alias" --registry-name "$reg_name" + +echo "Saidifying attestation rules" +kli saidify --file ./desig-aliases-rules-public.json --label "d" +echo "Saidifying attestation attributes" +kli saidify --file ./desig-aliases-attr-public.json --label "d" + +# manually add rules example SAID and attribute example SAID to the desig-aliases.json +# read -p "Hit enter after you have added the registry SAID (and maybe attrs, rules, etc) to desig-aliases-public.json" +# echo "Saidifying attestation with the registry you added" +# kli saidify --file ./desig-aliases-public.json --label "d" + +echo "Resolving schema at $da_schema_oobi" +kli oobi resolve --name "$alias" --oobi-alias myDesigAliases --oobi "$da_schema_oobi" +echo "Issuing attestation to registry $reg_name with schema $d_alias_schema from attr file desig-aliases-attr-public.json" +kli vc issue --name "$alias" --alias "$alias" --registry-name "$reg_name" --schema "${d_alias_schema}" --data @desig-aliases-attr-public.json --rules @desig-aliases-rules-public.json +# kli vc create --name "$alias" --alias "$alias" --registry-name "$reg_name" --schema "${d_alias_schema}" --credential @desig-aliases-public.json +echo "Getting SAID for attestation in registry $reg_name with schema $d_alias_schema" +SAID=$(kli vc list --name "$alias" --alias "$alias" --issued --said --schema "${d_alias_schema}") +echo "Listing attestations in registry $reg_name with schema $d_alias_schema" +kli vc list --name "$alias" --alias "$alias" --issued --schema "${d_alias_schema}" + +echo "Exporting attestation with SAID $SAID" +kli vc export --name "$alias" --alias "$alias" --said "${SAID}" --chain \ No newline at end of file diff --git a/volume/dkr/examples/scripts/keri/cf/main/wan.json b/volume/dkr/examples/scripts/keri/cf/main/wan.json new file mode 100755 index 0000000..e69de29 diff --git a/volume/dkr/examples/scripts/keri/cf/main/wes.json b/volume/dkr/examples/scripts/keri/cf/main/wes.json new file mode 100755 index 0000000..e69de29 diff --git a/volume/dkr/examples/scripts/keri/cf/main/wil.json b/volume/dkr/examples/scripts/keri/cf/main/wil.json new file mode 100755 index 0000000..e69de29 diff --git a/volume/dkr/examples/scripts/keri/cf/main/wit.json b/volume/dkr/examples/scripts/keri/cf/main/wit.json new file mode 100755 index 0000000..e69de29 diff --git a/volume/dkr/examples/scripts/keri/cf/main/wub.json b/volume/dkr/examples/scripts/keri/cf/main/wub.json new file mode 100755 index 0000000..e69de29 diff --git a/volume/dkr/examples/scripts/keri/cf/main/wyz.json b/volume/dkr/examples/scripts/keri/cf/main/wyz.json new file mode 100755 index 0000000..e69de29 diff --git a/volume/dkr/keri_cesr/.gitignore b/volume/dkr/keri_cesr/.gitignore new file mode 100644 index 0000000..7c9d611 --- /dev/null +++ b/volume/dkr/keri_cesr/.gitignore @@ -0,0 +1,3 @@ +* +!.gitignore +!README.md diff --git a/volume/dkr/keri_cesr/README.md b/volume/dkr/keri_cesr/README.md new file mode 100644 index 0000000..7b31fd3 --- /dev/null +++ b/volume/dkr/keri_cesr/README.md @@ -0,0 +1,3 @@ +# keri.cesr + +This target path contains keri.cesr files generated for did:webs identifiers. diff --git a/volume/dkr/my-scripts/keri/cf/my-agent.json b/volume/dkr/my-scripts/keri/cf/my-agent.json new file mode 100755 index 0000000..2c63c08 --- /dev/null +++ b/volume/dkr/my-scripts/keri/cf/my-agent.json @@ -0,0 +1,2 @@ +{ +} diff --git a/volume/dkr/my-scripts/keri/cf/my-config-multi-fractions.json b/volume/dkr/my-scripts/keri/cf/my-config-multi-fractions.json new file mode 100755 index 0000000..eee37b9 --- /dev/null +++ b/volume/dkr/my-scripts/keri/cf/my-config-multi-fractions.json @@ -0,0 +1,8 @@ +{ + "dt": "2022-01-20T12:57:59.823350+00:00", + "iurls": [ + "http://witnesshost:5642/oobi/BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha/controller", + "http://witnesshost:5644/oobi/BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX/controller", + "http://witnesshost:5643/oobi/BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM/controller" + ] +} diff --git a/volume/dkr/my-scripts/keri/cf/my-config-multi.json b/volume/dkr/my-scripts/keri/cf/my-config-multi.json new file mode 100755 index 0000000..eee37b9 --- /dev/null +++ b/volume/dkr/my-scripts/keri/cf/my-config-multi.json @@ -0,0 +1,8 @@ +{ + "dt": "2022-01-20T12:57:59.823350+00:00", + "iurls": [ + "http://witnesshost:5642/oobi/BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha/controller", + "http://witnesshost:5644/oobi/BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX/controller", + "http://witnesshost:5643/oobi/BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM/controller" + ] +} diff --git a/volume/dkr/my-scripts/keri/cf/my-config.json b/volume/dkr/my-scripts/keri/cf/my-config.json new file mode 100755 index 0000000..eee37b9 --- /dev/null +++ b/volume/dkr/my-scripts/keri/cf/my-config.json @@ -0,0 +1,8 @@ +{ + "dt": "2022-01-20T12:57:59.823350+00:00", + "iurls": [ + "http://witnesshost:5642/oobi/BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha/controller", + "http://witnesshost:5644/oobi/BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX/controller", + "http://witnesshost:5643/oobi/BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM/controller" + ] +} diff --git a/volume/dkr/my-scripts/my-incept-multi-fractions.json b/volume/dkr/my-scripts/my-incept-multi-fractions.json new file mode 100644 index 0000000..dbd2a19 --- /dev/null +++ b/volume/dkr/my-scripts/my-incept-multi-fractions.json @@ -0,0 +1,13 @@ +{ + "transferable": true, + "wits": [ + "BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha", + "BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM", + "BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX" + ], + "toad": 3, + "icount": 3, + "ncount": 3, + "isith": ["1/3", "3/5", "1/5"], + "nsith": "2" +} diff --git a/volume/dkr/my-scripts/my-incept-multi.json b/volume/dkr/my-scripts/my-incept-multi.json new file mode 100644 index 0000000..7bc0771 --- /dev/null +++ b/volume/dkr/my-scripts/my-incept-multi.json @@ -0,0 +1,13 @@ +{ + "transferable": true, + "wits": [ + "BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha", + "BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM", + "BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX" + ], + "toad": 3, + "icount": 3, + "ncount": 3, + "isith": "2", + "nsith": "2" +} diff --git a/volume/dkr/my-scripts/my-incept.json b/volume/dkr/my-scripts/my-incept.json new file mode 100644 index 0000000..850aca0 --- /dev/null +++ b/volume/dkr/my-scripts/my-incept.json @@ -0,0 +1,13 @@ +{ + "transferable": true, + "wits": [ + "BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha", + "BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM", + "BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX" + ], + "toad": 3, + "icount": 1, + "ncount": 1, + "isith": "1", + "nsith": "1" +} diff --git a/volume/dkr/my-scripts/my-rotate.json b/volume/dkr/my-scripts/my-rotate.json new file mode 100644 index 0000000..a0100be --- /dev/null +++ b/volume/dkr/my-scripts/my-rotate.json @@ -0,0 +1,9 @@ +{ + "isith": "1", + "nsith": "1", + "ncount": 1, + "toad": 3, + "wits": [], + "witsCut": [], + "witsAdd": [] +} diff --git a/volume/witnesshost/keripy/scripts/keri/cf/main/wan.json b/volume/witnesshost/keripy/scripts/keri/cf/main/wan.json new file mode 100755 index 0000000..65cc5fb --- /dev/null +++ b/volume/witnesshost/keripy/scripts/keri/cf/main/wan.json @@ -0,0 +1,9 @@ +{ + "dt": "2022-01-20T12:57:59.823350+00:00", + "wan": { + "dt": "2022-01-20T12:57:59.823350+00:00", + "curls": ["tcp://witnesshost:5632/", "http://witnesshost:5642/"] + }, + "iurls": [ + ] +} diff --git a/volume/witnesshost/keripy/scripts/keri/cf/main/wes.json b/volume/witnesshost/keripy/scripts/keri/cf/main/wes.json new file mode 100755 index 0000000..a5b4720 --- /dev/null +++ b/volume/witnesshost/keripy/scripts/keri/cf/main/wes.json @@ -0,0 +1,9 @@ +{ + "wes": { + "dt": "2022-01-20T12:57:59.823350+00:00", + "curls": ["tcp://witnesshost:5634/", "http://witnesshost:5644/"] + }, + "dt": "2022-01-20T12:57:59.823350+00:00", + "iurls": [ + ] +} diff --git a/volume/witnesshost/keripy/scripts/keri/cf/main/wil.json b/volume/witnesshost/keripy/scripts/keri/cf/main/wil.json new file mode 100755 index 0000000..e2250da --- /dev/null +++ b/volume/witnesshost/keripy/scripts/keri/cf/main/wil.json @@ -0,0 +1,9 @@ +{ + "wil": { + "dt": "2022-01-20T12:57:59.823350+00:00", + "curls": ["tcp://witnesshost:5633/", "http://witnesshost:5643/"] + }, + "dt": "2022-01-20T12:57:59.823350+00:00", + "iurls": [ + ] +} diff --git a/volume/witnesshost/keripy/scripts/keri/cf/main/wit.json b/volume/witnesshost/keripy/scripts/keri/cf/main/wit.json new file mode 100755 index 0000000..aba218b --- /dev/null +++ b/volume/witnesshost/keripy/scripts/keri/cf/main/wit.json @@ -0,0 +1,9 @@ +{ + "wit": { + "dt": "2022-01-20T12:57:59.823350+00:00", + "curls": ["tcp://127.0.0.1:5635/", "http://127.0.0.1:5645/"] + }, + "dt": "2022-01-20T12:57:59.823350+00:00", + "iurls": [ + ] +} diff --git a/volume/witnesshost/keripy/scripts/keri/cf/main/wub.json b/volume/witnesshost/keripy/scripts/keri/cf/main/wub.json new file mode 100755 index 0000000..fe06c95 --- /dev/null +++ b/volume/witnesshost/keripy/scripts/keri/cf/main/wub.json @@ -0,0 +1,9 @@ +{ + "wub": { + "dt": "2022-01-20T12:57:59.823350+00:00", + "curls": ["tcp://127.0.0.1:5636/", "http://127.0.0.1:5646/"] + }, + "dt": "2022-01-20T12:57:59.823350+00:00", + "iurls": [ + ] +} diff --git a/volume/witnesshost/keripy/scripts/keri/cf/main/wyz.json b/volume/witnesshost/keripy/scripts/keri/cf/main/wyz.json new file mode 100755 index 0000000..350a9e6 --- /dev/null +++ b/volume/witnesshost/keripy/scripts/keri/cf/main/wyz.json @@ -0,0 +1,9 @@ +{ + "wyz": { + "dt": "2022-01-20T12:57:59.823350+00:00", + "curls": ["tcp://127.0.0.1:5637/", "http://127.0.0.1:5647/"] + }, + "dt": "2022-01-20T12:57:59.823350+00:00", + "iurls": [ + ] +} From 0bcdeb24e979a634fd0303c0105dd1d264416f92 Mon Sep 17 00:00:00 2001 From: 2byrds <2byrds@gmail.com> Date: Sun, 17 Dec 2023 15:07:40 -0500 Subject: [PATCH 02/17] removing oobi option. should generate from local hab Signed-off-by: 2byrds <2byrds@gmail.com> --- GETTING_STARTED.md | 2 +- src/dkr/app/cli/commands/did/webs/generate.py | 46 +++++++++++-------- .../did.json | 1 - volume/dkr/examples/get_started.sh | 4 +- .../keri.cesr | 0 5 files changed, 29 insertions(+), 24 deletions(-) delete mode 100644 volume/dkr/examples/did_json/ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe/did.json mode change 100644 => 100755 volume/dkr/examples/get_started.sh delete mode 100644 volume/dkr/examples/keri_cesr/ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe/keri.cesr diff --git a/GETTING_STARTED.md b/GETTING_STARTED.md index ac34371..185ae72 100644 --- a/GETTING_STARTED.md +++ b/GETTING_STARTED.md @@ -128,7 +128,7 @@ Note: Replace with your actual web address and AID, convert to did:web(s) confor Be sure to execute the command in the root of your local `did-webs` repo (and in the Docker container) ``` -dkr did webs generate --name controller --did did:webs:labs.hyperledger.org:did-webs-resolver:pages:EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP --oobi http://witnesshost:5642/oobi/EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP/witness/BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha +dkr did webs generate --name controller --did did:webs:labs.hyperledger.org:did-webs-resolver:pages:EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP ``` This creates files: diff --git a/src/dkr/app/cli/commands/did/webs/generate.py b/src/dkr/app/cli/commands/did/webs/generate.py index 82a25b7..82f2986 100644 --- a/src/dkr/app/cli/commands/did/webs/generate.py +++ b/src/dkr/app/cli/commands/did/webs/generate.py @@ -32,14 +32,14 @@ parser.add_argument('--passcode', help='22 character encryption passcode for keystore (is not saved)', dest="bran", default=None) # passcode => bran parser.add_argument("--did", "-d", help="DID to generate (did:webs method)", required=True) -parser.add_argument("--oobi", "-o", help="OOBI to use for resolving the AID", required=False) +# parser.add_argument("--oobi", "-o", help="OOBI to use for resolving the AID", required=False) parser.add_argument('-da', '--da_reg', required=False, default=None, help="Name of regery to find designated aliases attestation. Default is None.") def handler(args): - gen = Generator(name=args.name, base=args.base, bran=args.bran, did=args.did, oobi=args.oobi, da_reg=args.da_reg) + gen = Generator(name=args.name, base=args.base, bran=args.bran, did=args.did, oobi=None, da_reg=args.da_reg) return [gen] class Generator(doing.DoDoer): @@ -53,7 +53,7 @@ def __init__(self, name, base, bran, did, oobi, da_reg): hbyDoer = habbing.HaberyDoer(habery=self.hby) # setup doer obl = oobiing.Oobiery(hby=self.hby) self.did = did - self.oobi = oobi + # self.oobi = oobi self.da_reg = da_reg self.toRemove = [hbyDoer] + obl.doers @@ -68,23 +68,29 @@ def generate(self, tymth, tock=0.0, **opts): domain, port, path, aid = didding.parseDIDWebs(self.did) msgs = bytearray() - if self.oobi is not None or self.oobi == "": - print(f"Using oobi {self.oobi} to get CESR event stream") - obr = basing.OobiRecord(date=helping.nowIso8601()) - obr.cid = aid - self.hby.db.oobis.pin(keys=(self.oobi,), val=obr) - - while self.hby.db.roobi.get(keys=(self.oobi,)) is None: - _ = yield tock + # if self.oobi is not None or self.oobi == "": + # print(f"Using oobi {self.oobi} to get CESR event stream") + # obr = basing.OobiRecord(date=helping.nowIso8601()) + # obr.cid = aid + # self.hby.db.oobis.pin(keys=(self.oobi,), val=obr) + + # print(f"Resolving OOBI {self.oobi}") + # roobi = self.hby.db.roobi.get(keys=(self.oobi,)) + # while roobi is None or roobi.state != oobiing.Result.resolved: + # roobi = self.hby.db.roobi.get(keys=(self.oobi,)) + # _ = yield tock + # print(f"OOBI {self.oobi} resolved {roobi}") - oobiHab = self.hby.habs[aid] - msgs = oobiHab.replyToOobi(aid=aid, role="controller", eids=None) - else: - print(f"Generating CESR event stream from local hab") - #add KEL - self.genKelCesr(aid, msgs) - #add designated aliases TELs and ACDCs - self.genCredCesr(aid, didding.DES_ALIASES_SCHEMA, msgs) + # oobiHab = self.hby.habs[aid] + # print(f"Loading hab for OOBI {self.oobi}:\n {oobiHab}") + # msgs = oobiHab.replyToOobi(aid=aid, role="controller", eids=None) + # print(f"OOBI {self.oobi} CESR event stream {msgs.decode('utf-8')}") + + print(f"Generating CESR event stream data from hab") + #add KEL + self.genKelCesr(aid, msgs) + #add designated aliases TELs and ACDCs + self.genCredCesr(aid, didding.DES_ALIASES_SCHEMA, msgs) # Create the directory (and any intermediate directories in the given path) if it doesn't already exist kc_dir_path = f"{webbing.KC_DEFAULT_DIR}/{aid}" @@ -99,7 +105,7 @@ def generate(self, tymth, tock=0.0, **opts): kcf.write(tmsg) #generate did doc - diddoc = didding.generateDIDDoc(self.hby, did=self.did, aid=aid, oobi=self.oobi, reg_name=self.da_reg) + diddoc = didding.generateDIDDoc(self.hby, did=self.did, aid=aid, oobi=None, reg_name=self.da_reg) # Create the directory (and any intermediate directories in the given path) if it doesn't already exist dd_dir_path = f"{webbing.DD_DEFAULT_DIR}/{aid}" diff --git a/volume/dkr/examples/did_json/ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe/did.json b/volume/dkr/examples/did_json/ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe/did.json deleted file mode 100644 index 277958b..0000000 --- a/volume/dkr/examples/did_json/ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe/did.json +++ /dev/null @@ -1 +0,0 @@ -{"id": "did:web:peacekeeper.github.io:did-webs-iiw37-tutorial:ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe", "verificationMethod": [{"id": "#DHr0-I-mMN7h6cLMOTRJkkfPuMd0vgQPrOk4Y3edaHjr", "type": "JsonWebKey", "controller": "did:web:peacekeeper.github.io:did-webs-iiw37-tutorial:ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe", "publicKeyJwk": {"kid": "DHr0-I-mMN7h6cLMOTRJkkfPuMd0vgQPrOk4Y3edaHjr", "kty": "OKP", "crv": "Ed25519", "x": "evT4j6Yw3uHpwsw5NEmSR8-4x3S-BA-s6Thjd51oeOs"}}], "service": [], "alsoKnownAs": ["did:web:example.com:ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe"]} \ No newline at end of file diff --git a/volume/dkr/examples/get_started.sh b/volume/dkr/examples/get_started.sh old mode 100644 new mode 100755 index c4ab1c6..b55f464 --- a/volume/dkr/examples/get_started.sh +++ b/volume/dkr/examples/get_started.sh @@ -10,5 +10,5 @@ kli incept --name controller --alias controller --file "/keripy/my-scripts/my-in curl http://witnesshost:5642/oobi/EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP/witness/BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha # generate controller did:webs for labs.hyperledger.org -dkr did webs generate --name controller --did did:webs:labs.hyperledger.org:did-webs-resolver:pages:EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP --oobi http://witnesshost:5642/oobi/EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP/witness/BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha -# dkr did webs generate --name controller --did did:webs:labs.hyperledger.org:did-webs-resolver:pages:EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP \ No newline at end of file +# dkr did webs generate --name controller --did did:webs:labs.hyperledger.org:did-webs-resolver:pages:EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP --oobi http://witnesshost:5642/oobi/EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP/witness/BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha +dkr did webs generate --name controller --did did:webs:labs.hyperledger.org:did-webs-resolver:pages:EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP \ No newline at end of file diff --git a/volume/dkr/examples/keri_cesr/ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe/keri.cesr b/volume/dkr/examples/keri_cesr/ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe/keri.cesr deleted file mode 100644 index e69de29..0000000 From b20952c9617d9848b3a1d77ff40530c9b944503d Mon Sep 17 00:00:00 2001 From: 2byrds <2byrds@gmail.com> Date: Sun, 17 Dec 2023 15:49:26 -0500 Subject: [PATCH 03/17] getting started without oobi Signed-off-by: 2byrds <2byrds@gmail.com> --- GETTING_STARTED.md | 29 ++++++++++++------- src/dkr/app/cli/commands/did/webs/generate.py | 4 +-- .../did.json | 1 + .../keri.cesr | 1 + 4 files changed, 23 insertions(+), 12 deletions(-) create mode 100644 volume/pages/EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP/did.json create mode 100644 volume/pages/EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP/keri.cesr diff --git a/GETTING_STARTED.md b/GETTING_STARTED.md index 185ae72..8f0c5a5 100644 --- a/GETTING_STARTED.md +++ b/GETTING_STARTED.md @@ -6,12 +6,14 @@ Thank you to Markus Sabadello @peacekeeper from DanubeTech who created the origi If you're running into trouble in the process below, be sure to check the section [Trouble Shooting](#trouble-shooting) below. +Let's get started! We'll use docker to setup and run in a simple environment. + ## Run Docker build ``` docker compose build ``` -## Run Docker containers for the keri witness network and `did:webs` generator and resolver +## Run Docker containers for the keri witness network and the `did:webs` generator and resolver environment ``` docker compose down @@ -24,7 +26,17 @@ docker compose up -d docker compose exec dkr /bin/bash ``` -## (Optional) You can use the KERI cli (kli) to create a unique salt (seed) for your KERI AID private keys +## Run the script or execute the commands yourself +If you would like to run the script, you can do so by running the following command: + +``` +cd examples +./get_started.sh +``` +Otherwise you can type these commands manually. +Lets go through each step. + +## (Optional) You can use the KERI-client (kli) to create a unique salt (seed) for your KERI AID private keys ``` kli salt @@ -36,7 +48,7 @@ Example response: 0AAQmsjh-C7kAJZQEzdrzwB7 ``` -Note: In our examples we will use this salt `0AAQmsjh-C7kAJZQEzdrzwB7` replace it when necessary +Note: In our examples we will use this salt `0AAQmsjh-C7kAJZQEzdrzwB7`, if you generated your own then replace it when necessary ## Provide your unique salt and configure your KERI AID @@ -75,7 +87,7 @@ http://witnesshost:5644/oobi/BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX/contro ``` ## Create your KERI AID -Now that your environment is ready, create your AID (via an inception event) with inception configuration that contains your witnesses. It is a transferable AID (meaning you can rotate the keys, witnesses, etc): +Now that you have intitalized things, create your AID (via an inception event) with inception configuration that contains your witnesses. It is a transferable AID (meaning you can rotate the keys, witnesses, etc): `config` ```json @@ -132,14 +144,11 @@ dkr did webs generate --name controller --did did:webs:labs.hyperledger.org:did- ``` This creates files: -- `did.json` under local path `./volume/dkr/did_json/` -- `keri.cesr` under local path `./volume/dkr/keri_cesr/` +- `did.json` and `keri.cesr` under local path `./volume/dkr/examples//did.json` You can access these files either from within your Docker container or on your local computer filesystem. -- `/volume/dkr/` -- `/usr/local/var/did-keri-resolver/did_json/` (local path in the Docker container) - -and extend those paths with either `did_json/` or `keri_cesr/`. +- `/volume/dkr/examples/` +- `/usr/local/var/did-keri-resolver/volume/dkr/examples/` (local path in the Docker container) ## Upload did.json and keri.cesr to your web server diff --git a/src/dkr/app/cli/commands/did/webs/generate.py b/src/dkr/app/cli/commands/did/webs/generate.py index 82f2986..3e7de51 100644 --- a/src/dkr/app/cli/commands/did/webs/generate.py +++ b/src/dkr/app/cli/commands/did/webs/generate.py @@ -93,7 +93,7 @@ def generate(self, tymth, tock=0.0, **opts): self.genCredCesr(aid, didding.DES_ALIASES_SCHEMA, msgs) # Create the directory (and any intermediate directories in the given path) if it doesn't already exist - kc_dir_path = f"{webbing.KC_DEFAULT_DIR}/{aid}" + kc_dir_path = f"{aid}" if not os.path.exists(kc_dir_path): os.makedirs(kc_dir_path) @@ -108,7 +108,7 @@ def generate(self, tymth, tock=0.0, **opts): diddoc = didding.generateDIDDoc(self.hby, did=self.did, aid=aid, oobi=None, reg_name=self.da_reg) # Create the directory (and any intermediate directories in the given path) if it doesn't already exist - dd_dir_path = f"{webbing.DD_DEFAULT_DIR}/{aid}" + dd_dir_path = f"{aid}" if not os.path.exists(dd_dir_path): os.makedirs(dd_dir_path) diff --git a/volume/pages/EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP/did.json b/volume/pages/EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP/did.json new file mode 100644 index 0000000..19112a9 --- /dev/null +++ b/volume/pages/EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP/did.json @@ -0,0 +1 @@ +{"id": "did:web:labs.hyperledger.org:did-webs-resolver:pages:EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP", "verificationMethod": [{"id": "#DHr0-I-mMN7h6cLMOTRJkkfPuMd0vgQPrOk4Y3edaHjr", "type": "JsonWebKey", "controller": "did:web:labs.hyperledger.org:did-webs-resolver:pages:EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP", "publicKeyJwk": {"kid": "DHr0-I-mMN7h6cLMOTRJkkfPuMd0vgQPrOk4Y3edaHjr", "kty": "OKP", "crv": "Ed25519", "x": "evT4j6Yw3uHpwsw5NEmSR8-4x3S-BA-s6Thjd51oeOs"}}], "service": [{"id": "#BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha/witness", "type": "witness", "serviceEndpoint": {"http": "http://witnesshost:5642/", "tcp": "tcp://witnesshost:5632/"}}, {"id": "#BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha/witness", "type": "witness", "serviceEndpoint": {"http": "http://witnesshost:5642/", "tcp": "tcp://witnesshost:5632/"}}, {"id": "#BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha/witness", "type": "witness", "serviceEndpoint": {"http": "http://witnesshost:5642/", "tcp": "tcp://witnesshost:5632/"}}], "alsoKnownAs": []} \ No newline at end of file diff --git a/volume/pages/EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP/keri.cesr b/volume/pages/EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP/keri.cesr new file mode 100644 index 0000000..ccf9f7a --- /dev/null +++ b/volume/pages/EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP/keri.cesr @@ -0,0 +1 @@ +{"v":"KERI10JSON0001b7_","t":"icp","d":"EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP","i":"EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP","s":"0","kt":"1","k":["DHr0-I-mMN7h6cLMOTRJkkfPuMd0vgQPrOk4Y3edaHjr"],"nt":"1","n":["ELa775aLyane1vdiJEuexP8zrueiIoG995pZPGJiBzGX"],"bt":"3","b":["BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha","BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM","BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX"],"c":[],"a":[]}-VBq-AABAABv33lz0MENsIaM2J1hsbl_8awkJlVT7M1Cnzix0JQSEEwhfSsOt5Wqvuw27wUUKZLCScKoT01FV4WfowFrh_MN-BADAAC_SiZWJFOCuIB_py4gqaMFQtTVWtFCpPfP2LgyqqUS2naTh0nZNlH6MPHSbQNRoImkHnMFrUiBr5ZtwvQ-tNwIABBazaCrt7WQD5Dj1U3KqlZhgOPh7-ca2S0BnRRSEHxW5yoECaC04nyTxYh_wU9TH2WLr14hP-mLHHJDM-wM2esOACA2lyZPmqv2mefIL3orZNm8vb7pyLO5R4zOhHqqXkS1utJrKndiNd4Yu4c6xJnVkc-l6DABB9qe-otLGCkoWDEI-EAB0AAAAAAAAAAAAAAAAAAAAAAA1AAG2023-12-17T20c35c38d614937p00c00 \ No newline at end of file From 390aeecb3a1b4ed7f64d8dc1f534a7e7d777c595 Mon Sep 17 00:00:00 2001 From: 2byrds <2byrds@gmail.com> Date: Sun, 17 Dec 2023 15:51:53 -0500 Subject: [PATCH 04/17] readable formatting Signed-off-by: 2byrds <2byrds@gmail.com> --- .../did.json | 44 ++++++++++++++++++- .../keri.cesr | 24 +++++++++- 2 files changed, 66 insertions(+), 2 deletions(-) diff --git a/volume/pages/EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP/did.json b/volume/pages/EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP/did.json index 19112a9..e5a5704 100644 --- a/volume/pages/EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP/did.json +++ b/volume/pages/EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP/did.json @@ -1 +1,43 @@ -{"id": "did:web:labs.hyperledger.org:did-webs-resolver:pages:EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP", "verificationMethod": [{"id": "#DHr0-I-mMN7h6cLMOTRJkkfPuMd0vgQPrOk4Y3edaHjr", "type": "JsonWebKey", "controller": "did:web:labs.hyperledger.org:did-webs-resolver:pages:EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP", "publicKeyJwk": {"kid": "DHr0-I-mMN7h6cLMOTRJkkfPuMd0vgQPrOk4Y3edaHjr", "kty": "OKP", "crv": "Ed25519", "x": "evT4j6Yw3uHpwsw5NEmSR8-4x3S-BA-s6Thjd51oeOs"}}], "service": [{"id": "#BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha/witness", "type": "witness", "serviceEndpoint": {"http": "http://witnesshost:5642/", "tcp": "tcp://witnesshost:5632/"}}, {"id": "#BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha/witness", "type": "witness", "serviceEndpoint": {"http": "http://witnesshost:5642/", "tcp": "tcp://witnesshost:5632/"}}, {"id": "#BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha/witness", "type": "witness", "serviceEndpoint": {"http": "http://witnesshost:5642/", "tcp": "tcp://witnesshost:5632/"}}], "alsoKnownAs": []} \ No newline at end of file +{ + "id": "did:web:labs.hyperledger.org:did-webs-resolver:pages:EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP", + "verificationMethod": [ + { + "id": "#DHr0-I-mMN7h6cLMOTRJkkfPuMd0vgQPrOk4Y3edaHjr", + "type": "JsonWebKey", + "controller": "did:web:labs.hyperledger.org:did-webs-resolver:pages:EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP", + "publicKeyJwk": { + "kid": "DHr0-I-mMN7h6cLMOTRJkkfPuMd0vgQPrOk4Y3edaHjr", + "kty": "OKP", + "crv": "Ed25519", + "x": "evT4j6Yw3uHpwsw5NEmSR8-4x3S-BA-s6Thjd51oeOs" + } + } + ], + "service": [ + { + "id": "#BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha/witness", + "type": "witness", + "serviceEndpoint": { + "http": "http://witnesshost:5642/", + "tcp": "tcp://witnesshost:5632/" + } + }, + { + "id": "#BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha/witness", + "type": "witness", + "serviceEndpoint": { + "http": "http://witnesshost:5642/", + "tcp": "tcp://witnesshost:5632/" + } + }, + { + "id": "#BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha/witness", + "type": "witness", + "serviceEndpoint": { + "http": "http://witnesshost:5642/", + "tcp": "tcp://witnesshost:5632/" + } + } + ], + "alsoKnownAs": [] +} \ No newline at end of file diff --git a/volume/pages/EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP/keri.cesr b/volume/pages/EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP/keri.cesr index ccf9f7a..b1e91bc 100644 --- a/volume/pages/EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP/keri.cesr +++ b/volume/pages/EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP/keri.cesr @@ -1 +1,23 @@ -{"v":"KERI10JSON0001b7_","t":"icp","d":"EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP","i":"EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP","s":"0","kt":"1","k":["DHr0-I-mMN7h6cLMOTRJkkfPuMd0vgQPrOk4Y3edaHjr"],"nt":"1","n":["ELa775aLyane1vdiJEuexP8zrueiIoG995pZPGJiBzGX"],"bt":"3","b":["BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha","BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM","BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX"],"c":[],"a":[]}-VBq-AABAABv33lz0MENsIaM2J1hsbl_8awkJlVT7M1Cnzix0JQSEEwhfSsOt5Wqvuw27wUUKZLCScKoT01FV4WfowFrh_MN-BADAAC_SiZWJFOCuIB_py4gqaMFQtTVWtFCpPfP2LgyqqUS2naTh0nZNlH6MPHSbQNRoImkHnMFrUiBr5ZtwvQ-tNwIABBazaCrt7WQD5Dj1U3KqlZhgOPh7-ca2S0BnRRSEHxW5yoECaC04nyTxYh_wU9TH2WLr14hP-mLHHJDM-wM2esOACA2lyZPmqv2mefIL3orZNm8vb7pyLO5R4zOhHqqXkS1utJrKndiNd4Yu4c6xJnVkc-l6DABB9qe-otLGCkoWDEI-EAB0AAAAAAAAAAAAAAAAAAAAAAA1AAG2023-12-17T20c35c38d614937p00c00 \ No newline at end of file +{ + "v": "KERI10JSON0001b7_", + "t": "icp", + "d": "EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP", + "i": "EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP", + "s": "0", + "kt": "1", + "k": [ + "DHr0-I-mMN7h6cLMOTRJkkfPuMd0vgQPrOk4Y3edaHjr" + ], + "nt": "1", + "n": [ + "ELa775aLyane1vdiJEuexP8zrueiIoG995pZPGJiBzGX" + ], + "bt": "3", + "b": [ + "BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha", + "BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM", + "BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX" + ], + "c": [], + "a": [] +}-VBq-AABAABv33lz0MENsIaM2J1hsbl_8awkJlVT7M1Cnzix0JQSEEwhfSsOt5Wqvuw27wUUKZLCScKoT01FV4WfowFrh_MN-BADAAC_SiZWJFOCuIB_py4gqaMFQtTVWtFCpPfP2LgyqqUS2naTh0nZNlH6MPHSbQNRoImkHnMFrUiBr5ZtwvQ-tNwIABBazaCrt7WQD5Dj1U3KqlZhgOPh7-ca2S0BnRRSEHxW5yoECaC04nyTxYh_wU9TH2WLr14hP-mLHHJDM-wM2esOACA2lyZPmqv2mefIL3orZNm8vb7pyLO5R4zOhHqqXkS1utJrKndiNd4Yu4c6xJnVkc-l6DABB9qe-otLGCkoWDEI-EAB0AAAAAAAAAAAAAAAAAAAAAAA1AAG2023-12-17T20c35c38d614937p00c00 \ No newline at end of file From 9b2511b0ed793af26ec41a33974b7d691bda4356 Mon Sep 17 00:00:00 2001 From: 2byrds <2byrds@gmail.com> Date: Thu, 21 Dec 2023 16:38:58 -0500 Subject: [PATCH 05/17] improved integration test for generate, need to work service/resolve Signed-off-by: 2byrds <2byrds@gmail.com> --- volume/dkr/examples/get_started_create_id.sh | 16 ++++++++++++++++ volume/dkr/examples/get_started_webs_gen.sh | 11 +++++++++++ volume/dkr/examples/get_started_webs_resolve.sh | 11 +++++++++++ volume/dkr/examples/get_started_webs_serve.sh | 11 +++++++++++ volume/dkr/examples/my-scripts/incept-wits.json | 13 +++++++++++++ volume/dkr/examples/my-scripts/incept.json | 9 +++++++++ .../keri/cf/{config.json => config-docker.json} | 0 .../keri/cf/{local.json => config-local.json} | 0 8 files changed, 71 insertions(+) create mode 100755 volume/dkr/examples/get_started_create_id.sh create mode 100755 volume/dkr/examples/get_started_webs_gen.sh create mode 100755 volume/dkr/examples/get_started_webs_resolve.sh create mode 100755 volume/dkr/examples/get_started_webs_serve.sh create mode 100644 volume/dkr/examples/my-scripts/incept-wits.json create mode 100644 volume/dkr/examples/my-scripts/incept.json rename volume/dkr/examples/my-scripts/keri/cf/{config.json => config-docker.json} (100%) rename volume/dkr/examples/my-scripts/keri/cf/{local.json => config-local.json} (100%) diff --git a/volume/dkr/examples/get_started_create_id.sh b/volume/dkr/examples/get_started_create_id.sh new file mode 100755 index 0000000..6682878 --- /dev/null +++ b/volume/dkr/examples/get_started_create_id.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +#controller +ctrlName=$1 +#/keripy/my-scripts +configDir=$2 +#my-config +configFile=$3 +#my-incept.json +inceptFile=$4 + +# init environment for controller AID +kli init --name "${ctrlName}" --salt 0AAQmsjh-C7kAJZQEzdrzwB7 --nopasscode --config-dir "${configDir}" --config-file "${configFile}" + +# inception for controller AID +kli incept --name "${ctrlName}" --alias "${ctrlName}" --file "${configDir}/${inceptFile}" \ No newline at end of file diff --git a/volume/dkr/examples/get_started_webs_gen.sh b/volume/dkr/examples/get_started_webs_gen.sh new file mode 100755 index 0000000..4797910 --- /dev/null +++ b/volume/dkr/examples/get_started_webs_gen.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +# controller +ctrlName=$1 +# host path +hostPath=$2 +# aid +aid=$3 + +# generate controller did:webs for EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP at labs.hyperledger.org +dkr did webs generate --name "${ctrlName}" --did "did:webs:${hostPath}:${aid}" \ No newline at end of file diff --git a/volume/dkr/examples/get_started_webs_resolve.sh b/volume/dkr/examples/get_started_webs_resolve.sh new file mode 100755 index 0000000..4797910 --- /dev/null +++ b/volume/dkr/examples/get_started_webs_resolve.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +# controller +ctrlName=$1 +# host path +hostPath=$2 +# aid +aid=$3 + +# generate controller did:webs for EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP at labs.hyperledger.org +dkr did webs generate --name "${ctrlName}" --did "did:webs:${hostPath}:${aid}" \ No newline at end of file diff --git a/volume/dkr/examples/get_started_webs_serve.sh b/volume/dkr/examples/get_started_webs_serve.sh new file mode 100755 index 0000000..1bed2ed --- /dev/null +++ b/volume/dkr/examples/get_started_webs_serve.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +#controller +ctrlName=$1 +#/keripy/my-scripts +configDir=$2 +#my-config +configFile=$3 + +# serve controller did:webs for EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP at 127.0.0.1: +dkr did webs service --name "${ctrlName}" --config-dir "${configDir}" --config-file "${configFile}" --http 7676 \ No newline at end of file diff --git a/volume/dkr/examples/my-scripts/incept-wits.json b/volume/dkr/examples/my-scripts/incept-wits.json new file mode 100644 index 0000000..850aca0 --- /dev/null +++ b/volume/dkr/examples/my-scripts/incept-wits.json @@ -0,0 +1,13 @@ +{ + "transferable": true, + "wits": [ + "BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha", + "BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM", + "BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX" + ], + "toad": 3, + "icount": 1, + "ncount": 1, + "isith": "1", + "nsith": "1" +} diff --git a/volume/dkr/examples/my-scripts/incept.json b/volume/dkr/examples/my-scripts/incept.json new file mode 100644 index 0000000..faec18d --- /dev/null +++ b/volume/dkr/examples/my-scripts/incept.json @@ -0,0 +1,9 @@ +{ + "transferable": true, + "wits": [], + "toad": 0, + "icount": 1, + "ncount": 1, + "isith": "1", + "nsith": "1" +} \ No newline at end of file diff --git a/volume/dkr/examples/my-scripts/keri/cf/config.json b/volume/dkr/examples/my-scripts/keri/cf/config-docker.json similarity index 100% rename from volume/dkr/examples/my-scripts/keri/cf/config.json rename to volume/dkr/examples/my-scripts/keri/cf/config-docker.json diff --git a/volume/dkr/examples/my-scripts/keri/cf/local.json b/volume/dkr/examples/my-scripts/keri/cf/config-local.json similarity index 100% rename from volume/dkr/examples/my-scripts/keri/cf/local.json rename to volume/dkr/examples/my-scripts/keri/cf/config-local.json From 9f410b86f0aef2ad35dcc3bcde9f80b90e8ebdf9 Mon Sep 17 00:00:00 2001 From: 2byrds <2byrds@gmail.com> Date: Thu, 21 Dec 2023 16:39:45 -0500 Subject: [PATCH 06/17] improved integration test for generate, need to work service/resolve Signed-off-by: 2byrds <2byrds@gmail.com> --- GETTING_STARTED.md | 3 +- docker-compose.yml | 2 - integration/app/integration.sh | 204 +++++++++++------- volume/dkr/examples/get_started.sh | 14 -- .../dkr/examples/my-scripts/incept-local.json | 13 -- volume/dkr/examples/my-scripts/my-incept.json | 9 - 6 files changed, 123 insertions(+), 122 deletions(-) delete mode 100755 volume/dkr/examples/get_started.sh delete mode 100644 volume/dkr/examples/my-scripts/incept-local.json delete mode 100644 volume/dkr/examples/my-scripts/my-incept.json diff --git a/GETTING_STARTED.md b/GETTING_STARTED.md index 8f0c5a5..1b09638 100644 --- a/GETTING_STARTED.md +++ b/GETTING_STARTED.md @@ -31,7 +31,8 @@ If you would like to run the script, you can do so by running the following comm ``` cd examples -./get_started.sh +./get_started_keri.sh "controller" "/keripy/my-scripts" "config-docker" "incept-wits.json" +./get_started_webs.sh "controller" "labs.hyperledger.org:did-webs-resolver:pages" "EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP" ``` Otherwise you can type these commands manually. Lets go through each step. diff --git a/docker-compose.yml b/docker-compose.yml index e6a0952..4ed20f4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -24,8 +24,6 @@ services: tty: true volumes: - ./volume/dkr/my-scripts/:/keripy/my-scripts/ - - ./volume/dkr/did_json/:/usr/local/var/did-keri-resolver/did_json/ - - ./volume/dkr/keri_cesr/:/usr/local/var/did-keri-resolver/keri_cesr/ - ./volume/dkr/examples/:/usr/local/var/did-keri-resolver/examples/ - ./volume/pages/:/pages/ diff --git a/integration/app/integration.sh b/integration/app/integration.sh index a15a17f..94998e5 100755 --- a/integration/app/integration.sh +++ b/integration/app/integration.sh @@ -6,55 +6,78 @@ # #print commands -#set -x +set -x #save this current directory, this is where the integration_clienting file also is ORIG_CUR_DIR=$( pwd ) -KERI_PRIMARY_STORAGE="/usr/local/var/keri" -KERI_FALLBACK_STORAGE="${HOME}/.keri" - -KERI_DEV_BRANCH="development" -# KERI_DEV_TAG="c3a6fc455b5fac194aa9c264e48ea2c52328d4c5" +CTRL_NAME="controller" + +KERI_BRANCH="main" +# KERI_TAG="c3a6fc455b5fac194aa9c264e48ea2c52328d4c5" +KERI_PRIMARY_STORAGE="/usr/local/var/keri/" +KERI_FALLBACK_STORAGE="${HOME}/.keri/" +db_files=() +db_names=("$CTRL_NAME" wan wes wil wit wub wyz) +for db_name in "${db_names[@]}"; do + path="${KERI_PRIMARY_STORAGE}*/${db_name}*" + db_files+=( $path ) + path="${KERI_FALLBACK_STORAGE}*/${db_name}*" + db_files+=( $path ) +done prompt="y" -function intro() { - echo "Welcome to the integration test setup/run/teardown script" - read -p "Enable prompts?, [y]: " enablePrompts - prompt=${enablePrompts:-"y"} - if [ "${prompt}" != "n" ]; then - echo "Prompts enabled" + +function cleanKeri() { + echo "Cleaning KERI data" + #clean up any old KERI data + default_clean_keri="y" + if [ "${prompt}" == "y" ]; then + read -p "Clean keri dbs ${db_files[*]} (y/n)? [${default_clean_keri}]: " cleanKeriInput + fi + clean_keri_data=${cleanKeriInput:-$default_clean_keri} + if [ "${clean_keri_data}" == "n" ]; then + echo "Skipping clean KERI data" else - echo "Skipping prompts, using defaults" + echo "Running clean KERI data" + for db_file in "${db_files[@]}"; do rm -R "$db_file";done + echo "Cleaned KERI data" fi } function genDidWebs() { + default_gen_webs="y" if [ "${prompt}" == "y" ]; then - read -p "Generate did:webs (y/n)? [n]: " runGenDid + default_gen_webs="n" + read -p "Generate did:webs (y/n)? [${default_gen_webs}]: " runGenDid fi - runGenDidWebs=${runGenDid:-"y"} - if [ "${runGenDidWebs}" == "n" ]; then + run_gen_webs=${runGenDid:-$default_gen_webs} + if [ "${run_gen_webs}" == "n" ]; then echo "Skipping generate did:webs did document" else - echo "Generating did:webs DID Document" - # if [ "${prompt}" == "y" ]; then - # read -p "Name the identity [searcher]: " runGenDid - # fi - dkr did webs generate --name=wan --did=did:webs:127.0.0.1%3a7676:BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha --oobi http://127.0.0.1:5642/oobi/BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha/controller + echo "Generating did:webs DID Document and KERI event stream" + start_webs="${ORIG_CUR_DIR}/volume/dkr/examples/get_started_webs.sh" + if [ -f "${start_webs}" ]; then + echo "Found get started script to generate did:webs" + source "${start_webs}" "${CTRL_NAME}" "labs.hyperledger.org:did-webs-resolver:pages" "EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP" + sleep 3 + echo "Completed loading generating did:webs" + else + echo "Couldn't find get started did:webs script" + fi fi } function getKeripyDir() { # Check if the environment variable is set if [ -z "$KERIPY_DIR" ]; then - default_value="../keripy" # Prompt the user for input with a default value + default_keri_dir="../keripy" if [ "${prompt}" == "y" ]; then - read -p "Set keripy dir [${default_value}]: " keriDirInput + read -p "Set keripy dir [${default_keri_dir}]: " keriDirInput fi # Set the value to the user input or the default value - KERIPY_DIR=${keriDirInput:-$default_value} + KERIPY_DIR=${keriDirInput:-$default_keri_dir} fi # Use the value of the environment variable echo "$KERIPY_DIR" @@ -74,34 +97,38 @@ function installPythonUpdates() { fi } -function loadKeriData() { +function intro() { + echo "Welcome to the integration test setup/run/teardown script" + read -p "Enable prompts?, [y]: " enablePrompts + prompt=${enablePrompts:-"y"} + if [ "${prompt}" != "n" ]; then + echo "Prompts enabled" + else + echo "Skipping prompts, using defaults" + fi +} + +function createKeriId() { cd ${ORIG_CUR_DIR} || exit kloadPid=-1 - keriDir=$(getKeripyDir) - echo "Keripy dir set to: ${keriDir}" + default_kload="y" if [ "${prompt}" == "y" ]; then - read -p "Run load keri data (y/n)? [y]: " runKload + default_kload="n" + read -p "Run create keri id (y/n)? [${default_kload}]: " run_kload_input fi - runLoadKeriData=${runKload:-"n"} - if [ "${runLoadKeriData}" == "n" ]; then + create_keri_id=${run_kload_input:-$default_kload} + if [ "${create_keri_id}" == "n" ]; then echo "Skipping load KERI data" else echo "Running load KERI data" - scriptsDir="${keriDir}/scripts" - if [ -d "${scriptsDir}" ]; then - echo "Found keri scripts dir" - demoScriptsDir="${scriptsDir}/demo" - if [ -d "${demoScriptsDir}" ]; then - echo "Found keri demo scripts dir" - cd ${demoScriptsDir} || exit - source demo-script.sh - source ./basic/query-for-anchor.sh - echo "Completed loading KERI data" - else - echo "Couldn't find keri demo scripts dir" - fi + create_aid_script="${ORIG_CUR_DIR}/volume/dkr/examples/get_started_create_id.sh" + if [ -f "${create_aid_script}" ]; then + echo "Found get started keri script" + source "${create_aid_script}" "${CTRL_NAME}" "${ORIG_CUR_DIR}/volume/dkr/examples/my-scripts" "config-local" "incept-wits.json" + sleep 3 + echo "Completed creating KERI identity" else - echo "Couldn't find keri scripts dir" + echo "Couldn't find get started keri script" fi fi cd "${ORIG_CUR_DIR}" || exit @@ -109,18 +136,27 @@ function loadKeriData() { } function resolveDIDAndKeriEvents() { + default_res_webs="y" if [ "${prompt}" == "y" ]; then - read -p "Resolve did:webs and keri events (y/n)? [n]: " resolveKeriEvents + default_res_webs="n" + read -p "Resolve did:webs and keri events (y/n)? [${default_res_webs}]: " res_webs_input fi - resolveDidsAndKeriEvents=${resolveKeriEvents:-"y"} - if [ "${resolveDidsAndKeriEvents}" == "n" ]; then + res_webs=${res_webs_input:-$default_res_webs} + if [ "${res_webs}" == "n" ]; then echo "Skipping resolving did:webs DID Document and Keri Events" else echo "Resolving did:webs DID Document and Keri Events" - # if [ "${prompt}" == "y" ]; then - # read -p "Name the identity [searcher]: " runGenDid - # fi + res_webs_script="${ORIG_CUR_DIR}/volume/dkr/examples/get_started_webs_resolve.sh" + if [ -f "${res_webs_script}" ]; then + echo "Found get started keri script" + source "${res_webs_script}" "${CTRL_NAME}" "${ORIG_CUR_DIR}/volume/dkr/examples/my-scripts" "config-local" + sleep 3 + echo "Completed creating KERI identity" + else + echo "Couldn't find get started keri script" + fi dkr did webs resolve --name wan --did did:webs:127.0.0.1%3a7676:BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha + sleep 3 fi } @@ -129,18 +165,21 @@ function runKeri() { witPid=-1 keriDir=$(getKeripyDir) echo "Keripy dir set to: ${keriDir}" + + default_wit="y" if [ "${prompt}" == "y" ]; then - read -p "Run witness network (y/n)? [y]: " runWitNet + default_wit="n" + read -p "Run witness network (y/n)? [${default_wit}]: " runWitNet fi - runWit=${runWitNet:-"y"} + runWit=${runWitNet:-$default_wit} if [ "${runWit}" == "y" ]; then if [ -d "${keriDir}" ]; then #run a clean witness network echo "Launching a clean witness network" cd "${keriDir}" || exit - updateFromGit ${KERI_DEV_BRANCH} + updateFromGit ${KERI_BRANCH} installPythonUpdates "keri" - rm -rf "${KERI_PRIMARY_STORAGE:?}/*";rm -Rf "${KERI_FALLBACK_STORAGE:?}/*";kli witness demo & + kli witness demo & witPid=$! sleep 5 echo "Clean witness network launched" @@ -155,32 +194,36 @@ function runKeri() { } function serveDidAndKeriEvents() { + default_serve_webs="y" if [ "${prompt}" == "y" ]; then - read -p "Serve dids and keri events (y/n)? [n]: " serveKeriEvents + default_serve_webs="n" + read -p "Serve dids and keri events (y/n)? [${default_serve_webs}]: " serveKeriEvents fi - serveDidsAndKeriEvents=${serveKeriEvents:-"y"} - if [ "${serveDidsAndKeriEvents}" == "n" ]; then - echo "Skipping serving did:webs did document and keri events" + serve_webs=${serveKeriEvents:-$default_serve_webs} + if [ "${serve_webs}" == "n" ]; then + echo "Skipping serving did:webs DID Document and Keri Events" else - echo "Serving did:webs DID Document and Keri Events" - # if [ "${prompt}" == "y" ]; then - # read -p "Name the identity [searcher]: " runGenDid - # fi - dkr did webs service --config-dir=./scripts --config-file=dkr.json & + srv_webs_script="${ORIG_CUR_DIR}/volume/dkr/examples/get_started_webs_resolve.sh" + if [ -f "${srv_webs_script}" ]; then + echo "Found get started serve script" + source "${srv_webs_script}" "${CTRL_NAME}" "${ORIG_CUR_DIR}/volume/dkr/examples/my-scripts" "config-local" servePid=$! - sleep 5 - echo "Serving dids and keri events" + sleep 3 + echo "Serving did:webs and keri events" + else + echo "Couldn't find get started serve script" + fi fi } function updateFromGit() { branch=$1 commit=$2 - + default_up_git="n" if [ "${prompt}" == "y" ]; then - read -p "Update git repo ${branch} ${commit}?, [n]: " upGitInput + read -p "Update git repo ${branch} ${commit}?, [${default_up_git}]: " upGitInput fi - update=${upGitInput:-"n"} + update=${upGitInput:-$default_up_git} if [ "${update}" == "y" ]; then echo "Updating git branch ${branch} ${commit}" fetch=$(git fetch) @@ -199,33 +242,25 @@ function updateFromGit() { fi } -runInt="test_salty" -while [ "${runInt}" != "n" ] +run_main_loop="y" +while [ "${run_main_loop}" != "n" ] do intro echo "Setting up..." - runKeri + cleanKeri - sleep 3 - - loadKeriData + runKeri - sleep 3 + createKeriId genDidWebs - sleep 3 - serveDidAndKeriEvents - sleep 3 - resolveDIDAndKeriEvents - sleep 3 - # runMultisig # echo "" @@ -245,8 +280,11 @@ do # tear down the witness network kill $witPid >/dev/null 2>&1 - read -p "Run again [n]?: " runAgain - runInt=${runAgain:-"n"} + default_run_again="n" + if [ "${prompt}" == "y" ]; then + read -p "Run again [${default_run_again}]?: " run_main_again + fi + run_main_loop=${run_main_again:-$default_run_again} done echo "Done" \ No newline at end of file diff --git a/volume/dkr/examples/get_started.sh b/volume/dkr/examples/get_started.sh deleted file mode 100755 index b55f464..0000000 --- a/volume/dkr/examples/get_started.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -# init environment for controller AID -kli init --name controller --salt 0AAQmsjh-C7kAJZQEzdrzwB7 --nopasscode --config-dir "/keripy/my-scripts" --config-file my-config - -# inception for controller AID -kli incept --name controller --alias controller --file "/keripy/my-scripts/my-incept.json" - -# check witness oobi for our AID -curl http://witnesshost:5642/oobi/EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP/witness/BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha - -# generate controller did:webs for labs.hyperledger.org -# dkr did webs generate --name controller --did did:webs:labs.hyperledger.org:did-webs-resolver:pages:EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP --oobi http://witnesshost:5642/oobi/EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP/witness/BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha -dkr did webs generate --name controller --did did:webs:labs.hyperledger.org:did-webs-resolver:pages:EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP \ No newline at end of file diff --git a/volume/dkr/examples/my-scripts/incept-local.json b/volume/dkr/examples/my-scripts/incept-local.json deleted file mode 100644 index 850aca0..0000000 --- a/volume/dkr/examples/my-scripts/incept-local.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "transferable": true, - "wits": [ - "BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha", - "BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM", - "BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX" - ], - "toad": 3, - "icount": 1, - "ncount": 1, - "isith": "1", - "nsith": "1" -} diff --git a/volume/dkr/examples/my-scripts/my-incept.json b/volume/dkr/examples/my-scripts/my-incept.json deleted file mode 100644 index faec18d..0000000 --- a/volume/dkr/examples/my-scripts/my-incept.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "transferable": true, - "wits": [], - "toad": 0, - "icount": 1, - "ncount": 1, - "isith": "1", - "nsith": "1" -} \ No newline at end of file From fe7c9091d8256fe222e5af81394605141865bcc5 Mon Sep 17 00:00:00 2001 From: 2byrds <2byrds@gmail.com> Date: Fri, 22 Dec 2023 13:59:28 -0500 Subject: [PATCH 07/17] fixed integration serving and resolving Signed-off-by: 2byrds <2byrds@gmail.com> --- data/did.json | 3 -- integration/app/integration.sh | 40 ++++++++++--------- scripts/keri/cf/dkr.json | 15 ------- src/dkr/app/cli/commands/did/webs/resolve.py | 10 ++--- src/dkr/app/cli/dkr.py | 1 + src/dkr/core/webbing.py | 20 ++++++---- .../dkr/examples/get_started_webs_resolve.sh | 2 +- volume/dkr/examples/get_started_webs_serve.sh | 6 ++- .../my-scripts/keri/cf/config-local.json | 4 +- 9 files changed, 49 insertions(+), 52 deletions(-) delete mode 100644 data/did.json delete mode 100755 scripts/keri/cf/dkr.json diff --git a/data/did.json b/data/did.json deleted file mode 100644 index 0f2b3c0..0000000 --- a/data/did.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "did": "did:keri:EJPiEYcCDjg6PdtffDzGB579qsQA2enwfx29EdGIU3Vj:http://127.0.0.1:5643/oobi/EJPiEYcCDjg6PdtffDzGB579qsQA2enwfx29EdGIU3Vj/witness/BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM" -} diff --git a/integration/app/integration.sh b/integration/app/integration.sh index 94998e5..b6f54c2 100755 --- a/integration/app/integration.sh +++ b/integration/app/integration.sh @@ -4,21 +4,24 @@ # Run this script from the base resolver directory, like # did-webs-resolver% ./integration/app/integration.sh # +# If there is an error you can search for running services (on mac) with +# sudo lsof -i -P -n | grep LISTEN | grep #print commands -set -x +# set -x #save this current directory, this is where the integration_clienting file also is ORIG_CUR_DIR=$( pwd ) -CTRL_NAME="controller" +controller="controller" +host="127.0.0.1" KERI_BRANCH="main" # KERI_TAG="c3a6fc455b5fac194aa9c264e48ea2c52328d4c5" KERI_PRIMARY_STORAGE="/usr/local/var/keri/" KERI_FALLBACK_STORAGE="${HOME}/.keri/" db_files=() -db_names=("$CTRL_NAME" wan wes wil wit wub wyz) +db_names=("$controller" wan wes wil wit wub wyz) for db_name in "${db_names[@]}"; do path="${KERI_PRIMARY_STORAGE}*/${db_name}*" db_files+=( $path ) @@ -56,10 +59,10 @@ function genDidWebs() { echo "Skipping generate did:webs did document" else echo "Generating did:webs DID Document and KERI event stream" - start_webs="${ORIG_CUR_DIR}/volume/dkr/examples/get_started_webs.sh" - if [ -f "${start_webs}" ]; then + start_webs_gen="${ORIG_CUR_DIR}/volume/dkr/examples/get_started_webs_gen.sh" + if [ -f "${start_webs_gen}" ]; then echo "Found get started script to generate did:webs" - source "${start_webs}" "${CTRL_NAME}" "labs.hyperledger.org:did-webs-resolver:pages" "EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP" + source "${start_webs_gen}" "${controller}" "${host}%3a7676" "EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP" sleep 3 echo "Completed loading generating did:webs" else @@ -118,13 +121,13 @@ function createKeriId() { fi create_keri_id=${run_kload_input:-$default_kload} if [ "${create_keri_id}" == "n" ]; then - echo "Skipping load KERI data" + echo "Skipping create KERI id" else - echo "Running load KERI data" + echo "Running create KERI id" create_aid_script="${ORIG_CUR_DIR}/volume/dkr/examples/get_started_create_id.sh" if [ -f "${create_aid_script}" ]; then - echo "Found get started keri script" - source "${create_aid_script}" "${CTRL_NAME}" "${ORIG_CUR_DIR}/volume/dkr/examples/my-scripts" "config-local" "incept-wits.json" + echo "Found get started create id script" + source "${create_aid_script}" "${controller}" "${ORIG_CUR_DIR}/volume/dkr/examples/my-scripts" "config-local" "incept-wits.json" sleep 3 echo "Completed creating KERI identity" else @@ -148,15 +151,13 @@ function resolveDIDAndKeriEvents() { echo "Resolving did:webs DID Document and Keri Events" res_webs_script="${ORIG_CUR_DIR}/volume/dkr/examples/get_started_webs_resolve.sh" if [ -f "${res_webs_script}" ]; then - echo "Found get started keri script" - source "${res_webs_script}" "${CTRL_NAME}" "${ORIG_CUR_DIR}/volume/dkr/examples/my-scripts" "config-local" + echo "Found get started resolve script" + source "${res_webs_script}" "${controller}" "${host}%3a7676" "EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP" sleep 3 echo "Completed creating KERI identity" else echo "Couldn't find get started keri script" fi - dkr did webs resolve --name wan --did did:webs:127.0.0.1%3a7676:BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha - sleep 3 fi } @@ -203,13 +204,14 @@ function serveDidAndKeriEvents() { if [ "${serve_webs}" == "n" ]; then echo "Skipping serving did:webs DID Document and Keri Events" else - srv_webs_script="${ORIG_CUR_DIR}/volume/dkr/examples/get_started_webs_resolve.sh" + srv_webs_script="${ORIG_CUR_DIR}/volume/dkr/examples/get_started_webs_serve.sh" if [ -f "${srv_webs_script}" ]; then echo "Found get started serve script" - source "${srv_webs_script}" "${CTRL_NAME}" "${ORIG_CUR_DIR}/volume/dkr/examples/my-scripts" "config-local" - servePid=$! - sleep 3 - echo "Serving did:webs and keri events" + source "${srv_webs_script}" "${controller}" "${ORIG_CUR_DIR}/volume/dkr/examples/my-scripts" "config-local" + servePid=$! + echo "Serving did:webs and keri events @pid ${servePid}" + echo "DID doc served at http://${host}:7676/EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP/did.json" + echo "KERI CESR at http://${host}:7676/EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP/keri.cesr" else echo "Couldn't find get started serve script" fi diff --git a/scripts/keri/cf/dkr.json b/scripts/keri/cf/dkr.json deleted file mode 100755 index 54c417a..0000000 --- a/scripts/keri/cf/dkr.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "dt": "2022-01-20T12:57:59.823350+00:00", - "did:web": { - "gleif/root": "EDP1vHcw_wc4M__Fj53-cJaBnZZASd-aMTaSyWEQ-PC2", - "gleif/external": "EINmHd5g7iV-UldkkkKyBIH052bIyxZNBn9pq-zNrYoS", - "gleif/internal": "EFcrtYzHx11TElxDmEDx355zm7nJhbmdcIluw7UMbUIL" - }, - "keri.cesr.dir": "./keri_cesr", - "did.json.dir": "./did_json", - "iurls": [ - "http://127.0.0.1:5642/oobi/BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha/controller", - "http://127.0.0.1:5643/oobi/BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM/controller", - "http://127.0.0.1:5644/oobi/BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX/controller" - ] -} \ No newline at end of file diff --git a/src/dkr/app/cli/commands/did/webs/resolve.py b/src/dkr/app/cli/commands/did/webs/resolve.py index 470d256..4b737d4 100644 --- a/src/dkr/app/cli/commands/did/webs/resolve.py +++ b/src/dkr/app/cli/commands/did/webs/resolve.py @@ -158,16 +158,16 @@ def compare_dicts(expected, actual, path=""): # # Test with the provided dictionaries # expected_dict = { -# 'id': 'did:webs:127.0.0.1:7676:BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha', -# 'verificationMethod': [{'id': 'did:webs:127.0.0.1:7676:BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha#key-0', 'type': 'Ed25519VerificationKey2020', 'controller': 'did:webs:127.0.0.1:7676:BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha', 'publicKeyMultibase': 'z2fD7Rmbbggzwa4SNpYKWi6csiiUcVeyUTgGzDtMrqC7b'}] +# 'id': 'did:webs:127.0.0.1%3a7676:BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha', +# 'verificationMethod': [{'id': 'did:webs:127.0.0.1%3a7676:BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha#key-0', 'type': 'Ed25519VerificationKey2020', 'controller': 'did:webs:127.0.0.1%3a7676:BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha', 'publicKeyMultibase': 'z2fD7Rmbbggzwa4SNpYKWi6csiiUcVeyUTgGzDtMrqC7b'}] # } # actual_dict = { -# "id": "did:webs:127.0.0.1:7676:BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha", +# "id": "did:webs:127.0.0.1%3a7676:BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha", # "verificationMethod": [{ -# "id": "did:webs:127.0.0.1:7676:BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha#key-0", +# "id": "did:webs:127.0.0.1%3a7676:BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha#key-0", # "type": "Ed25519VerificationKey2020", -# "controller": "did:webs:127.0.0.1:7676:BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha", +# "controller": "did:webs:127.0.0.1%3a7676:BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha", # "publicKeyMultibase": "z2fD7Rmbbggzwa4SNpYKWi6csiiUcVeyUTgGzDtMrqC7b" # }] # } diff --git a/src/dkr/app/cli/dkr.py b/src/dkr/app/cli/dkr.py index ac85c8e..52dd90d 100644 --- a/src/dkr/app/cli/dkr.py +++ b/src/dkr/app/cli/dkr.py @@ -26,6 +26,7 @@ def main(): try: doers = args.handler(args) + # print(f"doers={doers}") directing.runController(doers=doers, expire=0.0) except Exception as ex: diff --git a/src/dkr/core/webbing.py b/src/dkr/core/webbing.py index 713a39f..0554faf 100644 --- a/src/dkr/core/webbing.py +++ b/src/dkr/core/webbing.py @@ -13,11 +13,12 @@ from dkr.core import didding CESR_MIME = "application/cesr" -DD_DEFAULT_DIR = "./did_json" +DD_DEFAULT_DIR = "./" +DD_DIR_CFG = "did.doc.dir" DID_JSON = "did.json" -KC_DEFAULT_DIR = "./keri_cesr" +KC_DEFAULT_DIR = "./" KERI_CESR = "keri.cesr" -KERI_CESR_CFG = "keri.cesr.dir" +KC_DIR_CFG = "keri.cesr.dir" def setup(app, hby, cf): @@ -37,10 +38,15 @@ def setup(app, hby, cf): web = data["did:web"] loadEnds(app, hby, web) - loadFileEnds(app, DidJsonResourceEnd(), DID_JSON, DD_DEFAULT_DIR) - print(f"Using config property {KERI_CESR_CFG} to look for {KERI_CESR} files{data[KERI_CESR_CFG]}") - print(f"Found config {data[KERI_CESR_CFG]}") - loadFileEnds(app, KeriCesrWebResourceEnd(hby), KERI_CESR, data[KERI_CESR_CFG]) + if DD_DIR_CFG in data: + print(f"Using config property {DD_DIR_CFG} to look for {DID_JSON} files: {data[DD_DIR_CFG]}") + default_did_dir = data[DD_DIR_CFG] if DD_DIR_CFG in data else DD_DEFAULT_DIR + loadFileEnds(app, DidJsonResourceEnd(), DID_JSON, default_did_dir) + if KC_DIR_CFG in data: + print(f"Using config property {KC_DIR_CFG} to look for {KERI_CESR} files: {data[KC_DIR_CFG]}") + default_cesr_dir = data[KC_DIR_CFG] if KC_DIR_CFG in data else KC_DEFAULT_DIR + print(f"Using keri cesr dir {default_cesr_dir}") + loadFileEnds(app, KeriCesrWebResourceEnd(hby), KERI_CESR, default_cesr_dir) def loadEnds(app, hby, web): """ Load endpoints for all AIDs or configured AIDs only diff --git a/volume/dkr/examples/get_started_webs_resolve.sh b/volume/dkr/examples/get_started_webs_resolve.sh index 4797910..9b08871 100755 --- a/volume/dkr/examples/get_started_webs_resolve.sh +++ b/volume/dkr/examples/get_started_webs_resolve.sh @@ -8,4 +8,4 @@ hostPath=$2 aid=$3 # generate controller did:webs for EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP at labs.hyperledger.org -dkr did webs generate --name "${ctrlName}" --did "did:webs:${hostPath}:${aid}" \ No newline at end of file +dkr did webs resolve --name "${ctrlName}" --did "did:webs:${hostPath}:${aid}" \ No newline at end of file diff --git a/volume/dkr/examples/get_started_webs_serve.sh b/volume/dkr/examples/get_started_webs_serve.sh index 1bed2ed..f83c200 100755 --- a/volume/dkr/examples/get_started_webs_serve.sh +++ b/volume/dkr/examples/get_started_webs_serve.sh @@ -8,4 +8,8 @@ configDir=$2 configFile=$3 # serve controller did:webs for EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP at 127.0.0.1: -dkr did webs service --name "${ctrlName}" --config-dir "${configDir}" --config-file "${configFile}" --http 7676 \ No newline at end of file +dkr did webs service --name "${ctrlName}" --config-dir "${configDir}" --config-file "${configFile}" & +sleep 5 + +pid=$! +echo "dkr did webs service running as pid: $pid" \ No newline at end of file diff --git a/volume/dkr/examples/my-scripts/keri/cf/config-local.json b/volume/dkr/examples/my-scripts/keri/cf/config-local.json index f90c9c7..1b02013 100755 --- a/volume/dkr/examples/my-scripts/keri/cf/config-local.json +++ b/volume/dkr/examples/my-scripts/keri/cf/config-local.json @@ -7,5 +7,7 @@ ], "durls": [ "https://weboftrust.github.io/oobi/EN6Oh5XSD5_q2Hgu-aqpdfbVepdpYpFlgz6zvJL5b_r5" - ] + ], + "keri.cesr.dir": "./", + "did.doc.dir": "./" } \ No newline at end of file From 191511a15372deda4e841af23c16c97b9855669e Mon Sep 17 00:00:00 2001 From: 2byrds <2byrds@gmail.com> Date: Sat, 23 Dec 2023 18:50:45 -0500 Subject: [PATCH 08/17] testing docker and getting started guide. modifying commands, needs more work Signed-off-by: 2byrds <2byrds@gmail.com> --- GETTING_STARTED.md | 55 ++++++++++--------- docker-compose.yml | 6 +- images/did-webs-service.dockerfile | 3 +- images/dkr.dockerfile | 3 + scripts/did-webs-service.sh | 3 - volume/dkr/did_json/.gitignore | 3 - volume/dkr/did_json/README.md | 3 - .../my-scripts/my-incept-multi-fractions.json | 0 .../my-scripts/my-incept-multi.json | 0 .../{ => examples}/my-scripts/my-rotate.json | 0 volume/dkr/keri_cesr/.gitignore | 3 - volume/dkr/keri_cesr/README.md | 3 - volume/dkr/my-scripts/keri/cf/my-agent.json | 2 - .../keri/cf/my-config-multi-fractions.json | 8 --- .../my-scripts/keri/cf/my-config-multi.json | 8 --- volume/dkr/my-scripts/keri/cf/my-config.json | 8 --- volume/dkr/my-scripts/my-incept.json | 13 ----- 17 files changed, 38 insertions(+), 83 deletions(-) delete mode 100755 scripts/did-webs-service.sh delete mode 100644 volume/dkr/did_json/.gitignore delete mode 100644 volume/dkr/did_json/README.md rename volume/dkr/{ => examples}/my-scripts/my-incept-multi-fractions.json (100%) rename volume/dkr/{ => examples}/my-scripts/my-incept-multi.json (100%) rename volume/dkr/{ => examples}/my-scripts/my-rotate.json (100%) delete mode 100644 volume/dkr/keri_cesr/.gitignore delete mode 100644 volume/dkr/keri_cesr/README.md delete mode 100755 volume/dkr/my-scripts/keri/cf/my-agent.json delete mode 100755 volume/dkr/my-scripts/keri/cf/my-config-multi-fractions.json delete mode 100755 volume/dkr/my-scripts/keri/cf/my-config-multi.json delete mode 100755 volume/dkr/my-scripts/keri/cf/my-config.json delete mode 100644 volume/dkr/my-scripts/my-incept.json diff --git a/GETTING_STARTED.md b/GETTING_STARTED.md index 1b09638..6f55adc 100644 --- a/GETTING_STARTED.md +++ b/GETTING_STARTED.md @@ -26,36 +26,35 @@ docker compose up -d docker compose exec dkr /bin/bash ``` -## Run the script or execute the commands yourself -If you would like to run the script, you can do so by running the following command: - +## What ran when the dkr docker container started? +The following commands were run when the dkr docker container started: +* Go to the `examples` dir ``` cd examples -./get_started_keri.sh "controller" "/keripy/my-scripts" "config-docker" "incept-wits.json" -./get_started_webs.sh "controller" "labs.hyperledger.org:did-webs-resolver:pages" "EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP" ``` -Otherwise you can type these commands manually. -Lets go through each step. - -## (Optional) You can use the KERI-client (kli) to create a unique salt (seed) for your KERI AID private keys +* Create the KERI AID ```EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP``` +``` +./get_started_create_id.sh controller ./my-scripts config-docker incept-wits.json +``` +* Generate the did:webs ```did.json``` and ```keri.cesr``` for for the AID ```EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP``` +``` +./get_started_webs_gen.sh "controller" "did-webs-service%3a7676" "EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP" +``` +## Manually create your own KERI AID and did:webs files +### Create a cryptographic salt with sufficient entropy is generated ``` kli salt ``` - -Example response: - +The example salt we use in the scripts: ``` 0AAQmsjh-C7kAJZQEzdrzwB7 ``` -Note: In our examples we will use this salt `0AAQmsjh-C7kAJZQEzdrzwB7`, if you generated your own then replace it when necessary - -## Provide your unique salt and configure your KERI AID - +### Provide your unique salt and configure your KERI AID You control this AID so lets call it `controller`. -The config-file in the container is at /keripy/my-scripts/my-config and contains the oobis of the witnesses that we'll use: -In this case they are available from the witness network that we started in the docker-compose. If you `cat` the config at `/keripy/my-scripts/keri/cf/my-config.json` you should see: +The AID config-file in the container is at /keripy/my-scripts/keri/cf/config-docker.json and contains the KERI OOBIs of the witnesses that we'll use: +In this case they are available from the witness network that we started in the docker-compose. If you `cat` the config at `/keripy/my-scripts/keri/cf/config-docker.json` you should see: `config` ```json @@ -69,15 +68,19 @@ bash-5.1# cat /keripy/my-scripts/keri/cf/my-config.json ] } ``` -Run the init command to prep your environment with the config: +Run the init command to prep your environment with the *environment configuration*: + +`command` ``` -kli init --name controller --salt 0AAQmsjh-C7kAJZQEzdrzwB7 --nopasscode --config-dir "/keripy/my-scripts" --config-file my-config +kli init --name controller --salt 0AAQmsjh-C7kAJZQEzdrzwB7 --nopasscode --config-dir "/keripy/my-scripts" --config-file "config-docker" ``` +Produces output like: + `output` ``` -bash-5.1# kli init --name controller --salt 0AAQmsjh-C7kAJZQEzdrzwB7 --nopasscode --config-dir "/keripy/my-scripts" --config-file my-config KERI Keystore created at: /usr/local/var/keri/ks/controller +bash-5.1# kli init --name controller --salt 0AAQmsjh-C7kAJZQEzdrzwB7 --nopasscode --config-dir "/keripy/my-scripts" --config-file config-docker KERI Database created at: /usr/local/var/keri/db/controller KERI Credential Store created at: /usr/local/var/keri/reg/controller @@ -88,11 +91,11 @@ http://witnesshost:5644/oobi/BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX/contro ``` ## Create your KERI AID -Now that you have intitalized things, create your AID (via an inception event) with inception configuration that contains your witnesses. It is a transferable AID (meaning you can rotate the keys, witnesses, etc): +Now that you have intitalized your AID environment, you can create your AID (via an inception event) with *inception configuration* that contains your witnesses. It is a transferable AID (meaning you can rotate the keys, witnesses, etc): `config` ```json -bash-5.1# cat /keripy/my-scripts/my-incept.json +bash-5.1# cat /keripy/my-scripts/incept-wits.json { "transferable": true, "wits": [ @@ -104,13 +107,15 @@ bash-5.1# cat /keripy/my-scripts/my-incept.json ``` Run the incept command to create your AID: + +`command` ``` -kli incept --name controller --alias controller --file "/keripy/my-scripts/my-incept.json" +kli incept --name controller --alias controller --file "/keripy/my-scripts/incept-wits.json" ``` `output` ``` -bash-5.1# kli incept --name controller --alias controller --file "/keripy/my-scripts/my-incept.json" +bash-5.1# kli incept --name controller --alias controller --file "/keripy/my-scripts/incept-wits.json" Waiting for witness receipts... Prefix EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP Public key 1: DHr0-I-mMN7h6cLMOTRJkkfPuMd0vgQPrOk4Y3edaHjr diff --git a/docker-compose.yml b/docker-compose.yml index 4ed20f4..10c5071 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,8 +6,6 @@ services: hostname: witnesshost image: gleif/keri:latest tty: true - volumes: - - ./volume/witnesshost/keripy/scripts/keri/cf/main/:/keripy/scripts/keri/cf/main/ ports: - 5642:5642 # witness - 5643:5643 # witness @@ -23,7 +21,6 @@ services: image: gleif/dkr:latest tty: true volumes: - - ./volume/dkr/my-scripts/:/keripy/my-scripts/ - ./volume/dkr/examples/:/usr/local/var/did-keri-resolver/examples/ - ./volume/pages/:/pages/ @@ -38,6 +35,9 @@ services: image: gleif/did-webs-service:latest ports: - 7676:7676 + volumes: + - ./volume/dkr/examples/:/usr/local/var/did-keri-resolver/examples/ + - ./volume/pages/:/pages/ did-webs-resolver-service: container_name: did-webs-resolver-service diff --git a/images/did-webs-service.dockerfile b/images/did-webs-service.dockerfile index 0afba1c..3da435b 100644 --- a/images/did-webs-service.dockerfile +++ b/images/did-webs-service.dockerfile @@ -2,4 +2,5 @@ FROM gleif/dkr:latest EXPOSE 7676 -CMD ["/usr/local/var/did-keri-resolver/scripts/did-webs-service.sh"] +RUN cd /pages +RUN get_started_webs_serve.sh "controller" "${ORIG_CUR_DIR}/volume/dkr/examples/my-scripts" "config-local" diff --git a/images/dkr.dockerfile b/images/dkr.dockerfile index 314f9c0..b3e1624 100644 --- a/images/dkr.dockerfile +++ b/images/dkr.dockerfile @@ -10,3 +10,6 @@ COPY . /usr/local/var/did-keri-resolver WORKDIR /usr/local/var/did-keri-resolver RUN pip install -r requirements.txt +RUN cd example +RUN ./get_started_create_id.sh "controller" "./my-scripts config-docker" "incept-wits.json" +RUN ./get_started_webs_gen.sh "controller" "did-webs-service%3a7676" "EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP" diff --git a/scripts/did-webs-service.sh b/scripts/did-webs-service.sh deleted file mode 100755 index a4ea7d0..0000000 --- a/scripts/did-webs-service.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -dkr did webs service --config-dir=./scripts diff --git a/volume/dkr/did_json/.gitignore b/volume/dkr/did_json/.gitignore deleted file mode 100644 index 7c9d611..0000000 --- a/volume/dkr/did_json/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -* -!.gitignore -!README.md diff --git a/volume/dkr/did_json/README.md b/volume/dkr/did_json/README.md deleted file mode 100644 index ee3d618..0000000 --- a/volume/dkr/did_json/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# did.json - -This target path contains did.json files generated for did:webs identifiers. diff --git a/volume/dkr/my-scripts/my-incept-multi-fractions.json b/volume/dkr/examples/my-scripts/my-incept-multi-fractions.json similarity index 100% rename from volume/dkr/my-scripts/my-incept-multi-fractions.json rename to volume/dkr/examples/my-scripts/my-incept-multi-fractions.json diff --git a/volume/dkr/my-scripts/my-incept-multi.json b/volume/dkr/examples/my-scripts/my-incept-multi.json similarity index 100% rename from volume/dkr/my-scripts/my-incept-multi.json rename to volume/dkr/examples/my-scripts/my-incept-multi.json diff --git a/volume/dkr/my-scripts/my-rotate.json b/volume/dkr/examples/my-scripts/my-rotate.json similarity index 100% rename from volume/dkr/my-scripts/my-rotate.json rename to volume/dkr/examples/my-scripts/my-rotate.json diff --git a/volume/dkr/keri_cesr/.gitignore b/volume/dkr/keri_cesr/.gitignore deleted file mode 100644 index 7c9d611..0000000 --- a/volume/dkr/keri_cesr/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -* -!.gitignore -!README.md diff --git a/volume/dkr/keri_cesr/README.md b/volume/dkr/keri_cesr/README.md deleted file mode 100644 index 7b31fd3..0000000 --- a/volume/dkr/keri_cesr/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# keri.cesr - -This target path contains keri.cesr files generated for did:webs identifiers. diff --git a/volume/dkr/my-scripts/keri/cf/my-agent.json b/volume/dkr/my-scripts/keri/cf/my-agent.json deleted file mode 100755 index 2c63c08..0000000 --- a/volume/dkr/my-scripts/keri/cf/my-agent.json +++ /dev/null @@ -1,2 +0,0 @@ -{ -} diff --git a/volume/dkr/my-scripts/keri/cf/my-config-multi-fractions.json b/volume/dkr/my-scripts/keri/cf/my-config-multi-fractions.json deleted file mode 100755 index eee37b9..0000000 --- a/volume/dkr/my-scripts/keri/cf/my-config-multi-fractions.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "dt": "2022-01-20T12:57:59.823350+00:00", - "iurls": [ - "http://witnesshost:5642/oobi/BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha/controller", - "http://witnesshost:5644/oobi/BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX/controller", - "http://witnesshost:5643/oobi/BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM/controller" - ] -} diff --git a/volume/dkr/my-scripts/keri/cf/my-config-multi.json b/volume/dkr/my-scripts/keri/cf/my-config-multi.json deleted file mode 100755 index eee37b9..0000000 --- a/volume/dkr/my-scripts/keri/cf/my-config-multi.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "dt": "2022-01-20T12:57:59.823350+00:00", - "iurls": [ - "http://witnesshost:5642/oobi/BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha/controller", - "http://witnesshost:5644/oobi/BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX/controller", - "http://witnesshost:5643/oobi/BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM/controller" - ] -} diff --git a/volume/dkr/my-scripts/keri/cf/my-config.json b/volume/dkr/my-scripts/keri/cf/my-config.json deleted file mode 100755 index eee37b9..0000000 --- a/volume/dkr/my-scripts/keri/cf/my-config.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "dt": "2022-01-20T12:57:59.823350+00:00", - "iurls": [ - "http://witnesshost:5642/oobi/BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha/controller", - "http://witnesshost:5644/oobi/BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX/controller", - "http://witnesshost:5643/oobi/BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM/controller" - ] -} diff --git a/volume/dkr/my-scripts/my-incept.json b/volume/dkr/my-scripts/my-incept.json deleted file mode 100644 index 850aca0..0000000 --- a/volume/dkr/my-scripts/my-incept.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "transferable": true, - "wits": [ - "BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha", - "BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM", - "BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX" - ], - "toad": 3, - "icount": 1, - "ncount": 1, - "isith": "1", - "nsith": "1" -} From fa0f12efbe2ea5e99728a38769d0faa575bde284 Mon Sep 17 00:00:00 2001 From: 2byrds <2byrds@gmail.com> Date: Mon, 25 Dec 2023 08:18:18 -0500 Subject: [PATCH 09/17] more progress for docker images scenario Signed-off-by: 2byrds <2byrds@gmail.com> --- GETTING_STARTED.md | 8 ++++---- docker-compose.yml | 8 ++++---- images/did-webs-resolver-service.dockerfile | 2 +- images/did-webs-service.dockerfile | 5 +++-- images/dkr.dockerfile | 14 ++++++------- integration/app/integration.sh | 2 +- scripts/did-keri-resolver-service.sh | 3 --- scripts/did-webs-resolver-service.sh | 2 +- volume/dkr/examples/get_started_create_id.sh | 20 ++++++++++++++++--- .../my-scripts/keri/cf/config-docker.json | 5 +---- .../examples/scripts/keri/cf/main/wan.json | 0 .../examples/scripts/keri/cf/main/wes.json | 0 .../examples/scripts/keri/cf/main/wil.json | 0 .../examples/scripts/keri/cf/main/wit.json | 0 .../examples/scripts/keri/cf/main/wub.json | 0 .../examples/scripts/keri/cf/main/wyz.json | 0 16 files changed, 38 insertions(+), 31 deletions(-) delete mode 100755 scripts/did-keri-resolver-service.sh delete mode 100755 volume/dkr/examples/scripts/keri/cf/main/wan.json delete mode 100755 volume/dkr/examples/scripts/keri/cf/main/wes.json delete mode 100755 volume/dkr/examples/scripts/keri/cf/main/wil.json delete mode 100755 volume/dkr/examples/scripts/keri/cf/main/wit.json delete mode 100755 volume/dkr/examples/scripts/keri/cf/main/wub.json delete mode 100755 volume/dkr/examples/scripts/keri/cf/main/wyz.json diff --git a/GETTING_STARTED.md b/GETTING_STARTED.md index 6f55adc..49736f7 100644 --- a/GETTING_STARTED.md +++ b/GETTING_STARTED.md @@ -30,7 +30,7 @@ docker compose exec dkr /bin/bash The following commands were run when the dkr docker container started: * Go to the `examples` dir ``` -cd examples +cd volume/dkr/examples ``` * Create the KERI AID ```EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP``` ``` @@ -53,8 +53,8 @@ The example salt we use in the scripts: ### Provide your unique salt and configure your KERI AID You control this AID so lets call it `controller`. -The AID config-file in the container is at /keripy/my-scripts/keri/cf/config-docker.json and contains the KERI OOBIs of the witnesses that we'll use: -In this case they are available from the witness network that we started in the docker-compose. If you `cat` the config at `/keripy/my-scripts/keri/cf/config-docker.json` you should see: +The AID config-file in the container is at ./my-scripts/keri/cf/config-docker.json and contains the KERI OOBIs of the witnesses that we'll use: +In this case they are available from the witness network that we started in the docker-compose. If you `cat` the config at `./my-scripts/keri/cf/config-docker.json` you should see: `config` ```json @@ -121,7 +121,7 @@ Prefix EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP Public key 1: DHr0-I-mMN7h6cLMOTRJkkfPuMd0vgQPrOk4Y3edaHjr ``` -Congrats! You have an AID `EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP` with one public key as the current key `DHr0-I-mMN7h6cLMOTRJkkfPuMd0vgQPrOk4Y3edaHjr` +Congrats! You have an AID (the example one already created is `EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP`) with one public key as the current key `DHr0-I-mMN7h6cLMOTRJkkfPuMd0vgQPrOk4Y3edaHjr` ## (Optional) Perform more KERI operations diff --git a/docker-compose.yml b/docker-compose.yml index 10c5071..cd519ae 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -21,8 +21,8 @@ services: image: gleif/dkr:latest tty: true volumes: - - ./volume/dkr/examples/:/usr/local/var/did-keri-resolver/examples/ - - ./volume/pages/:/pages/ + - ./volume/dkr/examples/:/usr/local/var/webs/volume/dkr/examples/ + - ./volume/pages/:/usr/local/var/webs/volume/pages/ did-webs-service: container_name: did-webs-service @@ -36,8 +36,8 @@ services: ports: - 7676:7676 volumes: - - ./volume/dkr/examples/:/usr/local/var/did-keri-resolver/examples/ - - ./volume/pages/:/pages/ + - ./volume/dkr/examples/:/usr/local/var/webs/volume/dkr/examples/ + - ./volume/pages/:/usr/local/var/webs/volume/pages/ did-webs-resolver-service: container_name: did-webs-resolver-service diff --git a/images/did-webs-resolver-service.dockerfile b/images/did-webs-resolver-service.dockerfile index 9290de9..f846ce6 100644 --- a/images/did-webs-resolver-service.dockerfile +++ b/images/did-webs-resolver-service.dockerfile @@ -2,4 +2,4 @@ FROM gleif/dkr:latest EXPOSE 7677 -CMD ["/usr/local/var/did-keri-resolver/scripts/did-webs-resolver-service.sh"] +#RUN dkr did webs resolver-service --config-dir=./scripts \ No newline at end of file diff --git a/images/did-webs-service.dockerfile b/images/did-webs-service.dockerfile index 3da435b..8671706 100644 --- a/images/did-webs-service.dockerfile +++ b/images/did-webs-service.dockerfile @@ -2,5 +2,6 @@ FROM gleif/dkr:latest EXPOSE 7676 -RUN cd /pages -RUN get_started_webs_serve.sh "controller" "${ORIG_CUR_DIR}/volume/dkr/examples/my-scripts" "config-local" +WORKDIR /usr/local/var/webs/volume/dkr/examples + +# RUN ./get_started_webs_serve.sh "controller" "./my-scripts" "config-local" diff --git a/images/dkr.dockerfile b/images/dkr.dockerfile index b3e1624..6aed700 100644 --- a/images/dkr.dockerfile +++ b/images/dkr.dockerfile @@ -1,15 +1,13 @@ FROM gleif/keri:latest - - WORKDIR /usr/local/var -RUN mkdir did-keri-resolver -COPY . /usr/local/var/did-keri-resolver +RUN mkdir webs +COPY . /usr/local/var/webs -WORKDIR /usr/local/var/did-keri-resolver +WORKDIR /usr/local/var/webs/ RUN pip install -r requirements.txt -RUN cd example -RUN ./get_started_create_id.sh "controller" "./my-scripts config-docker" "incept-wits.json" -RUN ./get_started_webs_gen.sh "controller" "did-webs-service%3a7676" "EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP" +# RUN cd /usr/local/var/webs/volume/dkr/examples +# RUN ./get_started_create_id.sh "controller" "./my-scripts" "config-docker" "incept-wits.json" +# RUN ./get_started_webs_gen.sh "controller" "did-webs-service%3a7676" "EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP" diff --git a/integration/app/integration.sh b/integration/app/integration.sh index b6f54c2..42087de 100755 --- a/integration/app/integration.sh +++ b/integration/app/integration.sh @@ -127,7 +127,7 @@ function createKeriId() { create_aid_script="${ORIG_CUR_DIR}/volume/dkr/examples/get_started_create_id.sh" if [ -f "${create_aid_script}" ]; then echo "Found get started create id script" - source "${create_aid_script}" "${controller}" "${ORIG_CUR_DIR}/volume/dkr/examples/my-scripts" "config-local" "incept-wits.json" + source "${create_aid_script}" "${controller}" "${ORIG_CUR_DIR}/volume/dkr/examples/my-scripts" "config-local" "${ORIG_CUR_DIR}/volume/dkr/examples/my-scripts/incept-wits.json" sleep 3 echo "Completed creating KERI identity" else diff --git a/scripts/did-keri-resolver-service.sh b/scripts/did-keri-resolver-service.sh deleted file mode 100755 index 1187589..0000000 --- a/scripts/did-keri-resolver-service.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -dkr did keri resolver-service --config-dir=./scripts diff --git a/scripts/did-webs-resolver-service.sh b/scripts/did-webs-resolver-service.sh index 7c255ac..81183d3 100755 --- a/scripts/did-webs-resolver-service.sh +++ b/scripts/did-webs-resolver-service.sh @@ -1,3 +1,3 @@ #!/bin/bash -dkr did webs resolver-service --config-dir=./scripts +dkr did webs resolver-service --config-dir=./scripts \ No newline at end of file diff --git a/volume/dkr/examples/get_started_create_id.sh b/volume/dkr/examples/get_started_create_id.sh index 6682878..c0d066e 100755 --- a/volume/dkr/examples/get_started_create_id.sh +++ b/volume/dkr/examples/get_started_create_id.sh @@ -1,16 +1,30 @@ #!/bin/bash +set -x + +# RUN cd /usr/local/var/webs/volume/dkr/examples +# RUN ./get_started_create_id.sh "controller" "./my-scripts" "config-docker" "incept-wits.json" +# RUN ./get_started_webs_gen.sh "controller" "did-webs-service%3a7676" "EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP" #controller ctrlName=$1 -#/keripy/my-scripts +#./my-scripts configDir=$2 #my-config configFile=$3 -#my-incept.json +#./my-scripts/my-incept.json inceptFile=$4 +echo "Init KERI id config file at ${configDir}/keri/cf/${configFile} contains:" +cat "${configDir}/keri/cf/${configFile}" + # init environment for controller AID kli init --name "${ctrlName}" --salt 0AAQmsjh-C7kAJZQEzdrzwB7 --nopasscode --config-dir "${configDir}" --config-file "${configFile}" +echo "Incept KERI id config file at ${inceptFile} contains:" +cat "${inceptFile}" + # inception for controller AID -kli incept --name "${ctrlName}" --alias "${ctrlName}" --file "${configDir}/${inceptFile}" \ No newline at end of file +kli incept --name "${ctrlName}" --alias "${ctrlName}" --file "${inceptFile}" + +# see status +kli status --name "${ctrlName}" \ No newline at end of file diff --git a/volume/dkr/examples/my-scripts/keri/cf/config-docker.json b/volume/dkr/examples/my-scripts/keri/cf/config-docker.json index efeb96a..e56a8b8 100755 --- a/volume/dkr/examples/my-scripts/keri/cf/config-docker.json +++ b/volume/dkr/examples/my-scripts/keri/cf/config-docker.json @@ -4,8 +4,5 @@ "http://witnesshost:5642/oobi/BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha/controller", "http://witnesshost:5644/oobi/BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX/controller", "http://witnesshost:5643/oobi/BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM/controller" - ], - "durls": [ - "https://weboftrust.github.io/oobi/EN6Oh5XSD5_q2Hgu-aqpdfbVepdpYpFlgz6zvJL5b_r5" ] - } \ No newline at end of file +} \ No newline at end of file diff --git a/volume/dkr/examples/scripts/keri/cf/main/wan.json b/volume/dkr/examples/scripts/keri/cf/main/wan.json deleted file mode 100755 index e69de29..0000000 diff --git a/volume/dkr/examples/scripts/keri/cf/main/wes.json b/volume/dkr/examples/scripts/keri/cf/main/wes.json deleted file mode 100755 index e69de29..0000000 diff --git a/volume/dkr/examples/scripts/keri/cf/main/wil.json b/volume/dkr/examples/scripts/keri/cf/main/wil.json deleted file mode 100755 index e69de29..0000000 diff --git a/volume/dkr/examples/scripts/keri/cf/main/wit.json b/volume/dkr/examples/scripts/keri/cf/main/wit.json deleted file mode 100755 index e69de29..0000000 diff --git a/volume/dkr/examples/scripts/keri/cf/main/wub.json b/volume/dkr/examples/scripts/keri/cf/main/wub.json deleted file mode 100755 index e69de29..0000000 diff --git a/volume/dkr/examples/scripts/keri/cf/main/wyz.json b/volume/dkr/examples/scripts/keri/cf/main/wyz.json deleted file mode 100755 index e69de29..0000000 From 682838a50db9553d1b77d1b5b5235dd2b726111f Mon Sep 17 00:00:00 2001 From: 2byrds <2byrds@gmail.com> Date: Tue, 26 Dec 2023 15:56:53 -0500 Subject: [PATCH 10/17] align example with docker containers. still needs hosting and resolving instructions Signed-off-by: 2byrds <2byrds@gmail.com> --- GETTING_STARTED.md | 137 +++++++++++++++++++++++---------------------- docker-compose.yml | 6 +- 2 files changed, 72 insertions(+), 71 deletions(-) diff --git a/GETTING_STARTED.md b/GETTING_STARTED.md index 49736f7..9d0d2d7 100644 --- a/GETTING_STARTED.md +++ b/GETTING_STARTED.md @@ -20,28 +20,19 @@ docker compose down docker compose up -d ``` -## Enter the docker environment command line to begin running keri, etc. commands +## Enter the dkr docker environment command line to begin running keri, etc. commands ``` docker compose exec dkr /bin/bash ``` -## What ran when the dkr docker container started? -The following commands were run when the dkr docker container started: +## Create your KERI identifier +Execute the following commands to create your KERI identifier that secures your did:webs DID: * Go to the `examples` dir ``` cd volume/dkr/examples ``` -* Create the KERI AID ```EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP``` -``` -./get_started_create_id.sh controller ./my-scripts config-docker incept-wits.json -``` -* Generate the did:webs ```did.json``` and ```keri.cesr``` for for the AID ```EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP``` -``` -./get_started_webs_gen.sh "controller" "did-webs-service%3a7676" "EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP" -``` -## Manually create your own KERI AID and did:webs files ### Create a cryptographic salt with sufficient entropy is generated ``` kli salt @@ -51,78 +42,55 @@ The example salt we use in the scripts: 0AAQmsjh-C7kAJZQEzdrzwB7 ``` -### Provide your unique salt and configure your KERI AID -You control this AID so lets call it `controller`. -The AID config-file in the container is at ./my-scripts/keri/cf/config-docker.json and contains the KERI OOBIs of the witnesses that we'll use: -In this case they are available from the witness network that we started in the docker-compose. If you `cat` the config at `./my-scripts/keri/cf/config-docker.json` you should see: -`config` -```json -bash-5.1# cat /keripy/my-scripts/keri/cf/my-config.json -{ - "dt": "2022-01-20T12:57:59.823350+00:00", - "iurls": [ - "http://witnesshost:5642/oobi/BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha/controller", - "http://witnesshost:5644/oobi/BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX/controller", - "http://witnesshost:5643/oobi/BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM/controller" - ] -} -``` -Run the init command to prep your environment with the *environment configuration*: +### Create the KERI AID ```ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe``` +#### initialize your environment with a name, salt, and config file -`command` +`command:` ``` -kli init --name controller --salt 0AAQmsjh-C7kAJZQEzdrzwB7 --nopasscode --config-dir "/keripy/my-scripts" --config-file "config-docker" +kli init --name controller --salt 0AAQmsjh-C7kAJZQEzdrzwB7 --nopasscode --config-dir ./my-scripts --config-file config-docker ``` -Produces output like: +#### create your AID by creating it's first event, the inception event -`output` +`command:` +``` +kli incept --name controller --alias controller --file ./my-scripts/incept ``` + +```output:``` +``` +bash-5.1# kli init --name controller --salt 0AAQmsjh-C7kAJZQEzdrzwB7 --nopasscode --config-dir ./my-scripts --config-file config-docker KERI Keystore created at: /usr/local/var/keri/ks/controller -bash-5.1# kli init --name controller --salt 0AAQmsjh-C7kAJZQEzdrzwB7 --nopasscode --config-dir "/keripy/my-scripts" --config-file config-docker KERI Database created at: /usr/local/var/keri/db/controller KERI Credential Store created at: /usr/local/var/keri/reg/controller Loading 3 OOBIs... http://witnesshost:5642/oobi/BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha/controller succeeded http://witnesshost:5643/oobi/BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM/controller succeeded -http://witnesshost:5644/oobi/BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX/controller succeeded +http://witnesshost:5644/oobi/BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX/controller succeeded +bash-5.1# kli incept --name controller --alias controller --file ./my-scripts/incept.json +Prefix ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe + Public key 1: DHr0-I-mMN7h6cLMOTRJkkfPuMd0vgQPrOk4Y3edaHjr ``` +Your AID is ```ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe``` and your current public key is ```DHr0-I-mMN7h6cLMOTRJkkfPuMd0vgQPrOk4Y3edaHjr``` -## Create your KERI AID -Now that you have intitalized your AID environment, you can create your AID (via an inception event) with *inception configuration* that contains your witnesses. It is a transferable AID (meaning you can rotate the keys, witnesses, etc): +#### Additional info +The AID config-file in the container is at ./my-scripts/keri/cf/config-docker.json and contains the KERI OOBIs of the witnesses that we'll use: +In this case they are available from the witness network that we started in the docker-compose. If you `cat` the config at `./my-scripts/keri/cf/config-docker.json` you should see: -`config` +`config:` ```json -bash-5.1# cat /keripy/my-scripts/incept-wits.json { - "transferable": true, - "wits": [ - "BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha", - "BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM", - "BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX" - ]... + "dt": "2022-01-20T12:57:59.823350+00:00", + "iurls": [ + "http://witnesshost:5642/oobi/BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha/controller", + "http://witnesshost:5644/oobi/BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX/controller", + "http://witnesshost:5643/oobi/BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM/controller" + ] } ``` -Run the incept command to create your AID: - -`command` -``` -kli incept --name controller --alias controller --file "/keripy/my-scripts/incept-wits.json" -``` - -`output` -``` -bash-5.1# kli incept --name controller --alias controller --file "/keripy/my-scripts/incept-wits.json" -Waiting for witness receipts... -Prefix EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP - Public key 1: DHr0-I-mMN7h6cLMOTRJkkfPuMd0vgQPrOk4Y3edaHjr -``` - -Congrats! You have an AID (the example one already created is `EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP`) with one public key as the current key `DHr0-I-mMN7h6cLMOTRJkkfPuMd0vgQPrOk4Y3edaHjr` - ## (Optional) Perform more KERI operations Optionally use `kli` to perform additional KERI operations such as key rotation, threshold signatures, etc., see KERI docs for details. @@ -140,17 +108,46 @@ Example web address: https://labs.hyperledger.org/did-webs-resolver/pages/ ``` -## Generate did:webs files for AID +## Generate your did:webs identifier files using your KERI AID Note: Replace with your actual web address and AID, convert to did:web(s) conformant identifier -Be sure to execute the command in the root of your local `did-webs` repo (and in the Docker container) +You should pick the web address (domain, optional port, optional path) where you will host the did:webs identifier. For this example we'll use the docker service we've created `did-webs-service%3a7676` + +`command:` ``` -dkr did webs generate --name controller --did did:webs:labs.hyperledger.org:did-webs-resolver:pages:EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP +dkr did webs generate --name controller --did "did:webs:did-webs-service%3a7676:ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe" ``` -This creates files: -- `did.json` and `keri.cesr` under local path `./volume/dkr/examples//did.json` +`output:` +``` +bash-5.1# dkr did webs generate --name controller --did "did:webs:did-webs-service%3a7676:ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe" +Generating CESR event stream data from hab +Generating ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe KEL CESR events +Writing CESR events to ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe/keri.cesr: +{"v":"KERI10JSON00012b_","t":"icp","d":"ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe","i":"ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe","s":"0","kt":"1","k":["DHr0-I-mMN7h6cLMOTRJkkfPuMd0vgQPrOk4Y3edaHjr"],"nt":"1","n":["ELa775aLyane1vdiJEuexP8zrueiIoG995pZPGJiBzGX"],"bt":"0","b":[],"c":[],"a":[]}-VAn-AABAADjfOjbPu9OWce59OQIc-y3Su4kvfC2BAd_e_NLHbXcOK8-3s6do5vBfrxQ1kDyvFGCPMcSl620dLMZ4QDYlvME-EAB0AAAAAAAAAAAAAAAAAAAAAAA1AAG2023-12-26T20c12c58d336072p00c00 + + "didDocument": { + "id": "did:web:did-webs-service%3a7676:ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe", + "verificationMethod": [ + { + "id": "#DHr0-I-mMN7h6cLMOTRJkkfPuMd0vgQPrOk4Y3edaHjr", + "type": "JsonWebKey", + "controller": "did:web:did-webs-service%3a7676:ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe", + "publicKeyJwk": { + "kid": "DHr0-I-mMN7h6cLMOTRJkkfPuMd0vgQPrOk4Y3edaHjr", + "kty": "OKP", + "crv": "Ed25519", + "x": "evT4j6Yw3uHpwsw5NEmSR8-4x3S-BA-s6Thjd51oeOs" + } + } + ], + "service": [], + "alsoKnownAs": [] + }... +``` + +This creates files `did.json` and `keri.cesr` under local path `./volume/dkr/examples//did.json` You can access these files either from within your Docker container or on your local computer filesystem. - `/volume/dkr/examples/` @@ -161,7 +158,11 @@ You can access these files either from within your Docker container or on your l E.g. using git, Github pages, FTP, SCP, etc. -### Example WOT-terms install using git +### Example docker install + + + +### Example WOT-terms install using GIT We choose `WOT-terms` as our [DESTINATION LOCAL REPO] diff --git a/docker-compose.yml b/docker-compose.yml index cd519ae..8700c8c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -22,7 +22,7 @@ services: tty: true volumes: - ./volume/dkr/examples/:/usr/local/var/webs/volume/dkr/examples/ - - ./volume/pages/:/usr/local/var/webs/volume/pages/ + - ./volume/dkr/pages/:/usr/local/var/webs/volume/pages/ did-webs-service: container_name: did-webs-service @@ -36,8 +36,8 @@ services: ports: - 7676:7676 volumes: - - ./volume/dkr/examples/:/usr/local/var/webs/volume/dkr/examples/ - - ./volume/pages/:/usr/local/var/webs/volume/pages/ + - ./volume/dkr/examples/:/usr/local/var/did-keri-resolver/examples/ + - ./volume/dkr/pages/:/usr/local/var/did-keri-resolver/pages/ did-webs-resolver-service: container_name: did-webs-resolver-service From 6221e96bc7953738ef36cb2b26c7d39ce61a1f47 Mon Sep 17 00:00:00 2001 From: 2byrds <2byrds@gmail.com> Date: Tue, 26 Dec 2023 16:17:22 -0500 Subject: [PATCH 11/17] Cleaning up script names Signed-off-by: 2byrds <2byrds@gmail.com> --- .../examples/{public.sh => get_started_des_aliases.sh} | 0 volume/dkr/examples/get_started_docker.sh | 9 +++++++++ volume/dkr/examples/{local.sh => get_started_local.sh} | 0 3 files changed, 9 insertions(+) rename volume/dkr/examples/{public.sh => get_started_des_aliases.sh} (100%) create mode 100755 volume/dkr/examples/get_started_docker.sh rename volume/dkr/examples/{local.sh => get_started_local.sh} (100%) diff --git a/volume/dkr/examples/public.sh b/volume/dkr/examples/get_started_des_aliases.sh similarity index 100% rename from volume/dkr/examples/public.sh rename to volume/dkr/examples/get_started_des_aliases.sh diff --git a/volume/dkr/examples/get_started_docker.sh b/volume/dkr/examples/get_started_docker.sh new file mode 100755 index 0000000..4970571 --- /dev/null +++ b/volume/dkr/examples/get_started_docker.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +cd ./volume/dkr/examples + +kli init --name controller --salt 0AAQmsjh-C7kAJZQEzdrzwB7 --nopasscode --config-dir ./my-scripts --config-file config-docker + +kli incept --name controller --alias controller --file ./my-scripts/incept.json + +dkr did webs generate --name controller --did "did:webs:did-webs-service%3a7676:ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe" \ No newline at end of file diff --git a/volume/dkr/examples/local.sh b/volume/dkr/examples/get_started_local.sh similarity index 100% rename from volume/dkr/examples/local.sh rename to volume/dkr/examples/get_started_local.sh From 02bdf5e70edfe0faa3ee25276170f87eb12f8ac8 Mon Sep 17 00:00:00 2001 From: 2byrds <2byrds@gmail.com> Date: Fri, 29 Dec 2023 13:04:16 -0500 Subject: [PATCH 12/17] served did:webs files from docker container and updated instructions Signed-off-by: 2byrds <2byrds@gmail.com> --- GETTING_STARTED.md | 30 +++++++++++++++++-- docker-compose.yml | 5 ++-- images/did-webs-service.dockerfile | 4 +-- integration/app/integration.sh | 13 ++++---- volume/dkr/examples/get_started_docker.sh | 2 +- .../my-scripts/keri/cf/config-docker.json | 4 ++- 6 files changed, 42 insertions(+), 16 deletions(-) diff --git a/GETTING_STARTED.md b/GETTING_STARTED.md index 9d0d2d7..a342060 100644 --- a/GETTING_STARTED.md +++ b/GETTING_STARTED.md @@ -158,11 +158,37 @@ You can access these files either from within your Docker container or on your l E.g. using git, Github pages, FTP, SCP, etc. -### Example docker install +### Example: serve from docker +You can run the docker example service to serve the did.json and keri.cesr files for the other docker containers: +``` +docker compose exec did-webs-service /bin/bash +``` + +``` +dkr did webs service --name controller --config-dir ./my-scripts --config-file config-docker +``` + +It will search for AID named directories and for the two files under those directories. The search occurs from the directory specified in the config-file properties: +``` + "keri.cesr.dir": "./", + "did.doc.dir": "./" +``` + +And when a file is found it will look like: +``` +Looking for keri.cesr file ./ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe +registering /ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe/keri.cesr +``` + +It will serve it at a URL that you can CURL from any other docker container (for instance from the dkr container) like: + +``` +curl -GET http://did-webs-service:7676/ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe/did.json +``` -### Example WOT-terms install using GIT +### Example: WOT-terms install using GIT We choose `WOT-terms` as our [DESTINATION LOCAL REPO] diff --git a/docker-compose.yml b/docker-compose.yml index 8700c8c..15fb1d4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -30,11 +30,10 @@ services: build: context: . dockerfile: ./images/did-webs-service.dockerfile - depends_on: - - dkr - image: gleif/did-webs-service:latest + image: gleif/dkr:latest ports: - 7676:7676 + tty: true volumes: - ./volume/dkr/examples/:/usr/local/var/did-keri-resolver/examples/ - ./volume/dkr/pages/:/usr/local/var/did-keri-resolver/pages/ diff --git a/images/did-webs-service.dockerfile b/images/did-webs-service.dockerfile index 8671706..d02e419 100644 --- a/images/did-webs-service.dockerfile +++ b/images/did-webs-service.dockerfile @@ -2,6 +2,4 @@ FROM gleif/dkr:latest EXPOSE 7676 -WORKDIR /usr/local/var/webs/volume/dkr/examples - -# RUN ./get_started_webs_serve.sh "controller" "./my-scripts" "config-local" +WORKDIR /usr/local/var/webs/volume/dkr/examples \ No newline at end of file diff --git a/integration/app/integration.sh b/integration/app/integration.sh index 42087de..67741ba 100755 --- a/integration/app/integration.sh +++ b/integration/app/integration.sh @@ -15,6 +15,7 @@ ORIG_CUR_DIR=$( pwd ) controller="controller" host="127.0.0.1" +aid="EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP" KERI_BRANCH="main" # KERI_TAG="c3a6fc455b5fac194aa9c264e48ea2c52328d4c5" @@ -62,7 +63,7 @@ function genDidWebs() { start_webs_gen="${ORIG_CUR_DIR}/volume/dkr/examples/get_started_webs_gen.sh" if [ -f "${start_webs_gen}" ]; then echo "Found get started script to generate did:webs" - source "${start_webs_gen}" "${controller}" "${host}%3a7676" "EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP" + source "${start_webs_gen}" "${controller}" "${host}%3a7676" "${aid}" sleep 3 echo "Completed loading generating did:webs" else @@ -152,9 +153,9 @@ function resolveDIDAndKeriEvents() { res_webs_script="${ORIG_CUR_DIR}/volume/dkr/examples/get_started_webs_resolve.sh" if [ -f "${res_webs_script}" ]; then echo "Found get started resolve script" - source "${res_webs_script}" "${controller}" "${host}%3a7676" "EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP" + source "${res_webs_script}" "${controller}" "${host}%3a7676" "${aid}" sleep 3 - echo "Completed creating KERI identity" + echo "Resolved did:webs identity" else echo "Couldn't find get started keri script" fi @@ -210,8 +211,8 @@ function serveDidAndKeriEvents() { source "${srv_webs_script}" "${controller}" "${ORIG_CUR_DIR}/volume/dkr/examples/my-scripts" "config-local" servePid=$! echo "Serving did:webs and keri events @pid ${servePid}" - echo "DID doc served at http://${host}:7676/EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP/did.json" - echo "KERI CESR at http://${host}:7676/EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP/keri.cesr" + echo "DID doc served at http://${host}:7676/${aid}/did.json" + echo "KERI CESR at http://${host}:7676/${aid}/keri.cesr" else echo "Couldn't find get started serve script" fi @@ -270,7 +271,7 @@ do # if [ "${prompt}" == "y" ]; then # fi read -p "Your servers still running, hit enter to tear down: " teardown - echo "Tearing down any leftover processes" + echo "Tearing down any leftover processes ${teardown}" # #tear down the signify client # kill "$signifyPid" >/dev/null 2>&1 # # tear down the keria cloud agent diff --git a/volume/dkr/examples/get_started_docker.sh b/volume/dkr/examples/get_started_docker.sh index 4970571..90036f4 100755 --- a/volume/dkr/examples/get_started_docker.sh +++ b/volume/dkr/examples/get_started_docker.sh @@ -1,6 +1,6 @@ #!/bin/bash -cd ./volume/dkr/examples +#cd ./volume/dkr/examples kli init --name controller --salt 0AAQmsjh-C7kAJZQEzdrzwB7 --nopasscode --config-dir ./my-scripts --config-file config-docker diff --git a/volume/dkr/examples/my-scripts/keri/cf/config-docker.json b/volume/dkr/examples/my-scripts/keri/cf/config-docker.json index e56a8b8..d74a59c 100755 --- a/volume/dkr/examples/my-scripts/keri/cf/config-docker.json +++ b/volume/dkr/examples/my-scripts/keri/cf/config-docker.json @@ -4,5 +4,7 @@ "http://witnesshost:5642/oobi/BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha/controller", "http://witnesshost:5644/oobi/BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX/controller", "http://witnesshost:5643/oobi/BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM/controller" - ] + ], + "keri.cesr.dir": "./", + "did.doc.dir": "./" } \ No newline at end of file From 99e39785d3b8dc46fac6e2aee4e343db936824f3 Mon Sep 17 00:00:00 2001 From: 2byrds <2byrds@gmail.com> Date: Mon, 1 Jan 2024 10:42:27 -0500 Subject: [PATCH 13/17] Improving file server setup/instructions/impl, still working on hab functionality Signed-off-by: 2byrds <2byrds@gmail.com> --- GETTING_STARTED.md | 57 +++++++++++-------- Makefile | 10 ++-- docker-compose.yml | 19 +++---- images/did-keri-resolver-service.dockerfile | 2 +- images/did-webs-resolver-service.dockerfile | 3 + images/did-webs-service.dockerfile | 2 +- setup.py | 2 +- src/dkr/core/didding.py | 4 +- src/dkr/core/webbing.py | 23 ++++++-- tests/app/core/test_didding.py | 55 ++++++++++++++++++ .../dkr/examples/get_started_webs_resolve.sh | 2 +- .../my-scripts/keri/cf/config-docker.json | 4 +- .../did.json | 1 + .../keri.cesr | 1 + .../did.json | 43 -------------- .../keri.cesr | 23 -------- 16 files changed, 132 insertions(+), 119 deletions(-) create mode 100644 volume/dkr/pages/ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe/did.json create mode 100644 volume/dkr/pages/ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe/keri.cesr delete mode 100644 volume/pages/EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP/did.json delete mode 100644 volume/pages/EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP/keri.cesr diff --git a/GETTING_STARTED.md b/GETTING_STARTED.md index a342060..2518719 100644 --- a/GETTING_STARTED.md +++ b/GETTING_STARTED.md @@ -28,12 +28,12 @@ docker compose exec dkr /bin/bash ## Create your KERI identifier Execute the following commands to create your KERI identifier that secures your did:webs DID: -* Go to the `examples` dir +* From the dkr Docker container shell, go to the `examples` dir ``` cd volume/dkr/examples ``` -### Create a cryptographic salt with sufficient entropy is generated +### Create a cryptographic salt to secure your KERI identifier ``` kli salt ``` @@ -51,13 +51,6 @@ The example salt we use in the scripts: kli init --name controller --salt 0AAQmsjh-C7kAJZQEzdrzwB7 --nopasscode --config-dir ./my-scripts --config-file config-docker ``` -#### create your AID by creating it's first event, the inception event - -`command:` -``` -kli incept --name controller --alias controller --file ./my-scripts/incept -``` - ```output:``` ``` bash-5.1# kli init --name controller --salt 0AAQmsjh-C7kAJZQEzdrzwB7 --nopasscode --config-dir ./my-scripts --config-file config-docker @@ -69,6 +62,17 @@ Loading 3 OOBIs... http://witnesshost:5642/oobi/BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha/controller succeeded http://witnesshost:5643/oobi/BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM/controller succeeded http://witnesshost:5644/oobi/BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX/controller succeeded +``` + +#### create your AID by creating it's first event, the inception event + +`command:` +``` +kli incept --name controller --alias controller --file ./my-scripts/incept.json +``` + +```output:``` +``` bash-5.1# kli incept --name controller --alias controller --file ./my-scripts/incept.json Prefix ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe Public key 1: DHr0-I-mMN7h6cLMOTRJkkfPuMd0vgQPrOk4Y3edaHjr @@ -100,9 +104,9 @@ See [a key rotation example](#example-key-rotation) below. ## Decide your web address for did:webs -Find a web address (domain, optional port, optional path) that you control. +Find a web address (host, optional port, optional path) that you control. -Example web address: +Example web address with host `labs.hyperledger.org`, no optional port, and optional path `pages`: ``` https://labs.hyperledger.org/did-webs-resolver/pages/ @@ -110,9 +114,9 @@ https://labs.hyperledger.org/did-webs-resolver/pages/ ## Generate your did:webs identifier files using your KERI AID -Note: Replace with your actual web address and AID, convert to did:web(s) conformant identifier +Note: Replace with your actual web address and AID -You should pick the web address (domain, optional port, optional path) where you will host the did:webs identifier. For this example we'll use the docker service we've created `did-webs-service%3a7676` +You should pick the web address (host, optional port, optional path) where you will host the did:webs identifier. For this example we'll use the docker service we've created at host `did-webs-service` and with optional port `7676`. NOTE the spec requires the colon `:` before an optional port to be encoded as `%3a` in the did:webs identifier. `command:` ``` @@ -144,17 +148,18 @@ Writing CESR events to ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe/keri.cesr: ], "service": [], "alsoKnownAs": [] - }... + } + ... with additional output continuing... ``` This creates files `did.json` and `keri.cesr` under local path `./volume/dkr/examples//did.json` You can access these files either from within your Docker container or on your local computer filesystem. -- `/volume/dkr/examples/` -- `/usr/local/var/did-keri-resolver/volume/dkr/examples/` (local path in the Docker container) +- `/volume/dkr/examples/` (local path on your computer) +- `/usr/local/var/webs/volume/dkr/examples/` (local path in the Docker container) -## Upload did.json and keri.cesr to your web server +## Upload did.json and keri.cesr to the web address (host, optional port, optional path) that corresponds to the E.g. using git, Github pages, FTP, SCP, etc. @@ -166,19 +171,19 @@ docker compose exec did-webs-service /bin/bash ``` ``` -dkr did webs service --name controller --config-dir ./my-scripts --config-file config-docker +dkr did webs service --name webserve --config-dir /usr/local/var/webs/volume/dkr/examples/my-scripts --config-file config-docker ``` -It will search for AID named directories and for the two files under those directories. The search occurs from the directory specified in the config-file properties: +It will search for AID named directories and for the two files (`did.json` and `keri.cesr`) under those directories. The search occurs from the directory specified in the config-file properties: ``` - "keri.cesr.dir": "./", - "did.doc.dir": "./" + "keri.cesr.dir": "/usr/local/var/webs/volume/dkr/pages/", + "did.doc.dir": "/usr/local/var/webs/volume/dkr/pages/" ``` -And when a file is found it will look like: +And when a file is found by the service, there will be logs like: ``` -Looking for keri.cesr file ./ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe -registering /ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe/keri.cesr +Looking for did.json file /usr/local/var/webs/volume/dkr/pages/ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe +registering /ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe/did.json ``` It will serve it at a URL that you can CURL from any other docker container (for instance from the dkr container) like: @@ -186,6 +191,10 @@ It will serve it at a URL that you can CURL from any other docker container (for ``` curl -GET http://did-webs-service:7676/ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe/did.json ``` +and +``` +curl -GET http://did-webs-service:7676/ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe/keri.cesr +``` ### Example: WOT-terms install using GIT diff --git a/Makefile b/Makefile index dc04d6b..67e614c 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,14 @@ -.PHONY: build-did-keri-resolver -build-did-keri-resolver: - @docker buildx build --platform=linux/amd64 --no-cache -f images/did-keri-resolver.dockerfile --tag weboftrust/did-keri-resolver:latest --tag weboftrust/did-keri-resolver:0.1.0 . +.PHONY: build-did-webs-resolver +build-did-webs-resolver: + @docker buildx build --platform=linux/amd64 --no-cache -f images/did-webs-resolver.dockerfile --tag weboftrust/did-webs-resolver:latest --tag weboftrust/did-webs-resolver:0.1.0 . .PHONY: build-did-web build-did-web: @docker build --platform=linux/amd64 -f images/did-web.dockerfile --tag weboftrust/did-web:latest --tag weboftrust/did-web:0.1.0 . -.PHONY: run-did-keri-resolver +.PHONY: run-did-webs-resolver run-agent: - @docker run -p 5921:5921 -p 5923:5923 --name agent weboftrust/did-keri-resolver:0.1.0 + @docker run -p 5921:5921 -p 5923:5923 --name agent weboftrust/did-webs-resolver:0.1.0 .PHONY: push-all push-all: diff --git a/docker-compose.yml b/docker-compose.yml index 15fb1d4..faf4e07 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -21,8 +21,8 @@ services: image: gleif/dkr:latest tty: true volumes: - - ./volume/dkr/examples/:/usr/local/var/webs/volume/dkr/examples/ - - ./volume/dkr/pages/:/usr/local/var/webs/volume/pages/ + - ~/VSCode/did-keri-resolver/volume/dkr/examples:/usr/local/var/webs/volume/dkr/examples + - ~/VSCode/did-keri-resolver/volume/dkr/pages:/usr/local/var/webs/volume/dkr/pages did-webs-service: container_name: did-webs-service @@ -30,22 +30,21 @@ services: build: context: . dockerfile: ./images/did-webs-service.dockerfile - image: gleif/dkr:latest + # image: ./images/did-webs-service:latest ports: - 7676:7676 tty: true volumes: - - ./volume/dkr/examples/:/usr/local/var/did-keri-resolver/examples/ - - ./volume/dkr/pages/:/usr/local/var/did-keri-resolver/pages/ + - ~/VSCode/did-keri-resolver/volume/dkr/examples:/usr/local/var/webs/volume/dkr/examples + - ~/VSCode/did-keri-resolver/volume/dkr/pages:/usr/local/var/webs/volume/dkr/pages did-webs-resolver-service: - container_name: did-webs-resolver-service - hostname: did-webs-resolver-service + container_name: did-webs-resolver + hostname: did-webs-resolver build: context: . dockerfile: ./images/did-webs-resolver-service.dockerfile - depends_on: - - dkr - image: gleif/did-webs-resolver-service:latest + # image: gleif/did-webs-resolver:latest ports: - 7677:7677 + tty: true diff --git a/images/did-keri-resolver-service.dockerfile b/images/did-keri-resolver-service.dockerfile index 0a2a9bc..aeee361 100644 --- a/images/did-keri-resolver-service.dockerfile +++ b/images/did-keri-resolver-service.dockerfile @@ -2,4 +2,4 @@ FROM gleif/dkr:latest EXPOSE 7678 -CMD ["/usr/local/var/did-keri-resolver/scripts/did-keri-resolver-service.sh"] +CMD ["/usr/local/var/webs/scripts/webs-resolver-service.sh"] diff --git a/images/did-webs-resolver-service.dockerfile b/images/did-webs-resolver-service.dockerfile index f846ce6..02c3731 100644 --- a/images/did-webs-resolver-service.dockerfile +++ b/images/did-webs-resolver-service.dockerfile @@ -2,4 +2,7 @@ FROM gleif/dkr:latest EXPOSE 7677 +WORKDIR /usr/local/var/webs/volume/dkr/examples + + #RUN dkr did webs resolver-service --config-dir=./scripts \ No newline at end of file diff --git a/images/did-webs-service.dockerfile b/images/did-webs-service.dockerfile index d02e419..e86ea92 100644 --- a/images/did-webs-service.dockerfile +++ b/images/did-webs-service.dockerfile @@ -2,4 +2,4 @@ FROM gleif/dkr:latest EXPOSE 7676 -WORKDIR /usr/local/var/webs/volume/dkr/examples \ No newline at end of file +WORKDIR /usr/local/var/webs/volume/dkr/pages \ No newline at end of file diff --git a/setup.py b/setup.py index d6bf151..236ef69 100644 --- a/setup.py +++ b/setup.py @@ -32,7 +32,7 @@ setup( name='dkr', - version='0.0.1', # also change in src/did-keri-resolver/__init__.py + version='0.0.1', # also change in src/did-webs-resolver/__init__.py license='Apache Software License 2.0', description='did:keri DID Method Resolver', long_description="did:keri DID Method Resolver.", diff --git a/src/dkr/core/didding.py b/src/dkr/core/didding.py index 08caba0..80501ac 100644 --- a/src/dkr/core/didding.py +++ b/src/dkr/core/didding.py @@ -19,7 +19,7 @@ from keri.vdr import credentialing, verifying DID_KERI_RE = re.compile(r'\Adid:keri:(?P[^:]+)\Z', re.IGNORECASE) -DID_WEBS_RE = re.compile(r'\Adid:webs:(?P[^%:]+)(?:%3a(?P\d+))?(?::(?P.+?))?(?::(?P[^:]+))\Z', re.IGNORECASE) +DID_WEBS_RE = re.compile(r'\Adid:web(s)?:(?P[^%:]+)(?:%3a(?P\d+))?(?::(?P.+?))?(?::(?P[^:]+))\Z', re.IGNORECASE) DID_TIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ" DID_TIME_PATTERN = re.compile(r"\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z") DES_ALIASES_SCHEMA="EN6Oh5XSD5_q2Hgu-aqpdfbVepdpYpFlgz6zvJL5b_r5" @@ -41,7 +41,7 @@ def parseDIDKeri(did): def parseDIDWebs(did): match = DID_WEBS_RE.match(did) if match is None: - raise ValueError(f"{did} is not a valid did:webs DID") + raise ValueError(f"{did} is not a valid did:web(s) DID") domain, port, path, aid = match.group("domain", "port", "path", "aid") diff --git a/src/dkr/core/webbing.py b/src/dkr/core/webbing.py index 0554faf..98b24ed 100644 --- a/src/dkr/core/webbing.py +++ b/src/dkr/core/webbing.py @@ -8,6 +8,8 @@ import falcon from hio.core import http +from keri.app import habbing +from keri.core import coring, eventing, parsing, scheming from keri.end import ending from dkr.core import didding @@ -88,7 +90,7 @@ def loadFileEnds(app, res, file_end, dirPath): path=f"/{aid}/{file_end}" print(f"registering {path}") app.add_route(f"{path}", res) - res.add_lookup(path,fPath) + res.add_lookup(path,fPath,aid) else: print(f"Skipping {fPath} as it is not a file") @@ -146,7 +148,7 @@ def __init__(self): """ self.lookup = {} - def add_lookup(self, path, fPath): + def add_lookup(self, path, fPath, aid=None): self.lookup[path] = fPath def on_get(self, req, rep, aid=None): @@ -194,9 +196,18 @@ def __init__(self, hby): self.hby = hby self.lookup = {} - def add_lookup(self, path, fPath): + def add_lookup(self, path, fPath, aid=None): self.lookup[path] = fPath + if aid is None: + aid = os.path.basename(os.path.normpath(path.rstrip(f"/{KERI_CESR}"))) + ahab = self.hby.makeHab(name=aid, temp=True) + kvy = eventing.Kevery(db=ahab.db, lax=False, local=False) + with open(fPath, 'rb') as file: + ba = bytearray(file.read()) + parsing.Parser().parse(ims=ba, kvy=kvy) + assert ahab.pre in kvy.kevers + def on_get(self, req, rep, aid=None): """ GET endpoint for acessing {KERI_CESR} stream for AID @@ -217,10 +228,10 @@ def on_get(self, req, rep, aid=None): raise falcon.HTTPNotFound(description=f"keri.cesr for KERI AID {aid} not found") # 404 if AID not recognized - if aid not in self.hby.kevers: - raise falcon.HTTPNotFound(description=f"KERI AID {aid} not found") + # if aid not in self.hby.kevers: + # raise falcon.HTTPNotFound(description=f"KERI AID {aid} not found") - print(f"Serving data for {aid}") + print(f"Serving KERI CESR data for {aid}") port = "" if req.port != 80 and req.port != 443: port = f"%3A{req.port}" diff --git a/tests/app/core/test_didding.py b/tests/app/core/test_didding.py index 6b4157a..883ff02 100644 --- a/tests/app/core/test_didding.py +++ b/tests/app/core/test_didding.py @@ -91,6 +91,61 @@ def test_parse_webs_did(): assert "my:path" == path assert aid, "BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha" +def test_parse_web_did(): + with pytest.raises(ValueError): + did = "did:web:127.0.0.1:1234567" + domain, port, path, aid = didding.parseDIDWebs(did) + + did = "did:web:127.0.0.1:BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha" + domain, port, path, aid = didding.parseDIDWebs(did) + assert "127.0.0.1" == domain + assert None == port + assert None == path + assert aid == "BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha" + + # port url should be url encoded with %3a according to the spec + did_port_bad = ( + "did:web:127.0.0.1:7676:BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha" + ) + domain, port, path, aid = didding.parseDIDWebs(did_port_bad) + assert "127.0.0.1" == domain + assert None == port + assert "7676" == path + assert aid == "BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha" + + did_port = "did:web:127.0.0.1%3a7676:BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha" + domain, port, path, aid = didding.parseDIDWebs(did_port) + assert "127.0.0.1" == domain + assert "7676" == port + assert None == path + assert aid == "BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha" + + # port should be url encoded with %3a according to the spec + did_port_path_bad = ( + "did:web:127.0.0.1:7676:my:path:BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha" + ) + domain, port, path, aid = didding.parseDIDWebs(did_port_path_bad) + assert "127.0.0.1" == domain + assert None == port + assert "7676:my:path" == path + assert aid == "BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha" + + # port is properly url encoded with %3a according to the spec + did_port_path = ( + "did:web:127.0.0.1%3a7676:my:path:BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha" + ) + domain, port, path, aid = didding.parseDIDWebs(did_port_path) + assert "127.0.0.1" == domain + assert "7676" == port + assert "my:path" == path + assert aid == "BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha" + + did_path = "did:web:127.0.0.1:my:path:BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha" + domain, port, path, aid = didding.parseDIDWebs(did_path) + assert "127.0.0.1" == domain + assert None == port + assert "my:path" == path + assert aid, "BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha" @pytest.fixture def setup_habs(): diff --git a/volume/dkr/examples/get_started_webs_resolve.sh b/volume/dkr/examples/get_started_webs_resolve.sh index 9b08871..44706b9 100755 --- a/volume/dkr/examples/get_started_webs_resolve.sh +++ b/volume/dkr/examples/get_started_webs_resolve.sh @@ -8,4 +8,4 @@ hostPath=$2 aid=$3 # generate controller did:webs for EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP at labs.hyperledger.org -dkr did webs resolve --name "${ctrlName}" --did "did:webs:${hostPath}:${aid}" \ No newline at end of file +dkr did webs resolve --name "${ctrlName}" --did "did:webs:${hostPath}:${aid}" diff --git a/volume/dkr/examples/my-scripts/keri/cf/config-docker.json b/volume/dkr/examples/my-scripts/keri/cf/config-docker.json index d74a59c..c682373 100755 --- a/volume/dkr/examples/my-scripts/keri/cf/config-docker.json +++ b/volume/dkr/examples/my-scripts/keri/cf/config-docker.json @@ -5,6 +5,6 @@ "http://witnesshost:5644/oobi/BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX/controller", "http://witnesshost:5643/oobi/BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM/controller" ], - "keri.cesr.dir": "./", - "did.doc.dir": "./" + "keri.cesr.dir": "/usr/local/var/webs/volume/dkr/pages/", + "did.doc.dir": "/usr/local/var/webs/volume/dkr/pages/" } \ No newline at end of file diff --git a/volume/dkr/pages/ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe/did.json b/volume/dkr/pages/ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe/did.json new file mode 100644 index 0000000..622f4f4 --- /dev/null +++ b/volume/dkr/pages/ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe/did.json @@ -0,0 +1 @@ +{"id": "did:web:did-webs-service%3a7676:ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe", "verificationMethod": [{"id": "#DHr0-I-mMN7h6cLMOTRJkkfPuMd0vgQPrOk4Y3edaHjr", "type": "JsonWebKey", "controller": "did:web:did-webs-service%3a7676:ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe", "publicKeyJwk": {"kid": "DHr0-I-mMN7h6cLMOTRJkkfPuMd0vgQPrOk4Y3edaHjr", "kty": "OKP", "crv": "Ed25519", "x": "evT4j6Yw3uHpwsw5NEmSR8-4x3S-BA-s6Thjd51oeOs"}}], "service": [], "alsoKnownAs": []} \ No newline at end of file diff --git a/volume/dkr/pages/ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe/keri.cesr b/volume/dkr/pages/ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe/keri.cesr new file mode 100644 index 0000000..2a06ebf --- /dev/null +++ b/volume/dkr/pages/ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe/keri.cesr @@ -0,0 +1 @@ +{"v":"KERI10JSON00012b_","t":"icp","d":"ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe","i":"ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe","s":"0","kt":"1","k":["DHr0-I-mMN7h6cLMOTRJkkfPuMd0vgQPrOk4Y3edaHjr"],"nt":"1","n":["ELa775aLyane1vdiJEuexP8zrueiIoG995pZPGJiBzGX"],"bt":"0","b":[],"c":[],"a":[]}-VAn-AABAADjfOjbPu9OWce59OQIc-y3Su4kvfC2BAd_e_NLHbXcOK8-3s6do5vBfrxQ1kDyvFGCPMcSl620dLMZ4QDYlvME-EAB0AAAAAAAAAAAAAAAAAAAAAAA1AAG2024-01-01T14c06c32d442992p00c00 \ No newline at end of file diff --git a/volume/pages/EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP/did.json b/volume/pages/EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP/did.json deleted file mode 100644 index e5a5704..0000000 --- a/volume/pages/EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP/did.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "id": "did:web:labs.hyperledger.org:did-webs-resolver:pages:EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP", - "verificationMethod": [ - { - "id": "#DHr0-I-mMN7h6cLMOTRJkkfPuMd0vgQPrOk4Y3edaHjr", - "type": "JsonWebKey", - "controller": "did:web:labs.hyperledger.org:did-webs-resolver:pages:EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP", - "publicKeyJwk": { - "kid": "DHr0-I-mMN7h6cLMOTRJkkfPuMd0vgQPrOk4Y3edaHjr", - "kty": "OKP", - "crv": "Ed25519", - "x": "evT4j6Yw3uHpwsw5NEmSR8-4x3S-BA-s6Thjd51oeOs" - } - } - ], - "service": [ - { - "id": "#BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha/witness", - "type": "witness", - "serviceEndpoint": { - "http": "http://witnesshost:5642/", - "tcp": "tcp://witnesshost:5632/" - } - }, - { - "id": "#BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha/witness", - "type": "witness", - "serviceEndpoint": { - "http": "http://witnesshost:5642/", - "tcp": "tcp://witnesshost:5632/" - } - }, - { - "id": "#BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha/witness", - "type": "witness", - "serviceEndpoint": { - "http": "http://witnesshost:5642/", - "tcp": "tcp://witnesshost:5632/" - } - } - ], - "alsoKnownAs": [] -} \ No newline at end of file diff --git a/volume/pages/EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP/keri.cesr b/volume/pages/EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP/keri.cesr deleted file mode 100644 index b1e91bc..0000000 --- a/volume/pages/EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP/keri.cesr +++ /dev/null @@ -1,23 +0,0 @@ -{ - "v": "KERI10JSON0001b7_", - "t": "icp", - "d": "EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP", - "i": "EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP", - "s": "0", - "kt": "1", - "k": [ - "DHr0-I-mMN7h6cLMOTRJkkfPuMd0vgQPrOk4Y3edaHjr" - ], - "nt": "1", - "n": [ - "ELa775aLyane1vdiJEuexP8zrueiIoG995pZPGJiBzGX" - ], - "bt": "3", - "b": [ - "BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha", - "BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM", - "BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX" - ], - "c": [], - "a": [] -}-VBq-AABAABv33lz0MENsIaM2J1hsbl_8awkJlVT7M1Cnzix0JQSEEwhfSsOt5Wqvuw27wUUKZLCScKoT01FV4WfowFrh_MN-BADAAC_SiZWJFOCuIB_py4gqaMFQtTVWtFCpPfP2LgyqqUS2naTh0nZNlH6MPHSbQNRoImkHnMFrUiBr5ZtwvQ-tNwIABBazaCrt7WQD5Dj1U3KqlZhgOPh7-ca2S0BnRRSEHxW5yoECaC04nyTxYh_wU9TH2WLr14hP-mLHHJDM-wM2esOACA2lyZPmqv2mefIL3orZNm8vb7pyLO5R4zOhHqqXkS1utJrKndiNd4Yu4c6xJnVkc-l6DABB9qe-otLGCkoWDEI-EAB0AAAAAAAAAAAAAAAAAAAAAAA1AAG2023-12-17T20c35c38d614937p00c00 \ No newline at end of file From 4bddca6f876777d8a1b2a6f66d0172449818e591 Mon Sep 17 00:00:00 2001 From: 2byrds <2byrds@gmail.com> Date: Tue, 2 Jan 2024 16:18:54 -0500 Subject: [PATCH 14/17] in the middle of a test to fix the missing hab bug during resolve call Signed-off-by: 2byrds <2byrds@gmail.com> --- GETTING_STARTED.md | 12 ++-- docker-compose.yml | 26 ++++---- images/did-keri-resolver-service.dockerfile | 4 +- images/did-webs-resolver-service.dockerfile | 7 +-- images/did-webs-service.dockerfile | 4 +- images/dkr.dockerfile | 13 ---- images/webs.dockerfile | 10 ++++ integration/app/integration.sh | 1 + setup.py | 6 +- src/dkr/app/cli/commands/did/webs/resolve.py | 10 +--- src/dkr/core/resolving.py | 7 +++ src/dkr/core/webbing.py | 10 ++-- tests/app/core/test_didding.py | 60 ++++++++++++++++++- volume/dkr/examples/get_started_create_id.sh | 2 +- .../my-scripts/keri/cf/config-local.json | 4 +- 15 files changed, 115 insertions(+), 61 deletions(-) delete mode 100644 images/dkr.dockerfile create mode 100644 images/webs.dockerfile diff --git a/GETTING_STARTED.md b/GETTING_STARTED.md index 2518719..1ec326f 100644 --- a/GETTING_STARTED.md +++ b/GETTING_STARTED.md @@ -10,7 +10,7 @@ Let's get started! We'll use docker to setup and run in a simple environment. ## Run Docker build ``` -docker compose build +docker compose build --no-cache ``` ## Run Docker containers for the keri witness network and the `did:webs` generator and resolver environment @@ -48,12 +48,12 @@ The example salt we use in the scripts: `command:` ``` -kli init --name controller --salt 0AAQmsjh-C7kAJZQEzdrzwB7 --nopasscode --config-dir ./my-scripts --config-file config-docker +kli init --name controller --salt 0AAQmsjh-C7kAJZQEzdrzwB7 --nopasscode --config-dir /usr/local/var/webs/volume/dkr/examples/my-scripts --config-file config-docker ``` ```output:``` ``` -bash-5.1# kli init --name controller --salt 0AAQmsjh-C7kAJZQEzdrzwB7 --nopasscode --config-dir ./my-scripts --config-file config-docker +bash-5.1# kli init --name controller --salt 0AAQmsjh-C7kAJZQEzdrzwB7 --nopasscode --config-dir /usr/local/var/webs/volume/dkr/examples/my-scripts --config-file config-docker KERI Keystore created at: /usr/local/var/keri/ks/controller KERI Database created at: /usr/local/var/keri/db/controller KERI Credential Store created at: /usr/local/var/keri/reg/controller @@ -68,7 +68,7 @@ http://witnesshost:5644/oobi/BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX/contro `command:` ``` -kli incept --name controller --alias controller --file ./my-scripts/incept.json +kli incept --name controller --alias controller --file /usr/local/var/webs/volume/dkr/examples/my-scripts/incept.json ``` ```output:``` @@ -81,7 +81,7 @@ Your AID is ```ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe``` and your current #### Additional info The AID config-file in the container is at ./my-scripts/keri/cf/config-docker.json and contains the KERI OOBIs of the witnesses that we'll use: -In this case they are available from the witness network that we started in the docker-compose. If you `cat` the config at `./my-scripts/keri/cf/config-docker.json` you should see: +In this case they are available from the witness network that we started in the docker-compose. If you `cat` the config at `/usr/local/var/webs/volume/dkr/examples/my-scripts/keri/cf/config-docker.json` you should see: `config:` ```json @@ -319,7 +319,7 @@ But the exact spot to extract the files as text would be something like: ``` http://raw.githubusercontent.com/WOT-terms/test/did-webs-iiw37-tutorial/[your AID] ``` -The reason for this confusion is dat a static page generator like Docusaurus or Jekyll might interfere with the location, visibility and accessibility of your files on Github Pages. +The reason for this confusion is that a static page generator like Docusaurus or Jekyll might interfere with the location, visibility and accessibility of your files on Github Pages. We advise to choose a simple public directory that you control and we won't go into more detail on how to deal with static site generators. diff --git a/docker-compose.yml b/docker-compose.yml index faf4e07..3deeb2b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,6 +5,7 @@ services: container_name: witnesshost hostname: witnesshost image: gleif/keri:latest + platform: linux/amd64 tty: true ports: - 5642:5642 # witness @@ -12,17 +13,17 @@ services: - 5644:5644 # witness entrypoint: kli witness demo - dkr: - container_name: dkr - hostname: dkr + webs: + container_name: webs + hostname: webs build: context: . - dockerfile: ./images/dkr.dockerfile - image: gleif/dkr:latest + dockerfile: ./images/webs.dockerfile + image: 2byrds/webs:latest tty: true volumes: - - ~/VSCode/did-keri-resolver/volume/dkr/examples:/usr/local/var/webs/volume/dkr/examples - - ~/VSCode/did-keri-resolver/volume/dkr/pages:/usr/local/var/webs/volume/dkr/pages + - ~/VSCode/did-keri-resolver/volume/dkr/examples:/usr/local/var/webs/volume/webs/examples + - ~/VSCode/did-keri-resolver/volume/dkr/pages:/usr/local/var/webs/volume/webs/pages did-webs-service: container_name: did-webs-service @@ -30,13 +31,14 @@ services: build: context: . dockerfile: ./images/did-webs-service.dockerfile - # image: ./images/did-webs-service:latest + depends_on: + - webs ports: - 7676:7676 tty: true volumes: - - ~/VSCode/did-keri-resolver/volume/dkr/examples:/usr/local/var/webs/volume/dkr/examples - - ~/VSCode/did-keri-resolver/volume/dkr/pages:/usr/local/var/webs/volume/dkr/pages + - ~/VSCode/did-keri-resolver/volume/dkr/examples:/usr/local/var/webs/volume/webs/examples + - ~/VSCode/did-keri-resolver/volume/dkr/pages:/usr/local/var/webs/volume/webs/pages did-webs-resolver-service: container_name: did-webs-resolver @@ -44,7 +46,9 @@ services: build: context: . dockerfile: ./images/did-webs-resolver-service.dockerfile - # image: gleif/did-webs-resolver:latest + image: did-webs-resolver:latest ports: - 7677:7677 tty: true + depends_on: + - webs diff --git a/images/did-keri-resolver-service.dockerfile b/images/did-keri-resolver-service.dockerfile index aeee361..ecd18ba 100644 --- a/images/did-keri-resolver-service.dockerfile +++ b/images/did-keri-resolver-service.dockerfile @@ -1,5 +1,5 @@ -FROM gleif/dkr:latest +FROM 2byrds/webs:latest EXPOSE 7678 -CMD ["/usr/local/var/webs/scripts/webs-resolver-service.sh"] +CMD ["/usr/local/var/webs/scripts/webs-resolver-service.sh"] \ No newline at end of file diff --git a/images/did-webs-resolver-service.dockerfile b/images/did-webs-resolver-service.dockerfile index 02c3731..1dea501 100644 --- a/images/did-webs-resolver-service.dockerfile +++ b/images/did-webs-resolver-service.dockerfile @@ -1,8 +1,5 @@ -FROM gleif/dkr:latest +FROM 2byrds/webs:latest EXPOSE 7677 -WORKDIR /usr/local/var/webs/volume/dkr/examples - - -#RUN dkr did webs resolver-service --config-dir=./scripts \ No newline at end of file +WORKDIR /usr/local/var/webs/volume/webs/examples \ No newline at end of file diff --git a/images/did-webs-service.dockerfile b/images/did-webs-service.dockerfile index e86ea92..dcb21db 100644 --- a/images/did-webs-service.dockerfile +++ b/images/did-webs-service.dockerfile @@ -1,5 +1,5 @@ -FROM gleif/dkr:latest +FROM 2byrds/webs:latest EXPOSE 7676 -WORKDIR /usr/local/var/webs/volume/dkr/pages \ No newline at end of file +WORKDIR /usr/local/var/webs/volume/webs/pages \ No newline at end of file diff --git a/images/dkr.dockerfile b/images/dkr.dockerfile deleted file mode 100644 index 6aed700..0000000 --- a/images/dkr.dockerfile +++ /dev/null @@ -1,13 +0,0 @@ -FROM gleif/keri:latest - -WORKDIR /usr/local/var - -RUN mkdir webs -COPY . /usr/local/var/webs - -WORKDIR /usr/local/var/webs/ - -RUN pip install -r requirements.txt -# RUN cd /usr/local/var/webs/volume/dkr/examples -# RUN ./get_started_create_id.sh "controller" "./my-scripts" "config-docker" "incept-wits.json" -# RUN ./get_started_webs_gen.sh "controller" "did-webs-service%3a7676" "EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP" diff --git a/images/webs.dockerfile b/images/webs.dockerfile new file mode 100644 index 0000000..37f6693 --- /dev/null +++ b/images/webs.dockerfile @@ -0,0 +1,10 @@ +FROM gleif/keri:latest + +WORKDIR /usr/local/var + +RUN mkdir webs +COPY . /usr/local/var/webs + +WORKDIR /usr/local/var/webs/ + +RUN pip install -r requirements.txt diff --git a/integration/app/integration.sh b/integration/app/integration.sh index 67741ba..df5f4ea 100755 --- a/integration/app/integration.sh +++ b/integration/app/integration.sh @@ -66,6 +66,7 @@ function genDidWebs() { source "${start_webs_gen}" "${controller}" "${host}%3a7676" "${aid}" sleep 3 echo "Completed loading generating did:webs" + cp -R "${ORIG_CUR_DIR}/${aid}" "${ORIG_CUR_DIR}/volume/dkr/pages/${aid}" else echo "Couldn't find get started did:webs script" fi diff --git a/setup.py b/setup.py index 236ef69..fff84fe 100644 --- a/setup.py +++ b/setup.py @@ -34,11 +34,11 @@ name='dkr', version='0.0.1', # also change in src/did-webs-resolver/__init__.py license='Apache Software License 2.0', - description='did:keri DID Method Resolver', - long_description="did:keri DID Method Resolver.", + description='did:webs DID Method Resolver', + long_description="did:webs DID Method Resolver.", author='Philip S. Feairheller', author_email='pfeairheller@gmail.com', - url='https://github.com/WebOfTrust/kara', + url='https://github.com/hyperledger-labs/did-webs-resolver', packages=find_packages('src'), package_dir={'': 'src'}, py_modules=[splitext(basename(path))[0] for path in glob('src/*.py')], diff --git a/src/dkr/app/cli/commands/did/webs/resolve.py b/src/dkr/app/cli/commands/did/webs/resolve.py index 4b737d4..686aa41 100644 --- a/src/dkr/app/cli/commands/did/webs/resolve.py +++ b/src/dkr/app/cli/commands/did/webs/resolve.py @@ -71,7 +71,7 @@ def resolve(self, tymth, tock=0.0, **opts): # Load the KERI CESR kc_url = f"{base_url}/{webbing.KERI_CESR}" print(f"Loading KERI CESR from {kc_url}", file=sys.stderr) - self.hby.psr.parse(ims=bytearray(self.loadUrl(kc_url))) + self.hby.psr.parse(ims=bytearray(self.loadUrl(kc_url)),kvy=self.hby.kvy) didresult = didding.generateDIDDoc(self.hby, did=self.did, aid=aid, oobi=None, metadata=True) didresult['didDocumentMetadata']['didDocUrl'] = dd_url @@ -101,14 +101,6 @@ def loadUrl(self, url): response.raise_for_status() # Convert the content to a bytearray return response.content - - def loadFile(self, aid): - # File path - file_path = f"./keri_cesr/{aid}/{webbing.KERI_CESR}" - # Read the file in binary mode - with open(file_path, 'rb') as file: - msgs = file.read() - return msgs def verifyDidDocs(self, expected, actual): if expected != actual: diff --git a/src/dkr/core/resolving.py b/src/dkr/core/resolving.py index 6287c37..c646607 100644 --- a/src/dkr/core/resolving.py +++ b/src/dkr/core/resolving.py @@ -135,3 +135,10 @@ def __next__(self): self.finished = True return self.data.encode("utf-8") + + +def loadFile(file_path): + # Read the file in binary mode + with open(file_path, 'rb') as file: + msgs = file.read() + return msgs \ No newline at end of file diff --git a/src/dkr/core/webbing.py b/src/dkr/core/webbing.py index 98b24ed..76eb8dc 100644 --- a/src/dkr/core/webbing.py +++ b/src/dkr/core/webbing.py @@ -74,7 +74,7 @@ def loadEnds(app, hby, web): else: prefix = f"/{web.lstrip('/').rstrip('/')}/" - path = f"{prefix}/{{aid}}/{DID_JSON}" + path = f"{prefix}/{DID_JSON}" print(f"Added route {path}") app.add_route(path, res) @@ -201,12 +201,10 @@ def add_lookup(self, path, fPath, aid=None): if aid is None: aid = os.path.basename(os.path.normpath(path.rstrip(f"/{KERI_CESR}"))) - ahab = self.hby.makeHab(name=aid, temp=True) - kvy = eventing.Kevery(db=ahab.db, lax=False, local=False) + # ahab = habbing..makeHab(name=aid, temp=True) + # kvy = eventing.Kevery(db=ahab.db, lax=False, local=False) with open(fPath, 'rb') as file: - ba = bytearray(file.read()) - parsing.Parser().parse(ims=ba, kvy=kvy) - assert ahab.pre in kvy.kevers + self.hby.psr.parse(ims=bytearray(file.read())) def on_get(self, req, rep, aid=None): """ GET endpoint for acessing {KERI_CESR} stream for AID diff --git a/tests/app/core/test_didding.py b/tests/app/core/test_didding.py index 883ff02..d33fe6a 100644 --- a/tests/app/core/test_didding.py +++ b/tests/app/core/test_didding.py @@ -4,8 +4,9 @@ """ import json +import os import pytest -from dkr.core import didding +from dkr.core import didding, resolving import keri import re @@ -357,6 +358,63 @@ def test_gen_did_doc_with_metadata(setup_habs): != None ) +def test_gen_did_doc_no_hab(setup_habs): + hby, hab, wesHby, wesHab, did = setup_habs + aid = "ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe" + + try: + didDoc = didding.generateDIDDoc(hby, did, aid, oobi=None, metadata=False) + except KeyError as e: + assert str(e) == f"'{aid}'" + + hab = hby.makeHab(name=aid) + cwd = os.getcwd() + print(f"Current directory {cwd}") + msgs = resolving.loadFile("./volume/dkr/pages/ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe/keri.cesr") + hab.psr.parse(ims=msgs) + + didDoc = didding.generateDIDDoc(hby, did, aid, oobi=None, metadata=False) + + assert ( + didDoc["id"] + == "did:webs:127.0.0.1:BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha" + ) + + assert didDoc["verificationMethod"] == [ + { + "id": "#DCQbRBx58zbRPs8R9cXl-MMbPaxH1EPHdWp3ICSdQSyp", + "type": "JsonWebKey", + "controller": "did:webs:127.0.0.1:BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha", + "publicKeyJwk": { + "kid": "DCQbRBx58zbRPs8R9cXl-MMbPaxH1EPHdWp3ICSdQSyp", + "kty": "OKP", + "crv": "Ed25519", + "x": "JBtEHHnzNtE-zxH1xeX4wxs9rEfUQ8d1ancgJJ1BLKk", + }, + } + ] + + assert len(didDoc["service"]) == 4 + assert didDoc["service"][0] == { + "id": "#EGadHcyW9IfVIPrFUAa_I0z4dF8QzQAvUvfaUTJk8Jre/controller", + "type": "controller", + "serviceEndpoint": {"http": "http://127.0.0.1:7777"}, + } + assert didDoc["service"][1] == { + "id": "#EBErgFZoM3PBQNTpTuK9bax_U8HLJq1Re2RM1cdifaTJ/mailbox", + "type": "mailbox", + "serviceEndpoint": {"http": "http://127.0.0.1:6666"}, + } + assert didDoc["service"][2] == { + "id": "#EBErgFZoM3PBQNTpTuK9bax_U8HLJq1Re2RM1cdifaTJ/registrar", + "type": "registrar", + "serviceEndpoint": {"http": "http://127.0.0.1:6666"}, + } + assert didDoc["service"][3] == { + "id": "#BN8t3n1lxcV0SWGJIIF46fpSUqA7Mqre5KJNN3nbx3mr/witness", + "type": "witness", + "serviceEndpoint": {"http": "http://127.0.0.1:8888"}, + } def da_cred(): """ diff --git a/volume/dkr/examples/get_started_create_id.sh b/volume/dkr/examples/get_started_create_id.sh index c0d066e..7fb4823 100755 --- a/volume/dkr/examples/get_started_create_id.sh +++ b/volume/dkr/examples/get_started_create_id.sh @@ -1,5 +1,5 @@ #!/bin/bash -set -x +# set -x # RUN cd /usr/local/var/webs/volume/dkr/examples # RUN ./get_started_create_id.sh "controller" "./my-scripts" "config-docker" "incept-wits.json" diff --git a/volume/dkr/examples/my-scripts/keri/cf/config-local.json b/volume/dkr/examples/my-scripts/keri/cf/config-local.json index 1b02013..6aa3a8c 100755 --- a/volume/dkr/examples/my-scripts/keri/cf/config-local.json +++ b/volume/dkr/examples/my-scripts/keri/cf/config-local.json @@ -8,6 +8,6 @@ "durls": [ "https://weboftrust.github.io/oobi/EN6Oh5XSD5_q2Hgu-aqpdfbVepdpYpFlgz6zvJL5b_r5" ], - "keri.cesr.dir": "./", - "did.doc.dir": "./" + "keri.cesr.dir": "./volume/dkr/pages/", + "did.doc.dir": "./volume/dkr/pages/" } \ No newline at end of file From 48225d227e3b9ad7cf0a08e1d6ca9c00f93ddbec Mon Sep 17 00:00:00 2001 From: 2byrds <2byrds@gmail.com> Date: Tue, 2 Jan 2024 19:47:04 -0500 Subject: [PATCH 15/17] added unit test for non-hab aid Signed-off-by: 2byrds <2byrds@gmail.com> --- src/dkr/core/didding.py | 65 ++++++++++++++++++---------------- src/dkr/core/resolving.py | 6 ++++ tests/app/core/test_didding.py | 56 ++++++----------------------- 3 files changed, 51 insertions(+), 76 deletions(-) diff --git a/src/dkr/core/didding.py b/src/dkr/core/didding.py index 80501ac..f070b15 100644 --- a/src/dkr/core/didding.py +++ b/src/dkr/core/didding.py @@ -54,7 +54,9 @@ def parseDIDWebs(did): def generateDIDDoc(hby: habbing.Habery, did, aid, oobi=None, metadata=None, reg_name=None): - hab = hby.habs[aid] + hab = None + if aid in hby.habs: + hab = hby.habs[aid] if oobi is not None: obr = hby.db.roobi.get(keys=(oobi,)) @@ -183,37 +185,38 @@ def desAliases(hby: habbing.Habery, aid: str, reg_name: str=None): """ Returns the credentialer for the des-aliases schema, or None if it doesn't exist. """ - if reg_name is None: - reg_name = hby.habs[aid].name - rgy = credentialing.Regery(hby=hby, name=reg_name) - vry = verifying.Verifier(hby=hby, reger=rgy.reger) - - saids = rgy.reger.issus.get(keys=aid) - scads = rgy.reger.schms.get(keys=DES_ALIASES_SCHEMA.encode("utf-8")) - # self-attested, there is no issuee, and schmea is designated aliases - saiders = [saider for saider in saids if saider.qb64 in [saider.qb64 for saider in scads]] - da_ids = [] - # for saider in saiders: - creds = rgy.reger.cloneCreds(saiders) - - for idx, cred in enumerate(creds): - sad = cred['sad'] - status = cred["status"] - schema = sad['s'] - scraw = vry.resolver.resolve(schema) - schemer = scheming.Schemer(raw=scraw) - print(f"Credential #{idx+1}: {sad['d']}") - print(f" Type: {schemer.sed['title']}") - if status['et'] == 'iss' or status['et'] == 'bis': - print(f" Status: Issued {terming.Colors.OKGREEN}{terming.Symbols.CHECKMARK}{terming.Colors.ENDC}") - da_ids = sad['a']['ids'] - elif status['et'] == 'rev' or status['et'] == 'brv': - print(f" Status: Revoked {terming.Colors.FAIL}{terming.Symbols.FAILED}{terming.Colors.ENDC}") - else: - print(f" Status: Unknown") - print(f" Issued by {sad['i']}") - print(f" Issued on {status['dt']}") + if aid in hby.habs: + if reg_name is None: + reg_name = hby.habs[aid].name + rgy = credentialing.Regery(hby=hby, name=reg_name) + vry = verifying.Verifier(hby=hby, reger=rgy.reger) + + saids = rgy.reger.issus.get(keys=aid) + scads = rgy.reger.schms.get(keys=DES_ALIASES_SCHEMA.encode("utf-8")) + # self-attested, there is no issuee, and schmea is designated aliases + saiders = [saider for saider in saids if saider.qb64 in [saider.qb64 for saider in scads]] + + # for saider in saiders: + creds = rgy.reger.cloneCreds(saiders) + + for idx, cred in enumerate(creds): + sad = cred['sad'] + status = cred["status"] + schema = sad['s'] + scraw = vry.resolver.resolve(schema) + schemer = scheming.Schemer(raw=scraw) + print(f"Credential #{idx+1}: {sad['d']}") + print(f" Type: {schemer.sed['title']}") + if status['et'] == 'iss' or status['et'] == 'bis': + print(f" Status: Issued {terming.Colors.OKGREEN}{terming.Symbols.CHECKMARK}{terming.Colors.ENDC}") + da_ids = sad['a']['ids'] + elif status['et'] == 'rev' or status['et'] == 'brv': + print(f" Status: Revoked {terming.Colors.FAIL}{terming.Symbols.FAILED}{terming.Colors.ENDC}") + else: + print(f" Status: Unknown") + print(f" Issued by {sad['i']}") + print(f" Issued on {status['dt']}") return da_ids diff --git a/src/dkr/core/resolving.py b/src/dkr/core/resolving.py index c646607..d414fff 100644 --- a/src/dkr/core/resolving.py +++ b/src/dkr/core/resolving.py @@ -141,4 +141,10 @@ def loadFile(file_path): # Read the file in binary mode with open(file_path, 'rb') as file: msgs = file.read() + return msgs + +def loadJsonFile(file_path): + # Read the file in binary mode + with open(file_path, 'r', encoding="utf-8") as file: + msgs = json.load(file) return msgs \ No newline at end of file diff --git a/tests/app/core/test_didding.py b/tests/app/core/test_didding.py index d33fe6a..a2a9093 100644 --- a/tests/app/core/test_didding.py +++ b/tests/app/core/test_didding.py @@ -359,62 +359,28 @@ def test_gen_did_doc_with_metadata(setup_habs): ) def test_gen_did_doc_no_hab(setup_habs): - hby, hab, wesHby, wesHab, did = setup_habs + hby, hab, wesHby, wesHab, wdid = setup_habs aid = "ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe" + did = f"did:web:did-webs-service%3a7676:{aid}" try: didDoc = didding.generateDIDDoc(hby, did, aid, oobi=None, metadata=False) except KeyError as e: assert str(e) == f"'{aid}'" - hab = hby.makeHab(name=aid) - cwd = os.getcwd() - print(f"Current directory {cwd}") - msgs = resolving.loadFile("./volume/dkr/pages/ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe/keri.cesr") - hab.psr.parse(ims=msgs) + msgs = resolving.loadFile(f"./volume/dkr/pages/{aid}/keri.cesr") + hby.psr.parse(ims=msgs) didDoc = didding.generateDIDDoc(hby, did, aid, oobi=None, metadata=False) - assert ( - didDoc["id"] - == "did:webs:127.0.0.1:BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha" - ) - - assert didDoc["verificationMethod"] == [ - { - "id": "#DCQbRBx58zbRPs8R9cXl-MMbPaxH1EPHdWp3ICSdQSyp", - "type": "JsonWebKey", - "controller": "did:webs:127.0.0.1:BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha", - "publicKeyJwk": { - "kid": "DCQbRBx58zbRPs8R9cXl-MMbPaxH1EPHdWp3ICSdQSyp", - "kty": "OKP", - "crv": "Ed25519", - "x": "JBtEHHnzNtE-zxH1xeX4wxs9rEfUQ8d1ancgJJ1BLKk", - }, - } - ] + expected = resolving.loadJsonFile(f"./volume/dkr/pages/{aid}/did.json") + + assert (didDoc["id"] == expected["id"]) + assert (didDoc["id"].startswith("did:web:")) + assert (didDoc["id"].endswith(f"{aid}")) + assert didDoc["verificationMethod"] == expected["verificationMethod"] - assert len(didDoc["service"]) == 4 - assert didDoc["service"][0] == { - "id": "#EGadHcyW9IfVIPrFUAa_I0z4dF8QzQAvUvfaUTJk8Jre/controller", - "type": "controller", - "serviceEndpoint": {"http": "http://127.0.0.1:7777"}, - } - assert didDoc["service"][1] == { - "id": "#EBErgFZoM3PBQNTpTuK9bax_U8HLJq1Re2RM1cdifaTJ/mailbox", - "type": "mailbox", - "serviceEndpoint": {"http": "http://127.0.0.1:6666"}, - } - assert didDoc["service"][2] == { - "id": "#EBErgFZoM3PBQNTpTuK9bax_U8HLJq1Re2RM1cdifaTJ/registrar", - "type": "registrar", - "serviceEndpoint": {"http": "http://127.0.0.1:6666"}, - } - assert didDoc["service"][3] == { - "id": "#BN8t3n1lxcV0SWGJIIF46fpSUqA7Mqre5KJNN3nbx3mr/witness", - "type": "witness", - "serviceEndpoint": {"http": "http://127.0.0.1:8888"}, - } + assert len(didDoc["service"]) == 0 def da_cred(): """ From 0dc58ba42d9e744ee45cda87393e25e9a9ea382c Mon Sep 17 00:00:00 2001 From: 2byrds <2byrds@gmail.com> Date: Wed, 3 Jan 2024 16:26:20 -0500 Subject: [PATCH 16/17] recreating integration bug in integration script. will fix the bug next Signed-off-by: 2byrds <2byrds@gmail.com> --- GETTING_STARTED.md | 35 ++++++++++++------- docker-compose.yml | 8 ++--- images/did-webs-resolver-service.dockerfile | 2 +- images/did-webs-service.dockerfile | 2 +- integration/app/integration.sh | 34 +++++++++++------- src/dkr/app/cli/commands/did/webs/resolve.py | 8 +++-- volume/dkr/examples/get_started_create_id.sh | 12 ++++--- .../my-scripts/keri/cf/my-config.json | 3 ++ .../keri.cesr | 2 +- 9 files changed, 67 insertions(+), 39 deletions(-) diff --git a/GETTING_STARTED.md b/GETTING_STARTED.md index 1ec326f..8cb0a89 100644 --- a/GETTING_STARTED.md +++ b/GETTING_STARTED.md @@ -23,7 +23,7 @@ docker compose up -d ## Enter the dkr docker environment command line to begin running keri, etc. commands ``` -docker compose exec dkr /bin/bash +docker compose exec webs /bin/bash ``` ## Create your KERI identifier @@ -53,7 +53,6 @@ kli init --name controller --salt 0AAQmsjh-C7kAJZQEzdrzwB7 --nopasscode --config ```output:``` ``` -bash-5.1# kli init --name controller --salt 0AAQmsjh-C7kAJZQEzdrzwB7 --nopasscode --config-dir /usr/local/var/webs/volume/dkr/examples/my-scripts --config-file config-docker KERI Keystore created at: /usr/local/var/keri/ks/controller KERI Database created at: /usr/local/var/keri/db/controller KERI Credential Store created at: /usr/local/var/keri/reg/controller @@ -125,7 +124,6 @@ dkr did webs generate --name controller --did "did:webs:did-webs-service%3a7676: `output:` ``` -bash-5.1# dkr did webs generate --name controller --did "did:webs:did-webs-service%3a7676:ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe" Generating CESR event stream data from hab Generating ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe KEL CESR events Writing CESR events to ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe/keri.cesr: @@ -163,9 +161,11 @@ You can access these files either from within your Docker container or on your l E.g. using git, Github pages, FTP, SCP, etc. -### Example: serve from docker +## Example: serve from docker You can run the docker example service to serve the did.json and keri.cesr files for the other docker containers: +First, lets copy our generated files to the directory we'll serve from. On your local machine (or within the container) you can copy `volume/dkr/examples/ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe` to `volume/dkr/pages/ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe`: + ``` docker compose exec did-webs-service /bin/bash ``` @@ -186,7 +186,7 @@ Looking for did.json file /usr/local/var/webs/volume/dkr/pages/ENro7uf0ePmiK3jdT registering /ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe/did.json ``` -It will serve it at a URL that you can CURL from any other docker container (for instance from the dkr container) like: +It will serve it at a URL that you can CURL from any other docker container (for instance from the webs container) like: ``` curl -GET http://did-webs-service:7676/ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe/did.json @@ -195,9 +195,20 @@ and ``` curl -GET http://did-webs-service:7676/ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe/keri.cesr ``` +### Example: Resolve AID as did:webs using local resolver +Back in the webs docker container, you can resolve the DID from the did-webs-service: + +Initialize a `verifier` environment: +``` +kli init --name verifier --nopasscode +``` +Resolve the did:webs for the `controller` did: +``` +dkr did webs resolve --name verifier --did "did:webs:did-webs-service%3a7676:ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe" +``` -### Example: WOT-terms install using GIT +## Example: WOT-terms install using GIT We choose `WOT-terms` as our [DESTINATION LOCAL REPO] @@ -223,7 +234,7 @@ git push upstream main ``` If you get the expected output of the push action, the files are on the controlled webserver. -## Check if files are available on your server +### Check if files are available on your server Note: Replace with your actual web address and AID @@ -232,7 +243,7 @@ https://peacekeeper.github.io/did-webs-iiw37-tutorial/EKYGGh-FtAphGmSZbsuBs_t4qp https://peacekeeper.github.io/did-webs-iiw37-tutorial/EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP/keri.cesr -## (Optional) Resolve AID as did:keri using local resolver +### (Optional) Resolve AID as did:keri using local resolver Optionally resolve the AID locally as did:keri, given an OOBI as resolution option. @@ -242,7 +253,7 @@ Note: Replace with your actual AID dkr did keri resolve --name controller --did did:keri:EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP --oobi http://witnesshost:5642/oobi/EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP/witness/BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha ``` -## (Optional) Resolve AID as did:webs using local resolver +### (Optional) Resolve AID as did:webs using local resolver Optionally resolve the AID locally as did:webs. @@ -252,15 +263,15 @@ Note: Replace with your actual web address and AID dkr did webs resolve --name controller --did did:webs:peacekeeper.github.io:did-webs-iiw37-tutorial:EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP ``` -## Resolve as did:web using Universal Resolver +### Resolve as did:web using Universal Resolver https://dev.uniresolver.io/#did:web:peacekeeper.github.io:did-webs-iiw37-tutorial:EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP -## Resolve as did:webs using Universal Resolver +### Resolve as did:webs using Universal Resolver https://dev.uniresolver.io/#did:webs:peacekeeper.github.io:did-webs-iiw37-tutorial:EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP -## Example key rotation +### Example key rotation Use the following two commands in your running Docker container. diff --git a/docker-compose.yml b/docker-compose.yml index 3deeb2b..7fd9983 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -22,8 +22,8 @@ services: image: 2byrds/webs:latest tty: true volumes: - - ~/VSCode/did-keri-resolver/volume/dkr/examples:/usr/local/var/webs/volume/webs/examples - - ~/VSCode/did-keri-resolver/volume/dkr/pages:/usr/local/var/webs/volume/webs/pages + - ~/VSCode/did-keri-resolver/volume/dkr/examples:/usr/local/var/webs/volume/dkr/examples + - ~/VSCode/did-keri-resolver/volume/dkr/pages:/usr/local/var/webs/volume/dkr/pages did-webs-service: container_name: did-webs-service @@ -37,8 +37,8 @@ services: - 7676:7676 tty: true volumes: - - ~/VSCode/did-keri-resolver/volume/dkr/examples:/usr/local/var/webs/volume/webs/examples - - ~/VSCode/did-keri-resolver/volume/dkr/pages:/usr/local/var/webs/volume/webs/pages + - ~/VSCode/did-keri-resolver/volume/dkr/examples:/usr/local/var/webs/volume/dkr/examples + - ~/VSCode/did-keri-resolver/volume/dkr/pages:/usr/local/var/webs/volume/dkr/pages did-webs-resolver-service: container_name: did-webs-resolver diff --git a/images/did-webs-resolver-service.dockerfile b/images/did-webs-resolver-service.dockerfile index 1dea501..a4fe485 100644 --- a/images/did-webs-resolver-service.dockerfile +++ b/images/did-webs-resolver-service.dockerfile @@ -2,4 +2,4 @@ FROM 2byrds/webs:latest EXPOSE 7677 -WORKDIR /usr/local/var/webs/volume/webs/examples \ No newline at end of file +WORKDIR /usr/local/var/webs/volume/dkr/examples \ No newline at end of file diff --git a/images/did-webs-service.dockerfile b/images/did-webs-service.dockerfile index dcb21db..5566b4c 100644 --- a/images/did-webs-service.dockerfile +++ b/images/did-webs-service.dockerfile @@ -2,4 +2,4 @@ FROM 2byrds/webs:latest EXPOSE 7676 -WORKDIR /usr/local/var/webs/volume/webs/pages \ No newline at end of file +WORKDIR /usr/local/var/webs/volume/dkr/pages \ No newline at end of file diff --git a/integration/app/integration.sh b/integration/app/integration.sh index df5f4ea..2e8ac34 100755 --- a/integration/app/integration.sh +++ b/integration/app/integration.sh @@ -7,22 +7,26 @@ # If there is an error you can search for running services (on mac) with # sudo lsof -i -P -n | grep LISTEN | grep -#print commands -# set -x +# print commands +set -x #save this current directory, this is where the integration_clienting file also is ORIG_CUR_DIR=$( pwd ) -controller="controller" +controller="my-controller" +csalt="0AAQmsjh-C7kAJZQEzdrzwB7" +verifier="my-verifier" +vsalt="0ABPTOtI5Qy8dCYNSs3uoCHe" host="127.0.0.1" -aid="EKYGGh-FtAphGmSZbsuBs_t4qpsjYJ2ZqvMKluq9OxmP" +caid="ELCUOZXs-0xn3jOihm0AJ-L8XTFVT8SnIpmEDhFF9Kz_" +vaid="ENdjGq0Hfxtr0tBe7TzAtS2A6Gv9wEGu7GjFKcARalUE" KERI_BRANCH="main" # KERI_TAG="c3a6fc455b5fac194aa9c264e48ea2c52328d4c5" KERI_PRIMARY_STORAGE="/usr/local/var/keri/" KERI_FALLBACK_STORAGE="${HOME}/.keri/" db_files=() -db_names=("$controller" wan wes wil wit wub wyz) +db_names=("$controller" "$verifier" wan wes wil wit wub wyz) for db_name in "${db_names[@]}"; do path="${KERI_PRIMARY_STORAGE}*/${db_name}*" db_files+=( $path ) @@ -63,10 +67,10 @@ function genDidWebs() { start_webs_gen="${ORIG_CUR_DIR}/volume/dkr/examples/get_started_webs_gen.sh" if [ -f "${start_webs_gen}" ]; then echo "Found get started script to generate did:webs" - source "${start_webs_gen}" "${controller}" "${host}%3a7676" "${aid}" + source "${start_webs_gen}" "${controller}" "${host}%3a7676" "${caid}" sleep 3 echo "Completed loading generating did:webs" - cp -R "${ORIG_CUR_DIR}/${aid}" "${ORIG_CUR_DIR}/volume/dkr/pages/${aid}" + cp -R "${ORIG_CUR_DIR}/${caid}" "${ORIG_CUR_DIR}/volume/dkr/pages/${caid}" else echo "Couldn't find get started did:webs script" fi @@ -113,7 +117,7 @@ function intro() { fi } -function createKeriId() { +function createKeriIds() { cd ${ORIG_CUR_DIR} || exit kloadPid=-1 default_kload="y" @@ -129,7 +133,9 @@ function createKeriId() { create_aid_script="${ORIG_CUR_DIR}/volume/dkr/examples/get_started_create_id.sh" if [ -f "${create_aid_script}" ]; then echo "Found get started create id script" - source "${create_aid_script}" "${controller}" "${ORIG_CUR_DIR}/volume/dkr/examples/my-scripts" "config-local" "${ORIG_CUR_DIR}/volume/dkr/examples/my-scripts/incept-wits.json" + source "${create_aid_script}" "${controller}" "${csalt}" "${ORIG_CUR_DIR}/volume/dkr/examples/my-scripts" "config-local" "${ORIG_CUR_DIR}/volume/dkr/examples/my-scripts/incept-wits.json" + sleep 3 + source "${create_aid_script}" "${verifier}" "${vsalt}" "${ORIG_CUR_DIR}/volume/dkr/examples/my-scripts" "config-local-verifier" "${ORIG_CUR_DIR}/volume/dkr/examples/my-scripts/incept.json" sleep 3 echo "Completed creating KERI identity" else @@ -154,7 +160,9 @@ function resolveDIDAndKeriEvents() { res_webs_script="${ORIG_CUR_DIR}/volume/dkr/examples/get_started_webs_resolve.sh" if [ -f "${res_webs_script}" ]; then echo "Found get started resolve script" - source "${res_webs_script}" "${controller}" "${host}%3a7676" "${aid}" + # kli init --name "${verifier}" --salt 0ABPTOtI5Qy8dCYNSs3uoCHe --nopasscode + # kli incept --name "${verifier}" --alias "${verifier}" --file "${ORIG_CUR_DIR}/volume/dkr/examples/my-scripts/incept.json" + source "${res_webs_script}" "${verifier}" "${host}%3a7676" "${caid}" sleep 3 echo "Resolved did:webs identity" else @@ -212,8 +220,8 @@ function serveDidAndKeriEvents() { source "${srv_webs_script}" "${controller}" "${ORIG_CUR_DIR}/volume/dkr/examples/my-scripts" "config-local" servePid=$! echo "Serving did:webs and keri events @pid ${servePid}" - echo "DID doc served at http://${host}:7676/${aid}/did.json" - echo "KERI CESR at http://${host}:7676/${aid}/keri.cesr" + echo "DID doc served at http://${host}:7676/${caid}/did.json" + echo "KERI CESR at http://${host}:7676/${caid}/keri.cesr" else echo "Couldn't find get started serve script" fi @@ -257,7 +265,7 @@ do runKeri - createKeriId + createKeriIds genDidWebs diff --git a/src/dkr/app/cli/commands/did/webs/resolve.py b/src/dkr/app/cli/commands/did/webs/resolve.py index 686aa41..56283b3 100644 --- a/src/dkr/app/cli/commands/did/webs/resolve.py +++ b/src/dkr/app/cli/commands/did/webs/resolve.py @@ -52,7 +52,7 @@ def __init__(self, hby, hbyDoer, obl, did, metadata): doers = list(self.toRemove) + [doing.doify(self.resolve)] super(WebsResolver, self).__init__(doers=doers) - def resolve(self, tymth, tock=0.0, **opts): + def resolve(self, tymth, tock=0.125, **opts): self.wind(tymth) self.tock = tock _ = (yield self.tock) @@ -71,7 +71,11 @@ def resolve(self, tymth, tock=0.0, **opts): # Load the KERI CESR kc_url = f"{base_url}/{webbing.KERI_CESR}" print(f"Loading KERI CESR from {kc_url}", file=sys.stderr) - self.hby.psr.parse(ims=bytearray(self.loadUrl(kc_url)),kvy=self.hby.kvy) + kc_bytes = self.loadUrl(kc_url) + print(f"Got KERI CESR: {kc_bytes.decode('utf-8')}", file=sys.stderr) + self.hby.psr.parse(ims=bytearray(kc_bytes)) + print("Waiting for KERI CESR to be processed...") + yield 3.0 didresult = didding.generateDIDDoc(self.hby, did=self.did, aid=aid, oobi=None, metadata=True) didresult['didDocumentMetadata']['didDocUrl'] = dd_url diff --git a/volume/dkr/examples/get_started_create_id.sh b/volume/dkr/examples/get_started_create_id.sh index 7fb4823..c6a4260 100755 --- a/volume/dkr/examples/get_started_create_id.sh +++ b/volume/dkr/examples/get_started_create_id.sh @@ -7,18 +7,20 @@ #controller ctrlName=$1 +#salt +ctrlSalt=$2 #./my-scripts -configDir=$2 +configDir=$3 #my-config -configFile=$3 +configFile=$4 #./my-scripts/my-incept.json -inceptFile=$4 +inceptFile=$5 echo "Init KERI id config file at ${configDir}/keri/cf/${configFile} contains:" -cat "${configDir}/keri/cf/${configFile}" +cat "${configDir}/keri/cf/${configFile}.json" # init environment for controller AID -kli init --name "${ctrlName}" --salt 0AAQmsjh-C7kAJZQEzdrzwB7 --nopasscode --config-dir "${configDir}" --config-file "${configFile}" +kli init --name "${ctrlName}" --salt "${ctrlSalt}" --nopasscode --config-dir "${configDir}" --config-file "${configFile}" echo "Incept KERI id config file at ${inceptFile} contains:" cat "${inceptFile}" diff --git a/volume/dkr/examples/my-scripts/keri/cf/my-config.json b/volume/dkr/examples/my-scripts/keri/cf/my-config.json index e69de29..96a9550 100755 --- a/volume/dkr/examples/my-scripts/keri/cf/my-config.json +++ b/volume/dkr/examples/my-scripts/keri/cf/my-config.json @@ -0,0 +1,3 @@ +{ + "dt": "2022-01-20T12:57:59.823350+00:00" +} \ No newline at end of file diff --git a/volume/dkr/pages/ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe/keri.cesr b/volume/dkr/pages/ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe/keri.cesr index 2a06ebf..3683a53 100644 --- a/volume/dkr/pages/ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe/keri.cesr +++ b/volume/dkr/pages/ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe/keri.cesr @@ -1 +1 @@ -{"v":"KERI10JSON00012b_","t":"icp","d":"ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe","i":"ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe","s":"0","kt":"1","k":["DHr0-I-mMN7h6cLMOTRJkkfPuMd0vgQPrOk4Y3edaHjr"],"nt":"1","n":["ELa775aLyane1vdiJEuexP8zrueiIoG995pZPGJiBzGX"],"bt":"0","b":[],"c":[],"a":[]}-VAn-AABAADjfOjbPu9OWce59OQIc-y3Su4kvfC2BAd_e_NLHbXcOK8-3s6do5vBfrxQ1kDyvFGCPMcSl620dLMZ4QDYlvME-EAB0AAAAAAAAAAAAAAAAAAAAAAA1AAG2024-01-01T14c06c32d442992p00c00 \ No newline at end of file +{"v":"KERI10JSON00012b_","t":"icp","d":"ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe","i":"ENro7uf0ePmiK3jdTo2YCdXLqW7z7xoP6qhhBou6gBLe","s":"0","kt":"1","k":["DHr0-I-mMN7h6cLMOTRJkkfPuMd0vgQPrOk4Y3edaHjr"],"nt":"1","n":["ELa775aLyane1vdiJEuexP8zrueiIoG995pZPGJiBzGX"],"bt":"0","b":[],"c":[],"a":[]}-VAn-AABAADjfOjbPu9OWce59OQIc-y3Su4kvfC2BAd_e_NLHbXcOK8-3s6do5vBfrxQ1kDyvFGCPMcSl620dLMZ4QDYlvME-EAB0AAAAAAAAAAAAAAAAAAAAAAA1AAG2024-01-02T14c12c15d456835p00c00 \ No newline at end of file From ef12efa34083e6f146f094ba7505a8a81b9715a8 Mon Sep 17 00:00:00 2001 From: 2byrds <2byrds@gmail.com> Date: Fri, 5 Jan 2024 08:15:26 -0500 Subject: [PATCH 17/17] integration testing for the verifier/resolver. i'll create issues for the current bugs Signed-off-by: 2byrds <2byrds@gmail.com> --- integration/app/integration.sh | 2 +- src/dkr/app/cli/commands/did/webs/resolve.py | 2 +- src/dkr/core/didding.py | 10 +- .../app/cli/commands/did/webs/test_resolve.py | 137 ++++++++++++++++++ .../keri/cf/config-local-verifier.json | 13 ++ 5 files changed, 161 insertions(+), 3 deletions(-) create mode 100644 tests/app/cli/commands/did/webs/test_resolve.py create mode 100755 volume/dkr/examples/my-scripts/keri/cf/config-local-verifier.json diff --git a/integration/app/integration.sh b/integration/app/integration.sh index 2e8ac34..a8c3119 100755 --- a/integration/app/integration.sh +++ b/integration/app/integration.sh @@ -19,7 +19,7 @@ verifier="my-verifier" vsalt="0ABPTOtI5Qy8dCYNSs3uoCHe" host="127.0.0.1" caid="ELCUOZXs-0xn3jOihm0AJ-L8XTFVT8SnIpmEDhFF9Kz_" -vaid="ENdjGq0Hfxtr0tBe7TzAtS2A6Gv9wEGu7GjFKcARalUE" +vaid="EKK9_Aau-htVcu8HyAZCIUkTFMqyVB6I2LCa_GhMYWm2" KERI_BRANCH="main" # KERI_TAG="c3a6fc455b5fac194aa9c264e48ea2c52328d4c5" diff --git a/src/dkr/app/cli/commands/did/webs/resolve.py b/src/dkr/app/cli/commands/did/webs/resolve.py index 56283b3..5194c28 100644 --- a/src/dkr/app/cli/commands/did/webs/resolve.py +++ b/src/dkr/app/cli/commands/did/webs/resolve.py @@ -72,7 +72,7 @@ def resolve(self, tymth, tock=0.125, **opts): kc_url = f"{base_url}/{webbing.KERI_CESR}" print(f"Loading KERI CESR from {kc_url}", file=sys.stderr) kc_bytes = self.loadUrl(kc_url) - print(f"Got KERI CESR: {kc_bytes.decode('utf-8')}", file=sys.stderr) + print(f"Got KERI CESR: {kc_bytes.decode('utf-8')}") self.hby.psr.parse(ims=bytearray(kc_bytes)) print("Waiting for KERI CESR to be processed...") yield 3.0 diff --git a/src/dkr/core/didding.py b/src/dkr/core/didding.py index f070b15..36e6e77 100644 --- a/src/dkr/core/didding.py +++ b/src/dkr/core/didding.py @@ -65,7 +65,15 @@ def generateDIDDoc(hby: habbing.Habery, did, aid, oobi=None, metadata=None, reg_ data = json.dumps(msg) return data.encode("utf-8") - kever = hby.kevers[aid] + kever = None + if aid in hby.kevers: + kever = hby.kevers[aid] + else: + print(f"Habery does not have a kever for {did}. Did you parse the keri.cesr file?") + for kev in hby.kevers: + print("Known kevers: ", kev) + hby.kevers[aid] + vms = [] for idx, verfer in enumerate(kever.verfers): kid = verfer.qb64 diff --git a/tests/app/cli/commands/did/webs/test_resolve.py b/tests/app/cli/commands/did/webs/test_resolve.py new file mode 100644 index 0000000..a3ff873 --- /dev/null +++ b/tests/app/cli/commands/did/webs/test_resolve.py @@ -0,0 +1,137 @@ +import json + +import falcon +from falcon import testing, media, http_status +from hio.base import doing + +import keri +from dkr.app.cli.commands.did.webs import resolve +from hio.core import http +from keri.app import habbing, oobiing +from keri.core import coring +from keri.db import basing +from keri.end import ending +from keri.help import helping +from keri import help, kering + +import os +import time + +class ExampleEnd: + def on_get(self, req, rep): + """ + Handles GET requests + """ + message = "\nHello World\n\n" + rep.status = falcon.HTTP_200 # This is the default status + rep.content_type = "text/html" + rep.text = message + +class DidWebsEnd: + """ Test endpoint returning a static did document """ + def __init__(self, url): + self.url = url + + def on_get(self, req, rep): + """ Return a did document + + Args: + req (Request): Falcon request object + rep (Response): Falcon response object + + """ + a = { + "urls": [ + self.url + ] + } + + rep.status = falcon.HTTP_200 + rep.content_type = "application/json" + rep.data = "{reply: '/ELCUOZXs-0xn3jOihm0AJ-L8XTFVT8SnIpmEDhFF9Kz_/did.json'}" + +class KeriCesrEnd: + """ Test endpoint returning a static keri cesr file """ + def __init__(self, url): + self.url = url + + def on_get(self, req, rep): + """ Return a did document + + Args: + req (Request): Falcon request object + rep (Response): Falcon response object + + """ + a = { + "urls": [ + self.url + ] + } + + rep.status = falcon.HTTP_200 + rep.content_type = "application/json" + rep.data = "{reply: 'http://127.0.0.1:7676/ELCUOZXs-0xn3jOihm0AJ-L8XTFVT8SnIpmEDhFF9Kz_/keri.cesr'}" + +def test_resolver(): + with habbing.openHby(name="verifier") as hby: + hab = hby.makeHab(name="verifier") + hbyDoer = habbing.HaberyDoer(habery=hby) # setup doer + obl = oobiing.Oobiery(hby=hby) + did = "did:web:127.0.0.1%3a7676:ELCUOZXs-0xn3jOihm0AJ-L8XTFVT8SnIpmEDhFF9Kz_" + res = resolve.WebsResolver(hby,hbyDoer,obl,did,False) + + # Configure the did doc and keri cesr URL + ddurl = f'http://127.0.0.1:7676/ELCUOZXs-0xn3jOihm0AJ-L8XTFVT8SnIpmEDhFF9Kz_/did.json' + kcurl = f'http://127.0.0.1:7676/ELCUOZXs-0xn3jOihm0AJ-L8XTFVT8SnIpmEDhFF9Kz_/keri.cesr' + + app = falcon.App(middleware=falcon.CORSMiddleware( + allow_origins='*', allow_credentials='*', + expose_headers=['cesr-attachment', 'cesr-date', 'content-type', 'signature', 'signature-input', + 'signify-resource', 'signify-timestamp'])) + + print("CORS enabled") + app.add_middleware(middleware=HandleCORS()) + app.req_options.media_handlers.update(media.Handlers()) + app.resp_options.media_handlers.update(media.Handlers()) + # falcon.App instances are callable WSGI apps + example = ExampleEnd() # Resources are represented by long-lived class instances + app.add_route('/example', example) + dd = DidWebsEnd(url=ddurl) + kc = KeriCesrEnd(url=kcurl) + app.add_route(f"/did", dd) + app.add_route(f"/cesr", kc) + + server = http.Server(host="127.0.0.1",port=7676, app=app, scheme="http") + httpServerDoer = http.ServerDoer(server=server) + + client = testing.TestClient(app=app) + + rep = client.simulate_get('/example') + assert rep.status == falcon.HTTP_OK + assert rep.text == '\nHello World\n\n' + + limit = 2.0 + tock = 0.03125 + doers = [httpServerDoer] + doist = doing.Doist(limit=limit, tock=tock) + doist.do(doers=doers) + + assert doist.limit == limit + + # obr = hby.db.roobi.get(keys=(kcurl,)) + # assert obr is not None + # assert obr.state == oobiing.Result.resolved + # time.sleep(20) + # doist.exit() + + """Done Test""" + +class HandleCORS(object): + def process_request(self, req, resp): + resp.set_header('Access-Control-Allow-Origin', '*') + resp.set_header('Access-Control-Allow-Methods', '*') + resp.set_header('Access-Control-Allow-Headers', '*') + resp.set_header('Access-Control-Max-Age', 1728000) # 20 days + if req.method == 'OPTIONS': + raise http_status.HTTPStatus(falcon.HTTP_200, text='\n') \ No newline at end of file diff --git a/volume/dkr/examples/my-scripts/keri/cf/config-local-verifier.json b/volume/dkr/examples/my-scripts/keri/cf/config-local-verifier.json new file mode 100755 index 0000000..6aa3a8c --- /dev/null +++ b/volume/dkr/examples/my-scripts/keri/cf/config-local-verifier.json @@ -0,0 +1,13 @@ +{ + "dt": "2022-01-20T12:57:59.823350+00:00", + "iurls": [ + "http://127.0.0.1:5642/oobi/BBilc4-L3tFUnfM_wJr4S4OJanAv_VmF_dJNN6vkf2Ha/controller", + "http://127.0.0.1:5644/oobi/BIKKuvBwpmDVA4Ds-EpL5bt9OqPzWPja2LigFYZN2YfX/controller", + "http://127.0.0.1:5643/oobi/BLskRTInXnMxWaGqcpSyMgo0nYbalW99cGZESrz3zapM/controller" + ], + "durls": [ + "https://weboftrust.github.io/oobi/EN6Oh5XSD5_q2Hgu-aqpdfbVepdpYpFlgz6zvJL5b_r5" + ], + "keri.cesr.dir": "./volume/dkr/pages/", + "did.doc.dir": "./volume/dkr/pages/" + } \ No newline at end of file