From fb1effb29ff86bedb5a867389110f692c1832e19 Mon Sep 17 00:00:00 2001 From: Lyuben Penkovski <lyuben.penkovski@vereign.com> Date: Tue, 31 Oct 2023 11:34:13 +0200 Subject: [PATCH] Goa DSL for create VC endpoint --- .gitlab-ci.yml.old | 25 -- design/design.go | 14 +- design/types.go | 29 ++ gen/health/client.go | 20 +- gen/health/endpoints.go | 4 +- gen/health/service.go | 14 +- gen/http/cli/signer/cli.go | 181 ++++++----- gen/http/health/client/encode_decode.go | 30 +- gen/http/health/client/types.go | 81 +++++ gen/http/health/server/encode_decode.go | 11 +- gen/http/health/server/types.go | 48 +++ gen/http/openapi.json | 2 +- gen/http/openapi.yaml | 159 +++++++++- gen/http/openapi3.json | 2 +- gen/http/openapi3.yaml | 392 ++++++++++++++++-------- gen/http/signer/client/cli.go | 35 ++- gen/http/signer/client/client.go | 29 ++ gen/http/signer/client/encode_decode.go | 66 ++++ gen/http/signer/client/paths.go | 5 + gen/http/signer/client/types.go | 33 ++ gen/http/signer/server/encode_decode.go | 37 +++ gen/http/signer/server/paths.go | 5 + gen/http/signer/server/server.go | 56 ++++ gen/http/signer/server/types.go | 52 ++++ gen/signer/client.go | 15 +- gen/signer/endpoints.go | 12 + gen/signer/service.go | 19 +- 27 files changed, 1120 insertions(+), 256 deletions(-) delete mode 100644 .gitlab-ci.yml.old diff --git a/.gitlab-ci.yml.old b/.gitlab-ci.yml.old deleted file mode 100644 index 9a68bdb..0000000 --- a/.gitlab-ci.yml.old +++ /dev/null @@ -1,25 +0,0 @@ -stages: - - test - -before_script: - - ln -s /builds /go/src/code.vereign.com - - cd /go/src/code.vereign.com/${CI_PROJECT_PATH} - -lint: - image: golangci/golangci-lint:v1.46.2 - stage: test - tags: - - amd64-docker - script: - - golangci-lint --version - - golangci-lint run - -unit tests: - image: golang:1.17.10 - stage: test - tags: - - amd64-docker - script: - - go version - - go test -race ./... -coverprofile=coverage.out - - go tool cover -func=coverage.out diff --git a/design/design.go b/design/design.go index 4135d51..0831958 100644 --- a/design/design.go +++ b/design/design.go @@ -78,6 +78,16 @@ var _ = Service("signer", func() { }) }) + Method("CreateCredential", func() { + Description("CreateCredential creates VC with proof from raw JSON data.") + Payload(CreateCredentialRequest) + Result(Any) + HTTP(func() { + POST("/v1/credential") + Response(StatusOK) + }) + }) + Method("CreatePresentation", func() { Description("CreatePresentation creates VP with proof from raw JSON data.") Payload(CreatePresentationRequest) @@ -116,7 +126,7 @@ var _ = Service("health", func() { Method("Liveness", func() { Payload(Empty) - Result(Empty) + Result(HealthResponse) HTTP(func() { GET("/liveness") Response(StatusOK) @@ -125,7 +135,7 @@ var _ = Service("health", func() { Method("Readiness", func() { Payload(Empty) - Result(Empty) + Result(HealthResponse) HTTP(func() { GET("/readiness") Response(StatusOK) diff --git a/design/types.go b/design/types.go index d55e556..7d1debc 100644 --- a/design/types.go +++ b/design/types.go @@ -78,6 +78,28 @@ var CreatePresentationRequest = Type("CreatePresentationRequest", func() { Required("issuer", "namespace", "key", "data") }) +var CreateCredentialRequest = Type("CreateCredentialRequest", func() { + Field(1, "issuer", String, "Issuer DID of the Verifiable Credential.", func() { + Example("did:web:example.com") + }) + Field(2, "namespace", String, "Key namespace.", func() { + Example("transit") + }) + Field(3, "key", String, "Key to use for the proof signature.", func() { + Example("key1") + }) + Field(4, "credentialSubject", Any, "Raw JSON that will be the VC subject.", func() { + Example(map[string]interface{}{"hello": "world"}) + }) + Field(5, "context", ArrayOf(String), "Additional JSONLD contexts to be specified in the VC.", func() { + Example([]string{ + "https://w3id.org/security/suites/jws-2020/v1", + "https://schema.org", + }) + }) + Required("issuer", "namespace", "key", "credentialSubject") +}) + var VerifyCredentialRequest = Type("VerifyCredentialRequest", func() { Field(1, "credential", Bytes, "Verifiable Credential in JSON format.") Required("credential") @@ -136,3 +158,10 @@ var DIDVerificationMethod = Type("DIDVerificationMethod", func() { Field(4, "publicKeyJwk", Any, "Public Key encoded in JWK format.") Required("id", "type", "controller", "publicKeyJwk") }) + +var HealthResponse = Type("HealthResponse", func() { + Field(1, "service", String, "Service name.") + Field(2, "status", String, "Status message.") + Field(3, "version", String, "Service runtime version.") + Required("service", "status", "version") +}) diff --git a/gen/health/client.go b/gen/health/client.go index 7580630..7d166ea 100644 --- a/gen/health/client.go +++ b/gen/health/client.go @@ -28,13 +28,21 @@ func NewClient(liveness, readiness goa.Endpoint) *Client { } // Liveness calls the "Liveness" endpoint of the "health" service. -func (c *Client) Liveness(ctx context.Context) (err error) { - _, err = c.LivenessEndpoint(ctx, nil) - return +func (c *Client) Liveness(ctx context.Context) (res *HealthResponse, err error) { + var ires any + ires, err = c.LivenessEndpoint(ctx, nil) + if err != nil { + return + } + return ires.(*HealthResponse), nil } // Readiness calls the "Readiness" endpoint of the "health" service. -func (c *Client) Readiness(ctx context.Context) (err error) { - _, err = c.ReadinessEndpoint(ctx, nil) - return +func (c *Client) Readiness(ctx context.Context) (res *HealthResponse, err error) { + var ires any + ires, err = c.ReadinessEndpoint(ctx, nil) + if err != nil { + return + } + return ires.(*HealthResponse), nil } diff --git a/gen/health/endpoints.go b/gen/health/endpoints.go index 3b3eec0..5bfe578 100644 --- a/gen/health/endpoints.go +++ b/gen/health/endpoints.go @@ -37,7 +37,7 @@ func (e *Endpoints) Use(m func(goa.Endpoint) goa.Endpoint) { // "Liveness" of service "health". func NewLivenessEndpoint(s Service) goa.Endpoint { return func(ctx context.Context, req any) (any, error) { - return nil, s.Liveness(ctx) + return s.Liveness(ctx) } } @@ -45,6 +45,6 @@ func NewLivenessEndpoint(s Service) goa.Endpoint { // "Readiness" of service "health". func NewReadinessEndpoint(s Service) goa.Endpoint { return func(ctx context.Context, req any) (any, error) { - return nil, s.Readiness(ctx) + return s.Readiness(ctx) } } diff --git a/gen/health/service.go b/gen/health/service.go index 086ed25..cdd8bcf 100644 --- a/gen/health/service.go +++ b/gen/health/service.go @@ -14,9 +14,9 @@ import ( // Health service provides health check endpoints. type Service interface { // Liveness implements Liveness. - Liveness(context.Context) (err error) + Liveness(context.Context) (res *HealthResponse, err error) // Readiness implements Readiness. - Readiness(context.Context) (err error) + Readiness(context.Context) (res *HealthResponse, err error) } // ServiceName is the name of the service as defined in the design. This is the @@ -28,3 +28,13 @@ const ServiceName = "health" // are the same values that are set in the endpoint request contexts under the // MethodKey key. var MethodNames = [2]string{"Liveness", "Readiness"} + +// HealthResponse is the result type of the health service Liveness method. +type HealthResponse struct { + // Service name. + Service string + // Status message. + Status string + // Service runtime version. + Version string +} diff --git a/gen/http/cli/signer/cli.go b/gen/http/cli/signer/cli.go index 9c8ed36..7f2bfb0 100644 --- a/gen/http/cli/signer/cli.go +++ b/gen/http/cli/signer/cli.go @@ -23,15 +23,15 @@ import ( // // command (subcommand1|subcommand2|...) func UsageCommands() string { - return `health (liveness|readiness) -signer (namespaces|namespace-keys|verification-method|verification-methods|credential-proof|presentation-proof|create-presentation|verify-credential|verify-presentation) + return `signer (namespaces|namespace-keys|verification-method|verification-methods|credential-proof|presentation-proof|create-credential|create-presentation|verify-credential|verify-presentation) +health (liveness|readiness) ` } // UsageExamples produces an example of a valid invocation of the CLI tool. func UsageExamples() string { - return os.Args[0] + ` health liveness` + "\n" + - os.Args[0] + ` signer namespaces` + "\n" + + return os.Args[0] + ` signer namespaces` + "\n" + + os.Args[0] + ` health liveness` + "\n" + "" } @@ -45,12 +45,6 @@ func ParseEndpoint( restore bool, ) (goa.Endpoint, any, error) { var ( - healthFlags = flag.NewFlagSet("health", flag.ContinueOnError) - - healthLivenessFlags = flag.NewFlagSet("liveness", flag.ExitOnError) - - healthReadinessFlags = flag.NewFlagSet("readiness", flag.ExitOnError) - signerFlags = flag.NewFlagSet("signer", flag.ContinueOnError) signerNamespacesFlags = flag.NewFlagSet("namespaces", flag.ExitOnError) @@ -73,6 +67,9 @@ func ParseEndpoint( signerPresentationProofFlags = flag.NewFlagSet("presentation-proof", flag.ExitOnError) signerPresentationProofBodyFlag = signerPresentationProofFlags.String("body", "REQUIRED", "") + signerCreateCredentialFlags = flag.NewFlagSet("create-credential", flag.ExitOnError) + signerCreateCredentialBodyFlag = signerCreateCredentialFlags.String("body", "REQUIRED", "") + signerCreatePresentationFlags = flag.NewFlagSet("create-presentation", flag.ExitOnError) signerCreatePresentationBodyFlag = signerCreatePresentationFlags.String("body", "REQUIRED", "") @@ -81,11 +78,13 @@ func ParseEndpoint( signerVerifyPresentationFlags = flag.NewFlagSet("verify-presentation", flag.ExitOnError) signerVerifyPresentationBodyFlag = signerVerifyPresentationFlags.String("body", "REQUIRED", "") - ) - healthFlags.Usage = healthUsage - healthLivenessFlags.Usage = healthLivenessUsage - healthReadinessFlags.Usage = healthReadinessUsage + healthFlags = flag.NewFlagSet("health", flag.ContinueOnError) + + healthLivenessFlags = flag.NewFlagSet("liveness", flag.ExitOnError) + + healthReadinessFlags = flag.NewFlagSet("readiness", flag.ExitOnError) + ) signerFlags.Usage = signerUsage signerNamespacesFlags.Usage = signerNamespacesUsage signerNamespaceKeysFlags.Usage = signerNamespaceKeysUsage @@ -93,10 +92,15 @@ func ParseEndpoint( signerVerificationMethodsFlags.Usage = signerVerificationMethodsUsage signerCredentialProofFlags.Usage = signerCredentialProofUsage signerPresentationProofFlags.Usage = signerPresentationProofUsage + signerCreateCredentialFlags.Usage = signerCreateCredentialUsage signerCreatePresentationFlags.Usage = signerCreatePresentationUsage signerVerifyCredentialFlags.Usage = signerVerifyCredentialUsage signerVerifyPresentationFlags.Usage = signerVerifyPresentationUsage + healthFlags.Usage = healthUsage + healthLivenessFlags.Usage = healthLivenessUsage + healthReadinessFlags.Usage = healthReadinessUsage + if err := flag.CommandLine.Parse(os.Args[1:]); err != nil { return nil, nil, err } @@ -112,10 +116,10 @@ func ParseEndpoint( { svcn = flag.Arg(0) switch svcn { - case "health": - svcf = healthFlags case "signer": svcf = signerFlags + case "health": + svcf = healthFlags default: return nil, nil, fmt.Errorf("unknown service %q", svcn) } @@ -131,16 +135,6 @@ func ParseEndpoint( { epn = svcf.Arg(0) switch svcn { - case "health": - switch epn { - case "liveness": - epf = healthLivenessFlags - - case "readiness": - epf = healthReadinessFlags - - } - case "signer": switch epn { case "namespaces": @@ -161,6 +155,9 @@ func ParseEndpoint( case "presentation-proof": epf = signerPresentationProofFlags + case "create-credential": + epf = signerCreateCredentialFlags + case "create-presentation": epf = signerCreatePresentationFlags @@ -172,6 +169,16 @@ func ParseEndpoint( } + case "health": + switch epn { + case "liveness": + epf = healthLivenessFlags + + case "readiness": + epf = healthReadinessFlags + + } + } } if epf == nil { @@ -192,16 +199,6 @@ func ParseEndpoint( ) { switch svcn { - case "health": - c := healthc.NewClient(scheme, host, doer, enc, dec, restore) - switch epn { - case "liveness": - endpoint = c.Liveness() - data = nil - case "readiness": - endpoint = c.Readiness() - data = nil - } case "signer": c := signerc.NewClient(scheme, host, doer, enc, dec, restore) switch epn { @@ -223,6 +220,9 @@ func ParseEndpoint( case "presentation-proof": endpoint = c.PresentationProof() data, err = signerc.BuildPresentationProofPayload(*signerPresentationProofBodyFlag) + case "create-credential": + endpoint = c.CreateCredential() + data, err = signerc.BuildCreateCredentialPayload(*signerCreateCredentialBodyFlag) case "create-presentation": endpoint = c.CreatePresentation() data, err = signerc.BuildCreatePresentationPayload(*signerCreatePresentationBodyFlag) @@ -233,6 +233,16 @@ func ParseEndpoint( endpoint = c.VerifyPresentation() data, err = signerc.BuildVerifyPresentationPayload(*signerVerifyPresentationBodyFlag) } + case "health": + c := healthc.NewClient(scheme, host, doer, enc, dec, restore) + switch epn { + case "liveness": + endpoint = c.Liveness() + data = nil + case "readiness": + endpoint = c.Readiness() + data = nil + } } } if err != nil { @@ -242,40 +252,6 @@ func ParseEndpoint( return endpoint, data, nil } -// healthUsage displays the usage of the health command and its subcommands. -func healthUsage() { - fmt.Fprintf(os.Stderr, `Health service provides health check endpoints. -Usage: - %[1]s [globalflags] health COMMAND [flags] - -COMMAND: - liveness: Liveness implements Liveness. - readiness: Readiness implements Readiness. - -Additional help: - %[1]s health COMMAND --help -`, os.Args[0]) -} -func healthLivenessUsage() { - fmt.Fprintf(os.Stderr, `%[1]s [flags] health liveness - -Liveness implements Liveness. - -Example: - %[1]s health liveness -`, os.Args[0]) -} - -func healthReadinessUsage() { - fmt.Fprintf(os.Stderr, `%[1]s [flags] health readiness - -Readiness implements Readiness. - -Example: - %[1]s health readiness -`, os.Args[0]) -} - // signerUsage displays the usage of the signer command and its subcommands. func signerUsage() { fmt.Fprintf(os.Stderr, `Signer service makes digital signatures and proofs for verifiable credentials and presentations. @@ -289,6 +265,7 @@ COMMAND: verification-methods: VerificationMethods returns all public keys in a given namespace. The result is formatted as array of DID verification methods with their controller attribute being the given DID in the request. credential-proof: CredentialProof adds a proof to a given Verifiable Credential. presentation-proof: PresentationProof adds a proof to a given Verifiable Presentation. + create-credential: CreateCredential creates VC with proof from raw JSON data. create-presentation: CreatePresentation creates VP with proof from raw JSON data. verify-credential: VerifyCredential verifies the proof of a Verifiable Credential. verify-presentation: VerifyPresentation verifies the proof of a Verifiable Presentation. @@ -379,10 +356,32 @@ PresentationProof adds a proof to a given Verifiable Presentation. Example: %[1]s signer presentation-proof --body '{ - "issuer": "Qui ipsa aut non fuga iste.", + "issuer": "Consequatur facilis eius.", "key": "key1", "namespace": "transit", - "presentation": "Iure ex consequatur facilis." + "presentation": "Dicta commodi possimus recusandae et." + }' +`, os.Args[0]) +} + +func signerCreateCredentialUsage() { + fmt.Fprintf(os.Stderr, `%[1]s [flags] signer create-credential -body JSON + +CreateCredential creates VC with proof from raw JSON data. + -body JSON: + +Example: + %[1]s signer create-credential --body '{ + "context": [ + "https://w3id.org/security/suites/jws-2020/v1", + "https://schema.org" + ], + "credentialSubject": { + "hello": "world" + }, + "issuer": "did:web:example.com", + "key": "key1", + "namespace": "transit" }' `, os.Args[0]) } @@ -421,7 +420,7 @@ VerifyCredential verifies the proof of a Verifiable Credential. -body STRING: Example: - %[1]s signer verify-credential --body "VXQgZXN0IHZlcm8gYXJjaGl0ZWN0byBzZWQu" + %[1]s signer verify-credential --body "Q29ycnVwdGkgcHJhZXNlbnRpdW0gaW52ZW50b3JlLg==" `, os.Args[0]) } @@ -432,6 +431,40 @@ VerifyPresentation verifies the proof of a Verifiable Presentation. -body STRING: Example: - %[1]s signer verify-presentation --body "RG9sb3JlcyBlbmltIGRlbGVjdHVzIG51bXF1YW0gZnVnYSB2b2x1cHRhdGVtIGVpdXMu" + %[1]s signer verify-presentation --body "U2VkIHF1b3MgcmVydW0gZGVzZXJ1bnQgYSBuaWhpbCBhdXQu" +`, os.Args[0]) +} + +// healthUsage displays the usage of the health command and its subcommands. +func healthUsage() { + fmt.Fprintf(os.Stderr, `Health service provides health check endpoints. +Usage: + %[1]s [globalflags] health COMMAND [flags] + +COMMAND: + liveness: Liveness implements Liveness. + readiness: Readiness implements Readiness. + +Additional help: + %[1]s health COMMAND --help +`, os.Args[0]) +} +func healthLivenessUsage() { + fmt.Fprintf(os.Stderr, `%[1]s [flags] health liveness + +Liveness implements Liveness. + +Example: + %[1]s health liveness +`, os.Args[0]) +} + +func healthReadinessUsage() { + fmt.Fprintf(os.Stderr, `%[1]s [flags] health readiness + +Readiness implements Readiness. + +Example: + %[1]s health readiness `, os.Args[0]) } diff --git a/gen/http/health/client/encode_decode.go b/gen/http/health/client/encode_decode.go index ae60fb5..0dd2fc4 100644 --- a/gen/http/health/client/encode_decode.go +++ b/gen/http/health/client/encode_decode.go @@ -51,7 +51,20 @@ func DecodeLivenessResponse(decoder func(*http.Response) goahttp.Decoder, restor } switch resp.StatusCode { case http.StatusOK: - return nil, nil + var ( + body LivenessResponseBody + err error + ) + err = decoder(resp).Decode(&body) + if err != nil { + return nil, goahttp.ErrDecodingError("health", "Liveness", err) + } + err = ValidateLivenessResponseBody(&body) + if err != nil { + return nil, goahttp.ErrValidationError("health", "Liveness", err) + } + res := NewLivenessHealthResponseOK(&body) + return res, nil default: body, _ := io.ReadAll(resp.Body) return nil, goahttp.ErrInvalidResponse("health", "Liveness", resp.StatusCode, string(body)) @@ -93,7 +106,20 @@ func DecodeReadinessResponse(decoder func(*http.Response) goahttp.Decoder, resto } switch resp.StatusCode { case http.StatusOK: - return nil, nil + var ( + body ReadinessResponseBody + err error + ) + err = decoder(resp).Decode(&body) + if err != nil { + return nil, goahttp.ErrDecodingError("health", "Readiness", err) + } + err = ValidateReadinessResponseBody(&body) + if err != nil { + return nil, goahttp.ErrValidationError("health", "Readiness", err) + } + res := NewReadinessHealthResponseOK(&body) + return res, nil default: body, _ := io.ReadAll(resp.Body) return nil, goahttp.ErrInvalidResponse("health", "Readiness", resp.StatusCode, string(body)) diff --git a/gen/http/health/client/types.go b/gen/http/health/client/types.go index b33e5d0..8684d0f 100644 --- a/gen/http/health/client/types.go +++ b/gen/http/health/client/types.go @@ -6,3 +6,84 @@ // $ goa gen gitlab.eclipse.org/eclipse/xfsc/tsa/signer/design package client + +import ( + health "gitlab.eclipse.org/eclipse/xfsc/tsa/signer/gen/health" + goa "goa.design/goa/v3/pkg" +) + +// LivenessResponseBody is the type of the "health" service "Liveness" endpoint +// HTTP response body. +type LivenessResponseBody struct { + // Service name. + Service *string `form:"service,omitempty" json:"service,omitempty" xml:"service,omitempty"` + // Status message. + Status *string `form:"status,omitempty" json:"status,omitempty" xml:"status,omitempty"` + // Service runtime version. + Version *string `form:"version,omitempty" json:"version,omitempty" xml:"version,omitempty"` +} + +// ReadinessResponseBody is the type of the "health" service "Readiness" +// endpoint HTTP response body. +type ReadinessResponseBody struct { + // Service name. + Service *string `form:"service,omitempty" json:"service,omitempty" xml:"service,omitempty"` + // Status message. + Status *string `form:"status,omitempty" json:"status,omitempty" xml:"status,omitempty"` + // Service runtime version. + Version *string `form:"version,omitempty" json:"version,omitempty" xml:"version,omitempty"` +} + +// NewLivenessHealthResponseOK builds a "health" service "Liveness" endpoint +// result from a HTTP "OK" response. +func NewLivenessHealthResponseOK(body *LivenessResponseBody) *health.HealthResponse { + v := &health.HealthResponse{ + Service: *body.Service, + Status: *body.Status, + Version: *body.Version, + } + + return v +} + +// NewReadinessHealthResponseOK builds a "health" service "Readiness" endpoint +// result from a HTTP "OK" response. +func NewReadinessHealthResponseOK(body *ReadinessResponseBody) *health.HealthResponse { + v := &health.HealthResponse{ + Service: *body.Service, + Status: *body.Status, + Version: *body.Version, + } + + return v +} + +// ValidateLivenessResponseBody runs the validations defined on +// LivenessResponseBody +func ValidateLivenessResponseBody(body *LivenessResponseBody) (err error) { + if body.Service == nil { + err = goa.MergeErrors(err, goa.MissingFieldError("service", "body")) + } + if body.Status == nil { + err = goa.MergeErrors(err, goa.MissingFieldError("status", "body")) + } + if body.Version == nil { + err = goa.MergeErrors(err, goa.MissingFieldError("version", "body")) + } + return +} + +// ValidateReadinessResponseBody runs the validations defined on +// ReadinessResponseBody +func ValidateReadinessResponseBody(body *ReadinessResponseBody) (err error) { + if body.Service == nil { + err = goa.MergeErrors(err, goa.MissingFieldError("service", "body")) + } + if body.Status == nil { + err = goa.MergeErrors(err, goa.MissingFieldError("status", "body")) + } + if body.Version == nil { + err = goa.MergeErrors(err, goa.MissingFieldError("version", "body")) + } + return +} diff --git a/gen/http/health/server/encode_decode.go b/gen/http/health/server/encode_decode.go index c96aefa..3f375f3 100644 --- a/gen/http/health/server/encode_decode.go +++ b/gen/http/health/server/encode_decode.go @@ -11,6 +11,7 @@ import ( "context" "net/http" + health "gitlab.eclipse.org/eclipse/xfsc/tsa/signer/gen/health" goahttp "goa.design/goa/v3/http" ) @@ -18,8 +19,11 @@ import ( // health Liveness endpoint. func EncodeLivenessResponse(encoder func(context.Context, http.ResponseWriter) goahttp.Encoder) func(context.Context, http.ResponseWriter, any) error { return func(ctx context.Context, w http.ResponseWriter, v any) error { + res, _ := v.(*health.HealthResponse) + enc := encoder(ctx, w) + body := NewLivenessResponseBody(res) w.WriteHeader(http.StatusOK) - return nil + return enc.Encode(body) } } @@ -27,7 +31,10 @@ func EncodeLivenessResponse(encoder func(context.Context, http.ResponseWriter) g // health Readiness endpoint. func EncodeReadinessResponse(encoder func(context.Context, http.ResponseWriter) goahttp.Encoder) func(context.Context, http.ResponseWriter, any) error { return func(ctx context.Context, w http.ResponseWriter, v any) error { + res, _ := v.(*health.HealthResponse) + enc := encoder(ctx, w) + body := NewReadinessResponseBody(res) w.WriteHeader(http.StatusOK) - return nil + return enc.Encode(body) } } diff --git a/gen/http/health/server/types.go b/gen/http/health/server/types.go index 35f62e6..f74127d 100644 --- a/gen/http/health/server/types.go +++ b/gen/http/health/server/types.go @@ -6,3 +6,51 @@ // $ goa gen gitlab.eclipse.org/eclipse/xfsc/tsa/signer/design package server + +import ( + health "gitlab.eclipse.org/eclipse/xfsc/tsa/signer/gen/health" +) + +// LivenessResponseBody is the type of the "health" service "Liveness" endpoint +// HTTP response body. +type LivenessResponseBody struct { + // Service name. + Service string `form:"service" json:"service" xml:"service"` + // Status message. + Status string `form:"status" json:"status" xml:"status"` + // Service runtime version. + Version string `form:"version" json:"version" xml:"version"` +} + +// ReadinessResponseBody is the type of the "health" service "Readiness" +// endpoint HTTP response body. +type ReadinessResponseBody struct { + // Service name. + Service string `form:"service" json:"service" xml:"service"` + // Status message. + Status string `form:"status" json:"status" xml:"status"` + // Service runtime version. + Version string `form:"version" json:"version" xml:"version"` +} + +// NewLivenessResponseBody builds the HTTP response body from the result of the +// "Liveness" endpoint of the "health" service. +func NewLivenessResponseBody(res *health.HealthResponse) *LivenessResponseBody { + body := &LivenessResponseBody{ + Service: res.Service, + Status: res.Status, + Version: res.Version, + } + return body +} + +// NewReadinessResponseBody builds the HTTP response body from the result of +// the "Readiness" endpoint of the "health" service. +func NewReadinessResponseBody(res *health.HealthResponse) *ReadinessResponseBody { + body := &ReadinessResponseBody{ + Service: res.Service, + Status: res.Status, + Version: res.Version, + } + return body +} diff --git a/gen/http/openapi.json b/gen/http/openapi.json index 5bb03a9..74ef1e4 100644 --- a/gen/http/openapi.json +++ b/gen/http/openapi.json @@ -1 +1 @@ -{"swagger":"2.0","info":{"title":"Signer Service","description":"Signer service exposes HTTP API for making and verifying digital signatures and proofs for Verifiable Credentials.","version":""},"host":"localhost:8085","consumes":["application/json","application/xml","application/gob"],"produces":["application/json","application/xml","application/gob"],"paths":{"/liveness":{"get":{"tags":["health"],"summary":"Liveness health","operationId":"health#Liveness","responses":{"200":{"description":"OK response."}},"schemes":["http"]}},"/readiness":{"get":{"tags":["health"],"summary":"Readiness health","operationId":"health#Readiness","responses":{"200":{"description":"OK response."}},"schemes":["http"]}},"/v1/credential/proof":{"post":{"tags":["signer"],"summary":"CredentialProof signer","description":"CredentialProof adds a proof to a given Verifiable Credential.","operationId":"signer#CredentialProof","parameters":[{"name":"CredentialProofRequestBody","in":"body","required":true,"schema":{"$ref":"#/definitions/SignerCredentialProofRequestBody","required":["namespace","key","credential"]}}],"responses":{"200":{"description":"OK response.","schema":{"type":"string","format":"binary"}}},"schemes":["http"]}},"/v1/credential/verify":{"post":{"tags":["signer"],"summary":"VerifyCredential signer","description":"VerifyCredential verifies the proof of a Verifiable Credential.","operationId":"signer#VerifyCredential","parameters":[{"name":"bytes","in":"body","description":"Verifiable Credential in JSON format.","required":true,"schema":{"type":"string","format":"byte"}}],"responses":{"200":{"description":"OK response.","schema":{"$ref":"#/definitions/SignerVerifyCredentialResponseBody","required":["valid"]}}},"schemes":["http"]}},"/v1/namespaces":{"get":{"tags":["signer"],"summary":"Namespaces signer","description":"Namespaces returns all keys namespaces, which corresponds to enabled Vault transit engines.","operationId":"signer#Namespaces","responses":{"200":{"description":"OK response.","schema":{"type":"array","items":{"type":"string","example":"Sed quos rerum deserunt a nihil aut."}}}},"schemes":["http"]}},"/v1/namespaces/{namespace}/keys":{"get":{"tags":["signer"],"summary":"NamespaceKeys signer","description":"NamespaceKeys returns all keys in a given namespace.","operationId":"signer#NamespaceKeys","parameters":[{"name":"namespace","in":"path","description":"Namespace for signing keys.","required":true,"type":"string"}],"responses":{"200":{"description":"OK response.","schema":{"type":"array","items":{"type":"string","example":"Qui laboriosam qui est."}}}},"schemes":["http"]}},"/v1/presentation":{"post":{"tags":["signer"],"summary":"CreatePresentation signer","description":"CreatePresentation creates VP with proof from raw JSON data.","operationId":"signer#CreatePresentation","parameters":[{"name":"CreatePresentationRequestBody","in":"body","required":true,"schema":{"$ref":"#/definitions/SignerCreatePresentationRequestBody","required":["issuer","namespace","key","data"]}}],"responses":{"200":{"description":"OK response.","schema":{"type":"string","format":"binary"}}},"schemes":["http"]}},"/v1/presentation/proof":{"post":{"tags":["signer"],"summary":"PresentationProof signer","description":"PresentationProof adds a proof to a given Verifiable Presentation.","operationId":"signer#PresentationProof","parameters":[{"name":"PresentationProofRequestBody","in":"body","required":true,"schema":{"$ref":"#/definitions/SignerPresentationProofRequestBody","required":["issuer","namespace","key","presentation"]}}],"responses":{"200":{"description":"OK response.","schema":{"type":"string","format":"binary"}}},"schemes":["http"]}},"/v1/presentation/verify":{"post":{"tags":["signer"],"summary":"VerifyPresentation signer","description":"VerifyPresentation verifies the proof of a Verifiable Presentation.","operationId":"signer#VerifyPresentation","parameters":[{"name":"bytes","in":"body","description":"Verifiable Presentation in JSON format.","required":true,"schema":{"type":"string","format":"byte"}}],"responses":{"200":{"description":"OK response.","schema":{"$ref":"#/definitions/SignerVerifyPresentationResponseBody","required":["valid"]}}},"schemes":["http"]}},"/v1/verification-methods/{namespace}/{did}":{"get":{"tags":["signer"],"summary":"VerificationMethods signer","description":"VerificationMethods returns all public keys in a given namespace. The result is formatted as array of DID verification methods with their controller attribute being the given DID in the request.","operationId":"signer#VerificationMethods","parameters":[{"name":"namespace","in":"path","description":"Keys namespace.","required":true,"type":"string"},{"name":"did","in":"path","description":"DID controller of the keys.","required":true,"type":"string"}],"responses":{"200":{"description":"OK response.","schema":{"type":"array","items":{"$ref":"#/definitions/DIDVerificationMethodResponse"}}}},"schemes":["http"]}},"/v1/verification-methods/{namespace}/{key}/{did}":{"get":{"tags":["signer"],"summary":"VerificationMethod signer","description":"VerificationMethod returns a single public key formatted as DID verification method for a given namespace, key and did.","operationId":"signer#VerificationMethod","parameters":[{"name":"namespace","in":"path","description":"Key namespace.","required":true,"type":"string"},{"name":"key","in":"path","description":"Name of requested key.","required":true,"type":"string"},{"name":"did","in":"path","description":"DID controller of the key.","required":true,"type":"string"}],"responses":{"200":{"description":"OK response.","schema":{"$ref":"#/definitions/SignerVerificationMethodResponseBody","required":["id","type","controller","publicKeyJwk"]}}},"schemes":["http"]}}},"definitions":{"DIDVerificationMethodResponse":{"title":"DIDVerificationMethodResponse","type":"object","properties":{"controller":{"type":"string","description":"Controller of verification method specified as DID.","example":"did:web:example.com"},"id":{"type":"string","description":"ID of verification method.","example":"key1"},"publicKeyJwk":{"type":"string","description":"Public Key encoded in JWK format.","example":"Illum qui nihil.","format":"binary"},"type":{"type":"string","description":"Type of verification method key.","example":"JsonWebKey2020"}},"example":{"controller":"did:web:example.com","id":"key1","publicKeyJwk":"Ut occaecati repellat.","type":"JsonWebKey2020"},"required":["id","type","controller","publicKeyJwk"]},"SignerCreatePresentationRequestBody":{"title":"SignerCreatePresentationRequestBody","type":"object","properties":{"context":{"type":"array","items":{"type":"string","example":"Et nulla illo totam optio quia ab."},"description":"Additional JSONLD contexts to be specified in the VP.","example":["https://w3id.org/security/suites/jws-2020/v1","https://schema.org"]},"data":{"type":"array","items":{"type":"string","example":"Natus quos ut corrupti.","format":"binary"},"description":"Raw JSON to be included inside the VP as Verifiable Credential.","example":[{"hello":"world"},{"hola":"mundo"}]},"issuer":{"type":"string","description":"Issuer DID of the Verifiable Presentation.","example":"did:web:example.com"},"key":{"type":"string","description":"Key to use for the proof signature.","example":"key1"},"namespace":{"type":"string","description":"Key namespace.","example":"transit"}},"example":{"context":["https://w3id.org/security/suites/jws-2020/v1","https://schema.org"],"data":[{"hello":"world"},{"hola":"mundo"}],"issuer":"did:web:example.com","key":"key1","namespace":"transit"},"required":["issuer","namespace","key","data"]},"SignerCredentialProofRequestBody":{"title":"SignerCredentialProofRequestBody","type":"object","properties":{"credential":{"type":"string","description":"Verifiable Credential in JSON format.","example":{"@context":["https://www.w3.org/2018/credentials/v1","https://w3id.org/security/suites/jws-2020/v1","https://schema.org"],"type":"VerifiableCredential","issuer":"did:web:nginx:policy:policy:example:example:1.0:evaluation","issuanceDate":"2010-01-01T19:23:24.651387237Z","credentialSubject":{"name":"Alice","allow":true}},"format":"binary"},"key":{"type":"string","description":"Key to use for the proof signature (optional).","example":"key1"},"namespace":{"type":"string","description":"Key namespace.","example":"transit"}},"example":{"credential":{"@context":["https://www.w3.org/2018/credentials/v1","https://w3id.org/security/suites/jws-2020/v1","https://schema.org"],"type":"VerifiableCredential","issuer":"did:web:nginx:policy:policy:example:example:1.0:evaluation","issuanceDate":"2010-01-01T19:23:24.651387237Z","credentialSubject":{"name":"Alice","allow":true}},"key":"key1","namespace":"transit"},"required":["namespace","key","credential"]},"SignerPresentationProofRequestBody":{"title":"SignerPresentationProofRequestBody","type":"object","properties":{"issuer":{"type":"string","description":"Issuer DID used to specify proof verification info.","example":"Non amet."},"key":{"type":"string","description":"Key to use for the proof signature.","example":"key1"},"namespace":{"type":"string","description":"Key namespace.","example":"transit"},"presentation":{"type":"string","description":"Verifiable Presentation in JSON format.","example":"Nihil iste debitis.","format":"binary"}},"example":{"issuer":"Sapiente dolorem qui possimus qui labore veritatis.","key":"key1","namespace":"transit","presentation":"Fuga officia excepturi velit aut."},"required":["issuer","namespace","key","presentation"]},"SignerVerificationMethodResponseBody":{"title":"SignerVerificationMethodResponseBody","type":"object","properties":{"controller":{"type":"string","description":"Controller of verification method specified as DID.","example":"did:web:example.com"},"id":{"type":"string","description":"ID of verification method.","example":"key1"},"publicKeyJwk":{"type":"string","description":"Public Key encoded in JWK format.","example":"Accusamus dolor illo aliquid ipsum optio.","format":"binary"},"type":{"type":"string","description":"Type of verification method key.","example":"JsonWebKey2020"}},"description":"Public Key represented as DID Verification Method.","example":{"controller":"did:web:example.com","id":"key1","publicKeyJwk":"Et et cupiditate debitis.","type":"JsonWebKey2020"},"required":["id","type","controller","publicKeyJwk"]},"SignerVerifyCredentialResponseBody":{"title":"SignerVerifyCredentialResponseBody","type":"object","properties":{"valid":{"type":"boolean","description":"Valid specifies if the proof is successfully verified.","example":false}},"example":{"valid":true},"required":["valid"]},"SignerVerifyPresentationResponseBody":{"title":"SignerVerifyPresentationResponseBody","type":"object","properties":{"valid":{"type":"boolean","description":"Valid specifies if the proof is successfully verified.","example":true}},"example":{"valid":false},"required":["valid"]}}} \ No newline at end of file +{"swagger":"2.0","info":{"title":"Signer Service","description":"Signer service exposes HTTP API for making and verifying digital signatures and proofs for Verifiable Credentials.","version":""},"host":"localhost:8085","consumes":["application/json","application/xml","application/gob"],"produces":["application/json","application/xml","application/gob"],"paths":{"/liveness":{"get":{"tags":["health"],"summary":"Liveness health","operationId":"health#Liveness","responses":{"200":{"description":"OK response.","schema":{"$ref":"#/definitions/HealthLivenessResponseBody","required":["service","status","version"]}}},"schemes":["http"]}},"/readiness":{"get":{"tags":["health"],"summary":"Readiness health","operationId":"health#Readiness","responses":{"200":{"description":"OK response.","schema":{"$ref":"#/definitions/HealthReadinessResponseBody","required":["service","status","version"]}}},"schemes":["http"]}},"/v1/credential":{"post":{"tags":["signer"],"summary":"CreateCredential signer","description":"CreateCredential creates VC with proof from raw JSON data.","operationId":"signer#CreateCredential","parameters":[{"name":"CreateCredentialRequestBody","in":"body","required":true,"schema":{"$ref":"#/definitions/SignerCreateCredentialRequestBody","required":["issuer","namespace","key","credentialSubject"]}}],"responses":{"200":{"description":"OK response.","schema":{"type":"string","format":"binary"}}},"schemes":["http"]}},"/v1/credential/proof":{"post":{"tags":["signer"],"summary":"CredentialProof signer","description":"CredentialProof adds a proof to a given Verifiable Credential.","operationId":"signer#CredentialProof","parameters":[{"name":"CredentialProofRequestBody","in":"body","required":true,"schema":{"$ref":"#/definitions/SignerCredentialProofRequestBody","required":["namespace","key","credential"]}}],"responses":{"200":{"description":"OK response.","schema":{"type":"string","format":"binary"}}},"schemes":["http"]}},"/v1/credential/verify":{"post":{"tags":["signer"],"summary":"VerifyCredential signer","description":"VerifyCredential verifies the proof of a Verifiable Credential.","operationId":"signer#VerifyCredential","parameters":[{"name":"bytes","in":"body","description":"Verifiable Credential in JSON format.","required":true,"schema":{"type":"string","format":"byte"}}],"responses":{"200":{"description":"OK response.","schema":{"$ref":"#/definitions/SignerVerifyCredentialResponseBody","required":["valid"]}}},"schemes":["http"]}},"/v1/namespaces":{"get":{"tags":["signer"],"summary":"Namespaces signer","description":"Namespaces returns all keys namespaces, which corresponds to enabled Vault transit engines.","operationId":"signer#Namespaces","responses":{"200":{"description":"OK response.","schema":{"type":"array","items":{"type":"string","example":"Nihil iste debitis."}}}},"schemes":["http"]}},"/v1/namespaces/{namespace}/keys":{"get":{"tags":["signer"],"summary":"NamespaceKeys signer","description":"NamespaceKeys returns all keys in a given namespace.","operationId":"signer#NamespaceKeys","parameters":[{"name":"namespace","in":"path","description":"Namespace for signing keys.","required":true,"type":"string"}],"responses":{"200":{"description":"OK response.","schema":{"type":"array","items":{"type":"string","example":"Sapiente dolorem qui possimus qui labore veritatis."}}}},"schemes":["http"]}},"/v1/presentation":{"post":{"tags":["signer"],"summary":"CreatePresentation signer","description":"CreatePresentation creates VP with proof from raw JSON data.","operationId":"signer#CreatePresentation","parameters":[{"name":"CreatePresentationRequestBody","in":"body","required":true,"schema":{"$ref":"#/definitions/SignerCreatePresentationRequestBody","required":["issuer","namespace","key","data"]}}],"responses":{"200":{"description":"OK response.","schema":{"type":"string","format":"binary"}}},"schemes":["http"]}},"/v1/presentation/proof":{"post":{"tags":["signer"],"summary":"PresentationProof signer","description":"PresentationProof adds a proof to a given Verifiable Presentation.","operationId":"signer#PresentationProof","parameters":[{"name":"PresentationProofRequestBody","in":"body","required":true,"schema":{"$ref":"#/definitions/SignerPresentationProofRequestBody","required":["issuer","namespace","key","presentation"]}}],"responses":{"200":{"description":"OK response.","schema":{"type":"string","format":"binary"}}},"schemes":["http"]}},"/v1/presentation/verify":{"post":{"tags":["signer"],"summary":"VerifyPresentation signer","description":"VerifyPresentation verifies the proof of a Verifiable Presentation.","operationId":"signer#VerifyPresentation","parameters":[{"name":"bytes","in":"body","description":"Verifiable Presentation in JSON format.","required":true,"schema":{"type":"string","format":"byte"}}],"responses":{"200":{"description":"OK response.","schema":{"$ref":"#/definitions/SignerVerifyPresentationResponseBody","required":["valid"]}}},"schemes":["http"]}},"/v1/verification-methods/{namespace}/{did}":{"get":{"tags":["signer"],"summary":"VerificationMethods signer","description":"VerificationMethods returns all public keys in a given namespace. The result is formatted as array of DID verification methods with their controller attribute being the given DID in the request.","operationId":"signer#VerificationMethods","parameters":[{"name":"namespace","in":"path","description":"Keys namespace.","required":true,"type":"string"},{"name":"did","in":"path","description":"DID controller of the keys.","required":true,"type":"string"}],"responses":{"200":{"description":"OK response.","schema":{"type":"array","items":{"$ref":"#/definitions/DIDVerificationMethodResponse"}}}},"schemes":["http"]}},"/v1/verification-methods/{namespace}/{key}/{did}":{"get":{"tags":["signer"],"summary":"VerificationMethod signer","description":"VerificationMethod returns a single public key formatted as DID verification method for a given namespace, key and did.","operationId":"signer#VerificationMethod","parameters":[{"name":"namespace","in":"path","description":"Key namespace.","required":true,"type":"string"},{"name":"key","in":"path","description":"Name of requested key.","required":true,"type":"string"},{"name":"did","in":"path","description":"DID controller of the key.","required":true,"type":"string"}],"responses":{"200":{"description":"OK response.","schema":{"$ref":"#/definitions/SignerVerificationMethodResponseBody","required":["id","type","controller","publicKeyJwk"]}}},"schemes":["http"]}}},"definitions":{"DIDVerificationMethodResponse":{"title":"DIDVerificationMethodResponse","type":"object","properties":{"controller":{"type":"string","description":"Controller of verification method specified as DID.","example":"did:web:example.com"},"id":{"type":"string","description":"ID of verification method.","example":"key1"},"publicKeyJwk":{"type":"string","description":"Public Key encoded in JWK format.","example":"Et nulla illo totam optio quia ab.","format":"binary"},"type":{"type":"string","description":"Type of verification method key.","example":"JsonWebKey2020"}},"example":{"controller":"did:web:example.com","id":"key1","publicKeyJwk":"Quibusdam nemo ut iusto ut fugit.","type":"JsonWebKey2020"},"required":["id","type","controller","publicKeyJwk"]},"HealthLivenessResponseBody":{"title":"HealthLivenessResponseBody","type":"object","properties":{"service":{"type":"string","description":"Service name.","example":"Repudiandae quam reprehenderit sed molestias eaque."},"status":{"type":"string","description":"Status message.","example":"Rerum dolores ipsa."},"version":{"type":"string","description":"Service runtime version.","example":"Praesentium nesciunt."}},"example":{"service":"Laboriosam qui.","status":"Consequatur omnis architecto nobis vel id.","version":"Nam ea ducimus."},"required":["service","status","version"]},"HealthReadinessResponseBody":{"title":"HealthReadinessResponseBody","type":"object","properties":{"service":{"type":"string","description":"Service name.","example":"Ea quas praesentium voluptas occaecati est facere."},"status":{"type":"string","description":"Status message.","example":"Dolores velit."},"version":{"type":"string","description":"Service runtime version.","example":"Tempore suscipit ut occaecati."}},"example":{"service":"Ut dolor numquam et dolores.","status":"Neque blanditiis nostrum nihil consequuntur est.","version":"Explicabo possimus ea."},"required":["service","status","version"]},"SignerCreateCredentialRequestBody":{"title":"SignerCreateCredentialRequestBody","type":"object","properties":{"context":{"type":"array","items":{"type":"string","example":"Sed aut."},"description":"Additional JSONLD contexts to be specified in the VC.","example":["https://w3id.org/security/suites/jws-2020/v1","https://schema.org"]},"credentialSubject":{"type":"string","description":"Raw JSON that will be the VC subject.","example":{"hello":"world"},"format":"binary"},"issuer":{"type":"string","description":"Issuer DID of the Verifiable Credential.","example":"did:web:example.com"},"key":{"type":"string","description":"Key to use for the proof signature.","example":"key1"},"namespace":{"type":"string","description":"Key namespace.","example":"transit"}},"example":{"context":["https://w3id.org/security/suites/jws-2020/v1","https://schema.org"],"credentialSubject":{"hello":"world"},"issuer":"did:web:example.com","key":"key1","namespace":"transit"},"required":["issuer","namespace","key","credentialSubject"]},"SignerCreatePresentationRequestBody":{"title":"SignerCreatePresentationRequestBody","type":"object","properties":{"context":{"type":"array","items":{"type":"string","example":"Aut et aut adipisci voluptatem consectetur quidem."},"description":"Additional JSONLD contexts to be specified in the VP.","example":["https://w3id.org/security/suites/jws-2020/v1","https://schema.org"]},"data":{"type":"array","items":{"type":"string","example":"Facere quos corporis.","format":"binary"},"description":"Raw JSON to be included inside the VP as Verifiable Credential.","example":[{"hello":"world"},{"hola":"mundo"}]},"issuer":{"type":"string","description":"Issuer DID of the Verifiable Presentation.","example":"did:web:example.com"},"key":{"type":"string","description":"Key to use for the proof signature.","example":"key1"},"namespace":{"type":"string","description":"Key namespace.","example":"transit"}},"example":{"context":["https://w3id.org/security/suites/jws-2020/v1","https://schema.org"],"data":[{"hello":"world"},{"hola":"mundo"}],"issuer":"did:web:example.com","key":"key1","namespace":"transit"},"required":["issuer","namespace","key","data"]},"SignerCredentialProofRequestBody":{"title":"SignerCredentialProofRequestBody","type":"object","properties":{"credential":{"type":"string","description":"Verifiable Credential in JSON format.","example":{"@context":["https://www.w3.org/2018/credentials/v1","https://w3id.org/security/suites/jws-2020/v1","https://schema.org"],"type":"VerifiableCredential","issuer":"did:web:nginx:policy:policy:example:example:1.0:evaluation","issuanceDate":"2010-01-01T19:23:24.651387237Z","credentialSubject":{"name":"Alice","allow":true}},"format":"binary"},"key":{"type":"string","description":"Key to use for the proof signature (optional).","example":"key1"},"namespace":{"type":"string","description":"Key namespace.","example":"transit"}},"example":{"credential":{"@context":["https://www.w3.org/2018/credentials/v1","https://w3id.org/security/suites/jws-2020/v1","https://schema.org"],"type":"VerifiableCredential","issuer":"did:web:nginx:policy:policy:example:example:1.0:evaluation","issuanceDate":"2010-01-01T19:23:24.651387237Z","credentialSubject":{"name":"Alice","allow":true}},"key":"key1","namespace":"transit"},"required":["namespace","key","credential"]},"SignerPresentationProofRequestBody":{"title":"SignerPresentationProofRequestBody","type":"object","properties":{"issuer":{"type":"string","description":"Issuer DID used to specify proof verification info.","example":"Asperiores vitae rem."},"key":{"type":"string","description":"Key to use for the proof signature.","example":"key1"},"namespace":{"type":"string","description":"Key namespace.","example":"transit"},"presentation":{"type":"string","description":"Verifiable Presentation in JSON format.","example":"Quaerat odit optio.","format":"binary"}},"example":{"issuer":"Mollitia architecto rem beatae mollitia.","key":"key1","namespace":"transit","presentation":"Id tempora aut."},"required":["issuer","namespace","key","presentation"]},"SignerVerificationMethodResponseBody":{"title":"SignerVerificationMethodResponseBody","type":"object","properties":{"controller":{"type":"string","description":"Controller of verification method specified as DID.","example":"did:web:example.com"},"id":{"type":"string","description":"ID of verification method.","example":"key1"},"publicKeyJwk":{"type":"string","description":"Public Key encoded in JWK format.","example":"Fuga officia excepturi velit aut.","format":"binary"},"type":{"type":"string","description":"Type of verification method key.","example":"JsonWebKey2020"}},"description":"Public Key represented as DID Verification Method.","example":{"controller":"did:web:example.com","id":"key1","publicKeyJwk":"Natus quos ut corrupti.","type":"JsonWebKey2020"},"required":["id","type","controller","publicKeyJwk"]},"SignerVerifyCredentialResponseBody":{"title":"SignerVerifyCredentialResponseBody","type":"object","properties":{"valid":{"type":"boolean","description":"Valid specifies if the proof is successfully verified.","example":false}},"example":{"valid":false},"required":["valid"]},"SignerVerifyPresentationResponseBody":{"title":"SignerVerifyPresentationResponseBody","type":"object","properties":{"valid":{"type":"boolean","description":"Valid specifies if the proof is successfully verified.","example":true}},"example":{"valid":true},"required":["valid"]}}} \ No newline at end of file diff --git a/gen/http/openapi.yaml b/gen/http/openapi.yaml index e583d02..e234a3f 100644 --- a/gen/http/openapi.yaml +++ b/gen/http/openapi.yaml @@ -22,6 +22,12 @@ paths: responses: "200": description: OK response. + schema: + $ref: '#/definitions/HealthLivenessResponseBody' + required: + - service + - status + - version schemes: - http /readiness: @@ -33,6 +39,38 @@ paths: responses: "200": description: OK response. + schema: + $ref: '#/definitions/HealthReadinessResponseBody' + required: + - service + - status + - version + schemes: + - http + /v1/credential: + post: + tags: + - signer + summary: CreateCredential signer + description: CreateCredential creates VC with proof from raw JSON data. + operationId: signer#CreateCredential + parameters: + - name: CreateCredentialRequestBody + in: body + required: true + schema: + $ref: '#/definitions/SignerCreateCredentialRequestBody' + required: + - issuer + - namespace + - key + - credentialSubject + responses: + "200": + description: OK response. + schema: + type: string + format: binary schemes: - http /v1/credential/proof: @@ -98,7 +136,7 @@ paths: type: array items: type: string - example: Sed quos rerum deserunt a nihil aut. + example: Nihil iste debitis. schemes: - http /v1/namespaces/{namespace}/keys: @@ -121,7 +159,7 @@ paths: type: array items: type: string - example: Qui laboriosam qui est. + example: Sapiente dolorem qui possimus qui labore veritatis. schemes: - http /v1/presentation: @@ -278,7 +316,7 @@ definitions: publicKeyJwk: type: string description: Public Key encoded in JWK format. - example: Illum qui nihil. + example: Et nulla illo totam optio quia ab. format: binary type: type: string @@ -287,13 +325,106 @@ definitions: example: controller: did:web:example.com id: key1 - publicKeyJwk: Ut occaecati repellat. + publicKeyJwk: Quibusdam nemo ut iusto ut fugit. type: JsonWebKey2020 required: - id - type - controller - publicKeyJwk + HealthLivenessResponseBody: + title: HealthLivenessResponseBody + type: object + properties: + service: + type: string + description: Service name. + example: Repudiandae quam reprehenderit sed molestias eaque. + status: + type: string + description: Status message. + example: Rerum dolores ipsa. + version: + type: string + description: Service runtime version. + example: Praesentium nesciunt. + example: + service: Laboriosam qui. + status: Consequatur omnis architecto nobis vel id. + version: Nam ea ducimus. + required: + - service + - status + - version + HealthReadinessResponseBody: + title: HealthReadinessResponseBody + type: object + properties: + service: + type: string + description: Service name. + example: Ea quas praesentium voluptas occaecati est facere. + status: + type: string + description: Status message. + example: Dolores velit. + version: + type: string + description: Service runtime version. + example: Tempore suscipit ut occaecati. + example: + service: Ut dolor numquam et dolores. + status: Neque blanditiis nostrum nihil consequuntur est. + version: Explicabo possimus ea. + required: + - service + - status + - version + SignerCreateCredentialRequestBody: + title: SignerCreateCredentialRequestBody + type: object + properties: + context: + type: array + items: + type: string + example: Sed aut. + description: Additional JSONLD contexts to be specified in the VC. + example: + - https://w3id.org/security/suites/jws-2020/v1 + - https://schema.org + credentialSubject: + type: string + description: Raw JSON that will be the VC subject. + example: + hello: world + format: binary + issuer: + type: string + description: Issuer DID of the Verifiable Credential. + example: did:web:example.com + key: + type: string + description: Key to use for the proof signature. + example: key1 + namespace: + type: string + description: Key namespace. + example: transit + example: + context: + - https://w3id.org/security/suites/jws-2020/v1 + - https://schema.org + credentialSubject: + hello: world + issuer: did:web:example.com + key: key1 + namespace: transit + required: + - issuer + - namespace + - key + - credentialSubject SignerCreatePresentationRequestBody: title: SignerCreatePresentationRequestBody type: object @@ -302,7 +433,7 @@ definitions: type: array items: type: string - example: Et nulla illo totam optio quia ab. + example: Aut et aut adipisci voluptatem consectetur quidem. description: Additional JSONLD contexts to be specified in the VP. example: - https://w3id.org/security/suites/jws-2020/v1 @@ -311,7 +442,7 @@ definitions: type: array items: type: string - example: Natus quos ut corrupti. + example: Facere quos corporis. format: binary description: Raw JSON to be included inside the VP as Verifiable Credential. example: @@ -396,7 +527,7 @@ definitions: issuer: type: string description: Issuer DID used to specify proof verification info. - example: Non amet. + example: Asperiores vitae rem. key: type: string description: Key to use for the proof signature. @@ -408,13 +539,13 @@ definitions: presentation: type: string description: Verifiable Presentation in JSON format. - example: Nihil iste debitis. + example: Quaerat odit optio. format: binary example: - issuer: Sapiente dolorem qui possimus qui labore veritatis. + issuer: Mollitia architecto rem beatae mollitia. key: key1 namespace: transit - presentation: Fuga officia excepturi velit aut. + presentation: Id tempora aut. required: - issuer - namespace @@ -435,7 +566,7 @@ definitions: publicKeyJwk: type: string description: Public Key encoded in JWK format. - example: Accusamus dolor illo aliquid ipsum optio. + example: Fuga officia excepturi velit aut. format: binary type: type: string @@ -445,7 +576,7 @@ definitions: example: controller: did:web:example.com id: key1 - publicKeyJwk: Et et cupiditate debitis. + publicKeyJwk: Natus quos ut corrupti. type: JsonWebKey2020 required: - id @@ -461,7 +592,7 @@ definitions: description: Valid specifies if the proof is successfully verified. example: false example: - valid: true + valid: false required: - valid SignerVerifyPresentationResponseBody: @@ -473,6 +604,6 @@ definitions: description: Valid specifies if the proof is successfully verified. example: true example: - valid: false + valid: true required: - valid diff --git a/gen/http/openapi3.json b/gen/http/openapi3.json index 7aa9201..4b96dd7 100644 --- a/gen/http/openapi3.json +++ b/gen/http/openapi3.json @@ -1 +1 @@ -{"openapi":"3.0.3","info":{"title":"Signer Service","description":"Signer service exposes HTTP API for making and verifying digital signatures and proofs for Verifiable Credentials.","version":"1.0"},"servers":[{"url":"http://localhost:8085","description":"Signer Server"}],"paths":{"/liveness":{"get":{"tags":["health"],"summary":"Liveness health","operationId":"health#Liveness","responses":{"200":{"description":"OK response."}}}},"/readiness":{"get":{"tags":["health"],"summary":"Readiness health","operationId":"health#Readiness","responses":{"200":{"description":"OK response."}}}},"/v1/credential/proof":{"post":{"tags":["signer"],"summary":"CredentialProof signer","description":"CredentialProof adds a proof to a given Verifiable Credential.","operationId":"signer#CredentialProof","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CredentialProofRequestBody"},"example":{"credential":{"@context":["https://www.w3.org/2018/credentials/v1","https://w3id.org/security/suites/jws-2020/v1","https://schema.org"],"type":"VerifiableCredential","issuer":"did:web:nginx:policy:policy:example:example:1.0:evaluation","issuanceDate":"2010-01-01T19:23:24.651387237Z","credentialSubject":{"name":"Alice","allow":true}},"key":"key1","namespace":"transit"}}}},"responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"type":"string","example":"Qui et.","format":"binary"},"example":"Et repellat."}}}}}},"/v1/credential/verify":{"post":{"tags":["signer"],"summary":"VerifyCredential signer","description":"VerifyCredential verifies the proof of a Verifiable Credential.","operationId":"signer#VerifyCredential","requestBody":{"description":"Verifiable Credential in JSON format.","required":true,"content":{"application/json":{"schema":{"type":"string","description":"Verifiable Credential in JSON format.","example":"Vm9sdXB0YXMgdXQu","format":"binary"},"example":"VmVsaXQgc2l0IGV4ZXJjaXRhdGlvbmVtIGV0IGVsaWdlbmRpIGluY2lkdW50Lg=="}}},"responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/VerifyResult"},"example":{"valid":true}}}}}}},"/v1/namespaces":{"get":{"tags":["signer"],"summary":"Namespaces signer","description":"Namespaces returns all keys namespaces, which corresponds to enabled Vault transit engines.","operationId":"signer#Namespaces","responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"type":"array","items":{"type":"string","example":"Ut fugit."},"description":"List of available keys namespaces.","example":["Vitae rem soluta quaerat odit optio.","Mollitia architecto rem beatae mollitia.","Id tempora aut."]},"example":["Id vitae vel.","Vel porro qui quidem unde.","Quis voluptas.","Qui consequatur eum nulla eaque."]}}}}}},"/v1/namespaces/{namespace}/keys":{"get":{"tags":["signer"],"summary":"NamespaceKeys signer","description":"NamespaceKeys returns all keys in a given namespace.","operationId":"signer#NamespaceKeys","parameters":[{"name":"namespace","in":"path","description":"Namespace for signing keys.","required":true,"schema":{"type":"string","description":"Namespace for signing keys.","example":"did:web:example.com"},"example":"did:web:example.com"}],"responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"type":"array","items":{"type":"string","example":"Sed aut."},"description":"Array of key names in a given namespace.","example":["Quos corporis minus.","Et aut adipisci voluptatem consectetur.","Earum hic doloribus magnam.","Repudiandae quam reprehenderit sed molestias eaque."]},"example":["Occaecati nam temporibus.","Ex nihil.","Ea qui mollitia sapiente error nostrum quae."]}}}}}},"/v1/presentation":{"post":{"tags":["signer"],"summary":"CreatePresentation signer","description":"CreatePresentation creates VP with proof from raw JSON data.","operationId":"signer#CreatePresentation","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreatePresentationRequestBody"},"example":{"context":["https://w3id.org/security/suites/jws-2020/v1","https://schema.org"],"data":[{"hello":"world"},{"hola":"mundo"}],"issuer":"did:web:example.com","key":"key1","namespace":"transit"}}}},"responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"type":"string","example":"Explicabo possimus ea.","format":"binary"},"example":"Qui quia."}}}}}},"/v1/presentation/proof":{"post":{"tags":["signer"],"summary":"PresentationProof signer","description":"PresentationProof adds a proof to a given Verifiable Presentation.","operationId":"signer#PresentationProof","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PresentationProofRequestBody"},"example":{"issuer":"Qui ipsa aut non fuga iste.","key":"key1","namespace":"transit","presentation":"Iure ex consequatur facilis."}}}},"responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"type":"string","example":"Tempore suscipit ut occaecati.","format":"binary"},"example":"Sit quibusdam ipsam dolores quis."}}}}}},"/v1/presentation/verify":{"post":{"tags":["signer"],"summary":"VerifyPresentation signer","description":"VerifyPresentation verifies the proof of a Verifiable Presentation.","operationId":"signer#VerifyPresentation","requestBody":{"description":"Verifiable Presentation in JSON format.","required":true,"content":{"application/json":{"schema":{"type":"string","description":"Verifiable Presentation in JSON format.","example":"RW9zIGRvbG9yZW0gZG9sb3JlbXF1ZSBxdWlidXNkYW0u","format":"binary"},"example":"TW9sZXN0aWFlIGV2ZW5pZXQgdmVybyBlc3QgYWxpcXVhbS4="}}},"responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/VerifyResult"},"example":{"valid":false}}}}}}},"/v1/verification-methods/{namespace}/{did}":{"get":{"tags":["signer"],"summary":"VerificationMethods signer","description":"VerificationMethods returns all public keys in a given namespace. The result is formatted as array of DID verification methods with their controller attribute being the given DID in the request.","operationId":"signer#VerificationMethods","parameters":[{"name":"namespace","in":"path","description":"Keys namespace.","required":true,"schema":{"type":"string","description":"Keys namespace.","example":"transit"},"example":"transit"},{"name":"did","in":"path","description":"DID controller of the keys.","required":true,"schema":{"type":"string","description":"DID controller of the keys.","example":"did:web:example.com"},"example":"did:web:example.com"}],"responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/DIDVerificationMethod"},"description":"Array of public keys represented as DID Verification Methods.","example":[{"controller":"did:web:example.com","id":"key1","publicKeyJwk":"Illum nesciunt.","type":"JsonWebKey2020"},{"controller":"did:web:example.com","id":"key1","publicKeyJwk":"Illum nesciunt.","type":"JsonWebKey2020"}]},"example":[{"controller":"did:web:example.com","id":"key1","publicKeyJwk":"Illum nesciunt.","type":"JsonWebKey2020"},{"controller":"did:web:example.com","id":"key1","publicKeyJwk":"Illum nesciunt.","type":"JsonWebKey2020"},{"controller":"did:web:example.com","id":"key1","publicKeyJwk":"Illum nesciunt.","type":"JsonWebKey2020"},{"controller":"did:web:example.com","id":"key1","publicKeyJwk":"Illum nesciunt.","type":"JsonWebKey2020"}]}}}}}},"/v1/verification-methods/{namespace}/{key}/{did}":{"get":{"tags":["signer"],"summary":"VerificationMethod signer","description":"VerificationMethod returns a single public key formatted as DID verification method for a given namespace, key and did.","operationId":"signer#VerificationMethod","parameters":[{"name":"namespace","in":"path","description":"Key namespace.","required":true,"schema":{"type":"string","description":"Key namespace.","example":"transit"},"example":"transit"},{"name":"key","in":"path","description":"Name of requested key.","required":true,"schema":{"type":"string","description":"Name of requested key.","example":"key1"},"example":"key1"},{"name":"did","in":"path","description":"DID controller of the key.","required":true,"schema":{"type":"string","description":"DID controller of the key.","example":"did:web:example.com"},"example":"did:web:example.com"}],"responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DIDVerificationMethod"},"example":{"controller":"did:web:example.com","id":"key1","publicKeyJwk":"Iure maxime quasi exercitationem.","type":"JsonWebKey2020"}}}}}}}},"components":{"schemas":{"CreatePresentationRequestBody":{"type":"object","properties":{"context":{"type":"array","items":{"type":"string","example":"Neque blanditiis nostrum nihil consequuntur est."},"description":"Additional JSONLD contexts to be specified in the VP.","example":["https://w3id.org/security/suites/jws-2020/v1","https://schema.org"]},"data":{"type":"array","items":{"type":"string","example":"Ut dolor numquam et dolores.","format":"binary"},"description":"Raw JSON to be included inside the VP as Verifiable Credential.","example":[{"hello":"world"},{"hola":"mundo"}]},"issuer":{"type":"string","description":"Issuer DID of the Verifiable Presentation.","example":"did:web:example.com"},"key":{"type":"string","description":"Key to use for the proof signature.","example":"key1"},"namespace":{"type":"string","description":"Key namespace.","example":"transit"}},"example":{"context":["https://w3id.org/security/suites/jws-2020/v1","https://schema.org"],"data":[{"hello":"world"},{"hola":"mundo"}],"issuer":"did:web:example.com","key":"key1","namespace":"transit"},"required":["issuer","namespace","key","data"]},"CredentialProofRequestBody":{"type":"object","properties":{"credential":{"type":"string","description":"Verifiable Credential in JSON format.","example":{"@context":["https://www.w3.org/2018/credentials/v1","https://w3id.org/security/suites/jws-2020/v1","https://schema.org"],"type":"VerifiableCredential","issuer":"did:web:nginx:policy:policy:example:example:1.0:evaluation","issuanceDate":"2010-01-01T19:23:24.651387237Z","credentialSubject":{"name":"Alice","allow":true}},"format":"binary"},"key":{"type":"string","description":"Key to use for the proof signature (optional).","example":"key1"},"namespace":{"type":"string","description":"Key namespace.","example":"transit"}},"example":{"credential":{"@context":["https://www.w3.org/2018/credentials/v1","https://w3id.org/security/suites/jws-2020/v1","https://schema.org"],"type":"VerifiableCredential","issuer":"did:web:nginx:policy:policy:example:example:1.0:evaluation","issuanceDate":"2010-01-01T19:23:24.651387237Z","credentialSubject":{"name":"Alice","allow":true}},"key":"key1","namespace":"transit"},"required":["namespace","key","credential"]},"DIDVerificationMethod":{"type":"object","properties":{"controller":{"type":"string","description":"Controller of verification method specified as DID.","example":"did:web:example.com"},"id":{"type":"string","description":"ID of verification method.","example":"key1"},"publicKeyJwk":{"type":"string","description":"Public Key encoded in JWK format.","example":"Rerum dolores ipsa.","format":"binary"},"type":{"type":"string","description":"Type of verification method key.","example":"JsonWebKey2020"}},"description":"Public Key represented as DID Verification Method.","example":{"controller":"did:web:example.com","id":"key1","publicKeyJwk":"Praesentium nesciunt.","type":"JsonWebKey2020"},"required":["id","type","controller","publicKeyJwk"]},"PresentationProofRequestBody":{"type":"object","properties":{"issuer":{"type":"string","description":"Issuer DID used to specify proof verification info.","example":"Omnis architecto nobis vel id."},"key":{"type":"string","description":"Key to use for the proof signature.","example":"key1"},"namespace":{"type":"string","description":"Key namespace.","example":"transit"},"presentation":{"type":"string","description":"Verifiable Presentation in JSON format.","example":"Nam ea ducimus.","format":"binary"}},"example":{"issuer":"Ea quas praesentium voluptas occaecati est facere.","key":"key1","namespace":"transit","presentation":"Dolores velit."},"required":["issuer","namespace","key","presentation"]},"VerifyResult":{"type":"object","properties":{"valid":{"type":"boolean","description":"Valid specifies if the proof is successfully verified.","example":true}},"example":{"valid":true},"required":["valid"]}}},"tags":[{"name":"health","description":"Health service provides health check endpoints."},{"name":"signer","description":"Signer service makes digital signatures and proofs for verifiable credentials and presentations."}]} \ No newline at end of file +{"openapi":"3.0.3","info":{"title":"Signer Service","description":"Signer service exposes HTTP API for making and verifying digital signatures and proofs for Verifiable Credentials.","version":"1.0"},"servers":[{"url":"http://localhost:8085","description":"Signer Server"}],"paths":{"/liveness":{"get":{"tags":["health"],"summary":"Liveness health","operationId":"health#Liveness","responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HealthResponse"},"example":{"service":"Laboriosam qui est quaerat.","status":"Dolor illo aliquid ipsum optio.","version":"Et et cupiditate debitis."}}}}}}},"/readiness":{"get":{"tags":["health"],"summary":"Readiness health","operationId":"health#Readiness","responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HealthResponse"},"example":{"service":"Illum qui nihil.","status":"Ut occaecati repellat.","version":"Non amet."}}}}}}},"/v1/credential":{"post":{"tags":["signer"],"summary":"CreateCredential signer","description":"CreateCredential creates VC with proof from raw JSON data.","operationId":"signer#CreateCredential","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateCredentialRequestBody"},"example":{"context":["https://w3id.org/security/suites/jws-2020/v1","https://schema.org"],"credentialSubject":{"hello":"world"},"issuer":"did:web:example.com","key":"key1","namespace":"transit"}}}},"responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"type":"string","example":"Est quos possimus sed sit voluptates nihil.","format":"binary"},"example":"Aperiam odit illo natus."}}}}}},"/v1/credential/proof":{"post":{"tags":["signer"],"summary":"CredentialProof signer","description":"CredentialProof adds a proof to a given Verifiable Credential.","operationId":"signer#CredentialProof","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CredentialProofRequestBody"},"example":{"credential":{"@context":["https://www.w3.org/2018/credentials/v1","https://w3id.org/security/suites/jws-2020/v1","https://schema.org"],"type":"VerifiableCredential","issuer":"did:web:nginx:policy:policy:example:example:1.0:evaluation","issuanceDate":"2010-01-01T19:23:24.651387237Z","credentialSubject":{"name":"Alice","allow":true}},"key":"key1","namespace":"transit"}}}},"responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"type":"string","example":"Sit exercitationem et eligendi incidunt.","format":"binary"},"example":"Laudantium nulla quod ab adipisci odio."}}}}}},"/v1/credential/verify":{"post":{"tags":["signer"],"summary":"VerifyCredential signer","description":"VerifyCredential verifies the proof of a Verifiable Credential.","operationId":"signer#VerifyCredential","requestBody":{"description":"Verifiable Credential in JSON format.","required":true,"content":{"application/json":{"schema":{"type":"string","description":"Verifiable Credential in JSON format.","example":"UXVpIHJlcnVtLg==","format":"binary"},"example":"T2NjYWVjYXRpIGRvbG9yZW1xdWUgYW5pbWkgcXVpYSBkZXNlcnVudCBxdWlkZW0gZXQu"}}},"responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/VerifyResult"},"example":{"valid":true}}}}}}},"/v1/namespaces":{"get":{"tags":["signer"],"summary":"Namespaces signer","description":"Namespaces returns all keys namespaces, which corresponds to enabled Vault transit engines.","operationId":"signer#Namespaces","responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"type":"array","items":{"type":"string","example":"Voluptas ut."},"description":"List of available keys namespaces.","example":["Itaque eos dolorem doloremque quibusdam.","Molestiae id vitae vel.","Vel porro qui quidem unde.","Quis voluptas."]},"example":["Quae accusantium similique beatae nihil molestias.","Neque voluptates dolores.","Reiciendis aut nobis qui debitis enim quaerat."]}}}}}},"/v1/namespaces/{namespace}/keys":{"get":{"tags":["signer"],"summary":"NamespaceKeys signer","description":"NamespaceKeys returns all keys in a given namespace.","operationId":"signer#NamespaceKeys","parameters":[{"name":"namespace","in":"path","description":"Namespace for signing keys.","required":true,"schema":{"type":"string","description":"Namespace for signing keys.","example":"did:web:example.com"},"example":"did:web:example.com"}],"responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"type":"array","items":{"type":"string","example":"Qui consequatur eum nulla eaque."},"description":"Array of key names in a given namespace.","example":["Occaecati nam temporibus.","Ex nihil.","Ea qui mollitia sapiente error nostrum quae."]},"example":["Illum minus quasi sequi molestiae.","Ducimus occaecati reprehenderit neque labore quia rem.","Eum hic autem in.","Magnam unde provident explicabo numquam culpa eum."]}}}}}},"/v1/presentation":{"post":{"tags":["signer"],"summary":"CreatePresentation signer","description":"CreatePresentation creates VP with proof from raw JSON data.","operationId":"signer#CreatePresentation","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreatePresentationRequestBody"},"example":{"context":["https://w3id.org/security/suites/jws-2020/v1","https://schema.org"],"data":[{"hello":"world"},{"hola":"mundo"}],"issuer":"did:web:example.com","key":"key1","namespace":"transit"}}}},"responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"type":"string","example":"Suscipit expedita quos eligendi.","format":"binary"},"example":"Tenetur ut consequuntur."}}}}}},"/v1/presentation/proof":{"post":{"tags":["signer"],"summary":"PresentationProof signer","description":"PresentationProof adds a proof to a given Verifiable Presentation.","operationId":"signer#PresentationProof","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PresentationProofRequestBody"},"example":{"issuer":"Consequatur facilis eius.","key":"key1","namespace":"transit","presentation":"Dicta commodi possimus recusandae et."}}}},"responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"type":"string","example":"Earum debitis.","format":"binary"},"example":"Nam accusamus ea dolorem tenetur."}}}}}},"/v1/presentation/verify":{"post":{"tags":["signer"],"summary":"VerifyPresentation signer","description":"VerifyPresentation verifies the proof of a Verifiable Presentation.","operationId":"signer#VerifyPresentation","requestBody":{"description":"Verifiable Presentation in JSON format.","required":true,"content":{"application/json":{"schema":{"type":"string","description":"Verifiable Presentation in JSON format.","example":"UGVyc3BpY2lhdGlzIHZlbGl0IHJlcHVkaWFuZGFlIHZvbHVwdGF0ZW0gbW9kaSByZXJ1bSByYXRpb25lLg==","format":"binary"},"example":"TWF4aW1lIHRvdGFtIHZvbHVwdGF0aWJ1cyBjb3JydXB0aSBpcHNhbS4="}}},"responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/VerifyResult"},"example":{"valid":false}}}}}}},"/v1/verification-methods/{namespace}/{did}":{"get":{"tags":["signer"],"summary":"VerificationMethods signer","description":"VerificationMethods returns all public keys in a given namespace. The result is formatted as array of DID verification methods with their controller attribute being the given DID in the request.","operationId":"signer#VerificationMethods","parameters":[{"name":"namespace","in":"path","description":"Keys namespace.","required":true,"schema":{"type":"string","description":"Keys namespace.","example":"transit"},"example":"transit"},{"name":"did","in":"path","description":"DID controller of the keys.","required":true,"schema":{"type":"string","description":"DID controller of the keys.","example":"did:web:example.com"},"example":"did:web:example.com"}],"responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/DIDVerificationMethod"},"description":"Array of public keys represented as DID Verification Methods.","example":[{"controller":"did:web:example.com","id":"key1","publicKeyJwk":"Omnis aut qui odit ut.","type":"JsonWebKey2020"},{"controller":"did:web:example.com","id":"key1","publicKeyJwk":"Omnis aut qui odit ut.","type":"JsonWebKey2020"},{"controller":"did:web:example.com","id":"key1","publicKeyJwk":"Omnis aut qui odit ut.","type":"JsonWebKey2020"}]},"example":[{"controller":"did:web:example.com","id":"key1","publicKeyJwk":"Omnis aut qui odit ut.","type":"JsonWebKey2020"},{"controller":"did:web:example.com","id":"key1","publicKeyJwk":"Omnis aut qui odit ut.","type":"JsonWebKey2020"}]}}}}}},"/v1/verification-methods/{namespace}/{key}/{did}":{"get":{"tags":["signer"],"summary":"VerificationMethod signer","description":"VerificationMethod returns a single public key formatted as DID verification method for a given namespace, key and did.","operationId":"signer#VerificationMethod","parameters":[{"name":"namespace","in":"path","description":"Key namespace.","required":true,"schema":{"type":"string","description":"Key namespace.","example":"transit"},"example":"transit"},{"name":"key","in":"path","description":"Name of requested key.","required":true,"schema":{"type":"string","description":"Name of requested key.","example":"key1"},"example":"key1"},{"name":"did","in":"path","description":"DID controller of the key.","required":true,"schema":{"type":"string","description":"DID controller of the key.","example":"did:web:example.com"},"example":"did:web:example.com"}],"responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DIDVerificationMethod"},"example":{"controller":"did:web:example.com","id":"key1","publicKeyJwk":"Quasi exercitationem provident illum nesciunt similique veniam.","type":"JsonWebKey2020"}}}}}}}},"components":{"schemas":{"CreateCredentialRequestBody":{"type":"object","properties":{"context":{"type":"array","items":{"type":"string","example":"Rerum veritatis delectus quis recusandae."},"description":"Additional JSONLD contexts to be specified in the VC.","example":["https://w3id.org/security/suites/jws-2020/v1","https://schema.org"]},"credentialSubject":{"type":"string","description":"Raw JSON that will be the VC subject.","example":{"hello":"world"},"format":"binary"},"issuer":{"type":"string","description":"Issuer DID of the Verifiable Credential.","example":"did:web:example.com"},"key":{"type":"string","description":"Key to use for the proof signature.","example":"key1"},"namespace":{"type":"string","description":"Key namespace.","example":"transit"}},"example":{"context":["https://w3id.org/security/suites/jws-2020/v1","https://schema.org"],"credentialSubject":{"hello":"world"},"issuer":"did:web:example.com","key":"key1","namespace":"transit"},"required":["issuer","namespace","key","credentialSubject"]},"CreatePresentationRequestBody":{"type":"object","properties":{"context":{"type":"array","items":{"type":"string","example":"Sint laudantium rerum neque."},"description":"Additional JSONLD contexts to be specified in the VP.","example":["https://w3id.org/security/suites/jws-2020/v1","https://schema.org"]},"data":{"type":"array","items":{"type":"string","example":"Ducimus eum facere enim accusantium.","format":"binary"},"description":"Raw JSON to be included inside the VP as Verifiable Credential.","example":[{"hello":"world"},{"hola":"mundo"}]},"issuer":{"type":"string","description":"Issuer DID of the Verifiable Presentation.","example":"did:web:example.com"},"key":{"type":"string","description":"Key to use for the proof signature.","example":"key1"},"namespace":{"type":"string","description":"Key namespace.","example":"transit"}},"example":{"context":["https://w3id.org/security/suites/jws-2020/v1","https://schema.org"],"data":[{"hello":"world"},{"hola":"mundo"}],"issuer":"did:web:example.com","key":"key1","namespace":"transit"},"required":["issuer","namespace","key","data"]},"CredentialProofRequestBody":{"type":"object","properties":{"credential":{"type":"string","description":"Verifiable Credential in JSON format.","example":{"@context":["https://www.w3.org/2018/credentials/v1","https://w3id.org/security/suites/jws-2020/v1","https://schema.org"],"type":"VerifiableCredential","issuer":"did:web:nginx:policy:policy:example:example:1.0:evaluation","issuanceDate":"2010-01-01T19:23:24.651387237Z","credentialSubject":{"name":"Alice","allow":true}},"format":"binary"},"key":{"type":"string","description":"Key to use for the proof signature (optional).","example":"key1"},"namespace":{"type":"string","description":"Key namespace.","example":"transit"}},"example":{"credential":{"@context":["https://www.w3.org/2018/credentials/v1","https://w3id.org/security/suites/jws-2020/v1","https://schema.org"],"type":"VerifiableCredential","issuer":"did:web:nginx:policy:policy:example:example:1.0:evaluation","issuanceDate":"2010-01-01T19:23:24.651387237Z","credentialSubject":{"name":"Alice","allow":true}},"key":"key1","namespace":"transit"},"required":["namespace","key","credential"]},"DIDVerificationMethod":{"type":"object","properties":{"controller":{"type":"string","description":"Controller of verification method specified as DID.","example":"did:web:example.com"},"id":{"type":"string","description":"ID of verification method.","example":"key1"},"publicKeyJwk":{"type":"string","description":"Public Key encoded in JWK format.","example":"Incidunt et repellat cum sit quibusdam.","format":"binary"},"type":{"type":"string","description":"Type of verification method key.","example":"JsonWebKey2020"}},"description":"Public Key represented as DID Verification Method.","example":{"controller":"did:web:example.com","id":"key1","publicKeyJwk":"Dolores quis fugiat qui quia.","type":"JsonWebKey2020"},"required":["id","type","controller","publicKeyJwk"]},"HealthResponse":{"type":"object","properties":{"service":{"type":"string","description":"Service name.","example":"Asperiores rem tempora."},"status":{"type":"string","description":"Status message.","example":"Non aut inventore necessitatibus unde."},"version":{"type":"string","description":"Service runtime version.","example":"Ut similique molestias aperiam quia et."}},"example":{"service":"Est asperiores velit eum perferendis.","status":"Rerum quaerat sit.","version":"Omnis est aspernatur voluptas in."},"required":["service","status","version"]},"PresentationProofRequestBody":{"type":"object","properties":{"issuer":{"type":"string","description":"Issuer DID used to specify proof verification info.","example":"Molestiae eveniet vero est aliquam."},"key":{"type":"string","description":"Key to use for the proof signature.","example":"key1"},"namespace":{"type":"string","description":"Key namespace.","example":"transit"},"presentation":{"type":"string","description":"Verifiable Presentation in JSON format.","example":"Totam quam.","format":"binary"}},"example":{"issuer":"Voluptates consectetur et repellat.","key":"key1","namespace":"transit","presentation":"Repudiandae aut dolorum hic aut voluptatem soluta."},"required":["issuer","namespace","key","presentation"]},"VerifyResult":{"type":"object","properties":{"valid":{"type":"boolean","description":"Valid specifies if the proof is successfully verified.","example":false}},"example":{"valid":false},"required":["valid"]}}},"tags":[{"name":"signer","description":"Signer service makes digital signatures and proofs for verifiable credentials and presentations."},{"name":"health","description":"Health service provides health check endpoints."}]} \ No newline at end of file diff --git a/gen/http/openapi3.yaml b/gen/http/openapi3.yaml index 054b669..d8096d1 100644 --- a/gen/http/openapi3.yaml +++ b/gen/http/openapi3.yaml @@ -16,6 +16,14 @@ paths: responses: "200": description: OK response. + content: + application/json: + schema: + $ref: '#/components/schemas/HealthResponse' + example: + service: Laboriosam qui est quaerat. + status: Dolor illo aliquid ipsum optio. + version: Et et cupiditate debitis. /readiness: get: tags: @@ -25,6 +33,46 @@ paths: responses: "200": description: OK response. + content: + application/json: + schema: + $ref: '#/components/schemas/HealthResponse' + example: + service: Illum qui nihil. + status: Ut occaecati repellat. + version: Non amet. + /v1/credential: + post: + tags: + - signer + summary: CreateCredential signer + description: CreateCredential creates VC with proof from raw JSON data. + operationId: signer#CreateCredential + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/CreateCredentialRequestBody' + example: + context: + - https://w3id.org/security/suites/jws-2020/v1 + - https://schema.org + credentialSubject: + hello: world + issuer: did:web:example.com + key: key1 + namespace: transit + responses: + "200": + description: OK response. + content: + application/json: + schema: + type: string + example: Est quos possimus sed sit voluptates nihil. + format: binary + example: Aperiam odit illo natus. /v1/credential/proof: post: tags: @@ -59,9 +107,9 @@ paths: application/json: schema: type: string - example: Qui et. + example: Sit exercitationem et eligendi incidunt. format: binary - example: Et repellat. + example: Laudantium nulla quod ab adipisci odio. /v1/credential/verify: post: tags: @@ -78,65 +126,68 @@ paths: type: string description: Verifiable Credential in JSON format. example: - - 86 - - 111 - - 108 + - 81 - 117 - - 112 - - 116 - - 97 - - 115 + - 105 - 32 + - 114 + - 101 + - 114 - 117 - - 116 + - 109 - 46 format: binary example: - - 86 - - 101 - - 108 - - 105 - - 116 - - 32 - - 115 - - 105 - - 116 - - 32 - - 101 - - 120 + - 79 + - 99 + - 99 + - 97 - 101 - - 114 - 99 - - 105 - - 116 - 97 - 116 - 105 + - 32 + - 100 - 111 - - 110 + - 108 + - 111 + - 114 - 101 - 109 - - 32 + - 113 + - 117 - 101 - - 116 - 32 - - 101 - - 108 - - 105 - - 103 - - 101 + - 97 - 110 - - 100 - 105 - - 32 + - 109 - 105 - - 110 - - 99 + - 32 + - 113 + - 117 - 105 + - 97 + - 32 - 100 + - 101 + - 115 + - 101 + - 114 - 117 - 110 - 116 + - 32 + - 113 + - 117 + - 105 + - 100 + - 101 + - 109 + - 32 + - 101 + - 116 - 46 responses: "200": @@ -163,17 +214,17 @@ paths: type: array items: type: string - example: Ut fugit. + example: Voluptas ut. description: List of available keys namespaces. example: - - Vitae rem soluta quaerat odit optio. - - Mollitia architecto rem beatae mollitia. - - Id tempora aut. + - Itaque eos dolorem doloremque quibusdam. + - Molestiae id vitae vel. + - Vel porro qui quidem unde. + - Quis voluptas. example: - - Id vitae vel. - - Vel porro qui quidem unde. - - Quis voluptas. - - Qui consequatur eum nulla eaque. + - Quae accusantium similique beatae nihil molestias. + - Neque voluptates dolores. + - Reiciendis aut nobis qui debitis enim quaerat. /v1/namespaces/{namespace}/keys: get: tags: @@ -200,17 +251,17 @@ paths: type: array items: type: string - example: Sed aut. + example: Qui consequatur eum nulla eaque. description: Array of key names in a given namespace. example: - - Quos corporis minus. - - Et aut adipisci voluptatem consectetur. - - Earum hic doloribus magnam. - - Repudiandae quam reprehenderit sed molestias eaque. + - Occaecati nam temporibus. + - Ex nihil. + - Ea qui mollitia sapiente error nostrum quae. example: - - Occaecati nam temporibus. - - Ex nihil. - - Ea qui mollitia sapiente error nostrum quae. + - Illum minus quasi sequi molestiae. + - Ducimus occaecati reprehenderit neque labore quia rem. + - Eum hic autem in. + - Magnam unde provident explicabo numquam culpa eum. /v1/presentation: post: tags: @@ -241,9 +292,9 @@ paths: application/json: schema: type: string - example: Explicabo possimus ea. + example: Suscipit expedita quos eligendi. format: binary - example: Qui quia. + example: Tenetur ut consequuntur. /v1/presentation/proof: post: tags: @@ -258,10 +309,10 @@ paths: schema: $ref: '#/components/schemas/PresentationProofRequestBody' example: - issuer: Qui ipsa aut non fuga iste. + issuer: Consequatur facilis eius. key: key1 namespace: transit - presentation: Iure ex consequatur facilis. + presentation: Dicta commodi possimus recusandae et. responses: "200": description: OK response. @@ -269,9 +320,9 @@ paths: application/json: schema: type: string - example: Tempore suscipit ut occaecati. + example: Earum debitis. format: binary - example: Sit quibusdam ipsam dolores quis. + example: Nam accusamus ea dolorem tenetur. /v1/presentation/verify: post: tags: @@ -288,73 +339,107 @@ paths: type: string description: Verifiable Presentation in JSON format. example: - - 69 - - 111 + - 80 + - 101 + - 114 + - 115 + - 112 + - 105 + - 99 + - 105 + - 97 + - 116 + - 105 - 115 - 32 - - 100 - - 111 + - 118 + - 101 - 108 - - 111 + - 105 + - 116 + - 32 - 114 - 101 - - 109 - - 32 + - 112 + - 117 - 100 + - 105 + - 97 + - 110 + - 100 + - 97 + - 101 + - 32 + - 118 - 111 - 108 - - 111 - - 114 - - 101 - - 109 - - 113 - 117 + - 112 + - 116 + - 97 + - 116 - 101 + - 109 - 32 - - 113 - - 117 + - 109 + - 111 + - 100 - 105 - - 98 + - 32 + - 114 + - 101 + - 114 - 117 - - 115 - - 100 - - 97 - 109 + - 32 + - 114 + - 97 + - 116 + - 105 + - 111 + - 110 + - 101 - 46 format: binary example: - 77 - - 111 - - 108 - - 101 - - 115 - - 116 - - 105 - 97 - - 101 - - 32 - - 101 - - 118 - - 101 - - 110 + - 120 - 105 + - 109 - 101 + - 32 - 116 + - 111 + - 116 + - 97 + - 109 - 32 - 118 - - 101 - - 114 - 111 - - 32 - - 101 - - 115 + - 108 + - 117 + - 112 - 116 - - 32 - 97 - - 108 + - 116 - 105 - - 113 + - 98 + - 117 + - 115 + - 32 + - 99 + - 111 + - 114 + - 114 - 117 + - 112 + - 116 + - 105 + - 32 + - 105 + - 112 + - 115 - 97 - 109 - 46 @@ -406,28 +491,24 @@ paths: example: - controller: did:web:example.com id: key1 - publicKeyJwk: Illum nesciunt. + publicKeyJwk: Omnis aut qui odit ut. type: JsonWebKey2020 - controller: did:web:example.com id: key1 - publicKeyJwk: Illum nesciunt. + publicKeyJwk: Omnis aut qui odit ut. + type: JsonWebKey2020 + - controller: did:web:example.com + id: key1 + publicKeyJwk: Omnis aut qui odit ut. type: JsonWebKey2020 example: - controller: did:web:example.com id: key1 - publicKeyJwk: Illum nesciunt. - type: JsonWebKey2020 - - controller: did:web:example.com - id: key1 - publicKeyJwk: Illum nesciunt. + publicKeyJwk: Omnis aut qui odit ut. type: JsonWebKey2020 - controller: did:web:example.com id: key1 - publicKeyJwk: Illum nesciunt. - type: JsonWebKey2020 - - controller: did:web:example.com - id: key1 - publicKeyJwk: Illum nesciunt. + publicKeyJwk: Omnis aut qui odit ut. type: JsonWebKey2020 /v1/verification-methods/{namespace}/{key}/{did}: get: @@ -474,10 +555,54 @@ paths: example: controller: did:web:example.com id: key1 - publicKeyJwk: Iure maxime quasi exercitationem. + publicKeyJwk: Quasi exercitationem provident illum nesciunt similique veniam. type: JsonWebKey2020 components: schemas: + CreateCredentialRequestBody: + type: object + properties: + context: + type: array + items: + type: string + example: Rerum veritatis delectus quis recusandae. + description: Additional JSONLD contexts to be specified in the VC. + example: + - https://w3id.org/security/suites/jws-2020/v1 + - https://schema.org + credentialSubject: + type: string + description: Raw JSON that will be the VC subject. + example: + hello: world + format: binary + issuer: + type: string + description: Issuer DID of the Verifiable Credential. + example: did:web:example.com + key: + type: string + description: Key to use for the proof signature. + example: key1 + namespace: + type: string + description: Key namespace. + example: transit + example: + context: + - https://w3id.org/security/suites/jws-2020/v1 + - https://schema.org + credentialSubject: + hello: world + issuer: did:web:example.com + key: key1 + namespace: transit + required: + - issuer + - namespace + - key + - credentialSubject CreatePresentationRequestBody: type: object properties: @@ -485,7 +610,7 @@ components: type: array items: type: string - example: Neque blanditiis nostrum nihil consequuntur est. + example: Sint laudantium rerum neque. description: Additional JSONLD contexts to be specified in the VP. example: - https://w3id.org/security/suites/jws-2020/v1 @@ -494,7 +619,7 @@ components: type: array items: type: string - example: Ut dolor numquam et dolores. + example: Ducimus eum facere enim accusantium. format: binary description: Raw JSON to be included inside the VP as Verifiable Credential. example: @@ -585,7 +710,7 @@ components: publicKeyJwk: type: string description: Public Key encoded in JWK format. - example: Rerum dolores ipsa. + example: Incidunt et repellat cum sit quibusdam. format: binary type: type: string @@ -595,20 +720,43 @@ components: example: controller: did:web:example.com id: key1 - publicKeyJwk: Praesentium nesciunt. + publicKeyJwk: Dolores quis fugiat qui quia. type: JsonWebKey2020 required: - id - type - controller - publicKeyJwk + HealthResponse: + type: object + properties: + service: + type: string + description: Service name. + example: Asperiores rem tempora. + status: + type: string + description: Status message. + example: Non aut inventore necessitatibus unde. + version: + type: string + description: Service runtime version. + example: Ut similique molestias aperiam quia et. + example: + service: Est asperiores velit eum perferendis. + status: Rerum quaerat sit. + version: Omnis est aspernatur voluptas in. + required: + - service + - status + - version PresentationProofRequestBody: type: object properties: issuer: type: string description: Issuer DID used to specify proof verification info. - example: Omnis architecto nobis vel id. + example: Molestiae eveniet vero est aliquam. key: type: string description: Key to use for the proof signature. @@ -620,13 +768,13 @@ components: presentation: type: string description: Verifiable Presentation in JSON format. - example: Nam ea ducimus. + example: Totam quam. format: binary example: - issuer: Ea quas praesentium voluptas occaecati est facere. + issuer: Voluptates consectetur et repellat. key: key1 namespace: transit - presentation: Dolores velit. + presentation: Repudiandae aut dolorum hic aut voluptatem soluta. required: - issuer - namespace @@ -638,13 +786,13 @@ components: valid: type: boolean description: Valid specifies if the proof is successfully verified. - example: true + example: false example: - valid: true + valid: false required: - valid tags: - - name: health - description: Health service provides health check endpoints. - name: signer description: Signer service makes digital signatures and proofs for verifiable credentials and presentations. + - name: health + description: Health service provides health check endpoints. diff --git a/gen/http/signer/client/cli.go b/gen/http/signer/client/cli.go index 0dae0b6..4c4b7ee 100644 --- a/gen/http/signer/client/cli.go +++ b/gen/http/signer/client/cli.go @@ -103,7 +103,7 @@ func BuildPresentationProofPayload(signerPresentationProofBody string) (*signer. { err = json.Unmarshal([]byte(signerPresentationProofBody), &body) if err != nil { - return nil, fmt.Errorf("invalid JSON for body, \nerror: %s, \nexample of valid JSON:\n%s", err, "'{\n \"issuer\": \"Qui ipsa aut non fuga iste.\",\n \"key\": \"key1\",\n \"namespace\": \"transit\",\n \"presentation\": \"Iure ex consequatur facilis.\"\n }'") + return nil, fmt.Errorf("invalid JSON for body, \nerror: %s, \nexample of valid JSON:\n%s", err, "'{\n \"issuer\": \"Consequatur facilis eius.\",\n \"key\": \"key1\",\n \"namespace\": \"transit\",\n \"presentation\": \"Dicta commodi possimus recusandae et.\"\n }'") } if body.Presentation == nil { err = goa.MergeErrors(err, goa.MissingFieldError("presentation", "body")) @@ -122,6 +122,39 @@ func BuildPresentationProofPayload(signerPresentationProofBody string) (*signer. return v, nil } +// BuildCreateCredentialPayload builds the payload for the signer +// CreateCredential endpoint from CLI flags. +func BuildCreateCredentialPayload(signerCreateCredentialBody string) (*signer.CreateCredentialRequest, error) { + var err error + var body CreateCredentialRequestBody + { + err = json.Unmarshal([]byte(signerCreateCredentialBody), &body) + if err != nil { + return nil, fmt.Errorf("invalid JSON for body, \nerror: %s, \nexample of valid JSON:\n%s", err, "'{\n \"context\": [\n \"https://w3id.org/security/suites/jws-2020/v1\",\n \"https://schema.org\"\n ],\n \"credentialSubject\": {\n \"hello\": \"world\"\n },\n \"issuer\": \"did:web:example.com\",\n \"key\": \"key1\",\n \"namespace\": \"transit\"\n }'") + } + if body.CredentialSubject == nil { + err = goa.MergeErrors(err, goa.MissingFieldError("credentialSubject", "body")) + } + if err != nil { + return nil, err + } + } + v := &signer.CreateCredentialRequest{ + Issuer: body.Issuer, + Namespace: body.Namespace, + Key: body.Key, + CredentialSubject: body.CredentialSubject, + } + if body.Context != nil { + v.Context = make([]string, len(body.Context)) + for i, val := range body.Context { + v.Context[i] = val + } + } + + return v, nil +} + // BuildCreatePresentationPayload builds the payload for the signer // CreatePresentation endpoint from CLI flags. func BuildCreatePresentationPayload(signerCreatePresentationBody string) (*signer.CreatePresentationRequest, error) { diff --git a/gen/http/signer/client/client.go b/gen/http/signer/client/client.go index 4287db7..b41e17a 100644 --- a/gen/http/signer/client/client.go +++ b/gen/http/signer/client/client.go @@ -41,6 +41,10 @@ type Client struct { // PresentationProof endpoint. PresentationProofDoer goahttp.Doer + // CreateCredential Doer is the HTTP client used to make requests to the + // CreateCredential endpoint. + CreateCredentialDoer goahttp.Doer + // CreatePresentation Doer is the HTTP client used to make requests to the // CreatePresentation endpoint. CreatePresentationDoer goahttp.Doer @@ -79,6 +83,7 @@ func NewClient( VerificationMethodsDoer: doer, CredentialProofDoer: doer, PresentationProofDoer: doer, + CreateCredentialDoer: doer, CreatePresentationDoer: doer, VerifyCredentialDoer: doer, VerifyPresentationDoer: doer, @@ -214,6 +219,30 @@ func (c *Client) PresentationProof() goa.Endpoint { } } +// CreateCredential returns an endpoint that makes HTTP requests to the signer +// service CreateCredential server. +func (c *Client) CreateCredential() goa.Endpoint { + var ( + encodeRequest = EncodeCreateCredentialRequest(c.encoder) + decodeResponse = DecodeCreateCredentialResponse(c.decoder, c.RestoreResponseBody) + ) + return func(ctx context.Context, v any) (any, error) { + req, err := c.BuildCreateCredentialRequest(ctx, v) + if err != nil { + return nil, err + } + err = encodeRequest(req, v) + if err != nil { + return nil, err + } + resp, err := c.CreateCredentialDoer.Do(req) + if err != nil { + return nil, goahttp.ErrRequestError("signer", "CreateCredential", err) + } + return decodeResponse(resp) + } +} + // CreatePresentation returns an endpoint that makes HTTP requests to the // signer service CreatePresentation server. func (c *Client) CreatePresentation() goa.Endpoint { diff --git a/gen/http/signer/client/encode_decode.go b/gen/http/signer/client/encode_decode.go index 07f97e1..188c8dd 100644 --- a/gen/http/signer/client/encode_decode.go +++ b/gen/http/signer/client/encode_decode.go @@ -405,6 +405,72 @@ func DecodePresentationProofResponse(decoder func(*http.Response) goahttp.Decode } } +// BuildCreateCredentialRequest instantiates a HTTP request object with method +// and path set to call the "signer" service "CreateCredential" endpoint +func (c *Client) BuildCreateCredentialRequest(ctx context.Context, v any) (*http.Request, error) { + u := &url.URL{Scheme: c.scheme, Host: c.host, Path: CreateCredentialSignerPath()} + req, err := http.NewRequest("POST", u.String(), nil) + if err != nil { + return nil, goahttp.ErrInvalidURL("signer", "CreateCredential", u.String(), err) + } + if ctx != nil { + req = req.WithContext(ctx) + } + + return req, nil +} + +// EncodeCreateCredentialRequest returns an encoder for requests sent to the +// signer CreateCredential server. +func EncodeCreateCredentialRequest(encoder func(*http.Request) goahttp.Encoder) func(*http.Request, any) error { + return func(req *http.Request, v any) error { + p, ok := v.(*signer.CreateCredentialRequest) + if !ok { + return goahttp.ErrInvalidType("signer", "CreateCredential", "*signer.CreateCredentialRequest", v) + } + body := NewCreateCredentialRequestBody(p) + if err := encoder(req).Encode(&body); err != nil { + return goahttp.ErrEncodingError("signer", "CreateCredential", err) + } + return nil + } +} + +// DecodeCreateCredentialResponse returns a decoder for responses returned by +// the signer CreateCredential endpoint. restoreBody controls whether the +// response body should be restored after having been read. +func DecodeCreateCredentialResponse(decoder func(*http.Response) goahttp.Decoder, restoreBody bool) func(*http.Response) (any, error) { + return func(resp *http.Response) (any, error) { + if restoreBody { + b, err := io.ReadAll(resp.Body) + if err != nil { + return nil, err + } + resp.Body = io.NopCloser(bytes.NewBuffer(b)) + defer func() { + resp.Body = io.NopCloser(bytes.NewBuffer(b)) + }() + } else { + defer resp.Body.Close() + } + switch resp.StatusCode { + case http.StatusOK: + var ( + body any + err error + ) + err = decoder(resp).Decode(&body) + if err != nil { + return nil, goahttp.ErrDecodingError("signer", "CreateCredential", err) + } + return body, nil + default: + body, _ := io.ReadAll(resp.Body) + return nil, goahttp.ErrInvalidResponse("signer", "CreateCredential", resp.StatusCode, string(body)) + } + } +} + // BuildCreatePresentationRequest instantiates a HTTP request object with // method and path set to call the "signer" service "CreatePresentation" // endpoint diff --git a/gen/http/signer/client/paths.go b/gen/http/signer/client/paths.go index 78045e9..263b332 100644 --- a/gen/http/signer/client/paths.go +++ b/gen/http/signer/client/paths.go @@ -41,6 +41,11 @@ func PresentationProofSignerPath() string { return "/v1/presentation/proof" } +// CreateCredentialSignerPath returns the URL path to the signer service CreateCredential HTTP endpoint. +func CreateCredentialSignerPath() string { + return "/v1/credential" +} + // CreatePresentationSignerPath returns the URL path to the signer service CreatePresentation HTTP endpoint. func CreatePresentationSignerPath() string { return "/v1/presentation" diff --git a/gen/http/signer/client/types.go b/gen/http/signer/client/types.go index c67ad83..91ed9fc 100644 --- a/gen/http/signer/client/types.go +++ b/gen/http/signer/client/types.go @@ -36,6 +36,21 @@ type PresentationProofRequestBody struct { Presentation any `form:"presentation" json:"presentation" xml:"presentation"` } +// CreateCredentialRequestBody is the type of the "signer" service +// "CreateCredential" endpoint HTTP request body. +type CreateCredentialRequestBody struct { + // Issuer DID of the Verifiable Credential. + Issuer string `form:"issuer" json:"issuer" xml:"issuer"` + // Key namespace. + Namespace string `form:"namespace" json:"namespace" xml:"namespace"` + // Key to use for the proof signature. + Key string `form:"key" json:"key" xml:"key"` + // Raw JSON that will be the VC subject. + CredentialSubject any `form:"credentialSubject" json:"credentialSubject" xml:"credentialSubject"` + // Additional JSONLD contexts to be specified in the VC. + Context []string `form:"context,omitempty" json:"context,omitempty" xml:"context,omitempty"` +} + // CreatePresentationRequestBody is the type of the "signer" service // "CreatePresentation" endpoint HTTP request body. type CreatePresentationRequestBody struct { @@ -118,6 +133,24 @@ func NewPresentationProofRequestBody(p *signer.PresentationProofRequest) *Presen return body } +// NewCreateCredentialRequestBody builds the HTTP request body from the payload +// of the "CreateCredential" endpoint of the "signer" service. +func NewCreateCredentialRequestBody(p *signer.CreateCredentialRequest) *CreateCredentialRequestBody { + body := &CreateCredentialRequestBody{ + Issuer: p.Issuer, + Namespace: p.Namespace, + Key: p.Key, + CredentialSubject: p.CredentialSubject, + } + if p.Context != nil { + body.Context = make([]string, len(p.Context)) + for i, val := range p.Context { + body.Context[i] = val + } + } + return body +} + // NewCreatePresentationRequestBody builds the HTTP request body from the // payload of the "CreatePresentation" endpoint of the "signer" service. func NewCreatePresentationRequestBody(p *signer.CreatePresentationRequest) *CreatePresentationRequestBody { diff --git a/gen/http/signer/server/encode_decode.go b/gen/http/signer/server/encode_decode.go index 28ba5f5..41247ad 100644 --- a/gen/http/signer/server/encode_decode.go +++ b/gen/http/signer/server/encode_decode.go @@ -193,6 +193,43 @@ func DecodePresentationProofRequest(mux goahttp.Muxer, decoder func(*http.Reques } } +// EncodeCreateCredentialResponse returns an encoder for responses returned by +// the signer CreateCredential endpoint. +func EncodeCreateCredentialResponse(encoder func(context.Context, http.ResponseWriter) goahttp.Encoder) func(context.Context, http.ResponseWriter, any) error { + return func(ctx context.Context, w http.ResponseWriter, v any) error { + res, _ := v.(any) + enc := encoder(ctx, w) + body := res + w.WriteHeader(http.StatusOK) + return enc.Encode(body) + } +} + +// DecodeCreateCredentialRequest returns a decoder for requests sent to the +// signer CreateCredential endpoint. +func DecodeCreateCredentialRequest(mux goahttp.Muxer, decoder func(*http.Request) goahttp.Decoder) func(*http.Request) (any, error) { + return func(r *http.Request) (any, error) { + var ( + body CreateCredentialRequestBody + err error + ) + err = decoder(r).Decode(&body) + if err != nil { + if err == io.EOF { + return nil, goa.MissingPayloadError() + } + return nil, goa.DecodePayloadError(err.Error()) + } + err = ValidateCreateCredentialRequestBody(&body) + if err != nil { + return nil, err + } + payload := NewCreateCredentialRequest(&body) + + return payload, nil + } +} + // EncodeCreatePresentationResponse returns an encoder for responses returned // by the signer CreatePresentation endpoint. func EncodeCreatePresentationResponse(encoder func(context.Context, http.ResponseWriter) goahttp.Encoder) func(context.Context, http.ResponseWriter, any) error { diff --git a/gen/http/signer/server/paths.go b/gen/http/signer/server/paths.go index ec1266d..0550ca3 100644 --- a/gen/http/signer/server/paths.go +++ b/gen/http/signer/server/paths.go @@ -41,6 +41,11 @@ func PresentationProofSignerPath() string { return "/v1/presentation/proof" } +// CreateCredentialSignerPath returns the URL path to the signer service CreateCredential HTTP endpoint. +func CreateCredentialSignerPath() string { + return "/v1/credential" +} + // CreatePresentationSignerPath returns the URL path to the signer service CreatePresentation HTTP endpoint. func CreatePresentationSignerPath() string { return "/v1/presentation" diff --git a/gen/http/signer/server/server.go b/gen/http/signer/server/server.go index 8f98fff..9c29856 100644 --- a/gen/http/signer/server/server.go +++ b/gen/http/signer/server/server.go @@ -25,6 +25,7 @@ type Server struct { VerificationMethods http.Handler CredentialProof http.Handler PresentationProof http.Handler + CreateCredential http.Handler CreatePresentation http.Handler VerifyCredential http.Handler VerifyPresentation http.Handler @@ -63,6 +64,7 @@ func New( {"VerificationMethods", "GET", "/v1/verification-methods/{namespace}/{did}"}, {"CredentialProof", "POST", "/v1/credential/proof"}, {"PresentationProof", "POST", "/v1/presentation/proof"}, + {"CreateCredential", "POST", "/v1/credential"}, {"CreatePresentation", "POST", "/v1/presentation"}, {"VerifyCredential", "POST", "/v1/credential/verify"}, {"VerifyPresentation", "POST", "/v1/presentation/verify"}, @@ -73,6 +75,7 @@ func New( VerificationMethods: NewVerificationMethodsHandler(e.VerificationMethods, mux, decoder, encoder, errhandler, formatter), CredentialProof: NewCredentialProofHandler(e.CredentialProof, mux, decoder, encoder, errhandler, formatter), PresentationProof: NewPresentationProofHandler(e.PresentationProof, mux, decoder, encoder, errhandler, formatter), + CreateCredential: NewCreateCredentialHandler(e.CreateCredential, mux, decoder, encoder, errhandler, formatter), CreatePresentation: NewCreatePresentationHandler(e.CreatePresentation, mux, decoder, encoder, errhandler, formatter), VerifyCredential: NewVerifyCredentialHandler(e.VerifyCredential, mux, decoder, encoder, errhandler, formatter), VerifyPresentation: NewVerifyPresentationHandler(e.VerifyPresentation, mux, decoder, encoder, errhandler, formatter), @@ -90,6 +93,7 @@ func (s *Server) Use(m func(http.Handler) http.Handler) { s.VerificationMethods = m(s.VerificationMethods) s.CredentialProof = m(s.CredentialProof) s.PresentationProof = m(s.PresentationProof) + s.CreateCredential = m(s.CreateCredential) s.CreatePresentation = m(s.CreatePresentation) s.VerifyCredential = m(s.VerifyCredential) s.VerifyPresentation = m(s.VerifyPresentation) @@ -106,6 +110,7 @@ func Mount(mux goahttp.Muxer, h *Server) { MountVerificationMethodsHandler(mux, h.VerificationMethods) MountCredentialProofHandler(mux, h.CredentialProof) MountPresentationProofHandler(mux, h.PresentationProof) + MountCreateCredentialHandler(mux, h.CreateCredential) MountCreatePresentationHandler(mux, h.CreatePresentation) MountVerifyCredentialHandler(mux, h.VerifyCredential) MountVerifyPresentationHandler(mux, h.VerifyPresentation) @@ -415,6 +420,57 @@ func NewPresentationProofHandler( }) } +// MountCreateCredentialHandler configures the mux to serve the "signer" +// service "CreateCredential" endpoint. +func MountCreateCredentialHandler(mux goahttp.Muxer, h http.Handler) { + f, ok := h.(http.HandlerFunc) + if !ok { + f = func(w http.ResponseWriter, r *http.Request) { + h.ServeHTTP(w, r) + } + } + mux.Handle("POST", "/v1/credential", f) +} + +// NewCreateCredentialHandler creates a HTTP handler which loads the HTTP +// request and calls the "signer" service "CreateCredential" endpoint. +func NewCreateCredentialHandler( + endpoint goa.Endpoint, + mux goahttp.Muxer, + decoder func(*http.Request) goahttp.Decoder, + encoder func(context.Context, http.ResponseWriter) goahttp.Encoder, + errhandler func(context.Context, http.ResponseWriter, error), + formatter func(ctx context.Context, err error) goahttp.Statuser, +) http.Handler { + var ( + decodeRequest = DecodeCreateCredentialRequest(mux, decoder) + encodeResponse = EncodeCreateCredentialResponse(encoder) + encodeError = goahttp.ErrorEncoder(encoder, formatter) + ) + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + ctx := context.WithValue(r.Context(), goahttp.AcceptTypeKey, r.Header.Get("Accept")) + ctx = context.WithValue(ctx, goa.MethodKey, "CreateCredential") + ctx = context.WithValue(ctx, goa.ServiceKey, "signer") + payload, err := decodeRequest(r) + if err != nil { + if err := encodeError(ctx, w, err); err != nil { + errhandler(ctx, w, err) + } + return + } + res, err := endpoint(ctx, payload) + if err != nil { + if err := encodeError(ctx, w, err); err != nil { + errhandler(ctx, w, err) + } + return + } + if err := encodeResponse(ctx, w, res); err != nil { + errhandler(ctx, w, err) + } + }) +} + // MountCreatePresentationHandler configures the mux to serve the "signer" // service "CreatePresentation" endpoint. func MountCreatePresentationHandler(mux goahttp.Muxer, h http.Handler) { diff --git a/gen/http/signer/server/types.go b/gen/http/signer/server/types.go index 7155780..667b807 100644 --- a/gen/http/signer/server/types.go +++ b/gen/http/signer/server/types.go @@ -36,6 +36,21 @@ type PresentationProofRequestBody struct { Presentation any `form:"presentation,omitempty" json:"presentation,omitempty" xml:"presentation,omitempty"` } +// CreateCredentialRequestBody is the type of the "signer" service +// "CreateCredential" endpoint HTTP request body. +type CreateCredentialRequestBody struct { + // Issuer DID of the Verifiable Credential. + Issuer *string `form:"issuer,omitempty" json:"issuer,omitempty" xml:"issuer,omitempty"` + // Key namespace. + Namespace *string `form:"namespace,omitempty" json:"namespace,omitempty" xml:"namespace,omitempty"` + // Key to use for the proof signature. + Key *string `form:"key,omitempty" json:"key,omitempty" xml:"key,omitempty"` + // Raw JSON that will be the VC subject. + CredentialSubject any `form:"credentialSubject,omitempty" json:"credentialSubject,omitempty" xml:"credentialSubject,omitempty"` + // Additional JSONLD contexts to be specified in the VC. + Context []string `form:"context,omitempty" json:"context,omitempty" xml:"context,omitempty"` +} + // CreatePresentationRequestBody is the type of the "signer" service // "CreatePresentation" endpoint HTTP request body. type CreatePresentationRequestBody struct { @@ -190,6 +205,25 @@ func NewPresentationProofRequest(body *PresentationProofRequestBody) *signer.Pre return v } +// NewCreateCredentialRequest builds a signer service CreateCredential endpoint +// payload. +func NewCreateCredentialRequest(body *CreateCredentialRequestBody) *signer.CreateCredentialRequest { + v := &signer.CreateCredentialRequest{ + Issuer: *body.Issuer, + Namespace: *body.Namespace, + Key: *body.Key, + CredentialSubject: body.CredentialSubject, + } + if body.Context != nil { + v.Context = make([]string, len(body.Context)) + for i, val := range body.Context { + v.Context[i] = val + } + } + + return v +} + // NewCreatePresentationRequest builds a signer service CreatePresentation // endpoint payload. func NewCreatePresentationRequest(body *CreatePresentationRequestBody) *signer.CreatePresentationRequest { @@ -267,6 +301,24 @@ func ValidatePresentationProofRequestBody(body *PresentationProofRequestBody) (e return } +// ValidateCreateCredentialRequestBody runs the validations defined on +// CreateCredentialRequestBody +func ValidateCreateCredentialRequestBody(body *CreateCredentialRequestBody) (err error) { + if body.Issuer == nil { + err = goa.MergeErrors(err, goa.MissingFieldError("issuer", "body")) + } + if body.Namespace == nil { + err = goa.MergeErrors(err, goa.MissingFieldError("namespace", "body")) + } + if body.Key == nil { + err = goa.MergeErrors(err, goa.MissingFieldError("key", "body")) + } + if body.CredentialSubject == nil { + err = goa.MergeErrors(err, goa.MissingFieldError("credentialSubject", "body")) + } + return +} + // ValidateCreatePresentationRequestBody runs the validations defined on // CreatePresentationRequestBody func ValidateCreatePresentationRequestBody(body *CreatePresentationRequestBody) (err error) { diff --git a/gen/signer/client.go b/gen/signer/client.go index 9d0af4c..55a746d 100644 --- a/gen/signer/client.go +++ b/gen/signer/client.go @@ -21,13 +21,14 @@ type Client struct { VerificationMethodsEndpoint goa.Endpoint CredentialProofEndpoint goa.Endpoint PresentationProofEndpoint goa.Endpoint + CreateCredentialEndpoint goa.Endpoint CreatePresentationEndpoint goa.Endpoint VerifyCredentialEndpoint goa.Endpoint VerifyPresentationEndpoint goa.Endpoint } // NewClient initializes a "signer" service client given the endpoints. -func NewClient(namespaces, namespaceKeys, verificationMethod, verificationMethods, credentialProof, presentationProof, createPresentation, verifyCredential, verifyPresentation goa.Endpoint) *Client { +func NewClient(namespaces, namespaceKeys, verificationMethod, verificationMethods, credentialProof, presentationProof, createCredential, createPresentation, verifyCredential, verifyPresentation goa.Endpoint) *Client { return &Client{ NamespacesEndpoint: namespaces, NamespaceKeysEndpoint: namespaceKeys, @@ -35,6 +36,7 @@ func NewClient(namespaces, namespaceKeys, verificationMethod, verificationMethod VerificationMethodsEndpoint: verificationMethods, CredentialProofEndpoint: credentialProof, PresentationProofEndpoint: presentationProof, + CreateCredentialEndpoint: createCredential, CreatePresentationEndpoint: createPresentation, VerifyCredentialEndpoint: verifyCredential, VerifyPresentationEndpoint: verifyPresentation, @@ -104,6 +106,17 @@ func (c *Client) PresentationProof(ctx context.Context, p *PresentationProofRequ return ires.(any), nil } +// CreateCredential calls the "CreateCredential" endpoint of the "signer" +// service. +func (c *Client) CreateCredential(ctx context.Context, p *CreateCredentialRequest) (res any, err error) { + var ires any + ires, err = c.CreateCredentialEndpoint(ctx, p) + if err != nil { + return + } + return ires.(any), nil +} + // CreatePresentation calls the "CreatePresentation" endpoint of the "signer" // service. func (c *Client) CreatePresentation(ctx context.Context, p *CreatePresentationRequest) (res any, err error) { diff --git a/gen/signer/endpoints.go b/gen/signer/endpoints.go index 862cd20..dfcf024 100644 --- a/gen/signer/endpoints.go +++ b/gen/signer/endpoints.go @@ -21,6 +21,7 @@ type Endpoints struct { VerificationMethods goa.Endpoint CredentialProof goa.Endpoint PresentationProof goa.Endpoint + CreateCredential goa.Endpoint CreatePresentation goa.Endpoint VerifyCredential goa.Endpoint VerifyPresentation goa.Endpoint @@ -35,6 +36,7 @@ func NewEndpoints(s Service) *Endpoints { VerificationMethods: NewVerificationMethodsEndpoint(s), CredentialProof: NewCredentialProofEndpoint(s), PresentationProof: NewPresentationProofEndpoint(s), + CreateCredential: NewCreateCredentialEndpoint(s), CreatePresentation: NewCreatePresentationEndpoint(s), VerifyCredential: NewVerifyCredentialEndpoint(s), VerifyPresentation: NewVerifyPresentationEndpoint(s), @@ -49,6 +51,7 @@ func (e *Endpoints) Use(m func(goa.Endpoint) goa.Endpoint) { e.VerificationMethods = m(e.VerificationMethods) e.CredentialProof = m(e.CredentialProof) e.PresentationProof = m(e.PresentationProof) + e.CreateCredential = m(e.CreateCredential) e.CreatePresentation = m(e.CreatePresentation) e.VerifyCredential = m(e.VerifyCredential) e.VerifyPresentation = m(e.VerifyPresentation) @@ -107,6 +110,15 @@ func NewPresentationProofEndpoint(s Service) goa.Endpoint { } } +// NewCreateCredentialEndpoint returns an endpoint function that calls the +// method "CreateCredential" of service "signer". +func NewCreateCredentialEndpoint(s Service) goa.Endpoint { + return func(ctx context.Context, req any) (any, error) { + p := req.(*CreateCredentialRequest) + return s.CreateCredential(ctx, p) + } +} + // NewCreatePresentationEndpoint returns an endpoint function that calls the // method "CreatePresentation" of service "signer". func NewCreatePresentationEndpoint(s Service) goa.Endpoint { diff --git a/gen/signer/service.go b/gen/signer/service.go index a1b3195..a961b72 100644 --- a/gen/signer/service.go +++ b/gen/signer/service.go @@ -30,6 +30,8 @@ type Service interface { CredentialProof(context.Context, *CredentialProofRequest) (res any, err error) // PresentationProof adds a proof to a given Verifiable Presentation. PresentationProof(context.Context, *PresentationProofRequest) (res any, err error) + // CreateCredential creates VC with proof from raw JSON data. + CreateCredential(context.Context, *CreateCredentialRequest) (res any, err error) // CreatePresentation creates VP with proof from raw JSON data. CreatePresentation(context.Context, *CreatePresentationRequest) (res any, err error) // VerifyCredential verifies the proof of a Verifiable Credential. @@ -46,7 +48,22 @@ const ServiceName = "signer" // MethodNames lists the service method names as defined in the design. These // are the same values that are set in the endpoint request contexts under the // MethodKey key. -var MethodNames = [9]string{"Namespaces", "NamespaceKeys", "VerificationMethod", "VerificationMethods", "CredentialProof", "PresentationProof", "CreatePresentation", "VerifyCredential", "VerifyPresentation"} +var MethodNames = [10]string{"Namespaces", "NamespaceKeys", "VerificationMethod", "VerificationMethods", "CredentialProof", "PresentationProof", "CreateCredential", "CreatePresentation", "VerifyCredential", "VerifyPresentation"} + +// CreateCredentialRequest is the payload type of the signer service +// CreateCredential method. +type CreateCredentialRequest struct { + // Issuer DID of the Verifiable Credential. + Issuer string + // Key namespace. + Namespace string + // Key to use for the proof signature. + Key string + // Raw JSON that will be the VC subject. + CredentialSubject any + // Additional JSONLD contexts to be specified in the VC. + Context []string +} // CreatePresentationRequest is the payload type of the signer service // CreatePresentation method. -- GitLab