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

integration with 3divi to fetch KYC state into eskimo, availability #133

Merged
merged 3 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ kyc/social:
- US
facebook:
allow-long-live-tokens: true
kyc/face:
threeDiVi:
bafToken: bogus
bafHost: http://bogus.com/
availabilityUrl:
concurrentUsers: 1
kyc/quiz:
environment: local
enable-alerts: false
Expand Down
8 changes: 8 additions & 0 deletions cmd/eskimo-hut/api/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1638,6 +1638,10 @@ const docTemplate = `{
"type": "string",
"example": "did:ethr:0x4B73C58370AEfcEf86A6021afCDe5673511376B2"
},
"kycFaceAvailable": {
"type": "boolean",
"example": true
},
"kycQuizAvailabilityEndedAt": {
"type": "string"
},
Expand Down Expand Up @@ -1962,6 +1966,10 @@ const docTemplate = `{
"type": "string",
"example": "did:ethr:0x4B73C58370AEfcEf86A6021afCDe5673511376B2"
},
"kycFaceAvailable": {
"type": "boolean",
"example": true
},
"kycQuizAvailabilityEndedAt": {
"type": "string"
},
Expand Down
8 changes: 8 additions & 0 deletions cmd/eskimo-hut/api/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1632,6 +1632,10 @@
"type": "string",
"example": "did:ethr:0x4B73C58370AEfcEf86A6021afCDe5673511376B2"
},
"kycFaceAvailable": {
"type": "boolean",
"example": true
},
"kycQuizAvailabilityEndedAt": {
"type": "string"
},
Expand Down Expand Up @@ -1956,6 +1960,10 @@
"type": "string",
"example": "did:ethr:0x4B73C58370AEfcEf86A6021afCDe5673511376B2"
},
"kycFaceAvailable": {
"type": "boolean",
"example": true
},
"kycQuizAvailabilityEndedAt": {
"type": "string"
},
Expand Down
6 changes: 6 additions & 0 deletions cmd/eskimo-hut/api/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ definitions:
id:
example: did:ethr:0x4B73C58370AEfcEf86A6021afCDe5673511376B2
type: string
kycFaceAvailable:
example: true
type: boolean
kycQuizAvailabilityEndedAt:
type: string
kycQuizAvailabilityStartedAt:
Expand Down Expand Up @@ -325,6 +328,9 @@ definitions:
id:
example: did:ethr:0x4B73C58370AEfcEf86A6021afCDe5673511376B2
type: string
kycFaceAvailable:
example: true
type: boolean
kycQuizAvailabilityEndedAt:
type: string
kycQuizAvailabilityStartedAt:
Expand Down
6 changes: 5 additions & 1 deletion cmd/eskimo-hut/contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/pkg/errors"

emaillink "github.com/ice-blockchain/eskimo/auth/email_link"
facekyc "github.com/ice-blockchain/eskimo/kyc/face"
kycquiz "github.com/ice-blockchain/eskimo/kyc/quiz"
kycsocial "github.com/ice-blockchain/eskimo/kyc/social"
"github.com/ice-blockchain/eskimo/users"
Expand Down Expand Up @@ -128,7 +129,8 @@ type (
User struct {
*users.User
*kycquiz.QuizStatus
Checksum string `json:"checksum,omitempty" example:"1232412415326543647657"`
Checksum string `json:"checksum,omitempty" example:"1232412415326543647657"`
KycFaceAvailable bool `json:"kycFaceAvailable,omitempty" example:"true"`
}
Auth struct {
LoginSession string `json:"loginSession" example:"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJPbmxpbmUgSldUIEJ1aWxkZXIiLCJpYXQiOjE2ODQzMjQ0NTYsImV4cCI6MTcxNTg2MDQ1NiwiYXVkIjoiIiwic3ViIjoianJvY2tldEBleGFtcGxlLmNvbSIsIm90cCI6IjUxMzRhMzdkLWIyMWEtNGVhNi1hNzk2LTAxOGIwMjMwMmFhMCJ9.q3xa8Gwg2FVCRHLZqkSedH3aK8XBqykaIy85rRU40nM"` //nolint:lll // .
Expand Down Expand Up @@ -156,6 +158,7 @@ type (
XClientType string `form:"x_client_type" swaggerignore:"true" required:"false" example:"web"`
}
TryResetKYCStepsRequestBody struct {
NextKYCStep *users.KYCStep `form:"nextKYCStep" required:"false" swaggerignore:"true" example:"1"`
Authorization string `header:"Authorization" swaggerignore:"true" required:"true" example:"some token"`
XAccountMetadata string `header:"X-Account-Metadata" swaggerignore:"true" required:"false" example:"some token"`
UserID string `uri:"userId" required:"true" allowForbiddenWriteOperation:"true" swaggerignore:"true" example:"did:ethr:0x4B73C58370AEfcEf86A6021afCDe5673511376B2"` //nolint:lll // .
Expand Down Expand Up @@ -220,6 +223,7 @@ type (
quizRepository kycquiz.Repository
authEmailLinkClient emaillink.Client
socialRepository kycsocial.Repository
faceKycClient facekyc.Client
}
config struct {
APIKey string `yaml:"api-key" mapstructure:"api-key"` //nolint:tagliatelle // Nope.
Expand Down
2 changes: 2 additions & 0 deletions cmd/eskimo-hut/eskimo_hut.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

emaillink "github.com/ice-blockchain/eskimo/auth/email_link"
"github.com/ice-blockchain/eskimo/cmd/eskimo-hut/api"
facekyc "github.com/ice-blockchain/eskimo/kyc/face"
kycquiz "github.com/ice-blockchain/eskimo/kyc/quiz"
"github.com/ice-blockchain/eskimo/kyc/social"
"github.com/ice-blockchain/eskimo/users"
Expand Down Expand Up @@ -53,6 +54,7 @@ func (s *service) Init(ctx context.Context, cancel context.CancelFunc) {
s.authEmailLinkClient = emaillink.NewClient(ctx, s.usersProcessor, server.Auth(ctx))
s.socialRepository = social.New(ctx, s.usersProcessor)
s.quizRepository = kycquiz.NewRepository(ctx, s.usersProcessor)
s.faceKycClient = facekyc.New(s.usersProcessor)
}

func (s *service) Close(ctx context.Context) error {
Expand Down
12 changes: 10 additions & 2 deletions cmd/eskimo-hut/kyc.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,15 @@ func (s *service) TryResetKYCSteps( //nolint:gocritic,funlen,gocognit,revive,cyc
if err != nil {
return nil, server.Unexpected(errors.Wrapf(err, "failed to CheckQuizStatus for userID:%v", req.Data.UserID))
}
resp, err := s.usersProcessor.TryResetKYCSteps(ctx, req.Data.UserID)
kycFaceAvailable := false
if req.Data.NextKYCStep != nil &&
(*req.Data.NextKYCStep == users.FacialRecognitionKYCStep || *req.Data.NextKYCStep == users.LivenessDetectionKYCStep) {
kycFaceAvailable, err = s.faceKycClient.CheckStatus(ctx, req.Data.UserID, *req.Data.NextKYCStep)
if err != nil {
return nil, server.Unexpected(err)
}
}
resp, err := s.usersProcessor.TryResetKYCSteps(ctx, s.faceKycClient, req.Data.UserID)
if err = errors.Wrapf(err, "failed to TryResetKYCSteps for userID:%v", req.Data.UserID); err != nil {
switch {
case errors.Is(err, users.ErrNotFound):
Expand All @@ -302,5 +310,5 @@ func (s *service) TryResetKYCSteps( //nolint:gocritic,funlen,gocognit,revive,cyc
}
}

return server.OK(&User{User: resp, QuizStatus: quizStatus, Checksum: resp.Checksum()}), nil
return server.OK(&User{User: resp, QuizStatus: quizStatus, KycFaceAvailable: kycFaceAvailable, Checksum: resp.Checksum()}), nil
}
4 changes: 2 additions & 2 deletions cmd/fixture/fixture.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (b *TestConnectorsBridge) CreateUser(ctx context.Context, tb testing.TB, us
l, err := strconv.Atoi(headers.Get("Content-Length"))
require.NoError(tb, err)
assert.NotEmpty(tb, body)
assert.Greater(tb, l, 0)
assert.Positive(tb, l)
headers.Del("Date")
headers.Del("Content-Length")
assert.Equal(tb, http.Header{"Content-Type": []string{"application/json; charset=utf-8"}}, headers)
Expand Down Expand Up @@ -114,7 +114,7 @@ func (b *TestConnectorsBridge) GetUser(ctx context.Context, tb testing.TB, userI
l, err := strconv.Atoi(headers.Get("Content-Length"))
require.NoError(tb, err)
assert.NotEmpty(tb, body)
assert.Greater(tb, l, 0)
assert.Positive(tb, l)
headers.Del("Date")
headers.Del("Content-Length")
assert.Equal(tb, http.Header{"Content-Type": []string{"application/json; charset=utf-8"}}, headers)
Expand Down
36 changes: 24 additions & 12 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,20 @@ require (
github.com/ice-blockchain/wintr v1.135.0
github.com/imroc/req/v3 v3.43.5
github.com/ip2location/ip2location-go/v9 v9.7.0
github.com/jackc/pgx/v5 v5.5.5
github.com/jackc/pgx/v5 v5.6.0
github.com/pkg/errors v0.9.1
github.com/prometheus/common v0.53.0
github.com/prometheus/prometheus v0.52.0
github.com/stretchr/testify v1.9.0
github.com/swaggo/swag v1.16.3
github.com/testcontainers/testcontainers-go v0.31.0
github.com/testcontainers/testcontainers-go v0.30.0
github.com/zeebo/xxh3 v1.0.2
golang.org/x/mod v0.17.0
golang.org/x/net v0.25.0
)

require (
cloud.google.com/go v0.113.0 // indirect
cloud.google.com/go v0.114.0 // indirect
cloud.google.com/go/auth v0.4.2 // indirect
cloud.google.com/go/auth/oauth2adapt v0.2.2 // indirect
cloud.google.com/go/compute/metadata v0.3.0 // indirect
Expand All @@ -40,27 +42,32 @@ require (
github.com/Microsoft/hcsshim v0.12.3 // indirect
github.com/andybalholm/brotli v1.1.0 // indirect
github.com/andybalholm/cascadia v1.3.2 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bytedance/sonic v1.11.7 // indirect
github.com/bytedance/sonic/loader v0.1.1 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cloudflare/circl v1.3.8 // indirect
github.com/cloudwego/base64x v0.1.4 // indirect
github.com/cloudwego/iasm v0.2.0 // indirect
github.com/containerd/cgroups/v3 v3.0.3 // indirect
github.com/containerd/containerd v1.7.17 // indirect
github.com/containerd/containerd v1.7.15 // indirect
github.com/containerd/errdefs v0.1.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/dennwc/varint v1.0.0 // indirect
github.com/distribution/reference v0.6.0 // indirect
github.com/docker/distribution v2.8.3+incompatible // indirect
github.com/docker/docker v26.1.3+incompatible // indirect
github.com/docker/docker v26.0.1+incompatible // indirect
github.com/docker/go-connections v0.5.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/gabriel-vasile/mimetype v1.4.4 // indirect
github.com/georgysavva/scany/v2 v2.1.3 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/gin-gonic/gin v1.10.0 // indirect
github.com/go-kit/log v0.2.1 // indirect
github.com/go-logfmt/logfmt v0.6.0 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-openapi/jsonpointer v0.21.0 // indirect
Expand All @@ -76,10 +83,11 @@ require (
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/pprof v0.0.0-20240521024322-9665fa269a30 // indirect
github.com/google/pprof v0.0.0-20240528025155-186aa0362fba // indirect
github.com/google/s2a-go v0.1.7 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
github.com/googleapis/gax-go/v2 v2.12.4 // indirect
github.com/grafana/regexp v0.0.0-20240518133315-a468a5bfb3bc // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
Expand All @@ -102,17 +110,20 @@ require (
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/onsi/ginkgo/v2 v2.18.0 // indirect
github.com/onsi/ginkgo/v2 v2.19.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0 // indirect
github.com/opencontainers/runc v1.1.12 // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/pierrec/lz4/v4 v4.1.21 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.19.1 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/procfs v0.15.0 // indirect
github.com/quic-go/qpack v0.4.0 // indirect
github.com/quic-go/quic-go v0.44.0 // indirect
github.com/refraction-networking/utls v1.6.6 // indirect
github.com/rs/zerolog v1.32.0 // indirect
github.com/rs/zerolog v1.33.0 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sendgrid/rest v2.6.9+incompatible // indirect
Expand All @@ -127,8 +138,8 @@ require (
github.com/swaggo/files v1.0.1 // indirect
github.com/swaggo/gin-swagger v1.6.0 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/twmb/franz-go v1.16.1 // indirect
github.com/twmb/franz-go/pkg/kadm v1.11.0 // indirect
github.com/twmb/franz-go v1.17.0 // indirect
github.com/twmb/franz-go/pkg/kadm v1.12.0 // indirect
github.com/twmb/franz-go/pkg/kmsg v1.8.0 // indirect
github.com/ugorji/go/codec v1.2.12 // indirect
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
Expand All @@ -139,11 +150,12 @@ require (
go.opentelemetry.io/otel v1.27.0 // indirect
go.opentelemetry.io/otel/metric v1.27.0 // indirect
go.opentelemetry.io/otel/trace v1.27.0 // indirect
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/mock v0.4.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/arch v0.8.0 // indirect
golang.org/x/crypto v0.23.0 // indirect
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 // indirect
golang.org/x/exp v0.0.0-20240525044651-4c93da0ed11d // indirect
golang.org/x/oauth2 v0.20.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.20.0 // indirect
Expand Down
Loading
Loading