diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index 1d1fe94d..00000000 --- a/.dockerignore +++ /dev/null @@ -1 +0,0 @@ -Dockerfile \ No newline at end of file diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 88910e3b..1a5ab372 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -4,7 +4,7 @@ on: push jobs: - pdpd-test: + unit-test: runs-on: ubuntu-latest steps: @@ -15,6 +15,15 @@ jobs: with: go-version: 1.18 + - name: Install coveralls dependencies + run: | + go get github.com/mattn/goveralls + go get github.com/go-playground/validator/v10 + - name: Go test run: | - go test ./... -v \ No newline at end of file + go test ./... -v -coverprofile=profile.cov ./... + + - uses: shogo82148/actions-goveralls@v1 + with: + path-to-profile: profile.cov \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 9948be8f..feae9d41 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.18-alpine AS build +FROM golang:1.19-alpine AS build WORKDIR /go/src/app COPY ./ ./ @@ -6,16 +6,13 @@ COPY ./ ./ RUN apk add build-base RUN go get -d -v ./... -RUN go generate ./ent RUN go build -v . -FROM golang:1.18-alpine +FROM golang:1.19-alpine WORKDIR /go/src/app -COPY --from=build /go/src/app/back/views /go/src/app/back/views -COPY --from=build /go/src/app/back/www /go/src/app/back/www -COPY --from=build /go/src/app/configs /go/src/app/configs -COPY --from=build /go/src/app/vcverifier /go/src/app/vcverifier -COPY --from=build /go/src/app/vault/templates /go/src/app/vault/templates +COPY --from=build /go/src/app/views /go/src/app/views +COPY --from=build /go/src/app/VCVerifier /go/src/app/VCVerifier +COPY --from=build /go/src/app/server.yaml /go/src/app/server.yaml -CMD ["./vcverifier"] \ No newline at end of file +CMD ["./VCVerifier"] \ No newline at end of file diff --git a/README.md b/README.md index 2427f6dd..64684d31 100644 --- a/README.md +++ b/README.md @@ -1,84 +1,200 @@ -# vcverifier +# VCVerifier for SIOP-2/OIDC4VP -vcverifier includes in a single binary demo versions of Issuer, Verifier and Wallet (same-device only, for a cross-device wallet please see [VCWallet](https://github.com/hesusruiz/VCWallet)). +VCVerifier provides the necessary endpoints(see [API](./api/api.yaml)) to offer [SIOP-2](https://openid.net/specs/openid-connect-self-issued-v2-1_0.html#name-cross-device-self-issued-op)/[OIDC4VP](https://openid.net/specs/openid-4-verifiable-presentations-1_0.html#request_scope) compliant authentication flows. It exchanges [VerfiableCredentials](https://www.w3.org/TR/vc-data-model/) for [JWT](https://www.rfc-editor.org/rfc/rfc7519), that can be used for authorization and authentication in down-stream components. -This facilitates installation and allows to see how all components fit together and the protocol flows between them. +[![FIWARE Security](https://nexus.lab.fiware.org/repository/raw/public/badges/chapters/security.svg)](https://www.fiware.org/developers/catalogue/) +[![License badge](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) +[![Container Repository on Quay](https://img.shields.io/badge/quay.io-fiware%2Fvcverifier-grey?logo=red%20hat&labelColor=EE0000)](https://quay.io/repository/fiware/vcverifier) +[![Coverage Status](https://coveralls.io/repos/github/FIWARE/VCVerifier/badge.svg?branch=main)](https://coveralls.io/github/FIWARE/VCVerifier?branch=main) -## Installation +## Contents -Clone the repository: +* [Background](#background) + * [Overview](#overview) +* [Install](#install) + * [Container](#container) + * [Kubernetes](#kubernetes) + * [Local Setup](#local-setup) + * [Configuration](#configuration) + * [Templating](#templating) + * [WaltID SSIKit](#waltid-ssikit) +* [Usage](#usage) + * [Frontend-Integration](#frontend-integration) + * [REST-Example](#rest-example) +* [API](#api) + * [Open Issues](#open-issues) +* [Testing](#testing) +* [License](#license) +## Background + +[VerifiableCredentials](https://www.w3.org/TR/vc-data-model/) provide a mechanism to represent information in a tamper-evident and therefor trustworthy way. The term "verifiable" refers to the characteristic of a credential being able to be verified by a 3rd party(e.g. a verifier). Verification in that regard means, that it can be proven, that the claims made in the credential are as they were provided by the issuer of that credential. +This characteristics make [VerifiableCredentials](https://www.w3.org/TR/vc-data-model/) a good option to be used for authentication and authorization, as a replacement of other credentials types, like the traditional username/password. The [SIOP-2](https://openid.net/specs/openid-connect-self-issued-v2-1_0.html#name-cross-device-self-issued-op)/[OIDC4VP](https://openid.net/specs/openid-4-verifiable-presentations-1_0.html#request_scope) standards define a flow to request and present such credentials as an extension to the well-established [OpenID Connect](https://openid.net/connect/). +The VCVerifier provides the necessary endpoints required for a `Relying Party`(as used in the [SIOP-2 spec](https://openid.net/specs/openid-connect-self-issued-v2-1_0.html#name-abbreviations)) to participate in the authentication flows. It verifies the credentials by using [WaltID SSIkit](https://walt.id/ssi-kit) as a downstream component to provide Verfiable Credentials specific functionality and return a signed [JWT](https://www.rfc-editor.org/rfc/rfc7519), containing the credential as a claim, to be used for further interaction by the participant. + +### Overview + +The following diagram shows an example of how the VCVerifier would be placed inside a system, using VerifiableCredentials for authentication and authorization. It pictures a Human-2-Machine flow, where a certain user interacts with a frontend and uses its dedicated Wallet(for example installed on a mobile phone) to participate in the SIOP-2/OIDC4VP flow. + +![overview-setup](docs/verifier_overview.png) + +The following actions occur in the interaction: + +1. The user opens the frontend application. +2. The frontend-application forwards the user to the login-page of VCVerifier +3. The VCVerifier presents a QR-code, containing the ```openid:```-connection string with all necessary information to start the authentication process. The QR-code is scanned by the user's wallet. +4. The user approves the wallet's interaction with the VCVerifier and the VerifiableCredential is presented via the OIDC4VP-flow. +5. VCVerifier requests verification of the credential with a defined set of policies at WaltID-SSIKit. +6. A JWT is created, the frontend-application is informed via callback and the token is retrieved via the token-endpoint. +7. Frontend start to interact with the backend-service, using the jwt. +8. Authorization-Layer requests the JWKS from the VCVerifier(this can happen asynchronously, not in the sequential flow of the diagram). +9. Authorization-Layer verifies the JWT(using the retrieved JWKS) and handles authorization based on its contents. + +## Install + +### Container + +The VCVerifier is provided as a container and can be run via ```docker run -p 8080:8080 quay.io/fiware/vcverifier```. + +### Kubernetes + +To ease the deployment on [Kubernetes](https://kubernetes.io/) environments, the helm-chart [i4trust/vcverfier](https://github.com/i4Trust/helm-charts/tree/main/charts/vcverifier) can be used. + +### Local setup + +Since the VCVerifier requires WaltID, a Trusted Issuers Registry and someone to issuer credentials, a local setup is not directly integrated into this repository. However, the [vc-integrationtest](https://github.com/fiware/vc-integrationtest) repository provides an extensive setup of various components participating in the flows. It can be used to run a local setup, either for trying-out or as a basis for further development. Run it via: +```shell + git clone git@github.com:fiware/vc-integrationtest.git + cd vc-integrationtest/ + mvn clean integration-test -Pdev ``` -git clone git@github.com:hesusruiz/vcverifier.git -``` +See the documentation in that repo for more information. -Before running vcverifier you need to have accessible the endpoints implemented by [VCWaltid](https://github.com/FIWARE/VCWaltid). Please install an run VCWaltid following the instructions there. The endpoints and ports required from vcverifier are preconfigured to match the ones from VCWaltid without any change. If you do require changes, they can be setup in the configuration file in `configs\server.yaml`. +### Configuration -## Running +The configuration has to be provided via config-file. The file is either loaded from the default location at ```./server.yaml``` or from a location configured via the environment-variable ```CONFIG_FILE```. See the following yaml for documentation and default values: -The first time that you start the vcverifier you have to make sure the database artifacts are consistent. Tou can use the provided Makefile for that or run the command directly: +```yaml +# all configurations related to serving the endpoints +server: + # port to bin to + port: 8080 + # folder to load the template pages from + templateDir: "views/" + # directory to load static content from + staticDir: "views/static/" +# logging configuration +logging: + # the log level, accepted options are DEBUG, INFO, WARN and ERROR + level: "INFO" + # should the log output be in structured json-format + jsonLogging: true + # should the verifier log all incoming requests + logRequests: true + # a list of paths that should be excluded from the request logging. Can f.e. be used to omit continuous health-checks + pathsToSkip: + +# configuration directly connected to the functionality +verifier: + # did to be used by the verifier. + did: + # address of the (ebsi-compliant) trusted-issuers-registry to be used for verifying the issuer of a received credential + tirAddress: + # Expiry(in seconds) of an authentication session. After that, a new flow needs to be initiated. + sessionExpiry: 30 + # scope(e.g. type of credential) to be requested from the wallet. if not configured, not specific scope will be requested. + requestScope: + +# endpoints of ssikit to be used +ssiKit: + # url of the ssikit auditor-api(see https://docs.walt.id/v/ssikit/getting-started/rest-apis/auditor-api) + auditorURL: ``` -make datamodel +#### Templating + +The login-page, provided at ```/api/v1/loginQR```, can be configured by providing a different template in the ```templateDir```. The templateDir needs to contain a file named ```verifier_present_qr.html``` which will be rendered on calls to the login-api. The template needs to include the QR-Code via ``` 0) { - return nil, err - } - - if ccr.PublicKeyCredential.Credential.Type == "" { - return nil, fmt.Errorf("missing type") - } - - if ccr.PublicKeyCredential.Credential.Type != "public-key" { - return nil, fmt.Errorf("type not public-key") - } - - var pcc protocol.ParsedCredentialCreationData - pcc.ID, pcc.RawID, pcc.Type, pcc.ClientExtensionResults = ccr.ID, ccr.RawID, ccr.Type, ccr.ClientExtensionResults - pcc.Raw = ccr - - parsedAttestationResponse, err := ccr.AttestationResponse.Parse() - if err != nil { - return nil, err - } - - pcc.Response = *parsedAttestationResponse - - return &pcc, nil -} - -// Parse the credential request response into a format that is either required by the specification -// or makes the assertion verification steps easier to complete. This takes an io.Reader that contains -// the assertion response data in a raw, mostly base64 encoded format, and parses the data into -// manageable structures -func ParseCredentialRequestResponse(car protocol.CredentialAssertionResponse) (*protocol.ParsedCredentialAssertionData, error) { - - if car.ID == "" { - return nil, fmt.Errorf("CredentialAssertionResponse with ID missing") - } - - _, err := base64.RawURLEncoding.DecodeString(car.ID) - if err != nil { - return nil, err - } - if car.Type != "public-key" { - return nil, fmt.Errorf("CredentialAssertionResponse with bad type") - } - var par protocol.ParsedCredentialAssertionData - par.ID, par.RawID, par.Type, par.ClientExtensionResults = car.ID, car.RawID, car.Type, car.ClientExtensionResults - par.Raw = car - - par.Response.Signature = car.AssertionResponse.Signature - par.Response.UserHandle = car.AssertionResponse.UserHandle - - // Step 5. Let JSONtext be the result of running UTF-8 decode on the value of cData. - // We don't call it cData but this is Step 5 in the spec. - err = json.Unmarshal(car.AssertionResponse.ClientDataJSON, &par.Response.CollectedClientData) - if err != nil { - return nil, err - } - - err = par.Response.AuthenticatorData.Unmarshal(car.AssertionResponse.AuthenticatorData) - if err != nil { - return nil, err - } - return &par, nil -} - -func printJSON(val any) { - out, err := json.MarshalIndent(val, "", " ") - if err != nil { - zlog.Error().Err(err).Msg("Error in JSON Marshall") - return - } - fmt.Println(string(out)) -} diff --git a/back/operations/credentials.go b/back/operations/credentials.go deleted file mode 100644 index eedf99f9..00000000 --- a/back/operations/credentials.go +++ /dev/null @@ -1,179 +0,0 @@ -package operations - -import ( - "bytes" - "context" - "encoding/base64" - "encoding/json" - "fmt" - "strings" - - "github.com/gofiber/fiber/v2" -) - -type EmployeeCredentialData struct { - Jti string `json:"jti,omitempty" yaml:"jti" mapstructure:"jti"` - CredName string `json:"cred_name,omitempty" mapstructure:"credName"` - CredType string `json:"cred_type,omitempty" mapstructure:"credType"` - IssuerDID string `json:"iss,omitempty" mapstructure:"issuerDID"` - SubjectDID string `json:"did,omitempty" mapstructure:"subjectDID"` - Name string `json:"name,omitempty" mapstructure:"name"` - Given_name string `json:"given_name,omitempty" mapstructure:"given_name"` - Family_name string `json:"family_name,omitempty" mapstructure:"family_name"` - Preferred_username string `json:"preferred_username,omitempty" mapstructure:"preferred_username"` - Email string `json:"email,omitempty" mapstructure:"email"` - Target string `json:"target,omitempty"` - Roles string `json:"roles,omitempty"` -} - -type RoleForTarget struct { - Target string `json:"target,omitempty"` - Names []string `json:"names,omitempty"` -} - -func (m *Manager) ConvertToMap(credIn *EmployeeCredentialData) (map[string]any, error) { - out := make(map[string]any) - claims := make(map[string]any) - - claims["given_name"] = credIn.Given_name - claims["family_name"] = credIn.Family_name - claims["name"] = credIn.Name - claims["preferred_username"] = credIn.Preferred_username - claims["email"] = credIn.Email - - var roles = []RoleForTarget{} - - names := strings.Split(credIn.Roles, ",") - role := RoleForTarget{ - Target: credIn.Target, - Names: names, - } - - roles = append(roles, role) - claims["roles"] = roles - - out["claims"] = claims - - out["issuerDID"] = credIn.IssuerDID - out["credName"] = credIn.CredName - out["credType"] = credIn.CredType - out["subjectDID"] = credIn.SubjectDID - - return out, nil -} - -func (m *Manager) CreateServiceCredential(credIn map[string]any) (string, []byte, error) { - - credIn["credName"] = "PacketDeliveryCredential" - credIn["issuerDID"] = m.cfg.String("issuer.DID") - - // Check if the user is already registered. We use the email as a unique identifier - usr, err := m.v.UserByID(credIn["email"].(string)) - if err != nil { - return "", nil, fiber.NewError(fiber.StatusInternalServerError, "error searching for user") - } - - // Create a new user if it does not exist yet, with a default password - if usr == nil { - userName := credIn["familyName"].(string) + ", " + credIn["firstName"].(string) - usr, err = m.v.CreateNaturalPersonWithKey(credIn["email"].(string), userName, "ThePassword") - if err != nil { - return "", nil, fiber.NewError(fiber.StatusInternalServerError, "error creating new user") - } - } - - // // Get the first private key from the user - // keys, err := m.v.PrivateKeysForUser(usr.ID) - // if err != nil || len(keys) == 0 { - // return "", nil, fiber.NewError(fiber.StatusInternalServerError, "error getting private keys for user") - // } - - // pubKey, err := keys[0].GetPublicKey() - // if err != nil || len(keys) == 0 { - // return "", nil, fiber.NewError(fiber.StatusInternalServerError, "error getting public key for user") - // } - - credIn["subjectDID"] = "did:key:" + usr.ID - - return m.v.CreateCredentialJWTFromMap(credIn) - -} - -type CredentialSummary struct { - Id string `json:"id,omitempty"` -} - -func (m *Manager) GetAllCredentials() ([]CredentialSummary, error) { - rawCreds := m.v.GetAllCredentials() - - credentials := make([]CredentialSummary, len(rawCreds)) - - for i, rawCred := range rawCreds { - credentials[i].Id = rawCred.Id - } - - return credentials, nil - -} - -func (m *Manager) GetCredential(credID string) (claims string, err error) { - - // Check if the credential already exists - - rawCred, err := m.v.Client.Credential.Get(context.Background(), credID) - if err != nil { - return "", err - } - - // A JWT token is composed of 3 parts concatenated by dots (".") - parts := strings.Split(string(rawCred.Raw), ".") - if len(parts) != 3 { - return "", fmt.Errorf("token contains an invalid number of segments") - } - - // Decode claims part from B64Url - claimBytes, err := base64.RawURLEncoding.DecodeString(parts[1]) - if err != nil { - return "", err - } - - // JSON Decode, decoding to Number instead of floats - dec := json.NewDecoder(bytes.NewBuffer(claimBytes)) - dec.UseNumber() - - var claimDecoded any - err = dec.Decode(&claimDecoded) - if err != nil { - return "", err - } - - out, err := json.MarshalIndent(claimDecoded, "", " ") - if err != nil { - return "", err - } - - return string(out), nil - -} - -func (m *Manager) GetCredentialLD(credID string) (claims string, err error) { - - // Check if the credential already exists - - rawCred, err := m.v.Client.Credential.Get(context.Background(), credID) - if err != nil { - return "", err - } - - s := prettyFormatJSON(rawCred.Raw) - - return s, nil - -} - -func prettyFormatJSON(in []byte) string { - decoded := &fiber.Map{} - json.Unmarshal(in, decoded) - out, _ := json.MarshalIndent(decoded, "", " ") - return string(out) -} diff --git a/back/operations/manager.go b/back/operations/manager.go deleted file mode 100644 index 03df4681..00000000 --- a/back/operations/manager.go +++ /dev/null @@ -1,33 +0,0 @@ -package operations - -import ( - "github.com/fiware/vcverifier/vault" - "github.com/hesusruiz/vcutils/yaml" - - zlog "github.com/rs/zerolog/log" -) - -type Manager struct { - v *vault.Vault - cfg *yaml.YAML -} - -func NewManager(cfg *yaml.YAML) *Manager { - - // Open the Vault - v, err := vault.New(cfg) - if err != nil { - zlog.Panic().Err(err).Send() - } - - manager := &Manager{ - v: v, - cfg: cfg, - } - return manager - -} - -func (m *Manager) User() *User { - return &User{db: m.v.Client} -} diff --git a/back/operations/ssikit.go b/back/operations/ssikit.go deleted file mode 100644 index 5745a9aa..00000000 --- a/back/operations/ssikit.go +++ /dev/null @@ -1,48 +0,0 @@ -package operations - -import ( - "errors" - "fmt" - "net/http" - - "github.com/fiware/vcverifier/vault" - "github.com/gofiber/fiber/v2" - "go.uber.org/zap" -) - -var logger = zap.Must(zap.NewDevelopment()) - -func SSIKitCreateDID(custodianURL string, v *vault.Vault, userid string) (string, error) { - defer logger.Sync() - - // Create a new DID only if it does not exist - did, _ := v.GetDIDForUser(userid) - if len(did) > 0 { - return did, nil - } - - // Call the SSI Kit - agent := fiber.Post(custodianURL + "/did/create") - bodyRequest := fiber.Map{ - "method": "key", - } - agent.JSON(bodyRequest) - agent.ContentType("application/json") - agent.Set("accept", "application/json") - code, returnBody, reqErr := agent.Bytes() - if len(reqErr) > 0 { - err := fmt.Errorf("error calling SSI Kit: %v", reqErr[0]) - logger.Error("error calling SSI Kit", zap.Error(err)) - return "", err - } - if code != http.StatusOK { - logger.Error(fmt.Sprintf("Was not able to create the issuer. Status: %d, Message: %s", code, returnBody)) - return "", errors.New("issuer_not_created") - } - - did = string(returnBody) - // Store the new DID for the specified user - v.SetDIDForUser(userid, did) - - return did, nil -} diff --git a/back/operations/user.go b/back/operations/user.go deleted file mode 100644 index ed6d5396..00000000 --- a/back/operations/user.go +++ /dev/null @@ -1,150 +0,0 @@ -package operations - -import ( - "context" - "crypto/rand" - - "github.com/fiware/vcverifier/ent" - "github.com/fiware/vcverifier/ent/user" - - "github.com/duo-labs/webauthn/protocol" - "github.com/duo-labs/webauthn/webauthn" - zlog "github.com/rs/zerolog/log" -) - -// User represents the user model -// It implements the webauthn.User interface -type User struct { - db *ent.Client - entuser *ent.User - id string - name string - displayName string - credentials []webauthn.Credential -} - -func (u *User) Create(name string, displayName string) (*User, error) { - - u.id = randomString() - u.name = name - u.displayName = displayName - - u.entuser = u.db.User.Create().SetID(u.id). - SetName(name). - SetDisplayname(displayName).SaveX(context.Background()) - - return u, nil -} - -// GetUser returns a *User by the user's username -func (u *User) GetByName(name string) (*User, error) { - - entuser, err := u.db.User.Query().Where(user.Name(name)).Only(context.Background()) - if err != nil { - return nil, err - } - - u.id = entuser.ID - u.name = entuser.Name - u.displayName = entuser.Displayname - u.entuser = entuser - - // Get the credentials - u.WebAuthnCredentials() - - return u, nil - -} - -func (u *User) GetOrCreate(name string, displayName string) (*User, error) { - var err error - - // Search for the user - _, err = u.GetByName(name) - - if ent.IsNotFound(err) { - // User was not found, create a new user - return u.Create(name, displayName) - } else { - // Return the retrieved user, or an error - return u, err - } - -} - -// WebAuthnID returns the user's ID -func (u User) WebAuthnID() []byte { - return []byte(u.id) -} - -// WebAuthnName returns the user's username -func (u User) WebAuthnName() string { - return u.name -} - -// WebAuthnDisplayName returns the user's display name -func (u User) WebAuthnDisplayName() string { - return u.displayName -} - -// WebAuthnIcon is not (yet) implemented -func (u User) WebAuthnIcon() string { - return "" -} - -// AddCredential associates the credential to the user -// func (u *User) AddCredential(cred webauthn.Credential) { -// if u.entuser == nil { -// zlog.Panic().Msg("User model not initialized") -// } - -// u.db.WebauthnCredential.Create(). -// SetID(string(cred.ID)). -// SetCredential(cred). -// SetUser(u.entuser). -// SaveX(context.Background()) - -// } - -// WebAuthnCredentials returns credentials owned by the user -func (u *User) WebAuthnCredentials() []webauthn.Credential { - return nil - // if u.entuser == nil { - // zlog.Panic().Msg("User model not initialized") - // } - - // entCreds := u.db.User.QueryCredentials(u.entuser).AllX(context.Background()) - - // u.credentials = make([]webauthn.Credential, len(entCreds)) - - // for i, ec := range entCreds { - // u.credentials[i] = ec.Credential - // } - - // return u.credentials -} - -// CredentialExcludeList returns a CredentialDescriptor array filled -// with all a user's credentials -func (u *User) CredentialExcludeList() []protocol.CredentialDescriptor { - if u.entuser == nil { - zlog.Panic().Msg("User model not initialized") - } - - credentialExcludeList := []protocol.CredentialDescriptor{} - for _, cred := range u.credentials { - descriptor := protocol.CredentialDescriptor{ - Type: protocol.PublicKeyCredentialType, - CredentialID: cred.ID, - } - credentialExcludeList = append(credentialExcludeList, descriptor) - } - - return credentialExcludeList -} - -func randomString() string { - buf := make([]byte, 10) - rand.Read(buf) - return string(buf) -} diff --git a/back/views/creddetails.html b/back/views/creddetails.html deleted file mode 100644 index f06ab99c..00000000 --- a/back/views/creddetails.html +++ /dev/null @@ -1,12 +0,0 @@ -{{define "creddetails"}} {{template "partials/header" .}} - -
- - -

-{{.claims}}
-
- -
- -{{template "partials/footer" .}} {{end}} \ No newline at end of file diff --git a/back/views/displayerror.html b/back/views/displayerror.html deleted file mode 100644 index 8d25e8e3..00000000 --- a/back/views/displayerror.html +++ /dev/null @@ -1,22 +0,0 @@ -{{define "displayerror"}} {{template "partials/header" .}} - -
- -
- -
-
-

Error

-
- -
-

{{.error}}

-
- -
-
- - -
- -{{template "partials/footer" .}} {{end}} \ No newline at end of file diff --git a/back/views/errors/404.html b/back/views/errors/404.html deleted file mode 100644 index fbf09722..00000000 --- a/back/views/errors/404.html +++ /dev/null @@ -1 +0,0 @@ -

{{.Error}}

\ No newline at end of file diff --git a/back/views/index.html b/back/views/index.html deleted file mode 100644 index c73152aa..00000000 --- a/back/views/index.html +++ /dev/null @@ -1,36 +0,0 @@ -{{define "index"}} {{template "partials/header" .}} - -
-

Select the operation

- - -
-
-
-
-

Go to Issuer

-
- -
- Issuer -
- -
-
-
-
-
-

Go to Verifier

-
- -
- Verifier -
- -
-
-
- -
- -{{template "partials/footer" .}} {{end}} \ No newline at end of file diff --git a/back/views/layouts/main.html b/back/views/layouts/main.html deleted file mode 100644 index 0593fbf0..00000000 --- a/back/views/layouts/main.html +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - Credential Issuer - - - - - -{{embed}} - - - - \ No newline at end of file diff --git a/back/views/partials/footer.html b/back/views/partials/footer.html deleted file mode 100644 index 8b137891..00000000 --- a/back/views/partials/footer.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/back/views/partials/header.html b/back/views/partials/header.html deleted file mode 100644 index b194ebc5..00000000 --- a/back/views/partials/header.html +++ /dev/null @@ -1,5 +0,0 @@ -
- - FIWARE Verifiable Credentials - -
diff --git a/back/views/verifier_home.html b/back/views/verifier_home.html deleted file mode 100644 index f0719ff4..00000000 --- a/back/views/verifier_home.html +++ /dev/null @@ -1,13 +0,0 @@ -{{define "verifier_home"}} {{template "partials/header" .}} - -
- -

Welcome to the FIWARE Verifier

- -
- Login with a Verifiable Credential -
- -
- -{{template "partials/footer" .}} {{end}} \ No newline at end of file diff --git a/back/views/verifier_loginexpired.html b/back/views/verifier_loginexpired.html deleted file mode 100644 index cf7aadb2..00000000 --- a/back/views/verifier_loginexpired.html +++ /dev/null @@ -1,22 +0,0 @@ -{{define "verifier_loginexpired"}} {{template "partials/header" .}} - -
- -
-
-
-

The login session has expired

-
- -
-

Click the button to try again

- Home -
- -
-
- - -
- -{{template "partials/footer" .}} {{end}} \ No newline at end of file diff --git a/back/views/verifier_present_qr.html b/back/views/verifier_present_qr.html deleted file mode 100644 index 822d0c8e..00000000 --- a/back/views/verifier_present_qr.html +++ /dev/null @@ -1,48 +0,0 @@ -{{define "verifier_present_qr"}} {{template "partials/header" .}} - -
- -

Scan this QR code to authenticate with a mobile

- - EvidenceLedger logo - -

Or click this button to authenticate with the browser

- -
- Login with browser -
- -
- - - -{{template "partials/footer" .}} {{end}} \ No newline at end of file diff --git a/back/views/verifier_protectedservice.html b/back/views/verifier_protectedservice.html deleted file mode 100644 index a71002fa..00000000 --- a/back/views/verifier_protectedservice.html +++ /dev/null @@ -1,35 +0,0 @@ -{{define "verifier_protectedservice"}} {{template "partials/header" .}} - -
- - - {{if .accesstoken}} -
-

This is a protected service

-

We received an access token

-
- -

-{{.accesstoken}}
-
- - {{if .protected}} -
-

We also tried to access a resource at:

-

{{.protected}}

-

With status code {{.code}} and returned:

-

{{.returnBody}}

-
- {{end}} - - {{else}} -
-

This is a protected service

-

We did not receive an access token and access should be forbidden

-
- {{end}} - - -
- -{{template "partials/footer" .}} {{end}} \ No newline at end of file diff --git a/back/views/verifier_receivedcredential.html b/back/views/verifier_receivedcredential.html deleted file mode 100644 index 1be1a375..00000000 --- a/back/views/verifier_receivedcredential.html +++ /dev/null @@ -1,20 +0,0 @@ -{{define "verifier_receivedcredential"}} {{template "partials/header" .}} - -
- -
-

Received credential:

-
- - -

-{{.claims}}
-
- -
- Access protected service -
- -
- -{{template "partials/footer" .}} {{end}} \ No newline at end of file diff --git a/back/www/dash.html b/back/www/dash.html deleted file mode 100644 index ebc676dd..00000000 --- a/back/www/dash.html +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - - - - - - - - WebAuthn Login Screen - - - - - - - - - - - - - - - - - - - - -
-
- -
- -
-
- -

Login

- -
- - - -
-
-
-
-
-
- -
- -
- Register - Login -
- -
-
- -
- - - - - - \ No newline at end of file diff --git a/back/www/index.html b/back/www/index.html deleted file mode 100644 index 831e4542..00000000 --- a/back/www/index.html +++ /dev/null @@ -1,79 +0,0 @@ - - - - - - - - - - - - - - WebAuthn Login Screen - - - - - - - - - - - - - - - - - - - - -
-
- -
- -
-
- -
-

Login

-
- -
- - - -
-
-
-
-
-
- -
- -
- Register - Login -
- Test - -
-
- -
- - - - - - \ No newline at end of file diff --git a/config/config.go b/config/config.go new file mode 100644 index 00000000..2209d565 --- /dev/null +++ b/config/config.go @@ -0,0 +1,52 @@ +package config + +// CONFIGURATION STRUCTURE FOR THE VERIFIER CONFIG + +// general structure of the configuration file +type Configuration struct { + Server *Server `mapstructure:"server"` + Verifier *Verifier `mapstructure:"verifier"` + SSIKit *SSIKit `mapstructure:"ssiKit"` +} + +// configuration to be used by the ssiKit configuration +type SSIKit struct { + // address of waltIDs auditor-endpoint + AuditorURL string `mapstructure:"auditorURL"` +} + +// general configuration to run the application +type Server struct { + // port to bind the server + Port int `mapstructure:"port" default:"8080"` + // directory to read the template(s) from + TemplateDir string `mapstructure:"templateDir" default:"views/"` + // directory of static files to be provided, f.e. to be used inside the templates + StaticDir string `mapstructure:"staticDir" default:"views/static/"` + // logging configuration + Logging *Logging `mapstructure:"logging"` +} + +// logging config +type Logging struct { + // loglevel to be used - can be DEBUG, INFO, WARN or ERROR + Level string `mapstructure:"level" default:"INFO"` + // should the logging in a structured json format + JsonLogging bool `mapstructure:"jsonLogging" default:"true"` + // should requests be logged + LogRequests bool `mapstructure:"logRequests" default:"true"` + // list of paths to be ignored on request logging(could be often called operational endpoints like f.e. metrics) + PathsToSkip []string `mapstructure:"pathsToSkip"` +} + +// configuration specific to the functionality of the verifier +type Verifier struct { + // did to be used by the verifier + Did string `mapstructure:"did"` + // address of the (ebsi-compatible) trusted-issuers-registry for verifying the issuer + TirAddress string `mapstructure:"tirAddress"` + // expiry of auth sessions + SessionExpiry int `mapstructure:"sessionExpiry" default:"30"` + // scope to be used in the authentication request + RequestScope string `mapstructure:"requestScope"` +} diff --git a/configs/server.yaml b/configs/server.yaml deleted file mode 100644 index d59da7e5..00000000 --- a/configs/server.yaml +++ /dev/null @@ -1,36 +0,0 @@ -server: - listenAddress: "0.0.0.0:3000" - staticDir: "back/www" - templateDir: "back/views" - environment: development - loglevel: DEBUG - -store: - driverName: "sqlite3" - dataSourceName: "file:issuer.sqlite?mode=rwc&cache=shared&_fk=1" - -verifier: - id: PacketDelivery - name: PacketDelivery - password: ThePassword - store: - driverName: "sqlite3" - dataSourceName: "file:verifier.sqlite?mode=rwc&cache=shared&_fk=1" - uri_prefix: /verifier - jwks_uri: /.well-known/jwks_uri - protectedResource: - url: "https://www.google.com" - -verifiableregistry: - password: ThePassword - store: - driverName: "sqlite3" - dataSourceName: "file:verifiableregistry.sqlite?mode=rwc&cache=shared&_fk=1" - -ssikit: - coreURL: localhost:7000 - signatoryURL: http://localhost:7001 - auditorURL: localhost:7002 - custodianURL: localhost:7003 - essifURL: localhost:7010 - diff --git a/docs/verifier_overview.drawio b/docs/verifier_overview.drawio new file mode 100644 index 00000000..59cebe93 --- /dev/null +++ b/docs/verifier_overview.drawio @@ -0,0 +1 @@ +3Vpbk6I4FP41PtoFhAA+aju9MzW9u1Nl1cz0Iw1RsxONE6Kt/es3QIKEiDiKl/bJ5JAcwpfznUtiBzzO1n+xcDH9m8aIdBwrXnfAsOM4tt2D4ieVbHKJB6xcMGE4loO2ghF+R1Kohi1xjBJtIKeUcLzQhRGdz1HENVnIGH3Th40p0d+6CCfIEIyikJjSHzjm01waQGsr/4zwZKrebFvyySxUg6UgmYYxfSuJwKcOeGSU8rw1Wz8ikoKncMnnPdU8LRbG0JwfMuH95/C/z/8kz3139W/y1H+x8LrXlVpWIVnKD5aL5RuFAKPLeYxSJVYHDN6mmKPRIozSp29iz4VsymdE9GzRlOoQ42hdu067+HphNojOEGcbMUROAApBaTG2L/tvW/xBT8qmJeyBsplQ7vmk0L2FRTQkMn+CkrUDJo+I9w5ivErfSPBknj3wfi/TDR0QNObbnmhN0t/+kk8pw+8hx3TefQ43iClFYmGZrnygpl4XvbKqpMWptXtvN++9AiH7dDAYY0IeKaEsUwXGQYSiSMgTzugvVHryGkAXWu0Yjwt04ynYVzIeB+wwHu9ctuMYpjMIo19oHndHiK2wwPIk0FvADLrNmNnOJTFzDcyeGJ3zFLT+YkFwlPHn6sAVQN0McNAA7vvjd8TwGKeO5sbgAsG14fIMuH6EhH8ZdkejL18xvzpirndriNlmwtCPODWNS2Q7i7S5nJF8ABikUAjqkufwFZFvNMEZicHwlXJOZ6UBfRlIOK1ASpec4LmIHSrXaytqNPP4ojHDNoOGMEyCrm+RB1DYvyhSwEDKwEiEjX5aCYheRMIkwZEOi57gCiDY5me585J2HqDqDtflh8ONZoYoNsqJCrSifgnZBPGm8GduQQljuANjJWOIiPC40pexC3j5hm8UiwUWO+xXuAArW5fQJYuQnFQuNyp67Koiq6Ioh8FQlJlB8dUn5F2mZdimaYjtytzR7kw2EluH2A7PNMNxnOoYMJSIbP4105dawSL9nOwD4aADh/tIJytWOblTUKtsMXtsvpaiXevB9gHQwFdZ6LG2oYbQ8ThBZ9ku28z5TmbyGvOMyA8OlN0XOTBtb3mcdhSNt/SXswoP0Br/cwY1p7+NfgJe009And7QOdZPVMp917+sn7DNnPkwu0vEwvhNBZZGw1J5xW1bll1JMiBoKQS5wYVDkOnTwJ2EoBoDkepFBAIB1LFvxTSUa9SVXiA6mZXiicHpcFY3kjVn9dXigL7PxiHsoWTtVk/uehcmqxkH3Dshq7eXrCJfBLZbyRft02zjAoz022ZkKfPTEj+7IT7X5AGZ+AkTvfj++PWhE9QcAfwp4R3QkEGemfDAPMry7oTwfhPhnUCD/vbZHhzJ9ksl6arWVMVlaVZtqXm4R2hM7OGBnqMmElzIc1QqPe/YVMGoPavHi+f2HOZ1MLwTzxHs9Rwir9ezvQ+QJ/RazxOuS/WrBn9QCf72saW5cU9fPWY+d7ZvmoV/JxTuNQV/6LXkzvUZ5+OwY2ZqLXH42KNh/1pHwypk3vYJHqgcvIFjL5Hc6n3jgZdIwhTCTWmYJF7tgt1AT4gBsPauqzjl2D1eNPIVtJt2OAYNgvvwWQ2XzsJnWT7Qj/5uPvFQ6/1IN9PtuR/nqu6nys5jjyhA9f831XTn3IWGeSbZuw/Gg5o0tig0HOh7GvanXmHvvkFQWk/xB53034nqX9z58O1/4cGn/wE= \ No newline at end of file diff --git a/docs/verifier_overview.png b/docs/verifier_overview.png new file mode 100644 index 00000000..d5663325 Binary files /dev/null and b/docs/verifier_overview.png differ diff --git a/ent/client.go b/ent/client.go deleted file mode 100644 index 96af00f9..00000000 --- a/ent/client.go +++ /dev/null @@ -1,826 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "fmt" - "log" - - "github.com/fiware/vcverifier/ent/migrate" - - "github.com/fiware/vcverifier/ent/credential" - "github.com/fiware/vcverifier/ent/did" - "github.com/fiware/vcverifier/ent/naturalperson" - "github.com/fiware/vcverifier/ent/privatekey" - "github.com/fiware/vcverifier/ent/publickey" - "github.com/fiware/vcverifier/ent/user" - - "entgo.io/ent/dialect" - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" -) - -// Client is the client that holds all ent builders. -type Client struct { - config - // Schema is the client for creating, migrating and dropping schema. - Schema *migrate.Schema - // Credential is the client for interacting with the Credential builders. - Credential *CredentialClient - // DID is the client for interacting with the DID builders. - DID *DIDClient - // NaturalPerson is the client for interacting with the NaturalPerson builders. - NaturalPerson *NaturalPersonClient - // PrivateKey is the client for interacting with the PrivateKey builders. - PrivateKey *PrivateKeyClient - // PublicKey is the client for interacting with the PublicKey builders. - PublicKey *PublicKeyClient - // User is the client for interacting with the User builders. - User *UserClient -} - -// NewClient creates a new client configured with the given options. -func NewClient(opts ...Option) *Client { - cfg := config{log: log.Println, hooks: &hooks{}} - cfg.options(opts...) - client := &Client{config: cfg} - client.init() - return client -} - -func (c *Client) init() { - c.Schema = migrate.NewSchema(c.driver) - c.Credential = NewCredentialClient(c.config) - c.DID = NewDIDClient(c.config) - c.NaturalPerson = NewNaturalPersonClient(c.config) - c.PrivateKey = NewPrivateKeyClient(c.config) - c.PublicKey = NewPublicKeyClient(c.config) - c.User = NewUserClient(c.config) -} - -// Open opens a database/sql.DB specified by the driver name and -// the data source name, and returns a new client attached to it. -// Optional parameters can be added for configuring the client. -func Open(driverName, dataSourceName string, options ...Option) (*Client, error) { - switch driverName { - case dialect.MySQL, dialect.Postgres, dialect.SQLite: - drv, err := sql.Open(driverName, dataSourceName) - if err != nil { - return nil, err - } - return NewClient(append(options, Driver(drv))...), nil - default: - return nil, fmt.Errorf("unsupported driver: %q", driverName) - } -} - -// Tx returns a new transactional client. The provided context -// is used until the transaction is committed or rolled back. -func (c *Client) Tx(ctx context.Context) (*Tx, error) { - if _, ok := c.driver.(*txDriver); ok { - return nil, fmt.Errorf("ent: cannot start a transaction within a transaction") - } - tx, err := newTx(ctx, c.driver) - if err != nil { - return nil, fmt.Errorf("ent: starting a transaction: %w", err) - } - cfg := c.config - cfg.driver = tx - return &Tx{ - ctx: ctx, - config: cfg, - Credential: NewCredentialClient(cfg), - DID: NewDIDClient(cfg), - NaturalPerson: NewNaturalPersonClient(cfg), - PrivateKey: NewPrivateKeyClient(cfg), - PublicKey: NewPublicKeyClient(cfg), - User: NewUserClient(cfg), - }, nil -} - -// BeginTx returns a transactional client with specified options. -func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) { - if _, ok := c.driver.(*txDriver); ok { - return nil, fmt.Errorf("ent: cannot start a transaction within a transaction") - } - tx, err := c.driver.(interface { - BeginTx(context.Context, *sql.TxOptions) (dialect.Tx, error) - }).BeginTx(ctx, opts) - if err != nil { - return nil, fmt.Errorf("ent: starting a transaction: %w", err) - } - cfg := c.config - cfg.driver = &txDriver{tx: tx, drv: c.driver} - return &Tx{ - ctx: ctx, - config: cfg, - Credential: NewCredentialClient(cfg), - DID: NewDIDClient(cfg), - NaturalPerson: NewNaturalPersonClient(cfg), - PrivateKey: NewPrivateKeyClient(cfg), - PublicKey: NewPublicKeyClient(cfg), - User: NewUserClient(cfg), - }, nil -} - -// Debug returns a new debug-client. It's used to get verbose logging on specific operations. -// -// client.Debug(). -// Credential. -// Query(). -// Count(ctx) -func (c *Client) Debug() *Client { - if c.debug { - return c - } - cfg := c.config - cfg.driver = dialect.Debug(c.driver, c.log) - client := &Client{config: cfg} - client.init() - return client -} - -// Close closes the database connection and prevents new queries from starting. -func (c *Client) Close() error { - return c.driver.Close() -} - -// Use adds the mutation hooks to all the entity clients. -// In order to add hooks to a specific client, call: `client.Node.Use(...)`. -func (c *Client) Use(hooks ...Hook) { - c.Credential.Use(hooks...) - c.DID.Use(hooks...) - c.NaturalPerson.Use(hooks...) - c.PrivateKey.Use(hooks...) - c.PublicKey.Use(hooks...) - c.User.Use(hooks...) -} - -// CredentialClient is a client for the Credential schema. -type CredentialClient struct { - config -} - -// NewCredentialClient returns a client for the Credential from the given config. -func NewCredentialClient(c config) *CredentialClient { - return &CredentialClient{config: c} -} - -// Use adds a list of mutation hooks to the hooks stack. -// A call to `Use(f, g, h)` equals to `credential.Hooks(f(g(h())))`. -func (c *CredentialClient) Use(hooks ...Hook) { - c.hooks.Credential = append(c.hooks.Credential, hooks...) -} - -// Create returns a builder for creating a Credential entity. -func (c *CredentialClient) Create() *CredentialCreate { - mutation := newCredentialMutation(c.config, OpCreate) - return &CredentialCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// CreateBulk returns a builder for creating a bulk of Credential entities. -func (c *CredentialClient) CreateBulk(builders ...*CredentialCreate) *CredentialCreateBulk { - return &CredentialCreateBulk{config: c.config, builders: builders} -} - -// Update returns an update builder for Credential. -func (c *CredentialClient) Update() *CredentialUpdate { - mutation := newCredentialMutation(c.config, OpUpdate) - return &CredentialUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOne returns an update builder for the given entity. -func (c *CredentialClient) UpdateOne(cr *Credential) *CredentialUpdateOne { - mutation := newCredentialMutation(c.config, OpUpdateOne, withCredential(cr)) - return &CredentialUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOneID returns an update builder for the given id. -func (c *CredentialClient) UpdateOneID(id string) *CredentialUpdateOne { - mutation := newCredentialMutation(c.config, OpUpdateOne, withCredentialID(id)) - return &CredentialUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// Delete returns a delete builder for Credential. -func (c *CredentialClient) Delete() *CredentialDelete { - mutation := newCredentialMutation(c.config, OpDelete) - return &CredentialDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// DeleteOne returns a builder for deleting the given entity. -func (c *CredentialClient) DeleteOne(cr *Credential) *CredentialDeleteOne { - return c.DeleteOneID(cr.ID) -} - -// DeleteOne returns a builder for deleting the given entity by its id. -func (c *CredentialClient) DeleteOneID(id string) *CredentialDeleteOne { - builder := c.Delete().Where(credential.ID(id)) - builder.mutation.id = &id - builder.mutation.op = OpDeleteOne - return &CredentialDeleteOne{builder} -} - -// Query returns a query builder for Credential. -func (c *CredentialClient) Query() *CredentialQuery { - return &CredentialQuery{ - config: c.config, - } -} - -// Get returns a Credential entity by its id. -func (c *CredentialClient) Get(ctx context.Context, id string) (*Credential, error) { - return c.Query().Where(credential.ID(id)).Only(ctx) -} - -// GetX is like Get, but panics if an error occurs. -func (c *CredentialClient) GetX(ctx context.Context, id string) *Credential { - obj, err := c.Get(ctx, id) - if err != nil { - panic(err) - } - return obj -} - -// QueryAccount queries the account edge of a Credential. -func (c *CredentialClient) QueryAccount(cr *Credential) *UserQuery { - query := &UserQuery{config: c.config} - query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) { - id := cr.ID - step := sqlgraph.NewStep( - sqlgraph.From(credential.Table, credential.FieldID, id), - sqlgraph.To(user.Table, user.FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, credential.AccountTable, credential.AccountColumn), - ) - fromV = sqlgraph.Neighbors(cr.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// Hooks returns the client hooks. -func (c *CredentialClient) Hooks() []Hook { - return c.hooks.Credential -} - -// DIDClient is a client for the DID schema. -type DIDClient struct { - config -} - -// NewDIDClient returns a client for the DID from the given config. -func NewDIDClient(c config) *DIDClient { - return &DIDClient{config: c} -} - -// Use adds a list of mutation hooks to the hooks stack. -// A call to `Use(f, g, h)` equals to `did.Hooks(f(g(h())))`. -func (c *DIDClient) Use(hooks ...Hook) { - c.hooks.DID = append(c.hooks.DID, hooks...) -} - -// Create returns a builder for creating a DID entity. -func (c *DIDClient) Create() *DIDCreate { - mutation := newDIDMutation(c.config, OpCreate) - return &DIDCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// CreateBulk returns a builder for creating a bulk of DID entities. -func (c *DIDClient) CreateBulk(builders ...*DIDCreate) *DIDCreateBulk { - return &DIDCreateBulk{config: c.config, builders: builders} -} - -// Update returns an update builder for DID. -func (c *DIDClient) Update() *DIDUpdate { - mutation := newDIDMutation(c.config, OpUpdate) - return &DIDUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOne returns an update builder for the given entity. -func (c *DIDClient) UpdateOne(d *DID) *DIDUpdateOne { - mutation := newDIDMutation(c.config, OpUpdateOne, withDID(d)) - return &DIDUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOneID returns an update builder for the given id. -func (c *DIDClient) UpdateOneID(id string) *DIDUpdateOne { - mutation := newDIDMutation(c.config, OpUpdateOne, withDIDID(id)) - return &DIDUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// Delete returns a delete builder for DID. -func (c *DIDClient) Delete() *DIDDelete { - mutation := newDIDMutation(c.config, OpDelete) - return &DIDDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// DeleteOne returns a builder for deleting the given entity. -func (c *DIDClient) DeleteOne(d *DID) *DIDDeleteOne { - return c.DeleteOneID(d.ID) -} - -// DeleteOne returns a builder for deleting the given entity by its id. -func (c *DIDClient) DeleteOneID(id string) *DIDDeleteOne { - builder := c.Delete().Where(did.ID(id)) - builder.mutation.id = &id - builder.mutation.op = OpDeleteOne - return &DIDDeleteOne{builder} -} - -// Query returns a query builder for DID. -func (c *DIDClient) Query() *DIDQuery { - return &DIDQuery{ - config: c.config, - } -} - -// Get returns a DID entity by its id. -func (c *DIDClient) Get(ctx context.Context, id string) (*DID, error) { - return c.Query().Where(did.ID(id)).Only(ctx) -} - -// GetX is like Get, but panics if an error occurs. -func (c *DIDClient) GetX(ctx context.Context, id string) *DID { - obj, err := c.Get(ctx, id) - if err != nil { - panic(err) - } - return obj -} - -// QueryUser queries the user edge of a DID. -func (c *DIDClient) QueryUser(d *DID) *UserQuery { - query := &UserQuery{config: c.config} - query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) { - id := d.ID - step := sqlgraph.NewStep( - sqlgraph.From(did.Table, did.FieldID, id), - sqlgraph.To(user.Table, user.FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, did.UserTable, did.UserColumn), - ) - fromV = sqlgraph.Neighbors(d.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// Hooks returns the client hooks. -func (c *DIDClient) Hooks() []Hook { - return c.hooks.DID -} - -// NaturalPersonClient is a client for the NaturalPerson schema. -type NaturalPersonClient struct { - config -} - -// NewNaturalPersonClient returns a client for the NaturalPerson from the given config. -func NewNaturalPersonClient(c config) *NaturalPersonClient { - return &NaturalPersonClient{config: c} -} - -// Use adds a list of mutation hooks to the hooks stack. -// A call to `Use(f, g, h)` equals to `naturalperson.Hooks(f(g(h())))`. -func (c *NaturalPersonClient) Use(hooks ...Hook) { - c.hooks.NaturalPerson = append(c.hooks.NaturalPerson, hooks...) -} - -// Create returns a builder for creating a NaturalPerson entity. -func (c *NaturalPersonClient) Create() *NaturalPersonCreate { - mutation := newNaturalPersonMutation(c.config, OpCreate) - return &NaturalPersonCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// CreateBulk returns a builder for creating a bulk of NaturalPerson entities. -func (c *NaturalPersonClient) CreateBulk(builders ...*NaturalPersonCreate) *NaturalPersonCreateBulk { - return &NaturalPersonCreateBulk{config: c.config, builders: builders} -} - -// Update returns an update builder for NaturalPerson. -func (c *NaturalPersonClient) Update() *NaturalPersonUpdate { - mutation := newNaturalPersonMutation(c.config, OpUpdate) - return &NaturalPersonUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOne returns an update builder for the given entity. -func (c *NaturalPersonClient) UpdateOne(np *NaturalPerson) *NaturalPersonUpdateOne { - mutation := newNaturalPersonMutation(c.config, OpUpdateOne, withNaturalPerson(np)) - return &NaturalPersonUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOneID returns an update builder for the given id. -func (c *NaturalPersonClient) UpdateOneID(id string) *NaturalPersonUpdateOne { - mutation := newNaturalPersonMutation(c.config, OpUpdateOne, withNaturalPersonID(id)) - return &NaturalPersonUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// Delete returns a delete builder for NaturalPerson. -func (c *NaturalPersonClient) Delete() *NaturalPersonDelete { - mutation := newNaturalPersonMutation(c.config, OpDelete) - return &NaturalPersonDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// DeleteOne returns a builder for deleting the given entity. -func (c *NaturalPersonClient) DeleteOne(np *NaturalPerson) *NaturalPersonDeleteOne { - return c.DeleteOneID(np.ID) -} - -// DeleteOne returns a builder for deleting the given entity by its id. -func (c *NaturalPersonClient) DeleteOneID(id string) *NaturalPersonDeleteOne { - builder := c.Delete().Where(naturalperson.ID(id)) - builder.mutation.id = &id - builder.mutation.op = OpDeleteOne - return &NaturalPersonDeleteOne{builder} -} - -// Query returns a query builder for NaturalPerson. -func (c *NaturalPersonClient) Query() *NaturalPersonQuery { - return &NaturalPersonQuery{ - config: c.config, - } -} - -// Get returns a NaturalPerson entity by its id. -func (c *NaturalPersonClient) Get(ctx context.Context, id string) (*NaturalPerson, error) { - return c.Query().Where(naturalperson.ID(id)).Only(ctx) -} - -// GetX is like Get, but panics if an error occurs. -func (c *NaturalPersonClient) GetX(ctx context.Context, id string) *NaturalPerson { - obj, err := c.Get(ctx, id) - if err != nil { - panic(err) - } - return obj -} - -// QueryKeys queries the keys edge of a NaturalPerson. -func (c *NaturalPersonClient) QueryKeys(np *NaturalPerson) *PrivateKeyQuery { - query := &PrivateKeyQuery{config: c.config} - query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) { - id := np.ID - step := sqlgraph.NewStep( - sqlgraph.From(naturalperson.Table, naturalperson.FieldID, id), - sqlgraph.To(privatekey.Table, privatekey.FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, naturalperson.KeysTable, naturalperson.KeysColumn), - ) - fromV = sqlgraph.Neighbors(np.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// QueryCredentials queries the credentials edge of a NaturalPerson. -func (c *NaturalPersonClient) QueryCredentials(np *NaturalPerson) *CredentialQuery { - query := &CredentialQuery{config: c.config} - query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) { - id := np.ID - step := sqlgraph.NewStep( - sqlgraph.From(naturalperson.Table, naturalperson.FieldID, id), - sqlgraph.To(credential.Table, credential.FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, naturalperson.CredentialsTable, naturalperson.CredentialsColumn), - ) - fromV = sqlgraph.Neighbors(np.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// Hooks returns the client hooks. -func (c *NaturalPersonClient) Hooks() []Hook { - return c.hooks.NaturalPerson -} - -// PrivateKeyClient is a client for the PrivateKey schema. -type PrivateKeyClient struct { - config -} - -// NewPrivateKeyClient returns a client for the PrivateKey from the given config. -func NewPrivateKeyClient(c config) *PrivateKeyClient { - return &PrivateKeyClient{config: c} -} - -// Use adds a list of mutation hooks to the hooks stack. -// A call to `Use(f, g, h)` equals to `privatekey.Hooks(f(g(h())))`. -func (c *PrivateKeyClient) Use(hooks ...Hook) { - c.hooks.PrivateKey = append(c.hooks.PrivateKey, hooks...) -} - -// Create returns a builder for creating a PrivateKey entity. -func (c *PrivateKeyClient) Create() *PrivateKeyCreate { - mutation := newPrivateKeyMutation(c.config, OpCreate) - return &PrivateKeyCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// CreateBulk returns a builder for creating a bulk of PrivateKey entities. -func (c *PrivateKeyClient) CreateBulk(builders ...*PrivateKeyCreate) *PrivateKeyCreateBulk { - return &PrivateKeyCreateBulk{config: c.config, builders: builders} -} - -// Update returns an update builder for PrivateKey. -func (c *PrivateKeyClient) Update() *PrivateKeyUpdate { - mutation := newPrivateKeyMutation(c.config, OpUpdate) - return &PrivateKeyUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOne returns an update builder for the given entity. -func (c *PrivateKeyClient) UpdateOne(pk *PrivateKey) *PrivateKeyUpdateOne { - mutation := newPrivateKeyMutation(c.config, OpUpdateOne, withPrivateKey(pk)) - return &PrivateKeyUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOneID returns an update builder for the given id. -func (c *PrivateKeyClient) UpdateOneID(id string) *PrivateKeyUpdateOne { - mutation := newPrivateKeyMutation(c.config, OpUpdateOne, withPrivateKeyID(id)) - return &PrivateKeyUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// Delete returns a delete builder for PrivateKey. -func (c *PrivateKeyClient) Delete() *PrivateKeyDelete { - mutation := newPrivateKeyMutation(c.config, OpDelete) - return &PrivateKeyDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// DeleteOne returns a builder for deleting the given entity. -func (c *PrivateKeyClient) DeleteOne(pk *PrivateKey) *PrivateKeyDeleteOne { - return c.DeleteOneID(pk.ID) -} - -// DeleteOne returns a builder for deleting the given entity by its id. -func (c *PrivateKeyClient) DeleteOneID(id string) *PrivateKeyDeleteOne { - builder := c.Delete().Where(privatekey.ID(id)) - builder.mutation.id = &id - builder.mutation.op = OpDeleteOne - return &PrivateKeyDeleteOne{builder} -} - -// Query returns a query builder for PrivateKey. -func (c *PrivateKeyClient) Query() *PrivateKeyQuery { - return &PrivateKeyQuery{ - config: c.config, - } -} - -// Get returns a PrivateKey entity by its id. -func (c *PrivateKeyClient) Get(ctx context.Context, id string) (*PrivateKey, error) { - return c.Query().Where(privatekey.ID(id)).Only(ctx) -} - -// GetX is like Get, but panics if an error occurs. -func (c *PrivateKeyClient) GetX(ctx context.Context, id string) *PrivateKey { - obj, err := c.Get(ctx, id) - if err != nil { - panic(err) - } - return obj -} - -// QueryUser queries the user edge of a PrivateKey. -func (c *PrivateKeyClient) QueryUser(pk *PrivateKey) *UserQuery { - query := &UserQuery{config: c.config} - query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) { - id := pk.ID - step := sqlgraph.NewStep( - sqlgraph.From(privatekey.Table, privatekey.FieldID, id), - sqlgraph.To(user.Table, user.FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, privatekey.UserTable, privatekey.UserColumn), - ) - fromV = sqlgraph.Neighbors(pk.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// Hooks returns the client hooks. -func (c *PrivateKeyClient) Hooks() []Hook { - return c.hooks.PrivateKey -} - -// PublicKeyClient is a client for the PublicKey schema. -type PublicKeyClient struct { - config -} - -// NewPublicKeyClient returns a client for the PublicKey from the given config. -func NewPublicKeyClient(c config) *PublicKeyClient { - return &PublicKeyClient{config: c} -} - -// Use adds a list of mutation hooks to the hooks stack. -// A call to `Use(f, g, h)` equals to `publickey.Hooks(f(g(h())))`. -func (c *PublicKeyClient) Use(hooks ...Hook) { - c.hooks.PublicKey = append(c.hooks.PublicKey, hooks...) -} - -// Create returns a builder for creating a PublicKey entity. -func (c *PublicKeyClient) Create() *PublicKeyCreate { - mutation := newPublicKeyMutation(c.config, OpCreate) - return &PublicKeyCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// CreateBulk returns a builder for creating a bulk of PublicKey entities. -func (c *PublicKeyClient) CreateBulk(builders ...*PublicKeyCreate) *PublicKeyCreateBulk { - return &PublicKeyCreateBulk{config: c.config, builders: builders} -} - -// Update returns an update builder for PublicKey. -func (c *PublicKeyClient) Update() *PublicKeyUpdate { - mutation := newPublicKeyMutation(c.config, OpUpdate) - return &PublicKeyUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOne returns an update builder for the given entity. -func (c *PublicKeyClient) UpdateOne(pk *PublicKey) *PublicKeyUpdateOne { - mutation := newPublicKeyMutation(c.config, OpUpdateOne, withPublicKey(pk)) - return &PublicKeyUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOneID returns an update builder for the given id. -func (c *PublicKeyClient) UpdateOneID(id string) *PublicKeyUpdateOne { - mutation := newPublicKeyMutation(c.config, OpUpdateOne, withPublicKeyID(id)) - return &PublicKeyUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// Delete returns a delete builder for PublicKey. -func (c *PublicKeyClient) Delete() *PublicKeyDelete { - mutation := newPublicKeyMutation(c.config, OpDelete) - return &PublicKeyDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// DeleteOne returns a builder for deleting the given entity. -func (c *PublicKeyClient) DeleteOne(pk *PublicKey) *PublicKeyDeleteOne { - return c.DeleteOneID(pk.ID) -} - -// DeleteOne returns a builder for deleting the given entity by its id. -func (c *PublicKeyClient) DeleteOneID(id string) *PublicKeyDeleteOne { - builder := c.Delete().Where(publickey.ID(id)) - builder.mutation.id = &id - builder.mutation.op = OpDeleteOne - return &PublicKeyDeleteOne{builder} -} - -// Query returns a query builder for PublicKey. -func (c *PublicKeyClient) Query() *PublicKeyQuery { - return &PublicKeyQuery{ - config: c.config, - } -} - -// Get returns a PublicKey entity by its id. -func (c *PublicKeyClient) Get(ctx context.Context, id string) (*PublicKey, error) { - return c.Query().Where(publickey.ID(id)).Only(ctx) -} - -// GetX is like Get, but panics if an error occurs. -func (c *PublicKeyClient) GetX(ctx context.Context, id string) *PublicKey { - obj, err := c.Get(ctx, id) - if err != nil { - panic(err) - } - return obj -} - -// Hooks returns the client hooks. -func (c *PublicKeyClient) Hooks() []Hook { - return c.hooks.PublicKey -} - -// UserClient is a client for the User schema. -type UserClient struct { - config -} - -// NewUserClient returns a client for the User from the given config. -func NewUserClient(c config) *UserClient { - return &UserClient{config: c} -} - -// Use adds a list of mutation hooks to the hooks stack. -// A call to `Use(f, g, h)` equals to `user.Hooks(f(g(h())))`. -func (c *UserClient) Use(hooks ...Hook) { - c.hooks.User = append(c.hooks.User, hooks...) -} - -// Create returns a builder for creating a User entity. -func (c *UserClient) Create() *UserCreate { - mutation := newUserMutation(c.config, OpCreate) - return &UserCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// CreateBulk returns a builder for creating a bulk of User entities. -func (c *UserClient) CreateBulk(builders ...*UserCreate) *UserCreateBulk { - return &UserCreateBulk{config: c.config, builders: builders} -} - -// Update returns an update builder for User. -func (c *UserClient) Update() *UserUpdate { - mutation := newUserMutation(c.config, OpUpdate) - return &UserUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOne returns an update builder for the given entity. -func (c *UserClient) UpdateOne(u *User) *UserUpdateOne { - mutation := newUserMutation(c.config, OpUpdateOne, withUser(u)) - return &UserUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOneID returns an update builder for the given id. -func (c *UserClient) UpdateOneID(id string) *UserUpdateOne { - mutation := newUserMutation(c.config, OpUpdateOne, withUserID(id)) - return &UserUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// Delete returns a delete builder for User. -func (c *UserClient) Delete() *UserDelete { - mutation := newUserMutation(c.config, OpDelete) - return &UserDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// DeleteOne returns a builder for deleting the given entity. -func (c *UserClient) DeleteOne(u *User) *UserDeleteOne { - return c.DeleteOneID(u.ID) -} - -// DeleteOne returns a builder for deleting the given entity by its id. -func (c *UserClient) DeleteOneID(id string) *UserDeleteOne { - builder := c.Delete().Where(user.ID(id)) - builder.mutation.id = &id - builder.mutation.op = OpDeleteOne - return &UserDeleteOne{builder} -} - -// Query returns a query builder for User. -func (c *UserClient) Query() *UserQuery { - return &UserQuery{ - config: c.config, - } -} - -// Get returns a User entity by its id. -func (c *UserClient) Get(ctx context.Context, id string) (*User, error) { - return c.Query().Where(user.ID(id)).Only(ctx) -} - -// GetX is like Get, but panics if an error occurs. -func (c *UserClient) GetX(ctx context.Context, id string) *User { - obj, err := c.Get(ctx, id) - if err != nil { - panic(err) - } - return obj -} - -// QueryKeys queries the keys edge of a User. -func (c *UserClient) QueryKeys(u *User) *PrivateKeyQuery { - query := &PrivateKeyQuery{config: c.config} - query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) { - id := u.ID - step := sqlgraph.NewStep( - sqlgraph.From(user.Table, user.FieldID, id), - sqlgraph.To(privatekey.Table, privatekey.FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, user.KeysTable, user.KeysColumn), - ) - fromV = sqlgraph.Neighbors(u.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// QueryDids queries the dids edge of a User. -func (c *UserClient) QueryDids(u *User) *DIDQuery { - query := &DIDQuery{config: c.config} - query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) { - id := u.ID - step := sqlgraph.NewStep( - sqlgraph.From(user.Table, user.FieldID, id), - sqlgraph.To(did.Table, did.FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, user.DidsTable, user.DidsColumn), - ) - fromV = sqlgraph.Neighbors(u.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// QueryCredentials queries the credentials edge of a User. -func (c *UserClient) QueryCredentials(u *User) *CredentialQuery { - query := &CredentialQuery{config: c.config} - query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) { - id := u.ID - step := sqlgraph.NewStep( - sqlgraph.From(user.Table, user.FieldID, id), - sqlgraph.To(credential.Table, credential.FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, user.CredentialsTable, user.CredentialsColumn), - ) - fromV = sqlgraph.Neighbors(u.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// Hooks returns the client hooks. -func (c *UserClient) Hooks() []Hook { - return c.hooks.User -} diff --git a/ent/config.go b/ent/config.go deleted file mode 100644 index 46a8d5a1..00000000 --- a/ent/config.go +++ /dev/null @@ -1,64 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "entgo.io/ent" - "entgo.io/ent/dialect" -) - -// Option function to configure the client. -type Option func(*config) - -// Config is the configuration for the client and its builder. -type config struct { - // driver used for executing database requests. - driver dialect.Driver - // debug enable a debug logging. - debug bool - // log used for logging on debug mode. - log func(...interface{}) - // hooks to execute on mutations. - hooks *hooks -} - -// hooks per client, for fast access. -type hooks struct { - Credential []ent.Hook - DID []ent.Hook - NaturalPerson []ent.Hook - PrivateKey []ent.Hook - PublicKey []ent.Hook - User []ent.Hook -} - -// Options applies the options on the config object. -func (c *config) options(opts ...Option) { - for _, opt := range opts { - opt(c) - } - if c.debug { - c.driver = dialect.Debug(c.driver, c.log) - } -} - -// Debug enables debug logging on the ent.Driver. -func Debug() Option { - return func(c *config) { - c.debug = true - } -} - -// Log sets the logging function for debug mode. -func Log(fn func(...interface{})) Option { - return func(c *config) { - c.log = fn - } -} - -// Driver configures the client driver. -func Driver(driver dialect.Driver) Option { - return func(c *config) { - c.driver = driver - } -} diff --git a/ent/context.go b/ent/context.go deleted file mode 100644 index 7811bfa2..00000000 --- a/ent/context.go +++ /dev/null @@ -1,33 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" -) - -type clientCtxKey struct{} - -// FromContext returns a Client stored inside a context, or nil if there isn't one. -func FromContext(ctx context.Context) *Client { - c, _ := ctx.Value(clientCtxKey{}).(*Client) - return c -} - -// NewContext returns a new context with the given Client attached. -func NewContext(parent context.Context, c *Client) context.Context { - return context.WithValue(parent, clientCtxKey{}, c) -} - -type txCtxKey struct{} - -// TxFromContext returns a Tx stored inside a context, or nil if there isn't one. -func TxFromContext(ctx context.Context) *Tx { - tx, _ := ctx.Value(txCtxKey{}).(*Tx) - return tx -} - -// NewTxContext returns a new context with the given Tx attached. -func NewTxContext(parent context.Context, tx *Tx) context.Context { - return context.WithValue(parent, txCtxKey{}, tx) -} diff --git a/ent/credential.go b/ent/credential.go deleted file mode 100644 index e5ae7713..00000000 --- a/ent/credential.go +++ /dev/null @@ -1,190 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "encoding/json" - "fmt" - "strings" - "time" - - "entgo.io/ent/dialect/sql" - "github.com/fiware/vcverifier/ent/credential" - "github.com/fiware/vcverifier/ent/user" -) - -// Credential is the model entity for the Credential schema. -type Credential struct { - config `json:"-"` - // ID of the ent. - ID string `json:"id,omitempty"` - // Type holds the value of the "type" field. - Type string `json:"type,omitempty"` - // Raw holds the value of the "raw" field. - Raw []uint8 `json:"raw,omitempty"` - // CreatedAt holds the value of the "created_at" field. - CreatedAt time.Time `json:"created_at,omitempty"` - // UpdatedAt holds the value of the "updated_at" field. - UpdatedAt time.Time `json:"updated_at,omitempty"` - // Edges holds the relations/edges for other nodes in the graph. - // The values are being populated by the CredentialQuery when eager-loading is set. - Edges CredentialEdges `json:"edges"` - natural_person_credentials *string - user_credentials *string -} - -// CredentialEdges holds the relations/edges for other nodes in the graph. -type CredentialEdges struct { - // Account holds the value of the account edge. - Account *User `json:"account,omitempty"` - // loadedTypes holds the information for reporting if a - // type was loaded (or requested) in eager-loading or not. - loadedTypes [1]bool -} - -// AccountOrErr returns the Account value or an error if the edge -// was not loaded in eager-loading, or loaded but was not found. -func (e CredentialEdges) AccountOrErr() (*User, error) { - if e.loadedTypes[0] { - if e.Account == nil { - // The edge account was loaded in eager-loading, - // but was not found. - return nil, &NotFoundError{label: user.Label} - } - return e.Account, nil - } - return nil, &NotLoadedError{edge: "account"} -} - -// scanValues returns the types for scanning values from sql.Rows. -func (*Credential) scanValues(columns []string) ([]interface{}, error) { - values := make([]interface{}, len(columns)) - for i := range columns { - switch columns[i] { - case credential.FieldRaw: - values[i] = new([]byte) - case credential.FieldID, credential.FieldType: - values[i] = new(sql.NullString) - case credential.FieldCreatedAt, credential.FieldUpdatedAt: - values[i] = new(sql.NullTime) - case credential.ForeignKeys[0]: // natural_person_credentials - values[i] = new(sql.NullString) - case credential.ForeignKeys[1]: // user_credentials - values[i] = new(sql.NullString) - default: - return nil, fmt.Errorf("unexpected column %q for type Credential", columns[i]) - } - } - return values, nil -} - -// assignValues assigns the values that were returned from sql.Rows (after scanning) -// to the Credential fields. -func (c *Credential) assignValues(columns []string, values []interface{}) error { - if m, n := len(values), len(columns); m < n { - return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) - } - for i := range columns { - switch columns[i] { - case credential.FieldID: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field id", values[i]) - } else if value.Valid { - c.ID = value.String - } - case credential.FieldType: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field type", values[i]) - } else if value.Valid { - c.Type = value.String - } - case credential.FieldRaw: - if value, ok := values[i].(*[]byte); !ok { - return fmt.Errorf("unexpected type %T for field raw", values[i]) - } else if value != nil && len(*value) > 0 { - if err := json.Unmarshal(*value, &c.Raw); err != nil { - return fmt.Errorf("unmarshal field raw: %w", err) - } - } - case credential.FieldCreatedAt: - if value, ok := values[i].(*sql.NullTime); !ok { - return fmt.Errorf("unexpected type %T for field created_at", values[i]) - } else if value.Valid { - c.CreatedAt = value.Time - } - case credential.FieldUpdatedAt: - if value, ok := values[i].(*sql.NullTime); !ok { - return fmt.Errorf("unexpected type %T for field updated_at", values[i]) - } else if value.Valid { - c.UpdatedAt = value.Time - } - case credential.ForeignKeys[0]: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field natural_person_credentials", values[i]) - } else if value.Valid { - c.natural_person_credentials = new(string) - *c.natural_person_credentials = value.String - } - case credential.ForeignKeys[1]: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field user_credentials", values[i]) - } else if value.Valid { - c.user_credentials = new(string) - *c.user_credentials = value.String - } - } - } - return nil -} - -// QueryAccount queries the "account" edge of the Credential entity. -func (c *Credential) QueryAccount() *UserQuery { - return (&CredentialClient{config: c.config}).QueryAccount(c) -} - -// Update returns a builder for updating this Credential. -// Note that you need to call Credential.Unwrap() before calling this method if this Credential -// was returned from a transaction, and the transaction was committed or rolled back. -func (c *Credential) Update() *CredentialUpdateOne { - return (&CredentialClient{config: c.config}).UpdateOne(c) -} - -// Unwrap unwraps the Credential entity that was returned from a transaction after it was closed, -// so that all future queries will be executed through the driver which created the transaction. -func (c *Credential) Unwrap() *Credential { - _tx, ok := c.config.driver.(*txDriver) - if !ok { - panic("ent: Credential is not a transactional entity") - } - c.config.driver = _tx.drv - return c -} - -// String implements the fmt.Stringer. -func (c *Credential) String() string { - var builder strings.Builder - builder.WriteString("Credential(") - builder.WriteString(fmt.Sprintf("id=%v, ", c.ID)) - builder.WriteString("type=") - builder.WriteString(c.Type) - builder.WriteString(", ") - builder.WriteString("raw=") - builder.WriteString(fmt.Sprintf("%v", c.Raw)) - builder.WriteString(", ") - builder.WriteString("created_at=") - builder.WriteString(c.CreatedAt.Format(time.ANSIC)) - builder.WriteString(", ") - builder.WriteString("updated_at=") - builder.WriteString(c.UpdatedAt.Format(time.ANSIC)) - builder.WriteByte(')') - return builder.String() -} - -// Credentials is a parsable slice of Credential. -type Credentials []*Credential - -func (c Credentials) config(cfg config) { - for _i := range c { - c[_i].config = cfg - } -} diff --git a/ent/credential/credential.go b/ent/credential/credential.go deleted file mode 100644 index 668b15a8..00000000 --- a/ent/credential/credential.go +++ /dev/null @@ -1,73 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package credential - -import ( - "time" -) - -const ( - // Label holds the string label denoting the credential type in the database. - Label = "credential" - // FieldID holds the string denoting the id field in the database. - FieldID = "id" - // FieldType holds the string denoting the type field in the database. - FieldType = "type" - // FieldRaw holds the string denoting the raw field in the database. - FieldRaw = "raw" - // FieldCreatedAt holds the string denoting the created_at field in the database. - FieldCreatedAt = "created_at" - // FieldUpdatedAt holds the string denoting the updated_at field in the database. - FieldUpdatedAt = "updated_at" - // EdgeAccount holds the string denoting the account edge name in mutations. - EdgeAccount = "account" - // Table holds the table name of the credential in the database. - Table = "credentials" - // AccountTable is the table that holds the account relation/edge. - AccountTable = "credentials" - // AccountInverseTable is the table name for the User entity. - // It exists in this package in order to avoid circular dependency with the "user" package. - AccountInverseTable = "users" - // AccountColumn is the table column denoting the account relation/edge. - AccountColumn = "user_credentials" -) - -// Columns holds all SQL columns for credential fields. -var Columns = []string{ - FieldID, - FieldType, - FieldRaw, - FieldCreatedAt, - FieldUpdatedAt, -} - -// ForeignKeys holds the SQL foreign-keys that are owned by the "credentials" -// table and are not defined as standalone fields in the schema. -var ForeignKeys = []string{ - "natural_person_credentials", - "user_credentials", -} - -// ValidColumn reports if the column name is valid (part of the table columns). -func ValidColumn(column string) bool { - for i := range Columns { - if column == Columns[i] { - return true - } - } - for i := range ForeignKeys { - if column == ForeignKeys[i] { - return true - } - } - return false -} - -var ( - // DefaultType holds the default value on creation for the "type" field. - DefaultType string - // DefaultCreatedAt holds the default value on creation for the "created_at" field. - DefaultCreatedAt func() time.Time - // DefaultUpdatedAt holds the default value on creation for the "updated_at" field. - DefaultUpdatedAt func() time.Time -) diff --git a/ent/credential/where.go b/ent/credential/where.go deleted file mode 100644 index e08db51b..00000000 --- a/ent/credential/where.go +++ /dev/null @@ -1,426 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package credential - -import ( - "time" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "github.com/fiware/vcverifier/ent/predicate" -) - -// ID filters vertices based on their ID field. -func ID(id string) predicate.Credential { - return predicate.Credential(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldID), id)) - }) -} - -// IDEQ applies the EQ predicate on the ID field. -func IDEQ(id string) predicate.Credential { - return predicate.Credential(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldID), id)) - }) -} - -// IDNEQ applies the NEQ predicate on the ID field. -func IDNEQ(id string) predicate.Credential { - return predicate.Credential(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldID), id)) - }) -} - -// IDIn applies the In predicate on the ID field. -func IDIn(ids ...string) predicate.Credential { - return predicate.Credential(func(s *sql.Selector) { - v := make([]interface{}, len(ids)) - for i := range v { - v[i] = ids[i] - } - s.Where(sql.In(s.C(FieldID), v...)) - }) -} - -// IDNotIn applies the NotIn predicate on the ID field. -func IDNotIn(ids ...string) predicate.Credential { - return predicate.Credential(func(s *sql.Selector) { - v := make([]interface{}, len(ids)) - for i := range v { - v[i] = ids[i] - } - s.Where(sql.NotIn(s.C(FieldID), v...)) - }) -} - -// IDGT applies the GT predicate on the ID field. -func IDGT(id string) predicate.Credential { - return predicate.Credential(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldID), id)) - }) -} - -// IDGTE applies the GTE predicate on the ID field. -func IDGTE(id string) predicate.Credential { - return predicate.Credential(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldID), id)) - }) -} - -// IDLT applies the LT predicate on the ID field. -func IDLT(id string) predicate.Credential { - return predicate.Credential(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldID), id)) - }) -} - -// IDLTE applies the LTE predicate on the ID field. -func IDLTE(id string) predicate.Credential { - return predicate.Credential(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldID), id)) - }) -} - -// Type applies equality check predicate on the "type" field. It's identical to TypeEQ. -func Type(v string) predicate.Credential { - return predicate.Credential(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldType), v)) - }) -} - -// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. -func CreatedAt(v time.Time) predicate.Credential { - return predicate.Credential(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldCreatedAt), v)) - }) -} - -// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ. -func UpdatedAt(v time.Time) predicate.Credential { - return predicate.Credential(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldUpdatedAt), v)) - }) -} - -// TypeEQ applies the EQ predicate on the "type" field. -func TypeEQ(v string) predicate.Credential { - return predicate.Credential(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldType), v)) - }) -} - -// TypeNEQ applies the NEQ predicate on the "type" field. -func TypeNEQ(v string) predicate.Credential { - return predicate.Credential(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldType), v)) - }) -} - -// TypeIn applies the In predicate on the "type" field. -func TypeIn(vs ...string) predicate.Credential { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Credential(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldType), v...)) - }) -} - -// TypeNotIn applies the NotIn predicate on the "type" field. -func TypeNotIn(vs ...string) predicate.Credential { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Credential(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldType), v...)) - }) -} - -// TypeGT applies the GT predicate on the "type" field. -func TypeGT(v string) predicate.Credential { - return predicate.Credential(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldType), v)) - }) -} - -// TypeGTE applies the GTE predicate on the "type" field. -func TypeGTE(v string) predicate.Credential { - return predicate.Credential(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldType), v)) - }) -} - -// TypeLT applies the LT predicate on the "type" field. -func TypeLT(v string) predicate.Credential { - return predicate.Credential(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldType), v)) - }) -} - -// TypeLTE applies the LTE predicate on the "type" field. -func TypeLTE(v string) predicate.Credential { - return predicate.Credential(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldType), v)) - }) -} - -// TypeContains applies the Contains predicate on the "type" field. -func TypeContains(v string) predicate.Credential { - return predicate.Credential(func(s *sql.Selector) { - s.Where(sql.Contains(s.C(FieldType), v)) - }) -} - -// TypeHasPrefix applies the HasPrefix predicate on the "type" field. -func TypeHasPrefix(v string) predicate.Credential { - return predicate.Credential(func(s *sql.Selector) { - s.Where(sql.HasPrefix(s.C(FieldType), v)) - }) -} - -// TypeHasSuffix applies the HasSuffix predicate on the "type" field. -func TypeHasSuffix(v string) predicate.Credential { - return predicate.Credential(func(s *sql.Selector) { - s.Where(sql.HasSuffix(s.C(FieldType), v)) - }) -} - -// TypeEqualFold applies the EqualFold predicate on the "type" field. -func TypeEqualFold(v string) predicate.Credential { - return predicate.Credential(func(s *sql.Selector) { - s.Where(sql.EqualFold(s.C(FieldType), v)) - }) -} - -// TypeContainsFold applies the ContainsFold predicate on the "type" field. -func TypeContainsFold(v string) predicate.Credential { - return predicate.Credential(func(s *sql.Selector) { - s.Where(sql.ContainsFold(s.C(FieldType), v)) - }) -} - -// CreatedAtEQ applies the EQ predicate on the "created_at" field. -func CreatedAtEQ(v time.Time) predicate.Credential { - return predicate.Credential(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldCreatedAt), v)) - }) -} - -// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. -func CreatedAtNEQ(v time.Time) predicate.Credential { - return predicate.Credential(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldCreatedAt), v)) - }) -} - -// CreatedAtIn applies the In predicate on the "created_at" field. -func CreatedAtIn(vs ...time.Time) predicate.Credential { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Credential(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldCreatedAt), v...)) - }) -} - -// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. -func CreatedAtNotIn(vs ...time.Time) predicate.Credential { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Credential(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldCreatedAt), v...)) - }) -} - -// CreatedAtGT applies the GT predicate on the "created_at" field. -func CreatedAtGT(v time.Time) predicate.Credential { - return predicate.Credential(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldCreatedAt), v)) - }) -} - -// CreatedAtGTE applies the GTE predicate on the "created_at" field. -func CreatedAtGTE(v time.Time) predicate.Credential { - return predicate.Credential(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldCreatedAt), v)) - }) -} - -// CreatedAtLT applies the LT predicate on the "created_at" field. -func CreatedAtLT(v time.Time) predicate.Credential { - return predicate.Credential(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldCreatedAt), v)) - }) -} - -// CreatedAtLTE applies the LTE predicate on the "created_at" field. -func CreatedAtLTE(v time.Time) predicate.Credential { - return predicate.Credential(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldCreatedAt), v)) - }) -} - -// UpdatedAtEQ applies the EQ predicate on the "updated_at" field. -func UpdatedAtEQ(v time.Time) predicate.Credential { - return predicate.Credential(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldUpdatedAt), v)) - }) -} - -// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field. -func UpdatedAtNEQ(v time.Time) predicate.Credential { - return predicate.Credential(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldUpdatedAt), v)) - }) -} - -// UpdatedAtIn applies the In predicate on the "updated_at" field. -func UpdatedAtIn(vs ...time.Time) predicate.Credential { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Credential(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldUpdatedAt), v...)) - }) -} - -// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field. -func UpdatedAtNotIn(vs ...time.Time) predicate.Credential { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Credential(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldUpdatedAt), v...)) - }) -} - -// UpdatedAtGT applies the GT predicate on the "updated_at" field. -func UpdatedAtGT(v time.Time) predicate.Credential { - return predicate.Credential(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldUpdatedAt), v)) - }) -} - -// UpdatedAtGTE applies the GTE predicate on the "updated_at" field. -func UpdatedAtGTE(v time.Time) predicate.Credential { - return predicate.Credential(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldUpdatedAt), v)) - }) -} - -// UpdatedAtLT applies the LT predicate on the "updated_at" field. -func UpdatedAtLT(v time.Time) predicate.Credential { - return predicate.Credential(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldUpdatedAt), v)) - }) -} - -// UpdatedAtLTE applies the LTE predicate on the "updated_at" field. -func UpdatedAtLTE(v time.Time) predicate.Credential { - return predicate.Credential(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldUpdatedAt), v)) - }) -} - -// HasAccount applies the HasEdge predicate on the "account" edge. -func HasAccount() predicate.Credential { - return predicate.Credential(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(AccountTable, FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, AccountTable, AccountColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasAccountWith applies the HasEdge predicate on the "account" edge with a given conditions (other predicates). -func HasAccountWith(preds ...predicate.User) predicate.Credential { - return predicate.Credential(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(AccountInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, AccountTable, AccountColumn), - ) - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// And groups predicates with the AND operator between them. -func And(predicates ...predicate.Credential) predicate.Credential { - return predicate.Credential(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) -} - -// Or groups predicates with the OR operator between them. -func Or(predicates ...predicate.Credential) predicate.Credential { - return predicate.Credential(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) -} - -// Not applies the not operator on the given predicate. -func Not(p predicate.Credential) predicate.Credential { - return predicate.Credential(func(s *sql.Selector) { - p(s.Not()) - }) -} diff --git a/ent/credential_create.go b/ent/credential_create.go deleted file mode 100644 index 4210ed92..00000000 --- a/ent/credential_create.go +++ /dev/null @@ -1,371 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - "time" - - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/fiware/vcverifier/ent/credential" - "github.com/fiware/vcverifier/ent/user" -) - -// CredentialCreate is the builder for creating a Credential entity. -type CredentialCreate struct { - config - mutation *CredentialMutation - hooks []Hook -} - -// SetType sets the "type" field. -func (cc *CredentialCreate) SetType(s string) *CredentialCreate { - cc.mutation.SetType(s) - return cc -} - -// SetNillableType sets the "type" field if the given value is not nil. -func (cc *CredentialCreate) SetNillableType(s *string) *CredentialCreate { - if s != nil { - cc.SetType(*s) - } - return cc -} - -// SetRaw sets the "raw" field. -func (cc *CredentialCreate) SetRaw(u []uint8) *CredentialCreate { - cc.mutation.SetRaw(u) - return cc -} - -// SetCreatedAt sets the "created_at" field. -func (cc *CredentialCreate) SetCreatedAt(t time.Time) *CredentialCreate { - cc.mutation.SetCreatedAt(t) - return cc -} - -// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. -func (cc *CredentialCreate) SetNillableCreatedAt(t *time.Time) *CredentialCreate { - if t != nil { - cc.SetCreatedAt(*t) - } - return cc -} - -// SetUpdatedAt sets the "updated_at" field. -func (cc *CredentialCreate) SetUpdatedAt(t time.Time) *CredentialCreate { - cc.mutation.SetUpdatedAt(t) - return cc -} - -// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. -func (cc *CredentialCreate) SetNillableUpdatedAt(t *time.Time) *CredentialCreate { - if t != nil { - cc.SetUpdatedAt(*t) - } - return cc -} - -// SetID sets the "id" field. -func (cc *CredentialCreate) SetID(s string) *CredentialCreate { - cc.mutation.SetID(s) - return cc -} - -// SetAccountID sets the "account" edge to the User entity by ID. -func (cc *CredentialCreate) SetAccountID(id string) *CredentialCreate { - cc.mutation.SetAccountID(id) - return cc -} - -// SetNillableAccountID sets the "account" edge to the User entity by ID if the given value is not nil. -func (cc *CredentialCreate) SetNillableAccountID(id *string) *CredentialCreate { - if id != nil { - cc = cc.SetAccountID(*id) - } - return cc -} - -// SetAccount sets the "account" edge to the User entity. -func (cc *CredentialCreate) SetAccount(u *User) *CredentialCreate { - return cc.SetAccountID(u.ID) -} - -// Mutation returns the CredentialMutation object of the builder. -func (cc *CredentialCreate) Mutation() *CredentialMutation { - return cc.mutation -} - -// Save creates the Credential in the database. -func (cc *CredentialCreate) Save(ctx context.Context) (*Credential, error) { - var ( - err error - node *Credential - ) - cc.defaults() - if len(cc.hooks) == 0 { - if err = cc.check(); err != nil { - return nil, err - } - node, err = cc.sqlSave(ctx) - } else { - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*CredentialMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - if err = cc.check(); err != nil { - return nil, err - } - cc.mutation = mutation - if node, err = cc.sqlSave(ctx); err != nil { - return nil, err - } - mutation.id = &node.ID - mutation.done = true - return node, err - }) - for i := len(cc.hooks) - 1; i >= 0; i-- { - if cc.hooks[i] == nil { - return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") - } - mut = cc.hooks[i](mut) - } - v, err := mut.Mutate(ctx, cc.mutation) - if err != nil { - return nil, err - } - nv, ok := v.(*Credential) - if !ok { - return nil, fmt.Errorf("unexpected node type %T returned from CredentialMutation", v) - } - node = nv - } - return node, err -} - -// SaveX calls Save and panics if Save returns an error. -func (cc *CredentialCreate) SaveX(ctx context.Context) *Credential { - v, err := cc.Save(ctx) - if err != nil { - panic(err) - } - return v -} - -// Exec executes the query. -func (cc *CredentialCreate) Exec(ctx context.Context) error { - _, err := cc.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (cc *CredentialCreate) ExecX(ctx context.Context) { - if err := cc.Exec(ctx); err != nil { - panic(err) - } -} - -// defaults sets the default values of the builder before save. -func (cc *CredentialCreate) defaults() { - if _, ok := cc.mutation.GetType(); !ok { - v := credential.DefaultType - cc.mutation.SetType(v) - } - if _, ok := cc.mutation.CreatedAt(); !ok { - v := credential.DefaultCreatedAt() - cc.mutation.SetCreatedAt(v) - } - if _, ok := cc.mutation.UpdatedAt(); !ok { - v := credential.DefaultUpdatedAt() - cc.mutation.SetUpdatedAt(v) - } -} - -// check runs all checks and user-defined validators on the builder. -func (cc *CredentialCreate) check() error { - if _, ok := cc.mutation.GetType(); !ok { - return &ValidationError{Name: "type", err: errors.New(`ent: missing required field "Credential.type"`)} - } - if _, ok := cc.mutation.Raw(); !ok { - return &ValidationError{Name: "raw", err: errors.New(`ent: missing required field "Credential.raw"`)} - } - if _, ok := cc.mutation.CreatedAt(); !ok { - return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Credential.created_at"`)} - } - if _, ok := cc.mutation.UpdatedAt(); !ok { - return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Credential.updated_at"`)} - } - return nil -} - -func (cc *CredentialCreate) sqlSave(ctx context.Context) (*Credential, error) { - _node, _spec := cc.createSpec() - if err := sqlgraph.CreateNode(ctx, cc.driver, _spec); err != nil { - if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return nil, err - } - if _spec.ID.Value != nil { - if id, ok := _spec.ID.Value.(string); ok { - _node.ID = id - } else { - return nil, fmt.Errorf("unexpected Credential.ID type: %T", _spec.ID.Value) - } - } - return _node, nil -} - -func (cc *CredentialCreate) createSpec() (*Credential, *sqlgraph.CreateSpec) { - var ( - _node = &Credential{config: cc.config} - _spec = &sqlgraph.CreateSpec{ - Table: credential.Table, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: credential.FieldID, - }, - } - ) - if id, ok := cc.mutation.ID(); ok { - _node.ID = id - _spec.ID.Value = id - } - if value, ok := cc.mutation.GetType(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeString, - Value: value, - Column: credential.FieldType, - }) - _node.Type = value - } - if value, ok := cc.mutation.Raw(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeJSON, - Value: value, - Column: credential.FieldRaw, - }) - _node.Raw = value - } - if value, ok := cc.mutation.CreatedAt(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeTime, - Value: value, - Column: credential.FieldCreatedAt, - }) - _node.CreatedAt = value - } - if value, ok := cc.mutation.UpdatedAt(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeTime, - Value: value, - Column: credential.FieldUpdatedAt, - }) - _node.UpdatedAt = value - } - if nodes := cc.mutation.AccountIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: true, - Table: credential.AccountTable, - Columns: []string{credential.AccountColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: user.FieldID, - }, - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _node.user_credentials = &nodes[0] - _spec.Edges = append(_spec.Edges, edge) - } - return _node, _spec -} - -// CredentialCreateBulk is the builder for creating many Credential entities in bulk. -type CredentialCreateBulk struct { - config - builders []*CredentialCreate -} - -// Save creates the Credential entities in the database. -func (ccb *CredentialCreateBulk) Save(ctx context.Context) ([]*Credential, error) { - specs := make([]*sqlgraph.CreateSpec, len(ccb.builders)) - nodes := make([]*Credential, len(ccb.builders)) - mutators := make([]Mutator, len(ccb.builders)) - for i := range ccb.builders { - func(i int, root context.Context) { - builder := ccb.builders[i] - builder.defaults() - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*CredentialMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - if err := builder.check(); err != nil { - return nil, err - } - builder.mutation = mutation - nodes[i], specs[i] = builder.createSpec() - var err error - if i < len(mutators)-1 { - _, err = mutators[i+1].Mutate(root, ccb.builders[i+1].mutation) - } else { - spec := &sqlgraph.BatchCreateSpec{Nodes: specs} - // Invoke the actual operation on the latest mutation in the chain. - if err = sqlgraph.BatchCreate(ctx, ccb.driver, spec); err != nil { - if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - } - } - if err != nil { - return nil, err - } - mutation.id = &nodes[i].ID - mutation.done = true - return nodes[i], nil - }) - for i := len(builder.hooks) - 1; i >= 0; i-- { - mut = builder.hooks[i](mut) - } - mutators[i] = mut - }(i, ctx) - } - if len(mutators) > 0 { - if _, err := mutators[0].Mutate(ctx, ccb.builders[0].mutation); err != nil { - return nil, err - } - } - return nodes, nil -} - -// SaveX is like Save, but panics if an error occurs. -func (ccb *CredentialCreateBulk) SaveX(ctx context.Context) []*Credential { - v, err := ccb.Save(ctx) - if err != nil { - panic(err) - } - return v -} - -// Exec executes the query. -func (ccb *CredentialCreateBulk) Exec(ctx context.Context) error { - _, err := ccb.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (ccb *CredentialCreateBulk) ExecX(ctx context.Context) { - if err := ccb.Exec(ctx); err != nil { - panic(err) - } -} diff --git a/ent/credential_delete.go b/ent/credential_delete.go deleted file mode 100644 index e18e9220..00000000 --- a/ent/credential_delete.go +++ /dev/null @@ -1,115 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "fmt" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/fiware/vcverifier/ent/credential" - "github.com/fiware/vcverifier/ent/predicate" -) - -// CredentialDelete is the builder for deleting a Credential entity. -type CredentialDelete struct { - config - hooks []Hook - mutation *CredentialMutation -} - -// Where appends a list predicates to the CredentialDelete builder. -func (cd *CredentialDelete) Where(ps ...predicate.Credential) *CredentialDelete { - cd.mutation.Where(ps...) - return cd -} - -// Exec executes the deletion query and returns how many vertices were deleted. -func (cd *CredentialDelete) Exec(ctx context.Context) (int, error) { - var ( - err error - affected int - ) - if len(cd.hooks) == 0 { - affected, err = cd.sqlExec(ctx) - } else { - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*CredentialMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - cd.mutation = mutation - affected, err = cd.sqlExec(ctx) - mutation.done = true - return affected, err - }) - for i := len(cd.hooks) - 1; i >= 0; i-- { - if cd.hooks[i] == nil { - return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") - } - mut = cd.hooks[i](mut) - } - if _, err := mut.Mutate(ctx, cd.mutation); err != nil { - return 0, err - } - } - return affected, err -} - -// ExecX is like Exec, but panics if an error occurs. -func (cd *CredentialDelete) ExecX(ctx context.Context) int { - n, err := cd.Exec(ctx) - if err != nil { - panic(err) - } - return n -} - -func (cd *CredentialDelete) sqlExec(ctx context.Context) (int, error) { - _spec := &sqlgraph.DeleteSpec{ - Node: &sqlgraph.NodeSpec{ - Table: credential.Table, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: credential.FieldID, - }, - }, - } - if ps := cd.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - affected, err := sqlgraph.DeleteNodes(ctx, cd.driver, _spec) - if err != nil && sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return affected, err -} - -// CredentialDeleteOne is the builder for deleting a single Credential entity. -type CredentialDeleteOne struct { - cd *CredentialDelete -} - -// Exec executes the deletion query. -func (cdo *CredentialDeleteOne) Exec(ctx context.Context) error { - n, err := cdo.cd.Exec(ctx) - switch { - case err != nil: - return err - case n == 0: - return &NotFoundError{credential.Label} - default: - return nil - } -} - -// ExecX is like Exec, but panics if an error occurs. -func (cdo *CredentialDeleteOne) ExecX(ctx context.Context) { - cdo.cd.ExecX(ctx) -} diff --git a/ent/credential_query.go b/ent/credential_query.go deleted file mode 100644 index 3d1f7d3e..00000000 --- a/ent/credential_query.go +++ /dev/null @@ -1,605 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "fmt" - "math" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/fiware/vcverifier/ent/credential" - "github.com/fiware/vcverifier/ent/predicate" - "github.com/fiware/vcverifier/ent/user" -) - -// CredentialQuery is the builder for querying Credential entities. -type CredentialQuery struct { - config - limit *int - offset *int - unique *bool - order []OrderFunc - fields []string - predicates []predicate.Credential - // eager-loading edges. - withAccount *UserQuery - withFKs bool - // intermediate query (i.e. traversal path). - sql *sql.Selector - path func(context.Context) (*sql.Selector, error) -} - -// Where adds a new predicate for the CredentialQuery builder. -func (cq *CredentialQuery) Where(ps ...predicate.Credential) *CredentialQuery { - cq.predicates = append(cq.predicates, ps...) - return cq -} - -// Limit adds a limit step to the query. -func (cq *CredentialQuery) Limit(limit int) *CredentialQuery { - cq.limit = &limit - return cq -} - -// Offset adds an offset step to the query. -func (cq *CredentialQuery) Offset(offset int) *CredentialQuery { - cq.offset = &offset - return cq -} - -// Unique configures the query builder to filter duplicate records on query. -// By default, unique is set to true, and can be disabled using this method. -func (cq *CredentialQuery) Unique(unique bool) *CredentialQuery { - cq.unique = &unique - return cq -} - -// Order adds an order step to the query. -func (cq *CredentialQuery) Order(o ...OrderFunc) *CredentialQuery { - cq.order = append(cq.order, o...) - return cq -} - -// QueryAccount chains the current query on the "account" edge. -func (cq *CredentialQuery) QueryAccount() *UserQuery { - query := &UserQuery{config: cq.config} - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := cq.prepareQuery(ctx); err != nil { - return nil, err - } - selector := cq.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(credential.Table, credential.FieldID, selector), - sqlgraph.To(user.Table, user.FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, credential.AccountTable, credential.AccountColumn), - ) - fromU = sqlgraph.SetNeighbors(cq.driver.Dialect(), step) - return fromU, nil - } - return query -} - -// First returns the first Credential entity from the query. -// Returns a *NotFoundError when no Credential was found. -func (cq *CredentialQuery) First(ctx context.Context) (*Credential, error) { - nodes, err := cq.Limit(1).All(ctx) - if err != nil { - return nil, err - } - if len(nodes) == 0 { - return nil, &NotFoundError{credential.Label} - } - return nodes[0], nil -} - -// FirstX is like First, but panics if an error occurs. -func (cq *CredentialQuery) FirstX(ctx context.Context) *Credential { - node, err := cq.First(ctx) - if err != nil && !IsNotFound(err) { - panic(err) - } - return node -} - -// FirstID returns the first Credential ID from the query. -// Returns a *NotFoundError when no Credential ID was found. -func (cq *CredentialQuery) FirstID(ctx context.Context) (id string, err error) { - var ids []string - if ids, err = cq.Limit(1).IDs(ctx); err != nil { - return - } - if len(ids) == 0 { - err = &NotFoundError{credential.Label} - return - } - return ids[0], nil -} - -// FirstIDX is like FirstID, but panics if an error occurs. -func (cq *CredentialQuery) FirstIDX(ctx context.Context) string { - id, err := cq.FirstID(ctx) - if err != nil && !IsNotFound(err) { - panic(err) - } - return id -} - -// Only returns a single Credential entity found by the query, ensuring it only returns one. -// Returns a *NotSingularError when more than one Credential entity is found. -// Returns a *NotFoundError when no Credential entities are found. -func (cq *CredentialQuery) Only(ctx context.Context) (*Credential, error) { - nodes, err := cq.Limit(2).All(ctx) - if err != nil { - return nil, err - } - switch len(nodes) { - case 1: - return nodes[0], nil - case 0: - return nil, &NotFoundError{credential.Label} - default: - return nil, &NotSingularError{credential.Label} - } -} - -// OnlyX is like Only, but panics if an error occurs. -func (cq *CredentialQuery) OnlyX(ctx context.Context) *Credential { - node, err := cq.Only(ctx) - if err != nil { - panic(err) - } - return node -} - -// OnlyID is like Only, but returns the only Credential ID in the query. -// Returns a *NotSingularError when more than one Credential ID is found. -// Returns a *NotFoundError when no entities are found. -func (cq *CredentialQuery) OnlyID(ctx context.Context) (id string, err error) { - var ids []string - if ids, err = cq.Limit(2).IDs(ctx); err != nil { - return - } - switch len(ids) { - case 1: - id = ids[0] - case 0: - err = &NotFoundError{credential.Label} - default: - err = &NotSingularError{credential.Label} - } - return -} - -// OnlyIDX is like OnlyID, but panics if an error occurs. -func (cq *CredentialQuery) OnlyIDX(ctx context.Context) string { - id, err := cq.OnlyID(ctx) - if err != nil { - panic(err) - } - return id -} - -// All executes the query and returns a list of Credentials. -func (cq *CredentialQuery) All(ctx context.Context) ([]*Credential, error) { - if err := cq.prepareQuery(ctx); err != nil { - return nil, err - } - return cq.sqlAll(ctx) -} - -// AllX is like All, but panics if an error occurs. -func (cq *CredentialQuery) AllX(ctx context.Context) []*Credential { - nodes, err := cq.All(ctx) - if err != nil { - panic(err) - } - return nodes -} - -// IDs executes the query and returns a list of Credential IDs. -func (cq *CredentialQuery) IDs(ctx context.Context) ([]string, error) { - var ids []string - if err := cq.Select(credential.FieldID).Scan(ctx, &ids); err != nil { - return nil, err - } - return ids, nil -} - -// IDsX is like IDs, but panics if an error occurs. -func (cq *CredentialQuery) IDsX(ctx context.Context) []string { - ids, err := cq.IDs(ctx) - if err != nil { - panic(err) - } - return ids -} - -// Count returns the count of the given query. -func (cq *CredentialQuery) Count(ctx context.Context) (int, error) { - if err := cq.prepareQuery(ctx); err != nil { - return 0, err - } - return cq.sqlCount(ctx) -} - -// CountX is like Count, but panics if an error occurs. -func (cq *CredentialQuery) CountX(ctx context.Context) int { - count, err := cq.Count(ctx) - if err != nil { - panic(err) - } - return count -} - -// Exist returns true if the query has elements in the graph. -func (cq *CredentialQuery) Exist(ctx context.Context) (bool, error) { - if err := cq.prepareQuery(ctx); err != nil { - return false, err - } - return cq.sqlExist(ctx) -} - -// ExistX is like Exist, but panics if an error occurs. -func (cq *CredentialQuery) ExistX(ctx context.Context) bool { - exist, err := cq.Exist(ctx) - if err != nil { - panic(err) - } - return exist -} - -// Clone returns a duplicate of the CredentialQuery builder, including all associated steps. It can be -// used to prepare common query builders and use them differently after the clone is made. -func (cq *CredentialQuery) Clone() *CredentialQuery { - if cq == nil { - return nil - } - return &CredentialQuery{ - config: cq.config, - limit: cq.limit, - offset: cq.offset, - order: append([]OrderFunc{}, cq.order...), - predicates: append([]predicate.Credential{}, cq.predicates...), - withAccount: cq.withAccount.Clone(), - // clone intermediate query. - sql: cq.sql.Clone(), - path: cq.path, - unique: cq.unique, - } -} - -// WithAccount tells the query-builder to eager-load the nodes that are connected to -// the "account" edge. The optional arguments are used to configure the query builder of the edge. -func (cq *CredentialQuery) WithAccount(opts ...func(*UserQuery)) *CredentialQuery { - query := &UserQuery{config: cq.config} - for _, opt := range opts { - opt(query) - } - cq.withAccount = query - return cq -} - -// GroupBy is used to group vertices by one or more fields/columns. -// It is often used with aggregate functions, like: count, max, mean, min, sum. -// -// Example: -// -// var v []struct { -// Type string `json:"type,omitempty"` -// Count int `json:"count,omitempty"` -// } -// -// client.Credential.Query(). -// GroupBy(credential.FieldType). -// Aggregate(ent.Count()). -// Scan(ctx, &v) -func (cq *CredentialQuery) GroupBy(field string, fields ...string) *CredentialGroupBy { - grbuild := &CredentialGroupBy{config: cq.config} - grbuild.fields = append([]string{field}, fields...) - grbuild.path = func(ctx context.Context) (prev *sql.Selector, err error) { - if err := cq.prepareQuery(ctx); err != nil { - return nil, err - } - return cq.sqlQuery(ctx), nil - } - grbuild.label = credential.Label - grbuild.flds, grbuild.scan = &grbuild.fields, grbuild.Scan - return grbuild -} - -// Select allows the selection one or more fields/columns for the given query, -// instead of selecting all fields in the entity. -// -// Example: -// -// var v []struct { -// Type string `json:"type,omitempty"` -// } -// -// client.Credential.Query(). -// Select(credential.FieldType). -// Scan(ctx, &v) -func (cq *CredentialQuery) Select(fields ...string) *CredentialSelect { - cq.fields = append(cq.fields, fields...) - selbuild := &CredentialSelect{CredentialQuery: cq} - selbuild.label = credential.Label - selbuild.flds, selbuild.scan = &cq.fields, selbuild.Scan - return selbuild -} - -func (cq *CredentialQuery) prepareQuery(ctx context.Context) error { - for _, f := range cq.fields { - if !credential.ValidColumn(f) { - return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} - } - } - if cq.path != nil { - prev, err := cq.path(ctx) - if err != nil { - return err - } - cq.sql = prev - } - return nil -} - -func (cq *CredentialQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Credential, error) { - var ( - nodes = []*Credential{} - withFKs = cq.withFKs - _spec = cq.querySpec() - loadedTypes = [1]bool{ - cq.withAccount != nil, - } - ) - if cq.withAccount != nil { - withFKs = true - } - if withFKs { - _spec.Node.Columns = append(_spec.Node.Columns, credential.ForeignKeys...) - } - _spec.ScanValues = func(columns []string) ([]interface{}, error) { - return (*Credential).scanValues(nil, columns) - } - _spec.Assign = func(columns []string, values []interface{}) error { - node := &Credential{config: cq.config} - nodes = append(nodes, node) - node.Edges.loadedTypes = loadedTypes - return node.assignValues(columns, values) - } - for i := range hooks { - hooks[i](ctx, _spec) - } - if err := sqlgraph.QueryNodes(ctx, cq.driver, _spec); err != nil { - return nil, err - } - if len(nodes) == 0 { - return nodes, nil - } - - if query := cq.withAccount; query != nil { - ids := make([]string, 0, len(nodes)) - nodeids := make(map[string][]*Credential) - for i := range nodes { - if nodes[i].user_credentials == nil { - continue - } - fk := *nodes[i].user_credentials - if _, ok := nodeids[fk]; !ok { - ids = append(ids, fk) - } - nodeids[fk] = append(nodeids[fk], nodes[i]) - } - query.Where(user.IDIn(ids...)) - neighbors, err := query.All(ctx) - if err != nil { - return nil, err - } - for _, n := range neighbors { - nodes, ok := nodeids[n.ID] - if !ok { - return nil, fmt.Errorf(`unexpected foreign-key "user_credentials" returned %v`, n.ID) - } - for i := range nodes { - nodes[i].Edges.Account = n - } - } - } - - return nodes, nil -} - -func (cq *CredentialQuery) sqlCount(ctx context.Context) (int, error) { - _spec := cq.querySpec() - _spec.Node.Columns = cq.fields - if len(cq.fields) > 0 { - _spec.Unique = cq.unique != nil && *cq.unique - } - return sqlgraph.CountNodes(ctx, cq.driver, _spec) -} - -func (cq *CredentialQuery) sqlExist(ctx context.Context) (bool, error) { - n, err := cq.sqlCount(ctx) - if err != nil { - return false, fmt.Errorf("ent: check existence: %w", err) - } - return n > 0, nil -} - -func (cq *CredentialQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: credential.Table, - Columns: credential.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: credential.FieldID, - }, - }, - From: cq.sql, - Unique: true, - } - if unique := cq.unique; unique != nil { - _spec.Unique = *unique - } - if fields := cq.fields; len(fields) > 0 { - _spec.Node.Columns = make([]string, 0, len(fields)) - _spec.Node.Columns = append(_spec.Node.Columns, credential.FieldID) - for i := range fields { - if fields[i] != credential.FieldID { - _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) - } - } - } - if ps := cq.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if limit := cq.limit; limit != nil { - _spec.Limit = *limit - } - if offset := cq.offset; offset != nil { - _spec.Offset = *offset - } - if ps := cq.order; len(ps) > 0 { - _spec.Order = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - return _spec -} - -func (cq *CredentialQuery) sqlQuery(ctx context.Context) *sql.Selector { - builder := sql.Dialect(cq.driver.Dialect()) - t1 := builder.Table(credential.Table) - columns := cq.fields - if len(columns) == 0 { - columns = credential.Columns - } - selector := builder.Select(t1.Columns(columns...)...).From(t1) - if cq.sql != nil { - selector = cq.sql - selector.Select(selector.Columns(columns...)...) - } - if cq.unique != nil && *cq.unique { - selector.Distinct() - } - for _, p := range cq.predicates { - p(selector) - } - for _, p := range cq.order { - p(selector) - } - if offset := cq.offset; offset != nil { - // limit is mandatory for offset clause. We start - // with default value, and override it below if needed. - selector.Offset(*offset).Limit(math.MaxInt32) - } - if limit := cq.limit; limit != nil { - selector.Limit(*limit) - } - return selector -} - -// CredentialGroupBy is the group-by builder for Credential entities. -type CredentialGroupBy struct { - config - selector - fields []string - fns []AggregateFunc - // intermediate query (i.e. traversal path). - sql *sql.Selector - path func(context.Context) (*sql.Selector, error) -} - -// Aggregate adds the given aggregation functions to the group-by query. -func (cgb *CredentialGroupBy) Aggregate(fns ...AggregateFunc) *CredentialGroupBy { - cgb.fns = append(cgb.fns, fns...) - return cgb -} - -// Scan applies the group-by query and scans the result into the given value. -func (cgb *CredentialGroupBy) Scan(ctx context.Context, v interface{}) error { - query, err := cgb.path(ctx) - if err != nil { - return err - } - cgb.sql = query - return cgb.sqlScan(ctx, v) -} - -func (cgb *CredentialGroupBy) sqlScan(ctx context.Context, v interface{}) error { - for _, f := range cgb.fields { - if !credential.ValidColumn(f) { - return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)} - } - } - selector := cgb.sqlQuery() - if err := selector.Err(); err != nil { - return err - } - rows := &sql.Rows{} - query, args := selector.Query() - if err := cgb.driver.Query(ctx, query, args, rows); err != nil { - return err - } - defer rows.Close() - return sql.ScanSlice(rows, v) -} - -func (cgb *CredentialGroupBy) sqlQuery() *sql.Selector { - selector := cgb.sql.Select() - aggregation := make([]string, 0, len(cgb.fns)) - for _, fn := range cgb.fns { - aggregation = append(aggregation, fn(selector)) - } - // If no columns were selected in a custom aggregation function, the default - // selection is the fields used for "group-by", and the aggregation functions. - if len(selector.SelectedColumns()) == 0 { - columns := make([]string, 0, len(cgb.fields)+len(cgb.fns)) - for _, f := range cgb.fields { - columns = append(columns, selector.C(f)) - } - columns = append(columns, aggregation...) - selector.Select(columns...) - } - return selector.GroupBy(selector.Columns(cgb.fields...)...) -} - -// CredentialSelect is the builder for selecting fields of Credential entities. -type CredentialSelect struct { - *CredentialQuery - selector - // intermediate query (i.e. traversal path). - sql *sql.Selector -} - -// Scan applies the selector query and scans the result into the given value. -func (cs *CredentialSelect) Scan(ctx context.Context, v interface{}) error { - if err := cs.prepareQuery(ctx); err != nil { - return err - } - cs.sql = cs.CredentialQuery.sqlQuery(ctx) - return cs.sqlScan(ctx, v) -} - -func (cs *CredentialSelect) sqlScan(ctx context.Context, v interface{}) error { - rows := &sql.Rows{} - query, args := cs.sql.Query() - if err := cs.driver.Query(ctx, query, args, rows); err != nil { - return err - } - defer rows.Close() - return sql.ScanSlice(rows, v) -} diff --git a/ent/credential_update.go b/ent/credential_update.go deleted file mode 100644 index 09cbabff..00000000 --- a/ent/credential_update.go +++ /dev/null @@ -1,477 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - "time" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/fiware/vcverifier/ent/credential" - "github.com/fiware/vcverifier/ent/predicate" - "github.com/fiware/vcverifier/ent/user" -) - -// CredentialUpdate is the builder for updating Credential entities. -type CredentialUpdate struct { - config - hooks []Hook - mutation *CredentialMutation -} - -// Where appends a list predicates to the CredentialUpdate builder. -func (cu *CredentialUpdate) Where(ps ...predicate.Credential) *CredentialUpdate { - cu.mutation.Where(ps...) - return cu -} - -// SetType sets the "type" field. -func (cu *CredentialUpdate) SetType(s string) *CredentialUpdate { - cu.mutation.SetType(s) - return cu -} - -// SetNillableType sets the "type" field if the given value is not nil. -func (cu *CredentialUpdate) SetNillableType(s *string) *CredentialUpdate { - if s != nil { - cu.SetType(*s) - } - return cu -} - -// SetRaw sets the "raw" field. -func (cu *CredentialUpdate) SetRaw(u []uint8) *CredentialUpdate { - cu.mutation.SetRaw(u) - return cu -} - -// SetUpdatedAt sets the "updated_at" field. -func (cu *CredentialUpdate) SetUpdatedAt(t time.Time) *CredentialUpdate { - cu.mutation.SetUpdatedAt(t) - return cu -} - -// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. -func (cu *CredentialUpdate) SetNillableUpdatedAt(t *time.Time) *CredentialUpdate { - if t != nil { - cu.SetUpdatedAt(*t) - } - return cu -} - -// SetAccountID sets the "account" edge to the User entity by ID. -func (cu *CredentialUpdate) SetAccountID(id string) *CredentialUpdate { - cu.mutation.SetAccountID(id) - return cu -} - -// SetNillableAccountID sets the "account" edge to the User entity by ID if the given value is not nil. -func (cu *CredentialUpdate) SetNillableAccountID(id *string) *CredentialUpdate { - if id != nil { - cu = cu.SetAccountID(*id) - } - return cu -} - -// SetAccount sets the "account" edge to the User entity. -func (cu *CredentialUpdate) SetAccount(u *User) *CredentialUpdate { - return cu.SetAccountID(u.ID) -} - -// Mutation returns the CredentialMutation object of the builder. -func (cu *CredentialUpdate) Mutation() *CredentialMutation { - return cu.mutation -} - -// ClearAccount clears the "account" edge to the User entity. -func (cu *CredentialUpdate) ClearAccount() *CredentialUpdate { - cu.mutation.ClearAccount() - return cu -} - -// Save executes the query and returns the number of nodes affected by the update operation. -func (cu *CredentialUpdate) Save(ctx context.Context) (int, error) { - var ( - err error - affected int - ) - if len(cu.hooks) == 0 { - affected, err = cu.sqlSave(ctx) - } else { - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*CredentialMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - cu.mutation = mutation - affected, err = cu.sqlSave(ctx) - mutation.done = true - return affected, err - }) - for i := len(cu.hooks) - 1; i >= 0; i-- { - if cu.hooks[i] == nil { - return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") - } - mut = cu.hooks[i](mut) - } - if _, err := mut.Mutate(ctx, cu.mutation); err != nil { - return 0, err - } - } - return affected, err -} - -// SaveX is like Save, but panics if an error occurs. -func (cu *CredentialUpdate) SaveX(ctx context.Context) int { - affected, err := cu.Save(ctx) - if err != nil { - panic(err) - } - return affected -} - -// Exec executes the query. -func (cu *CredentialUpdate) Exec(ctx context.Context) error { - _, err := cu.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (cu *CredentialUpdate) ExecX(ctx context.Context) { - if err := cu.Exec(ctx); err != nil { - panic(err) - } -} - -func (cu *CredentialUpdate) sqlSave(ctx context.Context) (n int, err error) { - _spec := &sqlgraph.UpdateSpec{ - Node: &sqlgraph.NodeSpec{ - Table: credential.Table, - Columns: credential.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: credential.FieldID, - }, - }, - } - if ps := cu.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if value, ok := cu.mutation.GetType(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeString, - Value: value, - Column: credential.FieldType, - }) - } - if value, ok := cu.mutation.Raw(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeJSON, - Value: value, - Column: credential.FieldRaw, - }) - } - if value, ok := cu.mutation.UpdatedAt(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeTime, - Value: value, - Column: credential.FieldUpdatedAt, - }) - } - if cu.mutation.AccountCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: true, - Table: credential.AccountTable, - Columns: []string{credential.AccountColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: user.FieldID, - }, - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := cu.mutation.AccountIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: true, - Table: credential.AccountTable, - Columns: []string{credential.AccountColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: user.FieldID, - }, - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if n, err = sqlgraph.UpdateNodes(ctx, cu.driver, _spec); err != nil { - if _, ok := err.(*sqlgraph.NotFoundError); ok { - err = &NotFoundError{credential.Label} - } else if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return 0, err - } - return n, nil -} - -// CredentialUpdateOne is the builder for updating a single Credential entity. -type CredentialUpdateOne struct { - config - fields []string - hooks []Hook - mutation *CredentialMutation -} - -// SetType sets the "type" field. -func (cuo *CredentialUpdateOne) SetType(s string) *CredentialUpdateOne { - cuo.mutation.SetType(s) - return cuo -} - -// SetNillableType sets the "type" field if the given value is not nil. -func (cuo *CredentialUpdateOne) SetNillableType(s *string) *CredentialUpdateOne { - if s != nil { - cuo.SetType(*s) - } - return cuo -} - -// SetRaw sets the "raw" field. -func (cuo *CredentialUpdateOne) SetRaw(u []uint8) *CredentialUpdateOne { - cuo.mutation.SetRaw(u) - return cuo -} - -// SetUpdatedAt sets the "updated_at" field. -func (cuo *CredentialUpdateOne) SetUpdatedAt(t time.Time) *CredentialUpdateOne { - cuo.mutation.SetUpdatedAt(t) - return cuo -} - -// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. -func (cuo *CredentialUpdateOne) SetNillableUpdatedAt(t *time.Time) *CredentialUpdateOne { - if t != nil { - cuo.SetUpdatedAt(*t) - } - return cuo -} - -// SetAccountID sets the "account" edge to the User entity by ID. -func (cuo *CredentialUpdateOne) SetAccountID(id string) *CredentialUpdateOne { - cuo.mutation.SetAccountID(id) - return cuo -} - -// SetNillableAccountID sets the "account" edge to the User entity by ID if the given value is not nil. -func (cuo *CredentialUpdateOne) SetNillableAccountID(id *string) *CredentialUpdateOne { - if id != nil { - cuo = cuo.SetAccountID(*id) - } - return cuo -} - -// SetAccount sets the "account" edge to the User entity. -func (cuo *CredentialUpdateOne) SetAccount(u *User) *CredentialUpdateOne { - return cuo.SetAccountID(u.ID) -} - -// Mutation returns the CredentialMutation object of the builder. -func (cuo *CredentialUpdateOne) Mutation() *CredentialMutation { - return cuo.mutation -} - -// ClearAccount clears the "account" edge to the User entity. -func (cuo *CredentialUpdateOne) ClearAccount() *CredentialUpdateOne { - cuo.mutation.ClearAccount() - return cuo -} - -// Select allows selecting one or more fields (columns) of the returned entity. -// The default is selecting all fields defined in the entity schema. -func (cuo *CredentialUpdateOne) Select(field string, fields ...string) *CredentialUpdateOne { - cuo.fields = append([]string{field}, fields...) - return cuo -} - -// Save executes the query and returns the updated Credential entity. -func (cuo *CredentialUpdateOne) Save(ctx context.Context) (*Credential, error) { - var ( - err error - node *Credential - ) - if len(cuo.hooks) == 0 { - node, err = cuo.sqlSave(ctx) - } else { - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*CredentialMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - cuo.mutation = mutation - node, err = cuo.sqlSave(ctx) - mutation.done = true - return node, err - }) - for i := len(cuo.hooks) - 1; i >= 0; i-- { - if cuo.hooks[i] == nil { - return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") - } - mut = cuo.hooks[i](mut) - } - v, err := mut.Mutate(ctx, cuo.mutation) - if err != nil { - return nil, err - } - nv, ok := v.(*Credential) - if !ok { - return nil, fmt.Errorf("unexpected node type %T returned from CredentialMutation", v) - } - node = nv - } - return node, err -} - -// SaveX is like Save, but panics if an error occurs. -func (cuo *CredentialUpdateOne) SaveX(ctx context.Context) *Credential { - node, err := cuo.Save(ctx) - if err != nil { - panic(err) - } - return node -} - -// Exec executes the query on the entity. -func (cuo *CredentialUpdateOne) Exec(ctx context.Context) error { - _, err := cuo.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (cuo *CredentialUpdateOne) ExecX(ctx context.Context) { - if err := cuo.Exec(ctx); err != nil { - panic(err) - } -} - -func (cuo *CredentialUpdateOne) sqlSave(ctx context.Context) (_node *Credential, err error) { - _spec := &sqlgraph.UpdateSpec{ - Node: &sqlgraph.NodeSpec{ - Table: credential.Table, - Columns: credential.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: credential.FieldID, - }, - }, - } - id, ok := cuo.mutation.ID() - if !ok { - return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Credential.id" for update`)} - } - _spec.Node.ID.Value = id - if fields := cuo.fields; len(fields) > 0 { - _spec.Node.Columns = make([]string, 0, len(fields)) - _spec.Node.Columns = append(_spec.Node.Columns, credential.FieldID) - for _, f := range fields { - if !credential.ValidColumn(f) { - return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} - } - if f != credential.FieldID { - _spec.Node.Columns = append(_spec.Node.Columns, f) - } - } - } - if ps := cuo.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if value, ok := cuo.mutation.GetType(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeString, - Value: value, - Column: credential.FieldType, - }) - } - if value, ok := cuo.mutation.Raw(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeJSON, - Value: value, - Column: credential.FieldRaw, - }) - } - if value, ok := cuo.mutation.UpdatedAt(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeTime, - Value: value, - Column: credential.FieldUpdatedAt, - }) - } - if cuo.mutation.AccountCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: true, - Table: credential.AccountTable, - Columns: []string{credential.AccountColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: user.FieldID, - }, - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := cuo.mutation.AccountIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: true, - Table: credential.AccountTable, - Columns: []string{credential.AccountColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: user.FieldID, - }, - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - _node = &Credential{config: cuo.config} - _spec.Assign = _node.assignValues - _spec.ScanValues = _node.scanValues - if err = sqlgraph.UpdateNode(ctx, cuo.driver, _spec); err != nil { - if _, ok := err.(*sqlgraph.NotFoundError); ok { - err = &NotFoundError{credential.Label} - } else if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return nil, err - } - return _node, nil -} diff --git a/ent/did.go b/ent/did.go deleted file mode 100644 index e88a1444..00000000 --- a/ent/did.go +++ /dev/null @@ -1,164 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "fmt" - "strings" - "time" - - "entgo.io/ent/dialect/sql" - "github.com/fiware/vcverifier/ent/did" - "github.com/fiware/vcverifier/ent/user" -) - -// DID is the model entity for the DID schema. -type DID struct { - config `json:"-"` - // ID of the ent. - ID string `json:"id,omitempty"` - // Method holds the value of the "method" field. - Method string `json:"method,omitempty"` - // CreatedAt holds the value of the "created_at" field. - CreatedAt time.Time `json:"created_at,omitempty"` - // UpdatedAt holds the value of the "updated_at" field. - UpdatedAt time.Time `json:"updated_at,omitempty"` - // Edges holds the relations/edges for other nodes in the graph. - // The values are being populated by the DIDQuery when eager-loading is set. - Edges DIDEdges `json:"edges"` - user_dids *string -} - -// DIDEdges holds the relations/edges for other nodes in the graph. -type DIDEdges struct { - // User holds the value of the user edge. - User *User `json:"user,omitempty"` - // loadedTypes holds the information for reporting if a - // type was loaded (or requested) in eager-loading or not. - loadedTypes [1]bool -} - -// UserOrErr returns the User value or an error if the edge -// was not loaded in eager-loading, or loaded but was not found. -func (e DIDEdges) UserOrErr() (*User, error) { - if e.loadedTypes[0] { - if e.User == nil { - // The edge user was loaded in eager-loading, - // but was not found. - return nil, &NotFoundError{label: user.Label} - } - return e.User, nil - } - return nil, &NotLoadedError{edge: "user"} -} - -// scanValues returns the types for scanning values from sql.Rows. -func (*DID) scanValues(columns []string) ([]interface{}, error) { - values := make([]interface{}, len(columns)) - for i := range columns { - switch columns[i] { - case did.FieldID, did.FieldMethod: - values[i] = new(sql.NullString) - case did.FieldCreatedAt, did.FieldUpdatedAt: - values[i] = new(sql.NullTime) - case did.ForeignKeys[0]: // user_dids - values[i] = new(sql.NullString) - default: - return nil, fmt.Errorf("unexpected column %q for type DID", columns[i]) - } - } - return values, nil -} - -// assignValues assigns the values that were returned from sql.Rows (after scanning) -// to the DID fields. -func (d *DID) assignValues(columns []string, values []interface{}) error { - if m, n := len(values), len(columns); m < n { - return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) - } - for i := range columns { - switch columns[i] { - case did.FieldID: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field id", values[i]) - } else if value.Valid { - d.ID = value.String - } - case did.FieldMethod: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field method", values[i]) - } else if value.Valid { - d.Method = value.String - } - case did.FieldCreatedAt: - if value, ok := values[i].(*sql.NullTime); !ok { - return fmt.Errorf("unexpected type %T for field created_at", values[i]) - } else if value.Valid { - d.CreatedAt = value.Time - } - case did.FieldUpdatedAt: - if value, ok := values[i].(*sql.NullTime); !ok { - return fmt.Errorf("unexpected type %T for field updated_at", values[i]) - } else if value.Valid { - d.UpdatedAt = value.Time - } - case did.ForeignKeys[0]: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field user_dids", values[i]) - } else if value.Valid { - d.user_dids = new(string) - *d.user_dids = value.String - } - } - } - return nil -} - -// QueryUser queries the "user" edge of the DID entity. -func (d *DID) QueryUser() *UserQuery { - return (&DIDClient{config: d.config}).QueryUser(d) -} - -// Update returns a builder for updating this DID. -// Note that you need to call DID.Unwrap() before calling this method if this DID -// was returned from a transaction, and the transaction was committed or rolled back. -func (d *DID) Update() *DIDUpdateOne { - return (&DIDClient{config: d.config}).UpdateOne(d) -} - -// Unwrap unwraps the DID entity that was returned from a transaction after it was closed, -// so that all future queries will be executed through the driver which created the transaction. -func (d *DID) Unwrap() *DID { - _tx, ok := d.config.driver.(*txDriver) - if !ok { - panic("ent: DID is not a transactional entity") - } - d.config.driver = _tx.drv - return d -} - -// String implements the fmt.Stringer. -func (d *DID) String() string { - var builder strings.Builder - builder.WriteString("DID(") - builder.WriteString(fmt.Sprintf("id=%v, ", d.ID)) - builder.WriteString("method=") - builder.WriteString(d.Method) - builder.WriteString(", ") - builder.WriteString("created_at=") - builder.WriteString(d.CreatedAt.Format(time.ANSIC)) - builder.WriteString(", ") - builder.WriteString("updated_at=") - builder.WriteString(d.UpdatedAt.Format(time.ANSIC)) - builder.WriteByte(')') - return builder.String() -} - -// DIDs is a parsable slice of DID. -type DIDs []*DID - -func (d DIDs) config(cfg config) { - for _i := range d { - d[_i].config = cfg - } -} diff --git a/ent/did/did.go b/ent/did/did.go deleted file mode 100644 index 0ebe07c0..00000000 --- a/ent/did/did.go +++ /dev/null @@ -1,67 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package did - -import ( - "time" -) - -const ( - // Label holds the string label denoting the did type in the database. - Label = "did" - // FieldID holds the string denoting the id field in the database. - FieldID = "id" - // FieldMethod holds the string denoting the method field in the database. - FieldMethod = "method" - // FieldCreatedAt holds the string denoting the created_at field in the database. - FieldCreatedAt = "created_at" - // FieldUpdatedAt holds the string denoting the updated_at field in the database. - FieldUpdatedAt = "updated_at" - // EdgeUser holds the string denoting the user edge name in mutations. - EdgeUser = "user" - // Table holds the table name of the did in the database. - Table = "di_ds" - // UserTable is the table that holds the user relation/edge. - UserTable = "di_ds" - // UserInverseTable is the table name for the User entity. - // It exists in this package in order to avoid circular dependency with the "user" package. - UserInverseTable = "users" - // UserColumn is the table column denoting the user relation/edge. - UserColumn = "user_dids" -) - -// Columns holds all SQL columns for did fields. -var Columns = []string{ - FieldID, - FieldMethod, - FieldCreatedAt, - FieldUpdatedAt, -} - -// ForeignKeys holds the SQL foreign-keys that are owned by the "di_ds" -// table and are not defined as standalone fields in the schema. -var ForeignKeys = []string{ - "user_dids", -} - -// ValidColumn reports if the column name is valid (part of the table columns). -func ValidColumn(column string) bool { - for i := range Columns { - if column == Columns[i] { - return true - } - } - for i := range ForeignKeys { - if column == ForeignKeys[i] { - return true - } - } - return false -} - -var ( - // DefaultCreatedAt holds the default value on creation for the "created_at" field. - DefaultCreatedAt func() time.Time - // DefaultUpdatedAt holds the default value on creation for the "updated_at" field. - DefaultUpdatedAt func() time.Time -) diff --git a/ent/did/where.go b/ent/did/where.go deleted file mode 100644 index 4f14bc61..00000000 --- a/ent/did/where.go +++ /dev/null @@ -1,440 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package did - -import ( - "time" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "github.com/fiware/vcverifier/ent/predicate" -) - -// ID filters vertices based on their ID field. -func ID(id string) predicate.DID { - return predicate.DID(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldID), id)) - }) -} - -// IDEQ applies the EQ predicate on the ID field. -func IDEQ(id string) predicate.DID { - return predicate.DID(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldID), id)) - }) -} - -// IDNEQ applies the NEQ predicate on the ID field. -func IDNEQ(id string) predicate.DID { - return predicate.DID(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldID), id)) - }) -} - -// IDIn applies the In predicate on the ID field. -func IDIn(ids ...string) predicate.DID { - return predicate.DID(func(s *sql.Selector) { - v := make([]interface{}, len(ids)) - for i := range v { - v[i] = ids[i] - } - s.Where(sql.In(s.C(FieldID), v...)) - }) -} - -// IDNotIn applies the NotIn predicate on the ID field. -func IDNotIn(ids ...string) predicate.DID { - return predicate.DID(func(s *sql.Selector) { - v := make([]interface{}, len(ids)) - for i := range v { - v[i] = ids[i] - } - s.Where(sql.NotIn(s.C(FieldID), v...)) - }) -} - -// IDGT applies the GT predicate on the ID field. -func IDGT(id string) predicate.DID { - return predicate.DID(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldID), id)) - }) -} - -// IDGTE applies the GTE predicate on the ID field. -func IDGTE(id string) predicate.DID { - return predicate.DID(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldID), id)) - }) -} - -// IDLT applies the LT predicate on the ID field. -func IDLT(id string) predicate.DID { - return predicate.DID(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldID), id)) - }) -} - -// IDLTE applies the LTE predicate on the ID field. -func IDLTE(id string) predicate.DID { - return predicate.DID(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldID), id)) - }) -} - -// Method applies equality check predicate on the "method" field. It's identical to MethodEQ. -func Method(v string) predicate.DID { - return predicate.DID(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldMethod), v)) - }) -} - -// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. -func CreatedAt(v time.Time) predicate.DID { - return predicate.DID(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldCreatedAt), v)) - }) -} - -// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ. -func UpdatedAt(v time.Time) predicate.DID { - return predicate.DID(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldUpdatedAt), v)) - }) -} - -// MethodEQ applies the EQ predicate on the "method" field. -func MethodEQ(v string) predicate.DID { - return predicate.DID(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldMethod), v)) - }) -} - -// MethodNEQ applies the NEQ predicate on the "method" field. -func MethodNEQ(v string) predicate.DID { - return predicate.DID(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldMethod), v)) - }) -} - -// MethodIn applies the In predicate on the "method" field. -func MethodIn(vs ...string) predicate.DID { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.DID(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldMethod), v...)) - }) -} - -// MethodNotIn applies the NotIn predicate on the "method" field. -func MethodNotIn(vs ...string) predicate.DID { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.DID(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldMethod), v...)) - }) -} - -// MethodGT applies the GT predicate on the "method" field. -func MethodGT(v string) predicate.DID { - return predicate.DID(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldMethod), v)) - }) -} - -// MethodGTE applies the GTE predicate on the "method" field. -func MethodGTE(v string) predicate.DID { - return predicate.DID(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldMethod), v)) - }) -} - -// MethodLT applies the LT predicate on the "method" field. -func MethodLT(v string) predicate.DID { - return predicate.DID(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldMethod), v)) - }) -} - -// MethodLTE applies the LTE predicate on the "method" field. -func MethodLTE(v string) predicate.DID { - return predicate.DID(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldMethod), v)) - }) -} - -// MethodContains applies the Contains predicate on the "method" field. -func MethodContains(v string) predicate.DID { - return predicate.DID(func(s *sql.Selector) { - s.Where(sql.Contains(s.C(FieldMethod), v)) - }) -} - -// MethodHasPrefix applies the HasPrefix predicate on the "method" field. -func MethodHasPrefix(v string) predicate.DID { - return predicate.DID(func(s *sql.Selector) { - s.Where(sql.HasPrefix(s.C(FieldMethod), v)) - }) -} - -// MethodHasSuffix applies the HasSuffix predicate on the "method" field. -func MethodHasSuffix(v string) predicate.DID { - return predicate.DID(func(s *sql.Selector) { - s.Where(sql.HasSuffix(s.C(FieldMethod), v)) - }) -} - -// MethodIsNil applies the IsNil predicate on the "method" field. -func MethodIsNil() predicate.DID { - return predicate.DID(func(s *sql.Selector) { - s.Where(sql.IsNull(s.C(FieldMethod))) - }) -} - -// MethodNotNil applies the NotNil predicate on the "method" field. -func MethodNotNil() predicate.DID { - return predicate.DID(func(s *sql.Selector) { - s.Where(sql.NotNull(s.C(FieldMethod))) - }) -} - -// MethodEqualFold applies the EqualFold predicate on the "method" field. -func MethodEqualFold(v string) predicate.DID { - return predicate.DID(func(s *sql.Selector) { - s.Where(sql.EqualFold(s.C(FieldMethod), v)) - }) -} - -// MethodContainsFold applies the ContainsFold predicate on the "method" field. -func MethodContainsFold(v string) predicate.DID { - return predicate.DID(func(s *sql.Selector) { - s.Where(sql.ContainsFold(s.C(FieldMethod), v)) - }) -} - -// CreatedAtEQ applies the EQ predicate on the "created_at" field. -func CreatedAtEQ(v time.Time) predicate.DID { - return predicate.DID(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldCreatedAt), v)) - }) -} - -// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. -func CreatedAtNEQ(v time.Time) predicate.DID { - return predicate.DID(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldCreatedAt), v)) - }) -} - -// CreatedAtIn applies the In predicate on the "created_at" field. -func CreatedAtIn(vs ...time.Time) predicate.DID { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.DID(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldCreatedAt), v...)) - }) -} - -// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. -func CreatedAtNotIn(vs ...time.Time) predicate.DID { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.DID(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldCreatedAt), v...)) - }) -} - -// CreatedAtGT applies the GT predicate on the "created_at" field. -func CreatedAtGT(v time.Time) predicate.DID { - return predicate.DID(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldCreatedAt), v)) - }) -} - -// CreatedAtGTE applies the GTE predicate on the "created_at" field. -func CreatedAtGTE(v time.Time) predicate.DID { - return predicate.DID(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldCreatedAt), v)) - }) -} - -// CreatedAtLT applies the LT predicate on the "created_at" field. -func CreatedAtLT(v time.Time) predicate.DID { - return predicate.DID(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldCreatedAt), v)) - }) -} - -// CreatedAtLTE applies the LTE predicate on the "created_at" field. -func CreatedAtLTE(v time.Time) predicate.DID { - return predicate.DID(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldCreatedAt), v)) - }) -} - -// UpdatedAtEQ applies the EQ predicate on the "updated_at" field. -func UpdatedAtEQ(v time.Time) predicate.DID { - return predicate.DID(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldUpdatedAt), v)) - }) -} - -// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field. -func UpdatedAtNEQ(v time.Time) predicate.DID { - return predicate.DID(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldUpdatedAt), v)) - }) -} - -// UpdatedAtIn applies the In predicate on the "updated_at" field. -func UpdatedAtIn(vs ...time.Time) predicate.DID { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.DID(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldUpdatedAt), v...)) - }) -} - -// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field. -func UpdatedAtNotIn(vs ...time.Time) predicate.DID { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.DID(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldUpdatedAt), v...)) - }) -} - -// UpdatedAtGT applies the GT predicate on the "updated_at" field. -func UpdatedAtGT(v time.Time) predicate.DID { - return predicate.DID(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldUpdatedAt), v)) - }) -} - -// UpdatedAtGTE applies the GTE predicate on the "updated_at" field. -func UpdatedAtGTE(v time.Time) predicate.DID { - return predicate.DID(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldUpdatedAt), v)) - }) -} - -// UpdatedAtLT applies the LT predicate on the "updated_at" field. -func UpdatedAtLT(v time.Time) predicate.DID { - return predicate.DID(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldUpdatedAt), v)) - }) -} - -// UpdatedAtLTE applies the LTE predicate on the "updated_at" field. -func UpdatedAtLTE(v time.Time) predicate.DID { - return predicate.DID(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldUpdatedAt), v)) - }) -} - -// HasUser applies the HasEdge predicate on the "user" edge. -func HasUser() predicate.DID { - return predicate.DID(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(UserTable, FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, UserTable, UserColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasUserWith applies the HasEdge predicate on the "user" edge with a given conditions (other predicates). -func HasUserWith(preds ...predicate.User) predicate.DID { - return predicate.DID(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(UserInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, UserTable, UserColumn), - ) - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// And groups predicates with the AND operator between them. -func And(predicates ...predicate.DID) predicate.DID { - return predicate.DID(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) -} - -// Or groups predicates with the OR operator between them. -func Or(predicates ...predicate.DID) predicate.DID { - return predicate.DID(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) -} - -// Not applies the not operator on the given predicate. -func Not(p predicate.DID) predicate.DID { - return predicate.DID(func(s *sql.Selector) { - p(s.Not()) - }) -} diff --git a/ent/did_create.go b/ent/did_create.go deleted file mode 100644 index 5ef852cb..00000000 --- a/ent/did_create.go +++ /dev/null @@ -1,347 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - "time" - - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/fiware/vcverifier/ent/did" - "github.com/fiware/vcverifier/ent/user" -) - -// DIDCreate is the builder for creating a DID entity. -type DIDCreate struct { - config - mutation *DIDMutation - hooks []Hook -} - -// SetMethod sets the "method" field. -func (dc *DIDCreate) SetMethod(s string) *DIDCreate { - dc.mutation.SetMethod(s) - return dc -} - -// SetNillableMethod sets the "method" field if the given value is not nil. -func (dc *DIDCreate) SetNillableMethod(s *string) *DIDCreate { - if s != nil { - dc.SetMethod(*s) - } - return dc -} - -// SetCreatedAt sets the "created_at" field. -func (dc *DIDCreate) SetCreatedAt(t time.Time) *DIDCreate { - dc.mutation.SetCreatedAt(t) - return dc -} - -// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. -func (dc *DIDCreate) SetNillableCreatedAt(t *time.Time) *DIDCreate { - if t != nil { - dc.SetCreatedAt(*t) - } - return dc -} - -// SetUpdatedAt sets the "updated_at" field. -func (dc *DIDCreate) SetUpdatedAt(t time.Time) *DIDCreate { - dc.mutation.SetUpdatedAt(t) - return dc -} - -// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. -func (dc *DIDCreate) SetNillableUpdatedAt(t *time.Time) *DIDCreate { - if t != nil { - dc.SetUpdatedAt(*t) - } - return dc -} - -// SetID sets the "id" field. -func (dc *DIDCreate) SetID(s string) *DIDCreate { - dc.mutation.SetID(s) - return dc -} - -// SetUserID sets the "user" edge to the User entity by ID. -func (dc *DIDCreate) SetUserID(id string) *DIDCreate { - dc.mutation.SetUserID(id) - return dc -} - -// SetNillableUserID sets the "user" edge to the User entity by ID if the given value is not nil. -func (dc *DIDCreate) SetNillableUserID(id *string) *DIDCreate { - if id != nil { - dc = dc.SetUserID(*id) - } - return dc -} - -// SetUser sets the "user" edge to the User entity. -func (dc *DIDCreate) SetUser(u *User) *DIDCreate { - return dc.SetUserID(u.ID) -} - -// Mutation returns the DIDMutation object of the builder. -func (dc *DIDCreate) Mutation() *DIDMutation { - return dc.mutation -} - -// Save creates the DID in the database. -func (dc *DIDCreate) Save(ctx context.Context) (*DID, error) { - var ( - err error - node *DID - ) - dc.defaults() - if len(dc.hooks) == 0 { - if err = dc.check(); err != nil { - return nil, err - } - node, err = dc.sqlSave(ctx) - } else { - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*DIDMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - if err = dc.check(); err != nil { - return nil, err - } - dc.mutation = mutation - if node, err = dc.sqlSave(ctx); err != nil { - return nil, err - } - mutation.id = &node.ID - mutation.done = true - return node, err - }) - for i := len(dc.hooks) - 1; i >= 0; i-- { - if dc.hooks[i] == nil { - return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") - } - mut = dc.hooks[i](mut) - } - v, err := mut.Mutate(ctx, dc.mutation) - if err != nil { - return nil, err - } - nv, ok := v.(*DID) - if !ok { - return nil, fmt.Errorf("unexpected node type %T returned from DIDMutation", v) - } - node = nv - } - return node, err -} - -// SaveX calls Save and panics if Save returns an error. -func (dc *DIDCreate) SaveX(ctx context.Context) *DID { - v, err := dc.Save(ctx) - if err != nil { - panic(err) - } - return v -} - -// Exec executes the query. -func (dc *DIDCreate) Exec(ctx context.Context) error { - _, err := dc.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (dc *DIDCreate) ExecX(ctx context.Context) { - if err := dc.Exec(ctx); err != nil { - panic(err) - } -} - -// defaults sets the default values of the builder before save. -func (dc *DIDCreate) defaults() { - if _, ok := dc.mutation.CreatedAt(); !ok { - v := did.DefaultCreatedAt() - dc.mutation.SetCreatedAt(v) - } - if _, ok := dc.mutation.UpdatedAt(); !ok { - v := did.DefaultUpdatedAt() - dc.mutation.SetUpdatedAt(v) - } -} - -// check runs all checks and user-defined validators on the builder. -func (dc *DIDCreate) check() error { - if _, ok := dc.mutation.CreatedAt(); !ok { - return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "DID.created_at"`)} - } - if _, ok := dc.mutation.UpdatedAt(); !ok { - return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "DID.updated_at"`)} - } - return nil -} - -func (dc *DIDCreate) sqlSave(ctx context.Context) (*DID, error) { - _node, _spec := dc.createSpec() - if err := sqlgraph.CreateNode(ctx, dc.driver, _spec); err != nil { - if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return nil, err - } - if _spec.ID.Value != nil { - if id, ok := _spec.ID.Value.(string); ok { - _node.ID = id - } else { - return nil, fmt.Errorf("unexpected DID.ID type: %T", _spec.ID.Value) - } - } - return _node, nil -} - -func (dc *DIDCreate) createSpec() (*DID, *sqlgraph.CreateSpec) { - var ( - _node = &DID{config: dc.config} - _spec = &sqlgraph.CreateSpec{ - Table: did.Table, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: did.FieldID, - }, - } - ) - if id, ok := dc.mutation.ID(); ok { - _node.ID = id - _spec.ID.Value = id - } - if value, ok := dc.mutation.Method(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeString, - Value: value, - Column: did.FieldMethod, - }) - _node.Method = value - } - if value, ok := dc.mutation.CreatedAt(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeTime, - Value: value, - Column: did.FieldCreatedAt, - }) - _node.CreatedAt = value - } - if value, ok := dc.mutation.UpdatedAt(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeTime, - Value: value, - Column: did.FieldUpdatedAt, - }) - _node.UpdatedAt = value - } - if nodes := dc.mutation.UserIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: true, - Table: did.UserTable, - Columns: []string{did.UserColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: user.FieldID, - }, - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _node.user_dids = &nodes[0] - _spec.Edges = append(_spec.Edges, edge) - } - return _node, _spec -} - -// DIDCreateBulk is the builder for creating many DID entities in bulk. -type DIDCreateBulk struct { - config - builders []*DIDCreate -} - -// Save creates the DID entities in the database. -func (dcb *DIDCreateBulk) Save(ctx context.Context) ([]*DID, error) { - specs := make([]*sqlgraph.CreateSpec, len(dcb.builders)) - nodes := make([]*DID, len(dcb.builders)) - mutators := make([]Mutator, len(dcb.builders)) - for i := range dcb.builders { - func(i int, root context.Context) { - builder := dcb.builders[i] - builder.defaults() - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*DIDMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - if err := builder.check(); err != nil { - return nil, err - } - builder.mutation = mutation - nodes[i], specs[i] = builder.createSpec() - var err error - if i < len(mutators)-1 { - _, err = mutators[i+1].Mutate(root, dcb.builders[i+1].mutation) - } else { - spec := &sqlgraph.BatchCreateSpec{Nodes: specs} - // Invoke the actual operation on the latest mutation in the chain. - if err = sqlgraph.BatchCreate(ctx, dcb.driver, spec); err != nil { - if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - } - } - if err != nil { - return nil, err - } - mutation.id = &nodes[i].ID - mutation.done = true - return nodes[i], nil - }) - for i := len(builder.hooks) - 1; i >= 0; i-- { - mut = builder.hooks[i](mut) - } - mutators[i] = mut - }(i, ctx) - } - if len(mutators) > 0 { - if _, err := mutators[0].Mutate(ctx, dcb.builders[0].mutation); err != nil { - return nil, err - } - } - return nodes, nil -} - -// SaveX is like Save, but panics if an error occurs. -func (dcb *DIDCreateBulk) SaveX(ctx context.Context) []*DID { - v, err := dcb.Save(ctx) - if err != nil { - panic(err) - } - return v -} - -// Exec executes the query. -func (dcb *DIDCreateBulk) Exec(ctx context.Context) error { - _, err := dcb.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (dcb *DIDCreateBulk) ExecX(ctx context.Context) { - if err := dcb.Exec(ctx); err != nil { - panic(err) - } -} diff --git a/ent/did_delete.go b/ent/did_delete.go deleted file mode 100644 index 9b5f82f8..00000000 --- a/ent/did_delete.go +++ /dev/null @@ -1,115 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "fmt" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/fiware/vcverifier/ent/did" - "github.com/fiware/vcverifier/ent/predicate" -) - -// DIDDelete is the builder for deleting a DID entity. -type DIDDelete struct { - config - hooks []Hook - mutation *DIDMutation -} - -// Where appends a list predicates to the DIDDelete builder. -func (dd *DIDDelete) Where(ps ...predicate.DID) *DIDDelete { - dd.mutation.Where(ps...) - return dd -} - -// Exec executes the deletion query and returns how many vertices were deleted. -func (dd *DIDDelete) Exec(ctx context.Context) (int, error) { - var ( - err error - affected int - ) - if len(dd.hooks) == 0 { - affected, err = dd.sqlExec(ctx) - } else { - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*DIDMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - dd.mutation = mutation - affected, err = dd.sqlExec(ctx) - mutation.done = true - return affected, err - }) - for i := len(dd.hooks) - 1; i >= 0; i-- { - if dd.hooks[i] == nil { - return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") - } - mut = dd.hooks[i](mut) - } - if _, err := mut.Mutate(ctx, dd.mutation); err != nil { - return 0, err - } - } - return affected, err -} - -// ExecX is like Exec, but panics if an error occurs. -func (dd *DIDDelete) ExecX(ctx context.Context) int { - n, err := dd.Exec(ctx) - if err != nil { - panic(err) - } - return n -} - -func (dd *DIDDelete) sqlExec(ctx context.Context) (int, error) { - _spec := &sqlgraph.DeleteSpec{ - Node: &sqlgraph.NodeSpec{ - Table: did.Table, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: did.FieldID, - }, - }, - } - if ps := dd.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - affected, err := sqlgraph.DeleteNodes(ctx, dd.driver, _spec) - if err != nil && sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return affected, err -} - -// DIDDeleteOne is the builder for deleting a single DID entity. -type DIDDeleteOne struct { - dd *DIDDelete -} - -// Exec executes the deletion query. -func (ddo *DIDDeleteOne) Exec(ctx context.Context) error { - n, err := ddo.dd.Exec(ctx) - switch { - case err != nil: - return err - case n == 0: - return &NotFoundError{did.Label} - default: - return nil - } -} - -// ExecX is like Exec, but panics if an error occurs. -func (ddo *DIDDeleteOne) ExecX(ctx context.Context) { - ddo.dd.ExecX(ctx) -} diff --git a/ent/did_query.go b/ent/did_query.go deleted file mode 100644 index 2be57377..00000000 --- a/ent/did_query.go +++ /dev/null @@ -1,605 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "fmt" - "math" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/fiware/vcverifier/ent/did" - "github.com/fiware/vcverifier/ent/predicate" - "github.com/fiware/vcverifier/ent/user" -) - -// DIDQuery is the builder for querying DID entities. -type DIDQuery struct { - config - limit *int - offset *int - unique *bool - order []OrderFunc - fields []string - predicates []predicate.DID - // eager-loading edges. - withUser *UserQuery - withFKs bool - // intermediate query (i.e. traversal path). - sql *sql.Selector - path func(context.Context) (*sql.Selector, error) -} - -// Where adds a new predicate for the DIDQuery builder. -func (dq *DIDQuery) Where(ps ...predicate.DID) *DIDQuery { - dq.predicates = append(dq.predicates, ps...) - return dq -} - -// Limit adds a limit step to the query. -func (dq *DIDQuery) Limit(limit int) *DIDQuery { - dq.limit = &limit - return dq -} - -// Offset adds an offset step to the query. -func (dq *DIDQuery) Offset(offset int) *DIDQuery { - dq.offset = &offset - return dq -} - -// Unique configures the query builder to filter duplicate records on query. -// By default, unique is set to true, and can be disabled using this method. -func (dq *DIDQuery) Unique(unique bool) *DIDQuery { - dq.unique = &unique - return dq -} - -// Order adds an order step to the query. -func (dq *DIDQuery) Order(o ...OrderFunc) *DIDQuery { - dq.order = append(dq.order, o...) - return dq -} - -// QueryUser chains the current query on the "user" edge. -func (dq *DIDQuery) QueryUser() *UserQuery { - query := &UserQuery{config: dq.config} - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := dq.prepareQuery(ctx); err != nil { - return nil, err - } - selector := dq.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(did.Table, did.FieldID, selector), - sqlgraph.To(user.Table, user.FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, did.UserTable, did.UserColumn), - ) - fromU = sqlgraph.SetNeighbors(dq.driver.Dialect(), step) - return fromU, nil - } - return query -} - -// First returns the first DID entity from the query. -// Returns a *NotFoundError when no DID was found. -func (dq *DIDQuery) First(ctx context.Context) (*DID, error) { - nodes, err := dq.Limit(1).All(ctx) - if err != nil { - return nil, err - } - if len(nodes) == 0 { - return nil, &NotFoundError{did.Label} - } - return nodes[0], nil -} - -// FirstX is like First, but panics if an error occurs. -func (dq *DIDQuery) FirstX(ctx context.Context) *DID { - node, err := dq.First(ctx) - if err != nil && !IsNotFound(err) { - panic(err) - } - return node -} - -// FirstID returns the first DID ID from the query. -// Returns a *NotFoundError when no DID ID was found. -func (dq *DIDQuery) FirstID(ctx context.Context) (id string, err error) { - var ids []string - if ids, err = dq.Limit(1).IDs(ctx); err != nil { - return - } - if len(ids) == 0 { - err = &NotFoundError{did.Label} - return - } - return ids[0], nil -} - -// FirstIDX is like FirstID, but panics if an error occurs. -func (dq *DIDQuery) FirstIDX(ctx context.Context) string { - id, err := dq.FirstID(ctx) - if err != nil && !IsNotFound(err) { - panic(err) - } - return id -} - -// Only returns a single DID entity found by the query, ensuring it only returns one. -// Returns a *NotSingularError when more than one DID entity is found. -// Returns a *NotFoundError when no DID entities are found. -func (dq *DIDQuery) Only(ctx context.Context) (*DID, error) { - nodes, err := dq.Limit(2).All(ctx) - if err != nil { - return nil, err - } - switch len(nodes) { - case 1: - return nodes[0], nil - case 0: - return nil, &NotFoundError{did.Label} - default: - return nil, &NotSingularError{did.Label} - } -} - -// OnlyX is like Only, but panics if an error occurs. -func (dq *DIDQuery) OnlyX(ctx context.Context) *DID { - node, err := dq.Only(ctx) - if err != nil { - panic(err) - } - return node -} - -// OnlyID is like Only, but returns the only DID ID in the query. -// Returns a *NotSingularError when more than one DID ID is found. -// Returns a *NotFoundError when no entities are found. -func (dq *DIDQuery) OnlyID(ctx context.Context) (id string, err error) { - var ids []string - if ids, err = dq.Limit(2).IDs(ctx); err != nil { - return - } - switch len(ids) { - case 1: - id = ids[0] - case 0: - err = &NotFoundError{did.Label} - default: - err = &NotSingularError{did.Label} - } - return -} - -// OnlyIDX is like OnlyID, but panics if an error occurs. -func (dq *DIDQuery) OnlyIDX(ctx context.Context) string { - id, err := dq.OnlyID(ctx) - if err != nil { - panic(err) - } - return id -} - -// All executes the query and returns a list of DIDs. -func (dq *DIDQuery) All(ctx context.Context) ([]*DID, error) { - if err := dq.prepareQuery(ctx); err != nil { - return nil, err - } - return dq.sqlAll(ctx) -} - -// AllX is like All, but panics if an error occurs. -func (dq *DIDQuery) AllX(ctx context.Context) []*DID { - nodes, err := dq.All(ctx) - if err != nil { - panic(err) - } - return nodes -} - -// IDs executes the query and returns a list of DID IDs. -func (dq *DIDQuery) IDs(ctx context.Context) ([]string, error) { - var ids []string - if err := dq.Select(did.FieldID).Scan(ctx, &ids); err != nil { - return nil, err - } - return ids, nil -} - -// IDsX is like IDs, but panics if an error occurs. -func (dq *DIDQuery) IDsX(ctx context.Context) []string { - ids, err := dq.IDs(ctx) - if err != nil { - panic(err) - } - return ids -} - -// Count returns the count of the given query. -func (dq *DIDQuery) Count(ctx context.Context) (int, error) { - if err := dq.prepareQuery(ctx); err != nil { - return 0, err - } - return dq.sqlCount(ctx) -} - -// CountX is like Count, but panics if an error occurs. -func (dq *DIDQuery) CountX(ctx context.Context) int { - count, err := dq.Count(ctx) - if err != nil { - panic(err) - } - return count -} - -// Exist returns true if the query has elements in the graph. -func (dq *DIDQuery) Exist(ctx context.Context) (bool, error) { - if err := dq.prepareQuery(ctx); err != nil { - return false, err - } - return dq.sqlExist(ctx) -} - -// ExistX is like Exist, but panics if an error occurs. -func (dq *DIDQuery) ExistX(ctx context.Context) bool { - exist, err := dq.Exist(ctx) - if err != nil { - panic(err) - } - return exist -} - -// Clone returns a duplicate of the DIDQuery builder, including all associated steps. It can be -// used to prepare common query builders and use them differently after the clone is made. -func (dq *DIDQuery) Clone() *DIDQuery { - if dq == nil { - return nil - } - return &DIDQuery{ - config: dq.config, - limit: dq.limit, - offset: dq.offset, - order: append([]OrderFunc{}, dq.order...), - predicates: append([]predicate.DID{}, dq.predicates...), - withUser: dq.withUser.Clone(), - // clone intermediate query. - sql: dq.sql.Clone(), - path: dq.path, - unique: dq.unique, - } -} - -// WithUser tells the query-builder to eager-load the nodes that are connected to -// the "user" edge. The optional arguments are used to configure the query builder of the edge. -func (dq *DIDQuery) WithUser(opts ...func(*UserQuery)) *DIDQuery { - query := &UserQuery{config: dq.config} - for _, opt := range opts { - opt(query) - } - dq.withUser = query - return dq -} - -// GroupBy is used to group vertices by one or more fields/columns. -// It is often used with aggregate functions, like: count, max, mean, min, sum. -// -// Example: -// -// var v []struct { -// Method string `json:"method,omitempty"` -// Count int `json:"count,omitempty"` -// } -// -// client.DID.Query(). -// GroupBy(did.FieldMethod). -// Aggregate(ent.Count()). -// Scan(ctx, &v) -func (dq *DIDQuery) GroupBy(field string, fields ...string) *DIDGroupBy { - grbuild := &DIDGroupBy{config: dq.config} - grbuild.fields = append([]string{field}, fields...) - grbuild.path = func(ctx context.Context) (prev *sql.Selector, err error) { - if err := dq.prepareQuery(ctx); err != nil { - return nil, err - } - return dq.sqlQuery(ctx), nil - } - grbuild.label = did.Label - grbuild.flds, grbuild.scan = &grbuild.fields, grbuild.Scan - return grbuild -} - -// Select allows the selection one or more fields/columns for the given query, -// instead of selecting all fields in the entity. -// -// Example: -// -// var v []struct { -// Method string `json:"method,omitempty"` -// } -// -// client.DID.Query(). -// Select(did.FieldMethod). -// Scan(ctx, &v) -func (dq *DIDQuery) Select(fields ...string) *DIDSelect { - dq.fields = append(dq.fields, fields...) - selbuild := &DIDSelect{DIDQuery: dq} - selbuild.label = did.Label - selbuild.flds, selbuild.scan = &dq.fields, selbuild.Scan - return selbuild -} - -func (dq *DIDQuery) prepareQuery(ctx context.Context) error { - for _, f := range dq.fields { - if !did.ValidColumn(f) { - return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} - } - } - if dq.path != nil { - prev, err := dq.path(ctx) - if err != nil { - return err - } - dq.sql = prev - } - return nil -} - -func (dq *DIDQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*DID, error) { - var ( - nodes = []*DID{} - withFKs = dq.withFKs - _spec = dq.querySpec() - loadedTypes = [1]bool{ - dq.withUser != nil, - } - ) - if dq.withUser != nil { - withFKs = true - } - if withFKs { - _spec.Node.Columns = append(_spec.Node.Columns, did.ForeignKeys...) - } - _spec.ScanValues = func(columns []string) ([]interface{}, error) { - return (*DID).scanValues(nil, columns) - } - _spec.Assign = func(columns []string, values []interface{}) error { - node := &DID{config: dq.config} - nodes = append(nodes, node) - node.Edges.loadedTypes = loadedTypes - return node.assignValues(columns, values) - } - for i := range hooks { - hooks[i](ctx, _spec) - } - if err := sqlgraph.QueryNodes(ctx, dq.driver, _spec); err != nil { - return nil, err - } - if len(nodes) == 0 { - return nodes, nil - } - - if query := dq.withUser; query != nil { - ids := make([]string, 0, len(nodes)) - nodeids := make(map[string][]*DID) - for i := range nodes { - if nodes[i].user_dids == nil { - continue - } - fk := *nodes[i].user_dids - if _, ok := nodeids[fk]; !ok { - ids = append(ids, fk) - } - nodeids[fk] = append(nodeids[fk], nodes[i]) - } - query.Where(user.IDIn(ids...)) - neighbors, err := query.All(ctx) - if err != nil { - return nil, err - } - for _, n := range neighbors { - nodes, ok := nodeids[n.ID] - if !ok { - return nil, fmt.Errorf(`unexpected foreign-key "user_dids" returned %v`, n.ID) - } - for i := range nodes { - nodes[i].Edges.User = n - } - } - } - - return nodes, nil -} - -func (dq *DIDQuery) sqlCount(ctx context.Context) (int, error) { - _spec := dq.querySpec() - _spec.Node.Columns = dq.fields - if len(dq.fields) > 0 { - _spec.Unique = dq.unique != nil && *dq.unique - } - return sqlgraph.CountNodes(ctx, dq.driver, _spec) -} - -func (dq *DIDQuery) sqlExist(ctx context.Context) (bool, error) { - n, err := dq.sqlCount(ctx) - if err != nil { - return false, fmt.Errorf("ent: check existence: %w", err) - } - return n > 0, nil -} - -func (dq *DIDQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: did.Table, - Columns: did.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: did.FieldID, - }, - }, - From: dq.sql, - Unique: true, - } - if unique := dq.unique; unique != nil { - _spec.Unique = *unique - } - if fields := dq.fields; len(fields) > 0 { - _spec.Node.Columns = make([]string, 0, len(fields)) - _spec.Node.Columns = append(_spec.Node.Columns, did.FieldID) - for i := range fields { - if fields[i] != did.FieldID { - _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) - } - } - } - if ps := dq.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if limit := dq.limit; limit != nil { - _spec.Limit = *limit - } - if offset := dq.offset; offset != nil { - _spec.Offset = *offset - } - if ps := dq.order; len(ps) > 0 { - _spec.Order = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - return _spec -} - -func (dq *DIDQuery) sqlQuery(ctx context.Context) *sql.Selector { - builder := sql.Dialect(dq.driver.Dialect()) - t1 := builder.Table(did.Table) - columns := dq.fields - if len(columns) == 0 { - columns = did.Columns - } - selector := builder.Select(t1.Columns(columns...)...).From(t1) - if dq.sql != nil { - selector = dq.sql - selector.Select(selector.Columns(columns...)...) - } - if dq.unique != nil && *dq.unique { - selector.Distinct() - } - for _, p := range dq.predicates { - p(selector) - } - for _, p := range dq.order { - p(selector) - } - if offset := dq.offset; offset != nil { - // limit is mandatory for offset clause. We start - // with default value, and override it below if needed. - selector.Offset(*offset).Limit(math.MaxInt32) - } - if limit := dq.limit; limit != nil { - selector.Limit(*limit) - } - return selector -} - -// DIDGroupBy is the group-by builder for DID entities. -type DIDGroupBy struct { - config - selector - fields []string - fns []AggregateFunc - // intermediate query (i.e. traversal path). - sql *sql.Selector - path func(context.Context) (*sql.Selector, error) -} - -// Aggregate adds the given aggregation functions to the group-by query. -func (dgb *DIDGroupBy) Aggregate(fns ...AggregateFunc) *DIDGroupBy { - dgb.fns = append(dgb.fns, fns...) - return dgb -} - -// Scan applies the group-by query and scans the result into the given value. -func (dgb *DIDGroupBy) Scan(ctx context.Context, v interface{}) error { - query, err := dgb.path(ctx) - if err != nil { - return err - } - dgb.sql = query - return dgb.sqlScan(ctx, v) -} - -func (dgb *DIDGroupBy) sqlScan(ctx context.Context, v interface{}) error { - for _, f := range dgb.fields { - if !did.ValidColumn(f) { - return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)} - } - } - selector := dgb.sqlQuery() - if err := selector.Err(); err != nil { - return err - } - rows := &sql.Rows{} - query, args := selector.Query() - if err := dgb.driver.Query(ctx, query, args, rows); err != nil { - return err - } - defer rows.Close() - return sql.ScanSlice(rows, v) -} - -func (dgb *DIDGroupBy) sqlQuery() *sql.Selector { - selector := dgb.sql.Select() - aggregation := make([]string, 0, len(dgb.fns)) - for _, fn := range dgb.fns { - aggregation = append(aggregation, fn(selector)) - } - // If no columns were selected in a custom aggregation function, the default - // selection is the fields used for "group-by", and the aggregation functions. - if len(selector.SelectedColumns()) == 0 { - columns := make([]string, 0, len(dgb.fields)+len(dgb.fns)) - for _, f := range dgb.fields { - columns = append(columns, selector.C(f)) - } - columns = append(columns, aggregation...) - selector.Select(columns...) - } - return selector.GroupBy(selector.Columns(dgb.fields...)...) -} - -// DIDSelect is the builder for selecting fields of DID entities. -type DIDSelect struct { - *DIDQuery - selector - // intermediate query (i.e. traversal path). - sql *sql.Selector -} - -// Scan applies the selector query and scans the result into the given value. -func (ds *DIDSelect) Scan(ctx context.Context, v interface{}) error { - if err := ds.prepareQuery(ctx); err != nil { - return err - } - ds.sql = ds.DIDQuery.sqlQuery(ctx) - return ds.sqlScan(ctx, v) -} - -func (ds *DIDSelect) sqlScan(ctx context.Context, v interface{}) error { - rows := &sql.Rows{} - query, args := ds.sql.Query() - if err := ds.driver.Query(ctx, query, args, rows); err != nil { - return err - } - defer rows.Close() - return sql.ScanSlice(rows, v) -} diff --git a/ent/did_update.go b/ent/did_update.go deleted file mode 100644 index a362964f..00000000 --- a/ent/did_update.go +++ /dev/null @@ -1,475 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - "time" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/fiware/vcverifier/ent/did" - "github.com/fiware/vcverifier/ent/predicate" - "github.com/fiware/vcverifier/ent/user" -) - -// DIDUpdate is the builder for updating DID entities. -type DIDUpdate struct { - config - hooks []Hook - mutation *DIDMutation -} - -// Where appends a list predicates to the DIDUpdate builder. -func (du *DIDUpdate) Where(ps ...predicate.DID) *DIDUpdate { - du.mutation.Where(ps...) - return du -} - -// SetMethod sets the "method" field. -func (du *DIDUpdate) SetMethod(s string) *DIDUpdate { - du.mutation.SetMethod(s) - return du -} - -// SetNillableMethod sets the "method" field if the given value is not nil. -func (du *DIDUpdate) SetNillableMethod(s *string) *DIDUpdate { - if s != nil { - du.SetMethod(*s) - } - return du -} - -// ClearMethod clears the value of the "method" field. -func (du *DIDUpdate) ClearMethod() *DIDUpdate { - du.mutation.ClearMethod() - return du -} - -// SetUpdatedAt sets the "updated_at" field. -func (du *DIDUpdate) SetUpdatedAt(t time.Time) *DIDUpdate { - du.mutation.SetUpdatedAt(t) - return du -} - -// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. -func (du *DIDUpdate) SetNillableUpdatedAt(t *time.Time) *DIDUpdate { - if t != nil { - du.SetUpdatedAt(*t) - } - return du -} - -// SetUserID sets the "user" edge to the User entity by ID. -func (du *DIDUpdate) SetUserID(id string) *DIDUpdate { - du.mutation.SetUserID(id) - return du -} - -// SetNillableUserID sets the "user" edge to the User entity by ID if the given value is not nil. -func (du *DIDUpdate) SetNillableUserID(id *string) *DIDUpdate { - if id != nil { - du = du.SetUserID(*id) - } - return du -} - -// SetUser sets the "user" edge to the User entity. -func (du *DIDUpdate) SetUser(u *User) *DIDUpdate { - return du.SetUserID(u.ID) -} - -// Mutation returns the DIDMutation object of the builder. -func (du *DIDUpdate) Mutation() *DIDMutation { - return du.mutation -} - -// ClearUser clears the "user" edge to the User entity. -func (du *DIDUpdate) ClearUser() *DIDUpdate { - du.mutation.ClearUser() - return du -} - -// Save executes the query and returns the number of nodes affected by the update operation. -func (du *DIDUpdate) Save(ctx context.Context) (int, error) { - var ( - err error - affected int - ) - if len(du.hooks) == 0 { - affected, err = du.sqlSave(ctx) - } else { - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*DIDMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - du.mutation = mutation - affected, err = du.sqlSave(ctx) - mutation.done = true - return affected, err - }) - for i := len(du.hooks) - 1; i >= 0; i-- { - if du.hooks[i] == nil { - return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") - } - mut = du.hooks[i](mut) - } - if _, err := mut.Mutate(ctx, du.mutation); err != nil { - return 0, err - } - } - return affected, err -} - -// SaveX is like Save, but panics if an error occurs. -func (du *DIDUpdate) SaveX(ctx context.Context) int { - affected, err := du.Save(ctx) - if err != nil { - panic(err) - } - return affected -} - -// Exec executes the query. -func (du *DIDUpdate) Exec(ctx context.Context) error { - _, err := du.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (du *DIDUpdate) ExecX(ctx context.Context) { - if err := du.Exec(ctx); err != nil { - panic(err) - } -} - -func (du *DIDUpdate) sqlSave(ctx context.Context) (n int, err error) { - _spec := &sqlgraph.UpdateSpec{ - Node: &sqlgraph.NodeSpec{ - Table: did.Table, - Columns: did.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: did.FieldID, - }, - }, - } - if ps := du.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if value, ok := du.mutation.Method(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeString, - Value: value, - Column: did.FieldMethod, - }) - } - if du.mutation.MethodCleared() { - _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: did.FieldMethod, - }) - } - if value, ok := du.mutation.UpdatedAt(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeTime, - Value: value, - Column: did.FieldUpdatedAt, - }) - } - if du.mutation.UserCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: true, - Table: did.UserTable, - Columns: []string{did.UserColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: user.FieldID, - }, - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := du.mutation.UserIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: true, - Table: did.UserTable, - Columns: []string{did.UserColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: user.FieldID, - }, - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if n, err = sqlgraph.UpdateNodes(ctx, du.driver, _spec); err != nil { - if _, ok := err.(*sqlgraph.NotFoundError); ok { - err = &NotFoundError{did.Label} - } else if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return 0, err - } - return n, nil -} - -// DIDUpdateOne is the builder for updating a single DID entity. -type DIDUpdateOne struct { - config - fields []string - hooks []Hook - mutation *DIDMutation -} - -// SetMethod sets the "method" field. -func (duo *DIDUpdateOne) SetMethod(s string) *DIDUpdateOne { - duo.mutation.SetMethod(s) - return duo -} - -// SetNillableMethod sets the "method" field if the given value is not nil. -func (duo *DIDUpdateOne) SetNillableMethod(s *string) *DIDUpdateOne { - if s != nil { - duo.SetMethod(*s) - } - return duo -} - -// ClearMethod clears the value of the "method" field. -func (duo *DIDUpdateOne) ClearMethod() *DIDUpdateOne { - duo.mutation.ClearMethod() - return duo -} - -// SetUpdatedAt sets the "updated_at" field. -func (duo *DIDUpdateOne) SetUpdatedAt(t time.Time) *DIDUpdateOne { - duo.mutation.SetUpdatedAt(t) - return duo -} - -// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. -func (duo *DIDUpdateOne) SetNillableUpdatedAt(t *time.Time) *DIDUpdateOne { - if t != nil { - duo.SetUpdatedAt(*t) - } - return duo -} - -// SetUserID sets the "user" edge to the User entity by ID. -func (duo *DIDUpdateOne) SetUserID(id string) *DIDUpdateOne { - duo.mutation.SetUserID(id) - return duo -} - -// SetNillableUserID sets the "user" edge to the User entity by ID if the given value is not nil. -func (duo *DIDUpdateOne) SetNillableUserID(id *string) *DIDUpdateOne { - if id != nil { - duo = duo.SetUserID(*id) - } - return duo -} - -// SetUser sets the "user" edge to the User entity. -func (duo *DIDUpdateOne) SetUser(u *User) *DIDUpdateOne { - return duo.SetUserID(u.ID) -} - -// Mutation returns the DIDMutation object of the builder. -func (duo *DIDUpdateOne) Mutation() *DIDMutation { - return duo.mutation -} - -// ClearUser clears the "user" edge to the User entity. -func (duo *DIDUpdateOne) ClearUser() *DIDUpdateOne { - duo.mutation.ClearUser() - return duo -} - -// Select allows selecting one or more fields (columns) of the returned entity. -// The default is selecting all fields defined in the entity schema. -func (duo *DIDUpdateOne) Select(field string, fields ...string) *DIDUpdateOne { - duo.fields = append([]string{field}, fields...) - return duo -} - -// Save executes the query and returns the updated DID entity. -func (duo *DIDUpdateOne) Save(ctx context.Context) (*DID, error) { - var ( - err error - node *DID - ) - if len(duo.hooks) == 0 { - node, err = duo.sqlSave(ctx) - } else { - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*DIDMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - duo.mutation = mutation - node, err = duo.sqlSave(ctx) - mutation.done = true - return node, err - }) - for i := len(duo.hooks) - 1; i >= 0; i-- { - if duo.hooks[i] == nil { - return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") - } - mut = duo.hooks[i](mut) - } - v, err := mut.Mutate(ctx, duo.mutation) - if err != nil { - return nil, err - } - nv, ok := v.(*DID) - if !ok { - return nil, fmt.Errorf("unexpected node type %T returned from DIDMutation", v) - } - node = nv - } - return node, err -} - -// SaveX is like Save, but panics if an error occurs. -func (duo *DIDUpdateOne) SaveX(ctx context.Context) *DID { - node, err := duo.Save(ctx) - if err != nil { - panic(err) - } - return node -} - -// Exec executes the query on the entity. -func (duo *DIDUpdateOne) Exec(ctx context.Context) error { - _, err := duo.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (duo *DIDUpdateOne) ExecX(ctx context.Context) { - if err := duo.Exec(ctx); err != nil { - panic(err) - } -} - -func (duo *DIDUpdateOne) sqlSave(ctx context.Context) (_node *DID, err error) { - _spec := &sqlgraph.UpdateSpec{ - Node: &sqlgraph.NodeSpec{ - Table: did.Table, - Columns: did.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: did.FieldID, - }, - }, - } - id, ok := duo.mutation.ID() - if !ok { - return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "DID.id" for update`)} - } - _spec.Node.ID.Value = id - if fields := duo.fields; len(fields) > 0 { - _spec.Node.Columns = make([]string, 0, len(fields)) - _spec.Node.Columns = append(_spec.Node.Columns, did.FieldID) - for _, f := range fields { - if !did.ValidColumn(f) { - return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} - } - if f != did.FieldID { - _spec.Node.Columns = append(_spec.Node.Columns, f) - } - } - } - if ps := duo.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if value, ok := duo.mutation.Method(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeString, - Value: value, - Column: did.FieldMethod, - }) - } - if duo.mutation.MethodCleared() { - _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: did.FieldMethod, - }) - } - if value, ok := duo.mutation.UpdatedAt(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeTime, - Value: value, - Column: did.FieldUpdatedAt, - }) - } - if duo.mutation.UserCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: true, - Table: did.UserTable, - Columns: []string{did.UserColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: user.FieldID, - }, - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := duo.mutation.UserIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: true, - Table: did.UserTable, - Columns: []string{did.UserColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: user.FieldID, - }, - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - _node = &DID{config: duo.config} - _spec.Assign = _node.assignValues - _spec.ScanValues = _node.scanValues - if err = sqlgraph.UpdateNode(ctx, duo.driver, _spec); err != nil { - if _, ok := err.(*sqlgraph.NotFoundError); ok { - err = &NotFoundError{did.Label} - } else if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return nil, err - } - return _node, nil -} diff --git a/ent/ent.go b/ent/ent.go deleted file mode 100644 index 4885a407..00000000 --- a/ent/ent.go +++ /dev/null @@ -1,475 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - - "entgo.io/ent" - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "github.com/fiware/vcverifier/ent/credential" - "github.com/fiware/vcverifier/ent/did" - "github.com/fiware/vcverifier/ent/naturalperson" - "github.com/fiware/vcverifier/ent/privatekey" - "github.com/fiware/vcverifier/ent/publickey" - "github.com/fiware/vcverifier/ent/user" -) - -// ent aliases to avoid import conflicts in user's code. -type ( - Op = ent.Op - Hook = ent.Hook - Value = ent.Value - Query = ent.Query - Policy = ent.Policy - Mutator = ent.Mutator - Mutation = ent.Mutation - MutateFunc = ent.MutateFunc -) - -// OrderFunc applies an ordering on the sql selector. -type OrderFunc func(*sql.Selector) - -// columnChecker returns a function indicates if the column exists in the given column. -func columnChecker(table string) func(string) error { - checks := map[string]func(string) bool{ - credential.Table: credential.ValidColumn, - did.Table: did.ValidColumn, - naturalperson.Table: naturalperson.ValidColumn, - privatekey.Table: privatekey.ValidColumn, - publickey.Table: publickey.ValidColumn, - user.Table: user.ValidColumn, - } - check, ok := checks[table] - if !ok { - return func(string) error { - return fmt.Errorf("unknown table %q", table) - } - } - return func(column string) error { - if !check(column) { - return fmt.Errorf("unknown column %q for table %q", column, table) - } - return nil - } -} - -// Asc applies the given fields in ASC order. -func Asc(fields ...string) OrderFunc { - return func(s *sql.Selector) { - check := columnChecker(s.TableName()) - for _, f := range fields { - if err := check(f); err != nil { - s.AddError(&ValidationError{Name: f, err: fmt.Errorf("ent: %w", err)}) - } - s.OrderBy(sql.Asc(s.C(f))) - } - } -} - -// Desc applies the given fields in DESC order. -func Desc(fields ...string) OrderFunc { - return func(s *sql.Selector) { - check := columnChecker(s.TableName()) - for _, f := range fields { - if err := check(f); err != nil { - s.AddError(&ValidationError{Name: f, err: fmt.Errorf("ent: %w", err)}) - } - s.OrderBy(sql.Desc(s.C(f))) - } - } -} - -// AggregateFunc applies an aggregation step on the group-by traversal/selector. -type AggregateFunc func(*sql.Selector) string - -// As is a pseudo aggregation function for renaming another other functions with custom names. For example: -// -// GroupBy(field1, field2). -// Aggregate(ent.As(ent.Sum(field1), "sum_field1"), (ent.As(ent.Sum(field2), "sum_field2")). -// Scan(ctx, &v) -func As(fn AggregateFunc, end string) AggregateFunc { - return func(s *sql.Selector) string { - return sql.As(fn(s), end) - } -} - -// Count applies the "count" aggregation function on each group. -func Count() AggregateFunc { - return func(s *sql.Selector) string { - return sql.Count("*") - } -} - -// Max applies the "max" aggregation function on the given field of each group. -func Max(field string) AggregateFunc { - return func(s *sql.Selector) string { - check := columnChecker(s.TableName()) - if err := check(field); err != nil { - s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) - return "" - } - return sql.Max(s.C(field)) - } -} - -// Mean applies the "mean" aggregation function on the given field of each group. -func Mean(field string) AggregateFunc { - return func(s *sql.Selector) string { - check := columnChecker(s.TableName()) - if err := check(field); err != nil { - s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) - return "" - } - return sql.Avg(s.C(field)) - } -} - -// Min applies the "min" aggregation function on the given field of each group. -func Min(field string) AggregateFunc { - return func(s *sql.Selector) string { - check := columnChecker(s.TableName()) - if err := check(field); err != nil { - s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) - return "" - } - return sql.Min(s.C(field)) - } -} - -// Sum applies the "sum" aggregation function on the given field of each group. -func Sum(field string) AggregateFunc { - return func(s *sql.Selector) string { - check := columnChecker(s.TableName()) - if err := check(field); err != nil { - s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) - return "" - } - return sql.Sum(s.C(field)) - } -} - -// ValidationError returns when validating a field or edge fails. -type ValidationError struct { - Name string // Field or edge name. - err error -} - -// Error implements the error interface. -func (e *ValidationError) Error() string { - return e.err.Error() -} - -// Unwrap implements the errors.Wrapper interface. -func (e *ValidationError) Unwrap() error { - return e.err -} - -// IsValidationError returns a boolean indicating whether the error is a validation error. -func IsValidationError(err error) bool { - if err == nil { - return false - } - var e *ValidationError - return errors.As(err, &e) -} - -// NotFoundError returns when trying to fetch a specific entity and it was not found in the database. -type NotFoundError struct { - label string -} - -// Error implements the error interface. -func (e *NotFoundError) Error() string { - return "ent: " + e.label + " not found" -} - -// IsNotFound returns a boolean indicating whether the error is a not found error. -func IsNotFound(err error) bool { - if err == nil { - return false - } - var e *NotFoundError - return errors.As(err, &e) -} - -// MaskNotFound masks not found error. -func MaskNotFound(err error) error { - if IsNotFound(err) { - return nil - } - return err -} - -// NotSingularError returns when trying to fetch a singular entity and more then one was found in the database. -type NotSingularError struct { - label string -} - -// Error implements the error interface. -func (e *NotSingularError) Error() string { - return "ent: " + e.label + " not singular" -} - -// IsNotSingular returns a boolean indicating whether the error is a not singular error. -func IsNotSingular(err error) bool { - if err == nil { - return false - } - var e *NotSingularError - return errors.As(err, &e) -} - -// NotLoadedError returns when trying to get a node that was not loaded by the query. -type NotLoadedError struct { - edge string -} - -// Error implements the error interface. -func (e *NotLoadedError) Error() string { - return "ent: " + e.edge + " edge was not loaded" -} - -// IsNotLoaded returns a boolean indicating whether the error is a not loaded error. -func IsNotLoaded(err error) bool { - if err == nil { - return false - } - var e *NotLoadedError - return errors.As(err, &e) -} - -// ConstraintError returns when trying to create/update one or more entities and -// one or more of their constraints failed. For example, violation of edge or -// field uniqueness. -type ConstraintError struct { - msg string - wrap error -} - -// Error implements the error interface. -func (e ConstraintError) Error() string { - return "ent: constraint failed: " + e.msg -} - -// Unwrap implements the errors.Wrapper interface. -func (e *ConstraintError) Unwrap() error { - return e.wrap -} - -// IsConstraintError returns a boolean indicating whether the error is a constraint failure. -func IsConstraintError(err error) bool { - if err == nil { - return false - } - var e *ConstraintError - return errors.As(err, &e) -} - -// selector embedded by the different Select/GroupBy builders. -type selector struct { - label string - flds *[]string - scan func(context.Context, interface{}) error -} - -// ScanX is like Scan, but panics if an error occurs. -func (s *selector) ScanX(ctx context.Context, v interface{}) { - if err := s.scan(ctx, v); err != nil { - panic(err) - } -} - -// Strings returns list of strings from a selector. It is only allowed when selecting one field. -func (s *selector) Strings(ctx context.Context) ([]string, error) { - if len(*s.flds) > 1 { - return nil, errors.New("ent: Strings is not achievable when selecting more than 1 field") - } - var v []string - if err := s.scan(ctx, &v); err != nil { - return nil, err - } - return v, nil -} - -// StringsX is like Strings, but panics if an error occurs. -func (s *selector) StringsX(ctx context.Context) []string { - v, err := s.Strings(ctx) - if err != nil { - panic(err) - } - return v -} - -// String returns a single string from a selector. It is only allowed when selecting one field. -func (s *selector) String(ctx context.Context) (_ string, err error) { - var v []string - if v, err = s.Strings(ctx); err != nil { - return - } - switch len(v) { - case 1: - return v[0], nil - case 0: - err = &NotFoundError{s.label} - default: - err = fmt.Errorf("ent: Strings returned %d results when one was expected", len(v)) - } - return -} - -// StringX is like String, but panics if an error occurs. -func (s *selector) StringX(ctx context.Context) string { - v, err := s.String(ctx) - if err != nil { - panic(err) - } - return v -} - -// Ints returns list of ints from a selector. It is only allowed when selecting one field. -func (s *selector) Ints(ctx context.Context) ([]int, error) { - if len(*s.flds) > 1 { - return nil, errors.New("ent: Ints is not achievable when selecting more than 1 field") - } - var v []int - if err := s.scan(ctx, &v); err != nil { - return nil, err - } - return v, nil -} - -// IntsX is like Ints, but panics if an error occurs. -func (s *selector) IntsX(ctx context.Context) []int { - v, err := s.Ints(ctx) - if err != nil { - panic(err) - } - return v -} - -// Int returns a single int from a selector. It is only allowed when selecting one field. -func (s *selector) Int(ctx context.Context) (_ int, err error) { - var v []int - if v, err = s.Ints(ctx); err != nil { - return - } - switch len(v) { - case 1: - return v[0], nil - case 0: - err = &NotFoundError{s.label} - default: - err = fmt.Errorf("ent: Ints returned %d results when one was expected", len(v)) - } - return -} - -// IntX is like Int, but panics if an error occurs. -func (s *selector) IntX(ctx context.Context) int { - v, err := s.Int(ctx) - if err != nil { - panic(err) - } - return v -} - -// Float64s returns list of float64s from a selector. It is only allowed when selecting one field. -func (s *selector) Float64s(ctx context.Context) ([]float64, error) { - if len(*s.flds) > 1 { - return nil, errors.New("ent: Float64s is not achievable when selecting more than 1 field") - } - var v []float64 - if err := s.scan(ctx, &v); err != nil { - return nil, err - } - return v, nil -} - -// Float64sX is like Float64s, but panics if an error occurs. -func (s *selector) Float64sX(ctx context.Context) []float64 { - v, err := s.Float64s(ctx) - if err != nil { - panic(err) - } - return v -} - -// Float64 returns a single float64 from a selector. It is only allowed when selecting one field. -func (s *selector) Float64(ctx context.Context) (_ float64, err error) { - var v []float64 - if v, err = s.Float64s(ctx); err != nil { - return - } - switch len(v) { - case 1: - return v[0], nil - case 0: - err = &NotFoundError{s.label} - default: - err = fmt.Errorf("ent: Float64s returned %d results when one was expected", len(v)) - } - return -} - -// Float64X is like Float64, but panics if an error occurs. -func (s *selector) Float64X(ctx context.Context) float64 { - v, err := s.Float64(ctx) - if err != nil { - panic(err) - } - return v -} - -// Bools returns list of bools from a selector. It is only allowed when selecting one field. -func (s *selector) Bools(ctx context.Context) ([]bool, error) { - if len(*s.flds) > 1 { - return nil, errors.New("ent: Bools is not achievable when selecting more than 1 field") - } - var v []bool - if err := s.scan(ctx, &v); err != nil { - return nil, err - } - return v, nil -} - -// BoolsX is like Bools, but panics if an error occurs. -func (s *selector) BoolsX(ctx context.Context) []bool { - v, err := s.Bools(ctx) - if err != nil { - panic(err) - } - return v -} - -// Bool returns a single bool from a selector. It is only allowed when selecting one field. -func (s *selector) Bool(ctx context.Context) (_ bool, err error) { - var v []bool - if v, err = s.Bools(ctx); err != nil { - return - } - switch len(v) { - case 1: - return v[0], nil - case 0: - err = &NotFoundError{s.label} - default: - err = fmt.Errorf("ent: Bools returned %d results when one was expected", len(v)) - } - return -} - -// BoolX is like Bool, but panics if an error occurs. -func (s *selector) BoolX(ctx context.Context) bool { - v, err := s.Bool(ctx) - if err != nil { - panic(err) - } - return v -} - -// queryHook describes an internal hook for the different sqlAll methods. -type queryHook func(context.Context, *sqlgraph.QuerySpec) diff --git a/ent/enttest/enttest.go b/ent/enttest/enttest.go deleted file mode 100644 index bb2cab3b..00000000 --- a/ent/enttest/enttest.go +++ /dev/null @@ -1,84 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package enttest - -import ( - "context" - - "github.com/fiware/vcverifier/ent" - // required by schema hooks. - _ "github.com/fiware/vcverifier/ent/runtime" - - "entgo.io/ent/dialect/sql/schema" - "github.com/fiware/vcverifier/ent/migrate" -) - -type ( - // TestingT is the interface that is shared between - // testing.T and testing.B and used by enttest. - TestingT interface { - FailNow() - Error(...interface{}) - } - - // Option configures client creation. - Option func(*options) - - options struct { - opts []ent.Option - migrateOpts []schema.MigrateOption - } -) - -// WithOptions forwards options to client creation. -func WithOptions(opts ...ent.Option) Option { - return func(o *options) { - o.opts = append(o.opts, opts...) - } -} - -// WithMigrateOptions forwards options to auto migration. -func WithMigrateOptions(opts ...schema.MigrateOption) Option { - return func(o *options) { - o.migrateOpts = append(o.migrateOpts, opts...) - } -} - -func newOptions(opts []Option) *options { - o := &options{} - for _, opt := range opts { - opt(o) - } - return o -} - -// Open calls ent.Open and auto-run migration. -func Open(t TestingT, driverName, dataSourceName string, opts ...Option) *ent.Client { - o := newOptions(opts) - c, err := ent.Open(driverName, dataSourceName, o.opts...) - if err != nil { - t.Error(err) - t.FailNow() - } - migrateSchema(t, c, o) - return c -} - -// NewClient calls ent.NewClient and auto-run migration. -func NewClient(t TestingT, opts ...Option) *ent.Client { - o := newOptions(opts) - c := ent.NewClient(o.opts...) - migrateSchema(t, c, o) - return c -} -func migrateSchema(t TestingT, c *ent.Client, o *options) { - tables, err := schema.CopyTables(migrate.Tables) - if err != nil { - t.Error(err) - t.FailNow() - } - if err := migrate.Create(context.Background(), c.Schema, tables, o.migrateOpts...); err != nil { - t.Error(err) - t.FailNow() - } -} diff --git a/ent/generate.go b/ent/generate.go deleted file mode 100644 index 8d3fdfdc..00000000 --- a/ent/generate.go +++ /dev/null @@ -1,3 +0,0 @@ -package ent - -//go:generate go run -mod=mod entgo.io/ent/cmd/ent generate ./schema diff --git a/ent/hook/hook.go b/ent/hook/hook.go deleted file mode 100644 index a9e862f2..00000000 --- a/ent/hook/hook.go +++ /dev/null @@ -1,265 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package hook - -import ( - "context" - "fmt" - - "github.com/fiware/vcverifier/ent" -) - -// The CredentialFunc type is an adapter to allow the use of ordinary -// function as Credential mutator. -type CredentialFunc func(context.Context, *ent.CredentialMutation) (ent.Value, error) - -// Mutate calls f(ctx, m). -func (f CredentialFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { - mv, ok := m.(*ent.CredentialMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.CredentialMutation", m) - } - return f(ctx, mv) -} - -// The DIDFunc type is an adapter to allow the use of ordinary -// function as DID mutator. -type DIDFunc func(context.Context, *ent.DIDMutation) (ent.Value, error) - -// Mutate calls f(ctx, m). -func (f DIDFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { - mv, ok := m.(*ent.DIDMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.DIDMutation", m) - } - return f(ctx, mv) -} - -// The NaturalPersonFunc type is an adapter to allow the use of ordinary -// function as NaturalPerson mutator. -type NaturalPersonFunc func(context.Context, *ent.NaturalPersonMutation) (ent.Value, error) - -// Mutate calls f(ctx, m). -func (f NaturalPersonFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { - mv, ok := m.(*ent.NaturalPersonMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.NaturalPersonMutation", m) - } - return f(ctx, mv) -} - -// The PrivateKeyFunc type is an adapter to allow the use of ordinary -// function as PrivateKey mutator. -type PrivateKeyFunc func(context.Context, *ent.PrivateKeyMutation) (ent.Value, error) - -// Mutate calls f(ctx, m). -func (f PrivateKeyFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { - mv, ok := m.(*ent.PrivateKeyMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.PrivateKeyMutation", m) - } - return f(ctx, mv) -} - -// The PublicKeyFunc type is an adapter to allow the use of ordinary -// function as PublicKey mutator. -type PublicKeyFunc func(context.Context, *ent.PublicKeyMutation) (ent.Value, error) - -// Mutate calls f(ctx, m). -func (f PublicKeyFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { - mv, ok := m.(*ent.PublicKeyMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.PublicKeyMutation", m) - } - return f(ctx, mv) -} - -// The UserFunc type is an adapter to allow the use of ordinary -// function as User mutator. -type UserFunc func(context.Context, *ent.UserMutation) (ent.Value, error) - -// Mutate calls f(ctx, m). -func (f UserFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { - mv, ok := m.(*ent.UserMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.UserMutation", m) - } - return f(ctx, mv) -} - -// Condition is a hook condition function. -type Condition func(context.Context, ent.Mutation) bool - -// And groups conditions with the AND operator. -func And(first, second Condition, rest ...Condition) Condition { - return func(ctx context.Context, m ent.Mutation) bool { - if !first(ctx, m) || !second(ctx, m) { - return false - } - for _, cond := range rest { - if !cond(ctx, m) { - return false - } - } - return true - } -} - -// Or groups conditions with the OR operator. -func Or(first, second Condition, rest ...Condition) Condition { - return func(ctx context.Context, m ent.Mutation) bool { - if first(ctx, m) || second(ctx, m) { - return true - } - for _, cond := range rest { - if cond(ctx, m) { - return true - } - } - return false - } -} - -// Not negates a given condition. -func Not(cond Condition) Condition { - return func(ctx context.Context, m ent.Mutation) bool { - return !cond(ctx, m) - } -} - -// HasOp is a condition testing mutation operation. -func HasOp(op ent.Op) Condition { - return func(_ context.Context, m ent.Mutation) bool { - return m.Op().Is(op) - } -} - -// HasAddedFields is a condition validating `.AddedField` on fields. -func HasAddedFields(field string, fields ...string) Condition { - return func(_ context.Context, m ent.Mutation) bool { - if _, exists := m.AddedField(field); !exists { - return false - } - for _, field := range fields { - if _, exists := m.AddedField(field); !exists { - return false - } - } - return true - } -} - -// HasClearedFields is a condition validating `.FieldCleared` on fields. -func HasClearedFields(field string, fields ...string) Condition { - return func(_ context.Context, m ent.Mutation) bool { - if exists := m.FieldCleared(field); !exists { - return false - } - for _, field := range fields { - if exists := m.FieldCleared(field); !exists { - return false - } - } - return true - } -} - -// HasFields is a condition validating `.Field` on fields. -func HasFields(field string, fields ...string) Condition { - return func(_ context.Context, m ent.Mutation) bool { - if _, exists := m.Field(field); !exists { - return false - } - for _, field := range fields { - if _, exists := m.Field(field); !exists { - return false - } - } - return true - } -} - -// If executes the given hook under condition. -// -// hook.If(ComputeAverage, And(HasFields(...), HasAddedFields(...))) -func If(hk ent.Hook, cond Condition) ent.Hook { - return func(next ent.Mutator) ent.Mutator { - return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) { - if cond(ctx, m) { - return hk(next).Mutate(ctx, m) - } - return next.Mutate(ctx, m) - }) - } -} - -// On executes the given hook only for the given operation. -// -// hook.On(Log, ent.Delete|ent.Create) -func On(hk ent.Hook, op ent.Op) ent.Hook { - return If(hk, HasOp(op)) -} - -// Unless skips the given hook only for the given operation. -// -// hook.Unless(Log, ent.Update|ent.UpdateOne) -func Unless(hk ent.Hook, op ent.Op) ent.Hook { - return If(hk, Not(HasOp(op))) -} - -// FixedError is a hook returning a fixed error. -func FixedError(err error) ent.Hook { - return func(ent.Mutator) ent.Mutator { - return ent.MutateFunc(func(context.Context, ent.Mutation) (ent.Value, error) { - return nil, err - }) - } -} - -// Reject returns a hook that rejects all operations that match op. -// -// func (T) Hooks() []ent.Hook { -// return []ent.Hook{ -// Reject(ent.Delete|ent.Update), -// } -// } -func Reject(op ent.Op) ent.Hook { - hk := FixedError(fmt.Errorf("%s operation is not allowed", op)) - return On(hk, op) -} - -// Chain acts as a list of hooks and is effectively immutable. -// Once created, it will always hold the same set of hooks in the same order. -type Chain struct { - hooks []ent.Hook -} - -// NewChain creates a new chain of hooks. -func NewChain(hooks ...ent.Hook) Chain { - return Chain{append([]ent.Hook(nil), hooks...)} -} - -// Hook chains the list of hooks and returns the final hook. -func (c Chain) Hook() ent.Hook { - return func(mutator ent.Mutator) ent.Mutator { - for i := len(c.hooks) - 1; i >= 0; i-- { - mutator = c.hooks[i](mutator) - } - return mutator - } -} - -// Append extends a chain, adding the specified hook -// as the last ones in the mutation flow. -func (c Chain) Append(hooks ...ent.Hook) Chain { - newHooks := make([]ent.Hook, 0, len(c.hooks)+len(hooks)) - newHooks = append(newHooks, c.hooks...) - newHooks = append(newHooks, hooks...) - return Chain{newHooks} -} - -// Extend extends a chain, adding the specified chain -// as the last ones in the mutation flow. -func (c Chain) Extend(chain Chain) Chain { - return c.Append(chain.hooks...) -} diff --git a/ent/migrate/migrate.go b/ent/migrate/migrate.go deleted file mode 100644 index 1956a6bf..00000000 --- a/ent/migrate/migrate.go +++ /dev/null @@ -1,64 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package migrate - -import ( - "context" - "fmt" - "io" - - "entgo.io/ent/dialect" - "entgo.io/ent/dialect/sql/schema" -) - -var ( - // WithGlobalUniqueID sets the universal ids options to the migration. - // If this option is enabled, ent migration will allocate a 1<<32 range - // for the ids of each entity (table). - // Note that this option cannot be applied on tables that already exist. - WithGlobalUniqueID = schema.WithGlobalUniqueID - // WithDropColumn sets the drop column option to the migration. - // If this option is enabled, ent migration will drop old columns - // that were used for both fields and edges. This defaults to false. - WithDropColumn = schema.WithDropColumn - // WithDropIndex sets the drop index option to the migration. - // If this option is enabled, ent migration will drop old indexes - // that were defined in the schema. This defaults to false. - // Note that unique constraints are defined using `UNIQUE INDEX`, - // and therefore, it's recommended to enable this option to get more - // flexibility in the schema changes. - WithDropIndex = schema.WithDropIndex - // WithForeignKeys enables creating foreign-key in schema DDL. This defaults to true. - WithForeignKeys = schema.WithForeignKeys -) - -// Schema is the API for creating, migrating and dropping a schema. -type Schema struct { - drv dialect.Driver -} - -// NewSchema creates a new schema client. -func NewSchema(drv dialect.Driver) *Schema { return &Schema{drv: drv} } - -// Create creates all schema resources. -func (s *Schema) Create(ctx context.Context, opts ...schema.MigrateOption) error { - return Create(ctx, s, Tables, opts...) -} - -// Create creates all table resources using the given schema driver. -func Create(ctx context.Context, s *Schema, tables []*schema.Table, opts ...schema.MigrateOption) error { - migrate, err := schema.NewMigrate(s.drv, opts...) - if err != nil { - return fmt.Errorf("ent/migrate: %w", err) - } - return migrate.Create(ctx, tables...) -} - -// WriteTo writes the schema changes to w instead of running them against the database. -// -// if err := client.Schema.WriteTo(context.Background(), os.Stdout); err != nil { -// log.Fatal(err) -// } -func (s *Schema) WriteTo(ctx context.Context, w io.Writer, opts ...schema.MigrateOption) error { - return Create(ctx, &Schema{drv: &schema.WriteDriver{Writer: w, Driver: s.drv}}, Tables, opts...) -} diff --git a/ent/migrate/schema.go b/ent/migrate/schema.go deleted file mode 100644 index fb86413c..00000000 --- a/ent/migrate/schema.go +++ /dev/null @@ -1,158 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package migrate - -import ( - "entgo.io/ent/dialect/sql/schema" - "entgo.io/ent/schema/field" -) - -var ( - // CredentialsColumns holds the columns for the "credentials" table. - CredentialsColumns = []*schema.Column{ - {Name: "id", Type: field.TypeString, Unique: true}, - {Name: "type", Type: field.TypeString, Default: "jwt_vc"}, - {Name: "raw", Type: field.TypeJSON}, - {Name: "created_at", Type: field.TypeTime}, - {Name: "updated_at", Type: field.TypeTime}, - {Name: "natural_person_credentials", Type: field.TypeString, Nullable: true}, - {Name: "user_credentials", Type: field.TypeString, Nullable: true}, - } - // CredentialsTable holds the schema information for the "credentials" table. - CredentialsTable = &schema.Table{ - Name: "credentials", - Columns: CredentialsColumns, - PrimaryKey: []*schema.Column{CredentialsColumns[0]}, - ForeignKeys: []*schema.ForeignKey{ - { - Symbol: "credentials_natural_persons_credentials", - Columns: []*schema.Column{CredentialsColumns[5]}, - RefColumns: []*schema.Column{NaturalPersonsColumns[0]}, - OnDelete: schema.SetNull, - }, - { - Symbol: "credentials_users_credentials", - Columns: []*schema.Column{CredentialsColumns[6]}, - RefColumns: []*schema.Column{UsersColumns[0]}, - OnDelete: schema.SetNull, - }, - }, - } - // DiDsColumns holds the columns for the "di_ds" table. - DiDsColumns = []*schema.Column{ - {Name: "id", Type: field.TypeString, Unique: true}, - {Name: "method", Type: field.TypeString, Nullable: true}, - {Name: "created_at", Type: field.TypeTime}, - {Name: "updated_at", Type: field.TypeTime}, - {Name: "user_dids", Type: field.TypeString, Nullable: true}, - } - // DiDsTable holds the schema information for the "di_ds" table. - DiDsTable = &schema.Table{ - Name: "di_ds", - Columns: DiDsColumns, - PrimaryKey: []*schema.Column{DiDsColumns[0]}, - ForeignKeys: []*schema.ForeignKey{ - { - Symbol: "di_ds_users_dids", - Columns: []*schema.Column{DiDsColumns[4]}, - RefColumns: []*schema.Column{UsersColumns[0]}, - OnDelete: schema.SetNull, - }, - }, - } - // NaturalPersonsColumns holds the columns for the "natural_persons" table. - NaturalPersonsColumns = []*schema.Column{ - {Name: "id", Type: field.TypeString, Unique: true}, - {Name: "name", Type: field.TypeString}, - {Name: "displayname", Type: field.TypeString, Nullable: true}, - {Name: "type", Type: field.TypeString}, - {Name: "password", Type: field.TypeBytes}, - {Name: "created_at", Type: field.TypeTime}, - {Name: "updated_at", Type: field.TypeTime}, - } - // NaturalPersonsTable holds the schema information for the "natural_persons" table. - NaturalPersonsTable = &schema.Table{ - Name: "natural_persons", - Columns: NaturalPersonsColumns, - PrimaryKey: []*schema.Column{NaturalPersonsColumns[0]}, - } - // PrivateKeysColumns holds the columns for the "private_keys" table. - PrivateKeysColumns = []*schema.Column{ - {Name: "id", Type: field.TypeString, Unique: true}, - {Name: "kty", Type: field.TypeString}, - {Name: "alg", Type: field.TypeString, Nullable: true}, - {Name: "jwk", Type: field.TypeJSON}, - {Name: "created_at", Type: field.TypeTime}, - {Name: "updated_at", Type: field.TypeTime}, - {Name: "natural_person_keys", Type: field.TypeString, Nullable: true}, - {Name: "user_keys", Type: field.TypeString, Nullable: true}, - } - // PrivateKeysTable holds the schema information for the "private_keys" table. - PrivateKeysTable = &schema.Table{ - Name: "private_keys", - Columns: PrivateKeysColumns, - PrimaryKey: []*schema.Column{PrivateKeysColumns[0]}, - ForeignKeys: []*schema.ForeignKey{ - { - Symbol: "private_keys_natural_persons_keys", - Columns: []*schema.Column{PrivateKeysColumns[6]}, - RefColumns: []*schema.Column{NaturalPersonsColumns[0]}, - OnDelete: schema.SetNull, - }, - { - Symbol: "private_keys_users_keys", - Columns: []*schema.Column{PrivateKeysColumns[7]}, - RefColumns: []*schema.Column{UsersColumns[0]}, - OnDelete: schema.SetNull, - }, - }, - } - // PublicKeysColumns holds the columns for the "public_keys" table. - PublicKeysColumns = []*schema.Column{ - {Name: "id", Type: field.TypeString, Unique: true}, - {Name: "kty", Type: field.TypeString}, - {Name: "alg", Type: field.TypeString, Nullable: true}, - {Name: "jwk", Type: field.TypeJSON}, - {Name: "created_at", Type: field.TypeTime}, - {Name: "updated_at", Type: field.TypeTime}, - } - // PublicKeysTable holds the schema information for the "public_keys" table. - PublicKeysTable = &schema.Table{ - Name: "public_keys", - Columns: PublicKeysColumns, - PrimaryKey: []*schema.Column{PublicKeysColumns[0]}, - } - // UsersColumns holds the columns for the "users" table. - UsersColumns = []*schema.Column{ - {Name: "id", Type: field.TypeString, Unique: true}, - {Name: "name", Type: field.TypeString}, - {Name: "displayname", Type: field.TypeString, Nullable: true}, - {Name: "type", Type: field.TypeString}, - {Name: "password", Type: field.TypeBytes}, - {Name: "created_at", Type: field.TypeTime}, - {Name: "updated_at", Type: field.TypeTime}, - } - // UsersTable holds the schema information for the "users" table. - UsersTable = &schema.Table{ - Name: "users", - Columns: UsersColumns, - PrimaryKey: []*schema.Column{UsersColumns[0]}, - } - // Tables holds all the tables in the schema. - Tables = []*schema.Table{ - CredentialsTable, - DiDsTable, - NaturalPersonsTable, - PrivateKeysTable, - PublicKeysTable, - UsersTable, - } -) - -func init() { - CredentialsTable.ForeignKeys[0].RefTable = NaturalPersonsTable - CredentialsTable.ForeignKeys[1].RefTable = UsersTable - DiDsTable.ForeignKeys[0].RefTable = UsersTable - PrivateKeysTable.ForeignKeys[0].RefTable = NaturalPersonsTable - PrivateKeysTable.ForeignKeys[1].RefTable = UsersTable -} diff --git a/ent/mutation.go b/ent/mutation.go deleted file mode 100644 index d69b249c..00000000 --- a/ent/mutation.go +++ /dev/null @@ -1,3934 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - "sync" - "time" - - "github.com/fiware/vcverifier/ent/credential" - "github.com/fiware/vcverifier/ent/did" - "github.com/fiware/vcverifier/ent/naturalperson" - "github.com/fiware/vcverifier/ent/predicate" - "github.com/fiware/vcverifier/ent/privatekey" - "github.com/fiware/vcverifier/ent/publickey" - "github.com/fiware/vcverifier/ent/user" - - "entgo.io/ent" -) - -const ( - // Operation types. - OpCreate = ent.OpCreate - OpDelete = ent.OpDelete - OpDeleteOne = ent.OpDeleteOne - OpUpdate = ent.OpUpdate - OpUpdateOne = ent.OpUpdateOne - - // Node types. - TypeCredential = "Credential" - TypeDID = "DID" - TypeNaturalPerson = "NaturalPerson" - TypePrivateKey = "PrivateKey" - TypePublicKey = "PublicKey" - TypeUser = "User" -) - -// CredentialMutation represents an operation that mutates the Credential nodes in the graph. -type CredentialMutation struct { - config - op Op - typ string - id *string - _type *string - raw *[]uint8 - created_at *time.Time - updated_at *time.Time - clearedFields map[string]struct{} - account *string - clearedaccount bool - done bool - oldValue func(context.Context) (*Credential, error) - predicates []predicate.Credential -} - -var _ ent.Mutation = (*CredentialMutation)(nil) - -// credentialOption allows management of the mutation configuration using functional options. -type credentialOption func(*CredentialMutation) - -// newCredentialMutation creates new mutation for the Credential entity. -func newCredentialMutation(c config, op Op, opts ...credentialOption) *CredentialMutation { - m := &CredentialMutation{ - config: c, - op: op, - typ: TypeCredential, - clearedFields: make(map[string]struct{}), - } - for _, opt := range opts { - opt(m) - } - return m -} - -// withCredentialID sets the ID field of the mutation. -func withCredentialID(id string) credentialOption { - return func(m *CredentialMutation) { - var ( - err error - once sync.Once - value *Credential - ) - m.oldValue = func(ctx context.Context) (*Credential, error) { - once.Do(func() { - if m.done { - err = errors.New("querying old values post mutation is not allowed") - } else { - value, err = m.Client().Credential.Get(ctx, id) - } - }) - return value, err - } - m.id = &id - } -} - -// withCredential sets the old Credential of the mutation. -func withCredential(node *Credential) credentialOption { - return func(m *CredentialMutation) { - m.oldValue = func(context.Context) (*Credential, error) { - return node, nil - } - m.id = &node.ID - } -} - -// Client returns a new `ent.Client` from the mutation. If the mutation was -// executed in a transaction (ent.Tx), a transactional client is returned. -func (m CredentialMutation) Client() *Client { - client := &Client{config: m.config} - client.init() - return client -} - -// Tx returns an `ent.Tx` for mutations that were executed in transactions; -// it returns an error otherwise. -func (m CredentialMutation) Tx() (*Tx, error) { - if _, ok := m.driver.(*txDriver); !ok { - return nil, errors.New("ent: mutation is not running in a transaction") - } - tx := &Tx{config: m.config} - tx.init() - return tx, nil -} - -// SetID sets the value of the id field. Note that this -// operation is only accepted on creation of Credential entities. -func (m *CredentialMutation) SetID(id string) { - m.id = &id -} - -// ID returns the ID value in the mutation. Note that the ID is only available -// if it was provided to the builder or after it was returned from the database. -func (m *CredentialMutation) ID() (id string, exists bool) { - if m.id == nil { - return - } - return *m.id, true -} - -// IDs queries the database and returns the entity ids that match the mutation's predicate. -// That means, if the mutation is applied within a transaction with an isolation level such -// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated -// or updated by the mutation. -func (m *CredentialMutation) IDs(ctx context.Context) ([]string, error) { - switch { - case m.op.Is(OpUpdateOne | OpDeleteOne): - id, exists := m.ID() - if exists { - return []string{id}, nil - } - fallthrough - case m.op.Is(OpUpdate | OpDelete): - return m.Client().Credential.Query().Where(m.predicates...).IDs(ctx) - default: - return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) - } -} - -// SetType sets the "type" field. -func (m *CredentialMutation) SetType(s string) { - m._type = &s -} - -// GetType returns the value of the "type" field in the mutation. -func (m *CredentialMutation) GetType() (r string, exists bool) { - v := m._type - if v == nil { - return - } - return *v, true -} - -// OldType returns the old "type" field's value of the Credential entity. -// If the Credential object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *CredentialMutation) OldType(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldType is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldType requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldType: %w", err) - } - return oldValue.Type, nil -} - -// ResetType resets all changes to the "type" field. -func (m *CredentialMutation) ResetType() { - m._type = nil -} - -// SetRaw sets the "raw" field. -func (m *CredentialMutation) SetRaw(u []uint8) { - m.raw = &u -} - -// Raw returns the value of the "raw" field in the mutation. -func (m *CredentialMutation) Raw() (r []uint8, exists bool) { - v := m.raw - if v == nil { - return - } - return *v, true -} - -// OldRaw returns the old "raw" field's value of the Credential entity. -// If the Credential object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *CredentialMutation) OldRaw(ctx context.Context) (v []uint8, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldRaw is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldRaw requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldRaw: %w", err) - } - return oldValue.Raw, nil -} - -// ResetRaw resets all changes to the "raw" field. -func (m *CredentialMutation) ResetRaw() { - m.raw = nil -} - -// SetCreatedAt sets the "created_at" field. -func (m *CredentialMutation) SetCreatedAt(t time.Time) { - m.created_at = &t -} - -// CreatedAt returns the value of the "created_at" field in the mutation. -func (m *CredentialMutation) CreatedAt() (r time.Time, exists bool) { - v := m.created_at - if v == nil { - return - } - return *v, true -} - -// OldCreatedAt returns the old "created_at" field's value of the Credential entity. -// If the Credential object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *CredentialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldCreatedAt requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) - } - return oldValue.CreatedAt, nil -} - -// ResetCreatedAt resets all changes to the "created_at" field. -func (m *CredentialMutation) ResetCreatedAt() { - m.created_at = nil -} - -// SetUpdatedAt sets the "updated_at" field. -func (m *CredentialMutation) SetUpdatedAt(t time.Time) { - m.updated_at = &t -} - -// UpdatedAt returns the value of the "updated_at" field in the mutation. -func (m *CredentialMutation) UpdatedAt() (r time.Time, exists bool) { - v := m.updated_at - if v == nil { - return - } - return *v, true -} - -// OldUpdatedAt returns the old "updated_at" field's value of the Credential entity. -// If the Credential object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *CredentialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUpdatedAt requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) - } - return oldValue.UpdatedAt, nil -} - -// ResetUpdatedAt resets all changes to the "updated_at" field. -func (m *CredentialMutation) ResetUpdatedAt() { - m.updated_at = nil -} - -// SetAccountID sets the "account" edge to the User entity by id. -func (m *CredentialMutation) SetAccountID(id string) { - m.account = &id -} - -// ClearAccount clears the "account" edge to the User entity. -func (m *CredentialMutation) ClearAccount() { - m.clearedaccount = true -} - -// AccountCleared reports if the "account" edge to the User entity was cleared. -func (m *CredentialMutation) AccountCleared() bool { - return m.clearedaccount -} - -// AccountID returns the "account" edge ID in the mutation. -func (m *CredentialMutation) AccountID() (id string, exists bool) { - if m.account != nil { - return *m.account, true - } - return -} - -// AccountIDs returns the "account" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// AccountID instead. It exists only for internal usage by the builders. -func (m *CredentialMutation) AccountIDs() (ids []string) { - if id := m.account; id != nil { - ids = append(ids, *id) - } - return -} - -// ResetAccount resets all changes to the "account" edge. -func (m *CredentialMutation) ResetAccount() { - m.account = nil - m.clearedaccount = false -} - -// Where appends a list predicates to the CredentialMutation builder. -func (m *CredentialMutation) Where(ps ...predicate.Credential) { - m.predicates = append(m.predicates, ps...) -} - -// Op returns the operation name. -func (m *CredentialMutation) Op() Op { - return m.op -} - -// Type returns the node type of this mutation (Credential). -func (m *CredentialMutation) Type() string { - return m.typ -} - -// Fields returns all fields that were changed during this mutation. Note that in -// order to get all numeric fields that were incremented/decremented, call -// AddedFields(). -func (m *CredentialMutation) Fields() []string { - fields := make([]string, 0, 4) - if m._type != nil { - fields = append(fields, credential.FieldType) - } - if m.raw != nil { - fields = append(fields, credential.FieldRaw) - } - if m.created_at != nil { - fields = append(fields, credential.FieldCreatedAt) - } - if m.updated_at != nil { - fields = append(fields, credential.FieldUpdatedAt) - } - return fields -} - -// Field returns the value of a field with the given name. The second boolean -// return value indicates that this field was not set, or was not defined in the -// schema. -func (m *CredentialMutation) Field(name string) (ent.Value, bool) { - switch name { - case credential.FieldType: - return m.GetType() - case credential.FieldRaw: - return m.Raw() - case credential.FieldCreatedAt: - return m.CreatedAt() - case credential.FieldUpdatedAt: - return m.UpdatedAt() - } - return nil, false -} - -// OldField returns the old value of the field from the database. An error is -// returned if the mutation operation is not UpdateOne, or the query to the -// database failed. -func (m *CredentialMutation) OldField(ctx context.Context, name string) (ent.Value, error) { - switch name { - case credential.FieldType: - return m.OldType(ctx) - case credential.FieldRaw: - return m.OldRaw(ctx) - case credential.FieldCreatedAt: - return m.OldCreatedAt(ctx) - case credential.FieldUpdatedAt: - return m.OldUpdatedAt(ctx) - } - return nil, fmt.Errorf("unknown Credential field %s", name) -} - -// SetField sets the value of a field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *CredentialMutation) SetField(name string, value ent.Value) error { - switch name { - case credential.FieldType: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetType(v) - return nil - case credential.FieldRaw: - v, ok := value.([]uint8) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetRaw(v) - return nil - case credential.FieldCreatedAt: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetCreatedAt(v) - return nil - case credential.FieldUpdatedAt: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetUpdatedAt(v) - return nil - } - return fmt.Errorf("unknown Credential field %s", name) -} - -// AddedFields returns all numeric fields that were incremented/decremented during -// this mutation. -func (m *CredentialMutation) AddedFields() []string { - return nil -} - -// AddedField returns the numeric value that was incremented/decremented on a field -// with the given name. The second boolean return value indicates that this field -// was not set, or was not defined in the schema. -func (m *CredentialMutation) AddedField(name string) (ent.Value, bool) { - return nil, false -} - -// AddField adds the value to the field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *CredentialMutation) AddField(name string, value ent.Value) error { - switch name { - } - return fmt.Errorf("unknown Credential numeric field %s", name) -} - -// ClearedFields returns all nullable fields that were cleared during this -// mutation. -func (m *CredentialMutation) ClearedFields() []string { - return nil -} - -// FieldCleared returns a boolean indicating if a field with the given name was -// cleared in this mutation. -func (m *CredentialMutation) FieldCleared(name string) bool { - _, ok := m.clearedFields[name] - return ok -} - -// ClearField clears the value of the field with the given name. It returns an -// error if the field is not defined in the schema. -func (m *CredentialMutation) ClearField(name string) error { - return fmt.Errorf("unknown Credential nullable field %s", name) -} - -// ResetField resets all changes in the mutation for the field with the given name. -// It returns an error if the field is not defined in the schema. -func (m *CredentialMutation) ResetField(name string) error { - switch name { - case credential.FieldType: - m.ResetType() - return nil - case credential.FieldRaw: - m.ResetRaw() - return nil - case credential.FieldCreatedAt: - m.ResetCreatedAt() - return nil - case credential.FieldUpdatedAt: - m.ResetUpdatedAt() - return nil - } - return fmt.Errorf("unknown Credential field %s", name) -} - -// AddedEdges returns all edge names that were set/added in this mutation. -func (m *CredentialMutation) AddedEdges() []string { - edges := make([]string, 0, 1) - if m.account != nil { - edges = append(edges, credential.EdgeAccount) - } - return edges -} - -// AddedIDs returns all IDs (to other nodes) that were added for the given edge -// name in this mutation. -func (m *CredentialMutation) AddedIDs(name string) []ent.Value { - switch name { - case credential.EdgeAccount: - if id := m.account; id != nil { - return []ent.Value{*id} - } - } - return nil -} - -// RemovedEdges returns all edge names that were removed in this mutation. -func (m *CredentialMutation) RemovedEdges() []string { - edges := make([]string, 0, 1) - return edges -} - -// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with -// the given name in this mutation. -func (m *CredentialMutation) RemovedIDs(name string) []ent.Value { - switch name { - } - return nil -} - -// ClearedEdges returns all edge names that were cleared in this mutation. -func (m *CredentialMutation) ClearedEdges() []string { - edges := make([]string, 0, 1) - if m.clearedaccount { - edges = append(edges, credential.EdgeAccount) - } - return edges -} - -// EdgeCleared returns a boolean which indicates if the edge with the given name -// was cleared in this mutation. -func (m *CredentialMutation) EdgeCleared(name string) bool { - switch name { - case credential.EdgeAccount: - return m.clearedaccount - } - return false -} - -// ClearEdge clears the value of the edge with the given name. It returns an error -// if that edge is not defined in the schema. -func (m *CredentialMutation) ClearEdge(name string) error { - switch name { - case credential.EdgeAccount: - m.ClearAccount() - return nil - } - return fmt.Errorf("unknown Credential unique edge %s", name) -} - -// ResetEdge resets all changes to the edge with the given name in this mutation. -// It returns an error if the edge is not defined in the schema. -func (m *CredentialMutation) ResetEdge(name string) error { - switch name { - case credential.EdgeAccount: - m.ResetAccount() - return nil - } - return fmt.Errorf("unknown Credential edge %s", name) -} - -// DIDMutation represents an operation that mutates the DID nodes in the graph. -type DIDMutation struct { - config - op Op - typ string - id *string - method *string - created_at *time.Time - updated_at *time.Time - clearedFields map[string]struct{} - user *string - cleareduser bool - done bool - oldValue func(context.Context) (*DID, error) - predicates []predicate.DID -} - -var _ ent.Mutation = (*DIDMutation)(nil) - -// didOption allows management of the mutation configuration using functional options. -type didOption func(*DIDMutation) - -// newDIDMutation creates new mutation for the DID entity. -func newDIDMutation(c config, op Op, opts ...didOption) *DIDMutation { - m := &DIDMutation{ - config: c, - op: op, - typ: TypeDID, - clearedFields: make(map[string]struct{}), - } - for _, opt := range opts { - opt(m) - } - return m -} - -// withDIDID sets the ID field of the mutation. -func withDIDID(id string) didOption { - return func(m *DIDMutation) { - var ( - err error - once sync.Once - value *DID - ) - m.oldValue = func(ctx context.Context) (*DID, error) { - once.Do(func() { - if m.done { - err = errors.New("querying old values post mutation is not allowed") - } else { - value, err = m.Client().DID.Get(ctx, id) - } - }) - return value, err - } - m.id = &id - } -} - -// withDID sets the old DID of the mutation. -func withDID(node *DID) didOption { - return func(m *DIDMutation) { - m.oldValue = func(context.Context) (*DID, error) { - return node, nil - } - m.id = &node.ID - } -} - -// Client returns a new `ent.Client` from the mutation. If the mutation was -// executed in a transaction (ent.Tx), a transactional client is returned. -func (m DIDMutation) Client() *Client { - client := &Client{config: m.config} - client.init() - return client -} - -// Tx returns an `ent.Tx` for mutations that were executed in transactions; -// it returns an error otherwise. -func (m DIDMutation) Tx() (*Tx, error) { - if _, ok := m.driver.(*txDriver); !ok { - return nil, errors.New("ent: mutation is not running in a transaction") - } - tx := &Tx{config: m.config} - tx.init() - return tx, nil -} - -// SetID sets the value of the id field. Note that this -// operation is only accepted on creation of DID entities. -func (m *DIDMutation) SetID(id string) { - m.id = &id -} - -// ID returns the ID value in the mutation. Note that the ID is only available -// if it was provided to the builder or after it was returned from the database. -func (m *DIDMutation) ID() (id string, exists bool) { - if m.id == nil { - return - } - return *m.id, true -} - -// IDs queries the database and returns the entity ids that match the mutation's predicate. -// That means, if the mutation is applied within a transaction with an isolation level such -// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated -// or updated by the mutation. -func (m *DIDMutation) IDs(ctx context.Context) ([]string, error) { - switch { - case m.op.Is(OpUpdateOne | OpDeleteOne): - id, exists := m.ID() - if exists { - return []string{id}, nil - } - fallthrough - case m.op.Is(OpUpdate | OpDelete): - return m.Client().DID.Query().Where(m.predicates...).IDs(ctx) - default: - return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) - } -} - -// SetMethod sets the "method" field. -func (m *DIDMutation) SetMethod(s string) { - m.method = &s -} - -// Method returns the value of the "method" field in the mutation. -func (m *DIDMutation) Method() (r string, exists bool) { - v := m.method - if v == nil { - return - } - return *v, true -} - -// OldMethod returns the old "method" field's value of the DID entity. -// If the DID object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *DIDMutation) OldMethod(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldMethod is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldMethod requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldMethod: %w", err) - } - return oldValue.Method, nil -} - -// ClearMethod clears the value of the "method" field. -func (m *DIDMutation) ClearMethod() { - m.method = nil - m.clearedFields[did.FieldMethod] = struct{}{} -} - -// MethodCleared returns if the "method" field was cleared in this mutation. -func (m *DIDMutation) MethodCleared() bool { - _, ok := m.clearedFields[did.FieldMethod] - return ok -} - -// ResetMethod resets all changes to the "method" field. -func (m *DIDMutation) ResetMethod() { - m.method = nil - delete(m.clearedFields, did.FieldMethod) -} - -// SetCreatedAt sets the "created_at" field. -func (m *DIDMutation) SetCreatedAt(t time.Time) { - m.created_at = &t -} - -// CreatedAt returns the value of the "created_at" field in the mutation. -func (m *DIDMutation) CreatedAt() (r time.Time, exists bool) { - v := m.created_at - if v == nil { - return - } - return *v, true -} - -// OldCreatedAt returns the old "created_at" field's value of the DID entity. -// If the DID object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *DIDMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldCreatedAt requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) - } - return oldValue.CreatedAt, nil -} - -// ResetCreatedAt resets all changes to the "created_at" field. -func (m *DIDMutation) ResetCreatedAt() { - m.created_at = nil -} - -// SetUpdatedAt sets the "updated_at" field. -func (m *DIDMutation) SetUpdatedAt(t time.Time) { - m.updated_at = &t -} - -// UpdatedAt returns the value of the "updated_at" field in the mutation. -func (m *DIDMutation) UpdatedAt() (r time.Time, exists bool) { - v := m.updated_at - if v == nil { - return - } - return *v, true -} - -// OldUpdatedAt returns the old "updated_at" field's value of the DID entity. -// If the DID object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *DIDMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUpdatedAt requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) - } - return oldValue.UpdatedAt, nil -} - -// ResetUpdatedAt resets all changes to the "updated_at" field. -func (m *DIDMutation) ResetUpdatedAt() { - m.updated_at = nil -} - -// SetUserID sets the "user" edge to the User entity by id. -func (m *DIDMutation) SetUserID(id string) { - m.user = &id -} - -// ClearUser clears the "user" edge to the User entity. -func (m *DIDMutation) ClearUser() { - m.cleareduser = true -} - -// UserCleared reports if the "user" edge to the User entity was cleared. -func (m *DIDMutation) UserCleared() bool { - return m.cleareduser -} - -// UserID returns the "user" edge ID in the mutation. -func (m *DIDMutation) UserID() (id string, exists bool) { - if m.user != nil { - return *m.user, true - } - return -} - -// UserIDs returns the "user" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// UserID instead. It exists only for internal usage by the builders. -func (m *DIDMutation) UserIDs() (ids []string) { - if id := m.user; id != nil { - ids = append(ids, *id) - } - return -} - -// ResetUser resets all changes to the "user" edge. -func (m *DIDMutation) ResetUser() { - m.user = nil - m.cleareduser = false -} - -// Where appends a list predicates to the DIDMutation builder. -func (m *DIDMutation) Where(ps ...predicate.DID) { - m.predicates = append(m.predicates, ps...) -} - -// Op returns the operation name. -func (m *DIDMutation) Op() Op { - return m.op -} - -// Type returns the node type of this mutation (DID). -func (m *DIDMutation) Type() string { - return m.typ -} - -// Fields returns all fields that were changed during this mutation. Note that in -// order to get all numeric fields that were incremented/decremented, call -// AddedFields(). -func (m *DIDMutation) Fields() []string { - fields := make([]string, 0, 3) - if m.method != nil { - fields = append(fields, did.FieldMethod) - } - if m.created_at != nil { - fields = append(fields, did.FieldCreatedAt) - } - if m.updated_at != nil { - fields = append(fields, did.FieldUpdatedAt) - } - return fields -} - -// Field returns the value of a field with the given name. The second boolean -// return value indicates that this field was not set, or was not defined in the -// schema. -func (m *DIDMutation) Field(name string) (ent.Value, bool) { - switch name { - case did.FieldMethod: - return m.Method() - case did.FieldCreatedAt: - return m.CreatedAt() - case did.FieldUpdatedAt: - return m.UpdatedAt() - } - return nil, false -} - -// OldField returns the old value of the field from the database. An error is -// returned if the mutation operation is not UpdateOne, or the query to the -// database failed. -func (m *DIDMutation) OldField(ctx context.Context, name string) (ent.Value, error) { - switch name { - case did.FieldMethod: - return m.OldMethod(ctx) - case did.FieldCreatedAt: - return m.OldCreatedAt(ctx) - case did.FieldUpdatedAt: - return m.OldUpdatedAt(ctx) - } - return nil, fmt.Errorf("unknown DID field %s", name) -} - -// SetField sets the value of a field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *DIDMutation) SetField(name string, value ent.Value) error { - switch name { - case did.FieldMethod: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetMethod(v) - return nil - case did.FieldCreatedAt: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetCreatedAt(v) - return nil - case did.FieldUpdatedAt: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetUpdatedAt(v) - return nil - } - return fmt.Errorf("unknown DID field %s", name) -} - -// AddedFields returns all numeric fields that were incremented/decremented during -// this mutation. -func (m *DIDMutation) AddedFields() []string { - return nil -} - -// AddedField returns the numeric value that was incremented/decremented on a field -// with the given name. The second boolean return value indicates that this field -// was not set, or was not defined in the schema. -func (m *DIDMutation) AddedField(name string) (ent.Value, bool) { - return nil, false -} - -// AddField adds the value to the field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *DIDMutation) AddField(name string, value ent.Value) error { - switch name { - } - return fmt.Errorf("unknown DID numeric field %s", name) -} - -// ClearedFields returns all nullable fields that were cleared during this -// mutation. -func (m *DIDMutation) ClearedFields() []string { - var fields []string - if m.FieldCleared(did.FieldMethod) { - fields = append(fields, did.FieldMethod) - } - return fields -} - -// FieldCleared returns a boolean indicating if a field with the given name was -// cleared in this mutation. -func (m *DIDMutation) FieldCleared(name string) bool { - _, ok := m.clearedFields[name] - return ok -} - -// ClearField clears the value of the field with the given name. It returns an -// error if the field is not defined in the schema. -func (m *DIDMutation) ClearField(name string) error { - switch name { - case did.FieldMethod: - m.ClearMethod() - return nil - } - return fmt.Errorf("unknown DID nullable field %s", name) -} - -// ResetField resets all changes in the mutation for the field with the given name. -// It returns an error if the field is not defined in the schema. -func (m *DIDMutation) ResetField(name string) error { - switch name { - case did.FieldMethod: - m.ResetMethod() - return nil - case did.FieldCreatedAt: - m.ResetCreatedAt() - return nil - case did.FieldUpdatedAt: - m.ResetUpdatedAt() - return nil - } - return fmt.Errorf("unknown DID field %s", name) -} - -// AddedEdges returns all edge names that were set/added in this mutation. -func (m *DIDMutation) AddedEdges() []string { - edges := make([]string, 0, 1) - if m.user != nil { - edges = append(edges, did.EdgeUser) - } - return edges -} - -// AddedIDs returns all IDs (to other nodes) that were added for the given edge -// name in this mutation. -func (m *DIDMutation) AddedIDs(name string) []ent.Value { - switch name { - case did.EdgeUser: - if id := m.user; id != nil { - return []ent.Value{*id} - } - } - return nil -} - -// RemovedEdges returns all edge names that were removed in this mutation. -func (m *DIDMutation) RemovedEdges() []string { - edges := make([]string, 0, 1) - return edges -} - -// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with -// the given name in this mutation. -func (m *DIDMutation) RemovedIDs(name string) []ent.Value { - switch name { - } - return nil -} - -// ClearedEdges returns all edge names that were cleared in this mutation. -func (m *DIDMutation) ClearedEdges() []string { - edges := make([]string, 0, 1) - if m.cleareduser { - edges = append(edges, did.EdgeUser) - } - return edges -} - -// EdgeCleared returns a boolean which indicates if the edge with the given name -// was cleared in this mutation. -func (m *DIDMutation) EdgeCleared(name string) bool { - switch name { - case did.EdgeUser: - return m.cleareduser - } - return false -} - -// ClearEdge clears the value of the edge with the given name. It returns an error -// if that edge is not defined in the schema. -func (m *DIDMutation) ClearEdge(name string) error { - switch name { - case did.EdgeUser: - m.ClearUser() - return nil - } - return fmt.Errorf("unknown DID unique edge %s", name) -} - -// ResetEdge resets all changes to the edge with the given name in this mutation. -// It returns an error if the edge is not defined in the schema. -func (m *DIDMutation) ResetEdge(name string) error { - switch name { - case did.EdgeUser: - m.ResetUser() - return nil - } - return fmt.Errorf("unknown DID edge %s", name) -} - -// NaturalPersonMutation represents an operation that mutates the NaturalPerson nodes in the graph. -type NaturalPersonMutation struct { - config - op Op - typ string - id *string - name *string - displayname *string - _type *string - password *[]byte - created_at *time.Time - updated_at *time.Time - clearedFields map[string]struct{} - keys map[string]struct{} - removedkeys map[string]struct{} - clearedkeys bool - credentials map[string]struct{} - removedcredentials map[string]struct{} - clearedcredentials bool - done bool - oldValue func(context.Context) (*NaturalPerson, error) - predicates []predicate.NaturalPerson -} - -var _ ent.Mutation = (*NaturalPersonMutation)(nil) - -// naturalpersonOption allows management of the mutation configuration using functional options. -type naturalpersonOption func(*NaturalPersonMutation) - -// newNaturalPersonMutation creates new mutation for the NaturalPerson entity. -func newNaturalPersonMutation(c config, op Op, opts ...naturalpersonOption) *NaturalPersonMutation { - m := &NaturalPersonMutation{ - config: c, - op: op, - typ: TypeNaturalPerson, - clearedFields: make(map[string]struct{}), - } - for _, opt := range opts { - opt(m) - } - return m -} - -// withNaturalPersonID sets the ID field of the mutation. -func withNaturalPersonID(id string) naturalpersonOption { - return func(m *NaturalPersonMutation) { - var ( - err error - once sync.Once - value *NaturalPerson - ) - m.oldValue = func(ctx context.Context) (*NaturalPerson, error) { - once.Do(func() { - if m.done { - err = errors.New("querying old values post mutation is not allowed") - } else { - value, err = m.Client().NaturalPerson.Get(ctx, id) - } - }) - return value, err - } - m.id = &id - } -} - -// withNaturalPerson sets the old NaturalPerson of the mutation. -func withNaturalPerson(node *NaturalPerson) naturalpersonOption { - return func(m *NaturalPersonMutation) { - m.oldValue = func(context.Context) (*NaturalPerson, error) { - return node, nil - } - m.id = &node.ID - } -} - -// Client returns a new `ent.Client` from the mutation. If the mutation was -// executed in a transaction (ent.Tx), a transactional client is returned. -func (m NaturalPersonMutation) Client() *Client { - client := &Client{config: m.config} - client.init() - return client -} - -// Tx returns an `ent.Tx` for mutations that were executed in transactions; -// it returns an error otherwise. -func (m NaturalPersonMutation) Tx() (*Tx, error) { - if _, ok := m.driver.(*txDriver); !ok { - return nil, errors.New("ent: mutation is not running in a transaction") - } - tx := &Tx{config: m.config} - tx.init() - return tx, nil -} - -// SetID sets the value of the id field. Note that this -// operation is only accepted on creation of NaturalPerson entities. -func (m *NaturalPersonMutation) SetID(id string) { - m.id = &id -} - -// ID returns the ID value in the mutation. Note that the ID is only available -// if it was provided to the builder or after it was returned from the database. -func (m *NaturalPersonMutation) ID() (id string, exists bool) { - if m.id == nil { - return - } - return *m.id, true -} - -// IDs queries the database and returns the entity ids that match the mutation's predicate. -// That means, if the mutation is applied within a transaction with an isolation level such -// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated -// or updated by the mutation. -func (m *NaturalPersonMutation) IDs(ctx context.Context) ([]string, error) { - switch { - case m.op.Is(OpUpdateOne | OpDeleteOne): - id, exists := m.ID() - if exists { - return []string{id}, nil - } - fallthrough - case m.op.Is(OpUpdate | OpDelete): - return m.Client().NaturalPerson.Query().Where(m.predicates...).IDs(ctx) - default: - return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) - } -} - -// SetName sets the "name" field. -func (m *NaturalPersonMutation) SetName(s string) { - m.name = &s -} - -// Name returns the value of the "name" field in the mutation. -func (m *NaturalPersonMutation) Name() (r string, exists bool) { - v := m.name - if v == nil { - return - } - return *v, true -} - -// OldName returns the old "name" field's value of the NaturalPerson entity. -// If the NaturalPerson object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NaturalPersonMutation) OldName(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldName is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldName requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldName: %w", err) - } - return oldValue.Name, nil -} - -// ResetName resets all changes to the "name" field. -func (m *NaturalPersonMutation) ResetName() { - m.name = nil -} - -// SetDisplayname sets the "displayname" field. -func (m *NaturalPersonMutation) SetDisplayname(s string) { - m.displayname = &s -} - -// Displayname returns the value of the "displayname" field in the mutation. -func (m *NaturalPersonMutation) Displayname() (r string, exists bool) { - v := m.displayname - if v == nil { - return - } - return *v, true -} - -// OldDisplayname returns the old "displayname" field's value of the NaturalPerson entity. -// If the NaturalPerson object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NaturalPersonMutation) OldDisplayname(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDisplayname is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDisplayname requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldDisplayname: %w", err) - } - return oldValue.Displayname, nil -} - -// ClearDisplayname clears the value of the "displayname" field. -func (m *NaturalPersonMutation) ClearDisplayname() { - m.displayname = nil - m.clearedFields[naturalperson.FieldDisplayname] = struct{}{} -} - -// DisplaynameCleared returns if the "displayname" field was cleared in this mutation. -func (m *NaturalPersonMutation) DisplaynameCleared() bool { - _, ok := m.clearedFields[naturalperson.FieldDisplayname] - return ok -} - -// ResetDisplayname resets all changes to the "displayname" field. -func (m *NaturalPersonMutation) ResetDisplayname() { - m.displayname = nil - delete(m.clearedFields, naturalperson.FieldDisplayname) -} - -// SetType sets the "type" field. -func (m *NaturalPersonMutation) SetType(s string) { - m._type = &s -} - -// GetType returns the value of the "type" field in the mutation. -func (m *NaturalPersonMutation) GetType() (r string, exists bool) { - v := m._type - if v == nil { - return - } - return *v, true -} - -// OldType returns the old "type" field's value of the NaturalPerson entity. -// If the NaturalPerson object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NaturalPersonMutation) OldType(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldType is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldType requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldType: %w", err) - } - return oldValue.Type, nil -} - -// ResetType resets all changes to the "type" field. -func (m *NaturalPersonMutation) ResetType() { - m._type = nil -} - -// SetPassword sets the "password" field. -func (m *NaturalPersonMutation) SetPassword(b []byte) { - m.password = &b -} - -// Password returns the value of the "password" field in the mutation. -func (m *NaturalPersonMutation) Password() (r []byte, exists bool) { - v := m.password - if v == nil { - return - } - return *v, true -} - -// OldPassword returns the old "password" field's value of the NaturalPerson entity. -// If the NaturalPerson object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NaturalPersonMutation) OldPassword(ctx context.Context) (v []byte, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldPassword is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldPassword requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldPassword: %w", err) - } - return oldValue.Password, nil -} - -// ResetPassword resets all changes to the "password" field. -func (m *NaturalPersonMutation) ResetPassword() { - m.password = nil -} - -// SetCreatedAt sets the "created_at" field. -func (m *NaturalPersonMutation) SetCreatedAt(t time.Time) { - m.created_at = &t -} - -// CreatedAt returns the value of the "created_at" field in the mutation. -func (m *NaturalPersonMutation) CreatedAt() (r time.Time, exists bool) { - v := m.created_at - if v == nil { - return - } - return *v, true -} - -// OldCreatedAt returns the old "created_at" field's value of the NaturalPerson entity. -// If the NaturalPerson object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NaturalPersonMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldCreatedAt requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) - } - return oldValue.CreatedAt, nil -} - -// ResetCreatedAt resets all changes to the "created_at" field. -func (m *NaturalPersonMutation) ResetCreatedAt() { - m.created_at = nil -} - -// SetUpdatedAt sets the "updated_at" field. -func (m *NaturalPersonMutation) SetUpdatedAt(t time.Time) { - m.updated_at = &t -} - -// UpdatedAt returns the value of the "updated_at" field in the mutation. -func (m *NaturalPersonMutation) UpdatedAt() (r time.Time, exists bool) { - v := m.updated_at - if v == nil { - return - } - return *v, true -} - -// OldUpdatedAt returns the old "updated_at" field's value of the NaturalPerson entity. -// If the NaturalPerson object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NaturalPersonMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUpdatedAt requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) - } - return oldValue.UpdatedAt, nil -} - -// ResetUpdatedAt resets all changes to the "updated_at" field. -func (m *NaturalPersonMutation) ResetUpdatedAt() { - m.updated_at = nil -} - -// AddKeyIDs adds the "keys" edge to the PrivateKey entity by ids. -func (m *NaturalPersonMutation) AddKeyIDs(ids ...string) { - if m.keys == nil { - m.keys = make(map[string]struct{}) - } - for i := range ids { - m.keys[ids[i]] = struct{}{} - } -} - -// ClearKeys clears the "keys" edge to the PrivateKey entity. -func (m *NaturalPersonMutation) ClearKeys() { - m.clearedkeys = true -} - -// KeysCleared reports if the "keys" edge to the PrivateKey entity was cleared. -func (m *NaturalPersonMutation) KeysCleared() bool { - return m.clearedkeys -} - -// RemoveKeyIDs removes the "keys" edge to the PrivateKey entity by IDs. -func (m *NaturalPersonMutation) RemoveKeyIDs(ids ...string) { - if m.removedkeys == nil { - m.removedkeys = make(map[string]struct{}) - } - for i := range ids { - delete(m.keys, ids[i]) - m.removedkeys[ids[i]] = struct{}{} - } -} - -// RemovedKeys returns the removed IDs of the "keys" edge to the PrivateKey entity. -func (m *NaturalPersonMutation) RemovedKeysIDs() (ids []string) { - for id := range m.removedkeys { - ids = append(ids, id) - } - return -} - -// KeysIDs returns the "keys" edge IDs in the mutation. -func (m *NaturalPersonMutation) KeysIDs() (ids []string) { - for id := range m.keys { - ids = append(ids, id) - } - return -} - -// ResetKeys resets all changes to the "keys" edge. -func (m *NaturalPersonMutation) ResetKeys() { - m.keys = nil - m.clearedkeys = false - m.removedkeys = nil -} - -// AddCredentialIDs adds the "credentials" edge to the Credential entity by ids. -func (m *NaturalPersonMutation) AddCredentialIDs(ids ...string) { - if m.credentials == nil { - m.credentials = make(map[string]struct{}) - } - for i := range ids { - m.credentials[ids[i]] = struct{}{} - } -} - -// ClearCredentials clears the "credentials" edge to the Credential entity. -func (m *NaturalPersonMutation) ClearCredentials() { - m.clearedcredentials = true -} - -// CredentialsCleared reports if the "credentials" edge to the Credential entity was cleared. -func (m *NaturalPersonMutation) CredentialsCleared() bool { - return m.clearedcredentials -} - -// RemoveCredentialIDs removes the "credentials" edge to the Credential entity by IDs. -func (m *NaturalPersonMutation) RemoveCredentialIDs(ids ...string) { - if m.removedcredentials == nil { - m.removedcredentials = make(map[string]struct{}) - } - for i := range ids { - delete(m.credentials, ids[i]) - m.removedcredentials[ids[i]] = struct{}{} - } -} - -// RemovedCredentials returns the removed IDs of the "credentials" edge to the Credential entity. -func (m *NaturalPersonMutation) RemovedCredentialsIDs() (ids []string) { - for id := range m.removedcredentials { - ids = append(ids, id) - } - return -} - -// CredentialsIDs returns the "credentials" edge IDs in the mutation. -func (m *NaturalPersonMutation) CredentialsIDs() (ids []string) { - for id := range m.credentials { - ids = append(ids, id) - } - return -} - -// ResetCredentials resets all changes to the "credentials" edge. -func (m *NaturalPersonMutation) ResetCredentials() { - m.credentials = nil - m.clearedcredentials = false - m.removedcredentials = nil -} - -// Where appends a list predicates to the NaturalPersonMutation builder. -func (m *NaturalPersonMutation) Where(ps ...predicate.NaturalPerson) { - m.predicates = append(m.predicates, ps...) -} - -// Op returns the operation name. -func (m *NaturalPersonMutation) Op() Op { - return m.op -} - -// Type returns the node type of this mutation (NaturalPerson). -func (m *NaturalPersonMutation) Type() string { - return m.typ -} - -// Fields returns all fields that were changed during this mutation. Note that in -// order to get all numeric fields that were incremented/decremented, call -// AddedFields(). -func (m *NaturalPersonMutation) Fields() []string { - fields := make([]string, 0, 6) - if m.name != nil { - fields = append(fields, naturalperson.FieldName) - } - if m.displayname != nil { - fields = append(fields, naturalperson.FieldDisplayname) - } - if m._type != nil { - fields = append(fields, naturalperson.FieldType) - } - if m.password != nil { - fields = append(fields, naturalperson.FieldPassword) - } - if m.created_at != nil { - fields = append(fields, naturalperson.FieldCreatedAt) - } - if m.updated_at != nil { - fields = append(fields, naturalperson.FieldUpdatedAt) - } - return fields -} - -// Field returns the value of a field with the given name. The second boolean -// return value indicates that this field was not set, or was not defined in the -// schema. -func (m *NaturalPersonMutation) Field(name string) (ent.Value, bool) { - switch name { - case naturalperson.FieldName: - return m.Name() - case naturalperson.FieldDisplayname: - return m.Displayname() - case naturalperson.FieldType: - return m.GetType() - case naturalperson.FieldPassword: - return m.Password() - case naturalperson.FieldCreatedAt: - return m.CreatedAt() - case naturalperson.FieldUpdatedAt: - return m.UpdatedAt() - } - return nil, false -} - -// OldField returns the old value of the field from the database. An error is -// returned if the mutation operation is not UpdateOne, or the query to the -// database failed. -func (m *NaturalPersonMutation) OldField(ctx context.Context, name string) (ent.Value, error) { - switch name { - case naturalperson.FieldName: - return m.OldName(ctx) - case naturalperson.FieldDisplayname: - return m.OldDisplayname(ctx) - case naturalperson.FieldType: - return m.OldType(ctx) - case naturalperson.FieldPassword: - return m.OldPassword(ctx) - case naturalperson.FieldCreatedAt: - return m.OldCreatedAt(ctx) - case naturalperson.FieldUpdatedAt: - return m.OldUpdatedAt(ctx) - } - return nil, fmt.Errorf("unknown NaturalPerson field %s", name) -} - -// SetField sets the value of a field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *NaturalPersonMutation) SetField(name string, value ent.Value) error { - switch name { - case naturalperson.FieldName: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetName(v) - return nil - case naturalperson.FieldDisplayname: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetDisplayname(v) - return nil - case naturalperson.FieldType: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetType(v) - return nil - case naturalperson.FieldPassword: - v, ok := value.([]byte) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetPassword(v) - return nil - case naturalperson.FieldCreatedAt: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetCreatedAt(v) - return nil - case naturalperson.FieldUpdatedAt: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetUpdatedAt(v) - return nil - } - return fmt.Errorf("unknown NaturalPerson field %s", name) -} - -// AddedFields returns all numeric fields that were incremented/decremented during -// this mutation. -func (m *NaturalPersonMutation) AddedFields() []string { - return nil -} - -// AddedField returns the numeric value that was incremented/decremented on a field -// with the given name. The second boolean return value indicates that this field -// was not set, or was not defined in the schema. -func (m *NaturalPersonMutation) AddedField(name string) (ent.Value, bool) { - return nil, false -} - -// AddField adds the value to the field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *NaturalPersonMutation) AddField(name string, value ent.Value) error { - switch name { - } - return fmt.Errorf("unknown NaturalPerson numeric field %s", name) -} - -// ClearedFields returns all nullable fields that were cleared during this -// mutation. -func (m *NaturalPersonMutation) ClearedFields() []string { - var fields []string - if m.FieldCleared(naturalperson.FieldDisplayname) { - fields = append(fields, naturalperson.FieldDisplayname) - } - return fields -} - -// FieldCleared returns a boolean indicating if a field with the given name was -// cleared in this mutation. -func (m *NaturalPersonMutation) FieldCleared(name string) bool { - _, ok := m.clearedFields[name] - return ok -} - -// ClearField clears the value of the field with the given name. It returns an -// error if the field is not defined in the schema. -func (m *NaturalPersonMutation) ClearField(name string) error { - switch name { - case naturalperson.FieldDisplayname: - m.ClearDisplayname() - return nil - } - return fmt.Errorf("unknown NaturalPerson nullable field %s", name) -} - -// ResetField resets all changes in the mutation for the field with the given name. -// It returns an error if the field is not defined in the schema. -func (m *NaturalPersonMutation) ResetField(name string) error { - switch name { - case naturalperson.FieldName: - m.ResetName() - return nil - case naturalperson.FieldDisplayname: - m.ResetDisplayname() - return nil - case naturalperson.FieldType: - m.ResetType() - return nil - case naturalperson.FieldPassword: - m.ResetPassword() - return nil - case naturalperson.FieldCreatedAt: - m.ResetCreatedAt() - return nil - case naturalperson.FieldUpdatedAt: - m.ResetUpdatedAt() - return nil - } - return fmt.Errorf("unknown NaturalPerson field %s", name) -} - -// AddedEdges returns all edge names that were set/added in this mutation. -func (m *NaturalPersonMutation) AddedEdges() []string { - edges := make([]string, 0, 2) - if m.keys != nil { - edges = append(edges, naturalperson.EdgeKeys) - } - if m.credentials != nil { - edges = append(edges, naturalperson.EdgeCredentials) - } - return edges -} - -// AddedIDs returns all IDs (to other nodes) that were added for the given edge -// name in this mutation. -func (m *NaturalPersonMutation) AddedIDs(name string) []ent.Value { - switch name { - case naturalperson.EdgeKeys: - ids := make([]ent.Value, 0, len(m.keys)) - for id := range m.keys { - ids = append(ids, id) - } - return ids - case naturalperson.EdgeCredentials: - ids := make([]ent.Value, 0, len(m.credentials)) - for id := range m.credentials { - ids = append(ids, id) - } - return ids - } - return nil -} - -// RemovedEdges returns all edge names that were removed in this mutation. -func (m *NaturalPersonMutation) RemovedEdges() []string { - edges := make([]string, 0, 2) - if m.removedkeys != nil { - edges = append(edges, naturalperson.EdgeKeys) - } - if m.removedcredentials != nil { - edges = append(edges, naturalperson.EdgeCredentials) - } - return edges -} - -// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with -// the given name in this mutation. -func (m *NaturalPersonMutation) RemovedIDs(name string) []ent.Value { - switch name { - case naturalperson.EdgeKeys: - ids := make([]ent.Value, 0, len(m.removedkeys)) - for id := range m.removedkeys { - ids = append(ids, id) - } - return ids - case naturalperson.EdgeCredentials: - ids := make([]ent.Value, 0, len(m.removedcredentials)) - for id := range m.removedcredentials { - ids = append(ids, id) - } - return ids - } - return nil -} - -// ClearedEdges returns all edge names that were cleared in this mutation. -func (m *NaturalPersonMutation) ClearedEdges() []string { - edges := make([]string, 0, 2) - if m.clearedkeys { - edges = append(edges, naturalperson.EdgeKeys) - } - if m.clearedcredentials { - edges = append(edges, naturalperson.EdgeCredentials) - } - return edges -} - -// EdgeCleared returns a boolean which indicates if the edge with the given name -// was cleared in this mutation. -func (m *NaturalPersonMutation) EdgeCleared(name string) bool { - switch name { - case naturalperson.EdgeKeys: - return m.clearedkeys - case naturalperson.EdgeCredentials: - return m.clearedcredentials - } - return false -} - -// ClearEdge clears the value of the edge with the given name. It returns an error -// if that edge is not defined in the schema. -func (m *NaturalPersonMutation) ClearEdge(name string) error { - switch name { - } - return fmt.Errorf("unknown NaturalPerson unique edge %s", name) -} - -// ResetEdge resets all changes to the edge with the given name in this mutation. -// It returns an error if the edge is not defined in the schema. -func (m *NaturalPersonMutation) ResetEdge(name string) error { - switch name { - case naturalperson.EdgeKeys: - m.ResetKeys() - return nil - case naturalperson.EdgeCredentials: - m.ResetCredentials() - return nil - } - return fmt.Errorf("unknown NaturalPerson edge %s", name) -} - -// PrivateKeyMutation represents an operation that mutates the PrivateKey nodes in the graph. -type PrivateKeyMutation struct { - config - op Op - typ string - id *string - kty *string - alg *string - jwk *[]uint8 - created_at *time.Time - updated_at *time.Time - clearedFields map[string]struct{} - user *string - cleareduser bool - done bool - oldValue func(context.Context) (*PrivateKey, error) - predicates []predicate.PrivateKey -} - -var _ ent.Mutation = (*PrivateKeyMutation)(nil) - -// privatekeyOption allows management of the mutation configuration using functional options. -type privatekeyOption func(*PrivateKeyMutation) - -// newPrivateKeyMutation creates new mutation for the PrivateKey entity. -func newPrivateKeyMutation(c config, op Op, opts ...privatekeyOption) *PrivateKeyMutation { - m := &PrivateKeyMutation{ - config: c, - op: op, - typ: TypePrivateKey, - clearedFields: make(map[string]struct{}), - } - for _, opt := range opts { - opt(m) - } - return m -} - -// withPrivateKeyID sets the ID field of the mutation. -func withPrivateKeyID(id string) privatekeyOption { - return func(m *PrivateKeyMutation) { - var ( - err error - once sync.Once - value *PrivateKey - ) - m.oldValue = func(ctx context.Context) (*PrivateKey, error) { - once.Do(func() { - if m.done { - err = errors.New("querying old values post mutation is not allowed") - } else { - value, err = m.Client().PrivateKey.Get(ctx, id) - } - }) - return value, err - } - m.id = &id - } -} - -// withPrivateKey sets the old PrivateKey of the mutation. -func withPrivateKey(node *PrivateKey) privatekeyOption { - return func(m *PrivateKeyMutation) { - m.oldValue = func(context.Context) (*PrivateKey, error) { - return node, nil - } - m.id = &node.ID - } -} - -// Client returns a new `ent.Client` from the mutation. If the mutation was -// executed in a transaction (ent.Tx), a transactional client is returned. -func (m PrivateKeyMutation) Client() *Client { - client := &Client{config: m.config} - client.init() - return client -} - -// Tx returns an `ent.Tx` for mutations that were executed in transactions; -// it returns an error otherwise. -func (m PrivateKeyMutation) Tx() (*Tx, error) { - if _, ok := m.driver.(*txDriver); !ok { - return nil, errors.New("ent: mutation is not running in a transaction") - } - tx := &Tx{config: m.config} - tx.init() - return tx, nil -} - -// SetID sets the value of the id field. Note that this -// operation is only accepted on creation of PrivateKey entities. -func (m *PrivateKeyMutation) SetID(id string) { - m.id = &id -} - -// ID returns the ID value in the mutation. Note that the ID is only available -// if it was provided to the builder or after it was returned from the database. -func (m *PrivateKeyMutation) ID() (id string, exists bool) { - if m.id == nil { - return - } - return *m.id, true -} - -// IDs queries the database and returns the entity ids that match the mutation's predicate. -// That means, if the mutation is applied within a transaction with an isolation level such -// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated -// or updated by the mutation. -func (m *PrivateKeyMutation) IDs(ctx context.Context) ([]string, error) { - switch { - case m.op.Is(OpUpdateOne | OpDeleteOne): - id, exists := m.ID() - if exists { - return []string{id}, nil - } - fallthrough - case m.op.Is(OpUpdate | OpDelete): - return m.Client().PrivateKey.Query().Where(m.predicates...).IDs(ctx) - default: - return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) - } -} - -// SetKty sets the "kty" field. -func (m *PrivateKeyMutation) SetKty(s string) { - m.kty = &s -} - -// Kty returns the value of the "kty" field in the mutation. -func (m *PrivateKeyMutation) Kty() (r string, exists bool) { - v := m.kty - if v == nil { - return - } - return *v, true -} - -// OldKty returns the old "kty" field's value of the PrivateKey entity. -// If the PrivateKey object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *PrivateKeyMutation) OldKty(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldKty is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldKty requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldKty: %w", err) - } - return oldValue.Kty, nil -} - -// ResetKty resets all changes to the "kty" field. -func (m *PrivateKeyMutation) ResetKty() { - m.kty = nil -} - -// SetAlg sets the "alg" field. -func (m *PrivateKeyMutation) SetAlg(s string) { - m.alg = &s -} - -// Alg returns the value of the "alg" field in the mutation. -func (m *PrivateKeyMutation) Alg() (r string, exists bool) { - v := m.alg - if v == nil { - return - } - return *v, true -} - -// OldAlg returns the old "alg" field's value of the PrivateKey entity. -// If the PrivateKey object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *PrivateKeyMutation) OldAlg(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldAlg is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldAlg requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldAlg: %w", err) - } - return oldValue.Alg, nil -} - -// ClearAlg clears the value of the "alg" field. -func (m *PrivateKeyMutation) ClearAlg() { - m.alg = nil - m.clearedFields[privatekey.FieldAlg] = struct{}{} -} - -// AlgCleared returns if the "alg" field was cleared in this mutation. -func (m *PrivateKeyMutation) AlgCleared() bool { - _, ok := m.clearedFields[privatekey.FieldAlg] - return ok -} - -// ResetAlg resets all changes to the "alg" field. -func (m *PrivateKeyMutation) ResetAlg() { - m.alg = nil - delete(m.clearedFields, privatekey.FieldAlg) -} - -// SetJwk sets the "jwk" field. -func (m *PrivateKeyMutation) SetJwk(u []uint8) { - m.jwk = &u -} - -// Jwk returns the value of the "jwk" field in the mutation. -func (m *PrivateKeyMutation) Jwk() (r []uint8, exists bool) { - v := m.jwk - if v == nil { - return - } - return *v, true -} - -// OldJwk returns the old "jwk" field's value of the PrivateKey entity. -// If the PrivateKey object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *PrivateKeyMutation) OldJwk(ctx context.Context) (v []uint8, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldJwk is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldJwk requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldJwk: %w", err) - } - return oldValue.Jwk, nil -} - -// ResetJwk resets all changes to the "jwk" field. -func (m *PrivateKeyMutation) ResetJwk() { - m.jwk = nil -} - -// SetCreatedAt sets the "created_at" field. -func (m *PrivateKeyMutation) SetCreatedAt(t time.Time) { - m.created_at = &t -} - -// CreatedAt returns the value of the "created_at" field in the mutation. -func (m *PrivateKeyMutation) CreatedAt() (r time.Time, exists bool) { - v := m.created_at - if v == nil { - return - } - return *v, true -} - -// OldCreatedAt returns the old "created_at" field's value of the PrivateKey entity. -// If the PrivateKey object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *PrivateKeyMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldCreatedAt requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) - } - return oldValue.CreatedAt, nil -} - -// ResetCreatedAt resets all changes to the "created_at" field. -func (m *PrivateKeyMutation) ResetCreatedAt() { - m.created_at = nil -} - -// SetUpdatedAt sets the "updated_at" field. -func (m *PrivateKeyMutation) SetUpdatedAt(t time.Time) { - m.updated_at = &t -} - -// UpdatedAt returns the value of the "updated_at" field in the mutation. -func (m *PrivateKeyMutation) UpdatedAt() (r time.Time, exists bool) { - v := m.updated_at - if v == nil { - return - } - return *v, true -} - -// OldUpdatedAt returns the old "updated_at" field's value of the PrivateKey entity. -// If the PrivateKey object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *PrivateKeyMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUpdatedAt requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) - } - return oldValue.UpdatedAt, nil -} - -// ResetUpdatedAt resets all changes to the "updated_at" field. -func (m *PrivateKeyMutation) ResetUpdatedAt() { - m.updated_at = nil -} - -// SetUserID sets the "user" edge to the User entity by id. -func (m *PrivateKeyMutation) SetUserID(id string) { - m.user = &id -} - -// ClearUser clears the "user" edge to the User entity. -func (m *PrivateKeyMutation) ClearUser() { - m.cleareduser = true -} - -// UserCleared reports if the "user" edge to the User entity was cleared. -func (m *PrivateKeyMutation) UserCleared() bool { - return m.cleareduser -} - -// UserID returns the "user" edge ID in the mutation. -func (m *PrivateKeyMutation) UserID() (id string, exists bool) { - if m.user != nil { - return *m.user, true - } - return -} - -// UserIDs returns the "user" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// UserID instead. It exists only for internal usage by the builders. -func (m *PrivateKeyMutation) UserIDs() (ids []string) { - if id := m.user; id != nil { - ids = append(ids, *id) - } - return -} - -// ResetUser resets all changes to the "user" edge. -func (m *PrivateKeyMutation) ResetUser() { - m.user = nil - m.cleareduser = false -} - -// Where appends a list predicates to the PrivateKeyMutation builder. -func (m *PrivateKeyMutation) Where(ps ...predicate.PrivateKey) { - m.predicates = append(m.predicates, ps...) -} - -// Op returns the operation name. -func (m *PrivateKeyMutation) Op() Op { - return m.op -} - -// Type returns the node type of this mutation (PrivateKey). -func (m *PrivateKeyMutation) Type() string { - return m.typ -} - -// Fields returns all fields that were changed during this mutation. Note that in -// order to get all numeric fields that were incremented/decremented, call -// AddedFields(). -func (m *PrivateKeyMutation) Fields() []string { - fields := make([]string, 0, 5) - if m.kty != nil { - fields = append(fields, privatekey.FieldKty) - } - if m.alg != nil { - fields = append(fields, privatekey.FieldAlg) - } - if m.jwk != nil { - fields = append(fields, privatekey.FieldJwk) - } - if m.created_at != nil { - fields = append(fields, privatekey.FieldCreatedAt) - } - if m.updated_at != nil { - fields = append(fields, privatekey.FieldUpdatedAt) - } - return fields -} - -// Field returns the value of a field with the given name. The second boolean -// return value indicates that this field was not set, or was not defined in the -// schema. -func (m *PrivateKeyMutation) Field(name string) (ent.Value, bool) { - switch name { - case privatekey.FieldKty: - return m.Kty() - case privatekey.FieldAlg: - return m.Alg() - case privatekey.FieldJwk: - return m.Jwk() - case privatekey.FieldCreatedAt: - return m.CreatedAt() - case privatekey.FieldUpdatedAt: - return m.UpdatedAt() - } - return nil, false -} - -// OldField returns the old value of the field from the database. An error is -// returned if the mutation operation is not UpdateOne, or the query to the -// database failed. -func (m *PrivateKeyMutation) OldField(ctx context.Context, name string) (ent.Value, error) { - switch name { - case privatekey.FieldKty: - return m.OldKty(ctx) - case privatekey.FieldAlg: - return m.OldAlg(ctx) - case privatekey.FieldJwk: - return m.OldJwk(ctx) - case privatekey.FieldCreatedAt: - return m.OldCreatedAt(ctx) - case privatekey.FieldUpdatedAt: - return m.OldUpdatedAt(ctx) - } - return nil, fmt.Errorf("unknown PrivateKey field %s", name) -} - -// SetField sets the value of a field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *PrivateKeyMutation) SetField(name string, value ent.Value) error { - switch name { - case privatekey.FieldKty: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetKty(v) - return nil - case privatekey.FieldAlg: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetAlg(v) - return nil - case privatekey.FieldJwk: - v, ok := value.([]uint8) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetJwk(v) - return nil - case privatekey.FieldCreatedAt: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetCreatedAt(v) - return nil - case privatekey.FieldUpdatedAt: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetUpdatedAt(v) - return nil - } - return fmt.Errorf("unknown PrivateKey field %s", name) -} - -// AddedFields returns all numeric fields that were incremented/decremented during -// this mutation. -func (m *PrivateKeyMutation) AddedFields() []string { - return nil -} - -// AddedField returns the numeric value that was incremented/decremented on a field -// with the given name. The second boolean return value indicates that this field -// was not set, or was not defined in the schema. -func (m *PrivateKeyMutation) AddedField(name string) (ent.Value, bool) { - return nil, false -} - -// AddField adds the value to the field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *PrivateKeyMutation) AddField(name string, value ent.Value) error { - switch name { - } - return fmt.Errorf("unknown PrivateKey numeric field %s", name) -} - -// ClearedFields returns all nullable fields that were cleared during this -// mutation. -func (m *PrivateKeyMutation) ClearedFields() []string { - var fields []string - if m.FieldCleared(privatekey.FieldAlg) { - fields = append(fields, privatekey.FieldAlg) - } - return fields -} - -// FieldCleared returns a boolean indicating if a field with the given name was -// cleared in this mutation. -func (m *PrivateKeyMutation) FieldCleared(name string) bool { - _, ok := m.clearedFields[name] - return ok -} - -// ClearField clears the value of the field with the given name. It returns an -// error if the field is not defined in the schema. -func (m *PrivateKeyMutation) ClearField(name string) error { - switch name { - case privatekey.FieldAlg: - m.ClearAlg() - return nil - } - return fmt.Errorf("unknown PrivateKey nullable field %s", name) -} - -// ResetField resets all changes in the mutation for the field with the given name. -// It returns an error if the field is not defined in the schema. -func (m *PrivateKeyMutation) ResetField(name string) error { - switch name { - case privatekey.FieldKty: - m.ResetKty() - return nil - case privatekey.FieldAlg: - m.ResetAlg() - return nil - case privatekey.FieldJwk: - m.ResetJwk() - return nil - case privatekey.FieldCreatedAt: - m.ResetCreatedAt() - return nil - case privatekey.FieldUpdatedAt: - m.ResetUpdatedAt() - return nil - } - return fmt.Errorf("unknown PrivateKey field %s", name) -} - -// AddedEdges returns all edge names that were set/added in this mutation. -func (m *PrivateKeyMutation) AddedEdges() []string { - edges := make([]string, 0, 1) - if m.user != nil { - edges = append(edges, privatekey.EdgeUser) - } - return edges -} - -// AddedIDs returns all IDs (to other nodes) that were added for the given edge -// name in this mutation. -func (m *PrivateKeyMutation) AddedIDs(name string) []ent.Value { - switch name { - case privatekey.EdgeUser: - if id := m.user; id != nil { - return []ent.Value{*id} - } - } - return nil -} - -// RemovedEdges returns all edge names that were removed in this mutation. -func (m *PrivateKeyMutation) RemovedEdges() []string { - edges := make([]string, 0, 1) - return edges -} - -// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with -// the given name in this mutation. -func (m *PrivateKeyMutation) RemovedIDs(name string) []ent.Value { - switch name { - } - return nil -} - -// ClearedEdges returns all edge names that were cleared in this mutation. -func (m *PrivateKeyMutation) ClearedEdges() []string { - edges := make([]string, 0, 1) - if m.cleareduser { - edges = append(edges, privatekey.EdgeUser) - } - return edges -} - -// EdgeCleared returns a boolean which indicates if the edge with the given name -// was cleared in this mutation. -func (m *PrivateKeyMutation) EdgeCleared(name string) bool { - switch name { - case privatekey.EdgeUser: - return m.cleareduser - } - return false -} - -// ClearEdge clears the value of the edge with the given name. It returns an error -// if that edge is not defined in the schema. -func (m *PrivateKeyMutation) ClearEdge(name string) error { - switch name { - case privatekey.EdgeUser: - m.ClearUser() - return nil - } - return fmt.Errorf("unknown PrivateKey unique edge %s", name) -} - -// ResetEdge resets all changes to the edge with the given name in this mutation. -// It returns an error if the edge is not defined in the schema. -func (m *PrivateKeyMutation) ResetEdge(name string) error { - switch name { - case privatekey.EdgeUser: - m.ResetUser() - return nil - } - return fmt.Errorf("unknown PrivateKey edge %s", name) -} - -// PublicKeyMutation represents an operation that mutates the PublicKey nodes in the graph. -type PublicKeyMutation struct { - config - op Op - typ string - id *string - kty *string - alg *string - jwk *[]uint8 - created_at *time.Time - updated_at *time.Time - clearedFields map[string]struct{} - done bool - oldValue func(context.Context) (*PublicKey, error) - predicates []predicate.PublicKey -} - -var _ ent.Mutation = (*PublicKeyMutation)(nil) - -// publickeyOption allows management of the mutation configuration using functional options. -type publickeyOption func(*PublicKeyMutation) - -// newPublicKeyMutation creates new mutation for the PublicKey entity. -func newPublicKeyMutation(c config, op Op, opts ...publickeyOption) *PublicKeyMutation { - m := &PublicKeyMutation{ - config: c, - op: op, - typ: TypePublicKey, - clearedFields: make(map[string]struct{}), - } - for _, opt := range opts { - opt(m) - } - return m -} - -// withPublicKeyID sets the ID field of the mutation. -func withPublicKeyID(id string) publickeyOption { - return func(m *PublicKeyMutation) { - var ( - err error - once sync.Once - value *PublicKey - ) - m.oldValue = func(ctx context.Context) (*PublicKey, error) { - once.Do(func() { - if m.done { - err = errors.New("querying old values post mutation is not allowed") - } else { - value, err = m.Client().PublicKey.Get(ctx, id) - } - }) - return value, err - } - m.id = &id - } -} - -// withPublicKey sets the old PublicKey of the mutation. -func withPublicKey(node *PublicKey) publickeyOption { - return func(m *PublicKeyMutation) { - m.oldValue = func(context.Context) (*PublicKey, error) { - return node, nil - } - m.id = &node.ID - } -} - -// Client returns a new `ent.Client` from the mutation. If the mutation was -// executed in a transaction (ent.Tx), a transactional client is returned. -func (m PublicKeyMutation) Client() *Client { - client := &Client{config: m.config} - client.init() - return client -} - -// Tx returns an `ent.Tx` for mutations that were executed in transactions; -// it returns an error otherwise. -func (m PublicKeyMutation) Tx() (*Tx, error) { - if _, ok := m.driver.(*txDriver); !ok { - return nil, errors.New("ent: mutation is not running in a transaction") - } - tx := &Tx{config: m.config} - tx.init() - return tx, nil -} - -// SetID sets the value of the id field. Note that this -// operation is only accepted on creation of PublicKey entities. -func (m *PublicKeyMutation) SetID(id string) { - m.id = &id -} - -// ID returns the ID value in the mutation. Note that the ID is only available -// if it was provided to the builder or after it was returned from the database. -func (m *PublicKeyMutation) ID() (id string, exists bool) { - if m.id == nil { - return - } - return *m.id, true -} - -// IDs queries the database and returns the entity ids that match the mutation's predicate. -// That means, if the mutation is applied within a transaction with an isolation level such -// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated -// or updated by the mutation. -func (m *PublicKeyMutation) IDs(ctx context.Context) ([]string, error) { - switch { - case m.op.Is(OpUpdateOne | OpDeleteOne): - id, exists := m.ID() - if exists { - return []string{id}, nil - } - fallthrough - case m.op.Is(OpUpdate | OpDelete): - return m.Client().PublicKey.Query().Where(m.predicates...).IDs(ctx) - default: - return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) - } -} - -// SetKty sets the "kty" field. -func (m *PublicKeyMutation) SetKty(s string) { - m.kty = &s -} - -// Kty returns the value of the "kty" field in the mutation. -func (m *PublicKeyMutation) Kty() (r string, exists bool) { - v := m.kty - if v == nil { - return - } - return *v, true -} - -// OldKty returns the old "kty" field's value of the PublicKey entity. -// If the PublicKey object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *PublicKeyMutation) OldKty(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldKty is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldKty requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldKty: %w", err) - } - return oldValue.Kty, nil -} - -// ResetKty resets all changes to the "kty" field. -func (m *PublicKeyMutation) ResetKty() { - m.kty = nil -} - -// SetAlg sets the "alg" field. -func (m *PublicKeyMutation) SetAlg(s string) { - m.alg = &s -} - -// Alg returns the value of the "alg" field in the mutation. -func (m *PublicKeyMutation) Alg() (r string, exists bool) { - v := m.alg - if v == nil { - return - } - return *v, true -} - -// OldAlg returns the old "alg" field's value of the PublicKey entity. -// If the PublicKey object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *PublicKeyMutation) OldAlg(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldAlg is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldAlg requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldAlg: %w", err) - } - return oldValue.Alg, nil -} - -// ClearAlg clears the value of the "alg" field. -func (m *PublicKeyMutation) ClearAlg() { - m.alg = nil - m.clearedFields[publickey.FieldAlg] = struct{}{} -} - -// AlgCleared returns if the "alg" field was cleared in this mutation. -func (m *PublicKeyMutation) AlgCleared() bool { - _, ok := m.clearedFields[publickey.FieldAlg] - return ok -} - -// ResetAlg resets all changes to the "alg" field. -func (m *PublicKeyMutation) ResetAlg() { - m.alg = nil - delete(m.clearedFields, publickey.FieldAlg) -} - -// SetJwk sets the "jwk" field. -func (m *PublicKeyMutation) SetJwk(u []uint8) { - m.jwk = &u -} - -// Jwk returns the value of the "jwk" field in the mutation. -func (m *PublicKeyMutation) Jwk() (r []uint8, exists bool) { - v := m.jwk - if v == nil { - return - } - return *v, true -} - -// OldJwk returns the old "jwk" field's value of the PublicKey entity. -// If the PublicKey object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *PublicKeyMutation) OldJwk(ctx context.Context) (v []uint8, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldJwk is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldJwk requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldJwk: %w", err) - } - return oldValue.Jwk, nil -} - -// ResetJwk resets all changes to the "jwk" field. -func (m *PublicKeyMutation) ResetJwk() { - m.jwk = nil -} - -// SetCreatedAt sets the "created_at" field. -func (m *PublicKeyMutation) SetCreatedAt(t time.Time) { - m.created_at = &t -} - -// CreatedAt returns the value of the "created_at" field in the mutation. -func (m *PublicKeyMutation) CreatedAt() (r time.Time, exists bool) { - v := m.created_at - if v == nil { - return - } - return *v, true -} - -// OldCreatedAt returns the old "created_at" field's value of the PublicKey entity. -// If the PublicKey object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *PublicKeyMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldCreatedAt requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) - } - return oldValue.CreatedAt, nil -} - -// ResetCreatedAt resets all changes to the "created_at" field. -func (m *PublicKeyMutation) ResetCreatedAt() { - m.created_at = nil -} - -// SetUpdatedAt sets the "updated_at" field. -func (m *PublicKeyMutation) SetUpdatedAt(t time.Time) { - m.updated_at = &t -} - -// UpdatedAt returns the value of the "updated_at" field in the mutation. -func (m *PublicKeyMutation) UpdatedAt() (r time.Time, exists bool) { - v := m.updated_at - if v == nil { - return - } - return *v, true -} - -// OldUpdatedAt returns the old "updated_at" field's value of the PublicKey entity. -// If the PublicKey object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *PublicKeyMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUpdatedAt requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) - } - return oldValue.UpdatedAt, nil -} - -// ResetUpdatedAt resets all changes to the "updated_at" field. -func (m *PublicKeyMutation) ResetUpdatedAt() { - m.updated_at = nil -} - -// Where appends a list predicates to the PublicKeyMutation builder. -func (m *PublicKeyMutation) Where(ps ...predicate.PublicKey) { - m.predicates = append(m.predicates, ps...) -} - -// Op returns the operation name. -func (m *PublicKeyMutation) Op() Op { - return m.op -} - -// Type returns the node type of this mutation (PublicKey). -func (m *PublicKeyMutation) Type() string { - return m.typ -} - -// Fields returns all fields that were changed during this mutation. Note that in -// order to get all numeric fields that were incremented/decremented, call -// AddedFields(). -func (m *PublicKeyMutation) Fields() []string { - fields := make([]string, 0, 5) - if m.kty != nil { - fields = append(fields, publickey.FieldKty) - } - if m.alg != nil { - fields = append(fields, publickey.FieldAlg) - } - if m.jwk != nil { - fields = append(fields, publickey.FieldJwk) - } - if m.created_at != nil { - fields = append(fields, publickey.FieldCreatedAt) - } - if m.updated_at != nil { - fields = append(fields, publickey.FieldUpdatedAt) - } - return fields -} - -// Field returns the value of a field with the given name. The second boolean -// return value indicates that this field was not set, or was not defined in the -// schema. -func (m *PublicKeyMutation) Field(name string) (ent.Value, bool) { - switch name { - case publickey.FieldKty: - return m.Kty() - case publickey.FieldAlg: - return m.Alg() - case publickey.FieldJwk: - return m.Jwk() - case publickey.FieldCreatedAt: - return m.CreatedAt() - case publickey.FieldUpdatedAt: - return m.UpdatedAt() - } - return nil, false -} - -// OldField returns the old value of the field from the database. An error is -// returned if the mutation operation is not UpdateOne, or the query to the -// database failed. -func (m *PublicKeyMutation) OldField(ctx context.Context, name string) (ent.Value, error) { - switch name { - case publickey.FieldKty: - return m.OldKty(ctx) - case publickey.FieldAlg: - return m.OldAlg(ctx) - case publickey.FieldJwk: - return m.OldJwk(ctx) - case publickey.FieldCreatedAt: - return m.OldCreatedAt(ctx) - case publickey.FieldUpdatedAt: - return m.OldUpdatedAt(ctx) - } - return nil, fmt.Errorf("unknown PublicKey field %s", name) -} - -// SetField sets the value of a field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *PublicKeyMutation) SetField(name string, value ent.Value) error { - switch name { - case publickey.FieldKty: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetKty(v) - return nil - case publickey.FieldAlg: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetAlg(v) - return nil - case publickey.FieldJwk: - v, ok := value.([]uint8) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetJwk(v) - return nil - case publickey.FieldCreatedAt: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetCreatedAt(v) - return nil - case publickey.FieldUpdatedAt: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetUpdatedAt(v) - return nil - } - return fmt.Errorf("unknown PublicKey field %s", name) -} - -// AddedFields returns all numeric fields that were incremented/decremented during -// this mutation. -func (m *PublicKeyMutation) AddedFields() []string { - return nil -} - -// AddedField returns the numeric value that was incremented/decremented on a field -// with the given name. The second boolean return value indicates that this field -// was not set, or was not defined in the schema. -func (m *PublicKeyMutation) AddedField(name string) (ent.Value, bool) { - return nil, false -} - -// AddField adds the value to the field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *PublicKeyMutation) AddField(name string, value ent.Value) error { - switch name { - } - return fmt.Errorf("unknown PublicKey numeric field %s", name) -} - -// ClearedFields returns all nullable fields that were cleared during this -// mutation. -func (m *PublicKeyMutation) ClearedFields() []string { - var fields []string - if m.FieldCleared(publickey.FieldAlg) { - fields = append(fields, publickey.FieldAlg) - } - return fields -} - -// FieldCleared returns a boolean indicating if a field with the given name was -// cleared in this mutation. -func (m *PublicKeyMutation) FieldCleared(name string) bool { - _, ok := m.clearedFields[name] - return ok -} - -// ClearField clears the value of the field with the given name. It returns an -// error if the field is not defined in the schema. -func (m *PublicKeyMutation) ClearField(name string) error { - switch name { - case publickey.FieldAlg: - m.ClearAlg() - return nil - } - return fmt.Errorf("unknown PublicKey nullable field %s", name) -} - -// ResetField resets all changes in the mutation for the field with the given name. -// It returns an error if the field is not defined in the schema. -func (m *PublicKeyMutation) ResetField(name string) error { - switch name { - case publickey.FieldKty: - m.ResetKty() - return nil - case publickey.FieldAlg: - m.ResetAlg() - return nil - case publickey.FieldJwk: - m.ResetJwk() - return nil - case publickey.FieldCreatedAt: - m.ResetCreatedAt() - return nil - case publickey.FieldUpdatedAt: - m.ResetUpdatedAt() - return nil - } - return fmt.Errorf("unknown PublicKey field %s", name) -} - -// AddedEdges returns all edge names that were set/added in this mutation. -func (m *PublicKeyMutation) AddedEdges() []string { - edges := make([]string, 0, 0) - return edges -} - -// AddedIDs returns all IDs (to other nodes) that were added for the given edge -// name in this mutation. -func (m *PublicKeyMutation) AddedIDs(name string) []ent.Value { - return nil -} - -// RemovedEdges returns all edge names that were removed in this mutation. -func (m *PublicKeyMutation) RemovedEdges() []string { - edges := make([]string, 0, 0) - return edges -} - -// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with -// the given name in this mutation. -func (m *PublicKeyMutation) RemovedIDs(name string) []ent.Value { - return nil -} - -// ClearedEdges returns all edge names that were cleared in this mutation. -func (m *PublicKeyMutation) ClearedEdges() []string { - edges := make([]string, 0, 0) - return edges -} - -// EdgeCleared returns a boolean which indicates if the edge with the given name -// was cleared in this mutation. -func (m *PublicKeyMutation) EdgeCleared(name string) bool { - return false -} - -// ClearEdge clears the value of the edge with the given name. It returns an error -// if that edge is not defined in the schema. -func (m *PublicKeyMutation) ClearEdge(name string) error { - return fmt.Errorf("unknown PublicKey unique edge %s", name) -} - -// ResetEdge resets all changes to the edge with the given name in this mutation. -// It returns an error if the edge is not defined in the schema. -func (m *PublicKeyMutation) ResetEdge(name string) error { - return fmt.Errorf("unknown PublicKey edge %s", name) -} - -// UserMutation represents an operation that mutates the User nodes in the graph. -type UserMutation struct { - config - op Op - typ string - id *string - name *string - displayname *string - _type *string - password *[]byte - created_at *time.Time - updated_at *time.Time - clearedFields map[string]struct{} - keys map[string]struct{} - removedkeys map[string]struct{} - clearedkeys bool - dids map[string]struct{} - removeddids map[string]struct{} - cleareddids bool - credentials map[string]struct{} - removedcredentials map[string]struct{} - clearedcredentials bool - done bool - oldValue func(context.Context) (*User, error) - predicates []predicate.User -} - -var _ ent.Mutation = (*UserMutation)(nil) - -// userOption allows management of the mutation configuration using functional options. -type userOption func(*UserMutation) - -// newUserMutation creates new mutation for the User entity. -func newUserMutation(c config, op Op, opts ...userOption) *UserMutation { - m := &UserMutation{ - config: c, - op: op, - typ: TypeUser, - clearedFields: make(map[string]struct{}), - } - for _, opt := range opts { - opt(m) - } - return m -} - -// withUserID sets the ID field of the mutation. -func withUserID(id string) userOption { - return func(m *UserMutation) { - var ( - err error - once sync.Once - value *User - ) - m.oldValue = func(ctx context.Context) (*User, error) { - once.Do(func() { - if m.done { - err = errors.New("querying old values post mutation is not allowed") - } else { - value, err = m.Client().User.Get(ctx, id) - } - }) - return value, err - } - m.id = &id - } -} - -// withUser sets the old User of the mutation. -func withUser(node *User) userOption { - return func(m *UserMutation) { - m.oldValue = func(context.Context) (*User, error) { - return node, nil - } - m.id = &node.ID - } -} - -// Client returns a new `ent.Client` from the mutation. If the mutation was -// executed in a transaction (ent.Tx), a transactional client is returned. -func (m UserMutation) Client() *Client { - client := &Client{config: m.config} - client.init() - return client -} - -// Tx returns an `ent.Tx` for mutations that were executed in transactions; -// it returns an error otherwise. -func (m UserMutation) Tx() (*Tx, error) { - if _, ok := m.driver.(*txDriver); !ok { - return nil, errors.New("ent: mutation is not running in a transaction") - } - tx := &Tx{config: m.config} - tx.init() - return tx, nil -} - -// SetID sets the value of the id field. Note that this -// operation is only accepted on creation of User entities. -func (m *UserMutation) SetID(id string) { - m.id = &id -} - -// ID returns the ID value in the mutation. Note that the ID is only available -// if it was provided to the builder or after it was returned from the database. -func (m *UserMutation) ID() (id string, exists bool) { - if m.id == nil { - return - } - return *m.id, true -} - -// IDs queries the database and returns the entity ids that match the mutation's predicate. -// That means, if the mutation is applied within a transaction with an isolation level such -// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated -// or updated by the mutation. -func (m *UserMutation) IDs(ctx context.Context) ([]string, error) { - switch { - case m.op.Is(OpUpdateOne | OpDeleteOne): - id, exists := m.ID() - if exists { - return []string{id}, nil - } - fallthrough - case m.op.Is(OpUpdate | OpDelete): - return m.Client().User.Query().Where(m.predicates...).IDs(ctx) - default: - return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) - } -} - -// SetName sets the "name" field. -func (m *UserMutation) SetName(s string) { - m.name = &s -} - -// Name returns the value of the "name" field in the mutation. -func (m *UserMutation) Name() (r string, exists bool) { - v := m.name - if v == nil { - return - } - return *v, true -} - -// OldName returns the old "name" field's value of the User entity. -// If the User object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldName(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldName is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldName requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldName: %w", err) - } - return oldValue.Name, nil -} - -// ResetName resets all changes to the "name" field. -func (m *UserMutation) ResetName() { - m.name = nil -} - -// SetDisplayname sets the "displayname" field. -func (m *UserMutation) SetDisplayname(s string) { - m.displayname = &s -} - -// Displayname returns the value of the "displayname" field in the mutation. -func (m *UserMutation) Displayname() (r string, exists bool) { - v := m.displayname - if v == nil { - return - } - return *v, true -} - -// OldDisplayname returns the old "displayname" field's value of the User entity. -// If the User object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldDisplayname(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDisplayname is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDisplayname requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldDisplayname: %w", err) - } - return oldValue.Displayname, nil -} - -// ClearDisplayname clears the value of the "displayname" field. -func (m *UserMutation) ClearDisplayname() { - m.displayname = nil - m.clearedFields[user.FieldDisplayname] = struct{}{} -} - -// DisplaynameCleared returns if the "displayname" field was cleared in this mutation. -func (m *UserMutation) DisplaynameCleared() bool { - _, ok := m.clearedFields[user.FieldDisplayname] - return ok -} - -// ResetDisplayname resets all changes to the "displayname" field. -func (m *UserMutation) ResetDisplayname() { - m.displayname = nil - delete(m.clearedFields, user.FieldDisplayname) -} - -// SetType sets the "type" field. -func (m *UserMutation) SetType(s string) { - m._type = &s -} - -// GetType returns the value of the "type" field in the mutation. -func (m *UserMutation) GetType() (r string, exists bool) { - v := m._type - if v == nil { - return - } - return *v, true -} - -// OldType returns the old "type" field's value of the User entity. -// If the User object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldType(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldType is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldType requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldType: %w", err) - } - return oldValue.Type, nil -} - -// ResetType resets all changes to the "type" field. -func (m *UserMutation) ResetType() { - m._type = nil -} - -// SetPassword sets the "password" field. -func (m *UserMutation) SetPassword(b []byte) { - m.password = &b -} - -// Password returns the value of the "password" field in the mutation. -func (m *UserMutation) Password() (r []byte, exists bool) { - v := m.password - if v == nil { - return - } - return *v, true -} - -// OldPassword returns the old "password" field's value of the User entity. -// If the User object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldPassword(ctx context.Context) (v []byte, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldPassword is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldPassword requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldPassword: %w", err) - } - return oldValue.Password, nil -} - -// ResetPassword resets all changes to the "password" field. -func (m *UserMutation) ResetPassword() { - m.password = nil -} - -// SetCreatedAt sets the "created_at" field. -func (m *UserMutation) SetCreatedAt(t time.Time) { - m.created_at = &t -} - -// CreatedAt returns the value of the "created_at" field in the mutation. -func (m *UserMutation) CreatedAt() (r time.Time, exists bool) { - v := m.created_at - if v == nil { - return - } - return *v, true -} - -// OldCreatedAt returns the old "created_at" field's value of the User entity. -// If the User object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldCreatedAt requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) - } - return oldValue.CreatedAt, nil -} - -// ResetCreatedAt resets all changes to the "created_at" field. -func (m *UserMutation) ResetCreatedAt() { - m.created_at = nil -} - -// SetUpdatedAt sets the "updated_at" field. -func (m *UserMutation) SetUpdatedAt(t time.Time) { - m.updated_at = &t -} - -// UpdatedAt returns the value of the "updated_at" field in the mutation. -func (m *UserMutation) UpdatedAt() (r time.Time, exists bool) { - v := m.updated_at - if v == nil { - return - } - return *v, true -} - -// OldUpdatedAt returns the old "updated_at" field's value of the User entity. -// If the User object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUpdatedAt requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) - } - return oldValue.UpdatedAt, nil -} - -// ResetUpdatedAt resets all changes to the "updated_at" field. -func (m *UserMutation) ResetUpdatedAt() { - m.updated_at = nil -} - -// AddKeyIDs adds the "keys" edge to the PrivateKey entity by ids. -func (m *UserMutation) AddKeyIDs(ids ...string) { - if m.keys == nil { - m.keys = make(map[string]struct{}) - } - for i := range ids { - m.keys[ids[i]] = struct{}{} - } -} - -// ClearKeys clears the "keys" edge to the PrivateKey entity. -func (m *UserMutation) ClearKeys() { - m.clearedkeys = true -} - -// KeysCleared reports if the "keys" edge to the PrivateKey entity was cleared. -func (m *UserMutation) KeysCleared() bool { - return m.clearedkeys -} - -// RemoveKeyIDs removes the "keys" edge to the PrivateKey entity by IDs. -func (m *UserMutation) RemoveKeyIDs(ids ...string) { - if m.removedkeys == nil { - m.removedkeys = make(map[string]struct{}) - } - for i := range ids { - delete(m.keys, ids[i]) - m.removedkeys[ids[i]] = struct{}{} - } -} - -// RemovedKeys returns the removed IDs of the "keys" edge to the PrivateKey entity. -func (m *UserMutation) RemovedKeysIDs() (ids []string) { - for id := range m.removedkeys { - ids = append(ids, id) - } - return -} - -// KeysIDs returns the "keys" edge IDs in the mutation. -func (m *UserMutation) KeysIDs() (ids []string) { - for id := range m.keys { - ids = append(ids, id) - } - return -} - -// ResetKeys resets all changes to the "keys" edge. -func (m *UserMutation) ResetKeys() { - m.keys = nil - m.clearedkeys = false - m.removedkeys = nil -} - -// AddDidIDs adds the "dids" edge to the DID entity by ids. -func (m *UserMutation) AddDidIDs(ids ...string) { - if m.dids == nil { - m.dids = make(map[string]struct{}) - } - for i := range ids { - m.dids[ids[i]] = struct{}{} - } -} - -// ClearDids clears the "dids" edge to the DID entity. -func (m *UserMutation) ClearDids() { - m.cleareddids = true -} - -// DidsCleared reports if the "dids" edge to the DID entity was cleared. -func (m *UserMutation) DidsCleared() bool { - return m.cleareddids -} - -// RemoveDidIDs removes the "dids" edge to the DID entity by IDs. -func (m *UserMutation) RemoveDidIDs(ids ...string) { - if m.removeddids == nil { - m.removeddids = make(map[string]struct{}) - } - for i := range ids { - delete(m.dids, ids[i]) - m.removeddids[ids[i]] = struct{}{} - } -} - -// RemovedDids returns the removed IDs of the "dids" edge to the DID entity. -func (m *UserMutation) RemovedDidsIDs() (ids []string) { - for id := range m.removeddids { - ids = append(ids, id) - } - return -} - -// DidsIDs returns the "dids" edge IDs in the mutation. -func (m *UserMutation) DidsIDs() (ids []string) { - for id := range m.dids { - ids = append(ids, id) - } - return -} - -// ResetDids resets all changes to the "dids" edge. -func (m *UserMutation) ResetDids() { - m.dids = nil - m.cleareddids = false - m.removeddids = nil -} - -// AddCredentialIDs adds the "credentials" edge to the Credential entity by ids. -func (m *UserMutation) AddCredentialIDs(ids ...string) { - if m.credentials == nil { - m.credentials = make(map[string]struct{}) - } - for i := range ids { - m.credentials[ids[i]] = struct{}{} - } -} - -// ClearCredentials clears the "credentials" edge to the Credential entity. -func (m *UserMutation) ClearCredentials() { - m.clearedcredentials = true -} - -// CredentialsCleared reports if the "credentials" edge to the Credential entity was cleared. -func (m *UserMutation) CredentialsCleared() bool { - return m.clearedcredentials -} - -// RemoveCredentialIDs removes the "credentials" edge to the Credential entity by IDs. -func (m *UserMutation) RemoveCredentialIDs(ids ...string) { - if m.removedcredentials == nil { - m.removedcredentials = make(map[string]struct{}) - } - for i := range ids { - delete(m.credentials, ids[i]) - m.removedcredentials[ids[i]] = struct{}{} - } -} - -// RemovedCredentials returns the removed IDs of the "credentials" edge to the Credential entity. -func (m *UserMutation) RemovedCredentialsIDs() (ids []string) { - for id := range m.removedcredentials { - ids = append(ids, id) - } - return -} - -// CredentialsIDs returns the "credentials" edge IDs in the mutation. -func (m *UserMutation) CredentialsIDs() (ids []string) { - for id := range m.credentials { - ids = append(ids, id) - } - return -} - -// ResetCredentials resets all changes to the "credentials" edge. -func (m *UserMutation) ResetCredentials() { - m.credentials = nil - m.clearedcredentials = false - m.removedcredentials = nil -} - -// Where appends a list predicates to the UserMutation builder. -func (m *UserMutation) Where(ps ...predicate.User) { - m.predicates = append(m.predicates, ps...) -} - -// Op returns the operation name. -func (m *UserMutation) Op() Op { - return m.op -} - -// Type returns the node type of this mutation (User). -func (m *UserMutation) Type() string { - return m.typ -} - -// Fields returns all fields that were changed during this mutation. Note that in -// order to get all numeric fields that were incremented/decremented, call -// AddedFields(). -func (m *UserMutation) Fields() []string { - fields := make([]string, 0, 6) - if m.name != nil { - fields = append(fields, user.FieldName) - } - if m.displayname != nil { - fields = append(fields, user.FieldDisplayname) - } - if m._type != nil { - fields = append(fields, user.FieldType) - } - if m.password != nil { - fields = append(fields, user.FieldPassword) - } - if m.created_at != nil { - fields = append(fields, user.FieldCreatedAt) - } - if m.updated_at != nil { - fields = append(fields, user.FieldUpdatedAt) - } - return fields -} - -// Field returns the value of a field with the given name. The second boolean -// return value indicates that this field was not set, or was not defined in the -// schema. -func (m *UserMutation) Field(name string) (ent.Value, bool) { - switch name { - case user.FieldName: - return m.Name() - case user.FieldDisplayname: - return m.Displayname() - case user.FieldType: - return m.GetType() - case user.FieldPassword: - return m.Password() - case user.FieldCreatedAt: - return m.CreatedAt() - case user.FieldUpdatedAt: - return m.UpdatedAt() - } - return nil, false -} - -// OldField returns the old value of the field from the database. An error is -// returned if the mutation operation is not UpdateOne, or the query to the -// database failed. -func (m *UserMutation) OldField(ctx context.Context, name string) (ent.Value, error) { - switch name { - case user.FieldName: - return m.OldName(ctx) - case user.FieldDisplayname: - return m.OldDisplayname(ctx) - case user.FieldType: - return m.OldType(ctx) - case user.FieldPassword: - return m.OldPassword(ctx) - case user.FieldCreatedAt: - return m.OldCreatedAt(ctx) - case user.FieldUpdatedAt: - return m.OldUpdatedAt(ctx) - } - return nil, fmt.Errorf("unknown User field %s", name) -} - -// SetField sets the value of a field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *UserMutation) SetField(name string, value ent.Value) error { - switch name { - case user.FieldName: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetName(v) - return nil - case user.FieldDisplayname: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetDisplayname(v) - return nil - case user.FieldType: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetType(v) - return nil - case user.FieldPassword: - v, ok := value.([]byte) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetPassword(v) - return nil - case user.FieldCreatedAt: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetCreatedAt(v) - return nil - case user.FieldUpdatedAt: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetUpdatedAt(v) - return nil - } - return fmt.Errorf("unknown User field %s", name) -} - -// AddedFields returns all numeric fields that were incremented/decremented during -// this mutation. -func (m *UserMutation) AddedFields() []string { - return nil -} - -// AddedField returns the numeric value that was incremented/decremented on a field -// with the given name. The second boolean return value indicates that this field -// was not set, or was not defined in the schema. -func (m *UserMutation) AddedField(name string) (ent.Value, bool) { - return nil, false -} - -// AddField adds the value to the field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *UserMutation) AddField(name string, value ent.Value) error { - switch name { - } - return fmt.Errorf("unknown User numeric field %s", name) -} - -// ClearedFields returns all nullable fields that were cleared during this -// mutation. -func (m *UserMutation) ClearedFields() []string { - var fields []string - if m.FieldCleared(user.FieldDisplayname) { - fields = append(fields, user.FieldDisplayname) - } - return fields -} - -// FieldCleared returns a boolean indicating if a field with the given name was -// cleared in this mutation. -func (m *UserMutation) FieldCleared(name string) bool { - _, ok := m.clearedFields[name] - return ok -} - -// ClearField clears the value of the field with the given name. It returns an -// error if the field is not defined in the schema. -func (m *UserMutation) ClearField(name string) error { - switch name { - case user.FieldDisplayname: - m.ClearDisplayname() - return nil - } - return fmt.Errorf("unknown User nullable field %s", name) -} - -// ResetField resets all changes in the mutation for the field with the given name. -// It returns an error if the field is not defined in the schema. -func (m *UserMutation) ResetField(name string) error { - switch name { - case user.FieldName: - m.ResetName() - return nil - case user.FieldDisplayname: - m.ResetDisplayname() - return nil - case user.FieldType: - m.ResetType() - return nil - case user.FieldPassword: - m.ResetPassword() - return nil - case user.FieldCreatedAt: - m.ResetCreatedAt() - return nil - case user.FieldUpdatedAt: - m.ResetUpdatedAt() - return nil - } - return fmt.Errorf("unknown User field %s", name) -} - -// AddedEdges returns all edge names that were set/added in this mutation. -func (m *UserMutation) AddedEdges() []string { - edges := make([]string, 0, 3) - if m.keys != nil { - edges = append(edges, user.EdgeKeys) - } - if m.dids != nil { - edges = append(edges, user.EdgeDids) - } - if m.credentials != nil { - edges = append(edges, user.EdgeCredentials) - } - return edges -} - -// AddedIDs returns all IDs (to other nodes) that were added for the given edge -// name in this mutation. -func (m *UserMutation) AddedIDs(name string) []ent.Value { - switch name { - case user.EdgeKeys: - ids := make([]ent.Value, 0, len(m.keys)) - for id := range m.keys { - ids = append(ids, id) - } - return ids - case user.EdgeDids: - ids := make([]ent.Value, 0, len(m.dids)) - for id := range m.dids { - ids = append(ids, id) - } - return ids - case user.EdgeCredentials: - ids := make([]ent.Value, 0, len(m.credentials)) - for id := range m.credentials { - ids = append(ids, id) - } - return ids - } - return nil -} - -// RemovedEdges returns all edge names that were removed in this mutation. -func (m *UserMutation) RemovedEdges() []string { - edges := make([]string, 0, 3) - if m.removedkeys != nil { - edges = append(edges, user.EdgeKeys) - } - if m.removeddids != nil { - edges = append(edges, user.EdgeDids) - } - if m.removedcredentials != nil { - edges = append(edges, user.EdgeCredentials) - } - return edges -} - -// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with -// the given name in this mutation. -func (m *UserMutation) RemovedIDs(name string) []ent.Value { - switch name { - case user.EdgeKeys: - ids := make([]ent.Value, 0, len(m.removedkeys)) - for id := range m.removedkeys { - ids = append(ids, id) - } - return ids - case user.EdgeDids: - ids := make([]ent.Value, 0, len(m.removeddids)) - for id := range m.removeddids { - ids = append(ids, id) - } - return ids - case user.EdgeCredentials: - ids := make([]ent.Value, 0, len(m.removedcredentials)) - for id := range m.removedcredentials { - ids = append(ids, id) - } - return ids - } - return nil -} - -// ClearedEdges returns all edge names that were cleared in this mutation. -func (m *UserMutation) ClearedEdges() []string { - edges := make([]string, 0, 3) - if m.clearedkeys { - edges = append(edges, user.EdgeKeys) - } - if m.cleareddids { - edges = append(edges, user.EdgeDids) - } - if m.clearedcredentials { - edges = append(edges, user.EdgeCredentials) - } - return edges -} - -// EdgeCleared returns a boolean which indicates if the edge with the given name -// was cleared in this mutation. -func (m *UserMutation) EdgeCleared(name string) bool { - switch name { - case user.EdgeKeys: - return m.clearedkeys - case user.EdgeDids: - return m.cleareddids - case user.EdgeCredentials: - return m.clearedcredentials - } - return false -} - -// ClearEdge clears the value of the edge with the given name. It returns an error -// if that edge is not defined in the schema. -func (m *UserMutation) ClearEdge(name string) error { - switch name { - } - return fmt.Errorf("unknown User unique edge %s", name) -} - -// ResetEdge resets all changes to the edge with the given name in this mutation. -// It returns an error if the edge is not defined in the schema. -func (m *UserMutation) ResetEdge(name string) error { - switch name { - case user.EdgeKeys: - m.ResetKeys() - return nil - case user.EdgeDids: - m.ResetDids() - return nil - case user.EdgeCredentials: - m.ResetCredentials() - return nil - } - return fmt.Errorf("unknown User edge %s", name) -} diff --git a/ent/naturalperson.go b/ent/naturalperson.go deleted file mode 100644 index eb2c7950..00000000 --- a/ent/naturalperson.go +++ /dev/null @@ -1,198 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "fmt" - "strings" - "time" - - "entgo.io/ent/dialect/sql" - "github.com/fiware/vcverifier/ent/naturalperson" -) - -// NaturalPerson is the model entity for the NaturalPerson schema. -type NaturalPerson struct { - config `json:"-"` - // ID of the ent. - ID string `json:"id,omitempty"` - // Name holds the value of the "name" field. - Name string `json:"name,omitempty"` - // Displayname holds the value of the "displayname" field. - Displayname string `json:"displayname,omitempty"` - // Type holds the value of the "type" field. - Type string `json:"type,omitempty"` - // Password holds the value of the "password" field. - Password []byte `json:"-"` - // CreatedAt holds the value of the "created_at" field. - CreatedAt time.Time `json:"created_at,omitempty"` - // UpdatedAt holds the value of the "updated_at" field. - UpdatedAt time.Time `json:"updated_at,omitempty"` - // Edges holds the relations/edges for other nodes in the graph. - // The values are being populated by the NaturalPersonQuery when eager-loading is set. - Edges NaturalPersonEdges `json:"edges"` -} - -// NaturalPersonEdges holds the relations/edges for other nodes in the graph. -type NaturalPersonEdges struct { - // Keys holds the value of the keys edge. - Keys []*PrivateKey `json:"keys,omitempty"` - // Credentials holds the value of the credentials edge. - Credentials []*Credential `json:"credentials,omitempty"` - // loadedTypes holds the information for reporting if a - // type was loaded (or requested) in eager-loading or not. - loadedTypes [2]bool -} - -// KeysOrErr returns the Keys value or an error if the edge -// was not loaded in eager-loading. -func (e NaturalPersonEdges) KeysOrErr() ([]*PrivateKey, error) { - if e.loadedTypes[0] { - return e.Keys, nil - } - return nil, &NotLoadedError{edge: "keys"} -} - -// CredentialsOrErr returns the Credentials value or an error if the edge -// was not loaded in eager-loading. -func (e NaturalPersonEdges) CredentialsOrErr() ([]*Credential, error) { - if e.loadedTypes[1] { - return e.Credentials, nil - } - return nil, &NotLoadedError{edge: "credentials"} -} - -// scanValues returns the types for scanning values from sql.Rows. -func (*NaturalPerson) scanValues(columns []string) ([]interface{}, error) { - values := make([]interface{}, len(columns)) - for i := range columns { - switch columns[i] { - case naturalperson.FieldPassword: - values[i] = new([]byte) - case naturalperson.FieldID, naturalperson.FieldName, naturalperson.FieldDisplayname, naturalperson.FieldType: - values[i] = new(sql.NullString) - case naturalperson.FieldCreatedAt, naturalperson.FieldUpdatedAt: - values[i] = new(sql.NullTime) - default: - return nil, fmt.Errorf("unexpected column %q for type NaturalPerson", columns[i]) - } - } - return values, nil -} - -// assignValues assigns the values that were returned from sql.Rows (after scanning) -// to the NaturalPerson fields. -func (np *NaturalPerson) assignValues(columns []string, values []interface{}) error { - if m, n := len(values), len(columns); m < n { - return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) - } - for i := range columns { - switch columns[i] { - case naturalperson.FieldID: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field id", values[i]) - } else if value.Valid { - np.ID = value.String - } - case naturalperson.FieldName: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field name", values[i]) - } else if value.Valid { - np.Name = value.String - } - case naturalperson.FieldDisplayname: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field displayname", values[i]) - } else if value.Valid { - np.Displayname = value.String - } - case naturalperson.FieldType: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field type", values[i]) - } else if value.Valid { - np.Type = value.String - } - case naturalperson.FieldPassword: - if value, ok := values[i].(*[]byte); !ok { - return fmt.Errorf("unexpected type %T for field password", values[i]) - } else if value != nil { - np.Password = *value - } - case naturalperson.FieldCreatedAt: - if value, ok := values[i].(*sql.NullTime); !ok { - return fmt.Errorf("unexpected type %T for field created_at", values[i]) - } else if value.Valid { - np.CreatedAt = value.Time - } - case naturalperson.FieldUpdatedAt: - if value, ok := values[i].(*sql.NullTime); !ok { - return fmt.Errorf("unexpected type %T for field updated_at", values[i]) - } else if value.Valid { - np.UpdatedAt = value.Time - } - } - } - return nil -} - -// QueryKeys queries the "keys" edge of the NaturalPerson entity. -func (np *NaturalPerson) QueryKeys() *PrivateKeyQuery { - return (&NaturalPersonClient{config: np.config}).QueryKeys(np) -} - -// QueryCredentials queries the "credentials" edge of the NaturalPerson entity. -func (np *NaturalPerson) QueryCredentials() *CredentialQuery { - return (&NaturalPersonClient{config: np.config}).QueryCredentials(np) -} - -// Update returns a builder for updating this NaturalPerson. -// Note that you need to call NaturalPerson.Unwrap() before calling this method if this NaturalPerson -// was returned from a transaction, and the transaction was committed or rolled back. -func (np *NaturalPerson) Update() *NaturalPersonUpdateOne { - return (&NaturalPersonClient{config: np.config}).UpdateOne(np) -} - -// Unwrap unwraps the NaturalPerson entity that was returned from a transaction after it was closed, -// so that all future queries will be executed through the driver which created the transaction. -func (np *NaturalPerson) Unwrap() *NaturalPerson { - _tx, ok := np.config.driver.(*txDriver) - if !ok { - panic("ent: NaturalPerson is not a transactional entity") - } - np.config.driver = _tx.drv - return np -} - -// String implements the fmt.Stringer. -func (np *NaturalPerson) String() string { - var builder strings.Builder - builder.WriteString("NaturalPerson(") - builder.WriteString(fmt.Sprintf("id=%v, ", np.ID)) - builder.WriteString("name=") - builder.WriteString(np.Name) - builder.WriteString(", ") - builder.WriteString("displayname=") - builder.WriteString(np.Displayname) - builder.WriteString(", ") - builder.WriteString("type=") - builder.WriteString(np.Type) - builder.WriteString(", ") - builder.WriteString("password=") - builder.WriteString(", ") - builder.WriteString("created_at=") - builder.WriteString(np.CreatedAt.Format(time.ANSIC)) - builder.WriteString(", ") - builder.WriteString("updated_at=") - builder.WriteString(np.UpdatedAt.Format(time.ANSIC)) - builder.WriteByte(')') - return builder.String() -} - -// NaturalPersons is a parsable slice of NaturalPerson. -type NaturalPersons []*NaturalPerson - -func (np NaturalPersons) config(cfg config) { - for _i := range np { - np[_i].config = cfg - } -} diff --git a/ent/naturalperson/naturalperson.go b/ent/naturalperson/naturalperson.go deleted file mode 100644 index b8a165a3..00000000 --- a/ent/naturalperson/naturalperson.go +++ /dev/null @@ -1,82 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package naturalperson - -import ( - "time" -) - -const ( - // Label holds the string label denoting the naturalperson type in the database. - Label = "natural_person" - // FieldID holds the string denoting the id field in the database. - FieldID = "id" - // FieldName holds the string denoting the name field in the database. - FieldName = "name" - // FieldDisplayname holds the string denoting the displayname field in the database. - FieldDisplayname = "displayname" - // FieldType holds the string denoting the type field in the database. - FieldType = "type" - // FieldPassword holds the string denoting the password field in the database. - FieldPassword = "password" - // FieldCreatedAt holds the string denoting the created_at field in the database. - FieldCreatedAt = "created_at" - // FieldUpdatedAt holds the string denoting the updated_at field in the database. - FieldUpdatedAt = "updated_at" - // EdgeKeys holds the string denoting the keys edge name in mutations. - EdgeKeys = "keys" - // EdgeCredentials holds the string denoting the credentials edge name in mutations. - EdgeCredentials = "credentials" - // Table holds the table name of the naturalperson in the database. - Table = "natural_persons" - // KeysTable is the table that holds the keys relation/edge. - KeysTable = "private_keys" - // KeysInverseTable is the table name for the PrivateKey entity. - // It exists in this package in order to avoid circular dependency with the "privatekey" package. - KeysInverseTable = "private_keys" - // KeysColumn is the table column denoting the keys relation/edge. - KeysColumn = "natural_person_keys" - // CredentialsTable is the table that holds the credentials relation/edge. - CredentialsTable = "credentials" - // CredentialsInverseTable is the table name for the Credential entity. - // It exists in this package in order to avoid circular dependency with the "credential" package. - CredentialsInverseTable = "credentials" - // CredentialsColumn is the table column denoting the credentials relation/edge. - CredentialsColumn = "natural_person_credentials" -) - -// Columns holds all SQL columns for naturalperson fields. -var Columns = []string{ - FieldID, - FieldName, - FieldDisplayname, - FieldType, - FieldPassword, - FieldCreatedAt, - FieldUpdatedAt, -} - -// ValidColumn reports if the column name is valid (part of the table columns). -func ValidColumn(column string) bool { - for i := range Columns { - if column == Columns[i] { - return true - } - } - return false -} - -var ( - // NameValidator is a validator for the "name" field. It is called by the builders before save. - NameValidator func(string) error - // TypeValidator is a validator for the "type" field. It is called by the builders before save. - TypeValidator func(string) error - // PasswordValidator is a validator for the "password" field. It is called by the builders before save. - PasswordValidator func([]byte) error - // DefaultCreatedAt holds the default value on creation for the "created_at" field. - DefaultCreatedAt func() time.Time - // DefaultUpdatedAt holds the default value on creation for the "updated_at" field. - DefaultUpdatedAt func() time.Time - // IDValidator is a validator for the "id" field. It is called by the builders before save. - IDValidator func(string) error -) diff --git a/ent/naturalperson/where.go b/ent/naturalperson/where.go deleted file mode 100644 index 41cc5408..00000000 --- a/ent/naturalperson/where.go +++ /dev/null @@ -1,787 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package naturalperson - -import ( - "time" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "github.com/fiware/vcverifier/ent/predicate" -) - -// ID filters vertices based on their ID field. -func ID(id string) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldID), id)) - }) -} - -// IDEQ applies the EQ predicate on the ID field. -func IDEQ(id string) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldID), id)) - }) -} - -// IDNEQ applies the NEQ predicate on the ID field. -func IDNEQ(id string) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldID), id)) - }) -} - -// IDIn applies the In predicate on the ID field. -func IDIn(ids ...string) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - v := make([]interface{}, len(ids)) - for i := range v { - v[i] = ids[i] - } - s.Where(sql.In(s.C(FieldID), v...)) - }) -} - -// IDNotIn applies the NotIn predicate on the ID field. -func IDNotIn(ids ...string) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - v := make([]interface{}, len(ids)) - for i := range v { - v[i] = ids[i] - } - s.Where(sql.NotIn(s.C(FieldID), v...)) - }) -} - -// IDGT applies the GT predicate on the ID field. -func IDGT(id string) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldID), id)) - }) -} - -// IDGTE applies the GTE predicate on the ID field. -func IDGTE(id string) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldID), id)) - }) -} - -// IDLT applies the LT predicate on the ID field. -func IDLT(id string) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldID), id)) - }) -} - -// IDLTE applies the LTE predicate on the ID field. -func IDLTE(id string) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldID), id)) - }) -} - -// Name applies equality check predicate on the "name" field. It's identical to NameEQ. -func Name(v string) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldName), v)) - }) -} - -// Displayname applies equality check predicate on the "displayname" field. It's identical to DisplaynameEQ. -func Displayname(v string) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldDisplayname), v)) - }) -} - -// Type applies equality check predicate on the "type" field. It's identical to TypeEQ. -func Type(v string) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldType), v)) - }) -} - -// Password applies equality check predicate on the "password" field. It's identical to PasswordEQ. -func Password(v []byte) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldPassword), v)) - }) -} - -// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. -func CreatedAt(v time.Time) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldCreatedAt), v)) - }) -} - -// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ. -func UpdatedAt(v time.Time) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldUpdatedAt), v)) - }) -} - -// NameEQ applies the EQ predicate on the "name" field. -func NameEQ(v string) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldName), v)) - }) -} - -// NameNEQ applies the NEQ predicate on the "name" field. -func NameNEQ(v string) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldName), v)) - }) -} - -// NameIn applies the In predicate on the "name" field. -func NameIn(vs ...string) predicate.NaturalPerson { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.NaturalPerson(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldName), v...)) - }) -} - -// NameNotIn applies the NotIn predicate on the "name" field. -func NameNotIn(vs ...string) predicate.NaturalPerson { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.NaturalPerson(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldName), v...)) - }) -} - -// NameGT applies the GT predicate on the "name" field. -func NameGT(v string) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldName), v)) - }) -} - -// NameGTE applies the GTE predicate on the "name" field. -func NameGTE(v string) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldName), v)) - }) -} - -// NameLT applies the LT predicate on the "name" field. -func NameLT(v string) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldName), v)) - }) -} - -// NameLTE applies the LTE predicate on the "name" field. -func NameLTE(v string) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldName), v)) - }) -} - -// NameContains applies the Contains predicate on the "name" field. -func NameContains(v string) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.Contains(s.C(FieldName), v)) - }) -} - -// NameHasPrefix applies the HasPrefix predicate on the "name" field. -func NameHasPrefix(v string) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.HasPrefix(s.C(FieldName), v)) - }) -} - -// NameHasSuffix applies the HasSuffix predicate on the "name" field. -func NameHasSuffix(v string) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.HasSuffix(s.C(FieldName), v)) - }) -} - -// NameEqualFold applies the EqualFold predicate on the "name" field. -func NameEqualFold(v string) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.EqualFold(s.C(FieldName), v)) - }) -} - -// NameContainsFold applies the ContainsFold predicate on the "name" field. -func NameContainsFold(v string) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.ContainsFold(s.C(FieldName), v)) - }) -} - -// DisplaynameEQ applies the EQ predicate on the "displayname" field. -func DisplaynameEQ(v string) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldDisplayname), v)) - }) -} - -// DisplaynameNEQ applies the NEQ predicate on the "displayname" field. -func DisplaynameNEQ(v string) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldDisplayname), v)) - }) -} - -// DisplaynameIn applies the In predicate on the "displayname" field. -func DisplaynameIn(vs ...string) predicate.NaturalPerson { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.NaturalPerson(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldDisplayname), v...)) - }) -} - -// DisplaynameNotIn applies the NotIn predicate on the "displayname" field. -func DisplaynameNotIn(vs ...string) predicate.NaturalPerson { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.NaturalPerson(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldDisplayname), v...)) - }) -} - -// DisplaynameGT applies the GT predicate on the "displayname" field. -func DisplaynameGT(v string) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldDisplayname), v)) - }) -} - -// DisplaynameGTE applies the GTE predicate on the "displayname" field. -func DisplaynameGTE(v string) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldDisplayname), v)) - }) -} - -// DisplaynameLT applies the LT predicate on the "displayname" field. -func DisplaynameLT(v string) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldDisplayname), v)) - }) -} - -// DisplaynameLTE applies the LTE predicate on the "displayname" field. -func DisplaynameLTE(v string) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldDisplayname), v)) - }) -} - -// DisplaynameContains applies the Contains predicate on the "displayname" field. -func DisplaynameContains(v string) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.Contains(s.C(FieldDisplayname), v)) - }) -} - -// DisplaynameHasPrefix applies the HasPrefix predicate on the "displayname" field. -func DisplaynameHasPrefix(v string) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.HasPrefix(s.C(FieldDisplayname), v)) - }) -} - -// DisplaynameHasSuffix applies the HasSuffix predicate on the "displayname" field. -func DisplaynameHasSuffix(v string) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.HasSuffix(s.C(FieldDisplayname), v)) - }) -} - -// DisplaynameIsNil applies the IsNil predicate on the "displayname" field. -func DisplaynameIsNil() predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.IsNull(s.C(FieldDisplayname))) - }) -} - -// DisplaynameNotNil applies the NotNil predicate on the "displayname" field. -func DisplaynameNotNil() predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.NotNull(s.C(FieldDisplayname))) - }) -} - -// DisplaynameEqualFold applies the EqualFold predicate on the "displayname" field. -func DisplaynameEqualFold(v string) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.EqualFold(s.C(FieldDisplayname), v)) - }) -} - -// DisplaynameContainsFold applies the ContainsFold predicate on the "displayname" field. -func DisplaynameContainsFold(v string) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.ContainsFold(s.C(FieldDisplayname), v)) - }) -} - -// TypeEQ applies the EQ predicate on the "type" field. -func TypeEQ(v string) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldType), v)) - }) -} - -// TypeNEQ applies the NEQ predicate on the "type" field. -func TypeNEQ(v string) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldType), v)) - }) -} - -// TypeIn applies the In predicate on the "type" field. -func TypeIn(vs ...string) predicate.NaturalPerson { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.NaturalPerson(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldType), v...)) - }) -} - -// TypeNotIn applies the NotIn predicate on the "type" field. -func TypeNotIn(vs ...string) predicate.NaturalPerson { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.NaturalPerson(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldType), v...)) - }) -} - -// TypeGT applies the GT predicate on the "type" field. -func TypeGT(v string) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldType), v)) - }) -} - -// TypeGTE applies the GTE predicate on the "type" field. -func TypeGTE(v string) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldType), v)) - }) -} - -// TypeLT applies the LT predicate on the "type" field. -func TypeLT(v string) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldType), v)) - }) -} - -// TypeLTE applies the LTE predicate on the "type" field. -func TypeLTE(v string) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldType), v)) - }) -} - -// TypeContains applies the Contains predicate on the "type" field. -func TypeContains(v string) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.Contains(s.C(FieldType), v)) - }) -} - -// TypeHasPrefix applies the HasPrefix predicate on the "type" field. -func TypeHasPrefix(v string) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.HasPrefix(s.C(FieldType), v)) - }) -} - -// TypeHasSuffix applies the HasSuffix predicate on the "type" field. -func TypeHasSuffix(v string) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.HasSuffix(s.C(FieldType), v)) - }) -} - -// TypeEqualFold applies the EqualFold predicate on the "type" field. -func TypeEqualFold(v string) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.EqualFold(s.C(FieldType), v)) - }) -} - -// TypeContainsFold applies the ContainsFold predicate on the "type" field. -func TypeContainsFold(v string) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.ContainsFold(s.C(FieldType), v)) - }) -} - -// PasswordEQ applies the EQ predicate on the "password" field. -func PasswordEQ(v []byte) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldPassword), v)) - }) -} - -// PasswordNEQ applies the NEQ predicate on the "password" field. -func PasswordNEQ(v []byte) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldPassword), v)) - }) -} - -// PasswordIn applies the In predicate on the "password" field. -func PasswordIn(vs ...[]byte) predicate.NaturalPerson { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.NaturalPerson(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldPassword), v...)) - }) -} - -// PasswordNotIn applies the NotIn predicate on the "password" field. -func PasswordNotIn(vs ...[]byte) predicate.NaturalPerson { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.NaturalPerson(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldPassword), v...)) - }) -} - -// PasswordGT applies the GT predicate on the "password" field. -func PasswordGT(v []byte) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldPassword), v)) - }) -} - -// PasswordGTE applies the GTE predicate on the "password" field. -func PasswordGTE(v []byte) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldPassword), v)) - }) -} - -// PasswordLT applies the LT predicate on the "password" field. -func PasswordLT(v []byte) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldPassword), v)) - }) -} - -// PasswordLTE applies the LTE predicate on the "password" field. -func PasswordLTE(v []byte) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldPassword), v)) - }) -} - -// CreatedAtEQ applies the EQ predicate on the "created_at" field. -func CreatedAtEQ(v time.Time) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldCreatedAt), v)) - }) -} - -// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. -func CreatedAtNEQ(v time.Time) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldCreatedAt), v)) - }) -} - -// CreatedAtIn applies the In predicate on the "created_at" field. -func CreatedAtIn(vs ...time.Time) predicate.NaturalPerson { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.NaturalPerson(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldCreatedAt), v...)) - }) -} - -// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. -func CreatedAtNotIn(vs ...time.Time) predicate.NaturalPerson { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.NaturalPerson(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldCreatedAt), v...)) - }) -} - -// CreatedAtGT applies the GT predicate on the "created_at" field. -func CreatedAtGT(v time.Time) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldCreatedAt), v)) - }) -} - -// CreatedAtGTE applies the GTE predicate on the "created_at" field. -func CreatedAtGTE(v time.Time) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldCreatedAt), v)) - }) -} - -// CreatedAtLT applies the LT predicate on the "created_at" field. -func CreatedAtLT(v time.Time) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldCreatedAt), v)) - }) -} - -// CreatedAtLTE applies the LTE predicate on the "created_at" field. -func CreatedAtLTE(v time.Time) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldCreatedAt), v)) - }) -} - -// UpdatedAtEQ applies the EQ predicate on the "updated_at" field. -func UpdatedAtEQ(v time.Time) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldUpdatedAt), v)) - }) -} - -// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field. -func UpdatedAtNEQ(v time.Time) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldUpdatedAt), v)) - }) -} - -// UpdatedAtIn applies the In predicate on the "updated_at" field. -func UpdatedAtIn(vs ...time.Time) predicate.NaturalPerson { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.NaturalPerson(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldUpdatedAt), v...)) - }) -} - -// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field. -func UpdatedAtNotIn(vs ...time.Time) predicate.NaturalPerson { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.NaturalPerson(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldUpdatedAt), v...)) - }) -} - -// UpdatedAtGT applies the GT predicate on the "updated_at" field. -func UpdatedAtGT(v time.Time) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldUpdatedAt), v)) - }) -} - -// UpdatedAtGTE applies the GTE predicate on the "updated_at" field. -func UpdatedAtGTE(v time.Time) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldUpdatedAt), v)) - }) -} - -// UpdatedAtLT applies the LT predicate on the "updated_at" field. -func UpdatedAtLT(v time.Time) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldUpdatedAt), v)) - }) -} - -// UpdatedAtLTE applies the LTE predicate on the "updated_at" field. -func UpdatedAtLTE(v time.Time) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldUpdatedAt), v)) - }) -} - -// HasKeys applies the HasEdge predicate on the "keys" edge. -func HasKeys() predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(KeysTable, FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, KeysTable, KeysColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasKeysWith applies the HasEdge predicate on the "keys" edge with a given conditions (other predicates). -func HasKeysWith(preds ...predicate.PrivateKey) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(KeysInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, KeysTable, KeysColumn), - ) - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// HasCredentials applies the HasEdge predicate on the "credentials" edge. -func HasCredentials() predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(CredentialsTable, FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, CredentialsTable, CredentialsColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasCredentialsWith applies the HasEdge predicate on the "credentials" edge with a given conditions (other predicates). -func HasCredentialsWith(preds ...predicate.Credential) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(CredentialsInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, CredentialsTable, CredentialsColumn), - ) - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// And groups predicates with the AND operator between them. -func And(predicates ...predicate.NaturalPerson) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) -} - -// Or groups predicates with the OR operator between them. -func Or(predicates ...predicate.NaturalPerson) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) -} - -// Not applies the not operator on the given predicate. -func Not(p predicate.NaturalPerson) predicate.NaturalPerson { - return predicate.NaturalPerson(func(s *sql.Selector) { - p(s.Not()) - }) -} diff --git a/ent/naturalperson_create.go b/ent/naturalperson_create.go deleted file mode 100644 index dc81b404..00000000 --- a/ent/naturalperson_create.go +++ /dev/null @@ -1,448 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - "time" - - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/fiware/vcverifier/ent/credential" - "github.com/fiware/vcverifier/ent/naturalperson" - "github.com/fiware/vcverifier/ent/privatekey" -) - -// NaturalPersonCreate is the builder for creating a NaturalPerson entity. -type NaturalPersonCreate struct { - config - mutation *NaturalPersonMutation - hooks []Hook -} - -// SetName sets the "name" field. -func (npc *NaturalPersonCreate) SetName(s string) *NaturalPersonCreate { - npc.mutation.SetName(s) - return npc -} - -// SetDisplayname sets the "displayname" field. -func (npc *NaturalPersonCreate) SetDisplayname(s string) *NaturalPersonCreate { - npc.mutation.SetDisplayname(s) - return npc -} - -// SetNillableDisplayname sets the "displayname" field if the given value is not nil. -func (npc *NaturalPersonCreate) SetNillableDisplayname(s *string) *NaturalPersonCreate { - if s != nil { - npc.SetDisplayname(*s) - } - return npc -} - -// SetType sets the "type" field. -func (npc *NaturalPersonCreate) SetType(s string) *NaturalPersonCreate { - npc.mutation.SetType(s) - return npc -} - -// SetPassword sets the "password" field. -func (npc *NaturalPersonCreate) SetPassword(b []byte) *NaturalPersonCreate { - npc.mutation.SetPassword(b) - return npc -} - -// SetCreatedAt sets the "created_at" field. -func (npc *NaturalPersonCreate) SetCreatedAt(t time.Time) *NaturalPersonCreate { - npc.mutation.SetCreatedAt(t) - return npc -} - -// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. -func (npc *NaturalPersonCreate) SetNillableCreatedAt(t *time.Time) *NaturalPersonCreate { - if t != nil { - npc.SetCreatedAt(*t) - } - return npc -} - -// SetUpdatedAt sets the "updated_at" field. -func (npc *NaturalPersonCreate) SetUpdatedAt(t time.Time) *NaturalPersonCreate { - npc.mutation.SetUpdatedAt(t) - return npc -} - -// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. -func (npc *NaturalPersonCreate) SetNillableUpdatedAt(t *time.Time) *NaturalPersonCreate { - if t != nil { - npc.SetUpdatedAt(*t) - } - return npc -} - -// SetID sets the "id" field. -func (npc *NaturalPersonCreate) SetID(s string) *NaturalPersonCreate { - npc.mutation.SetID(s) - return npc -} - -// AddKeyIDs adds the "keys" edge to the PrivateKey entity by IDs. -func (npc *NaturalPersonCreate) AddKeyIDs(ids ...string) *NaturalPersonCreate { - npc.mutation.AddKeyIDs(ids...) - return npc -} - -// AddKeys adds the "keys" edges to the PrivateKey entity. -func (npc *NaturalPersonCreate) AddKeys(p ...*PrivateKey) *NaturalPersonCreate { - ids := make([]string, len(p)) - for i := range p { - ids[i] = p[i].ID - } - return npc.AddKeyIDs(ids...) -} - -// AddCredentialIDs adds the "credentials" edge to the Credential entity by IDs. -func (npc *NaturalPersonCreate) AddCredentialIDs(ids ...string) *NaturalPersonCreate { - npc.mutation.AddCredentialIDs(ids...) - return npc -} - -// AddCredentials adds the "credentials" edges to the Credential entity. -func (npc *NaturalPersonCreate) AddCredentials(c ...*Credential) *NaturalPersonCreate { - ids := make([]string, len(c)) - for i := range c { - ids[i] = c[i].ID - } - return npc.AddCredentialIDs(ids...) -} - -// Mutation returns the NaturalPersonMutation object of the builder. -func (npc *NaturalPersonCreate) Mutation() *NaturalPersonMutation { - return npc.mutation -} - -// Save creates the NaturalPerson in the database. -func (npc *NaturalPersonCreate) Save(ctx context.Context) (*NaturalPerson, error) { - var ( - err error - node *NaturalPerson - ) - npc.defaults() - if len(npc.hooks) == 0 { - if err = npc.check(); err != nil { - return nil, err - } - node, err = npc.sqlSave(ctx) - } else { - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*NaturalPersonMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - if err = npc.check(); err != nil { - return nil, err - } - npc.mutation = mutation - if node, err = npc.sqlSave(ctx); err != nil { - return nil, err - } - mutation.id = &node.ID - mutation.done = true - return node, err - }) - for i := len(npc.hooks) - 1; i >= 0; i-- { - if npc.hooks[i] == nil { - return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") - } - mut = npc.hooks[i](mut) - } - v, err := mut.Mutate(ctx, npc.mutation) - if err != nil { - return nil, err - } - nv, ok := v.(*NaturalPerson) - if !ok { - return nil, fmt.Errorf("unexpected node type %T returned from NaturalPersonMutation", v) - } - node = nv - } - return node, err -} - -// SaveX calls Save and panics if Save returns an error. -func (npc *NaturalPersonCreate) SaveX(ctx context.Context) *NaturalPerson { - v, err := npc.Save(ctx) - if err != nil { - panic(err) - } - return v -} - -// Exec executes the query. -func (npc *NaturalPersonCreate) Exec(ctx context.Context) error { - _, err := npc.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (npc *NaturalPersonCreate) ExecX(ctx context.Context) { - if err := npc.Exec(ctx); err != nil { - panic(err) - } -} - -// defaults sets the default values of the builder before save. -func (npc *NaturalPersonCreate) defaults() { - if _, ok := npc.mutation.CreatedAt(); !ok { - v := naturalperson.DefaultCreatedAt() - npc.mutation.SetCreatedAt(v) - } - if _, ok := npc.mutation.UpdatedAt(); !ok { - v := naturalperson.DefaultUpdatedAt() - npc.mutation.SetUpdatedAt(v) - } -} - -// check runs all checks and user-defined validators on the builder. -func (npc *NaturalPersonCreate) check() error { - if _, ok := npc.mutation.Name(); !ok { - return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "NaturalPerson.name"`)} - } - if v, ok := npc.mutation.Name(); ok { - if err := naturalperson.NameValidator(v); err != nil { - return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "NaturalPerson.name": %w`, err)} - } - } - if _, ok := npc.mutation.GetType(); !ok { - return &ValidationError{Name: "type", err: errors.New(`ent: missing required field "NaturalPerson.type"`)} - } - if v, ok := npc.mutation.GetType(); ok { - if err := naturalperson.TypeValidator(v); err != nil { - return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "NaturalPerson.type": %w`, err)} - } - } - if _, ok := npc.mutation.Password(); !ok { - return &ValidationError{Name: "password", err: errors.New(`ent: missing required field "NaturalPerson.password"`)} - } - if v, ok := npc.mutation.Password(); ok { - if err := naturalperson.PasswordValidator(v); err != nil { - return &ValidationError{Name: "password", err: fmt.Errorf(`ent: validator failed for field "NaturalPerson.password": %w`, err)} - } - } - if _, ok := npc.mutation.CreatedAt(); !ok { - return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "NaturalPerson.created_at"`)} - } - if _, ok := npc.mutation.UpdatedAt(); !ok { - return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "NaturalPerson.updated_at"`)} - } - if v, ok := npc.mutation.ID(); ok { - if err := naturalperson.IDValidator(v); err != nil { - return &ValidationError{Name: "id", err: fmt.Errorf(`ent: validator failed for field "NaturalPerson.id": %w`, err)} - } - } - return nil -} - -func (npc *NaturalPersonCreate) sqlSave(ctx context.Context) (*NaturalPerson, error) { - _node, _spec := npc.createSpec() - if err := sqlgraph.CreateNode(ctx, npc.driver, _spec); err != nil { - if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return nil, err - } - if _spec.ID.Value != nil { - if id, ok := _spec.ID.Value.(string); ok { - _node.ID = id - } else { - return nil, fmt.Errorf("unexpected NaturalPerson.ID type: %T", _spec.ID.Value) - } - } - return _node, nil -} - -func (npc *NaturalPersonCreate) createSpec() (*NaturalPerson, *sqlgraph.CreateSpec) { - var ( - _node = &NaturalPerson{config: npc.config} - _spec = &sqlgraph.CreateSpec{ - Table: naturalperson.Table, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: naturalperson.FieldID, - }, - } - ) - if id, ok := npc.mutation.ID(); ok { - _node.ID = id - _spec.ID.Value = id - } - if value, ok := npc.mutation.Name(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeString, - Value: value, - Column: naturalperson.FieldName, - }) - _node.Name = value - } - if value, ok := npc.mutation.Displayname(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeString, - Value: value, - Column: naturalperson.FieldDisplayname, - }) - _node.Displayname = value - } - if value, ok := npc.mutation.GetType(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeString, - Value: value, - Column: naturalperson.FieldType, - }) - _node.Type = value - } - if value, ok := npc.mutation.Password(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeBytes, - Value: value, - Column: naturalperson.FieldPassword, - }) - _node.Password = value - } - if value, ok := npc.mutation.CreatedAt(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeTime, - Value: value, - Column: naturalperson.FieldCreatedAt, - }) - _node.CreatedAt = value - } - if value, ok := npc.mutation.UpdatedAt(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeTime, - Value: value, - Column: naturalperson.FieldUpdatedAt, - }) - _node.UpdatedAt = value - } - if nodes := npc.mutation.KeysIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: naturalperson.KeysTable, - Columns: []string{naturalperson.KeysColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: privatekey.FieldID, - }, - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges = append(_spec.Edges, edge) - } - if nodes := npc.mutation.CredentialsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: naturalperson.CredentialsTable, - Columns: []string{naturalperson.CredentialsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: credential.FieldID, - }, - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges = append(_spec.Edges, edge) - } - return _node, _spec -} - -// NaturalPersonCreateBulk is the builder for creating many NaturalPerson entities in bulk. -type NaturalPersonCreateBulk struct { - config - builders []*NaturalPersonCreate -} - -// Save creates the NaturalPerson entities in the database. -func (npcb *NaturalPersonCreateBulk) Save(ctx context.Context) ([]*NaturalPerson, error) { - specs := make([]*sqlgraph.CreateSpec, len(npcb.builders)) - nodes := make([]*NaturalPerson, len(npcb.builders)) - mutators := make([]Mutator, len(npcb.builders)) - for i := range npcb.builders { - func(i int, root context.Context) { - builder := npcb.builders[i] - builder.defaults() - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*NaturalPersonMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - if err := builder.check(); err != nil { - return nil, err - } - builder.mutation = mutation - nodes[i], specs[i] = builder.createSpec() - var err error - if i < len(mutators)-1 { - _, err = mutators[i+1].Mutate(root, npcb.builders[i+1].mutation) - } else { - spec := &sqlgraph.BatchCreateSpec{Nodes: specs} - // Invoke the actual operation on the latest mutation in the chain. - if err = sqlgraph.BatchCreate(ctx, npcb.driver, spec); err != nil { - if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - } - } - if err != nil { - return nil, err - } - mutation.id = &nodes[i].ID - mutation.done = true - return nodes[i], nil - }) - for i := len(builder.hooks) - 1; i >= 0; i-- { - mut = builder.hooks[i](mut) - } - mutators[i] = mut - }(i, ctx) - } - if len(mutators) > 0 { - if _, err := mutators[0].Mutate(ctx, npcb.builders[0].mutation); err != nil { - return nil, err - } - } - return nodes, nil -} - -// SaveX is like Save, but panics if an error occurs. -func (npcb *NaturalPersonCreateBulk) SaveX(ctx context.Context) []*NaturalPerson { - v, err := npcb.Save(ctx) - if err != nil { - panic(err) - } - return v -} - -// Exec executes the query. -func (npcb *NaturalPersonCreateBulk) Exec(ctx context.Context) error { - _, err := npcb.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (npcb *NaturalPersonCreateBulk) ExecX(ctx context.Context) { - if err := npcb.Exec(ctx); err != nil { - panic(err) - } -} diff --git a/ent/naturalperson_delete.go b/ent/naturalperson_delete.go deleted file mode 100644 index 9d7e7e13..00000000 --- a/ent/naturalperson_delete.go +++ /dev/null @@ -1,115 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "fmt" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/fiware/vcverifier/ent/naturalperson" - "github.com/fiware/vcverifier/ent/predicate" -) - -// NaturalPersonDelete is the builder for deleting a NaturalPerson entity. -type NaturalPersonDelete struct { - config - hooks []Hook - mutation *NaturalPersonMutation -} - -// Where appends a list predicates to the NaturalPersonDelete builder. -func (npd *NaturalPersonDelete) Where(ps ...predicate.NaturalPerson) *NaturalPersonDelete { - npd.mutation.Where(ps...) - return npd -} - -// Exec executes the deletion query and returns how many vertices were deleted. -func (npd *NaturalPersonDelete) Exec(ctx context.Context) (int, error) { - var ( - err error - affected int - ) - if len(npd.hooks) == 0 { - affected, err = npd.sqlExec(ctx) - } else { - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*NaturalPersonMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - npd.mutation = mutation - affected, err = npd.sqlExec(ctx) - mutation.done = true - return affected, err - }) - for i := len(npd.hooks) - 1; i >= 0; i-- { - if npd.hooks[i] == nil { - return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") - } - mut = npd.hooks[i](mut) - } - if _, err := mut.Mutate(ctx, npd.mutation); err != nil { - return 0, err - } - } - return affected, err -} - -// ExecX is like Exec, but panics if an error occurs. -func (npd *NaturalPersonDelete) ExecX(ctx context.Context) int { - n, err := npd.Exec(ctx) - if err != nil { - panic(err) - } - return n -} - -func (npd *NaturalPersonDelete) sqlExec(ctx context.Context) (int, error) { - _spec := &sqlgraph.DeleteSpec{ - Node: &sqlgraph.NodeSpec{ - Table: naturalperson.Table, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: naturalperson.FieldID, - }, - }, - } - if ps := npd.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - affected, err := sqlgraph.DeleteNodes(ctx, npd.driver, _spec) - if err != nil && sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return affected, err -} - -// NaturalPersonDeleteOne is the builder for deleting a single NaturalPerson entity. -type NaturalPersonDeleteOne struct { - npd *NaturalPersonDelete -} - -// Exec executes the deletion query. -func (npdo *NaturalPersonDeleteOne) Exec(ctx context.Context) error { - n, err := npdo.npd.Exec(ctx) - switch { - case err != nil: - return err - case n == 0: - return &NotFoundError{naturalperson.Label} - default: - return nil - } -} - -// ExecX is like Exec, but panics if an error occurs. -func (npdo *NaturalPersonDeleteOne) ExecX(ctx context.Context) { - npdo.npd.ExecX(ctx) -} diff --git a/ent/naturalperson_query.go b/ent/naturalperson_query.go deleted file mode 100644 index 1f8f9a85..00000000 --- a/ent/naturalperson_query.go +++ /dev/null @@ -1,664 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "database/sql/driver" - "fmt" - "math" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/fiware/vcverifier/ent/credential" - "github.com/fiware/vcverifier/ent/naturalperson" - "github.com/fiware/vcverifier/ent/predicate" - "github.com/fiware/vcverifier/ent/privatekey" -) - -// NaturalPersonQuery is the builder for querying NaturalPerson entities. -type NaturalPersonQuery struct { - config - limit *int - offset *int - unique *bool - order []OrderFunc - fields []string - predicates []predicate.NaturalPerson - // eager-loading edges. - withKeys *PrivateKeyQuery - withCredentials *CredentialQuery - // intermediate query (i.e. traversal path). - sql *sql.Selector - path func(context.Context) (*sql.Selector, error) -} - -// Where adds a new predicate for the NaturalPersonQuery builder. -func (npq *NaturalPersonQuery) Where(ps ...predicate.NaturalPerson) *NaturalPersonQuery { - npq.predicates = append(npq.predicates, ps...) - return npq -} - -// Limit adds a limit step to the query. -func (npq *NaturalPersonQuery) Limit(limit int) *NaturalPersonQuery { - npq.limit = &limit - return npq -} - -// Offset adds an offset step to the query. -func (npq *NaturalPersonQuery) Offset(offset int) *NaturalPersonQuery { - npq.offset = &offset - return npq -} - -// Unique configures the query builder to filter duplicate records on query. -// By default, unique is set to true, and can be disabled using this method. -func (npq *NaturalPersonQuery) Unique(unique bool) *NaturalPersonQuery { - npq.unique = &unique - return npq -} - -// Order adds an order step to the query. -func (npq *NaturalPersonQuery) Order(o ...OrderFunc) *NaturalPersonQuery { - npq.order = append(npq.order, o...) - return npq -} - -// QueryKeys chains the current query on the "keys" edge. -func (npq *NaturalPersonQuery) QueryKeys() *PrivateKeyQuery { - query := &PrivateKeyQuery{config: npq.config} - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := npq.prepareQuery(ctx); err != nil { - return nil, err - } - selector := npq.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(naturalperson.Table, naturalperson.FieldID, selector), - sqlgraph.To(privatekey.Table, privatekey.FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, naturalperson.KeysTable, naturalperson.KeysColumn), - ) - fromU = sqlgraph.SetNeighbors(npq.driver.Dialect(), step) - return fromU, nil - } - return query -} - -// QueryCredentials chains the current query on the "credentials" edge. -func (npq *NaturalPersonQuery) QueryCredentials() *CredentialQuery { - query := &CredentialQuery{config: npq.config} - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := npq.prepareQuery(ctx); err != nil { - return nil, err - } - selector := npq.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(naturalperson.Table, naturalperson.FieldID, selector), - sqlgraph.To(credential.Table, credential.FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, naturalperson.CredentialsTable, naturalperson.CredentialsColumn), - ) - fromU = sqlgraph.SetNeighbors(npq.driver.Dialect(), step) - return fromU, nil - } - return query -} - -// First returns the first NaturalPerson entity from the query. -// Returns a *NotFoundError when no NaturalPerson was found. -func (npq *NaturalPersonQuery) First(ctx context.Context) (*NaturalPerson, error) { - nodes, err := npq.Limit(1).All(ctx) - if err != nil { - return nil, err - } - if len(nodes) == 0 { - return nil, &NotFoundError{naturalperson.Label} - } - return nodes[0], nil -} - -// FirstX is like First, but panics if an error occurs. -func (npq *NaturalPersonQuery) FirstX(ctx context.Context) *NaturalPerson { - node, err := npq.First(ctx) - if err != nil && !IsNotFound(err) { - panic(err) - } - return node -} - -// FirstID returns the first NaturalPerson ID from the query. -// Returns a *NotFoundError when no NaturalPerson ID was found. -func (npq *NaturalPersonQuery) FirstID(ctx context.Context) (id string, err error) { - var ids []string - if ids, err = npq.Limit(1).IDs(ctx); err != nil { - return - } - if len(ids) == 0 { - err = &NotFoundError{naturalperson.Label} - return - } - return ids[0], nil -} - -// FirstIDX is like FirstID, but panics if an error occurs. -func (npq *NaturalPersonQuery) FirstIDX(ctx context.Context) string { - id, err := npq.FirstID(ctx) - if err != nil && !IsNotFound(err) { - panic(err) - } - return id -} - -// Only returns a single NaturalPerson entity found by the query, ensuring it only returns one. -// Returns a *NotSingularError when more than one NaturalPerson entity is found. -// Returns a *NotFoundError when no NaturalPerson entities are found. -func (npq *NaturalPersonQuery) Only(ctx context.Context) (*NaturalPerson, error) { - nodes, err := npq.Limit(2).All(ctx) - if err != nil { - return nil, err - } - switch len(nodes) { - case 1: - return nodes[0], nil - case 0: - return nil, &NotFoundError{naturalperson.Label} - default: - return nil, &NotSingularError{naturalperson.Label} - } -} - -// OnlyX is like Only, but panics if an error occurs. -func (npq *NaturalPersonQuery) OnlyX(ctx context.Context) *NaturalPerson { - node, err := npq.Only(ctx) - if err != nil { - panic(err) - } - return node -} - -// OnlyID is like Only, but returns the only NaturalPerson ID in the query. -// Returns a *NotSingularError when more than one NaturalPerson ID is found. -// Returns a *NotFoundError when no entities are found. -func (npq *NaturalPersonQuery) OnlyID(ctx context.Context) (id string, err error) { - var ids []string - if ids, err = npq.Limit(2).IDs(ctx); err != nil { - return - } - switch len(ids) { - case 1: - id = ids[0] - case 0: - err = &NotFoundError{naturalperson.Label} - default: - err = &NotSingularError{naturalperson.Label} - } - return -} - -// OnlyIDX is like OnlyID, but panics if an error occurs. -func (npq *NaturalPersonQuery) OnlyIDX(ctx context.Context) string { - id, err := npq.OnlyID(ctx) - if err != nil { - panic(err) - } - return id -} - -// All executes the query and returns a list of NaturalPersons. -func (npq *NaturalPersonQuery) All(ctx context.Context) ([]*NaturalPerson, error) { - if err := npq.prepareQuery(ctx); err != nil { - return nil, err - } - return npq.sqlAll(ctx) -} - -// AllX is like All, but panics if an error occurs. -func (npq *NaturalPersonQuery) AllX(ctx context.Context) []*NaturalPerson { - nodes, err := npq.All(ctx) - if err != nil { - panic(err) - } - return nodes -} - -// IDs executes the query and returns a list of NaturalPerson IDs. -func (npq *NaturalPersonQuery) IDs(ctx context.Context) ([]string, error) { - var ids []string - if err := npq.Select(naturalperson.FieldID).Scan(ctx, &ids); err != nil { - return nil, err - } - return ids, nil -} - -// IDsX is like IDs, but panics if an error occurs. -func (npq *NaturalPersonQuery) IDsX(ctx context.Context) []string { - ids, err := npq.IDs(ctx) - if err != nil { - panic(err) - } - return ids -} - -// Count returns the count of the given query. -func (npq *NaturalPersonQuery) Count(ctx context.Context) (int, error) { - if err := npq.prepareQuery(ctx); err != nil { - return 0, err - } - return npq.sqlCount(ctx) -} - -// CountX is like Count, but panics if an error occurs. -func (npq *NaturalPersonQuery) CountX(ctx context.Context) int { - count, err := npq.Count(ctx) - if err != nil { - panic(err) - } - return count -} - -// Exist returns true if the query has elements in the graph. -func (npq *NaturalPersonQuery) Exist(ctx context.Context) (bool, error) { - if err := npq.prepareQuery(ctx); err != nil { - return false, err - } - return npq.sqlExist(ctx) -} - -// ExistX is like Exist, but panics if an error occurs. -func (npq *NaturalPersonQuery) ExistX(ctx context.Context) bool { - exist, err := npq.Exist(ctx) - if err != nil { - panic(err) - } - return exist -} - -// Clone returns a duplicate of the NaturalPersonQuery builder, including all associated steps. It can be -// used to prepare common query builders and use them differently after the clone is made. -func (npq *NaturalPersonQuery) Clone() *NaturalPersonQuery { - if npq == nil { - return nil - } - return &NaturalPersonQuery{ - config: npq.config, - limit: npq.limit, - offset: npq.offset, - order: append([]OrderFunc{}, npq.order...), - predicates: append([]predicate.NaturalPerson{}, npq.predicates...), - withKeys: npq.withKeys.Clone(), - withCredentials: npq.withCredentials.Clone(), - // clone intermediate query. - sql: npq.sql.Clone(), - path: npq.path, - unique: npq.unique, - } -} - -// WithKeys tells the query-builder to eager-load the nodes that are connected to -// the "keys" edge. The optional arguments are used to configure the query builder of the edge. -func (npq *NaturalPersonQuery) WithKeys(opts ...func(*PrivateKeyQuery)) *NaturalPersonQuery { - query := &PrivateKeyQuery{config: npq.config} - for _, opt := range opts { - opt(query) - } - npq.withKeys = query - return npq -} - -// WithCredentials tells the query-builder to eager-load the nodes that are connected to -// the "credentials" edge. The optional arguments are used to configure the query builder of the edge. -func (npq *NaturalPersonQuery) WithCredentials(opts ...func(*CredentialQuery)) *NaturalPersonQuery { - query := &CredentialQuery{config: npq.config} - for _, opt := range opts { - opt(query) - } - npq.withCredentials = query - return npq -} - -// GroupBy is used to group vertices by one or more fields/columns. -// It is often used with aggregate functions, like: count, max, mean, min, sum. -// -// Example: -// -// var v []struct { -// Name string `json:"name,omitempty"` -// Count int `json:"count,omitempty"` -// } -// -// client.NaturalPerson.Query(). -// GroupBy(naturalperson.FieldName). -// Aggregate(ent.Count()). -// Scan(ctx, &v) -func (npq *NaturalPersonQuery) GroupBy(field string, fields ...string) *NaturalPersonGroupBy { - grbuild := &NaturalPersonGroupBy{config: npq.config} - grbuild.fields = append([]string{field}, fields...) - grbuild.path = func(ctx context.Context) (prev *sql.Selector, err error) { - if err := npq.prepareQuery(ctx); err != nil { - return nil, err - } - return npq.sqlQuery(ctx), nil - } - grbuild.label = naturalperson.Label - grbuild.flds, grbuild.scan = &grbuild.fields, grbuild.Scan - return grbuild -} - -// Select allows the selection one or more fields/columns for the given query, -// instead of selecting all fields in the entity. -// -// Example: -// -// var v []struct { -// Name string `json:"name,omitempty"` -// } -// -// client.NaturalPerson.Query(). -// Select(naturalperson.FieldName). -// Scan(ctx, &v) -func (npq *NaturalPersonQuery) Select(fields ...string) *NaturalPersonSelect { - npq.fields = append(npq.fields, fields...) - selbuild := &NaturalPersonSelect{NaturalPersonQuery: npq} - selbuild.label = naturalperson.Label - selbuild.flds, selbuild.scan = &npq.fields, selbuild.Scan - return selbuild -} - -func (npq *NaturalPersonQuery) prepareQuery(ctx context.Context) error { - for _, f := range npq.fields { - if !naturalperson.ValidColumn(f) { - return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} - } - } - if npq.path != nil { - prev, err := npq.path(ctx) - if err != nil { - return err - } - npq.sql = prev - } - return nil -} - -func (npq *NaturalPersonQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*NaturalPerson, error) { - var ( - nodes = []*NaturalPerson{} - _spec = npq.querySpec() - loadedTypes = [2]bool{ - npq.withKeys != nil, - npq.withCredentials != nil, - } - ) - _spec.ScanValues = func(columns []string) ([]interface{}, error) { - return (*NaturalPerson).scanValues(nil, columns) - } - _spec.Assign = func(columns []string, values []interface{}) error { - node := &NaturalPerson{config: npq.config} - nodes = append(nodes, node) - node.Edges.loadedTypes = loadedTypes - return node.assignValues(columns, values) - } - for i := range hooks { - hooks[i](ctx, _spec) - } - if err := sqlgraph.QueryNodes(ctx, npq.driver, _spec); err != nil { - return nil, err - } - if len(nodes) == 0 { - return nodes, nil - } - - if query := npq.withKeys; query != nil { - fks := make([]driver.Value, 0, len(nodes)) - nodeids := make(map[string]*NaturalPerson) - for i := range nodes { - fks = append(fks, nodes[i].ID) - nodeids[nodes[i].ID] = nodes[i] - nodes[i].Edges.Keys = []*PrivateKey{} - } - query.withFKs = true - query.Where(predicate.PrivateKey(func(s *sql.Selector) { - s.Where(sql.InValues(naturalperson.KeysColumn, fks...)) - })) - neighbors, err := query.All(ctx) - if err != nil { - return nil, err - } - for _, n := range neighbors { - fk := n.natural_person_keys - if fk == nil { - return nil, fmt.Errorf(`foreign-key "natural_person_keys" is nil for node %v`, n.ID) - } - node, ok := nodeids[*fk] - if !ok { - return nil, fmt.Errorf(`unexpected foreign-key "natural_person_keys" returned %v for node %v`, *fk, n.ID) - } - node.Edges.Keys = append(node.Edges.Keys, n) - } - } - - if query := npq.withCredentials; query != nil { - fks := make([]driver.Value, 0, len(nodes)) - nodeids := make(map[string]*NaturalPerson) - for i := range nodes { - fks = append(fks, nodes[i].ID) - nodeids[nodes[i].ID] = nodes[i] - nodes[i].Edges.Credentials = []*Credential{} - } - query.withFKs = true - query.Where(predicate.Credential(func(s *sql.Selector) { - s.Where(sql.InValues(naturalperson.CredentialsColumn, fks...)) - })) - neighbors, err := query.All(ctx) - if err != nil { - return nil, err - } - for _, n := range neighbors { - fk := n.natural_person_credentials - if fk == nil { - return nil, fmt.Errorf(`foreign-key "natural_person_credentials" is nil for node %v`, n.ID) - } - node, ok := nodeids[*fk] - if !ok { - return nil, fmt.Errorf(`unexpected foreign-key "natural_person_credentials" returned %v for node %v`, *fk, n.ID) - } - node.Edges.Credentials = append(node.Edges.Credentials, n) - } - } - - return nodes, nil -} - -func (npq *NaturalPersonQuery) sqlCount(ctx context.Context) (int, error) { - _spec := npq.querySpec() - _spec.Node.Columns = npq.fields - if len(npq.fields) > 0 { - _spec.Unique = npq.unique != nil && *npq.unique - } - return sqlgraph.CountNodes(ctx, npq.driver, _spec) -} - -func (npq *NaturalPersonQuery) sqlExist(ctx context.Context) (bool, error) { - n, err := npq.sqlCount(ctx) - if err != nil { - return false, fmt.Errorf("ent: check existence: %w", err) - } - return n > 0, nil -} - -func (npq *NaturalPersonQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: naturalperson.Table, - Columns: naturalperson.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: naturalperson.FieldID, - }, - }, - From: npq.sql, - Unique: true, - } - if unique := npq.unique; unique != nil { - _spec.Unique = *unique - } - if fields := npq.fields; len(fields) > 0 { - _spec.Node.Columns = make([]string, 0, len(fields)) - _spec.Node.Columns = append(_spec.Node.Columns, naturalperson.FieldID) - for i := range fields { - if fields[i] != naturalperson.FieldID { - _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) - } - } - } - if ps := npq.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if limit := npq.limit; limit != nil { - _spec.Limit = *limit - } - if offset := npq.offset; offset != nil { - _spec.Offset = *offset - } - if ps := npq.order; len(ps) > 0 { - _spec.Order = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - return _spec -} - -func (npq *NaturalPersonQuery) sqlQuery(ctx context.Context) *sql.Selector { - builder := sql.Dialect(npq.driver.Dialect()) - t1 := builder.Table(naturalperson.Table) - columns := npq.fields - if len(columns) == 0 { - columns = naturalperson.Columns - } - selector := builder.Select(t1.Columns(columns...)...).From(t1) - if npq.sql != nil { - selector = npq.sql - selector.Select(selector.Columns(columns...)...) - } - if npq.unique != nil && *npq.unique { - selector.Distinct() - } - for _, p := range npq.predicates { - p(selector) - } - for _, p := range npq.order { - p(selector) - } - if offset := npq.offset; offset != nil { - // limit is mandatory for offset clause. We start - // with default value, and override it below if needed. - selector.Offset(*offset).Limit(math.MaxInt32) - } - if limit := npq.limit; limit != nil { - selector.Limit(*limit) - } - return selector -} - -// NaturalPersonGroupBy is the group-by builder for NaturalPerson entities. -type NaturalPersonGroupBy struct { - config - selector - fields []string - fns []AggregateFunc - // intermediate query (i.e. traversal path). - sql *sql.Selector - path func(context.Context) (*sql.Selector, error) -} - -// Aggregate adds the given aggregation functions to the group-by query. -func (npgb *NaturalPersonGroupBy) Aggregate(fns ...AggregateFunc) *NaturalPersonGroupBy { - npgb.fns = append(npgb.fns, fns...) - return npgb -} - -// Scan applies the group-by query and scans the result into the given value. -func (npgb *NaturalPersonGroupBy) Scan(ctx context.Context, v interface{}) error { - query, err := npgb.path(ctx) - if err != nil { - return err - } - npgb.sql = query - return npgb.sqlScan(ctx, v) -} - -func (npgb *NaturalPersonGroupBy) sqlScan(ctx context.Context, v interface{}) error { - for _, f := range npgb.fields { - if !naturalperson.ValidColumn(f) { - return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)} - } - } - selector := npgb.sqlQuery() - if err := selector.Err(); err != nil { - return err - } - rows := &sql.Rows{} - query, args := selector.Query() - if err := npgb.driver.Query(ctx, query, args, rows); err != nil { - return err - } - defer rows.Close() - return sql.ScanSlice(rows, v) -} - -func (npgb *NaturalPersonGroupBy) sqlQuery() *sql.Selector { - selector := npgb.sql.Select() - aggregation := make([]string, 0, len(npgb.fns)) - for _, fn := range npgb.fns { - aggregation = append(aggregation, fn(selector)) - } - // If no columns were selected in a custom aggregation function, the default - // selection is the fields used for "group-by", and the aggregation functions. - if len(selector.SelectedColumns()) == 0 { - columns := make([]string, 0, len(npgb.fields)+len(npgb.fns)) - for _, f := range npgb.fields { - columns = append(columns, selector.C(f)) - } - columns = append(columns, aggregation...) - selector.Select(columns...) - } - return selector.GroupBy(selector.Columns(npgb.fields...)...) -} - -// NaturalPersonSelect is the builder for selecting fields of NaturalPerson entities. -type NaturalPersonSelect struct { - *NaturalPersonQuery - selector - // intermediate query (i.e. traversal path). - sql *sql.Selector -} - -// Scan applies the selector query and scans the result into the given value. -func (nps *NaturalPersonSelect) Scan(ctx context.Context, v interface{}) error { - if err := nps.prepareQuery(ctx); err != nil { - return err - } - nps.sql = nps.NaturalPersonQuery.sqlQuery(ctx) - return nps.sqlScan(ctx, v) -} - -func (nps *NaturalPersonSelect) sqlScan(ctx context.Context, v interface{}) error { - rows := &sql.Rows{} - query, args := nps.sql.Query() - if err := nps.driver.Query(ctx, query, args, rows); err != nil { - return err - } - defer rows.Close() - return sql.ScanSlice(rows, v) -} diff --git a/ent/naturalperson_update.go b/ent/naturalperson_update.go deleted file mode 100644 index f64c3e8a..00000000 --- a/ent/naturalperson_update.go +++ /dev/null @@ -1,846 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - "time" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/fiware/vcverifier/ent/credential" - "github.com/fiware/vcverifier/ent/naturalperson" - "github.com/fiware/vcverifier/ent/predicate" - "github.com/fiware/vcverifier/ent/privatekey" -) - -// NaturalPersonUpdate is the builder for updating NaturalPerson entities. -type NaturalPersonUpdate struct { - config - hooks []Hook - mutation *NaturalPersonMutation -} - -// Where appends a list predicates to the NaturalPersonUpdate builder. -func (npu *NaturalPersonUpdate) Where(ps ...predicate.NaturalPerson) *NaturalPersonUpdate { - npu.mutation.Where(ps...) - return npu -} - -// SetName sets the "name" field. -func (npu *NaturalPersonUpdate) SetName(s string) *NaturalPersonUpdate { - npu.mutation.SetName(s) - return npu -} - -// SetDisplayname sets the "displayname" field. -func (npu *NaturalPersonUpdate) SetDisplayname(s string) *NaturalPersonUpdate { - npu.mutation.SetDisplayname(s) - return npu -} - -// SetNillableDisplayname sets the "displayname" field if the given value is not nil. -func (npu *NaturalPersonUpdate) SetNillableDisplayname(s *string) *NaturalPersonUpdate { - if s != nil { - npu.SetDisplayname(*s) - } - return npu -} - -// ClearDisplayname clears the value of the "displayname" field. -func (npu *NaturalPersonUpdate) ClearDisplayname() *NaturalPersonUpdate { - npu.mutation.ClearDisplayname() - return npu -} - -// SetType sets the "type" field. -func (npu *NaturalPersonUpdate) SetType(s string) *NaturalPersonUpdate { - npu.mutation.SetType(s) - return npu -} - -// SetPassword sets the "password" field. -func (npu *NaturalPersonUpdate) SetPassword(b []byte) *NaturalPersonUpdate { - npu.mutation.SetPassword(b) - return npu -} - -// SetUpdatedAt sets the "updated_at" field. -func (npu *NaturalPersonUpdate) SetUpdatedAt(t time.Time) *NaturalPersonUpdate { - npu.mutation.SetUpdatedAt(t) - return npu -} - -// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. -func (npu *NaturalPersonUpdate) SetNillableUpdatedAt(t *time.Time) *NaturalPersonUpdate { - if t != nil { - npu.SetUpdatedAt(*t) - } - return npu -} - -// AddKeyIDs adds the "keys" edge to the PrivateKey entity by IDs. -func (npu *NaturalPersonUpdate) AddKeyIDs(ids ...string) *NaturalPersonUpdate { - npu.mutation.AddKeyIDs(ids...) - return npu -} - -// AddKeys adds the "keys" edges to the PrivateKey entity. -func (npu *NaturalPersonUpdate) AddKeys(p ...*PrivateKey) *NaturalPersonUpdate { - ids := make([]string, len(p)) - for i := range p { - ids[i] = p[i].ID - } - return npu.AddKeyIDs(ids...) -} - -// AddCredentialIDs adds the "credentials" edge to the Credential entity by IDs. -func (npu *NaturalPersonUpdate) AddCredentialIDs(ids ...string) *NaturalPersonUpdate { - npu.mutation.AddCredentialIDs(ids...) - return npu -} - -// AddCredentials adds the "credentials" edges to the Credential entity. -func (npu *NaturalPersonUpdate) AddCredentials(c ...*Credential) *NaturalPersonUpdate { - ids := make([]string, len(c)) - for i := range c { - ids[i] = c[i].ID - } - return npu.AddCredentialIDs(ids...) -} - -// Mutation returns the NaturalPersonMutation object of the builder. -func (npu *NaturalPersonUpdate) Mutation() *NaturalPersonMutation { - return npu.mutation -} - -// ClearKeys clears all "keys" edges to the PrivateKey entity. -func (npu *NaturalPersonUpdate) ClearKeys() *NaturalPersonUpdate { - npu.mutation.ClearKeys() - return npu -} - -// RemoveKeyIDs removes the "keys" edge to PrivateKey entities by IDs. -func (npu *NaturalPersonUpdate) RemoveKeyIDs(ids ...string) *NaturalPersonUpdate { - npu.mutation.RemoveKeyIDs(ids...) - return npu -} - -// RemoveKeys removes "keys" edges to PrivateKey entities. -func (npu *NaturalPersonUpdate) RemoveKeys(p ...*PrivateKey) *NaturalPersonUpdate { - ids := make([]string, len(p)) - for i := range p { - ids[i] = p[i].ID - } - return npu.RemoveKeyIDs(ids...) -} - -// ClearCredentials clears all "credentials" edges to the Credential entity. -func (npu *NaturalPersonUpdate) ClearCredentials() *NaturalPersonUpdate { - npu.mutation.ClearCredentials() - return npu -} - -// RemoveCredentialIDs removes the "credentials" edge to Credential entities by IDs. -func (npu *NaturalPersonUpdate) RemoveCredentialIDs(ids ...string) *NaturalPersonUpdate { - npu.mutation.RemoveCredentialIDs(ids...) - return npu -} - -// RemoveCredentials removes "credentials" edges to Credential entities. -func (npu *NaturalPersonUpdate) RemoveCredentials(c ...*Credential) *NaturalPersonUpdate { - ids := make([]string, len(c)) - for i := range c { - ids[i] = c[i].ID - } - return npu.RemoveCredentialIDs(ids...) -} - -// Save executes the query and returns the number of nodes affected by the update operation. -func (npu *NaturalPersonUpdate) Save(ctx context.Context) (int, error) { - var ( - err error - affected int - ) - if len(npu.hooks) == 0 { - if err = npu.check(); err != nil { - return 0, err - } - affected, err = npu.sqlSave(ctx) - } else { - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*NaturalPersonMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - if err = npu.check(); err != nil { - return 0, err - } - npu.mutation = mutation - affected, err = npu.sqlSave(ctx) - mutation.done = true - return affected, err - }) - for i := len(npu.hooks) - 1; i >= 0; i-- { - if npu.hooks[i] == nil { - return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") - } - mut = npu.hooks[i](mut) - } - if _, err := mut.Mutate(ctx, npu.mutation); err != nil { - return 0, err - } - } - return affected, err -} - -// SaveX is like Save, but panics if an error occurs. -func (npu *NaturalPersonUpdate) SaveX(ctx context.Context) int { - affected, err := npu.Save(ctx) - if err != nil { - panic(err) - } - return affected -} - -// Exec executes the query. -func (npu *NaturalPersonUpdate) Exec(ctx context.Context) error { - _, err := npu.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (npu *NaturalPersonUpdate) ExecX(ctx context.Context) { - if err := npu.Exec(ctx); err != nil { - panic(err) - } -} - -// check runs all checks and user-defined validators on the builder. -func (npu *NaturalPersonUpdate) check() error { - if v, ok := npu.mutation.Name(); ok { - if err := naturalperson.NameValidator(v); err != nil { - return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "NaturalPerson.name": %w`, err)} - } - } - if v, ok := npu.mutation.GetType(); ok { - if err := naturalperson.TypeValidator(v); err != nil { - return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "NaturalPerson.type": %w`, err)} - } - } - if v, ok := npu.mutation.Password(); ok { - if err := naturalperson.PasswordValidator(v); err != nil { - return &ValidationError{Name: "password", err: fmt.Errorf(`ent: validator failed for field "NaturalPerson.password": %w`, err)} - } - } - return nil -} - -func (npu *NaturalPersonUpdate) sqlSave(ctx context.Context) (n int, err error) { - _spec := &sqlgraph.UpdateSpec{ - Node: &sqlgraph.NodeSpec{ - Table: naturalperson.Table, - Columns: naturalperson.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: naturalperson.FieldID, - }, - }, - } - if ps := npu.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if value, ok := npu.mutation.Name(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeString, - Value: value, - Column: naturalperson.FieldName, - }) - } - if value, ok := npu.mutation.Displayname(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeString, - Value: value, - Column: naturalperson.FieldDisplayname, - }) - } - if npu.mutation.DisplaynameCleared() { - _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: naturalperson.FieldDisplayname, - }) - } - if value, ok := npu.mutation.GetType(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeString, - Value: value, - Column: naturalperson.FieldType, - }) - } - if value, ok := npu.mutation.Password(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeBytes, - Value: value, - Column: naturalperson.FieldPassword, - }) - } - if value, ok := npu.mutation.UpdatedAt(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeTime, - Value: value, - Column: naturalperson.FieldUpdatedAt, - }) - } - if npu.mutation.KeysCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: naturalperson.KeysTable, - Columns: []string{naturalperson.KeysColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: privatekey.FieldID, - }, - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := npu.mutation.RemovedKeysIDs(); len(nodes) > 0 && !npu.mutation.KeysCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: naturalperson.KeysTable, - Columns: []string{naturalperson.KeysColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: privatekey.FieldID, - }, - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := npu.mutation.KeysIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: naturalperson.KeysTable, - Columns: []string{naturalperson.KeysColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: privatekey.FieldID, - }, - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if npu.mutation.CredentialsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: naturalperson.CredentialsTable, - Columns: []string{naturalperson.CredentialsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: credential.FieldID, - }, - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := npu.mutation.RemovedCredentialsIDs(); len(nodes) > 0 && !npu.mutation.CredentialsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: naturalperson.CredentialsTable, - Columns: []string{naturalperson.CredentialsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: credential.FieldID, - }, - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := npu.mutation.CredentialsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: naturalperson.CredentialsTable, - Columns: []string{naturalperson.CredentialsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: credential.FieldID, - }, - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if n, err = sqlgraph.UpdateNodes(ctx, npu.driver, _spec); err != nil { - if _, ok := err.(*sqlgraph.NotFoundError); ok { - err = &NotFoundError{naturalperson.Label} - } else if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return 0, err - } - return n, nil -} - -// NaturalPersonUpdateOne is the builder for updating a single NaturalPerson entity. -type NaturalPersonUpdateOne struct { - config - fields []string - hooks []Hook - mutation *NaturalPersonMutation -} - -// SetName sets the "name" field. -func (npuo *NaturalPersonUpdateOne) SetName(s string) *NaturalPersonUpdateOne { - npuo.mutation.SetName(s) - return npuo -} - -// SetDisplayname sets the "displayname" field. -func (npuo *NaturalPersonUpdateOne) SetDisplayname(s string) *NaturalPersonUpdateOne { - npuo.mutation.SetDisplayname(s) - return npuo -} - -// SetNillableDisplayname sets the "displayname" field if the given value is not nil. -func (npuo *NaturalPersonUpdateOne) SetNillableDisplayname(s *string) *NaturalPersonUpdateOne { - if s != nil { - npuo.SetDisplayname(*s) - } - return npuo -} - -// ClearDisplayname clears the value of the "displayname" field. -func (npuo *NaturalPersonUpdateOne) ClearDisplayname() *NaturalPersonUpdateOne { - npuo.mutation.ClearDisplayname() - return npuo -} - -// SetType sets the "type" field. -func (npuo *NaturalPersonUpdateOne) SetType(s string) *NaturalPersonUpdateOne { - npuo.mutation.SetType(s) - return npuo -} - -// SetPassword sets the "password" field. -func (npuo *NaturalPersonUpdateOne) SetPassword(b []byte) *NaturalPersonUpdateOne { - npuo.mutation.SetPassword(b) - return npuo -} - -// SetUpdatedAt sets the "updated_at" field. -func (npuo *NaturalPersonUpdateOne) SetUpdatedAt(t time.Time) *NaturalPersonUpdateOne { - npuo.mutation.SetUpdatedAt(t) - return npuo -} - -// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. -func (npuo *NaturalPersonUpdateOne) SetNillableUpdatedAt(t *time.Time) *NaturalPersonUpdateOne { - if t != nil { - npuo.SetUpdatedAt(*t) - } - return npuo -} - -// AddKeyIDs adds the "keys" edge to the PrivateKey entity by IDs. -func (npuo *NaturalPersonUpdateOne) AddKeyIDs(ids ...string) *NaturalPersonUpdateOne { - npuo.mutation.AddKeyIDs(ids...) - return npuo -} - -// AddKeys adds the "keys" edges to the PrivateKey entity. -func (npuo *NaturalPersonUpdateOne) AddKeys(p ...*PrivateKey) *NaturalPersonUpdateOne { - ids := make([]string, len(p)) - for i := range p { - ids[i] = p[i].ID - } - return npuo.AddKeyIDs(ids...) -} - -// AddCredentialIDs adds the "credentials" edge to the Credential entity by IDs. -func (npuo *NaturalPersonUpdateOne) AddCredentialIDs(ids ...string) *NaturalPersonUpdateOne { - npuo.mutation.AddCredentialIDs(ids...) - return npuo -} - -// AddCredentials adds the "credentials" edges to the Credential entity. -func (npuo *NaturalPersonUpdateOne) AddCredentials(c ...*Credential) *NaturalPersonUpdateOne { - ids := make([]string, len(c)) - for i := range c { - ids[i] = c[i].ID - } - return npuo.AddCredentialIDs(ids...) -} - -// Mutation returns the NaturalPersonMutation object of the builder. -func (npuo *NaturalPersonUpdateOne) Mutation() *NaturalPersonMutation { - return npuo.mutation -} - -// ClearKeys clears all "keys" edges to the PrivateKey entity. -func (npuo *NaturalPersonUpdateOne) ClearKeys() *NaturalPersonUpdateOne { - npuo.mutation.ClearKeys() - return npuo -} - -// RemoveKeyIDs removes the "keys" edge to PrivateKey entities by IDs. -func (npuo *NaturalPersonUpdateOne) RemoveKeyIDs(ids ...string) *NaturalPersonUpdateOne { - npuo.mutation.RemoveKeyIDs(ids...) - return npuo -} - -// RemoveKeys removes "keys" edges to PrivateKey entities. -func (npuo *NaturalPersonUpdateOne) RemoveKeys(p ...*PrivateKey) *NaturalPersonUpdateOne { - ids := make([]string, len(p)) - for i := range p { - ids[i] = p[i].ID - } - return npuo.RemoveKeyIDs(ids...) -} - -// ClearCredentials clears all "credentials" edges to the Credential entity. -func (npuo *NaturalPersonUpdateOne) ClearCredentials() *NaturalPersonUpdateOne { - npuo.mutation.ClearCredentials() - return npuo -} - -// RemoveCredentialIDs removes the "credentials" edge to Credential entities by IDs. -func (npuo *NaturalPersonUpdateOne) RemoveCredentialIDs(ids ...string) *NaturalPersonUpdateOne { - npuo.mutation.RemoveCredentialIDs(ids...) - return npuo -} - -// RemoveCredentials removes "credentials" edges to Credential entities. -func (npuo *NaturalPersonUpdateOne) RemoveCredentials(c ...*Credential) *NaturalPersonUpdateOne { - ids := make([]string, len(c)) - for i := range c { - ids[i] = c[i].ID - } - return npuo.RemoveCredentialIDs(ids...) -} - -// Select allows selecting one or more fields (columns) of the returned entity. -// The default is selecting all fields defined in the entity schema. -func (npuo *NaturalPersonUpdateOne) Select(field string, fields ...string) *NaturalPersonUpdateOne { - npuo.fields = append([]string{field}, fields...) - return npuo -} - -// Save executes the query and returns the updated NaturalPerson entity. -func (npuo *NaturalPersonUpdateOne) Save(ctx context.Context) (*NaturalPerson, error) { - var ( - err error - node *NaturalPerson - ) - if len(npuo.hooks) == 0 { - if err = npuo.check(); err != nil { - return nil, err - } - node, err = npuo.sqlSave(ctx) - } else { - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*NaturalPersonMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - if err = npuo.check(); err != nil { - return nil, err - } - npuo.mutation = mutation - node, err = npuo.sqlSave(ctx) - mutation.done = true - return node, err - }) - for i := len(npuo.hooks) - 1; i >= 0; i-- { - if npuo.hooks[i] == nil { - return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") - } - mut = npuo.hooks[i](mut) - } - v, err := mut.Mutate(ctx, npuo.mutation) - if err != nil { - return nil, err - } - nv, ok := v.(*NaturalPerson) - if !ok { - return nil, fmt.Errorf("unexpected node type %T returned from NaturalPersonMutation", v) - } - node = nv - } - return node, err -} - -// SaveX is like Save, but panics if an error occurs. -func (npuo *NaturalPersonUpdateOne) SaveX(ctx context.Context) *NaturalPerson { - node, err := npuo.Save(ctx) - if err != nil { - panic(err) - } - return node -} - -// Exec executes the query on the entity. -func (npuo *NaturalPersonUpdateOne) Exec(ctx context.Context) error { - _, err := npuo.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (npuo *NaturalPersonUpdateOne) ExecX(ctx context.Context) { - if err := npuo.Exec(ctx); err != nil { - panic(err) - } -} - -// check runs all checks and user-defined validators on the builder. -func (npuo *NaturalPersonUpdateOne) check() error { - if v, ok := npuo.mutation.Name(); ok { - if err := naturalperson.NameValidator(v); err != nil { - return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "NaturalPerson.name": %w`, err)} - } - } - if v, ok := npuo.mutation.GetType(); ok { - if err := naturalperson.TypeValidator(v); err != nil { - return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "NaturalPerson.type": %w`, err)} - } - } - if v, ok := npuo.mutation.Password(); ok { - if err := naturalperson.PasswordValidator(v); err != nil { - return &ValidationError{Name: "password", err: fmt.Errorf(`ent: validator failed for field "NaturalPerson.password": %w`, err)} - } - } - return nil -} - -func (npuo *NaturalPersonUpdateOne) sqlSave(ctx context.Context) (_node *NaturalPerson, err error) { - _spec := &sqlgraph.UpdateSpec{ - Node: &sqlgraph.NodeSpec{ - Table: naturalperson.Table, - Columns: naturalperson.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: naturalperson.FieldID, - }, - }, - } - id, ok := npuo.mutation.ID() - if !ok { - return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "NaturalPerson.id" for update`)} - } - _spec.Node.ID.Value = id - if fields := npuo.fields; len(fields) > 0 { - _spec.Node.Columns = make([]string, 0, len(fields)) - _spec.Node.Columns = append(_spec.Node.Columns, naturalperson.FieldID) - for _, f := range fields { - if !naturalperson.ValidColumn(f) { - return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} - } - if f != naturalperson.FieldID { - _spec.Node.Columns = append(_spec.Node.Columns, f) - } - } - } - if ps := npuo.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if value, ok := npuo.mutation.Name(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeString, - Value: value, - Column: naturalperson.FieldName, - }) - } - if value, ok := npuo.mutation.Displayname(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeString, - Value: value, - Column: naturalperson.FieldDisplayname, - }) - } - if npuo.mutation.DisplaynameCleared() { - _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: naturalperson.FieldDisplayname, - }) - } - if value, ok := npuo.mutation.GetType(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeString, - Value: value, - Column: naturalperson.FieldType, - }) - } - if value, ok := npuo.mutation.Password(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeBytes, - Value: value, - Column: naturalperson.FieldPassword, - }) - } - if value, ok := npuo.mutation.UpdatedAt(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeTime, - Value: value, - Column: naturalperson.FieldUpdatedAt, - }) - } - if npuo.mutation.KeysCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: naturalperson.KeysTable, - Columns: []string{naturalperson.KeysColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: privatekey.FieldID, - }, - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := npuo.mutation.RemovedKeysIDs(); len(nodes) > 0 && !npuo.mutation.KeysCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: naturalperson.KeysTable, - Columns: []string{naturalperson.KeysColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: privatekey.FieldID, - }, - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := npuo.mutation.KeysIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: naturalperson.KeysTable, - Columns: []string{naturalperson.KeysColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: privatekey.FieldID, - }, - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if npuo.mutation.CredentialsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: naturalperson.CredentialsTable, - Columns: []string{naturalperson.CredentialsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: credential.FieldID, - }, - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := npuo.mutation.RemovedCredentialsIDs(); len(nodes) > 0 && !npuo.mutation.CredentialsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: naturalperson.CredentialsTable, - Columns: []string{naturalperson.CredentialsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: credential.FieldID, - }, - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := npuo.mutation.CredentialsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: naturalperson.CredentialsTable, - Columns: []string{naturalperson.CredentialsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: credential.FieldID, - }, - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - _node = &NaturalPerson{config: npuo.config} - _spec.Assign = _node.assignValues - _spec.ScanValues = _node.scanValues - if err = sqlgraph.UpdateNode(ctx, npuo.driver, _spec); err != nil { - if _, ok := err.(*sqlgraph.NotFoundError); ok { - err = &NotFoundError{naturalperson.Label} - } else if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return nil, err - } - return _node, nil -} diff --git a/ent/predicate/predicate.go b/ent/predicate/predicate.go deleted file mode 100644 index b868bc04..00000000 --- a/ent/predicate/predicate.go +++ /dev/null @@ -1,25 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package predicate - -import ( - "entgo.io/ent/dialect/sql" -) - -// Credential is the predicate function for credential builders. -type Credential func(*sql.Selector) - -// DID is the predicate function for did builders. -type DID func(*sql.Selector) - -// NaturalPerson is the predicate function for naturalperson builders. -type NaturalPerson func(*sql.Selector) - -// PrivateKey is the predicate function for privatekey builders. -type PrivateKey func(*sql.Selector) - -// PublicKey is the predicate function for publickey builders. -type PublicKey func(*sql.Selector) - -// User is the predicate function for user builders. -type User func(*sql.Selector) diff --git a/ent/privatekey.go b/ent/privatekey.go deleted file mode 100644 index 41ed0883..00000000 --- a/ent/privatekey.go +++ /dev/null @@ -1,201 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "encoding/json" - "fmt" - "strings" - "time" - - "entgo.io/ent/dialect/sql" - "github.com/fiware/vcverifier/ent/privatekey" - "github.com/fiware/vcverifier/ent/user" -) - -// PrivateKey is the model entity for the PrivateKey schema. -type PrivateKey struct { - config `json:"-"` - // ID of the ent. - ID string `json:"id,omitempty"` - // Kty holds the value of the "kty" field. - Kty string `json:"kty,omitempty"` - // Alg holds the value of the "alg" field. - Alg string `json:"alg,omitempty"` - // Jwk holds the value of the "jwk" field. - Jwk []uint8 `json:"jwk,omitempty"` - // CreatedAt holds the value of the "created_at" field. - CreatedAt time.Time `json:"created_at,omitempty"` - // UpdatedAt holds the value of the "updated_at" field. - UpdatedAt time.Time `json:"updated_at,omitempty"` - // Edges holds the relations/edges for other nodes in the graph. - // The values are being populated by the PrivateKeyQuery when eager-loading is set. - Edges PrivateKeyEdges `json:"edges"` - natural_person_keys *string - user_keys *string -} - -// PrivateKeyEdges holds the relations/edges for other nodes in the graph. -type PrivateKeyEdges struct { - // User holds the value of the user edge. - User *User `json:"user,omitempty"` - // loadedTypes holds the information for reporting if a - // type was loaded (or requested) in eager-loading or not. - loadedTypes [1]bool -} - -// UserOrErr returns the User value or an error if the edge -// was not loaded in eager-loading, or loaded but was not found. -func (e PrivateKeyEdges) UserOrErr() (*User, error) { - if e.loadedTypes[0] { - if e.User == nil { - // The edge user was loaded in eager-loading, - // but was not found. - return nil, &NotFoundError{label: user.Label} - } - return e.User, nil - } - return nil, &NotLoadedError{edge: "user"} -} - -// scanValues returns the types for scanning values from sql.Rows. -func (*PrivateKey) scanValues(columns []string) ([]interface{}, error) { - values := make([]interface{}, len(columns)) - for i := range columns { - switch columns[i] { - case privatekey.FieldJwk: - values[i] = new([]byte) - case privatekey.FieldID, privatekey.FieldKty, privatekey.FieldAlg: - values[i] = new(sql.NullString) - case privatekey.FieldCreatedAt, privatekey.FieldUpdatedAt: - values[i] = new(sql.NullTime) - case privatekey.ForeignKeys[0]: // natural_person_keys - values[i] = new(sql.NullString) - case privatekey.ForeignKeys[1]: // user_keys - values[i] = new(sql.NullString) - default: - return nil, fmt.Errorf("unexpected column %q for type PrivateKey", columns[i]) - } - } - return values, nil -} - -// assignValues assigns the values that were returned from sql.Rows (after scanning) -// to the PrivateKey fields. -func (pk *PrivateKey) assignValues(columns []string, values []interface{}) error { - if m, n := len(values), len(columns); m < n { - return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) - } - for i := range columns { - switch columns[i] { - case privatekey.FieldID: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field id", values[i]) - } else if value.Valid { - pk.ID = value.String - } - case privatekey.FieldKty: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field kty", values[i]) - } else if value.Valid { - pk.Kty = value.String - } - case privatekey.FieldAlg: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field alg", values[i]) - } else if value.Valid { - pk.Alg = value.String - } - case privatekey.FieldJwk: - if value, ok := values[i].(*[]byte); !ok { - return fmt.Errorf("unexpected type %T for field jwk", values[i]) - } else if value != nil && len(*value) > 0 { - if err := json.Unmarshal(*value, &pk.Jwk); err != nil { - return fmt.Errorf("unmarshal field jwk: %w", err) - } - } - case privatekey.FieldCreatedAt: - if value, ok := values[i].(*sql.NullTime); !ok { - return fmt.Errorf("unexpected type %T for field created_at", values[i]) - } else if value.Valid { - pk.CreatedAt = value.Time - } - case privatekey.FieldUpdatedAt: - if value, ok := values[i].(*sql.NullTime); !ok { - return fmt.Errorf("unexpected type %T for field updated_at", values[i]) - } else if value.Valid { - pk.UpdatedAt = value.Time - } - case privatekey.ForeignKeys[0]: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field natural_person_keys", values[i]) - } else if value.Valid { - pk.natural_person_keys = new(string) - *pk.natural_person_keys = value.String - } - case privatekey.ForeignKeys[1]: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field user_keys", values[i]) - } else if value.Valid { - pk.user_keys = new(string) - *pk.user_keys = value.String - } - } - } - return nil -} - -// QueryUser queries the "user" edge of the PrivateKey entity. -func (pk *PrivateKey) QueryUser() *UserQuery { - return (&PrivateKeyClient{config: pk.config}).QueryUser(pk) -} - -// Update returns a builder for updating this PrivateKey. -// Note that you need to call PrivateKey.Unwrap() before calling this method if this PrivateKey -// was returned from a transaction, and the transaction was committed or rolled back. -func (pk *PrivateKey) Update() *PrivateKeyUpdateOne { - return (&PrivateKeyClient{config: pk.config}).UpdateOne(pk) -} - -// Unwrap unwraps the PrivateKey entity that was returned from a transaction after it was closed, -// so that all future queries will be executed through the driver which created the transaction. -func (pk *PrivateKey) Unwrap() *PrivateKey { - _tx, ok := pk.config.driver.(*txDriver) - if !ok { - panic("ent: PrivateKey is not a transactional entity") - } - pk.config.driver = _tx.drv - return pk -} - -// String implements the fmt.Stringer. -func (pk *PrivateKey) String() string { - var builder strings.Builder - builder.WriteString("PrivateKey(") - builder.WriteString(fmt.Sprintf("id=%v, ", pk.ID)) - builder.WriteString("kty=") - builder.WriteString(pk.Kty) - builder.WriteString(", ") - builder.WriteString("alg=") - builder.WriteString(pk.Alg) - builder.WriteString(", ") - builder.WriteString("jwk=") - builder.WriteString(fmt.Sprintf("%v", pk.Jwk)) - builder.WriteString(", ") - builder.WriteString("created_at=") - builder.WriteString(pk.CreatedAt.Format(time.ANSIC)) - builder.WriteString(", ") - builder.WriteString("updated_at=") - builder.WriteString(pk.UpdatedAt.Format(time.ANSIC)) - builder.WriteByte(')') - return builder.String() -} - -// PrivateKeys is a parsable slice of PrivateKey. -type PrivateKeys []*PrivateKey - -func (pk PrivateKeys) config(cfg config) { - for _i := range pk { - pk[_i].config = cfg - } -} diff --git a/ent/privatekey/privatekey.go b/ent/privatekey/privatekey.go deleted file mode 100644 index 233cf6fb..00000000 --- a/ent/privatekey/privatekey.go +++ /dev/null @@ -1,74 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package privatekey - -import ( - "time" -) - -const ( - // Label holds the string label denoting the privatekey type in the database. - Label = "private_key" - // FieldID holds the string denoting the id field in the database. - FieldID = "id" - // FieldKty holds the string denoting the kty field in the database. - FieldKty = "kty" - // FieldAlg holds the string denoting the alg field in the database. - FieldAlg = "alg" - // FieldJwk holds the string denoting the jwk field in the database. - FieldJwk = "jwk" - // FieldCreatedAt holds the string denoting the created_at field in the database. - FieldCreatedAt = "created_at" - // FieldUpdatedAt holds the string denoting the updated_at field in the database. - FieldUpdatedAt = "updated_at" - // EdgeUser holds the string denoting the user edge name in mutations. - EdgeUser = "user" - // Table holds the table name of the privatekey in the database. - Table = "private_keys" - // UserTable is the table that holds the user relation/edge. - UserTable = "private_keys" - // UserInverseTable is the table name for the User entity. - // It exists in this package in order to avoid circular dependency with the "user" package. - UserInverseTable = "users" - // UserColumn is the table column denoting the user relation/edge. - UserColumn = "user_keys" -) - -// Columns holds all SQL columns for privatekey fields. -var Columns = []string{ - FieldID, - FieldKty, - FieldAlg, - FieldJwk, - FieldCreatedAt, - FieldUpdatedAt, -} - -// ForeignKeys holds the SQL foreign-keys that are owned by the "private_keys" -// table and are not defined as standalone fields in the schema. -var ForeignKeys = []string{ - "natural_person_keys", - "user_keys", -} - -// ValidColumn reports if the column name is valid (part of the table columns). -func ValidColumn(column string) bool { - for i := range Columns { - if column == Columns[i] { - return true - } - } - for i := range ForeignKeys { - if column == ForeignKeys[i] { - return true - } - } - return false -} - -var ( - // DefaultCreatedAt holds the default value on creation for the "created_at" field. - DefaultCreatedAt func() time.Time - // DefaultUpdatedAt holds the default value on creation for the "updated_at" field. - DefaultUpdatedAt func() time.Time -) diff --git a/ent/privatekey/where.go b/ent/privatekey/where.go deleted file mode 100644 index 293b81ea..00000000 --- a/ent/privatekey/where.go +++ /dev/null @@ -1,558 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package privatekey - -import ( - "time" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "github.com/fiware/vcverifier/ent/predicate" -) - -// ID filters vertices based on their ID field. -func ID(id string) predicate.PrivateKey { - return predicate.PrivateKey(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldID), id)) - }) -} - -// IDEQ applies the EQ predicate on the ID field. -func IDEQ(id string) predicate.PrivateKey { - return predicate.PrivateKey(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldID), id)) - }) -} - -// IDNEQ applies the NEQ predicate on the ID field. -func IDNEQ(id string) predicate.PrivateKey { - return predicate.PrivateKey(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldID), id)) - }) -} - -// IDIn applies the In predicate on the ID field. -func IDIn(ids ...string) predicate.PrivateKey { - return predicate.PrivateKey(func(s *sql.Selector) { - v := make([]interface{}, len(ids)) - for i := range v { - v[i] = ids[i] - } - s.Where(sql.In(s.C(FieldID), v...)) - }) -} - -// IDNotIn applies the NotIn predicate on the ID field. -func IDNotIn(ids ...string) predicate.PrivateKey { - return predicate.PrivateKey(func(s *sql.Selector) { - v := make([]interface{}, len(ids)) - for i := range v { - v[i] = ids[i] - } - s.Where(sql.NotIn(s.C(FieldID), v...)) - }) -} - -// IDGT applies the GT predicate on the ID field. -func IDGT(id string) predicate.PrivateKey { - return predicate.PrivateKey(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldID), id)) - }) -} - -// IDGTE applies the GTE predicate on the ID field. -func IDGTE(id string) predicate.PrivateKey { - return predicate.PrivateKey(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldID), id)) - }) -} - -// IDLT applies the LT predicate on the ID field. -func IDLT(id string) predicate.PrivateKey { - return predicate.PrivateKey(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldID), id)) - }) -} - -// IDLTE applies the LTE predicate on the ID field. -func IDLTE(id string) predicate.PrivateKey { - return predicate.PrivateKey(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldID), id)) - }) -} - -// Kty applies equality check predicate on the "kty" field. It's identical to KtyEQ. -func Kty(v string) predicate.PrivateKey { - return predicate.PrivateKey(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldKty), v)) - }) -} - -// Alg applies equality check predicate on the "alg" field. It's identical to AlgEQ. -func Alg(v string) predicate.PrivateKey { - return predicate.PrivateKey(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldAlg), v)) - }) -} - -// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. -func CreatedAt(v time.Time) predicate.PrivateKey { - return predicate.PrivateKey(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldCreatedAt), v)) - }) -} - -// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ. -func UpdatedAt(v time.Time) predicate.PrivateKey { - return predicate.PrivateKey(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldUpdatedAt), v)) - }) -} - -// KtyEQ applies the EQ predicate on the "kty" field. -func KtyEQ(v string) predicate.PrivateKey { - return predicate.PrivateKey(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldKty), v)) - }) -} - -// KtyNEQ applies the NEQ predicate on the "kty" field. -func KtyNEQ(v string) predicate.PrivateKey { - return predicate.PrivateKey(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldKty), v)) - }) -} - -// KtyIn applies the In predicate on the "kty" field. -func KtyIn(vs ...string) predicate.PrivateKey { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.PrivateKey(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldKty), v...)) - }) -} - -// KtyNotIn applies the NotIn predicate on the "kty" field. -func KtyNotIn(vs ...string) predicate.PrivateKey { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.PrivateKey(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldKty), v...)) - }) -} - -// KtyGT applies the GT predicate on the "kty" field. -func KtyGT(v string) predicate.PrivateKey { - return predicate.PrivateKey(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldKty), v)) - }) -} - -// KtyGTE applies the GTE predicate on the "kty" field. -func KtyGTE(v string) predicate.PrivateKey { - return predicate.PrivateKey(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldKty), v)) - }) -} - -// KtyLT applies the LT predicate on the "kty" field. -func KtyLT(v string) predicate.PrivateKey { - return predicate.PrivateKey(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldKty), v)) - }) -} - -// KtyLTE applies the LTE predicate on the "kty" field. -func KtyLTE(v string) predicate.PrivateKey { - return predicate.PrivateKey(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldKty), v)) - }) -} - -// KtyContains applies the Contains predicate on the "kty" field. -func KtyContains(v string) predicate.PrivateKey { - return predicate.PrivateKey(func(s *sql.Selector) { - s.Where(sql.Contains(s.C(FieldKty), v)) - }) -} - -// KtyHasPrefix applies the HasPrefix predicate on the "kty" field. -func KtyHasPrefix(v string) predicate.PrivateKey { - return predicate.PrivateKey(func(s *sql.Selector) { - s.Where(sql.HasPrefix(s.C(FieldKty), v)) - }) -} - -// KtyHasSuffix applies the HasSuffix predicate on the "kty" field. -func KtyHasSuffix(v string) predicate.PrivateKey { - return predicate.PrivateKey(func(s *sql.Selector) { - s.Where(sql.HasSuffix(s.C(FieldKty), v)) - }) -} - -// KtyEqualFold applies the EqualFold predicate on the "kty" field. -func KtyEqualFold(v string) predicate.PrivateKey { - return predicate.PrivateKey(func(s *sql.Selector) { - s.Where(sql.EqualFold(s.C(FieldKty), v)) - }) -} - -// KtyContainsFold applies the ContainsFold predicate on the "kty" field. -func KtyContainsFold(v string) predicate.PrivateKey { - return predicate.PrivateKey(func(s *sql.Selector) { - s.Where(sql.ContainsFold(s.C(FieldKty), v)) - }) -} - -// AlgEQ applies the EQ predicate on the "alg" field. -func AlgEQ(v string) predicate.PrivateKey { - return predicate.PrivateKey(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldAlg), v)) - }) -} - -// AlgNEQ applies the NEQ predicate on the "alg" field. -func AlgNEQ(v string) predicate.PrivateKey { - return predicate.PrivateKey(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldAlg), v)) - }) -} - -// AlgIn applies the In predicate on the "alg" field. -func AlgIn(vs ...string) predicate.PrivateKey { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.PrivateKey(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldAlg), v...)) - }) -} - -// AlgNotIn applies the NotIn predicate on the "alg" field. -func AlgNotIn(vs ...string) predicate.PrivateKey { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.PrivateKey(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldAlg), v...)) - }) -} - -// AlgGT applies the GT predicate on the "alg" field. -func AlgGT(v string) predicate.PrivateKey { - return predicate.PrivateKey(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldAlg), v)) - }) -} - -// AlgGTE applies the GTE predicate on the "alg" field. -func AlgGTE(v string) predicate.PrivateKey { - return predicate.PrivateKey(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldAlg), v)) - }) -} - -// AlgLT applies the LT predicate on the "alg" field. -func AlgLT(v string) predicate.PrivateKey { - return predicate.PrivateKey(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldAlg), v)) - }) -} - -// AlgLTE applies the LTE predicate on the "alg" field. -func AlgLTE(v string) predicate.PrivateKey { - return predicate.PrivateKey(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldAlg), v)) - }) -} - -// AlgContains applies the Contains predicate on the "alg" field. -func AlgContains(v string) predicate.PrivateKey { - return predicate.PrivateKey(func(s *sql.Selector) { - s.Where(sql.Contains(s.C(FieldAlg), v)) - }) -} - -// AlgHasPrefix applies the HasPrefix predicate on the "alg" field. -func AlgHasPrefix(v string) predicate.PrivateKey { - return predicate.PrivateKey(func(s *sql.Selector) { - s.Where(sql.HasPrefix(s.C(FieldAlg), v)) - }) -} - -// AlgHasSuffix applies the HasSuffix predicate on the "alg" field. -func AlgHasSuffix(v string) predicate.PrivateKey { - return predicate.PrivateKey(func(s *sql.Selector) { - s.Where(sql.HasSuffix(s.C(FieldAlg), v)) - }) -} - -// AlgIsNil applies the IsNil predicate on the "alg" field. -func AlgIsNil() predicate.PrivateKey { - return predicate.PrivateKey(func(s *sql.Selector) { - s.Where(sql.IsNull(s.C(FieldAlg))) - }) -} - -// AlgNotNil applies the NotNil predicate on the "alg" field. -func AlgNotNil() predicate.PrivateKey { - return predicate.PrivateKey(func(s *sql.Selector) { - s.Where(sql.NotNull(s.C(FieldAlg))) - }) -} - -// AlgEqualFold applies the EqualFold predicate on the "alg" field. -func AlgEqualFold(v string) predicate.PrivateKey { - return predicate.PrivateKey(func(s *sql.Selector) { - s.Where(sql.EqualFold(s.C(FieldAlg), v)) - }) -} - -// AlgContainsFold applies the ContainsFold predicate on the "alg" field. -func AlgContainsFold(v string) predicate.PrivateKey { - return predicate.PrivateKey(func(s *sql.Selector) { - s.Where(sql.ContainsFold(s.C(FieldAlg), v)) - }) -} - -// CreatedAtEQ applies the EQ predicate on the "created_at" field. -func CreatedAtEQ(v time.Time) predicate.PrivateKey { - return predicate.PrivateKey(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldCreatedAt), v)) - }) -} - -// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. -func CreatedAtNEQ(v time.Time) predicate.PrivateKey { - return predicate.PrivateKey(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldCreatedAt), v)) - }) -} - -// CreatedAtIn applies the In predicate on the "created_at" field. -func CreatedAtIn(vs ...time.Time) predicate.PrivateKey { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.PrivateKey(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldCreatedAt), v...)) - }) -} - -// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. -func CreatedAtNotIn(vs ...time.Time) predicate.PrivateKey { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.PrivateKey(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldCreatedAt), v...)) - }) -} - -// CreatedAtGT applies the GT predicate on the "created_at" field. -func CreatedAtGT(v time.Time) predicate.PrivateKey { - return predicate.PrivateKey(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldCreatedAt), v)) - }) -} - -// CreatedAtGTE applies the GTE predicate on the "created_at" field. -func CreatedAtGTE(v time.Time) predicate.PrivateKey { - return predicate.PrivateKey(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldCreatedAt), v)) - }) -} - -// CreatedAtLT applies the LT predicate on the "created_at" field. -func CreatedAtLT(v time.Time) predicate.PrivateKey { - return predicate.PrivateKey(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldCreatedAt), v)) - }) -} - -// CreatedAtLTE applies the LTE predicate on the "created_at" field. -func CreatedAtLTE(v time.Time) predicate.PrivateKey { - return predicate.PrivateKey(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldCreatedAt), v)) - }) -} - -// UpdatedAtEQ applies the EQ predicate on the "updated_at" field. -func UpdatedAtEQ(v time.Time) predicate.PrivateKey { - return predicate.PrivateKey(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldUpdatedAt), v)) - }) -} - -// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field. -func UpdatedAtNEQ(v time.Time) predicate.PrivateKey { - return predicate.PrivateKey(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldUpdatedAt), v)) - }) -} - -// UpdatedAtIn applies the In predicate on the "updated_at" field. -func UpdatedAtIn(vs ...time.Time) predicate.PrivateKey { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.PrivateKey(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldUpdatedAt), v...)) - }) -} - -// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field. -func UpdatedAtNotIn(vs ...time.Time) predicate.PrivateKey { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.PrivateKey(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldUpdatedAt), v...)) - }) -} - -// UpdatedAtGT applies the GT predicate on the "updated_at" field. -func UpdatedAtGT(v time.Time) predicate.PrivateKey { - return predicate.PrivateKey(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldUpdatedAt), v)) - }) -} - -// UpdatedAtGTE applies the GTE predicate on the "updated_at" field. -func UpdatedAtGTE(v time.Time) predicate.PrivateKey { - return predicate.PrivateKey(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldUpdatedAt), v)) - }) -} - -// UpdatedAtLT applies the LT predicate on the "updated_at" field. -func UpdatedAtLT(v time.Time) predicate.PrivateKey { - return predicate.PrivateKey(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldUpdatedAt), v)) - }) -} - -// UpdatedAtLTE applies the LTE predicate on the "updated_at" field. -func UpdatedAtLTE(v time.Time) predicate.PrivateKey { - return predicate.PrivateKey(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldUpdatedAt), v)) - }) -} - -// HasUser applies the HasEdge predicate on the "user" edge. -func HasUser() predicate.PrivateKey { - return predicate.PrivateKey(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(UserTable, FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, UserTable, UserColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasUserWith applies the HasEdge predicate on the "user" edge with a given conditions (other predicates). -func HasUserWith(preds ...predicate.User) predicate.PrivateKey { - return predicate.PrivateKey(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(UserInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, UserTable, UserColumn), - ) - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// And groups predicates with the AND operator between them. -func And(predicates ...predicate.PrivateKey) predicate.PrivateKey { - return predicate.PrivateKey(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) -} - -// Or groups predicates with the OR operator between them. -func Or(predicates ...predicate.PrivateKey) predicate.PrivateKey { - return predicate.PrivateKey(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) -} - -// Not applies the not operator on the given predicate. -func Not(p predicate.PrivateKey) predicate.PrivateKey { - return predicate.PrivateKey(func(s *sql.Selector) { - p(s.Not()) - }) -} diff --git a/ent/privatekey_create.go b/ent/privatekey_create.go deleted file mode 100644 index 470cc022..00000000 --- a/ent/privatekey_create.go +++ /dev/null @@ -1,381 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - "time" - - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/fiware/vcverifier/ent/privatekey" - "github.com/fiware/vcverifier/ent/user" -) - -// PrivateKeyCreate is the builder for creating a PrivateKey entity. -type PrivateKeyCreate struct { - config - mutation *PrivateKeyMutation - hooks []Hook -} - -// SetKty sets the "kty" field. -func (pkc *PrivateKeyCreate) SetKty(s string) *PrivateKeyCreate { - pkc.mutation.SetKty(s) - return pkc -} - -// SetAlg sets the "alg" field. -func (pkc *PrivateKeyCreate) SetAlg(s string) *PrivateKeyCreate { - pkc.mutation.SetAlg(s) - return pkc -} - -// SetNillableAlg sets the "alg" field if the given value is not nil. -func (pkc *PrivateKeyCreate) SetNillableAlg(s *string) *PrivateKeyCreate { - if s != nil { - pkc.SetAlg(*s) - } - return pkc -} - -// SetJwk sets the "jwk" field. -func (pkc *PrivateKeyCreate) SetJwk(u []uint8) *PrivateKeyCreate { - pkc.mutation.SetJwk(u) - return pkc -} - -// SetCreatedAt sets the "created_at" field. -func (pkc *PrivateKeyCreate) SetCreatedAt(t time.Time) *PrivateKeyCreate { - pkc.mutation.SetCreatedAt(t) - return pkc -} - -// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. -func (pkc *PrivateKeyCreate) SetNillableCreatedAt(t *time.Time) *PrivateKeyCreate { - if t != nil { - pkc.SetCreatedAt(*t) - } - return pkc -} - -// SetUpdatedAt sets the "updated_at" field. -func (pkc *PrivateKeyCreate) SetUpdatedAt(t time.Time) *PrivateKeyCreate { - pkc.mutation.SetUpdatedAt(t) - return pkc -} - -// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. -func (pkc *PrivateKeyCreate) SetNillableUpdatedAt(t *time.Time) *PrivateKeyCreate { - if t != nil { - pkc.SetUpdatedAt(*t) - } - return pkc -} - -// SetID sets the "id" field. -func (pkc *PrivateKeyCreate) SetID(s string) *PrivateKeyCreate { - pkc.mutation.SetID(s) - return pkc -} - -// SetUserID sets the "user" edge to the User entity by ID. -func (pkc *PrivateKeyCreate) SetUserID(id string) *PrivateKeyCreate { - pkc.mutation.SetUserID(id) - return pkc -} - -// SetNillableUserID sets the "user" edge to the User entity by ID if the given value is not nil. -func (pkc *PrivateKeyCreate) SetNillableUserID(id *string) *PrivateKeyCreate { - if id != nil { - pkc = pkc.SetUserID(*id) - } - return pkc -} - -// SetUser sets the "user" edge to the User entity. -func (pkc *PrivateKeyCreate) SetUser(u *User) *PrivateKeyCreate { - return pkc.SetUserID(u.ID) -} - -// Mutation returns the PrivateKeyMutation object of the builder. -func (pkc *PrivateKeyCreate) Mutation() *PrivateKeyMutation { - return pkc.mutation -} - -// Save creates the PrivateKey in the database. -func (pkc *PrivateKeyCreate) Save(ctx context.Context) (*PrivateKey, error) { - var ( - err error - node *PrivateKey - ) - pkc.defaults() - if len(pkc.hooks) == 0 { - if err = pkc.check(); err != nil { - return nil, err - } - node, err = pkc.sqlSave(ctx) - } else { - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*PrivateKeyMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - if err = pkc.check(); err != nil { - return nil, err - } - pkc.mutation = mutation - if node, err = pkc.sqlSave(ctx); err != nil { - return nil, err - } - mutation.id = &node.ID - mutation.done = true - return node, err - }) - for i := len(pkc.hooks) - 1; i >= 0; i-- { - if pkc.hooks[i] == nil { - return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") - } - mut = pkc.hooks[i](mut) - } - v, err := mut.Mutate(ctx, pkc.mutation) - if err != nil { - return nil, err - } - nv, ok := v.(*PrivateKey) - if !ok { - return nil, fmt.Errorf("unexpected node type %T returned from PrivateKeyMutation", v) - } - node = nv - } - return node, err -} - -// SaveX calls Save and panics if Save returns an error. -func (pkc *PrivateKeyCreate) SaveX(ctx context.Context) *PrivateKey { - v, err := pkc.Save(ctx) - if err != nil { - panic(err) - } - return v -} - -// Exec executes the query. -func (pkc *PrivateKeyCreate) Exec(ctx context.Context) error { - _, err := pkc.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (pkc *PrivateKeyCreate) ExecX(ctx context.Context) { - if err := pkc.Exec(ctx); err != nil { - panic(err) - } -} - -// defaults sets the default values of the builder before save. -func (pkc *PrivateKeyCreate) defaults() { - if _, ok := pkc.mutation.CreatedAt(); !ok { - v := privatekey.DefaultCreatedAt() - pkc.mutation.SetCreatedAt(v) - } - if _, ok := pkc.mutation.UpdatedAt(); !ok { - v := privatekey.DefaultUpdatedAt() - pkc.mutation.SetUpdatedAt(v) - } -} - -// check runs all checks and user-defined validators on the builder. -func (pkc *PrivateKeyCreate) check() error { - if _, ok := pkc.mutation.Kty(); !ok { - return &ValidationError{Name: "kty", err: errors.New(`ent: missing required field "PrivateKey.kty"`)} - } - if _, ok := pkc.mutation.Jwk(); !ok { - return &ValidationError{Name: "jwk", err: errors.New(`ent: missing required field "PrivateKey.jwk"`)} - } - if _, ok := pkc.mutation.CreatedAt(); !ok { - return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "PrivateKey.created_at"`)} - } - if _, ok := pkc.mutation.UpdatedAt(); !ok { - return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "PrivateKey.updated_at"`)} - } - return nil -} - -func (pkc *PrivateKeyCreate) sqlSave(ctx context.Context) (*PrivateKey, error) { - _node, _spec := pkc.createSpec() - if err := sqlgraph.CreateNode(ctx, pkc.driver, _spec); err != nil { - if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return nil, err - } - if _spec.ID.Value != nil { - if id, ok := _spec.ID.Value.(string); ok { - _node.ID = id - } else { - return nil, fmt.Errorf("unexpected PrivateKey.ID type: %T", _spec.ID.Value) - } - } - return _node, nil -} - -func (pkc *PrivateKeyCreate) createSpec() (*PrivateKey, *sqlgraph.CreateSpec) { - var ( - _node = &PrivateKey{config: pkc.config} - _spec = &sqlgraph.CreateSpec{ - Table: privatekey.Table, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: privatekey.FieldID, - }, - } - ) - if id, ok := pkc.mutation.ID(); ok { - _node.ID = id - _spec.ID.Value = id - } - if value, ok := pkc.mutation.Kty(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeString, - Value: value, - Column: privatekey.FieldKty, - }) - _node.Kty = value - } - if value, ok := pkc.mutation.Alg(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeString, - Value: value, - Column: privatekey.FieldAlg, - }) - _node.Alg = value - } - if value, ok := pkc.mutation.Jwk(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeJSON, - Value: value, - Column: privatekey.FieldJwk, - }) - _node.Jwk = value - } - if value, ok := pkc.mutation.CreatedAt(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeTime, - Value: value, - Column: privatekey.FieldCreatedAt, - }) - _node.CreatedAt = value - } - if value, ok := pkc.mutation.UpdatedAt(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeTime, - Value: value, - Column: privatekey.FieldUpdatedAt, - }) - _node.UpdatedAt = value - } - if nodes := pkc.mutation.UserIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: true, - Table: privatekey.UserTable, - Columns: []string{privatekey.UserColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: user.FieldID, - }, - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _node.user_keys = &nodes[0] - _spec.Edges = append(_spec.Edges, edge) - } - return _node, _spec -} - -// PrivateKeyCreateBulk is the builder for creating many PrivateKey entities in bulk. -type PrivateKeyCreateBulk struct { - config - builders []*PrivateKeyCreate -} - -// Save creates the PrivateKey entities in the database. -func (pkcb *PrivateKeyCreateBulk) Save(ctx context.Context) ([]*PrivateKey, error) { - specs := make([]*sqlgraph.CreateSpec, len(pkcb.builders)) - nodes := make([]*PrivateKey, len(pkcb.builders)) - mutators := make([]Mutator, len(pkcb.builders)) - for i := range pkcb.builders { - func(i int, root context.Context) { - builder := pkcb.builders[i] - builder.defaults() - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*PrivateKeyMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - if err := builder.check(); err != nil { - return nil, err - } - builder.mutation = mutation - nodes[i], specs[i] = builder.createSpec() - var err error - if i < len(mutators)-1 { - _, err = mutators[i+1].Mutate(root, pkcb.builders[i+1].mutation) - } else { - spec := &sqlgraph.BatchCreateSpec{Nodes: specs} - // Invoke the actual operation on the latest mutation in the chain. - if err = sqlgraph.BatchCreate(ctx, pkcb.driver, spec); err != nil { - if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - } - } - if err != nil { - return nil, err - } - mutation.id = &nodes[i].ID - mutation.done = true - return nodes[i], nil - }) - for i := len(builder.hooks) - 1; i >= 0; i-- { - mut = builder.hooks[i](mut) - } - mutators[i] = mut - }(i, ctx) - } - if len(mutators) > 0 { - if _, err := mutators[0].Mutate(ctx, pkcb.builders[0].mutation); err != nil { - return nil, err - } - } - return nodes, nil -} - -// SaveX is like Save, but panics if an error occurs. -func (pkcb *PrivateKeyCreateBulk) SaveX(ctx context.Context) []*PrivateKey { - v, err := pkcb.Save(ctx) - if err != nil { - panic(err) - } - return v -} - -// Exec executes the query. -func (pkcb *PrivateKeyCreateBulk) Exec(ctx context.Context) error { - _, err := pkcb.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (pkcb *PrivateKeyCreateBulk) ExecX(ctx context.Context) { - if err := pkcb.Exec(ctx); err != nil { - panic(err) - } -} diff --git a/ent/privatekey_delete.go b/ent/privatekey_delete.go deleted file mode 100644 index 9ff1a19c..00000000 --- a/ent/privatekey_delete.go +++ /dev/null @@ -1,115 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "fmt" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/fiware/vcverifier/ent/predicate" - "github.com/fiware/vcverifier/ent/privatekey" -) - -// PrivateKeyDelete is the builder for deleting a PrivateKey entity. -type PrivateKeyDelete struct { - config - hooks []Hook - mutation *PrivateKeyMutation -} - -// Where appends a list predicates to the PrivateKeyDelete builder. -func (pkd *PrivateKeyDelete) Where(ps ...predicate.PrivateKey) *PrivateKeyDelete { - pkd.mutation.Where(ps...) - return pkd -} - -// Exec executes the deletion query and returns how many vertices were deleted. -func (pkd *PrivateKeyDelete) Exec(ctx context.Context) (int, error) { - var ( - err error - affected int - ) - if len(pkd.hooks) == 0 { - affected, err = pkd.sqlExec(ctx) - } else { - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*PrivateKeyMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - pkd.mutation = mutation - affected, err = pkd.sqlExec(ctx) - mutation.done = true - return affected, err - }) - for i := len(pkd.hooks) - 1; i >= 0; i-- { - if pkd.hooks[i] == nil { - return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") - } - mut = pkd.hooks[i](mut) - } - if _, err := mut.Mutate(ctx, pkd.mutation); err != nil { - return 0, err - } - } - return affected, err -} - -// ExecX is like Exec, but panics if an error occurs. -func (pkd *PrivateKeyDelete) ExecX(ctx context.Context) int { - n, err := pkd.Exec(ctx) - if err != nil { - panic(err) - } - return n -} - -func (pkd *PrivateKeyDelete) sqlExec(ctx context.Context) (int, error) { - _spec := &sqlgraph.DeleteSpec{ - Node: &sqlgraph.NodeSpec{ - Table: privatekey.Table, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: privatekey.FieldID, - }, - }, - } - if ps := pkd.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - affected, err := sqlgraph.DeleteNodes(ctx, pkd.driver, _spec) - if err != nil && sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return affected, err -} - -// PrivateKeyDeleteOne is the builder for deleting a single PrivateKey entity. -type PrivateKeyDeleteOne struct { - pkd *PrivateKeyDelete -} - -// Exec executes the deletion query. -func (pkdo *PrivateKeyDeleteOne) Exec(ctx context.Context) error { - n, err := pkdo.pkd.Exec(ctx) - switch { - case err != nil: - return err - case n == 0: - return &NotFoundError{privatekey.Label} - default: - return nil - } -} - -// ExecX is like Exec, but panics if an error occurs. -func (pkdo *PrivateKeyDeleteOne) ExecX(ctx context.Context) { - pkdo.pkd.ExecX(ctx) -} diff --git a/ent/privatekey_query.go b/ent/privatekey_query.go deleted file mode 100644 index c64c2de6..00000000 --- a/ent/privatekey_query.go +++ /dev/null @@ -1,605 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "fmt" - "math" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/fiware/vcverifier/ent/predicate" - "github.com/fiware/vcverifier/ent/privatekey" - "github.com/fiware/vcverifier/ent/user" -) - -// PrivateKeyQuery is the builder for querying PrivateKey entities. -type PrivateKeyQuery struct { - config - limit *int - offset *int - unique *bool - order []OrderFunc - fields []string - predicates []predicate.PrivateKey - // eager-loading edges. - withUser *UserQuery - withFKs bool - // intermediate query (i.e. traversal path). - sql *sql.Selector - path func(context.Context) (*sql.Selector, error) -} - -// Where adds a new predicate for the PrivateKeyQuery builder. -func (pkq *PrivateKeyQuery) Where(ps ...predicate.PrivateKey) *PrivateKeyQuery { - pkq.predicates = append(pkq.predicates, ps...) - return pkq -} - -// Limit adds a limit step to the query. -func (pkq *PrivateKeyQuery) Limit(limit int) *PrivateKeyQuery { - pkq.limit = &limit - return pkq -} - -// Offset adds an offset step to the query. -func (pkq *PrivateKeyQuery) Offset(offset int) *PrivateKeyQuery { - pkq.offset = &offset - return pkq -} - -// Unique configures the query builder to filter duplicate records on query. -// By default, unique is set to true, and can be disabled using this method. -func (pkq *PrivateKeyQuery) Unique(unique bool) *PrivateKeyQuery { - pkq.unique = &unique - return pkq -} - -// Order adds an order step to the query. -func (pkq *PrivateKeyQuery) Order(o ...OrderFunc) *PrivateKeyQuery { - pkq.order = append(pkq.order, o...) - return pkq -} - -// QueryUser chains the current query on the "user" edge. -func (pkq *PrivateKeyQuery) QueryUser() *UserQuery { - query := &UserQuery{config: pkq.config} - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := pkq.prepareQuery(ctx); err != nil { - return nil, err - } - selector := pkq.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(privatekey.Table, privatekey.FieldID, selector), - sqlgraph.To(user.Table, user.FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, privatekey.UserTable, privatekey.UserColumn), - ) - fromU = sqlgraph.SetNeighbors(pkq.driver.Dialect(), step) - return fromU, nil - } - return query -} - -// First returns the first PrivateKey entity from the query. -// Returns a *NotFoundError when no PrivateKey was found. -func (pkq *PrivateKeyQuery) First(ctx context.Context) (*PrivateKey, error) { - nodes, err := pkq.Limit(1).All(ctx) - if err != nil { - return nil, err - } - if len(nodes) == 0 { - return nil, &NotFoundError{privatekey.Label} - } - return nodes[0], nil -} - -// FirstX is like First, but panics if an error occurs. -func (pkq *PrivateKeyQuery) FirstX(ctx context.Context) *PrivateKey { - node, err := pkq.First(ctx) - if err != nil && !IsNotFound(err) { - panic(err) - } - return node -} - -// FirstID returns the first PrivateKey ID from the query. -// Returns a *NotFoundError when no PrivateKey ID was found. -func (pkq *PrivateKeyQuery) FirstID(ctx context.Context) (id string, err error) { - var ids []string - if ids, err = pkq.Limit(1).IDs(ctx); err != nil { - return - } - if len(ids) == 0 { - err = &NotFoundError{privatekey.Label} - return - } - return ids[0], nil -} - -// FirstIDX is like FirstID, but panics if an error occurs. -func (pkq *PrivateKeyQuery) FirstIDX(ctx context.Context) string { - id, err := pkq.FirstID(ctx) - if err != nil && !IsNotFound(err) { - panic(err) - } - return id -} - -// Only returns a single PrivateKey entity found by the query, ensuring it only returns one. -// Returns a *NotSingularError when more than one PrivateKey entity is found. -// Returns a *NotFoundError when no PrivateKey entities are found. -func (pkq *PrivateKeyQuery) Only(ctx context.Context) (*PrivateKey, error) { - nodes, err := pkq.Limit(2).All(ctx) - if err != nil { - return nil, err - } - switch len(nodes) { - case 1: - return nodes[0], nil - case 0: - return nil, &NotFoundError{privatekey.Label} - default: - return nil, &NotSingularError{privatekey.Label} - } -} - -// OnlyX is like Only, but panics if an error occurs. -func (pkq *PrivateKeyQuery) OnlyX(ctx context.Context) *PrivateKey { - node, err := pkq.Only(ctx) - if err != nil { - panic(err) - } - return node -} - -// OnlyID is like Only, but returns the only PrivateKey ID in the query. -// Returns a *NotSingularError when more than one PrivateKey ID is found. -// Returns a *NotFoundError when no entities are found. -func (pkq *PrivateKeyQuery) OnlyID(ctx context.Context) (id string, err error) { - var ids []string - if ids, err = pkq.Limit(2).IDs(ctx); err != nil { - return - } - switch len(ids) { - case 1: - id = ids[0] - case 0: - err = &NotFoundError{privatekey.Label} - default: - err = &NotSingularError{privatekey.Label} - } - return -} - -// OnlyIDX is like OnlyID, but panics if an error occurs. -func (pkq *PrivateKeyQuery) OnlyIDX(ctx context.Context) string { - id, err := pkq.OnlyID(ctx) - if err != nil { - panic(err) - } - return id -} - -// All executes the query and returns a list of PrivateKeys. -func (pkq *PrivateKeyQuery) All(ctx context.Context) ([]*PrivateKey, error) { - if err := pkq.prepareQuery(ctx); err != nil { - return nil, err - } - return pkq.sqlAll(ctx) -} - -// AllX is like All, but panics if an error occurs. -func (pkq *PrivateKeyQuery) AllX(ctx context.Context) []*PrivateKey { - nodes, err := pkq.All(ctx) - if err != nil { - panic(err) - } - return nodes -} - -// IDs executes the query and returns a list of PrivateKey IDs. -func (pkq *PrivateKeyQuery) IDs(ctx context.Context) ([]string, error) { - var ids []string - if err := pkq.Select(privatekey.FieldID).Scan(ctx, &ids); err != nil { - return nil, err - } - return ids, nil -} - -// IDsX is like IDs, but panics if an error occurs. -func (pkq *PrivateKeyQuery) IDsX(ctx context.Context) []string { - ids, err := pkq.IDs(ctx) - if err != nil { - panic(err) - } - return ids -} - -// Count returns the count of the given query. -func (pkq *PrivateKeyQuery) Count(ctx context.Context) (int, error) { - if err := pkq.prepareQuery(ctx); err != nil { - return 0, err - } - return pkq.sqlCount(ctx) -} - -// CountX is like Count, but panics if an error occurs. -func (pkq *PrivateKeyQuery) CountX(ctx context.Context) int { - count, err := pkq.Count(ctx) - if err != nil { - panic(err) - } - return count -} - -// Exist returns true if the query has elements in the graph. -func (pkq *PrivateKeyQuery) Exist(ctx context.Context) (bool, error) { - if err := pkq.prepareQuery(ctx); err != nil { - return false, err - } - return pkq.sqlExist(ctx) -} - -// ExistX is like Exist, but panics if an error occurs. -func (pkq *PrivateKeyQuery) ExistX(ctx context.Context) bool { - exist, err := pkq.Exist(ctx) - if err != nil { - panic(err) - } - return exist -} - -// Clone returns a duplicate of the PrivateKeyQuery builder, including all associated steps. It can be -// used to prepare common query builders and use them differently after the clone is made. -func (pkq *PrivateKeyQuery) Clone() *PrivateKeyQuery { - if pkq == nil { - return nil - } - return &PrivateKeyQuery{ - config: pkq.config, - limit: pkq.limit, - offset: pkq.offset, - order: append([]OrderFunc{}, pkq.order...), - predicates: append([]predicate.PrivateKey{}, pkq.predicates...), - withUser: pkq.withUser.Clone(), - // clone intermediate query. - sql: pkq.sql.Clone(), - path: pkq.path, - unique: pkq.unique, - } -} - -// WithUser tells the query-builder to eager-load the nodes that are connected to -// the "user" edge. The optional arguments are used to configure the query builder of the edge. -func (pkq *PrivateKeyQuery) WithUser(opts ...func(*UserQuery)) *PrivateKeyQuery { - query := &UserQuery{config: pkq.config} - for _, opt := range opts { - opt(query) - } - pkq.withUser = query - return pkq -} - -// GroupBy is used to group vertices by one or more fields/columns. -// It is often used with aggregate functions, like: count, max, mean, min, sum. -// -// Example: -// -// var v []struct { -// Kty string `json:"kty,omitempty"` -// Count int `json:"count,omitempty"` -// } -// -// client.PrivateKey.Query(). -// GroupBy(privatekey.FieldKty). -// Aggregate(ent.Count()). -// Scan(ctx, &v) -func (pkq *PrivateKeyQuery) GroupBy(field string, fields ...string) *PrivateKeyGroupBy { - grbuild := &PrivateKeyGroupBy{config: pkq.config} - grbuild.fields = append([]string{field}, fields...) - grbuild.path = func(ctx context.Context) (prev *sql.Selector, err error) { - if err := pkq.prepareQuery(ctx); err != nil { - return nil, err - } - return pkq.sqlQuery(ctx), nil - } - grbuild.label = privatekey.Label - grbuild.flds, grbuild.scan = &grbuild.fields, grbuild.Scan - return grbuild -} - -// Select allows the selection one or more fields/columns for the given query, -// instead of selecting all fields in the entity. -// -// Example: -// -// var v []struct { -// Kty string `json:"kty,omitempty"` -// } -// -// client.PrivateKey.Query(). -// Select(privatekey.FieldKty). -// Scan(ctx, &v) -func (pkq *PrivateKeyQuery) Select(fields ...string) *PrivateKeySelect { - pkq.fields = append(pkq.fields, fields...) - selbuild := &PrivateKeySelect{PrivateKeyQuery: pkq} - selbuild.label = privatekey.Label - selbuild.flds, selbuild.scan = &pkq.fields, selbuild.Scan - return selbuild -} - -func (pkq *PrivateKeyQuery) prepareQuery(ctx context.Context) error { - for _, f := range pkq.fields { - if !privatekey.ValidColumn(f) { - return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} - } - } - if pkq.path != nil { - prev, err := pkq.path(ctx) - if err != nil { - return err - } - pkq.sql = prev - } - return nil -} - -func (pkq *PrivateKeyQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*PrivateKey, error) { - var ( - nodes = []*PrivateKey{} - withFKs = pkq.withFKs - _spec = pkq.querySpec() - loadedTypes = [1]bool{ - pkq.withUser != nil, - } - ) - if pkq.withUser != nil { - withFKs = true - } - if withFKs { - _spec.Node.Columns = append(_spec.Node.Columns, privatekey.ForeignKeys...) - } - _spec.ScanValues = func(columns []string) ([]interface{}, error) { - return (*PrivateKey).scanValues(nil, columns) - } - _spec.Assign = func(columns []string, values []interface{}) error { - node := &PrivateKey{config: pkq.config} - nodes = append(nodes, node) - node.Edges.loadedTypes = loadedTypes - return node.assignValues(columns, values) - } - for i := range hooks { - hooks[i](ctx, _spec) - } - if err := sqlgraph.QueryNodes(ctx, pkq.driver, _spec); err != nil { - return nil, err - } - if len(nodes) == 0 { - return nodes, nil - } - - if query := pkq.withUser; query != nil { - ids := make([]string, 0, len(nodes)) - nodeids := make(map[string][]*PrivateKey) - for i := range nodes { - if nodes[i].user_keys == nil { - continue - } - fk := *nodes[i].user_keys - if _, ok := nodeids[fk]; !ok { - ids = append(ids, fk) - } - nodeids[fk] = append(nodeids[fk], nodes[i]) - } - query.Where(user.IDIn(ids...)) - neighbors, err := query.All(ctx) - if err != nil { - return nil, err - } - for _, n := range neighbors { - nodes, ok := nodeids[n.ID] - if !ok { - return nil, fmt.Errorf(`unexpected foreign-key "user_keys" returned %v`, n.ID) - } - for i := range nodes { - nodes[i].Edges.User = n - } - } - } - - return nodes, nil -} - -func (pkq *PrivateKeyQuery) sqlCount(ctx context.Context) (int, error) { - _spec := pkq.querySpec() - _spec.Node.Columns = pkq.fields - if len(pkq.fields) > 0 { - _spec.Unique = pkq.unique != nil && *pkq.unique - } - return sqlgraph.CountNodes(ctx, pkq.driver, _spec) -} - -func (pkq *PrivateKeyQuery) sqlExist(ctx context.Context) (bool, error) { - n, err := pkq.sqlCount(ctx) - if err != nil { - return false, fmt.Errorf("ent: check existence: %w", err) - } - return n > 0, nil -} - -func (pkq *PrivateKeyQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: privatekey.Table, - Columns: privatekey.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: privatekey.FieldID, - }, - }, - From: pkq.sql, - Unique: true, - } - if unique := pkq.unique; unique != nil { - _spec.Unique = *unique - } - if fields := pkq.fields; len(fields) > 0 { - _spec.Node.Columns = make([]string, 0, len(fields)) - _spec.Node.Columns = append(_spec.Node.Columns, privatekey.FieldID) - for i := range fields { - if fields[i] != privatekey.FieldID { - _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) - } - } - } - if ps := pkq.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if limit := pkq.limit; limit != nil { - _spec.Limit = *limit - } - if offset := pkq.offset; offset != nil { - _spec.Offset = *offset - } - if ps := pkq.order; len(ps) > 0 { - _spec.Order = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - return _spec -} - -func (pkq *PrivateKeyQuery) sqlQuery(ctx context.Context) *sql.Selector { - builder := sql.Dialect(pkq.driver.Dialect()) - t1 := builder.Table(privatekey.Table) - columns := pkq.fields - if len(columns) == 0 { - columns = privatekey.Columns - } - selector := builder.Select(t1.Columns(columns...)...).From(t1) - if pkq.sql != nil { - selector = pkq.sql - selector.Select(selector.Columns(columns...)...) - } - if pkq.unique != nil && *pkq.unique { - selector.Distinct() - } - for _, p := range pkq.predicates { - p(selector) - } - for _, p := range pkq.order { - p(selector) - } - if offset := pkq.offset; offset != nil { - // limit is mandatory for offset clause. We start - // with default value, and override it below if needed. - selector.Offset(*offset).Limit(math.MaxInt32) - } - if limit := pkq.limit; limit != nil { - selector.Limit(*limit) - } - return selector -} - -// PrivateKeyGroupBy is the group-by builder for PrivateKey entities. -type PrivateKeyGroupBy struct { - config - selector - fields []string - fns []AggregateFunc - // intermediate query (i.e. traversal path). - sql *sql.Selector - path func(context.Context) (*sql.Selector, error) -} - -// Aggregate adds the given aggregation functions to the group-by query. -func (pkgb *PrivateKeyGroupBy) Aggregate(fns ...AggregateFunc) *PrivateKeyGroupBy { - pkgb.fns = append(pkgb.fns, fns...) - return pkgb -} - -// Scan applies the group-by query and scans the result into the given value. -func (pkgb *PrivateKeyGroupBy) Scan(ctx context.Context, v interface{}) error { - query, err := pkgb.path(ctx) - if err != nil { - return err - } - pkgb.sql = query - return pkgb.sqlScan(ctx, v) -} - -func (pkgb *PrivateKeyGroupBy) sqlScan(ctx context.Context, v interface{}) error { - for _, f := range pkgb.fields { - if !privatekey.ValidColumn(f) { - return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)} - } - } - selector := pkgb.sqlQuery() - if err := selector.Err(); err != nil { - return err - } - rows := &sql.Rows{} - query, args := selector.Query() - if err := pkgb.driver.Query(ctx, query, args, rows); err != nil { - return err - } - defer rows.Close() - return sql.ScanSlice(rows, v) -} - -func (pkgb *PrivateKeyGroupBy) sqlQuery() *sql.Selector { - selector := pkgb.sql.Select() - aggregation := make([]string, 0, len(pkgb.fns)) - for _, fn := range pkgb.fns { - aggregation = append(aggregation, fn(selector)) - } - // If no columns were selected in a custom aggregation function, the default - // selection is the fields used for "group-by", and the aggregation functions. - if len(selector.SelectedColumns()) == 0 { - columns := make([]string, 0, len(pkgb.fields)+len(pkgb.fns)) - for _, f := range pkgb.fields { - columns = append(columns, selector.C(f)) - } - columns = append(columns, aggregation...) - selector.Select(columns...) - } - return selector.GroupBy(selector.Columns(pkgb.fields...)...) -} - -// PrivateKeySelect is the builder for selecting fields of PrivateKey entities. -type PrivateKeySelect struct { - *PrivateKeyQuery - selector - // intermediate query (i.e. traversal path). - sql *sql.Selector -} - -// Scan applies the selector query and scans the result into the given value. -func (pks *PrivateKeySelect) Scan(ctx context.Context, v interface{}) error { - if err := pks.prepareQuery(ctx); err != nil { - return err - } - pks.sql = pks.PrivateKeyQuery.sqlQuery(ctx) - return pks.sqlScan(ctx, v) -} - -func (pks *PrivateKeySelect) sqlScan(ctx context.Context, v interface{}) error { - rows := &sql.Rows{} - query, args := pks.sql.Query() - if err := pks.driver.Query(ctx, query, args, rows); err != nil { - return err - } - defer rows.Close() - return sql.ScanSlice(rows, v) -} diff --git a/ent/privatekey_update.go b/ent/privatekey_update.go deleted file mode 100644 index 5539ea7b..00000000 --- a/ent/privatekey_update.go +++ /dev/null @@ -1,527 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - "time" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/fiware/vcverifier/ent/predicate" - "github.com/fiware/vcverifier/ent/privatekey" - "github.com/fiware/vcverifier/ent/user" -) - -// PrivateKeyUpdate is the builder for updating PrivateKey entities. -type PrivateKeyUpdate struct { - config - hooks []Hook - mutation *PrivateKeyMutation -} - -// Where appends a list predicates to the PrivateKeyUpdate builder. -func (pku *PrivateKeyUpdate) Where(ps ...predicate.PrivateKey) *PrivateKeyUpdate { - pku.mutation.Where(ps...) - return pku -} - -// SetKty sets the "kty" field. -func (pku *PrivateKeyUpdate) SetKty(s string) *PrivateKeyUpdate { - pku.mutation.SetKty(s) - return pku -} - -// SetAlg sets the "alg" field. -func (pku *PrivateKeyUpdate) SetAlg(s string) *PrivateKeyUpdate { - pku.mutation.SetAlg(s) - return pku -} - -// SetNillableAlg sets the "alg" field if the given value is not nil. -func (pku *PrivateKeyUpdate) SetNillableAlg(s *string) *PrivateKeyUpdate { - if s != nil { - pku.SetAlg(*s) - } - return pku -} - -// ClearAlg clears the value of the "alg" field. -func (pku *PrivateKeyUpdate) ClearAlg() *PrivateKeyUpdate { - pku.mutation.ClearAlg() - return pku -} - -// SetJwk sets the "jwk" field. -func (pku *PrivateKeyUpdate) SetJwk(u []uint8) *PrivateKeyUpdate { - pku.mutation.SetJwk(u) - return pku -} - -// SetUpdatedAt sets the "updated_at" field. -func (pku *PrivateKeyUpdate) SetUpdatedAt(t time.Time) *PrivateKeyUpdate { - pku.mutation.SetUpdatedAt(t) - return pku -} - -// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. -func (pku *PrivateKeyUpdate) SetNillableUpdatedAt(t *time.Time) *PrivateKeyUpdate { - if t != nil { - pku.SetUpdatedAt(*t) - } - return pku -} - -// SetUserID sets the "user" edge to the User entity by ID. -func (pku *PrivateKeyUpdate) SetUserID(id string) *PrivateKeyUpdate { - pku.mutation.SetUserID(id) - return pku -} - -// SetNillableUserID sets the "user" edge to the User entity by ID if the given value is not nil. -func (pku *PrivateKeyUpdate) SetNillableUserID(id *string) *PrivateKeyUpdate { - if id != nil { - pku = pku.SetUserID(*id) - } - return pku -} - -// SetUser sets the "user" edge to the User entity. -func (pku *PrivateKeyUpdate) SetUser(u *User) *PrivateKeyUpdate { - return pku.SetUserID(u.ID) -} - -// Mutation returns the PrivateKeyMutation object of the builder. -func (pku *PrivateKeyUpdate) Mutation() *PrivateKeyMutation { - return pku.mutation -} - -// ClearUser clears the "user" edge to the User entity. -func (pku *PrivateKeyUpdate) ClearUser() *PrivateKeyUpdate { - pku.mutation.ClearUser() - return pku -} - -// Save executes the query and returns the number of nodes affected by the update operation. -func (pku *PrivateKeyUpdate) Save(ctx context.Context) (int, error) { - var ( - err error - affected int - ) - if len(pku.hooks) == 0 { - affected, err = pku.sqlSave(ctx) - } else { - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*PrivateKeyMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - pku.mutation = mutation - affected, err = pku.sqlSave(ctx) - mutation.done = true - return affected, err - }) - for i := len(pku.hooks) - 1; i >= 0; i-- { - if pku.hooks[i] == nil { - return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") - } - mut = pku.hooks[i](mut) - } - if _, err := mut.Mutate(ctx, pku.mutation); err != nil { - return 0, err - } - } - return affected, err -} - -// SaveX is like Save, but panics if an error occurs. -func (pku *PrivateKeyUpdate) SaveX(ctx context.Context) int { - affected, err := pku.Save(ctx) - if err != nil { - panic(err) - } - return affected -} - -// Exec executes the query. -func (pku *PrivateKeyUpdate) Exec(ctx context.Context) error { - _, err := pku.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (pku *PrivateKeyUpdate) ExecX(ctx context.Context) { - if err := pku.Exec(ctx); err != nil { - panic(err) - } -} - -func (pku *PrivateKeyUpdate) sqlSave(ctx context.Context) (n int, err error) { - _spec := &sqlgraph.UpdateSpec{ - Node: &sqlgraph.NodeSpec{ - Table: privatekey.Table, - Columns: privatekey.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: privatekey.FieldID, - }, - }, - } - if ps := pku.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if value, ok := pku.mutation.Kty(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeString, - Value: value, - Column: privatekey.FieldKty, - }) - } - if value, ok := pku.mutation.Alg(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeString, - Value: value, - Column: privatekey.FieldAlg, - }) - } - if pku.mutation.AlgCleared() { - _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: privatekey.FieldAlg, - }) - } - if value, ok := pku.mutation.Jwk(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeJSON, - Value: value, - Column: privatekey.FieldJwk, - }) - } - if value, ok := pku.mutation.UpdatedAt(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeTime, - Value: value, - Column: privatekey.FieldUpdatedAt, - }) - } - if pku.mutation.UserCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: true, - Table: privatekey.UserTable, - Columns: []string{privatekey.UserColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: user.FieldID, - }, - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := pku.mutation.UserIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: true, - Table: privatekey.UserTable, - Columns: []string{privatekey.UserColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: user.FieldID, - }, - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if n, err = sqlgraph.UpdateNodes(ctx, pku.driver, _spec); err != nil { - if _, ok := err.(*sqlgraph.NotFoundError); ok { - err = &NotFoundError{privatekey.Label} - } else if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return 0, err - } - return n, nil -} - -// PrivateKeyUpdateOne is the builder for updating a single PrivateKey entity. -type PrivateKeyUpdateOne struct { - config - fields []string - hooks []Hook - mutation *PrivateKeyMutation -} - -// SetKty sets the "kty" field. -func (pkuo *PrivateKeyUpdateOne) SetKty(s string) *PrivateKeyUpdateOne { - pkuo.mutation.SetKty(s) - return pkuo -} - -// SetAlg sets the "alg" field. -func (pkuo *PrivateKeyUpdateOne) SetAlg(s string) *PrivateKeyUpdateOne { - pkuo.mutation.SetAlg(s) - return pkuo -} - -// SetNillableAlg sets the "alg" field if the given value is not nil. -func (pkuo *PrivateKeyUpdateOne) SetNillableAlg(s *string) *PrivateKeyUpdateOne { - if s != nil { - pkuo.SetAlg(*s) - } - return pkuo -} - -// ClearAlg clears the value of the "alg" field. -func (pkuo *PrivateKeyUpdateOne) ClearAlg() *PrivateKeyUpdateOne { - pkuo.mutation.ClearAlg() - return pkuo -} - -// SetJwk sets the "jwk" field. -func (pkuo *PrivateKeyUpdateOne) SetJwk(u []uint8) *PrivateKeyUpdateOne { - pkuo.mutation.SetJwk(u) - return pkuo -} - -// SetUpdatedAt sets the "updated_at" field. -func (pkuo *PrivateKeyUpdateOne) SetUpdatedAt(t time.Time) *PrivateKeyUpdateOne { - pkuo.mutation.SetUpdatedAt(t) - return pkuo -} - -// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. -func (pkuo *PrivateKeyUpdateOne) SetNillableUpdatedAt(t *time.Time) *PrivateKeyUpdateOne { - if t != nil { - pkuo.SetUpdatedAt(*t) - } - return pkuo -} - -// SetUserID sets the "user" edge to the User entity by ID. -func (pkuo *PrivateKeyUpdateOne) SetUserID(id string) *PrivateKeyUpdateOne { - pkuo.mutation.SetUserID(id) - return pkuo -} - -// SetNillableUserID sets the "user" edge to the User entity by ID if the given value is not nil. -func (pkuo *PrivateKeyUpdateOne) SetNillableUserID(id *string) *PrivateKeyUpdateOne { - if id != nil { - pkuo = pkuo.SetUserID(*id) - } - return pkuo -} - -// SetUser sets the "user" edge to the User entity. -func (pkuo *PrivateKeyUpdateOne) SetUser(u *User) *PrivateKeyUpdateOne { - return pkuo.SetUserID(u.ID) -} - -// Mutation returns the PrivateKeyMutation object of the builder. -func (pkuo *PrivateKeyUpdateOne) Mutation() *PrivateKeyMutation { - return pkuo.mutation -} - -// ClearUser clears the "user" edge to the User entity. -func (pkuo *PrivateKeyUpdateOne) ClearUser() *PrivateKeyUpdateOne { - pkuo.mutation.ClearUser() - return pkuo -} - -// Select allows selecting one or more fields (columns) of the returned entity. -// The default is selecting all fields defined in the entity schema. -func (pkuo *PrivateKeyUpdateOne) Select(field string, fields ...string) *PrivateKeyUpdateOne { - pkuo.fields = append([]string{field}, fields...) - return pkuo -} - -// Save executes the query and returns the updated PrivateKey entity. -func (pkuo *PrivateKeyUpdateOne) Save(ctx context.Context) (*PrivateKey, error) { - var ( - err error - node *PrivateKey - ) - if len(pkuo.hooks) == 0 { - node, err = pkuo.sqlSave(ctx) - } else { - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*PrivateKeyMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - pkuo.mutation = mutation - node, err = pkuo.sqlSave(ctx) - mutation.done = true - return node, err - }) - for i := len(pkuo.hooks) - 1; i >= 0; i-- { - if pkuo.hooks[i] == nil { - return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") - } - mut = pkuo.hooks[i](mut) - } - v, err := mut.Mutate(ctx, pkuo.mutation) - if err != nil { - return nil, err - } - nv, ok := v.(*PrivateKey) - if !ok { - return nil, fmt.Errorf("unexpected node type %T returned from PrivateKeyMutation", v) - } - node = nv - } - return node, err -} - -// SaveX is like Save, but panics if an error occurs. -func (pkuo *PrivateKeyUpdateOne) SaveX(ctx context.Context) *PrivateKey { - node, err := pkuo.Save(ctx) - if err != nil { - panic(err) - } - return node -} - -// Exec executes the query on the entity. -func (pkuo *PrivateKeyUpdateOne) Exec(ctx context.Context) error { - _, err := pkuo.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (pkuo *PrivateKeyUpdateOne) ExecX(ctx context.Context) { - if err := pkuo.Exec(ctx); err != nil { - panic(err) - } -} - -func (pkuo *PrivateKeyUpdateOne) sqlSave(ctx context.Context) (_node *PrivateKey, err error) { - _spec := &sqlgraph.UpdateSpec{ - Node: &sqlgraph.NodeSpec{ - Table: privatekey.Table, - Columns: privatekey.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: privatekey.FieldID, - }, - }, - } - id, ok := pkuo.mutation.ID() - if !ok { - return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "PrivateKey.id" for update`)} - } - _spec.Node.ID.Value = id - if fields := pkuo.fields; len(fields) > 0 { - _spec.Node.Columns = make([]string, 0, len(fields)) - _spec.Node.Columns = append(_spec.Node.Columns, privatekey.FieldID) - for _, f := range fields { - if !privatekey.ValidColumn(f) { - return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} - } - if f != privatekey.FieldID { - _spec.Node.Columns = append(_spec.Node.Columns, f) - } - } - } - if ps := pkuo.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if value, ok := pkuo.mutation.Kty(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeString, - Value: value, - Column: privatekey.FieldKty, - }) - } - if value, ok := pkuo.mutation.Alg(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeString, - Value: value, - Column: privatekey.FieldAlg, - }) - } - if pkuo.mutation.AlgCleared() { - _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: privatekey.FieldAlg, - }) - } - if value, ok := pkuo.mutation.Jwk(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeJSON, - Value: value, - Column: privatekey.FieldJwk, - }) - } - if value, ok := pkuo.mutation.UpdatedAt(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeTime, - Value: value, - Column: privatekey.FieldUpdatedAt, - }) - } - if pkuo.mutation.UserCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: true, - Table: privatekey.UserTable, - Columns: []string{privatekey.UserColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: user.FieldID, - }, - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := pkuo.mutation.UserIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: true, - Table: privatekey.UserTable, - Columns: []string{privatekey.UserColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: user.FieldID, - }, - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - _node = &PrivateKey{config: pkuo.config} - _spec.Assign = _node.assignValues - _spec.ScanValues = _node.scanValues - if err = sqlgraph.UpdateNode(ctx, pkuo.driver, _spec); err != nil { - if _, ok := err.(*sqlgraph.NotFoundError); ok { - err = &NotFoundError{privatekey.Label} - } else if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return nil, err - } - return _node, nil -} diff --git a/ent/publickey.go b/ent/publickey.go deleted file mode 100644 index bc004119..00000000 --- a/ent/publickey.go +++ /dev/null @@ -1,149 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "encoding/json" - "fmt" - "strings" - "time" - - "entgo.io/ent/dialect/sql" - "github.com/fiware/vcverifier/ent/publickey" -) - -// PublicKey is the model entity for the PublicKey schema. -type PublicKey struct { - config `json:"-"` - // ID of the ent. - ID string `json:"id,omitempty"` - // Kty holds the value of the "kty" field. - Kty string `json:"kty,omitempty"` - // Alg holds the value of the "alg" field. - Alg string `json:"alg,omitempty"` - // Jwk holds the value of the "jwk" field. - Jwk []uint8 `json:"jwk,omitempty"` - // CreatedAt holds the value of the "created_at" field. - CreatedAt time.Time `json:"created_at,omitempty"` - // UpdatedAt holds the value of the "updated_at" field. - UpdatedAt time.Time `json:"updated_at,omitempty"` -} - -// scanValues returns the types for scanning values from sql.Rows. -func (*PublicKey) scanValues(columns []string) ([]interface{}, error) { - values := make([]interface{}, len(columns)) - for i := range columns { - switch columns[i] { - case publickey.FieldJwk: - values[i] = new([]byte) - case publickey.FieldID, publickey.FieldKty, publickey.FieldAlg: - values[i] = new(sql.NullString) - case publickey.FieldCreatedAt, publickey.FieldUpdatedAt: - values[i] = new(sql.NullTime) - default: - return nil, fmt.Errorf("unexpected column %q for type PublicKey", columns[i]) - } - } - return values, nil -} - -// assignValues assigns the values that were returned from sql.Rows (after scanning) -// to the PublicKey fields. -func (pk *PublicKey) assignValues(columns []string, values []interface{}) error { - if m, n := len(values), len(columns); m < n { - return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) - } - for i := range columns { - switch columns[i] { - case publickey.FieldID: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field id", values[i]) - } else if value.Valid { - pk.ID = value.String - } - case publickey.FieldKty: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field kty", values[i]) - } else if value.Valid { - pk.Kty = value.String - } - case publickey.FieldAlg: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field alg", values[i]) - } else if value.Valid { - pk.Alg = value.String - } - case publickey.FieldJwk: - if value, ok := values[i].(*[]byte); !ok { - return fmt.Errorf("unexpected type %T for field jwk", values[i]) - } else if value != nil && len(*value) > 0 { - if err := json.Unmarshal(*value, &pk.Jwk); err != nil { - return fmt.Errorf("unmarshal field jwk: %w", err) - } - } - case publickey.FieldCreatedAt: - if value, ok := values[i].(*sql.NullTime); !ok { - return fmt.Errorf("unexpected type %T for field created_at", values[i]) - } else if value.Valid { - pk.CreatedAt = value.Time - } - case publickey.FieldUpdatedAt: - if value, ok := values[i].(*sql.NullTime); !ok { - return fmt.Errorf("unexpected type %T for field updated_at", values[i]) - } else if value.Valid { - pk.UpdatedAt = value.Time - } - } - } - return nil -} - -// Update returns a builder for updating this PublicKey. -// Note that you need to call PublicKey.Unwrap() before calling this method if this PublicKey -// was returned from a transaction, and the transaction was committed or rolled back. -func (pk *PublicKey) Update() *PublicKeyUpdateOne { - return (&PublicKeyClient{config: pk.config}).UpdateOne(pk) -} - -// Unwrap unwraps the PublicKey entity that was returned from a transaction after it was closed, -// so that all future queries will be executed through the driver which created the transaction. -func (pk *PublicKey) Unwrap() *PublicKey { - _tx, ok := pk.config.driver.(*txDriver) - if !ok { - panic("ent: PublicKey is not a transactional entity") - } - pk.config.driver = _tx.drv - return pk -} - -// String implements the fmt.Stringer. -func (pk *PublicKey) String() string { - var builder strings.Builder - builder.WriteString("PublicKey(") - builder.WriteString(fmt.Sprintf("id=%v, ", pk.ID)) - builder.WriteString("kty=") - builder.WriteString(pk.Kty) - builder.WriteString(", ") - builder.WriteString("alg=") - builder.WriteString(pk.Alg) - builder.WriteString(", ") - builder.WriteString("jwk=") - builder.WriteString(fmt.Sprintf("%v", pk.Jwk)) - builder.WriteString(", ") - builder.WriteString("created_at=") - builder.WriteString(pk.CreatedAt.Format(time.ANSIC)) - builder.WriteString(", ") - builder.WriteString("updated_at=") - builder.WriteString(pk.UpdatedAt.Format(time.ANSIC)) - builder.WriteByte(')') - return builder.String() -} - -// PublicKeys is a parsable slice of PublicKey. -type PublicKeys []*PublicKey - -func (pk PublicKeys) config(cfg config) { - for _i := range pk { - pk[_i].config = cfg - } -} diff --git a/ent/publickey/publickey.go b/ent/publickey/publickey.go deleted file mode 100644 index e5aa759f..00000000 --- a/ent/publickey/publickey.go +++ /dev/null @@ -1,53 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package publickey - -import ( - "time" -) - -const ( - // Label holds the string label denoting the publickey type in the database. - Label = "public_key" - // FieldID holds the string denoting the id field in the database. - FieldID = "id" - // FieldKty holds the string denoting the kty field in the database. - FieldKty = "kty" - // FieldAlg holds the string denoting the alg field in the database. - FieldAlg = "alg" - // FieldJwk holds the string denoting the jwk field in the database. - FieldJwk = "jwk" - // FieldCreatedAt holds the string denoting the created_at field in the database. - FieldCreatedAt = "created_at" - // FieldUpdatedAt holds the string denoting the updated_at field in the database. - FieldUpdatedAt = "updated_at" - // Table holds the table name of the publickey in the database. - Table = "public_keys" -) - -// Columns holds all SQL columns for publickey fields. -var Columns = []string{ - FieldID, - FieldKty, - FieldAlg, - FieldJwk, - FieldCreatedAt, - FieldUpdatedAt, -} - -// ValidColumn reports if the column name is valid (part of the table columns). -func ValidColumn(column string) bool { - for i := range Columns { - if column == Columns[i] { - return true - } - } - return false -} - -var ( - // DefaultCreatedAt holds the default value on creation for the "created_at" field. - DefaultCreatedAt func() time.Time - // DefaultUpdatedAt holds the default value on creation for the "updated_at" field. - DefaultUpdatedAt func() time.Time -) diff --git a/ent/publickey/where.go b/ent/publickey/where.go deleted file mode 100644 index 72db58c6..00000000 --- a/ent/publickey/where.go +++ /dev/null @@ -1,529 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package publickey - -import ( - "time" - - "entgo.io/ent/dialect/sql" - "github.com/fiware/vcverifier/ent/predicate" -) - -// ID filters vertices based on their ID field. -func ID(id string) predicate.PublicKey { - return predicate.PublicKey(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldID), id)) - }) -} - -// IDEQ applies the EQ predicate on the ID field. -func IDEQ(id string) predicate.PublicKey { - return predicate.PublicKey(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldID), id)) - }) -} - -// IDNEQ applies the NEQ predicate on the ID field. -func IDNEQ(id string) predicate.PublicKey { - return predicate.PublicKey(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldID), id)) - }) -} - -// IDIn applies the In predicate on the ID field. -func IDIn(ids ...string) predicate.PublicKey { - return predicate.PublicKey(func(s *sql.Selector) { - v := make([]interface{}, len(ids)) - for i := range v { - v[i] = ids[i] - } - s.Where(sql.In(s.C(FieldID), v...)) - }) -} - -// IDNotIn applies the NotIn predicate on the ID field. -func IDNotIn(ids ...string) predicate.PublicKey { - return predicate.PublicKey(func(s *sql.Selector) { - v := make([]interface{}, len(ids)) - for i := range v { - v[i] = ids[i] - } - s.Where(sql.NotIn(s.C(FieldID), v...)) - }) -} - -// IDGT applies the GT predicate on the ID field. -func IDGT(id string) predicate.PublicKey { - return predicate.PublicKey(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldID), id)) - }) -} - -// IDGTE applies the GTE predicate on the ID field. -func IDGTE(id string) predicate.PublicKey { - return predicate.PublicKey(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldID), id)) - }) -} - -// IDLT applies the LT predicate on the ID field. -func IDLT(id string) predicate.PublicKey { - return predicate.PublicKey(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldID), id)) - }) -} - -// IDLTE applies the LTE predicate on the ID field. -func IDLTE(id string) predicate.PublicKey { - return predicate.PublicKey(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldID), id)) - }) -} - -// Kty applies equality check predicate on the "kty" field. It's identical to KtyEQ. -func Kty(v string) predicate.PublicKey { - return predicate.PublicKey(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldKty), v)) - }) -} - -// Alg applies equality check predicate on the "alg" field. It's identical to AlgEQ. -func Alg(v string) predicate.PublicKey { - return predicate.PublicKey(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldAlg), v)) - }) -} - -// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. -func CreatedAt(v time.Time) predicate.PublicKey { - return predicate.PublicKey(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldCreatedAt), v)) - }) -} - -// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ. -func UpdatedAt(v time.Time) predicate.PublicKey { - return predicate.PublicKey(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldUpdatedAt), v)) - }) -} - -// KtyEQ applies the EQ predicate on the "kty" field. -func KtyEQ(v string) predicate.PublicKey { - return predicate.PublicKey(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldKty), v)) - }) -} - -// KtyNEQ applies the NEQ predicate on the "kty" field. -func KtyNEQ(v string) predicate.PublicKey { - return predicate.PublicKey(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldKty), v)) - }) -} - -// KtyIn applies the In predicate on the "kty" field. -func KtyIn(vs ...string) predicate.PublicKey { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.PublicKey(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldKty), v...)) - }) -} - -// KtyNotIn applies the NotIn predicate on the "kty" field. -func KtyNotIn(vs ...string) predicate.PublicKey { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.PublicKey(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldKty), v...)) - }) -} - -// KtyGT applies the GT predicate on the "kty" field. -func KtyGT(v string) predicate.PublicKey { - return predicate.PublicKey(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldKty), v)) - }) -} - -// KtyGTE applies the GTE predicate on the "kty" field. -func KtyGTE(v string) predicate.PublicKey { - return predicate.PublicKey(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldKty), v)) - }) -} - -// KtyLT applies the LT predicate on the "kty" field. -func KtyLT(v string) predicate.PublicKey { - return predicate.PublicKey(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldKty), v)) - }) -} - -// KtyLTE applies the LTE predicate on the "kty" field. -func KtyLTE(v string) predicate.PublicKey { - return predicate.PublicKey(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldKty), v)) - }) -} - -// KtyContains applies the Contains predicate on the "kty" field. -func KtyContains(v string) predicate.PublicKey { - return predicate.PublicKey(func(s *sql.Selector) { - s.Where(sql.Contains(s.C(FieldKty), v)) - }) -} - -// KtyHasPrefix applies the HasPrefix predicate on the "kty" field. -func KtyHasPrefix(v string) predicate.PublicKey { - return predicate.PublicKey(func(s *sql.Selector) { - s.Where(sql.HasPrefix(s.C(FieldKty), v)) - }) -} - -// KtyHasSuffix applies the HasSuffix predicate on the "kty" field. -func KtyHasSuffix(v string) predicate.PublicKey { - return predicate.PublicKey(func(s *sql.Selector) { - s.Where(sql.HasSuffix(s.C(FieldKty), v)) - }) -} - -// KtyEqualFold applies the EqualFold predicate on the "kty" field. -func KtyEqualFold(v string) predicate.PublicKey { - return predicate.PublicKey(func(s *sql.Selector) { - s.Where(sql.EqualFold(s.C(FieldKty), v)) - }) -} - -// KtyContainsFold applies the ContainsFold predicate on the "kty" field. -func KtyContainsFold(v string) predicate.PublicKey { - return predicate.PublicKey(func(s *sql.Selector) { - s.Where(sql.ContainsFold(s.C(FieldKty), v)) - }) -} - -// AlgEQ applies the EQ predicate on the "alg" field. -func AlgEQ(v string) predicate.PublicKey { - return predicate.PublicKey(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldAlg), v)) - }) -} - -// AlgNEQ applies the NEQ predicate on the "alg" field. -func AlgNEQ(v string) predicate.PublicKey { - return predicate.PublicKey(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldAlg), v)) - }) -} - -// AlgIn applies the In predicate on the "alg" field. -func AlgIn(vs ...string) predicate.PublicKey { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.PublicKey(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldAlg), v...)) - }) -} - -// AlgNotIn applies the NotIn predicate on the "alg" field. -func AlgNotIn(vs ...string) predicate.PublicKey { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.PublicKey(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldAlg), v...)) - }) -} - -// AlgGT applies the GT predicate on the "alg" field. -func AlgGT(v string) predicate.PublicKey { - return predicate.PublicKey(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldAlg), v)) - }) -} - -// AlgGTE applies the GTE predicate on the "alg" field. -func AlgGTE(v string) predicate.PublicKey { - return predicate.PublicKey(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldAlg), v)) - }) -} - -// AlgLT applies the LT predicate on the "alg" field. -func AlgLT(v string) predicate.PublicKey { - return predicate.PublicKey(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldAlg), v)) - }) -} - -// AlgLTE applies the LTE predicate on the "alg" field. -func AlgLTE(v string) predicate.PublicKey { - return predicate.PublicKey(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldAlg), v)) - }) -} - -// AlgContains applies the Contains predicate on the "alg" field. -func AlgContains(v string) predicate.PublicKey { - return predicate.PublicKey(func(s *sql.Selector) { - s.Where(sql.Contains(s.C(FieldAlg), v)) - }) -} - -// AlgHasPrefix applies the HasPrefix predicate on the "alg" field. -func AlgHasPrefix(v string) predicate.PublicKey { - return predicate.PublicKey(func(s *sql.Selector) { - s.Where(sql.HasPrefix(s.C(FieldAlg), v)) - }) -} - -// AlgHasSuffix applies the HasSuffix predicate on the "alg" field. -func AlgHasSuffix(v string) predicate.PublicKey { - return predicate.PublicKey(func(s *sql.Selector) { - s.Where(sql.HasSuffix(s.C(FieldAlg), v)) - }) -} - -// AlgIsNil applies the IsNil predicate on the "alg" field. -func AlgIsNil() predicate.PublicKey { - return predicate.PublicKey(func(s *sql.Selector) { - s.Where(sql.IsNull(s.C(FieldAlg))) - }) -} - -// AlgNotNil applies the NotNil predicate on the "alg" field. -func AlgNotNil() predicate.PublicKey { - return predicate.PublicKey(func(s *sql.Selector) { - s.Where(sql.NotNull(s.C(FieldAlg))) - }) -} - -// AlgEqualFold applies the EqualFold predicate on the "alg" field. -func AlgEqualFold(v string) predicate.PublicKey { - return predicate.PublicKey(func(s *sql.Selector) { - s.Where(sql.EqualFold(s.C(FieldAlg), v)) - }) -} - -// AlgContainsFold applies the ContainsFold predicate on the "alg" field. -func AlgContainsFold(v string) predicate.PublicKey { - return predicate.PublicKey(func(s *sql.Selector) { - s.Where(sql.ContainsFold(s.C(FieldAlg), v)) - }) -} - -// CreatedAtEQ applies the EQ predicate on the "created_at" field. -func CreatedAtEQ(v time.Time) predicate.PublicKey { - return predicate.PublicKey(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldCreatedAt), v)) - }) -} - -// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. -func CreatedAtNEQ(v time.Time) predicate.PublicKey { - return predicate.PublicKey(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldCreatedAt), v)) - }) -} - -// CreatedAtIn applies the In predicate on the "created_at" field. -func CreatedAtIn(vs ...time.Time) predicate.PublicKey { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.PublicKey(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldCreatedAt), v...)) - }) -} - -// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. -func CreatedAtNotIn(vs ...time.Time) predicate.PublicKey { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.PublicKey(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldCreatedAt), v...)) - }) -} - -// CreatedAtGT applies the GT predicate on the "created_at" field. -func CreatedAtGT(v time.Time) predicate.PublicKey { - return predicate.PublicKey(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldCreatedAt), v)) - }) -} - -// CreatedAtGTE applies the GTE predicate on the "created_at" field. -func CreatedAtGTE(v time.Time) predicate.PublicKey { - return predicate.PublicKey(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldCreatedAt), v)) - }) -} - -// CreatedAtLT applies the LT predicate on the "created_at" field. -func CreatedAtLT(v time.Time) predicate.PublicKey { - return predicate.PublicKey(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldCreatedAt), v)) - }) -} - -// CreatedAtLTE applies the LTE predicate on the "created_at" field. -func CreatedAtLTE(v time.Time) predicate.PublicKey { - return predicate.PublicKey(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldCreatedAt), v)) - }) -} - -// UpdatedAtEQ applies the EQ predicate on the "updated_at" field. -func UpdatedAtEQ(v time.Time) predicate.PublicKey { - return predicate.PublicKey(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldUpdatedAt), v)) - }) -} - -// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field. -func UpdatedAtNEQ(v time.Time) predicate.PublicKey { - return predicate.PublicKey(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldUpdatedAt), v)) - }) -} - -// UpdatedAtIn applies the In predicate on the "updated_at" field. -func UpdatedAtIn(vs ...time.Time) predicate.PublicKey { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.PublicKey(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldUpdatedAt), v...)) - }) -} - -// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field. -func UpdatedAtNotIn(vs ...time.Time) predicate.PublicKey { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.PublicKey(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldUpdatedAt), v...)) - }) -} - -// UpdatedAtGT applies the GT predicate on the "updated_at" field. -func UpdatedAtGT(v time.Time) predicate.PublicKey { - return predicate.PublicKey(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldUpdatedAt), v)) - }) -} - -// UpdatedAtGTE applies the GTE predicate on the "updated_at" field. -func UpdatedAtGTE(v time.Time) predicate.PublicKey { - return predicate.PublicKey(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldUpdatedAt), v)) - }) -} - -// UpdatedAtLT applies the LT predicate on the "updated_at" field. -func UpdatedAtLT(v time.Time) predicate.PublicKey { - return predicate.PublicKey(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldUpdatedAt), v)) - }) -} - -// UpdatedAtLTE applies the LTE predicate on the "updated_at" field. -func UpdatedAtLTE(v time.Time) predicate.PublicKey { - return predicate.PublicKey(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldUpdatedAt), v)) - }) -} - -// And groups predicates with the AND operator between them. -func And(predicates ...predicate.PublicKey) predicate.PublicKey { - return predicate.PublicKey(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) -} - -// Or groups predicates with the OR operator between them. -func Or(predicates ...predicate.PublicKey) predicate.PublicKey { - return predicate.PublicKey(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) -} - -// Not applies the not operator on the given predicate. -func Not(p predicate.PublicKey) predicate.PublicKey { - return predicate.PublicKey(func(s *sql.Selector) { - p(s.Not()) - }) -} diff --git a/ent/publickey_create.go b/ent/publickey_create.go deleted file mode 100644 index 180e1823..00000000 --- a/ent/publickey_create.go +++ /dev/null @@ -1,341 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - "time" - - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/fiware/vcverifier/ent/publickey" -) - -// PublicKeyCreate is the builder for creating a PublicKey entity. -type PublicKeyCreate struct { - config - mutation *PublicKeyMutation - hooks []Hook -} - -// SetKty sets the "kty" field. -func (pkc *PublicKeyCreate) SetKty(s string) *PublicKeyCreate { - pkc.mutation.SetKty(s) - return pkc -} - -// SetAlg sets the "alg" field. -func (pkc *PublicKeyCreate) SetAlg(s string) *PublicKeyCreate { - pkc.mutation.SetAlg(s) - return pkc -} - -// SetNillableAlg sets the "alg" field if the given value is not nil. -func (pkc *PublicKeyCreate) SetNillableAlg(s *string) *PublicKeyCreate { - if s != nil { - pkc.SetAlg(*s) - } - return pkc -} - -// SetJwk sets the "jwk" field. -func (pkc *PublicKeyCreate) SetJwk(u []uint8) *PublicKeyCreate { - pkc.mutation.SetJwk(u) - return pkc -} - -// SetCreatedAt sets the "created_at" field. -func (pkc *PublicKeyCreate) SetCreatedAt(t time.Time) *PublicKeyCreate { - pkc.mutation.SetCreatedAt(t) - return pkc -} - -// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. -func (pkc *PublicKeyCreate) SetNillableCreatedAt(t *time.Time) *PublicKeyCreate { - if t != nil { - pkc.SetCreatedAt(*t) - } - return pkc -} - -// SetUpdatedAt sets the "updated_at" field. -func (pkc *PublicKeyCreate) SetUpdatedAt(t time.Time) *PublicKeyCreate { - pkc.mutation.SetUpdatedAt(t) - return pkc -} - -// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. -func (pkc *PublicKeyCreate) SetNillableUpdatedAt(t *time.Time) *PublicKeyCreate { - if t != nil { - pkc.SetUpdatedAt(*t) - } - return pkc -} - -// SetID sets the "id" field. -func (pkc *PublicKeyCreate) SetID(s string) *PublicKeyCreate { - pkc.mutation.SetID(s) - return pkc -} - -// Mutation returns the PublicKeyMutation object of the builder. -func (pkc *PublicKeyCreate) Mutation() *PublicKeyMutation { - return pkc.mutation -} - -// Save creates the PublicKey in the database. -func (pkc *PublicKeyCreate) Save(ctx context.Context) (*PublicKey, error) { - var ( - err error - node *PublicKey - ) - pkc.defaults() - if len(pkc.hooks) == 0 { - if err = pkc.check(); err != nil { - return nil, err - } - node, err = pkc.sqlSave(ctx) - } else { - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*PublicKeyMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - if err = pkc.check(); err != nil { - return nil, err - } - pkc.mutation = mutation - if node, err = pkc.sqlSave(ctx); err != nil { - return nil, err - } - mutation.id = &node.ID - mutation.done = true - return node, err - }) - for i := len(pkc.hooks) - 1; i >= 0; i-- { - if pkc.hooks[i] == nil { - return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") - } - mut = pkc.hooks[i](mut) - } - v, err := mut.Mutate(ctx, pkc.mutation) - if err != nil { - return nil, err - } - nv, ok := v.(*PublicKey) - if !ok { - return nil, fmt.Errorf("unexpected node type %T returned from PublicKeyMutation", v) - } - node = nv - } - return node, err -} - -// SaveX calls Save and panics if Save returns an error. -func (pkc *PublicKeyCreate) SaveX(ctx context.Context) *PublicKey { - v, err := pkc.Save(ctx) - if err != nil { - panic(err) - } - return v -} - -// Exec executes the query. -func (pkc *PublicKeyCreate) Exec(ctx context.Context) error { - _, err := pkc.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (pkc *PublicKeyCreate) ExecX(ctx context.Context) { - if err := pkc.Exec(ctx); err != nil { - panic(err) - } -} - -// defaults sets the default values of the builder before save. -func (pkc *PublicKeyCreate) defaults() { - if _, ok := pkc.mutation.CreatedAt(); !ok { - v := publickey.DefaultCreatedAt() - pkc.mutation.SetCreatedAt(v) - } - if _, ok := pkc.mutation.UpdatedAt(); !ok { - v := publickey.DefaultUpdatedAt() - pkc.mutation.SetUpdatedAt(v) - } -} - -// check runs all checks and user-defined validators on the builder. -func (pkc *PublicKeyCreate) check() error { - if _, ok := pkc.mutation.Kty(); !ok { - return &ValidationError{Name: "kty", err: errors.New(`ent: missing required field "PublicKey.kty"`)} - } - if _, ok := pkc.mutation.Jwk(); !ok { - return &ValidationError{Name: "jwk", err: errors.New(`ent: missing required field "PublicKey.jwk"`)} - } - if _, ok := pkc.mutation.CreatedAt(); !ok { - return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "PublicKey.created_at"`)} - } - if _, ok := pkc.mutation.UpdatedAt(); !ok { - return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "PublicKey.updated_at"`)} - } - return nil -} - -func (pkc *PublicKeyCreate) sqlSave(ctx context.Context) (*PublicKey, error) { - _node, _spec := pkc.createSpec() - if err := sqlgraph.CreateNode(ctx, pkc.driver, _spec); err != nil { - if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return nil, err - } - if _spec.ID.Value != nil { - if id, ok := _spec.ID.Value.(string); ok { - _node.ID = id - } else { - return nil, fmt.Errorf("unexpected PublicKey.ID type: %T", _spec.ID.Value) - } - } - return _node, nil -} - -func (pkc *PublicKeyCreate) createSpec() (*PublicKey, *sqlgraph.CreateSpec) { - var ( - _node = &PublicKey{config: pkc.config} - _spec = &sqlgraph.CreateSpec{ - Table: publickey.Table, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: publickey.FieldID, - }, - } - ) - if id, ok := pkc.mutation.ID(); ok { - _node.ID = id - _spec.ID.Value = id - } - if value, ok := pkc.mutation.Kty(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeString, - Value: value, - Column: publickey.FieldKty, - }) - _node.Kty = value - } - if value, ok := pkc.mutation.Alg(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeString, - Value: value, - Column: publickey.FieldAlg, - }) - _node.Alg = value - } - if value, ok := pkc.mutation.Jwk(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeJSON, - Value: value, - Column: publickey.FieldJwk, - }) - _node.Jwk = value - } - if value, ok := pkc.mutation.CreatedAt(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeTime, - Value: value, - Column: publickey.FieldCreatedAt, - }) - _node.CreatedAt = value - } - if value, ok := pkc.mutation.UpdatedAt(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeTime, - Value: value, - Column: publickey.FieldUpdatedAt, - }) - _node.UpdatedAt = value - } - return _node, _spec -} - -// PublicKeyCreateBulk is the builder for creating many PublicKey entities in bulk. -type PublicKeyCreateBulk struct { - config - builders []*PublicKeyCreate -} - -// Save creates the PublicKey entities in the database. -func (pkcb *PublicKeyCreateBulk) Save(ctx context.Context) ([]*PublicKey, error) { - specs := make([]*sqlgraph.CreateSpec, len(pkcb.builders)) - nodes := make([]*PublicKey, len(pkcb.builders)) - mutators := make([]Mutator, len(pkcb.builders)) - for i := range pkcb.builders { - func(i int, root context.Context) { - builder := pkcb.builders[i] - builder.defaults() - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*PublicKeyMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - if err := builder.check(); err != nil { - return nil, err - } - builder.mutation = mutation - nodes[i], specs[i] = builder.createSpec() - var err error - if i < len(mutators)-1 { - _, err = mutators[i+1].Mutate(root, pkcb.builders[i+1].mutation) - } else { - spec := &sqlgraph.BatchCreateSpec{Nodes: specs} - // Invoke the actual operation on the latest mutation in the chain. - if err = sqlgraph.BatchCreate(ctx, pkcb.driver, spec); err != nil { - if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - } - } - if err != nil { - return nil, err - } - mutation.id = &nodes[i].ID - mutation.done = true - return nodes[i], nil - }) - for i := len(builder.hooks) - 1; i >= 0; i-- { - mut = builder.hooks[i](mut) - } - mutators[i] = mut - }(i, ctx) - } - if len(mutators) > 0 { - if _, err := mutators[0].Mutate(ctx, pkcb.builders[0].mutation); err != nil { - return nil, err - } - } - return nodes, nil -} - -// SaveX is like Save, but panics if an error occurs. -func (pkcb *PublicKeyCreateBulk) SaveX(ctx context.Context) []*PublicKey { - v, err := pkcb.Save(ctx) - if err != nil { - panic(err) - } - return v -} - -// Exec executes the query. -func (pkcb *PublicKeyCreateBulk) Exec(ctx context.Context) error { - _, err := pkcb.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (pkcb *PublicKeyCreateBulk) ExecX(ctx context.Context) { - if err := pkcb.Exec(ctx); err != nil { - panic(err) - } -} diff --git a/ent/publickey_delete.go b/ent/publickey_delete.go deleted file mode 100644 index cae6f581..00000000 --- a/ent/publickey_delete.go +++ /dev/null @@ -1,115 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "fmt" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/fiware/vcverifier/ent/predicate" - "github.com/fiware/vcverifier/ent/publickey" -) - -// PublicKeyDelete is the builder for deleting a PublicKey entity. -type PublicKeyDelete struct { - config - hooks []Hook - mutation *PublicKeyMutation -} - -// Where appends a list predicates to the PublicKeyDelete builder. -func (pkd *PublicKeyDelete) Where(ps ...predicate.PublicKey) *PublicKeyDelete { - pkd.mutation.Where(ps...) - return pkd -} - -// Exec executes the deletion query and returns how many vertices were deleted. -func (pkd *PublicKeyDelete) Exec(ctx context.Context) (int, error) { - var ( - err error - affected int - ) - if len(pkd.hooks) == 0 { - affected, err = pkd.sqlExec(ctx) - } else { - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*PublicKeyMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - pkd.mutation = mutation - affected, err = pkd.sqlExec(ctx) - mutation.done = true - return affected, err - }) - for i := len(pkd.hooks) - 1; i >= 0; i-- { - if pkd.hooks[i] == nil { - return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") - } - mut = pkd.hooks[i](mut) - } - if _, err := mut.Mutate(ctx, pkd.mutation); err != nil { - return 0, err - } - } - return affected, err -} - -// ExecX is like Exec, but panics if an error occurs. -func (pkd *PublicKeyDelete) ExecX(ctx context.Context) int { - n, err := pkd.Exec(ctx) - if err != nil { - panic(err) - } - return n -} - -func (pkd *PublicKeyDelete) sqlExec(ctx context.Context) (int, error) { - _spec := &sqlgraph.DeleteSpec{ - Node: &sqlgraph.NodeSpec{ - Table: publickey.Table, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: publickey.FieldID, - }, - }, - } - if ps := pkd.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - affected, err := sqlgraph.DeleteNodes(ctx, pkd.driver, _spec) - if err != nil && sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return affected, err -} - -// PublicKeyDeleteOne is the builder for deleting a single PublicKey entity. -type PublicKeyDeleteOne struct { - pkd *PublicKeyDelete -} - -// Exec executes the deletion query. -func (pkdo *PublicKeyDeleteOne) Exec(ctx context.Context) error { - n, err := pkdo.pkd.Exec(ctx) - switch { - case err != nil: - return err - case n == 0: - return &NotFoundError{publickey.Label} - default: - return nil - } -} - -// ExecX is like Exec, but panics if an error occurs. -func (pkdo *PublicKeyDeleteOne) ExecX(ctx context.Context) { - pkdo.pkd.ExecX(ctx) -} diff --git a/ent/publickey_query.go b/ent/publickey_query.go deleted file mode 100644 index e72fe697..00000000 --- a/ent/publickey_query.go +++ /dev/null @@ -1,526 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "fmt" - "math" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/fiware/vcverifier/ent/predicate" - "github.com/fiware/vcverifier/ent/publickey" -) - -// PublicKeyQuery is the builder for querying PublicKey entities. -type PublicKeyQuery struct { - config - limit *int - offset *int - unique *bool - order []OrderFunc - fields []string - predicates []predicate.PublicKey - // intermediate query (i.e. traversal path). - sql *sql.Selector - path func(context.Context) (*sql.Selector, error) -} - -// Where adds a new predicate for the PublicKeyQuery builder. -func (pkq *PublicKeyQuery) Where(ps ...predicate.PublicKey) *PublicKeyQuery { - pkq.predicates = append(pkq.predicates, ps...) - return pkq -} - -// Limit adds a limit step to the query. -func (pkq *PublicKeyQuery) Limit(limit int) *PublicKeyQuery { - pkq.limit = &limit - return pkq -} - -// Offset adds an offset step to the query. -func (pkq *PublicKeyQuery) Offset(offset int) *PublicKeyQuery { - pkq.offset = &offset - return pkq -} - -// Unique configures the query builder to filter duplicate records on query. -// By default, unique is set to true, and can be disabled using this method. -func (pkq *PublicKeyQuery) Unique(unique bool) *PublicKeyQuery { - pkq.unique = &unique - return pkq -} - -// Order adds an order step to the query. -func (pkq *PublicKeyQuery) Order(o ...OrderFunc) *PublicKeyQuery { - pkq.order = append(pkq.order, o...) - return pkq -} - -// First returns the first PublicKey entity from the query. -// Returns a *NotFoundError when no PublicKey was found. -func (pkq *PublicKeyQuery) First(ctx context.Context) (*PublicKey, error) { - nodes, err := pkq.Limit(1).All(ctx) - if err != nil { - return nil, err - } - if len(nodes) == 0 { - return nil, &NotFoundError{publickey.Label} - } - return nodes[0], nil -} - -// FirstX is like First, but panics if an error occurs. -func (pkq *PublicKeyQuery) FirstX(ctx context.Context) *PublicKey { - node, err := pkq.First(ctx) - if err != nil && !IsNotFound(err) { - panic(err) - } - return node -} - -// FirstID returns the first PublicKey ID from the query. -// Returns a *NotFoundError when no PublicKey ID was found. -func (pkq *PublicKeyQuery) FirstID(ctx context.Context) (id string, err error) { - var ids []string - if ids, err = pkq.Limit(1).IDs(ctx); err != nil { - return - } - if len(ids) == 0 { - err = &NotFoundError{publickey.Label} - return - } - return ids[0], nil -} - -// FirstIDX is like FirstID, but panics if an error occurs. -func (pkq *PublicKeyQuery) FirstIDX(ctx context.Context) string { - id, err := pkq.FirstID(ctx) - if err != nil && !IsNotFound(err) { - panic(err) - } - return id -} - -// Only returns a single PublicKey entity found by the query, ensuring it only returns one. -// Returns a *NotSingularError when more than one PublicKey entity is found. -// Returns a *NotFoundError when no PublicKey entities are found. -func (pkq *PublicKeyQuery) Only(ctx context.Context) (*PublicKey, error) { - nodes, err := pkq.Limit(2).All(ctx) - if err != nil { - return nil, err - } - switch len(nodes) { - case 1: - return nodes[0], nil - case 0: - return nil, &NotFoundError{publickey.Label} - default: - return nil, &NotSingularError{publickey.Label} - } -} - -// OnlyX is like Only, but panics if an error occurs. -func (pkq *PublicKeyQuery) OnlyX(ctx context.Context) *PublicKey { - node, err := pkq.Only(ctx) - if err != nil { - panic(err) - } - return node -} - -// OnlyID is like Only, but returns the only PublicKey ID in the query. -// Returns a *NotSingularError when more than one PublicKey ID is found. -// Returns a *NotFoundError when no entities are found. -func (pkq *PublicKeyQuery) OnlyID(ctx context.Context) (id string, err error) { - var ids []string - if ids, err = pkq.Limit(2).IDs(ctx); err != nil { - return - } - switch len(ids) { - case 1: - id = ids[0] - case 0: - err = &NotFoundError{publickey.Label} - default: - err = &NotSingularError{publickey.Label} - } - return -} - -// OnlyIDX is like OnlyID, but panics if an error occurs. -func (pkq *PublicKeyQuery) OnlyIDX(ctx context.Context) string { - id, err := pkq.OnlyID(ctx) - if err != nil { - panic(err) - } - return id -} - -// All executes the query and returns a list of PublicKeys. -func (pkq *PublicKeyQuery) All(ctx context.Context) ([]*PublicKey, error) { - if err := pkq.prepareQuery(ctx); err != nil { - return nil, err - } - return pkq.sqlAll(ctx) -} - -// AllX is like All, but panics if an error occurs. -func (pkq *PublicKeyQuery) AllX(ctx context.Context) []*PublicKey { - nodes, err := pkq.All(ctx) - if err != nil { - panic(err) - } - return nodes -} - -// IDs executes the query and returns a list of PublicKey IDs. -func (pkq *PublicKeyQuery) IDs(ctx context.Context) ([]string, error) { - var ids []string - if err := pkq.Select(publickey.FieldID).Scan(ctx, &ids); err != nil { - return nil, err - } - return ids, nil -} - -// IDsX is like IDs, but panics if an error occurs. -func (pkq *PublicKeyQuery) IDsX(ctx context.Context) []string { - ids, err := pkq.IDs(ctx) - if err != nil { - panic(err) - } - return ids -} - -// Count returns the count of the given query. -func (pkq *PublicKeyQuery) Count(ctx context.Context) (int, error) { - if err := pkq.prepareQuery(ctx); err != nil { - return 0, err - } - return pkq.sqlCount(ctx) -} - -// CountX is like Count, but panics if an error occurs. -func (pkq *PublicKeyQuery) CountX(ctx context.Context) int { - count, err := pkq.Count(ctx) - if err != nil { - panic(err) - } - return count -} - -// Exist returns true if the query has elements in the graph. -func (pkq *PublicKeyQuery) Exist(ctx context.Context) (bool, error) { - if err := pkq.prepareQuery(ctx); err != nil { - return false, err - } - return pkq.sqlExist(ctx) -} - -// ExistX is like Exist, but panics if an error occurs. -func (pkq *PublicKeyQuery) ExistX(ctx context.Context) bool { - exist, err := pkq.Exist(ctx) - if err != nil { - panic(err) - } - return exist -} - -// Clone returns a duplicate of the PublicKeyQuery builder, including all associated steps. It can be -// used to prepare common query builders and use them differently after the clone is made. -func (pkq *PublicKeyQuery) Clone() *PublicKeyQuery { - if pkq == nil { - return nil - } - return &PublicKeyQuery{ - config: pkq.config, - limit: pkq.limit, - offset: pkq.offset, - order: append([]OrderFunc{}, pkq.order...), - predicates: append([]predicate.PublicKey{}, pkq.predicates...), - // clone intermediate query. - sql: pkq.sql.Clone(), - path: pkq.path, - unique: pkq.unique, - } -} - -// GroupBy is used to group vertices by one or more fields/columns. -// It is often used with aggregate functions, like: count, max, mean, min, sum. -// -// Example: -// -// var v []struct { -// Kty string `json:"kty,omitempty"` -// Count int `json:"count,omitempty"` -// } -// -// client.PublicKey.Query(). -// GroupBy(publickey.FieldKty). -// Aggregate(ent.Count()). -// Scan(ctx, &v) -func (pkq *PublicKeyQuery) GroupBy(field string, fields ...string) *PublicKeyGroupBy { - grbuild := &PublicKeyGroupBy{config: pkq.config} - grbuild.fields = append([]string{field}, fields...) - grbuild.path = func(ctx context.Context) (prev *sql.Selector, err error) { - if err := pkq.prepareQuery(ctx); err != nil { - return nil, err - } - return pkq.sqlQuery(ctx), nil - } - grbuild.label = publickey.Label - grbuild.flds, grbuild.scan = &grbuild.fields, grbuild.Scan - return grbuild -} - -// Select allows the selection one or more fields/columns for the given query, -// instead of selecting all fields in the entity. -// -// Example: -// -// var v []struct { -// Kty string `json:"kty,omitempty"` -// } -// -// client.PublicKey.Query(). -// Select(publickey.FieldKty). -// Scan(ctx, &v) -func (pkq *PublicKeyQuery) Select(fields ...string) *PublicKeySelect { - pkq.fields = append(pkq.fields, fields...) - selbuild := &PublicKeySelect{PublicKeyQuery: pkq} - selbuild.label = publickey.Label - selbuild.flds, selbuild.scan = &pkq.fields, selbuild.Scan - return selbuild -} - -func (pkq *PublicKeyQuery) prepareQuery(ctx context.Context) error { - for _, f := range pkq.fields { - if !publickey.ValidColumn(f) { - return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} - } - } - if pkq.path != nil { - prev, err := pkq.path(ctx) - if err != nil { - return err - } - pkq.sql = prev - } - return nil -} - -func (pkq *PublicKeyQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*PublicKey, error) { - var ( - nodes = []*PublicKey{} - _spec = pkq.querySpec() - ) - _spec.ScanValues = func(columns []string) ([]interface{}, error) { - return (*PublicKey).scanValues(nil, columns) - } - _spec.Assign = func(columns []string, values []interface{}) error { - node := &PublicKey{config: pkq.config} - nodes = append(nodes, node) - return node.assignValues(columns, values) - } - for i := range hooks { - hooks[i](ctx, _spec) - } - if err := sqlgraph.QueryNodes(ctx, pkq.driver, _spec); err != nil { - return nil, err - } - if len(nodes) == 0 { - return nodes, nil - } - return nodes, nil -} - -func (pkq *PublicKeyQuery) sqlCount(ctx context.Context) (int, error) { - _spec := pkq.querySpec() - _spec.Node.Columns = pkq.fields - if len(pkq.fields) > 0 { - _spec.Unique = pkq.unique != nil && *pkq.unique - } - return sqlgraph.CountNodes(ctx, pkq.driver, _spec) -} - -func (pkq *PublicKeyQuery) sqlExist(ctx context.Context) (bool, error) { - n, err := pkq.sqlCount(ctx) - if err != nil { - return false, fmt.Errorf("ent: check existence: %w", err) - } - return n > 0, nil -} - -func (pkq *PublicKeyQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: publickey.Table, - Columns: publickey.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: publickey.FieldID, - }, - }, - From: pkq.sql, - Unique: true, - } - if unique := pkq.unique; unique != nil { - _spec.Unique = *unique - } - if fields := pkq.fields; len(fields) > 0 { - _spec.Node.Columns = make([]string, 0, len(fields)) - _spec.Node.Columns = append(_spec.Node.Columns, publickey.FieldID) - for i := range fields { - if fields[i] != publickey.FieldID { - _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) - } - } - } - if ps := pkq.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if limit := pkq.limit; limit != nil { - _spec.Limit = *limit - } - if offset := pkq.offset; offset != nil { - _spec.Offset = *offset - } - if ps := pkq.order; len(ps) > 0 { - _spec.Order = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - return _spec -} - -func (pkq *PublicKeyQuery) sqlQuery(ctx context.Context) *sql.Selector { - builder := sql.Dialect(pkq.driver.Dialect()) - t1 := builder.Table(publickey.Table) - columns := pkq.fields - if len(columns) == 0 { - columns = publickey.Columns - } - selector := builder.Select(t1.Columns(columns...)...).From(t1) - if pkq.sql != nil { - selector = pkq.sql - selector.Select(selector.Columns(columns...)...) - } - if pkq.unique != nil && *pkq.unique { - selector.Distinct() - } - for _, p := range pkq.predicates { - p(selector) - } - for _, p := range pkq.order { - p(selector) - } - if offset := pkq.offset; offset != nil { - // limit is mandatory for offset clause. We start - // with default value, and override it below if needed. - selector.Offset(*offset).Limit(math.MaxInt32) - } - if limit := pkq.limit; limit != nil { - selector.Limit(*limit) - } - return selector -} - -// PublicKeyGroupBy is the group-by builder for PublicKey entities. -type PublicKeyGroupBy struct { - config - selector - fields []string - fns []AggregateFunc - // intermediate query (i.e. traversal path). - sql *sql.Selector - path func(context.Context) (*sql.Selector, error) -} - -// Aggregate adds the given aggregation functions to the group-by query. -func (pkgb *PublicKeyGroupBy) Aggregate(fns ...AggregateFunc) *PublicKeyGroupBy { - pkgb.fns = append(pkgb.fns, fns...) - return pkgb -} - -// Scan applies the group-by query and scans the result into the given value. -func (pkgb *PublicKeyGroupBy) Scan(ctx context.Context, v interface{}) error { - query, err := pkgb.path(ctx) - if err != nil { - return err - } - pkgb.sql = query - return pkgb.sqlScan(ctx, v) -} - -func (pkgb *PublicKeyGroupBy) sqlScan(ctx context.Context, v interface{}) error { - for _, f := range pkgb.fields { - if !publickey.ValidColumn(f) { - return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)} - } - } - selector := pkgb.sqlQuery() - if err := selector.Err(); err != nil { - return err - } - rows := &sql.Rows{} - query, args := selector.Query() - if err := pkgb.driver.Query(ctx, query, args, rows); err != nil { - return err - } - defer rows.Close() - return sql.ScanSlice(rows, v) -} - -func (pkgb *PublicKeyGroupBy) sqlQuery() *sql.Selector { - selector := pkgb.sql.Select() - aggregation := make([]string, 0, len(pkgb.fns)) - for _, fn := range pkgb.fns { - aggregation = append(aggregation, fn(selector)) - } - // If no columns were selected in a custom aggregation function, the default - // selection is the fields used for "group-by", and the aggregation functions. - if len(selector.SelectedColumns()) == 0 { - columns := make([]string, 0, len(pkgb.fields)+len(pkgb.fns)) - for _, f := range pkgb.fields { - columns = append(columns, selector.C(f)) - } - columns = append(columns, aggregation...) - selector.Select(columns...) - } - return selector.GroupBy(selector.Columns(pkgb.fields...)...) -} - -// PublicKeySelect is the builder for selecting fields of PublicKey entities. -type PublicKeySelect struct { - *PublicKeyQuery - selector - // intermediate query (i.e. traversal path). - sql *sql.Selector -} - -// Scan applies the selector query and scans the result into the given value. -func (pks *PublicKeySelect) Scan(ctx context.Context, v interface{}) error { - if err := pks.prepareQuery(ctx); err != nil { - return err - } - pks.sql = pks.PublicKeyQuery.sqlQuery(ctx) - return pks.sqlScan(ctx, v) -} - -func (pks *PublicKeySelect) sqlScan(ctx context.Context, v interface{}) error { - rows := &sql.Rows{} - query, args := pks.sql.Query() - if err := pks.driver.Query(ctx, query, args, rows); err != nil { - return err - } - defer rows.Close() - return sql.ScanSlice(rows, v) -} diff --git a/ent/publickey_update.go b/ent/publickey_update.go deleted file mode 100644 index 35b0cf35..00000000 --- a/ent/publickey_update.go +++ /dev/null @@ -1,406 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - "time" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/fiware/vcverifier/ent/predicate" - "github.com/fiware/vcverifier/ent/publickey" -) - -// PublicKeyUpdate is the builder for updating PublicKey entities. -type PublicKeyUpdate struct { - config - hooks []Hook - mutation *PublicKeyMutation -} - -// Where appends a list predicates to the PublicKeyUpdate builder. -func (pku *PublicKeyUpdate) Where(ps ...predicate.PublicKey) *PublicKeyUpdate { - pku.mutation.Where(ps...) - return pku -} - -// SetKty sets the "kty" field. -func (pku *PublicKeyUpdate) SetKty(s string) *PublicKeyUpdate { - pku.mutation.SetKty(s) - return pku -} - -// SetAlg sets the "alg" field. -func (pku *PublicKeyUpdate) SetAlg(s string) *PublicKeyUpdate { - pku.mutation.SetAlg(s) - return pku -} - -// SetNillableAlg sets the "alg" field if the given value is not nil. -func (pku *PublicKeyUpdate) SetNillableAlg(s *string) *PublicKeyUpdate { - if s != nil { - pku.SetAlg(*s) - } - return pku -} - -// ClearAlg clears the value of the "alg" field. -func (pku *PublicKeyUpdate) ClearAlg() *PublicKeyUpdate { - pku.mutation.ClearAlg() - return pku -} - -// SetJwk sets the "jwk" field. -func (pku *PublicKeyUpdate) SetJwk(u []uint8) *PublicKeyUpdate { - pku.mutation.SetJwk(u) - return pku -} - -// SetUpdatedAt sets the "updated_at" field. -func (pku *PublicKeyUpdate) SetUpdatedAt(t time.Time) *PublicKeyUpdate { - pku.mutation.SetUpdatedAt(t) - return pku -} - -// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. -func (pku *PublicKeyUpdate) SetNillableUpdatedAt(t *time.Time) *PublicKeyUpdate { - if t != nil { - pku.SetUpdatedAt(*t) - } - return pku -} - -// Mutation returns the PublicKeyMutation object of the builder. -func (pku *PublicKeyUpdate) Mutation() *PublicKeyMutation { - return pku.mutation -} - -// Save executes the query and returns the number of nodes affected by the update operation. -func (pku *PublicKeyUpdate) Save(ctx context.Context) (int, error) { - var ( - err error - affected int - ) - if len(pku.hooks) == 0 { - affected, err = pku.sqlSave(ctx) - } else { - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*PublicKeyMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - pku.mutation = mutation - affected, err = pku.sqlSave(ctx) - mutation.done = true - return affected, err - }) - for i := len(pku.hooks) - 1; i >= 0; i-- { - if pku.hooks[i] == nil { - return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") - } - mut = pku.hooks[i](mut) - } - if _, err := mut.Mutate(ctx, pku.mutation); err != nil { - return 0, err - } - } - return affected, err -} - -// SaveX is like Save, but panics if an error occurs. -func (pku *PublicKeyUpdate) SaveX(ctx context.Context) int { - affected, err := pku.Save(ctx) - if err != nil { - panic(err) - } - return affected -} - -// Exec executes the query. -func (pku *PublicKeyUpdate) Exec(ctx context.Context) error { - _, err := pku.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (pku *PublicKeyUpdate) ExecX(ctx context.Context) { - if err := pku.Exec(ctx); err != nil { - panic(err) - } -} - -func (pku *PublicKeyUpdate) sqlSave(ctx context.Context) (n int, err error) { - _spec := &sqlgraph.UpdateSpec{ - Node: &sqlgraph.NodeSpec{ - Table: publickey.Table, - Columns: publickey.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: publickey.FieldID, - }, - }, - } - if ps := pku.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if value, ok := pku.mutation.Kty(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeString, - Value: value, - Column: publickey.FieldKty, - }) - } - if value, ok := pku.mutation.Alg(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeString, - Value: value, - Column: publickey.FieldAlg, - }) - } - if pku.mutation.AlgCleared() { - _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: publickey.FieldAlg, - }) - } - if value, ok := pku.mutation.Jwk(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeJSON, - Value: value, - Column: publickey.FieldJwk, - }) - } - if value, ok := pku.mutation.UpdatedAt(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeTime, - Value: value, - Column: publickey.FieldUpdatedAt, - }) - } - if n, err = sqlgraph.UpdateNodes(ctx, pku.driver, _spec); err != nil { - if _, ok := err.(*sqlgraph.NotFoundError); ok { - err = &NotFoundError{publickey.Label} - } else if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return 0, err - } - return n, nil -} - -// PublicKeyUpdateOne is the builder for updating a single PublicKey entity. -type PublicKeyUpdateOne struct { - config - fields []string - hooks []Hook - mutation *PublicKeyMutation -} - -// SetKty sets the "kty" field. -func (pkuo *PublicKeyUpdateOne) SetKty(s string) *PublicKeyUpdateOne { - pkuo.mutation.SetKty(s) - return pkuo -} - -// SetAlg sets the "alg" field. -func (pkuo *PublicKeyUpdateOne) SetAlg(s string) *PublicKeyUpdateOne { - pkuo.mutation.SetAlg(s) - return pkuo -} - -// SetNillableAlg sets the "alg" field if the given value is not nil. -func (pkuo *PublicKeyUpdateOne) SetNillableAlg(s *string) *PublicKeyUpdateOne { - if s != nil { - pkuo.SetAlg(*s) - } - return pkuo -} - -// ClearAlg clears the value of the "alg" field. -func (pkuo *PublicKeyUpdateOne) ClearAlg() *PublicKeyUpdateOne { - pkuo.mutation.ClearAlg() - return pkuo -} - -// SetJwk sets the "jwk" field. -func (pkuo *PublicKeyUpdateOne) SetJwk(u []uint8) *PublicKeyUpdateOne { - pkuo.mutation.SetJwk(u) - return pkuo -} - -// SetUpdatedAt sets the "updated_at" field. -func (pkuo *PublicKeyUpdateOne) SetUpdatedAt(t time.Time) *PublicKeyUpdateOne { - pkuo.mutation.SetUpdatedAt(t) - return pkuo -} - -// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. -func (pkuo *PublicKeyUpdateOne) SetNillableUpdatedAt(t *time.Time) *PublicKeyUpdateOne { - if t != nil { - pkuo.SetUpdatedAt(*t) - } - return pkuo -} - -// Mutation returns the PublicKeyMutation object of the builder. -func (pkuo *PublicKeyUpdateOne) Mutation() *PublicKeyMutation { - return pkuo.mutation -} - -// Select allows selecting one or more fields (columns) of the returned entity. -// The default is selecting all fields defined in the entity schema. -func (pkuo *PublicKeyUpdateOne) Select(field string, fields ...string) *PublicKeyUpdateOne { - pkuo.fields = append([]string{field}, fields...) - return pkuo -} - -// Save executes the query and returns the updated PublicKey entity. -func (pkuo *PublicKeyUpdateOne) Save(ctx context.Context) (*PublicKey, error) { - var ( - err error - node *PublicKey - ) - if len(pkuo.hooks) == 0 { - node, err = pkuo.sqlSave(ctx) - } else { - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*PublicKeyMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - pkuo.mutation = mutation - node, err = pkuo.sqlSave(ctx) - mutation.done = true - return node, err - }) - for i := len(pkuo.hooks) - 1; i >= 0; i-- { - if pkuo.hooks[i] == nil { - return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") - } - mut = pkuo.hooks[i](mut) - } - v, err := mut.Mutate(ctx, pkuo.mutation) - if err != nil { - return nil, err - } - nv, ok := v.(*PublicKey) - if !ok { - return nil, fmt.Errorf("unexpected node type %T returned from PublicKeyMutation", v) - } - node = nv - } - return node, err -} - -// SaveX is like Save, but panics if an error occurs. -func (pkuo *PublicKeyUpdateOne) SaveX(ctx context.Context) *PublicKey { - node, err := pkuo.Save(ctx) - if err != nil { - panic(err) - } - return node -} - -// Exec executes the query on the entity. -func (pkuo *PublicKeyUpdateOne) Exec(ctx context.Context) error { - _, err := pkuo.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (pkuo *PublicKeyUpdateOne) ExecX(ctx context.Context) { - if err := pkuo.Exec(ctx); err != nil { - panic(err) - } -} - -func (pkuo *PublicKeyUpdateOne) sqlSave(ctx context.Context) (_node *PublicKey, err error) { - _spec := &sqlgraph.UpdateSpec{ - Node: &sqlgraph.NodeSpec{ - Table: publickey.Table, - Columns: publickey.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: publickey.FieldID, - }, - }, - } - id, ok := pkuo.mutation.ID() - if !ok { - return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "PublicKey.id" for update`)} - } - _spec.Node.ID.Value = id - if fields := pkuo.fields; len(fields) > 0 { - _spec.Node.Columns = make([]string, 0, len(fields)) - _spec.Node.Columns = append(_spec.Node.Columns, publickey.FieldID) - for _, f := range fields { - if !publickey.ValidColumn(f) { - return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} - } - if f != publickey.FieldID { - _spec.Node.Columns = append(_spec.Node.Columns, f) - } - } - } - if ps := pkuo.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if value, ok := pkuo.mutation.Kty(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeString, - Value: value, - Column: publickey.FieldKty, - }) - } - if value, ok := pkuo.mutation.Alg(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeString, - Value: value, - Column: publickey.FieldAlg, - }) - } - if pkuo.mutation.AlgCleared() { - _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: publickey.FieldAlg, - }) - } - if value, ok := pkuo.mutation.Jwk(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeJSON, - Value: value, - Column: publickey.FieldJwk, - }) - } - if value, ok := pkuo.mutation.UpdatedAt(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeTime, - Value: value, - Column: publickey.FieldUpdatedAt, - }) - } - _node = &PublicKey{config: pkuo.config} - _spec.Assign = _node.assignValues - _spec.ScanValues = _node.scanValues - if err = sqlgraph.UpdateNode(ctx, pkuo.driver, _spec); err != nil { - if _, ok := err.(*sqlgraph.NotFoundError); ok { - err = &NotFoundError{publickey.Label} - } else if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return nil, err - } - return _node, nil -} diff --git a/ent/runtime.go b/ent/runtime.go deleted file mode 100644 index a00f733b..00000000 --- a/ent/runtime.go +++ /dev/null @@ -1,117 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "time" - - "github.com/fiware/vcverifier/ent/credential" - "github.com/fiware/vcverifier/ent/did" - "github.com/fiware/vcverifier/ent/naturalperson" - "github.com/fiware/vcverifier/ent/privatekey" - "github.com/fiware/vcverifier/ent/publickey" - "github.com/fiware/vcverifier/ent/schema" - "github.com/fiware/vcverifier/ent/user" -) - -// The init function reads all schema descriptors with runtime code -// (default values, validators, hooks and policies) and stitches it -// to their package variables. -func init() { - credentialFields := schema.Credential{}.Fields() - _ = credentialFields - // credentialDescType is the schema descriptor for type field. - credentialDescType := credentialFields[1].Descriptor() - // credential.DefaultType holds the default value on creation for the type field. - credential.DefaultType = credentialDescType.Default.(string) - // credentialDescCreatedAt is the schema descriptor for created_at field. - credentialDescCreatedAt := credentialFields[3].Descriptor() - // credential.DefaultCreatedAt holds the default value on creation for the created_at field. - credential.DefaultCreatedAt = credentialDescCreatedAt.Default.(func() time.Time) - // credentialDescUpdatedAt is the schema descriptor for updated_at field. - credentialDescUpdatedAt := credentialFields[4].Descriptor() - // credential.DefaultUpdatedAt holds the default value on creation for the updated_at field. - credential.DefaultUpdatedAt = credentialDescUpdatedAt.Default.(func() time.Time) - didFields := schema.DID{}.Fields() - _ = didFields - // didDescCreatedAt is the schema descriptor for created_at field. - didDescCreatedAt := didFields[2].Descriptor() - // did.DefaultCreatedAt holds the default value on creation for the created_at field. - did.DefaultCreatedAt = didDescCreatedAt.Default.(func() time.Time) - // didDescUpdatedAt is the schema descriptor for updated_at field. - didDescUpdatedAt := didFields[3].Descriptor() - // did.DefaultUpdatedAt holds the default value on creation for the updated_at field. - did.DefaultUpdatedAt = didDescUpdatedAt.Default.(func() time.Time) - naturalpersonFields := schema.NaturalPerson{}.Fields() - _ = naturalpersonFields - // naturalpersonDescName is the schema descriptor for name field. - naturalpersonDescName := naturalpersonFields[1].Descriptor() - // naturalperson.NameValidator is a validator for the "name" field. It is called by the builders before save. - naturalperson.NameValidator = naturalpersonDescName.Validators[0].(func(string) error) - // naturalpersonDescType is the schema descriptor for type field. - naturalpersonDescType := naturalpersonFields[3].Descriptor() - // naturalperson.TypeValidator is a validator for the "type" field. It is called by the builders before save. - naturalperson.TypeValidator = naturalpersonDescType.Validators[0].(func(string) error) - // naturalpersonDescPassword is the schema descriptor for password field. - naturalpersonDescPassword := naturalpersonFields[4].Descriptor() - // naturalperson.PasswordValidator is a validator for the "password" field. It is called by the builders before save. - naturalperson.PasswordValidator = naturalpersonDescPassword.Validators[0].(func([]byte) error) - // naturalpersonDescCreatedAt is the schema descriptor for created_at field. - naturalpersonDescCreatedAt := naturalpersonFields[5].Descriptor() - // naturalperson.DefaultCreatedAt holds the default value on creation for the created_at field. - naturalperson.DefaultCreatedAt = naturalpersonDescCreatedAt.Default.(func() time.Time) - // naturalpersonDescUpdatedAt is the schema descriptor for updated_at field. - naturalpersonDescUpdatedAt := naturalpersonFields[6].Descriptor() - // naturalperson.DefaultUpdatedAt holds the default value on creation for the updated_at field. - naturalperson.DefaultUpdatedAt = naturalpersonDescUpdatedAt.Default.(func() time.Time) - // naturalpersonDescID is the schema descriptor for id field. - naturalpersonDescID := naturalpersonFields[0].Descriptor() - // naturalperson.IDValidator is a validator for the "id" field. It is called by the builders before save. - naturalperson.IDValidator = naturalpersonDescID.Validators[0].(func(string) error) - privatekeyFields := schema.PrivateKey{}.Fields() - _ = privatekeyFields - // privatekeyDescCreatedAt is the schema descriptor for created_at field. - privatekeyDescCreatedAt := privatekeyFields[4].Descriptor() - // privatekey.DefaultCreatedAt holds the default value on creation for the created_at field. - privatekey.DefaultCreatedAt = privatekeyDescCreatedAt.Default.(func() time.Time) - // privatekeyDescUpdatedAt is the schema descriptor for updated_at field. - privatekeyDescUpdatedAt := privatekeyFields[5].Descriptor() - // privatekey.DefaultUpdatedAt holds the default value on creation for the updated_at field. - privatekey.DefaultUpdatedAt = privatekeyDescUpdatedAt.Default.(func() time.Time) - publickeyFields := schema.PublicKey{}.Fields() - _ = publickeyFields - // publickeyDescCreatedAt is the schema descriptor for created_at field. - publickeyDescCreatedAt := publickeyFields[4].Descriptor() - // publickey.DefaultCreatedAt holds the default value on creation for the created_at field. - publickey.DefaultCreatedAt = publickeyDescCreatedAt.Default.(func() time.Time) - // publickeyDescUpdatedAt is the schema descriptor for updated_at field. - publickeyDescUpdatedAt := publickeyFields[5].Descriptor() - // publickey.DefaultUpdatedAt holds the default value on creation for the updated_at field. - publickey.DefaultUpdatedAt = publickeyDescUpdatedAt.Default.(func() time.Time) - userFields := schema.User{}.Fields() - _ = userFields - // userDescName is the schema descriptor for name field. - userDescName := userFields[1].Descriptor() - // user.NameValidator is a validator for the "name" field. It is called by the builders before save. - user.NameValidator = userDescName.Validators[0].(func(string) error) - // userDescType is the schema descriptor for type field. - userDescType := userFields[3].Descriptor() - // user.TypeValidator is a validator for the "type" field. It is called by the builders before save. - user.TypeValidator = userDescType.Validators[0].(func(string) error) - // userDescPassword is the schema descriptor for password field. - userDescPassword := userFields[4].Descriptor() - // user.PasswordValidator is a validator for the "password" field. It is called by the builders before save. - user.PasswordValidator = userDescPassword.Validators[0].(func([]byte) error) - // userDescCreatedAt is the schema descriptor for created_at field. - userDescCreatedAt := userFields[5].Descriptor() - // user.DefaultCreatedAt holds the default value on creation for the created_at field. - user.DefaultCreatedAt = userDescCreatedAt.Default.(func() time.Time) - // userDescUpdatedAt is the schema descriptor for updated_at field. - userDescUpdatedAt := userFields[6].Descriptor() - // user.DefaultUpdatedAt holds the default value on creation for the updated_at field. - user.DefaultUpdatedAt = userDescUpdatedAt.Default.(func() time.Time) - // userDescID is the schema descriptor for id field. - userDescID := userFields[0].Descriptor() - // user.IDValidator is a validator for the "id" field. It is called by the builders before save. - user.IDValidator = userDescID.Validators[0].(func(string) error) -} diff --git a/ent/runtime/runtime.go b/ent/runtime/runtime.go deleted file mode 100644 index 4a8e3655..00000000 --- a/ent/runtime/runtime.go +++ /dev/null @@ -1,10 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package runtime - -// The schema-stitching logic is generated in github.com/fiware/vcverifier/ent/runtime.go - -const ( - Version = "v0.11.0" // Version of ent codegen. - Sum = "h1:4G5GKmXOpHnIbWIkY2nZvNmuXmHpKWC4SYV1bqfoyZY=" // Sum of ent codegen. -) diff --git a/ent/schema/credential.go b/ent/schema/credential.go deleted file mode 100644 index 234128a4..00000000 --- a/ent/schema/credential.go +++ /dev/null @@ -1,37 +0,0 @@ -package schema - -import ( - "time" - - "entgo.io/ent" - "entgo.io/ent/schema/edge" - "entgo.io/ent/schema/field" -) - -// Credential holds the schema definition for the Credential entity. -type Credential struct { - ent.Schema -} - -// Fields of the Credential. -func (Credential) Fields() []ent.Field { - return []ent.Field{ - field.String("id").Unique().Immutable(), - field.String("type").Default("jwt_vc"), - field.JSON("raw", []byte{}), - field.Time("created_at"). - Default(time.Now). - Immutable(), - field.Time("updated_at"). - Default(time.Now), - } -} - -// Edges of the Credential. -func (Credential) Edges() []ent.Edge { - return []ent.Edge{ - edge.From("account", User.Type). - Ref("credentials"). - Unique(), - } -} diff --git a/ent/schema/did.go b/ent/schema/did.go deleted file mode 100644 index a8788430..00000000 --- a/ent/schema/did.go +++ /dev/null @@ -1,36 +0,0 @@ -package schema - -import ( - "time" - - "entgo.io/ent" - "entgo.io/ent/schema/edge" - "entgo.io/ent/schema/field" -) - -// DID holds the schema definition for the DID entity. -type DID struct { - ent.Schema -} - -// Fields of the DIDs. -func (DID) Fields() []ent.Field { - return []ent.Field{ - field.String("id").Unique().Immutable(), - field.String("method").Optional(), - field.Time("created_at"). - Default(time.Now). - Immutable(), - field.Time("updated_at"). - Default(time.Now), - } -} - -// Edges of the DIDs. -func (DID) Edges() []ent.Edge { - return []ent.Edge{ - edge.From("user", User.Type). - Ref("dids"). - Unique(), - } -} diff --git a/ent/schema/naturalperson.go b/ent/schema/naturalperson.go deleted file mode 100644 index 7c8e8a11..00000000 --- a/ent/schema/naturalperson.go +++ /dev/null @@ -1,44 +0,0 @@ -package schema - -import ( - "time" - - "entgo.io/ent" - "entgo.io/ent/schema/edge" - "entgo.io/ent/schema/field" -) - -// NaturalPerson holds the schema definition for the NaturalPerson entity. -type NaturalPerson struct { - ent.Schema -} - -// Fields of the NaturalPerson. -func (NaturalPerson) Fields() []ent.Field { - return []ent.Field{ - field.String("id"). - NotEmpty(). - Unique(), - field.String("name"). - NotEmpty(), - field.String("displayname"). - Optional(), - field.String("type"). - NotEmpty(), - field.Bytes("password"). - NotEmpty().Sensitive(), - field.Time("created_at"). - Default(time.Now). - Immutable(), - field.Time("updated_at"). - Default(time.Now), - } -} - -// Edges of the NaturalPerson. -func (NaturalPerson) Edges() []ent.Edge { - return []ent.Edge{ - edge.To("keys", PrivateKey.Type), - edge.To("credentials", Credential.Type), - } -} diff --git a/ent/schema/privatekey.go b/ent/schema/privatekey.go deleted file mode 100644 index a2183d37..00000000 --- a/ent/schema/privatekey.go +++ /dev/null @@ -1,38 +0,0 @@ -package schema - -import ( - "time" - - "entgo.io/ent" - "entgo.io/ent/schema/edge" - "entgo.io/ent/schema/field" -) - -// PrivateKey holds the schema definition for the PrivateKey entity. -type PrivateKey struct { - ent.Schema -} - -// Fields of the PrivateKeys. -func (PrivateKey) Fields() []ent.Field { - return []ent.Field{ - field.String("id").Unique().Immutable(), - field.String("kty"), - field.String("alg").Optional(), - field.JSON("jwk", []byte{}), - field.Time("created_at"). - Default(time.Now). - Immutable(), - field.Time("updated_at"). - Default(time.Now), - } -} - -// Edges of the PrivateKeys. -func (PrivateKey) Edges() []ent.Edge { - return []ent.Edge{ - edge.From("user", User.Type). - Ref("keys"). - Unique(), - } -} diff --git a/ent/schema/publickey.go b/ent/schema/publickey.go deleted file mode 100644 index de4e51d5..00000000 --- a/ent/schema/publickey.go +++ /dev/null @@ -1,33 +0,0 @@ -package schema - -import ( - "time" - - "entgo.io/ent" - "entgo.io/ent/schema/field" -) - -// PublicKey holds the schema definition for the PublicKey entity. -type PublicKey struct { - ent.Schema -} - -// Fields of the PublicKey. -func (PublicKey) Fields() []ent.Field { - return []ent.Field{ - field.String("id").Unique().Immutable(), - field.String("kty"), - field.String("alg").Optional(), - field.JSON("jwk", []byte{}), - field.Time("created_at"). - Default(time.Now). - Immutable(), - field.Time("updated_at"). - Default(time.Now), - } -} - -// Edges of the PublicKey. -func (PublicKey) Edges() []ent.Edge { - return nil -} diff --git a/ent/schema/user.go b/ent/schema/user.go deleted file mode 100644 index d97be6a1..00000000 --- a/ent/schema/user.go +++ /dev/null @@ -1,45 +0,0 @@ -package schema - -import ( - "time" - - "entgo.io/ent" - "entgo.io/ent/schema/edge" - "entgo.io/ent/schema/field" -) - -// User holds the schema definition for the User entity. -type User struct { - ent.Schema -} - -// Fields of the User. -func (User) Fields() []ent.Field { - return []ent.Field{ - field.String("id"). - NotEmpty(). - Unique(), - field.String("name"). - NotEmpty(), - field.String("displayname"). - Optional(), - field.String("type"). - NotEmpty(), - field.Bytes("password"). - NotEmpty().Sensitive(), - field.Time("created_at"). - Default(time.Now). - Immutable(), - field.Time("updated_at"). - Default(time.Now), - } -} - -// Edges of the User. -func (User) Edges() []ent.Edge { - return []ent.Edge{ - edge.To("keys", PrivateKey.Type), - edge.To("dids", DID.Type), - edge.To("credentials", Credential.Type), - } -} diff --git a/ent/tx.go b/ent/tx.go deleted file mode 100644 index b465dbe5..00000000 --- a/ent/tx.go +++ /dev/null @@ -1,225 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "sync" - - "entgo.io/ent/dialect" -) - -// Tx is a transactional client that is created by calling Client.Tx(). -type Tx struct { - config - // Credential is the client for interacting with the Credential builders. - Credential *CredentialClient - // DID is the client for interacting with the DID builders. - DID *DIDClient - // NaturalPerson is the client for interacting with the NaturalPerson builders. - NaturalPerson *NaturalPersonClient - // PrivateKey is the client for interacting with the PrivateKey builders. - PrivateKey *PrivateKeyClient - // PublicKey is the client for interacting with the PublicKey builders. - PublicKey *PublicKeyClient - // User is the client for interacting with the User builders. - User *UserClient - - // lazily loaded. - client *Client - clientOnce sync.Once - - // completion callbacks. - mu sync.Mutex - onCommit []CommitHook - onRollback []RollbackHook - - // ctx lives for the life of the transaction. It is - // the same context used by the underlying connection. - ctx context.Context -} - -type ( - // Committer is the interface that wraps the Commit method. - Committer interface { - Commit(context.Context, *Tx) error - } - - // The CommitFunc type is an adapter to allow the use of ordinary - // function as a Committer. If f is a function with the appropriate - // signature, CommitFunc(f) is a Committer that calls f. - CommitFunc func(context.Context, *Tx) error - - // CommitHook defines the "commit middleware". A function that gets a Committer - // and returns a Committer. For example: - // - // hook := func(next ent.Committer) ent.Committer { - // return ent.CommitFunc(func(ctx context.Context, tx *ent.Tx) error { - // // Do some stuff before. - // if err := next.Commit(ctx, tx); err != nil { - // return err - // } - // // Do some stuff after. - // return nil - // }) - // } - // - CommitHook func(Committer) Committer -) - -// Commit calls f(ctx, m). -func (f CommitFunc) Commit(ctx context.Context, tx *Tx) error { - return f(ctx, tx) -} - -// Commit commits the transaction. -func (tx *Tx) Commit() error { - txDriver := tx.config.driver.(*txDriver) - var fn Committer = CommitFunc(func(context.Context, *Tx) error { - return txDriver.tx.Commit() - }) - tx.mu.Lock() - hooks := append([]CommitHook(nil), tx.onCommit...) - tx.mu.Unlock() - for i := len(hooks) - 1; i >= 0; i-- { - fn = hooks[i](fn) - } - return fn.Commit(tx.ctx, tx) -} - -// OnCommit adds a hook to call on commit. -func (tx *Tx) OnCommit(f CommitHook) { - tx.mu.Lock() - defer tx.mu.Unlock() - tx.onCommit = append(tx.onCommit, f) -} - -type ( - // Rollbacker is the interface that wraps the Rollback method. - Rollbacker interface { - Rollback(context.Context, *Tx) error - } - - // The RollbackFunc type is an adapter to allow the use of ordinary - // function as a Rollbacker. If f is a function with the appropriate - // signature, RollbackFunc(f) is a Rollbacker that calls f. - RollbackFunc func(context.Context, *Tx) error - - // RollbackHook defines the "rollback middleware". A function that gets a Rollbacker - // and returns a Rollbacker. For example: - // - // hook := func(next ent.Rollbacker) ent.Rollbacker { - // return ent.RollbackFunc(func(ctx context.Context, tx *ent.Tx) error { - // // Do some stuff before. - // if err := next.Rollback(ctx, tx); err != nil { - // return err - // } - // // Do some stuff after. - // return nil - // }) - // } - // - RollbackHook func(Rollbacker) Rollbacker -) - -// Rollback calls f(ctx, m). -func (f RollbackFunc) Rollback(ctx context.Context, tx *Tx) error { - return f(ctx, tx) -} - -// Rollback rollbacks the transaction. -func (tx *Tx) Rollback() error { - txDriver := tx.config.driver.(*txDriver) - var fn Rollbacker = RollbackFunc(func(context.Context, *Tx) error { - return txDriver.tx.Rollback() - }) - tx.mu.Lock() - hooks := append([]RollbackHook(nil), tx.onRollback...) - tx.mu.Unlock() - for i := len(hooks) - 1; i >= 0; i-- { - fn = hooks[i](fn) - } - return fn.Rollback(tx.ctx, tx) -} - -// OnRollback adds a hook to call on rollback. -func (tx *Tx) OnRollback(f RollbackHook) { - tx.mu.Lock() - defer tx.mu.Unlock() - tx.onRollback = append(tx.onRollback, f) -} - -// Client returns a Client that binds to current transaction. -func (tx *Tx) Client() *Client { - tx.clientOnce.Do(func() { - tx.client = &Client{config: tx.config} - tx.client.init() - }) - return tx.client -} - -func (tx *Tx) init() { - tx.Credential = NewCredentialClient(tx.config) - tx.DID = NewDIDClient(tx.config) - tx.NaturalPerson = NewNaturalPersonClient(tx.config) - tx.PrivateKey = NewPrivateKeyClient(tx.config) - tx.PublicKey = NewPublicKeyClient(tx.config) - tx.User = NewUserClient(tx.config) -} - -// txDriver wraps the given dialect.Tx with a nop dialect.Driver implementation. -// The idea is to support transactions without adding any extra code to the builders. -// When a builder calls to driver.Tx(), it gets the same dialect.Tx instance. -// Commit and Rollback are nop for the internal builders and the user must call one -// of them in order to commit or rollback the transaction. -// -// If a closed transaction is embedded in one of the generated entities, and the entity -// applies a query, for example: Credential.QueryXXX(), the query will be executed -// through the driver which created this transaction. -// -// Note that txDriver is not goroutine safe. -type txDriver struct { - // the driver we started the transaction from. - drv dialect.Driver - // tx is the underlying transaction. - tx dialect.Tx -} - -// newTx creates a new transactional driver. -func newTx(ctx context.Context, drv dialect.Driver) (*txDriver, error) { - tx, err := drv.Tx(ctx) - if err != nil { - return nil, err - } - return &txDriver{tx: tx, drv: drv}, nil -} - -// Tx returns the transaction wrapper (txDriver) to avoid Commit or Rollback calls -// from the internal builders. Should be called only by the internal builders. -func (tx *txDriver) Tx(context.Context) (dialect.Tx, error) { return tx, nil } - -// Dialect returns the dialect of the driver we started the transaction from. -func (tx *txDriver) Dialect() string { return tx.drv.Dialect() } - -// Close is a nop close. -func (*txDriver) Close() error { return nil } - -// Commit is a nop commit for the internal builders. -// User must call `Tx.Commit` in order to commit the transaction. -func (*txDriver) Commit() error { return nil } - -// Rollback is a nop rollback for the internal builders. -// User must call `Tx.Rollback` in order to rollback the transaction. -func (*txDriver) Rollback() error { return nil } - -// Exec calls tx.Exec. -func (tx *txDriver) Exec(ctx context.Context, query string, args, v interface{}) error { - return tx.tx.Exec(ctx, query, args, v) -} - -// Query calls tx.Query. -func (tx *txDriver) Query(ctx context.Context, query string, args, v interface{}) error { - return tx.tx.Query(ctx, query, args, v) -} - -var _ dialect.Driver = (*txDriver)(nil) diff --git a/ent/user.go b/ent/user.go deleted file mode 100644 index 6e91e56e..00000000 --- a/ent/user.go +++ /dev/null @@ -1,214 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "fmt" - "strings" - "time" - - "entgo.io/ent/dialect/sql" - "github.com/fiware/vcverifier/ent/user" -) - -// User is the model entity for the User schema. -type User struct { - config `json:"-"` - // ID of the ent. - ID string `json:"id,omitempty"` - // Name holds the value of the "name" field. - Name string `json:"name,omitempty"` - // Displayname holds the value of the "displayname" field. - Displayname string `json:"displayname,omitempty"` - // Type holds the value of the "type" field. - Type string `json:"type,omitempty"` - // Password holds the value of the "password" field. - Password []byte `json:"-"` - // CreatedAt holds the value of the "created_at" field. - CreatedAt time.Time `json:"created_at,omitempty"` - // UpdatedAt holds the value of the "updated_at" field. - UpdatedAt time.Time `json:"updated_at,omitempty"` - // Edges holds the relations/edges for other nodes in the graph. - // The values are being populated by the UserQuery when eager-loading is set. - Edges UserEdges `json:"edges"` -} - -// UserEdges holds the relations/edges for other nodes in the graph. -type UserEdges struct { - // Keys holds the value of the keys edge. - Keys []*PrivateKey `json:"keys,omitempty"` - // Dids holds the value of the dids edge. - Dids []*DID `json:"dids,omitempty"` - // Credentials holds the value of the credentials edge. - Credentials []*Credential `json:"credentials,omitempty"` - // loadedTypes holds the information for reporting if a - // type was loaded (or requested) in eager-loading or not. - loadedTypes [3]bool -} - -// KeysOrErr returns the Keys value or an error if the edge -// was not loaded in eager-loading. -func (e UserEdges) KeysOrErr() ([]*PrivateKey, error) { - if e.loadedTypes[0] { - return e.Keys, nil - } - return nil, &NotLoadedError{edge: "keys"} -} - -// DidsOrErr returns the Dids value or an error if the edge -// was not loaded in eager-loading. -func (e UserEdges) DidsOrErr() ([]*DID, error) { - if e.loadedTypes[1] { - return e.Dids, nil - } - return nil, &NotLoadedError{edge: "dids"} -} - -// CredentialsOrErr returns the Credentials value or an error if the edge -// was not loaded in eager-loading. -func (e UserEdges) CredentialsOrErr() ([]*Credential, error) { - if e.loadedTypes[2] { - return e.Credentials, nil - } - return nil, &NotLoadedError{edge: "credentials"} -} - -// scanValues returns the types for scanning values from sql.Rows. -func (*User) scanValues(columns []string) ([]interface{}, error) { - values := make([]interface{}, len(columns)) - for i := range columns { - switch columns[i] { - case user.FieldPassword: - values[i] = new([]byte) - case user.FieldID, user.FieldName, user.FieldDisplayname, user.FieldType: - values[i] = new(sql.NullString) - case user.FieldCreatedAt, user.FieldUpdatedAt: - values[i] = new(sql.NullTime) - default: - return nil, fmt.Errorf("unexpected column %q for type User", columns[i]) - } - } - return values, nil -} - -// assignValues assigns the values that were returned from sql.Rows (after scanning) -// to the User fields. -func (u *User) assignValues(columns []string, values []interface{}) error { - if m, n := len(values), len(columns); m < n { - return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) - } - for i := range columns { - switch columns[i] { - case user.FieldID: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field id", values[i]) - } else if value.Valid { - u.ID = value.String - } - case user.FieldName: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field name", values[i]) - } else if value.Valid { - u.Name = value.String - } - case user.FieldDisplayname: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field displayname", values[i]) - } else if value.Valid { - u.Displayname = value.String - } - case user.FieldType: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field type", values[i]) - } else if value.Valid { - u.Type = value.String - } - case user.FieldPassword: - if value, ok := values[i].(*[]byte); !ok { - return fmt.Errorf("unexpected type %T for field password", values[i]) - } else if value != nil { - u.Password = *value - } - case user.FieldCreatedAt: - if value, ok := values[i].(*sql.NullTime); !ok { - return fmt.Errorf("unexpected type %T for field created_at", values[i]) - } else if value.Valid { - u.CreatedAt = value.Time - } - case user.FieldUpdatedAt: - if value, ok := values[i].(*sql.NullTime); !ok { - return fmt.Errorf("unexpected type %T for field updated_at", values[i]) - } else if value.Valid { - u.UpdatedAt = value.Time - } - } - } - return nil -} - -// QueryKeys queries the "keys" edge of the User entity. -func (u *User) QueryKeys() *PrivateKeyQuery { - return (&UserClient{config: u.config}).QueryKeys(u) -} - -// QueryDids queries the "dids" edge of the User entity. -func (u *User) QueryDids() *DIDQuery { - return (&UserClient{config: u.config}).QueryDids(u) -} - -// QueryCredentials queries the "credentials" edge of the User entity. -func (u *User) QueryCredentials() *CredentialQuery { - return (&UserClient{config: u.config}).QueryCredentials(u) -} - -// Update returns a builder for updating this User. -// Note that you need to call User.Unwrap() before calling this method if this User -// was returned from a transaction, and the transaction was committed or rolled back. -func (u *User) Update() *UserUpdateOne { - return (&UserClient{config: u.config}).UpdateOne(u) -} - -// Unwrap unwraps the User entity that was returned from a transaction after it was closed, -// so that all future queries will be executed through the driver which created the transaction. -func (u *User) Unwrap() *User { - _tx, ok := u.config.driver.(*txDriver) - if !ok { - panic("ent: User is not a transactional entity") - } - u.config.driver = _tx.drv - return u -} - -// String implements the fmt.Stringer. -func (u *User) String() string { - var builder strings.Builder - builder.WriteString("User(") - builder.WriteString(fmt.Sprintf("id=%v, ", u.ID)) - builder.WriteString("name=") - builder.WriteString(u.Name) - builder.WriteString(", ") - builder.WriteString("displayname=") - builder.WriteString(u.Displayname) - builder.WriteString(", ") - builder.WriteString("type=") - builder.WriteString(u.Type) - builder.WriteString(", ") - builder.WriteString("password=") - builder.WriteString(", ") - builder.WriteString("created_at=") - builder.WriteString(u.CreatedAt.Format(time.ANSIC)) - builder.WriteString(", ") - builder.WriteString("updated_at=") - builder.WriteString(u.UpdatedAt.Format(time.ANSIC)) - builder.WriteByte(')') - return builder.String() -} - -// Users is a parsable slice of User. -type Users []*User - -func (u Users) config(cfg config) { - for _i := range u { - u[_i].config = cfg - } -} diff --git a/ent/user/user.go b/ent/user/user.go deleted file mode 100644 index 6e28f3a6..00000000 --- a/ent/user/user.go +++ /dev/null @@ -1,91 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package user - -import ( - "time" -) - -const ( - // Label holds the string label denoting the user type in the database. - Label = "user" - // FieldID holds the string denoting the id field in the database. - FieldID = "id" - // FieldName holds the string denoting the name field in the database. - FieldName = "name" - // FieldDisplayname holds the string denoting the displayname field in the database. - FieldDisplayname = "displayname" - // FieldType holds the string denoting the type field in the database. - FieldType = "type" - // FieldPassword holds the string denoting the password field in the database. - FieldPassword = "password" - // FieldCreatedAt holds the string denoting the created_at field in the database. - FieldCreatedAt = "created_at" - // FieldUpdatedAt holds the string denoting the updated_at field in the database. - FieldUpdatedAt = "updated_at" - // EdgeKeys holds the string denoting the keys edge name in mutations. - EdgeKeys = "keys" - // EdgeDids holds the string denoting the dids edge name in mutations. - EdgeDids = "dids" - // EdgeCredentials holds the string denoting the credentials edge name in mutations. - EdgeCredentials = "credentials" - // Table holds the table name of the user in the database. - Table = "users" - // KeysTable is the table that holds the keys relation/edge. - KeysTable = "private_keys" - // KeysInverseTable is the table name for the PrivateKey entity. - // It exists in this package in order to avoid circular dependency with the "privatekey" package. - KeysInverseTable = "private_keys" - // KeysColumn is the table column denoting the keys relation/edge. - KeysColumn = "user_keys" - // DidsTable is the table that holds the dids relation/edge. - DidsTable = "di_ds" - // DidsInverseTable is the table name for the DID entity. - // It exists in this package in order to avoid circular dependency with the "did" package. - DidsInverseTable = "di_ds" - // DidsColumn is the table column denoting the dids relation/edge. - DidsColumn = "user_dids" - // CredentialsTable is the table that holds the credentials relation/edge. - CredentialsTable = "credentials" - // CredentialsInverseTable is the table name for the Credential entity. - // It exists in this package in order to avoid circular dependency with the "credential" package. - CredentialsInverseTable = "credentials" - // CredentialsColumn is the table column denoting the credentials relation/edge. - CredentialsColumn = "user_credentials" -) - -// Columns holds all SQL columns for user fields. -var Columns = []string{ - FieldID, - FieldName, - FieldDisplayname, - FieldType, - FieldPassword, - FieldCreatedAt, - FieldUpdatedAt, -} - -// ValidColumn reports if the column name is valid (part of the table columns). -func ValidColumn(column string) bool { - for i := range Columns { - if column == Columns[i] { - return true - } - } - return false -} - -var ( - // NameValidator is a validator for the "name" field. It is called by the builders before save. - NameValidator func(string) error - // TypeValidator is a validator for the "type" field. It is called by the builders before save. - TypeValidator func(string) error - // PasswordValidator is a validator for the "password" field. It is called by the builders before save. - PasswordValidator func([]byte) error - // DefaultCreatedAt holds the default value on creation for the "created_at" field. - DefaultCreatedAt func() time.Time - // DefaultUpdatedAt holds the default value on creation for the "updated_at" field. - DefaultUpdatedAt func() time.Time - // IDValidator is a validator for the "id" field. It is called by the builders before save. - IDValidator func(string) error -) diff --git a/ent/user/where.go b/ent/user/where.go deleted file mode 100644 index ef5da4e2..00000000 --- a/ent/user/where.go +++ /dev/null @@ -1,815 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package user - -import ( - "time" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "github.com/fiware/vcverifier/ent/predicate" -) - -// ID filters vertices based on their ID field. -func ID(id string) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldID), id)) - }) -} - -// IDEQ applies the EQ predicate on the ID field. -func IDEQ(id string) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldID), id)) - }) -} - -// IDNEQ applies the NEQ predicate on the ID field. -func IDNEQ(id string) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldID), id)) - }) -} - -// IDIn applies the In predicate on the ID field. -func IDIn(ids ...string) predicate.User { - return predicate.User(func(s *sql.Selector) { - v := make([]interface{}, len(ids)) - for i := range v { - v[i] = ids[i] - } - s.Where(sql.In(s.C(FieldID), v...)) - }) -} - -// IDNotIn applies the NotIn predicate on the ID field. -func IDNotIn(ids ...string) predicate.User { - return predicate.User(func(s *sql.Selector) { - v := make([]interface{}, len(ids)) - for i := range v { - v[i] = ids[i] - } - s.Where(sql.NotIn(s.C(FieldID), v...)) - }) -} - -// IDGT applies the GT predicate on the ID field. -func IDGT(id string) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldID), id)) - }) -} - -// IDGTE applies the GTE predicate on the ID field. -func IDGTE(id string) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldID), id)) - }) -} - -// IDLT applies the LT predicate on the ID field. -func IDLT(id string) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldID), id)) - }) -} - -// IDLTE applies the LTE predicate on the ID field. -func IDLTE(id string) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldID), id)) - }) -} - -// Name applies equality check predicate on the "name" field. It's identical to NameEQ. -func Name(v string) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldName), v)) - }) -} - -// Displayname applies equality check predicate on the "displayname" field. It's identical to DisplaynameEQ. -func Displayname(v string) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldDisplayname), v)) - }) -} - -// Type applies equality check predicate on the "type" field. It's identical to TypeEQ. -func Type(v string) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldType), v)) - }) -} - -// Password applies equality check predicate on the "password" field. It's identical to PasswordEQ. -func Password(v []byte) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldPassword), v)) - }) -} - -// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. -func CreatedAt(v time.Time) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldCreatedAt), v)) - }) -} - -// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ. -func UpdatedAt(v time.Time) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldUpdatedAt), v)) - }) -} - -// NameEQ applies the EQ predicate on the "name" field. -func NameEQ(v string) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldName), v)) - }) -} - -// NameNEQ applies the NEQ predicate on the "name" field. -func NameNEQ(v string) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldName), v)) - }) -} - -// NameIn applies the In predicate on the "name" field. -func NameIn(vs ...string) predicate.User { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.User(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldName), v...)) - }) -} - -// NameNotIn applies the NotIn predicate on the "name" field. -func NameNotIn(vs ...string) predicate.User { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.User(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldName), v...)) - }) -} - -// NameGT applies the GT predicate on the "name" field. -func NameGT(v string) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldName), v)) - }) -} - -// NameGTE applies the GTE predicate on the "name" field. -func NameGTE(v string) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldName), v)) - }) -} - -// NameLT applies the LT predicate on the "name" field. -func NameLT(v string) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldName), v)) - }) -} - -// NameLTE applies the LTE predicate on the "name" field. -func NameLTE(v string) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldName), v)) - }) -} - -// NameContains applies the Contains predicate on the "name" field. -func NameContains(v string) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.Contains(s.C(FieldName), v)) - }) -} - -// NameHasPrefix applies the HasPrefix predicate on the "name" field. -func NameHasPrefix(v string) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.HasPrefix(s.C(FieldName), v)) - }) -} - -// NameHasSuffix applies the HasSuffix predicate on the "name" field. -func NameHasSuffix(v string) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.HasSuffix(s.C(FieldName), v)) - }) -} - -// NameEqualFold applies the EqualFold predicate on the "name" field. -func NameEqualFold(v string) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.EqualFold(s.C(FieldName), v)) - }) -} - -// NameContainsFold applies the ContainsFold predicate on the "name" field. -func NameContainsFold(v string) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.ContainsFold(s.C(FieldName), v)) - }) -} - -// DisplaynameEQ applies the EQ predicate on the "displayname" field. -func DisplaynameEQ(v string) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldDisplayname), v)) - }) -} - -// DisplaynameNEQ applies the NEQ predicate on the "displayname" field. -func DisplaynameNEQ(v string) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldDisplayname), v)) - }) -} - -// DisplaynameIn applies the In predicate on the "displayname" field. -func DisplaynameIn(vs ...string) predicate.User { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.User(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldDisplayname), v...)) - }) -} - -// DisplaynameNotIn applies the NotIn predicate on the "displayname" field. -func DisplaynameNotIn(vs ...string) predicate.User { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.User(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldDisplayname), v...)) - }) -} - -// DisplaynameGT applies the GT predicate on the "displayname" field. -func DisplaynameGT(v string) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldDisplayname), v)) - }) -} - -// DisplaynameGTE applies the GTE predicate on the "displayname" field. -func DisplaynameGTE(v string) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldDisplayname), v)) - }) -} - -// DisplaynameLT applies the LT predicate on the "displayname" field. -func DisplaynameLT(v string) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldDisplayname), v)) - }) -} - -// DisplaynameLTE applies the LTE predicate on the "displayname" field. -func DisplaynameLTE(v string) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldDisplayname), v)) - }) -} - -// DisplaynameContains applies the Contains predicate on the "displayname" field. -func DisplaynameContains(v string) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.Contains(s.C(FieldDisplayname), v)) - }) -} - -// DisplaynameHasPrefix applies the HasPrefix predicate on the "displayname" field. -func DisplaynameHasPrefix(v string) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.HasPrefix(s.C(FieldDisplayname), v)) - }) -} - -// DisplaynameHasSuffix applies the HasSuffix predicate on the "displayname" field. -func DisplaynameHasSuffix(v string) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.HasSuffix(s.C(FieldDisplayname), v)) - }) -} - -// DisplaynameIsNil applies the IsNil predicate on the "displayname" field. -func DisplaynameIsNil() predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.IsNull(s.C(FieldDisplayname))) - }) -} - -// DisplaynameNotNil applies the NotNil predicate on the "displayname" field. -func DisplaynameNotNil() predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.NotNull(s.C(FieldDisplayname))) - }) -} - -// DisplaynameEqualFold applies the EqualFold predicate on the "displayname" field. -func DisplaynameEqualFold(v string) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.EqualFold(s.C(FieldDisplayname), v)) - }) -} - -// DisplaynameContainsFold applies the ContainsFold predicate on the "displayname" field. -func DisplaynameContainsFold(v string) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.ContainsFold(s.C(FieldDisplayname), v)) - }) -} - -// TypeEQ applies the EQ predicate on the "type" field. -func TypeEQ(v string) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldType), v)) - }) -} - -// TypeNEQ applies the NEQ predicate on the "type" field. -func TypeNEQ(v string) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldType), v)) - }) -} - -// TypeIn applies the In predicate on the "type" field. -func TypeIn(vs ...string) predicate.User { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.User(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldType), v...)) - }) -} - -// TypeNotIn applies the NotIn predicate on the "type" field. -func TypeNotIn(vs ...string) predicate.User { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.User(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldType), v...)) - }) -} - -// TypeGT applies the GT predicate on the "type" field. -func TypeGT(v string) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldType), v)) - }) -} - -// TypeGTE applies the GTE predicate on the "type" field. -func TypeGTE(v string) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldType), v)) - }) -} - -// TypeLT applies the LT predicate on the "type" field. -func TypeLT(v string) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldType), v)) - }) -} - -// TypeLTE applies the LTE predicate on the "type" field. -func TypeLTE(v string) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldType), v)) - }) -} - -// TypeContains applies the Contains predicate on the "type" field. -func TypeContains(v string) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.Contains(s.C(FieldType), v)) - }) -} - -// TypeHasPrefix applies the HasPrefix predicate on the "type" field. -func TypeHasPrefix(v string) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.HasPrefix(s.C(FieldType), v)) - }) -} - -// TypeHasSuffix applies the HasSuffix predicate on the "type" field. -func TypeHasSuffix(v string) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.HasSuffix(s.C(FieldType), v)) - }) -} - -// TypeEqualFold applies the EqualFold predicate on the "type" field. -func TypeEqualFold(v string) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.EqualFold(s.C(FieldType), v)) - }) -} - -// TypeContainsFold applies the ContainsFold predicate on the "type" field. -func TypeContainsFold(v string) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.ContainsFold(s.C(FieldType), v)) - }) -} - -// PasswordEQ applies the EQ predicate on the "password" field. -func PasswordEQ(v []byte) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldPassword), v)) - }) -} - -// PasswordNEQ applies the NEQ predicate on the "password" field. -func PasswordNEQ(v []byte) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldPassword), v)) - }) -} - -// PasswordIn applies the In predicate on the "password" field. -func PasswordIn(vs ...[]byte) predicate.User { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.User(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldPassword), v...)) - }) -} - -// PasswordNotIn applies the NotIn predicate on the "password" field. -func PasswordNotIn(vs ...[]byte) predicate.User { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.User(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldPassword), v...)) - }) -} - -// PasswordGT applies the GT predicate on the "password" field. -func PasswordGT(v []byte) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldPassword), v)) - }) -} - -// PasswordGTE applies the GTE predicate on the "password" field. -func PasswordGTE(v []byte) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldPassword), v)) - }) -} - -// PasswordLT applies the LT predicate on the "password" field. -func PasswordLT(v []byte) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldPassword), v)) - }) -} - -// PasswordLTE applies the LTE predicate on the "password" field. -func PasswordLTE(v []byte) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldPassword), v)) - }) -} - -// CreatedAtEQ applies the EQ predicate on the "created_at" field. -func CreatedAtEQ(v time.Time) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldCreatedAt), v)) - }) -} - -// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. -func CreatedAtNEQ(v time.Time) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldCreatedAt), v)) - }) -} - -// CreatedAtIn applies the In predicate on the "created_at" field. -func CreatedAtIn(vs ...time.Time) predicate.User { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.User(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldCreatedAt), v...)) - }) -} - -// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. -func CreatedAtNotIn(vs ...time.Time) predicate.User { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.User(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldCreatedAt), v...)) - }) -} - -// CreatedAtGT applies the GT predicate on the "created_at" field. -func CreatedAtGT(v time.Time) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldCreatedAt), v)) - }) -} - -// CreatedAtGTE applies the GTE predicate on the "created_at" field. -func CreatedAtGTE(v time.Time) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldCreatedAt), v)) - }) -} - -// CreatedAtLT applies the LT predicate on the "created_at" field. -func CreatedAtLT(v time.Time) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldCreatedAt), v)) - }) -} - -// CreatedAtLTE applies the LTE predicate on the "created_at" field. -func CreatedAtLTE(v time.Time) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldCreatedAt), v)) - }) -} - -// UpdatedAtEQ applies the EQ predicate on the "updated_at" field. -func UpdatedAtEQ(v time.Time) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldUpdatedAt), v)) - }) -} - -// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field. -func UpdatedAtNEQ(v time.Time) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldUpdatedAt), v)) - }) -} - -// UpdatedAtIn applies the In predicate on the "updated_at" field. -func UpdatedAtIn(vs ...time.Time) predicate.User { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.User(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.In(s.C(FieldUpdatedAt), v...)) - }) -} - -// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field. -func UpdatedAtNotIn(vs ...time.Time) predicate.User { - v := make([]interface{}, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.User(func(s *sql.Selector) { - // if not arguments were provided, append the FALSE constants, - // since we can't apply "IN ()". This will make this predicate falsy. - if len(v) == 0 { - s.Where(sql.False()) - return - } - s.Where(sql.NotIn(s.C(FieldUpdatedAt), v...)) - }) -} - -// UpdatedAtGT applies the GT predicate on the "updated_at" field. -func UpdatedAtGT(v time.Time) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldUpdatedAt), v)) - }) -} - -// UpdatedAtGTE applies the GTE predicate on the "updated_at" field. -func UpdatedAtGTE(v time.Time) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldUpdatedAt), v)) - }) -} - -// UpdatedAtLT applies the LT predicate on the "updated_at" field. -func UpdatedAtLT(v time.Time) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldUpdatedAt), v)) - }) -} - -// UpdatedAtLTE applies the LTE predicate on the "updated_at" field. -func UpdatedAtLTE(v time.Time) predicate.User { - return predicate.User(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldUpdatedAt), v)) - }) -} - -// HasKeys applies the HasEdge predicate on the "keys" edge. -func HasKeys() predicate.User { - return predicate.User(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(KeysTable, FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, KeysTable, KeysColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasKeysWith applies the HasEdge predicate on the "keys" edge with a given conditions (other predicates). -func HasKeysWith(preds ...predicate.PrivateKey) predicate.User { - return predicate.User(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(KeysInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, KeysTable, KeysColumn), - ) - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// HasDids applies the HasEdge predicate on the "dids" edge. -func HasDids() predicate.User { - return predicate.User(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(DidsTable, FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, DidsTable, DidsColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasDidsWith applies the HasEdge predicate on the "dids" edge with a given conditions (other predicates). -func HasDidsWith(preds ...predicate.DID) predicate.User { - return predicate.User(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(DidsInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, DidsTable, DidsColumn), - ) - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// HasCredentials applies the HasEdge predicate on the "credentials" edge. -func HasCredentials() predicate.User { - return predicate.User(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(CredentialsTable, FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, CredentialsTable, CredentialsColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasCredentialsWith applies the HasEdge predicate on the "credentials" edge with a given conditions (other predicates). -func HasCredentialsWith(preds ...predicate.Credential) predicate.User { - return predicate.User(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(CredentialsInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, CredentialsTable, CredentialsColumn), - ) - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// And groups predicates with the AND operator between them. -func And(predicates ...predicate.User) predicate.User { - return predicate.User(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) -} - -// Or groups predicates with the OR operator between them. -func Or(predicates ...predicate.User) predicate.User { - return predicate.User(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) -} - -// Not applies the not operator on the given predicate. -func Not(p predicate.User) predicate.User { - return predicate.User(func(s *sql.Selector) { - p(s.Not()) - }) -} diff --git a/ent/user_create.go b/ent/user_create.go deleted file mode 100644 index 0c78babb..00000000 --- a/ent/user_create.go +++ /dev/null @@ -1,483 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - "time" - - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/fiware/vcverifier/ent/credential" - "github.com/fiware/vcverifier/ent/did" - "github.com/fiware/vcverifier/ent/privatekey" - "github.com/fiware/vcverifier/ent/user" -) - -// UserCreate is the builder for creating a User entity. -type UserCreate struct { - config - mutation *UserMutation - hooks []Hook -} - -// SetName sets the "name" field. -func (uc *UserCreate) SetName(s string) *UserCreate { - uc.mutation.SetName(s) - return uc -} - -// SetDisplayname sets the "displayname" field. -func (uc *UserCreate) SetDisplayname(s string) *UserCreate { - uc.mutation.SetDisplayname(s) - return uc -} - -// SetNillableDisplayname sets the "displayname" field if the given value is not nil. -func (uc *UserCreate) SetNillableDisplayname(s *string) *UserCreate { - if s != nil { - uc.SetDisplayname(*s) - } - return uc -} - -// SetType sets the "type" field. -func (uc *UserCreate) SetType(s string) *UserCreate { - uc.mutation.SetType(s) - return uc -} - -// SetPassword sets the "password" field. -func (uc *UserCreate) SetPassword(b []byte) *UserCreate { - uc.mutation.SetPassword(b) - return uc -} - -// SetCreatedAt sets the "created_at" field. -func (uc *UserCreate) SetCreatedAt(t time.Time) *UserCreate { - uc.mutation.SetCreatedAt(t) - return uc -} - -// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. -func (uc *UserCreate) SetNillableCreatedAt(t *time.Time) *UserCreate { - if t != nil { - uc.SetCreatedAt(*t) - } - return uc -} - -// SetUpdatedAt sets the "updated_at" field. -func (uc *UserCreate) SetUpdatedAt(t time.Time) *UserCreate { - uc.mutation.SetUpdatedAt(t) - return uc -} - -// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. -func (uc *UserCreate) SetNillableUpdatedAt(t *time.Time) *UserCreate { - if t != nil { - uc.SetUpdatedAt(*t) - } - return uc -} - -// SetID sets the "id" field. -func (uc *UserCreate) SetID(s string) *UserCreate { - uc.mutation.SetID(s) - return uc -} - -// AddKeyIDs adds the "keys" edge to the PrivateKey entity by IDs. -func (uc *UserCreate) AddKeyIDs(ids ...string) *UserCreate { - uc.mutation.AddKeyIDs(ids...) - return uc -} - -// AddKeys adds the "keys" edges to the PrivateKey entity. -func (uc *UserCreate) AddKeys(p ...*PrivateKey) *UserCreate { - ids := make([]string, len(p)) - for i := range p { - ids[i] = p[i].ID - } - return uc.AddKeyIDs(ids...) -} - -// AddDidIDs adds the "dids" edge to the DID entity by IDs. -func (uc *UserCreate) AddDidIDs(ids ...string) *UserCreate { - uc.mutation.AddDidIDs(ids...) - return uc -} - -// AddDids adds the "dids" edges to the DID entity. -func (uc *UserCreate) AddDids(d ...*DID) *UserCreate { - ids := make([]string, len(d)) - for i := range d { - ids[i] = d[i].ID - } - return uc.AddDidIDs(ids...) -} - -// AddCredentialIDs adds the "credentials" edge to the Credential entity by IDs. -func (uc *UserCreate) AddCredentialIDs(ids ...string) *UserCreate { - uc.mutation.AddCredentialIDs(ids...) - return uc -} - -// AddCredentials adds the "credentials" edges to the Credential entity. -func (uc *UserCreate) AddCredentials(c ...*Credential) *UserCreate { - ids := make([]string, len(c)) - for i := range c { - ids[i] = c[i].ID - } - return uc.AddCredentialIDs(ids...) -} - -// Mutation returns the UserMutation object of the builder. -func (uc *UserCreate) Mutation() *UserMutation { - return uc.mutation -} - -// Save creates the User in the database. -func (uc *UserCreate) Save(ctx context.Context) (*User, error) { - var ( - err error - node *User - ) - uc.defaults() - if len(uc.hooks) == 0 { - if err = uc.check(); err != nil { - return nil, err - } - node, err = uc.sqlSave(ctx) - } else { - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*UserMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - if err = uc.check(); err != nil { - return nil, err - } - uc.mutation = mutation - if node, err = uc.sqlSave(ctx); err != nil { - return nil, err - } - mutation.id = &node.ID - mutation.done = true - return node, err - }) - for i := len(uc.hooks) - 1; i >= 0; i-- { - if uc.hooks[i] == nil { - return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") - } - mut = uc.hooks[i](mut) - } - v, err := mut.Mutate(ctx, uc.mutation) - if err != nil { - return nil, err - } - nv, ok := v.(*User) - if !ok { - return nil, fmt.Errorf("unexpected node type %T returned from UserMutation", v) - } - node = nv - } - return node, err -} - -// SaveX calls Save and panics if Save returns an error. -func (uc *UserCreate) SaveX(ctx context.Context) *User { - v, err := uc.Save(ctx) - if err != nil { - panic(err) - } - return v -} - -// Exec executes the query. -func (uc *UserCreate) Exec(ctx context.Context) error { - _, err := uc.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (uc *UserCreate) ExecX(ctx context.Context) { - if err := uc.Exec(ctx); err != nil { - panic(err) - } -} - -// defaults sets the default values of the builder before save. -func (uc *UserCreate) defaults() { - if _, ok := uc.mutation.CreatedAt(); !ok { - v := user.DefaultCreatedAt() - uc.mutation.SetCreatedAt(v) - } - if _, ok := uc.mutation.UpdatedAt(); !ok { - v := user.DefaultUpdatedAt() - uc.mutation.SetUpdatedAt(v) - } -} - -// check runs all checks and user-defined validators on the builder. -func (uc *UserCreate) check() error { - if _, ok := uc.mutation.Name(); !ok { - return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "User.name"`)} - } - if v, ok := uc.mutation.Name(); ok { - if err := user.NameValidator(v); err != nil { - return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "User.name": %w`, err)} - } - } - if _, ok := uc.mutation.GetType(); !ok { - return &ValidationError{Name: "type", err: errors.New(`ent: missing required field "User.type"`)} - } - if v, ok := uc.mutation.GetType(); ok { - if err := user.TypeValidator(v); err != nil { - return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "User.type": %w`, err)} - } - } - if _, ok := uc.mutation.Password(); !ok { - return &ValidationError{Name: "password", err: errors.New(`ent: missing required field "User.password"`)} - } - if v, ok := uc.mutation.Password(); ok { - if err := user.PasswordValidator(v); err != nil { - return &ValidationError{Name: "password", err: fmt.Errorf(`ent: validator failed for field "User.password": %w`, err)} - } - } - if _, ok := uc.mutation.CreatedAt(); !ok { - return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "User.created_at"`)} - } - if _, ok := uc.mutation.UpdatedAt(); !ok { - return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "User.updated_at"`)} - } - if v, ok := uc.mutation.ID(); ok { - if err := user.IDValidator(v); err != nil { - return &ValidationError{Name: "id", err: fmt.Errorf(`ent: validator failed for field "User.id": %w`, err)} - } - } - return nil -} - -func (uc *UserCreate) sqlSave(ctx context.Context) (*User, error) { - _node, _spec := uc.createSpec() - if err := sqlgraph.CreateNode(ctx, uc.driver, _spec); err != nil { - if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return nil, err - } - if _spec.ID.Value != nil { - if id, ok := _spec.ID.Value.(string); ok { - _node.ID = id - } else { - return nil, fmt.Errorf("unexpected User.ID type: %T", _spec.ID.Value) - } - } - return _node, nil -} - -func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) { - var ( - _node = &User{config: uc.config} - _spec = &sqlgraph.CreateSpec{ - Table: user.Table, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: user.FieldID, - }, - } - ) - if id, ok := uc.mutation.ID(); ok { - _node.ID = id - _spec.ID.Value = id - } - if value, ok := uc.mutation.Name(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeString, - Value: value, - Column: user.FieldName, - }) - _node.Name = value - } - if value, ok := uc.mutation.Displayname(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeString, - Value: value, - Column: user.FieldDisplayname, - }) - _node.Displayname = value - } - if value, ok := uc.mutation.GetType(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeString, - Value: value, - Column: user.FieldType, - }) - _node.Type = value - } - if value, ok := uc.mutation.Password(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeBytes, - Value: value, - Column: user.FieldPassword, - }) - _node.Password = value - } - if value, ok := uc.mutation.CreatedAt(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeTime, - Value: value, - Column: user.FieldCreatedAt, - }) - _node.CreatedAt = value - } - if value, ok := uc.mutation.UpdatedAt(); ok { - _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ - Type: field.TypeTime, - Value: value, - Column: user.FieldUpdatedAt, - }) - _node.UpdatedAt = value - } - if nodes := uc.mutation.KeysIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: user.KeysTable, - Columns: []string{user.KeysColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: privatekey.FieldID, - }, - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges = append(_spec.Edges, edge) - } - if nodes := uc.mutation.DidsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: user.DidsTable, - Columns: []string{user.DidsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: did.FieldID, - }, - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges = append(_spec.Edges, edge) - } - if nodes := uc.mutation.CredentialsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: user.CredentialsTable, - Columns: []string{user.CredentialsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: credential.FieldID, - }, - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges = append(_spec.Edges, edge) - } - return _node, _spec -} - -// UserCreateBulk is the builder for creating many User entities in bulk. -type UserCreateBulk struct { - config - builders []*UserCreate -} - -// Save creates the User entities in the database. -func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) { - specs := make([]*sqlgraph.CreateSpec, len(ucb.builders)) - nodes := make([]*User, len(ucb.builders)) - mutators := make([]Mutator, len(ucb.builders)) - for i := range ucb.builders { - func(i int, root context.Context) { - builder := ucb.builders[i] - builder.defaults() - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*UserMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - if err := builder.check(); err != nil { - return nil, err - } - builder.mutation = mutation - nodes[i], specs[i] = builder.createSpec() - var err error - if i < len(mutators)-1 { - _, err = mutators[i+1].Mutate(root, ucb.builders[i+1].mutation) - } else { - spec := &sqlgraph.BatchCreateSpec{Nodes: specs} - // Invoke the actual operation on the latest mutation in the chain. - if err = sqlgraph.BatchCreate(ctx, ucb.driver, spec); err != nil { - if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - } - } - if err != nil { - return nil, err - } - mutation.id = &nodes[i].ID - mutation.done = true - return nodes[i], nil - }) - for i := len(builder.hooks) - 1; i >= 0; i-- { - mut = builder.hooks[i](mut) - } - mutators[i] = mut - }(i, ctx) - } - if len(mutators) > 0 { - if _, err := mutators[0].Mutate(ctx, ucb.builders[0].mutation); err != nil { - return nil, err - } - } - return nodes, nil -} - -// SaveX is like Save, but panics if an error occurs. -func (ucb *UserCreateBulk) SaveX(ctx context.Context) []*User { - v, err := ucb.Save(ctx) - if err != nil { - panic(err) - } - return v -} - -// Exec executes the query. -func (ucb *UserCreateBulk) Exec(ctx context.Context) error { - _, err := ucb.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (ucb *UserCreateBulk) ExecX(ctx context.Context) { - if err := ucb.Exec(ctx); err != nil { - panic(err) - } -} diff --git a/ent/user_delete.go b/ent/user_delete.go deleted file mode 100644 index a74287bc..00000000 --- a/ent/user_delete.go +++ /dev/null @@ -1,115 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "fmt" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/fiware/vcverifier/ent/predicate" - "github.com/fiware/vcverifier/ent/user" -) - -// UserDelete is the builder for deleting a User entity. -type UserDelete struct { - config - hooks []Hook - mutation *UserMutation -} - -// Where appends a list predicates to the UserDelete builder. -func (ud *UserDelete) Where(ps ...predicate.User) *UserDelete { - ud.mutation.Where(ps...) - return ud -} - -// Exec executes the deletion query and returns how many vertices were deleted. -func (ud *UserDelete) Exec(ctx context.Context) (int, error) { - var ( - err error - affected int - ) - if len(ud.hooks) == 0 { - affected, err = ud.sqlExec(ctx) - } else { - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*UserMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - ud.mutation = mutation - affected, err = ud.sqlExec(ctx) - mutation.done = true - return affected, err - }) - for i := len(ud.hooks) - 1; i >= 0; i-- { - if ud.hooks[i] == nil { - return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") - } - mut = ud.hooks[i](mut) - } - if _, err := mut.Mutate(ctx, ud.mutation); err != nil { - return 0, err - } - } - return affected, err -} - -// ExecX is like Exec, but panics if an error occurs. -func (ud *UserDelete) ExecX(ctx context.Context) int { - n, err := ud.Exec(ctx) - if err != nil { - panic(err) - } - return n -} - -func (ud *UserDelete) sqlExec(ctx context.Context) (int, error) { - _spec := &sqlgraph.DeleteSpec{ - Node: &sqlgraph.NodeSpec{ - Table: user.Table, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: user.FieldID, - }, - }, - } - if ps := ud.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - affected, err := sqlgraph.DeleteNodes(ctx, ud.driver, _spec) - if err != nil && sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return affected, err -} - -// UserDeleteOne is the builder for deleting a single User entity. -type UserDeleteOne struct { - ud *UserDelete -} - -// Exec executes the deletion query. -func (udo *UserDeleteOne) Exec(ctx context.Context) error { - n, err := udo.ud.Exec(ctx) - switch { - case err != nil: - return err - case n == 0: - return &NotFoundError{user.Label} - default: - return nil - } -} - -// ExecX is like Exec, but panics if an error occurs. -func (udo *UserDeleteOne) ExecX(ctx context.Context) { - udo.ud.ExecX(ctx) -} diff --git a/ent/user_query.go b/ent/user_query.go deleted file mode 100644 index 7b6080d6..00000000 --- a/ent/user_query.go +++ /dev/null @@ -1,730 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "database/sql/driver" - "fmt" - "math" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/fiware/vcverifier/ent/credential" - "github.com/fiware/vcverifier/ent/did" - "github.com/fiware/vcverifier/ent/predicate" - "github.com/fiware/vcverifier/ent/privatekey" - "github.com/fiware/vcverifier/ent/user" -) - -// UserQuery is the builder for querying User entities. -type UserQuery struct { - config - limit *int - offset *int - unique *bool - order []OrderFunc - fields []string - predicates []predicate.User - // eager-loading edges. - withKeys *PrivateKeyQuery - withDids *DIDQuery - withCredentials *CredentialQuery - // intermediate query (i.e. traversal path). - sql *sql.Selector - path func(context.Context) (*sql.Selector, error) -} - -// Where adds a new predicate for the UserQuery builder. -func (uq *UserQuery) Where(ps ...predicate.User) *UserQuery { - uq.predicates = append(uq.predicates, ps...) - return uq -} - -// Limit adds a limit step to the query. -func (uq *UserQuery) Limit(limit int) *UserQuery { - uq.limit = &limit - return uq -} - -// Offset adds an offset step to the query. -func (uq *UserQuery) Offset(offset int) *UserQuery { - uq.offset = &offset - return uq -} - -// Unique configures the query builder to filter duplicate records on query. -// By default, unique is set to true, and can be disabled using this method. -func (uq *UserQuery) Unique(unique bool) *UserQuery { - uq.unique = &unique - return uq -} - -// Order adds an order step to the query. -func (uq *UserQuery) Order(o ...OrderFunc) *UserQuery { - uq.order = append(uq.order, o...) - return uq -} - -// QueryKeys chains the current query on the "keys" edge. -func (uq *UserQuery) QueryKeys() *PrivateKeyQuery { - query := &PrivateKeyQuery{config: uq.config} - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := uq.prepareQuery(ctx); err != nil { - return nil, err - } - selector := uq.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(user.Table, user.FieldID, selector), - sqlgraph.To(privatekey.Table, privatekey.FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, user.KeysTable, user.KeysColumn), - ) - fromU = sqlgraph.SetNeighbors(uq.driver.Dialect(), step) - return fromU, nil - } - return query -} - -// QueryDids chains the current query on the "dids" edge. -func (uq *UserQuery) QueryDids() *DIDQuery { - query := &DIDQuery{config: uq.config} - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := uq.prepareQuery(ctx); err != nil { - return nil, err - } - selector := uq.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(user.Table, user.FieldID, selector), - sqlgraph.To(did.Table, did.FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, user.DidsTable, user.DidsColumn), - ) - fromU = sqlgraph.SetNeighbors(uq.driver.Dialect(), step) - return fromU, nil - } - return query -} - -// QueryCredentials chains the current query on the "credentials" edge. -func (uq *UserQuery) QueryCredentials() *CredentialQuery { - query := &CredentialQuery{config: uq.config} - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := uq.prepareQuery(ctx); err != nil { - return nil, err - } - selector := uq.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(user.Table, user.FieldID, selector), - sqlgraph.To(credential.Table, credential.FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, user.CredentialsTable, user.CredentialsColumn), - ) - fromU = sqlgraph.SetNeighbors(uq.driver.Dialect(), step) - return fromU, nil - } - return query -} - -// First returns the first User entity from the query. -// Returns a *NotFoundError when no User was found. -func (uq *UserQuery) First(ctx context.Context) (*User, error) { - nodes, err := uq.Limit(1).All(ctx) - if err != nil { - return nil, err - } - if len(nodes) == 0 { - return nil, &NotFoundError{user.Label} - } - return nodes[0], nil -} - -// FirstX is like First, but panics if an error occurs. -func (uq *UserQuery) FirstX(ctx context.Context) *User { - node, err := uq.First(ctx) - if err != nil && !IsNotFound(err) { - panic(err) - } - return node -} - -// FirstID returns the first User ID from the query. -// Returns a *NotFoundError when no User ID was found. -func (uq *UserQuery) FirstID(ctx context.Context) (id string, err error) { - var ids []string - if ids, err = uq.Limit(1).IDs(ctx); err != nil { - return - } - if len(ids) == 0 { - err = &NotFoundError{user.Label} - return - } - return ids[0], nil -} - -// FirstIDX is like FirstID, but panics if an error occurs. -func (uq *UserQuery) FirstIDX(ctx context.Context) string { - id, err := uq.FirstID(ctx) - if err != nil && !IsNotFound(err) { - panic(err) - } - return id -} - -// Only returns a single User entity found by the query, ensuring it only returns one. -// Returns a *NotSingularError when more than one User entity is found. -// Returns a *NotFoundError when no User entities are found. -func (uq *UserQuery) Only(ctx context.Context) (*User, error) { - nodes, err := uq.Limit(2).All(ctx) - if err != nil { - return nil, err - } - switch len(nodes) { - case 1: - return nodes[0], nil - case 0: - return nil, &NotFoundError{user.Label} - default: - return nil, &NotSingularError{user.Label} - } -} - -// OnlyX is like Only, but panics if an error occurs. -func (uq *UserQuery) OnlyX(ctx context.Context) *User { - node, err := uq.Only(ctx) - if err != nil { - panic(err) - } - return node -} - -// OnlyID is like Only, but returns the only User ID in the query. -// Returns a *NotSingularError when more than one User ID is found. -// Returns a *NotFoundError when no entities are found. -func (uq *UserQuery) OnlyID(ctx context.Context) (id string, err error) { - var ids []string - if ids, err = uq.Limit(2).IDs(ctx); err != nil { - return - } - switch len(ids) { - case 1: - id = ids[0] - case 0: - err = &NotFoundError{user.Label} - default: - err = &NotSingularError{user.Label} - } - return -} - -// OnlyIDX is like OnlyID, but panics if an error occurs. -func (uq *UserQuery) OnlyIDX(ctx context.Context) string { - id, err := uq.OnlyID(ctx) - if err != nil { - panic(err) - } - return id -} - -// All executes the query and returns a list of Users. -func (uq *UserQuery) All(ctx context.Context) ([]*User, error) { - if err := uq.prepareQuery(ctx); err != nil { - return nil, err - } - return uq.sqlAll(ctx) -} - -// AllX is like All, but panics if an error occurs. -func (uq *UserQuery) AllX(ctx context.Context) []*User { - nodes, err := uq.All(ctx) - if err != nil { - panic(err) - } - return nodes -} - -// IDs executes the query and returns a list of User IDs. -func (uq *UserQuery) IDs(ctx context.Context) ([]string, error) { - var ids []string - if err := uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { - return nil, err - } - return ids, nil -} - -// IDsX is like IDs, but panics if an error occurs. -func (uq *UserQuery) IDsX(ctx context.Context) []string { - ids, err := uq.IDs(ctx) - if err != nil { - panic(err) - } - return ids -} - -// Count returns the count of the given query. -func (uq *UserQuery) Count(ctx context.Context) (int, error) { - if err := uq.prepareQuery(ctx); err != nil { - return 0, err - } - return uq.sqlCount(ctx) -} - -// CountX is like Count, but panics if an error occurs. -func (uq *UserQuery) CountX(ctx context.Context) int { - count, err := uq.Count(ctx) - if err != nil { - panic(err) - } - return count -} - -// Exist returns true if the query has elements in the graph. -func (uq *UserQuery) Exist(ctx context.Context) (bool, error) { - if err := uq.prepareQuery(ctx); err != nil { - return false, err - } - return uq.sqlExist(ctx) -} - -// ExistX is like Exist, but panics if an error occurs. -func (uq *UserQuery) ExistX(ctx context.Context) bool { - exist, err := uq.Exist(ctx) - if err != nil { - panic(err) - } - return exist -} - -// Clone returns a duplicate of the UserQuery builder, including all associated steps. It can be -// used to prepare common query builders and use them differently after the clone is made. -func (uq *UserQuery) Clone() *UserQuery { - if uq == nil { - return nil - } - return &UserQuery{ - config: uq.config, - limit: uq.limit, - offset: uq.offset, - order: append([]OrderFunc{}, uq.order...), - predicates: append([]predicate.User{}, uq.predicates...), - withKeys: uq.withKeys.Clone(), - withDids: uq.withDids.Clone(), - withCredentials: uq.withCredentials.Clone(), - // clone intermediate query. - sql: uq.sql.Clone(), - path: uq.path, - unique: uq.unique, - } -} - -// WithKeys tells the query-builder to eager-load the nodes that are connected to -// the "keys" edge. The optional arguments are used to configure the query builder of the edge. -func (uq *UserQuery) WithKeys(opts ...func(*PrivateKeyQuery)) *UserQuery { - query := &PrivateKeyQuery{config: uq.config} - for _, opt := range opts { - opt(query) - } - uq.withKeys = query - return uq -} - -// WithDids tells the query-builder to eager-load the nodes that are connected to -// the "dids" edge. The optional arguments are used to configure the query builder of the edge. -func (uq *UserQuery) WithDids(opts ...func(*DIDQuery)) *UserQuery { - query := &DIDQuery{config: uq.config} - for _, opt := range opts { - opt(query) - } - uq.withDids = query - return uq -} - -// WithCredentials tells the query-builder to eager-load the nodes that are connected to -// the "credentials" edge. The optional arguments are used to configure the query builder of the edge. -func (uq *UserQuery) WithCredentials(opts ...func(*CredentialQuery)) *UserQuery { - query := &CredentialQuery{config: uq.config} - for _, opt := range opts { - opt(query) - } - uq.withCredentials = query - return uq -} - -// GroupBy is used to group vertices by one or more fields/columns. -// It is often used with aggregate functions, like: count, max, mean, min, sum. -// -// Example: -// -// var v []struct { -// Name string `json:"name,omitempty"` -// Count int `json:"count,omitempty"` -// } -// -// client.User.Query(). -// GroupBy(user.FieldName). -// Aggregate(ent.Count()). -// Scan(ctx, &v) -func (uq *UserQuery) GroupBy(field string, fields ...string) *UserGroupBy { - grbuild := &UserGroupBy{config: uq.config} - grbuild.fields = append([]string{field}, fields...) - grbuild.path = func(ctx context.Context) (prev *sql.Selector, err error) { - if err := uq.prepareQuery(ctx); err != nil { - return nil, err - } - return uq.sqlQuery(ctx), nil - } - grbuild.label = user.Label - grbuild.flds, grbuild.scan = &grbuild.fields, grbuild.Scan - return grbuild -} - -// Select allows the selection one or more fields/columns for the given query, -// instead of selecting all fields in the entity. -// -// Example: -// -// var v []struct { -// Name string `json:"name,omitempty"` -// } -// -// client.User.Query(). -// Select(user.FieldName). -// Scan(ctx, &v) -func (uq *UserQuery) Select(fields ...string) *UserSelect { - uq.fields = append(uq.fields, fields...) - selbuild := &UserSelect{UserQuery: uq} - selbuild.label = user.Label - selbuild.flds, selbuild.scan = &uq.fields, selbuild.Scan - return selbuild -} - -func (uq *UserQuery) prepareQuery(ctx context.Context) error { - for _, f := range uq.fields { - if !user.ValidColumn(f) { - return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} - } - } - if uq.path != nil { - prev, err := uq.path(ctx) - if err != nil { - return err - } - uq.sql = prev - } - return nil -} - -func (uq *UserQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*User, error) { - var ( - nodes = []*User{} - _spec = uq.querySpec() - loadedTypes = [3]bool{ - uq.withKeys != nil, - uq.withDids != nil, - uq.withCredentials != nil, - } - ) - _spec.ScanValues = func(columns []string) ([]interface{}, error) { - return (*User).scanValues(nil, columns) - } - _spec.Assign = func(columns []string, values []interface{}) error { - node := &User{config: uq.config} - nodes = append(nodes, node) - node.Edges.loadedTypes = loadedTypes - return node.assignValues(columns, values) - } - for i := range hooks { - hooks[i](ctx, _spec) - } - if err := sqlgraph.QueryNodes(ctx, uq.driver, _spec); err != nil { - return nil, err - } - if len(nodes) == 0 { - return nodes, nil - } - - if query := uq.withKeys; query != nil { - fks := make([]driver.Value, 0, len(nodes)) - nodeids := make(map[string]*User) - for i := range nodes { - fks = append(fks, nodes[i].ID) - nodeids[nodes[i].ID] = nodes[i] - nodes[i].Edges.Keys = []*PrivateKey{} - } - query.withFKs = true - query.Where(predicate.PrivateKey(func(s *sql.Selector) { - s.Where(sql.InValues(user.KeysColumn, fks...)) - })) - neighbors, err := query.All(ctx) - if err != nil { - return nil, err - } - for _, n := range neighbors { - fk := n.user_keys - if fk == nil { - return nil, fmt.Errorf(`foreign-key "user_keys" is nil for node %v`, n.ID) - } - node, ok := nodeids[*fk] - if !ok { - return nil, fmt.Errorf(`unexpected foreign-key "user_keys" returned %v for node %v`, *fk, n.ID) - } - node.Edges.Keys = append(node.Edges.Keys, n) - } - } - - if query := uq.withDids; query != nil { - fks := make([]driver.Value, 0, len(nodes)) - nodeids := make(map[string]*User) - for i := range nodes { - fks = append(fks, nodes[i].ID) - nodeids[nodes[i].ID] = nodes[i] - nodes[i].Edges.Dids = []*DID{} - } - query.withFKs = true - query.Where(predicate.DID(func(s *sql.Selector) { - s.Where(sql.InValues(user.DidsColumn, fks...)) - })) - neighbors, err := query.All(ctx) - if err != nil { - return nil, err - } - for _, n := range neighbors { - fk := n.user_dids - if fk == nil { - return nil, fmt.Errorf(`foreign-key "user_dids" is nil for node %v`, n.ID) - } - node, ok := nodeids[*fk] - if !ok { - return nil, fmt.Errorf(`unexpected foreign-key "user_dids" returned %v for node %v`, *fk, n.ID) - } - node.Edges.Dids = append(node.Edges.Dids, n) - } - } - - if query := uq.withCredentials; query != nil { - fks := make([]driver.Value, 0, len(nodes)) - nodeids := make(map[string]*User) - for i := range nodes { - fks = append(fks, nodes[i].ID) - nodeids[nodes[i].ID] = nodes[i] - nodes[i].Edges.Credentials = []*Credential{} - } - query.withFKs = true - query.Where(predicate.Credential(func(s *sql.Selector) { - s.Where(sql.InValues(user.CredentialsColumn, fks...)) - })) - neighbors, err := query.All(ctx) - if err != nil { - return nil, err - } - for _, n := range neighbors { - fk := n.user_credentials - if fk == nil { - return nil, fmt.Errorf(`foreign-key "user_credentials" is nil for node %v`, n.ID) - } - node, ok := nodeids[*fk] - if !ok { - return nil, fmt.Errorf(`unexpected foreign-key "user_credentials" returned %v for node %v`, *fk, n.ID) - } - node.Edges.Credentials = append(node.Edges.Credentials, n) - } - } - - return nodes, nil -} - -func (uq *UserQuery) sqlCount(ctx context.Context) (int, error) { - _spec := uq.querySpec() - _spec.Node.Columns = uq.fields - if len(uq.fields) > 0 { - _spec.Unique = uq.unique != nil && *uq.unique - } - return sqlgraph.CountNodes(ctx, uq.driver, _spec) -} - -func (uq *UserQuery) sqlExist(ctx context.Context) (bool, error) { - n, err := uq.sqlCount(ctx) - if err != nil { - return false, fmt.Errorf("ent: check existence: %w", err) - } - return n > 0, nil -} - -func (uq *UserQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: user.Table, - Columns: user.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: user.FieldID, - }, - }, - From: uq.sql, - Unique: true, - } - if unique := uq.unique; unique != nil { - _spec.Unique = *unique - } - if fields := uq.fields; len(fields) > 0 { - _spec.Node.Columns = make([]string, 0, len(fields)) - _spec.Node.Columns = append(_spec.Node.Columns, user.FieldID) - for i := range fields { - if fields[i] != user.FieldID { - _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) - } - } - } - if ps := uq.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if limit := uq.limit; limit != nil { - _spec.Limit = *limit - } - if offset := uq.offset; offset != nil { - _spec.Offset = *offset - } - if ps := uq.order; len(ps) > 0 { - _spec.Order = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - return _spec -} - -func (uq *UserQuery) sqlQuery(ctx context.Context) *sql.Selector { - builder := sql.Dialect(uq.driver.Dialect()) - t1 := builder.Table(user.Table) - columns := uq.fields - if len(columns) == 0 { - columns = user.Columns - } - selector := builder.Select(t1.Columns(columns...)...).From(t1) - if uq.sql != nil { - selector = uq.sql - selector.Select(selector.Columns(columns...)...) - } - if uq.unique != nil && *uq.unique { - selector.Distinct() - } - for _, p := range uq.predicates { - p(selector) - } - for _, p := range uq.order { - p(selector) - } - if offset := uq.offset; offset != nil { - // limit is mandatory for offset clause. We start - // with default value, and override it below if needed. - selector.Offset(*offset).Limit(math.MaxInt32) - } - if limit := uq.limit; limit != nil { - selector.Limit(*limit) - } - return selector -} - -// UserGroupBy is the group-by builder for User entities. -type UserGroupBy struct { - config - selector - fields []string - fns []AggregateFunc - // intermediate query (i.e. traversal path). - sql *sql.Selector - path func(context.Context) (*sql.Selector, error) -} - -// Aggregate adds the given aggregation functions to the group-by query. -func (ugb *UserGroupBy) Aggregate(fns ...AggregateFunc) *UserGroupBy { - ugb.fns = append(ugb.fns, fns...) - return ugb -} - -// Scan applies the group-by query and scans the result into the given value. -func (ugb *UserGroupBy) Scan(ctx context.Context, v interface{}) error { - query, err := ugb.path(ctx) - if err != nil { - return err - } - ugb.sql = query - return ugb.sqlScan(ctx, v) -} - -func (ugb *UserGroupBy) sqlScan(ctx context.Context, v interface{}) error { - for _, f := range ugb.fields { - if !user.ValidColumn(f) { - return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)} - } - } - selector := ugb.sqlQuery() - if err := selector.Err(); err != nil { - return err - } - rows := &sql.Rows{} - query, args := selector.Query() - if err := ugb.driver.Query(ctx, query, args, rows); err != nil { - return err - } - defer rows.Close() - return sql.ScanSlice(rows, v) -} - -func (ugb *UserGroupBy) sqlQuery() *sql.Selector { - selector := ugb.sql.Select() - aggregation := make([]string, 0, len(ugb.fns)) - for _, fn := range ugb.fns { - aggregation = append(aggregation, fn(selector)) - } - // If no columns were selected in a custom aggregation function, the default - // selection is the fields used for "group-by", and the aggregation functions. - if len(selector.SelectedColumns()) == 0 { - columns := make([]string, 0, len(ugb.fields)+len(ugb.fns)) - for _, f := range ugb.fields { - columns = append(columns, selector.C(f)) - } - columns = append(columns, aggregation...) - selector.Select(columns...) - } - return selector.GroupBy(selector.Columns(ugb.fields...)...) -} - -// UserSelect is the builder for selecting fields of User entities. -type UserSelect struct { - *UserQuery - selector - // intermediate query (i.e. traversal path). - sql *sql.Selector -} - -// Scan applies the selector query and scans the result into the given value. -func (us *UserSelect) Scan(ctx context.Context, v interface{}) error { - if err := us.prepareQuery(ctx); err != nil { - return err - } - us.sql = us.UserQuery.sqlQuery(ctx) - return us.sqlScan(ctx, v) -} - -func (us *UserSelect) sqlScan(ctx context.Context, v interface{}) error { - rows := &sql.Rows{} - query, args := us.sql.Query() - if err := us.driver.Query(ctx, query, args, rows); err != nil { - return err - } - defer rows.Close() - return sql.ScanSlice(rows, v) -} diff --git a/ent/user_update.go b/ent/user_update.go deleted file mode 100644 index 750afcd3..00000000 --- a/ent/user_update.go +++ /dev/null @@ -1,1027 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - "time" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/fiware/vcverifier/ent/credential" - "github.com/fiware/vcverifier/ent/did" - "github.com/fiware/vcverifier/ent/predicate" - "github.com/fiware/vcverifier/ent/privatekey" - "github.com/fiware/vcverifier/ent/user" -) - -// UserUpdate is the builder for updating User entities. -type UserUpdate struct { - config - hooks []Hook - mutation *UserMutation -} - -// Where appends a list predicates to the UserUpdate builder. -func (uu *UserUpdate) Where(ps ...predicate.User) *UserUpdate { - uu.mutation.Where(ps...) - return uu -} - -// SetName sets the "name" field. -func (uu *UserUpdate) SetName(s string) *UserUpdate { - uu.mutation.SetName(s) - return uu -} - -// SetDisplayname sets the "displayname" field. -func (uu *UserUpdate) SetDisplayname(s string) *UserUpdate { - uu.mutation.SetDisplayname(s) - return uu -} - -// SetNillableDisplayname sets the "displayname" field if the given value is not nil. -func (uu *UserUpdate) SetNillableDisplayname(s *string) *UserUpdate { - if s != nil { - uu.SetDisplayname(*s) - } - return uu -} - -// ClearDisplayname clears the value of the "displayname" field. -func (uu *UserUpdate) ClearDisplayname() *UserUpdate { - uu.mutation.ClearDisplayname() - return uu -} - -// SetType sets the "type" field. -func (uu *UserUpdate) SetType(s string) *UserUpdate { - uu.mutation.SetType(s) - return uu -} - -// SetPassword sets the "password" field. -func (uu *UserUpdate) SetPassword(b []byte) *UserUpdate { - uu.mutation.SetPassword(b) - return uu -} - -// SetUpdatedAt sets the "updated_at" field. -func (uu *UserUpdate) SetUpdatedAt(t time.Time) *UserUpdate { - uu.mutation.SetUpdatedAt(t) - return uu -} - -// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. -func (uu *UserUpdate) SetNillableUpdatedAt(t *time.Time) *UserUpdate { - if t != nil { - uu.SetUpdatedAt(*t) - } - return uu -} - -// AddKeyIDs adds the "keys" edge to the PrivateKey entity by IDs. -func (uu *UserUpdate) AddKeyIDs(ids ...string) *UserUpdate { - uu.mutation.AddKeyIDs(ids...) - return uu -} - -// AddKeys adds the "keys" edges to the PrivateKey entity. -func (uu *UserUpdate) AddKeys(p ...*PrivateKey) *UserUpdate { - ids := make([]string, len(p)) - for i := range p { - ids[i] = p[i].ID - } - return uu.AddKeyIDs(ids...) -} - -// AddDidIDs adds the "dids" edge to the DID entity by IDs. -func (uu *UserUpdate) AddDidIDs(ids ...string) *UserUpdate { - uu.mutation.AddDidIDs(ids...) - return uu -} - -// AddDids adds the "dids" edges to the DID entity. -func (uu *UserUpdate) AddDids(d ...*DID) *UserUpdate { - ids := make([]string, len(d)) - for i := range d { - ids[i] = d[i].ID - } - return uu.AddDidIDs(ids...) -} - -// AddCredentialIDs adds the "credentials" edge to the Credential entity by IDs. -func (uu *UserUpdate) AddCredentialIDs(ids ...string) *UserUpdate { - uu.mutation.AddCredentialIDs(ids...) - return uu -} - -// AddCredentials adds the "credentials" edges to the Credential entity. -func (uu *UserUpdate) AddCredentials(c ...*Credential) *UserUpdate { - ids := make([]string, len(c)) - for i := range c { - ids[i] = c[i].ID - } - return uu.AddCredentialIDs(ids...) -} - -// Mutation returns the UserMutation object of the builder. -func (uu *UserUpdate) Mutation() *UserMutation { - return uu.mutation -} - -// ClearKeys clears all "keys" edges to the PrivateKey entity. -func (uu *UserUpdate) ClearKeys() *UserUpdate { - uu.mutation.ClearKeys() - return uu -} - -// RemoveKeyIDs removes the "keys" edge to PrivateKey entities by IDs. -func (uu *UserUpdate) RemoveKeyIDs(ids ...string) *UserUpdate { - uu.mutation.RemoveKeyIDs(ids...) - return uu -} - -// RemoveKeys removes "keys" edges to PrivateKey entities. -func (uu *UserUpdate) RemoveKeys(p ...*PrivateKey) *UserUpdate { - ids := make([]string, len(p)) - for i := range p { - ids[i] = p[i].ID - } - return uu.RemoveKeyIDs(ids...) -} - -// ClearDids clears all "dids" edges to the DID entity. -func (uu *UserUpdate) ClearDids() *UserUpdate { - uu.mutation.ClearDids() - return uu -} - -// RemoveDidIDs removes the "dids" edge to DID entities by IDs. -func (uu *UserUpdate) RemoveDidIDs(ids ...string) *UserUpdate { - uu.mutation.RemoveDidIDs(ids...) - return uu -} - -// RemoveDids removes "dids" edges to DID entities. -func (uu *UserUpdate) RemoveDids(d ...*DID) *UserUpdate { - ids := make([]string, len(d)) - for i := range d { - ids[i] = d[i].ID - } - return uu.RemoveDidIDs(ids...) -} - -// ClearCredentials clears all "credentials" edges to the Credential entity. -func (uu *UserUpdate) ClearCredentials() *UserUpdate { - uu.mutation.ClearCredentials() - return uu -} - -// RemoveCredentialIDs removes the "credentials" edge to Credential entities by IDs. -func (uu *UserUpdate) RemoveCredentialIDs(ids ...string) *UserUpdate { - uu.mutation.RemoveCredentialIDs(ids...) - return uu -} - -// RemoveCredentials removes "credentials" edges to Credential entities. -func (uu *UserUpdate) RemoveCredentials(c ...*Credential) *UserUpdate { - ids := make([]string, len(c)) - for i := range c { - ids[i] = c[i].ID - } - return uu.RemoveCredentialIDs(ids...) -} - -// Save executes the query and returns the number of nodes affected by the update operation. -func (uu *UserUpdate) Save(ctx context.Context) (int, error) { - var ( - err error - affected int - ) - if len(uu.hooks) == 0 { - if err = uu.check(); err != nil { - return 0, err - } - affected, err = uu.sqlSave(ctx) - } else { - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*UserMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - if err = uu.check(); err != nil { - return 0, err - } - uu.mutation = mutation - affected, err = uu.sqlSave(ctx) - mutation.done = true - return affected, err - }) - for i := len(uu.hooks) - 1; i >= 0; i-- { - if uu.hooks[i] == nil { - return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") - } - mut = uu.hooks[i](mut) - } - if _, err := mut.Mutate(ctx, uu.mutation); err != nil { - return 0, err - } - } - return affected, err -} - -// SaveX is like Save, but panics if an error occurs. -func (uu *UserUpdate) SaveX(ctx context.Context) int { - affected, err := uu.Save(ctx) - if err != nil { - panic(err) - } - return affected -} - -// Exec executes the query. -func (uu *UserUpdate) Exec(ctx context.Context) error { - _, err := uu.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (uu *UserUpdate) ExecX(ctx context.Context) { - if err := uu.Exec(ctx); err != nil { - panic(err) - } -} - -// check runs all checks and user-defined validators on the builder. -func (uu *UserUpdate) check() error { - if v, ok := uu.mutation.Name(); ok { - if err := user.NameValidator(v); err != nil { - return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "User.name": %w`, err)} - } - } - if v, ok := uu.mutation.GetType(); ok { - if err := user.TypeValidator(v); err != nil { - return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "User.type": %w`, err)} - } - } - if v, ok := uu.mutation.Password(); ok { - if err := user.PasswordValidator(v); err != nil { - return &ValidationError{Name: "password", err: fmt.Errorf(`ent: validator failed for field "User.password": %w`, err)} - } - } - return nil -} - -func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { - _spec := &sqlgraph.UpdateSpec{ - Node: &sqlgraph.NodeSpec{ - Table: user.Table, - Columns: user.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: user.FieldID, - }, - }, - } - if ps := uu.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if value, ok := uu.mutation.Name(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeString, - Value: value, - Column: user.FieldName, - }) - } - if value, ok := uu.mutation.Displayname(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeString, - Value: value, - Column: user.FieldDisplayname, - }) - } - if uu.mutation.DisplaynameCleared() { - _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: user.FieldDisplayname, - }) - } - if value, ok := uu.mutation.GetType(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeString, - Value: value, - Column: user.FieldType, - }) - } - if value, ok := uu.mutation.Password(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeBytes, - Value: value, - Column: user.FieldPassword, - }) - } - if value, ok := uu.mutation.UpdatedAt(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeTime, - Value: value, - Column: user.FieldUpdatedAt, - }) - } - if uu.mutation.KeysCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: user.KeysTable, - Columns: []string{user.KeysColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: privatekey.FieldID, - }, - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := uu.mutation.RemovedKeysIDs(); len(nodes) > 0 && !uu.mutation.KeysCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: user.KeysTable, - Columns: []string{user.KeysColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: privatekey.FieldID, - }, - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := uu.mutation.KeysIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: user.KeysTable, - Columns: []string{user.KeysColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: privatekey.FieldID, - }, - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if uu.mutation.DidsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: user.DidsTable, - Columns: []string{user.DidsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: did.FieldID, - }, - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := uu.mutation.RemovedDidsIDs(); len(nodes) > 0 && !uu.mutation.DidsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: user.DidsTable, - Columns: []string{user.DidsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: did.FieldID, - }, - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := uu.mutation.DidsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: user.DidsTable, - Columns: []string{user.DidsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: did.FieldID, - }, - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if uu.mutation.CredentialsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: user.CredentialsTable, - Columns: []string{user.CredentialsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: credential.FieldID, - }, - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := uu.mutation.RemovedCredentialsIDs(); len(nodes) > 0 && !uu.mutation.CredentialsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: user.CredentialsTable, - Columns: []string{user.CredentialsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: credential.FieldID, - }, - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := uu.mutation.CredentialsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: user.CredentialsTable, - Columns: []string{user.CredentialsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: credential.FieldID, - }, - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if n, err = sqlgraph.UpdateNodes(ctx, uu.driver, _spec); err != nil { - if _, ok := err.(*sqlgraph.NotFoundError); ok { - err = &NotFoundError{user.Label} - } else if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return 0, err - } - return n, nil -} - -// UserUpdateOne is the builder for updating a single User entity. -type UserUpdateOne struct { - config - fields []string - hooks []Hook - mutation *UserMutation -} - -// SetName sets the "name" field. -func (uuo *UserUpdateOne) SetName(s string) *UserUpdateOne { - uuo.mutation.SetName(s) - return uuo -} - -// SetDisplayname sets the "displayname" field. -func (uuo *UserUpdateOne) SetDisplayname(s string) *UserUpdateOne { - uuo.mutation.SetDisplayname(s) - return uuo -} - -// SetNillableDisplayname sets the "displayname" field if the given value is not nil. -func (uuo *UserUpdateOne) SetNillableDisplayname(s *string) *UserUpdateOne { - if s != nil { - uuo.SetDisplayname(*s) - } - return uuo -} - -// ClearDisplayname clears the value of the "displayname" field. -func (uuo *UserUpdateOne) ClearDisplayname() *UserUpdateOne { - uuo.mutation.ClearDisplayname() - return uuo -} - -// SetType sets the "type" field. -func (uuo *UserUpdateOne) SetType(s string) *UserUpdateOne { - uuo.mutation.SetType(s) - return uuo -} - -// SetPassword sets the "password" field. -func (uuo *UserUpdateOne) SetPassword(b []byte) *UserUpdateOne { - uuo.mutation.SetPassword(b) - return uuo -} - -// SetUpdatedAt sets the "updated_at" field. -func (uuo *UserUpdateOne) SetUpdatedAt(t time.Time) *UserUpdateOne { - uuo.mutation.SetUpdatedAt(t) - return uuo -} - -// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. -func (uuo *UserUpdateOne) SetNillableUpdatedAt(t *time.Time) *UserUpdateOne { - if t != nil { - uuo.SetUpdatedAt(*t) - } - return uuo -} - -// AddKeyIDs adds the "keys" edge to the PrivateKey entity by IDs. -func (uuo *UserUpdateOne) AddKeyIDs(ids ...string) *UserUpdateOne { - uuo.mutation.AddKeyIDs(ids...) - return uuo -} - -// AddKeys adds the "keys" edges to the PrivateKey entity. -func (uuo *UserUpdateOne) AddKeys(p ...*PrivateKey) *UserUpdateOne { - ids := make([]string, len(p)) - for i := range p { - ids[i] = p[i].ID - } - return uuo.AddKeyIDs(ids...) -} - -// AddDidIDs adds the "dids" edge to the DID entity by IDs. -func (uuo *UserUpdateOne) AddDidIDs(ids ...string) *UserUpdateOne { - uuo.mutation.AddDidIDs(ids...) - return uuo -} - -// AddDids adds the "dids" edges to the DID entity. -func (uuo *UserUpdateOne) AddDids(d ...*DID) *UserUpdateOne { - ids := make([]string, len(d)) - for i := range d { - ids[i] = d[i].ID - } - return uuo.AddDidIDs(ids...) -} - -// AddCredentialIDs adds the "credentials" edge to the Credential entity by IDs. -func (uuo *UserUpdateOne) AddCredentialIDs(ids ...string) *UserUpdateOne { - uuo.mutation.AddCredentialIDs(ids...) - return uuo -} - -// AddCredentials adds the "credentials" edges to the Credential entity. -func (uuo *UserUpdateOne) AddCredentials(c ...*Credential) *UserUpdateOne { - ids := make([]string, len(c)) - for i := range c { - ids[i] = c[i].ID - } - return uuo.AddCredentialIDs(ids...) -} - -// Mutation returns the UserMutation object of the builder. -func (uuo *UserUpdateOne) Mutation() *UserMutation { - return uuo.mutation -} - -// ClearKeys clears all "keys" edges to the PrivateKey entity. -func (uuo *UserUpdateOne) ClearKeys() *UserUpdateOne { - uuo.mutation.ClearKeys() - return uuo -} - -// RemoveKeyIDs removes the "keys" edge to PrivateKey entities by IDs. -func (uuo *UserUpdateOne) RemoveKeyIDs(ids ...string) *UserUpdateOne { - uuo.mutation.RemoveKeyIDs(ids...) - return uuo -} - -// RemoveKeys removes "keys" edges to PrivateKey entities. -func (uuo *UserUpdateOne) RemoveKeys(p ...*PrivateKey) *UserUpdateOne { - ids := make([]string, len(p)) - for i := range p { - ids[i] = p[i].ID - } - return uuo.RemoveKeyIDs(ids...) -} - -// ClearDids clears all "dids" edges to the DID entity. -func (uuo *UserUpdateOne) ClearDids() *UserUpdateOne { - uuo.mutation.ClearDids() - return uuo -} - -// RemoveDidIDs removes the "dids" edge to DID entities by IDs. -func (uuo *UserUpdateOne) RemoveDidIDs(ids ...string) *UserUpdateOne { - uuo.mutation.RemoveDidIDs(ids...) - return uuo -} - -// RemoveDids removes "dids" edges to DID entities. -func (uuo *UserUpdateOne) RemoveDids(d ...*DID) *UserUpdateOne { - ids := make([]string, len(d)) - for i := range d { - ids[i] = d[i].ID - } - return uuo.RemoveDidIDs(ids...) -} - -// ClearCredentials clears all "credentials" edges to the Credential entity. -func (uuo *UserUpdateOne) ClearCredentials() *UserUpdateOne { - uuo.mutation.ClearCredentials() - return uuo -} - -// RemoveCredentialIDs removes the "credentials" edge to Credential entities by IDs. -func (uuo *UserUpdateOne) RemoveCredentialIDs(ids ...string) *UserUpdateOne { - uuo.mutation.RemoveCredentialIDs(ids...) - return uuo -} - -// RemoveCredentials removes "credentials" edges to Credential entities. -func (uuo *UserUpdateOne) RemoveCredentials(c ...*Credential) *UserUpdateOne { - ids := make([]string, len(c)) - for i := range c { - ids[i] = c[i].ID - } - return uuo.RemoveCredentialIDs(ids...) -} - -// Select allows selecting one or more fields (columns) of the returned entity. -// The default is selecting all fields defined in the entity schema. -func (uuo *UserUpdateOne) Select(field string, fields ...string) *UserUpdateOne { - uuo.fields = append([]string{field}, fields...) - return uuo -} - -// Save executes the query and returns the updated User entity. -func (uuo *UserUpdateOne) Save(ctx context.Context) (*User, error) { - var ( - err error - node *User - ) - if len(uuo.hooks) == 0 { - if err = uuo.check(); err != nil { - return nil, err - } - node, err = uuo.sqlSave(ctx) - } else { - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*UserMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - if err = uuo.check(); err != nil { - return nil, err - } - uuo.mutation = mutation - node, err = uuo.sqlSave(ctx) - mutation.done = true - return node, err - }) - for i := len(uuo.hooks) - 1; i >= 0; i-- { - if uuo.hooks[i] == nil { - return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") - } - mut = uuo.hooks[i](mut) - } - v, err := mut.Mutate(ctx, uuo.mutation) - if err != nil { - return nil, err - } - nv, ok := v.(*User) - if !ok { - return nil, fmt.Errorf("unexpected node type %T returned from UserMutation", v) - } - node = nv - } - return node, err -} - -// SaveX is like Save, but panics if an error occurs. -func (uuo *UserUpdateOne) SaveX(ctx context.Context) *User { - node, err := uuo.Save(ctx) - if err != nil { - panic(err) - } - return node -} - -// Exec executes the query on the entity. -func (uuo *UserUpdateOne) Exec(ctx context.Context) error { - _, err := uuo.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (uuo *UserUpdateOne) ExecX(ctx context.Context) { - if err := uuo.Exec(ctx); err != nil { - panic(err) - } -} - -// check runs all checks and user-defined validators on the builder. -func (uuo *UserUpdateOne) check() error { - if v, ok := uuo.mutation.Name(); ok { - if err := user.NameValidator(v); err != nil { - return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "User.name": %w`, err)} - } - } - if v, ok := uuo.mutation.GetType(); ok { - if err := user.TypeValidator(v); err != nil { - return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "User.type": %w`, err)} - } - } - if v, ok := uuo.mutation.Password(); ok { - if err := user.PasswordValidator(v); err != nil { - return &ValidationError{Name: "password", err: fmt.Errorf(`ent: validator failed for field "User.password": %w`, err)} - } - } - return nil -} - -func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) { - _spec := &sqlgraph.UpdateSpec{ - Node: &sqlgraph.NodeSpec{ - Table: user.Table, - Columns: user.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: user.FieldID, - }, - }, - } - id, ok := uuo.mutation.ID() - if !ok { - return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "User.id" for update`)} - } - _spec.Node.ID.Value = id - if fields := uuo.fields; len(fields) > 0 { - _spec.Node.Columns = make([]string, 0, len(fields)) - _spec.Node.Columns = append(_spec.Node.Columns, user.FieldID) - for _, f := range fields { - if !user.ValidColumn(f) { - return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} - } - if f != user.FieldID { - _spec.Node.Columns = append(_spec.Node.Columns, f) - } - } - } - if ps := uuo.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if value, ok := uuo.mutation.Name(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeString, - Value: value, - Column: user.FieldName, - }) - } - if value, ok := uuo.mutation.Displayname(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeString, - Value: value, - Column: user.FieldDisplayname, - }) - } - if uuo.mutation.DisplaynameCleared() { - _spec.Fields.Clear = append(_spec.Fields.Clear, &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: user.FieldDisplayname, - }) - } - if value, ok := uuo.mutation.GetType(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeString, - Value: value, - Column: user.FieldType, - }) - } - if value, ok := uuo.mutation.Password(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeBytes, - Value: value, - Column: user.FieldPassword, - }) - } - if value, ok := uuo.mutation.UpdatedAt(); ok { - _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ - Type: field.TypeTime, - Value: value, - Column: user.FieldUpdatedAt, - }) - } - if uuo.mutation.KeysCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: user.KeysTable, - Columns: []string{user.KeysColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: privatekey.FieldID, - }, - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := uuo.mutation.RemovedKeysIDs(); len(nodes) > 0 && !uuo.mutation.KeysCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: user.KeysTable, - Columns: []string{user.KeysColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: privatekey.FieldID, - }, - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := uuo.mutation.KeysIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: user.KeysTable, - Columns: []string{user.KeysColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: privatekey.FieldID, - }, - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if uuo.mutation.DidsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: user.DidsTable, - Columns: []string{user.DidsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: did.FieldID, - }, - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := uuo.mutation.RemovedDidsIDs(); len(nodes) > 0 && !uuo.mutation.DidsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: user.DidsTable, - Columns: []string{user.DidsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: did.FieldID, - }, - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := uuo.mutation.DidsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: user.DidsTable, - Columns: []string{user.DidsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: did.FieldID, - }, - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if uuo.mutation.CredentialsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: user.CredentialsTable, - Columns: []string{user.CredentialsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: credential.FieldID, - }, - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := uuo.mutation.RemovedCredentialsIDs(); len(nodes) > 0 && !uuo.mutation.CredentialsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: user.CredentialsTable, - Columns: []string{user.CredentialsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: credential.FieldID, - }, - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := uuo.mutation.CredentialsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: user.CredentialsTable, - Columns: []string{user.CredentialsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: &sqlgraph.FieldSpec{ - Type: field.TypeString, - Column: credential.FieldID, - }, - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - _node = &User{config: uuo.config} - _spec.Assign = _node.assignValues - _spec.ScanValues = _node.scanValues - if err = sqlgraph.UpdateNode(ctx, uuo.driver, _spec); err != nil { - if _, ok := err.(*sqlgraph.NotFoundError); ok { - err = &NotFoundError{user.Label} - } else if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return nil, err - } - return _node, nil -} diff --git a/go.mod b/go.mod index 2ab9e924..269cf7b4 100644 --- a/go.mod +++ b/go.mod @@ -1,73 +1,77 @@ -module github.com/fiware/vcverifier +module fiware/VCVerifier go 1.19 -require ( - entgo.io/ent v0.11.0 - github.com/duo-labs/webauthn v0.0.0-20220815211337-00c9fb5711f5 - github.com/gofiber/fiber/v2 v2.40.1 - github.com/gofiber/storage/memory v0.0.0-20221128090226-a21499405c25 - github.com/gorilla/sessions v1.2.1 - github.com/mattn/go-sqlite3 v1.14.16 - github.com/rs/zerolog v1.28.0 - github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e -) +require github.com/gin-gonic/gin v1.9.0 require ( - github.com/Masterminds/goutils v1.1.1 // indirect - github.com/Masterminds/semver/v3 v3.1.1 // indirect - github.com/benbjohnson/clock v1.3.0 // indirect - github.com/goccy/go-yaml v1.9.6 // indirect - github.com/huandu/xstrings v1.3.3 // indirect + github.com/beorn7/perks v1.0.1 // indirect + github.com/bits-and-blooms/bitset v1.2.0 // indirect + github.com/cespare/xxhash/v2 v2.1.2 // indirect + github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect + github.com/fatih/color v1.14.1 // indirect + github.com/foolin/goview v0.3.0 // indirect + github.com/gin-contrib/cors v1.4.0 // indirect + github.com/goccy/go-yaml v1.10.0 // indirect + github.com/golang-jwt/jwt/v5 v5.0.0-rc.1 // indirect + github.com/golang/protobuf v1.5.2 // indirect + github.com/gookit/color v1.5.2 // indirect + github.com/gookit/config/v2 v2.2.1 // indirect + github.com/gookit/goutil v0.6.6 // indirect + github.com/hellofresh/health-go/v5 v5.0.0 // indirect github.com/imdario/mergo v0.3.13 // indirect - github.com/mitchellh/copystructure v1.2.0 // indirect - github.com/mitchellh/reflectwalk v1.0.2 // indirect - github.com/shopspring/decimal v1.3.1 // indirect - github.com/spf13/cast v1.5.0 // indirect - github.com/tidwall/match v1.1.1 // indirect - github.com/tidwall/pretty v1.2.1 // indirect - go.uber.org/atomic v1.10.0 // indirect - go.uber.org/goleak v1.1.12 // indirect - go.uber.org/multierr v1.8.0 // indirect + github.com/lestrrat-go/backoff/v2 v2.0.8 // indirect + github.com/lestrrat-go/blackmagic v1.0.1 // indirect + github.com/lestrrat-go/httpcc v1.0.1 // indirect + github.com/lestrrat-go/iter v1.0.2 // indirect + github.com/lestrrat-go/jwx v1.2.25 // indirect + github.com/lestrrat-go/option v1.0.1 // indirect + github.com/mattn/go-colorable v0.1.13 // indirect + github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect + github.com/mitchellh/mapstructure v1.5.0 // indirect + github.com/patrickmn/go-cache v2.1.0+incompatible // indirect + github.com/pkg/errors v0.9.1 // indirect + github.com/prometheus/client_golang v1.14.0 // indirect + github.com/prometheus/client_model v0.3.0 // indirect + github.com/prometheus/common v0.37.0 // indirect + github.com/prometheus/procfs v0.8.0 // indirect + github.com/valyala/bytebufferpool v1.0.0 // indirect + github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect + go.opentelemetry.io/otel v1.10.0 // indirect + go.opentelemetry.io/otel/trace v1.10.0 // indirect + golang.org/x/sync v0.1.0 // indirect + golang.org/x/term v0.6.0 // indirect + golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect ) require ( - ariga.io/atlas v0.8.2 // indirect - github.com/Masterminds/sprig/v3 v3.2.2 - github.com/agext/levenshtein v1.2.3 // indirect - github.com/andybalholm/brotli v1.0.4 // indirect - github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect - github.com/cloudflare/cfssl v1.6.3 // indirect - github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 - github.com/fatih/color v1.13.0 // indirect - github.com/fxamacker/cbor/v2 v2.4.0 // indirect - github.com/go-openapi/inflect v0.19.0 // indirect - github.com/gofiber/template v1.7.2 - github.com/golang-jwt/jwt/v4 v4.4.2 - github.com/google/certificate-transparency-go v1.1.4 // indirect - github.com/google/go-cmp v0.5.9 // indirect + github.com/bytedance/sonic v1.8.5 // indirect + github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect + github.com/fiware/dsba-pdp v0.0.0-20230215083849-cf2b4c3daacf + github.com/gin-contrib/sse v0.1.0 // indirect + github.com/go-playground/locales v0.14.1 // indirect + github.com/go-playground/universal-translator v0.18.1 // indirect + github.com/go-playground/validator/v10 v10.11.2 // indirect + github.com/goccy/go-json v0.10.1 // indirect github.com/google/uuid v1.3.0 - github.com/gorilla/securecookie v1.1.1 // indirect - github.com/hashicorp/hcl/v2 v2.15.0 // indirect - github.com/hesusruiz/vcutils v0.0.0-20221011172906-f573373bbe40 - github.com/klauspost/compress v1.15.12 // indirect - github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.16 // indirect - github.com/mattn/go-runewidth v0.0.14 // indirect - github.com/mitchellh/go-wordwrap v1.0.1 // indirect - github.com/mitchellh/mapstructure v1.5.0 // indirect - github.com/rivo/uniseg v0.4.3 // indirect - github.com/tidwall/gjson v1.14.4 - github.com/valyala/bytebufferpool v1.0.0 // indirect - github.com/valyala/fasthttp v1.41.0 // indirect + github.com/json-iterator/go v1.1.12 // indirect + github.com/klauspost/cpuid/v2 v2.2.4 // indirect + github.com/leodido/go-urn v1.2.2 // indirect + github.com/mattn/go-isatty v0.0.17 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/pelletier/go-toml/v2 v2.0.7 // indirect + github.com/penglongli/gin-metrics v0.1.10 + github.com/sirupsen/logrus v1.9.0 + github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e + github.com/twitchyliquid64/golang-asm v0.15.1 // indirect + github.com/ugorji/go/codec v1.2.11 // indirect github.com/valyala/fasttemplate v1.2.2 - github.com/valyala/tcplisten v1.0.0 // indirect - github.com/x448/float16 v0.8.4 // indirect - github.com/zclconf/go-cty v1.12.1 // indirect - go.uber.org/zap v1.23.0 - golang.org/x/crypto v0.3.0 - golang.org/x/mod v0.7.0 // indirect - golang.org/x/sys v0.2.0 // indirect - golang.org/x/text v0.4.0 // indirect - golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect + golang.org/x/arch v0.3.0 // indirect + golang.org/x/crypto v0.7.0 // indirect + golang.org/x/net v0.8.0 // indirect + golang.org/x/sys v0.6.0 // indirect + golang.org/x/text v0.8.0 // indirect + google.golang.org/protobuf v1.30.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 2f1b1b31..11b5b470 100644 --- a/go.sum +++ b/go.sum @@ -1,15 +1,8 @@ -ariga.io/atlas v0.8.2 h1:uXRegk0Zd7nlCYC60tdx12xUvN2NmeGTc2MB5HnnbkA= -ariga.io/atlas v0.8.2/go.mod h1:ft47uSh5hWGDCmQC9DsztZg6Xk+KagM5Ts/mZYKb9JE= -bazil.org/fuse v0.0.0-20180421153158-65cc252bf669/go.mod h1:Xbm+BRKSBEpa4q4hTSxohYNQpsxXPbPry4JJWOB3LB8= -bitbucket.org/creachadair/shell v0.0.6/go.mod h1:8Qqi/cYk7vPnsOePHroKXDJYmb5x7ENhtiFtfZq8K+M= -bitbucket.org/liamstask/goose v0.0.0-20150115234039-8488cc47d90c/go.mod h1:hSVuE3qU7grINVSwrmzHfpg9k87ALBk+XaualNyUzI4= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= -cloud.google.com/go v0.39.0/go.mod h1:rVLT6fkc8chs9sfPtFc1SBH6em7n+ZoXaG+87tDISts= cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= -cloud.google.com/go v0.44.3/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= @@ -20,20 +13,6 @@ cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKV cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= -cloud.google.com/go v0.72.0/go.mod h1:M+5Vjvlc2wnp6tjzE102Dw08nGShTscUx2nZMufOKPI= -cloud.google.com/go v0.74.0/go.mod h1:VV1xSbzvo+9QJOxLDaJfTjx5e+MePCpCWwvftOeQmWk= -cloud.google.com/go v0.78.0/go.mod h1:QjdrLG0uq+YwhjoVOLsS1t7TW8fs36kLs4XO5R5ECHg= -cloud.google.com/go v0.79.0/go.mod h1:3bzgcEeQlzbuEAYu4mrWhKqWjmpprinYgKJLgKHnbb8= -cloud.google.com/go v0.81.0/go.mod h1:mk/AM35KwGk/Nm2YSeZbxXdrNK3KZOYHmLkOqC2V6E0= -cloud.google.com/go v0.83.0/go.mod h1:Z7MJUsANfY0pYPdw0lbnivPx4/vhy/e2FEkSkF7vAVY= -cloud.google.com/go v0.84.0/go.mod h1:RazrYuxIK6Kb7YrzzhPoLmCVzl7Sup4NrbKPg8KHSUM= -cloud.google.com/go v0.87.0/go.mod h1:TpDYlFy7vuLzZMMZ+B6iRiELaY7z/gJPaqbMx6mlWcY= -cloud.google.com/go v0.90.0/go.mod h1:kRX0mNRHe0e2rC6oNakvwQqzyDmg57xJ+SZU1eT2aDQ= -cloud.google.com/go v0.93.3/go.mod h1:8utlLll2EF5XMAV15woO4lSbWQlk8rer9aLOfLh7+YI= -cloud.google.com/go v0.94.1/go.mod h1:qAlAugsXlC+JWO+Bke5vCtc9ONxjQT3drlTTnAplMW4= -cloud.google.com/go v0.97.0/go.mod h1:GF7l59pYBVlXQIBLx3a761cZ41F9bBH3JUlihCt2Udc= -cloud.google.com/go v0.98.0/go.mod h1:ua6Ush4NALrHk5QXDWnjvZHN93OuF0HfuEPq9I1X0cM= -cloud.google.com/go v0.99.0/go.mod h1:w0Xx2nLzqWJPuozYQX+hFfCSI8WioryfRDzkoI/Y2ZA= cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= @@ -42,288 +21,119 @@ cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4g cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= -cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqClKRT5SZwBmk= -cloud.google.com/go/firestore v1.6.1/go.mod h1:asNXNOzBdyVQmEU+ggO8UPodTkEVFW5Qx+rwHnAz+EY= cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= -cloud.google.com/go/spanner v1.17.0/go.mod h1:+17t2ixFwRG4lWRwE+5kipDR9Ef07Jkmc8z0IbMDKUs= cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= -code.gitea.io/sdk/gitea v0.11.3/go.mod h1:z3uwDV/b9Ls47NGukYM9XhnHtqPh/J+t40lsUrR6JDY= -contrib.go.opencensus.io/exporter/aws v0.0.0-20181029163544-2befc13012d0/go.mod h1:uu1P0UCM/6RbsMrgPa98ll8ZcHM858i/AD06a9aLRCA= -contrib.go.opencensus.io/exporter/ocagent v0.5.0/go.mod h1:ImxhfLRpxoYiSq891pBrLVhN+qmP8BTVvdH2YLs7Gl0= -contrib.go.opencensus.io/exporter/stackdriver v0.12.1/go.mod h1:iwB6wGarfphGGe/e5CWqyUk/cLzKnWsOKPVW3no6OTw= -contrib.go.opencensus.io/exporter/stackdriver v0.13.5/go.mod h1:aXENhDJ1Y4lIg4EUaVTwzvYETVNZk10Pu26tevFKLUc= -contrib.go.opencensus.io/integrations/ocsql v0.1.4/go.mod h1:8DsSdjz3F+APR+0z0WkU1aRorQCFfRxvqjUUPMbF3fE= -contrib.go.opencensus.io/resource v0.1.1/go.mod h1:F361eGI91LCmW1I/Saf+rX0+OFcigGlFvXwEGEnkRLA= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -entgo.io/ent v0.11.0 h1:4G5GKmXOpHnIbWIkY2nZvNmuXmHpKWC4SYV1bqfoyZY= -entgo.io/ent v0.11.0/go.mod h1:Q8cDTupeHjWoIo0K8NyTyV0B9FVrFNSM9AnwnLt22KQ= -github.com/Azure/azure-amqp-common-go/v2 v2.1.0/go.mod h1:R8rea+gJRuJR6QxTir/XuEd+YuKoUiazDC/N96FiDEU= -github.com/Azure/azure-pipeline-go v0.2.1/go.mod h1:UGSo8XybXnIGZ3epmeBw7Jdz+HiUVpqIlpz/HKHylF4= -github.com/Azure/azure-sdk-for-go v29.0.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= -github.com/Azure/azure-sdk-for-go v30.1.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= -github.com/Azure/azure-service-bus-go v0.9.1/go.mod h1:yzBx6/BUGfjfeqbRZny9AQIbIe3AcV9WZbAdpkoXOa0= -github.com/Azure/azure-storage-blob-go v0.8.0/go.mod h1:lPI3aLPpuLTeUwh1sViKXFxwl2B6teiRqI0deQUvsw0= -github.com/Azure/go-autorest v12.0.0+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53/go.mod h1:+3IMCy2vIlbG1XG/0ggNQv0SvxCAIpPM5b1nCz56Xno= -github.com/CloudyKit/jet/v6 v6.1.0/go.mod h1:d3ypHeIRNo2+XyqnGA8s+aphtcVpjP5hPwP/Lzo7Ro4= -github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60= -github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= -github.com/GoogleCloudPlatform/cloudsql-proxy v0.0.0-20191009163259-e802c2cb94ae/go.mod h1:mjwGPas4yKduTyubHvD1Atl9r1rUq8DfVy+gkVvZ+oo= -github.com/Joker/hpp v1.0.0/go.mod h1:8x5n+M1Hp5hC0g8okX3sR3vFQwynaX/UgSOM9MeBKzY= -github.com/Joker/jade v1.1.3/go.mod h1:T+2WLyt7VH6Lp0TRxQrUYEs64nRc83wkMQrfeIQKduM= -github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= -github.com/Masterminds/goutils v1.1.0/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= -github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI= -github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= -github.com/Masterminds/semver v1.4.2/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y= -github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y= -github.com/Masterminds/semver/v3 v3.0.3/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= -github.com/Masterminds/semver/v3 v3.1.0/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= -github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc= -github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= -github.com/Masterminds/sprig v2.15.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o= -github.com/Masterminds/sprig v2.22.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o= -github.com/Masterminds/sprig/v3 v3.2.2 h1:17jRggJu518dr3QaafizSXOjKYp94wKfABxUmyxvxX8= -github.com/Masterminds/sprig/v3 v3.2.2/go.mod h1:UoaO7Yp8KlPnJIYWTFkMaqPUYKTfGFPhxNuwnnxkKlk= -github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= -github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= -github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= -github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= -github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c= -github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= -github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= -github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7/go.mod h1:6zEj6s6u/ghQa61ZWa/C2Aw3RkjiTBOix7dkqa1VLIs= -github.com/alecthomas/kingpin v2.2.6+incompatible/go.mod h1:59OFYbFVLKQKq+mqrL6Rw5bR0c3ACQaawgXx0QYndlE= +github.com/GeertJohan/go.incremental v1.0.0/go.mod h1:6fAjUhbVuX1KcMD3c8TEgVUqmo4seqhv0i0kdATSkM0= +github.com/GeertJohan/go.rice v1.0.0/go.mod h1:eH6gbSOAUv07dQuZVnBmoDP8mgsM1rtixis4Tib9if0= +github.com/akavel/rsrc v0.8.0/go.mod h1:uLoCtb9J+EyAqh+26kdrTgmzRBFPGOolLWKpdxkKq+c= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= -github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY= -github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= -github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= -github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= -github.com/aokoli/goutils v1.0.1/go.mod h1:SijmP0QR8LtwsmDs8Yii5Z/S4trXFGFC2oO5g9DP+DQ= -github.com/apache/beam v2.28.0+incompatible/go.mod h1:/8NX3Qi8vGstDLLaeaU7+lzVEu/ACaQhYjeefzQ0y1o= -github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= -github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= -github.com/apex/log v1.1.4/go.mod h1:AlpoD9aScyQfJDVHmLMEcx4oU6LqzkWp4Mg9GdAcEvQ= -github.com/apex/logs v0.0.4/go.mod h1:XzxuLZ5myVHDy9SAmYpamKKRNApGj54PfYLcFrXqDwo= -github.com/aphistic/golf v0.0.0-20180712155816-02c07f170c5a/go.mod h1:3NqKYiepwy8kCu4PNA+aP7WUV72eXWJeP9/r3/K9aLE= -github.com/aphistic/sweet v0.2.0/go.mod h1:fWDlIh/isSE9n6EPsRmC0det+whmX6dJid3stzu0Xys= -github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw= -github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo= -github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= -github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= -github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= -github.com/armon/go-metrics v0.3.10/go.mod h1:4O98XIr/9W0sxpJ8UaYkvjk10Iff7SnFrb4QAOwNTFc= -github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= -github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= -github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= -github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6lCRdSC2Tm3DSWRPvIPr6xNKyeHdqDQSQT+A= -github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU= -github.com/aws/aws-sdk-go v1.15.27/go.mod h1:mFuSZ37Z9YOHbQEwBWztmVzqXrEkub65tZoCYDt7FT0= -github.com/aws/aws-sdk-go v1.19.18/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= -github.com/aws/aws-sdk-go v1.19.45/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= -github.com/aws/aws-sdk-go v1.20.6/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= -github.com/aws/aws-sdk-go v1.23.20/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= -github.com/aws/aws-sdk-go v1.25.11/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= -github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= -github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= -github.com/aybabtme/rgbterm v0.0.0-20170906152045-cc83f3b3ce59/go.mod h1:q/89r3U2H7sSsE2t6Kca0lfwTK8JdoNGS/yzM/4iH5I= -github.com/aymerick/raymond v2.0.2+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= -github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= -github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= +github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= -github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= -github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84= -github.com/blakesmith/ar v0.0.0-20190502131153-809d4375e1fb/go.mod h1:PkYb9DJNAwrSvRx5DYA+gUcOIgTGVMNkfSCbZM8cWpI= -github.com/caarlos0/ctrlc v1.0.0/go.mod h1:CdXpj4rmq0q/1Eb44M9zi2nKB0QraNKuRGYGrrHhcQw= -github.com/campoy/unique v0.0.0-20180121183637-88950e537e7e/go.mod h1:9IOqJGCPMSc6E5ydlp5NIonxObaeu/Iub/X03EKPVYo= -github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ= -github.com/cavaliercoder/go-cpio v0.0.0-20180626203310-925f9528c45e/go.mod h1:oDpT4efm8tSYHXV5tHSdRvBet/b/QzxZ+XyyPehvm3A= -github.com/cbroglie/mustache v1.4.0/go.mod h1:SS1FTIghy0sjse4DUVGV1k/40B1qE1XkD9DtDsHo9iM= -github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= -github.com/census-instrumentation/opencensus-proto v0.2.0/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/bits-and-blooms/bitset v1.2.0 h1:Kn4yilvwNtMACtf1eYDlG8H77R07mZSPbMjLyS07ChA= +github.com/bits-and-blooms/bitset v1.2.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA= +github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM= +github.com/bytedance/sonic v1.8.0 h1:ea0Xadu+sHlu7x5O3gKhRpQ1IKiMrSiHttPF0ybECuA= +github.com/bytedance/sonic v1.8.0/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U= +github.com/bytedance/sonic v1.8.5 h1:kjX0/vo5acEQ/sinD/18SkA/lDDUk23F0RcaHvI7omc= +github.com/bytedance/sonic v1.8.5/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/census-instrumentation/opencensus-proto v0.3.0/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/certifi/gocertifi v0.0.0-20191021191039-0944d244cd40/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA= -github.com/certifi/gocertifi v0.0.0-20210507211836-431795d63e8d/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA= -github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE= github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY= +github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 h1:qSGYFH7+jGhDF8vLC+iwCD4WpbV1EBDSzWkJODFLams= +github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= -github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag= -github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= -github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4dUb/I5gc9Hdhagfvm9+RyrPryS/auMzxE= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/cloudflare/backoff v0.0.0-20161212185259-647f3cdfc87a/go.mod h1:rzgs2ZOiguV6/NpiDgADjRLPNyZlApIWxKpkT+X8SdY= -github.com/cloudflare/cfssl v1.6.3 h1:hDhRaGQN55nh0510/7A5QBN3xLoDz/M7nQX80icXvzs= -github.com/cloudflare/cfssl v1.6.3/go.mod h1:Kq0iHKY8sm2klDeQ2Ci/FI+6QdBGuyPWodgTJFLrXIw= -github.com/cloudflare/redoctober v0.0.0-20201013214028-99c99a8e7544/go.mod h1:6Se34jNoqrd8bTxrmJB2Bg2aoZ2CdSXonils9NsiNgo= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= -github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= -github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= -github.com/cncf/udpa/go v0.0.0-20210322005330-6414d713912e/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= -github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= -github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20211130200136-a8f946100490/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= -github.com/cockroachdb/datadriven v0.0.0-20200714090401-bf6692d28da5/go.mod h1:h6jFvWxBdQXxjopDMZyH2UVceIRfR84bdzbkoKrsWNo= -github.com/cockroachdb/errors v1.2.4/go.mod h1:rQD95gz6FARkaKkQXUksEje/d9a6wBJoCr5oaCLELYA= -github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f/go.mod h1:i/u985jwjWRlyHXQbwatDASoW0RMlZ/3i9yJHE2xLkI= -github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= -github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= -github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= -github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= -github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= -github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= -github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= -github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= -github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= -github.com/coreos/go-systemd/v22 v22.1.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+1atmu1JpKERPPk= -github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= -github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= -github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= -github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= -github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= -github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= -github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= -github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= -github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= -github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= -github.com/davecgh/go-spew v0.0.0-20161028175848-04cdfd42973b/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/daaku/go.zipexe v1.0.0/go.mod h1:z8IiR6TsVLEYKwXAoE/I+8ys/sDkgTzSL0CLnGVd57E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.0-20210816181553-5444fa50b93d/go.mod h1:tmAIfUFEirG/Y8jhZ9M+h36obRZAk/1fcSpXwAVlfqE= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 h1:HbphB4TFFXpv7MNrT52FGrrgVXF1owhMVTHFZIlnvd4= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0/go.mod h1:DZGJHZMqrU4JJqFAWUS2UO1+lbSKsdiOoYi9Zzey7Fc= -github.com/devigned/tab v0.1.1/go.mod h1:XG9mPq0dFghrYvoBF3xdRrJzSTX1b7IQrvaL9mzjeJY= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= -github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= -github.com/dimchansky/utfbom v1.1.0/go.mod h1:rO41eb7gLfo8SF1jd9F8HplJm1Fewwi4mQvIirEdv+8= -github.com/duo-labs/webauthn v0.0.0-20220815211337-00c9fb5711f5 h1:BaeJtFDlto/NjX9t730OebRRJf2P+t9YEDz3ur18824= -github.com/duo-labs/webauthn v0.0.0-20220815211337-00c9fb5711f5/go.mod h1:Jcj7rFNlTknb18v9jpSA58BveX2LDhXqaoy+6YV1N9g= -github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= -github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= -github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= -github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= -github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= -github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= -github.com/eknkc/amber v0.0.0-20171010120322-cdade1c07385/go.mod h1:0vRUJqYpeSZifjYj7uP3BG/gKcuzL9xWVV/Y+cK33KM= -github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o= -github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= -github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po= -github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= -github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= -github.com/envoyproxy/go-control-plane v0.10.1/go.mod h1:AY7fTTXNdv/aJ2O5jwpxAPOWUZ7hQAEvzN5Pf27BkQQ= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/envoyproxy/protoc-gen-validate v0.3.0-java/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/envoyproxy/protoc-gen-validate v0.6.1/go.mod h1:txg5va2Qkip90uYoSKH+nkAAmXrb2j3iq4FLwdrCbXQ= -github.com/envoyproxy/protoc-gen-validate v0.6.2/go.mod h1:2t7qjJNvHPx8IjnBOzl9E9/baC+qXE/TeeyBRzgJDws= -github.com/etcd-io/gofail v0.0.0-20190801230047-ad7f989257ca/go.mod h1:49H/RkXP8pKaZy4h0d+NW16rSLhyVBt4o6VLJbmOqDE= -github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= -github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM= -github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= -github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= -github.com/flosch/pongo2/v4 v4.0.2/go.mod h1:B5ObFANs/36VwxxlgKpdchIJHMvHB562PW+BWPhwZD8= -github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= -github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= -github.com/form3tech-oss/jwt-go v3.2.3+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= -github.com/fortytw2/leaktest v1.2.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= -github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= -github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4= -github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20= -github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE= -github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/fsnotify/fsnotify v1.5.1/go.mod h1:T3375wBYaZdLLcVNkcVbzGHY7f1l/uK5T5Ai1i3InKU= -github.com/fullstorydev/grpcurl v1.8.0/go.mod h1:Mn2jWbdMrQGJQ8UD62uNyMumT2acsZUCkZIqFxsQf1o= -github.com/fullstorydev/grpcurl v1.8.1/go.mod h1:3BWhvHZwNO7iLXaQlojdg5NA6SxUDePli4ecpK1N7gw= -github.com/fxamacker/cbor/v2 v2.4.0 h1:ri0ArlOR+5XunOP8CRUowT0pSJOwhW098ZCUyskZD88= -github.com/fxamacker/cbor/v2 v2.4.0/go.mod h1:TA1xS00nchWmaBnEIxPSE5oHLuJBAVvqrtAnWBwBCVo= -github.com/getsentry/raven-go v0.2.0/go.mod h1:KungGk8q33+aIAZUIVWZDr2OfAEBsO49PX4NzFV5kcQ= -github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= -github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= +github.com/fatih/color v1.14.1 h1:qfhVLaG5s+nCROl1zJsZRxFeYrHLqWroPOQ8BWiNb4w= +github.com/fatih/color v1.14.1/go.mod h1:2oHN61fhTpgcxD3TSWCgKDiH1+x4OiDVVGH8WlgGZGg= +github.com/fiware/dsba-pdp v0.0.0-20230215083849-cf2b4c3daacf h1:2bEmlh0Au6+n66cYm+5ECFzfwUqlHPAIWLJ28rOjkoc= +github.com/fiware/dsba-pdp v0.0.0-20230215083849-cf2b4c3daacf/go.mod h1:HpYuQF4RWRFxAFkqItyaCszNbOarnCOFuqKxWMGvFEI= +github.com/foolin/goview v0.3.0 h1:q5wKwXKEFb20dMRfYd59uj5qGCo7q4L9eVHHUjmMWrg= +github.com/foolin/goview v0.3.0/go.mod h1:OC1VHC4FfpWymhShj8L1Tc3qipFmrmm+luAEdTvkos4= +github.com/gin-contrib/cors v1.4.0 h1:oJ6gwtUl3lqV0WEIwM/LxPF1QZ5qe2lGWdY2+bz7y0g= +github.com/gin-contrib/cors v1.4.0/go.mod h1:bs9pNM0x/UsmHPBWT2xZz9ROh8xYjYkiURUfmBoMlcs= +github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s= +github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= +github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= +github.com/gin-gonic/gin v1.4.0/go.mod h1:OW2EZn3DO8Ln9oIKOvM++LBO+5UPHJJDH72/q/3rZdM= +github.com/gin-gonic/gin v1.7.4/go.mod h1:jD2toBW3GZUr5UMcdrwQA10I7RuaFOl/SGeDjXkfUtY= +github.com/gin-gonic/gin v1.8.1/go.mod h1:ji8BvRH1azfM+SYow9zQ6SZMvR8qOMZHmsCuWR9tTTk= +github.com/gin-gonic/gin v1.9.0 h1:OjyFBKICoexlu99ctXNR2gg+c5pKrKMuyjgARg9qeY8= +github.com/gin-gonic/gin v1.9.0/go.mod h1:W1Me9+hsUSyj3CePGrd1/QrKJMSJ1Tu/0hFEH89961k= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-ini/ini v1.25.4/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o= +github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= +github.com/go-kit/log v0.2.0/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= -github.com/go-openapi/inflect v0.19.0 h1:9jCH9scKIbHeV9m12SmPilScz6krDxKRasNNSNPXu/4= -github.com/go-openapi/inflect v0.19.0/go.mod h1:lHpZVlpIQqLyKwJ4N+YSc9hchQy/i12fJykb83CRBH4= +github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= -github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= -github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no= +github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs= +github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= +github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= -github.com/go-playground/validator/v10 v10.4.1 h1:pH2c5ADXtd66mxoE0Zm9SUhxE20r7aM3F26W0hOn+GE= +github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA= +github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= +github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4= -github.com/go-redis/redis v6.15.9+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA= -github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= -github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= -github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= -github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= +github.com/go-playground/validator/v10 v10.10.0/go.mod h1:74x4gJWsvQexRdW8Pn3dXSGrTK4nAUsbPlLADvpJkos= +github.com/go-playground/validator/v10 v10.11.2 h1:q3SHpufmypg+erIExEKUmsgmhDTyhcJ38oeKGACXohU= +github.com/go-playground/validator/v10 v10.11.2/go.mod h1:NieE624vt4SCTJtD87arVLvdmjPAeV8BQlHtMnw9D7s= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= -github.com/goccy/go-yaml v1.9.6 h1:KhAu1zf9JXnm3vbG49aDE0E5uEBUsM4uwD31/58ZWyI= -github.com/goccy/go-yaml v1.9.6/go.mod h1:JubOolP3gh0HpiBc4BLRD4YmjEjHAmIIB2aaXKkTfoE= -github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= -github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= -github.com/gofiber/fiber/v2 v2.39.0/go.mod h1:Cmuu+elPYGqlvQvdKyjtYsjGMi69PDp8a1AY2I5B2gM= -github.com/gofiber/fiber/v2 v2.40.1 h1:pc7n9VVpGIqNsvg9IPLQhyFEMJL8gCs1kneH5D1pIl4= -github.com/gofiber/fiber/v2 v2.40.1/go.mod h1:Gko04sLksnHbzLSRBFWPFdzM9Ws9pRxvvIaohJK1dsk= -github.com/gofiber/storage/memory v0.0.0-20221128090226-a21499405c25 h1:2Li0tAx47d4n2AF85ARdXHUJSbiWTNu7cFEcf64aIKw= -github.com/gofiber/storage/memory v0.0.0-20221128090226-a21499405c25/go.mod h1:pYsCUle/+4exGfsG7IlpmFYBVmNntP8OIDBvmABU8PE= -github.com/gofiber/template v1.7.2 h1:sCHY5WcvmLtR7t8ihXCs5HRdYv4W9EzgBIMbUl4a5zw= -github.com/gofiber/template v1.7.2/go.mod h1:uk/mUKTXJMBMoETvo/5CA/QlTFERHMooOm0pJPGDGVA= -github.com/gofiber/utils v1.0.1 h1:knct4cXwBipWQqFrOy1Pv6UcgPM+EXo9jDgc66V1Qio= -github.com/gofiber/utils v1.0.1/go.mod h1:pacRFtghAE3UoknMOUiXh2Io/nLWSUHtQCi/3QASsOc= -github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= +github.com/goccy/go-json v0.9.7/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= +github.com/goccy/go-json v0.10.0 h1:mXKd9Qw4NuzShiRlOXKews24ufknHO7gx30lsDyokKA= +github.com/goccy/go-json v0.10.0/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= +github.com/goccy/go-json v0.10.1 h1:lEs5Ob+oOG/Ze199njvzHbhn6p9T+h64F5hRj69iTTo= +github.com/goccy/go-json v0.10.1/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= +github.com/goccy/go-yaml v1.10.0 h1:rBi+5HGuznOxx0JZ+60LDY85gc0dyIJCIMvsMJTKSKQ= +github.com/goccy/go-yaml v1.10.0/go.mod h1:h/18Lr6oSQ3mvmqFoWmQ47KChOgpfHpTyIHl3yVmpiY= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= -github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= -github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= -github.com/gogo/protobuf v1.3.0/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= -github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang-jwt/jwt/v4 v4.4.2 h1:rcc4lwaZgFMCZ5jxF9ABolDcIHdBytAFgqFPbSJQAYs= -github.com/golang-jwt/jwt/v4 v4.4.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY= +github.com/golang-jwt/jwt/v5 v5.0.0-rc.1 h1:tDQ1LjKga657layZ4JLsRdxgvupebc0xuPwRNuTfUgs= +github.com/golang-jwt/jwt/v5 v5.0.0-rc.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/glog v0.0.0-20210429001901-424d2337a529/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= @@ -331,8 +141,6 @@ github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= -github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8= -github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -348,18 +156,10 @@ github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QD github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM= +github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/btree v1.0.1/go.mod h1:xXMiIv4Fb/0kKde4SpL7qlzvu5cMJDRkFDxJfI9uaxA= -github.com/google/certificate-transparency-go v1.0.21/go.mod h1:QeJfpSbVSfYc7RgB3gJFj9cbuQMMchQxrWXz8Ruopmg= -github.com/google/certificate-transparency-go v1.1.2-0.20210422104406-9f33727a7a18/go.mod h1:6CKh9dscIRoqc2kC6YUFICHZMT9NrClyPrRVFrdw1QQ= -github.com/google/certificate-transparency-go v1.1.2-0.20210511102531-373a877eec92/go.mod h1:kXWPsHVPSKVuxPPG69BRtumCbAW537FydV/GH89oBhM= -github.com/google/certificate-transparency-go v1.1.4 h1:hCyXHDbtqlr/lMXU0D4WgbalXL0Zk4dSWWMbPV8VrqY= -github.com/google/certificate-transparency-go v1.1.4/go.mod h1:D6lvbfwckhNrbM9WVl1EVeMOyzC19mpIjMOI4nxBHtQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= @@ -367,25 +167,12 @@ github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/go-github/v28 v28.1.1/go.mod h1:bsqJWQX05omyWVmc00nEUql9mhQyv38lDZ8kPZcQVoM= -github.com/google/go-licenses v0.0.0-20210329231322-ce1d9163b77d/go.mod h1:+TYOmkVoJOpwnS0wfdsJCV9CoD5nJYsHoFk/0CrTK4M= -github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= -github.com/google/go-replayers/grpcreplay v0.1.0/go.mod h1:8Ig2Idjpr6gifRd6pNVggX6TC1Zw6Jx74AKp7QNH2QE= -github.com/google/go-replayers/httpreplay v0.1.0/go.mod h1:YKZViNhiGgqdBlUbI2MwGpq4pXxNmhJLPHQ7cv2b5no= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/licenseclassifier v0.0.0-20210325184830-bb04aff29e72/go.mod h1:qsqn2hxC+vURpyBRygGUuinTO42MFRLcsmQ/P8v94+M= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= -github.com/google/martian v2.1.1-0.20190517191504-25dcb96d9e51+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= -github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= -github.com/google/martian/v3 v3.2.1/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= @@ -393,574 +180,214 @@ github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hf github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210122040257-d980be63207e/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= -github.com/google/rpmpack v0.0.0-20191226140753-aa36bfddb3a0/go.mod h1:RaTPr0KUf2K7fnZYLNDrr8rxAamWs3iNywJLtQ2AzBg= -github.com/google/subcommands v1.0.1/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= -github.com/google/trillian v1.3.14-0.20210409160123-c5ea3abd4a41/go.mod h1:1dPv0CUjNQVFEDuAUFhZql16pw/VlPgaX8qj+g5pVzQ= -github.com/google/trillian v1.3.14-0.20210428093031-b4ddea2e86b1/go.mod h1:FdIJX+NoDk/dIN2ZxTyz5nAJWgf+NSSSriPAMThChTY= -github.com/google/uuid v0.0.0-20161128191214-064e2069ce9c/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/wire v0.3.0/go.mod h1:i1DMg/Lu8Sz5yYl25iOdmc5CT5qusaa+zmRWs16741s= -github.com/googleapis/gax-go v2.0.2+incompatible/go.mod h1:SFVmujtThgffbyetf+mdk2eWhX2bMyUtNHzFKcPA9HY= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= -github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0= -github.com/googleapis/gax-go/v2 v2.1.1/go.mod h1:hddJymUZASv3XPyGkUpKj8pPO47Rmb0eJc8R6ouapiM= -github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= -github.com/gordonklaus/ineffassign v0.0.0-20200309095847-7953dde2c7bf/go.mod h1:cuNKsD1zp2v6XfE/orVX2QE1LC+i254ceGcVeDT3pTU= -github.com/goreleaser/goreleaser v0.134.0/go.mod h1:ZT6Y2rSYa6NxQzIsdfWWNWAlYGXGbreo66NmE+3X3WQ= -github.com/goreleaser/nfpm v1.2.1/go.mod h1:TtWrABZozuLOttX2uDlYyECfQX7x5XYkVxhjYcR6G9w= -github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= -github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= -github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= -github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyCS8BvQ= -github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4= -github.com/gorilla/sessions v1.2.1 h1:DHd3rPN5lE3Ts3D8rKkQ8x/0kqfeNmBAaiSi+o7FsgI= -github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM= -github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= -github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= -github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= -github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= -github.com/grpc-ecosystem/go-grpc-middleware v1.2.2/go.mod h1:EaizFBKfUKtMIF5iaDEhniwNedqGo9FuLFzppDr3uwI= -github.com/grpc-ecosystem/go-grpc-middleware v1.3.0/go.mod h1:z0ButlSOZa5vEBq9m2m2hlwIgKw+rp3sdCBRoJY+30Y= -github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= -github.com/grpc-ecosystem/grpc-gateway v1.8.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= -github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= -github.com/grpc-ecosystem/grpc-gateway v1.9.2/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= -github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= -github.com/grpc-ecosystem/grpc-gateway v1.14.6/go.mod h1:zdiPV4Yse/1gnckTHtghG4GkDEdKCRJduHpTxT3/jcw= -github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= -github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q= -github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE= -github.com/hashicorp/consul/api v1.11.0/go.mod h1:XjsvQN+RJGWI2TWy1/kqaE16HrR2J/FWgkYjdZQsX9M= -github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= -github.com/hashicorp/consul/sdk v0.3.0/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= -github.com/hashicorp/consul/sdk v0.8.0/go.mod h1:GBvyrGALthsZObzUGsfgHZQDXjg4lOjagTIwIR1vPms= -github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= -github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= -github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= -github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= -github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= -github.com/hashicorp/go-hclog v0.12.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= -github.com/hashicorp/go-hclog v1.0.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= -github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= -github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= -github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= -github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= -github.com/hashicorp/go-multierror v1.1.0/go.mod h1:spPvp8C1qA32ftKqdAHm4hHTbPw+vmowP0z+KUhOZdA= -github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= -github.com/hashicorp/go-retryablehttp v0.6.4/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER/9wtLZZ8meHqQvEYWY= -github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= -github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= -github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= -github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= -github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= +github.com/gookit/color v1.5.2 h1:uLnfXcaFjlrDnQDT+NCBcfhrXqYTx/rcCa6xn01Y8yI= +github.com/gookit/color v1.5.2/go.mod h1:w8h4bGiHeeBpvQVePTutdbERIUf3oJE5lZ8HM0UgXyg= +github.com/gookit/config/v2 v2.2.1 h1:9WOXW5JCDwLcShdQZ1Ztzr67qrI63jjRmT+Cm3lzk7Q= +github.com/gookit/config/v2 v2.2.1/go.mod h1:22ZTM0ve1ESyAx/ocUfjOrQ5ztFwy1Rs3YH1ifu9XXc= +github.com/gookit/goutil v0.6.6 h1:XdvnPocHpKDXA+eykfc/F846Y1V2Vyo3+cV8rfliG90= +github.com/gookit/goutil v0.6.6/go.mod h1:D++7kbQd/6vECyYTxB5tq6AKDIG9ZYwZNhubWJvN9dw= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= -github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= -github.com/hashicorp/hcl/v2 v2.15.0 h1:CPDXO6+uORPjKflkWCCwoWc9uRp+zSIPcCQ+BrxV7m8= -github.com/hashicorp/hcl/v2 v2.15.0/go.mod h1:JRmR89jycNkrrqnMmvPDMd56n1rQJ2Q6KocSLCMCXng= -github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= -github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= -github.com/hashicorp/mdns v1.0.1/go.mod h1:4gW7WsVCke5TE7EPeYliwHlRUyBtfCwuFwuMg2DmyNY= -github.com/hashicorp/mdns v1.0.4/go.mod h1:mtBihi+LeNXGtG8L9dX59gAEa12BDtBQSp4v/YAJqrc= -github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= -github.com/hashicorp/memberlist v0.2.2/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOnAH9VT3Sh9MUE= -github.com/hashicorp/memberlist v0.3.0/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOnAH9VT3Sh9MUE= -github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= -github.com/hashicorp/serf v0.9.5/go.mod h1:UWDWwZeL5cuWDJdl0C6wrvrUwEqtQ4ZKBKKENpqIUyk= -github.com/hashicorp/serf v0.9.6/go.mod h1:TXZNMjZQijwlDvp+r0b63xZ45H7JmCmgg4gpTwn9UV4= -github.com/hesusruiz/vcutils v0.0.0-20221011172906-f573373bbe40 h1:Xm80TtFeagIP8Oy6+3piAE9dmbT6xKHSkDFOaFuFogU= -github.com/hesusruiz/vcutils v0.0.0-20221011172906-f573373bbe40/go.mod h1:a6e0tbmiKjvvdIdCRXALijm4rE45rCz9pnUnmQ/n0jI= -github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/huandu/xstrings v1.0.0/go.mod h1:4qWG/gcEcfX4z/mBDHJ++3ReCw9ibxbsNJbcucJdbSo= -github.com/huandu/xstrings v1.2.0/go.mod h1:DvyZB1rfVYsBIigL8HwpZgxHwXozlTgGqn63UyNX5k4= -github.com/huandu/xstrings v1.3.1/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= -github.com/huandu/xstrings v1.3.3 h1:/Gcsuc1x8JVbJ9/rlye4xZnVAbEkGauT8lbebqcQws4= -github.com/huandu/xstrings v1.3.3/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= -github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg= -github.com/iancoleman/strcase v0.0.0-20180726023541-3605ed457bf7/go.mod h1:SK73tn/9oHe+/Y0h39VT4UCxmurVJkR5NA7kMEAOgSE= -github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= +github.com/hellofresh/health-go/v5 v5.0.0 h1:jxjllHekqEU4VYIajKJtFoOxDp1YaaygNWwAoZwWFh0= +github.com/hellofresh/health-go/v5 v5.0.0/go.mod h1:9hFVIBdKkxrg1bJurUPlw1D/0FWhl47IVfGYPy4Op9o= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= -github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= -github.com/imdario/mergo v0.3.4/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= -github.com/imdario/mergo v0.3.8/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= -github.com/imdario/mergo v0.3.9/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= -github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk= github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg= -github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= -github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= -github.com/jarcoal/httpmock v1.0.5/go.mod h1:ATjnClrvW/3tijVmpL/va5Z3aAyGvqU3gCT8nX0Txik= -github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= -github.com/jhump/protoreflect v1.6.1/go.mod h1:RZQ/lnuN+zqeRVpQigTwO6o0AJUkxbnSnpuG7toUTG4= -github.com/jhump/protoreflect v1.8.2/go.mod h1:7GcYQDdMU/O/BBrl/cX6PNHpXh6cenjd8pneu5yW7Tg= -github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= -github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= -github.com/jmhodges/clock v0.0.0-20160418191101-880ee4c33548/go.mod h1:hGT6jSUVzF6no3QaDSMLGLEHtHSBSefs+MgcDWnmhmo= -github.com/jmoiron/sqlx v1.3.3/go.mod h1:2BljVx/86SuTyjE+aPYlHCTNvZrnJXghYGpNiXLBMCQ= -github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= -github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= -github.com/jonboulle/clockwork v0.2.2/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8= -github.com/jpillora/backoff v0.0.0-20180909062703-3050d21c67d7/go.mod h1:2iMrUgbbvHEiQClaW2NsSzMyGHqN+rDFqY705q49KG0= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= -github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= -github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= -github.com/juju/ratelimit v1.0.1/go.mod h1:qapgC/Gy+xNh9UxzV13HGGl/6UXNN+ct+vwSgWNm/qk= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= -github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= -github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= -github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/kisielk/sqlstruct v0.0.0-20201105191214-5f3e10d3ab46/go.mod h1:yyMNCyc/Ib3bDTKd379tNMpB/7/H5TjM2Y9QJ5THLbE= -github.com/kisom/goutils v1.4.3/go.mod h1:Lp5qrquG7yhYnWzZCI/68Pa/GpFynw//od6EkGnWpac= -github.com/klauspost/compress v1.15.0/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= -github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU= -github.com/klauspost/compress v1.15.12 h1:YClS/PImqYbn+UILDnqxQCZ3RehC9N318SU3kElDUEM= -github.com/klauspost/compress v1.15.12/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM= +github.com/klauspost/cpuid/v2 v2.0.9 h1:lgaqFMSdTdQYdZ04uHyN2d/eKdOMyi2YLSvlQIBFYa4= +github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= +github.com/klauspost/cpuid/v2 v2.2.4 h1:acbojRNwl3o09bUq+yDCtZFc1aiwaAAxtcn8YkZXnvk= +github.com/klauspost/cpuid/v2 v2.2.4/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= -github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/kylelemons/go-gypsy v1.0.0/go.mod h1:chkXM0zjdpXOiqkCW1XcCHDfjfk14PH2KKkQWxfJUcU= -github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= -github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= +github.com/labstack/echo v3.3.10+incompatible/go.mod h1:0INS7j/VjnFxD4E2wkz67b8cVwCLbBmJyDaka6Cmk1s= +github.com/labstack/echo/v4 v4.1.6/go.mod h1:kU/7PwzgNxZH4das4XNsSpBSOD09XIF5YEPzjpkGnGE= +github.com/labstack/gommon v0.2.9/go.mod h1:E8ZTmW9vw5az5/ZyHWCp0Lw4OH2ecsaBP1C/NKavGG4= github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= -github.com/letsencrypt/pkcs11key/v4 v4.0.0/go.mod h1:EFUvBDay26dErnNb70Nd0/VW3tJiIbETBPTl9ATXQag= -github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= -github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= -github.com/lib/pq v1.10.1/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= -github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= -github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4= -github.com/lyft/protoc-gen-star v0.5.1/go.mod h1:9toiA3cC7z5uVbODF7kEQ91Xn7XNFkVUl+SrEe+ZORU= -github.com/lyft/protoc-gen-star v0.5.3/go.mod h1:V0xaHgaf5oCCqmcxYcWiDfTiKsZsRc87/1qhoTACD8w= -github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= -github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= -github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= -github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= -github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= -github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ= +github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w= +github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= +github.com/leodido/go-urn v1.2.2 h1:7z68G0FCGvDk646jz1AelTYNYWrTNm0bEcFAo147wt4= +github.com/leodido/go-urn v1.2.2/go.mod h1:kUaIbLZWttglzwNuG0pgsh5vuV6u2YcGBYz1hIPjtOQ= +github.com/lestrrat-go/backoff/v2 v2.0.8 h1:oNb5E5isby2kiro9AgdHLv5N5tint1AnDVVf2E2un5A= +github.com/lestrrat-go/backoff/v2 v2.0.8/go.mod h1:rHP/q/r9aT27n24JQLa7JhSQZCKBBOiM/uP402WwN8Y= +github.com/lestrrat-go/blackmagic v1.0.0/go.mod h1:TNgH//0vYSs8VXDCfkZLgIrVTTXQELZffUV0tz3MtdQ= +github.com/lestrrat-go/blackmagic v1.0.1 h1:lS5Zts+5HIC/8og6cGHb0uCcNCa3OUt1ygh3Qz2Fe80= +github.com/lestrrat-go/blackmagic v1.0.1/go.mod h1:UrEqBzIR2U6CnzVyUtfM6oZNMt/7O7Vohk2J0OGSAtU= +github.com/lestrrat-go/httpcc v1.0.1 h1:ydWCStUeJLkpYyjLDHihupbn2tYmZ7m22BGkcvZZrIE= +github.com/lestrrat-go/httpcc v1.0.1/go.mod h1:qiltp3Mt56+55GPVCbTdM9MlqhvzyuL6W/NMDA8vA5E= +github.com/lestrrat-go/iter v1.0.1/go.mod h1:zIdgO1mRKhn8l9vrZJZz9TUMMFbQbLeTsbqPDrJ/OJc= +github.com/lestrrat-go/iter v1.0.2 h1:gMXo1q4c2pHmC3dn8LzRhJfP1ceCbgSiT9lUydIzltI= +github.com/lestrrat-go/iter v1.0.2/go.mod h1:Momfcq3AnRlRjI5b5O8/G5/BvpzrhoFTZcn06fEOPt4= +github.com/lestrrat-go/jwx v1.2.25 h1:tAx93jN2SdPvFn08fHNAhqFJazn5mBBOB8Zli0g0otA= +github.com/lestrrat-go/jwx v1.2.25/go.mod h1:zoNuZymNl5lgdcu6P7K6ie2QRll5HVfF4xwxBBK1NxY= +github.com/lestrrat-go/option v1.0.0/go.mod h1:5ZHFbivi4xwXxhxY9XHDe2FHo6/Z7WWmtT7T5nBBp3I= +github.com/lestrrat-go/option v1.0.1 h1:oAzP2fvZGQKWkvHa1/SAcFolBEca1oN+mQ7eooNBEYU= +github.com/lestrrat-go/option v1.0.1/go.mod h1:5ZHFbivi4xwXxhxY9XHDe2FHo6/Z7WWmtT7T5nBBp3I= github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= -github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= -github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= -github.com/mattn/go-ieproxy v0.0.0-20190610004146-91bb50d98149/go.mod h1:31jz6HNzdxOmlERGGEc4v/dMssOfmp2p5bT/okiKFFc= -github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= -github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= -github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= -github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= -github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= -github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= -github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= -github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk= -github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU= -github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= -github.com/mattn/go-shellwords v1.0.10/go.mod h1:EZzvwXDESEeg03EKmM+RmDnNOPKG4lLtQsUlTZDWQ8Y= -github.com/mattn/go-slim v0.0.0-20200618151855-bde33eecb5ee/go.mod h1:ma9TUJeni8LGZMJvOwbAv/FOwiwqIMQN570LnpqCBSM= -github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= -github.com/mattn/go-sqlite3 v1.14.7/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= -github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y= -github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= -github.com/mattn/go-zglob v0.0.1/go.mod h1:9fxibJccNxU2cnpIKLRRFA7zX7qhkJIQWBb449FYHOo= +github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng= +github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= -github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE= -github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= -github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso= -github.com/miekg/dns v1.1.41/go.mod h1:p6aan82bvRIyn+zDIv9xYNUpwa73JcSh9BKwknJysuI= -github.com/miekg/pkcs11 v1.0.2/go.mod h1:XsNlhZGX73bx86s2hdc/FuaLm2CPZJemRLMA+WTFxgs= -github.com/miekg/pkcs11 v1.0.3/go.mod h1:XsNlhZGX73bx86s2hdc/FuaLm2CPZJemRLMA+WTFxgs= -github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= -github.com/mitchellh/cli v1.1.0/go.mod h1:xcISNoH86gajksDmfB23e/pu+B+GeFRMYmoHXxx3xhI= -github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= -github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= -github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= -github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= -github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= -github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= -github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= -github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= -github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= -github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= -github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/mitchellh/mapstructure v1.4.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= -github.com/mitchellh/reflectwalk v1.0.1/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= -github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= -github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= -github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8= -github.com/mreiferson/go-httpclient v0.0.0-20160630210159-31f0106b4474/go.mod h1:OQA4XLvDbMgS8P0CevmM4m9Q3Jq4phKUzcocxuGJ5m8= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= -github.com/mwitkow/go-proto-validators v0.0.0-20180403085117-0950a7990007/go.mod h1:m2XC9Qq0AlmmVksL6FktJCdTYyLk7V3fKyp0sl1yWQo= -github.com/mwitkow/go-proto-validators v0.2.0/go.mod h1:ZfA1hW+UH/2ZHOWvQ3HnQaU0DtnpXu850MZiy+YUgcc= -github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg= -github.com/nats-io/jwt v0.3.2/go.mod h1:/euKqTS1ZD+zzjYrY7pseZrTtWQSjujC7xjPc8wL6eU= -github.com/nats-io/nats-server/v2 v2.1.2/go.mod h1:Afk+wRZqkMQs/p45uXdrVLuab3gwv3Z8C4HTBu8GD/k= -github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzEE/Zbp4w= -github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= -github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= -github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= -github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= -github.com/nishanths/predeclared v0.0.0-20200524104333-86fad755b4d3/go.mod h1:nt3d53pc1VYcphSCIaYAJtnPYnr3Zyn8fMq2wvPGPso= -github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs= -github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= -github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= -github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= -github.com/olekukonko/tablewriter v0.0.4/go.mod h1:zq6QwlOf5SlnkVbMSr5EoBv3636FWnp+qbPhuoO21uA= -github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= -github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.10.3/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= -github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= -github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= -github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= -github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis= -github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74= -github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= -github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= -github.com/openzipkin-contrib/zipkin-go-opentracing v0.4.5/go.mod h1:/wsWhb9smxSfWAKL3wpBW7V8scJMt8N8gnaMCS9E/cA= -github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw= -github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= -github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= -github.com/otiai10/copy v1.2.0/go.mod h1:rrF5dJ5F0t/EWSYODDu4j9/vEeYHMkc8jt0zJChqQWw= -github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE= -github.com/otiai10/curr v1.0.0/go.mod h1:LskTG5wDwr8Rs+nNQ+1LlxRjAtTZZjtJW4rMXl6j4vs= -github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo= -github.com/otiai10/mint v1.3.1/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc= -github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIwwtUjcrb0b5/5kLM= -github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= -github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= -github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= -github.com/pelletier/go-buffruneio v0.2.0/go.mod h1:JkE26KsDizTr40EUHkXVtNPvgGtbSNq5BcowyYOWdKo= -github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= -github.com/pelletier/go-toml v1.9.4/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= -github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= -github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= -github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= +github.com/nkovacs/streamquote v0.0.0-20170412213628-49af9bddb229/go.mod h1:0aYXnNPJ8l7uZxf45rWW1a/uME32OF0rhiYGNQ2oF2E= +github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc= +github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= +github.com/pelletier/go-toml/v2 v2.0.1/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo= +github.com/pelletier/go-toml/v2 v2.0.6 h1:nrzqCb7j9cDFj2coyLNLaZuJTLjWjlaz6nvTvIwycIU= +github.com/pelletier/go-toml/v2 v2.0.6/go.mod h1:eumQOmlWiOPt5WriQQqoM5y18pDHwha2N+QD+EUNTek= +github.com/pelletier/go-toml/v2 v2.0.7 h1:muncTPStnKRos5dpVKULv2FVd4bMOhNePj9CjgDb8Us= +github.com/pelletier/go-toml/v2 v2.0.7/go.mod h1:eumQOmlWiOPt5WriQQqoM5y18pDHwha2N+QD+EUNTek= +github.com/penglongli/gin-metrics v0.1.10 h1:mNNWCM3swMOVHwzrHeXsE4C/myu8P/HIFohtyMi9rN8= +github.com/penglongli/gin-metrics v0.1.10/go.mod h1:wxGsGUwpVGv3hmYSxQn2GZgRL3YuCgiRFq2d0X6+EOU= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA= -github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI= -github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= -github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= -github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs= -github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= -github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= -github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= -github.com/prometheus/client_golang v1.5.1/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.10.0/go.mod h1:WJM3cc3yu7XKBKa/I8WeZm+V3eltZnBwfENSU7mdogU= +github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= +github.com/prometheus/client_golang v1.12.0/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= +github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= +github.com/prometheus/client_golang v1.14.0 h1:nJdhIvne2eSX/XRAFV9PcvFFRbrjbcTUj0VP62TMhnw= +github.com/prometheus/client_golang v1.14.0/go.mod h1:8vpkKitgIVNcqrRBWh1C4TIUQgYNtG/XQE4E/Zae36Y= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= -github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.1.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= -github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= -github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4= +github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= -github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt26CguLLsqA= -github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= -github.com/prometheus/common v0.18.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= -github.com/prometheus/common v0.24.0/go.mod h1:H6QK/N6XVT42whUeIdI3dp36w49c+/iMDk7UAI2qm7Q= +github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= +github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= +github.com/prometheus/common v0.37.0 h1:ccBbHCgIiT9uSoFY0vX8H3zsNR5eLt17/RQLUvn8pXE= +github.com/prometheus/common v0.37.0/go.mod h1:phzohg0JFMnBEFGxTDbfu3QyL5GI8gTQJFhYO5B3mfA= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= -github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= -github.com/prometheus/procfs v0.2.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= -github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= -github.com/pseudomuto/protoc-gen-doc v1.4.1/go.mod h1:exDTOVwqpp30eV/EDPFLZy3Pwr2sn6hBC1WIYH/UbIg= -github.com/pseudomuto/protokit v0.2.0/go.mod h1:2PdH30hxVHsup8KpBTOXTBeMVhJZVio3Q8ViKSAXT0Q= -github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= -github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= -github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= -github.com/rivo/uniseg v0.4.3 h1:utMvzDsuh3suAEnhH0RdHmoPbU648o6CvXxTx4SBMOw= -github.com/rivo/uniseg v0.4.3/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= -github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= -github.com/rogpeppe/fastuuid v1.1.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= -github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= +github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= +github.com/prometheus/procfs v0.8.0 h1:ODq8ZFEaYeCaZOJlZZdJA2AbQR98dSHSM1KW/You5mo= +github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k= -github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= -github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= -github.com/rs/zerolog v1.28.0 h1:MirSo27VyNi7RJYP3078AA1+Cyzd2GB66qy3aUHvsWY= -github.com/rs/zerolog v1.28.0/go.mod h1:NILgTygv/Uej1ra5XxGf82ZFSLk58MFGAUS2o6usyD0= -github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= -github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= -github.com/sagikazarmark/crypt v0.3.0/go.mod h1:uD/D+6UF4SrIR1uGEv7bBNkNqLGqUr43MRiaGWX1Nig= -github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= -github.com/sassoftware/go-rpmutils v0.0.0-20190420191620-a8f1baeba37b/go.mod h1:am+Fp8Bt506lA3Rk3QCmSqmYmLMnPDhdDUcosQCAx+I= -github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= -github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= -github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= -github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= -github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= -github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= -github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8= -github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= -github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= +github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= +github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE= +github.com/rwtodd/Go.Sed v0.0.0-20210816025313-55464686f9ef/go.mod h1:8AEUvGVi2uQ5b24BIhcr0GCcpd/RNAFWaN2CJFrWIIQ= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= -github.com/sirupsen/logrus v1.3.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= -github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= -github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= +github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= +github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e h1:MRM5ITcdelLK2j1vwZ3Je0FKVCfqOLp5zO6trqMLYs0= github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e/go.mod h1:XV66xRDqSt+GTGFMVlhk3ULuV0y9ZmzeVGR4mloJI3M= -github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= -github.com/smartystreets/assertions v1.0.0/go.mod h1:kHHU4qYBaI3q23Pp3VPrmWhuIUrLW/7eUrw0BU5VaoM= -github.com/smartystreets/go-aws-auth v0.0.0-20180515143844-0c1422d1fdb9/go.mod h1:SnhjPscd9TpLiy1LpzGSKh3bXCfxxXuqd9xmQJy3slM= -github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= -github.com/smartystreets/gunit v1.0.0/go.mod h1:qwPWnhz6pn0NnRBP++URONOVyNkPyr4SauJk4cUOwJs= -github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= -github.com/soheilhy/cmux v0.1.5-0.20210205191134-5ec6847320e5/go.mod h1:T7TcVDs9LWfQgPlPsdngu6I6QIoyIFZDDC6sNE1GqG0= -github.com/soheilhy/cmux v0.1.5/go.mod h1:T7TcVDs9LWfQgPlPsdngu6I6QIoyIFZDDC6sNE1GqG0= -github.com/sony/gobreaker v0.4.1/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJOjmxWY= -github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= -github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= -github.com/spf13/afero v1.3.3/go.mod h1:5KUK8ByomD5Ti5Artl0RtHeI5pTF7MIDuXL3yY520V4= -github.com/spf13/afero v1.3.4/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I= -github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I= -github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= -github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= -github.com/spf13/cast v1.4.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= -github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w= -github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU= -github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= -github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= -github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE= -github.com/spf13/cobra v1.1.1/go.mod h1:WnodtKOvamDL/PwE2M4iKs8aMDBZ5Q5klgD3qfVJQMI= -github.com/spf13/cobra v1.1.3/go.mod h1:pGADOWyqRD/YMrPZigI/zbliZ2wVD/23d+is3pSWzOo= -github.com/spf13/cobra v1.3.0/go.mod h1:BrRVncBjOJa/eUcVVm9CE+oC6as8k+VYr4NY7WCi9V4= -github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= -github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= -github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= -github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= -github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= -github.com/spf13/viper v1.10.0/go.mod h1:SoyBPwAtKDzypXNDFKN5kzH7ppppbGZtls1UpIy5AsM= -github.com/src-d/gcfg v1.4.0/go.mod h1:p/UMsR43ujA89BJY9duynAwIpvqEujIH/jFlfL7jWoI= -github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= -github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= -github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= -github.com/stretchr/testify v0.0.0-20170130113145-4d4bfba8f1d1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= -github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= -github.com/tidwall/gjson v1.14.4 h1:uo0p8EbA09J7RQaflQ1aBRffTR7xedD2bcIVSYxLnkM= -github.com/tidwall/gjson v1.14.4/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= -github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= -github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= -github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= -github.com/tj/assert v0.0.0-20171129193455-018094318fb0/go.mod h1:mZ9/Rh9oLWpLLDRpvE+3b7gP/C2YyLFYxNmcLnPTMe0= -github.com/tj/go-elastic v0.0.0-20171221160941-36157cbbebc2/go.mod h1:WjeM0Oo1eNAjXGDx2yma7uG2XoyRZTq1uv3M/o7imD0= -github.com/tj/go-kinesis v0.0.0-20171128231115-08b17f58cb1b/go.mod h1:/yhzCV0xPfx6jb1bBgRFjl5lytqVqZXEaeqWP8lTEao= -github.com/tj/go-spin v1.1.0/go.mod h1:Mg1mzmePZm4dva8Qz60H2lHwmJ2loum4VIrLgVnKwh4= -github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= -github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= -github.com/tmc/grpc-websocket-proxy v0.0.0-20200427203606-3cfed13b9966/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= -github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= -github.com/tomasen/realip v0.0.0-20180522021738-f0c99a92ddce/go.mod h1:o8v6yHRoik09Xen7gje4m9ERNah1d1PPsVq1VEx9vE4= -github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= +github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= -github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= -github.com/ulikunitz/xz v0.5.6/go.mod h1:2bypXElzHzzJZwzH67Y6wb67pO62Rzfn7BSiF4ABRW8= -github.com/ulikunitz/xz v0.5.7/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= -github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= -github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= -github.com/urfave/cli v1.22.4/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= -github.com/urfave/cli v1.22.5/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= +github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= +github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M= +github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= +github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY= +github.com/ugorji/go/codec v1.2.9 h1:rmenucSohSTiyL09Y+l2OCk+FrMxGMzho2+tjr5ticU= +github.com/ugorji/go/codec v1.2.9/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= +github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU= +github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= -github.com/valyala/fasthttp v1.40.0/go.mod h1:t/G+3rLek+CyY9bnIE+YlMRddxVAAGjhxndDB4i4C0I= -github.com/valyala/fasthttp v1.41.0 h1:zeR0Z1my1wDHTRiamBCXVglQdbUwgb9uWG3k1HQz6jY= -github.com/valyala/fasthttp v1.41.0/go.mod h1:f6VbjjoI3z1NDOZOv17o6RvtRSWxC77seBFc2uWtgiY= +github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo= github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= -github.com/valyala/tcplisten v1.0.0 h1:rBHj/Xf+E1tRGZyWIWwJDiRY0zc1Js+CV5DqwacVSA8= -github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc= -github.com/weppos/publicsuffix-go v0.13.1-0.20210123135404-5fd73613514e/go.mod h1:HYux0V0Zi04bHNwOHy4cXJVz/TQjYonnF6aoYhj+3QE= -github.com/weppos/publicsuffix-go v0.15.1-0.20210511084619-b1f36a2d6c0b/go.mod h1:HYux0V0Zi04bHNwOHy4cXJVz/TQjYonnF6aoYhj+3QE= -github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= -github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= -github.com/xanzy/go-gitlab v0.31.0/go.mod h1:sPLojNBn68fMUWSxIJtdVVIP8uSBYqesTfDUseX11Ug= -github.com/xanzy/ssh-agent v0.2.1/go.mod h1:mLlQY/MoOhWBj+gOGMQkOeiEvkx+8pJSI+0Bx9h2kr4= -github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8/go.mod h1:HUYIGzjTL3rfEspMxjDjgmT5uz5wzYJKVo23qUhYTos= -github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= -github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= -github.com/yosssi/ace v0.0.5/go.mod h1:ALfIzm2vT7t5ZE7uoIZqF3TQ7SAOyupFZnkrF5id+K0= +github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778/go.mod h1:2MuV+tbUrU1zIOPMxZ5EncGwgmMJsa+9ucAQZXxsObs= +github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no= +github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -github.com/zclconf/go-cty v1.12.1 h1:PcupnljUm9EIvbgSHQnHhUr3fO6oFmkOrvs2BAFNXXY= -github.com/zclconf/go-cty v1.12.1/go.mod h1:s9IfD1LK5ccNMSWCVFCE2rJfHiZgi7JijgeWIMfhLvA= -github.com/ziutek/mymysql v1.5.4/go.mod h1:LMSpPZ6DbqWFxNCHW77HeMg9I646SAhApZ/wKdgO/C0= -github.com/zmap/rc2 v0.0.0-20131011165748-24b9757f5521/go.mod h1:3YZ9o3WnatTIZhuOtot4IcUfzoKVjUHqu6WALIyI0nE= -github.com/zmap/zcertificate v0.0.0-20180516150559-0e3d58b1bac4/go.mod h1:5iU54tB79AMBcySS0R2XIyZBAVmeHranShAFELYx7is= -github.com/zmap/zcrypto v0.0.0-20210123152837-9cf5beac6d91/go.mod h1:R/deQh6+tSWlgI9tb4jNmXxn8nSCabl5ZQsBX9//I/E= -github.com/zmap/zcrypto v0.0.0-20210511125630-18f1e0152cfc/go.mod h1:FM4U1E3NzlNMRnSUTU3P1UdukWhYGifqEsjk9fn7BCk= -github.com/zmap/zlint/v3 v3.1.0/go.mod h1:L7t8s3sEKkb0A2BxGy1IWrxt1ZATa1R4QfJZaQOD3zU= -go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= -go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= -go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= -go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= -go.etcd.io/etcd/api/v3 v3.5.0-alpha.0/go.mod h1:mPcW6aZJukV6Aa81LSKpBjQXTWlXB5r74ymPoSWa3Sw= -go.etcd.io/etcd/api/v3 v3.5.1/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs= -go.etcd.io/etcd/client/pkg/v3 v3.5.1/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g= -go.etcd.io/etcd/client/v2 v2.305.0-alpha.0/go.mod h1:kdV+xzCJ3luEBSIeQyB/OEKkWKd8Zkux4sbDeANrosU= -go.etcd.io/etcd/client/v2 v2.305.1/go.mod h1:pMEacxZW7o8pg4CrFE7pquyCJJzZvkvdD2RibOCCCGs= -go.etcd.io/etcd/client/v3 v3.5.0-alpha.0/go.mod h1:wKt7jgDgf/OfKiYmCq5WFGxOFAkVMLxiiXgLDFhECr8= -go.etcd.io/etcd/etcdctl/v3 v3.5.0-alpha.0/go.mod h1:YPwSaBciV5G6Gpt435AasAG3ROetZsKNUzibRa/++oo= -go.etcd.io/etcd/pkg/v3 v3.5.0-alpha.0/go.mod h1:tV31atvwzcybuqejDoY3oaNRTtlD2l/Ot78Pc9w7DMY= -go.etcd.io/etcd/raft/v3 v3.5.0-alpha.0/go.mod h1:FAwse6Zlm5v4tEWZaTjmNhe17Int4Oxbu7+2r0DiD3w= -go.etcd.io/etcd/server/v3 v3.5.0-alpha.0/go.mod h1:tsKetYpt980ZTpzl/gb+UOJj9RkIyCb1u4wjzMg90BQ= -go.etcd.io/etcd/tests/v3 v3.5.0-alpha.0/go.mod h1:HnrHxjyCuZ8YDt8PYVyQQ5d1ZQfzJVEtQWllr5Vp/30= -go.etcd.io/etcd/v3 v3.5.0-alpha.0/go.mod h1:JZ79d3LV6NUfPjUxXrpiFAYcjhT+06qqw+i28snx8To= -go.opencensus.io v0.15.0/go.mod h1:UffZAU+4sDEINUGP/B7UfBBkq4fqLu9zXAX7ke6CHW0= -go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= -go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= -go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= -go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= -go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= -go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= -go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= -go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= -go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= -go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= -go.uber.org/goleak v1.1.12 h1:gZAh5/EyT/HQwlpkCy6wTpqfH9H8Lz8zbm3dZh+OyzA= -go.uber.org/goleak v1.1.12/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= -go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= -go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= -go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU= -go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= -go.uber.org/multierr v1.7.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak= -go.uber.org/multierr v1.8.0 h1:dg6GjLku4EH+249NNmoIciG9N/jURbDG+pFlTkhzIC8= -go.uber.org/multierr v1.8.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak= -go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= -go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= -go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= -go.uber.org/zap v1.16.0/go.mod h1:MA8QOfq0BHJwdXa996Y4dYkAqRKB8/1K1QMMZVaNZjQ= -go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo= -go.uber.org/zap v1.23.0 h1:OjGQ5KQDEUawVHxNwQgPpiypGHOxo2mNZsOqTak4fFY= -go.uber.org/zap v1.23.0/go.mod h1:D+nX8jyLsMHMYrln8A0rJjFt/T/9/bGgIhAqxv5URuY= -gocloud.dev v0.19.0/go.mod h1:SmKwiR8YwIMMJvQBKLsC3fHNyMwXLw3PMDO+VVteJMI= -golang.org/x/crypto v0.0.0-20180501155221-613d6eafa307/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +go.opentelemetry.io/otel v1.10.0 h1:Y7DTJMR6zs1xkS/upamJYk0SxxN4C9AqRd77jmZnyY4= +go.opentelemetry.io/otel v1.10.0/go.mod h1:NbvWjCthWHKBEUMpf0/v8ZRZlni86PpGFEMA9pnQSnQ= +go.opentelemetry.io/otel/trace v1.10.0 h1:npQMbR8o7mum8uF95yFbOEJffhs1sbCOfDh8zAJiH5E= +go.opentelemetry.io/otel/trace v1.10.0/go.mod h1:Sij3YYczqAdz+EhmGhE6TpTxUO5/F/AzrK+kxfGqySM= +golang.org/x/arch v0.0.0-20210923205945-b76863e36670 h1:18EFjUmQOcUvxNYSkA6jO9VAiXCnxFY6NyDX0bHDmkU= +golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= +golang.org/x/arch v0.3.0 h1:02VY4/ZcO/gBOH6PUaoiptASxtXU10jazRCP865E97k= +golang.org/x/arch v0.3.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3H3cr1v9wB50oz8l4C4h62xy7jSTY= -golang.org/x/crypto v0.0.0-20191002192127-34f69633bfdc/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20191117063200-497ca9f6d64f/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20200414173820-0848c9571904/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20201124201722-c8d3bf9c5392/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= -golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20220824171710-5757bc0c5503/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.3.0 h1:a06MkbcxBrEFc0w0QIZWXrH/9cCX6KJyWbBOIwAn+7A= -golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= +golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20220427172511-eb4f295cb31f/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.5.0 h1:U/0M97KRkSFvyD/3FSmdP5W5swImpNgle/EHFhOsQPE= +golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU= +golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A= +golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -971,7 +398,6 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -984,8 +410,6 @@ golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHl golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= @@ -994,40 +418,21 @@ golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzB golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.5.0/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= -golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= -golang.org/x/mod v0.7.0 h1:LapD9S96VoQRhi/GrNTqeBJFrUjs5UHCAtTlgwA5oZA= -golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181108082009-03003ca0c849/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190327091125-710a502c58a2/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= +golang.org/x/net v0.0.0-20190607181551-461777fb6f67/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190619014844-b5b0513f8c1b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191002035440-2ec189313ef0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191119073136-fc4aabc6c914/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -1035,7 +440,6 @@ golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200421231249-e086a090c8fd/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= @@ -1043,98 +447,61 @@ golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/ golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= -golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1/go.mod h1:9tjilg8BloeKEkVJvy7fQ90B1CfIiPueXVOjqfkSzI8= -golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220906165146-f3363e06e74c/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= +golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= +golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/oauth2 v0.0.0-20181106182150-f42d05182288/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210313182246-cd4f82c27b84/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210413134643-5e61552d6c78/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210427180440-81ed05c6b58c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20211005180243-6b3c2da341f1/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190412183630-56d357773e84/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= +golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190221075227-b4e8571b14e0/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190602015325-4c4f7f33c9ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190620070143-6f217b454f45/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190609082536-301114b31cce/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190922100055-0a153f010e69/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191119060738-e882bf8e40c2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191220142924-d4481acd189f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200124204421-9fbb57f87de9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200420163511-1957bb5e6d1f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1142,102 +509,67 @@ golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201009025420-dfb3f7c4e634/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201126233918-771906719818/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210305230114-8fe3ee5dd75b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210309074719-68d13333faf2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210412220455-f1c623a9e750/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210603125802-9665404d3644/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210816183151-1e6c022a8912/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211205182925-97ca703d548d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220406163625-3f8b81556e12/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A= -golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= +golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.5.0 h1:n2a8QNdAb0sZNpU9R1ALUXBbY+w51fCQDN+7EdxNBsY= +golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= +golang.org/x/term v0.6.0 h1:clScbb1cHjoCkyRbWwBEUZ5H/tIFu5TAXIqaZD0Gcjw= +golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg= -golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= +golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190422233926-fe54fb35175b/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190608022120-eacb66d2a7c3/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190729092621-ff9f1409240a/go.mod h1:jcCCGcm9btYwXyDqrUWc6MKQKKGJCWEQ3AfLSRIbEuI= golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20190907020128-2ca718005c18/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191010075000-0337d82405ff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191118222007-07fc4c7f2b98/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= @@ -1249,45 +581,23 @@ golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapK golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= -golang.org/x/tools v0.0.0-20200426102838-f3a5411a4c3b/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200522201501-cb1345f3a375/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200717024301-6ddee64345a6/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE= -golang.org/x/tools v0.0.0-20201014170642-d1624618ad65/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU= -golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= -golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.9/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 h1:H2TDz8ibqkAF6YGhCdN3jS9O0/s90v0rJh3X/OLHEUk= golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= -google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk= google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= -google.golang.org/api v0.5.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= -google.golang.org/api v0.6.0/go.mod h1:btoxGiFvQNVUZQ8W08zLtrVS08CNpINPEfxXxgJL1Q4= google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= -google.golang.org/api v0.10.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= @@ -1300,43 +610,17 @@ google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0M google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= -google.golang.org/api v0.35.0/go.mod h1:/XrVsuzM0rZmrsbjJutiuftIzeuTQcEeaYcSk/mQ1dg= -google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34qYtE= -google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8= -google.golang.org/api v0.41.0/go.mod h1:RkxM5lITDfTzmyKFPt+wGrCJbVfniCr2ool8kTBzRTU= -google.golang.org/api v0.43.0/go.mod h1:nQsDGjRXMo4lvh5hP0TKqF244gqhGcr/YSIykhUk/94= -google.golang.org/api v0.45.0/go.mod h1:ISLIJCedJolbZvDfAk+Ctuq5hf+aJ33WgtUsfyFoLXA= -google.golang.org/api v0.47.0/go.mod h1:Wbvgpq1HddcWVtzsVLyfLp8lDg6AA241LmgIL59tHXo= -google.golang.org/api v0.48.0/go.mod h1:71Pr1vy+TAZRPkPs/xlCf5SsU8WjuAWv1Pfjbtukyy4= -google.golang.org/api v0.50.0/go.mod h1:4bNT5pAuq5ji4SRZm+5QIkjny9JAyVD/3gaSihNefaw= -google.golang.org/api v0.51.0/go.mod h1:t4HdrdoNgyN5cbEfm7Lum0lcLDLiise1F8qDKX00sOU= -google.golang.org/api v0.54.0/go.mod h1:7C4bFFOvVDGXjfDTAsgGwDgAxRDeQ4X8NvUedIt6z3k= -google.golang.org/api v0.55.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= -google.golang.org/api v0.56.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= -google.golang.org/api v0.57.0/go.mod h1:dVPlbZyBo2/OjBpmvNdpn2GRm6rPy75jyU7bmhdrMgI= -google.golang.org/api v0.59.0/go.mod h1:sT2boj7M9YJxZzgeZqXogmhfmRWDtPzT31xkieUbuZU= -google.golang.org/api v0.61.0/go.mod h1:xQRti5UdCmoCEqFxcz93fTl338AVqDgyaDRuOZ3hg9I= -google.golang.org/api v0.62.0/go.mod h1:dKmwPCydfsad4qCH08MSdgWjfHOyfpd4VtDGgRFdavw= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.3.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= -google.golang.org/appengine v1.6.2/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/genproto v0.0.0-20170818010345-ee236bd376b0/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20181107211654-5fc9ac540362/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190508193815-b515fa19cec8/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190530194941-fb225487d101/go.mod h1:z3L6/3dTEVtUr6QSP8miRzeRqwQOioJ9I66odjN4I7s= -google.golang.org/genproto v0.0.0-20190620144150-6af8c5fc6601/go.mod h1:z3L6/3dTEVtUr6QSP8miRzeRqwQOioJ9I66odjN4I7s= google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= @@ -1353,62 +637,18 @@ google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfG google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201109203340-2640f1f9cdfb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210222152913-aa3ee6e6a81c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210303154014-9728d6b83eeb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210310155132-4ce2db91004e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210319143718-93e7006c17a6/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210331142528-b7513248f0ba/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= -google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= -google.golang.org/genproto v0.0.0-20210413151531-c14fb6ef47c3/go.mod h1:P3QM42oQyzQSnHPnZ/vqoCdDmzH28fzWByN9asMeM8A= -google.golang.org/genproto v0.0.0-20210510173355-fb37daa5cd7a/go.mod h1:P3QM42oQyzQSnHPnZ/vqoCdDmzH28fzWByN9asMeM8A= -google.golang.org/genproto v0.0.0-20210513213006-bf773b8c8384/go.mod h1:P3QM42oQyzQSnHPnZ/vqoCdDmzH28fzWByN9asMeM8A= -google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= -google.golang.org/genproto v0.0.0-20210604141403-392c879c8b08/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= -google.golang.org/genproto v0.0.0-20210608205507-b6d2f5bf0d7d/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= -google.golang.org/genproto v0.0.0-20210624195500-8bfb893ecb84/go.mod h1:SzzZ/N+nwJDaO1kznhnlzqS8ocJICar6hYhVyhi++24= -google.golang.org/genproto v0.0.0-20210713002101-d411969a0d9a/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k= -google.golang.org/genproto v0.0.0-20210716133855-ce7ef5c701ea/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k= -google.golang.org/genproto v0.0.0-20210728212813-7823e685a01f/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= -google.golang.org/genproto v0.0.0-20210805201207-89edb61ffb67/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= -google.golang.org/genproto v0.0.0-20210813162853-db860fec028c/go.mod h1:cFeNkxwySK631ADgubI+/XFU/xp8FD5KIVV4rj8UC5w= -google.golang.org/genproto v0.0.0-20210821163610-241b8fcbd6c8/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210828152312-66f60bf46e71/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210831024726-fe130286e0e2/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210903162649-d08c68adba83/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210909211513-a8c4777a87af/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210924002016-3dee208752a0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211008145708-270636b82663/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211028162531-8db9c33dc351/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211129164237-f09f9a12af12/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211203200212-54befc351ae9/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211206160659-862468c7d6e0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/grpc v1.8.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= -google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= -google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= -google.golang.org/grpc v1.22.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= @@ -1417,23 +657,6 @@ google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKa google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.32.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= -google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= -google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8= -google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.36.1/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.37.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= -google.golang.org/grpc v1.37.1/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= -google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= -google.golang.org/grpc v1.39.0/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= -google.golang.org/grpc v1.39.1/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= -google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= -google.golang.org/grpc v1.40.1/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= -google.golang.org/grpc v1.42.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= -google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -1444,32 +667,23 @@ google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2 google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= -google.golang.org/protobuf v1.25.1-0.20200805231151-a709e31e5d12/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= +google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= +google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= -gopkg.in/cheggaaa/pb.v1 v1.0.28/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= -gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= -gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o= -gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/ini.v1 v1.66.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= -gopkg.in/src-d/go-billy.v4 v4.3.2/go.mod h1:nDjArDMp+XMs1aFAESLRjfGSgfvoYN0hDfzEk0GjC98= -gopkg.in/src-d/go-git-fixtures.v3 v3.5.0/go.mod h1:dLBcvytrw/TYZsNTWCnkNF2DSIlzWYqTe3rJR56Ac7g= -gopkg.in/src-d/go-git.v4 v4.13.1/go.mod h1:nx5NYcxdKxq5fpltdHnPa2Exj4Sx0EclMWZQbYDu2z8= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= -gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= -gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= +gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= +gopkg.in/go-playground/validator.v8 v8.18.2/go.mod h1:RX2a/7Ha8BgOhfk7j780h4/u/RRjR0eouCJSH80/M2Y= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= @@ -1479,7 +693,7 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= @@ -1487,11 +701,7 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -honnef.co/go/tools v0.1.4/go.mod h1:NgwopIslSNH47DimFoV78dnkksY2EFtX0ajyb3K/las= -pack.ag/amqp v0.11.2/go.mod h1:4/cbmt4EJXSKlG6LCfWHoqmN0uFdy5i/+YFz+fTfhV4= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= +rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= -sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= -sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc= -sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU= diff --git a/health.go b/health.go new file mode 100644 index 00000000..c32c646d --- /dev/null +++ b/health.go @@ -0,0 +1,32 @@ +package main + +import ( + "net/http" + + "github.com/gin-gonic/gin" + "github.com/hellofresh/health-go/v5" +) + +/** +* Pointer to the health check. Can be used to register additional components to check + */ +var healthCheck *health.Health + +func init() { + healthCheck, _ = health.New(health.WithComponent(health.Component{ + Name: "vcverifier", + })) +} + +func HealthReq(c *gin.Context) { + checkResult := healthCheck.Measure(c.Request.Context()) + if checkResult.Status == health.StatusOK { + c.AbortWithStatusJSON(http.StatusOK, checkResult) + } else { + c.AbortWithStatusJSON(http.StatusServiceUnavailable, checkResult) + } +} + +func Health() *health.Health { + return healthCheck +} diff --git a/internal/jwk/jwk.go b/internal/jwk/jwk.go deleted file mode 100644 index 6cb879c6..00000000 --- a/internal/jwk/jwk.go +++ /dev/null @@ -1,407 +0,0 @@ -package jwk - -import ( - "crypto" - "crypto/ecdsa" - "crypto/elliptic" - "crypto/rand" - "encoding/base64" - "encoding/json" - "fmt" - "io/ioutil" - "math/big" - "strings" - - "github.com/decred/dcrd/dcrec/secp256k1/v4" - "github.com/google/uuid" -) - -const ( - - // Key type, EC or RSA. - ktyEC = "EC" - ktyRSA = "RSA" - - // Use, Signature or Encryption - useSIG = "sig" - useENC = "enc" - - // P256 represents a 256-bit cryptographic elliptical curve type. - P256 = "P-256" - - // P256K represents the Ethereum 256-bit cryptographic elliptical curve type. - P256K = "P-256K" - - // P384 represents a 384-bit cryptographic elliptical curve type. - P384 = "P-384" - - // P521 represents a 521-bit cryptographic elliptical curve type. - P521 = "P-521" -) - -type JWK struct { - Kid string `json:"kid"` - Kty string `json:"kty"` - Use string `json:"use"` - Alg string `json:"alg"` - - // Elliptic curve, common to Public and Private keys - Crv string `json:"crv"` - X string `json:"x"` - Y string `json:"y"` - - // RSA curve, common to Public and Private keys - N string `json:"n"` // Modulus. Base64urlUInt-encoded - E string `json:"e"` // Exponent. Base64urlUInt-encoded - - // For Private Keys, both Elliptic and RSA - D string `json:"d"` -} - -func NewEthereum() (*JWK, error) { - - nativeKey, err := ecdsa.GenerateKey(secp256k1.S256(), rand.Reader) - if err != nil { - return nil, err - } - - jwkKey := &JWK{} - jwkKey.Kid = uuid.New().String() - jwkKey.Kty = ktyEC - jwkKey.Crv = P256K - jwkKey.Alg = "ES256K" // ECDSA using P256K and SHA-256 - jwkKey.Use = useSIG - jwkKey.D = toBase64url(nativeKey.D.Bytes()) - jwkKey.X = toBase64url(nativeKey.X.Bytes()) - jwkKey.Y = toBase64url(nativeKey.Y.Bytes()) - - return jwkKey, nil - -} - -func NewECDSA() (*JWK, error) { - - nativeKey, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader) - if err != nil { - return nil, err - } - - jwkKey := &JWK{} - jwkKey.Kid = uuid.New().String() - jwkKey.Kty = ktyEC - jwkKey.Crv = P256 - jwkKey.Alg = "ES256" // ECDSA using P-256 and SHA-256 - jwkKey.Use = useSIG - jwkKey.D = toBase64url(nativeKey.D.Bytes()) - jwkKey.X = toBase64url(nativeKey.X.Bytes()) - jwkKey.Y = toBase64url(nativeKey.Y.Bytes()) - - return jwkKey, nil - -} - -func NewJWKFromFile(location string) (*JWK, error) { - - // Read the key from the file as a text string - keyData, err := ioutil.ReadFile(location) - if err != nil { - return nil, err - } - - // Convert to a JWK structure - j := &JWK{} - err = json.Unmarshal(keyData, j) - if err != nil { - return nil, err - } - - return j, nil -} - -func NewFromBytes(b []byte) (k *JWK, err error) { - - // Convert to a JWK structure - k = &JWK{} - err = json.Unmarshal(b, k) - if err != nil { - return nil, err - } - - return k, nil -} - -func (k *JWK) AsJSON() ([]byte, error) { - return json.Marshal(k) -} - -func (key *JWK) GetKid() string { - return key.Kid -} - -func (key *JWK) GetAlg() string { - return key.Alg -} - -func (k *JWK) String() (s string) { - b, err := json.MarshalIndent(k, "", " ") - if err != nil { - return "" - } - return string(b) -} - -func (key *JWK) PublicJWKKey() (publicKey *JWK) { - - // Create a new JWK struct - publicKey = &JWK{} - - // Copy the relevant fields for a public key - publicKey.Kid = key.Kid - publicKey.Kty = key.Kty - publicKey.Use = key.Use - publicKey.Alg = key.Alg - publicKey.Crv = key.Crv - publicKey.X = key.X - publicKey.Y = key.Y - publicKey.N = key.N - publicKey.E = key.E - - return publicKey -} - -func (key *JWK) GetPublicKey() (publicKeyEC crypto.PublicKey, err error) { - - if key.X == "" || key.Y == "" || key.Crv == "" { - return nil, fmt.Errorf("Missing fields in the JWK") - } - - // Decode the X coordinate from Base64. - // - // According to RFC 7518, this is a Base64 URL unsigned integer. - // https://tools.ietf.org/html/rfc7518#section-6.3 - xCoordinate, err := fromBase64url(key.X) - if err != nil { - return nil, err - } - yCoordinate, err := fromBase64url(key.Y) - if err != nil { - return nil, err - } - - publicKey := &ecdsa.PublicKey{} - // Turn the X coordinate into *big.Int. - // - // According to RFC 7517, these numbers are in big-endian format. - // https://tools.ietf.org/html/rfc7517#appendix-A.1 - publicKey.X = big.NewInt(0).SetBytes(xCoordinate) - publicKey.Y = big.NewInt(0).SetBytes(yCoordinate) - - switch key.Crv { - case P256: - publicKey.Curve = elliptic.P256() - case P384: - publicKey.Curve = elliptic.P384() - case P521: - publicKey.Curve = elliptic.P521() - } - - return publicKey, nil -} - -func (key *JWK) GetPrivateKey() (privateKeyEC crypto.PrivateKey, err error) { - - if key.X == "" || key.Y == "" || key.D == "" || key.Crv == "" { - return nil, fmt.Errorf("Missing fields in the JWK") - } - - // Decode the X coordinate from Base64. - // - // According to RFC 7518, this is a Base64 URL unsigned integer. - // https://tools.ietf.org/html/rfc7518#section-6.3 - xCoordinate, err := fromBase64url(key.X) - if err != nil { - return nil, err - } - yCoordinate, err := fromBase64url(key.Y) - if err != nil { - return nil, err - } - - privateKey := &ecdsa.PrivateKey{} - // Turn the X coordinate into *big.Int. - // - // According to RFC 7517, these numbers are in big-endian format. - // https://tools.ietf.org/html/rfc7517#appendix-A.1 - privateKey.X = big.NewInt(0).SetBytes(xCoordinate) - privateKey.Y = big.NewInt(0).SetBytes(yCoordinate) - - switch key.Crv { - case P256: - privateKey.Curve = elliptic.P256() - case P384: - privateKey.Curve = elliptic.P384() - case P521: - privateKey.Curve = elliptic.P521() - } - - var dCoordinate []byte - if len(key.D) > 0 { - dCoordinate, err = fromBase64url(key.D) - if err != nil { - return nil, err - } - privateKey.D = big.NewInt(0).SetBytes(dCoordinate) - } - - return privateKey, nil - -} - -func LoadECPublicKeyFromJWKFile(location string) crypto.PublicKey { - keyData, e := ioutil.ReadFile(location) - if e != nil { - panic(e.Error()) - } - - j := JWK{} - json.Unmarshal(keyData, &j) - - key, e := JWK2PublicECDSA(j) - if e != nil { - panic(e.Error()) - } - return key -} - -func LoadECPrivateKeyFromJWKFile(location string) crypto.PrivateKey { - keyData, e := ioutil.ReadFile(location) - if e != nil { - panic(e.Error()) - } - - j := JWK{} - json.Unmarshal(keyData, &j) - - key, e := JWK2PrivateECDSA(j) - if e != nil { - panic(e.Error()) - } - return key -} - -// JWK2PublicECDSA parses a jsonWebKey and turns it into an ECDSA public key. -func JWK2PublicECDSA(j JWK) (publicKey *ecdsa.PublicKey, err error) { - if j.X == "" || j.Y == "" || j.Crv == "" { - return nil, fmt.Errorf("Missing fields in the JWK") - } - - // Decode the X coordinate from Base64. - // - // According to RFC 7518, this is a Base64 URL unsigned integer. - // https://tools.ietf.org/html/rfc7518#section-6.3 - xCoordinate, err := fromBase64url(j.X) - if err != nil { - return nil, err - } - yCoordinate, err := fromBase64url(j.Y) - if err != nil { - return nil, err - } - - publicKey = &ecdsa.PublicKey{} - // Turn the X coordinate into *big.Int. - // - // According to RFC 7517, these numbers are in big-endian format. - // https://tools.ietf.org/html/rfc7517#appendix-A.1 - publicKey.X = big.NewInt(0).SetBytes(xCoordinate) - publicKey.Y = big.NewInt(0).SetBytes(yCoordinate) - - switch j.Crv { - case P256: - publicKey.Curve = elliptic.P256() - case P384: - publicKey.Curve = elliptic.P384() - case P521: - publicKey.Curve = elliptic.P521() - } - - return - -} - -// JWK2PrivateECDSA parses a jsonWebKey and turns it into an ECDSA private key. -func JWK2PrivateECDSA(j JWK) (privateKey *ecdsa.PrivateKey, err error) { - if j.X == "" || j.Y == "" || j.D == "" || j.Crv == "" { - return nil, fmt.Errorf("Missing fields in the JWK") - } - - // Decode the X coordinate from Base64. - // - // According to RFC 7518, this is a Base64 URL unsigned integer. - // https://tools.ietf.org/html/rfc7518#section-6.3 - xCoordinate, err := fromBase64url(j.X) - if err != nil { - return nil, err - } - yCoordinate, err := fromBase64url(j.Y) - if err != nil { - return nil, err - } - - privateKey = &ecdsa.PrivateKey{} - // Turn the X coordinate into *big.Int. - // - // According to RFC 7517, these numbers are in big-endian format. - // https://tools.ietf.org/html/rfc7517#appendix-A.1 - privateKey.X = big.NewInt(0).SetBytes(xCoordinate) - privateKey.Y = big.NewInt(0).SetBytes(yCoordinate) - - switch j.Crv { - case P256: - privateKey.Curve = elliptic.P256() - case P384: - privateKey.Curve = elliptic.P384() - case P521: - privateKey.Curve = elliptic.P521() - } - - var dCoordinate []byte - if len(j.D) > 0 { - dCoordinate, err = fromBase64url(j.D) - if err != nil { - return nil, err - } - privateKey.D = big.NewInt(0).SetBytes(dCoordinate) - } - - return privateKey, nil - -} - -// fromBase64url removes trailing padding before decoding a string from base64url. Some non-RFC compliant -// JWKS contain padding at the end values for base64url encoded public keys. -// -// Trailing padding is required to be removed from base64url encoded keys. -// RFC 7517 defines base64url the same as RFC 7515 Section 2: -// https://datatracker.ietf.org/doc/html/rfc7517#section-1.1 -// https://datatracker.ietf.org/doc/html/rfc7515#section-2 -func fromBase64url(s string) ([]byte, error) { - s = strings.TrimRight(s, "=") - return base64.RawURLEncoding.DecodeString(s) -} - -func toBase64url(n []byte) string { - return base64.RawURLEncoding.EncodeToString(n) -} - -// base64urlTrailingPadding removes trailing padding before decoding a string from base64url. Some non-RFC compliant -// JWKS contain padding at the end values for base64url encoded public keys. -// -// Trailing padding is required to be removed from base64url encoded keys. -// RFC 7517 defines base64url the same as RFC 7515 Section 2: -// https://datatracker.ietf.org/doc/html/rfc7517#section-1.1 -// https://datatracker.ietf.org/doc/html/rfc7515#section-2 -func base64urlTrailingPadding(s string) ([]byte, error) { - s = strings.TrimRight(s, "=") - return base64.RawURLEncoding.DecodeString(s) -} diff --git a/internal/jwt/claims.go b/internal/jwt/claims.go deleted file mode 100644 index 0fd2c884..00000000 --- a/internal/jwt/claims.go +++ /dev/null @@ -1,177 +0,0 @@ -package jwt - -import ( - "crypto/subtle" - "fmt" - "time" -) - -// Claims must just have a Valid method that determines -// if the token is invalid for any supported reason -type Claims interface { - Valid() error -} - -// RegisteredClaims are a structured version of the JWT Claims Set, -// restricted to Registered Claim Names, as referenced at -// https://datatracker.ietf.org/doc/html/rfc7519#section-4.1 -// -// This type can be used on its own, but then additional private and -// public claims embedded in the JWT will not be parsed. The typical usecase -// therefore is to embed this in a user-defined claim type. -// -// See examples for how to use this with your own claim types. -type RegisteredClaims struct { - // the `iss` (Issuer) claim. See https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.1 - Issuer string `json:"iss,omitempty"` - - // the `sub` (Subject) claim. See https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.2 - Subject string `json:"sub,omitempty"` - - // the `aud` (Audience) claim. See https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.3 - Audience ClaimStrings `json:"aud,omitempty"` - - // the `exp` (Expiration Time) claim. See https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.4 - ExpiresAt *NumericDate `json:"exp,omitempty"` - - // the `nbf` (Not Before) claim. See https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.5 - NotBefore *NumericDate `json:"nbf,omitempty"` - - // the `iat` (Issued At) claim. See https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.6 - IssuedAt *NumericDate `json:"iat,omitempty"` - - // the `jti` (JWT ID) claim. See https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.7 - ID string `json:"jti,omitempty"` -} - -// Valid validates time based claims "exp, iat, nbf". -// There is no accounting for clock skew. -// As well, if any of the above claims are not in the token, it will still -// be considered a valid claim. -func (c RegisteredClaims) Valid() error { - vErr := new(ValidationError) - now := TimeFunc() - - // The claims below are optional, by default, so if they are set to the - // default value in Go, let's not fail the verification for them. - if !c.VerifyExpiresAt(now, false) { - delta := now.Sub(c.ExpiresAt.Time) - vErr.Inner = fmt.Errorf("%s by %s", ErrTokenExpired, delta) - vErr.Errors |= ValidationErrorExpired - } - - if !c.VerifyIssuedAt(now, false) { - vErr.Inner = ErrTokenUsedBeforeIssued - vErr.Errors |= ValidationErrorIssuedAt - } - - if !c.VerifyNotBefore(now, false) { - vErr.Inner = ErrTokenNotValidYet - vErr.Errors |= ValidationErrorNotValidYet - } - - if vErr.valid() { - return nil - } - - return vErr -} - -// VerifyAudience compares the aud claim against cmp. -// If required is false, this method will return true if the value matches or is unset -func (c *RegisteredClaims) VerifyAudience(cmp string, req bool) bool { - return verifyAud(c.Audience, cmp, req) -} - -// VerifyExpiresAt compares the exp claim against cmp (cmp < exp). -// If req is false, it will return true, if exp is unset. -func (c *RegisteredClaims) VerifyExpiresAt(cmp time.Time, req bool) bool { - if c.ExpiresAt == nil { - return verifyExp(nil, cmp, req) - } - - return verifyExp(&c.ExpiresAt.Time, cmp, req) -} - -// VerifyIssuedAt compares the iat claim against cmp (cmp >= iat). -// If req is false, it will return true, if iat is unset. -func (c *RegisteredClaims) VerifyIssuedAt(cmp time.Time, req bool) bool { - if c.IssuedAt == nil { - return verifyIat(nil, cmp, req) - } - - return verifyIat(&c.IssuedAt.Time, cmp, req) -} - -// VerifyNotBefore compares the nbf claim against cmp (cmp >= nbf). -// If req is false, it will return true, if nbf is unset. -func (c *RegisteredClaims) VerifyNotBefore(cmp time.Time, req bool) bool { - if c.NotBefore == nil { - return verifyNbf(nil, cmp, req) - } - - return verifyNbf(&c.NotBefore.Time, cmp, req) -} - -// VerifyIssuer compares the iss claim against cmp. -// If required is false, this method will return true if the value matches or is unset -func (c *RegisteredClaims) VerifyIssuer(cmp string, req bool) bool { - return verifyIss(c.Issuer, cmp, req) -} - -// ----- helpers - -func verifyAud(aud []string, cmp string, required bool) bool { - if len(aud) == 0 { - return !required - } - // use a var here to keep constant time compare when looping over a number of claims - result := false - - var stringClaims string - for _, a := range aud { - if subtle.ConstantTimeCompare([]byte(a), []byte(cmp)) != 0 { - result = true - } - stringClaims = stringClaims + a - } - - // case where "" is sent in one or many aud claims - if len(stringClaims) == 0 { - return !required - } - - return result -} - -func verifyExp(exp *time.Time, now time.Time, required bool) bool { - if exp == nil { - return !required - } - return now.Before(*exp) -} - -func verifyIat(iat *time.Time, now time.Time, required bool) bool { - if iat == nil { - return !required - } - return now.After(*iat) || now.Equal(*iat) -} - -func verifyNbf(nbf *time.Time, now time.Time, required bool) bool { - if nbf == nil { - return !required - } - return now.After(*nbf) || now.Equal(*nbf) -} - -func verifyIss(iss string, cmp string, required bool) bool { - if iss == "" { - return !required - } - if subtle.ConstantTimeCompare([]byte(iss), []byte(cmp)) != 0 { - return true - } else { - return false - } -} diff --git a/internal/jwt/doc.go b/internal/jwt/doc.go deleted file mode 100644 index a86dc1a3..00000000 --- a/internal/jwt/doc.go +++ /dev/null @@ -1,4 +0,0 @@ -// Package jwt is a Go implementation of JSON Web Tokens: http://self-issued.info/docs/draft-jones-json-web-token.html -// -// See README.md for more info. -package jwt diff --git a/internal/jwt/ecdsa.go b/internal/jwt/ecdsa.go deleted file mode 100644 index eac023fc..00000000 --- a/internal/jwt/ecdsa.go +++ /dev/null @@ -1,142 +0,0 @@ -package jwt - -import ( - "crypto" - "crypto/ecdsa" - "crypto/rand" - "errors" - "math/big" -) - -var ( - // Sadly this is missing from crypto/ecdsa compared to crypto/rsa - ErrECDSAVerification = errors.New("crypto/ecdsa: verification error") -) - -// SigningMethodECDSA implements the ECDSA family of signing methods. -// Expects *ecdsa.PrivateKey for signing and *ecdsa.PublicKey for verification -type SigningMethodECDSA struct { - Name string - Hash crypto.Hash - KeySize int - CurveBits int -} - -// Specific instances for EC256 and company -var ( - SigningMethodES256 *SigningMethodECDSA - SigningMethodES384 *SigningMethodECDSA - SigningMethodES512 *SigningMethodECDSA -) - -func init() { - // ES256 - SigningMethodES256 = &SigningMethodECDSA{"ES256", crypto.SHA256, 32, 256} - RegisterSigningMethod(SigningMethodES256.Alg(), func() SigningMethod { - return SigningMethodES256 - }) - - // ES384 - SigningMethodES384 = &SigningMethodECDSA{"ES384", crypto.SHA384, 48, 384} - RegisterSigningMethod(SigningMethodES384.Alg(), func() SigningMethod { - return SigningMethodES384 - }) - - // ES512 - SigningMethodES512 = &SigningMethodECDSA{"ES512", crypto.SHA512, 66, 521} - RegisterSigningMethod(SigningMethodES512.Alg(), func() SigningMethod { - return SigningMethodES512 - }) -} - -func (m *SigningMethodECDSA) Alg() string { - return m.Name -} - -// Verify implements token verification for the SigningMethod. -// For this verify method, key must be an ecdsa.PublicKey struct -func (m *SigningMethodECDSA) Verify(signingString, signature string, key interface{}) error { - var err error - - // Decode the signature - var sig []byte - if sig, err = DecodeSegment(signature); err != nil { - return err - } - - // Get the key - var ecdsaKey *ecdsa.PublicKey - switch k := key.(type) { - case *ecdsa.PublicKey: - ecdsaKey = k - default: - return ErrInvalidKeyType - } - - if len(sig) != 2*m.KeySize { - return ErrECDSAVerification - } - - r := big.NewInt(0).SetBytes(sig[:m.KeySize]) - s := big.NewInt(0).SetBytes(sig[m.KeySize:]) - - // Create hasher - if !m.Hash.Available() { - return ErrHashUnavailable - } - hasher := m.Hash.New() - hasher.Write([]byte(signingString)) - - // Verify the signature - if verifystatus := ecdsa.Verify(ecdsaKey, hasher.Sum(nil), r, s); verifystatus { - return nil - } - - return ErrECDSAVerification -} - -// Sign implements token signing for the SigningMethod. -// For this signing method, key must be an ecdsa.PrivateKey struct -func (m *SigningMethodECDSA) Sign(signingString string, key interface{}) (string, error) { - // Get the key - var ecdsaKey *ecdsa.PrivateKey - switch k := key.(type) { - case *ecdsa.PrivateKey: - ecdsaKey = k - default: - return "", ErrInvalidKeyType - } - - // Create the hasher - if !m.Hash.Available() { - return "", ErrHashUnavailable - } - - hasher := m.Hash.New() - hasher.Write([]byte(signingString)) - - // Sign the string and return r, s - if r, s, err := ecdsa.Sign(rand.Reader, ecdsaKey, hasher.Sum(nil)); err == nil { - curveBits := ecdsaKey.Curve.Params().BitSize - - if m.CurveBits != curveBits { - return "", ErrInvalidKey - } - - keyBytes := curveBits / 8 - if curveBits%8 > 0 { - keyBytes += 1 - } - - // We serialize the outputs (r and s) into big-endian byte arrays - // padded with zeros on the left to make sure the sizes work out. - // Output must be 2*keyBytes long. - out := make([]byte, 2*keyBytes) - r.FillBytes(out[0:keyBytes]) // r is assigned to the first half of output. - s.FillBytes(out[keyBytes:]) // s is assigned to the second half of output. - - return EncodeSegment(out), nil - } else { - return "", err - } -} diff --git a/internal/jwt/ecdsa_utils.go b/internal/jwt/ecdsa_utils.go deleted file mode 100644 index 5700636d..00000000 --- a/internal/jwt/ecdsa_utils.go +++ /dev/null @@ -1,69 +0,0 @@ -package jwt - -import ( - "crypto/ecdsa" - "crypto/x509" - "encoding/pem" - "errors" -) - -var ( - ErrNotECPublicKey = errors.New("key is not a valid ECDSA public key") - ErrNotECPrivateKey = errors.New("key is not a valid ECDSA private key") -) - -// ParseECPrivateKeyFromPEM parses a PEM encoded Elliptic Curve Private Key Structure -func ParseECPrivateKeyFromPEM(key []byte) (*ecdsa.PrivateKey, error) { - var err error - - // Parse PEM block - var block *pem.Block - if block, _ = pem.Decode(key); block == nil { - return nil, ErrKeyMustBePEMEncoded - } - - // Parse the key - var parsedKey interface{} - if parsedKey, err = x509.ParseECPrivateKey(block.Bytes); err != nil { - if parsedKey, err = x509.ParsePKCS8PrivateKey(block.Bytes); err != nil { - return nil, err - } - } - - var pkey *ecdsa.PrivateKey - var ok bool - if pkey, ok = parsedKey.(*ecdsa.PrivateKey); !ok { - return nil, ErrNotECPrivateKey - } - - return pkey, nil -} - -// ParseECPublicKeyFromPEM parses a PEM encoded PKCS1 or PKCS8 public key -func ParseECPublicKeyFromPEM(key []byte) (*ecdsa.PublicKey, error) { - var err error - - // Parse PEM block - var block *pem.Block - if block, _ = pem.Decode(key); block == nil { - return nil, ErrKeyMustBePEMEncoded - } - - // Parse the key - var parsedKey interface{} - if parsedKey, err = x509.ParsePKIXPublicKey(block.Bytes); err != nil { - if cert, err := x509.ParseCertificate(block.Bytes); err == nil { - parsedKey = cert.PublicKey - } else { - return nil, err - } - } - - var pkey *ecdsa.PublicKey - var ok bool - if pkey, ok = parsedKey.(*ecdsa.PublicKey); !ok { - return nil, ErrNotECPublicKey - } - - return pkey, nil -} diff --git a/internal/jwt/ed25519.go b/internal/jwt/ed25519.go deleted file mode 100644 index 07d3aacd..00000000 --- a/internal/jwt/ed25519.go +++ /dev/null @@ -1,85 +0,0 @@ -package jwt - -import ( - "errors" - - "crypto" - "crypto/ed25519" - "crypto/rand" -) - -var ( - ErrEd25519Verification = errors.New("ed25519: verification error") -) - -// SigningMethodEd25519 implements the EdDSA family. -// Expects ed25519.PrivateKey for signing and ed25519.PublicKey for verification -type SigningMethodEd25519 struct{} - -// Specific instance for EdDSA -var ( - SigningMethodEdDSA *SigningMethodEd25519 -) - -func init() { - SigningMethodEdDSA = &SigningMethodEd25519{} - RegisterSigningMethod(SigningMethodEdDSA.Alg(), func() SigningMethod { - return SigningMethodEdDSA - }) -} - -func (m *SigningMethodEd25519) Alg() string { - return "EdDSA" -} - -// Verify implements token verification for the SigningMethod. -// For this verify method, key must be an ed25519.PublicKey -func (m *SigningMethodEd25519) Verify(signingString, signature string, key interface{}) error { - var err error - var ed25519Key ed25519.PublicKey - var ok bool - - if ed25519Key, ok = key.(ed25519.PublicKey); !ok { - return ErrInvalidKeyType - } - - if len(ed25519Key) != ed25519.PublicKeySize { - return ErrInvalidKey - } - - // Decode the signature - var sig []byte - if sig, err = DecodeSegment(signature); err != nil { - return err - } - - // Verify the signature - if !ed25519.Verify(ed25519Key, []byte(signingString), sig) { - return ErrEd25519Verification - } - - return nil -} - -// Sign implements token signing for the SigningMethod. -// For this signing method, key must be an ed25519.PrivateKey -func (m *SigningMethodEd25519) Sign(signingString string, key interface{}) (string, error) { - var ed25519Key crypto.Signer - var ok bool - - if ed25519Key, ok = key.(crypto.Signer); !ok { - return "", ErrInvalidKeyType - } - - if _, ok := ed25519Key.Public().(ed25519.PublicKey); !ok { - return "", ErrInvalidKey - } - - // Sign the string and return the encoded result - // ed25519 performs a two-pass hash as part of its algorithm. Therefore, we need to pass a non-prehashed message into the Sign function, as indicated by crypto.Hash(0) - sig, err := ed25519Key.Sign(rand.Reader, []byte(signingString), crypto.Hash(0)) - if err != nil { - return "", err - } - return EncodeSegment(sig), nil -} diff --git a/internal/jwt/ed25519_test.go b/internal/jwt/ed25519_test.go deleted file mode 100644 index c7109c76..00000000 --- a/internal/jwt/ed25519_test.go +++ /dev/null @@ -1,84 +0,0 @@ -package jwt_test - -import ( - "io/ioutil" - "strings" - "testing" - - "github.com/golang-jwt/jwt/v4" -) - -var ed25519TestData = []struct { - name string - keys map[string]string - tokenString string - alg string - claims map[string]interface{} - valid bool -}{ - { - "Basic Ed25519", - map[string]string{"private": "test/ed25519-private.pem", "public": "test/ed25519-public.pem"}, - "eyJhbGciOiJFRDI1NTE5IiwidHlwIjoiSldUIn0.eyJmb28iOiJiYXIifQ.ESuVzZq1cECrt9Od_gLPVG-_6uRP_8Nq-ajx6CtmlDqRJZqdejro2ilkqaQgSL-siE_3JMTUW7UwAorLaTyFCw", - "EdDSA", - map[string]interface{}{"foo": "bar"}, - true, - }, - { - "Basic Ed25519", - map[string]string{"private": "test/ed25519-private.pem", "public": "test/ed25519-public.pem"}, - "eyJhbGciOiJFRDI1NTE5IiwidHlwIjoiSldUIn0.eyJmb28iOiJiYXoifQ.ESuVzZq1cECrt9Od_gLPVG-_6uRP_8Nq-ajx6CtmlDqRJZqdejro2ilkqaQgSL-siE_3JMTUW7UwAorLaTyFCw", - "EdDSA", - map[string]interface{}{"foo": "bar"}, - false, - }, -} - -func TestEd25519Verify(t *testing.T) { - for _, data := range ed25519TestData { - var err error - - key, _ := ioutil.ReadFile(data.keys["public"]) - - ed25519Key, err := jwt.ParseEdPublicKeyFromPEM(key) - if err != nil { - t.Errorf("Unable to parse Ed25519 public key: %v", err) - } - - parts := strings.Split(data.tokenString, ".") - - method := jwt.GetSigningMethod(data.alg) - - err = method.Verify(strings.Join(parts[0:2], "."), parts[2], ed25519Key) - if data.valid && err != nil { - t.Errorf("[%v] Error while verifying key: %v", data.name, err) - } - if !data.valid && err == nil { - t.Errorf("[%v] Invalid key passed validation", data.name) - } - } -} - -func TestEd25519Sign(t *testing.T) { - for _, data := range ed25519TestData { - var err error - key, _ := ioutil.ReadFile(data.keys["private"]) - - ed25519Key, err := jwt.ParseEdPrivateKeyFromPEM(key) - if err != nil { - t.Errorf("Unable to parse Ed25519 private key: %v", err) - } - - parts := strings.Split(data.tokenString, ".") - - method := jwt.GetSigningMethod(data.alg) - - sig, err := method.Sign(strings.Join(parts[0:2], "."), ed25519Key) - if err != nil { - t.Errorf("[%v] Error signing token: %v", data.name, err) - } - if sig == parts[2] && !data.valid { - t.Errorf("[%v] Identical signatures\nbefore:\n%v\nafter:\n%v", data.name, parts[2], sig) - } - } -} diff --git a/internal/jwt/ed25519_utils.go b/internal/jwt/ed25519_utils.go deleted file mode 100644 index cdb5e68e..00000000 --- a/internal/jwt/ed25519_utils.go +++ /dev/null @@ -1,64 +0,0 @@ -package jwt - -import ( - "crypto" - "crypto/ed25519" - "crypto/x509" - "encoding/pem" - "errors" -) - -var ( - ErrNotEdPrivateKey = errors.New("key is not a valid Ed25519 private key") - ErrNotEdPublicKey = errors.New("key is not a valid Ed25519 public key") -) - -// ParseEdPrivateKeyFromPEM parses a PEM-encoded Edwards curve private key -func ParseEdPrivateKeyFromPEM(key []byte) (crypto.PrivateKey, error) { - var err error - - // Parse PEM block - var block *pem.Block - if block, _ = pem.Decode(key); block == nil { - return nil, ErrKeyMustBePEMEncoded - } - - // Parse the key - var parsedKey interface{} - if parsedKey, err = x509.ParsePKCS8PrivateKey(block.Bytes); err != nil { - return nil, err - } - - var pkey ed25519.PrivateKey - var ok bool - if pkey, ok = parsedKey.(ed25519.PrivateKey); !ok { - return nil, ErrNotEdPrivateKey - } - - return pkey, nil -} - -// ParseEdPublicKeyFromPEM parses a PEM-encoded Edwards curve public key -func ParseEdPublicKeyFromPEM(key []byte) (crypto.PublicKey, error) { - var err error - - // Parse PEM block - var block *pem.Block - if block, _ = pem.Decode(key); block == nil { - return nil, ErrKeyMustBePEMEncoded - } - - // Parse the key - var parsedKey interface{} - if parsedKey, err = x509.ParsePKIXPublicKey(block.Bytes); err != nil { - return nil, err - } - - var pkey ed25519.PublicKey - var ok bool - if pkey, ok = parsedKey.(ed25519.PublicKey); !ok { - return nil, ErrNotEdPublicKey - } - - return pkey, nil -} diff --git a/internal/jwt/errors.go b/internal/jwt/errors.go deleted file mode 100644 index 10ac8835..00000000 --- a/internal/jwt/errors.go +++ /dev/null @@ -1,112 +0,0 @@ -package jwt - -import ( - "errors" -) - -// Error constants -var ( - ErrInvalidKey = errors.New("key is invalid") - ErrInvalidKeyType = errors.New("key is of invalid type") - ErrHashUnavailable = errors.New("the requested hash function is unavailable") - - ErrTokenMalformed = errors.New("token is malformed") - ErrTokenUnverifiable = errors.New("token is unverifiable") - ErrTokenSignatureInvalid = errors.New("token signature is invalid") - - ErrTokenInvalidAudience = errors.New("token has invalid audience") - ErrTokenExpired = errors.New("token is expired") - ErrTokenUsedBeforeIssued = errors.New("token used before issued") - ErrTokenInvalidIssuer = errors.New("token has invalid issuer") - ErrTokenNotValidYet = errors.New("token is not valid yet") - ErrTokenInvalidId = errors.New("token has invalid id") - ErrTokenInvalidClaims = errors.New("token has invalid claims") -) - -// The errors that might occur when parsing and validating a token -const ( - ValidationErrorMalformed uint32 = 1 << iota // Token is malformed - ValidationErrorUnverifiable // Token could not be verified because of signing problems - ValidationErrorSignatureInvalid // Signature validation failed - - // Standard Claim validation errors - ValidationErrorAudience // AUD validation failed - ValidationErrorExpired // EXP validation failed - ValidationErrorIssuedAt // IAT validation failed - ValidationErrorIssuer // ISS validation failed - ValidationErrorNotValidYet // NBF validation failed - ValidationErrorId // JTI validation failed - ValidationErrorClaimsInvalid // Generic claims validation error -) - -// NewValidationError is a helper for constructing a ValidationError with a string error message -func NewValidationError(errorText string, errorFlags uint32) *ValidationError { - return &ValidationError{ - text: errorText, - Errors: errorFlags, - } -} - -// ValidationError represents an error from Parse if token is not valid -type ValidationError struct { - Inner error // stores the error returned by external dependencies, i.e.: KeyFunc - Errors uint32 // bitfield. see ValidationError... constants - text string // errors that do not have a valid error just have text -} - -// Error is the implementation of the err interface. -func (e ValidationError) Error() string { - if e.Inner != nil { - return e.Inner.Error() - } else if e.text != "" { - return e.text - } else { - return "token is invalid" - } -} - -// Unwrap gives errors.Is and errors.As access to the inner error. -func (e *ValidationError) Unwrap() error { - return e.Inner -} - -// No errors -func (e *ValidationError) valid() bool { - return e.Errors == 0 -} - -// Is checks if this ValidationError is of the supplied error. We are first checking for the exact error message -// by comparing the inner error message. If that fails, we compare using the error flags. This way we can use -// custom error messages (mainly for backwards compatability) and still leverage errors.Is using the global error variables. -func (e *ValidationError) Is(err error) bool { - // Check, if our inner error is a direct match - if errors.Is(errors.Unwrap(e), err) { - return true - } - - // Otherwise, we need to match using our error flags - switch err { - case ErrTokenMalformed: - return e.Errors&ValidationErrorMalformed != 0 - case ErrTokenUnverifiable: - return e.Errors&ValidationErrorUnverifiable != 0 - case ErrTokenSignatureInvalid: - return e.Errors&ValidationErrorSignatureInvalid != 0 - case ErrTokenInvalidAudience: - return e.Errors&ValidationErrorAudience != 0 - case ErrTokenExpired: - return e.Errors&ValidationErrorExpired != 0 - case ErrTokenUsedBeforeIssued: - return e.Errors&ValidationErrorIssuedAt != 0 - case ErrTokenInvalidIssuer: - return e.Errors&ValidationErrorIssuer != 0 - case ErrTokenNotValidYet: - return e.Errors&ValidationErrorNotValidYet != 0 - case ErrTokenInvalidId: - return e.Errors&ValidationErrorId != 0 - case ErrTokenInvalidClaims: - return e.Errors&ValidationErrorClaimsInvalid != 0 - } - - return false -} diff --git a/internal/jwt/example_test.go b/internal/jwt/example_test.go deleted file mode 100644 index d5b9327d..00000000 --- a/internal/jwt/example_test.go +++ /dev/null @@ -1,117 +0,0 @@ -package jwt_test - -import ( - "errors" - "fmt" - "time" - - "github.com/fiware/vcverifier/internal/jwt" -) - -// Example (atypical) using the RegisteredClaims type by itself to parse a token. -// The RegisteredClaims type is designed to be embedded into your custom types -// to provide standard validation features. You can use it alone, but there's -// no way to retrieve other fields after parsing. -// See the CustomClaimsType example for intended usage. -func ExampleNewWithClaims_registeredClaims() { - mySigningKey := []byte("AllYourBase") - - // Create the Claims - claims := &jwt.RegisteredClaims{ - ExpiresAt: jwt.NewNumericDate(time.Unix(1516239022, 0)), - Issuer: "test", - } - - token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims) - ss, err := token.SignedString(mySigningKey) - fmt.Printf("%v %v", ss, err) - //Output: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0ZXN0IiwiZXhwIjoxNTE2MjM5MDIyfQ.0XN_1Tpp9FszFOonIBpwha0c_SfnNI22DhTnjMshPg8 -} - -// Example creating a token using a custom claims type. The RegisteredClaims is embedded -// in the custom type to allow for easy encoding, parsing and validation of registered claims. -func ExampleNewWithClaims_customClaimsType() { - mySigningKey := []byte("AllYourBase") - - type MyCustomClaims struct { - Foo string `json:"foo"` - jwt.RegisteredClaims - } - - // Create the claims - claims := MyCustomClaims{ - "bar", - jwt.RegisteredClaims{ - // A usual scenario is to set the expiration time relative to the current time - ExpiresAt: jwt.NewNumericDate(time.Now().Add(24 * time.Hour)), - IssuedAt: jwt.NewNumericDate(time.Now()), - NotBefore: jwt.NewNumericDate(time.Now()), - Issuer: "test", - Subject: "somebody", - ID: "1", - Audience: []string{"somebody_else"}, - }, - } - - // Create claims while leaving out some of the optional fields - claims = MyCustomClaims{ - "bar", - jwt.RegisteredClaims{ - // Also fixed dates can be used for the NumericDate - ExpiresAt: jwt.NewNumericDate(time.Unix(1516239022, 0)), - Issuer: "test", - }, - } - - token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims) - ss, err := token.SignedString(mySigningKey) - fmt.Printf("%v %v", ss, err) - - //Output: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmb28iOiJiYXIiLCJpc3MiOiJ0ZXN0IiwiZXhwIjoxNTE2MjM5MDIyfQ.xVuY2FZ_MRXMIEgVQ7J-TFtaucVFRXUzHm9LmV41goM -} - -// Example creating a token using a custom claims type. The StandardClaim is embedded -// in the custom type to allow for easy encoding, parsing and validation of standard claims. -func ExampleParseWithClaims_customClaimsType() { - tokenString := "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmb28iOiJiYXIiLCJpc3MiOiJ0ZXN0IiwiYXVkIjoic2luZ2xlIn0.QAWg1vGvnqRuCFTMcPkjZljXHh8U3L_qUjszOtQbeaA" - - type MyCustomClaims struct { - Foo string `json:"foo"` - jwt.RegisteredClaims - } - - token, err := jwt.ParseWithClaims(tokenString, &MyCustomClaims{}, func(token *jwt.Token) (interface{}, error) { - return []byte("AllYourBase"), nil - }) - - if claims, ok := token.Claims.(*MyCustomClaims); ok && token.Valid { - fmt.Printf("%v %v", claims.Foo, claims.RegisteredClaims.Issuer) - } else { - fmt.Println(err) - } - - // Output: bar test -} - -// An example of parsing the error types using bitfield checks -func ExampleParse_errorChecking() { - // Token from another example. This token is expired - var tokenString = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmb28iOiJiYXIiLCJleHAiOjE1MDAwLCJpc3MiOiJ0ZXN0In0.HE7fK0xOQwFEr4WDgRWj4teRPZ6i3GLwD5YCm6Pwu_c" - - token, err := jwt.Parse(tokenString, func(token *jwt.Token) (interface{}, error) { - return []byte("AllYourBase"), nil - }) - - if token.Valid { - fmt.Println("You look nice today") - } else if errors.Is(err, jwt.ErrTokenMalformed) { - fmt.Println("That's not even a token") - } else if errors.Is(err, jwt.ErrTokenExpired) || errors.Is(err, jwt.ErrTokenNotValidYet) { - // Token is either expired or not active yet - fmt.Println("Timing is everything") - } else { - fmt.Println("Couldn't handle this token:", err) - } - - // Output: Timing is everything -} diff --git a/internal/jwt/hmac.go b/internal/jwt/hmac.go deleted file mode 100644 index 011f68a2..00000000 --- a/internal/jwt/hmac.go +++ /dev/null @@ -1,95 +0,0 @@ -package jwt - -import ( - "crypto" - "crypto/hmac" - "errors" -) - -// SigningMethodHMAC implements the HMAC-SHA family of signing methods. -// Expects key type of []byte for both signing and validation -type SigningMethodHMAC struct { - Name string - Hash crypto.Hash -} - -// Specific instances for HS256 and company -var ( - SigningMethodHS256 *SigningMethodHMAC - SigningMethodHS384 *SigningMethodHMAC - SigningMethodHS512 *SigningMethodHMAC - ErrSignatureInvalid = errors.New("signature is invalid") -) - -func init() { - // HS256 - SigningMethodHS256 = &SigningMethodHMAC{"HS256", crypto.SHA256} - RegisterSigningMethod(SigningMethodHS256.Alg(), func() SigningMethod { - return SigningMethodHS256 - }) - - // HS384 - SigningMethodHS384 = &SigningMethodHMAC{"HS384", crypto.SHA384} - RegisterSigningMethod(SigningMethodHS384.Alg(), func() SigningMethod { - return SigningMethodHS384 - }) - - // HS512 - SigningMethodHS512 = &SigningMethodHMAC{"HS512", crypto.SHA512} - RegisterSigningMethod(SigningMethodHS512.Alg(), func() SigningMethod { - return SigningMethodHS512 - }) -} - -func (m *SigningMethodHMAC) Alg() string { - return m.Name -} - -// Verify implements token verification for the SigningMethod. Returns nil if the signature is valid. -func (m *SigningMethodHMAC) Verify(signingString, signature string, key interface{}) error { - // Verify the key is the right type - keyBytes, ok := key.([]byte) - if !ok { - return ErrInvalidKeyType - } - - // Decode signature, for comparison - sig, err := DecodeSegment(signature) - if err != nil { - return err - } - - // Can we use the specified hashing method? - if !m.Hash.Available() { - return ErrHashUnavailable - } - - // This signing method is symmetric, so we validate the signature - // by reproducing the signature from the signing string and key, then - // comparing that against the provided signature. - hasher := hmac.New(m.Hash.New, keyBytes) - hasher.Write([]byte(signingString)) - if !hmac.Equal(sig, hasher.Sum(nil)) { - return ErrSignatureInvalid - } - - // No validation errors. Signature is good. - return nil -} - -// Sign implements token signing for the SigningMethod. -// Key must be []byte -func (m *SigningMethodHMAC) Sign(signingString string, key interface{}) (string, error) { - if keyBytes, ok := key.([]byte); ok { - if !m.Hash.Available() { - return "", ErrHashUnavailable - } - - hasher := hmac.New(m.Hash.New, keyBytes) - hasher.Write([]byte(signingString)) - - return EncodeSegment(hasher.Sum(nil)), nil - } - - return "", ErrInvalidKeyType -} diff --git a/internal/jwt/hmac_example_test.go b/internal/jwt/hmac_example_test.go deleted file mode 100644 index 95111a4b..00000000 --- a/internal/jwt/hmac_example_test.go +++ /dev/null @@ -1,67 +0,0 @@ -package jwt_test - -import ( - "fmt" - "io/ioutil" - "time" - - "github.com/fiware/vcverifier/internal/jwt" -) - -// For HMAC signing method, the key can be any []byte. It is recommended to generate -// a key using crypto/rand or something equivalent. You need the same key for signing -// and validating. -var hmacSampleSecret []byte - -func init() { - // Load sample key data - if keyData, e := ioutil.ReadFile("test/hmacTestKey"); e == nil { - hmacSampleSecret = keyData - } else { - panic(e) - } -} - -// Example creating, signing, and encoding a JWT token using the HMAC signing method -func ExampleNew_hmac() { - // Create a new token object, specifying signing method and the claims - // you would like it to contain. - token := jwt.NewWithClaims(jwt.SigningMethodHS256, jwt.MapClaims{ - "foo": "bar", - "nbf": time.Date(2015, 10, 10, 12, 0, 0, 0, time.UTC).Unix(), - }) - - // Sign and get the complete encoded token as a string using the secret - tokenString, err := token.SignedString(hmacSampleSecret) - - fmt.Println(tokenString, err) - // Output: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmb28iOiJiYXIiLCJuYmYiOjE0NDQ0Nzg0MDB9.u1riaD1rW97opCoAuRCTy4w58Br-Zk-bh7vLiRIsrpU -} - -// Example parsing and validating a token using the HMAC signing method -func ExampleParse_hmac() { - // sample token string taken from the New example - tokenString := "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmb28iOiJiYXIiLCJuYmYiOjE0NDQ0Nzg0MDB9.u1riaD1rW97opCoAuRCTy4w58Br-Zk-bh7vLiRIsrpU" - - // Parse takes the token string and a function for looking up the key. The latter is especially - // useful if you use multiple keys for your application. The standard is to use 'kid' in the - // head of the token to identify which key to use, but the parsed token (head and claims) is provided - // to the callback, providing flexibility. - token, err := jwt.Parse(tokenString, func(token *jwt.Token) (interface{}, error) { - // Don't forget to validate the alg is what you expect: - if _, ok := token.Method.(*jwt.SigningMethodHMAC); !ok { - return nil, fmt.Errorf("Unexpected signing method: %v", token.Header["alg"]) - } - - // hmacSampleSecret is a []byte containing your secret, e.g. []byte("my_secret_key") - return hmacSampleSecret, nil - }) - - if claims, ok := token.Claims.(jwt.MapClaims); ok && token.Valid { - fmt.Println(claims["foo"], claims["nbf"]) - } else { - fmt.Println(err) - } - - // Output: bar 1.4444784e+09 -} diff --git a/internal/jwt/http_example_test.go b/internal/jwt/http_example_test.go deleted file mode 100644 index c43ab5f9..00000000 --- a/internal/jwt/http_example_test.go +++ /dev/null @@ -1,210 +0,0 @@ -package jwt_test - -// Example HTTP auth using asymmetric crypto/RSA keys -// This is based on a (now outdated) example at https://gist.github.com/cryptix/45c33ecf0ae54828e63b - -import ( - "bytes" - "crypto/rsa" - "fmt" - "io" - "io/ioutil" - "log" - "net" - "net/http" - "net/url" - "strings" - "time" - - "github.com/golang-jwt/jwt/v4" - "github.com/golang-jwt/jwt/v4/request" -) - -// location of the files used for signing and verification -const ( - privKeyPath = "test/sample_key" // openssl genrsa -out app.rsa keysize - pubKeyPath = "test/sample_key.pub" // openssl rsa -in app.rsa -pubout > app.rsa.pub -) - -var ( - verifyKey *rsa.PublicKey - signKey *rsa.PrivateKey - serverPort int -) - -// read the key files before starting http handlers -func init() { - signBytes, err := ioutil.ReadFile(privKeyPath) - fatal(err) - - signKey, err = jwt.ParseRSAPrivateKeyFromPEM(signBytes) - fatal(err) - - verifyBytes, err := ioutil.ReadFile(pubKeyPath) - fatal(err) - - verifyKey, err = jwt.ParseRSAPublicKeyFromPEM(verifyBytes) - fatal(err) - - http.HandleFunc("/authenticate", authHandler) - http.HandleFunc("/restricted", restrictedHandler) - - // Setup listener - listener, err := net.ListenTCP("tcp", &net.TCPAddr{}) - fatal(err) - serverPort = listener.Addr().(*net.TCPAddr).Port - - log.Println("Listening...") - go func() { - fatal(http.Serve(listener, nil)) - }() -} - -func fatal(err error) { - if err != nil { - log.Fatal(err) - } -} - -// Define some custom types were going to use within our tokens -type CustomerInfo struct { - Name string - Kind string -} - -type CustomClaimsExample struct { - *jwt.RegisteredClaims - TokenType string - CustomerInfo -} - -func Example_getTokenViaHTTP() { - // See func authHandler for an example auth handler that produces a token - res, err := http.PostForm(fmt.Sprintf("http://localhost:%v/authenticate", serverPort), url.Values{ - "user": {"test"}, - "pass": {"known"}, - }) - if err != nil { - fatal(err) - } - - if res.StatusCode != 200 { - fmt.Println("Unexpected status code", res.StatusCode) - } - - // Read the token out of the response body - buf := new(bytes.Buffer) - io.Copy(buf, res.Body) - res.Body.Close() - tokenString := strings.TrimSpace(buf.String()) - - // Parse the token - token, err := jwt.ParseWithClaims(tokenString, &CustomClaimsExample{}, func(token *jwt.Token) (interface{}, error) { - // since we only use the one private key to sign the tokens, - // we also only use its public counter part to verify - return verifyKey, nil - }) - fatal(err) - - claims := token.Claims.(*CustomClaimsExample) - fmt.Println(claims.CustomerInfo.Name) - - //Output: test -} - -func Example_useTokenViaHTTP() { - - // Make a sample token - // In a real world situation, this token will have been acquired from - // some other API call (see Example_getTokenViaHTTP) - token, err := createToken("foo") - fatal(err) - - // Make request. See func restrictedHandler for example request processor - req, err := http.NewRequest("GET", fmt.Sprintf("http://localhost:%v/restricted", serverPort), nil) - fatal(err) - req.Header.Set("Authorization", fmt.Sprintf("Bearer %v", token)) - res, err := http.DefaultClient.Do(req) - fatal(err) - - // Read the response body - buf := new(bytes.Buffer) - io.Copy(buf, res.Body) - res.Body.Close() - fmt.Println(buf.String()) - - // Output: Welcome, foo -} - -func createToken(user string) (string, error) { - // create a signer for rsa 256 - t := jwt.New(jwt.GetSigningMethod("RS256")) - - // set our claims - t.Claims = &CustomClaimsExample{ - &jwt.RegisteredClaims{ - // set the expire time - // see https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.4 - ExpiresAt: jwt.NewNumericDate(time.Now().Add(time.Minute * 1)), - }, - "level1", - CustomerInfo{user, "human"}, - } - - // Creat token string - return t.SignedString(signKey) -} - -// reads the form values, checks them and creates the token -func authHandler(w http.ResponseWriter, r *http.Request) { - // make sure its post - if r.Method != "POST" { - w.WriteHeader(http.StatusBadRequest) - fmt.Fprintln(w, "No POST", r.Method) - return - } - - user := r.FormValue("user") - pass := r.FormValue("pass") - - log.Printf("Authenticate: user[%s] pass[%s]\n", user, pass) - - // check values - if user != "test" || pass != "known" { - w.WriteHeader(http.StatusForbidden) - fmt.Fprintln(w, "Wrong info") - return - } - - tokenString, err := createToken(user) - if err != nil { - w.WriteHeader(http.StatusInternalServerError) - fmt.Fprintln(w, "Sorry, error while Signing Token!") - log.Printf("Token Signing error: %v\n", err) - return - } - - w.Header().Set("Content-Type", "application/jwt") - w.WriteHeader(http.StatusOK) - fmt.Fprintln(w, tokenString) -} - -// only accessible with a valid token -func restrictedHandler(w http.ResponseWriter, r *http.Request) { - // Get token from request - token, err := request.ParseFromRequest(r, request.OAuth2Extractor, func(token *jwt.Token) (interface{}, error) { - // since we only use the one private key to sign the tokens, - // we also only use its public counter part to verify - return verifyKey, nil - }, request.WithClaims(&CustomClaimsExample{})) - - // If the token is missing or invalid, return error - if err != nil { - w.WriteHeader(http.StatusUnauthorized) - fmt.Fprintln(w, "Invalid token:", err) - return - } - - // Token is valid - fmt.Fprintln(w, "Welcome,", token.Claims.(*CustomClaimsExample).Name) -} diff --git a/internal/jwt/map_claims.go b/internal/jwt/map_claims.go deleted file mode 100644 index 2700d64a..00000000 --- a/internal/jwt/map_claims.go +++ /dev/null @@ -1,151 +0,0 @@ -package jwt - -import ( - "encoding/json" - "errors" - "time" - // "fmt" -) - -// MapClaims is a claims type that uses the map[string]interface{} for JSON decoding. -// This is the default claims type if you don't supply one -type MapClaims map[string]interface{} - -// VerifyAudience Compares the aud claim against cmp. -// If required is false, this method will return true if the value matches or is unset -func (m MapClaims) VerifyAudience(cmp string, req bool) bool { - var aud []string - switch v := m["aud"].(type) { - case string: - aud = append(aud, v) - case []string: - aud = v - case []interface{}: - for _, a := range v { - vs, ok := a.(string) - if !ok { - return false - } - aud = append(aud, vs) - } - } - return verifyAud(aud, cmp, req) -} - -// VerifyExpiresAt compares the exp claim against cmp (cmp <= exp). -// If req is false, it will return true, if exp is unset. -func (m MapClaims) VerifyExpiresAt(cmp int64, req bool) bool { - cmpTime := time.Unix(cmp, 0) - - v, ok := m["exp"] - if !ok { - return !req - } - - switch exp := v.(type) { - case float64: - if exp == 0 { - return verifyExp(nil, cmpTime, req) - } - - return verifyExp(&newNumericDateFromSeconds(exp).Time, cmpTime, req) - case json.Number: - v, _ := exp.Float64() - - return verifyExp(&newNumericDateFromSeconds(v).Time, cmpTime, req) - } - - return false -} - -// VerifyIssuedAt compares the exp claim against cmp (cmp >= iat). -// If req is false, it will return true, if iat is unset. -func (m MapClaims) VerifyIssuedAt(cmp int64, req bool) bool { - cmpTime := time.Unix(cmp, 0) - - v, ok := m["iat"] - if !ok { - return !req - } - - switch iat := v.(type) { - case float64: - if iat == 0 { - return verifyIat(nil, cmpTime, req) - } - - return verifyIat(&newNumericDateFromSeconds(iat).Time, cmpTime, req) - case json.Number: - v, _ := iat.Float64() - - return verifyIat(&newNumericDateFromSeconds(v).Time, cmpTime, req) - } - - return false -} - -// VerifyNotBefore compares the nbf claim against cmp (cmp >= nbf). -// If req is false, it will return true, if nbf is unset. -func (m MapClaims) VerifyNotBefore(cmp int64, req bool) bool { - cmpTime := time.Unix(cmp, 0) - - v, ok := m["nbf"] - if !ok { - return !req - } - - switch nbf := v.(type) { - case float64: - if nbf == 0 { - return verifyNbf(nil, cmpTime, req) - } - - return verifyNbf(&newNumericDateFromSeconds(nbf).Time, cmpTime, req) - case json.Number: - v, _ := nbf.Float64() - - return verifyNbf(&newNumericDateFromSeconds(v).Time, cmpTime, req) - } - - return false -} - -// VerifyIssuer compares the iss claim against cmp. -// If required is false, this method will return true if the value matches or is unset -func (m MapClaims) VerifyIssuer(cmp string, req bool) bool { - iss, _ := m["iss"].(string) - return verifyIss(iss, cmp, req) -} - -// Valid validates time based claims "exp, iat, nbf". -// There is no accounting for clock skew. -// As well, if any of the above claims are not in the token, it will still -// be considered a valid claim. -func (m MapClaims) Valid() error { - vErr := new(ValidationError) - now := TimeFunc().Unix() - - if !m.VerifyExpiresAt(now, false) { - // TODO(oxisto): this should be replaced with ErrTokenExpired - vErr.Inner = errors.New("Token is expired") - vErr.Errors |= ValidationErrorExpired - } - - if !m.VerifyIssuedAt(now, false) { - // TODO(oxisto): this should be replaced with ErrTokenUsedBeforeIssued - vErr.Inner = errors.New("Token used before issued") - vErr.Errors |= ValidationErrorIssuedAt - } - - if !m.VerifyNotBefore(now, false) { - // TODO(oxisto): this should be replaced with ErrTokenNotValidYet - vErr.Inner = errors.New("Token is not valid yet") - vErr.Errors |= ValidationErrorNotValidYet - } - - if vErr.valid() { - return nil - } - - return vErr -} diff --git a/internal/jwt/map_claims_test.go b/internal/jwt/map_claims_test.go deleted file mode 100644 index b8b9eb74..00000000 --- a/internal/jwt/map_claims_test.go +++ /dev/null @@ -1,123 +0,0 @@ -package jwt - -import ( - "testing" - "time" -) - -func TestVerifyAud(t *testing.T) { - var nilInterface interface{} - var nilListInterface []interface{} - var intListInterface interface{} = []int{1, 2, 3} - type test struct { - Name string - MapClaims MapClaims - Expected bool - Comparison string - Required bool - } - tests := []test{ - // Matching Claim in aud - // Required = true - {Name: "String Aud matching required", MapClaims: MapClaims{"aud": "example.com"}, Expected: true, Required: true, Comparison: "example.com"}, - {Name: "[]String Aud with match required", MapClaims: MapClaims{"aud": []string{"example.com", "example.example.com"}}, Expected: true, Required: true, Comparison: "example.com"}, - - // Required = false - {Name: "String Aud with match not required", MapClaims: MapClaims{"aud": "example.com"}, Expected: true, Required: false, Comparison: "example.com"}, - {Name: "Empty String Aud with match not required", MapClaims: MapClaims{}, Expected: true, Required: false, Comparison: "example.com"}, - {Name: "Empty String Aud with match not required", MapClaims: MapClaims{"aud": ""}, Expected: true, Required: false, Comparison: "example.com"}, - {Name: "Nil String Aud with match not required", MapClaims: MapClaims{"aud": nil}, Expected: true, Required: false, Comparison: "example.com"}, - - {Name: "[]String Aud with match not required", MapClaims: MapClaims{"aud": []string{"example.com", "example.example.com"}}, Expected: true, Required: false, Comparison: "example.com"}, - {Name: "Empty []String Aud with match not required", MapClaims: MapClaims{"aud": []string{}}, Expected: true, Required: false, Comparison: "example.com"}, - - // Non-Matching Claim in aud - // Required = true - {Name: "String Aud without match required", MapClaims: MapClaims{"aud": "not.example.com"}, Expected: false, Required: true, Comparison: "example.com"}, - {Name: "Empty String Aud without match required", MapClaims: MapClaims{"aud": ""}, Expected: false, Required: true, Comparison: "example.com"}, - {Name: "[]String Aud without match required", MapClaims: MapClaims{"aud": []string{"not.example.com", "example.example.com"}}, Expected: false, Required: true, Comparison: "example.com"}, - {Name: "Empty []String Aud without match required", MapClaims: MapClaims{"aud": []string{""}}, Expected: false, Required: true, Comparison: "example.com"}, - {Name: "String Aud without match not required", MapClaims: MapClaims{"aud": "not.example.com"}, Expected: false, Required: true, Comparison: "example.com"}, - {Name: "Empty String Aud without match not required", MapClaims: MapClaims{"aud": ""}, Expected: false, Required: true, Comparison: "example.com"}, - {Name: "[]String Aud without match not required", MapClaims: MapClaims{"aud": []string{"not.example.com", "example.example.com"}}, Expected: false, Required: true, Comparison: "example.com"}, - - // Required = false - {Name: "Empty []String Aud without match required", MapClaims: MapClaims{"aud": []string{""}}, Expected: false, Required: true, Comparison: "example.com"}, - - // []interface{} - {Name: "Empty []interface{} Aud without match required", MapClaims: MapClaims{"aud": nilListInterface}, Expected: true, Required: false, Comparison: "example.com"}, - {Name: "[]interface{} Aud wit match required", MapClaims: MapClaims{"aud": []interface{}{"a", "foo", "example.com"}}, Expected: true, Required: true, Comparison: "example.com"}, - {Name: "[]interface{} Aud wit match but invalid types", MapClaims: MapClaims{"aud": []interface{}{"a", 5, "example.com"}}, Expected: false, Required: true, Comparison: "example.com"}, - {Name: "[]interface{} Aud int wit match required", MapClaims: MapClaims{"aud": intListInterface}, Expected: false, Required: true, Comparison: "example.com"}, - - // interface{} - {Name: "Empty interface{} Aud without match not required", MapClaims: MapClaims{"aud": nilInterface}, Expected: true, Required: false, Comparison: "example.com"}, - } - - for _, test := range tests { - t.Run(test.Name, func(t *testing.T) { - got := test.MapClaims.VerifyAudience(test.Comparison, test.Required) - - if got != test.Expected { - t.Errorf("Expected %v, got %v", test.Expected, got) - } - }) - } -} - -func TestMapclaimsVerifyIssuedAtInvalidTypeString(t *testing.T) { - mapClaims := MapClaims{ - "iat": "foo", - } - want := false - got := mapClaims.VerifyIssuedAt(0, false) - if want != got { - t.Fatalf("Failed to verify claims, wanted: %v got %v", want, got) - } -} - -func TestMapclaimsVerifyNotBeforeInvalidTypeString(t *testing.T) { - mapClaims := MapClaims{ - "nbf": "foo", - } - want := false - got := mapClaims.VerifyNotBefore(0, false) - if want != got { - t.Fatalf("Failed to verify claims, wanted: %v got %v", want, got) - } -} - -func TestMapclaimsVerifyExpiresAtInvalidTypeString(t *testing.T) { - mapClaims := MapClaims{ - "exp": "foo", - } - want := false - got := mapClaims.VerifyExpiresAt(0, false) - - if want != got { - t.Fatalf("Failed to verify claims, wanted: %v got %v", want, got) - } -} - -func TestMapClaimsVerifyExpiresAtExpire(t *testing.T) { - exp := time.Now().Unix() - mapClaims := MapClaims{ - "exp": float64(exp), - } - want := false - got := mapClaims.VerifyExpiresAt(exp, true) - if want != got { - t.Fatalf("Failed to verify claims, wanted: %v got %v", want, got) - } - - got = mapClaims.VerifyExpiresAt(exp + 1, true) - if want != got { - t.Fatalf("Failed to verify claims, wanted: %v got %v", want, got) - } - - want = true - got = mapClaims.VerifyExpiresAt(exp - 1, true) - if want != got { - t.Fatalf("Failed to verify claims, wanted: %v got %v", want, got) - } -} diff --git a/internal/jwt/parser.go b/internal/jwt/parser.go deleted file mode 100644 index 8436d484..00000000 --- a/internal/jwt/parser.go +++ /dev/null @@ -1,245 +0,0 @@ -package jwt - -import ( - "bytes" - "encoding/json" - "fmt" - "strings" -) - -type Parser struct { - // If populated, only these methods will be considered valid. - // - // Deprecated: In future releases, this field will not be exported anymore and should be set with an option to NewParser instead. - ValidMethods []string - - // Use JSON Number format in JSON decoder. - // - // Deprecated: In future releases, this field will not be exported anymore and should be set with an option to NewParser instead. - UseJSONNumber bool - - // Skip claims validation during token parsing. - // - // Deprecated: In future releases, this field will not be exported anymore and should be set with an option to NewParser instead. - SkipClaimsValidation bool -} - -// NewParser creates a new Parser with the specified options -func NewParser(options ...ParserOption) *Parser { - p := &Parser{} - - // loop through our parsing options and apply them - for _, option := range options { - option(p) - } - - return p -} - -// Parse parses, validates, verifies the signature and returns the parsed token. -// keyFunc will receive the parsed token and should return the key for validating. -func (p *Parser) Parse(tokenString string, keyFunc Keyfunc) (*Token, error) { - return p.ParseWithClaims(tokenString, MapClaims{}, keyFunc) -} - -func (p *Parser) ParseWithClaims(tokenString string, claims Claims, keyFunc Keyfunc) (*Token, error) { - - token, parts, err := p.ParseUnverified(tokenString, claims) - if err != nil { - return token, err - } - - // Verify signing method is in the required set - if p.ValidMethods != nil { - var signingMethodValid = false - var alg = token.Method.Alg() - for _, m := range p.ValidMethods { - if m == alg { - signingMethodValid = true - break - } - } - if !signingMethodValid { - // signing method is not in the listed set - return token, NewValidationError(fmt.Sprintf("signing method %v is invalid", alg), ValidationErrorSignatureInvalid) - } - } - - // Lookup key - var key interface{} - if keyFunc == nil { - // keyFunc was not provided. short circuiting validation - return token, NewValidationError("no Keyfunc was provided.", ValidationErrorUnverifiable) - } - if key, err = keyFunc(token); err != nil { - // keyFunc returned an error - if ve, ok := err.(*ValidationError); ok { - return token, ve - } - return token, &ValidationError{Inner: err, Errors: ValidationErrorUnverifiable} - } - - vErr := &ValidationError{} - - // Validate Claims - if !p.SkipClaimsValidation { - if err := token.Claims.Valid(); err != nil { - - // If the Claims Valid returned an error, check if it is a validation error, - // If it was another error type, create a ValidationError with a generic ClaimsInvalid flag set - if e, ok := err.(*ValidationError); !ok { - vErr = &ValidationError{Inner: err, Errors: ValidationErrorClaimsInvalid} - } else { - vErr = e - } - } - } - - // Perform validation - token.Signature = parts[2] - if err = token.Method.Verify(strings.Join(parts[0:2], "."), token.Signature, key); err != nil { - vErr.Inner = err - vErr.Errors |= ValidationErrorSignatureInvalid - } - - if vErr.valid() { - token.Valid = true - return token, nil - } - - return token, vErr -} - -// ParseUnverified parses the token but doesn't validate the signature. -// -// WARNING: Don't use this method unless you know what you're doing. -// -// It's only ever useful in cases where you know the signature is valid (because it has -// been checked previously in the stack) and you want to extract values from it. -func (p *Parser) ParseUnverified(tokenString string, claims Claims) (token *Token, parts []string, err error) { - - // A JWT token is composed of 3 parts concatenated by dots (".") - parts = strings.Split(tokenString, ".") - if len(parts) != 3 { - return nil, parts, NewValidationError("token contains an invalid number of segments", ValidationErrorMalformed) - } - - // Initialize the Token struct - token = &Token{Raw: tokenString} - - // Parse Header - var headerBytes []byte - if headerBytes, err = DecodeSegment(parts[0]); err != nil { - if strings.HasPrefix(strings.ToLower(tokenString), "bearer ") { - return token, parts, NewValidationError("tokenstring should not contain 'bearer '", ValidationErrorMalformed) - } - return token, parts, &ValidationError{Inner: err, Errors: ValidationErrorMalformed} - } - if err = json.Unmarshal(headerBytes, &token.Header); err != nil { - return token, parts, &ValidationError{Inner: err, Errors: ValidationErrorMalformed} - } - - // parse Claims - var claimBytes []byte - token.Claims = claims - - if claimBytes, err = DecodeSegment(parts[1]); err != nil { - return token, parts, &ValidationError{Inner: err, Errors: ValidationErrorMalformed} - } - dec := json.NewDecoder(bytes.NewBuffer(claimBytes)) - if p.UseJSONNumber { - dec.UseNumber() - } - // JSON Decode. Special case for map type to avoid weird pointer behavior - if c, ok := token.Claims.(MapClaims); ok { - err = dec.Decode(&c) - } else { - err = dec.Decode(&claims) - } - // Handle decode error - if err != nil { - return token, parts, &ValidationError{Inner: err, Errors: ValidationErrorMalformed} - } - - // Lookup signature alg - if alg, ok := token.Header["alg"].(string); ok { - if token.Method = GetSigningMethod(alg); token.Method == nil { - return token, parts, NewValidationError("signing method (alg) is unavailable.", ValidationErrorUnverifiable) - } - } else { - return token, parts, NewValidationError("signing method (alg) is unspecified.", ValidationErrorUnverifiable) - } - - return token, parts, nil -} - -func (p *Parser) ParseUnverified2(tokenString string, claims Claims) (token *Token, err error) { - - // A JWT token is composed of 3 parts concatenated by dots (".") - parts := strings.Split(tokenString, ".") - if len(parts) != 3 { - return nil, NewValidationError("token contains an invalid number of segments", ValidationErrorMalformed) - } - - // Initialize the Token struct - token = &Token{ - Raw: tokenString, - } - - // Parse Header - var headerBytes []byte - if headerBytes, err = DecodeSegment(parts[0]); err != nil { - return nil, &ValidationError{Inner: err, Errors: ValidationErrorMalformed} - } - if err = json.Unmarshal(headerBytes, &token.Header); err != nil { - return nil, &ValidationError{Inner: err, Errors: ValidationErrorMalformed} - } - - // TODO: verify header for minimum requirements, eg alg and kid - - // Check that signature alg is included in header and it is a string - alg, ok := token.Header["alg"].(string) - if !ok { - return nil, NewValidationError("signing method (alg) not in token header.", ValidationErrorUnverifiable) - } - token.Header["alg"] = alg - - // Check that kid is included in header and it is a string - kid, ok := token.Header["kid"].(string) - if !ok { - return nil, NewValidationError("signing method (alg) not in token header.", ValidationErrorUnverifiable) - } - token.Header["kid"] = kid - - // Decode claims part from B64Url - if token.ClaimBytes, err = DecodeSegment(parts[1]); err != nil { - return nil, &ValidationError{Inner: err, Errors: ValidationErrorMalformed} - } - - // JSON Decode, decoding to Number instead of floats - dec := json.NewDecoder(bytes.NewBuffer(token.ClaimBytes)) - dec.UseNumber() - - err = dec.Decode(&claims) - if err != nil { - return nil, &ValidationError{Inner: err, Errors: ValidationErrorMalformed} - } - - // Validate the registered claims exp, iat, nbf - if err = claims.Valid(); err != nil { - return nil, err - } - - // All is valid (except signature), set the claims field in the token - token.Claims = claims - - // And the corresponding parts - token.ToBeSignedString = strings.Join(parts[0:2], ".") - token.Signature = parts[2] - - // TODO: verify claims for minimum requirements - - // All validations performed, reply with success - return token, nil - -} diff --git a/internal/jwt/parser_option.go b/internal/jwt/parser_option.go deleted file mode 100644 index 6ea6f952..00000000 --- a/internal/jwt/parser_option.go +++ /dev/null @@ -1,29 +0,0 @@ -package jwt - -// ParserOption is used to implement functional-style options that modify the behavior of the parser. To add -// new options, just create a function (ideally beginning with With or Without) that returns an anonymous function that -// takes a *Parser type as input and manipulates its configuration accordingly. -type ParserOption func(*Parser) - -// WithValidMethods is an option to supply algorithm methods that the parser will check. Only those methods will be considered valid. -// It is heavily encouraged to use this option in order to prevent attacks such as https://auth0.com/blog/critical-vulnerabilities-in-json-web-token-libraries/. -func WithValidMethods(methods []string) ParserOption { - return func(p *Parser) { - p.ValidMethods = methods - } -} - -// WithJSONNumber is an option to configure the underlying JSON parser with UseNumber -func WithJSONNumber() ParserOption { - return func(p *Parser) { - p.UseJSONNumber = true - } -} - -// WithoutClaimsValidation is an option to disable claims validation. This option should only be used if you exactly know -// what you are doing. -func WithoutClaimsValidation() ParserOption { - return func(p *Parser) { - p.SkipClaimsValidation = true - } -} diff --git a/internal/jwt/rsa.go b/internal/jwt/rsa.go deleted file mode 100644 index b910b19c..00000000 --- a/internal/jwt/rsa.go +++ /dev/null @@ -1,101 +0,0 @@ -package jwt - -import ( - "crypto" - "crypto/rand" - "crypto/rsa" -) - -// SigningMethodRSA implements the RSA family of signing methods. -// Expects *rsa.PrivateKey for signing and *rsa.PublicKey for validation -type SigningMethodRSA struct { - Name string - Hash crypto.Hash -} - -// Specific instances for RS256 and company -var ( - SigningMethodRS256 *SigningMethodRSA - SigningMethodRS384 *SigningMethodRSA - SigningMethodRS512 *SigningMethodRSA -) - -func init() { - // RS256 - SigningMethodRS256 = &SigningMethodRSA{"RS256", crypto.SHA256} - RegisterSigningMethod(SigningMethodRS256.Alg(), func() SigningMethod { - return SigningMethodRS256 - }) - - // RS384 - SigningMethodRS384 = &SigningMethodRSA{"RS384", crypto.SHA384} - RegisterSigningMethod(SigningMethodRS384.Alg(), func() SigningMethod { - return SigningMethodRS384 - }) - - // RS512 - SigningMethodRS512 = &SigningMethodRSA{"RS512", crypto.SHA512} - RegisterSigningMethod(SigningMethodRS512.Alg(), func() SigningMethod { - return SigningMethodRS512 - }) -} - -func (m *SigningMethodRSA) Alg() string { - return m.Name -} - -// Verify implements token verification for the SigningMethod -// For this signing method, must be an *rsa.PublicKey structure. -func (m *SigningMethodRSA) Verify(signingString, signature string, key interface{}) error { - var err error - - // Decode the signature - var sig []byte - if sig, err = DecodeSegment(signature); err != nil { - return err - } - - var rsaKey *rsa.PublicKey - var ok bool - - if rsaKey, ok = key.(*rsa.PublicKey); !ok { - return ErrInvalidKeyType - } - - // Create hasher - if !m.Hash.Available() { - return ErrHashUnavailable - } - hasher := m.Hash.New() - hasher.Write([]byte(signingString)) - - // Verify the signature - return rsa.VerifyPKCS1v15(rsaKey, m.Hash, hasher.Sum(nil), sig) -} - -// Sign implements token signing for the SigningMethod -// For this signing method, must be an *rsa.PrivateKey structure. -func (m *SigningMethodRSA) Sign(signingString string, key interface{}) (string, error) { - var rsaKey *rsa.PrivateKey - var ok bool - - // Validate type of key - if rsaKey, ok = key.(*rsa.PrivateKey); !ok { - return "", ErrInvalidKey - } - - // Create the hasher - if !m.Hash.Available() { - return "", ErrHashUnavailable - } - - hasher := m.Hash.New() - hasher.Write([]byte(signingString)) - - // Sign the string and return the encoded bytes - if sigBytes, err := rsa.SignPKCS1v15(rand.Reader, rsaKey, m.Hash, hasher.Sum(nil)); err == nil { - return EncodeSegment(sigBytes), nil - } else { - return "", err - } -} diff --git a/internal/jwt/rsa_pss.go b/internal/jwt/rsa_pss.go deleted file mode 100644 index 5a8502fe..00000000 --- a/internal/jwt/rsa_pss.go +++ /dev/null @@ -1,142 +0,0 @@ -// +build go1.4 - -package jwt - -import ( - "crypto" - "crypto/rand" - "crypto/rsa" -) - -// SigningMethodRSAPSS implements the RSAPSS family of signing methods signing methods -type SigningMethodRSAPSS struct { - *SigningMethodRSA - Options *rsa.PSSOptions - // VerifyOptions is optional. If set overrides Options for rsa.VerifyPPS. - // Used to accept tokens signed with rsa.PSSSaltLengthAuto, what doesn't follow - // https://tools.ietf.org/html/rfc7518#section-3.5 but was used previously. - // See https://github.com/dgrijalva/jwt-go/issues/285#issuecomment-437451244 for details. - VerifyOptions *rsa.PSSOptions -} - -// Specific instances for RS/PS and company. -var ( - SigningMethodPS256 *SigningMethodRSAPSS - SigningMethodPS384 *SigningMethodRSAPSS - SigningMethodPS512 *SigningMethodRSAPSS -) - -func init() { - // PS256 - SigningMethodPS256 = &SigningMethodRSAPSS{ - SigningMethodRSA: &SigningMethodRSA{ - Name: "PS256", - Hash: crypto.SHA256, - }, - Options: &rsa.PSSOptions{ - SaltLength: rsa.PSSSaltLengthEqualsHash, - }, - VerifyOptions: &rsa.PSSOptions{ - SaltLength: rsa.PSSSaltLengthAuto, - }, - } - RegisterSigningMethod(SigningMethodPS256.Alg(), func() SigningMethod { - return SigningMethodPS256 - }) - - // PS384 - SigningMethodPS384 = &SigningMethodRSAPSS{ - SigningMethodRSA: &SigningMethodRSA{ - Name: "PS384", - Hash: crypto.SHA384, - }, - Options: &rsa.PSSOptions{ - SaltLength: rsa.PSSSaltLengthEqualsHash, - }, - VerifyOptions: &rsa.PSSOptions{ - SaltLength: rsa.PSSSaltLengthAuto, - }, - } - RegisterSigningMethod(SigningMethodPS384.Alg(), func() SigningMethod { - return SigningMethodPS384 - }) - - // PS512 - SigningMethodPS512 = &SigningMethodRSAPSS{ - SigningMethodRSA: &SigningMethodRSA{ - Name: "PS512", - Hash: crypto.SHA512, - }, - Options: &rsa.PSSOptions{ - SaltLength: rsa.PSSSaltLengthEqualsHash, - }, - VerifyOptions: &rsa.PSSOptions{ - SaltLength: rsa.PSSSaltLengthAuto, - }, - } - RegisterSigningMethod(SigningMethodPS512.Alg(), func() SigningMethod { - return SigningMethodPS512 - }) -} - -// Verify implements token verification for the SigningMethod. -// For this verify method, key must be an rsa.PublicKey struct -func (m *SigningMethodRSAPSS) Verify(signingString, signature string, key interface{}) error { - var err error - - // Decode the signature - var sig []byte - if sig, err = DecodeSegment(signature); err != nil { - return err - } - - var rsaKey *rsa.PublicKey - switch k := key.(type) { - case *rsa.PublicKey: - rsaKey = k - default: - return ErrInvalidKey - } - - // Create hasher - if !m.Hash.Available() { - return ErrHashUnavailable - } - hasher := m.Hash.New() - hasher.Write([]byte(signingString)) - - opts := m.Options - if m.VerifyOptions != nil { - opts = m.VerifyOptions - } - - return rsa.VerifyPSS(rsaKey, m.Hash, hasher.Sum(nil), sig, opts) -} - -// Sign implements token signing for the SigningMethod. -// For this signing method, key must be an rsa.PrivateKey struct -func (m *SigningMethodRSAPSS) Sign(signingString string, key interface{}) (string, error) { - var rsaKey *rsa.PrivateKey - - switch k := key.(type) { - case *rsa.PrivateKey: - rsaKey = k - default: - return "", ErrInvalidKeyType - } - - // Create the hasher - if !m.Hash.Available() { - return "", ErrHashUnavailable - } - - hasher := m.Hash.New() - hasher.Write([]byte(signingString)) - - // Sign the string and return the encoded bytes - if sigBytes, err := rsa.SignPSS(rand.Reader, rsaKey, m.Hash, hasher.Sum(nil), m.Options); err == nil { - return EncodeSegment(sigBytes), nil - } else { - return "", err - } -} diff --git a/internal/jwt/rsa_pss_test.go b/internal/jwt/rsa_pss_test.go deleted file mode 100644 index 4d2987f8..00000000 --- a/internal/jwt/rsa_pss_test.go +++ /dev/null @@ -1,151 +0,0 @@ -//go:build go1.4 -// +build go1.4 - -package jwt_test - -import ( - "crypto/rsa" - "io/ioutil" - "strings" - "testing" - "time" - - "github.com/fiware/vcverifier/internal/jwt" - "github.com/fiware/vcverifier/internal/jwt/test" -) - -var rsaPSSTestData = []struct { - name string - tokenString string - alg string - claims map[string]interface{} - valid bool -}{ - { - "Basic PS256", - "eyJhbGciOiJQUzI1NiIsInR5cCI6IkpXVCJ9.eyJmb28iOiJiYXIifQ.PPG4xyDVY8ffp4CcxofNmsTDXsrVG2npdQuibLhJbv4ClyPTUtR5giNSvuxo03kB6I8VXVr0Y9X7UxhJVEoJOmULAwRWaUsDnIewQa101cVhMa6iR8X37kfFoiZ6NkS-c7henVkkQWu2HtotkEtQvN5hFlk8IevXXPmvZlhQhwzB1sGzGYnoi1zOfuL98d3BIjUjtlwii5w6gYG2AEEzp7HnHCsb3jIwUPdq86Oe6hIFjtBwduIK90ca4UqzARpcfwxHwVLMpatKask00AgGVI0ysdk0BLMjmLutquD03XbThHScC2C2_Pp4cHWgMzvbgLU2RYYZcZRKr46QeNgz9w", - "PS256", - map[string]interface{}{"foo": "bar"}, - true, - }, - { - "Basic PS384", - "eyJhbGciOiJQUzM4NCIsInR5cCI6IkpXVCJ9.eyJmb28iOiJiYXIifQ.w7-qqgj97gK4fJsq_DCqdYQiylJjzWONvD0qWWWhqEOFk2P1eDULPnqHRnjgTXoO4HAw4YIWCsZPet7nR3Xxq4ZhMqvKW8b7KlfRTb9cH8zqFvzMmybQ4jv2hKc3bXYqVow3AoR7hN_CWXI3Dv6Kd2X5xhtxRHI6IL39oTVDUQ74LACe-9t4c3QRPuj6Pq1H4FAT2E2kW_0KOc6EQhCLWEhm2Z2__OZskDC8AiPpP8Kv4k2vB7l0IKQu8Pr4RcNBlqJdq8dA5D3hk5TLxP8V5nG1Ib80MOMMqoS3FQvSLyolFX-R_jZ3-zfq6Ebsqr0yEb0AH2CfsECF7935Pa0FKQ", - "PS384", - map[string]interface{}{"foo": "bar"}, - true, - }, - { - "Basic PS512", - "eyJhbGciOiJQUzUxMiIsInR5cCI6IkpXVCJ9.eyJmb28iOiJiYXIifQ.GX1HWGzFaJevuSLavqqFYaW8_TpvcjQ8KfC5fXiSDzSiT9UD9nB_ikSmDNyDILNdtjZLSvVKfXxZJqCfefxAtiozEDDdJthZ-F0uO4SPFHlGiXszvKeodh7BuTWRI2wL9-ZO4mFa8nq3GMeQAfo9cx11i7nfN8n2YNQ9SHGovG7_T_AvaMZB_jT6jkDHpwGR9mz7x1sycckEo6teLdHRnH_ZdlHlxqknmyTu8Odr5Xh0sJFOL8BepWbbvIIn-P161rRHHiDWFv6nhlHwZnVzjx7HQrWSGb6-s2cdLie9QL_8XaMcUpjLkfOMKkDOfHo6AvpL7Jbwi83Z2ZTHjJWB-A", - "PS512", - map[string]interface{}{"foo": "bar"}, - true, - }, - { - "basic PS256 invalid: foo => bar", - "eyJhbGciOiJQUzI1NiIsInR5cCI6IkpXVCJ9.eyJmb28iOiJiYXIifQ.PPG4xyDVY8ffp4CcxofNmsTDXsrVG2npdQuibLhJbv4ClyPTUtR5giNSvuxo03kB6I8VXVr0Y9X7UxhJVEoJOmULAwRWaUsDnIewQa101cVhMa6iR8X37kfFoiZ6NkS-c7henVkkQWu2HtotkEtQvN5hFlk8IevXXPmvZlhQhwzB1sGzGYnoi1zOfuL98d3BIjUjtlwii5w6gYG2AEEzp7HnHCsb3jIwUPdq86Oe6hIFjtBwduIK90ca4UqzARpcfwxHwVLMpatKask00AgGVI0ysdk0BLMjmLutquD03XbThHScC2C2_Pp4cHWgMzvbgLU2RYYZcZRKr46QeNgz9W", - "PS256", - map[string]interface{}{"foo": "bar"}, - false, - }, -} - -func TestRSAPSSVerify(t *testing.T) { - var err error - - key, _ := ioutil.ReadFile("test/sample_key.pub") - var rsaPSSKey *rsa.PublicKey - if rsaPSSKey, err = jwt.ParseRSAPublicKeyFromPEM(key); err != nil { - t.Errorf("Unable to parse RSA public key: %v", err) - } - - for _, data := range rsaPSSTestData { - parts := strings.Split(data.tokenString, ".") - - method := jwt.GetSigningMethod(data.alg) - err := method.Verify(strings.Join(parts[0:2], "."), parts[2], rsaPSSKey) - if data.valid && err != nil { - t.Errorf("[%v] Error while verifying key: %v", data.name, err) - } - if !data.valid && err == nil { - t.Errorf("[%v] Invalid key passed validation", data.name) - } - } -} - -func TestRSAPSSSign(t *testing.T) { - var err error - - key, _ := ioutil.ReadFile("test/sample_key") - var rsaPSSKey *rsa.PrivateKey - if rsaPSSKey, err = jwt.ParseRSAPrivateKeyFromPEM(key); err != nil { - t.Errorf("Unable to parse RSA private key: %v", err) - } - - for _, data := range rsaPSSTestData { - if data.valid { - parts := strings.Split(data.tokenString, ".") - method := jwt.GetSigningMethod(data.alg) - sig, err := method.Sign(strings.Join(parts[0:2], "."), rsaPSSKey) - if err != nil { - t.Errorf("[%v] Error signing token: %v", data.name, err) - } - if sig == parts[2] { - t.Errorf("[%v] Signatures shouldn't match\nnew:\n%v\noriginal:\n%v", data.name, sig, parts[2]) - } - } - } -} - -func TestRSAPSSSaltLengthCompatibility(t *testing.T) { - // Fails token verify, if salt length is auto. - ps256SaltLengthEqualsHash := &jwt.SigningMethodRSAPSS{ - SigningMethodRSA: jwt.SigningMethodPS256.SigningMethodRSA, - Options: &rsa.PSSOptions{ - SaltLength: rsa.PSSSaltLengthEqualsHash, - }, - } - - // Behaves as before https://github.com/dgrijalva/jwt-go/issues/285 fix. - ps256SaltLengthAuto := &jwt.SigningMethodRSAPSS{ - SigningMethodRSA: jwt.SigningMethodPS256.SigningMethodRSA, - Options: &rsa.PSSOptions{ - SaltLength: rsa.PSSSaltLengthAuto, - }, - } - if !verify(jwt.SigningMethodPS256, makeToken(ps256SaltLengthEqualsHash)) { - t.Error("SigningMethodPS256 should accept salt length that is defined in RFC") - } - if !verify(ps256SaltLengthEqualsHash, makeToken(jwt.SigningMethodPS256)) { - t.Error("Sign by SigningMethodPS256 should have salt length that is defined in RFC") - } - if !verify(jwt.SigningMethodPS256, makeToken(ps256SaltLengthAuto)) { - t.Error("SigningMethodPS256 should accept auto salt length to be compatible with previous versions") - } - if !verify(ps256SaltLengthAuto, makeToken(jwt.SigningMethodPS256)) { - t.Error("Sign by SigningMethodPS256 should be accepted by previous versions") - } - if verify(ps256SaltLengthEqualsHash, makeToken(ps256SaltLengthAuto)) { - t.Error("Auto salt length should be not accepted, when RFC salt length is required") - } -} - -func makeToken(method jwt.SigningMethod) string { - token := jwt.NewWithClaims(method, jwt.RegisteredClaims{ - Issuer: "example", - IssuedAt: jwt.NewNumericDate(time.Now()), - }) - privateKey := test.LoadRSAPrivateKeyFromDisk("test/sample_key") - signed, err := token.SignedString(privateKey) - if err != nil { - panic(err) - } - return signed -} - -func verify(signingMethod jwt.SigningMethod, token string) bool { - segments := strings.Split(token, ".") - err := signingMethod.Verify(strings.Join(segments[:2], "."), segments[2], test.LoadRSAPublicKeyFromDisk("test/sample_key.pub")) - return err == nil -} diff --git a/internal/jwt/rsa_utils.go b/internal/jwt/rsa_utils.go deleted file mode 100644 index 1966c450..00000000 --- a/internal/jwt/rsa_utils.go +++ /dev/null @@ -1,105 +0,0 @@ -package jwt - -import ( - "crypto/rsa" - "crypto/x509" - "encoding/pem" - "errors" -) - -var ( - ErrKeyMustBePEMEncoded = errors.New("invalid key: Key must be a PEM encoded PKCS1 or PKCS8 key") - ErrNotRSAPrivateKey = errors.New("key is not a valid RSA private key") - ErrNotRSAPublicKey = errors.New("key is not a valid RSA public key") -) - -// ParseRSAPrivateKeyFromPEM parses a PEM encoded PKCS1 or PKCS8 private key -func ParseRSAPrivateKeyFromPEM(key []byte) (*rsa.PrivateKey, error) { - var err error - - // Parse PEM block - var block *pem.Block - if block, _ = pem.Decode(key); block == nil { - return nil, ErrKeyMustBePEMEncoded - } - - var parsedKey interface{} - if parsedKey, err = x509.ParsePKCS1PrivateKey(block.Bytes); err != nil { - if parsedKey, err = x509.ParsePKCS8PrivateKey(block.Bytes); err != nil { - return nil, err - } - } - - var pkey *rsa.PrivateKey - var ok bool - if pkey, ok = parsedKey.(*rsa.PrivateKey); !ok { - return nil, ErrNotRSAPrivateKey - } - - return pkey, nil -} - -// ParseRSAPrivateKeyFromPEMWithPassword parses a PEM encoded PKCS1 or PKCS8 private key protected with password -// -// Deprecated: This function is deprecated and should not be used anymore. It uses the deprecated x509.DecryptPEMBlock -// function, which was deprecated since RFC 1423 is regarded insecure by design. Unfortunately, there is no alternative -// in the Go standard library for now. See https://github.com/golang/go/issues/8860. -func ParseRSAPrivateKeyFromPEMWithPassword(key []byte, password string) (*rsa.PrivateKey, error) { - var err error - - // Parse PEM block - var block *pem.Block - if block, _ = pem.Decode(key); block == nil { - return nil, ErrKeyMustBePEMEncoded - } - - var parsedKey interface{} - - var blockDecrypted []byte - if blockDecrypted, err = x509.DecryptPEMBlock(block, []byte(password)); err != nil { - return nil, err - } - - if parsedKey, err = x509.ParsePKCS1PrivateKey(blockDecrypted); err != nil { - if parsedKey, err = x509.ParsePKCS8PrivateKey(blockDecrypted); err != nil { - return nil, err - } - } - - var pkey *rsa.PrivateKey - var ok bool - if pkey, ok = parsedKey.(*rsa.PrivateKey); !ok { - return nil, ErrNotRSAPrivateKey - } - - return pkey, nil -} - -// ParseRSAPublicKeyFromPEM parses a PEM encoded PKCS1 or PKCS8 public key -func ParseRSAPublicKeyFromPEM(key []byte) (*rsa.PublicKey, error) { - var err error - - // Parse PEM block - var block *pem.Block - if block, _ = pem.Decode(key); block == nil { - return nil, ErrKeyMustBePEMEncoded - } - - // Parse the key - var parsedKey interface{} - if parsedKey, err = x509.ParsePKIXPublicKey(block.Bytes); err != nil { - if cert, err := x509.ParseCertificate(block.Bytes); err == nil { - parsedKey = cert.PublicKey - } else { - return nil, err - } - } - - var pkey *rsa.PublicKey - var ok bool - if pkey, ok = parsedKey.(*rsa.PublicKey); !ok { - return nil, ErrNotRSAPublicKey - } - - return pkey, nil -} diff --git a/internal/jwt/signing_method.go b/internal/jwt/signing_method.go deleted file mode 100644 index 241ae9c6..00000000 --- a/internal/jwt/signing_method.go +++ /dev/null @@ -1,46 +0,0 @@ -package jwt - -import ( - "sync" -) - -var signingMethods = map[string]func() SigningMethod{} -var signingMethodLock = new(sync.RWMutex) - -// SigningMethod can be used add new methods for signing or verifying tokens. -type SigningMethod interface { - Verify(signingString, signature string, key interface{}) error // Returns nil if signature is valid - Sign(signingString string, key interface{}) (string, error) // Returns encoded signature or error - Alg() string // returns the alg identifier for this method (example: 'HS256') -} - -// RegisterSigningMethod registers the "alg" name and a factory function for signing method. -// This is typically done during init() in the method's implementation -func RegisterSigningMethod(alg string, f func() SigningMethod) { - signingMethodLock.Lock() - defer signingMethodLock.Unlock() - - signingMethods[alg] = f -} - -// GetSigningMethod retrieves a signing method from an "alg" string -func GetSigningMethod(alg string) (method SigningMethod) { - signingMethodLock.RLock() - defer signingMethodLock.RUnlock() - - if methodF, ok := signingMethods[alg]; ok { - method = methodF() - } - return -} - -// GetAlgorithms returns a list of registered "alg" names -func GetAlgorithms() (algs []string) { - signingMethodLock.RLock() - defer signingMethodLock.RUnlock() - - for alg := range signingMethods { - algs = append(algs, alg) - } - return -} diff --git a/internal/jwt/test/ec256-private.pem b/internal/jwt/test/ec256-private.pem deleted file mode 100644 index a6882b3e..00000000 --- a/internal/jwt/test/ec256-private.pem +++ /dev/null @@ -1,5 +0,0 @@ ------BEGIN EC PRIVATE KEY----- -MHcCAQEEIAh5qA3rmqQQuu0vbKV/+zouz/y/Iy2pLpIcWUSyImSwoAoGCCqGSM49 -AwEHoUQDQgAEYD54V/vp+54P9DXarYqx4MPcm+HKRIQzNasYSoRQHQ/6S6Ps8tpM -cT+KvIIC8W/e9k0W7Cm72M1P9jU7SLf/vg== ------END EC PRIVATE KEY----- diff --git a/internal/jwt/test/ec256-public.pem b/internal/jwt/test/ec256-public.pem deleted file mode 100644 index 7191361e..00000000 --- a/internal/jwt/test/ec256-public.pem +++ /dev/null @@ -1,4 +0,0 @@ ------BEGIN PUBLIC KEY----- -MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEYD54V/vp+54P9DXarYqx4MPcm+HK -RIQzNasYSoRQHQ/6S6Ps8tpMcT+KvIIC8W/e9k0W7Cm72M1P9jU7SLf/vg== ------END PUBLIC KEY----- diff --git a/internal/jwt/test/ec384-private.pem b/internal/jwt/test/ec384-private.pem deleted file mode 100644 index a86c823e..00000000 --- a/internal/jwt/test/ec384-private.pem +++ /dev/null @@ -1,6 +0,0 @@ ------BEGIN EC PRIVATE KEY----- -MIGkAgEBBDCaCvMHKhcG/qT7xsNLYnDT7sE/D+TtWIol1ROdaK1a564vx5pHbsRy -SEKcIxISi1igBwYFK4EEACKhZANiAATYa7rJaU7feLMqrAx6adZFNQOpaUH/Uylb -ZLriOLON5YFVwtVUpO1FfEXZUIQpptRPtc5ixIPY658yhBSb6irfIJUSP9aYTflJ -GKk/mDkK4t8mWBzhiD5B6jg9cEGhGgA= ------END EC PRIVATE KEY----- diff --git a/internal/jwt/test/ec384-public.pem b/internal/jwt/test/ec384-public.pem deleted file mode 100644 index e80d0056..00000000 --- a/internal/jwt/test/ec384-public.pem +++ /dev/null @@ -1,5 +0,0 @@ ------BEGIN PUBLIC KEY----- -MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAE2Gu6yWlO33izKqwMemnWRTUDqWlB/1Mp -W2S64jizjeWBVcLVVKTtRXxF2VCEKabUT7XOYsSD2OufMoQUm+oq3yCVEj/WmE35 -SRipP5g5CuLfJlgc4Yg+Qeo4PXBBoRoA ------END PUBLIC KEY----- diff --git a/internal/jwt/test/ec512-private.pem b/internal/jwt/test/ec512-private.pem deleted file mode 100644 index 213afaf1..00000000 --- a/internal/jwt/test/ec512-private.pem +++ /dev/null @@ -1,7 +0,0 @@ ------BEGIN EC PRIVATE KEY----- -MIHcAgEBBEIB0pE4uFaWRx7t03BsYlYvF1YvKaBGyvoakxnodm9ou0R9wC+sJAjH -QZZJikOg4SwNqgQ/hyrOuDK2oAVHhgVGcYmgBwYFK4EEACOhgYkDgYYABAAJXIuw -12MUzpHggia9POBFYXSxaOGKGbMjIyDI+6q7wi7LMw3HgbaOmgIqFG72o8JBQwYN -4IbXHf+f86CRY1AA2wHzbHvt6IhkCXTNxBEffa1yMUgu8n9cKKF2iLgyQKcKqW33 -8fGOw/n3Rm2Yd/EB56u2rnD29qS+nOM9eGS+gy39OQ== ------END EC PRIVATE KEY----- diff --git a/internal/jwt/test/ec512-public.pem b/internal/jwt/test/ec512-public.pem deleted file mode 100644 index 02ea0220..00000000 --- a/internal/jwt/test/ec512-public.pem +++ /dev/null @@ -1,6 +0,0 @@ ------BEGIN PUBLIC KEY----- -MIGbMBAGByqGSM49AgEGBSuBBAAjA4GGAAQACVyLsNdjFM6R4IImvTzgRWF0sWjh -ihmzIyMgyPuqu8IuyzMNx4G2jpoCKhRu9qPCQUMGDeCG1x3/n/OgkWNQANsB82x7 -7eiIZAl0zcQRH32tcjFILvJ/XCihdoi4MkCnCqlt9/HxjsP590ZtmHfxAeertq5w -9vakvpzjPXhkvoMt/Tk= ------END PUBLIC KEY----- diff --git a/internal/jwt/test/ed25519-private.pem b/internal/jwt/test/ed25519-private.pem deleted file mode 100644 index e77a58c8..00000000 --- a/internal/jwt/test/ed25519-private.pem +++ /dev/null @@ -1,3 +0,0 @@ ------BEGIN PRIVATE KEY----- -MC4CAQAwBQYDK2VwBCIEIEFMEZrmlYxczXKFxIlNvNGR5JQvDhTkLovJYxwQd3ua ------END PRIVATE KEY----- diff --git a/internal/jwt/test/ed25519-public.pem b/internal/jwt/test/ed25519-public.pem deleted file mode 100644 index 37c34c50..00000000 --- a/internal/jwt/test/ed25519-public.pem +++ /dev/null @@ -1,3 +0,0 @@ ------BEGIN PUBLIC KEY----- -MCowBQYDK2VwAyEAWH7z6hpYqvPns2i4n9yymwvB3APhi4LyQ7iHOT6crtE= ------END PUBLIC KEY----- diff --git a/internal/jwt/test/examplePaddedKey-public.pem b/internal/jwt/test/examplePaddedKey-public.pem deleted file mode 100644 index cb84e6c8..00000000 --- a/internal/jwt/test/examplePaddedKey-public.pem +++ /dev/null @@ -1,4 +0,0 @@ ------BEGIN PUBLIC KEY----- -MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEIcaUjXhC7Mn2OonyfHF+zjblKkns -4GLbILnHrZr+aQwddiff5urCDAZ177t81Mn39CDs3uhlNDxfRIRheGnK/Q== ------END PUBLIC KEY----- \ No newline at end of file diff --git a/internal/jwt/test/helpers.go b/internal/jwt/test/helpers.go deleted file mode 100644 index bc17dbcb..00000000 --- a/internal/jwt/test/helpers.go +++ /dev/null @@ -1,69 +0,0 @@ -package test - -import ( - "crypto" - "crypto/rsa" - "io/ioutil" - - "github.com/fiware/vcverifier/internal/jwt" -) - -func LoadRSAPrivateKeyFromDisk(location string) *rsa.PrivateKey { - keyData, e := ioutil.ReadFile(location) - if e != nil { - panic(e.Error()) - } - key, e := jwt.ParseRSAPrivateKeyFromPEM(keyData) - if e != nil { - panic(e.Error()) - } - return key -} - -func LoadRSAPublicKeyFromDisk(location string) *rsa.PublicKey { - keyData, e := ioutil.ReadFile(location) - if e != nil { - panic(e.Error()) - } - key, e := jwt.ParseRSAPublicKeyFromPEM(keyData) - if e != nil { - panic(e.Error()) - } - return key -} - -// MakeSampleToken creates and returns a encoded JWT token that has been signed with the specified cryptographic key. -func MakeSampleToken(c jwt.Claims, method jwt.SigningMethod, key interface{}) string { - token := jwt.NewWithClaims(method, c) - s, e := token.SignedString(key) - - if e != nil { - panic(e.Error()) - } - - return s -} - -func LoadECPrivateKeyFromDisk(location string) crypto.PrivateKey { - keyData, e := ioutil.ReadFile(location) - if e != nil { - panic(e.Error()) - } - key, e := jwt.ParseECPrivateKeyFromPEM(keyData) - if e != nil { - panic(e.Error()) - } - return key -} - -func LoadECPublicKeyFromDisk(location string) crypto.PublicKey { - keyData, e := ioutil.ReadFile(location) - if e != nil { - panic(e.Error()) - } - key, e := jwt.ParseECPublicKeyFromPEM(keyData) - if e != nil { - panic(e.Error()) - } - return key -} diff --git a/internal/jwt/test/hmacTestKey b/internal/jwt/test/hmacTestKey deleted file mode 100644 index 435b8ddb..00000000 --- a/internal/jwt/test/hmacTestKey +++ /dev/null @@ -1 +0,0 @@ -#5K+~ew{Z(T(P.ZGwb="=.!r.O͚gЀ \ No newline at end of file diff --git a/internal/jwt/test/privateSecure.pem b/internal/jwt/test/privateSecure.pem deleted file mode 100644 index 8537e074..00000000 --- a/internal/jwt/test/privateSecure.pem +++ /dev/null @@ -1,30 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -Proc-Type: 4,ENCRYPTED -DEK-Info: DES-EDE3-CBC,7487BB8910A3741B - -iL7m48mbFSIy1Y5xbXWwPTR07ufxu7o+myGUE+AdDeWWISkd5W6Gl44oX/jgXldS -mL/ntUXoZzQz2WKEYLwssAtSTGF+QgSIMvV5faiP+pLYvWgk0oVr42po00CvADFL -eDAJC7LgagYifS1l4EAK4MY8RGCHyJWEN5JAr0fc/Haa3WfWZ009kOWAp8MDuYxB -hQlCKUmnUpXCp5c6jwbjlyinLj8XwzzjZ/rVRsY+t2Z0Vcd5qzR5BV8IJCqbG5Py -z15/EFgMG2N2eYMsiEKgdXeKW2H5XIoWyun/3pBigWaDnTtiWSt9kz2MplqYfIT7 -F+0XE3gdDGalAeN3YwFPHCkxxBmcI+s6lQG9INmf2/gkJQ+MOZBVXKmGLv6Qis3l -0eyUz1yZvNzf0zlcUBjiPulLF3peThHMEzhSsATfPomyg5NJ0X7ttd0ybnq+sPe4 -qg2OJ8qNhYrqnx7Xlvj61+B2NAZVHvIioma1FzqX8DxQYrnR5S6DJExDqvzNxEz6 -5VPQlH2Ig4hTvNzla84WgJ6USc/2SS4ehCReiNvfeNG9sPZKQnr/Ss8KPIYsKGcC -Pz/vEqbWDmJwHb7KixCQKPt1EbD+/uf0YnhskOWM15YiFbYAOZKJ5rcbz2Zu66vg -GAmqcBsHeFR3s/bObEzjxOmMfSr1vzvr4ActNJWVtfNKZNobSehZiMSHL54AXAZW -Yj48pwTbf7b1sbF0FeCuwTFiYxM+yiZVO5ciYOfmo4HUg53PjknKpcKtEFSj02P1 -8JRBSb++V0IeMDyZLl12zgURDsvualbJMMBBR8emIpF13h0qdyah431gDhHGBnnC -J5UDGq21/flFjzz0x/Okjwf7mPK5pcmF+uW7AxtHqws6m93yD5+RFmfZ8cb/8CL8 -jmsQslj+OIE64ykkRoJWpNBKyQjL3CnPnLmAB6TQKxegR94C7/hP1FvRW+W0AgZy -g2QczKQU3KBQP18Ui1HTbkOUJT0Lsy4FnmJFCB/STPRo6NlJiATKHq/cqHWQUvZd -d4oTMb1opKfs7AI9wiJBuskpGAECdRnVduml3dT4p//3BiP6K9ImWMSJeFpjFAFs -AbBMKyitMs0Fyn9AJRPl23TKVQ3cYeSTxus4wLmx5ECSsHRV6g06nYjBp4GWEqSX -RVclXF3zmy3b1+O5s2chJN6TrypzYSEYXJb1vvQLK0lNXqwxZAFV7Roi6xSG0fSY -EAtdUifLonu43EkrLh55KEwkXdVV8xneUjh+TF8VgJKMnqDFfeHFdmN53YYh3n3F -kpYSmVLRzQmLbH9dY+7kqvnsQm8y76vjug3p4IbEbHp/fNGf+gv7KDng1HyCl9A+ -Ow/Hlr0NqCAIhminScbRsZ4SgbRTRgGEYZXvyOtQa/uL6I8t2NR4W7ynispMs0QL -RD61i3++bQXuTi4i8dg3yqIfe9S22NHSzZY/lAHAmmc3r5NrQ1TM1hsSxXawT5CU -anWFjbH6YQ/QplkkAqZMpropWn6ZdNDg/+BUjukDs0HZrbdGy846WxQUvE7G2bAw -IFQ1SymBZBtfnZXhfAXOHoWh017p6HsIkb2xmFrigMj7Jh10VVhdWg== ------END RSA PRIVATE KEY----- diff --git a/internal/jwt/test/sample_key b/internal/jwt/test/sample_key deleted file mode 100644 index abdbade3..00000000 --- a/internal/jwt/test/sample_key +++ /dev/null @@ -1,27 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIIEowIBAAKCAQEA4f5wg5l2hKsTeNem/V41fGnJm6gOdrj8ym3rFkEU/wT8RDtn -SgFEZOQpHEgQ7JL38xUfU0Y3g6aYw9QT0hJ7mCpz9Er5qLaMXJwZxzHzAahlfA0i -cqabvJOMvQtzD6uQv6wPEyZtDTWiQi9AXwBpHssPnpYGIn20ZZuNlX2BrClciHhC -PUIIZOQn/MmqTD31jSyjoQoV7MhhMTATKJx2XrHhR+1DcKJzQBSTAGnpYVaqpsAR -ap+nwRipr3nUTuxyGohBTSmjJ2usSeQXHI3bODIRe1AuTyHceAbewn8b462yEWKA -Rdpd9AjQW5SIVPfdsz5B6GlYQ5LdYKtznTuy7wIDAQABAoIBAQCwia1k7+2oZ2d3 -n6agCAbqIE1QXfCmh41ZqJHbOY3oRQG3X1wpcGH4Gk+O+zDVTV2JszdcOt7E5dAy -MaomETAhRxB7hlIOnEN7WKm+dGNrKRvV0wDU5ReFMRHg31/Lnu8c+5BvGjZX+ky9 -POIhFFYJqwCRlopGSUIxmVj5rSgtzk3iWOQXr+ah1bjEXvlxDOWkHN6YfpV5ThdE -KdBIPGEVqa63r9n2h+qazKrtiRqJqGnOrHzOECYbRFYhexsNFz7YT02xdfSHn7gM -IvabDDP/Qp0PjE1jdouiMaFHYnLBbgvlnZW9yuVf/rpXTUq/njxIXMmvmEyyvSDn -FcFikB8pAoGBAPF77hK4m3/rdGT7X8a/gwvZ2R121aBcdPwEaUhvj/36dx596zvY -mEOjrWfZhF083/nYWE2kVquj2wjs+otCLfifEEgXcVPTnEOPO9Zg3uNSL0nNQghj -FuD3iGLTUBCtM66oTe0jLSslHe8gLGEQqyMzHOzYxNqibxcOZIe8Qt0NAoGBAO+U -I5+XWjWEgDmvyC3TrOSf/KCGjtu0TSv30ipv27bDLMrpvPmD/5lpptTFwcxvVhCs -2b+chCjlghFSWFbBULBrfci2FtliClOVMYrlNBdUSJhf3aYSG2Doe6Bgt1n2CpNn -/iu37Y3NfemZBJA7hNl4dYe+f+uzM87cdQ214+jrAoGAXA0XxX8ll2+ToOLJsaNT -OvNB9h9Uc5qK5X5w+7G7O998BN2PC/MWp8H+2fVqpXgNENpNXttkRm1hk1dych86 -EunfdPuqsX+as44oCyJGFHVBnWpm33eWQw9YqANRI+pCJzP08I5WK3osnPiwshd+ -hR54yjgfYhBFNI7B95PmEQkCgYBzFSz7h1+s34Ycr8SvxsOBWxymG5zaCsUbPsL0 -4aCgLScCHb9J+E86aVbbVFdglYa5Id7DPTL61ixhl7WZjujspeXZGSbmq0Kcnckb -mDgqkLECiOJW2NHP/j0McAkDLL4tysF8TLDO8gvuvzNC+WQ6drO2ThrypLVZQ+ry -eBIPmwKBgEZxhqa0gVvHQG/7Od69KWj4eJP28kq13RhKay8JOoN0vPmspXJo1HY3 -CKuHRG+AP579dncdUnOMvfXOtkdM4vk0+hWASBQzM9xzVcztCa+koAugjVaLS9A+ -9uQoqEeVNTckxx0S2bYevRy7hGQmUJTyQm3j1zEUR5jpdbL83Fbq ------END RSA PRIVATE KEY----- diff --git a/internal/jwt/test/sample_key.pub b/internal/jwt/test/sample_key.pub deleted file mode 100644 index 03dc982a..00000000 --- a/internal/jwt/test/sample_key.pub +++ /dev/null @@ -1,9 +0,0 @@ ------BEGIN PUBLIC KEY----- -MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4f5wg5l2hKsTeNem/V41 -fGnJm6gOdrj8ym3rFkEU/wT8RDtnSgFEZOQpHEgQ7JL38xUfU0Y3g6aYw9QT0hJ7 -mCpz9Er5qLaMXJwZxzHzAahlfA0icqabvJOMvQtzD6uQv6wPEyZtDTWiQi9AXwBp -HssPnpYGIn20ZZuNlX2BrClciHhCPUIIZOQn/MmqTD31jSyjoQoV7MhhMTATKJx2 -XrHhR+1DcKJzQBSTAGnpYVaqpsARap+nwRipr3nUTuxyGohBTSmjJ2usSeQXHI3b -ODIRe1AuTyHceAbewn8b462yEWKARdpd9AjQW5SIVPfdsz5B6GlYQ5LdYKtznTuy -7wIDAQAB ------END PUBLIC KEY----- diff --git a/internal/jwt/token.go b/internal/jwt/token.go deleted file mode 100644 index 3712bb0b..00000000 --- a/internal/jwt/token.go +++ /dev/null @@ -1,192 +0,0 @@ -package jwt - -import ( - "encoding/base64" - "encoding/json" - "strings" - "time" -) - -// DecodePaddingAllowed will switch the codec used for decoding JWTs respectively. Note that the JWS RFC7515 -// states that the tokens will utilize a Base64url encoding with no padding. Unfortunately, some implementations -// of JWT are producing non-standard tokens, and thus require support for decoding. Note that this is a global -// variable, and updating it will change the behavior on a package level, and is also NOT go-routine safe. -// To use the non-recommended decoding, set this boolean to `true` prior to using this package. -var DecodePaddingAllowed bool - -// TimeFunc provides the current time when parsing token to validate "exp" claim (expiration time). -// You can override it to use another time value. This is useful for testing or if your -// server uses a different time zone than your tokens. -var TimeFunc = time.Now - -// Keyfunc will be used by the Parse methods as a callback function to supply -// the key for verification. The function receives the parsed, -// but unverified Token. This allows you to use properties in the -// Header of the token (such as `kid`) to identify which key to use. -type Keyfunc func(*Token) (interface{}, error) - -// Token represents a JWT Token. Different fields will be used depending on whether you're -// creating or parsing/verifying a token. -type Token struct { - Raw string // The raw token. Populated when you Parse a token - Method SigningMethod // The signing method used or to be used - Header map[string]interface{} // The first segment of the token - Claims Claims // The second segment of the token - ClaimBytes []byte - ToBeSignedString string - Signature string // The third segment of the token. Populated when you Parse a token - Valid bool // Is the token valid? Populated when you Parse/Verify a token -} - -// New creates a new Token with the specified signing method and an empty map of claims. -func New(method SigningMethod) *Token { - return NewWithClaims(method, MapClaims{}) -} - -// NewWithClaims creates a new Token with the specified signing method and claims. -func NewWithClaims(method SigningMethod, claims Claims) *Token { - return &Token{ - Header: map[string]interface{}{ - "typ": "JWT", - "alg": method.Alg(), - }, - Claims: claims, - Method: method, - } -} - -func (t *Token) Alg() string { - return (t.Header["alg"]).(string) -} - -func (t *Token) Kid() string { - return (t.Header["kid"]).(string) -} - -// SignedString creates and returns a complete, signed JWT. -// The token is signed using the SigningMethod specified in the token. -func (t *Token) SignedString(key interface{}) (string, error) { - var sig, sstr string - var err error - if sstr, err = t.SigningString(); err != nil { - return "", err - } - if sig, err = t.Method.Sign(sstr, key); err != nil { - return "", err - } - return strings.Join([]string{sstr, sig}, "."), nil -} - -// SigningString generates the string to be signed: "b64url(header).b64url(claims)" -func (t *Token) SigningString() (string, error) { - var err error - var jsonValue []byte - - if jsonValue, err = json.Marshal(t.Header); err != nil { - return "", err - } - header := EncodeSegment(jsonValue) - - if jsonValue, err = json.Marshal(t.Claims); err != nil { - return "", err - } - claim := EncodeSegment(jsonValue) - - return strings.Join([]string{header, claim}, "."), nil -} - -// Parse parses, validates, verifies the signature and returns the parsed token. -// keyFunc will receive the parsed token and should return the cryptographic key -// for verifying the signature. -// The caller is strongly encouraged to set the WithValidMethods option to -// validate the 'alg' claim in the token matches the expected algorithm. -// For more details about the importance of validating the 'alg' claim, -// see https://auth0.com/blog/critical-vulnerabilities-in-json-web-token-libraries/ -func Parse(tokenString string, keyFunc Keyfunc, options ...ParserOption) (*Token, error) { - return NewParser(options...).Parse(tokenString, keyFunc) -} - -func ParseWithClaims(tokenString string, claims Claims, keyFunc Keyfunc, options ...ParserOption) (*Token, error) { - return NewParser(options...).ParseWithClaims(tokenString, claims, keyFunc) -} - -// EncodeSegment encodes a JWT specific base64url encoding with padding stripped -// -// Deprecated: In a future release, we will demote this function to a non-exported function, since it -// should only be used internally -func EncodeSegment(seg []byte) string { - return base64.RawURLEncoding.EncodeToString(seg) -} - -// DecodeSegment decodes a JWT specific base64url encoding with padding stripped -// -// Deprecated: In a future release, we will demote this function to a non-exported function, since it -// should only be used internally -func DecodeSegment(seg string) ([]byte, error) { - if DecodePaddingAllowed { - if l := len(seg) % 4; l > 0 { - seg += strings.Repeat("=", 4-l) - } - return base64.URLEncoding.DecodeString(seg) - } - - return base64.RawURLEncoding.DecodeString(seg) -} - -type TokenNG struct { - Raw []byte // The raw token. Populated when you Parse a token - Method SigningMethod // The signing method used or to be used - Header HeaderNG - Claims Claims // The second segment of the token - ClaimBytes []byte - Signature []byte // The third segment of the token. Populated when you Parse a token -} - -type HeaderNG struct { - Alg string `json:"alg"` - Kid string `json:"kid"` - Typ string `json:"typ"` -} - -// func NewTokenNGWithClaims() *TokenNG { -// t := &TokenNG{} -// t.Header = *NewHeader() -// return t -// } - -// func NewHeader() *HeaderNG { -// h := &HeaderNG{ -// Typ: "JWT", -// Alg: siop.DefaultPreferredAlgorithm, -// } -// // The field "kid" is compulsory but will be specified when signing - -// return h -// } - -func (h *HeaderNG) Serialize() []byte { - - // Convert to JSON and encode in B64Url - hs, _ := json.Marshal(h) - - buf := make([]byte, base64.RawURLEncoding.EncodedLen(len(hs))) - base64.RawURLEncoding.Encode(buf, hs) - return buf - -} - -func ParseHeaderSerialized(hs []byte) (h *HeaderNG, err error) { - - // Decode from B64Url and create the struct - dbuf := make([]byte, base64.RawURLEncoding.DecodedLen(len(hs))) - n, err := base64.RawURLEncoding.Decode(dbuf, hs) - if err != nil { - return nil, err - } - dbuf = dbuf[:n] - - err = json.Unmarshal(dbuf, h) - - return h, err - -} diff --git a/internal/jwt/token_test.go b/internal/jwt/token_test.go deleted file mode 100644 index e0d740a9..00000000 --- a/internal/jwt/token_test.go +++ /dev/null @@ -1,79 +0,0 @@ -package jwt_test - -import ( - "testing" - - "github.com/golang-jwt/jwt/v4" -) - -func TestToken_SigningString(t1 *testing.T) { - type fields struct { - Raw string - Method jwt.SigningMethod - Header map[string]interface{} - Claims jwt.Claims - Signature string - Valid bool - } - tests := []struct { - name string - fields fields - want string - wantErr bool - }{ - { - name: "", - fields: fields{ - Raw: "", - Method: jwt.SigningMethodHS256, - Header: map[string]interface{}{ - "typ": "JWT", - "alg": jwt.SigningMethodHS256.Alg(), - }, - Claims: jwt.StandardClaims{}, - Signature: "", - Valid: false, - }, - want: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.e30", - wantErr: false, - }, - } - for _, tt := range tests { - t1.Run(tt.name, func(t1 *testing.T) { - t := &jwt.Token{ - Raw: tt.fields.Raw, - Method: tt.fields.Method, - Header: tt.fields.Header, - Claims: tt.fields.Claims, - Signature: tt.fields.Signature, - Valid: tt.fields.Valid, - } - got, err := t.SigningString() - if (err != nil) != tt.wantErr { - t1.Errorf("SigningString() error = %v, wantErr %v", err, tt.wantErr) - return - } - if got != tt.want { - t1.Errorf("SigningString() got = %v, want %v", got, tt.want) - } - }) - } -} - -func BenchmarkToken_SigningString(b *testing.B) { - t := &jwt.Token{ - Method: jwt.SigningMethodHS256, - Header: map[string]interface{}{ - "typ": "JWT", - "alg": jwt.SigningMethodHS256.Alg(), - }, - Claims: jwt.StandardClaims{}, - } - b.Run("BenchmarkToken_SigningString", func(b *testing.B) { - b.ResetTimer() - b.ReportAllocs() - for i := 0; i < b.N; i++ { - t.SigningString() - } - }) -} diff --git a/internal/jwt/types.go b/internal/jwt/types.go deleted file mode 100644 index 2c647fd2..00000000 --- a/internal/jwt/types.go +++ /dev/null @@ -1,131 +0,0 @@ -package jwt - -import ( - "encoding/json" - "fmt" - "math" - "reflect" - "strconv" - "time" -) - -// TimePrecision sets the precision of times and dates within this library. -// This has an influence on the precision of times when comparing expiry or -// other related time fields. Furthermore, it is also the precision of times -// when serializing. -// -// For backwards compatibility the default precision is set to seconds, so that -// no fractional timestamps are generated. -var TimePrecision = time.Second - -// MarshalSingleStringAsArray modifies the behaviour of the ClaimStrings type, especially -// its MarshalJSON function. -// -// If it is set to true (the default), it will always serialize the type as an -// array of strings, even if it just contains one element, defaulting to the behaviour -// of the underlying []string. If it is set to false, it will serialize to a single -// string, if it contains one element. Otherwise, it will serialize to an array of strings. -var MarshalSingleStringAsArray = true - -// NumericDate represents a JSON numeric date value, as referenced at -// https://datatracker.ietf.org/doc/html/rfc7519#section-2. -type NumericDate struct { - time.Time -} - -// NewNumericDate constructs a new *NumericDate from a standard library time.Time struct. -// It will truncate the timestamp according to the precision specified in TimePrecision. -func NewNumericDate(t time.Time) *NumericDate { - return &NumericDate{t.Truncate(TimePrecision)} -} - -// newNumericDateFromSeconds creates a new *NumericDate out of a float64 representing a -// UNIX epoch with the float fraction representing non-integer seconds. -func newNumericDateFromSeconds(f float64) *NumericDate { - round, frac := math.Modf(f) - return NewNumericDate(time.Unix(int64(round), int64(frac*1e9))) -} - -// MarshalJSON is an implementation of the json.RawMessage interface and serializes the UNIX epoch -// represented in NumericDate to a byte array, using the precision specified in TimePrecision. -func (date NumericDate) MarshalJSON() (b []byte, err error) { - var prec int - if TimePrecision < time.Second { - prec = int(math.Log10(float64(time.Second) / float64(TimePrecision))) - } - f := float64(date.Truncate(TimePrecision).UnixNano()) / float64(time.Second) - - return []byte(strconv.FormatFloat(f, 'f', prec, 64)), nil -} - -// UnmarshalJSON is an implementation of the json.RawMessage interface and deserializses a -// NumericDate from a JSON representation, i.e. a json.Number. This number represents an UNIX epoch -// with either integer or non-integer seconds. -func (date *NumericDate) UnmarshalJSON(b []byte) (err error) { - var ( - number json.Number - f float64 - ) - - if err = json.Unmarshal(b, &number); err != nil { - return fmt.Errorf("could not parse NumericData: %w", err) - } - - if f, err = number.Float64(); err != nil { - return fmt.Errorf("could not convert json number value to float: %w", err) - } - - n := newNumericDateFromSeconds(f) - *date = *n - - return nil -} - -// ClaimStrings is basically just a slice of strings, but it can be either serialized from a string array or just a string. -// This type is necessary, since the "aud" claim can either be a single string or an array. -type ClaimStrings []string - -func (s *ClaimStrings) UnmarshalJSON(data []byte) (err error) { - var value interface{} - - if err = json.Unmarshal(data, &value); err != nil { - return err - } - - var aud []string - - switch v := value.(type) { - case string: - aud = append(aud, v) - case []string: - aud = ClaimStrings(v) - case []interface{}: - for _, vv := range v { - vs, ok := vv.(string) - if !ok { - return &json.UnsupportedTypeError{Type: reflect.TypeOf(vv)} - } - aud = append(aud, vs) - } - case nil: - return nil - default: - return &json.UnsupportedTypeError{Type: reflect.TypeOf(v)} - } - - *s = aud - - return -} - -func (s ClaimStrings) MarshalJSON() (b []byte, err error) { - // This handles a special case in the JWT RFC. If the string array, e.g. used by the "aud" field, - // only contains one element, it MAY be serialized as a single string. This may or may not be - // desired based on the ecosystem of other JWT library used, so we make it configurable by the - // variable MarshalSingleStringAsArray. - if len(s) == 1 && !MarshalSingleStringAsArray { - return json.Marshal(s[0]) - } - - return json.Marshal([]string(s)) -} diff --git a/internal/jwt/types_test.go b/internal/jwt/types_test.go deleted file mode 100644 index ac054ffb..00000000 --- a/internal/jwt/types_test.go +++ /dev/null @@ -1,111 +0,0 @@ -package jwt_test - -import ( - "encoding/json" - "testing" - "time" - - "github.com/golang-jwt/jwt/v4" -) - -func TestNumericDate(t *testing.T) { - var s struct { - Iat jwt.NumericDate `json:"iat"` - Exp jwt.NumericDate `json:"exp"` - } - - oldPrecision := jwt.TimePrecision - - jwt.TimePrecision = time.Microsecond - - raw := `{"iat":1516239022.000000,"exp":1516239022.123450}` - - if err := json.Unmarshal([]byte(raw), &s); err != nil { - t.Fatalf("Unexpected error: %s", err) - } - - b, _ := json.Marshal(s) - - if raw != string(b) { - t.Errorf("Serialized format of numeric date mismatch. Expecting: %s Got: %s", string(raw), string(b)) - } - - jwt.TimePrecision = oldPrecision -} - -func TestSingleArrayMarshal(t *testing.T) { - jwt.MarshalSingleStringAsArray = false - - s := jwt.ClaimStrings{"test"} - expected := `"test"` - - b, err := json.Marshal(s) - - if err != nil { - t.Errorf("Unexpected error: %s", err) - } - - if expected != string(b) { - t.Errorf("Serialized format of string array mismatch. Expecting: %s Got: %s", string(expected), string(b)) - } - - jwt.MarshalSingleStringAsArray = true - - expected = `["test"]` - - b, err = json.Marshal(s) - - if err != nil { - t.Errorf("Unexpected error: %s", err) - } - - if expected != string(b) { - t.Errorf("Serialized format of string array mismatch. Expecting: %s Got: %s", string(expected), string(b)) - } -} - -func TestNumericDate_MarshalJSON(t *testing.T) { - // Do not run this test in parallel because it's changing - // global state. - oldPrecision := jwt.TimePrecision - t.Cleanup(func() { - jwt.TimePrecision = oldPrecision - }) - - tt := []struct { - in time.Time - want string - precision time.Duration - }{ - {time.Unix(5243700879, 0), "5243700879", time.Second}, - {time.Unix(5243700879, 0), "5243700879.000", time.Millisecond}, - {time.Unix(5243700879, 0), "5243700879.000000", time.Microsecond}, - {time.Unix(5243700879, 0), "5243700879.000000000", time.Nanosecond}, - // - {time.Unix(4239425898, 0), "4239425898", time.Second}, - {time.Unix(4239425898, 0), "4239425898.000", time.Millisecond}, - {time.Unix(4239425898, 0), "4239425898.000000", time.Microsecond}, - {time.Unix(4239425898, 0), "4239425898.000000000", time.Nanosecond}, - // - {time.Unix(0, 1644285000210402000), "1644285000", time.Second}, - {time.Unix(0, 1644285000210402000), "1644285000.210", time.Millisecond}, - {time.Unix(0, 1644285000210402000), "1644285000.210402", time.Microsecond}, - {time.Unix(0, 1644285000210402000), "1644285000.210402000", time.Nanosecond}, - // - {time.Unix(0, 1644285315063096000), "1644285315", time.Second}, - {time.Unix(0, 1644285315063096000), "1644285315.063", time.Millisecond}, - {time.Unix(0, 1644285315063096000), "1644285315.063096", time.Microsecond}, - {time.Unix(0, 1644285315063096000), "1644285315.063096000", time.Nanosecond}, - } - - for i, tc := range tt { - jwt.TimePrecision = tc.precision - by, err := jwt.NewNumericDate(tc.in).MarshalJSON() - if err != nil { - t.Fatal(err) - } - if got := string(by); got != tc.want { - t.Errorf("[%d]: failed encoding: got %q want %q", i, got, tc.want) - } - } -} diff --git a/logging/logging.go b/logging/logging.go new file mode 100644 index 00000000..275a9074 --- /dev/null +++ b/logging/logging.go @@ -0,0 +1,109 @@ +package logging + +import ( + "encoding/json" + "time" + + "github.com/gin-gonic/gin" + "github.com/sirupsen/logrus" +) + +/** +* Global logger + */ +var logger = logrus.New() + +var logRequests bool +var skipPaths []string + +/** +* Apply the given configuration to the global logger. +**/ +func Configure(jsonLogging bool, logLevel string, logRequestsParam bool, skipPathsParam []string) { + if logLevel == "DEBUG" { + logger.SetLevel(logrus.DebugLevel) + } else if logLevel == "INFO" { + logger.SetLevel(logrus.InfoLevel) + } else if logLevel == "WARN" { + logger.SetLevel(logrus.WarnLevel) + } else if logLevel == "ERROR" { + logger.SetLevel(logrus.ErrorLevel) + } + + if jsonLogging { + logger.SetFormatter(&logrus.JSONFormatter{}) + } else { + logger.SetFormatter(&logrus.TextFormatter{}) + } + + logRequests = logRequestsParam + skipPaths = skipPathsParam +} + +/** +* Global access to the singleton logger +**/ +func Log() *logrus.Logger { + return logger +} + +/** +* Gin compatible function to enable logger injection into the gin-framework +**/ +func GinHandlerFunc() gin.HandlerFunc { + return func(c *gin.Context) { + if !logRequests { + c.Next() + } else { + // Start timer + start := time.Now() + path := c.Request.URL.Path + raw := c.Request.URL.RawQuery + if raw != "" { + path = path + "?" + raw + } + + // Process request + c.Next() + + if contains(skipPaths, path) { + return + } + + // Stop timer + end := time.Now() + latency := end.Sub(start) + method := c.Request.Method + statusCode := c.Writer.Status() + errorMessage := c.Errors.ByType(gin.ErrorTypePrivate).String() + + if errorMessage != "" { + Log().Warnf("Request [%s]%s took %d ms - Result: %d - %s", method, path, latency, statusCode, errorMessage) + } else { + Log().Infof("Request [%s]%s took %d ms - Result: %d", method, path, latency, statusCode) + } + } + } +} + +/** +* Helper method to print objects with json-serialization information in a more human readable way + */ +func PrettyPrintObject(objectInterface interface{}) string { + jsonBytes, err := json.Marshal(objectInterface) + if err != nil { + logger.Debugf("Was not able to pretty print the object: %v", objectInterface) + return "" + } + return string(jsonBytes) +} + +// helper method to check if s contains e +func contains(s []string, e string) bool { + for _, a := range s { + if a == e { + return true + } + } + return false +} diff --git a/main.go b/main.go index c338296d..f2c8bf0c 100644 --- a/main.go +++ b/main.go @@ -1,358 +1,142 @@ package main import ( - "crypto/rand" - "encoding/base64" - "encoding/json" - "errors" "fmt" - "io" + "net/http" "os" - "github.com/fiware/vcverifier/back/handlers" - "github.com/fiware/vcverifier/back/operations" - "github.com/fiware/vcverifier/internal/jwk" - "github.com/fiware/vcverifier/vault" - - "github.com/hesusruiz/vcutils/yaml" - - "flag" - "log" - - "github.com/gofiber/fiber/v2" - "github.com/gofiber/fiber/v2/middleware/cors" - "github.com/gofiber/fiber/v2/middleware/recover" - "github.com/gofiber/storage/memory" - "github.com/gofiber/template/html" - "go.uber.org/zap" + configModel "fiware/VCVerifier/config" + logging "fiware/VCVerifier/logging" + api "fiware/VCVerifier/openapi" + ssi "fiware/VCVerifier/ssikit" + "fiware/VCVerifier/verifier" + + "github.com/foolin/goview/supports/ginview" + "github.com/gin-contrib/cors" + "github.com/gin-gonic/gin" + "github.com/gookit/config/v2" + "github.com/gookit/config/v2/yaml" + "github.com/penglongli/gin-metrics/ginmetrics" ) -const defaultConfigFile = "configs/server.yaml" -const defaultTemplateDir = "back/views" -const defaultStaticDir = "back/www" -const defaultStoreDriverName = "sqlite3" -const defaultStoreDataSourceName = "file:issuer.sqlite?mode=rwc&cache=shared&_fk=1" -const defaultPassword = "ThePassword" +// default config file location - can be overwritten by envvar +var configFile string = "server.yaml" -const corePrefix = "/core/api/v1" -const issuerPrefix = "/issuer/api/v1" -const verifierPrefix = "/verifier/api/v1" -const walletPrefix = "/wallet/api/v1" - -var ( - prod = flag.Bool("prod", false, "Enable prefork in Production") - configFile = flag.String("config", LookupEnvOrString("CONFIG_FILE", defaultConfigFile), "path to configuration file") - password = flag.String("pass", LookupEnvOrString("PASSWORD", defaultPassword), "admin password for the server") -) - -type SSIKitConfig struct { - coreUrl string - signatoryUrl string - auditorUrl string - custodianUrl string - essifUrl string -} - -// Server is the struct holding the state of the server -type Server struct { - *fiber.App - cfg *yaml.YAML - WebAuthn *handlers.WebAuthnHandler - Operations *operations.Manager - verifierVault *vault.Vault - issuerDID string - verifierDID string - logger *zap.SugaredLogger - storage *memory.Storage - ssiKit *SSIKitConfig -} - -func LookupEnvOrString(key string, defaultVal string) string { - if val, ok := os.LookupEnv(key); ok { - return val - } - return defaultVal -} +// config objects +var serverConfig configModel.Server +var loggingConfig configModel.Logging +var ssiKitConfig configModel.SSIKit +var verifierConfig configModel.Verifier +/** +* Startup method to run the gin-server. + */ func main() { - BackendServer() -} - -func BackendServer() { - var err error - - // Create the server instance - s := &Server{} - - // Read configuration file - cfg := readConfiguration(*configFile) - // Create the logger and store in Server so all handlers can use it - if cfg.String("server.environment") == "production" { - s.logger = zap.Must(zap.NewProduction()).Sugar() - } else { - s.logger = zap.Must(zap.NewDevelopment()).Sugar() - } - zap.WithCaller(true) - defer s.logger.Sync() - - // Parse command-line flags - flag.Parse() + readConfig() - // Create the template engine using the templates in the configured directory - templateDir := cfg.String("server.templateDir", defaultTemplateDir) - templateEngine := html.New(templateDir, ".html") + logging.Configure( + loggingConfig.JsonLogging, + loggingConfig.Level, + loggingConfig.LogRequests, + loggingConfig.PathsToSkip) - if cfg.String("server.environment") == "development" { - // Just for development time. Disable when in production - templateEngine.Reload(true) - } - - // Define the configuration for Fiber - fiberCfg := fiber.Config{ - Views: templateEngine, - ViewsLayout: "layouts/main", - Prefork: *prod, - } + logger := logging.Log() - // Create a Fiber instance and set it in our Server struct - s.App = fiber.New(fiberCfg) - s.cfg = cfg + logger.Infof("Logging config is: %s", logging.PrettyPrintObject(loggingConfig)) + logger.Infof("Server config is: %s", logging.PrettyPrintObject(serverConfig)) + logger.Infof("SSIKit config is: %s", logging.PrettyPrintObject(ssiKitConfig)) + logger.Infof("Verifier config is: %s", logging.PrettyPrintObject(verifierConfig)) - // Connect to the different store engines - s.verifierVault = vault.Must(vault.New(yaml.New(cfg.Map("verifier")))) - - // Create the issuer and verifier users - // TODO: the password is only for testing - s.verifierVault.CreateUserWithKey(cfg.String("verifier.id"), cfg.String("verifier.name"), "legalperson", cfg.String("verifier.password")) - - s.ssiKit = fromMap(cfg.Map("ssikit")) - - s.logger.Infof("SSIKit is configured at: %v", s.ssiKit) - - s.verifierDID, err = operations.SSIKitCreateDID(s.ssiKit.custodianUrl, s.verifierVault, cfg.String("verifier.id")) + ssiKitClient, err := ssi.NewSSIKitClient(&ssiKitConfig) if err != nil { - panic(err) - } - s.logger.Infow("VerifierDID created", "did", s.verifierDID) - - // Backend Operations, with its DB connection configuration - s.Operations = operations.NewManager(cfg) - - // Recover panics from the HTTP handlers so the server continues running - s.Use(recover.New(recover.Config{EnableStackTrace: true})) - - // CORS - s.Use(cors.New()) - - // Create a storage entry for logon expiration - s.storage = memory.New() - defer s.storage.Close() - - // ########################## - // Application Home pages - s.Get("/", s.HandleHome) - s.Get("/verifier", s.HandleVerifierHome) - - // Info base path - s.Get("/info", s.GetBackendInfo) - - // WARNING! This is just for development. Disable this in production by using the config file setting - if cfg.String("server.environment") == "development" { - s.Get("/stop", s.HandleStop) - } - - setupVerifier(s) - setupCoreRoutes(s) - - // Setup static files - s.Static("/static", cfg.String("server.staticDir", defaultStaticDir)) - - // Start the server - log.Fatal(s.Listen(cfg.String("server.listenAddress"))) - -} - -func setupCoreRoutes(s *Server) { - // ######################################## - // Core routes - coreRoutes := s.Group(corePrefix) - - // Create DID - coreRoutes.Get("/createdid", s.CoreAPICreateDID) - // List Templates - coreRoutes.Get("/listcredentialtemplates", s.CoreAPIListCredentialTemplates) - // Get one template - coreRoutes.Get("/getcredentialtemplate/:id", s.CoreAPIGetCredentialTemplate) - -} - -func fromMap(configMap map[string]any) (skc *SSIKitConfig) { - coreUrl, ok := configMap["coreURL"] - if !ok { - panic(errors.New("no_core_url")) - } - custodianUrl, ok := configMap["custodianURL"] - if !ok { - panic(errors.New("no_custodian_url")) - } - signatoryUrl, ok := configMap["signatoryURL"] - if !ok { - panic(errors.New("no_signatory_url")) + logger.Errorf("Was not able to get an ssiKit client. Err: %v", err) + return } - essifUrl, ok := configMap["essifURL"] - if !ok { - panic(errors.New("no_essif_url")) - } - auditorUrl, ok := configMap["auditorURL"] - if !ok { - panic(errors.New("no_auditor_url")) - } - return &SSIKitConfig{coreUrl: coreUrl.(string), signatoryUrl: signatoryUrl.(string), auditorUrl: auditorUrl.(string), essifUrl: essifUrl.(string), custodianUrl: custodianUrl.(string)} -} + verifier.InitVerifier(&verifierConfig, ssiKitClient) -type backendInfo struct { - VerifierDID string `json:"verifierDid"` -} + router := getRouter() -func (s *Server) GetBackendInfo(c *fiber.Ctx) error { - info := backendInfo{VerifierDID: s.verifierDID} + // health check + router.GET("/health", HealthReq) - return c.JSON(info) -} + router.Use(cors.New(cors.Config{ + // we need to allow all, since we do not know the potential origin of a wallet + AllowOrigins: []string{"*"}, + AllowMethods: []string{"POST", "GET"}, + AllowHeaders: []string{"Origin", "Content-Type", "Authorization"}, + AllowCredentials: true, + })) -func (s *Server) HandleHome(c *fiber.Ctx) error { + //new template engine + router.HTMLRender = ginview.Default() + // static files for the frontend + router.Static("/static", serverConfig.StaticDir) - // Render index - return c.Render("index", "") -} - -func (s *Server) HandleStop(c *fiber.Ctx) error { - os.Exit(0) - return nil -} - -func (s *Server) HandleVerifierHome(c *fiber.Ctx) error { - - // Get the list of credentials - credsSummary, err := s.Operations.GetAllCredentials() - if err != nil { - return err - } + // initiate metrics + metrics := ginmetrics.GetMonitor() + metrics.SetMetricPath("/metrics") + metrics.Use(router) - // Render template - m := fiber.Map{ - "verifierPrefix": verifierPrefix, - "prefix": verifierPrefix, - "credlist": credsSummary, - } - return c.Render("verifier_home", m) -} + router.Run(fmt.Sprintf("0.0.0.0:%v", serverConfig.Port)) -func generateNonce() string { - b := make([]byte, 16) - io.ReadFull(rand.Reader, b) - nonce := base64.RawURLEncoding.EncodeToString(b) - return nonce + logger.Infof("Started router at %v", serverConfig.Port) } -var sameDevice = false +// initiate the router +func getRouter() *gin.Engine { + // the openapi generated router uses the defaults, which we want to override to improve and configure logging + router := gin.New() + router.Use(logging.GinHandlerFunc(), gin.Recovery()) -type jwkSet struct { - Keys []*jwk.JWK `json:"keys"` -} + for _, route := range api.NewRouter().Routes() { -func (s *Server) VerifierAPIJWKS(c *fiber.Ctx) error { - - // Get public keys from Verifier - pubkeys, err := s.verifierVault.PublicKeysForUser(s.cfg.String("verifier.id")) - if err != nil { - return err + switch route.Method { + case http.MethodGet: + router.GET(route.Path, route.HandlerFunc) + case http.MethodPost: + router.POST(route.Path, route.HandlerFunc) + case http.MethodPut: + router.PUT(route.Path, route.HandlerFunc) + case http.MethodPatch: + router.PATCH(route.Path, route.HandlerFunc) + case http.MethodDelete: + router.DELETE(route.Path, route.HandlerFunc) + } } - keySet := jwkSet{pubkeys} - - return c.JSON(keySet) - + return router } -// readConfiguration reads a YAML file and creates an easy-to navigate structure -func readConfiguration(configFile string) *yaml.YAML { - var cfg *yaml.YAML - var err error +// read the config from the config file +func readConfig() { + config.WithOptions(config.ParseDefault) + config.AddDriver(yaml.Driver) + err := config.LoadFiles(configFile) - cfg, err = yaml.ParseYamlFile(configFile) if err != nil { - fmt.Printf("Config file not found, exiting\n") panic(err) } - return cfg -} - -// DID handling -func (srv *Server) CoreAPICreateDID(c *fiber.Ctx) error { - - // body := c.Body() - - // Call the SSI Kit - agent := fiber.Post(srv.ssiKit.custodianUrl + "/did/create") - bodyRequest := fiber.Map{ - "method": "key", - } - agent.JSON(bodyRequest) - agent.ContentType("application/json") - agent.Set("accept", "application/json") - _, returnBody, errors := agent.Bytes() - if len(errors) > 0 { - srv.logger.Errorw("error calling SSI Kit", zap.Errors("errors", errors)) - return fmt.Errorf("error calling SSI Kit: %v", errors[0]) - } - c.Set("Content-Type", "application/json") - return c.Send(returnBody) + serverConfig = configModel.Server{} + config.BindStruct("server", &serverConfig) -} - -func (srv *Server) CoreAPIListCredentialTemplates(c *fiber.Ctx) error { + loggingConfig = configModel.Logging{} + config.BindStruct("logging", &loggingConfig) - // Call the SSI Kit - agent := fiber.Get(srv.ssiKit.signatoryUrl + "/v1/templates") - agent.Set("accept", "application/json") - _, returnBody, errors := agent.Bytes() - if len(errors) > 0 { - srv.logger.Errorw("error calling SSI Kit", zap.Errors("errors", errors)) - return fmt.Errorf("error calling SSI Kit: %v", errors[0]) - } - - c.Set("Content-Type", "application/json") - return c.Send(returnBody) + ssiKitConfig = configModel.SSIKit{} + config.BindStruct("ssiKit", &ssiKitConfig) + verifierConfig = configModel.Verifier{} + config.BindStruct("verifier", &verifierConfig) } -func (srv *Server) CoreAPIGetCredentialTemplate(c *fiber.Ctx) error { - - id := c.Params("id") - if len(id) == 0 { - return fmt.Errorf("no template id specified") - } +// allow override of the config-file on init. Everything else happens on main to improve testability +func init() { - // Call the SSI Kit - agent := fiber.Get(srv.ssiKit.signatoryUrl + "/v1/templates/" + id) - agent.Set("accept", "application/json") - _, returnBody, errors := agent.Bytes() - if len(errors) > 0 { - srv.logger.Errorw("error calling SSI Kit", zap.Errors("errors", errors)) - return fmt.Errorf("error calling SSI Kit: %v", errors[0]) + configFileEnv := os.Getenv("CONFIG_FILE") + if configFileEnv != "" { + configFile = configFileEnv } - - c.Set("Content-Type", "application/json") - return c.Send(returnBody) - -} - -func prettyFormatJSON(in []byte) string { - decoded := &fiber.Map{} - json.Unmarshal(in, decoded) - out, _ := json.MarshalIndent(decoded, "", " ") - return string(out) + logging.Log().Infof("Will read config from %s", configFile) } diff --git a/openapi/README.md b/openapi/README.md new file mode 100644 index 00000000..b87ac6b1 --- /dev/null +++ b/openapi/README.md @@ -0,0 +1,49 @@ +# Go API Server for openapi + +Backend component to verify credentials + +## Overview +This server was generated by the [openapi-generator] +(https://openapi-generator.tech) project. +By using the [OpenAPI-Spec](https://github.com/OAI/OpenAPI-Specification) from a remote server, you can easily generate a server stub. +- + +To see how to make this your own, look here: + +[README](https://openapi-generator.tech) + +- API version: 0.0.1 +- Build date: 2023-03-15T12:51:54.096463Z[Etc/UTC] + +### Running the server + +To run the server, follow these simple steps: + +``` +go run main.go +``` + +To run the server in a docker container +``` +docker build --network=host -t openapi . +``` + +Once the image is built, just run +``` +docker run --rm -it openapi +``` + +### Known Issue + +Endpoints sharing a common path may result in issues. For example, `/v2/pet/findByTags` and `/v2/pet/:petId` will result in an issue with the Gin framework. For more information about this known limitation, please refer to [gin-gonic/gin#388](https://github.com/gin-gonic/gin/issues/388) for more information. + +A workaround is to manually update the path and handler. Please refer to [gin-gonic/gin/issues/205#issuecomment-296155497](https://github.com/gin-gonic/gin/issues/205#issuecomment-296155497) for more information. + + +## Create + +docker run --rm \ + -v ${PWD}:/local openapitools/openapi-generator-cli generate \ + -i /local/api/api.yaml \ + -g go-gin-server \ + -o /local/out/go \ No newline at end of file diff --git a/openapi/api_api.go b/openapi/api_api.go new file mode 100644 index 00000000..4a95a3ad --- /dev/null +++ b/openapi/api_api.go @@ -0,0 +1,210 @@ +/* + * vcverifier + * + * Backend component to verify credentials + * + * API version: 0.0.1 + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package openapi + +import ( + "encoding/base64" + "encoding/json" + "fiware/VCVerifier/logging" + "fiware/VCVerifier/verifier" + "fmt" + "net/http" + + "github.com/gin-gonic/gin" +) + +var apiVerifier verifier.Verifier + +var ErrorMessagNoGrantType = ErrorMessage{"no_grant_type_provided", "Token requests require a grant_type."} +var ErrorMessageNoCode = ErrorMessage{"no_code_provided", "Token requests require a code."} +var ErrorMessageNoRedircetUri = ErrorMessage{"no_redirect_uri_provided", "Token requests require a redirect_uri."} +var ErrorMessageNoState = ErrorMessage{"no_state_provided", "Authentication requires a state provided as query parameter."} +var ErrorMessageNoToken = ErrorMessage{"no_token_provided", "Authentication requires a token provided as a form parameter."} +var ErrorMessageNoCallback = ErrorMessage{"NoCallbackProvided", "A callback address has to be provided as query-parameter."} +var ErrorMessageUnableToDecodeToken = ErrorMessage{"invalid_token", "Token could not be decoded."} +var ErrorMessageUnableToDecodeCredential = ErrorMessage{"invalid_token", "Could not read the credential(s) inside the token."} +var ErrorMessageUnableToDecodeHolder = ErrorMessage{"invalid_token", "Could not read the holder inside the token."} + +func getApiVerifier() verifier.Verifier { + if apiVerifier == nil { + apiVerifier = verifier.GetVerifier() + } + return apiVerifier +} + +// GetToken - Token endpoint to exchange the authorization code with the actual JWT. +func GetToken(c *gin.Context) { + + logging.Log().Debugf("%v", c.Request) + grantType, grantTypeExists := c.GetPostForm("grant_type") + if !grantTypeExists { + logging.Log().Debug("No grant_type present in the request.") + c.AbortWithStatusJSON(400, ErrorMessagNoGrantType) + return + } + code, codeExists := c.GetPostForm("code") + if !codeExists { + logging.Log().Debug("No code present in the request.") + c.AbortWithStatusJSON(400, ErrorMessageNoCode) + return + } + redirectUri, redirectUriExists := c.GetPostForm("redirect_uri") + if !redirectUriExists { + logging.Log().Debug("No redircet_uri present in the request.") + c.AbortWithStatusJSON(400, ErrorMessageNoRedircetUri) + return + } + jwt, expiration, err := getApiVerifier().GetToken(grantType, code, redirectUri) + + if err != nil { + c.AbortWithStatusJSON(403, ErrorMessage{Summary: err.Error()}) + return + } + + c.JSON(http.StatusOK, TokenResponse{"Bearer", float32(expiration), jwt}) +} + +// StartSIOPSameDevice - Starts the siop flow for credentials hold by the same device +func StartSIOPSameDevice(c *gin.Context) { + state, stateExists := c.GetQuery("state") + if !stateExists { + logging.Log().Debugf("No state was provided.") + c.AbortWithStatusJSON(400, ErrorMessage{"no_state_provided", "Authentication requires a state provided as query parameter."}) + return + } + redirectPath, redirectPathExists := c.GetQuery("redirect_path") + if !redirectPathExists { + redirectPath = "/" + } + + protocol := "https" + if c.Request.TLS == nil { + protocol = "http" + } + + redirect, err := getApiVerifier().StartSameDeviceFlow(c.Request.Host, protocol, state, redirectPath) + if err != nil { + logging.Log().Warnf("Error starting the same-device flow. Err: %v", err) + c.AbortWithStatusJSON(500, ErrorMessage{err.Error(), "Was not able to start the same device flow."}) + return + } + c.Redirect(302, redirect) +} + +// VerifierAPIAuthenticationResponse - Stores the credential for the given session +func VerifierAPIAuthenticationResponse(c *gin.Context) { + state, stateExists := c.GetQuery("state") + if !stateExists { + c.AbortWithStatusJSON(400, ErrorMessageNoState) + return + } + + base64Token, tokenExists := c.GetPostForm("vp_token") + if !tokenExists { + logging.Log().Info("No token was provided.") + c.AbortWithStatusJSON(400, ErrorMessageNoToken) + return + } + + handleAuthenticationResponse(c, state, base64Token) +} + +// GetVerifierAPIAuthenticationResponse - Stores the credential for the given session +func GetVerifierAPIAuthenticationResponse(c *gin.Context) { + state, stateExists := c.GetQuery("state") + if !stateExists { + c.AbortWithStatusJSON(400, ErrorMessageNoState) + return + } + + base64Token, tokenExists := c.GetQuery("vp_token") + if !tokenExists { + logging.Log().Info("No token was provided.") + c.AbortWithStatusJSON(400, ErrorMessageNoToken) + return + } + + handleAuthenticationResponse(c, state, base64Token) +} + +func handleAuthenticationResponse(c *gin.Context, state string, vpToken string) { + bytes, err := base64.RawURLEncoding.DecodeString(vpToken) + if err != nil { + logging.Log().Infof("Was not able to decode the form string %s. Err: %v", vpToken, err) + c.AbortWithStatusJSON(400, ErrorMessageUnableToDecodeToken) + return + } + var vpObjectMap map[string]json.RawMessage + json.Unmarshal(bytes, &vpObjectMap) + + verifiableCredentials := vpObjectMap["verifiableCredential"] + rawHolder := vpObjectMap["holder"] + + var rawCredentials []map[string]interface{} + var holder string + + err = json.Unmarshal(verifiableCredentials, &rawCredentials) + if err != nil { + logging.Log().Infof("Was not able to decode the credentials from the token %s. Err: %v", vpToken, err) + c.AbortWithStatusJSON(400, ErrorMessageUnableToDecodeCredential) + return + } + err = json.Unmarshal(rawHolder, &holder) + if err != nil || holder == "" { + logging.Log().Infof("Was not able to decode the holder from the token %s. Err: %v", vpToken, err) + c.AbortWithStatusJSON(400, ErrorMessageUnableToDecodeHolder) + return + } + + sameDeviceResponse, err := getApiVerifier().AuthenticationResponse(state, rawCredentials, holder) + if err != nil { + logging.Log().Warnf("Was not able to get fullfil the authentication response. Err: %v", err) + c.AbortWithStatusJSON(400, ErrorMessage{Summary: err.Error()}) + return + } + if sameDeviceResponse != (verifier.SameDeviceResponse{}) { + c.Redirect(302, fmt.Sprintf("%s?state=%s&code=%s", sameDeviceResponse.RedirectTarget, sameDeviceResponse.SessionId, sameDeviceResponse.Code)) + return + } + logging.Log().Debugf("Successfully authenticated %s.", state) + c.JSON(http.StatusOK, gin.H{}) +} + +// VerifierAPIJWKS - Provides the public keys for the given verifier, to be used for verifing the JWTs +func VerifierAPIJWKS(c *gin.Context) { + c.JSON(http.StatusOK, getApiVerifier().GetJWKS()) +} + +// VerifierAPIStartSIOP - Initiates the siop flow and returns the 'openid://...' connection string +func VerifierAPIStartSIOP(c *gin.Context) { + state, stateExists := c.GetQuery("state") + if !stateExists { + c.AbortWithStatusJSON(400, ErrorMessageNoState) + // early exit + return + } + + callback, callbackExists := c.GetQuery("client_callback") + if !callbackExists { + c.AbortWithStatusJSON(400, ErrorMessageNoCallback) + // early exit + return + } + protocol := "https" + if c.Request.TLS == nil { + protocol = "http" + } + connectionString, err := getApiVerifier().StartSiopFlow(c.Request.Host, protocol, callback, state) + if err != nil { + c.AbortWithStatusJSON(500, ErrorMessage{err.Error(), "Was not able to generate the connection string."}) + return + } + c.String(http.StatusOK, connectionString) +} diff --git a/openapi/api_api_test.go b/openapi/api_api_test.go new file mode 100644 index 00000000..12f0e1c2 --- /dev/null +++ b/openapi/api_api_test.go @@ -0,0 +1,356 @@ +package openapi + +import ( + "bytes" + "encoding/json" + "errors" + "io/ioutil" + "net/http" + "net/http/httptest" + "strings" + "testing" + + "fiware/VCVerifier/logging" + verifier "fiware/VCVerifier/verifier" + + "github.com/gin-gonic/gin" + "github.com/lestrrat-go/jwx/jwk" +) + +type mockVerifier struct { + mockJWTString string + mockQR string + mockConnectionString string + mockAuthRequest string + mockJWKS jwk.Set + mockSameDevice verifier.SameDeviceResponse + mockExpiration int64 + mockError error +} + +func (mV *mockVerifier) ReturnLoginQR(host string, protocol string, callback string, sessionId string) (qr string, err error) { + return mV.mockQR, mV.mockError +} +func (mV *mockVerifier) StartSiopFlow(host string, protocol string, callback string, sessionId string) (connectionString string, err error) { + return mV.mockConnectionString, mV.mockError +} +func (mV *mockVerifier) StartSameDeviceFlow(host string, protocol string, sessionId string, redirectPath string) (authenticationRequest string, err error) { + return mV.mockAuthRequest, mV.mockError +} +func (mV *mockVerifier) GetToken(grantType string, authorizationCode string, redirectUri string) (jwtString string, expiration int64, err error) { + return mV.mockJWTString, mV.mockExpiration, mV.mockError +} +func (mV *mockVerifier) GetJWKS() jwk.Set { + return mV.mockJWKS +} +func (mV *mockVerifier) AuthenticationResponse(state string, verifiableCredentials []map[string]interface{}, holder string) (sameDevice verifier.SameDeviceResponse, err error) { + return mV.mockSameDevice, mV.mockError +} + +func TestGetToken(t *testing.T) { + + logging.Configure(true, "DEBUG", true, []string{}) + + type test struct { + testName string + testGrantType string + testCode string + testRedirectUri string + mockJWTString string + mockExpiration int64 + mockError error + expectedStatusCode int + expectedResponse TokenResponse + expectedError ErrorMessage + } + tests := []test{ + {"If a valid request is received a token should be responded.", "authorization_code", "my-auth-code", "http://my-redirect.org", "theJWT", 10, nil, 200, TokenResponse{TokenType: "Bearer", ExpiresIn: 10, AccessToken: "theJWT"}, ErrorMessage{}}, + {"If no grant type is provided, the request should fail.", "", "my-auth-code", "http://my-redirect.org", "theJWT", 10, nil, 400, TokenResponse{}, ErrorMessagNoGrantType}, + {"If no auth code is provided, the request should fail.", "authorization_code", "", "http://my-redirect.org", "theJWT", 10, nil, 400, TokenResponse{}, ErrorMessageNoCode}, + {"If no redirect uri is provided, the request should fail.", "authorization_code", "my-auth-code", "", "theJWT", 10, nil, 400, TokenResponse{}, ErrorMessageNoRedircetUri}, + {"If the verify returns an error, a 403 should be answerd.", "authorization_code", "my-auth-code", "http://my-redirect.org", "", 10, errors.New("invalid"), 403, TokenResponse{}, ErrorMessage{}}, + } + + for _, tc := range tests { + + logging.Log().Info("TestGetToken +++++++++++++++++ Running test: ", tc.testName) + + recorder := httptest.NewRecorder() + testContext, _ := gin.CreateTestContext(recorder) + apiVerifier = &mockVerifier{mockJWTString: tc.mockJWTString, mockExpiration: tc.mockExpiration, mockError: tc.mockError} + + formArray := []string{} + + if tc.testGrantType != "" { + formArray = append(formArray, "grant_type="+tc.testGrantType) + } + if tc.testCode != "" { + formArray = append(formArray, "code="+tc.testCode) + } + if tc.testRedirectUri != "" { + formArray = append(formArray, "redirect_uri="+tc.testRedirectUri) + } + + body := bytes.NewBufferString(strings.Join(formArray, "&")) + testContext.Request, _ = http.NewRequest("POST", "/", body) + testContext.Request.Header.Add("Content-Type", gin.MIMEPOSTForm) + + GetToken(testContext) + + if recorder.Code != tc.expectedStatusCode { + t.Errorf("%s - Expected status %v but was %v.", tc.testName, tc.expectedStatusCode, recorder.Code) + continue + } + + if tc.expectedStatusCode == 400 { + errorBody, _ := ioutil.ReadAll(recorder.Body) + errorMessage := ErrorMessage{} + json.Unmarshal(errorBody, &errorMessage) + if errorMessage != tc.expectedError { + t.Errorf("%s - Expected error %s but was %s.", tc.testName, logging.PrettyPrintObject(tc.expectedError), logging.PrettyPrintObject(errorMessage)) + continue + } + continue + } + + tokenResponse := TokenResponse{} + if tc.expectedResponse != tokenResponse { + body, _ := ioutil.ReadAll(recorder.Body) + err := json.Unmarshal(body, &tokenResponse) + if err != nil { + t.Errorf("%s - Was not able to unmarshal the token response. Err: %v.", tc.testName, err) + continue + } + if tokenResponse != tc.expectedResponse { + t.Errorf("%s - Expected token response %s but was %s.", tc.testName, logging.PrettyPrintObject(tc.expectedResponse), logging.PrettyPrintObject(tokenResponse)) + continue + } + } + + } +} + +func TestStartSIOPSameDevice(t *testing.T) { + + logging.Configure(true, "DEBUG", true, []string{}) + + type test struct { + testName string + testState string + testRedirectPath string + testRequestAddress string + mockRedirect string + mockError error + expectedStatusCode int + expectedLocation string + } + + tests := []test{ + {"If all neccessary parameters provided, a valid redirect should be returned.", "my-state", "/my-redirect", "http://host.org", "http://host.org/api/v1/authentication_response", nil, 302, "http://host.org/api/v1/authentication_response"}, + {"If no path is provided, the default redirect should be returned.", "my-state", "", "http://host.org", "http://host.org/api/v1/authentication_response", nil, 302, "http://host.org/api/v1/authentication_response"}, + {"If no state is provided, a 400 should be returned.", "", "", "http://host.org", "http://host.org/api/v1/authentication_response", nil, 400, ""}, + {"If the verifier returns an error, a 500 should be returned.", "my-state", "/", "http://host.org", "http://host.org/api/v1/authentication_response", errors.New("verifier_failure"), 500, ""}, + } + + for _, tc := range tests { + + logging.Log().Info("TestStartSIOPSameDevice +++++++++++++++++ Running test: ", tc.testName) + + recorder := httptest.NewRecorder() + testContext, _ := gin.CreateTestContext(recorder) + apiVerifier = &mockVerifier{mockAuthRequest: tc.mockRedirect, mockError: tc.mockError} + + testParameters := []string{} + if tc.testState != "" { + testParameters = append(testParameters, "state="+tc.testState) + } + if tc.testRedirectPath != "" { + testParameters = append(testParameters, "redirect_path="+tc.testRedirectPath) + } + + testContext.Request, _ = http.NewRequest("GET", tc.testRequestAddress+"/?"+strings.Join(testParameters, "&"), nil) + StartSIOPSameDevice(testContext) + + if recorder.Code != tc.expectedStatusCode { + t.Errorf("%s - Expected status %v but was %v.", tc.testName, tc.expectedStatusCode, recorder.Code) + continue + } + if tc.expectedStatusCode != 302 { + // everything other is an error, we dont care about the details + continue + } + + location := recorder.Result().Header.Get("Location") + if location != tc.expectedLocation { + t.Errorf("%s - Expected location %s but was %s.", tc.testName, tc.expectedLocation, location) + } + } +} + +func TestVerifierAPIAuthenticationResponse(t *testing.T) { + + logging.Configure(true, "DEBUG", true, []string{}) + + type test struct { + testName string + sameDevice bool + testState string + testVPToken string + mockError error + mockSameDeviceResponse verifier.SameDeviceResponse + expectedStatusCode int + expectedRedirect string + expectedError ErrorMessage + } + + tests := []test{ + {"If a same-device flow is authenticated, a valid redirect should be returned.", true, "my-state", getValidVPToken(), nil, verifier.SameDeviceResponse{RedirectTarget: "http://my-verifier.org", Code: "my-code", SessionId: "my-session-id"}, 302, "http://my-verifier.org?state=my-session-id&code=my-code", ErrorMessage{}}, + {"If a cross-device flow is authenticated, a simple ok should be returned.", false, "my-state", getValidVPToken(), nil, verifier.SameDeviceResponse{}, 200, "", ErrorMessage{}}, + {"If the same-device flow responds an error, a 400 should be returend", true, "my-state", getValidVPToken(), errors.New("verification_error"), verifier.SameDeviceResponse{}, 400, "", ErrorMessage{Summary: "verification_error"}}, + {"If no state is provided, a 400 should be returned.", true, "", getValidVPToken(), nil, verifier.SameDeviceResponse{}, 400, "", ErrorMessageNoState}, + {"If an no token is provided, a 400 should be returned.", true, "my-state", "", nil, verifier.SameDeviceResponse{}, 400, "", ErrorMessageNoToken}, + {"If a token with invalid credentials is provided, a 400 should be returned.", true, "my-state", getNoVCVPToken(), nil, verifier.SameDeviceResponse{}, 400, "", ErrorMessageUnableToDecodeCredential}, + {"If a token with an invalid holder is provided, a 400 should be returned.", true, "my-state", getNoHolderVPToken(), nil, verifier.SameDeviceResponse{}, 400, "", ErrorMessageUnableToDecodeHolder}, + } + + for _, tc := range tests { + + logging.Log().Info("TestVerifierAPIAuthenticationResponse +++++++++++++++++ Running test: ", tc.testName) + + recorder := httptest.NewRecorder() + testContext, _ := gin.CreateTestContext(recorder) + apiVerifier = &mockVerifier{mockSameDevice: tc.mockSameDeviceResponse, mockError: tc.mockError} + + formArray := []string{} + + if tc.testVPToken != "" { + formArray = append(formArray, "vp_token="+tc.testVPToken) + } + + requestAddress := "http://my-verifier.org/" + if tc.testState != "" { + requestAddress = requestAddress + "?state=" + tc.testState + } + + body := bytes.NewBufferString(strings.Join(formArray, "&")) + testContext.Request, _ = http.NewRequest("POST", requestAddress, body) + testContext.Request.Header.Add("Content-Type", gin.MIMEPOSTForm) + + VerifierAPIAuthenticationResponse(testContext) + + if tc.expectedStatusCode == 400 { + errorBody, _ := ioutil.ReadAll(recorder.Body) + errorMessage := ErrorMessage{} + json.Unmarshal(errorBody, &errorMessage) + if errorMessage != tc.expectedError { + t.Errorf("%s - Expected error %s but was %s.", tc.testName, logging.PrettyPrintObject(tc.expectedError), logging.PrettyPrintObject(errorMessage)) + continue + } + continue + } + + if tc.sameDevice && tc.expectedStatusCode != 302 && tc.expectedStatusCode != recorder.Code { + t.Errorf("%s - Expected status %v but was %v.", tc.testName, tc.expectedStatusCode, recorder.Code) + continue + } + + if tc.sameDevice { + location := recorder.Result().Header.Get("Location") + if location != tc.expectedRedirect { + t.Errorf("%s - Expected location %s but was %s.", tc.testName, tc.expectedRedirect, location) + continue + } + continue + } + + if recorder.Code != tc.expectedStatusCode { + t.Errorf("%s - Expected status %v but was %v.", tc.testName, tc.expectedStatusCode, recorder.Code) + continue + } + if tc.expectedStatusCode != 200 { + continue + } + + } +} + +func TestVerifierAPIStartSIOP(t *testing.T) { + + logging.Configure(true, "DEBUG", true, []string{}) + + type test struct { + testName string + testState string + testCallback string + testAddress string + mockConnectionString string + mockError error + expectedStatusCode int + expectedConnectionString string + expectedError ErrorMessage + } + + tests := []test{ + {"If all parameters are present, a siop flow should be started.", "my-state", "http://my-callback.org", "http://my-verifier.org", "openid://mockConnectionString", nil, 200, "openid://mockConnectionString", ErrorMessage{}}, + {"If no state is present, a 400 should be returned.", "", "http://my-callback.org", "http://my-verifier.org", "openid://mockConnectionString", nil, 400, "", ErrorMessageNoState}, + {"If no callback is present, a 400 should be returned.", "my-state", "", "http://my-verifier.org", "openid://mockConnectionString", nil, 400, "", ErrorMessageNoCallback}, + {"If the verifier cannot start the flow, a 500 should be returend.", "my-state", "http://my-callback.org", "http://my-verifier.org", "openid://mockConnectionString", errors.New("verifier_failure"), 500, "", ErrorMessageNoState}, + } + + for _, tc := range tests { + + logging.Log().Info("TestVerifierAPIStartSIOP +++++++++++++++++ Running test: ", tc.testName) + + recorder := httptest.NewRecorder() + testContext, _ := gin.CreateTestContext(recorder) + apiVerifier = &mockVerifier{mockConnectionString: tc.mockConnectionString, mockError: tc.mockError} + + testParameters := []string{} + if tc.testState != "" { + testParameters = append(testParameters, "state="+tc.testState) + } + if tc.testCallback != "" { + testParameters = append(testParameters, "client_callback="+tc.testCallback) + } + + testContext.Request, _ = http.NewRequest("GET", tc.testAddress+"/?"+strings.Join(testParameters, "&"), nil) + VerifierAPIStartSIOP(testContext) + + if recorder.Code != tc.expectedStatusCode { + t.Errorf("%s - Expected code %v but was %v.", tc.testName, tc.expectedStatusCode, recorder.Code) + continue + } + if tc.expectedStatusCode == 500 { + // something internal, we dont care about the details + continue + } + + if tc.expectedStatusCode == 400 { + errorBody, _ := ioutil.ReadAll(recorder.Body) + errorMessage := ErrorMessage{} + json.Unmarshal(errorBody, &errorMessage) + if errorMessage != tc.expectedError { + t.Errorf("%s - Expected error %s but was %s.", tc.testName, logging.PrettyPrintObject(tc.expectedError), logging.PrettyPrintObject(errorMessage)) + continue + } + continue + } + body, _ := ioutil.ReadAll(recorder.Body) + connectionString := string(body) + if connectionString != tc.expectedConnectionString { + t.Errorf("%s - Expected connectionString %s but was %s.", tc.testName, tc.expectedConnectionString, connectionString) + } + } +} + +func getValidVPToken() string { + return "ewogICJAY29udGV4dCI6IFsKICAgICJodHRwczovL3d3dy53My5vcmcvMjAxOC9jcmVkZW50aWFscy92MSIKICBdLAogICJ0eXBlIjogWwogICAgIlZlcmlmaWFibGVQcmVzZW50YXRpb24iCiAgXSwKICAidmVyaWZpYWJsZUNyZWRlbnRpYWwiOiBbCiAgICB7CiAgICAgICJ0eXBlcyI6IFsKICAgICAgICAiUGFja2V0RGVsaXZlcnlTZXJ2aWNlIiwKICAgICAgICAiVmVyaWZpYWJsZUNyZWRlbnRpYWwiCiAgICAgIF0sCiAgICAgICJAY29udGV4dCI6IFsKICAgICAgICAiaHR0cHM6Ly93d3cudzMub3JnLzIwMTgvY3JlZGVudGlhbHMvdjEiLAogICAgICAgICJodHRwczovL3czaWQub3JnL3NlY3VyaXR5L3N1aXRlcy9qd3MtMjAyMC92MSIKICAgICAgXSwKICAgICAgImNyZWRlbnRpYWxzU3ViamVjdCI6IHt9LAogICAgICAiYWRkaXRpb25hbFByb3AxIjoge30KICAgIH0KICBdLAogICJpZCI6ICJlYmM2ZjFjMiIsCiAgImhvbGRlciI6ICJkaWQ6a2V5Ono2TWtzOW05aWZMd3kzSldxSDRjNTdFYkJRVlMyU3BSQ2pmYTc5d0hiNXZXTTZ2aCIsCiAgInByb29mIjogewogICAgInR5cGUiOiAiSnNvbldlYlNpZ25hdHVyZTIwMjAiLAogICAgImNyZWF0b3IiOiAiZGlkOmtleTp6Nk1rczltOWlmTHd5M0pXcUg0YzU3RWJCUVZTMlNwUkNqZmE3OXdIYjV2V002dmgiLAogICAgImNyZWF0ZWQiOiAiMjAyMy0wMS0wNlQwNzo1MTozNloiLAogICAgInZlcmlmaWNhdGlvbk1ldGhvZCI6ICJkaWQ6a2V5Ono2TWtzOW05aWZMd3kzSldxSDRjNTdFYkJRVlMyU3BSQ2pmYTc5d0hiNXZXTTZ2aCN6Nk1rczltOWlmTHd5M0pXcUg0YzU3RWJCUVZTMlNwUkNqZmE3OXdIYjV2V002dmgiLAogICAgImp3cyI6ICJleUppTmpRaU9tWmhiSE5sTENKamNtbDBJanBiSW1JMk5DSmRMQ0poYkdjaU9pSkZaRVJUUVNKOS4uNnhTcW9aamEwTndqRjBhZjlaa25xeDNDYmg5R0VOdW5CZjlDOHVMMnVsR2Z3dXMzVUZNX1puaFBqV3RIUGwtNzJFOXAzQlQ1ZjJwdFpvWWt0TUtwREEiCiAgfQp9" +} + +func getNoVCVPToken() string { + return "ewogICJAY29udGV4dCI6IFsKICAgICJodHRwczovL3d3dy53My5vcmcvMjAxOC9jcmVkZW50aWFscy92MSIKICBdLAogICJ0eXBlIjogWwogICAgIlZlcmlmaWFibGVQcmVzZW50YXRpb24iCiAgXSwKICAiaWQiOiAiZWJjNmYxYzIiLAogICJob2xkZXIiOiB7CiAgICAiaWQiOiAiZGlkOmtleTp6Nk1rczltOWlmTHd5M0pXcUg0YzU3RWJCUVZTMlNwUkNqZmE3OXdIYjV2V002dmgiCiAgfSwKICAicHJvb2YiOiB7CiAgICAidHlwZSI6ICJKc29uV2ViU2lnbmF0dXJlMjAyMCIsCiAgICAiY3JlYXRvciI6ICJkaWQ6a2V5Ono2TWtzOW05aWZMd3kzSldxSDRjNTdFYkJRVlMyU3BSQ2pmYTc5d0hiNXZXTTZ2aCIsCiAgICAiY3JlYXRlZCI6ICIyMDIzLTAxLTA2VDA3OjUxOjM2WiIsCiAgICAidmVyaWZpY2F0aW9uTWV0aG9kIjogImRpZDprZXk6ejZNa3M5bTlpZkx3eTNKV3FINGM1N0ViQlFWUzJTcFJDamZhNzl3SGI1dldNNnZoI3o2TWtzOW05aWZMd3kzSldxSDRjNTdFYkJRVlMyU3BSQ2pmYTc5d0hiNXZXTTZ2aCIsCiAgICAiandzIjogImV5SmlOalFpT21aaGJITmxMQ0pqY21sMElqcGJJbUkyTkNKZExDSmhiR2NpT2lKRlpFUlRRU0o5Li42eFNxb1pqYTBOd2pGMGFmOVprbnF4M0NiaDlHRU51bkJmOUM4dUwydWxHZnd1czNVRk1fWm5oUGpXdEhQbC03MkU5cDNCVDVmMnB0Wm9Za3RNS3BEQSIKICB9Cn0" +} + +func getNoHolderVPToken() string { + return "ewogICJAY29udGV4dCI6IFsKICAgICJodHRwczovL3d3dy53My5vcmcvMjAxOC9jcmVkZW50aWFscy92MSIKICBdLAogICJ0eXBlIjogWwogICAgIlZlcmlmaWFibGVQcmVzZW50YXRpb24iCiAgXSwKICAidmVyaWZpYWJsZUNyZWRlbnRpYWwiOiBbCiAgICB7CiAgICAgICJ0eXBlcyI6IFsKICAgICAgICAiUGFja2V0RGVsaXZlcnlTZXJ2aWNlIiwKICAgICAgICAiVmVyaWZpYWJsZUNyZWRlbnRpYWwiCiAgICAgIF0sCiAgICAgICJAY29udGV4dCI6IFsKICAgICAgICAiaHR0cHM6Ly93d3cudzMub3JnLzIwMTgvY3JlZGVudGlhbHMvdjEiLAogICAgICAgICJodHRwczovL3czaWQub3JnL3NlY3VyaXR5L3N1aXRlcy9qd3MtMjAyMC92MSIKICAgICAgXSwKICAgICAgImNyZWRlbnRpYWxzU3ViamVjdCI6IHt9LAogICAgICAiYWRkaXRpb25hbFByb3AxIjoge30KICAgIH0KICBdLAogICJpZCI6ICJlYmM2ZjFjMiIsCiAgImhvbGRlciI6IHsKICAgICJub3RhIjogImhvbGRlciIKICB9LAogICJwcm9vZiI6IHsKICAgICJ0eXBlIjogIkpzb25XZWJTaWduYXR1cmUyMDIwIiwKICAgICJjcmVhdG9yIjogImRpZDprZXk6ejZNa3M5bTlpZkx3eTNKV3FINGM1N0ViQlFWUzJTcFJDamZhNzl3SGI1dldNNnZoIiwKICAgICJjcmVhdGVkIjogIjIwMjMtMDEtMDZUMDc6NTE6MzZaIiwKICAgICJ2ZXJpZmljYXRpb25NZXRob2QiOiAiZGlkOmtleTp6Nk1rczltOWlmTHd5M0pXcUg0YzU3RWJCUVZTMlNwUkNqZmE3OXdIYjV2V002dmgjejZNa3M5bTlpZkx3eTNKV3FINGM1N0ViQlFWUzJTcFJDamZhNzl3SGI1dldNNnZoIiwKICAgICJqd3MiOiAiZXlKaU5qUWlPbVpoYkhObExDSmpjbWwwSWpwYkltSTJOQ0pkTENKaGJHY2lPaUpGWkVSVFFTSjkuLjZ4U3FvWmphME53akYwYWY5WmtucXgzQ2JoOUdFTnVuQmY5Qzh1TDJ1bEdmd3VzM1VGTV9abmhQald0SFBsLTcyRTlwM0JUNWYycHRab1lrdE1LcERBIgogIH0KfQ" +} diff --git a/openapi/api_frontend.go b/openapi/api_frontend.go new file mode 100644 index 00000000..3f1cf610 --- /dev/null +++ b/openapi/api_frontend.go @@ -0,0 +1,56 @@ +/* + * vcverifier + * + * Backend component to verify credentials + * + * API version: 0.0.1 + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package openapi + +import ( + "fiware/VCVerifier/verifier" + "net/http" + + "github.com/gin-gonic/gin" +) + +var frontendVerifier verifier.Verifier + +func getFrontendVerifier() verifier.Verifier { + if frontendVerifier == nil { + frontendVerifier = verifier.GetVerifier() + } + return frontendVerifier +} + +// VerifierPageDisplayQRSIOP - Presents a qr as starting point for the auth process +func VerifierPageDisplayQRSIOP(c *gin.Context) { + + state, stateExists := c.GetQuery("state") + if !stateExists { + c.AbortWithStatusJSON(400, ErrorMessageNoState) + // early exit + return + } + + callback, callbackExists := c.GetQuery("client_callback") + if !callbackExists { + c.AbortWithStatusJSON(400, ErrorMessageNoCallback) + // early exit + return + } + + qr, err := getFrontendVerifier().ReturnLoginQR(c.Request.Host, "https", callback, state) + if err != nil { + c.AbortWithStatusJSON(500, ErrorMessage{"qr_generation_error", err.Error()}) + return + } + c.HTML(http.StatusOK, "verifier_present_qr.html", gin.H{"qrcode": qr}) +} + +// VerifierPageLoginExpired - Presents a page when the login session is expired +func VerifierPageLoginExpired(c *gin.Context) { + c.JSON(http.StatusOK, gin.H{}) +} diff --git a/openapi/api_frontend_test.go b/openapi/api_frontend_test.go new file mode 100644 index 00000000..82c69617 --- /dev/null +++ b/openapi/api_frontend_test.go @@ -0,0 +1,81 @@ +package openapi + +import ( + "encoding/json" + "errors" + "fiware/VCVerifier/logging" + "io/ioutil" + "net/http" + "net/http/httptest" + "strings" + "testing" + + "github.com/foolin/goview/supports/ginview" + "github.com/gin-gonic/gin" +) + +func TestVerifierPageDisplayQRSIOP(t *testing.T) { + + logging.Configure(true, "DEBUG", true, []string{}) + + type test struct { + testName string + testState string + testCallback string + testAddress string + mockQR string + mockError error + expectedStatusCode int + expectedError ErrorMessage + } + + tests := []test{ + {"If all parameters are present, a siop flow should be started.", "my-state", "http://my-callback.org", "http://my-verifier.org", "openid://mockConnectionString", nil, 200, ErrorMessage{}}, + {"If no state is present, a 400 should be returned.", "", "http://my-callback.org", "http://my-verifier.org", "openid://mockConnectionString", nil, 400, ErrorMessageNoState}, + {"If no callback is present, a 400 should be returned.", "my-state", "", "http://my-verifier.org", "openid://mockConnectionString", nil, 400, ErrorMessageNoCallback}, + {"If the verifier cannot start the flow, a 500 should be returend.", "my-state", "http://my-callback.org", "http://my-verifier.org", "openid://mockConnectionString", errors.New("verifier_failure"), 500, ErrorMessageNoState}, + } + + for _, tc := range tests { + + logging.Log().Info("TestVerifierPageDisplayQRSIOP +++++++++++++++++ Running test: ", tc.testName) + + recorder := httptest.NewRecorder() + testContext, engine := gin.CreateTestContext(recorder) + + engine.HTMLRender = ginview.Default() + + frontendVerifier = &mockVerifier{mockQR: tc.mockQR, mockError: tc.mockError} + + testParameters := []string{} + if tc.testState != "" { + testParameters = append(testParameters, "state="+tc.testState) + } + if tc.testCallback != "" { + testParameters = append(testParameters, "client_callback="+tc.testCallback) + } + + testContext.Request, _ = http.NewRequest("GET", tc.testAddress+"/?"+strings.Join(testParameters, "&"), nil) + VerifierPageDisplayQRSIOP(testContext) + + if recorder.Code != tc.expectedStatusCode { + t.Errorf("%s - Expected code %v but was %v.", tc.testName, tc.expectedStatusCode, recorder.Code) + continue + } + if tc.expectedStatusCode == 500 { + // something internal, we dont care about the details + continue + } + + if tc.expectedStatusCode == 400 { + errorBody, _ := ioutil.ReadAll(recorder.Body) + errorMessage := ErrorMessage{} + json.Unmarshal(errorBody, &errorMessage) + if errorMessage != tc.expectedError { + t.Errorf("%s - Expected error %s but was %s.", tc.testName, logging.PrettyPrintObject(tc.expectedError), logging.PrettyPrintObject(errorMessage)) + continue + } + continue + } + } +} diff --git a/openapi/model_backend_info.go b/openapi/model_backend_info.go new file mode 100644 index 00000000..8cb759b9 --- /dev/null +++ b/openapi/model_backend_info.go @@ -0,0 +1,17 @@ +/* + * vcverifier + * + * Backend component to verify credentials + * + * API version: 0.0.1 + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package openapi + +type BackendInfo struct { + + IssuerDid Did `json:"issuerDid,omitempty"` + + VerifierDid Did `json:"verifierDid,omitempty"` +} diff --git a/openapi/model_credential_schema.go b/openapi/model_credential_schema.go new file mode 100644 index 00000000..50c948fb --- /dev/null +++ b/openapi/model_credential_schema.go @@ -0,0 +1,17 @@ +/* + * vcverifier + * + * Backend component to verify credentials + * + * API version: 0.0.1 + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package openapi + +type CredentialSchema struct { + + Id string `json:"id,omitempty"` + + Type string `json:"type,omitempty"` +} diff --git a/openapi/model_did.go b/openapi/model_did.go new file mode 100644 index 00000000..457e5e5b --- /dev/null +++ b/openapi/model_did.go @@ -0,0 +1,15 @@ +/* + * vcverifier + * + * Backend component to verify credentials + * + * API version: 0.0.1 + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package openapi + +type Did struct { + + Id string `json:"id,omitempty"` +} diff --git a/openapi/model_error_message.go b/openapi/model_error_message.go new file mode 100644 index 00000000..8fec55d9 --- /dev/null +++ b/openapi/model_error_message.go @@ -0,0 +1,17 @@ +/* + * vcverifier + * + * Backend component to verify credentials + * + * API version: 0.0.1 + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package openapi + +type ErrorMessage struct { + + Summary string `json:"summary,omitempty"` + + Details string `json:"details,omitempty"` +} diff --git a/openapi/model_jwk.go b/openapi/model_jwk.go new file mode 100644 index 00000000..4f7e79db --- /dev/null +++ b/openapi/model_jwk.go @@ -0,0 +1,33 @@ +/* + * vcverifier + * + * Backend component to verify credentials + * + * API version: 0.0.1 + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package openapi + +type Jwk struct { + + Kid string `json:"kid,omitempty"` + + Kty string `json:"kty,omitempty"` + + Use string `json:"use,omitempty"` + + Alg string `json:"alg,omitempty"` + + Crv string `json:"crv,omitempty"` + + X string `json:"x,omitempty"` + + Y string `json:"y,omitempty"` + + N string `json:"n,omitempty"` + + E string `json:"e,omitempty"` + + D string `json:"d,omitempty"` +} diff --git a/openapi/model_jwk_set.go b/openapi/model_jwk_set.go new file mode 100644 index 00000000..afc4393a --- /dev/null +++ b/openapi/model_jwk_set.go @@ -0,0 +1,15 @@ +/* + * vcverifier + * + * Backend component to verify credentials + * + * API version: 0.0.1 + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package openapi + +type JwkSet struct { + + Keys []Jwk `json:"keys,omitempty"` +} diff --git a/openapi/model_packet_delivery_subject.go b/openapi/model_packet_delivery_subject.go new file mode 100644 index 00000000..8220f20d --- /dev/null +++ b/openapi/model_packet_delivery_subject.go @@ -0,0 +1,23 @@ +/* + * vcverifier + * + * Backend component to verify credentials + * + * API version: 0.0.1 + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package openapi + +type PacketDeliverySubject struct { + + Id string `json:"id,omitempty"` + + FamilyName string `json:"familyName,omitempty"` + + FirstName string `json:"firstName,omitempty"` + + Roles []SubjectRole `json:"roles,omitempty"` + + Email string `json:"email,omitempty"` +} diff --git a/openapi/model_subject_role.go b/openapi/model_subject_role.go new file mode 100644 index 00000000..16db88ea --- /dev/null +++ b/openapi/model_subject_role.go @@ -0,0 +1,17 @@ +/* + * vcverifier + * + * Backend component to verify credentials + * + * API version: 0.0.1 + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package openapi + +type SubjectRole struct { + + Names []string `json:"names,omitempty"` + + Target string `json:"target,omitempty"` +} diff --git a/openapi/model_token_response.go b/openapi/model_token_response.go new file mode 100644 index 00000000..a9a57a56 --- /dev/null +++ b/openapi/model_token_response.go @@ -0,0 +1,19 @@ +/* + * vcverifier + * + * Backend component to verify credentials + * + * API version: 0.0.1 + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package openapi + +type TokenResponse struct { + + TokenType string `json:"token_type,omitempty"` + + ExpiresIn float32 `json:"expires_in,omitempty"` + + AccessToken string `json:"access_token,omitempty"` +} diff --git a/openapi/routers.go b/openapi/routers.go new file mode 100644 index 00000000..7c16acff --- /dev/null +++ b/openapi/routers.go @@ -0,0 +1,110 @@ +/* + * vcverifier + * + * Backend component to verify credentials + * + * API version: 0.0.1 + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package openapi + +import ( + "net/http" + + "github.com/gin-gonic/gin" +) + +// Route is the information for every URI. +type Route struct { + // Name is the name of this Route. + Name string + // Method is the string for the HTTP method. ex) GET, POST etc.. + Method string + // Pattern is the pattern of the URI. + Pattern string + // HandlerFunc is the handler function of this route. + HandlerFunc gin.HandlerFunc +} + +// Routes is the list of the generated Route. +type Routes []Route + +// NewRouter returns a new router. +func NewRouter() *gin.Engine { + router := gin.New() + + for _, route := range routes { + switch route.Method { + case http.MethodGet: + router.GET(route.Pattern, route.HandlerFunc) + case http.MethodPost: + router.POST(route.Pattern, route.HandlerFunc) + case http.MethodPut: + router.PUT(route.Pattern, route.HandlerFunc) + case http.MethodPatch: + router.PATCH(route.Pattern, route.HandlerFunc) + case http.MethodDelete: + router.DELETE(route.Pattern, route.HandlerFunc) + } + } + + return router +} + +// Index is the index handler. +func Index(c *gin.Context) { + c.String(http.StatusOK, "Hello World!") +} + +var routes = Routes{ + + { + "GetToken", + http.MethodPost, + "/token", + GetToken, + }, + + { + "StartSIOPSameDevice", + http.MethodGet, + "/api/v1/samedevice", + StartSIOPSameDevice, + }, + + { + "VerifierAPIAuthenticationResponse", + http.MethodPost, + "/api/v1/authentication_response", + VerifierAPIAuthenticationResponse, + }, + + { + "GetVerifierAPIAuthenticationResponse", + http.MethodGet, + "/api/v1/authentication_response", + GetVerifierAPIAuthenticationResponse, + }, + + { + "VerifierAPIJWKS", + http.MethodGet, + "/.well-known/jwks", + VerifierAPIJWKS, + }, + + { + "VerifierAPIStartSIOP", + http.MethodGet, + "/api/v1/startsiop", + VerifierAPIStartSIOP, + }, + + { + "VerifierPageDisplayQRSIOP", + http.MethodGet, + "/api/v1/loginQR", + VerifierPageDisplayQRSIOP, + }, +} diff --git a/server.yaml b/server.yaml new file mode 100644 index 00000000..f9282d9c --- /dev/null +++ b/server.yaml @@ -0,0 +1,12 @@ +server: + port: 8080 + logging: + jsonLogging: true + logRequests: true + +verifier: + tirAddress: https://tir.de + did: did:key:myverifier + +ssiKit: + auditorURL: http://my-auditor \ No newline at end of file diff --git a/ssikit/ssikit.go b/ssikit/ssikit.go new file mode 100644 index 00000000..bd779461 --- /dev/null +++ b/ssikit/ssikit.go @@ -0,0 +1,125 @@ +package ssikit + +import ( + "bytes" + "encoding/json" + "errors" + configModel "fiware/VCVerifier/config" + "fiware/VCVerifier/logging" + "net/http" + + client "github.com/fiware/dsba-pdp/http" +) + +const verificationPath = "/v1/verify" + +var ErrorSSIKitNoResponse = errors.New("no_response_from_ssikit") +var ErrorNoAuditorConfigured = errors.New("no_auditor_configured") + +// http client to be used +var httpClient = client.HttpClient() + +// configuration object for the ssikit client connection(s) +type SSIKitClient struct { + auditorAddress string +} + +// Policy object as defined by waltId +type Policy struct { + Policy string `json:"policy"` + Argument *TirArgument `json:"argument,omitempty"` +} + +// TrustedIssuerRegistry Policy Argument - has to be provided to waltId +type TirArgument struct { + RegistryAddress string `json:"registryAddress"` +} + +// request structure for validating VCs at waltId +type verificationRequest struct { + Policies []Policy `json:"policies"` + Credentials []map[string]interface{} `json:"credentials"` +} + +// result of the individual policy +type verificationResult struct { + Valid bool `json:"valid"` + PolicyResults map[string]bool `json:"policyResults"` +} + +// response structure from the verification request +type verificationResponse struct { + Valid bool `json:"valid"` + Results []verificationResult `json:"results"` +} + +type SSIKit interface { + VerifyVC(policies []Policy, verifiableCredential map[string]interface{}) (result bool, err error) +} + +/** +* Create a new SSIKit client from the configuration +**/ +func NewSSIKitClient(config *configModel.SSIKit) (client *SSIKitClient, err error) { + if config.AuditorURL == "" { + return client, ErrorNoAuditorConfigured + } + return &SSIKitClient{config.AuditorURL}, err +} + +/** +* Verify the given credentials at the walt against the provided policies +**/ +func (s *SSIKitClient) VerifyVC(policies []Policy, verifiableCredential map[string]interface{}) (result bool, err error) { + + logging.Log().Debugf("Verify credential %s", logging.PrettyPrintObject(verifiableCredential)) + auditorAddress := s.auditorAddress + verificationPath + + // prepare the request + verificationRequest := verificationRequest{policies, []map[string]interface{}{verifiableCredential}} + jsonBody, err := json.Marshal(verificationRequest) + if err != nil { + logging.Log().Warnf("Was not able to marshal verification request body. Err: %v", err) + return false, err + } + verificationHttpRequest, err := http.NewRequest("POST", auditorAddress, bytes.NewReader(jsonBody)) + if err != nil { + logging.Log().Warnf("Was not able to create verification request. Err: %v", err) + return false, err + } + verificationHttpRequest.Header.Set("Content-Type", "application/json") + verificationHttpRequest.Header.Set("accept", "application/json") + verificationHttpResponse, err := httpClient.Do(verificationHttpRequest) + + // evaluate the results + if err != nil { + logging.Log().Warnf("Did not receive a valid verification response. Err: %v", err) + return false, err + } + if verificationHttpResponse == nil { + logging.Log().Warn("Did not receive any response from ssikit.") + return false, ErrorSSIKitNoResponse + } + if verificationHttpResponse.StatusCode != 200 { + logging.Log().Infof("Did not receive an ok from the verifier. Was %s", logging.PrettyPrintObject(verificationHttpResponse)) + return false, err + } + if verificationHttpResponse.Body == nil { + logging.Log().Info("Received an empty body on the verification.") + return false, err + } + var verficationResponse verificationResponse + + err = json.NewDecoder(verificationHttpResponse.Body).Decode(&verficationResponse) + if err != nil { + logging.Log().Warn("Was not able to decode the verification response.") + return false, err + } + if verficationResponse.Valid { + return true, err + } else { + logging.Log().Info("Verfication failed.") + logging.Log().Debugf("Detailed result is %v", logging.PrettyPrintObject(verficationResponse)) + return false, err + } +} diff --git a/ssikit/ssikit_test.go b/ssikit/ssikit_test.go new file mode 100644 index 00000000..a2aa87f5 --- /dev/null +++ b/ssikit/ssikit_test.go @@ -0,0 +1,129 @@ +package ssikit + +import ( + "bytes" + "encoding/json" + "errors" + configModel "fiware/VCVerifier/config" + "fiware/VCVerifier/logging" + "io" + "net/http" + "net/url" + "testing" +) + +func TestNewSSIKitClient(t *testing.T) { + + logging.Configure(true, "DEBUG", true, []string{}) + type test struct { + testName string + testConfig configModel.SSIKit + expectedError error + } + + tests := []test{ + {"If a valid config is provided, a client should be returned.", configModel.SSIKit{AuditorURL: "http://my-walt.org/auditor"}, nil}, + {"If no auditor is configured, an error should be returned.", configModel.SSIKit{}, ErrorNoAuditorConfigured}, + } + + for _, tc := range tests { + + logging.Log().Info("TestNewSSIKitClient +++++++++++++++++ Running test: ", tc.testName) + + client, err := NewSSIKitClient(&tc.testConfig) + if tc.expectedError != err { + t.Errorf("%s - Expected error %v but was %v.", tc.testName, tc.expectedError, err) + } + if tc.expectedError != nil { + continue + } + + if client == nil { + t.Errorf("%s - A new client should have been created.", tc.testName) + } + } + +} + +func TestVerifyVC(t *testing.T) { + + logging.Configure(true, "DEBUG", true, []string{}) + + type test struct { + testName string + testPolicies []Policy + testVC map[string]interface{} + ssiKitResponse *http.Response + ssiKitError error + expectedResult bool + expectedError error + } + + waltIdError := errors.New("walt_failure") + + tests := []test{ + + {"A verifiable credential should be successfully validated.", []Policy{{"MyPolicy", nil}}, getVC("vc"), getVRResponse(verificationResponse{Valid: true}), nil, true, nil}, + {"If walt responds an error, the validation should fail.", []Policy{{"MyPolicy", nil}}, getVC("vc"), nil, waltIdError, false, waltIdError}, + {"If walt does not respond, the validation should fail.", []Policy{{"MyPolicy", nil}}, getVC("vc"), nil, nil, false, ErrorSSIKitNoResponse}, + {"If walt does not respond ok, the validation should fail.", []Policy{{"MyPolicy", nil}}, getVC("vc"), &http.Response{StatusCode: 204}, nil, false, nil}, + {"If walt does not respond with a body, the validation should fail.", []Policy{{"MyPolicy", nil}}, getVC("vc"), &http.Response{StatusCode: 200}, nil, false, nil}, + {"If walt does not respond with a valid body, the validation should fail.", []Policy{{"MyPolicy", nil}}, getVC("vc"), getInvalidResponse(), nil, false, nil}, + {"If walt does respond that the VC is invalid, the validation should fail.", []Policy{{"MyPolicy", nil}}, getVC("vc"), getVRResponse(verificationResponse{Valid: false}), nil, false, nil}, + } + + for _, tc := range tests { + + logging.Log().Info("TestVerifyVC +++++++++++++++++ Running test: ", tc.testName) + + httpClient = mockHttpClient{tc.ssiKitError, tc.ssiKitResponse} + ssiKitClient := SSIKitClient{auditorAddress: "http://auditor.org"} + ssiKitClient.VerifyVC(tc.testPolicies, tc.testVC) + } +} + +func getVRResponse(vr verificationResponse) *http.Response { + d, _ := json.Marshal(vr) + return &http.Response{Status: "200 ok", StatusCode: 200, Body: io.NopCloser(bytes.NewReader(d))} +} + +func getInvalidResponse() *http.Response { + return &http.Response{Status: "200 ok", StatusCode: 200, Body: io.NopCloser(bytes.NewReader([]byte("something")))} + +} + +type mockHttpClient struct { + err error + response *http.Response +} + +func (mhc mockHttpClient) Do(req *http.Request) (r *http.Response, err error) { + return mhc.response, mhc.err +} + +func (mhc mockHttpClient) PostForm(url string, data url.Values) (r *http.Response, err error) { + // not used + return +} + +func getVC(id string) map[string]interface{} { + return map[string]interface{}{ + "@context": []string{ + "https://www.w3.org/2018/credentials/v1", + "https://happypets.fiware.io/2022/credentials/employee/v1", + }, + "id": "https://happypets.fiware.io/credential/25159389-8dd17b796ac0", + "type": []string{ + "VerifiableCredential", + "CustomerCredential", + }, + "issuer": "did:key:verifier", + "issuanceDate": "2022-11-23T15:23:13Z", + "validFrom": "2022-11-23T15:23:13Z", + "expirationDate": "2032-11-23T15:23:13Z", + "credentialSubject": map[string]interface{}{ + "id": id, + "target": "did:ebsi:packetdelivery", + }, + } +} diff --git a/vault/accesstoken.go b/vault/accesstoken.go deleted file mode 100644 index bd30ab71..00000000 --- a/vault/accesstoken.go +++ /dev/null @@ -1,56 +0,0 @@ -package vault - -import ( - "encoding/json" - "fmt" - - "github.com/hesusruiz/vcutils/yaml" - zlog "github.com/rs/zerolog/log" -) - -// CreateAccessToken creates a JWT access token from the credential in serialized form, -// signed with the first private key associated to the issuer DID -func (v *Vault) CreateAccessToken(credData string, issuerDID string) (json.RawMessage, error) { - - // Return error if the issuerDID does not exist - iss, err := v.UserByID(issuerDID) - if err != nil { - return nil, err - } - if iss == nil { - return nil, fmt.Errorf("user does not exist") - } - - // Get the first private key of the issuer to make the signature - jwks, err := v.PrivateKeysForUser(issuerDID) - if err != nil { - return nil, err - } - - // At this point, jwks has at least one key, get the first one - privateJWK := jwks[0] - - // Parse the serialized credential into a struct - data, err := yaml.ParseJson(credData) - if err != nil { - zlog.Logger.Error().Err(err).Send() - return nil, err - } - - jwt := map[string]any{"verifiableCredential": data.Data()} - - // Sign the credential data with the private key - signedString, err := v.SignWithJWK(privateJWK, jwt) - if err != nil { - return nil, err - } - - _, err = v.CredentialFromJWT(signedString) - if err != nil { - zlog.Logger.Error().Err(err).Send() - return nil, err - } - - return []byte(signedString), nil - -} diff --git a/vault/credential.go b/vault/credential.go deleted file mode 100644 index a521b788..00000000 --- a/vault/credential.go +++ /dev/null @@ -1,289 +0,0 @@ -package vault - -import ( - "bytes" - "context" - "encoding/json" - "fmt" - "text/template" - - "github.com/Masterminds/sprig/v3" - "github.com/fiware/vcverifier/ent" - "github.com/fiware/vcverifier/internal/jwk" - "github.com/fiware/vcverifier/internal/jwt" - "github.com/google/uuid" - "github.com/hesusruiz/vcutils/yaml" - zlog "github.com/rs/zerolog/log" - "github.com/tidwall/gjson" -) - -type CredentialData struct { - Jti string `json:"jti" yaml:"jti"` - CredName string `json:"cred_name"` - IssuerDID string `json:"iss"` - SubjectDID string `json:"did"` - Name string `json:"name"` - Given_name string `json:"given_name"` - Family_name string `json:"family_name"` - Preferred_username string `json:"preferred_username"` - Email string `json:"email"` -} - -var t *template.Template - -func init() { - - t = template.Must(template.New("base").Funcs(sprig.TxtFuncMap()).ParseGlob("vault/templates/*.tpl")) - -} - -func (v *Vault) TestCred(credData *CredentialData) (rawJsonCred json.RawMessage, err error) { - - // Generate the id as a UUID - jti, err := uuid.NewRandom() - if err != nil { - return nil, err - } - - // Set the unique id in the credential - credData.Jti = jti.String() - - // Generate the credential from the template - var b bytes.Buffer - err = t.ExecuteTemplate(&b, credData.CredName, credData) - if err != nil { - return nil, err - } - - // The serialized credential - rawJsonCred = b.Bytes() - - // Validate the generated JSON, just in case the template is malformed - if !gjson.ValidBytes(b.Bytes()) { - zlog.Error().Msg("Error validating JSON") - return nil, nil - } - m, ok := gjson.ParseBytes(b.Bytes()).Value().(map[string]interface{}) - if !ok { - return nil, nil - } - - rj, err := json.Marshal(m) - if err != nil { - return nil, err - } - - zlog.Info().Msgf("Value: %T\n\n%v", rj, string(rj)) - - // cc := make(map[string]any) - - return nil, nil - -} - -// CreateCredentialJWTFromMap receives a map with the hierarchical data of the credential and returns -// the id of a new credential and the raw JWT string representing the credential -func (v *Vault) CreateCredentialJWTFromMap(credmap map[string]any) (credID string, rawJSONCred json.RawMessage, err error) { - - credData := yaml.New(credmap) - - // Return error if the issuer does not exist - issuer := credData.String("issuerDID") - iss, err := v.UserByID(issuer) - if err != nil { - return "", nil, err - } - if iss == nil { - return "", nil, fmt.Errorf("user does not exist") - } - - // Get the private key of the issuer. If not specified, get the first one - var privateJWK *jwk.JWK - if keyID := credData.String("issuerKeyID"); len(keyID) > 0 { - - // KeyID specified, try to get it from the store - privateJWK, err = v.PrivateKeyByID(keyID) - if err != nil { - return "", nil, err - } - - } else { - - // KeyID was not specified, look for the first key of the user - jwks, err := v.PrivateKeysForUser(issuer) - if err != nil { - return "", nil, err - } - - // jwks has at least one key, get the first one - privateJWK = jwks[0] - } - - // Generate a credential ID (jti) if it was not specified in the input data - if len(credData.String("jti")) == 0 { - - // Generate the id as a UUID - jti, err := uuid.NewRandom() - if err != nil { - return "", nil, err - } - - // Set the unique id in the credential - credmap["jti"] = jti.String() - - } - - credentialID := credmap["jti"].(string) - - // Generate the credential from the template - var b bytes.Buffer - err = t.ExecuteTemplate(&b, credData.String("credName"), credmap) - if err != nil { - zlog.Logger.Error().Err(err).Send() - return "", nil, err - } - - // The serialized credential - fmt.Println("**** Serialized Credential ****") - rawJSONCred = b.Bytes() - fmt.Printf("%v\n\n", string(rawJSONCred)) - fmt.Println("**** End Serialized Credential ****") - - // Parse the resulting byte string - data, err := yaml.ParseYamlBytes(rawJSONCred) - if err != nil { - zlog.Logger.Error().Err(err).Send() - return "", nil, err - } - - // Sign the credential data with the private key - signedString, err := v.SignWithJWK(privateJWK, data.Data()) - if err != nil { - return "", nil, err - } - - _, err = v.CredentialFromJWT(signedString) - if err != nil { - zlog.Logger.Error().Err(err).Send() - return "", nil, err - } - - // Store credential - _, err = v.Client.Credential.Create(). - SetID(credentialID). - SetRaw([]uint8(signedString)). - Save(context.Background()) - if err != nil { - zlog.Logger.Error().Err(err).Send() - return "", nil, err - } - - return credentialID, []byte(signedString), nil - -} - -type CredRawData struct { - Id string `json:"id,omitempty"` - Type string `json:"type,omitempty"` - Encoded string `json:"encoded,omitempty"` -} - -func (v *Vault) GetAllCredentials() (creds []*CredRawData) { - - entCredentials, err := v.Client.Credential.Query().All(context.Background()) - if err != nil { - return nil - } - - credentials := make([]*CredRawData, len(entCredentials)) - - for i, cred := range entCredentials { - cr := &CredRawData{} - cr.Id = cred.ID - cr.Type = cred.Type - cr.Encoded = string(cred.Raw) - credentials[i] = cr - } - - return credentials - -} - -func (v *Vault) CreateOrGetCredential(credData *CredentialData) (rawJsonCred json.RawMessage, err error) { - - // Check if the credential already exists - cred, err := v.Client.Credential.Get(context.Background(), credData.Jti) - if err == nil { - // Credential found, just return it - return cred.Raw, nil - } - if !ent.IsNotFound(err) { - // Continue only if the error was that the credential was not found - return nil, err - } - - // Generate the credential from the template - var b bytes.Buffer - err = t.ExecuteTemplate(&b, credData.CredName, credData) - if err != nil { - return nil, err - } - - // The serialized credential - rawJsonCred = b.Bytes() - - // Store in DB - _, err = v.Client.Credential. - Create(). - SetID(credData.Jti). - SetRaw(rawJsonCred). - Save(context.Background()) - if err != nil { - zlog.Error().Err(err).Msg("failed storing credential") - return nil, err - } - zlog.Info().Str("jti", credData.Jti).Msg("credential created") - - return rawJsonCred, nil - -} - -type CredentialDecoded struct { - jwt.RegisteredClaims - Other map[string]any -} - -func (v *Vault) CredentialFromJWT(credSerialized string) (rawJsonCred json.RawMessage, err error) { - - cred := &CredentialDecoded{} - - // Parse the serialized string into the structure, no signature validation yet - token, err := jwt.NewParser().ParseUnverified2(credSerialized, cred) - if err != nil { - zlog.Logger.Error().Err(err).Send() - return nil, err - } - - // // Enable for Debugging - // zlog.Debug().Msg("Parsed Token") - // if out, err := json.MarshalIndent(token, "", " "); err == nil { - // zlog.Debug().Msg(string(out)) - // } - - // Verify the signature - err = v.VerifySignature(token.ToBeSignedString, token.Signature, token.Alg(), token.Kid()) - if err != nil { - zlog.Logger.Error().Err(err).Send() - return nil, err - } - - // Display the formatted JSON structure - st := map[string]any{} - json.Unmarshal(token.ClaimBytes, &st) - if out, err := json.MarshalIndent(st, "", " "); err == nil { - zlog.Debug().Msg(string(out)) - } - - return nil, nil - -} diff --git a/vault/templates/PacketDeliveryCredentialYaml.yaml.tpl b/vault/templates/PacketDeliveryCredentialYaml.yaml.tpl deleted file mode 100644 index 6b436906..00000000 --- a/vault/templates/PacketDeliveryCredentialYaml.yaml.tpl +++ /dev/null @@ -1,47 +0,0 @@ -{{define "PacketDeliveryCredential"}} -{{ $now := now | unixEpoch }} - -sub: "{{.subjectDID}}" -jti: "{{.jti}}" -iss: "{{.issuerDID}}" -nbf: "{{ $now }}" -iat: "{{ $now }}" -exp: "{{ add $now 10000 }}" -nonce: "{{ randBytes 12 }}" -vc: - @context: - - "https://www.w3.org/2018/credentials/v1" - - "https://pd.i4trust.fiware.io/2022/credentials/employee/v1" - id: "{{.jti}}" - type: ["VerifiableCredential", "{{.credName}}"] - issuer: "{{.issuerDID}}" - issuanceDate: "{{ $now }}" - - credentialSubject: - id: "{{.subjectDID}}" - given_name: "{{.claims.given_name}}" - family_name: "{{.claims.family_name}}" - email: "{{.claims.email}}" - roles: - {{- range .claims.roles}} - - target: {{.target}} - names: - {{- range .names}} - - {{.}} - {{- end}} - {{- end}} - {{with .verificationMethod}} - verificationMethod: - {{range .verificationMethod}} - - id: "{{.subjectDID}}#{{.publicKey.kid}}" - type: "JwsVerificationKey2020" - controller: "{{.subjectDID}}" - publicKeyJwk: - kid: "{{.publicKey.kid}}" - kty: "{{.publicKey.kty}}" - crv: "{{.publicKey.crv}}" - x: "{{.publicKey.x}}" - y: "{{.publicKey.y}}" - {{end}} - {{end}} -{{end}} \ No newline at end of file diff --git a/vault/templates/customer_credential.tpl b/vault/templates/customer_credential.tpl deleted file mode 100644 index 5eee9ba6..00000000 --- a/vault/templates/customer_credential.tpl +++ /dev/null @@ -1,51 +0,0 @@ -{{define "customervp"}} -{ - "iss": "{{.IssuerDID}}", - "sub": "{{.SubjectDID}}", - "exp": "2023-03-22T14:00:00Z", - "nbf": "2022-03-22T14:00:00Z", - "jti": "https://pdc.i4trust.fiware.io/credentials/1872", - "vc": { - "@context": [ - "https://www.w3.org/2018/credentials/v1", - "https://marketplace.i4trust.fiware.io/2022/credentials/customer/v1" - ], - "id": "https://pdc.i4trust.fiware.io/credentials/1872", - "type": ["VerifiableCredential", "CustomerCredential"], - "issuer": { - "id": "did:elsi:EU.EORI.NLHAPPYPETS" - }, - "issuanceDate": "2022-03-22T14:00:00Z", - "validFrom": "2022-03-22T14:00:00Z", - "expirationDate": "2023-03-22T14:00:00Z", - "credentialSubject": { - "id": "{{.SubjectDID}}", - "verificationMethod": [ - { - "id": "{{.SubjectDID}}#key1", - "type": "JwsVerificationKey2020", - "controller": "{{.SubjectDID}}", - "publicKeyJwk": { - "kid": "key1", - "kty": "EC", - "crv": "P-256", - "x": "lJtvoA5_XptBvcfcrvtGCvXd9bLymmfBSSdNJf5mogo", - "y": "fSc4gZX2R3QKKfHvS3m2vGSVSN8Xc04qsquyfEM55Z0" - } - } - ], - "roles": [ - { - "target": "did:elsi:EU.EORI.NLPACKETDEL", - "names": ["GoldCustomer"] - } - ], - "name": "{{.Name}}", - "given_name": "{{.Given_name}}", - "family_name": "{{.Family_name}}", - "preferred_username": "{{.Preferred_username}}", - "email": "{{.Email}}" - } - } -} -{{end}} \ No newline at end of file diff --git a/vault/templates/employee_credential copy.tpl b/vault/templates/employee_credential copy.tpl deleted file mode 100644 index 7a63d72a..00000000 --- a/vault/templates/employee_credential copy.tpl +++ /dev/null @@ -1,51 +0,0 @@ -{{define "employeecopy"}} -{ - "iss": "{{.IssuerDID}}", - "sub": "{{.SubjectDID}}", - "exp": "2023-03-22T14:00:00Z", - "nbf": "2022-03-22T14:00:00Z", - "jti": "https://pdc.i4trust.fiware.io/credentials/1872", - "vc": { - "@context": [ - "https://www.w3.org/2018/credentials/v1", - "https://marketplace.i4trust.fiware.io/2022/credentials/employee/v1" - ], - "id": "https://pdc.i4trust.fiware.io/credentials/1872", - "type": ["VerifiableCredential", "EmployeeCredential"], - "issuer": { - "id": "did:elsi:EU.EORI.NLPACKETDEL" - }, - "issuanceDate": "2022-03-22T14:00:00Z", - "validFrom": "2022-03-22T14:00:00Z", - "expirationDate": "2023-03-22T14:00:00Z", - "credentialSubject": { - "id": "{{.SubjectDID}}", - "verificationMethod": [ - { - "id": "{{.SubjectDID}}#key1", - "type": "JwsVerificationKey2020", - "controller": "{{.SubjectDID}}", - "publicKeyJwk": { - "kid": "key1", - "kty": "EC", - "crv": "P-256", - "x": "lJtvoA5_XptBvcfcrvtGCvXd9bLymmfBSSdNJf5mogo", - "y": "fSc4gZX2R3QKKfHvS3m2vGSVSN8Xc04qsquyfEM55Z0" - } - } - ], - "roles": [ - { - "target": "did:elsi:EU.EORI.NLMARKETPLA", - "names": ["seller", "buyer"] - } - ], - "name": "{{.Name}}", - "given_name": "{{.Given_name}}", - "family_name": "{{.Family_name}}", - "preferred_username": "{{.Preferred_username}}", - "email": "{{.Email}}" - } - } -} -{{end}} \ No newline at end of file diff --git a/vault/templates/employee_credential.tpl b/vault/templates/employee_credential.tpl deleted file mode 100644 index edf9428b..00000000 --- a/vault/templates/employee_credential.tpl +++ /dev/null @@ -1,41 +0,0 @@ -{{define "EmployeeCredential"}} -{ - "@context": [ - "https://www.w3.org/2018/credentials/v1", - "https://marketplace.i4trust.fiware.io/2022/credentials/employee/v1" - ], - "id": "{{.jti}}", - "type": ["VerifiableCredential", "EmployeeCredential"], - "issuer": { - "id": "{{.issuer.DID}}" - }, - "issuanceDate": "2022-03-22T14:00:00Z", - "validFrom": "2022-03-22T14:00:00Z", - "expirationDate": "2023-03-22T14:00:00Z", - "credentialSubject": { - "id": "{{.subject.DID}}", - "verificationMethod": [ - {{range .VerificationMethod}} - { - "id": "{{.subjectDID}}#{{.publicKey.kid}}", - "type": "JwsVerificationKey2020", - "controller": "{{.subjectDID}}", - "publicKeyJwk": { - "kid": "{{.publicKey.kid}}", - "kty": "{{.publicKey.kty}}", - "crv": "{{.publicKey.crv}}", - "x": "{{.publicKey.x}}", - "y": "{{.publicKey.y}}" - } - } - {{end}} - ], - "roles": {{toJson .claims.roles}}, - "name": "{{.claims.name}}", - "given_name": "{{.claims.given_name}}", - "family_name": "{{.claims.family_name}}", - "preferred_username": "{{.claims.preferred_username}}", - "email": "{{.claims.email}}" - } -} -{{end}} \ No newline at end of file diff --git a/vault/vault.go b/vault/vault.go deleted file mode 100644 index 9c522fc7..00000000 --- a/vault/vault.go +++ /dev/null @@ -1,584 +0,0 @@ -package vault - -import ( - "context" - "encoding/base64" - "encoding/json" - "fmt" - "os" - "strings" - "sync" - - "github.com/fiware/vcverifier/ent" - "github.com/fiware/vcverifier/ent/did" - "github.com/fiware/vcverifier/ent/user" - "github.com/fiware/vcverifier/internal/jwk" - "github.com/fiware/vcverifier/internal/jwt" - "github.com/hesusruiz/vcutils/yaml" - "golang.org/x/crypto/bcrypt" - - _ "github.com/mattn/go-sqlite3" - "github.com/rs/zerolog" - zlog "github.com/rs/zerolog/log" -) - -func init() { - zerolog.TimeFieldFormat = zerolog.TimeFormatUnix - zlog.Logger = zlog.Output(zerolog.ConsoleWriter{Out: os.Stderr}) - zlog.Logger = zlog.With().Caller().Logger() -} - -type Vault struct { - Client *ent.Client -} - -type Signable interface { - SigningString() (string, error) - Kid() string -} - -var mutexForNew sync.Mutex - -// Must is a helper that wraps a call to a function returning (*Vault, error) -// and panics if the error is non-nil. It is intended for use in program -// initialization where the starting process has to be aborted in case of error. -// Usage is like this: -// -// var issuerVault = vault.Must(vault.New(cfg)) -func Must(v *Vault, err error) *Vault { - if err != nil { - panic(err) - } - - return v -} - -// New opens or creates a repository storing users, keys and credentials -func New(cfg *yaml.YAML) (v *Vault, err error) { - - if cfg == nil { - return nil, fmt.Errorf("no configuration received") - } - - // Make sure only one thread performs initialization of the database, - // including migrations - mutexForNew.Lock() - defer mutexForNew.Unlock() - - v = &Vault{} - - // Get the configured parameters for the database - storeDriverName := cfg.String("store.driverName") - storeDataSourceName := cfg.String("store.dataSourceName") - - // Open the database - v.Client, err = ent.Open(storeDriverName, storeDataSourceName) - if err != nil { - zlog.Error().Err(err).Msg("failed opening database") - return nil, err - } - - // Run the auto migration tool. - if err := v.Client.Schema.Create(context.Background()); err != nil { - zlog.Error().Err(err).Str("dataSourceName", storeDataSourceName).Msg("failed creating schema resources") - return nil, err - } - - return v, nil -} - -// NewFromDBClient uses an existing client connection for creating the storage object -func NewFromDBClient(entClient *ent.Client) (v *Vault) { - - v = &Vault{} - v.Client = entClient - - return v -} - -// CreateLegalPersonWithKey creates a user of type "issuer" and an associated private key for signing. -// For a single tenant issuer installation, it should be enough with a single Issuer. -// The function expects the IssuerDID (a unique identifier) and the name of the entity. -func (v *Vault) CreateLegalPersonWithKey(issuerDID string, name string, password string) (usr *ent.User, err error) { - - return v.CreateUserWithKey(issuerDID, name, "issuer", password) - -} - -func (v *Vault) CreateNaturalPersonWithKey(id string, name string, password string) (usr *ent.User, err error) { - return v.CreateUserWithKey(id, name, "normal", password) -} - -func (v *Vault) CreateUser(userid string, name string, usertype string, password string) (usr *ent.User, err error) { - - // Return an error if the user already exists - usr, _ = v.Client.User.Get(context.Background(), userid) - if usr != nil { - return nil, fmt.Errorf("user already exists") - } - - // Calculate the password to store - hashedPassword, err := bcrypt.GenerateFromPassword([]byte(password), 0) - if err != nil { - panic(err) - } - - // Create new user of the specified type - usr, err = v.Client.User. - Create(). - SetID(userid). - SetName(name). - SetType(usertype). - SetPassword(hashedPassword). - Save(context.Background()) - if err != nil { - return nil, err - } - - zlog.Info().Str("id", userid).Str("name", name).Str("type", usertype).Msg("user created") - - return usr, nil - -} - -// CreateUserWithKeyX is like CreateUserWithKey but panics if there is an error -func (v *Vault) CreateUserWithKeyX(userid string, name string, usertype string, password string) (usr *ent.User, err error) { - usr, err = v.CreateUserWithKey(userid, name, usertype, password) - if err != nil { - panic(err) - } - return usr, err -} - -func (v *Vault) CreateUserWithKey(userid string, name string, usertype string, password string) (usr *ent.User, err error) { - - // Return an error if the user already exists - usr, _ = v.Client.User.Get(context.Background(), userid) - if usr != nil { - return nil, fmt.Errorf("user already exists") - } - - // Calculate the password to store - hashedPassword, err := bcrypt.GenerateFromPassword([]byte(password), 0) - if err != nil { - panic(err) - } - - // Create new user of the specified type - usr, err = v.Client.User. - Create(). - SetID(userid). - SetName(name). - SetType(usertype). - SetPassword(hashedPassword). - Save(context.Background()) - if err != nil { - return nil, err - } - - // Create a new key and add it to the user - _, err = v.NewKeyForUser(userid) - if err != nil { - return nil, err - } - - zlog.Info().Str("id", userid).Str("name", name).Str("type", usertype).Msg("user created") - - return usr, nil - -} - -func (v *Vault) SetDIDForUser(userid string, did string) error { - // Get the account - usr, err := v.Client.User.Get(context.Background(), userid) - if err != nil { - zlog.Error().Err(err).Str("id", userid).Msg("error retrieving user") - return err - } - - // Do nothing if the DID already exists - if len(v.Client.DID.Query().AllX(context.Background())) > 0 { - zlog.Info().Msg("did already exists") - return nil - } - - // Add the DID to this user - newDID, err := v.Client.DID.Create().SetID(did).Save(context.Background()) - if err != nil { - zlog.Error().Err(err).Msg("failed storing DID") - return err - } - - // Update the user record to point to this key - _, err = usr.Update().AddDids(newDID).Save(context.Background()) - - return err - -} - -func (v *Vault) GetDIDForUser(userid string) (string, error) { - return v.Client.DID.Query().Where(did.HasUserWith(user.ID(userid))).FirstID(context.Background()) -} - -func (v *Vault) NewKeyForUser(userid string) (*ent.PrivateKey, error) { - - // Get the account - usr, err := v.Client.User.Get(context.Background(), userid) - if err != nil { - return nil, err - } - - // Create a new private key, of the preferred type - privKey, err := jwk.NewECDSA() - if err != nil { - zlog.Error().Err(err).Msg("failed creating new native ECDSA key") - return nil, err - } - - // Convert to JSON-JWK - asJSON, err := privKey.AsJSON() - if err != nil { - zlog.Error().Err(err).Msg("failed converting key to json") - return nil, err - } - - // Store in private keys table - kid := privKey.GetKid() - dbKey, err := v.Client.PrivateKey. - Create(). - SetID(kid). - SetKty("EC"). - SetJwk(asJSON). - SetUser(usr). - Save(context.Background()) - if err != nil { - zlog.Error().Err(err).Msg("failed storing key") - return nil, err - } - zlog.Info().Str("kid", kid).Msg("key created") - - // Update the user record to point to this key - usr.Update().AddKeys(dbKey).Save(context.Background()) - - // Store the public part of the key in the public key table, to be used for verification - pubKey := privKey.PublicJWKKey() - // Convert to JSON-JWK - asJSON, err = pubKey.AsJSON() - if err != nil { - zlog.Error().Err(err).Msg("failed converting public key to json") - return nil, err - } - - _, err = v.Client.PublicKey. - Create(). - SetID(kid). - SetKty("EC"). - SetJwk(asJSON). - Save(context.Background()) - if err != nil { - zlog.Error().Err(err).Msg("failed storing public key") - return nil, err - } - - zlog.Info().Str("name", userid).Msg("user updated") - - return dbKey, nil - -} - -func (v *Vault) AddKeyToUser(userid string, privKey *jwk.JWK) (*ent.PrivateKey, error) { - - // Get the account - usr, err := v.Client.User.Get(context.Background(), userid) - if err != nil { - return nil, err - } - - // Convert to JSON-JWK - asJSON, err := privKey.AsJSON() - if err != nil { - zlog.Error().Err(err).Msg("failed converting key to json") - return nil, err - } - - // Store in private keys table - kid := privKey.GetKid() - dbKey, err := v.Client.PrivateKey. - Create(). - SetID(kid). - SetKty("EC"). - SetJwk(asJSON). - SetUser(usr). - Save(context.Background()) - if err != nil { - zlog.Error().Err(err).Msg("failed storing key") - return nil, err - } - zlog.Info().Str("kid", kid).Msg("key created") - - // Update the user record to point to this key - usr.Update().AddKeys(dbKey).Save(context.Background()) - - // Store the public part of the key in the public key table, to be used for verification - pubKey := privKey.PublicJWKKey() - // Convert to JSON-JWK - asJSON, err = pubKey.AsJSON() - if err != nil { - zlog.Error().Err(err).Msg("failed converting public key to json") - return nil, err - } - - _, err = v.Client.PublicKey. - Create(). - SetID(kid). - SetKty("EC"). - SetJwk(asJSON). - Save(context.Background()) - if err != nil { - zlog.Error().Err(err).Msg("failed storing public key") - return nil, err - } - - zlog.Info().Str("name", userid).Msg("user updated") - - return dbKey, nil - -} - -// UserByID returns either a user or nil if not found, in the absence of any other error -func (v *Vault) UserByID(id string) (usr *ent.User, err error) { - - // Retrieve user by ID - usr, err = v.Client.User.Get(context.Background(), id) - - // Log if the error is NotFound - if ent.IsNotFound(err) { - zlog.Debug().Err(err).Str("name", id).Msg("user not found") - return nil, nil - } - - if err != nil { - zlog.Error().Err(err).Str("name", id).Msg("failed querying user") - return nil, fmt.Errorf("failed querying user: %w", err) - } - zlog.Info().Str("name", id).Msg("user retrieved") - return usr, nil - -} - -// PrivateKeysForUser returns all the private keys belonging to the userid -func (v *Vault) PrivateKeysForUser(userid string) (keys []*jwk.JWK, err error) { - - // Return an error if the user does not exist - usr, err := v.UserByID(userid) - if err != nil { - zlog.Error().Err(err).Str("id", userid).Send() - return nil, err - } - - // Get all the keys - entKeys, err := usr.QueryKeys().All(context.Background()) - if err != nil { - zlog.Error().Err(err).Str("id", userid).Send() - return nil, err - } - - // Convert the keys to the JKW format - keys = make([]*jwk.JWK, len(entKeys)) - - for i, k := range entKeys { - jwkKey, err := jwk.NewFromBytes(k.Jwk) - if err != nil { - continue - } - keys[i] = jwkKey - } - - // Return an error if no keys were found - if len(keys) == 0 { - return nil, fmt.Errorf("the user has no private keys") - } - - return keys, nil -} - -// PublicKeysForUser returns all the public keys belonging to the userid -func (v *Vault) PublicKeysForUser(userid string) (keys []*jwk.JWK, err error) { - - // Return an error if the user does not exist - usr, err := v.UserByID(userid) - if err != nil { - zlog.Error().Err(err).Str("id", userid).Send() - return nil, err - } - - // Get all the private keys - entKeys, err := usr.QueryKeys().All(context.Background()) - if err != nil { - zlog.Error().Err(err).Str("id", userid).Send() - return nil, err - } - - // Convert the keys to the JKW format - keys = make([]*jwk.JWK, len(entKeys)) - - for i, k := range entKeys { - jwkKey, err := jwk.NewFromBytes(k.Jwk) - if err != nil { - continue - } - keys[i] = jwkKey - } - - // Return an error if no keys were found - if len(keys) == 0 { - return nil, fmt.Errorf("the user has no private keys") - } - - // Convert the keys to public keys - pubkeys := make([]*jwk.JWK, len(keys)) - for i, k := range keys { - pubkeys[i] = k.PublicJWKKey() - } - - return pubkeys, nil -} - -func (v *Vault) PrivateKeyByID(id string) (jwkKey *jwk.JWK, err error) { - - // Retrieve key by its ID, which should be unique - k, err := v.Client.PrivateKey.Get(context.Background(), id) - if err != nil { - return nil, err - } - - // Convert to JWK format - jwkKey, err = jwk.NewFromBytes(k.Jwk) - if err != nil { - return nil, err - } - - return jwkKey, err -} - -// SignWithJWK signs the JWT using the algorithm and key ID in its header -func (v *Vault) SignWithJWK(k *jwk.JWK, claims any) (signedString string, err error) { - - var jsonValue []byte - var toBeSigned string - - // Create the headerMap - headerMap := map[string]string{ - "typ": "JWT", - "alg": k.GetAlg(), - "kid": k.GetKid(), - } - - if jsonValue, err = json.Marshal(headerMap); err != nil { - return "", err - } - header := base64.RawURLEncoding.EncodeToString(jsonValue) - - if jsonValue, err = json.Marshal(claims); err != nil { - return "", err - } - fmt.Println("**** Build Claim String ****") - fmt.Println(string(jsonValue)) - - claim := base64.RawURLEncoding.EncodeToString(jsonValue) - - toBeSigned = strings.Join([]string{header, claim}, ".") - - // Perform the signature - signedString, err = v.SignString(toBeSigned, headerMap["kid"]) - - return signedString, err - -} - -// Sign signs the JWT using the algorithm and key ID in its header -func (v *Vault) Sign(object Signable) (signedString string, err error) { - - var toBeSigned string - - // Convert token to a serialized string to be signed - toBeSigned, err = object.SigningString() - if err != nil { - return "", err - } - - // Perform the signature - signedString, err = v.SignString(toBeSigned, object.Kid()) - - return signedString, err - -} - -// SignString signs the string using the key with given ID and using algorithm alg -func (v *Vault) SignString(toBeSigned string, kid string) (signedString string, err error) { - - var signature string - - // Get the private key for signing - jwkKey, err := v.PrivateKeyByID(kid) - if err != nil { - return "", err - } - - // Convert the key to native - key, err := jwkKey.GetPrivateKey() - if err != nil { - return "", err - } - - // Get the algorithm from the JWK (it is compulsory for our application) - alg := jwkKey.GetAlg() - - // Get the method for signing - method := jwt.GetSigningMethod(alg) - - // Sign the string - if signature, err = method.Sign(toBeSigned, key); err != nil { - return "", err - } - - // Concatenate the signature with a "." as specified in the JWT standards - return strings.Join([]string{toBeSigned, signature}, "."), nil - -} - -// VerifySignature verifies that a signature corresponds to a signed string given a key ID and algorithm -func (v *Vault) VerifySignature(signedString string, signature string, alg string, kid string) (err error) { - - // Get the key for verification - jwkKey, err := v.PrivateKeyByID(kid) - if err != nil { - return err - } - - // Check that the externally specified 'alg' matches the 'alg' in the JWK - if jwkKey.GetAlg() != alg { - return fmt.Errorf("alg does not match with alg in the JWK") - } - - // Convert the key to native - key, err := jwkKey.GetPublicKey() - if err != nil { - return err - } - - // Get the method to verify - method := jwt.GetSigningMethod(alg) - if method == nil { - return fmt.Errorf("signing method (alg) is unavailable") - } - - // Verify signature - if err = method.Verify(signedString, signature, key); err != nil { - return err - } - - // Verification performed, reply with success - return nil - -} diff --git a/verifier.go b/verifier.go deleted file mode 100644 index 98491a99..00000000 --- a/verifier.go +++ /dev/null @@ -1,460 +0,0 @@ -package main - -import ( - "encoding/base64" - "encoding/json" - "errors" - "fmt" - "time" - - "github.com/gofiber/fiber/v2" - "github.com/hesusruiz/vcutils/yaml" - qrcode "github.com/skip2/go-qrcode" - "github.com/valyala/fasttemplate" - "go.uber.org/zap" -) - -type Verifier struct { - server *Server -} - -// setupVerifier creates and setups the Issuer routes -func setupVerifier(s *Server) { - - verifier := &Verifier{s} - - // Define the prefix for Verifier routes - verifierRoutes := s.Group(verifierPrefix) - - // Routes consist of a set of pages rendering HTML using templates and a set of APIs - - // The JWKS endpoint - jwks_uri := s.cfg.String("verifier.uri_prefix") + s.cfg.String("verifier.jwks_uri") - s.Get(jwks_uri, s.VerifierAPIJWKS) - - // Pages - - // Display a QR code for mobile wallet or a link for enterprise wallet - verifierRoutes.Get("/displayqr", verifier.VerifierPageDisplayQRSIOP) - - // Error page when login session has expired without the user sending the credential - verifierRoutes.Get("/loginexpired", verifier.VerifierPageLoginExpired) - - // For same-device logins (e.g., with the enterprise wallet) - verifierRoutes.Get("/startsiopsamedevice", verifier.VerifierPageStartSIOPSameDevice) - - // Page displaying the received credential, after successful login - verifierRoutes.Get("/receivecredential/:state", verifier.VerifierPageReceiveCredential) - - // Allow simulation of accessing protected resources, after successful login - verifierRoutes.Get("/accessprotectedservice", verifier.VerifierPageAccessProtectedService) - - // APIs - - // Used by the login page from the browser, to check successful login or expiration - verifierRoutes.Get("/poll/:state", verifier.VerifierAPIPoll) - - verifierRoutes.Get("/token/:state", verifier.VerifierAPIToken) - - // Start the SIOP flows - verifierRoutes.Get("/startsiop", verifier.VerifierAPIStartSIOP) - verifierRoutes.Get("/authenticationrequest", verifier.VerifierAPIStartSIOP) - - // Used by the wallet (both enterprise and mobile) to send the VC/VP as Authentication Response - verifierRoutes.Post("/authenticationresponse", verifier.VerifierAPIAuthenticationResponse) - -} - -func (v *Verifier) VerifierPageDisplayQRSIOP(c *fiber.Ctx) error { - - // Generate the state that will be used for checking expiration and also successful logon - state := generateNonce() - - // Create an entry in storage that will expire. - // The entry is identified by the nonce - v.server.storage.Set(state, []byte("pending"), 200*time.Second) - - // This is the endpoint inside the QR that the wallet will use to send the VC/VP - redirect_uri := c.Protocol() + "://" + c.Hostname() + verifierPrefix + "/authenticationresponse" - - // Create the Authentication Request - authRequest := createAuthenticationRequest(v.server.verifierDID, redirect_uri, state) - v.server.logger.Info("AuthRequest", authRequest) - - // Create the QR code for cross-device SIOP - png, err := qrcode.Encode(authRequest, qrcode.Medium, 256) - if err != nil { - return err - } - - // Convert the image data to a dataURL - base64Img := base64.StdEncoding.EncodeToString(png) - base64Img = "data:image/png;base64," + base64Img - - // Render the page - m := fiber.Map{ - "issuerPrefix": issuerPrefix, - "verifierPrefix": verifierPrefix, - "walletPrefix": walletPrefix, - "qrcode": base64Img, - "prefix": verifierPrefix, - "state": state, - } - return c.Render("verifier_present_qr", m) -} - -func (v *Verifier) VerifierPageLoginExpired(c *fiber.Ctx) error { - m := fiber.Map{ - "prefix": verifierPrefix, - } - return c.Render("verifier_loginexpired", m) -} - -func (v *Verifier) VerifierPageStartSIOPSameDevice(c *fiber.Ctx) error { - - state := c.Query("state") - - const scope = "dsba.credentials.presentation.PacketDeliveryService" - const response_type = "vp_token" - redirect_uri := c.Protocol() + "://" + c.Hostname() + verifierPrefix + "/authenticationresponse" - - // template := "https://hesusruiz.github.io/faster/?scope={{scope}}" + - // "&response_type={{response_type}}" + - // "&response_mode=post" + - // "&client_id={{client_id}}" + - // "&redirect_uri={{redirect_uri}}" + - // "&state={{state}}" + - // "&nonce={{nonce}}" - - walletUri := c.Protocol() + "://" + c.Hostname() + walletPrefix + "/selectcredential" - template := walletUri + "/?scope={{scope}}" + - "&response_type={{response_type}}" + - "&response_mode=post" + - "&client_id={{client_id}}" + - "&redirect_uri={{redirect_uri}}" + - "&state={{state}}" + - "&nonce={{nonce}}" - - t := fasttemplate.New(template, "{{", "}}") - str := t.ExecuteString(map[string]interface{}{ - "scope": scope, - "response_type": response_type, - "client_id": v.server.verifierDID, - "redirect_uri": redirect_uri, - "state": state, - "nonce": generateNonce(), - }) - fmt.Println(str) - - return c.Redirect(str) -} - -func (v *Verifier) VerifierPageReceiveCredential(c *fiber.Ctx) error { - - // Get the state as a path parameter - state := c.Params("state") - - // get the credential from the storage - rawCred, _ := v.server.storage.Get(state) - if len(rawCred) == 0 { - // Render an error - m := fiber.Map{ - "error": "No credential found", - } - return c.Render("displayerror", m) - } - - claims := string(rawCred) - - // Create an access token from the credential - accessToken, err := v.server.verifierVault.CreateAccessToken(claims, v.server.cfg.String("verifier.id")) - if err != nil { - return err - } - - // Set it in a cookie - cookie := new(fiber.Cookie) - cookie.Name = "dbsamvf" - cookie.Value = string(accessToken) - cookie.Expires = time.Now().Add(1 * time.Hour) - - // Set cookie - c.Cookie(cookie) - - // Set also the access token in the Authorization field of the response header - bearer := "Bearer " + string(accessToken) - c.Set("Authorization", bearer) - - // Render - m := fiber.Map{ - "issuerPrefix": issuerPrefix, - "verifierPrefix": verifierPrefix, - "walletPrefix": walletPrefix, - "claims": claims, - "prefix": verifierPrefix, - } - return c.Render("verifier_receivedcredential", m) -} - -func (v *Verifier) VerifierPageAccessProtectedService(c *fiber.Ctx) error { - - var code int - var returnBody []byte - var errors []error - - // Get the access token from the cookie - accessToken := c.Cookies("dbsamvf") - - // Check if the user has configured a protected service to access - protected := v.server.cfg.String("verifier.protectedResource.url") - if len(protected) > 0 { - - // Prepare to GET to the url - agent := fiber.Get(protected) - - // Set the Authentication header - agent.Set("Authorization", "Bearer "+accessToken) - - agent.Set("accept", "application/json") - code, returnBody, errors = agent.Bytes() - if len(errors) > 0 { - v.server.logger.Errorw("error calling SSI Kit", zap.Errors("errors", errors)) - return fmt.Errorf("error calling SSI Kit: %v", errors[0]) - } - - } - - // Render - m := fiber.Map{ - "issuerPrefix": issuerPrefix, - "verifierPrefix": verifierPrefix, - "walletPrefix": walletPrefix, - "accesstoken": accessToken, - "protected": protected, - "code": code, - "returnBody": string(returnBody), - } - return c.Render("verifier_protectedservice", m) -} - -func (v *Verifier) VerifierAPIPoll(c *fiber.Ctx) error { - - // get the state - state := c.Params("state") - - // Check if session still pending - status, _ := v.server.storage.Get(state) - if len(status) == 0 { - return c.SendString("expired") - } else { - return c.SendString(string(status)) - } - -} - -// retrieve token for the given session("state"-paramter) -func (v *Verifier) VerifierAPIToken(c *fiber.Ctx) error { - v.server.logger.Info("Get the token") - // get the state - state := c.Params("state") - - v.server.logger.Infof("Get for state %s", state) - // get the credential from the storage - rawCred, _ := v.server.storage.Get(state) - if len(rawCred) == 0 { - - v.server.logger.Infof("No credential stored for '%s'", state) - c.Status(403) - return errors.New("No_such_credential") - } - - claims := string(rawCred) - - // Create an access token from the credential - accessToken, err := v.server.verifierVault.CreateAccessToken(claims, v.server.cfg.String("verifier.id")) - if err != nil { - v.server.logger.Infof("Was not able to create the token. Err: %s", err) - c.Status(500) - return err - } - - return c.SendString(string(accessToken)) -} - -func (v *Verifier) VerifierAPIStartSIOP(c *fiber.Ctx) error { - - // Get the state - state := c.Query("state") - - const scope = "dsba.credentials.presentation.PacketDeliveryService" - const response_type = "vp_token" - redirect_uri := c.Protocol() + "://" + c.Hostname() + verifierPrefix + "/authenticationresponse" - - template := "openid://?scope={{scope}}" + - "&response_type={{response_type}}" + - "&response_mode=post" + - "&client_id={{client_id}}" + - "&redirect_uri={{redirect_uri}}" + - "&state={{state}}" + - "&nonce={{nonce}}" - - t := fasttemplate.New(template, "{{", "}}") - str := t.ExecuteString(map[string]interface{}{ - "scope": scope, - "response_type": response_type, - "client_id": v.server.verifierDID, - "redirect_uri": redirect_uri, - "state": state, - "nonce": generateNonce(), - }) - - return c.SendString(str) -} - -// VerifierAPIAuthenticationResponseVP receives a VP, extracts the VC and display a page -func (v *Verifier) VerifierAPIAuthenticationResponseVP(c *fiber.Ctx) error { - - // Get the state, which indicates the login session to which this request belongs - state := c.Query("state") - - // We should receive the Verifiable Presentation in the body as JSON - body := c.Body() - fmt.Println(string(body)) - fmt.Println(string(state)) - - // Decode into a map - vp, err := yaml.ParseJson(string(body)) - if err != nil { - v.server.logger.Errorw("invalid vp received", zap.Error(err)) - return err - } - - credential := vp.String("credential") - // Validate the credential - - // Set the credential in storage, and wait for the polling from client - v.server.storage.Set(state, []byte(credential), 10*time.Second) - - return c.SendString("ok") -} - -type verifiableCredential struct { - Credential *json.RawMessage `json:"credential"` -} - -func (v *Verifier) VerifierAPIAuthenticationResponse(c *fiber.Ctx) error { - - // Get the state - state := c.Query("state") - - // We should receive the credential in the body as JSON - body := c.Body() - v.server.logger.Infof("Authenticate for state '%s' with %s", state, body) - // Decode into a map - - vc := &verifiableCredential{} - json.Unmarshal(body, vc) - - // Validate the credential - v.server.logger.Infof("Store credential %s", *vc.Credential) - // Set the credential in storage, and wait for the polling from client - v.server.storage.Set(state, *vc.Credential, 10*time.Second) - - v.server.logger.Infof("Stored for state %s", state) - return c.SendString("ok") -} - -func (v *Verifier) VerifierPageDisplayQR(c *fiber.Ctx) error { - - if sameDevice { - return v.VerifierPageStartSIOPSameDevice(c) - } - - // Generate the state that will be used for checking expiration - state := generateNonce() - - // Create an entry in storage that will expire in 2 minutes - // The entry is identified by the nonce - // s.storage.Set(state, []byte("pending"), 2*time.Minute) - v.server.storage.Set(state, []byte("pending"), 40*time.Second) - - // QR code for cross-device SIOP - template := "{{protocol}}://{{hostname}}{{prefix}}/startsiop?state={{state}}" - qrCode1, err := qrCode(template, c.Protocol(), c.Hostname(), verifierPrefix, state) - if err != nil { - return err - } - - // Render index - m := fiber.Map{ - "issuerPrefix": issuerPrefix, - "verifierPrefix": verifierPrefix, - "walletPrefix": walletPrefix, - "qrcode": qrCode1, - "prefix": verifierPrefix, - "state": state, - } - return c.Render("verifier_present_qr", m) -} - -func qrCode(template, protocol, hostname, prefix, state string) (string, error) { - - // Construct the URL to be included in the QR - t := fasttemplate.New(template, "{{", "}}") - str := t.ExecuteString(map[string]interface{}{ - "protocol": protocol, - "hostname": hostname, - "prefix": prefix, - "state": state, - }) - - // Create the QR - png, err := qrcode.Encode(str, qrcode.Medium, 256) - if err != nil { - return "", err - } - - // Convert to a dataURL - base64Img := base64.StdEncoding.EncodeToString(png) - base64Img = "data:image/png;base64," + base64Img - - return base64Img, nil - -} - -func createAuthenticationRequest(verifierDID string, redirect_uri string, state string) string { - - // This specifies the type of credential that the Verifier will accept - // TODO: In this use case it is hardcoded, which is enough if the Verifier is simple and uses - // only one type of credential for authentication its users. - const scope = "dsba.credentials.presentation.PacketDeliveryService" - - // The response type should be 'vp_token' - const response_type = "vp_token" - - // Response mode should be 'post' - const response_mode = "post" - - // We use a template to generate the final string - template := "openid://?scope={{scope}}" + - "&response_type={{response_type}}" + - "&response_mode={{response_mode}}" + - "&client_id={{client_id}}" + - "&redirect_uri={{redirect_uri}}" + - "&state={{state}}" + - "&nonce={{nonce}}" - - t := fasttemplate.New(template, "{{", "}}") - authRequest := t.ExecuteString(map[string]interface{}{ - "scope": scope, - "response_type": response_type, - "response_mode": response_mode, - "client_id": verifierDID, - "redirect_uri": redirect_uri, - "state": state, - "nonce": generateNonce(), - }) - - return authRequest - -} diff --git a/verifier/verifier.go b/verifier/verifier.go new file mode 100644 index 00000000..4d0fd131 --- /dev/null +++ b/verifier/verifier.go @@ -0,0 +1,457 @@ +package verifier + +import ( + "crypto/ecdsa" + "crypto/elliptic" + "crypto/rand" + "encoding/base64" + "errors" + configModel "fiware/VCVerifier/config" + "fmt" + "io" + "net/http" + "net/url" + "time" + + logging "fiware/VCVerifier/logging" + + client "github.com/fiware/dsba-pdp/http" + + "fiware/VCVerifier/ssikit" + + "github.com/lestrrat-go/jwx/jwa" + "github.com/lestrrat-go/jwx/jwk" + "github.com/lestrrat-go/jwx/jwt" + "github.com/patrickmn/go-cache" + qrcode "github.com/skip2/go-qrcode" + "github.com/valyala/fasttemplate" +) + +var ErrorNoDID = errors.New("no_did_configured") +var ErrorNoTIR = errors.New("nod_tir_configured") +var ErrorInvalidVC = errors.New("invalid_vc") +var ErrorNoSuchSession = errors.New("no_such_session") +var ErrorWrongGrantType = errors.New("wrong_grant_type") +var ErrorNoSuchCode = errors.New("no_such_code") +var ErrorRedirectUriMismatch = errors.New("redirect_uri_does_not_match") + +// Actual implementation of the verfifier functionality + +// verifier interface +type Verifier interface { + ReturnLoginQR(host string, protocol string, callback string, sessionId string) (qr string, err error) + StartSiopFlow(host string, protocol string, callback string, sessionId string) (connectionString string, err error) + StartSameDeviceFlow(host string, protocol string, sessionId string, redirectPath string) (authenticationRequest string, err error) + GetToken(grantType string, authorizationCode string, redirectUri string) (jwtString string, expiration int64, err error) + GetJWKS() jwk.Set + AuthenticationResponse(state string, verifiableCredentials []map[string]interface{}, holder string) (sameDevice SameDeviceResponse, err error) +} + +// implementation of the verifier, using waltId ssikit as a validation backend. +type SsiKitVerifier struct { + // did of the verifier + did string + // trusted-issuers-registry to be used for verification + tirAddress string + // optional scope of credentials to be requested + scope string + // array of policies to be verified - currently statically filled on init + policies []ssikit.Policy + // key to sign the jwt's with + signingKey jwk.Key + // client for connection waltId + ssiKitClient ssikit.SSIKit + // cache to be used for in-progress authentication sessions + sessionCache Cache + // cache to be used for jwt retrieval + tokenCache Cache + // nonce generator + nonceGenerator NonceGenerator + // provides the current time + clock Clock + // provides the capabilities to signt the jwt + tokenSigner TokenSigner +} + +// allow singleton access to the verifier +var verifier Verifier + +// http client to be used +var httpClient = client.HttpClient() + +// interfaces and default implementations + +type Cache interface { + Add(k string, x interface{}, d time.Duration) error + Get(k string) (interface{}, bool) + Delete(k string) +} + +type Clock interface { + Now() time.Time +} + +type realClock struct{} + +func (realClock) Now() time.Time { + return time.Now() +} + +type TokenSigner interface { + Sign(t jwt.Token, alg jwa.SignatureAlgorithm, key interface{}, options ...jwt.SignOption) ([]byte, error) +} + +type jwtTokenSigner struct{} + +func (jwtTokenSigner) Sign(t jwt.Token, alg jwa.SignatureAlgorithm, key interface{}, options ...jwt.SignOption) ([]byte, error) { + return jwt.Sign(t, alg, key, options...) +} + +type randomGenerator struct{} + +type NonceGenerator interface { + GenerateNonce() string +} + +// generate a random nonce +func (r *randomGenerator) GenerateNonce() string { + b := make([]byte, 16) + io.ReadFull(rand.Reader, b) + nonce := base64.RawURLEncoding.EncodeToString(b) + return nonce +} + +// struct to represent a running login session +type loginSession struct { + // is it using the same-device flow? + sameDevice bool + // callback to be notfied after success + callback string + // sessionId to be included in the notification + sessionId string +} + +// struct to represent a token, accessible through the token endpoint +type tokenStore struct { + token jwt.Token + redirect_uri string +} + +// Response structure for successful same-device authentications +type SameDeviceResponse struct { + // the redirect target to be informed + RedirectTarget string + // code of the siop flow + Code string + // session id provided by the client + SessionId string +} + +/** +* Global singelton access to the verifier +**/ +func GetVerifier() Verifier { + if verifier == nil { + logging.Log().Error("Verifier is not initialized.") + } + return verifier +} + +/** +* Initialize the verifier and all its components from the configuration +**/ +func InitVerifier(verifierConfig *configModel.Verifier, ssiKitClient ssikit.SSIKit) (err error) { + + err = verifyConfig(verifierConfig) + if err != nil { + return + } + + sessionCache := cache.New(time.Duration(verifierConfig.SessionExpiry)*time.Second, time.Duration(2*verifierConfig.SessionExpiry)*time.Second) + tokenCache := cache.New(time.Duration(verifierConfig.SessionExpiry)*time.Second, time.Duration(2*verifierConfig.SessionExpiry)*time.Second) + + policies := []ssikit.Policy{ + {Policy: "SignaturePolicy"}, + {Policy: "IssuedDateBeforePolicy"}, + {Policy: "ValidFromBeforePolicy"}, + {Policy: "ExpirationDateAfterPolicy"}, + {Policy: "TrustedIssuerRegistryPolicy", Argument: &ssikit.TirArgument{RegistryAddress: verifierConfig.TirAddress}}, + } + + key, err := initPrivateKey() + if err != nil { + logging.Log().Errorf("Was not able to initiate a signing key. Err: %v", err) + return err + } + logging.Log().Warnf("Initiated key %s.", logging.PrettyPrintObject(key)) + verifier = &SsiKitVerifier{verifierConfig.Did, verifierConfig.TirAddress, verifierConfig.RequestScope, policies, key, ssiKitClient, sessionCache, tokenCache, &randomGenerator{}, realClock{}, jwtTokenSigner{}} + + logging.Log().Debug("Successfully initalized the verifier") + return +} + +/** +* Initializes the cross-device login flow and returns all neccessary information as a qr-code +**/ +func (v *SsiKitVerifier) ReturnLoginQR(host string, protocol string, callback string, sessionId string) (qr string, err error) { + + logging.Log().Debugf("Generate a login qr for %s.", callback) + authenticationRequest, err := v.initSiopFlow(host, protocol, callback, sessionId) + + if err != nil { + return qr, err + } + + png, err := qrcode.Encode(authenticationRequest, qrcode.Medium, 256) + base64Img := base64.StdEncoding.EncodeToString(png) + base64Img = "data:image/png;base64," + base64Img + + return base64Img, err +} + +/** +* Starts a siop-flow and returns the required connection information +**/ +func (v *SsiKitVerifier) StartSiopFlow(host string, protocol string, callback string, sessionId string) (connectionString string, err error) { + logging.Log().Debugf("Start a plain siop-flow fro %s.", callback) + + return v.initSiopFlow(host, protocol, callback, sessionId) +} + +/** +* Starts a same-device siop-flow and returns the required redirection information +**/ +func (v *SsiKitVerifier) StartSameDeviceFlow(host string, protocol string, sessionId string, redirectPath string) (authenticationRequest string, err error) { + logging.Log().Debugf("Initiate samedevice flow for %s.", host) + state := v.nonceGenerator.GenerateNonce() + + loginSession := loginSession{true, fmt.Sprintf("%s://%s%s", protocol, host, redirectPath), sessionId} + err = v.sessionCache.Add(state, loginSession, cache.DefaultExpiration) + if err != nil { + logging.Log().Warnf("Was not able to store the login session %s in cache. Err: %v", logging.PrettyPrintObject(loginSession), err) + return authenticationRequest, err + } + + redirectUri := fmt.Sprintf("%s://%s/api/v1/authentication_response", protocol, host) + + walletUri := protocol + "://" + host + redirectPath + return v.createAuthenticationRequest(walletUri, redirectUri, state), err +} + +/** +* Returns an already generated jwt from the cache to properly authorized requests. Every token will only be returend once. +**/ +func (v *SsiKitVerifier) GetToken(grantType string, authorizationCode string, redirectUri string) (jwtString string, expiration int64, err error) { + + if grantType != "authorization_code" { + return jwtString, expiration, ErrorWrongGrantType + } + + tokenSessionInterface, hit := v.tokenCache.Get(authorizationCode) + if !hit { + logging.Log().Infof("No such authorization code cached: %s.", authorizationCode) + return jwtString, expiration, ErrorNoSuchCode + } + // we do only allow retrieval once. + v.tokenCache.Delete(authorizationCode) + + tokenSession := tokenSessionInterface.(tokenStore) + if tokenSession.redirect_uri != redirectUri { + logging.Log().Infof("Redirect uri does not match for authorization %s. Was %s but is expected %s.", authorizationCode, redirectUri, tokenSession.redirect_uri) + return jwtString, expiration, ErrorRedirectUriMismatch + } + jwtBytes, err := v.tokenSigner.Sign(tokenSession.token, jwa.ES256, v.signingKey) + if err != nil { + logging.Log().Warnf("Was not able to sign the token. Err: %v", err) + return jwtString, expiration, err + } + expiration = tokenSession.token.Expiration().Unix() - v.clock.Now().Unix() + + return string(jwtBytes), expiration, err +} + +/** +* Return the JWKS used by the verifier to allow jwt verification +**/ +func (v *SsiKitVerifier) GetJWKS() jwk.Set { + jwks := jwk.NewSet() + publicKey, _ := v.signingKey.PublicKey() + jwks.Add(publicKey) + return jwks +} + +/** +* Receive credentials and verify them in the context of an already present login-session. Will return either an error if failed, a sameDevice response to be used for +* redirection or notify the original initiator(in case of a cross-device flow) +**/ +func (v *SsiKitVerifier) AuthenticationResponse(state string, verifiableCredentials []map[string]interface{}, holder string) (sameDevice SameDeviceResponse, err error) { + + logging.Log().Debugf("Authenticate credential for session %s", state) + + loginSessionInterface, hit := v.sessionCache.Get(state) + if !hit { + logging.Log().Infof("Session %s is either expired or did never exist.", state) + return sameDevice, ErrorNoSuchSession + } + loginSession := loginSessionInterface.(loginSession) + + for _, vc := range verifiableCredentials { + result, err := v.ssiKitClient.VerifyVC(v.policies, vc) + if err != nil { + logging.Log().Warnf("Failed to verify credential %s. Err: %v", logging.PrettyPrintObject(vc), err) + return sameDevice, err + } + if !result { + logging.Log().Infof("VC %s is not valid.", logging.PrettyPrintObject(vc)) + return sameDevice, ErrorInvalidVC + } + } + + // we ignore the error here, since the only consequence is that sub will be empty. + hostname, _ := getHostName(loginSession.callback) + + token, err := v.generateJWT(verifiableCredentials, holder, hostname) + if err != nil { + logging.Log().Warnf("Was not able to create a jwt for %s. Err: %v", state, err) + return sameDevice, err + } + + tokenStore := tokenStore{token, loginSession.callback} + authorizationCode := v.nonceGenerator.GenerateNonce() + // store for retrieval by token endpoint + err = v.tokenCache.Add(authorizationCode, tokenStore, cache.DefaultExpiration) + logging.Log().Infof("Stored token for %s.", authorizationCode) + if err != nil { + logging.Log().Warnf("Was not able to store the token %s in cache.", logging.PrettyPrintObject(tokenStore)) + return sameDevice, err + } + if loginSession.sameDevice { + return SameDeviceResponse{loginSession.callback, authorizationCode, loginSession.sessionId}, err + } else { + return sameDevice, callbackToRequestor(loginSession, authorizationCode) + } +} + +// initializes the cross-device siop flow +func (v *SsiKitVerifier) initSiopFlow(host string, protocol string, callback string, sessionId string) (authenticationRequest string, err error) { + state := v.nonceGenerator.GenerateNonce() + + loginSession := loginSession{false, callback, sessionId} + err = v.sessionCache.Add(state, loginSession, cache.DefaultExpiration) + + if err != nil { + logging.Log().Warnf("Was not able to store the login session %s in cache.", logging.PrettyPrintObject(loginSession)) + return authenticationRequest, err + } + redirectUri := fmt.Sprintf("%s://%s/api/v1/authentication_response", protocol, host) + authenticationRequest = v.createAuthenticationRequest("openid://", redirectUri, state) + + logging.Log().Debugf("Authentication request is %s.", authenticationRequest) + return authenticationRequest, err +} + +// generate a jwt, containing the credential and mandatory information as defined by the dsba-convergence +func (v *SsiKitVerifier) generateJWT(verifiableCredentials []map[string]interface{}, holder string, audience string) (generatedJwt jwt.Token, err error) { + + jwtBuilder := jwt.NewBuilder().Issuer(v.did).Claim("client_id", v.did).Subject(holder).Audience([]string{audience}).Claim("kid", v.signingKey.KeyID()).Expiration(v.clock.Now().Add(time.Minute * 30)) + if v.scope != "" { + jwtBuilder.Claim("scope", v.scope) + } + jwtBuilder.Claim("verifiableCredential", verifiableCredentials[0]) + + token, err := jwtBuilder.Build() + if err != nil { + logging.Log().Warnf("Was not able to build a token. Err: %v", err) + return generatedJwt, err + } + + return token, err +} + +// creates an authenticationRequest string from the given parameters +func (v *SsiKitVerifier) createAuthenticationRequest(base string, redirect_uri string, state string) string { + + // We use a template to generate the final string + template := "{{base}}?response_type=vp_token" + + "&response_mode=direct_post" + + "&client_id={{client_id}}" + + "&redirect_uri={{redirect_uri}}" + + "&state={{state}}" + + "&nonce={{nonce}}" + + if v.scope != "" { + template = template + "&scope={{scope}}" + } + + t := fasttemplate.New(template, "{{", "}}") + authRequest := t.ExecuteString(map[string]interface{}{ + "base": base, + "scope": v.scope, + "client_id": v.did, + "redirect_uri": redirect_uri, + "state": state, + "nonce": v.nonceGenerator.GenerateNonce(), + }) + + return authRequest + +} + +// call back to the original initiator of the login-session, providing an authorization_code for token retrieval +func callbackToRequestor(loginSession loginSession, authorizationCode string) error { + callbackRequest, err := http.NewRequest("GET", loginSession.callback, nil) + logging.Log().Infof("Try to callback %s", loginSession.callback) + if err != nil { + logging.Log().Warnf("Was not able to create callback request to %s. Err: %v", loginSession.callback, err) + return err + } + q := callbackRequest.URL.Query() + q.Add("state", loginSession.sessionId) + q.Add("code", authorizationCode) + callbackRequest.URL.RawQuery = q.Encode() + + _, err = httpClient.Do(callbackRequest) + if err != nil { + logging.Log().Warnf("Was not able to notify requestor %s. Err: %v", loginSession.callback, err) + return err + } + return nil +} + +// helper method to extract the hostname from a url +func getHostName(urlString string) (host string, err error) { + url, err := url.Parse(urlString) + if err != nil { + logging.Log().Warnf("Was not able to extract the host from the redirect_url %s. Err: %v", urlString, err) + return host, err + } + return url.Host, err +} + +// Initialize the private key of the verifier. Might need to be persisted in future iterations. +func initPrivateKey() (key jwk.Key, err error) { + newKey, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader) + + if err != nil { + return nil, err + } + key, err = jwk.New(newKey) + if err != nil { + return nil, err + } + if err != jwk.AssignKeyID(key) { + return nil, err + } + return key, err +} + +// verify the configuration +func verifyConfig(verifierConfig *configModel.Verifier) error { + if verifierConfig.Did == "" { + return ErrorNoDID + } + if verifierConfig.TirAddress == "" { + return ErrorNoTIR + } + return nil +} diff --git a/verifier/verifier_test.go b/verifier/verifier_test.go new file mode 100644 index 00000000..b314d3c9 --- /dev/null +++ b/verifier/verifier_test.go @@ -0,0 +1,528 @@ +package verifier + +import ( + "crypto/ecdsa" + "crypto/elliptic" + "crypto/rand" + "errors" + "net/http" + "net/url" + "testing" + "time" + + configModel "fiware/VCVerifier/config" + logging "fiware/VCVerifier/logging" + "fiware/VCVerifier/ssikit" + + "github.com/lestrrat-go/jwx/jwa" + "github.com/lestrrat-go/jwx/jwk" + "github.com/lestrrat-go/jwx/jwt" +) + +func TestVerifyConfig(t *testing.T) { + + logging.Configure(true, "DEBUG", true, []string{}) + + type test struct { + testName string + configToTest configModel.Verifier + expectedError error + } + + tests := []test{ + {"If all mandatory parameters are present, verfication should succeed.", configModel.Verifier{Did: "did:key:verifier", TirAddress: "http:tir.de"}, nil}, + {"If no TIR is configured, the verification should fail.", configModel.Verifier{Did: "did:key:verifier"}, ErrorNoTIR}, + {"If no DID is configured, the verification should fail.", configModel.Verifier{TirAddress: "http:tir.de"}, ErrorNoDID}, + {"If no DID and TIR is configured, the verification should fail.", configModel.Verifier{}, ErrorNoDID}, + } + + for _, tc := range tests { + + logging.Log().Info("TestVerifyConfig +++++++++++++++++ Running test: ", tc.testName) + + verificationResult := verifyConfig(&tc.configToTest) + if verificationResult != tc.expectedError { + t.Errorf("%s - Expected %v but was %v.", tc.testName, tc.expectedError, verificationResult) + } + } + +} + +type mockNonceGenerator struct { + staticValues []string +} + +func (mng *mockNonceGenerator) GenerateNonce() string { + nonce := "myMockNonce" + if len(mng.staticValues) > 0 { + nonce = mng.staticValues[0] + copy(mng.staticValues[0:], mng.staticValues[1:]) + mng.staticValues[len(mng.staticValues)-1] = "" + mng.staticValues = mng.staticValues[:len(mng.staticValues)-1] + } + return nonce +} + +type mockSessionCache struct { + sessions map[string]loginSession + errorToThrow error +} +type mockTokenCache struct { + tokens map[string]tokenStore + errorToThrow error +} + +func (msc *mockSessionCache) Add(k string, x interface{}, d time.Duration) error { + if msc.errorToThrow != nil { + return msc.errorToThrow + } + msc.sessions[k] = x.(loginSession) + return nil +} + +func (msc *mockSessionCache) Get(k string) (interface{}, bool) { + v, found := msc.sessions[k] + return v, found +} + +func (msc *mockSessionCache) Delete(k string) { + delete(msc.sessions, k) +} + +func (mtc *mockTokenCache) Add(k string, x interface{}, d time.Duration) error { + if mtc.errorToThrow != nil { + return mtc.errorToThrow + } + mtc.tokens[k] = x.(tokenStore) + return nil +} + +func (mtc *mockTokenCache) Get(k string) (interface{}, bool) { + v, found := mtc.tokens[k] + return v, found +} + +func (mtc *mockTokenCache) Delete(k string) { + delete(mtc.tokens, k) +} + +type siopInitTest struct { + testName string + testHost string + testProtocol string + testAddress string + testSessionId string + scopeConfig string + expectedCallback string + expectedConnection string + sessionCacheError error + expectedError error +} + +func TestInitSiopFlow(t *testing.T) { + + logging.Configure(true, "DEBUG", true, []string{}) + + tests := getInitSiopTests() + for _, tc := range tests { + + logging.Log().Info("TestInitSiopFlow +++++++++++++++++ Running test: ", tc.testName) + sessionCache := mockSessionCache{sessions: map[string]loginSession{}, errorToThrow: tc.sessionCacheError} + nonceGenerator := mockNonceGenerator{staticValues: []string{"randomState", "randomNonce"}} + verifier := SsiKitVerifier{did: "did:key:verifier", scope: tc.scopeConfig, sessionCache: &sessionCache, nonceGenerator: &nonceGenerator} + authReq, err := verifier.initSiopFlow(tc.testHost, tc.testProtocol, tc.testAddress, tc.testSessionId) + verifyInitTest(t, tc, authReq, err, sessionCache, false) + } +} + +// the start siop flow method just returns the init result, therefor the test is basically the same +func TestStartSiopFlow(t *testing.T) { + + logging.Configure(true, "DEBUG", true, []string{}) + + tests := getInitSiopTests() + for _, tc := range tests { + logging.Log().Info("TestStartSiopFlow +++++++++++++++++ Running test: ", tc.testName) + + sessionCache := mockSessionCache{sessions: map[string]loginSession{}, errorToThrow: tc.sessionCacheError} + nonceGenerator := mockNonceGenerator{staticValues: []string{"randomState", "randomNonce"}} + verifier := SsiKitVerifier{did: "did:key:verifier", scope: tc.scopeConfig, sessionCache: &sessionCache, nonceGenerator: &nonceGenerator} + authReq, err := verifier.StartSiopFlow(tc.testHost, tc.testProtocol, tc.testAddress, tc.testSessionId) + verifyInitTest(t, tc, authReq, err, sessionCache, false) + } +} + +func verifyInitTest(t *testing.T, tc siopInitTest, authRequest string, err error, sessionCache mockSessionCache, sameDevice bool) { + if tc.expectedError != err { + t.Errorf("%s - Expected %v but was %v.", tc.testName, tc.expectedError, err) + } + if tc.expectedError != nil { + // if the error was successfully verfied, we can just continue + return + } + if authRequest != tc.expectedConnection { + t.Errorf("%s - Expected %s but was %s.", tc.testName, tc.expectedConnection, authRequest) + } + cachedSession, found := sessionCache.sessions["randomState"] + if !found { + t.Errorf("%s - A login session should have been stored.", tc.testName) + } + expectedSession := loginSession{sameDevice, tc.expectedCallback, tc.testSessionId} + if cachedSession != expectedSession { + t.Errorf("%s - The login session was expected to be %v but was %v.", tc.testName, expectedSession, cachedSession) + } +} + +func getInitSiopTests() []siopInitTest { + + cacheFailError := errors.New("cache_fail") + + return []siopInitTest{ + {"If all parameters are set, a proper connection string should be returned.", "verifier.org", "https", "https://client.org/callback", "my-super-random-id", "", "https://client.org/callback", + "openid://?response_type=vp_token&response_mode=direct_post&client_id=did:key:verifier&redirect_uri=https://verifier.org/api/v1/authentication_response&state=randomState&nonce=randomNonce", nil, nil, + }, + {"The scope should be included if configured.", "verifier.org", "https", "https://client.org/callback", "my-super-random-id", "org.fiware.MySpecialCredential", "https://client.org/callback", + "openid://?response_type=vp_token&response_mode=direct_post&client_id=did:key:verifier&redirect_uri=https://verifier.org/api/v1/authentication_response&state=randomState&nonce=randomNonce&scope=org.fiware.MySpecialCredential", nil, nil, + }, + {"If the login-session could not be cached, an error should be thrown.", "verifier.org", "https", "https://client.org/callback", "my-super-random-id", "org.fiware.MySpecialCredential", "https://client.org/callback", + "", cacheFailError, cacheFailError, + }, + } +} + +func TestStartSameDeviceFlow(t *testing.T) { + + cacheFailError := errors.New("cache_fail") + logging.Configure(true, "DEBUG", true, []string{}) + + tests := []siopInitTest{ + {"If everything is provided, a samedevice flow should be started.", "myhost.org", "https", "/redirect", "my-random-session-id", "", "https://myhost.org/redirect", + "https://myhost.org/redirect?response_type=vp_token&response_mode=direct_post&client_id=did:key:verifier&redirect_uri=https://myhost.org/api/v1/authentication_response&state=randomState&nonce=randomNonce", nil, nil, + }, + {"The scope should be included if configured.", "myhost.org", "https", "/redirect", "my-random-session-id", "org.fiware.MySpecialCredential", "https://myhost.org/redirect", + "https://myhost.org/redirect?response_type=vp_token&response_mode=direct_post&client_id=did:key:verifier&redirect_uri=https://myhost.org/api/v1/authentication_response&state=randomState&nonce=randomNonce&scope=org.fiware.MySpecialCredential", nil, nil, + }, + {"If the request cannot be cached, an error should be responded.", "myhost.org", "https", "/redirect", "my-random-session-id", "", "https://myhost.org/redirect", + "", cacheFailError, cacheFailError, + }, + } + + for _, tc := range tests { + + logging.Log().Info("TestSameDeviceFlow +++++++++++++++++ Running test: ", tc.testName) + sessionCache := mockSessionCache{sessions: map[string]loginSession{}, errorToThrow: tc.sessionCacheError} + nonceGenerator := mockNonceGenerator{staticValues: []string{"randomState", "randomNonce"}} + verifier := SsiKitVerifier{did: "did:key:verifier", scope: tc.scopeConfig, sessionCache: &sessionCache, nonceGenerator: &nonceGenerator} + authReq, err := verifier.StartSameDeviceFlow(tc.testHost, tc.testProtocol, tc.testSessionId, tc.testAddress) + verifyInitTest(t, tc, authReq, err, sessionCache, true) + } + +} + +type mockSsiKit struct { + verificationResults []bool + verificationError error +} + +func (msk *mockSsiKit) VerifyVC(policies []ssikit.Policy, verifiableCredential map[string]interface{}) (result bool, err error) { + if msk.verificationError != nil { + return result, msk.verificationError + } + result = msk.verificationResults[0] + copy(msk.verificationResults[0:], msk.verificationResults[1:]) + msk.verificationResults[len(msk.verificationResults)-1] = false + msk.verificationResults = msk.verificationResults[:len(msk.verificationResults)-1] + return +} + +type mockHttpClient struct { + callbackError error + lastRequest *url.URL +} + +var lastRequest *url.URL + +func (mhc mockHttpClient) Do(req *http.Request) (r *http.Response, err error) { + if mhc.callbackError != nil { + return r, mhc.callbackError + } + + lastRequest = req.URL + return +} + +func (mhc mockHttpClient) PostForm(url string, data url.Values) (r *http.Response, err error) { + // not used + return +} + +type authTest struct { + testName string + sameDevice bool + testState string + testVC []map[string]interface{} + testHolder string + testSession loginSession + requestedState string + callbackError error + verificationResult []bool + verificationError error + expectedResponse SameDeviceResponse + expectedCallback *url.URL + expectedError error + tokenCacheError error +} + +func TestAuthenticationResponse(t *testing.T) { + logging.Configure(true, "DEBUG", true, []string{}) + + ssiKitError := errors.New("ssikit_failure") + cacheError := errors.New("cache_failure") + callbackError := errors.New("callback_failure") + + tests := []authTest{ + // general behaviour + {"If the credential is invalid, return an error.", true, "login-state", []map[string]interface{}{getVC("vc")}, "holder", loginSession{true, "https://myhost.org/callback", "my-session"}, "login-state", nil, []bool{false}, nil, SameDeviceResponse{}, nil, ErrorInvalidVC, nil}, + {"If one credential is invalid, return an error.", true, "login-state", []map[string]interface{}{getVC("vc1"), getVC("vc2")}, "holder", loginSession{true, "https://myhost.org/callback", "my-session"}, "login-state", nil, []bool{true, false}, nil, SameDeviceResponse{}, nil, ErrorInvalidVC, nil}, + {"If an authentication response is received without a session, an error should be responded.", true, "", []map[string]interface{}{getVC("vc")}, "holder", loginSession{}, "login-state", nil, []bool{}, nil, SameDeviceResponse{}, nil, ErrorNoSuchSession, nil}, + {"If ssiKit throws an error, an error should be responded.", true, "login-state", []map[string]interface{}{getVC("vc")}, "holder", loginSession{true, "https://myhost.org/callback", "my-session"}, "login-state", nil, []bool{}, ssiKitError, SameDeviceResponse{}, nil, ssiKitError, nil}, + {"If tokenCache throws an error, an error should be responded.", true, "login-state", []map[string]interface{}{getVC("vc")}, "holder", loginSession{true, "https://myhost.org/callback", "my-session"}, "login-state", nil, []bool{true}, nil, SameDeviceResponse{}, nil, cacheError, cacheError}, + {"If the credential is invalid, return an error.", false, "login-state", []map[string]interface{}{getVC("vc")}, "holder", loginSession{false, "https://myhost.org/callback", "my-session"}, "login-state", nil, []bool{false}, nil, SameDeviceResponse{}, nil, ErrorInvalidVC, nil}, + {"If one credential is invalid, return an error.", false, "login-state", []map[string]interface{}{getVC("vc1"), getVC("vc2")}, "holder", loginSession{false, "https://myhost.org/callback", "my-session"}, "login-state", nil, []bool{true, false}, nil, SameDeviceResponse{}, nil, ErrorInvalidVC, nil}, + {"If an authentication response is received without a session, an error should be responded.", false, "", []map[string]interface{}{getVC("vc")}, "holder", loginSession{}, "login-state", nil, []bool{}, nil, SameDeviceResponse{}, nil, ErrorNoSuchSession, nil}, + {"If ssiKit throws an error, an error should be responded.", false, "login-state", []map[string]interface{}{getVC("vc")}, "holder", loginSession{false, "https://myhost.org/callback", "my-session"}, "login-state", nil, []bool{}, ssiKitError, SameDeviceResponse{}, nil, ssiKitError, nil}, + {"If tokenCache throws an error, an error should be responded.", false, "login-state", []map[string]interface{}{getVC("vc")}, "holder", loginSession{false, "https://myhost.org/callback", "my-session"}, "login-state", nil, []bool{true}, nil, SameDeviceResponse{}, nil, cacheError, cacheError}, + {"If a non-existent session is requested, an error should be responded.", false, "login-state", []map[string]interface{}{getVC("vc")}, "holder", loginSession{false, "https://myhost.org/callback", "my-session"}, "non-existent-state", nil, []bool{true}, nil, SameDeviceResponse{}, nil, ErrorNoSuchSession, nil}, + + // same-device flow + {"When a same device flow is present, a proper response should be returned.", true, "login-state", []map[string]interface{}{getVC("vc")}, "holder", loginSession{true, "https://myhost.org/callback", "my-session"}, "login-state", nil, []bool{true}, nil, SameDeviceResponse{"https://myhost.org/callback", "authCode", "my-session"}, nil, nil, nil}, + {"When a same device flow is present, a proper response should be returned for VPs.", true, "login-state", []map[string]interface{}{getVC("vc1"), getVC("vc2")}, "holder", loginSession{true, "https://myhost.org/callback", "my-session"}, "login-state", nil, []bool{true, true}, nil, SameDeviceResponse{"https://myhost.org/callback", "authCode", "my-session"}, nil, nil, nil}, + + // cross-device flow + {"When a cross-device flow is present, a proper response should be sent to the requestors callback.", false, "login-state", []map[string]interface{}{getVC("vc")}, "holder", loginSession{false, "https://myhost.org/callback", "my-session"}, "login-state", nil, []bool{true}, nil, SameDeviceResponse{}, getRequest("https://myhost.org/callback?code=authCode&state=my-session"), nil, nil}, + {"When a cross-device flow is present, a proper response should be sent to the requestors callback for VPs.", false, "login-state", []map[string]interface{}{getVC("vc1"), getVC("vc2")}, "holder", loginSession{false, "https://myhost.org/callback", "my-session"}, "login-state", nil, []bool{true, true}, nil, SameDeviceResponse{}, getRequest("https://myhost.org/callback?code=authCode&state=my-session"), nil, nil}, + {"When the requestor-callback fails, an error should be returned.", false, "login-state", []map[string]interface{}{getVC("vc")}, "holder", loginSession{false, "https://myhost.org/callback", "my-session"}, "login-state", callbackError, []bool{true}, nil, SameDeviceResponse{}, nil, callbackError, nil}, + } + + for _, tc := range tests { + + logging.Log().Info("TestAuthenticationResponse +++++++++++++++++ Running test: ", tc.testName) + sessionCache := mockSessionCache{sessions: map[string]loginSession{}} + + // initialize siop session + if tc.testSession != (loginSession{}) { + sessionCache.sessions[tc.testState] = tc.testSession + } + + tokenCache := mockTokenCache{tokens: map[string]tokenStore{}, errorToThrow: tc.tokenCacheError} + + httpClient = mockHttpClient{tc.callbackError, nil} + ecdsKey, _ := ecdsa.GenerateKey(elliptic.P256(), rand.Reader) + testKey, _ := jwk.New(ecdsKey) + jwk.AssignKeyID(testKey) + nonceGenerator := mockNonceGenerator{staticValues: []string{"authCode"}} + verifier := SsiKitVerifier{did: "did:key:verifier", signingKey: testKey, tokenCache: &tokenCache, sessionCache: &sessionCache, nonceGenerator: &nonceGenerator, ssiKitClient: &mockSsiKit{tc.verificationResult, tc.verificationError}, clock: mockClock{}} + + sameDeviceResponse, err := verifier.AuthenticationResponse(tc.requestedState, tc.testVC, tc.testHolder) + if err != tc.expectedError { + t.Errorf("%s - Expected error %v but was %v.", tc.testName, tc.expectedError, err) + } + if tc.expectedError != nil { + continue + } + + if tc.sameDevice { + verifySameDevice(t, sameDeviceResponse, tokenCache, tc) + continue + } + + if *tc.expectedCallback != *lastRequest { + t.Errorf("%s - Expected callback %s but was %s.", tc.testName, tc.expectedCallback, lastRequest) + } + + } +} + +func verifySameDevice(t *testing.T, sdr SameDeviceResponse, tokenCache mockTokenCache, tc authTest) { + if sdr != tc.expectedResponse { + t.Errorf("%s - Expected response %v but was %v.", tc.testName, tc.expectedResponse, sdr) + } + _, found := tokenCache.tokens[sdr.Code] + if !found { + t.Errorf("%s - No token was cached.", tc.testName) + } +} + +func getVC(id string) map[string]interface{} { + return map[string]interface{}{ + "@context": []string{ + "https://www.w3.org/2018/credentials/v1", + "https://happypets.fiware.io/2022/credentials/employee/v1", + }, + "id": "https://happypets.fiware.io/credential/25159389-8dd17b796ac0", + "type": []string{ + "VerifiableCredential", + "CustomerCredential", + }, + "issuer": "did:key:verifier", + "issuanceDate": "2022-11-23T15:23:13Z", + "validFrom": "2022-11-23T15:23:13Z", + "expirationDate": "2032-11-23T15:23:13Z", + "credentialSubject": map[string]interface{}{ + "id": id, + "target": "did:ebsi:packetdelivery", + }, + } +} + +func getRequest(request string) *url.URL { + url, _ := url.Parse(request) + return url +} + +func TestInitVerifier(t *testing.T) { + + logging.Configure(true, "DEBUG", true, []string{}) + + type test struct { + testName string + testConfig configModel.Verifier + expectedError error + } + + tests := []test{ + {"A verifier should be properly intantiated.", configModel.Verifier{Did: "did:key:verifier", TirAddress: "https://tir.org", SessionExpiry: 30, RequestScope: "org.fiware.MyVC"}, nil}, + {"Without a did, no verifier should be instantiated.", configModel.Verifier{TirAddress: "https://tir.org", SessionExpiry: 30, RequestScope: "org.fiware.MyVC"}, ErrorNoDID}, + {"Without a tir, no verifier should be instantiated.", configModel.Verifier{Did: "did:key:verifier", SessionExpiry: 30, RequestScope: "org.fiware.MyVC"}, ErrorNoTIR}, + } + + for _, tc := range tests { + + verifier = nil + logging.Log().Info("TestInitVerifier +++++++++++++++++ Running test: ", tc.testName) + + err := InitVerifier(&tc.testConfig, &mockSsiKit{}) + if tc.expectedError != err { + t.Errorf("%s - Expected error %v but was %v.", tc.testName, tc.expectedError, err) + } + if tc.expectedError != nil && GetVerifier() != nil { + t.Errorf("%s - When an error happens, no verifier should be created.", tc.testName) + continue + } + if tc.expectedError != nil { + continue + } + + if GetVerifier() == nil { + t.Errorf("%s - Verifier should have been initiated, but is not available.", tc.testName) + } + } +} + +func TestGetJWKS(t *testing.T) { + logging.Configure(true, "DEBUG", true, []string{}) + + ecdsKey, _ := ecdsa.GenerateKey(elliptic.P256(), rand.Reader) + testKey, _ := jwk.New(ecdsKey) + + verifier := SsiKitVerifier{signingKey: testKey} + + jwks := verifier.GetJWKS() + + if jwks.Len() != 1 { + t.Errorf("TestGetJWKS: Exactly the current signing key should be included.") + } + returnedKey, _ := jwks.Get(0) + expectedKey, _ := testKey.PublicKey() + // we compare the json-output to avoid address comparison instead of by-value. + if logging.PrettyPrintObject(expectedKey) != logging.PrettyPrintObject(returnedKey) { + t.Errorf("TestGetJWKS: Exactly the public key should be returned. Expected %v but was %v.", logging.PrettyPrintObject(expectedKey), logging.PrettyPrintObject(returnedKey)) + } +} + +type mockClock struct{} + +func (mockClock) Now() time.Time { + return time.Unix(0, 0) +} + +type mockTokenSigner struct { + signingError error +} + +func (mts mockTokenSigner) Sign(t jwt.Token, alg jwa.SignatureAlgorithm, key interface{}, options ...jwt.SignOption) ([]byte, error) { + if mts.signingError != nil { + return []byte{}, mts.signingError + } + return jwt.Sign(t, alg, key, options...) +} + +func TestGetToken(t *testing.T) { + + logging.Configure(true, "DEBUG", true, []string{}) + + signingError := errors.New("signature_failure") + + ecdsKey, _ := ecdsa.GenerateKey(elliptic.P256(), rand.Reader) + testKey, _ := jwk.New(ecdsKey) + publicKey, _ := testKey.PublicKey() + + type test struct { + testName string + testGrantType string + testCode string + testRedirectUri string + tokenSession map[string]tokenStore + signingKey jwk.Key + signingError error + expectedJWT jwt.Token + expectedExpiration int64 + expectedError error + } + + tests := []test{ + {"If a valid code is provided, the token should be returned.", "authorization_code", "my-auth-code", "https://myhost.org/redirect", map[string]tokenStore{"my-auth-code": {token: getToken(), redirect_uri: "https://myhost.org/redirect"}}, testKey, nil, getToken(), 1000, nil}, + {"If the wrong grant_type is provided, an error should be returned.", "implicit", "my-auth-code", "https://myhost.org/redirect", map[string]tokenStore{"my-auth-code": {token: getToken(), redirect_uri: "https://myhost.org/redirect"}}, testKey, nil, nil, 0, ErrorWrongGrantType}, + {"If the no such code exists, an error should be returned.", "authorization_code", "another-auth-code", "https://myhost.org/redirect", map[string]tokenStore{"my-auth-code": {token: getToken(), redirect_uri: "https://myhost.org/redirect"}}, testKey, nil, nil, 0, ErrorNoSuchCode}, + {"If the redirect uri does not match, an error should be returned.", "authorization_code", "my-auth-code", "https://my-other-host.org/redirect", map[string]tokenStore{"my-auth-code": {token: getToken(), redirect_uri: "https://myhost.org/redirect"}}, testKey, nil, nil, 0, ErrorRedirectUriMismatch}, + {"If the token cannot be signed, an error should be returned.", "authorization_code", "my-auth-code", "https://myhost.org/redirect", map[string]tokenStore{"my-auth-code": {token: getToken(), redirect_uri: "https://myhost.org/redirect"}}, testKey, signingError, nil, 0, signingError}, + } + + for _, tc := range tests { + + logging.Log().Info("TestGetToken +++++++++++++++++ Running test: ", tc.testName) + + tokenCache := mockTokenCache{tokens: tc.tokenSession} + verifier := SsiKitVerifier{tokenCache: &tokenCache, signingKey: testKey, clock: mockClock{}, tokenSigner: mockTokenSigner{tc.signingError}} + jwtString, expiration, err := verifier.GetToken(tc.testGrantType, tc.testCode, tc.testRedirectUri) + + if err != tc.expectedError { + t.Errorf("%s - Expected error %v but was %v.", tc.testName, tc.expectedError, err) + continue + } + if tc.expectedError != nil { + // we successfully verified that it failed. + continue + } + + returnedToken, err := jwt.Parse([]byte(jwtString), jwt.WithVerify(jwa.ES256, publicKey)) + + if err != nil { + t.Errorf("%s - No valid token signature. Err: %v", tc.testName, err) + continue + } + if logging.PrettyPrintObject(returnedToken) != logging.PrettyPrintObject(tc.expectedJWT) { + t.Errorf("%s - Expected jwt %s but was %s.", tc.testName, logging.PrettyPrintObject(tc.expectedJWT), logging.PrettyPrintObject(returnedToken)) + continue + } + if expiration != tc.expectedExpiration { + t.Errorf("%s - Expected expiration %v but was %v.", tc.testName, tc.expectedExpiration, expiration) + continue + } + } +} + +func getToken() jwt.Token { + token, _ := jwt.NewBuilder().Expiration(time.Unix(1000, 0)).Build() + return token +} diff --git a/back/www/css/mystyle.css b/views/static/css/mystyle.css similarity index 100% rename from back/www/css/mystyle.css rename to views/static/css/mystyle.css diff --git a/back/www/css/prism.css b/views/static/css/prism.css similarity index 100% rename from back/www/css/prism.css rename to views/static/css/prism.css diff --git a/back/www/css/w3pro.css b/views/static/css/w3pro.css similarity index 100% rename from back/www/css/w3pro.css rename to views/static/css/w3pro.css diff --git a/back/www/img/evidencesmall.png b/views/static/img/evidencesmall.png similarity index 100% rename from back/www/img/evidencesmall.png rename to views/static/img/evidencesmall.png diff --git a/views/static/img/logo.png b/views/static/img/logo.png new file mode 100644 index 00000000..88974aee Binary files /dev/null and b/views/static/img/logo.png differ diff --git a/back/www/img/logo.svg b/views/static/img/logo.svg similarity index 100% rename from back/www/img/logo.svg rename to views/static/img/logo.svg diff --git a/back/www/img/meme.png b/views/static/img/meme.png similarity index 100% rename from back/www/img/meme.png rename to views/static/img/meme.png diff --git a/back/www/js/app.js b/views/static/js/app.js similarity index 100% rename from back/www/js/app.js rename to views/static/js/app.js diff --git a/back/www/js/prism.js b/views/static/js/prism.js similarity index 100% rename from back/www/js/prism.js rename to views/static/js/prism.js diff --git a/views/verifier_present_qr.html b/views/verifier_present_qr.html new file mode 100644 index 00000000..d7379398 --- /dev/null +++ b/views/verifier_present_qr.html @@ -0,0 +1,31 @@ +{{define "verifier_present_qr"}} + + + + + + + + + + + + Credential Verifier + + + + +
+ FIWARE + +
+
+ +

Scan this QR code to authenticate with a mobile

+ + the qr. + +
+ + +{{end}} \ No newline at end of file