supertokens

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 23, 2021 License: Apache-2.0 Imports: 13 Imported by: 84

Documentation

Index

Constants

View Source
const (
	HeaderRID = "rid"
	HeaderFDI = "fdi-version"
)
View Source
const VERSION = "0.3.0"

VERSION current version of the lib

Variables

View Source
var IsTestFlag = false

this will be set to true if this is used in a test app environment

Functions

func ErrorHandler

func ErrorHandler(err error, req *http.Request, res http.ResponseWriter) error

func GetAllCORSHeaders

func GetAllCORSHeaders() []string

func GetInstanceOrThrowError added in v0.2.0

func GetInstanceOrThrowError() (*superTokens, error)

func GetUserCount

func GetUserCount(includeRecipeIds *[]string) (float64, error)

func Init

func Init(config TypeInput) error

func IsAnIPAddress

func IsAnIPAddress(ipaddress string) (bool, error)

func IsRunningInTestMode

func IsRunningInTestMode() bool

func Middleware

func Middleware(theirHandler http.Handler) http.Handler

func ResetForTest

func ResetForTest()

func ResetQuerierForTest

func ResetQuerierForTest()

func Send200Response

func Send200Response(res http.ResponseWriter, responseJson interface{}) error

func SendNon200Response

func SendNon200Response(res http.ResponseWriter, message string, statusCode int) error

Types

type APIHandled

type APIHandled struct {
	PathWithoutAPIBasePath NormalisedURLPath
	Method                 string
	ID                     string
	Disabled               bool
}

type AppInfo

type AppInfo struct {
	AppName         string
	WebsiteDomain   string
	APIDomain       string
	WebsiteBasePath *string
	APIBasePath     *string
	APIGatewayPath  *string
}

type BadInputError

type BadInputError struct {
	Msg string
}

BadInputError used for non specific exceptions

func (BadInputError) Error

func (err BadInputError) Error() string

type ConnectionInfo

type ConnectionInfo struct {
	ConnectionURI string
	APIKey        string
}

type DoneWriter added in v0.2.2

type DoneWriter struct {
	http.ResponseWriter
	// contains filtered or unexported fields
}

func (*DoneWriter) Write added in v0.2.2

func (w *DoneWriter) Write(b []byte) (int, error)

type NormalisedAppinfo

type NormalisedAppinfo struct {
	AppName         string
	WebsiteDomain   NormalisedURLDomain
	APIDomain       NormalisedURLDomain
	APIBasePath     NormalisedURLPath
	APIGatewayPath  NormalisedURLPath
	WebsiteBasePath NormalisedURLPath
}

func NormaliseInputAppInfoOrThrowError

func NormaliseInputAppInfoOrThrowError(appInfo AppInfo) (NormalisedAppinfo, error)

type NormalisedURLDomain

type NormalisedURLDomain struct {
	// contains filtered or unexported fields
}

func NewNormalisedURLDomain

func NewNormalisedURLDomain(url string) (NormalisedURLDomain, error)

func (NormalisedURLDomain) GetAsStringDangerous

func (n NormalisedURLDomain) GetAsStringDangerous() string

type NormalisedURLPath

type NormalisedURLPath struct {
	// contains filtered or unexported fields
}

func NewNormalisedURLPath

func NewNormalisedURLPath(url string) (NormalisedURLPath, error)

func (NormalisedURLPath) AppendPath

func (NormalisedURLPath) Equals

func (n NormalisedURLPath) Equals(other NormalisedURLPath) bool

func (NormalisedURLPath) GetAsStringDangerous

func (n NormalisedURLPath) GetAsStringDangerous() string

func (NormalisedURLPath) IsARecipePath

func (n NormalisedURLPath) IsARecipePath() bool

func (NormalisedURLPath) StartsWith

func (n NormalisedURLPath) StartsWith(other NormalisedURLPath) bool

type Querier

type Querier struct {
	RIDToCore string
}

func GetNewQuerierInstanceOrThrowError

func GetNewQuerierInstanceOrThrowError(rIDToCore string) (*Querier, error)

func (*Querier) SendDeleteRequest

func (q *Querier) SendDeleteRequest(path string, data map[string]interface{}) (map[string]interface{}, error)

func (*Querier) SendGetRequest

func (q *Querier) SendGetRequest(path string, params map[string]string) (map[string]interface{}, error)

func (*Querier) SendPostRequest

func (q *Querier) SendPostRequest(path string, data map[string]interface{}) (map[string]interface{}, error)

func (*Querier) SendPutRequest

func (q *Querier) SendPutRequest(path string, data map[string]interface{}) (map[string]interface{}, error)

type Recipe

type Recipe func(appInfo NormalisedAppinfo, onGeneralError func(err error, req *http.Request, res http.ResponseWriter)) (*RecipeModule, error)

type RecipeModule

type RecipeModule struct {
	HandleAPIRequest  func(ID string, req *http.Request, res http.ResponseWriter, theirHandler http.HandlerFunc, path NormalisedURLPath, method string) error
	GetAllCORSHeaders func() []string
	GetAPIsHandled    func() ([]APIHandled, error)
	HandleError       func(err error, req *http.Request, res http.ResponseWriter) (bool, error)
	OnGeneralError    func(err error, req *http.Request, res http.ResponseWriter)
	// contains filtered or unexported fields
}

func MakeRecipeModule

func MakeRecipeModule(
	recipeId string,
	appInfo NormalisedAppinfo,
	handleAPIRequest func(id string, req *http.Request, res http.ResponseWriter, theirHandler http.HandlerFunc, path NormalisedURLPath, method string) error,
	getAllCORSHeaders func() []string,
	getAPIsHandled func() ([]APIHandled, error),
	handleError func(err error, req *http.Request, res http.ResponseWriter) (bool, error),
	onGeneralError func(err error, req *http.Request, res http.ResponseWriter)) RecipeModule

func (RecipeModule) GetAppInfo

func (r RecipeModule) GetAppInfo() NormalisedAppinfo

func (RecipeModule) GetRecipeID

func (r RecipeModule) GetRecipeID() string

func (*RecipeModule) ReturnAPIIdIfCanHandleRequest

func (r *RecipeModule) ReturnAPIIdIfCanHandleRequest(path NormalisedURLPath, method string) (*string, error)

type TypeInput

type TypeInput struct {
	Supertokens    *ConnectionInfo
	AppInfo        AppInfo
	RecipeList     []Recipe
	Telemetry      *bool
	OnGeneralError func(err error, req *http.Request, res http.ResponseWriter)
}

type UserPaginationResult

type UserPaginationResult struct {
	Users []struct {
		RecipeId string
		User     map[string]interface{}
	}
	NextPaginationToken *string
}

func GetUsersNewestFirst

func GetUsersNewestFirst(paginationToken *string, limit *int, includeRecipeIds *[]string) (UserPaginationResult, error)

func GetUsersOldestFirst

func GetUsersOldestFirst(paginationToken *string, limit *int, includeRecipeIds *[]string) (UserPaginationResult, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL