···
+
indigo_xrpc "github.com/bluesky-social/indigo/xrpc"
"github.com/gorilla/sessions"
oauth "tangled.sh/icyphox.sh/atproto-oauth"
"tangled.sh/icyphox.sh/atproto-oauth/helpers"
···
+
// use this to create a client to communicate with knots or spindles
+
// this is a higher level abstraction on ServerGetServiceAuth
+
type ServiceClientOpts struct {
+
type ServiceClientOpt func(*ServiceClientOpts)
+
func WithService(service string) ServiceClientOpt {
+
return func(s *ServiceClientOpts) {
+
func WithExp(exp int64) ServiceClientOpt {
+
return func(s *ServiceClientOpts) {
+
func WithLxm(lxm string) ServiceClientOpt {
+
return func(s *ServiceClientOpts) {
+
func WithDev(dev bool) ServiceClientOpt {
+
return func(s *ServiceClientOpts) {
+
func (s *ServiceClientOpts) Audience() string {
+
return fmt.Sprintf("did:web:%s", s.service)
+
func (s *ServiceClientOpts) Host() string {
+
return scheme + s.service
+
func (o *OAuth) ServiceClient(r *http.Request, os ...ServiceClientOpt) (*indigo_xrpc.Client, error) {
+
opts := ServiceClientOpts{}
+
authorizedClient, err := o.AuthorizedClient(r)
+
resp, err := authorizedClient.ServerGetServiceAuth(r.Context(), opts.Audience(), opts.exp, opts.lxm)
+
return &indigo_xrpc.Client{
+
Auth: &indigo_xrpc.AuthInfo{
type ClientMetadata struct {