Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Submit verifications #855

Open
wants to merge 14 commits into
base: create_verification_tables
Choose a base branch
from

Conversation

aldigjo
Copy link

@aldigjo aldigjo commented Dec 10, 2024

Adding verification endpoints

  1. Check verification - get status and check if a verification query exists already
  2. SubmitVerificationResponse - post the proof token for an existing verification query

@aldigjo aldigjo force-pushed the submit_verifications branch from b35afec to 3a2eeb1 Compare December 10, 2024 15:42
return CheckVerification200JSONResponse{union: json.RawMessage(fmt.Sprintf(`{"query": %v}`, query))}, nil
}

return CheckVerification404JSONResponse{N404JSONResponse{Message: "Verification query not found"}}, nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default response should be 500. To return error 404 we'd check the error from the repository /service layer


// VerificationService interface
type VerificationService interface {
CheckVerification(ctx context.Context, issuerID w3c.DID, verificationQueryID uuid.UUID) (*domain.VerificationResponse, *domain.VerificationQuery, error)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

methods inside services should not contain the service name. Rename this to Check

// VerificationService interface
type VerificationService interface {
CheckVerification(ctx context.Context, issuerID w3c.DID, verificationQueryID uuid.UUID) (*domain.VerificationResponse, *domain.VerificationQuery, error)
SubmitVerificationResponse(ctx context.Context, verificationQueryID uuid.UUID, issuerID w3c.DID, token string, serverURL string) (*domain.VerificationResponse, error)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

methods inside services should not contain the service name. Rename this to SubmitResponse

@x1m3
Copy link
Contributor

x1m3 commented Dec 16, 2024

Please, run golangci-lint (or make lint) and fix linter warnings.

Copy link
Contributor

@x1m3 x1m3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aldigjo good work! I left some comments, but overall is very good!

internal/api/main_test.go Outdated Show resolved Hide resolved
api/api.yaml Outdated Show resolved Hide resolved
api/api.yaml Show resolved Hide resolved
api/api.yaml Outdated Show resolved Hide resolved
internal/api/verification.go Outdated Show resolved Hide resolved
}

nullifierSessionID := new(big.Int)
if _, ok := nullifierSessionID.SetString(val.(string), defaultBigIntBase); !ok {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should check that this conversion to string is valid. If not we will have a core dump.
Something like this.

var sVal string
	if sVal, ok = val.(string); ok {
		return nil, errors.New("nullifierSessionID is not a string")
	}

Working with map[string]interfaces needs a lot of boilerplate

@@ -101,3 +105,28 @@ func (r *VerificationRepository) AddResponse(ctx context.Context, queryID uuid.U
}
return responseID, nil
}

// GetVerificationResponse returns a verification response by scopeID and userDID
func (r *VerificationRepository) GetVerificationResponse(ctx context.Context, queryID uuid.UUID) (*domain.VerificationResponse, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need a test for this function in repositories/verification_test.go

internal/api/verification.go Show resolved Hide resolved
internal/api/verification.go Show resolved Hide resolved
internal/api/verification.go Show resolved Hide resolved
@aldigjo aldigjo force-pushed the submit_verifications branch from 392cf6f to fdb7307 Compare January 2, 2025 15:13
@aldigjo aldigjo marked this pull request as ready for review January 3, 2025 17:31
@aldigjo aldigjo requested a review from a team as a code owner January 3, 2025 17:31
@aldigjo aldigjo requested review from x1m3 and martinsaporiti January 3, 2025 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants