Skip to content

Commit

Permalink
fix(sd_jwt): credential_configuration_supported is a dictionary where…
Browse files Browse the repository at this point in the history
  • Loading branch information
matteo-cristino authored and jaromil committed Oct 29, 2024
1 parent 1c9da4e commit ad00236
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
16 changes: 3 additions & 13 deletions src/lua/zencode_sd_jwt.lua
Original file line number Diff line number Diff line change
Expand Up @@ -367,19 +367,9 @@ When("create selective disclosure request from '' with id '' for ''", function(s
local id = have(id_name)
local object = have(object_name)

local creds = ssd.credential_configurations_supported
local pos = 0
for i=1,#creds do
local cred_def = creds[i].credential_definition
for _,v in pairs(cred_def.type) do
if v == id then
pos = i
break
end
end
end
zencode_assert(pos > 0, "Unknown credential id")
local credSubject = creds[pos].credential_definition.credentialSubject
local credential = ssd.credential_configurations_supported[O.to_string(id)]
zencode_assert(credential, "Unknown credential id")
local credSubject = credential.credential_definition.credentialSubject
local fields = {}
for k,_ in pairs(credSubject) do
table.insert(fields, O.from_str(k))
Expand Down
4 changes: 2 additions & 2 deletions test/zencode/sd_jwt.bats
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ SUBDOC=sd_jwt

@test "Import metadata" {
cat <<EOF | save_asset metadata.keys.json
{"supported_selective_disclosure":{"authorization_servers":["http://server.example.org"],"credential_configurations_supported":[{"credential_definition":{"credentialSubject":{"family_name":{"display":[{"locale":"en-US","name":"Family Name"}]},"given_name":{"display":[{"locale":"en-US","name":"Given Name"}]}},"type":["ab8c936e-b9ab-4cf5-9862-c3a25bb82996","VerifiableCredential","IdentityCredential"]},"credential_signing_alg_values_supported":["ES256"],"cryptographic_binding_methods_supported":["jwk","did:dyne:sandbox.signroom"],"display":[{"background_color":"#000000","locale":"en-US","name":"IdentityCredential","text_color":"#ffffff"}],"format":"vc+sd-jwt","proof_types_supported":{"jwt":{"proof_signing_alg_values_supported":["ES256"]}}}],"credential_endpoint":"http://issuer.example.org/credentials","credential_issuer":"http://issuer.example.org"}}
{"supported_selective_disclosure":{"authorization_servers":["http://server.example.org"],"credential_configurations_supported":{"IdentityCredential":{"credential_definition":{"credentialSubject":{"family_name":{"display":[{"locale":"en-US","name":"Family Name"}]},"given_name":{"display":[{"locale":"en-US","name":"Given Name"}]}},"type":["ab8c936e-b9ab-4cf5-9862-c3a25bb82996","VerifiableCredential","IdentityCredential"]},"credential_signing_alg_values_supported":["ES256"],"cryptographic_binding_methods_supported":["jwk","did:dyne:sandbox.signroom"],"display":[{"background_color":"#000000","locale":"en-US","name":"IdentityCredential","text_color":"#ffffff"}],"format":"vc+sd-jwt","proof_types_supported":{"jwt":{"proof_signing_alg_values_supported":["ES256"]}}}},"credential_endpoint":"http://issuer.example.org/credentials","credential_issuer":"http://issuer.example.org"}}
EOF
cat <<EOF | zexe metadata.zen metadata.keys.json
Scenario 'sd_jwt': sign JSON
Expand Down Expand Up @@ -55,7 +55,7 @@ EOF

@test "SSD to SDR" {
cat <<EOF | save_asset object.data.json
{"object":{"age":42,"degree":"math","family_name":"Lippo","given_name":"Mimmo","iss":"http://example.org","sub":"user 42"}, "id": "ab8c936e-b9ab-4cf5-9862-c3a25bb82996"}
{"object":{"age":42,"degree":"math","family_name":"Lippo","given_name":"Mimmo","iss":"http://example.org","sub":"user 42"}, "id": "IdentityCredential"}
EOF
cat <<EOF | zexe ssd_to_sdr.zen object.data.json metadata.keys.json
Scenario 'sd_jwt'
Expand Down

0 comments on commit ad00236

Please sign in to comment.