From ad00236a1ae1b992c4282d267a187f82c7cccbee Mon Sep 17 00:00:00 2001 From: matteo-cristino Date: Mon, 28 Oct 2024 16:44:37 +0100 Subject: [PATCH] fix(sd_jwt): credential_configuration_supported is a dictionary where the key is the unique identifier as stated by https://openid.net/specs/openid-4-verifiable-credential-issuance-1_0-13.html#name-credential-issuer-metadata-p --- src/lua/zencode_sd_jwt.lua | 16 +++------------- test/zencode/sd_jwt.bats | 4 ++-- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/src/lua/zencode_sd_jwt.lua b/src/lua/zencode_sd_jwt.lua index 4210473a3..35b864cbd 100644 --- a/src/lua/zencode_sd_jwt.lua +++ b/src/lua/zencode_sd_jwt.lua @@ -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)) diff --git a/test/zencode/sd_jwt.bats b/test/zencode/sd_jwt.bats index 8c596f07d..6b6b5bc89 100644 --- a/test/zencode/sd_jwt.bats +++ b/test/zencode/sd_jwt.bats @@ -4,7 +4,7 @@ SUBDOC=sd_jwt @test "Import metadata" { cat <