diff --git a/cli/tests/ion-create-deactivate.sh b/cli/tests/ion-create-deactivate.sh new file mode 100755 index 00000000..5b3d42be --- /dev/null +++ b/cli/tests/ion-create-deactivate.sh @@ -0,0 +1,48 @@ +#!/bin/sh +set -e +cd "$(dirname "$0")" + +# Create and use temp directory if does not already exist +dir=did-ion-test +if test -d "$dir" +then + printf 'Directory already exists: %s\n' "$dir" >&2 + exit 1 +fi +mkdir "$dir" +cd "$dir" + +# Generate initial update keypair and initial recovery keypair +didkit generate-secp256k1-key > 1-u.jwk +didkit generate-secp256k1-key > 1-r.jwk +# Construct Create operation with initial public keys +didkit did-create ion -r 1-r.jwk -u 1-u.jwk | tee 1-create.json +# Get long-form and short-form DID from Create operation +longdid=$(didkit did-from-tx < 1-create.json) +shortdid=$(echo -n "$longdid" | sed 's/:[^:]*$//') +didsuffix=$(echo -n "$shortdid" | sed 's/.*://') +echo "Sidetree DID Suffix: $didsuffix" +echo "DID (long-form/unpublished): $longdid" +echo "DID (short-form/canonical): $shortdid" + +# Now that the DID suffix is set, rename the directory to it. +cd .. +mv "$dir" "$didsuffix" +cd "$didsuffix" + +# Submit Create operation +export DID_ION_API_URL=http://localhost:3000/ +read -p "Press enter to submit Create operation. " _ +didkit did-submit-tx < 1-create.json + +# Construct Deactivate operation to add verification key to DID document +didkit did-deactivate "$shortdid" -k 1-r.jwk | tee 2-deactivate.json +# Submit operation +read -p 'Press enter to submit Deactivate operation. ' _ +if ! didkit did-submit-tx < 2-deactivate.json +then + # Provide retry in case submission failed, e.g. because the + # create operation has not yet been processed. + read -p 'Press enter to retry Deactivate operation. ' _ + didkit did-submit-tx < 2-deactivate.json +fi diff --git a/cli/tests/ion-create-recover.sh b/cli/tests/ion-create-recover.sh new file mode 100755 index 00000000..0e717054 --- /dev/null +++ b/cli/tests/ion-create-recover.sh @@ -0,0 +1,52 @@ +#!/bin/sh +set -e +cd "$(dirname "$0")" + +# Create and use temp directory if does not already exist +dir=did-ion-test +if test -d "$dir" +then + printf 'Directory already exists: %s\n' "$dir" >&2 + exit 1 +fi +mkdir "$dir" +cd "$dir" + +# Generate initial update keypair and initial recovery keypair +didkit generate-secp256k1-key > 1-u.jwk +didkit generate-secp256k1-key > 1-r.jwk +# Construct Create operation with initial public keys +didkit did-create ion -r 1-r.jwk -u 1-u.jwk | tee 1-create.json +# Get long-form and short-form DID from Create operation +longdid=$(didkit did-from-tx < 1-create.json) +shortdid=$(echo -n "$longdid" | sed 's/:[^:]*$//') +didsuffix=$(echo -n "$shortdid" | sed 's/.*://') +echo "Sidetree DID Suffix: $didsuffix" +echo "DID (long-form/unpublished): $longdid" +echo "DID (short-form/canonical): $shortdid" + +# Now that the DID suffix is set, rename the directory to it. +cd .. +mv "$dir" "$didsuffix" +cd "$didsuffix" + +# Submit Create operation +export DID_ION_API_URL=http://localhost:3000/ +read -p "Press enter to submit Create operation. " _ +didkit did-submit-tx < 1-create.json + +# Generate new update keypair and recovery keypair for recover operation +didkit generate-secp256k1-key > 2-u.jwk +didkit generate-secp256k1-key > 2-r.jwk + +# Construct Recover operation +didkit did-recover "$shortdid" -R 1-r.jwk -r 2-r.jwk -u 2-u.jwk | tee 2-recover.json +# Submit operation +read -p 'Press enter to submit Recover operation. ' _ +if ! didkit did-submit-tx < 2-recover.json +then + # Provide retry in case submission failed, e.g. because the + # create operation has not yet been processed. + read -p 'Press enter to retry Recover operation. ' _ + didkit did-submit-tx < 2-recover.json +fi diff --git a/cli/tests/ion-create-update-svc.sh b/cli/tests/ion-create-update-svc.sh new file mode 100755 index 00000000..8e8a7053 --- /dev/null +++ b/cli/tests/ion-create-update-svc.sh @@ -0,0 +1,64 @@ +#!/bin/sh +set -e +cd "$(dirname "$0")" +export DID_ION_API_URL=http://localhost:3000/ + +if false; then + +# Create and use temp directory if does not already exist +dir=did-ion-test +if test -d "$dir" +then + printf 'Directory already exists: %s\n' "$dir" >&2 + exit 1 +fi +mkdir "$dir" +cd "$dir" + +# Generate initial update keypair and initial recovery keypair +didkit generate-secp256k1-key > 1-u.jwk +didkit generate-secp256k1-key > 1-r.jwk +# Construct Create operation with initial public keys +didkit did-create ion -r 1-r.jwk -u 1-u.jwk | tee 1-create.json +# Get long-form and short-form DID from Create operation +longdid=$(didkit did-from-tx < 1-create.json) +shortdid=$(echo -n "$longdid" | sed 's/:[^:]*$//') +didsuffix=$(echo -n "$shortdid" | sed 's/.*://') +echo "Sidetree DID Suffix: $didsuffix" +echo "DID (long-form/unpublished): $longdid" +echo "DID (short-form/canonical): $shortdid" + +# Now that the DID suffix is set, rename the directory to it. +cd .. +mv "$dir" "$didsuffix" +cd "$didsuffix" + + +# Submit Create operation +read -p "Press enter to submit Create operation. " _ +didkit did-submit-tx < 1-create.json + +else + +cd EiD9XruTmYlnZNAqYMjKDSosqnHkAHuw8GeR8nIGpr7nCg +shortdid=did:ion:test:EiD9XruTmYlnZNAqYMjKDSosqnHkAHuw8GeR8nIGpr7nCg + +fi + +# Construct DID URL for new service endpoint +svc="$shortdid#svc-1" + +# Construct Update operation to add verification key to DID document +didkit did-update -U 1-u.jwk -u 2-u.jwk \ + set-service "$svc" \ + -t DIDKitDemoService \ + -e https://demo.didkit.dev/ \ + | tee 2-update.json +# Submit Update operation +read -p 'Press enter to submit Update operation. ' _ +if ! didkit did-submit-tx < 2-update.json +then + read -p 'Press enter to retry submit operation. ' _ + didkit did-submit-tx < 2-update.json +fi + diff --git a/cli/tests/ion-create-update-vm.sh b/cli/tests/ion-create-update-vm.sh new file mode 100755 index 00000000..4d731d59 --- /dev/null +++ b/cli/tests/ion-create-update-vm.sh @@ -0,0 +1,57 @@ +#!/bin/sh +set -e +cd "$(dirname "$0")" + +# Create and use temp directory if does not already exist +dir=did-ion-test +if test -d "$dir" +then + printf 'Directory already exists: %s\n' "$dir" >&2 + exit 1 +fi +mkdir "$dir" +cd "$dir" + +# Generate initial update keypair and initial recovery keypair +didkit generate-secp256k1-key > 1-u.jwk +didkit generate-secp256k1-key > 1-r.jwk +# Construct Create operation with initial public keys +didkit did-create ion -r 1-r.jwk -u 1-u.jwk | tee 1-create.json +# Get long-form and short-form DID from Create operation +longdid=$(didkit did-from-tx < 1-create.json) +shortdid=$(echo -n "$longdid" | sed 's/:[^:]*$//') +didsuffix=$(echo -n "$shortdid" | sed 's/.*://') +echo "Sidetree DID Suffix: $didsuffix" +echo "DID (long-form/unpublished): $longdid" +echo "DID (short-form/canonical): $shortdid" + +# Now that the DID suffix is set, rename the directory to it. +cd .. +mv "$dir" "$didsuffix" +cd "$didsuffix" + +# Submit Create operation +export DID_ION_API_URL=http://localhost:3000/ +read -p "Press enter to submit Create operation. " _ +didkit did-submit-tx < 1-create.json + +# Generate verification key to be added to DID document +didkit generate-secp256k1-key > 2-v.jwk +# Construct DID URL for new verification method +vm="$shortdid#key-1" + +# Generate new update key keypair +didkit generate-secp256k1-key > 2-u.jwk +# Construct Update operation to add verification key to DID document +didkit did-update -U 1-u.jwk -u 2-u.jwk \ + set-verification-method "$vm" -k 2-v.jwk \ + --authentication --assertionMethod -t JsonWebKey2020 \ + | tee 2-update.json +# Submit Update operation +read -p 'Press enter to submit Update operation. ' _ +if ! didkit did-submit-tx < 2-update.json +then + read -p 'Press enter to retry submit operation. ' _ + didkit did-submit-tx < 2-update.json +fi +