This repository has been archived by the owner on Mar 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: fix format filtering in pEx V2 for JWTVCs, and add bdd tests (#…
…3368) - also fix an issue with initializing sdk agents, when old clients still exist under the same name - also rename wallet-jsonld bdd tests since they aren't jsonld-only Signed-off-by: Filip Burlacu <[email protected]>
- Loading branch information
Showing
17 changed files
with
165 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
Copyright SecureKey Technologies Inc. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package vcwallet | ||
|
||
import ( | ||
_ "embed" //nolint:gci // required for go:embed | ||
"encoding/json" | ||
"fmt" | ||
"strings" | ||
) | ||
|
||
//go:embed testdata/query_by_example_fmt.json | ||
var sampleQueryByExFmt string //nolint:gochecknoglobals | ||
|
||
//go:embed testdata/presentation_definition_fmt.json | ||
var presentationDefinitionFmt string //nolint:gochecknoglobals | ||
|
||
//go:embed testdata/presentation_definition_v2.json | ||
var presentationDefinitionFmtV2 string //nolint:gochecknoglobals | ||
|
||
func (s *SDKSteps) getQuery(queryType, didID, format string) (json.RawMessage, error) { | ||
switch queryType { | ||
case "QueryByExample": | ||
return []byte(fmt.Sprintf(sampleQueryByExFmt, didID)), nil | ||
case "PresentationExchange": | ||
return []byte(fmt.Sprintf(presentationDefinitionFmt, didID)), nil | ||
case "PresentationExchange-v2": | ||
return []byte(pExV2Format(didID, s.crypto, format)), nil | ||
} | ||
|
||
// QueryByFrame is not covered in tests, since BBS isn't usable yet for JWT credentials | ||
return nil, fmt.Errorf("invalid queryType %v", queryType) | ||
} | ||
|
||
const ( | ||
ecdsa = "ECDSA" | ||
) | ||
|
||
func pExV2Format(didID, crypto, format string) string { | ||
formatString := "" | ||
signingAlg := strings.Split(crypto, " ")[0] | ||
|
||
if format == "JWT" { | ||
alg := "" | ||
|
||
switch signingAlg { | ||
case "Ed25519": | ||
alg = "EdDSA" | ||
case ecdsa: | ||
alg = ecdsa | ||
} | ||
|
||
formatString = fmt.Sprintf(`{"jwt": {"alg":["%s"]}}`, alg) | ||
} else if format == "JSON-LD" { | ||
proofType := "" | ||
|
||
switch signingAlg { | ||
case "Ed25519": | ||
proofType = "Ed25519Signature2018" | ||
case ecdsa: | ||
proofType = "JSONWebSignature2020" | ||
} | ||
|
||
formatString = fmt.Sprintf(`{"ldp": {"proof_type":["%s"]}}`, proofType) | ||
} | ||
|
||
return fmt.Sprintf(presentationDefinitionFmtV2, didID, formatString) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
22 changes: 22 additions & 0 deletions
22
test/bdd/pkg/vcwallet/testdata/presentation_definition_v2.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"id": "ec2f83c5-eac4-4d04-b41e-6636d6670a2e", | ||
"input_descriptors": [ | ||
{ | ||
"id": "105b1d58-71f8-4d1e-be71-36c9c6f600c9", | ||
"constraints": { | ||
"fields": [ | ||
{ | ||
"path": [ | ||
"$.issuer.id" | ||
], | ||
"filter": { | ||
"type": "string", | ||
"const": "%s" | ||
} | ||
} | ||
] | ||
}, | ||
"format":%s | ||
} | ||
] | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.