Skip to content

Commit

Permalink
revert: "fix: sdjwt-v5 type parameter (#18)" (#20)
Browse files Browse the repository at this point in the history
Revert "fix: sdjwt-v5 type parameter (#18)"

This reverts commit c170833.
  • Loading branch information
rolsonquadras authored Sep 18, 2023
1 parent 9a6d6c1 commit 9e6e238
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 56 deletions.
23 changes: 0 additions & 23 deletions verifiable/credential_jwt_proof_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,29 +44,6 @@ const jwtTestCredential = `
}
`

const jwtTestCredentialWithType = `
{
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://www.w3.org/2018/credentials/examples/v1"
],
"type": ["VerifiableCredential", "UniversityDegreeCredential"],
"credentialSubject": {
"id": "did:example:ebfeb1f712ebc6f1c276e12ec21",
"type": ["UniversityDegreeCredential"],
"degree": {
"university": "MIT"
}
},
"issuer": {
"id": "did:example:76e12ec712ebc6f1c221ebfeb1f",
"name": "Example University"
},
"issuanceDate": "2010-01-01T19:23:24Z",
"expirationDate": "2020-01-01T19:23:24Z"
}
`

const keyID = "1"

func TestParseCredentialFromJWS(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion verifiable/credential_sdjwt.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ func makeSDJWT( //nolint:funlen,gocyclo
)
}

opts.nonSDClaims = append(opts.nonSDClaims, "id", "type", "@type")
opts.nonSDClaims = append(opts.nonSDClaims, "id")
issuerOptions = append(issuerOptions,
issuer.WithNonSelectivelyDisclosableClaims(opts.nonSDClaims),
)
Expand Down
32 changes: 0 additions & 32 deletions verifiable/credential_sdjwt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"encoding/base64"
"fmt"
"sort"
"strings"
"testing"

"github.com/go-jose/go-jose/v3/jwt"
Expand Down Expand Up @@ -364,37 +363,6 @@ func TestMakeSDJWT(t *testing.T) {
require.NoError(t, err)
})

t.Run("with SD JWT V5", func(t *testing.T) {
vcWithType, vcErr := parseTestCredential(t, []byte(jwtTestCredentialWithType), WithCredDisableValidation())
require.NoError(t, vcErr)

originalVersion := vcWithType.SDJWTVersion
vcWithType.SDJWTVersion = common.SDJWTVersionDefault
defer func() {
vcWithType.SDJWTVersion = originalVersion
}()

sdjwt, err := vcWithType.MakeSDJWT(
afgojwt.NewEd25519Signer(privKey), "did:example:abc123#key-1",
MakeSDJWTWithVersion(common.SDJWTVersionV5),
MakeSDJWTWithRecursiveClaimsObjects([]string{"degree"}),
MakeSDJWTWithAlwaysIncludeObjects([]string{"degree"}),
)
require.NoError(t, err)

p, err := jwt.ParseSigned(strings.Split(sdjwt, "~")[0])
require.NoError(t, err)

var targetMap map[string]interface{}
require.NoError(t, p.UnsafeClaimsWithoutVerification(&targetMap))

parsed, err := ParseCredential([]byte(sdjwt), WithPublicKeyFetcher(holderPublicKeyFetcher(pubKey)))
require.NoError(t, err)
require.Len(t, parsed.SDJWTDisclosures, 1)
require.Equal(t, []interface{}{"UniversityDegreeCredential"},
targetMap["credentialSubject"].(map[string]interface{})["type"])
})

t.Run("with hash option", func(t *testing.T) {
sdjwt, err := vc.MakeSDJWT(afgojwt.NewEd25519Signer(privKey), "did:example:abc123#key-1",
MakeSDJWTWithHash(crypto.SHA512))
Expand Down

0 comments on commit 9e6e238

Please sign in to comment.