Skip to content

Commit

Permalink
Merge pull request #139 from petridishdev/fix/oca-paths
Browse files Browse the repository at this point in the history
fix: oca path encoding
  • Loading branch information
swcurran authored Jun 25, 2024
2 parents 1e4ee8f + dc6ba98 commit 1836c17
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 33 deletions.
3 changes: 2 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"image": "mcr.microsoft.com/devcontainers/typescript-node:0-16",
"features": {
"ghcr.io/devcontainers/features/rust:1": {},
"ghcr.io/eitsupi/devcontainer-features/jq-likes:1": {}
"ghcr.io/eitsupi/devcontainer-features/jq-likes:1": {},
"ghcr.io/devcontainers/features/python": {}
},
"shutdownAction": "none",
// Features to add to the dev container. More info: https://containers.dev/features.
Expand Down
18 changes: 9 additions & 9 deletions ocabundleslist.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
[
{ "id": "AcZpBDz3oxmKrpcuPcdKai:2:Digital~Business~Card:1.0.0", "org": "Digital Trust, Government of British Columbia", "name": "BC Registries Digital Business Card", "desc": "A verifiable credential schema for a business registered within the province of British Columbia", "type": "schema", "ocabundle": "OCABundles/schema/bcgov-digital-trust/business-card/OCABundle.json", "shasum": "34804dbb328cd8741d048121963786f4be63c654abdf0757a10f477c8e8924d5" },
{ "id": "K9igebFysBL6jcBwR8bKuN:2:Digital~Business~Card:1.0.0", "org": "Digital Trust, Government of British Columbia", "name": "BC Registries Digital Business Card", "desc": "A verifiable credential schema for a business registered within the province of British Columbia", "type": "schema", "ocabundle": "OCABundles/schema/bcgov-digital-trust/business-card-showcase/OCABundle.json", "shasum": "aa4dc9de20639a77ab53c419e9e46f405008be170e68ddf4d22551cc0a6be230" },
{ "id": "AcZpBDz3oxmKrpcuPcdKai:2:Digital Business Card:1.0.0", "org": "Digital Trust, Government of British Columbia", "name": "BC Registries Digital Business Card", "desc": "A verifiable credential schema for a business registered within the province of British Columbia", "type": "schema", "ocabundle": "OCABundles/schema/bcgov-digital-trust/business-card/OCABundle.json", "shasum": "34804dbb328cd8741d048121963786f4be63c654abdf0757a10f477c8e8924d5" },
{ "id": "K9igebFysBL6jcBwR8bKuN:2:Digital Business Card:1.0.0", "org": "Digital Trust, Government of British Columbia", "name": "BC Registries Digital Business Card", "desc": "A verifiable credential schema for a business registered within the province of British Columbia", "type": "schema", "ocabundle": "OCABundles/schema/bcgov-digital-trust/business-card-showcase/OCABundle.json", "shasum": "aa4dc9de20639a77ab53c419e9e46f405008be170e68ddf4d22551cc0a6be230" },
{ "id": "4WW6792ksq62UroZyfd6nQ:3:CL:1098:SellingItRight", "org": "LCRB", "name": "LCRB Selling It Right Credential", "desc": "A schema for the \"Selling It Right\" credential issued by LCRB.", "type": "schema", "ocabundle": "OCABundles/schema/bcgov-digital-trust/LCRB/selling-it-right/OCABundle.json", "shasum": "8d574bd0e6a948bf60eb5a7f251235dfd5c1dc9c9b2d2b5de77c5721a91f11b4" },
{ "id": "TeT8SJGHruVL9up3Erp4o:3:CL:224665:Selling~It~Right", "org": "LCRB", "name": "LCRB Selling It Right Credential", "desc": "A schema for the \"Selling It Right\" credential issued by LCRB.", "type": "schema", "ocabundle": "OCABundles/schema/bcgov-digital-trust/LCRB/selling-it-right-showcase/OCABundle.json", "shasum": "fd4011c8a534a7c355256960dafdc7a304c23436446971f36ed84edf6c8807c3" },
{ "id": "TeT8SJGHruVL9up3Erp4o:3:CL:224665:Selling It Right", "org": "LCRB", "name": "LCRB Selling It Right Credential", "desc": "A schema for the \"Selling It Right\" credential issued by LCRB.", "type": "schema", "ocabundle": "OCABundles/schema/bcgov-digital-trust/LCRB/selling-it-right-showcase/OCABundle.json", "shasum": "fd4011c8a534a7c355256960dafdc7a304c23436446971f36ed84edf6c8807c3" },
{ "id": "TeT8SJGHruVL9up3Erp4o:3:CL:400095:SellingItRight", "org": "LCRB", "name": "LCRB Selling It Right Credential", "desc": "A schema for the \"Selling It Right\" credential issued by LCRB.", "type": "schema", "ocabundle": "OCABundles/schema/bcgov-digital-trust/LCRB/selling-it-right-showcase/OCABundle.json", "shasum": "fd4011c8a534a7c355256960dafdc7a304c23436446971f36ed84edf6c8807c3" },
{ "id": "Ttmj1pEotg8FbKZZD81S7i:3:CL:184:SellingItRight", "org": "LCRB", "name": "LCRB Selling It Right Credential", "desc": "A schema for the \"Selling It Right\" credential issued by LCRB.", "type": "schema", "ocabundle": "OCABundles/schema/bcgov-digital-trust/LCRB/selling-it-right-showcase/OCABundle.json", "shasum": "fd4011c8a534a7c355256960dafdc7a304c23436446971f36ed84edf6c8807c3" },
{ "id": "4WW6792ksq62UroZyfd6nQ:3:CL:1098:ServingItRight", "org": "LCRB", "name": "LCRB Serving It Right Credential", "desc": "A schema for the \"Serving It Right\" credential issued by LCRB.", "type": "schema", "ocabundle": "OCABundles/schema/bcgov-digital-trust/LCRB/serving-it-right/OCABundle.json", "shasum": "0c934e349ee17daef2674a55af5c1c6bb1831a7f87eaf082cdc2d9da65ceaa73" },
{ "id": "TeT8SJGHruVL9up3Erp4o:3:CL:224665:Serving~It~Right", "org": "LCRB", "name": "LCRB Serving It Right Credential", "desc": "A schema for the \"Serving It Right\" credential issued by LCRB.", "type": "schema", "ocabundle": "OCABundles/schema/bcgov-digital-trust/LCRB/serving-it-right-showcase/OCABundle.json", "shasum": "427068e5737f9ec0581f43a3b5a562acdd8be8667be4de3f46283d1d095e68ba" },
{ "id": "TeT8SJGHruVL9up3Erp4o:3:CL:224665:Serving It Right", "org": "LCRB", "name": "LCRB Serving It Right Credential", "desc": "A schema for the \"Serving It Right\" credential issued by LCRB.", "type": "schema", "ocabundle": "OCABundles/schema/bcgov-digital-trust/LCRB/serving-it-right-showcase/OCABundle.json", "shasum": "427068e5737f9ec0581f43a3b5a562acdd8be8667be4de3f46283d1d095e68ba" },
{ "id": "TeT8SJGHruVL9up3Erp4o:3:CL:400095:ServingItRight", "org": "LCRB", "name": "LCRB Serving It Right Credential", "desc": "A schema for the \"Serving It Right\" credential issued by LCRB.", "type": "schema", "ocabundle": "OCABundles/schema/bcgov-digital-trust/LCRB/serving-it-right-showcase/OCABundle.json", "shasum": "427068e5737f9ec0581f43a3b5a562acdd8be8667be4de3f46283d1d095e68ba" },
{ "id": "Ttmj1pEotg8FbKZZD81S7i:3:CL:184:ServingItRight", "org": "LCRB", "name": "LCRB Serving It Right Credential", "desc": "A schema for the \"Serving It Right\" credential issued by LCRB.", "type": "schema", "ocabundle": "OCABundles/schema/bcgov-digital-trust/LCRB/serving-it-right-showcase/OCABundle.json", "shasum": "427068e5737f9ec0581f43a3b5a562acdd8be8667be4de3f46283d1d095e68ba" },
{ "id": "4WW6792ksq62UroZyfd6nQ:3:CL:1098:SpecialEventServer", "org": "LCRB", "name": "LCRB Special Event Server Credential", "desc": "A schema for the \"Special Event Server\" credential issued by LCRB.", "type": "schema", "ocabundle": "OCABundles/schema/bcgov-digital-trust/LCRB/special-event-server/OCABundle.json", "shasum": "47f85e79f726204159ca599f825e823033723e136f2474c3b530905ceeac92a0" },
{ "id": "TeT8SJGHruVL9up3Erp4o:3:CL:224665:Special~Event~Server", "org": "LCRB", "name": "LCRB Special Event Server Credential", "desc": "A schema for the \"Special Event Server\" credential issued by LCRB.", "type": "schema", "ocabundle": "OCABundles/schema/bcgov-digital-trust/LCRB/special-event-server-showcase/OCABundle.json", "shasum": "63e057d4bc173f063af1ced0a4a025c12f0db4b5a21b459bf50770de3d13dfb5" },
{ "id": "TeT8SJGHruVL9up3Erp4o:3:CL:224665:Special Event Server", "org": "LCRB", "name": "LCRB Special Event Server Credential", "desc": "A schema for the \"Special Event Server\" credential issued by LCRB.", "type": "schema", "ocabundle": "OCABundles/schema/bcgov-digital-trust/LCRB/special-event-server-showcase/OCABundle.json", "shasum": "63e057d4bc173f063af1ced0a4a025c12f0db4b5a21b459bf50770de3d13dfb5" },
{ "id": "TeT8SJGHruVL9up3Erp4o:3:CL:400095:SpecialEventServer", "org": "LCRB", "name": "LCRB Special Event Server Credential", "desc": "A schema for the \"Special Event Server\" credential issued by LCRB.", "type": "schema", "ocabundle": "OCABundles/schema/bcgov-digital-trust/LCRB/special-event-server-showcase/OCABundle.json", "shasum": "63e057d4bc173f063af1ced0a4a025c12f0db4b5a21b459bf50770de3d13dfb5" },
{ "id": "Ttmj1pEotg8FbKZZD81S7i:3:CL:184:SpecialEventServer", "org": "LCRB", "name": "LCRB Special Event Server Credential", "desc": "A schema for the \"Special Event Server\" credential issued by LCRB.", "type": "schema", "ocabundle": "OCABundles/schema/bcgov-digital-trust/LCRB/special-event-server-showcase/OCABundle.json", "shasum": "63e057d4bc173f063af1ced0a4a025c12f0db4b5a21b459bf50770de3d13dfb5" },
{ "id": "4xE68b6S5VRFrKMMG1U95M:3:CL:59232:default", "org": "Digital Trust, Government of British Columbia", "name": "BC Lawyer Showcase Lawyer Member Card", "desc": "A verifiable credential schema for a lawyer's membership card that used in a demo that is part of the BC Gov Digital Trust Showcase.", "type": "schema", "ocabundle": "OCABundles/schema/bcgov-digital-trust/member-card/OCABundle.json", "shasum": "849fd68e30714d9ad41862e477d1a31468e88099b795e636843c0ece25c6a464" },
Expand All @@ -28,12 +28,12 @@
{ "id": "KCxVC8GkKywjhWJnUfCmkW:3:CL:20:PersonQA", "org": "Digital Trust, Government of British Columbia", "name": "BC Lawyer Showcase Person Credential", "desc": "A schema for a \"person\" credential used in a demo that is part of the BC Gov Digital Trust Showcase.", "type": "schema", "ocabundle": "OCABundles/schema/bcgov-digital-trust/person-showcase/OCABundle.json", "shasum": "84d27be5680762f5d2d59b9cc95a49874ce73dc67af6f854bc246ed7fa8e6dfb" },
{ "id": "7xjfawcnyTUcduWVysLww5:3:CL:28075:PersonSIT", "org": "Digital Trust, Government of British Columbia", "name": "BC Lawyer Showcase Person Credential", "desc": "A schema for a \"person\" credential used in a demo that is part of the BC Gov Digital Trust Showcase.", "type": "schema", "ocabundle": "OCABundles/schema/bcgov-digital-trust/person-showcase/OCABundle.json", "shasum": "84d27be5680762f5d2d59b9cc95a49874ce73dc67af6f854bc246ed7fa8e6dfb" },
{ "id": "XpgeQa93eZvGSZBZef3PHn:3:CL:28075:PersonDEV", "org": "Digital Trust, Government of British Columbia", "name": "BC Lawyer Showcase Person Credential", "desc": "A schema for a \"person\" credential used in a demo that is part of the BC Gov Digital Trust Showcase.", "type": "schema", "ocabundle": "OCABundles/schema/bcgov-digital-trust/person-showcase/OCABundle.json", "shasum": "84d27be5680762f5d2d59b9cc95a49874ce73dc67af6f854bc246ed7fa8e6dfb" },
{ "id": "Mp2pDQqS2eSjNVA7kXc8ut:2:BC~VC~Pilot~Certificate:1.0.1", "org": "Digital Trust, Government of British Columbia", "name": "Digital Identity Trust Program Pilot Invitation", "desc": "A verifiable credential schema for a Pilot Invitation credential to gain access to the Person Credential.", "type": "schema", "ocabundle": "OCABundles/schema/bcgov-digital-trust/pilot/OCABundle.json", "shasum": "044d0e8e66ca5464d9ff712a50bb06ea74d07056c5442c2311dd1fb1a23dc6b3" },
{ "id": "4zBepKVWZcGTzug4X49vAN:2:BC~VC~Pilot~Certificate:1.0.1", "org": "Digital Trust, Government of British Columbia", "name": "Digital Identity Trust Program Pilot Invitation", "desc": "A verifiable credential schema for a Pilot Invitation credential to gain access to the Person Credential.", "type": "schema", "ocabundle": "OCABundles/schema/bcgov-digital-trust/pilot/OCABundle.json", "shasum": "044d0e8e66ca5464d9ff712a50bb06ea74d07056c5442c2311dd1fb1a23dc6b3" },
{ "id": "E2h4RUJxyh48PLJ1CtGJrq:2:BC~VC~Pilot~Certificate:1.0.1", "org": "Digital Trust, Government of British Columbia", "name": "Digital Identity Trust Program Pilot Invitation", "desc": "A verifiable credential schema for a Pilot Invitation credential to gain access to the Person Credential.", "type": "schema", "ocabundle": "OCABundles/schema/bcgov-digital-trust/pilot/OCABundle.json", "shasum": "044d0e8e66ca5464d9ff712a50bb06ea74d07056c5442c2311dd1fb1a23dc6b3" },
{ "id": "Mp2pDQqS2eSjNVA7kXc8ut:2:BC VC Pilot Certificate:1.0.1", "org": "Digital Trust, Government of British Columbia", "name": "Digital Identity Trust Program Pilot Invitation", "desc": "A verifiable credential schema for a Pilot Invitation credential to gain access to the Person Credential.", "type": "schema", "ocabundle": "OCABundles/schema/bcgov-digital-trust/pilot/OCABundle.json", "shasum": "044d0e8e66ca5464d9ff712a50bb06ea74d07056c5442c2311dd1fb1a23dc6b3" },
{ "id": "4zBepKVWZcGTzug4X49vAN:2:BC VC Pilot Certificate:1.0.1", "org": "Digital Trust, Government of British Columbia", "name": "Digital Identity Trust Program Pilot Invitation", "desc": "A verifiable credential schema for a Pilot Invitation credential to gain access to the Person Credential.", "type": "schema", "ocabundle": "OCABundles/schema/bcgov-digital-trust/pilot/OCABundle.json", "shasum": "044d0e8e66ca5464d9ff712a50bb06ea74d07056c5442c2311dd1fb1a23dc6b3" },
{ "id": "E2h4RUJxyh48PLJ1CtGJrq:2:BC VC Pilot Certificate:1.0.1", "org": "Digital Trust, Government of British Columbia", "name": "Digital Identity Trust Program Pilot Invitation", "desc": "A verifiable credential schema for a Pilot Invitation credential to gain access to the Person Credential.", "type": "schema", "ocabundle": "OCABundles/schema/bcgov-digital-trust/pilot/OCABundle.json", "shasum": "044d0e8e66ca5464d9ff712a50bb06ea74d07056c5442c2311dd1fb1a23dc6b3" },
{ "id": "L6ASjmDDbDH7yPL1t2yFj9:2:student_card:1.2", "org": "Digital Trust, Government of British Columbia", "name": "BC Best College Demo Student Card", "desc": "A verifiable credential schema for a Student Card used in a demo that is part of the BC Gov Digital Trust Showcase.", "type": "schema", "ocabundle": "OCABundles/schema/bcgov-digital-trust/student-card/OCABundle.json", "shasum": "e65625acad0f1baab8e05b6cd1a5619b22e1f20cb47768616680a0fb2e8dc21d" },
{ "id": "M6dhuFj5UwbhWkSLmvYSPc:2:student_card:1.6", "org": "Digital Trust, Government of British Columbia", "name": "BC Best College Demo Student Card", "desc": "A verifiable credential schema for a Student Card used in a demo that is part of the BC Gov Digital Trust Showcase.", "type": "schema", "ocabundle": "OCABundles/schema/bcgov-digital-trust/student-card/OCABundle.json", "shasum": "e65625acad0f1baab8e05b6cd1a5619b22e1f20cb47768616680a0fb2e8dc21d" },
{ "id": "QEquAHkM35w4XVT3Ku5yat:2:student_card:1.6", "org": "Digital Trust, Government of British Columbia", "name": "BC Best College Demo Student Card", "desc": "A verifiable credential schema for a Student Card used in a demo that is part of the BC Gov Digital Trust Showcase.", "type": "schema", "ocabundle": "OCABundles/schema/bcgov-digital-trust/student-card/OCABundle.json", "shasum": "e65625acad0f1baab8e05b6cd1a5619b22e1f20cb47768616680a0fb2e8dc21d" },
{ "id": "YXCtXE4YhVjULgj5hrk4ML:2:unverified_person:0.1.0", "org": "Digital Trust, Government of British Columbia", "name": "Unverified Person Credential", "desc": "A verifiable credential schema for an \"unverified\" person, used in various BC Wallet demos where an unofficial Person credential is useful.", "type": "schema", "ocabundle": "OCABundles/schema/bcgov-digital-trust/unverified-person/OCABundle.json", "shasum": "48b20b00cb38bed85b9615674d9af32b0d5e16f75e365c144218dad6ec2b7aa0" },
{ "id": "Ep31SvFAetugFPe5CGzJxt:2:Attestation~numérique~d'identité~gouvernemental~(EXP):1.0", "org": "MCN, Government of Quebec", "name": "QC ANIG ID", "desc": "A verifiable credential schema used for demonstration and internal use purposes only.", "type": "schema", "ocabundle": "OCABundles/schema/qc_anig_demo/Attestation_numérique_didentité_gouvernemental/OCABundle.json", "shasum": "29bf8f8729f235450980d0b273f9ca49b7ab73b7358467bf52b311bf40464bb0" }
{ "id": "Ep31SvFAetugFPe5CGzJxt:2:Attestation numérique d'identité gouvernemental (EXP):1.0", "org": "MCN, Government of Quebec", "name": "QC ANIG ID", "desc": "A verifiable credential schema used for demonstration and internal use purposes only.", "type": "schema", "ocabundle": "OCABundles/schema/qc_anig_demo/Attestation_numérique_didentité_gouvernemental/OCABundle.json", "shasum": "29bf8f8729f235450980d0b273f9ca49b7ab73b7358467bf52b311bf40464bb0" }
]
28 changes: 5 additions & 23 deletions scripts/gen_ocabundlesjson.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,26 +48,6 @@ if [ ! -d "OCABundles" ]; then
exit 1
fi

# Raw URL encode the argument
rawurlencode() {
local string="${1}"
local strlen=${#string}
local encoded=""
local pos c o

for (( pos=0 ; pos<strlen ; pos++ )); do
c=${string:$pos:1}
case "$c" in
[-_.~a-zA-Z0-9] ) o="${c}" ;;
* ) printf -v o '%%%02x' "'$c"
esac
encoded+="${o}"
done
echo "${encoded}" # You can either set a return variable (FASTER)
REPLY="${encoded}" #+or echo the result (EASIER)... or both... :p
}


# In a folder with an OCABundle, process the file, and add the data for the bundle into the JSON files
processBundle() {
BUNDLE_PATH=OCABundle.json
Expand All @@ -81,8 +61,9 @@ processBundle() {
TYPE="credential"
fi
for id in ${ID}; do
echo " \"${id}\": { \"path\": \"${RELPATH}/${BUNDLE_PATH}\", \"sha256\": \"${SHASUM}\" }," | sed "s/~/ /g" >>${OCAIDSJSON}
echo "{ \"id\": \"${id}\", \"org\": \"${ORG}\", \"name\": \"${NAME}\", \"desc\": \"${DESC}\", \"type\": \"${TYPE}\", \"ocabundle\": \"${RELPATH}/${BUNDLE_PATH}\", \"shasum\": \"${SHASUM}\" }," >>${OCALISTJSON}
processed_id=$(echo -n ${id} | sed "s/~/ /g")
echo " \"${processed_id}\": { \"path\": \"${RELPATH}/${BUNDLE_PATH}\", \"sha256\": \"${SHASUM}\" }," >>${OCAIDSJSON}
echo "{ \"id\": \"${processed_id}\", \"org\": \"${ORG}\", \"name\": \"${NAME}\", \"desc\": \"${DESC}\", \"type\": \"${TYPE}\", \"ocabundle\": \"${RELPATH}/${BUNDLE_PATH}\", \"shasum\": \"${SHASUM}\" }," >>${OCALISTJSON}
done
}

Expand All @@ -91,9 +72,10 @@ insertBundleiframe () {
# Do nothing, but $id will be set to the last one...use it
echo -n ""
done
encoded_id=$(echo -n ${id} | sed "s/~/ /g" | jq -sRr @uri)
# We're scanning the real OCABundles file, but want to update the copied files in the docs folder
FILE=${thisDir}/docs/$RELPATH/README.md
sed -e "/## Authorization/i## Credential Appearance\n\n\\<iframe src=\\"https://bcgov.github.io/aries-oca-explorer/identifier/$(rawurlencode ${id})?view=readonly\\" width=\\"100%\\" height=\\"800\\" frameborder=\\"0\\"\\>\\</iframe\\>\n" $FILE >$FILE.tmp
sed -e "/## Authorization/i## Credential Appearance\n\n\\<iframe src=\\"https://bcgov.github.io/aries-oca-explorer/identifier/${encoded_id}?view=readonly\\" width=\\"100%\\" height=\\"800\\" frameborder=\\"0\\"\\>\\</iframe\\>\n" $FILE >$FILE.tmp
mv $FILE.tmp $FILE
}

Expand Down

0 comments on commit 1836c17

Please sign in to comment.