tpmodels

package
v0.17.5 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 License: Apache-2.0 Imports: 4 Imported by: 42

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIInterface

type APIInterface struct {
	AuthorisationUrlGET      *func(provider *TypeProvider, redirectURIOnProviderDashboard string, tenantId string, options APIOptions, userContext supertokens.UserContext) (AuthorisationUrlGETResponse, error)
	SignInUpPOST             *func(provider *TypeProvider, input TypeSignInUpInput, tenantId string, options APIOptions, userContext supertokens.UserContext) (SignInUpPOSTResponse, error)
	AppleRedirectHandlerPOST *func(formPostInfoFromProvider map[string]interface{}, options APIOptions, userContext supertokens.UserContext) error
}

type APIOptions

type APIOptions struct {
	RecipeImplementation RecipeInterface
	Config               TypeNormalisedInput
	RecipeID             string
	Providers            []ProviderInput
	Req                  *http.Request
	Res                  http.ResponseWriter
	OtherHandler         http.HandlerFunc
	AppInfo              supertokens.NormalisedAppinfo
	EmailDelivery        emaildelivery.Ingredient
}

type AuthorisationUrlGETResponse

type AuthorisationUrlGETResponse struct {
	OK           *TypeAuthorisationRedirect
	GeneralError *supertokens.GeneralErrorResponse
}

type EmailStruct

type EmailStruct struct {
	ID         string `json:"id"`
	IsVerified bool   `json:"isVerified"`
}

type ManuallyCreateOrUpdateUserResponse added in v0.13.0

type ManuallyCreateOrUpdateUserResponse struct {
	OK *struct {
		CreatedNewUser bool
		User           User
	}
}

type OverrideStruct

type OverrideStruct struct {
	Functions func(originalImplementation RecipeInterface) RecipeInterface
	APIs      func(originalImplementation APIInterface) APIInterface
}

type ProviderClientConfig added in v0.13.0

type ProviderClientConfig struct {
	ClientType       string                 `json:"clientType,omitempty"` // optional
	ClientID         string                 `json:"clientId"`
	ClientSecret     string                 `json:"clientSecret,omitempty"`
	Scope            []string               `json:"scope,omitempty"`
	ForcePKCE        *bool                  `json:"forcePKCE,omitempty"`
	AdditionalConfig map[string]interface{} `json:"additionalConfig,omitempty"`
}

type ProviderConfig added in v0.13.0

type ProviderConfig struct {
	ThirdPartyId string `json:"thirdPartyId"`
	Name         string `json:"name,omitempty"`

	Clients []ProviderClientConfig `json:"clients,omitempty"`

	// Fields below are optional for built-in providers
	AuthorizationEndpoint            string                 `json:"authorizationEndpoint,omitempty"`
	AuthorizationEndpointQueryParams map[string]interface{} `json:"authorizationEndpointQueryParams,omitempty"`
	TokenEndpoint                    string                 `json:"tokenEndpoint,omitempty"`
	TokenEndpointBodyParams          map[string]interface{} `json:"tokenEndpointBodyParams,omitempty"`
	UserInfoEndpoint                 string                 `json:"userInfoEndpoint,omitempty"`
	UserInfoEndpointQueryParams      map[string]interface{} `json:"userInfoEndpointQueryParams,omitempty"`
	UserInfoEndpointHeaders          map[string]interface{} `json:"userInfoEndpointHeaders,omitempty"`
	JwksURI                          string                 `json:"jwksURI,omitempty"`
	OIDCDiscoveryEndpoint            string                 `json:"oidcDiscoveryEndpoint,omitempty"`
	UserInfoMap                      TypeUserInfoMap        `json:"userInfoMap,omitempty"`
	RequireEmail                     *bool                  `json:"requireEmail,omitempty"`

	ValidateIdTokenPayload func(idTokenPayload map[string]interface{}, clientConfig ProviderConfigForClientType, userContext supertokens.UserContext) error `json:"-"`
	ValidateAccessToken    func(accessToken string, clientConfig ProviderConfigForClientType, userContext supertokens.UserContext) error                    `json:"-"`
	GenerateFakeEmail      func(thirdPartyUserId string, tenantId string, userContext supertokens.UserContext) string                                       `json:"-"`
}

type ProviderConfigForClientType added in v0.13.0

type ProviderConfigForClientType struct {
	Name string

	ClientID         string
	ClientSecret     string
	Scope            []string
	AdditionalConfig map[string]interface{}

	AuthorizationEndpoint            string
	AuthorizationEndpointQueryParams map[string]interface{}
	TokenEndpoint                    string
	TokenEndpointBodyParams          map[string]interface{}
	ForcePKCE                        *bool // Providers like twitter expects PKCE to be used along with secret
	UserInfoEndpoint                 string
	UserInfoEndpointQueryParams      map[string]interface{}
	UserInfoEndpointHeaders          map[string]interface{}
	JwksURI                          string
	OIDCDiscoveryEndpoint            string
	UserInfoMap                      TypeUserInfoMap
	ValidateIdTokenPayload           func(idTokenPayload map[string]interface{}, clientConfig ProviderConfigForClientType, userContext supertokens.UserContext) error
	ValidateAccessToken              func(accessToken string, clientConfig ProviderConfigForClientType, userContext supertokens.UserContext) error

	RequireEmail      *bool
	GenerateFakeEmail func(thirdPartyUserId string, tenantId string, userContext supertokens.UserContext) string
}

type ProviderInput added in v0.13.0

type ProviderInput struct {
	Config   ProviderConfig
	Override func(originalImplementation *TypeProvider) *TypeProvider
}

type RecipeInterface

type RecipeInterface struct {
	GetUserByID             *func(userID string, userContext supertokens.UserContext) (*User, error)
	GetUsersByEmail         *func(email string, tenantId string, userContext supertokens.UserContext) ([]User, error)
	GetUserByThirdPartyInfo *func(thirdPartyID string, thirdPartyUserID string, tenantId string, userContext supertokens.UserContext) (*User, error)

	GetProvider *func(thirdPartyID string, clientType *string, tenantId string, userContext supertokens.UserContext) (*TypeProvider, error)

	SignInUp                   *func(thirdPartyID string, thirdPartyUserID string, email string, oAuthTokens TypeOAuthTokens, rawUserInfoFromProvider TypeRawUserInfoFromProvider, tenantId string, userContext supertokens.UserContext) (SignInUpResponse, error)
	ManuallyCreateOrUpdateUser *func(thirdPartyID string, thirdPartyUserID string, email string, tenantId string, userContext supertokens.UserContext) (ManuallyCreateOrUpdateUserResponse, error)
}

type SignInUpPOSTResponse

type SignInUpPOSTResponse struct {
	OK *struct {
		CreatedNewUser          bool
		User                    User
		Session                 sessmodels.SessionContainer
		OAuthTokens             TypeOAuthTokens
		RawUserInfoFromProvider TypeRawUserInfoFromProvider
	}
	NoEmailGivenByProviderError *struct{}
	GeneralError                *supertokens.GeneralErrorResponse
}

type SignInUpResponse

type SignInUpResponse struct {
	OK *struct {
		CreatedNewUser          bool
		User                    User
		OAuthTokens             TypeOAuthTokens
		RawUserInfoFromProvider TypeRawUserInfoFromProvider
	}
}

type TypeAuthorisationRedirect added in v0.13.0

type TypeAuthorisationRedirect struct {
	URLWithQueryParams string
	PKCECodeVerifier   *string
}

type TypeFrom added in v0.13.0

type TypeFrom string
const (
	FromIdTokenPayload TypeFrom = "idTokenPayload"
	FromUserInfoAPI    TypeFrom = "userInfoAPI"
)

type TypeInput

type TypeInput struct {
	SignInAndUpFeature TypeInputSignInAndUp
	Override           *OverrideStruct
}

type TypeInputSignInAndUp

type TypeInputSignInAndUp struct {
	Providers []ProviderInput
}

type TypeNormalisedInput

type TypeNormalisedInput struct {
	SignInAndUpFeature TypeNormalisedInputSignInAndUp
	Override           OverrideStruct
}

type TypeNormalisedInputSignInAndUp

type TypeNormalisedInputSignInAndUp struct {
	Providers []ProviderInput
}

type TypeOAuthTokens added in v0.13.0

type TypeOAuthTokens = map[string]interface{}

type TypeProvider

type TypeProvider struct {
	ID     string
	Config ProviderConfigForClientType

	GetConfigForClientType         func(clientType *string, userContext supertokens.UserContext) (ProviderConfigForClientType, error)
	GetAuthorisationRedirectURL    func(redirectURIOnProviderDashboard string, userContext supertokens.UserContext) (TypeAuthorisationRedirect, error)
	ExchangeAuthCodeForOAuthTokens func(redirectURIInfo TypeRedirectURIInfo, userContext supertokens.UserContext) (TypeOAuthTokens, error) // For apple, add userInfo from callbackInfo to oAuthTOkens
	GetUserInfo                    func(oAuthTokens TypeOAuthTokens, userContext supertokens.UserContext) (TypeUserInfo, error)
}

type TypeRawUserInfoFromProvider added in v0.13.0

type TypeRawUserInfoFromProvider struct {
	FromIdTokenPayload map[string]interface{}
	FromUserInfoAPI    map[string]interface{}
}

type TypeRedirectURIInfo added in v0.13.0

type TypeRedirectURIInfo struct {
	RedirectURIOnProviderDashboard string                     `json:"redirectURIOnProviderDashboard"`
	RedirectURIQueryParams         TypeRedirectURIQueryParams `json:"redirectURIQueryParams"`
	PKCECodeVerifier               *string                    `json:"pkceCodeVerifier"`
}

type TypeRedirectURIQueryParams added in v0.13.0

type TypeRedirectURIQueryParams = map[string]interface{}

type TypeSignInUpInput added in v0.13.0

type TypeSignInUpInput struct {
	// Either of the below
	RedirectURIInfo *TypeRedirectURIInfo `json:"redirectURIInfo"`
	OAuthTokens     *TypeOAuthTokens     `json:"oAuthTokens"`
}

type TypeUserInfo added in v0.13.0

type TypeUserInfo struct {
	ThirdPartyUserId        string
	Email                   *EmailStruct
	RawUserInfoFromProvider TypeRawUserInfoFromProvider
}

type TypeUserInfoMap added in v0.13.0

type TypeUserInfoMap struct {
	FromIdTokenPayload TypeUserInfoMapFields `json:"fromIdTokenPayload,omitempty"`
	FromUserInfoAPI    TypeUserInfoMapFields `json:"fromUserInfoAPI,omitempty"`
}

type TypeUserInfoMapFields added in v0.13.0

type TypeUserInfoMapFields struct {
	UserId        string `json:"userId,omitempty"`
	Email         string `json:"email,omitempty"`
	EmailVerified string `json:"emailVerified,omitempty"`
}

type User

type User struct {
	ID         string `json:"id"`
	TimeJoined uint64 `json:"timeJoined"`
	Email      string `json:"email"`
	ThirdParty struct {
		ID     string `json:"id"`
		UserID string `json:"userId"`
	} `json:"thirdParty"`
	TenantIds []string `json:"tenantIds"`
}

Jump to

Keyboard shortcuts

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