backend for xcvr appview
3
fork

Configure Feed

Select the types of activity you want to include in your feed.

add adding did/handle pairs to database

rachel-mp4 e35a95f3 fe82b707

+158 -48
+12 -1
server/go.mod
··· 3 3 go 1.24.2 4 4 5 5 require ( 6 + github.com/bluesky-social/indigo v0.0.0-20250612212613-34115b57349c 6 7 github.com/gorilla/sessions v1.4.0 7 8 github.com/haileyok/atproto-oauth-golang v0.0.2 8 9 github.com/jackc/pgx/v5 v5.7.4 ··· 12 13 ) 13 14 14 15 require ( 15 - github.com/bluesky-social/indigo v0.0.0-20250301025210-a4e0cc37e188 // indirect 16 + github.com/beorn7/perks v1.0.1 // indirect 16 17 github.com/carlmjohnson/versioninfo v0.22.5 // indirect 18 + github.com/cespare/xxhash/v2 v2.2.0 // indirect 17 19 github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect 18 20 github.com/felixge/httpsnoop v1.0.4 // indirect 19 21 github.com/go-logr/logr v1.4.2 // indirect ··· 27 29 github.com/hashicorp/go-cleanhttp v0.5.2 // indirect 28 30 github.com/hashicorp/go-retryablehttp v0.7.5 // indirect 29 31 github.com/hashicorp/golang-lru v1.0.2 // indirect 32 + github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect 30 33 github.com/ipfs/bbloom v0.0.4 // indirect 31 34 github.com/ipfs/go-block-format v0.2.0 // indirect 32 35 github.com/ipfs/go-cid v0.4.1 // indirect ··· 50 53 github.com/lestrrat-go/iter v1.0.2 // indirect 51 54 github.com/lestrrat-go/option v1.0.1 // indirect 52 55 github.com/mattn/go-isatty v0.0.20 // indirect 56 + github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect 53 57 github.com/minio/sha256-simd v1.0.1 // indirect 54 58 github.com/mr-tron/base58 v1.2.0 // indirect 55 59 github.com/multiformats/go-base32 v0.1.0 // indirect ··· 59 63 github.com/multiformats/go-varint v0.0.7 // indirect 60 64 github.com/opentracing/opentracing-go v1.2.0 // indirect 61 65 github.com/polydawn/refmt v0.89.1-0.20221221234430-40501e09de1f // indirect 66 + github.com/prometheus/client_golang v1.17.0 // indirect 67 + github.com/prometheus/client_model v0.5.0 // indirect 68 + github.com/prometheus/common v0.45.0 // indirect 69 + github.com/prometheus/procfs v0.12.0 // indirect 62 70 github.com/rachel-mp4/lrcproto v0.0.0-20250527205756-58da8216f98c // indirect 63 71 github.com/segmentio/asm v1.2.0 // indirect 64 72 github.com/spaolacci/murmur3 v1.1.0 // indirect 65 73 github.com/whyrusleeping/cbor-gen v0.2.1-0.20241030202151-b7a6831be65e // indirect 74 + gitlab.com/yawning/secp256k1-voi v0.0.0-20230925100816-f2616030848b // indirect 75 + gitlab.com/yawning/tuplehash v0.0.0-20230713102510-df83abbf9a02 // indirect 66 76 go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect 67 77 go.opentelemetry.io/otel v1.29.0 // indirect 68 78 go.opentelemetry.io/otel/metric v1.29.0 // indirect ··· 74 84 golang.org/x/sync v0.10.0 // indirect 75 85 golang.org/x/sys v0.28.0 // indirect 76 86 golang.org/x/text v0.21.0 // indirect 87 + golang.org/x/time v0.8.0 // indirect 77 88 golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect 78 89 google.golang.org/protobuf v1.36.6 // indirect 79 90 lukechampine.com/blake3 v1.2.1 // indirect
+24 -2
server/go.sum
··· 1 1 github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= 2 2 github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= 3 - github.com/bluesky-social/indigo v0.0.0-20250301025210-a4e0cc37e188 h1:1sQaG37xk08/rpmdhrmMkfQWF9kZbnfHm9Zav3bbSMk= 4 - github.com/bluesky-social/indigo v0.0.0-20250301025210-a4e0cc37e188/go.mod h1:NVBwZvbBSa93kfyweAmKwOLYawdVHdwZ9s+GZtBBVLA= 3 + github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= 4 + github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= 5 + github.com/bluesky-social/indigo v0.0.0-20250612212613-34115b57349c h1:nnOI4tOIqlmxUohPWqaFdYh+SbkwxciQrWAUZTyTOC8= 6 + github.com/bluesky-social/indigo v0.0.0-20250612212613-34115b57349c/go.mod h1:ovyxp8AMO1Hoe838vMJUbqHTZaAR8ABM3g3TXu+A5Ng= 5 7 github.com/carlmjohnson/versioninfo v0.22.5 h1:O00sjOLUAFxYQjlN/bzYTuZiS0y6fWDQjMRvwtKgwwc= 6 8 github.com/carlmjohnson/versioninfo v0.22.5/go.mod h1:QT9mph3wcVfISUKd0i9sZfVrPviHuSF+cUtLjm2WSf8= 9 + github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= 10 + github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= 7 11 github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= 8 12 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 9 13 github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= ··· 51 55 github.com/hashicorp/go-retryablehttp v0.7.5/go.mod h1:Jy/gPYAdjqffZ/yFGCFV2doI5wjtH1ewM9u8iYVjtX8= 52 56 github.com/hashicorp/golang-lru v1.0.2 h1:dV3g9Z/unq5DpblPpw+Oqcv4dU/1omnb4Ok8iPY6p1c= 53 57 github.com/hashicorp/golang-lru v1.0.2/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= 58 + github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k= 59 + github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM= 54 60 github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs= 55 61 github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0= 56 62 github.com/ipfs/go-block-format v0.2.0 h1:ZqrkxBA2ICbDRbK8KJs/u0O3dlp6gmAuuXUJNiW1Ycs= ··· 121 127 github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= 122 128 github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= 123 129 github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= 130 + github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 h1:jWpvCLoY8Z/e3VKvlsiIGKtc+UG6U5vzxaoagmhXfyg= 131 + github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0/go.mod h1:QUyp042oQthUoa9bqDv0ER0wrtXnBruoNd7aNjkbP+k= 124 132 github.com/minio/sha256-simd v1.0.1 h1:6kaan5IFmwTNynnKKpDHe6FWHohJOHhCPchzK49dzMM= 125 133 github.com/minio/sha256-simd v1.0.1/go.mod h1:Pz6AKMiUdngCLpeTL/RJY1M9rUuPMYujV5xJjtbRSN8= 126 134 github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o= ··· 143 151 github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 144 152 github.com/polydawn/refmt v0.89.1-0.20221221234430-40501e09de1f h1:VXTQfuJj9vKR4TCkEuWIckKvdHFeJH/huIFJ9/cXOB0= 145 153 github.com/polydawn/refmt v0.89.1-0.20221221234430-40501e09de1f/go.mod h1:/zvteZs/GwLtCgZ4BL6CBsk9IKIlexP43ObX9AxTqTw= 154 + github.com/prometheus/client_golang v1.17.0 h1:rl2sfwZMtSthVU752MqfjQozy7blglC+1SOtjMAMh+Q= 155 + github.com/prometheus/client_golang v1.17.0/go.mod h1:VeL+gMmOAxkS2IqfCq0ZmHSL+LjWfWDUmp1mBz9JgUY= 156 + github.com/prometheus/client_model v0.5.0 h1:VQw1hfvPvk3Uv6Qf29VrPF32JB6rtbgI6cYPYQjL0Qw= 157 + github.com/prometheus/client_model v0.5.0/go.mod h1:dTiFglRmd66nLR9Pv9f0mZi7B7fk5Pm3gvsjB5tr+kI= 158 + github.com/prometheus/common v0.45.0 h1:2BGz0eBc2hdMDLnO/8n0jeB3oPrt2D08CekT0lneoxM= 159 + github.com/prometheus/common v0.45.0/go.mod h1:YJmSTw9BoKxJplESWWxlbyttQR4uaEcGyv9MZjVOJsY= 160 + github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= 161 + github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= 146 162 github.com/rachel-mp4/lrcd v0.0.0-20250603192958-089ba44e79a5 h1:NMDkC4XYysiYebcoFDnsPdBVr8/NEuahKM6xqQJITp0= 147 163 github.com/rachel-mp4/lrcd v0.0.0-20250603192958-089ba44e79a5/go.mod h1:Hn8xgJ2JwdiFJM5WjamVv4lRTwB6CdcqPjrCvJM7234= 148 164 github.com/rachel-mp4/lrcproto v0.0.0-20250527205756-58da8216f98c h1:nOWeKeE7wph0IcwUyUBi0YBynUnAo4JW/J5DM88x4KM= ··· 182 198 github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= 183 199 github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= 184 200 github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= 201 + gitlab.com/yawning/secp256k1-voi v0.0.0-20230925100816-f2616030848b h1:CzigHMRySiX3drau9C6Q5CAbNIApmLdat5jPMqChvDA= 202 + gitlab.com/yawning/secp256k1-voi v0.0.0-20230925100816-f2616030848b/go.mod h1:/y/V339mxv2sZmYYR64O07VuCpdNZqCTwO8ZcouTMI8= 203 + gitlab.com/yawning/tuplehash v0.0.0-20230713102510-df83abbf9a02 h1:qwDnMxjkyLmAFgcfgTnfJrmYKWhHnci3GjDqcZp1M3Q= 204 + gitlab.com/yawning/tuplehash v0.0.0-20230713102510-df83abbf9a02/go.mod h1:JTnUj0mpYiAsuZLmKjTx/ex3AtMowcCgnE7YNyCEP0I= 185 205 go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 h1:aFJWCqJMNjENlcleuuOkGAPH82y0yULBScfXcIEdS24= 186 206 go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1/go.mod h1:sEGXWArGqc3tVa+ekntsN65DmVbVeW+7lTKTjZF3/Fo= 187 207 go.opentelemetry.io/otel v1.29.0 h1:PdomN/Al4q/lN6iBJEN3AwPvUiHPMlt93c8bqTG5Llw= ··· 269 289 golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= 270 290 golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= 271 291 golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= 292 + golang.org/x/time v0.8.0 h1:9i3RxcPv3PZnitoVGMPDKZSq1xW1gK1Xy3ArNOGZfEg= 293 + golang.org/x/time v0.8.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= 272 294 golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 273 295 golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= 274 296 golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
+34
server/internal/atputils/identity.go
··· 1 + package atputils 2 + import ( 3 + "context" 4 + "github.com/bluesky-social/indigo/atproto/identity" 5 + "github.com/bluesky-social/indigo/atproto/syntax" 6 + "errors" 7 + ) 8 + 9 + func GetHandleFromDid(ctx context.Context, did string) (string, error) { 10 + sdid, err := syntax.ParseDID(did) 11 + if err != nil { 12 + return "", errors.New("did did not parse: " + err.Error()) 13 + } 14 + resolver := identity.DefaultDirectory() 15 + 16 + ident, err := resolver.LookupDID(ctx, sdid) 17 + if err != nil { 18 + return "", errors.New("failed to lookupDID: " + err.Error()) 19 + } 20 + return ident.Handle.String(), nil 21 + } 22 + 23 + func GetDidFromHandle(ctx context.Context, handle string) (string, error) { 24 + shandle, err := syntax.ParseHandle(handle) 25 + if err != nil { 26 + return "", errors.New("handle did not parse: " + err.Error()) 27 + } 28 + resolver := identity.DefaultDirectory() 29 + ident, err := resolver.LookupHandle(ctx,shandle) 30 + if err != nil { 31 + return "", errors.New("failed to lookupHandle: " + err.Error()) 32 + } 33 + return ident.DID.String(), nil 34 + }
+22 -3
server/internal/db/db.go
··· 2 2 3 3 import ( 4 4 "context" 5 + "errors" 5 6 "fmt" 6 7 "os" 7 8 "xcvr-backend/internal/types" ··· 41 42 return pool, nil 42 43 } 43 44 44 - 45 45 func (s *Store) ResolveHandle(handle string, ctx context.Context) (string, error) { 46 46 rows, err := s.pool.Query(ctx, ` 47 47 SELECT ··· 62 62 } 63 63 } 64 64 return did, nil 65 + } 66 + 67 + func (s *Store) ResolveDid(did string, ctx context.Context) (string, error) { 68 + row := s.pool.QueryRow(ctx, `SELECT h.handle FROM did_handles h WHERE h.did = $1`, did) 69 + var handle string 70 + err := row.Scan(&handle) 71 + if err != nil { 72 + return "", errors.New("error scanning row for handle: " + err.Error()) 73 + } 74 + return handle, nil 75 + } 76 + 77 + func (s *Store) StoreDidHandle(did string, handle string, ctx context.Context) error { 78 + _, err := s.pool.Exec(ctx, `INSERT INTO did_handles ( 79 + handle 80 + did 81 + ) VALUES ($1, $2)`, handle, did) 82 + if err != nil { 83 + return errors.New("error storing did/handle: " + err.Error()) 84 + } 85 + return nil 65 86 } 66 87 67 88 func (s *Store) GetMessages(channelURI string, limit int, ctx context.Context) ([]types.Message, error) { ··· 178 199 } 179 200 return chans, nil 180 201 } 181 - 182 -
+26 -2
server/internal/handler/oauthHandlers.go
··· 1 1 package handler 2 2 3 3 import ( 4 + "context" 4 5 "encoding/json" 5 6 "errors" 6 7 "fmt" 7 - "github.com/gorilla/sessions" 8 8 "net/http" 9 9 "net/url" 10 10 "os" 11 + "xcvr-backend/internal/atputils" 11 12 "xcvr-backend/internal/oauth" 13 + 14 + "github.com/gorilla/sessions" 12 15 "github.com/haileyok/atproto-oauth-golang/helpers" 13 16 ) 14 17 ··· 62 65 h.serverError(w, err) 63 66 return 64 67 } 68 + go func() { 69 + err := h.db.StoreDidHandle(res.DID, handle, context.Background()) 70 + if err != nil { 71 + h.logger.Deprintln("failed to store did handle: " + err.Error()) 72 + } 73 + }() 65 74 http.Redirect(w, r, u.String(), http.StatusFound) 66 75 } 67 76 ··· 145 154 http.Error(w, "not authenticated", http.StatusUnauthorized) 146 155 return 147 156 } 157 + handle, err := h.db.ResolveDid(did, r.Context()) 158 + if err != nil { 159 + handle, err = atputils.GetHandleFromDid(r.Context(), did) 160 + if err != nil { 161 + h.serverError(w, errors.New("error resolving handle")) 162 + return 163 + } 164 + err = h.db.StoreDidHandle(did, handle, r.Context()) 165 + if err != nil { 166 + h.logger.Deprintln("error storing did_handle in getSession: " + err.Error()) 167 + } 168 + } 148 169 w.Header().Set("Content-Type", "application/json") 149 170 json.NewEncoder(w).Encode(map[string]any{ 150 - "did": did, 171 + "id": map[string]any{ 172 + "did": did, 173 + "handle": handle, 174 + }, 151 175 }) 152 176 }
+40 -40
server/internal/oauth/service.go
··· 6 6 "errors" 7 7 "fmt" 8 8 "io" 9 - "time" 10 9 "net/http" 11 - "net/url" 12 10 "strings" 11 + "time" 12 + "xcvr-backend/internal/atputils" 13 13 14 14 atoauth "github.com/haileyok/atproto-oauth-golang" 15 15 "github.com/haileyok/atproto-oauth-golang/helpers" ··· 70 70 71 71 type Session struct { 72 72 OAuthRequest 73 - DpopPdsNonce string 74 - AccessToken string 75 - RefreshToken string 76 - Expiration time.Time 73 + DpopPdsNonce string 74 + AccessToken string 75 + RefreshToken string 76 + Expiration time.Time 77 77 } 78 78 79 79 func (s *Service) StartAuthFlow(ctx context.Context, handle string) (*OAuthRequest, *OauthFlowResult, error) { 80 - did, err := s.resolveHandle(handle) 80 + did, err := atputils.GetDidFromHandle(ctx, handle) 81 81 if err != nil { 82 82 return nil, nil, errors.New("error resolving handle:" + err.Error()) 83 83 } ··· 116 116 service, err = s.resolveService(ctx, did) 117 117 if err != nil { 118 118 err = errors.New("error resolving service:" + err.Error()) 119 - return 119 + return 120 120 } 121 121 authserver, err := s.oauth.ResolvePdsAuthServer(ctx, service) 122 122 if err != nil { ··· 125 125 } 126 126 meta, err = s.oauth.FetchAuthServerMetadata(ctx, authserver) 127 127 if err != nil { 128 - err = errors.New("error fetching "+ authserver + " metadata:" + err.Error()) 128 + err = errors.New("error fetching " + authserver + " metadata:" + err.Error()) 129 129 return 130 130 } 131 131 resp, err = s.oauth.SendParAuthRequest(ctx, authserver, meta, handle, "atproto transition:generic", dpop) 132 132 if err != nil { 133 - err = errors.New("error sending PAR auth request to " + authserver + " h: "+ handle + err.Error()) 133 + err = errors.New("error sending PAR auth request to " + authserver + " h: " + handle + err.Error()) 134 134 } 135 135 return 136 136 } ··· 184 184 return *service, nil 185 185 } 186 186 187 - func (s *Service) resolveHandle(handle string) (string, error) { 188 - params := url.Values{ 189 - "handle": []string{handle}, 190 - } 191 - reqUrl := "https://public.api.bsky.app/xrpc/com.atproto.identity.resolveHandle?" + params.Encode() 192 - resp, err := s.http.Get(reqUrl) 193 - if err != nil { 194 - return "", errors.New("error making handle -> did resolution request:" + err.Error()) 195 - } 196 - defer resp.Body.Close() 197 - 198 - type did struct { 199 - Did string 200 - } 201 - b, err := io.ReadAll(resp.Body) 202 - if err != nil { 203 - return "", errors.New("error reading handle -> did resolution response" + err.Error()) 204 - } 205 - var resDid did 206 - err = json.Unmarshal(b, &resDid) 207 - if err != nil { 208 - return "", errors.New("error unmarshaling resDid:" + err.Error()) 209 - } 210 - return resDid.Did, nil 211 - } 187 + // func (s *Service) resolveHandle(handle string) (string, error) { 188 + // params := url.Values{ 189 + // "handle": []string{handle}, 190 + // } 191 + // reqUrl := "https://public.api.bsky.app/xrpc/com.atproto.identity.resolveHandle?" + params.Encode() 192 + // resp, err := s.http.Get(reqUrl) 193 + // if err != nil { 194 + // return "", errors.New("error making handle -> did resolution request:" + err.Error()) 195 + // } 196 + // defer resp.Body.Close() 197 + // 198 + // type did struct { 199 + // Did string 200 + // } 201 + // b, err := io.ReadAll(resp.Body) 202 + // if err != nil { 203 + // return "", errors.New("error reading handle -> did resolution response" + err.Error()) 204 + // } 205 + // var resDid did 206 + // err = json.Unmarshal(b, &resDid) 207 + // if err != nil { 208 + // return "", errors.New("error unmarshaling resDid:" + err.Error()) 209 + // } 210 + // return resDid.Did, nil 211 + // } 212 212 213 213 func (s *Service) OauthCallback(ctx context.Context, oauthRequest *OAuthRequest, params CallbackParams) (*Session, error) { 214 214 jwk, err := helpers.ParseJWKFromBytes([]byte(oauthRequest.DpopPrivKey)) ··· 217 217 } 218 218 initialTokenResp, err := s.oauth.InitialTokenRequest(ctx, params.Code, params.Iss, oauthRequest.PkceVerifier, oauthRequest.DpopAuthServerNonce, jwk) 219 219 if err != nil { 220 - return nil, errors.New("error in initialTokenRequest:"+ err.Error()) 220 + return nil, errors.New("error in initialTokenRequest:" + err.Error()) 221 221 } 222 222 if initialTokenResp.Scope != "atproto transition:generic" { 223 223 return nil, errors.New(fmt.Sprintf("incorrect scope: %s", initialTokenResp.Scope)) 224 224 } 225 225 oauthSession := Session{ 226 - OAuthRequest: *oauthRequest, 227 - AccessToken: initialTokenResp.AccessToken, 228 - RefreshToken: initialTokenResp.RefreshToken, 229 - Expiration: time.Now().Add(time.Duration(int(time.Second) * int(initialTokenResp.ExpiresIn))), 226 + OAuthRequest: *oauthRequest, 227 + AccessToken: initialTokenResp.AccessToken, 228 + RefreshToken: initialTokenResp.RefreshToken, 229 + Expiration: time.Now().Add(time.Duration(int(time.Second) * int(initialTokenResp.ExpiresIn))), 230 230 } 231 231 return &oauthSession, nil 232 232 }