From 8bde6bde5377e7a70eb8b991e976054af28a33ff Mon Sep 17 00:00:00 2001 From: matteo-cristino Date: Tue, 15 Oct 2024 11:23:40 +0200 Subject: [PATCH] feat(sd_jwt): create the key-value table of disclosed informations --- src/lua/zencode_sd_jwt.lua | 16 ++++++++++++++++ test/zencode/sd_jwt.bats | 15 +++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/src/lua/zencode_sd_jwt.lua b/src/lua/zencode_sd_jwt.lua index 8eb4f4bc4..9ec1fd1c9 100644 --- a/src/lua/zencode_sd_jwt.lua +++ b/src/lua/zencode_sd_jwt.lua @@ -478,3 +478,19 @@ IfWhen("verify signed selective disclosure '' issued by '' is valid", function(o end end) + +When("create disclosed informations from signed selective disclosure ''", function(ssd_name) + local ssd, ssd_c = have(ssd_name) + zencode_assert(ssd_c.schema and ssd_c.schema == "signed_selective_disclosure", + "Object is not a signed selective disclosure: " .. ssd_name) + local disclosed_informations = {} + for _, v in pairs(ssd.disclosures) do + disclosed_informations[v[2]:str()] = v[3] + end + ACK.disclosed_informations = disclosed_informations + new_codec('disclosed_informations', { + encoding = 'string', + luatype = 'table', + zentype = 'd' + }) +end) diff --git a/test/zencode/sd_jwt.bats b/test/zencode/sd_jwt.bats index 914d05a7d..d4c7df55b 100644 --- a/test/zencode/sd_jwt.bats +++ b/test/zencode/sd_jwt.bats @@ -528,3 +528,18 @@ EOF #test vector from App. A.3 of https://www.ietf.org/archive/id/draft-ietf-oauth-selective-disclosure-jwt-07.txt #issuer key from https://github.com/oauth-wg/oauth-selective-disclosure-jwt/blob/master/examples/settings.yml } + +@test "create table of disclosed informations" { + cat <