Skip to content

Commit

Permalink
add support of discovery-protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
volodymyr-basiuk committed Dec 23, 2024
1 parent ef00fd9 commit c33fb60
Show file tree
Hide file tree
Showing 8 changed files with 280 additions and 41 deletions.
4 changes: 3 additions & 1 deletion cmd/platform/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ func main() {
map[iden3comm.ProtocolMessage][]string{
iden3commProtocol.CredentialFetchRequestMessageType: {string(packers.MediaTypeZKPMessage)},
iden3commProtocol.RevocationStatusRequestMessageType: {"*"},
iden3commProtocol.DiscoverFeatureQueriesMessageType: {"*"},
},
*cfg.MediaTypeManager.Enabled,
)
Expand Down Expand Up @@ -155,6 +156,7 @@ func main() {
displayMethodService := services.NewDisplayMethod(repositories.NewDisplayMethod(*storage))
keyService := services.NewKey(keyStore, claimsService, keyRepository)
transactionService, err := gateways.NewTransaction(*networkResolver)
discoveryService := services.NewDiscovery(mediaTypeManager, packageManager)
if err != nil {
log.Error(ctx, "error creating transaction service", "err", err)
return
Expand Down Expand Up @@ -196,7 +198,7 @@ func main() {

api.HandlerWithOptions(
api.NewStrictHandlerWithOptions(
api.NewServer(cfg, identityService, accountService, connectionsService, claimsService, qrService, publisher, packageManager, *networkResolver, serverHealth, schemaService, linkService, displayMethodService, keyService),
api.NewServer(cfg, identityService, accountService, connectionsService, claimsService, qrService, publisher, packageManager, *networkResolver, serverHealth, schemaService, linkService, displayMethodService, keyService, discoveryService),
middlewares(ctx, cfg.HTTPBasicAuth),
api.StrictHTTPServerOptions{
RequestErrorHandlerFunc: errors.RequestErrorHandlerFunc,
Expand Down
17 changes: 10 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module github.com/polygonid/sh-id-platform

go 1.22.1
go 1.22.6

toolchain go1.23.3

require (
github.com/alicebob/miniredis/v2 v2.33.0
Expand All @@ -10,7 +12,7 @@ require (
github.com/aws/aws-sdk-go-v2/service/kms v1.35.5
github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.34.2
github.com/caarlos0/env/v11 v11.2.2
github.com/ethereum/go-ethereum v1.14.8
github.com/ethereum/go-ethereum v1.14.11
github.com/getkin/kin-openapi v0.127.0
github.com/go-chi/chi/v5 v5.1.0
github.com/go-chi/cors v1.2.1
Expand All @@ -24,7 +26,7 @@ require (
github.com/iden3/contracts-abi/onchain-credential-status-resolver/go/abi v0.0.0-20230911113809-c58b7e7a69b0
github.com/iden3/contracts-abi/state/go/abi v1.0.2-0.20230911112726-4533c5701af1
github.com/iden3/go-circuits/v2 v2.4.0
github.com/iden3/go-iden3-auth/v2 v2.5.0
github.com/iden3/go-iden3-auth/v2 v2.6.0
github.com/iden3/go-iden3-core/v2 v2.3.1
github.com/iden3/go-iden3-crypto v0.0.17
github.com/iden3/go-jwz/v2 v2.2.0
Expand All @@ -36,7 +38,7 @@ require (
github.com/iden3/go-rapidsnark/witness/wazero v0.0.0-20240914111027-9588ce2d7e1b
github.com/iden3/go-schema-processor v1.3.1
github.com/iden3/go-schema-processor/v2 v2.6.1
github.com/iden3/iden3comm/v2 v2.6.0
github.com/iden3/iden3comm/v2 v2.9.2-0.20241220155923-303258bd747f
github.com/iden3/merkletree-proof v0.3.0
github.com/ipfs/go-ipfs-api v0.7.0
github.com/jackc/pgconn v1.14.3
Expand Down Expand Up @@ -119,7 +121,7 @@ require (
github.com/cockroachdb/errors v1.11.3 // indirect
github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce // indirect
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
github.com/cockroachdb/pebble v1.1.1 // indirect
github.com/cockroachdb/pebble v1.1.2 // indirect
github.com/cockroachdb/redact v1.1.5 // indirect
github.com/consensys/bavard v0.1.13 // indirect
github.com/consensys/gnark-crypto v0.12.1 // indirect
Expand All @@ -136,7 +138,7 @@ require (
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/dustinxie/ecc v0.0.0-20210511000915-959544187564 // indirect
github.com/ethereum/c-kzg-4844 v1.0.1 // indirect
github.com/ethereum/go-verkle v0.1.1-0.20240306133620-7d920df305f0 // indirect
github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9 // indirect
github.com/ettle/strcase v0.2.0 // indirect
github.com/fatih/color v1.17.0 // indirect
github.com/fatih/structtag v1.2.0 // indirect
Expand Down Expand Up @@ -191,6 +193,7 @@ require (
github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
github.com/holiman/uint256 v1.3.1 // indirect
github.com/iden3/contracts-abi/rhs-storage/go/abi v0.0.0-20231006141557-7d13ef7e3c48 // indirect
github.com/iden3/driver-did-iden3 v0.0.5 // indirect
github.com/iden3/go-iden3-core v1.0.2 // indirect
github.com/iden3/go-rapidsnark/verifier v0.0.5 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
Expand Down Expand Up @@ -308,7 +311,7 @@ require (
github.com/stbenjam/no-sprintf-host-port v0.1.1 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/supranational/blst v0.3.11 // indirect
github.com/supranational/blst v0.3.13 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
github.com/tdakkota/asciicheck v0.2.0 // indirect
github.com/tetafro/godot v1.4.16 // indirect
Expand Down
46 changes: 24 additions & 22 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,14 @@ github.com/breml/bidichk v0.2.7 h1:dAkKQPLl/Qrk7hnP6P+E0xOodrq8Us7+U0o4UBOAlQY=
github.com/breml/bidichk v0.2.7/go.mod h1:YodjipAGI9fGcYM7II6wFvGhdMYsC5pHDlGzqvEW3tQ=
github.com/breml/errchkjson v0.3.6 h1:VLhVkqSBH96AvXEyclMR37rZslRrY2kcyq+31HCsVrA=
github.com/breml/errchkjson v0.3.6/go.mod h1:jhSDoFheAF2RSDOlCfhHO9KqhZgAYLyvHe7bRCX8f/U=
github.com/btcsuite/btcd v0.23.3 h1:4KH/JKy9WiCd+iUS9Mu0Zp7Dnj17TGdKrg9xc/FGj24=
github.com/btcsuite/btcd v0.23.3/go.mod h1:0QJIIN1wwIXF/3G/m87gIwGniDMDQqjVn4SZgnFpsYY=
github.com/btcsuite/btcd v0.24.2 h1:aLmxPguqxza+4ag8R1I2nnJjSu2iFn/kqtHTIImswcY=
github.com/btcsuite/btcd v0.24.2/go.mod h1:5C8ChTkl5ejr3WHj8tkQSCmydiMEPB0ZhQhehpq7Dgg=
github.com/btcsuite/btcd/btcec/v2 v2.3.4 h1:3EJjcN70HCu/mwqlUsGK8GcNVyLVxFDlWurTXGPFfiQ=
github.com/btcsuite/btcd/btcec/v2 v2.3.4/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04=
github.com/btcsuite/btcd/btcutil v1.1.3 h1:xfbtw8lwpp0G6NwSHb+UE67ryTFHJAiNuipusjXSohQ=
github.com/btcsuite/btcd/btcutil v1.1.3/go.mod h1:UR7dsSJzJUfMmFiiLlIrMq1lS9jh9EdCV7FStZSnpi0=
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U=
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc=
github.com/btcsuite/btcd/btcutil v1.1.6 h1:zFL2+c3Lb9gEgqKNzowKUPQNb8jV7v5Oaodi/AYFd6c=
github.com/btcsuite/btcd/btcutil v1.1.6/go.mod h1:9dFymx8HpuLqBnsPELrImQeTQfKBQqzqGbbV3jK55aE=
github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 h1:59Kx4K6lzOW5w6nFlA0v5+lk/6sjybR934QNHSJZPTQ=
github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc=
github.com/butuzov/ireturn v0.3.0 h1:hTjMqWw3y5JC3kpnC5vXmFJAWI/m31jaCYQqzkS6PL0=
github.com/butuzov/ireturn v0.3.0/go.mod h1:A09nIiwiqzN/IoVo9ogpa0Hzi9fex1kd9PSD6edP5ZA=
github.com/butuzov/mirror v1.2.0 h1:9YVK1qIjNspaqWutSv8gsge2e/Xpq1eqEkslEUHy5cs=
Expand All @@ -128,8 +128,8 @@ github.com/ccojocar/zxcvbn-go v1.0.2 h1:na/czXU8RrhXO4EZme6eQJLR4PzcGsahsBOAwU6I
github.com/ccojocar/zxcvbn-go v1.0.2/go.mod h1:g1qkXtUSvHP8lhHp5GrSmTz6uWALGRMQdw6Qnz/hi60=
github.com/cenkalti/backoff/v3 v3.2.2 h1:cfUAAO3yvKMYKPrvhDuHSwQnhZNk/RMHKdZqKTxfm6M=
github.com/cenkalti/backoff/v3 v3.2.2/go.mod h1:cIeZDE3IrqwwJl6VUwCN6trj1oXrTS4rc0ij+ULvLYs=
github.com/cespare/cp v0.1.0 h1:SE+dxFebS7Iik5LK0tsi1k9ZCxEaFX4AjQmoyA+1dJk=
github.com/cespare/cp v0.1.0/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s=
github.com/cespare/cp v1.1.1 h1:nCb6ZLdB7NRaqsm91JtQTAme2SKJzXVsdPIPkyJr1MU=
github.com/cespare/cp v1.1.1/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
Expand All @@ -153,8 +153,8 @@ github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce h1:giXvy4KSc/6g/e
github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce/go.mod h1:9/y3cnZ5GKakj/H4y9r9GTjCvAFta7KLgSHPJJYc52M=
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE=
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs=
github.com/cockroachdb/pebble v1.1.1 h1:XnKU22oiCLy2Xn8vp1re67cXg4SAasg/WDt1NtcRFaw=
github.com/cockroachdb/pebble v1.1.1/go.mod h1:4exszw1r40423ZsmkG/09AFEG83I0uDgfujJdbL6kYU=
github.com/cockroachdb/pebble v1.1.2 h1:CUh2IPtR4swHlEj48Rhfzw6l/d0qA31fItcIszQVIsA=
github.com/cockroachdb/pebble v1.1.2/go.mod h1:4exszw1r40423ZsmkG/09AFEG83I0uDgfujJdbL6kYU=
github.com/cockroachdb/redact v1.1.5 h1:u1PMllDkdFfPWaNGMyLD1+so+aq3uUItthCFqzwPJ30=
github.com/cockroachdb/redact v1.1.5/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg=
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 h1:zuQyyAKVxetITBuuhv3BI9cMrmStnpT18zmgmTxunpo=
Expand Down Expand Up @@ -201,10 +201,10 @@ github.com/dustinxie/ecc v0.0.0-20210511000915-959544187564 h1:I6KUy4CI6hHjqnyJL
github.com/dustinxie/ecc v0.0.0-20210511000915-959544187564/go.mod h1:yekO+3ZShy19S+bsmnERmznGy9Rfg6dWWWpiGJjNAz8=
github.com/ethereum/c-kzg-4844 v1.0.1 h1:pGixCbGizcVKSwoV70ge48+PrbB+iSKs2rjgfE4yJmQ=
github.com/ethereum/c-kzg-4844 v1.0.1/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0=
github.com/ethereum/go-ethereum v1.14.8 h1:NgOWvXS+lauK+zFukEvi85UmmsS/OkV0N23UZ1VTIig=
github.com/ethereum/go-ethereum v1.14.8/go.mod h1:TJhyuDq0JDppAkFXgqjwpdlQApywnu/m10kFPxh8vvs=
github.com/ethereum/go-verkle v0.1.1-0.20240306133620-7d920df305f0 h1:KrE8I4reeVvf7C1tm8elRjj4BdscTYzz/WAbYyf/JI4=
github.com/ethereum/go-verkle v0.1.1-0.20240306133620-7d920df305f0/go.mod h1:D9AJLVXSyZQXJQVk8oh1EwjISE+sJTn2duYIZC0dy3w=
github.com/ethereum/go-ethereum v1.14.11 h1:8nFDCUUE67rPc6AKxFj7JKaOa2W/W1Rse3oS6LvvxEY=
github.com/ethereum/go-ethereum v1.14.11/go.mod h1:+l/fr42Mma+xBnhefL/+z11/hcmJ2egl+ScIVPjhc7E=
github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9 h1:8NfxH2iXvJ60YRB8ChToFTUzl8awsc3cJ8CbLjGIl/A=
github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9/go.mod h1:M3b90YRnzqKyyzBEWJGqj8Qff4IDeXnzFw0P9bFw3uk=
github.com/ettle/strcase v0.2.0 h1:fGNiVF21fHXpX1niBgk0aROov1LagYsOwV/xqKDKR/Q=
github.com/ettle/strcase v0.2.0/go.mod h1:DajmHElDSaX76ITe3/VHVyMin4LWSJN5Z909Wp+ED1A=
github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4=
Expand All @@ -221,8 +221,8 @@ github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nos
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
github.com/fzipp/gocyclo v0.6.0 h1:lsblElZG7d3ALtGMx9fmxeTKZaLLpU8mET09yN4BBLo=
github.com/fzipp/gocyclo v0.6.0/go.mod h1:rXPyn8fnlpa0R2csP/31uerbiVBugk5whMdlyaLkLoA=
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff h1:tY80oXqGNY4FhTFhk+o9oFHGINQ/+vhlm8HFzi6znCI=
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww=
github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08 h1:f6D9Hr8xV8uYKlyuj8XIruxlh9WjVjdh1gIicAS7ays=
github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww=
github.com/getkin/kin-openapi v0.127.0 h1:Mghqi3Dhryf3F8vR370nN67pAERW+3a95vomb3MAREY=
github.com/getkin/kin-openapi v0.127.0/go.mod h1:OZrfXzUfGrNbsKj+xmFBx6E5c6yH3At/tAKSc2UszXM=
github.com/getsentry/sentry-go v0.27.0 h1:Pv98CIbtB3LkMWmXi4Joa5OOcwbmnX88sF5qbK3r3Ps=
Expand Down Expand Up @@ -417,10 +417,12 @@ github.com/iden3/contracts-abi/rhs-storage/go/abi v0.0.0-20231006141557-7d13ef7e
github.com/iden3/contracts-abi/rhs-storage/go/abi v0.0.0-20231006141557-7d13ef7e3c48/go.mod h1:kJmVPMk4HfWyl2kcta34aad/K4TAfCwB29xX9PsR7LQ=
github.com/iden3/contracts-abi/state/go/abi v1.0.2-0.20230911112726-4533c5701af1 h1:67302Oni3SpT2sbz7HXXEOR3zK3/usEC69W9ULILR1o=
github.com/iden3/contracts-abi/state/go/abi v1.0.2-0.20230911112726-4533c5701af1/go.mod h1:TxgIrXCvxms3sbOdsy8kTvffUCIpEEifNy0fSXdkU4w=
github.com/iden3/driver-did-iden3 v0.0.5 h1:N3B9S3CBZHqWIZWspAiq2JFaLyq0eLZf26sN3ZEMAhQ=
github.com/iden3/driver-did-iden3 v0.0.5/go.mod h1:TcEG6fkExW6hgafjrU4ObOQ/HZqIRPQoL3TMU+URbS0=
github.com/iden3/go-circuits/v2 v2.4.0 h1:m+7uYtrvJKuc+gVhbXDXl1BJQyK7sWdW7OWttM3R/8I=
github.com/iden3/go-circuits/v2 v2.4.0/go.mod h1:k0uYx/ZdZPiDEIy7kI3MAixnREKcc7NdCKDRw8Q+iFA=
github.com/iden3/go-iden3-auth/v2 v2.5.0 h1:vvleEbb9WvZ5dH9FSLnE9pYCsdKh+jgIBLfr1tgP+7o=
github.com/iden3/go-iden3-auth/v2 v2.5.0/go.mod h1:z+7+loGUSX2loVVyyipwySvxAizrecz8sbDqdGwqKiI=
github.com/iden3/go-iden3-auth/v2 v2.6.0 h1:R+QD/H1zhtO9+uvZ73Z9CVU7Omx8xf8ckgv4Syv4IsI=
github.com/iden3/go-iden3-auth/v2 v2.6.0/go.mod h1:s6t4ierMRafmJPxHSfwDW3Mh5+ceNbUrtbdP1EVoqfI=
github.com/iden3/go-iden3-core v1.0.2 h1:HwNDFeqcUv4ybZj5tH+58JKWKarn/qqBpNCqTLxGP0Y=
github.com/iden3/go-iden3-core v1.0.2/go.mod h1:X4PjlJG8OsEQEsSbzzYqqAk2olYGZ2nuGqiUPyEYjOo=
github.com/iden3/go-iden3-core/v2 v2.3.1 h1:ytQqiclnVAIWyRKR2LF31hfz4DGRBD6nMjiPILXGSKk=
Expand All @@ -447,8 +449,8 @@ github.com/iden3/go-schema-processor v1.3.1 h1:LJfFInfYGMOp0bTKKC17R8q4XI+VtqhFL
github.com/iden3/go-schema-processor v1.3.1/go.mod h1:NwJ1nuGdRlCFaN1/V6mS0AOAdvpLcGf4KKq0mluLG7U=
github.com/iden3/go-schema-processor/v2 v2.6.1 h1:KD33sTAu2xAyG94SmrUAMxI+MREFTmSsavYy70gkTW4=
github.com/iden3/go-schema-processor/v2 v2.6.1/go.mod h1:MYrkk55aEx3ZBKz0d/0rfxa7lBH4x9TfKGI1T/WBlpw=
github.com/iden3/iden3comm/v2 v2.6.0 h1:6cu0N2b9oluJGDMvM2C0r2IH1GtrMUmmHOcJTn3O0mQ=
github.com/iden3/iden3comm/v2 v2.6.0/go.mod h1:ZRnfFg4geX336Bp9+29ZQdSqchbsBoVcd7ARn6JXH5Y=
github.com/iden3/iden3comm/v2 v2.9.2-0.20241220155923-303258bd747f h1:ixUpMi3r+OcEsx9qdmXJ/3RtbV5EM7w7z1ahWfEveLY=
github.com/iden3/iden3comm/v2 v2.9.2-0.20241220155923-303258bd747f/go.mod h1:l8t+BkbHU3ri7kiExZYc4CTY6erkzkcBbYXw416nwhA=
github.com/iden3/merkletree-proof v0.3.0 h1:NVlvtUBEgn4Etxxn+RsOmXP/qlI+85BdN8oUDTf3mxI=
github.com/iden3/merkletree-proof v0.3.0/go.mod h1:+E2sBxMqhcn/fcu0LDGjmk3us+Vr+fxQUiZMxdpbgUE=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
Expand Down Expand Up @@ -857,8 +859,8 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
github.com/supranational/blst v0.3.11 h1:LyU6FolezeWAhvQk0k6O/d49jqgO52MSDDfYgbeoEm4=
github.com/supranational/blst v0.3.11/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw=
github.com/supranational/blst v0.3.13 h1:AYeSxdOMacwu7FBmpfloBz5pbFXDmJL33RuwnKtmTjk=
github.com/supranational/blst v0.3.13/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw=
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY=
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc=
github.com/tdakkota/asciicheck v0.2.0 h1:o8jvnUANo0qXtnslk2d3nMKTFNlOnJjRrNcj0j9qkHM=
Expand Down
38 changes: 29 additions & 9 deletions internal/api/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package api
import (
"context"

"github.com/iden3/iden3comm/v2/protocol"
"github.com/polygonid/sh-id-platform/internal/core/domain"
"github.com/polygonid/sh-id-platform/internal/core/ports"
"github.com/polygonid/sh-id-platform/internal/log"
)
Expand All @@ -20,16 +22,34 @@ func (s *Server) Agent(ctx context.Context, request AgentRequestObject) (AgentRe
return Agent400JSONResponse{N400JSONResponse{"cannot proceed with the given request"}}, nil
}

req, err := ports.NewAgentRequest(basicMessage)
if err != nil {
log.Error(ctx, "agent parsing request", "err", err)
return Agent400JSONResponse{N400JSONResponse{err.Error()}}, nil
}
var agent *domain.Agent

agent, err := s.claimService.Agent(ctx, req, mediatype)
if err != nil {
log.Error(ctx, "agent error", "err", err)
return Agent400JSONResponse{N400JSONResponse{err.Error()}}, nil
if basicMessage.Type == protocol.DiscoverFeatureQueriesMessageType {
req, err := ports.NewDiscoveryAgentRequest(basicMessage)
if err != nil {
log.Error(ctx, "agent parsing request", "err", err)
return Agent400JSONResponse{N400JSONResponse{err.Error()}}, nil
}

agent, err = s.discoveryService.Agent(ctx, req)
if err != nil {
log.Error(ctx, "agent error", "err", err)
return Agent400JSONResponse{N400JSONResponse{err.Error()}}, nil
}

} else {

req, err := ports.NewAgentRequest(basicMessage)
if err != nil {
log.Error(ctx, "agent parsing request", "err", err)
return Agent400JSONResponse{N400JSONResponse{err.Error()}}, nil
}

agent, err = s.claimService.Agent(ctx, req, mediatype)
if err != nil {
log.Error(ctx, "agent error", "err", err)
return Agent400JSONResponse{N400JSONResponse{err.Error()}}, nil
}
}

return Agent200JSONResponse{
Expand Down
3 changes: 2 additions & 1 deletion internal/api/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,8 @@ func newTestServer(t *testing.T, st *db.Storage) *testServer {
linkService := services.NewLinkService(storage, claimsService, qrService, repos.claims, repos.links, repos.schemas, schemaLoader, repos.sessions, pubSub, identityService, *networkResolver, cfg.UniversalLinks)
displayMethodService := services.NewDisplayMethod(repos.displayMethod)
keyService := services.NewKey(keyStore, claimsService, repos.keyRepository)
server := NewServer(&cfg, identityService, accountService, connectionService, claimsService, qrService, NewPublisherMock(), NewPackageManagerMock(), *networkResolver, nil, schemaService, linkService, displayMethodService, keyService)
discoveryService := services.NewDiscovery(mediaTypeManager, NewPackageManagerMock())
server := NewServer(&cfg, identityService, accountService, connectionService, claimsService, qrService, NewPublisherMock(), NewPackageManagerMock(), *networkResolver, nil, schemaService, linkService, displayMethodService, keyService, discoveryService)

return &testServer{
Server: server,
Expand Down
4 changes: 3 additions & 1 deletion internal/api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ type Server struct {
schemaService ports.SchemaService
displayMethodService ports.DisplayMethodService
keyService ports.KeyService
discoveryService ports.DiscoveryService
}

// NewServer is a Server constructor
func NewServer(cfg *config.Configuration, identityService ports.IdentityService, accountService ports.AccountService, connectionsService ports.ConnectionService, claimsService ports.ClaimService, qrService ports.QrStoreService, publisherGateway ports.Publisher, packageManager *iden3comm.PackageManager, networkResolver network.Resolver, health *health.Status, schemaService ports.SchemaService, linkService ports.LinkService, displayMethodService ports.DisplayMethodService, keyService ports.KeyService) *Server {
func NewServer(cfg *config.Configuration, identityService ports.IdentityService, accountService ports.AccountService, connectionsService ports.ConnectionService, claimsService ports.ClaimService, qrService ports.QrStoreService, publisherGateway ports.Publisher, packageManager *iden3comm.PackageManager, networkResolver network.Resolver, health *health.Status, schemaService ports.SchemaService, linkService ports.LinkService, displayMethodService ports.DisplayMethodService, keyService ports.KeyService, discoveryService ports.DiscoveryService) *Server {
return &Server{
cfg: cfg,
accountService: accountService,
Expand All @@ -50,6 +51,7 @@ func NewServer(cfg *config.Configuration, identityService ports.IdentityService,
schemaService: schemaService,
displayMethodService: displayMethodService,
keyService: keyService,
discoveryService: discoveryService,
}
}

Expand Down
Loading

0 comments on commit c33fb60

Please sign in to comment.