Skip to content
This repository has been archived by the owner on Dec 12, 2024. It is now read-only.

Test/updated input e2e #144

Merged
merged 8 commits into from
Oct 24, 2022
Merged
Show file tree
Hide file tree
Changes from 7 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
13 changes: 8 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/tbd54566975/ssi-service
go 1.19

require (
github.com/BurntSushi/toml v1.2.1
github.com/BurntSushi/toml v1.2.0
github.com/TBD54566975/ssi-sdk v0.0.1-alpha.0.20221019200812-2e73f0ac7722
github.com/ardanlabs/conf v1.5.0
github.com/dimfeld/httptreemux/v5 v5.4.0
Expand All @@ -21,17 +21,19 @@ require (
github.com/sirupsen/logrus v1.9.0
github.com/stretchr/testify v1.8.0
go.etcd.io/bbolt v1.3.6
go.opentelemetry.io/otel v1.11.1
go.opentelemetry.io/otel/exporters/jaeger v1.11.1
go.opentelemetry.io/otel/sdk v1.11.1
go.opentelemetry.io/otel/trace v1.11.1
go.opentelemetry.io/otel v1.11.0
go.opentelemetry.io/otel/exporters/jaeger v1.11.0
go.opentelemetry.io/otel/sdk v1.11.0
go.opentelemetry.io/otel/trace v1.11.0
golang.org/x/crypto v0.0.0-20221005025214-4161e89ecf1b
gopkg.in/go-playground/validator.v9 v9.31.0
)

require (
github.com/buger/jsonparser v1.1.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect
github.com/flowstack-com/jsonschema v0.1.2 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-playground/validator/v10 v10.11.1 // indirect
Expand All @@ -51,6 +53,7 @@ require (
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 // indirect
golang.org/x/sys v0.0.0-20221006211917-84dc82d7e875 // indirect
golang.org/x/term v0.0.0-20220919170432-7a66f970e087 // indirect
golang.org/x/text v0.3.7 // indirect
Expand Down
38 changes: 27 additions & 11 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
github.com/BurntSushi/toml v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=
github.com/BurntSushi/toml v1.2.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/BurntSushi/toml v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0=
github.com/BurntSushi/toml v1.2.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/TBD54566975/ssi-sdk v0.0.1-alpha.0.20221018194946-8583e4f4cc0c h1:BhL+EcNdgDeN0bfkKnBJLBXQJqJT4oZLlj/K+AgCKWI=
github.com/TBD54566975/ssi-sdk v0.0.1-alpha.0.20221018194946-8583e4f4cc0c/go.mod h1:WBOPlvZkJ1qXW5HINQiNxgWTEm5THpkPy8iHXNkYnRY=
github.com/TBD54566975/ssi-sdk v0.0.1-alpha.0.20221018201910-e1f529bd6a66 h1:3QwnubV4j2NQVnSt2YAT1hUHM26hrMS6xq3nPWofV1k=
github.com/TBD54566975/ssi-sdk v0.0.1-alpha.0.20221018201910-e1f529bd6a66/go.mod h1:WBOPlvZkJ1qXW5HINQiNxgWTEm5THpkPy8iHXNkYnRY=
github.com/TBD54566975/ssi-sdk v0.0.1-alpha.0.20221018210928-40550f92af68 h1:sH0LMADYtuTsvjBJPn1hwVIiM73HPHPaQN6xdf5msIY=
github.com/TBD54566975/ssi-sdk v0.0.1-alpha.0.20221018210928-40550f92af68/go.mod h1:WBOPlvZkJ1qXW5HINQiNxgWTEm5THpkPy8iHXNkYnRY=
github.com/TBD54566975/ssi-sdk v0.0.1-alpha.0.20221018231409-c5db11472c38 h1:SvBK316+1tgBJmQOX0khxyRmyXOPtxqonPSQPPrLIuA=
github.com/TBD54566975/ssi-sdk v0.0.1-alpha.0.20221018231409-c5db11472c38/go.mod h1:WBOPlvZkJ1qXW5HINQiNxgWTEm5THpkPy8iHXNkYnRY=
github.com/TBD54566975/ssi-sdk v0.0.1-alpha.0.20221019161256-4b326c0c823a h1:YAdegwCMrbEr1N43FMKmqjObci8q+sc1NVf9qlyLoto=
github.com/TBD54566975/ssi-sdk v0.0.1-alpha.0.20221019161256-4b326c0c823a/go.mod h1:WBOPlvZkJ1qXW5HINQiNxgWTEm5THpkPy8iHXNkYnRY=
github.com/TBD54566975/ssi-sdk v0.0.1-alpha.0.20221019200812-2e73f0ac7722 h1:aDCoimfCRlAcFCYo3XUiYmavv39VXf45xX2eLrTgmtA=
github.com/TBD54566975/ssi-sdk v0.0.1-alpha.0.20221019200812-2e73f0ac7722/go.mod h1:WBOPlvZkJ1qXW5HINQiNxgWTEm5THpkPy8iHXNkYnRY=
github.com/ardanlabs/conf v1.5.0 h1:5TwP6Wu9Xi07eLFEpiCUF3oQXh9UzHMDVnD3u/I5d5c=
github.com/ardanlabs/conf v1.5.0/go.mod h1:ILsMo9dMqYzCxDjDXTiwMI0IgxOJd0MOiucbQY2wlJw=
github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs=
github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
Expand All @@ -14,6 +26,8 @@ github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 h1:HbphB4TFFXpv7MNrT52FGrrgVXF1
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0/go.mod h1:DZGJHZMqrU4JJqFAWUS2UO1+lbSKsdiOoYi9Zzey7Fc=
github.com/dimfeld/httptreemux/v5 v5.4.0 h1:IiHYEjh+A7pYbhWyjmGnj5HZK6gpOOvyBXCJ+BE8/Gs=
github.com/dimfeld/httptreemux/v5 v5.4.0/go.mod h1:QeEylH57C0v3VO0tkKraVz9oD3Uu93CKPnTLbsidvSw=
github.com/flowstack-com/jsonschema v0.1.2 h1:qO2Ed0OHxY88yqqfNwUGfWxF64rVQCdbJ68lmlHSIXs=
github.com/flowstack-com/jsonschema v0.1.2/go.mod h1:Ce82M1ocyTfow5soqyAcHShvlSUqM8odW0UZVIIK4pQ=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0=
github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
Expand All @@ -31,7 +45,7 @@ github.com/goccy/go-json v0.9.7/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGF
github.com/goccy/go-json v0.9.11 h1:/pAaQDLHEoCq/5FFmSKBswWmK6H0e8g4159Kc/X/nqk=
github.com/goccy/go-json v0.9.11/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 h1:2VTzZjLZBgl62/EtslCrtky5vbi9dd7HrQPQIx6wqiw=
Expand Down Expand Up @@ -108,18 +122,20 @@ github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
go.etcd.io/bbolt v1.3.6 h1:/ecaJf0sk1l4l6V4awd65v2C3ILy7MSj+s/x1ADCIMU=
go.etcd.io/bbolt v1.3.6/go.mod h1:qXsaaIqmgQH0T+OPdb99Bf+PKfBBQVAdyD6TY9G8XM4=
go.opentelemetry.io/otel v1.11.1 h1:4WLLAmcfkmDk2ukNXJyq3/kiz/3UzCaYq6PskJsaou4=
go.opentelemetry.io/otel v1.11.1/go.mod h1:1nNhXBbWSD0nsL38H6btgnFN2k4i0sNLHNNMZMSbUGE=
go.opentelemetry.io/otel/exporters/jaeger v1.11.1 h1:F9Io8lqWdGyIbY3/SOGki34LX/l+7OL0gXNxjqwcbuQ=
go.opentelemetry.io/otel/exporters/jaeger v1.11.1/go.mod h1:lRa2w3bQ4R4QN6zYsDgy7tEezgoKEu7Ow2g35Y75+KI=
go.opentelemetry.io/otel/sdk v1.11.1 h1:F7KmQgoHljhUuJyA+9BiU+EkJfyX5nVVF4wyzWZpKxs=
go.opentelemetry.io/otel/sdk v1.11.1/go.mod h1:/l3FE4SupHJ12TduVjUkZtlfFqDCQJlOlithYrdktys=
go.opentelemetry.io/otel/trace v1.11.1 h1:ofxdnzsNrGBYXbP7t7zpUK281+go5rF7dvdIZXF8gdQ=
go.opentelemetry.io/otel/trace v1.11.1/go.mod h1:f/Q9G7vzk5u91PhbmKbg1Qn0rzH1LJ4vbPHFGkTPtOk=
go.opentelemetry.io/otel v1.11.0 h1:kfToEGMDq6TrVrJ9Vht84Y8y9enykSZzDDZglV0kIEk=
go.opentelemetry.io/otel v1.11.0/go.mod h1:H2KtuEphyMvlhZ+F7tg9GRhAOe60moNx61Ex+WmiKkk=
go.opentelemetry.io/otel/exporters/jaeger v1.11.0 h1:Sv2valcFfMlfu6g8USSS+ZUN5vwbuGj1aY/CFtMG33w=
go.opentelemetry.io/otel/exporters/jaeger v1.11.0/go.mod h1:nRgyJbgJ0hmaUdHwyDpTTfBYz61cTTeeGhVzfQc+FsI=
go.opentelemetry.io/otel/sdk v1.11.0 h1:ZnKIL9V9Ztaq+ME43IUi/eo22mNsb6a7tGfzaOWB5fo=
go.opentelemetry.io/otel/sdk v1.11.0/go.mod h1:REusa8RsyKaq0OlyangWXaw97t2VogoO4SSEeKkSTAk=
go.opentelemetry.io/otel/trace v1.11.0 h1:20U/Vj42SX+mASlXLmSGBg6jpI1jQtv682lZtTAOVFI=
go.opentelemetry.io/otel/trace v1.11.0/go.mod h1:nyYjis9jy0gytE9LXGU+/m1sHTKbRY0fX0hulNNDP1U=
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20220427172511-eb4f295cb31f/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20221005025214-4161e89ecf1b h1:huxqepDufQpLLIRXiVkTvnxrzJlpwmIWAObmcCcUFr0=
golang.org/x/crypto v0.0.0-20221005025214-4161e89ecf1b/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 h1:CIJ76btIcR3eFI5EgSo6k1qKw9KJexJuRLI9G7Hp5wE=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/sys v0.0.0-20200923182605-d9f96fdee20d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand Down
123 changes: 105 additions & 18 deletions test/steelthread.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@ import (
"bytes"
"embed"
"fmt"
manifestsdk "github.com/TBD54566975/ssi-sdk/credential/manifest"
"github.com/TBD54566975/ssi-sdk/crypto"
"github.com/mr-tron/base58"
credmodel "github.com/tbd54566975/ssi-service/internal/credential"
"github.com/tbd54566975/ssi-service/internal/keyaccess"
"io"
"net/http"
"strings"

cmpact "encoding/json"
"github.com/goccy/go-json"
"github.com/oliveagle/jsonpath"
"github.com/pkg/errors"
Expand All @@ -32,46 +38,55 @@ func RunTest() error {
return errors.Wrapf(err, "problem with readiness endpoint with output: %s", output)
}

fmt.Println(output)

// Create a did for the issuer
fmt.Println("\n\nCreate a did for the issuer:")
output, err = put(endpoint+version+"dids/key", getJSONFromFile("did-input.json"))
if err != nil {
return errors.Wrapf(err, "problem with dids/key endpoint with output: %s", output)
}

fmt.Println(output)
issuerDID, err := getJSONElement(output, "$.did.id")
if err != nil {
return errors.Wrap(err, "problem with getting json element")
}

// Create a did for alice
fmt.Println("\n\nCreate a did for alice:")
output, err = put(endpoint+version+"dids/key", getJSONFromFile("did-input.json"))
if err != nil {
return errors.Wrapf(err, "problem with dids/key endpoint with output: %s", output)
}

aliceDID, err := getJSONElement(output, "$.did.id")
if err != nil {
return errors.Wrap(err, "problem with getting json element")
}

aliceDidPrivateKey, err := getJSONElement(output, "$.privateKeyBase58")

// Create a schema to be used in CM
fmt.Println("\n\nCreate a schema to be used in CM:")
output, err = put(endpoint+version+"schemas", getJSONFromFile("schema-input.json"))
if err != nil {
return errors.Wrapf(err, "problem with schema endpoint with output: %s", output)
}

fmt.Println(output)
schemaID, err := getJSONElement(output, "$.id")
if err != nil {
return errors.Wrap(err, "problem getting json element")
}

// Create a credential
// Create a credential to be used in CA:
fmt.Println("\n\nCreate a credential to be used in CA:")
credentialJSON := getJSONFromFile("credential-input.json")
credentialJSON = strings.Replace(credentialJSON, "<CREDISSUERID>", issuerDID, -1)
credentialJSON = strings.Replace(credentialJSON, "<CREDSUBJECTID>", issuerDID, -1)
credentialJSON = strings.Replace(credentialJSON, "<SCHEMAID>", schemaID, -1)
credentialJSON = strings.ReplaceAll(credentialJSON, "<CREDISSUERID>", issuerDID)
credentialJSON = strings.ReplaceAll(credentialJSON, "<CREDSUBJECTID>", issuerDID)
credentialJSON = strings.ReplaceAll(credentialJSON, "<SCHEMAID>", schemaID)
output, err = put(endpoint+version+"credentials", credentialJSON)
if err != nil {
return errors.Wrapf(err, "problem with credentials endpoint with output: %s", output)
}

fmt.Println(output)
credentialJWT, err := getJSONElement(output, "$.credentialJwt")
if err != nil {
return errors.Wrap(err, "problem getting json element")
Expand All @@ -80,37 +95,80 @@ func RunTest() error {
// Create our Credential Manifest
fmt.Println("\n\nCreate our Credential Manifest:")
manifestJSON := getJSONFromFile("manifest-input.json")
manifestJSON = strings.Replace(manifestJSON, "<SCHEMAID>", schemaID, -1)
manifestJSON = strings.Replace(manifestJSON, "<ISSUERID>", issuerDID, -1)
manifestJSON = strings.ReplaceAll(manifestJSON, "<SCHEMAID>", schemaID)
manifestJSON = strings.ReplaceAll(manifestJSON, "<ISSUERID>", issuerDID)
output, err = put(endpoint+version+"manifests", manifestJSON)
if err != nil {
return errors.Wrapf(err, "problem with manifest endpoint with output: %s", output)
}

fmt.Println(output)
presentationDefinitionID, err := getJSONElement(output, "$.credential_manifest.presentation_definition.id")
if err != nil {
return errors.Wrap(err, "problem getting json element")
}
manifestID, err := getJSONElement(output, "$.credential_manifest.id")
if err != nil {
return errors.Wrap(err, "problem getting json element")
}

// Submit an application
fmt.Println("\n\nSubmit an Application:")
applicationJSON := getJSONFromFile("application-input.json")
applicationJSON = strings.Replace(applicationJSON, "<DEFINITIONID>", presentationDefinitionID, -1)
applicationJSON = strings.Replace(applicationJSON, "<VCJWT>", credentialJWT, -1)
applicationJSON = strings.ReplaceAll(applicationJSON, "<DEFINITIONID>", presentationDefinitionID)
applicationJSON = strings.ReplaceAll(applicationJSON, "<VCJWT>", credentialJWT)
applicationJSON = strings.ReplaceAll(applicationJSON, "<MANIFESTID>", manifestID)

// sign the application as a jwt
// Start signing credential application
alicPrivKeyBytes, err := base58.Decode(aliceDidPrivateKey)
if err != nil {
return errors.Wrap(err, "problem base58 decoding")
}

output, err = put(endpoint+version+"manifests/applications", applicationJSON)
alicePrivKey, err := crypto.BytesToPrivKey(alicPrivKeyBytes, "Ed25519")
if err != nil {
return errors.Wrapf(err, "problem with application endpoint with output: %s", output)
return errors.Wrap(err, "problem with bytes to priv key")
}

signer, err := keyaccess.NewJWKKeyAccess(aliceDID, alicePrivKey)
if err != nil {
return errors.Wrap(err, "problem with creating signer")
}

credAppWrapper := getValidApplicationRequest(applicationJSON, credentialJWT)

signed, err := signer.SignJSON(credAppWrapper)
if err != nil {
return errors.Wrap(err, "problem signing json")
}

fmt.Println(output)
fmt.Println("\nApplication JSON:")
fmt.Println(compactJSONOutput(applicationJSON))

fmt.Println("\nSIGNED APPLICATION JWT:")
fmt.Println(signed)
// End signing credential application

trueApplicationJSON := getJSONFromFile("application-input-jwt.json")
trueApplicationJSON = strings.Replace(trueApplicationJSON, "<APPLICATIONJWT>", signed.String(), -1)

output, err = put(endpoint+version+"manifests/applications", trueApplicationJSON)
if err != nil {
return errors.Wrapf(err, "problem with application endpoint with output: %s", output)
}

return err
}

func compactJSONOutput(json string) string {
var json_bytes = []byte(json)
buffer := new(bytes.Buffer)
if err := cmpact.Compact(buffer, json_bytes); err != nil {
fmt.Println(err)
}

return buffer.String()
}

func getJSONElement(jsonString string, jsonPath string) (string, error) {
jsonMap := make(map[string]interface{})
if err := json.Unmarshal([]byte(jsonString), &jsonMap); err != nil {
Expand All @@ -126,6 +184,8 @@ func getJSONElement(jsonString string, jsonPath string) (string, error) {
}

func get(url string) (string, error) {
fmt.Printf("\nPerforming GET request to: %s\n", url)

resp, err := http.Get(url)
if err != nil {
return "", errors.Wrap(err, "problem with finding element in json string")
Expand All @@ -140,10 +200,15 @@ func get(url string) (string, error) {
return "", fmt.Errorf("status code not in the 200s. body: %s", string(body))
}

fmt.Printf("\nOutput:\n")
fmt.Println(string(body))

return string(body), err
}

func put(url string, json string) (string, error) {
fmt.Printf("\nPerforming PUT request to: %s \n\nwith data: \n%s\n", url, compactJSONOutput(json))

client := new(http.Client)

req, err := http.NewRequest(http.MethodPut, url, bytes.NewBuffer([]byte(json)))
Expand All @@ -166,6 +231,9 @@ func put(url string, json string) (string, error) {
return "", fmt.Errorf("status code not in the 200s. body: %s", string(body))
}

fmt.Printf("\nOutput:\n")
fmt.Println(string(body))

return string(body), err
}

Expand All @@ -177,3 +245,22 @@ func getJSONFromFile(fileName string) string {
func is200Response(statusCode int) bool {
return statusCode/100 != 2
}

func getValidApplicationRequest(credAppJson string, credentialJWT string) manifestsdk.CredentialApplicationWrapper {
var createApplication manifestsdk.CredentialApplication
if err := json.Unmarshal([]byte(credAppJson), &createApplication); err != nil {
fmt.Println("unmarshal error")
}

contain, err := credmodel.NewCredentialContainerFromJWT(credentialJWT)
if err != nil {
fmt.Println("Problem making NewCredentialContainerFromJWT")
}
contains := []credmodel.Container{*contain}

creds := credmodel.ContainersToInterface(contains)
return manifestsdk.CredentialApplicationWrapper{
CredentialApplication: createApplication,
Credentials: creds,
}
}
3 changes: 3 additions & 0 deletions test/testdata/application-input-jwt.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"applicationJwt": "<APPLICATIONJWT>"
}
44 changes: 19 additions & 25 deletions test/testdata/application-input.json
Original file line number Diff line number Diff line change
@@ -1,29 +1,23 @@
{
"applicantDid": "did:example:1234",
"credential_application": {
"format": {
"jwt_vc": {
"alg": [
"string"
]
}
},
"id": "id123",
"manifest_id": "WA-DL-CLASS-A",
"presentation_submission": {
"id": "psid",
"definition_id": "<DEFINITIONID>",
"descriptor_map": [
{
"format": "jwt_vc",
"id": "kyc1",
"path": "$[0]"
}
"id":"id123",
"format":{
"jwt":{
"alg":[
"EdDSA"
]
},
"spec_version": "https://identity.foundation/credential-manifest/spec/v1.0.0/"
}
},
"manifest_id":"<MANIFESTID>",
"presentation_submission":{
"id":"psid",
"definition_id":"<DEFINITIONID>",
"descriptor_map":[
{
"id":"kyc1",
"format":"jwt_vc",
"path": "$.verifiableCredentials[0]"
}
]
},
"verifiableCredentials": [
"<VCJWT>"
]
"spec_version":"https://identity.foundation/credential-manifest/spec/v1.0.0/"
}
Loading