Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions api/ssi_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,14 @@ func createVerifiableCredential() vcr.VerifiableCredential {
ssi.MustParseURI("NutsOrganizationCredential"),
ssi.MustParseURI("VerifiableCredential"),
},
Issuer: ssi.MustParseURI("did:nuts:CuE3qeFGGLhEAS3gKzhMCeqd1dGa9at5JCbmCfyMU2Ey"),
IssuanceDate: issuanceDate,
CredentialSubject: []interface{}{"subject"},
Proof: []interface{}{"because"},
Issuer: ssi.MustParseURI("did:nuts:CuE3qeFGGLhEAS3gKzhMCeqd1dGa9at5JCbmCfyMU2Ey"),
IssuanceDate: issuanceDate,
CredentialSubject: []map[string]any{
{
"id": "subject",
},
},
Proof: []interface{}{"because"},
}
}

Expand Down
5 changes: 3 additions & 2 deletions auth/api/auth/v1/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"github.com/nuts-foundation/nuts-node/auth/services/oauth"
"github.com/nuts-foundation/nuts-node/core"
"github.com/nuts-foundation/nuts-node/core/to"
"github.com/nuts-foundation/nuts-node/test"
"github.com/nuts-foundation/nuts-node/vcr"
"github.com/nuts-foundation/nuts-node/vcr/credential"
"github.com/nuts-foundation/nuts-node/vdr"
Expand Down Expand Up @@ -507,7 +508,7 @@ func TestWrapper_RequestAccessToken(t *testing.T) {
Type: []ssi.URI{*credential.NutsAuthorizationCredentialTypeURI, vc.VerifiableCredentialTypeV1URI()},
Issuer: vdr.TestDIDA.URI(),
IssuanceDate: issuanceDate,
CredentialSubject: []interface{}{credential.NutsAuthorizationCredentialSubject{
CredentialSubject: []map[string]any{test.MustRemarshalIntoMap(credential.NutsAuthorizationCredentialSubject{
ID: vdr.TestDIDB.String(),
PurposeOfUse: "eTransfer",
Resources: []credential.Resource{
Expand All @@ -517,7 +518,7 @@ func TestWrapper_RequestAccessToken(t *testing.T) {
UserContext: true,
},
},
}},
})},
Proof: []interface{}{vc.Proof{}},
},
}
Expand Down
7 changes: 1 addition & 6 deletions auth/api/iam/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -754,12 +754,7 @@ func (r Wrapper) RequestServiceAccessToken(ctx context.Context, request RequestS
// by the nuts-node to build the correct wallet for a DID. See https://github.com/nuts-foundation/nuts-node/issues/3696
// As a sideeffect it is no longer possible to pass signed credentials to this API.
for _, cred := range credentials {
var credentialSubject []map[string]interface{}
if err := cred.UnmarshalCredentialSubject(&credentialSubject); err != nil {
// extremely unlikely
return nil, core.InvalidInputError("failed to parse credentialSubject.id: %w", err)
}
for _, credSub := range credentialSubject {
for _, credSub := range cred.CredentialSubject {
if _, ok := credSub["id"]; ok {
return nil, core.InvalidInputError("self-asserted credentials MUST NOT contain a 'credentialSubject.id'")
}
Expand Down
4 changes: 2 additions & 2 deletions auth/api/iam/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1034,7 +1034,7 @@ func TestWrapper_RequestServiceAccessToken(t *testing.T) {
body.Credentials = &[]vc.VerifiableCredential{
{
ID: to.Ptr(ssi.MustParseURI("not empty")),
CredentialSubject: []any{map[string]string{"id": "not empty"}},
CredentialSubject: []map[string]any{{"id": "not empty"}},
},
}
request := RequestServiceAccessTokenRequestObject{SubjectID: holderSubjectID, Body: body}
Expand Down Expand Up @@ -1498,7 +1498,7 @@ func createIssuerCredential(issuerDID did.DID, holderDID did.DID) *vc.Verifiable
Issuer: issuerDID.URI(),
Context: []ssi.URI{credential.NutsV1ContextURI},
Type: []ssi.URI{credType},
CredentialSubject: []interface{}{map[string]interface{}{"id": holderDID.String()}},
CredentialSubject: []map[string]any{{"id": holderDID.String()}},
IssuanceDate: time.Now(),
}
verifiableCredential, _ := vc.CreateJWTVerifiableCredential(nil, template, captureFn)
Expand Down
6 changes: 3 additions & 3 deletions auth/api/iam/s2s_vptoken_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ func TestWrapper_handleS2SAccessTokenRequest(t *testing.T) {
t.Run("VC without credentialSubject.id", func(t *testing.T) {
ctx := newTestClient(t)
presentation := test.CreateJSONLDPresentation(t, *subjectDID, proofVisitor, vc.VerifiableCredential{
CredentialSubject: []interface{}{map[string]string{}},
CredentialSubject: []map[string]any{{}},
})

resp, err := ctx.client.handleS2SAccessTokenRequest(context.Background(), clientID, issuerSubjectID, requestedScope, submissionJSON, presentation.Raw())
Expand Down Expand Up @@ -353,8 +353,8 @@ func TestWrapper_handleS2SAccessTokenRequest(t *testing.T) {
// This indicates the client presented credentials that don't actually match the presentation definition,
// which could indicate a malicious client.
otherVerifiableCredential := vc.VerifiableCredential{
CredentialSubject: []interface{}{
map[string]interface{}{
CredentialSubject: []map[string]any{
{
"id": subjectDID.String(),
// just for demonstration purposes, what matters is that the credential does not match the presentation definition.
"IsAdministrator": true,
Expand Down
4 changes: 2 additions & 2 deletions auth/api/iam/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ func (r Wrapper) issueEmployeeCredential(ctx context.Context, session user.Sessi
Issuer: issuerDID,
IssuanceDate: issuanceDate,
ExpirationDate: &expirationDate,
CredentialSubject: []interface{}{
map[string]string{
CredentialSubject: []map[string]any{
{
"id": session.Wallet.DID.String(),
"identifier": userDetails.Id,
"name": userDetails.Name,
Expand Down
4 changes: 2 additions & 2 deletions auth/api/iam/user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ func TestWrapper_handleUserLanding(t *testing.T) {
assert.Equal(t, jwa.EC, sessionKey.KeyType())
// check for details of issued NutsEmployeeCredential
assert.Equal(t, "NutsEmployeeCredential", employeeCredentialTemplate.Type[0].String())
employeeCredentialSubject := employeeCredentialTemplate.CredentialSubject[0].(map[string]string)
assert.True(t, strings.HasPrefix(employeeCredentialSubject["id"], "did:jwk:"))
employeeCredentialSubject := employeeCredentialTemplate.CredentialSubject[0]
assert.True(t, strings.HasPrefix(employeeCredentialSubject["id"].(string), "did:jwk:"))
assert.Equal(t, userDetails.Id, employeeCredentialSubject["identifier"])
assert.Equal(t, userDetails.Name, employeeCredentialSubject["name"])
assert.Equal(t, userDetails.Role, employeeCredentialSubject["roleName"])
Expand Down
4 changes: 2 additions & 2 deletions auth/client/iam/openid4vp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,8 @@ func TestRelyingParty_RequestRFC021AccessToken(t *testing.T) {
credential.NutsV1ContextURI,
},
Type: []ssi.URI{vc.VerifiableCredentialTypeV1URI(), ssi.MustParseURI("NutsEmployeeCredential")},
CredentialSubject: []interface{}{
map[string]interface{}{
CredentialSubject: []map[string]any{
{
"roleName": "employee",
"name": "John Doe",
"identifier": "123",
Expand Down
20 changes: 11 additions & 9 deletions auth/services/oauth/relying_party_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,17 +133,19 @@ func TestService_CreateJwtBearerToken(t *testing.T) {
Type: []ssi.URI{*credential.NutsAuthorizationCredentialTypeURI, vc.VerifiableCredentialTypeV1URI()},
Issuer: vdr.TestDIDA.URI(),
IssuanceDate: issuanceDate,
CredentialSubject: []interface{}{credential.NutsAuthorizationCredentialSubject{
ID: vdr.TestDIDB.String(),
PurposeOfUse: "eTransfer",
Resources: []credential.Resource{
{
Path: "/composition/1",
Operations: []string{"read"},
UserContext: true,
CredentialSubject: []map[string]any{
{
"id": vdr.TestDIDB.String(),
"purposeOfUse": "eTransfer",
"resources": []any{
map[string]any{
"path": "/composition/1",
"operations": []string{"read"},
"userContext": true,
},
},
},
}},
},
Proof: []interface{}{vc.Proof{}},
}

Expand Down
2 changes: 1 addition & 1 deletion auth/services/selfsigned/signer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ func TestSessionStore_SigningSessionStatus(t *testing.T) {
assert.Equal(t, employer.URI(), credential.Issuer)
assert.Equal(t, []ssi.URI{ssi.MustParseURI("NutsEmployeeCredential")}, credential.Type)

credentialSubject := credential.CredentialSubject[0].(map[string]interface{})
credentialSubject := credential.CredentialSubject[0]
assert.Equal(t, employer.String(), credentialSubject["id"])
assert.Equal(t, "Organization", credentialSubject["type"])
require.IsType(t, map[string]interface{}{}, credentialSubject["member"])
Expand Down
36 changes: 17 additions & 19 deletions auth/services/selfsigned/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ package types

import (
"context"
"encoding/json"
"github.com/nuts-foundation/nuts-node/vcr/credential"
"strings"
"time"
Expand All @@ -44,27 +43,26 @@ type Session struct {
Employee Employee
}

func (s Session) CredentialSubject() []interface{} {
subject := EmployeeIdentityCredentialSubject{
BaseCredentialSubject: credential.BaseCredentialSubject{
ID: s.Employer,
func (s Session) CredentialSubject() []map[string]any {
member := map[string]any{
"identifier": s.Employee.Identifier,
"member": map[string]any{
"familyName": s.Employee.FamilyName,
"initials": s.Employee.Initials,
"type": "Person",
},
Type: "Organization",
Member: EmployeeIdentityCredentialMember{
Identifier: s.Employee.Identifier,
Member: EmployeeIdentityCredentialMemberMember{
FamilyName: s.Employee.FamilyName,
Initials: s.Employee.Initials,
Type: "Person",
},
RoleName: s.Employee.RoleName,
Type: "EmployeeRole",
"type": "EmployeeRole",
}
if s.Employee.RoleName != nil {
member["roleName"] = *s.Employee.RoleName
}
return []map[string]any{
{
"id": s.Employer,
"type": "Organization",
"member": member,
},
}
data, _ := json.Marshal(subject)
result := map[string]interface{}{}
_ = json.Unmarshal(data, &result)
return []interface{}{result}
}

// HumanReadableContract returns the contract text without the contract type (e.g. "NL:LoginContract:v3")
Expand Down
2 changes: 1 addition & 1 deletion auth/services/selfsigned/types/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func TestSession_CredentialSubject(t *testing.T) {
}
res := s.CredentialSubject()
require.Len(t, res, 1)
subject := res[0].(map[string]interface{})
subject := res[0]
// subject is an organization and contains information about the employer
require.Equal(t, "did:nuts:123", subject["id"])
require.Equal(t, "Organization", subject["type"])
Expand Down
8 changes: 4 additions & 4 deletions auth/services/selfsigned/validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -448,10 +448,10 @@ func createOrganizationCredential(issuerDID string) vc.VerifiableCredential {
Context: []ssi.URI{credential.NutsV1ContextURI},
Type: []ssi.URI{ssi.MustParseURI("NutsOrganizationCredential")},
Issuer: did.MustParseDID(issuerDID).URI(),
CredentialSubject: []interface{}{
credential.NutsOrganizationCredentialSubject{
ID: issuerDID,
Organization: map[string]string{
CredentialSubject: []map[string]any{
{
"id": issuerDID,
"organization": map[string]string{
"name": "CareBears",
"city": "CareTown",
},
Expand Down
9 changes: 1 addition & 8 deletions didman/didman.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import (
"github.com/nuts-foundation/nuts-node/didman/log"
"github.com/nuts-foundation/nuts-node/jsonld"
"github.com/nuts-foundation/nuts-node/vcr"
"github.com/nuts-foundation/nuts-node/vcr/credential"
)

// ModuleName contains the name of this module: Didman
Expand Down Expand Up @@ -501,13 +500,7 @@ func (d *didman) resolveOrganizationDIDDocument(organization vc.VerifiableCreden
if len(organization.CredentialSubject) == 0 {
return nil, did.DID{}, errors.New("no credential subjects in organization credential")
}
credentialSubject := make([]credential.BaseCredentialSubject, 0)
err := organization.UnmarshalCredentialSubject(&credentialSubject)
if err != nil {
return nil, did.DID{}, fmt.Errorf("unable to get DID from organization credential: %w", err)
}
organizationDIDStr := credentialSubject[0].ID
organizationDID, err := did.ParseDID(organizationDIDStr)
organizationDID, err := organization.SubjectDID()
Comment on lines -504 to +503
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this is now a stricter check since VerifiableCredential.SubjectDID() checks if all credentialSubject.IDs are the same compared to just parsing the first value.

if err != nil {
return nil, did.DID{}, fmt.Errorf("unable to parse DID from organization credential: %w", err)
}
Expand Down
8 changes: 4 additions & 4 deletions didman/didman_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -859,8 +859,8 @@ func TestDidman_SearchOrganizations(t *testing.T) {
ctx := newMockContext(t)
credentialWithInvalidSubjectID := vc.VerifiableCredential{}
_ = json.Unmarshal([]byte(jsonld.TestOrganizationCredential), &credentialWithInvalidSubjectID)
credentialWithInvalidSubjectID.CredentialSubject = []interface{}{
map[string]interface{}{
credentialWithInvalidSubjectID.CredentialSubject = []map[string]any{
{
"id": "90",
},
}
Expand All @@ -877,8 +877,8 @@ func TestDidman_SearchOrganizations(t *testing.T) {
ctx := newMockContext(t)
credentialWithoutSubjectID := vc.VerifiableCredential{}
_ = json.Unmarshal([]byte(jsonld.TestOrganizationCredential), &credentialWithoutSubjectID)
credentialWithoutSubjectID.CredentialSubject = []interface{}{
map[string]interface{}{},
credentialWithoutSubjectID.CredentialSubject = []map[string]any{
{},
}

ctx.vcr.EXPECT().Search(reqCtx, searchTerms, false, nil).Return([]vc.VerifiableCredential{credentialWithoutSubjectID}, nil)
Expand Down
2 changes: 1 addition & 1 deletion discovery/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ func (r *clientRegistrationManager) findCredentialsAndBuildPresentation(ctx cont
registrationCredential = vc.VerifiableCredential{
Context: []ssi.URI{vc.VCContextV1URI(), credential.NutsV1ContextURI},
Type: []ssi.URI{vc.VerifiableCredentialTypeV1URI(), credential.DiscoveryRegistrationCredentialTypeV1URI()},
CredentialSubject: []interface{}{parameters},
CredentialSubject: []map[string]any{parameters},
}
credentials = append(credentials, credential.AutoCorrectSelfAttestedCredential(registrationCredential, subjectDID))
}
Expand Down
4 changes: 2 additions & 2 deletions discovery/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func createCredential(issuerDID did.DID, subjectDID did.DID, credentialSubject m
Issuer: issuerDID.URI(),
IssuanceDate: issuanceDate,
ExpirationDate: &expirationDate,
CredentialSubject: []interface{}{credentialSubject},
CredentialSubject: []map[string]any{credentialSubject},
}, func(ctx context.Context, claims map[string]interface{}, headers map[string]interface{}) (string, error) {
if claimVisitor != nil {
claimVisitor(claims)
Expand All @@ -214,7 +214,7 @@ func createHolderCredential(subjectDID did.DID, credentialSubject map[string]int
c := vc.VerifiableCredential{
Context: []ssi.URI{vc.VCContextV1URI(), credential.NutsV1ContextURI},
Type: []ssi.URI{vc.VerifiableCredentialTypeV1URI(), credential.DiscoveryRegistrationCredentialTypeV1URI()},
CredentialSubject: []interface{}{credentialSubject},
CredentialSubject: []map[string]any{credentialSubject},
}
c = credential.AutoCorrectSelfAttestedCredential(c, subjectDID)
// serialize/deserialize
Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ require (
github.com/nats-io/nats-server/v2 v2.11.1
github.com/nats-io/nats.go v1.41.1
github.com/nuts-foundation/crypto-ecies v0.0.0-20211207143025-5b84f9efce2b
github.com/nuts-foundation/go-did v0.15.0
github.com/nuts-foundation/go-did v0.17.0
github.com/nuts-foundation/go-leia/v4 v4.1.0
github.com/nuts-foundation/go-stoabs v1.11.0
github.com/nuts-foundation/sqlite v1.0.0
Expand Down Expand Up @@ -106,7 +106,7 @@ require (
github.com/gobwas/httphead v0.1.0 // indirect
github.com/gobwas/pool v0.2.1 // indirect
github.com/gobwas/ws v1.4.0 // indirect
github.com/goccy/go-json v0.10.3 // indirect
github.com/goccy/go-json v0.10.5 // indirect
github.com/golang-jwt/jwt/v4 v4.5.2 // indirect
github.com/golang-jwt/jwt/v5 v5.2.2 // indirect
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect
Expand Down Expand Up @@ -148,8 +148,8 @@ require (
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/multiformats/go-base32 v0.0.3 // indirect
github.com/multiformats/go-base36 v0.1.0 // indirect
github.com/multiformats/go-base32 v0.1.0 // indirect
github.com/multiformats/go-base36 v0.2.0 // indirect
github.com/multiformats/go-multibase v0.2.0 // indirect
github.com/multiformats/go-multihash v0.0.11 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
Expand Down
11 changes: 11 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ github.com/gobwas/ws v1.4.0 h1:CTaoG1tojrh4ucGPcoJFiAQUAsEWekEWvLy7GsVNqGs=
github.com/gobwas/ws v1.4.0/go.mod h1:G3gNqMNtPppf5XUz7O4shetPpcZ1VJ7zt18dlUeakrc=
github.com/goccy/go-json v0.10.3 h1:KZ5WoDbxAIgm2HNbYckL0se1fHD6rz5j4ywS6ebzDqA=
github.com/goccy/go-json v0.10.3/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/golang-jwt/jwt/v4 v4.5.2 h1:YtQM7lnr8iZ+j5q71MGKkNw9Mn7AjHM68uc9g5fXeUI=
github.com/golang-jwt/jwt/v4 v4.5.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
Expand Down Expand Up @@ -340,8 +341,10 @@ github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o=
github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc=
github.com/multiformats/go-base32 v0.0.3 h1:tw5+NhuwaOjJCC5Pp82QuXbrmLzWg7uxlMFp8Nq/kkI=
github.com/multiformats/go-base32 v0.0.3/go.mod h1:pLiuGC8y0QR3Ue4Zug5UzK9LjgbkL8NSQj0zQ5Nz/AA=
github.com/multiformats/go-base32 v0.1.0/go.mod h1:Kj3tFY6zNr+ABYMqeUNeGvkIC/UYgtWibDcT0rExnbI=
github.com/multiformats/go-base36 v0.1.0 h1:JR6TyF7JjGd3m6FbLU2cOxhC0Li8z8dLNGQ89tUg4F4=
github.com/multiformats/go-base36 v0.1.0/go.mod h1:kFGE83c6s80PklsHO9sRn2NCoffoRdUUOENyW/Vv6sM=
github.com/multiformats/go-base36 v0.2.0/go.mod h1:qvnKE++v+2MWCfePClUEjE78Z7P2a1UV0xHgWc0hkp4=
github.com/multiformats/go-multibase v0.2.0 h1:isdYCVLvksgWlMW9OZRYJEa9pZETFivncJHmHnnd87g=
github.com/multiformats/go-multibase v0.2.0/go.mod h1:bFBZX4lKCA/2lyOFSAoKH5SS6oPyjtnzK/XTFDPkNuk=
github.com/multiformats/go-multicodec v0.9.0 h1:pb/dlPnzee/Sxv/j4PmkDRxCOi3hXTz3IbPKOXWJkmg=
Expand All @@ -368,6 +371,14 @@ github.com/nuts-foundation/crypto-ecies v0.0.0-20211207143025-5b84f9efce2b h1:80
github.com/nuts-foundation/crypto-ecies v0.0.0-20211207143025-5b84f9efce2b/go.mod h1:6YUioYirD6/8IahZkoS4Ypc8xbeJW76Xdk1QKcziNTM=
github.com/nuts-foundation/go-did v0.15.0 h1:aNl6KC8jiyRJGl9PPKFBboLLC0wUm5h+tjE1UBDQEPw=
github.com/nuts-foundation/go-did v0.15.0/go.mod h1:swjCJvcRxc+i1nyieIERWEb3vFb4N7iYC+qen2OIbNg=
github.com/nuts-foundation/go-did v0.15.1-0.20250318150623-d2ac97c002b6 h1:8dPWXKbZbe10YtN2o3vNKw9jzHF4l0k4S/ZLA+JZ/bo=
github.com/nuts-foundation/go-did v0.15.1-0.20250318150623-d2ac97c002b6/go.mod h1:+CKZlsyh7oXp35uXfXkWkauVKgAFmxxhvV9EFDc1Ips=
github.com/nuts-foundation/go-did v0.15.1-0.20250318154645-e72bfe1fdc5b h1:705SSiJW5L6ZtcCseFAej2aIdDz3T223acONGsXjT9g=
github.com/nuts-foundation/go-did v0.15.1-0.20250318154645-e72bfe1fdc5b/go.mod h1:+CKZlsyh7oXp35uXfXkWkauVKgAFmxxhvV9EFDc1Ips=
github.com/nuts-foundation/go-did v0.15.1-0.20250319081900-aa2a47f72926 h1:9E0uBk36lyEQCaXI/8ElgJO7ng/71ZCIvsHoezVllLY=
github.com/nuts-foundation/go-did v0.15.1-0.20250319081900-aa2a47f72926/go.mod h1:+CKZlsyh7oXp35uXfXkWkauVKgAFmxxhvV9EFDc1Ips=
github.com/nuts-foundation/go-did v0.17.0 h1:nLmMiiKjIJwgZsfJ98ywATiCb9VHomnb3r86oWHdILw=
github.com/nuts-foundation/go-did v0.17.0/go.mod h1:8VLZhVjkFH9VgGu//3y7ICowwItpym3NWkOih1Ka1fw=
github.com/nuts-foundation/go-leia/v4 v4.1.0 h1:5Jo9c5hL4G6IP4JTI/UpPfpY6BILlHbdv9+PTf4lc14=
github.com/nuts-foundation/go-leia/v4 v4.1.0/go.mod h1:tYveGED8tSbQYhZNv2DVTc51c2zEWmSF+MG96PAtalY=
github.com/nuts-foundation/go-stoabs v1.11.0 h1:q18jVruPdFcVhodDrnKuhq/24i0pUC/YXgzJS0glKUU=
Expand Down
19 changes: 19 additions & 0 deletions test/json.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package test

import "encoding/json"

func remarshal(src interface{}, dst interface{}) error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dst in the signature should probably be a pointer to match unmarshal behavior. the least line should then be return json.Unmarshal(asJSON, dst)

asJSON, err := json.Marshal(src)
if err != nil {
return err
}
return json.Unmarshal(asJSON, &dst)
}

func MustRemarshalIntoMap(v interface{}) map[string]any {
var result map[string]interface{}
if err := remarshal(v, &result); err != nil {
panic(err)
}
return result
}
Loading
Loading