Documentation
¶
Index ¶
- Constants
- Variables
- func Account[T proto.Message](ctx context.Context, subject AccountFn[T]) (val T, err error)
- func AdminFromContext(ctx context.Context) (value *accountv1.Admin, found bool)
- func Authorize(ctx context.Context, resource string, scope accountv1.Admin_Scope) error
- func Broadcast[T comparable](observer Observer[T], payload protoreflect.ProtoMessage, topics ...T)
- func COUNT[T proto.Message](filters Filters) (q string, bindVars map[string]interface{})
- func Collection[T any]() string
- func ConfigFromEnv[T proto.Message](defaultConf T) T
- func ConnectionClosed(conn *websocket.Conn) <-chan struct{}
- func DOCUMENT(id string) (q string, bindVars map[string]interface{})
- func DirectivesFromContext(ctx context.Context) (directives []string, found bool)
- func Dot(parts ...string) string
- func DoubleQuote(s string) string
- func ElectrumSeedType(mnemonic string) string
- func ElectrumSegwitAddress(chain *hdkeychain.ExtendedKey, index uint32, network paymentv1.Network) (address, wif string, err error)
- func ElectrumSegwitReceivingKey(seed []byte, network paymentv1.Network) (*hdkeychain.ExtendedKey, error)
- func ElectrumSegwitSeed(mnemonic, passphrase string) ([]byte, error)
- func Enforce[T proto.Message](ctx context.Context, enforcer casbin.IEnforcer, accountFn AccountFn[T], ...) (subject T, authorized bool)
- func Enforcer(conf, policy string) func() (*casbin.Enforcer, error)
- func Expose[T proto.Message](_ T) exposed
- func FOR[T proto.Message](filter Filters) (q string, bindVars map[string]interface{})
- func Filter(exprs ...string) filters
- func FilterFrom[T proto.Message](elem T) filters
- func GEO_POINT(value *typesv1.Point) map[string]interface{}
- func GEO_POLYGON(value *typesv1.Polygon) map[string]interface{}
- func HandleDownloadFile(fs FileStorage) http.HandlerFunc
- func HandleUploadFile(fs FileStorage) http.HandlerFunc
- func HashFile(file []byte) (string, error)
- func ID[T any](key string) string
- func Join(parts ...string) string
- func Map[T any](size int, fn func(int) T) (result []T)
- func Mutation[Arg, Out proto.Message](fn func(context.Context, Arg) (Out, error)) mutation
- func NewBitcoinCore(ctx context.Context, config *configv1.Bitcoin, observer Observer[Topic], ...) (*bitcoinCore, error)
- func NewConnection(ctx context.Context, conf *configv1.Connection) (*connection, error)
- func NewDbFileStorage(access Access) (*dbFileStorage, error)
- func NewEnforcer(conf, policy string) (*casbin.Enforcer, error)
- func NewFilesystemStorage(config *configv1.FilesystemStorage) (*filesystemStorage, error)
- func NewGraph() *graph
- func NewObserver[T comparable]() *observer[T]
- func OTPSubscriber(ctx context.Context, config *configv1.Mail, ...) (Topic, Processor[Topic])
- func ProtoMarshal(v any, out proto.Message) error
- func Provide[T any](val any) fx.Option
- func Pure[T any](v T) (result T)
- func Query[Arg, Out proto.Message](fn func(context.Context, Arg) (Out, error)) query
- func QueryJoin(parts ...string) string
- func Quote(s string) string
- func REMOVE[T proto.Message](filters Filters) (q string, bindVars map[string]interface{})
- func ReadReset(r *http.Request) ([]byte, error)
- func Select[T any](v T) selector[T]
- func SessionFromContext(ctx context.Context) (session *authv1.Session, found bool)
- func Should[T any](v T, _ error) T
- func Subject(contact *domainv1.Contact) string
- func ToMap(v any) (result map[string]any)
- func ValueOfEnum(enum protoreflect.EnumDescriptor, name string) protoreflect.Value
- type Access
- type AccountFn
- type ArangoAccess
- func (e *ArangoAccess) AutoMigrate(ctx context.Context, graph Graph) error
- func (e *ArangoAccess) Collection(ctx context.Context, elem any, ...) (col driver.Collection, err error)
- func (e *ArangoAccess) Create(ctx context.Context, val any) ([]string, error)
- func (e *ArangoAccess) Delete(ctx context.Context, item any) error
- func (e *ArangoAccess) Fetch(ctx context.Context, query string, bindVars map[string]any, out any) error
- func (e *ArangoAccess) Get(ctx context.Context, filters Filters, out any) error
- func (e *ArangoAccess) List(ctx context.Context, filters Filters, out any) (int64, error)
- func (e *ArangoAccess) Query(ctx context.Context, query string, bindVars map[string]any, out any) error
- func (e *ArangoAccess) Relations(ctx context.Context, id string, filters Filters, direction Direction, out any) (int64, error)
- func (e *ArangoAccess) Replace(ctx context.Context, key string, item any) error
- func (e *ArangoAccess) Update(ctx context.Context, key string, item any) error
- type AuthHandler
- func (h *AuthHandler) Config(ctx context.Context, req *emptypb.Empty) (*authv1.ConfigResponse, error)
- func (h *AuthHandler) Enforce(next http.Handler) http.Handler
- func (h *AuthHandler) FetchAccessToken(ctx context.Context, req *emptypb.Empty) (*authv1.AuthResponse, error)
- func (h *AuthHandler) FetchSession(ctx context.Context, req *emptypb.Empty) (*authv1.FetchSessionResponse, error)
- func (h *AuthHandler) Handler(ctx context.Context) http.Handler
- func (h *AuthHandler) Logout(ctx context.Context, req *emptypb.Empty) (*emptypb.Empty, error)
- func (h *AuthHandler) Middleware(next http.Handler) http.Handler
- func (h *AuthHandler) RequestGuestAccount(ctx context.Context, req *emptypb.Empty) (*authv1.AuthResponse, error)
- func (h *AuthHandler) RequestNonce(ctx context.Context, req *authv1.RequestNonceRequest) (*authv1.RequestNonceResponse, error)
- func (h *AuthHandler) RequestOTP(ctx context.Context, req *authv1.RequestOTPRequest) (*authv1.RequestOTPResponse, error)
- func (h *AuthHandler) RuntimeMiddleware(next runtime.HandlerFunc) runtime.HandlerFunc
- func (h *AuthHandler) VerifyNonce(ctx context.Context, req *authv1.VerifyNonceRequest) (*authv1.AuthResponse, error)
- func (h *AuthHandler) VerifyOTP(ctx context.Context, req *authv1.VerifyOTPRequest) (*authv1.AuthResponse, error)
- type AuthHandlerParams
- type BitcoinPaymentGateway
- func (h *BitcoinPaymentGateway) CreateInvoice(ctx context.Context, req *bitcoinv1.CreateInvoiceRequest) (*bitcoinv1.CreateInvoiceResponse, error)
- func (h *BitcoinPaymentGateway) DashboardHandler(ctx context.Context, auth *AuthHandler, dashboard *DashboardHandler) http.Handler
- func (h *BitcoinPaymentGateway) GetInvoice(ctx context.Context, req *bitcoinv1.GetInvoiceRequest) (resp *bitcoinv1.GetInvoiceResponse, err error)
- func (h *BitcoinPaymentGateway) Handler(ctx context.Context) http.Handler
- func (h *BitcoinPaymentGateway) ListInvoices(ctx context.Context, req *bitcoinv1.ListInvoicesRequest) (*bitcoinv1.ListInvoicesResponse, error)
- func (*BitcoinPaymentGateway) Ping(context.Context, *emptypb.Empty) (*emptypb.Empty, error)
- func (h *BitcoinPaymentGateway) Subscribe(w http.ResponseWriter, r *http.Request, pathParams map[string]string)
- type BitcoinPaymentGatewayParams
- type CasbinAdapter
- func (a *CasbinAdapter[T]) AddPolicy(sec string, ptype string, rule []string) error
- func (a *CasbinAdapter[T]) ExtraFields() (result []protoreflect.FieldDescriptor)
- func (a *CasbinAdapter[T]) LoadPolicy(model model.Model) error
- func (a *CasbinAdapter[T]) Marshal(elem T) (sec string, ptype string, rule []string)
- func (a *CasbinAdapter[T]) RemoveFilteredPolicy(sec string, ptype string, fieldIndex int, fieldValues ...string) error
- func (a *CasbinAdapter[T]) RemovePolicy(sec string, ptype string, rule []string) error
- func (a *CasbinAdapter[T]) SavePolicy(model model.Model) error
- func (a *CasbinAdapter[T]) Unmarshal(sec string, ptype string, rule []string) (out T, err error)
- type Checks
- type Comparer
- type Config
- type Connection
- type DashboardHandler
- func (h *DashboardHandler) CreateResource(ctx context.Context, req *dashboardv1.CreateResourceRequest) (*dashboardv1.CreateResourceResponse, error)
- func (h *DashboardHandler) DeleteAccount(ctx context.Context, req *dashboardv1.DeleteAccountRequest) (*emptypb.Empty, error)
- func (h *DashboardHandler) DeleteResource(ctx context.Context, req *dashboardv1.DeleteResourceRequest) (*emptypb.Empty, error)
- func (h *DashboardHandler) GetAccount(ctx context.Context, req *dashboardv1.GetAccountRequest) (*dashboardv1.GetAccountResponse, error)
- func (h *DashboardHandler) GetCurrentAccount(ctx context.Context, _ *emptypb.Empty) (*dashboardv1.GetAccountResponse, error)
- func (h *DashboardHandler) GetResource(ctx context.Context, req *dashboardv1.GetResourceRequest) (*dashboardv1.GetResourceResponse, error)
- func (h *DashboardHandler) GetResourceRelation(ctx context.Context, req *dashboardv1.GetResourceRelationRequest) (*dashboardv1.GetResourceRelationResponse, error)
- func (h *DashboardHandler) GetSchema(ctx context.Context, req *emptypb.Empty) (*dashboardv1.GetSchemaResponse, error)
- func (h *DashboardHandler) Handler(ctx context.Context, auth *AuthHandler) http.Handler
- func (h *DashboardHandler) ListAccounts(ctx context.Context, _ *emptypb.Empty) (*dashboardv1.ListAccountsResponse, error)
- func (h *DashboardHandler) ListResources(ctx context.Context, req *dashboardv1.ListResourcesRequest) (*dashboardv1.ListResourcesResponse, error)
- func (h *DashboardHandler) RegisterAccount(ctx context.Context, req *dashboardv1.RegisterAccountRequest) (*dashboardv1.RegisterAccountResponse, error)
- func (h *DashboardHandler) RuntimeMiddleware(next runtime.HandlerFunc) runtime.HandlerFunc
- func (h *DashboardHandler) UpdateDetails(ctx context.Context, req *dashboardv1.UpdateDetailsRequest) (*dashboardv1.UpdateDetailsResponse, error)
- func (h *DashboardHandler) UpdateResource(ctx context.Context, req *dashboardv1.UpdateResourceRequest) (*dashboardv1.UpdateResourceResponse, error)
- func (h *DashboardHandler) UpdateScopes(ctx context.Context, req *dashboardv1.UpdateScopesRequest) (*dashboardv1.UpdateScopesResponse, error)
- func (h *DashboardHandler) UpdateStatus(ctx context.Context, req *dashboardv1.UpdateStatusRequest) (*dashboardv1.UpdateStatusResponse, error)
- type DashboardParams
- type Definition
- type Direction
- type Directives
- type EnforceFn
- type Eq
- type Event
- type Executor
- type FileStorage
- type Filters
- type Graph
- type GraphqlHandler
- type Gt
- type Gte
- type Ignore
- type In
- type Lt
- type Lte
- type Middleware
- type Ne
- type Nin
- type OTPTemplate
- type Observer
- type Processor
- type Relation
- type RetryErr
- type Rule
- type Rules
- type SourceID
- type Topic
Constants ¶
const ( ElectrumSeedStandard = "standard" ElectrumSeedSegwit = "segwit" ElectrumSeed2FA = "2fa" ElectrumSeed2FASegwit = "2fa_segwit" )
Electrum seed types, as returned by calc_seed_type.
const ( CountKey Definition = "count" OffsetKey Definition = "offset" SortKey Ignore = "sort" IdKey string = "_id" KeyKey string = "_key" FromKey string = "_from" ToKey string = "_to" )
const ( // RequestMaxBodySize limits the amount of data read from the request body to prevent memory exhaustion RequestMaxBodySize = 2 * 1024 * 1024 // 2 MB )
Variables ¶
var ( OTPRequestedTopic = Topic("auth.otp.requested") NonceRequestedTopic = Topic("auth.nonce.requested") )
var ( True = Eq{To: true} False = Eq{To: false} )
var AccessModule = fx.Module("access", Provide[Access](NewArangoAccess), )
AccessModule ...
var AuthModule = fx.Module("authHandler", fx.Provide(NewAuthHandler), fx.Invoke(func(ctx context.Context, router *http.ServeMux, auth *AuthHandler) { router.Handle("/auth/", auth.Handler(ctx)) }), )
AuthModule ...
var BitcoinDashboardModule = fx.Module("bitcoin-dashboard", fx.Invoke(func(ctx context.Context, router *http.ServeMux, auth *AuthHandler, dashboard *DashboardHandler, payment *BitcoinPaymentGateway) { router.Handle("/bitcoin-dashboard/", payment.DashboardHandler(ctx, auth, dashboard)) }), )
BitcoinDashboardModule ...
var BitcoinModule = fx.Module("bitcoin", fx.Provide(NewBitcoinPaymentGateway), fx.Invoke(func(ctx context.Context, router *http.ServeMux, payment *BitcoinPaymentGateway) { router.Handle("/bitcoin/", payment.Handler(ctx)) }), )
BitcoinModule ...
var ConnectionModule = fx.Module("connection", Provide[Connection](NewConnection), )
ConnectionModule ...
var DashboardModule = fx.Module("dashboard", fx.Provide(NewDashboard), fx.Invoke(func(ctx context.Context, router *http.ServeMux, dashboard *DashboardHandler, auth *AuthHandler) { router.Handle("/dashboard/", dashboard.Handler(ctx, auth)) }), )
DashboardModule ...
var DbFileStorageModule = fx.Module("dbFileStorage", Provide[FileStorage](NewDbFileStorage), StorageHandlerModule, )
DbFileStorageModule ...
var FileSystemStorageModule = fx.Module("filesystemStorage", Provide[FileStorage](NewFilesystemStorage), StorageHandlerModule, )
FileSystemStorageModule ...
GraphModule ...
var GraphqlModule = fx.Module("graphql", fx.Provide(handler.New), fx.Invoke(func(router *http.ServeMux, handler *handler.Handler) { router.Handle("/graphql/", handler) }), )
var ObserverModule = fx.Module("observer", Provide[Observer[Topic]](NewObserver[Topic]), )
var ServerModule = fx.Module("server", fx.Provide(http.NewServeMux), fx.Invoke(func(ctx context.Context, lc fx.Lifecycle, router *http.ServeMux, config Config) { srv := &http.Server{ Addr: config.Router.Address, Handler: Chain(config.Middlewares...)(router), BaseContext: func(net.Listener) context.Context { return ctx }, } if config.Router.Cors != nil { c := cors.New(cors.Options{ AllowedMethods: config.Router.Cors.AllowedMethods, AllowedHeaders: config.Router.Cors.AllowedHeaders, AllowCredentials: config.Router.Cors.AllowCredentials, AllowOriginFunc: func(string) bool { return config.Router.Cors.AllowOriginFunc }, }) srv.Handler = c.Handler(srv.Handler) } lc.Append(fx.Hook{ OnStart: func(ctx context.Context) error { ln, err := net.Listen("tcp", srv.Addr) if err != nil { return fmt.Errorf("error listening: %v", err) } go srv.Serve(ln) return nil }, OnStop: func(ctx context.Context) error { return srv.Shutdown(ctx) }, }) }), )
ServerModule ...
var StorageHandlerModule = fx.Module("storageHandler", fx.Invoke(func(router *http.ServeMux, storage FileStorage) { router.Handle("/files/{hash}", HandleDownloadFile(storage)) router.Handle("/files", HandleUploadFile(storage)) }), )
StorageHandlerModule ...
Functions ¶
func AdminFromContext ¶ added in v0.19.0
func Authorize ¶ added in v0.19.0
Authorize checks if the current admin has the given scope for the given resource
func Broadcast ¶
func Broadcast[T comparable](observer Observer[T], payload protoreflect.ProtoMessage, topics ...T)
Broadcast emits an event to the observer for the given topics
func COUNT ¶
COUNT returns the number of documents in a collection
Example: "RETURN COUNT(FOR doc IN col FILTER doc.name == @name RETURN doc)" {"name": "John"}
func Collection ¶
Collection returns the name of the collection for the given element
func ConfigFromEnv ¶
func ConnectionClosed ¶
ConnectionClosed returns a channel that is closed when the connection is closed
func DOCUMENT ¶
DOCUMENT returns a document by its id
Example: "RETURN DOCUMENT(@id)" {"id": "col/123"}
func DirectivesFromContext ¶
func ElectrumSeedType ¶ added in v0.21.0
ElectrumSeedType returns the Electrum seed type of mnemonic ("standard", "segwit", "2fa", "2fa_segwit"), or "" if it is not an Electrum seed. Mirrors calc_seed_type, except that pre-2.0 "old" seeds are not recognised.
func ElectrumSegwitAddress ¶ added in v0.21.0
func ElectrumSegwitAddress(chain *hdkeychain.ExtendedKey, index uint32, network paymentv1.Network) (address, wif string, err error)
ElectrumSegwitAddress returns the P2WPKH address and the Electrum-importable private key ("p2wpkh:<WIF>") at index of a chain from ElectrumSegwitReceivingKey, encoded for network: bc1… on mainnet, tb1… on testnet3/testnet4/signet, bcrt1… on regtest. Electrum only uses non-hardened indexes.
func ElectrumSegwitReceivingKey ¶ added in v0.21.0
func ElectrumSegwitReceivingKey(seed []byte, network paymentv1.Network) (*hdkeychain.ExtendedKey, error)
ElectrumSegwitReceivingKey returns the extended key of the receiving chain m/0'/0 of an Electrum segwit wallet (keystore.from_seed uses m/0'/ for segwit seeds; receiving addresses are /0/i, change /1/i). The network only affects how the key serialises (xprv/tprv), not the keys themselves.
func ElectrumSegwitSeed ¶ added in v0.21.0
ElectrumSegwitSeed validates that mnemonic is an Electrum "segwit" seed (the type Electrum creates by default) and returns its BIP32 seed, stretched with the optional passphrase ("seed extension" in Electrum). It never includes the mnemonic in errors.
func Enforce ¶
func Enforce[T proto.Message](ctx context.Context, enforcer casbin.IEnforcer, accountFn AccountFn[T], enforceFn EnforceFn[T]) (subject T, authorized bool)
Enforce is a helper function to enforce a policy
func FOR ¶
FOR returns documents from a collection
Example: "FOR doc IN col FILTER doc.name == @name RETURN doc" {"name": "John"}
func GEO_POLYGON ¶ added in v0.14.4
func HandleDownloadFile ¶
func HandleDownloadFile(fs FileStorage) http.HandlerFunc
HandleDownloadFile ...
func NewBitcoinCore ¶
func NewConnection ¶
func NewConnection(ctx context.Context, conf *configv1.Connection) (*connection, error)
NewConnection ...
func NewDbFileStorage ¶
NewDbFileStorage ...
func NewFilesystemStorage ¶
func NewFilesystemStorage(config *configv1.FilesystemStorage) (*filesystemStorage, error)
NewFilesystemStorage ...
func OTPSubscriber ¶ added in v0.16.8
func OTPSubscriber(ctx context.Context, config *configv1.Mail, mailTemplate, smsTemplate OTPTemplate) (Topic, Processor[Topic])
OTPSubscriber is a function that sends an email to the user with the OTP code
func REMOVE ¶
REMOVE removes documents from a collection
Example: "FOR doc IN col FILTER doc.name == @name REMOVE doc IN col" {"name": "John"}
func ReadReset ¶
ReadReset reads and returns the full body of the request without consuming it permanently. It restores the body so it can be read again later. Returns an error if reading fails or body exceeds MaxBodySize.
func Select ¶
func Select[T any](v T) selector[T]
Select returns a new selector with the given value
func SessionFromContext ¶
func ValueOfEnum ¶
func ValueOfEnum(enum protoreflect.EnumDescriptor, name string) protoreflect.Value
Types ¶
type Access ¶
type Access interface {
// AutoMigrate ...
AutoMigrate(ctx context.Context, graph Graph) error
// Collection ...
Collection(ctx context.Context, elem any, callbacks ...func(context.Context, driver.Collection)) (driver.Collection, error)
// Query returns a list of elements
Query(ctx context.Context, query string, bindVars map[string]any, out any) error
// Fetch returns a single element
Fetch(ctx context.Context, query string, bindVars map[string]any, out any) error
// List ...
List(ctx context.Context, filters Filters, out any) (int64, error)
// Get ...
Get(ctx context.Context, filters Filters, out any) error
// Create ...
Create(ctx context.Context, val any) ([]string, error)
// Update ...
Update(ctx context.Context, key string, item any) error
// Replace ...
Replace(ctx context.Context, key string, item any) error
// Delete ...
Delete(ctx context.Context, item any) error
// Relations ...
Relations(ctx context.Context, id string, filters Filters, direction Direction, out any) (int64, error)
}
Access ...
type ArangoAccess ¶
type ArangoAccess struct {
// contains filtered or unexported fields
}
func NewArangoAccess ¶
func NewArangoAccess(conn Connection, observer Observer[Topic]) (*ArangoAccess, error)
func (*ArangoAccess) AutoMigrate ¶
func (e *ArangoAccess) AutoMigrate(ctx context.Context, graph Graph) error
AutoMigrate ...
func (*ArangoAccess) Collection ¶
func (e *ArangoAccess) Collection(ctx context.Context, elem any, callbacks ...func(context.Context, driver.Collection)) (col driver.Collection, err error)
Collection ...
func (*ArangoAccess) Delete ¶
func (e *ArangoAccess) Delete(ctx context.Context, item any) error
Delete ...
func (*ArangoAccess) Fetch ¶
func (e *ArangoAccess) Fetch(ctx context.Context, query string, bindVars map[string]any, out any) error
Fetch ...
func (*ArangoAccess) Query ¶
func (e *ArangoAccess) Query(ctx context.Context, query string, bindVars map[string]any, out any) error
Query ...
func (*ArangoAccess) Relations ¶
func (e *ArangoAccess) Relations(ctx context.Context, id string, filters Filters, direction Direction, out any) (int64, error)
Relations ...
type AuthHandler ¶
type AuthHandler struct {
authv1.UnsafeAuthenticationServiceServer
authv1.UnsafeClientServiceServer
// contains filtered or unexported fields
}
func NewAuthHandler ¶
func NewAuthHandler(ctx context.Context, config *configv1.Auth, params AuthHandlerParams) (*AuthHandler, error)
func (*AuthHandler) Config ¶ added in v0.18.6
func (h *AuthHandler) Config(ctx context.Context, req *emptypb.Empty) (*authv1.ConfigResponse, error)
Config implements [authv1.ClientServiceServer].
func (*AuthHandler) Enforce ¶ added in v0.19.25
func (h *AuthHandler) Enforce(next http.Handler) http.Handler
func (*AuthHandler) FetchAccessToken ¶ added in v0.18.6
func (h *AuthHandler) FetchAccessToken(ctx context.Context, req *emptypb.Empty) (*authv1.AuthResponse, error)
FetchAccessToken implements [authv1.AuthenticationServiceServer].
func (*AuthHandler) FetchSession ¶ added in v0.18.6
func (h *AuthHandler) FetchSession(ctx context.Context, req *emptypb.Empty) (*authv1.FetchSessionResponse, error)
FetchSession implements [authv1.AuthenticationServiceServer].
func (*AuthHandler) Middleware ¶
func (h *AuthHandler) Middleware(next http.Handler) http.Handler
func (*AuthHandler) RequestGuestAccount ¶ added in v0.19.26
func (h *AuthHandler) RequestGuestAccount(ctx context.Context, req *emptypb.Empty) (*authv1.AuthResponse, error)
RequestGuestAccount implements [authv1.AuthenticationServiceServer].
func (*AuthHandler) RequestNonce ¶ added in v0.15.0
func (h *AuthHandler) RequestNonce(ctx context.Context, req *authv1.RequestNonceRequest) (*authv1.RequestNonceResponse, error)
RequestNonce implements [authv1.AuthenticationServiceServer].
func (*AuthHandler) RequestOTP ¶
func (h *AuthHandler) RequestOTP(ctx context.Context, req *authv1.RequestOTPRequest) (*authv1.RequestOTPResponse, error)
RequestOTP implements [authv1.AuthenticationServiceServer].
func (*AuthHandler) RuntimeMiddleware ¶ added in v0.18.0
func (h *AuthHandler) RuntimeMiddleware(next runtime.HandlerFunc) runtime.HandlerFunc
func (*AuthHandler) VerifyNonce ¶ added in v0.15.0
func (h *AuthHandler) VerifyNonce(ctx context.Context, req *authv1.VerifyNonceRequest) (*authv1.AuthResponse, error)
VerifyNonce implements [authv1.AuthenticationServiceServer]. It verifies an Ethereum personal_sign (EIP-191) signature over the nonce we issued for the address, then issues JWT tokens for the session.
func (*AuthHandler) VerifyOTP ¶
func (h *AuthHandler) VerifyOTP(ctx context.Context, req *authv1.VerifyOTPRequest) (*authv1.AuthResponse, error)
type AuthHandlerParams ¶
type BitcoinPaymentGateway ¶
type BitcoinPaymentGateway struct {
bitcoinv1.UnsafeBitcoinPaymentServiceServer
bitcoinv1.UnsafeBitcoinPaymentDashboardServiceServer
// contains filtered or unexported fields
}
func NewBitcoinPaymentGateway ¶
func NewBitcoinPaymentGateway(ctx context.Context, config *configv1.Bitcoin, params BitcoinPaymentGatewayParams) (*BitcoinPaymentGateway, error)
func (*BitcoinPaymentGateway) CreateInvoice ¶
func (h *BitcoinPaymentGateway) CreateInvoice(ctx context.Context, req *bitcoinv1.CreateInvoiceRequest) (*bitcoinv1.CreateInvoiceResponse, error)
func (*BitcoinPaymentGateway) DashboardHandler ¶ added in v0.19.0
func (h *BitcoinPaymentGateway) DashboardHandler(ctx context.Context, auth *AuthHandler, dashboard *DashboardHandler) http.Handler
func (*BitcoinPaymentGateway) GetInvoice ¶
func (h *BitcoinPaymentGateway) GetInvoice(ctx context.Context, req *bitcoinv1.GetInvoiceRequest) (resp *bitcoinv1.GetInvoiceResponse, err error)
func (*BitcoinPaymentGateway) Handler ¶
func (h *BitcoinPaymentGateway) Handler(ctx context.Context) http.Handler
func (*BitcoinPaymentGateway) ListInvoices ¶
func (h *BitcoinPaymentGateway) ListInvoices(ctx context.Context, req *bitcoinv1.ListInvoicesRequest) (*bitcoinv1.ListInvoicesResponse, error)
func (*BitcoinPaymentGateway) Subscribe ¶
func (h *BitcoinPaymentGateway) Subscribe(w http.ResponseWriter, r *http.Request, pathParams map[string]string)
type CasbinAdapter ¶
CasbinAdapter ...
func Unsafe_NewCasbinAdapter ¶
func Unsafe_NewCasbinAdapter[T proto.Message](ctx context.Context, access Access) (*CasbinAdapter[T], error)
Unsafe_NewCasbinAdapter ... TODO: finish this
func (*CasbinAdapter[T]) AddPolicy ¶
func (a *CasbinAdapter[T]) AddPolicy(sec string, ptype string, rule []string) error
AddPolicy implements persist.Adapter.
func (*CasbinAdapter[T]) ExtraFields ¶
func (a *CasbinAdapter[T]) ExtraFields() (result []protoreflect.FieldDescriptor)
func (*CasbinAdapter[T]) LoadPolicy ¶
func (a *CasbinAdapter[T]) LoadPolicy(model model.Model) error
LoadPolicy implements persist.Adapter.
func (*CasbinAdapter[T]) Marshal ¶
func (a *CasbinAdapter[T]) Marshal(elem T) (sec string, ptype string, rule []string)
func (*CasbinAdapter[T]) RemoveFilteredPolicy ¶
func (a *CasbinAdapter[T]) RemoveFilteredPolicy(sec string, ptype string, fieldIndex int, fieldValues ...string) error
RemoveFilteredPolicy implements persist.Adapter.
func (*CasbinAdapter[T]) RemovePolicy ¶
func (a *CasbinAdapter[T]) RemovePolicy(sec string, ptype string, rule []string) error
RemovePolicy implements persist.Adapter.
func (*CasbinAdapter[T]) SavePolicy ¶
func (a *CasbinAdapter[T]) SavePolicy(model model.Model) error
SavePolicy implements persist.Adapter.
type Checks ¶
Checks is a collection of functions that can be used to check if a key should be ignored
type Comparer ¶
type Comparer interface {
Symbol() string
Value() interface{}
}
Comparer is a type that represents a comparison operator and its value.
type Config ¶ added in v0.13.11
type Config struct {
fx.In
Router *configv1.Router
Middlewares []Middleware `group:"middlewares"`
}
type Connection ¶
type Connection interface {
// Database ...
Database(ctx context.Context) (driver.Database, error)
// Collection ...
Collection(ctx context.Context, elem any) (driver.Collection, error)
// Reflect ...
Reflect(ctx context.Context, elem reflect.Type) (driver.Collection, error)
}
Connection ...
type DashboardHandler ¶
type DashboardHandler struct {
Access
Graph
Observer[Topic]
FileStorage
dashboardv1.UnimplementedAccountServiceServer
dashboardv1.UnimplementedResourceServiceServer
dashboardv1.UnimplementedSchemaServiceServer
}
DashboardHandler ...
func NewDashboard ¶
func NewDashboard(ctx context.Context, config *configv1.Dashboard, auth *AuthHandler, params DashboardParams) (*DashboardHandler, error)
NewDashboard ...
func (*DashboardHandler) CreateResource ¶
func (h *DashboardHandler) CreateResource(ctx context.Context, req *dashboardv1.CreateResourceRequest) (*dashboardv1.CreateResourceResponse, error)
func (*DashboardHandler) DeleteAccount ¶
func (h *DashboardHandler) DeleteAccount(ctx context.Context, req *dashboardv1.DeleteAccountRequest) (*emptypb.Empty, error)
func (*DashboardHandler) DeleteResource ¶
func (h *DashboardHandler) DeleteResource(ctx context.Context, req *dashboardv1.DeleteResourceRequest) (*emptypb.Empty, error)
func (*DashboardHandler) GetAccount ¶
func (h *DashboardHandler) GetAccount(ctx context.Context, req *dashboardv1.GetAccountRequest) (*dashboardv1.GetAccountResponse, error)
func (*DashboardHandler) GetCurrentAccount ¶ added in v0.18.0
func (h *DashboardHandler) GetCurrentAccount(ctx context.Context, _ *emptypb.Empty) (*dashboardv1.GetAccountResponse, error)
func (*DashboardHandler) GetResource ¶
func (h *DashboardHandler) GetResource(ctx context.Context, req *dashboardv1.GetResourceRequest) (*dashboardv1.GetResourceResponse, error)
func (*DashboardHandler) GetResourceRelation ¶
func (h *DashboardHandler) GetResourceRelation(ctx context.Context, req *dashboardv1.GetResourceRelationRequest) (*dashboardv1.GetResourceRelationResponse, error)
func (*DashboardHandler) GetSchema ¶
func (h *DashboardHandler) GetSchema(ctx context.Context, req *emptypb.Empty) (*dashboardv1.GetSchemaResponse, error)
func (*DashboardHandler) Handler ¶
func (h *DashboardHandler) Handler(ctx context.Context, auth *AuthHandler) http.Handler
func (*DashboardHandler) ListAccounts ¶
func (h *DashboardHandler) ListAccounts(ctx context.Context, _ *emptypb.Empty) (*dashboardv1.ListAccountsResponse, error)
func (*DashboardHandler) ListResources ¶
func (h *DashboardHandler) ListResources(ctx context.Context, req *dashboardv1.ListResourcesRequest) (*dashboardv1.ListResourcesResponse, error)
func (*DashboardHandler) RegisterAccount ¶
func (h *DashboardHandler) RegisterAccount(ctx context.Context, req *dashboardv1.RegisterAccountRequest) (*dashboardv1.RegisterAccountResponse, error)
func (*DashboardHandler) RuntimeMiddleware ¶ added in v0.19.0
func (h *DashboardHandler) RuntimeMiddleware(next runtime.HandlerFunc) runtime.HandlerFunc
func (*DashboardHandler) UpdateDetails ¶
func (h *DashboardHandler) UpdateDetails(ctx context.Context, req *dashboardv1.UpdateDetailsRequest) (*dashboardv1.UpdateDetailsResponse, error)
func (*DashboardHandler) UpdateResource ¶
func (h *DashboardHandler) UpdateResource(ctx context.Context, req *dashboardv1.UpdateResourceRequest) (*dashboardv1.UpdateResourceResponse, error)
func (*DashboardHandler) UpdateScopes ¶
func (h *DashboardHandler) UpdateScopes(ctx context.Context, req *dashboardv1.UpdateScopesRequest) (*dashboardv1.UpdateScopesResponse, error)
func (*DashboardHandler) UpdateStatus ¶
func (h *DashboardHandler) UpdateStatus(ctx context.Context, req *dashboardv1.UpdateStatusRequest) (*dashboardv1.UpdateStatusResponse, error)
type DashboardParams ¶
DashboardParams ...
type Definition ¶ added in v0.15.1
type Definition string
Definition is a type that represents a definition.
type Direction ¶
type Direction int
Direction is a direction of a relation.
INBOUND: the relation is inbound to the node, means the node is the target of the relation.
OUTBOUND: the relation is outbound from the node, means the node is the source of the relation.
ANY: the relation is inbound or outbound from the node, means the node is the source or target of the relation.
type Directives ¶ added in v0.19.25
func (*Directives) Check ¶ added in v0.19.25
func (d *Directives) Check(ctx context.Context, role string) error
Check checks if the user has access to the directives
func (*Directives) Enforce ¶ added in v0.19.25
func (d *Directives) Enforce(next http.Handler) http.Handler
Enforce enforces the directives on the request
func (*Directives) Middleware ¶ added in v0.19.25
func (d *Directives) Middleware(next http.Handler) http.Handler
GraphqlDirectives injects the directives into the context
type Event ¶
type Event[T comparable] struct { // Topic ... Topic T // Payload ... Payload protoreflect.ProtoMessage // Timestamp ... Timestamp time.Time }
Event ...
type Executor ¶ added in v0.21.0
Executor is a function that executes a hook with a value of type T. It can be used to run hooks with a shared value that can be recreated if it is broken.
func Fallback ¶ added in v0.21.0
func Fallback[T any](life context.Context, onCreate func(context.Context) T, onRecreate func(ctx context.Context, broken T) T) Executor[T]
Fallback initializes the value with onCreate and returns an Executor that runs hooks with it. If a hook returns a RetryErr, the value is recreated with onRecreate and the hook runs again; any other result is returned. onRecreate receives the broken value so it can release it (close connections, stop goroutines); executions still holding it will see it fail and move to the new one.
Concurrent executions share the value. When several of them fail on the same value at once, it is recreated only once and all of them retry with the new one. Executions stop with the context error once ctx (the Fallback's lifetime) or their own context is done, including while they wait for a recreation.
type FileStorage ¶
type FileStorage interface {
// StoreFile ...
StoreFile(name string, file []byte) (id string, err error)
// StoreByHash ...
StoreByHash(file []byte) (id string, err error)
// ReadFile ...
ReadFile(id string) (fileContent []byte, errr error)
// MaxMemory ...
MaxMemory() int64
}
FileStorage ...
type Filters ¶
type Filters interface {
// FilterString ...
FilterString(doc string) string
// SortString ...
SortString(doc string) string
// LimitString ...
LimitString() string
// BindVars ...
BindVars() map[string]interface{}
}
Filters ...
type Graph ¶
type Graph interface {
// Node ...
Node(node any)
// Edge ...
Edge(from, to, edge any)
// Nodes ...
Nodes() []reflect.Type
// Edges ...
Edges() []reflect.Type
// Relation ...
Relation(edge reflect.Type) *Relation
// CollectionFor ...
CollectionFor(elem reflect.Type) string
// TypeOf ...
TypeOf(name string) reflect.Type
}
Graph ...
type GraphqlHandler ¶
GraphqlHandler ...
type Middleware ¶
Middleware is a function that wraps an http.Handler to add functionality before and/or after the handler is executed.
func Chain ¶ added in v0.18.0
func Chain(m ...Middleware) Middleware
func Match ¶
func Match(re *regexp.Regexp, mw ...Middleware) Middleware
Match applies a single mux.MiddlewareFunc only if the request path matches the given regexp.
type OTPTemplate ¶ added in v0.16.8
OTPTemplate is a function that returns the message to send to the user
type Observer ¶
type Observer[T comparable] interface { // Subscribe ... Subscribe(t T, p Processor[T]) SourceID // Unsubscribe ... Unsubscribe(s SourceID) // Emit ... Emit(e *Event[T]) error }
Observer ...
type RetryErr ¶ added in v0.21.0
type RetryErr struct{ Err error }
RetryErr marks a hook error meaning the value is broken: the Fallback recreates the value and runs the hook again. Return it as RetryErr{Err: err}.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
library
command
|
|
|
internal
|
|
|
pkg
|
|
|
auth/domain/auth/v1
Package authv1 is a reverse proxy.
|
Package authv1 is a reverse proxy. |
|
dashboard/domain/dashboard/v1
Package dashboardv1 is a reverse proxy.
|
Package dashboardv1 is a reverse proxy. |
|
payment/domain/bitcoin/v1
Package bitcoinv1 is a reverse proxy.
|
Package bitcoinv1 is a reverse proxy. |