Skip to content

Commit

Permalink
add qr-optimization: return only get_proof_params link (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
chabanyknikita authored Sep 5, 2024
1 parent 4205390 commit 5157374
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 18 deletions.
1 change: 0 additions & 1 deletion docs/spec/components/schemas/Links.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ allOf:
properties:
attributes:
required:
- callback_url
- get_proof_params
properties:
callback_url:
Expand Down
5 changes: 4 additions & 1 deletion docs/spec/components/schemas/ProofParams.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,7 @@ allOf:
example: "0x303630393032"
citizenship_mask:
type: string
example: "0x554B52"
example: "0x554B52"
callback_url:
type: string
example: "https://example.com/integrations/verificator-svc/public/callback/c15ad8f88949"
3 changes: 3 additions & 0 deletions internal/service/handlers/proof_params.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package handlers

import (
"fmt"
"github.com/rarimo/verificator-svc/internal/service/handlers/helpers"
"github.com/rarimo/verificator-svc/internal/service/requests"
"github.com/rarimo/verificator-svc/internal/service/responses"
Expand Down Expand Up @@ -36,6 +37,7 @@ func GetProofParamsById(w http.ResponseWriter, r *http.Request) {
eventID = Verifiers(r).EventID
birthDateUpperBound = helpers.CalculateBirthDateHex(existingUser.AgeLowerBound)
proofSelector = helpers.CalculateProofSelector(existingUser.Uniqueness, existingUser.AgeLowerBound, existingUser.Nationality)
callbackURL = fmt.Sprintf("%s/integrations/verificator-svc/public/callback/%s", Callback(r).URL, userIDHash)
)

if existingUser.EventId != "" {
Expand Down Expand Up @@ -66,6 +68,7 @@ func GetProofParamsById(w http.ResponseWriter, r *http.Request) {
Selector: strconv.Itoa(proofSelector),
TimestampLowerBound: "0",
TimestampUpperBound: TimestampUpperBound,
CallbackUrl: &callbackURL,
}

ape.Render(w, responses.NewProofParamsByIdResponse(*existingUser, proofParameters))
Expand Down
1 change: 0 additions & 1 deletion internal/service/responses/verification_link.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ func NewVerificationLinkResponse(user data.VerifyUsers, host string) resources.L
Type: resources.VERIFICATION_LINK,
},
Attributes: resources.LinksAttributes{
CallbackUrl: fmt.Sprintf("%s/integrations/verificator-svc/public/callback/%s", host, user.UserIDHash),
GetProofParams: fmt.Sprintf("%s/integrations/verificator-svc/public/proof-params/%s", host, user.UserIDHash),
},
},
Expand Down
4 changes: 2 additions & 2 deletions resources/model_links_attributes.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
package resources

type LinksAttributes struct {
CallbackUrl string `json:"callback_url"`
GetProofParams string `json:"get_proof_params"`
CallbackUrl *string `json:"callback_url,omitempty"`
GetProofParams string `json:"get_proof_params"`
}
27 changes: 14 additions & 13 deletions resources/model_proof_params_attributes.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@
package resources

type ProofParamsAttributes struct {
BirthDateLowerBound string `json:"birth_date_lower_bound"`
BirthDateUpperBound string `json:"birth_date_upper_bound"`
CitizenshipMask string `json:"citizenship_mask"`
EventData string `json:"event_data"`
EventId string `json:"event_id"`
ExpirationDateLowerBound string `json:"expiration_date_lower_bound"`
ExpirationDateUpperBound string `json:"expiration_date_upper_bound"`
IdentityCounter int32 `json:"identity_counter"`
IdentityCounterLowerBound int32 `json:"identity_counter_lower_bound"`
IdentityCounterUpperBound int32 `json:"identity_counter_upper_bound"`
Selector string `json:"selector"`
TimestampLowerBound string `json:"timestamp_lower_bound"`
TimestampUpperBound string `json:"timestamp_upper_bound"`
BirthDateLowerBound string `json:"birth_date_lower_bound"`
BirthDateUpperBound string `json:"birth_date_upper_bound"`
CallbackUrl *string `json:"callback_url,omitempty"`
CitizenshipMask string `json:"citizenship_mask"`
EventData string `json:"event_data"`
EventId string `json:"event_id"`
ExpirationDateLowerBound string `json:"expiration_date_lower_bound"`
ExpirationDateUpperBound string `json:"expiration_date_upper_bound"`
IdentityCounter int32 `json:"identity_counter"`
IdentityCounterLowerBound int32 `json:"identity_counter_lower_bound"`
IdentityCounterUpperBound int32 `json:"identity_counter_upper_bound"`
Selector string `json:"selector"`
TimestampLowerBound string `json:"timestamp_lower_bound"`
TimestampUpperBound string `json:"timestamp_upper_bound"`
}

0 comments on commit 5157374

Please sign in to comment.