diff --git a/design/design.go b/design/design.go index eafcfefa6ba78fd0b8be5cf2a3583c822ae377bf..cb8477f5eb610cabf6a2496b4f4025f73d08a509 100644 --- a/design/design.go +++ b/design/design.go @@ -58,6 +58,18 @@ var _ = Service("signer", func() { }) }) + Method("JwkPublicKey", func() { + Description("JwkPublicKey returns public key by name and namespace.") + Payload(JwkPublicKeyRequest) + Result(Any, "Public key encoded as JSON Web Key.") + HTTP(func() { + GET("/v1/jwk/{namespace}/{key}") + Response(StatusOK) + Response(StatusNotFound) + Response(StatusInternalServerError) + }) + }) + Method("CredentialProof", func() { Description("CredentialProof adds a proof to a given Verifiable Credential.") Payload(CredentialProofRequest) diff --git a/design/types.go b/design/types.go index bbcc86a7dbe8c4d04e1462577c1191d6fe1e8c4a..dd8ee49915247d8ef34c4cba261dac1a71d3c386 100644 --- a/design/types.go +++ b/design/types.go @@ -159,6 +159,16 @@ var DIDVerificationMethod = Type("DIDVerificationMethod", func() { Required("id", "type", "controller", "publicKeyJwk") }) +var JwkPublicKeyRequest = Type("JwkPublicKeyRequest", func() { + Field(1, "namespace", String, "Key namespace.", func() { + Example("transit") + }) + Field(2, "key", String, "Key name.", func() { + Example("my-ecdsa-key1") + }) + Required("namespace", "key") +}) + var SignRequest = Type("SignRequest", func() { Field(1, "namespace", String, "Key namespace to be used for signing.") Field(2, "key", String, "Key to be used for signing.") diff --git a/gen/http/cli/signer/cli.go b/gen/http/cli/signer/cli.go index 36aa7673c2d916b30bf4adcc1b57d715bec74d0b..7b6eb773e9759a4ae7cf6825dc70666ce72d4043 100644 --- a/gen/http/cli/signer/cli.go +++ b/gen/http/cli/signer/cli.go @@ -23,7 +23,7 @@ import ( // // command (subcommand1|subcommand2|...) func UsageCommands() string { - return `signer (namespaces|namespace-keys|verification-method|verification-methods|credential-proof|presentation-proof|create-credential|create-presentation|verify-credential|verify-presentation|sign) + return `signer (namespaces|namespace-keys|verification-method|verification-methods|jwk-public-key|credential-proof|presentation-proof|create-credential|create-presentation|verify-credential|verify-presentation|sign) health (liveness|readiness) ` } @@ -61,6 +61,10 @@ func ParseEndpoint( signerVerificationMethodsNamespaceFlag = signerVerificationMethodsFlags.String("namespace", "REQUIRED", "Keys namespace.") signerVerificationMethodsDidFlag = signerVerificationMethodsFlags.String("did", "REQUIRED", "DID controller of the keys.") + signerJwkPublicKeyFlags = flag.NewFlagSet("jwk-public-key", flag.ExitOnError) + signerJwkPublicKeyNamespaceFlag = signerJwkPublicKeyFlags.String("namespace", "REQUIRED", "Key namespace.") + signerJwkPublicKeyKeyFlag = signerJwkPublicKeyFlags.String("key", "REQUIRED", "Key name.") + signerCredentialProofFlags = flag.NewFlagSet("credential-proof", flag.ExitOnError) signerCredentialProofBodyFlag = signerCredentialProofFlags.String("body", "REQUIRED", "") @@ -93,6 +97,7 @@ func ParseEndpoint( signerNamespaceKeysFlags.Usage = signerNamespaceKeysUsage signerVerificationMethodFlags.Usage = signerVerificationMethodUsage signerVerificationMethodsFlags.Usage = signerVerificationMethodsUsage + signerJwkPublicKeyFlags.Usage = signerJwkPublicKeyUsage signerCredentialProofFlags.Usage = signerCredentialProofUsage signerPresentationProofFlags.Usage = signerPresentationProofUsage signerCreateCredentialFlags.Usage = signerCreateCredentialUsage @@ -153,6 +158,9 @@ func ParseEndpoint( case "verification-methods": epf = signerVerificationMethodsFlags + case "jwk-public-key": + epf = signerJwkPublicKeyFlags + case "credential-proof": epf = signerCredentialProofFlags @@ -221,6 +229,9 @@ func ParseEndpoint( case "verification-methods": endpoint = c.VerificationMethods() data, err = signerc.BuildVerificationMethodsPayload(*signerVerificationMethodsNamespaceFlag, *signerVerificationMethodsDidFlag) + case "jwk-public-key": + endpoint = c.JwkPublicKey() + data, err = signerc.BuildJwkPublicKeyPayload(*signerJwkPublicKeyNamespaceFlag, *signerJwkPublicKeyKeyFlag) case "credential-proof": endpoint = c.CredentialProof() data, err = signerc.BuildCredentialProofPayload(*signerCredentialProofBodyFlag) @@ -273,6 +284,7 @@ COMMAND: namespace-keys: NamespaceKeys returns all keys in a given namespace. verification-method: VerificationMethod returns a single public key formatted as DID verification method for a given namespace, key and did. 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. + jwk-public-key: JwkPublicKey returns public key by name and namespace. 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. @@ -331,6 +343,18 @@ Example: `, os.Args[0]) } +func signerJwkPublicKeyUsage() { + fmt.Fprintf(os.Stderr, `%[1]s [flags] signer jwk-public-key -namespace STRING -key STRING + +JwkPublicKey returns public key by name and namespace. + -namespace STRING: Key namespace. + -key STRING: Key name. + +Example: + %[1]s signer jwk-public-key --namespace "transit" --key "my-ecdsa-key1" +`, os.Args[0]) +} + func signerCredentialProofUsage() { fmt.Fprintf(os.Stderr, `%[1]s [flags] signer credential-proof -body JSON @@ -367,10 +391,10 @@ PresentationProof adds a proof to a given Verifiable Presentation. Example: %[1]s signer presentation-proof --body '{ - "issuer": "Neque impedit.", + "issuer": "Adipisci perferendis.", "key": "key1", "namespace": "transit", - "presentation": "Sunt vitae." + "presentation": "Est et autem." }' `, os.Args[0]) } @@ -431,7 +455,7 @@ VerifyCredential verifies the proof of a Verifiable Credential. -body STRING: Example: - %[1]s signer verify-credential --body "RGVzZXJ1bnQgYSBuaWhpbC4=" + %[1]s signer verify-credential --body "TmloaWwgaXN0ZSBkZWJpdGlzLg==" `, os.Args[0]) } @@ -442,7 +466,7 @@ VerifyPresentation verifies the proof of a Verifiable Presentation. -body STRING: Example: - %[1]s signer verify-presentation --body "SWxsdW0gcXVpIG5paGlsLg==" + %[1]s signer verify-presentation --body "TnVsbGEgaWxsbyB0b3RhbSBvcHRpbyBxdWlhIGFiLg==" `, os.Args[0]) } @@ -454,9 +478,9 @@ Sign creates digital signature on base64 encoded binary data. Example: %[1]s signer sign --body '{ - "data": "Sapiente dolorem qui possimus qui labore veritatis.", - "key": "Nihil iste debitis.", - "namespace": "Occaecati repellat est non amet." + "data": "Quaerat odit optio.", + "key": "Asperiores vitae rem.", + "namespace": "Nemo ut iusto ut fugit." }' `, os.Args[0]) } diff --git a/gen/http/openapi.json b/gen/http/openapi.json index ec41590df013ad6657bfafa0b7da4e8787f33eda..963549c67175e9a38a93e0e31ae6b5f1a6208095 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.","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":"Facere quos corporis."}}}},"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":"Aut et aut adipisci voluptatem consectetur quidem."}}}},"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/sign":{"post":{"tags":["signer"],"summary":"Sign signer","description":"Sign creates digital signature on base64 encoded binary data.","operationId":"signer#Sign","parameters":[{"name":"SignRequestBody","in":"body","required":true,"schema":{"$ref":"#/definitions/SignerSignRequestBody","required":["namespace","key","data"]}}],"responses":{"200":{"description":"OK response.","schema":{"$ref":"#/definitions/SignerSignOKResponseBody","required":["signature"]}},"404":{"description":"Not Found response.","schema":{"$ref":"#/definitions/SignerSignNotFoundResponseBody","required":["signature"]}},"500":{"description":"Internal Server Error response.","schema":{"$ref":"#/definitions/SignerSignInternalServerErrorResponseBody","required":["signature"]}}},"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":"Molestias eaque eos rerum dolores ipsa dolores.","format":"binary"},"type":{"type":"string","description":"Type of verification method key.","example":"JsonWebKey2020"}},"example":{"controller":"did:web:example.com","id":"key1","publicKeyJwk":"Nesciunt eaque.","type":"JsonWebKey2020"},"required":["id","type","controller","publicKeyJwk"]},"HealthLivenessResponseBody":{"title":"HealthLivenessResponseBody","type":"object","properties":{"service":{"type":"string","description":"Service name.","example":"Velit sit exercitationem et eligendi incidunt."},"status":{"type":"string","description":"Status message.","example":"Molestiae eveniet vero est aliquam."},"version":{"type":"string","description":"Service runtime version.","example":"Totam quam."}},"example":{"service":"Voluptates consectetur et repellat.","status":"Repudiandae aut dolorum hic aut voluptatem soluta.","version":"Earum debitis."},"required":["service","status","version"]},"HealthReadinessResponseBody":{"title":"HealthReadinessResponseBody","type":"object","properties":{"service":{"type":"string","description":"Service name.","example":"Rerum veritatis delectus quis recusandae."},"status":{"type":"string","description":"Status message.","example":"Est quos possimus sed sit voluptates nihil."},"version":{"type":"string","description":"Service runtime version.","example":"Ducimus eum facere enim accusantium."}},"example":{"service":"Sint laudantium rerum neque.","status":"Suscipit expedita quos eligendi.","version":"Qui rerum."},"required":["service","status","version"]},"SignerCreateCredentialRequestBody":{"title":"SignerCreateCredentialRequestBody","type":"object","properties":{"context":{"type":"array","items":{"type":"string","example":"Dolores velit."},"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":"Ut dolor numquam et dolores."},"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":"Tempore suscipit ut occaecati.","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":"Qui et."},"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":"Omnis architecto nobis vel id.","format":"binary"}},"example":{"issuer":"Nam ea ducimus.","key":"key1","namespace":"transit","presentation":"Ea quas praesentium voluptas occaecati est facere."},"required":["issuer","namespace","key","presentation"]},"SignerSignInternalServerErrorResponseBody":{"title":"SignerSignInternalServerErrorResponseBody","type":"object","properties":{"signature":{"type":"string","description":"Signature encoded as base64 string.","example":"Vel porro qui quidem unde."}},"example":{"signature":"Quis voluptas."},"required":["signature"]},"SignerSignNotFoundResponseBody":{"title":"SignerSignNotFoundResponseBody","type":"object","properties":{"signature":{"type":"string","description":"Signature encoded as base64 string.","example":"Corporis itaque eos dolorem doloremque quibusdam."}},"example":{"signature":"Molestiae id vitae vel."},"required":["signature"]},"SignerSignOKResponseBody":{"title":"SignerSignOKResponseBody","type":"object","properties":{"signature":{"type":"string","description":"Signature encoded as base64 string.","example":"Consequuntur est sit explicabo possimus."}},"example":{"signature":"Accusantium voluptas ut."},"required":["signature"]},"SignerSignRequestBody":{"title":"SignerSignRequestBody","type":"object","properties":{"data":{"type":"string","description":"Data that must be signed, encoded as base64 string.","example":"Accusamus ex nihil inventore ea qui."},"key":{"type":"string","description":"Key to be used for signing.","example":"Est occaecati nam."},"namespace":{"type":"string","description":"Key namespace to be used for signing.","example":"Qui consequatur eum nulla eaque."}},"example":{"data":"Dolores quis fugiat qui quia.","key":"Sunt incidunt et repellat cum sit quibusdam.","namespace":"Sapiente error nostrum."},"required":["namespace","key","data"]},"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":"Hic doloribus.","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":"Soluta repudiandae quam reprehenderit.","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 +{"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/jwk/{namespace}/{key}":{"get":{"tags":["signer"],"summary":"JwkPublicKey signer","description":"JwkPublicKey returns public key by name and namespace.","operationId":"signer#JwkPublicKey","parameters":[{"name":"namespace","in":"path","description":"Key namespace.","required":true,"type":"string"},{"name":"key","in":"path","description":"Key name.","required":true,"type":"string"}],"responses":{"200":{"description":"OK response.","schema":{"type":"string","format":"binary"}},"404":{"description":"Not Found response.","schema":{"type":"string","format":"binary"}},"500":{"description":"Internal Server Error response.","schema":{"type":"string","format":"binary"}}},"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":"Qui et."}}}},"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":"Omnis architecto nobis vel id."}}}},"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/sign":{"post":{"tags":["signer"],"summary":"Sign signer","description":"Sign creates digital signature on base64 encoded binary data.","operationId":"signer#Sign","parameters":[{"name":"SignRequestBody","in":"body","required":true,"schema":{"$ref":"#/definitions/SignerSignRequestBody","required":["namespace","key","data"]}}],"responses":{"200":{"description":"OK response.","schema":{"$ref":"#/definitions/SignerSignOKResponseBody","required":["signature"]}},"404":{"description":"Not Found response.","schema":{"$ref":"#/definitions/SignerSignNotFoundResponseBody","required":["signature"]}},"500":{"description":"Internal Server Error response.","schema":{"$ref":"#/definitions/SignerSignInternalServerErrorResponseBody","required":["signature"]}}},"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":"Dolores velit.","format":"binary"},"type":{"type":"string","description":"Type of verification method key.","example":"JsonWebKey2020"}},"example":{"controller":"did:web:example.com","id":"key1","publicKeyJwk":"Tempore suscipit ut occaecati.","type":"JsonWebKey2020"},"required":["id","type","controller","publicKeyJwk"]},"HealthLivenessResponseBody":{"title":"HealthLivenessResponseBody","type":"object","properties":{"service":{"type":"string","description":"Service name.","example":"Est quos possimus sed sit voluptates nihil."},"status":{"type":"string","description":"Status message.","example":"Ducimus eum facere enim accusantium."},"version":{"type":"string","description":"Service runtime version.","example":"Sint laudantium rerum neque."}},"example":{"service":"Suscipit expedita quos eligendi.","status":"Qui rerum.","version":"Ut error perspiciatis velit repudiandae voluptatem."},"required":["service","status","version"]},"HealthReadinessResponseBody":{"title":"HealthReadinessResponseBody","type":"object","properties":{"service":{"type":"string","description":"Service name.","example":"Rerum ratione voluptatibus 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"]},"SignerCreateCredentialRequestBody":{"title":"SignerCreateCredentialRequestBody","type":"object","properties":{"context":{"type":"array","items":{"type":"string","example":"Corporis itaque eos dolorem doloremque quibusdam."},"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":"Vel porro qui quidem unde."},"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":"Molestiae id vitae vel.","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":"Ut dolor numquam et dolores."},"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":"Neque blanditiis nostrum nihil consequuntur est.","format":"binary"}},"example":{"issuer":"Explicabo possimus ea.","key":"key1","namespace":"transit","presentation":"Voluptas ut."},"required":["issuer","namespace","key","presentation"]},"SignerSignInternalServerErrorResponseBody":{"title":"SignerSignInternalServerErrorResponseBody","type":"object","properties":{"signature":{"type":"string","description":"Signature encoded as base64 string.","example":"Dolores quis fugiat qui quia."}},"example":{"signature":"Velit sit exercitationem et eligendi incidunt."},"required":["signature"]},"SignerSignNotFoundResponseBody":{"title":"SignerSignNotFoundResponseBody","type":"object","properties":{"signature":{"type":"string","description":"Signature encoded as base64 string.","example":"Ea qui mollitia sapiente error nostrum quae."}},"example":{"signature":"Incidunt et repellat cum sit quibusdam."},"required":["signature"]},"SignerSignOKResponseBody":{"title":"SignerSignOKResponseBody","type":"object","properties":{"signature":{"type":"string","description":"Signature encoded as base64 string.","example":"Consequatur eum nulla eaque rerum est."}},"example":{"signature":"Nam temporibus accusamus ex nihil."},"required":["signature"]},"SignerSignRequestBody":{"title":"SignerSignRequestBody","type":"object","properties":{"data":{"type":"string","description":"Data that must be signed, encoded as base64 string.","example":"Voluptates consectetur et repellat."},"key":{"type":"string","description":"Key to be used for signing.","example":"Totam quam."},"namespace":{"type":"string","description":"Key namespace to be used for signing.","example":"Molestiae eveniet vero est aliquam."}},"example":{"data":"Rerum veritatis delectus quis recusandae.","key":"Earum debitis.","namespace":"Repudiandae aut dolorum hic aut voluptatem soluta."},"required":["namespace","key","data"]},"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":"Nam ea ducimus.","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":"Ea quas praesentium voluptas occaecati est facere.","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":true}},"example":{"valid":false},"required":["valid"]},"SignerVerifyPresentationResponseBody":{"title":"SignerVerifyPresentationResponseBody","type":"object","properties":{"valid":{"type":"boolean","description":"Valid specifies if the proof is successfully verified.","example":false}},"example":{"valid":true},"required":["valid"]}}} \ No newline at end of file diff --git a/gen/http/openapi.yaml b/gen/http/openapi.yaml index 7a1baf62a8fda4c908a40484e853f5d8370d9c99..7cb41e2f553584dc684c767e449ee279c0d17177 100644 --- a/gen/http/openapi.yaml +++ b/gen/http/openapi.yaml @@ -122,6 +122,42 @@ paths: - valid schemes: - http + /v1/jwk/{namespace}/{key}: + get: + tags: + - signer + summary: JwkPublicKey signer + description: JwkPublicKey returns public key by name and namespace. + operationId: signer#JwkPublicKey + parameters: + - name: namespace + in: path + description: Key namespace. + required: true + type: string + - name: key + in: path + description: Key name. + required: true + type: string + responses: + "200": + description: OK response. + schema: + type: string + format: binary + "404": + description: Not Found response. + schema: + type: string + format: binary + "500": + description: Internal Server Error response. + schema: + type: string + format: binary + schemes: + - http /v1/namespaces: get: tags: @@ -136,7 +172,7 @@ paths: type: array items: type: string - example: Facere quos corporis. + example: Qui et. schemes: - http /v1/namespaces/{namespace}/keys: @@ -159,7 +195,7 @@ paths: type: array items: type: string - example: Aut et aut adipisci voluptatem consectetur quidem. + example: Omnis architecto nobis vel id. schemes: - http /v1/presentation: @@ -354,7 +390,7 @@ definitions: publicKeyJwk: type: string description: Public Key encoded in JWK format. - example: Molestias eaque eos rerum dolores ipsa dolores. + example: Dolores velit. format: binary type: type: string @@ -363,7 +399,7 @@ definitions: example: controller: did:web:example.com id: key1 - publicKeyJwk: Nesciunt eaque. + publicKeyJwk: Tempore suscipit ut occaecati. type: JsonWebKey2020 required: - id @@ -377,19 +413,19 @@ definitions: service: type: string description: Service name. - example: Velit sit exercitationem et eligendi incidunt. + example: Est quos possimus sed sit voluptates nihil. status: type: string description: Status message. - example: Molestiae eveniet vero est aliquam. + example: Ducimus eum facere enim accusantium. version: type: string description: Service runtime version. - example: Totam quam. + example: Sint laudantium rerum neque. example: - service: Voluptates consectetur et repellat. - status: Repudiandae aut dolorum hic aut voluptatem soluta. - version: Earum debitis. + service: Suscipit expedita quos eligendi. + status: Qui rerum. + version: Ut error perspiciatis velit repudiandae voluptatem. required: - service - status @@ -401,19 +437,19 @@ definitions: service: type: string description: Service name. - example: Rerum veritatis delectus quis recusandae. + example: Rerum ratione voluptatibus asperiores rem tempora. status: type: string description: Status message. - example: Est quos possimus sed sit voluptates nihil. + example: Non aut inventore necessitatibus unde. version: type: string description: Service runtime version. - example: Ducimus eum facere enim accusantium. + example: Ut similique molestias aperiam quia et. example: - service: Sint laudantium rerum neque. - status: Suscipit expedita quos eligendi. - version: Qui rerum. + service: Est asperiores velit eum perferendis. + status: Rerum quaerat sit. + version: Omnis est aspernatur voluptas in. required: - service - status @@ -426,7 +462,7 @@ definitions: type: array items: type: string - example: Dolores velit. + example: Corporis itaque eos dolorem doloremque quibusdam. description: Additional JSONLD contexts to be specified in the VC. example: - https://w3id.org/security/suites/jws-2020/v1 @@ -471,7 +507,7 @@ definitions: type: array items: type: string - example: Ut dolor numquam et dolores. + example: Vel porro qui quidem unde. description: Additional JSONLD contexts to be specified in the VP. example: - https://w3id.org/security/suites/jws-2020/v1 @@ -480,7 +516,7 @@ definitions: type: array items: type: string - example: Tempore suscipit ut occaecati. + example: Molestiae id vitae vel. format: binary description: Raw JSON to be included inside the VP as Verifiable Credential. example: @@ -565,7 +601,7 @@ definitions: issuer: type: string description: Issuer DID used to specify proof verification info. - example: Qui et. + example: Ut dolor numquam et dolores. key: type: string description: Key to use for the proof signature. @@ -577,13 +613,13 @@ definitions: presentation: type: string description: Verifiable Presentation in JSON format. - example: Omnis architecto nobis vel id. + example: Neque blanditiis nostrum nihil consequuntur est. format: binary example: - issuer: Nam ea ducimus. + issuer: Explicabo possimus ea. key: key1 namespace: transit - presentation: Ea quas praesentium voluptas occaecati est facere. + presentation: Voluptas ut. required: - issuer - namespace @@ -596,9 +632,9 @@ definitions: signature: type: string description: Signature encoded as base64 string. - example: Vel porro qui quidem unde. + example: Dolores quis fugiat qui quia. example: - signature: Quis voluptas. + signature: Velit sit exercitationem et eligendi incidunt. required: - signature SignerSignNotFoundResponseBody: @@ -608,9 +644,9 @@ definitions: signature: type: string description: Signature encoded as base64 string. - example: Corporis itaque eos dolorem doloremque quibusdam. + example: Ea qui mollitia sapiente error nostrum quae. example: - signature: Molestiae id vitae vel. + signature: Incidunt et repellat cum sit quibusdam. required: - signature SignerSignOKResponseBody: @@ -620,9 +656,9 @@ definitions: signature: type: string description: Signature encoded as base64 string. - example: Consequuntur est sit explicabo possimus. + example: Consequatur eum nulla eaque rerum est. example: - signature: Accusantium voluptas ut. + signature: Nam temporibus accusamus ex nihil. required: - signature SignerSignRequestBody: @@ -632,19 +668,19 @@ definitions: data: type: string description: Data that must be signed, encoded as base64 string. - example: Accusamus ex nihil inventore ea qui. + example: Voluptates consectetur et repellat. key: type: string description: Key to be used for signing. - example: Est occaecati nam. + example: Totam quam. namespace: type: string description: Key namespace to be used for signing. - example: Qui consequatur eum nulla eaque. + example: Molestiae eveniet vero est aliquam. example: - data: Dolores quis fugiat qui quia. - key: Sunt incidunt et repellat cum sit quibusdam. - namespace: Sapiente error nostrum. + data: Rerum veritatis delectus quis recusandae. + key: Earum debitis. + namespace: Repudiandae aut dolorum hic aut voluptatem soluta. required: - namespace - key @@ -664,7 +700,7 @@ definitions: publicKeyJwk: type: string description: Public Key encoded in JWK format. - example: Hic doloribus. + example: Nam ea ducimus. format: binary type: type: string @@ -674,7 +710,7 @@ definitions: example: controller: did:web:example.com id: key1 - publicKeyJwk: Soluta repudiandae quam reprehenderit. + publicKeyJwk: Ea quas praesentium voluptas occaecati est facere. type: JsonWebKey2020 required: - id @@ -688,7 +724,7 @@ definitions: valid: type: boolean description: Valid specifies if the proof is successfully verified. - example: false + example: true example: valid: false required: @@ -700,7 +736,7 @@ definitions: valid: type: boolean description: Valid specifies if the proof is successfully verified. - example: true + example: false example: valid: true required: diff --git a/gen/http/openapi3.json b/gen/http/openapi3.json index e0815d76cb6133c1af24af7bccb3bff25ec1aa06..1ccf870851302352b522c0163cee870d56aefb10 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.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HealthResponse"},"example":{"service":"Quibusdam nemo ut iusto ut fugit.","status":"Asperiores vitae rem.","version":"Quaerat odit optio."}}}}}}},"/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":"Mollitia architecto rem beatae mollitia.","status":"Id tempora aut.","version":"Sed aut."}}}}}}},"/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":"Ab adipisci odio.","format":"binary"},"example":"Temporibus maxime ipsum laudantium voluptatibus ipsam."}}}}}},"/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":"Aut nobis qui debitis enim.","format":"binary"},"example":"Recusandae unde consequatur odit ut at iste."}}}}}},"/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":"T2NjYWVjYXRpIGRvbG9yZW1xdWUgYW5pbWkgcXVpYSBkZXNlcnVudCBxdWlkZW0gZXQu","format":"binary"},"example":"VmVybyBxdWkgdXQgZHVjaW11cy4="}}},"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 error perspiciatis velit repudiandae voluptatem."},"description":"List of available keys namespaces.","example":["Ratione voluptatibus asperiores.","Tempora et non aut inventore."]},"example":["Qui consequatur et.","Pariatur numquam porro facilis et.","Ut ea reiciendis vel nihil.","Doloremque ea saepe quidem dolores fugiat aliquam."]}}}}}},"/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":"Unde facilis ut similique molestias aperiam quia."},"description":"Array of key names in a given namespace.","example":["Est asperiores velit eum perferendis.","Rerum quaerat sit.","Omnis est aspernatur voluptas in."]},"example":["Maxime dolor et sed fugit quo.","Aut quisquam unde."]}}}}}},"/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":"Tenetur ut consequuntur.","format":"binary"},"example":"Eligendi nostrum eveniet et autem voluptas eos."}}}}}},"/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":"Neque impedit.","key":"key1","namespace":"transit","presentation":"Sunt vitae."}}}},"responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"type":"string","example":"Magnam unde provident explicabo numquam culpa eum.","format":"binary"},"example":"Numquam quaerat."}}}}}},"/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":"Vm9sdXB0YXRpYnVzIGNvcnJ1cHRpIGlwc2FtIG1haW9yZXMgb2ZmaWNpaXMgbWFnbmkgY3VtLg==","format":"binary"},"example":"Tm9uIGF1dCBxdWlzcXVhbSBzdW50IGhpYy4="}}},"responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/VerifyResult"},"example":{"valid":false}}}}}}},"/v1/sign":{"post":{"tags":["signer"],"summary":"Sign signer","description":"Sign creates digital signature on base64 encoded binary data.","operationId":"signer#Sign","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SignRequestBody"},"example":{"data":"Sapiente dolorem qui possimus qui labore veritatis.","key":"Nihil iste debitis.","namespace":"Occaecati repellat est non amet."}}}},"responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SignResult"},"example":{"signature":"Fuga officia excepturi velit aut."}}}},"404":{"description":"Not Found response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SignResult"},"example":{"signature":"Natus quos ut corrupti."}}}},"500":{"description":"Internal Server Error response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SignResult"},"example":{"signature":"Et nulla illo totam optio quia ab."}}}}}}},"/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":"Iure ex consequatur facilis.","type":"JsonWebKey2020"},{"controller":"did:web:example.com","id":"key1","publicKeyJwk":"Iure ex consequatur facilis.","type":"JsonWebKey2020"},{"controller":"did:web:example.com","id":"key1","publicKeyJwk":"Iure ex consequatur facilis.","type":"JsonWebKey2020"},{"controller":"did:web:example.com","id":"key1","publicKeyJwk":"Iure ex consequatur facilis.","type":"JsonWebKey2020"}]},"example":[{"controller":"did:web:example.com","id":"key1","publicKeyJwk":"Iure ex consequatur facilis.","type":"JsonWebKey2020"},{"controller":"did:web:example.com","id":"key1","publicKeyJwk":"Iure ex consequatur facilis.","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":"Qui ipsa aut non fuga iste.","type":"JsonWebKey2020"}}}}}}}},"components":{"schemas":{"CreateCredentialRequestBody":{"type":"object","properties":{"context":{"type":"array","items":{"type":"string","example":"Sunt laudantium nulla."},"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":"Aperiam odit illo natus."},"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":"Nam accusamus ea dolorem tenetur.","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":"Unde quae accusantium similique beatae nihil molestias.","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":"Neque voluptates dolores.","type":"JsonWebKey2020"},"required":["id","type","controller","publicKeyJwk"]},"HealthResponse":{"type":"object","properties":{"service":{"type":"string","description":"Service name.","example":"Voluptatibus aperiam eius velit."},"status":{"type":"string","description":"Status message.","example":"Dolores libero."},"version":{"type":"string","description":"Service runtime version.","example":"Tempora voluptatem error molestiae."}},"example":{"service":"Deleniti laudantium exercitationem tenetur iusto eos quidem.","status":"Dolorum et consequatur sed in vero qui.","version":"Ut et quasi eius error minima eaque."},"required":["service","status","version"]},"PresentationProofRequestBody":{"type":"object","properties":{"issuer":{"type":"string","description":"Issuer DID used to specify proof verification info.","example":"Consectetur aut illum."},"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":"Quasi sequi molestiae assumenda ducimus occaecati reprehenderit.","format":"binary"}},"example":{"issuer":"Labore quia rem.","key":"key1","namespace":"transit","presentation":"Eum hic autem in."},"required":["issuer","namespace","key","presentation"]},"SignRequestBody":{"type":"object","properties":{"data":{"type":"string","description":"Data that must be signed, encoded as base64 string.","example":"Sit ut non est fugiat et repellat."},"key":{"type":"string","description":"Key to be used for signing.","example":"Porro iste."},"namespace":{"type":"string","description":"Key namespace to be used for signing.","example":"Culpa quibusdam sunt nemo tempora dolores."}},"example":{"data":"Et voluptatem.","key":"Minus et ut ullam quidem vitae qui.","namespace":"Consequatur veritatis ab."},"required":["namespace","key","data"]},"SignResult":{"type":"object","properties":{"signature":{"type":"string","description":"Signature encoded as base64 string.","example":"Saepe itaque ratione."}},"example":{"signature":"Laborum delectus."},"required":["signature"]},"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":"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 +{"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":"Facere quos corporis.","status":"Aut et aut adipisci voluptatem consectetur quidem.","version":"Hic doloribus."}}}}}}},"/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":"Soluta repudiandae quam reprehenderit.","status":"Molestias eaque eos rerum dolores ipsa dolores.","version":"Nesciunt eaque."}}}}}}},"/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":"Itaque ratione.","format":"binary"},"example":"Voluptatem et quo vel eaque molestiae."}}}}}},"/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":"Officiis magni cum sunt.","format":"binary"},"example":"Quis consectetur."}}}}}},"/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":"VGVtcG9yYSB2b2x1cHRhdGVtIGVycm9yIG1vbGVzdGlhZS4=","format":"binary"},"example":"U2ltaWxpcXVlIGZ1Z2EgaXN0ZSBhbGlxdWlkIHF1YW0u"}}},"responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/VerifyResult"},"example":{"valid":true}}}}}}},"/v1/jwk/{namespace}/{key}":{"get":{"tags":["signer"],"summary":"JwkPublicKey signer","description":"JwkPublicKey returns public key by name and namespace.","operationId":"signer#JwkPublicKey","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":"Key name.","required":true,"schema":{"type":"string","description":"Key name.","example":"my-ecdsa-key1"},"example":"my-ecdsa-key1"}],"responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"type":"string","description":"Public key encoded as JSON Web Key.","example":"Ut consequuntur.","format":"binary"},"example":"Ut et pariatur omnis est."}}},"404":{"description":"Not Found response.","content":{"application/json":{"schema":{"type":"string","description":"Public key encoded as JSON Web Key.","example":"Occaecati doloremque animi quia deserunt quidem et.","format":"binary"},"example":"Sit delectus."}}},"500":{"description":"Internal Server Error response.","content":{"application/json":{"schema":{"type":"string","description":"Public key encoded as JSON Web Key.","example":"Maxime totam voluptatibus corrupti ipsam.","format":"binary"},"example":"Fugiat sapiente provident."}}}}}},"/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":"Unde quae accusantium similique beatae nihil molestias."},"description":"List of available keys namespaces.","example":["Voluptates dolores aut reiciendis aut nobis.","Debitis enim quaerat consectetur aut.","Minus quasi sequi molestiae.","Ducimus occaecati reprehenderit neque labore quia rem."]},"example":["Ducimus autem non aut quisquam sunt.","Porro consequatur voluptatibus dignissimos.","Rerum tempora ut veniam voluptatem."]}}}}}},"/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":"Eum hic autem in."},"description":"Array of key names in a given namespace.","example":["Unde provident explicabo numquam culpa eum porro.","Laudantium nulla quod ab adipisci odio."]},"example":["Cumque ab doloremque voluptatibus autem cumque.","Quis dolor expedita.","Molestias dicta in dignissimos."]}}}}}},"/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":"Dolores libero.","format":"binary"},"example":"Sed quia aspernatur consequuntur ducimus eos 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":"Adipisci perferendis.","key":"key1","namespace":"transit","presentation":"Est et autem."}}}},"responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"type":"string","example":"Ab molestiae minus et ut.","format":"binary"},"example":"Ratione eum."}}}}}},"/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":"RXhlcmNpdGF0aW9uZW0gdGVuZXR1ciBpdXN0by4=","format":"binary"},"example":"T21uaXMgcXVhcyBwZXJmZXJlbmRpcyBpZCBpcHN1bSBxdWlzIHJlY3VzYW5kYWUu"}}},"responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/VerifyResult"},"example":{"valid":false}}}}}}},"/v1/sign":{"post":{"tags":["signer"],"summary":"Sign signer","description":"Sign creates digital signature on base64 encoded binary data.","operationId":"signer#Sign","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SignRequestBody"},"example":{"data":"Quaerat odit optio.","key":"Asperiores vitae rem.","namespace":"Nemo ut iusto ut fugit."}}}},"responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SignResult"},"example":{"signature":"Mollitia architecto rem beatae mollitia."}}}},"404":{"description":"Not Found response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SignResult"},"example":{"signature":"Id tempora aut."}}}},"500":{"description":"Internal Server Error response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SignResult"},"example":{"signature":"Sed aut."}}}}}}},"/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":"Molestias sunt vitae mollitia et repellat laboriosam.","type":"JsonWebKey2020"},{"controller":"did:web:example.com","id":"key1","publicKeyJwk":"Molestias sunt vitae mollitia et repellat laboriosam.","type":"JsonWebKey2020"}]},"example":[{"controller":"did:web:example.com","id":"key1","publicKeyJwk":"Molestias sunt vitae mollitia et repellat laboriosam.","type":"JsonWebKey2020"},{"controller":"did:web:example.com","id":"key1","publicKeyJwk":"Molestias sunt vitae mollitia et repellat laboriosam.","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":"Et odio facere praesentium neque.","type":"JsonWebKey2020"}}}}}}}},"components":{"schemas":{"CreateCredentialRequestBody":{"type":"object","properties":{"context":{"type":"array","items":{"type":"string","example":"Quidem vitae qui est et voluptatem voluptatum."},"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":"Voluptatibus aperiam eius velit."},"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":"Laborum delectus.","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":"Nam accusamus ea dolorem tenetur.","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":"Aperiam odit illo natus.","type":"JsonWebKey2020"},"required":["id","type","controller","publicKeyJwk"]},"HealthResponse":{"type":"object","properties":{"service":{"type":"string","description":"Service name.","example":"Voluptatem maxime dolor et sed fugit."},"status":{"type":"string","description":"Status message.","example":"Voluptatem aut quisquam."},"version":{"type":"string","description":"Service runtime version.","example":"Blanditiis ea recusandae unde consequatur odit."}},"example":{"service":"At iste nostrum numquam quaerat natus temporibus.","status":"Ipsum laudantium voluptatibus ipsam autem eligendi nostrum.","version":"Et autem voluptas eos sed vero."},"required":["service","status","version"]},"PresentationProofRequestBody":{"type":"object","properties":{"issuer":{"type":"string","description":"Issuer DID used to specify proof verification info.","example":"Quibusdam sunt."},"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":"Tempora dolores aliquid porro iste totam.","format":"binary"}},"example":{"issuer":"Ut non.","key":"key1","namespace":"transit","presentation":"Fugiat et repellat vel consequatur."},"required":["issuer","namespace","key","presentation"]},"SignRequestBody":{"type":"object","properties":{"data":{"type":"string","description":"Data that must be signed, encoded as base64 string.","example":"Qui odit."},"key":{"type":"string","description":"Key to be used for signing.","example":"Consequatur sed in."},"namespace":{"type":"string","description":"Key namespace to be used for signing.","example":"Quidem magnam dolorum."}},"example":{"data":"Pariatur numquam porro facilis et.","key":"Qui consequatur et.","namespace":"Et quasi eius error minima eaque dolorum."},"required":["namespace","key","data"]},"SignResult":{"type":"object","properties":{"signature":{"type":"string","description":"Signature encoded as base64 string.","example":"Ut ea reiciendis vel nihil."}},"example":{"signature":"Doloremque ea saepe quidem dolores fugiat aliquam."},"required":["signature"]},"VerifyResult":{"type":"object","properties":{"valid":{"type":"boolean","description":"Valid specifies if the proof is successfully verified.","example":false}},"example":{"valid":true},"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 e1f1994cb89c036971e191dc0c4f5356ea193cd5..c649f0c2c8a1a1f28718d0f120c3bbc7f45fbd06 100644 --- a/gen/http/openapi3.yaml +++ b/gen/http/openapi3.yaml @@ -21,9 +21,9 @@ paths: schema: $ref: '#/components/schemas/HealthResponse' example: - service: Quibusdam nemo ut iusto ut fugit. - status: Asperiores vitae rem. - version: Quaerat odit optio. + service: Facere quos corporis. + status: Aut et aut adipisci voluptatem consectetur quidem. + version: Hic doloribus. /readiness: get: tags: @@ -38,9 +38,9 @@ paths: schema: $ref: '#/components/schemas/HealthResponse' example: - service: Mollitia architecto rem beatae mollitia. - status: Id tempora aut. - version: Sed aut. + service: Soluta repudiandae quam reprehenderit. + status: Molestias eaque eos rerum dolores ipsa dolores. + version: Nesciunt eaque. /v1/credential: post: tags: @@ -70,9 +70,9 @@ paths: application/json: schema: type: string - example: Ab adipisci odio. + example: Itaque ratione. format: binary - example: Temporibus maxime ipsum laudantium voluptatibus ipsam. + example: Voluptatem et quo vel eaque molestiae. /v1/credential/proof: post: tags: @@ -107,9 +107,9 @@ paths: application/json: schema: type: string - example: Aut nobis qui debitis enim. + example: Officiis magni cum sunt. format: binary - example: Recusandae unde consequatur odit ut at iste. + example: Quis consectetur. /v1/credential/verify: post: tags: @@ -126,78 +126,75 @@ paths: type: string description: Verifiable Credential in JSON format. example: - - 79 - - 99 - - 99 - - 97 + - 84 - 101 - - 99 + - 109 + - 112 + - 111 + - 114 - 97 - - 116 - - 105 - 32 - - 100 + - 118 - 111 - 108 - - 111 - - 114 - - 101 - - 109 - - 113 - 117 - - 101 - - 32 + - 112 + - 116 - 97 - - 110 - - 105 + - 116 + - 101 - 109 - - 105 - - 32 - - 113 - - 117 - - 105 - - 97 - 32 - - 100 - - 101 - - 115 - 101 - 114 - - 117 - - 110 - - 116 + - 114 + - 111 + - 114 - 32 - - 113 - - 117 - - 105 - - 100 - - 101 - 109 - - 32 + - 111 + - 108 - 101 + - 115 - 116 + - 105 + - 97 + - 101 - 46 format: binary example: - - 86 - - 101 - - 114 - - 111 - - 32 + - 83 + - 105 + - 109 + - 105 + - 108 + - 105 - 113 - 117 - - 105 + - 101 - 32 + - 102 - 117 + - 103 + - 97 + - 32 + - 105 + - 115 - 116 + - 101 - 32 - - 100 + - 97 + - 108 + - 105 + - 113 - 117 - - 99 - 105 - - 109 + - 100 + - 32 + - 113 - 117 - - 115 + - 97 + - 109 - 46 responses: "200": @@ -208,6 +205,63 @@ paths: $ref: '#/components/schemas/VerifyResult' example: valid: true + /v1/jwk/{namespace}/{key}: + get: + tags: + - signer + summary: JwkPublicKey signer + description: JwkPublicKey returns public key by name and namespace. + operationId: signer#JwkPublicKey + 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: Key name. + required: true + schema: + type: string + description: Key name. + example: my-ecdsa-key1 + example: my-ecdsa-key1 + responses: + "200": + description: OK response. + content: + application/json: + schema: + type: string + description: Public key encoded as JSON Web Key. + example: Ut consequuntur. + format: binary + example: Ut et pariatur omnis est. + "404": + description: Not Found response. + content: + application/json: + schema: + type: string + description: Public key encoded as JSON Web Key. + example: Occaecati doloremque animi quia deserunt quidem et. + format: binary + example: Sit delectus. + "500": + description: Internal Server Error response. + content: + application/json: + schema: + type: string + description: Public key encoded as JSON Web Key. + example: Maxime totam voluptatibus corrupti ipsam. + format: binary + example: Fugiat sapiente provident. /v1/namespaces: get: tags: @@ -224,16 +278,17 @@ paths: type: array items: type: string - example: Ut error perspiciatis velit repudiandae voluptatem. + example: Unde quae accusantium similique beatae nihil molestias. description: List of available keys namespaces. example: - - Ratione voluptatibus asperiores. - - Tempora et non aut inventore. + - Voluptates dolores aut reiciendis aut nobis. + - Debitis enim quaerat consectetur aut. + - Minus quasi sequi molestiae. + - Ducimus occaecati reprehenderit neque labore quia rem. example: - - Qui consequatur et. - - Pariatur numquam porro facilis et. - - Ut ea reiciendis vel nihil. - - Doloremque ea saepe quidem dolores fugiat aliquam. + - Ducimus autem non aut quisquam sunt. + - Porro consequatur voluptatibus dignissimos. + - Rerum tempora ut veniam voluptatem. /v1/namespaces/{namespace}/keys: get: tags: @@ -260,15 +315,15 @@ paths: type: array items: type: string - example: Unde facilis ut similique molestias aperiam quia. + example: Eum hic autem in. description: Array of key names in a given namespace. example: - - Est asperiores velit eum perferendis. - - Rerum quaerat sit. - - Omnis est aspernatur voluptas in. + - Unde provident explicabo numquam culpa eum porro. + - Laudantium nulla quod ab adipisci odio. example: - - Maxime dolor et sed fugit quo. - - Aut quisquam unde. + - Cumque ab doloremque voluptatibus autem cumque. + - Quis dolor expedita. + - Molestias dicta in dignissimos. /v1/presentation: post: tags: @@ -299,9 +354,9 @@ paths: application/json: schema: type: string - example: Tenetur ut consequuntur. + example: Dolores libero. format: binary - example: Eligendi nostrum eveniet et autem voluptas eos. + example: Sed quia aspernatur consequuntur ducimus eos consequuntur. /v1/presentation/proof: post: tags: @@ -316,10 +371,10 @@ paths: schema: $ref: '#/components/schemas/PresentationProofRequestBody' example: - issuer: Neque impedit. + issuer: Adipisci perferendis. key: key1 namespace: transit - presentation: Sunt vitae. + presentation: Est et autem. responses: "200": description: OK response. @@ -327,9 +382,9 @@ paths: application/json: schema: type: string - example: Magnam unde provident explicabo numquam culpa eum. + example: Ab molestiae minus et ut. format: binary - example: Numquam quaerat. + example: Ratione eum. /v1/presentation/verify: post: tags: @@ -346,88 +401,84 @@ paths: type: string description: Verifiable Presentation in JSON format. example: - - 86 - - 111 - - 108 - - 117 - - 112 + - 69 + - 120 + - 101 + - 114 + - 99 + - 105 - 116 - 97 - 116 - 105 - - 98 - - 117 - - 115 - - 32 - - 99 - 111 - - 114 - - 114 - - 117 - - 112 - - 116 - - 105 - - 32 - - 105 - - 112 - - 115 - - 97 + - 110 + - 101 - 109 - 32 - - 109 - - 97 - - 105 - - 111 - - 114 + - 116 - 101 - - 115 - - 32 - - 111 - - 102 - - 102 - - 105 - - 99 - - 105 - - 105 - - 115 - - 32 - - 109 - - 97 - - 103 - 110 - - 105 + - 101 + - 116 + - 117 + - 114 - 32 - - 99 + - 105 - 117 - - 109 + - 115 + - 116 + - 111 - 46 format: binary example: - - 78 - - 111 + - 79 + - 109 - 110 - - 32 - - 97 - - 117 - - 116 - - 32 - - 113 - - 117 - 105 - 115 + - 32 - 113 - 117 - 97 - - 109 + - 115 + - 32 + - 112 + - 101 + - 114 + - 102 + - 101 + - 114 + - 101 + - 110 + - 100 + - 105 + - 115 - 32 + - 105 + - 100 + - 32 + - 105 + - 112 - 115 - 117 - - 110 - - 116 + - 109 - 32 - - 104 + - 113 + - 117 - 105 + - 115 + - 32 + - 114 + - 101 - 99 + - 117 + - 115 + - 97 + - 110 + - 100 + - 97 + - 101 - 46 responses: "200": @@ -452,9 +503,9 @@ paths: schema: $ref: '#/components/schemas/SignRequestBody' example: - data: Sapiente dolorem qui possimus qui labore veritatis. - key: Nihil iste debitis. - namespace: Occaecati repellat est non amet. + data: Quaerat odit optio. + key: Asperiores vitae rem. + namespace: Nemo ut iusto ut fugit. responses: "200": description: OK response. @@ -463,7 +514,7 @@ paths: schema: $ref: '#/components/schemas/SignResult' example: - signature: Fuga officia excepturi velit aut. + signature: Mollitia architecto rem beatae mollitia. "404": description: Not Found response. content: @@ -471,7 +522,7 @@ paths: schema: $ref: '#/components/schemas/SignResult' example: - signature: Natus quos ut corrupti. + signature: Id tempora aut. "500": description: Internal Server Error response. content: @@ -479,7 +530,7 @@ paths: schema: $ref: '#/components/schemas/SignResult' example: - signature: Et nulla illo totam optio quia ab. + signature: Sed aut. /v1/verification-methods/{namespace}/{did}: get: tags: @@ -519,28 +570,20 @@ paths: example: - controller: did:web:example.com id: key1 - publicKeyJwk: Iure ex consequatur facilis. - type: JsonWebKey2020 - - controller: did:web:example.com - id: key1 - publicKeyJwk: Iure ex consequatur facilis. - type: JsonWebKey2020 - - controller: did:web:example.com - id: key1 - publicKeyJwk: Iure ex consequatur facilis. + publicKeyJwk: Molestias sunt vitae mollitia et repellat laboriosam. type: JsonWebKey2020 - controller: did:web:example.com id: key1 - publicKeyJwk: Iure ex consequatur facilis. + publicKeyJwk: Molestias sunt vitae mollitia et repellat laboriosam. type: JsonWebKey2020 example: - controller: did:web:example.com id: key1 - publicKeyJwk: Iure ex consequatur facilis. + publicKeyJwk: Molestias sunt vitae mollitia et repellat laboriosam. type: JsonWebKey2020 - controller: did:web:example.com id: key1 - publicKeyJwk: Iure ex consequatur facilis. + publicKeyJwk: Molestias sunt vitae mollitia et repellat laboriosam. type: JsonWebKey2020 /v1/verification-methods/{namespace}/{key}/{did}: get: @@ -587,7 +630,7 @@ paths: example: controller: did:web:example.com id: key1 - publicKeyJwk: Qui ipsa aut non fuga iste. + publicKeyJwk: Et odio facere praesentium neque. type: JsonWebKey2020 components: schemas: @@ -598,7 +641,7 @@ components: type: array items: type: string - example: Sunt laudantium nulla. + example: Quidem vitae qui est et voluptatem voluptatum. description: Additional JSONLD contexts to be specified in the VC. example: - https://w3id.org/security/suites/jws-2020/v1 @@ -642,7 +685,7 @@ components: type: array items: type: string - example: Aperiam odit illo natus. + example: Voluptatibus aperiam eius velit. description: Additional JSONLD contexts to be specified in the VP. example: - https://w3id.org/security/suites/jws-2020/v1 @@ -651,7 +694,7 @@ components: type: array items: type: string - example: Nam accusamus ea dolorem tenetur. + example: Laborum delectus. format: binary description: Raw JSON to be included inside the VP as Verifiable Credential. example: @@ -742,7 +785,7 @@ components: publicKeyJwk: type: string description: Public Key encoded in JWK format. - example: Unde quae accusantium similique beatae nihil molestias. + example: Nam accusamus ea dolorem tenetur. format: binary type: type: string @@ -752,7 +795,7 @@ components: example: controller: did:web:example.com id: key1 - publicKeyJwk: Neque voluptates dolores. + publicKeyJwk: Aperiam odit illo natus. type: JsonWebKey2020 required: - id @@ -765,19 +808,19 @@ components: service: type: string description: Service name. - example: Voluptatibus aperiam eius velit. + example: Voluptatem maxime dolor et sed fugit. status: type: string description: Status message. - example: Dolores libero. + example: Voluptatem aut quisquam. version: type: string description: Service runtime version. - example: Tempora voluptatem error molestiae. + example: Blanditiis ea recusandae unde consequatur odit. example: - service: Deleniti laudantium exercitationem tenetur iusto eos quidem. - status: Dolorum et consequatur sed in vero qui. - version: Ut et quasi eius error minima eaque. + service: At iste nostrum numquam quaerat natus temporibus. + status: Ipsum laudantium voluptatibus ipsam autem eligendi nostrum. + version: Et autem voluptas eos sed vero. required: - service - status @@ -788,7 +831,7 @@ components: issuer: type: string description: Issuer DID used to specify proof verification info. - example: Consectetur aut illum. + example: Quibusdam sunt. key: type: string description: Key to use for the proof signature. @@ -800,13 +843,13 @@ components: presentation: type: string description: Verifiable Presentation in JSON format. - example: Quasi sequi molestiae assumenda ducimus occaecati reprehenderit. + example: Tempora dolores aliquid porro iste totam. format: binary example: - issuer: Labore quia rem. + issuer: Ut non. key: key1 namespace: transit - presentation: Eum hic autem in. + presentation: Fugiat et repellat vel consequatur. required: - issuer - namespace @@ -818,19 +861,19 @@ components: data: type: string description: Data that must be signed, encoded as base64 string. - example: Sit ut non est fugiat et repellat. + example: Qui odit. key: type: string description: Key to be used for signing. - example: Porro iste. + example: Consequatur sed in. namespace: type: string description: Key namespace to be used for signing. - example: Culpa quibusdam sunt nemo tempora dolores. + example: Quidem magnam dolorum. example: - data: Et voluptatem. - key: Minus et ut ullam quidem vitae qui. - namespace: Consequatur veritatis ab. + data: Pariatur numquam porro facilis et. + key: Qui consequatur et. + namespace: Et quasi eius error minima eaque dolorum. required: - namespace - key @@ -841,9 +884,9 @@ components: signature: type: string description: Signature encoded as base64 string. - example: Saepe itaque ratione. + example: Ut ea reiciendis vel nihil. example: - signature: Laborum delectus. + signature: Doloremque ea saepe quidem dolores fugiat aliquam. required: - signature VerifyResult: @@ -852,7 +895,7 @@ components: valid: type: boolean description: Valid specifies if the proof is successfully verified. - example: true + example: false example: valid: true required: diff --git a/gen/http/signer/client/cli.go b/gen/http/signer/client/cli.go index d1873d38f68787e81f738f8e18f1f217d99ed4a7..ea85bab16a978b73c84af1d091bcbcc346767b4c 100644 --- a/gen/http/signer/client/cli.go +++ b/gen/http/signer/client/cli.go @@ -69,6 +69,24 @@ func BuildVerificationMethodsPayload(signerVerificationMethodsNamespace string, return v, nil } +// BuildJwkPublicKeyPayload builds the payload for the signer JwkPublicKey +// endpoint from CLI flags. +func BuildJwkPublicKeyPayload(signerJwkPublicKeyNamespace string, signerJwkPublicKeyKey string) (*signer.JwkPublicKeyRequest, error) { + var namespace string + { + namespace = signerJwkPublicKeyNamespace + } + var key string + { + key = signerJwkPublicKeyKey + } + v := &signer.JwkPublicKeyRequest{} + v.Namespace = namespace + v.Key = key + + return v, nil +} + // BuildCredentialProofPayload builds the payload for the signer // CredentialProof endpoint from CLI flags. func BuildCredentialProofPayload(signerCredentialProofBody string) (*signer.CredentialProofRequest, error) { @@ -103,7 +121,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\": \"Neque impedit.\",\n \"key\": \"key1\",\n \"namespace\": \"transit\",\n \"presentation\": \"Sunt vitae.\"\n }'") + return nil, fmt.Errorf("invalid JSON for body, \nerror: %s, \nexample of valid JSON:\n%s", err, "'{\n \"issuer\": \"Adipisci perferendis.\",\n \"key\": \"key1\",\n \"namespace\": \"transit\",\n \"presentation\": \"Est et autem.\"\n }'") } if body.Presentation == nil { err = goa.MergeErrors(err, goa.MissingFieldError("presentation", "body")) @@ -233,7 +251,7 @@ func BuildSignPayload(signerSignBody string) (*signer.SignRequest, error) { { err = json.Unmarshal([]byte(signerSignBody), &body) if err != nil { - return nil, fmt.Errorf("invalid JSON for body, \nerror: %s, \nexample of valid JSON:\n%s", err, "'{\n \"data\": \"Sapiente dolorem qui possimus qui labore veritatis.\",\n \"key\": \"Nihil iste debitis.\",\n \"namespace\": \"Occaecati repellat est non amet.\"\n }'") + return nil, fmt.Errorf("invalid JSON for body, \nerror: %s, \nexample of valid JSON:\n%s", err, "'{\n \"data\": \"Quaerat odit optio.\",\n \"key\": \"Asperiores vitae rem.\",\n \"namespace\": \"Nemo ut iusto ut fugit.\"\n }'") } } v := &signer.SignRequest{ diff --git a/gen/http/signer/client/client.go b/gen/http/signer/client/client.go index a260a4f75f84dc0454e6d8a9e7b6b34ff1079536..888de2bf244669682ecb862d07707ca618e7dc5a 100644 --- a/gen/http/signer/client/client.go +++ b/gen/http/signer/client/client.go @@ -33,6 +33,10 @@ type Client struct { // VerificationMethods endpoint. VerificationMethodsDoer goahttp.Doer + // JwkPublicKey Doer is the HTTP client used to make requests to the + // JwkPublicKey endpoint. + JwkPublicKeyDoer goahttp.Doer + // CredentialProof Doer is the HTTP client used to make requests to the // CredentialProof endpoint. CredentialProofDoer goahttp.Doer @@ -84,6 +88,7 @@ func NewClient( NamespaceKeysDoer: doer, VerificationMethodDoer: doer, VerificationMethodsDoer: doer, + JwkPublicKeyDoer: doer, CredentialProofDoer: doer, PresentationProofDoer: doer, CreateCredentialDoer: doer, @@ -175,6 +180,25 @@ func (c *Client) VerificationMethods() goa.Endpoint { } } +// JwkPublicKey returns an endpoint that makes HTTP requests to the signer +// service JwkPublicKey server. +func (c *Client) JwkPublicKey() goa.Endpoint { + var ( + decodeResponse = DecodeJwkPublicKeyResponse(c.decoder, c.RestoreResponseBody) + ) + return func(ctx context.Context, v any) (any, error) { + req, err := c.BuildJwkPublicKeyRequest(ctx, v) + if err != nil { + return nil, err + } + resp, err := c.JwkPublicKeyDoer.Do(req) + if err != nil { + return nil, goahttp.ErrRequestError("signer", "JwkPublicKey", err) + } + return decodeResponse(resp) + } +} + // CredentialProof returns an endpoint that makes HTTP requests to the signer // service CredentialProof server. func (c *Client) CredentialProof() goa.Endpoint { diff --git a/gen/http/signer/client/encode_decode.go b/gen/http/signer/client/encode_decode.go index e7dd0d4d9e24fea7951872c3ff64b08a74772a70..7e935a8a0a2a6cf431af3c05542dc62187df1395 100644 --- a/gen/http/signer/client/encode_decode.go +++ b/gen/http/signer/client/encode_decode.go @@ -273,6 +273,68 @@ func DecodeVerificationMethodsResponse(decoder func(*http.Response) goahttp.Deco } } +// BuildJwkPublicKeyRequest instantiates a HTTP request object with method and +// path set to call the "signer" service "JwkPublicKey" endpoint +func (c *Client) BuildJwkPublicKeyRequest(ctx context.Context, v any) (*http.Request, error) { + var ( + namespace string + key string + ) + { + p, ok := v.(*signer.JwkPublicKeyRequest) + if !ok { + return nil, goahttp.ErrInvalidType("signer", "JwkPublicKey", "*signer.JwkPublicKeyRequest", v) + } + namespace = p.Namespace + key = p.Key + } + u := &url.URL{Scheme: c.scheme, Host: c.host, Path: JwkPublicKeySignerPath(namespace, key)} + req, err := http.NewRequest("GET", u.String(), nil) + if err != nil { + return nil, goahttp.ErrInvalidURL("signer", "JwkPublicKey", u.String(), err) + } + if ctx != nil { + req = req.WithContext(ctx) + } + + return req, nil +} + +// DecodeJwkPublicKeyResponse returns a decoder for responses returned by the +// signer JwkPublicKey endpoint. restoreBody controls whether the response body +// should be restored after having been read. +func DecodeJwkPublicKeyResponse(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", "JwkPublicKey", err) + } + return body, nil + default: + body, _ := io.ReadAll(resp.Body) + return nil, goahttp.ErrInvalidResponse("signer", "JwkPublicKey", resp.StatusCode, string(body)) + } + } +} + // BuildCredentialProofRequest instantiates a HTTP request object with method // and path set to call the "signer" service "CredentialProof" endpoint func (c *Client) BuildCredentialProofRequest(ctx context.Context, v any) (*http.Request, error) { diff --git a/gen/http/signer/client/paths.go b/gen/http/signer/client/paths.go index 7cf84029dfeacbad7a6175e67fa8891cde115f13..90e1cfd221dc2aa63869559fd2dc935b1168e109 100644 --- a/gen/http/signer/client/paths.go +++ b/gen/http/signer/client/paths.go @@ -31,6 +31,11 @@ func VerificationMethodsSignerPath(namespace string, did string) string { return fmt.Sprintf("/v1/verification-methods/%v/%v", namespace, did) } +// JwkPublicKeySignerPath returns the URL path to the signer service JwkPublicKey HTTP endpoint. +func JwkPublicKeySignerPath(namespace string, key string) string { + return fmt.Sprintf("/v1/jwk/%v/%v", namespace, key) +} + // CredentialProofSignerPath returns the URL path to the signer service CredentialProof HTTP endpoint. func CredentialProofSignerPath() string { return "/v1/credential/proof" diff --git a/gen/http/signer/server/encode_decode.go b/gen/http/signer/server/encode_decode.go index 0e88f0ec4ac0538ccf7d12ef846af7d123449658..55766db861d57fc958ce026c185183169972b87b 100644 --- a/gen/http/signer/server/encode_decode.go +++ b/gen/http/signer/server/encode_decode.go @@ -119,6 +119,36 @@ func DecodeVerificationMethodsRequest(mux goahttp.Muxer, decoder func(*http.Requ } } +// EncodeJwkPublicKeyResponse returns an encoder for responses returned by the +// signer JwkPublicKey endpoint. +func EncodeJwkPublicKeyResponse(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) + } +} + +// DecodeJwkPublicKeyRequest returns a decoder for requests sent to the signer +// JwkPublicKey endpoint. +func DecodeJwkPublicKeyRequest(mux goahttp.Muxer, decoder func(*http.Request) goahttp.Decoder) func(*http.Request) (any, error) { + return func(r *http.Request) (any, error) { + var ( + namespace string + key string + + params = mux.Vars(r) + ) + namespace = params["namespace"] + key = params["key"] + payload := NewJwkPublicKeyRequest(namespace, key) + + return payload, nil + } +} + // EncodeCredentialProofResponse returns an encoder for responses returned by // the signer CredentialProof endpoint. func EncodeCredentialProofResponse(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 855184e120bde7a0d2d090738f5430d2fa161af5..1fa144839e00cee06a96d275e67572548fba243e 100644 --- a/gen/http/signer/server/paths.go +++ b/gen/http/signer/server/paths.go @@ -31,6 +31,11 @@ func VerificationMethodsSignerPath(namespace string, did string) string { return fmt.Sprintf("/v1/verification-methods/%v/%v", namespace, did) } +// JwkPublicKeySignerPath returns the URL path to the signer service JwkPublicKey HTTP endpoint. +func JwkPublicKeySignerPath(namespace string, key string) string { + return fmt.Sprintf("/v1/jwk/%v/%v", namespace, key) +} + // CredentialProofSignerPath returns the URL path to the signer service CredentialProof HTTP endpoint. func CredentialProofSignerPath() string { return "/v1/credential/proof" diff --git a/gen/http/signer/server/server.go b/gen/http/signer/server/server.go index dd1afe1f6ef13ab767e6d744aa1ac76958071a63..14a7798aed46651abc49eee476e259dde962e526 100644 --- a/gen/http/signer/server/server.go +++ b/gen/http/signer/server/server.go @@ -23,6 +23,7 @@ type Server struct { NamespaceKeys http.Handler VerificationMethod http.Handler VerificationMethods http.Handler + JwkPublicKey http.Handler CredentialProof http.Handler PresentationProof http.Handler CreateCredential http.Handler @@ -63,6 +64,7 @@ func New( {"NamespaceKeys", "GET", "/v1/namespaces/{namespace}/keys"}, {"VerificationMethod", "GET", "/v1/verification-methods/{namespace}/{key}/{did}"}, {"VerificationMethods", "GET", "/v1/verification-methods/{namespace}/{did}"}, + {"JwkPublicKey", "GET", "/v1/jwk/{namespace}/{key}"}, {"CredentialProof", "POST", "/v1/credential/proof"}, {"PresentationProof", "POST", "/v1/presentation/proof"}, {"CreateCredential", "POST", "/v1/credential"}, @@ -75,6 +77,7 @@ func New( NamespaceKeys: NewNamespaceKeysHandler(e.NamespaceKeys, mux, decoder, encoder, errhandler, formatter), VerificationMethod: NewVerificationMethodHandler(e.VerificationMethod, mux, decoder, encoder, errhandler, formatter), VerificationMethods: NewVerificationMethodsHandler(e.VerificationMethods, mux, decoder, encoder, errhandler, formatter), + JwkPublicKey: NewJwkPublicKeyHandler(e.JwkPublicKey, 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), @@ -94,6 +97,7 @@ func (s *Server) Use(m func(http.Handler) http.Handler) { s.NamespaceKeys = m(s.NamespaceKeys) s.VerificationMethod = m(s.VerificationMethod) s.VerificationMethods = m(s.VerificationMethods) + s.JwkPublicKey = m(s.JwkPublicKey) s.CredentialProof = m(s.CredentialProof) s.PresentationProof = m(s.PresentationProof) s.CreateCredential = m(s.CreateCredential) @@ -112,6 +116,7 @@ func Mount(mux goahttp.Muxer, h *Server) { MountNamespaceKeysHandler(mux, h.NamespaceKeys) MountVerificationMethodHandler(mux, h.VerificationMethod) MountVerificationMethodsHandler(mux, h.VerificationMethods) + MountJwkPublicKeyHandler(mux, h.JwkPublicKey) MountCredentialProofHandler(mux, h.CredentialProof) MountPresentationProofHandler(mux, h.PresentationProof) MountCreateCredentialHandler(mux, h.CreateCredential) @@ -323,6 +328,57 @@ func NewVerificationMethodsHandler( }) } +// MountJwkPublicKeyHandler configures the mux to serve the "signer" service +// "JwkPublicKey" endpoint. +func MountJwkPublicKeyHandler(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("GET", "/v1/jwk/{namespace}/{key}", f) +} + +// NewJwkPublicKeyHandler creates a HTTP handler which loads the HTTP request +// and calls the "signer" service "JwkPublicKey" endpoint. +func NewJwkPublicKeyHandler( + 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 = DecodeJwkPublicKeyRequest(mux, decoder) + encodeResponse = EncodeJwkPublicKeyResponse(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, "JwkPublicKey") + 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) + } + }) +} + // MountCredentialProofHandler configures the mux to serve the "signer" service // "CredentialProof" endpoint. func MountCredentialProofHandler(mux goahttp.Muxer, h http.Handler) { diff --git a/gen/http/signer/server/types.go b/gen/http/signer/server/types.go index 0e4ae67c6f56c8cb332289dddbd07abb10cc807e..708502345649b497063b83235fb8f212b3eedf10 100644 --- a/gen/http/signer/server/types.go +++ b/gen/http/signer/server/types.go @@ -207,6 +207,15 @@ func NewVerificationMethodsRequest(namespace string, did string) *signer.Verific return v } +// NewJwkPublicKeyRequest builds a signer service JwkPublicKey endpoint payload. +func NewJwkPublicKeyRequest(namespace string, key string) *signer.JwkPublicKeyRequest { + v := &signer.JwkPublicKeyRequest{} + v.Namespace = namespace + v.Key = key + + return v +} + // NewCredentialProofRequest builds a signer service CredentialProof endpoint // payload. func NewCredentialProofRequest(body *CredentialProofRequestBody) *signer.CredentialProofRequest { diff --git a/gen/signer/client.go b/gen/signer/client.go index 2004a51e239cafc38c6bb4d3acbd00bdec27d3dd..aedc27e0684100d83a6c4b9ac6b14bf3cc7ba1d7 100644 --- a/gen/signer/client.go +++ b/gen/signer/client.go @@ -19,6 +19,7 @@ type Client struct { NamespaceKeysEndpoint goa.Endpoint VerificationMethodEndpoint goa.Endpoint VerificationMethodsEndpoint goa.Endpoint + JwkPublicKeyEndpoint goa.Endpoint CredentialProofEndpoint goa.Endpoint PresentationProofEndpoint goa.Endpoint CreateCredentialEndpoint goa.Endpoint @@ -29,12 +30,13 @@ type Client struct { } // NewClient initializes a "signer" service client given the endpoints. -func NewClient(namespaces, namespaceKeys, verificationMethod, verificationMethods, credentialProof, presentationProof, createCredential, createPresentation, verifyCredential, verifyPresentation, sign goa.Endpoint) *Client { +func NewClient(namespaces, namespaceKeys, verificationMethod, verificationMethods, jwkPublicKey, credentialProof, presentationProof, createCredential, createPresentation, verifyCredential, verifyPresentation, sign goa.Endpoint) *Client { return &Client{ NamespacesEndpoint: namespaces, NamespaceKeysEndpoint: namespaceKeys, VerificationMethodEndpoint: verificationMethod, VerificationMethodsEndpoint: verificationMethods, + JwkPublicKeyEndpoint: jwkPublicKey, CredentialProofEndpoint: credentialProof, PresentationProofEndpoint: presentationProof, CreateCredentialEndpoint: createCredential, @@ -87,6 +89,16 @@ func (c *Client) VerificationMethods(ctx context.Context, p *VerificationMethods return ires.([]*DIDVerificationMethod), nil } +// JwkPublicKey calls the "JwkPublicKey" endpoint of the "signer" service. +func (c *Client) JwkPublicKey(ctx context.Context, p *JwkPublicKeyRequest) (res any, err error) { + var ires any + ires, err = c.JwkPublicKeyEndpoint(ctx, p) + if err != nil { + return + } + return ires.(any), nil +} + // CredentialProof calls the "CredentialProof" endpoint of the "signer" service. func (c *Client) CredentialProof(ctx context.Context, p *CredentialProofRequest) (res any, err error) { var ires any diff --git a/gen/signer/endpoints.go b/gen/signer/endpoints.go index 1dd95410e1a1ad429dc54664beab122abd45c274..821acf77c0cedea7c1f8b0fe188e6343d2a539b3 100644 --- a/gen/signer/endpoints.go +++ b/gen/signer/endpoints.go @@ -19,6 +19,7 @@ type Endpoints struct { NamespaceKeys goa.Endpoint VerificationMethod goa.Endpoint VerificationMethods goa.Endpoint + JwkPublicKey goa.Endpoint CredentialProof goa.Endpoint PresentationProof goa.Endpoint CreateCredential goa.Endpoint @@ -35,6 +36,7 @@ func NewEndpoints(s Service) *Endpoints { NamespaceKeys: NewNamespaceKeysEndpoint(s), VerificationMethod: NewVerificationMethodEndpoint(s), VerificationMethods: NewVerificationMethodsEndpoint(s), + JwkPublicKey: NewJwkPublicKeyEndpoint(s), CredentialProof: NewCredentialProofEndpoint(s), PresentationProof: NewPresentationProofEndpoint(s), CreateCredential: NewCreateCredentialEndpoint(s), @@ -51,6 +53,7 @@ func (e *Endpoints) Use(m func(goa.Endpoint) goa.Endpoint) { e.NamespaceKeys = m(e.NamespaceKeys) e.VerificationMethod = m(e.VerificationMethod) e.VerificationMethods = m(e.VerificationMethods) + e.JwkPublicKey = m(e.JwkPublicKey) e.CredentialProof = m(e.CredentialProof) e.PresentationProof = m(e.PresentationProof) e.CreateCredential = m(e.CreateCredential) @@ -95,6 +98,15 @@ func NewVerificationMethodsEndpoint(s Service) goa.Endpoint { } } +// NewJwkPublicKeyEndpoint returns an endpoint function that calls the method +// "JwkPublicKey" of service "signer". +func NewJwkPublicKeyEndpoint(s Service) goa.Endpoint { + return func(ctx context.Context, req any) (any, error) { + p := req.(*JwkPublicKeyRequest) + return s.JwkPublicKey(ctx, p) + } +} + // NewCredentialProofEndpoint returns an endpoint function that calls the // method "CredentialProof" of service "signer". func NewCredentialProofEndpoint(s Service) goa.Endpoint { diff --git a/gen/signer/service.go b/gen/signer/service.go index b24ca8e8eef808240d6a04ffa6c1b65ced53eb4c..261cc1d8d49067f55771c9219a33c8b8547199cc 100644 --- a/gen/signer/service.go +++ b/gen/signer/service.go @@ -26,6 +26,8 @@ type Service interface { // is formatted as array of DID verification methods with their controller // attribute being the given DID in the request. VerificationMethods(context.Context, *VerificationMethodsRequest) (res []*DIDVerificationMethod, err error) + // JwkPublicKey returns public key by name and namespace. + JwkPublicKey(context.Context, *JwkPublicKeyRequest) (res any, err error) // CredentialProof adds a proof to a given Verifiable Credential. CredentialProof(context.Context, *CredentialProofRequest) (res any, err error) // PresentationProof adds a proof to a given Verifiable Presentation. @@ -50,7 +52,7 @@ 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 = [11]string{"Namespaces", "NamespaceKeys", "VerificationMethod", "VerificationMethods", "CredentialProof", "PresentationProof", "CreateCredential", "CreatePresentation", "VerifyCredential", "VerifyPresentation", "Sign"} +var MethodNames = [12]string{"Namespaces", "NamespaceKeys", "VerificationMethod", "VerificationMethods", "JwkPublicKey", "CredentialProof", "PresentationProof", "CreateCredential", "CreatePresentation", "VerifyCredential", "VerifyPresentation", "Sign"} // CreateCredentialRequest is the payload type of the signer service // CreateCredential method. @@ -105,6 +107,15 @@ type DIDVerificationMethod struct { PublicKeyJwk any } +// JwkPublicKeyRequest is the payload type of the signer service JwkPublicKey +// method. +type JwkPublicKeyRequest struct { + // Key namespace. + Namespace string + // Key name. + Key string +} + // NamespaceKeysRequest is the payload type of the signer service NamespaceKeys // method. type NamespaceKeysRequest struct { diff --git a/internal/service/signer/service.go b/internal/service/signer/service.go index 685ecd112e4d870f4f58e8601753780d316307c4..889dcfb14827cf31775ed84425bba33e6f95d32c 100644 --- a/internal/service/signer/service.go +++ b/internal/service/signer/service.go @@ -195,6 +195,33 @@ func (s *Service) VerificationMethods(ctx context.Context, req *signer.Verificat return res, nil } +// JwkPublicKey returns public key by name and namespace. +func (s *Service) JwkPublicKey(ctx context.Context, req *signer.JwkPublicKeyRequest) (any, error) { + logger := s.logger.With( + zap.String("operation", "jwkPublicKey"), + zap.String("namespace", req.Namespace), + zap.String("key", req.Key), + ) + + key, err := s.vault.Key(ctx, req.Namespace, req.Key) + if err != nil { + logger.Error("error getting key", zap.Error(err)) + return nil, err + } + + pubKey, err := s.jwkFromKey(key) + if err != nil { + logger.Error("error converting public key to jwk", + zap.String("key", key.Name), + zap.String("keyType", key.Type), + zap.Error(err), + ) + return nil, fmt.Errorf("error converting public key to jwk: %v", err) + } + + return pubKey, nil +} + // CredentialProof adds a proof to a given Verifiable Credential. func (s *Service) CredentialProof(ctx context.Context, req *signer.CredentialProofRequest) (interface{}, error) { logger := s.logger.With( diff --git a/internal/service/signer/service_test.go b/internal/service/signer/service_test.go index 70c919ad404ace0ed2545cf1811e80539e1aae7a..e1b0c4b498c8aca27dce7489bba1780dc8a203b9 100644 --- a/internal/service/signer/service_test.go +++ b/internal/service/signer/service_test.go @@ -7,7 +7,9 @@ import ( "encoding/base64" "encoding/json" "fmt" + "net" "net/http" + "os" "testing" "time" @@ -26,10 +28,26 @@ import ( var docLoader *ld.CachingDocumentLoader -func init() { +func TestMain(m *testing.M) { + c := &http.Client{ + Transport: &http.Transport{ + Proxy: http.ProxyFromEnvironment, + DialContext: (&net.Dialer{ + Timeout: 5 * time.Second, + }).DialContext, + MaxIdleConns: 1, + MaxIdleConnsPerHost: 1, + TLSHandshakeTimeout: 5 * time.Second, + IdleConnTimeout: 60 * time.Second, + }, + Timeout: 10 * time.Second, + } + if docLoader == nil { - docLoader = ld.NewCachingDocumentLoader(ld.NewDefaultDocumentLoader(http.DefaultClient)) + docLoader = ld.NewCachingDocumentLoader(ld.NewDefaultDocumentLoader(c)) } + + os.Exit(m.Run()) } func TestService_Namespaces(t *testing.T) { @@ -262,6 +280,52 @@ func TestService_VerificationMethods(t *testing.T) { }) } +func TestService_JwkPublicKey(t *testing.T) { + t.Run("signer returns error when getting key", func(t *testing.T) { + vaultError := &signerfakes.FakeVault{ + KeyStub: func(ctx context.Context, namespace, key string) (*signer.VaultKey, error) { + return nil, errors.New(errors.NotFound, "key not found") + }, + } + + svc := signer.New(vaultError, []string{}, docLoader, zap.NewNop()) + result, err := svc.JwkPublicKey( + context.Background(), + &goasigner.JwkPublicKeyRequest{Namespace: "transit", Key: "key1"}, + ) + assert.Nil(t, result) + assert.Error(t, err) + e, ok := err.(*errors.Error) + assert.True(t, ok) + assert.Equal(t, errors.NotFound, e.Kind) + }) + + t.Run("signer returns ecdsa-p256 key successfully", func(t *testing.T) { + signerOK := &signerfakes.FakeVault{ + KeyStub: func(ctx context.Context, namespace, key string) (*signer.VaultKey, error) { + return &signer.VaultKey{ + Name: "key1", + Type: "ecdsa-p256", + PublicKey: "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAERTx/2cyYcGVSIRP/826S32BiZxSg\nnzyXgRYmKP8N2l26ec/MwCdsHIEyraX1ZYqwMUT4wO9fqFiGsRKyMBpPnQ==\n-----END PUBLIC KEY-----\n", + }, nil + }, + } + + svc := signer.New(signerOK, []string{"ecdsa-p256"}, docLoader, zap.NewNop()) + result, err := svc.JwkPublicKey( + context.Background(), + &goasigner.JwkPublicKeyRequest{Namespace: "transit", Key: "key1"}, + ) + assert.NotNil(t, result) + assert.NoError(t, err) + + pub, ok := result.(*jose.JSONWebKey) + assert.True(t, ok) + assert.NotNil(t, pub) + assert.IsType(t, (*ecdsa.PublicKey)(nil), pub.Key) + }) +} + func TestService_CredentialProof(t *testing.T) { tests := []struct { name string @@ -428,7 +492,7 @@ func TestService_CredentialProof(t *testing.T) { }) if err != nil { assert.Nil(t, res) - require.NotEmpty(t, test.errtext, "error is not expected, but got: %v ") + require.NotEmpty(t, test.errtext, "error is not expected, but got: %v ", err) assert.Contains(t, err.Error(), test.errtext) if e, ok := err.(*errors.Error); ok { assert.Equal(t, test.errkind, e.Kind) @@ -451,7 +515,7 @@ func TestService_CredentialProof(t *testing.T) { } }) - time.Sleep(500 * time.Millisecond) + time.Sleep(1 * time.Second) } } @@ -652,7 +716,7 @@ func TestService_PresentationProof(t *testing.T) { assert.NotEmpty(t, vp.Proofs[0]["jws"]) }) - time.Sleep(500 * time.Millisecond) + time.Sleep(1 * time.Second) } } @@ -815,6 +879,8 @@ func TestService_CreateCredential(t *testing.T) { assert.Equal(t, test.wantedCredentialSubject, vc.Subject) } }) + + time.Sleep(1 * time.Second) } }