Documentation
¶
Index ¶
- Constants
- Variables
- func MarshalVerifyOtpCredentials(c VerifyOtpCredentials) ([]byte, error)
- type Admin
- func (a *Admin) CreateUser(ctx context.Context, params AdminUserParams) (*AdminUser, error)
- func (a *Admin) GenerateLink(ctx context.Context, params GenerateLinkParams) (*GenerateLinkResponse, error)
- func (a *Admin) GetUser(ctx context.Context, userID string) (*AdminUser, error)
- func (a *Admin) UpdateUser(ctx context.Context, userID string, params AdminUserParams) (*AdminUser, error)
- type AdminUser
- type AdminUserParams
- type Auth
- func (a *Auth) ExchangeCode(ctx context.Context, opts ExchangeCodeOpts) (*AuthenticatedDetails, error)
- func (a *Auth) InviteUserByEmail(ctx context.Context, email string) (*User, error)
- func (a *Auth) InviteUserByEmailWithData(ctx context.Context, email string, data map[string]interface{}, ...) (*User, error)
- func (a *Auth) RefreshUser(ctx context.Context, userToken string, refreshToken string) (*AuthenticatedDetails, error)
- func (a *Auth) ResetPasswordForEmail(ctx context.Context, email string, redirectTo string) error
- func (a *Auth) SendMagicLink(ctx context.Context, email string) error
- func (a *Auth) SignIn(ctx context.Context, credentials UserCredentials) (*AuthenticatedDetails, error)
- func (a *Auth) SignInWithProvider(opts ProviderSignInOptions) (*ProviderSignInDetails, error)
- func (a *Auth) SignOut(ctx context.Context, userToken string) error
- func (a *Auth) SignUp(ctx context.Context, credentials UserCredentials) (*User, error)
- func (a *Auth) UpdateUser(ctx context.Context, userToken string, updateData map[string]interface{}) (*User, error)
- func (a *Auth) User(ctx context.Context, userToken string) (*User, error)
- func (a *Auth) VerifyOtp(ctx context.Context, credentials VerifyOtpCredentials) (*AuthenticatedDetails, error)
- type AuthenticatedDetails
- type BucketOption
- type Client
- type EmailOtpType
- type ErrorResponse
- type ExchangeCodeOpts
- type Factor
- type FileErrorResponse
- type FileObject
- type FileResponse
- type FileSearchOptions
- type FileUploadOptions
- type FlowType
- type GenerateLinkParams
- type GenerateLinkResponse
- type Identity
- type JSONMap
- type ListFileRequest
- type PKCEParams
- type PhoneOtpType
- type ProviderSignInDetails
- type ProviderSignInOptions
- type SignedUrlResponse
- type SortBy
- type Storage
- func (s *Storage) CreateBucket(ctx context.Context, option BucketOption) (*bucket, error)
- func (s *Storage) DeleteBucket(ctx context.Context, id string) (*bucketResponse, error)
- func (s *Storage) EmptyBucket(ctx context.Context, id string) (*bucketMessage, error)
- func (s *Storage) From(bucketId string) *file
- func (s *Storage) GetBucket(ctx context.Context, id string) (*bucketResponse, error)
- func (s *Storage) ListBuckets(ctx context.Context) (*[]bucketResponse, error)
- func (s *Storage) UpdateBucket(ctx context.Context, id string, option BucketOption) (*bucketMessage, error)
- type User
- type UserCredentials
- type VerifyEmailOtpCredentials
- type VerifyOtpCredentials
- type VerifyPhoneOtpCredentials
- type VerifyTokenHashOtpCredentials
Constants ¶
const ( AuthEndpoint = "auth/v1" AdminEndpoint = "auth/v1/admin" RestEndpoint = "rest/v1" StorageEndpoint = "storage/v1" )
Variables ¶
var ErrNotFound = errors.New("file not found")
Functions ¶
func MarshalVerifyOtpCredentials ¶ added in v0.5.0
func MarshalVerifyOtpCredentials(c VerifyOtpCredentials) ([]byte, error)
MarshalVerifyOtpCredentials marshals the VerifyOtpCredentials into a JSON byte slice.
Types ¶
type Admin ¶ added in v0.4.0
type Admin struct {
// contains filtered or unexported fields
}
func (*Admin) CreateUser ¶ added in v0.4.0
Create a user
func (*Admin) GenerateLink ¶ added in v0.4.0
func (a *Admin) GenerateLink(ctx context.Context, params GenerateLinkParams) (*GenerateLinkResponse, error)
Update a user
func (*Admin) UpdateUser ¶ added in v0.4.0
func (a *Admin) UpdateUser(ctx context.Context, userID string, params AdminUserParams) (*AdminUser, error)
Update a user
type AdminUser ¶ added in v0.4.0
type AdminUser struct { ID string `json:"id" db:"id"` Aud string `json:"aud" db:"aud"` Role string `json:"role" db:"role"` Email string `json:"email" db:"email"` EmailConfirmedAt *time.Time `json:"email_confirmed_at,omitempty" db:"email_confirmed_at"` InvitedAt *time.Time `json:"invited_at,omitempty" db:"invited_at"` Phone string `json:"phone" db:"phone"` PhoneConfirmedAt *time.Time `json:"phone_confirmed_at,omitempty" db:"phone_confirmed_at"` ConfirmationSentAt *time.Time `json:"confirmation_sent_at,omitempty" db:"confirmation_sent_at"` RecoverySentAt *time.Time `json:"recovery_sent_at,omitempty" db:"recovery_sent_at"` EmailChange string `json:"new_email,omitempty" db:"email_change"` EmailChangeSentAt *time.Time `json:"email_change_sent_at,omitempty" db:"email_change_sent_at"` PhoneChange string `json:"new_phone,omitempty" db:"phone_change"` PhoneChangeSentAt *time.Time `json:"phone_change_sent_at,omitempty" db:"phone_change_sent_at"` ReauthenticationSentAt *time.Time `json:"reauthentication_sent_at,omitempty" db:"reauthentication_sent_at"` LastSignInAt *time.Time `json:"last_sign_in_at,omitempty" db:"last_sign_in_at"` AppMetaData JSONMap `json:"app_metadata" db:"raw_app_meta_data"` UserMetaData JSONMap `json:"user_metadata" db:"raw_user_meta_data"` Factors []Factor `json:"factors,omitempty" has_many:"factors"` Identities []Identity `json:"identities" has_many:"identities"` CreatedAt time.Time `json:"created_at" db:"created_at"` UpdatedAt time.Time `json:"updated_at" db:"updated_at"` BannedUntil *time.Time `json:"banned_until,omitempty" db:"banned_until"` DeletedAt *time.Time `json:"deleted_at,omitempty" db:"deleted_at"` }
type AdminUserParams ¶ added in v0.4.0
type AdminUserParams struct { Role string `json:"role"` Email string `json:"email"` Phone string `json:"phone"` Password *string `json:"password"` EmailConfirm bool `json:"email_confirm"` PhoneConfirm bool `json:"phone_confirm"` UserMetadata JSONMap `json:"user_metadata"` AppMetadata JSONMap `json:"app_metadata"` BanDuration string `json:"ban_duration"` }
type Auth ¶ added in v0.1.2
type Auth struct {
// contains filtered or unexported fields
}
func (*Auth) ExchangeCode ¶ added in v0.3.0
func (a *Auth) ExchangeCode(ctx context.Context, opts ExchangeCodeOpts) (*AuthenticatedDetails, error)
ExchangeCode takes an auth code and PCKE verifier and returns the current user if succeeded.
func (*Auth) InviteUserByEmail ¶ added in v0.1.2
InviteUserByEmail sends an invite link to the given email. Returns a user.
func (*Auth) InviteUserByEmailWithData ¶ added in v0.5.0
func (a *Auth) InviteUserByEmailWithData(ctx context.Context, email string, data map[string]interface{}, redirectTo string) (*User, error)
InviteUserByEmailWithOpts sends an invite link to the given email with metadata. Returns a user.
func (*Auth) RefreshUser ¶ added in v0.1.2
func (a *Auth) RefreshUser(ctx context.Context, userToken string, refreshToken string) (*AuthenticatedDetails, error)
SignIn enters the user credentials and returns the current user if succeeded.
func (*Auth) ResetPasswordForEmail ¶ added in v0.1.2
ResetPasswordForEmail sends a password recovery link to the given e-mail address.
func (*Auth) SendMagicLink ¶ added in v0.1.2
SendMagicLink sends a link to a specific e-mail address for passwordless auth.
func (*Auth) SignIn ¶ added in v0.1.2
func (a *Auth) SignIn(ctx context.Context, credentials UserCredentials) (*AuthenticatedDetails, error)
SignIn enters the user credentials and returns the current user if succeeded.
func (*Auth) SignInWithProvider ¶ added in v0.1.2
func (a *Auth) SignInWithProvider(opts ProviderSignInOptions) (*ProviderSignInDetails, error)
SignInWithProvider returns a URL for signing in via OAuth
func (*Auth) SignUp ¶ added in v0.1.2
SignUp registers the user's email and password to the database.
func (*Auth) UpdateUser ¶ added in v0.1.2
func (a *Auth) UpdateUser(ctx context.Context, userToken string, updateData map[string]interface{}) (*User, error)
UpdateUser updates the user information
func (*Auth) VerifyOtp ¶ added in v0.5.0
func (a *Auth) VerifyOtp(ctx context.Context, credentials VerifyOtpCredentials) (*AuthenticatedDetails, error)
verify otp takes in a token hash and verify type, verifies the user and returns the the user if succeeded.
type AuthenticatedDetails ¶
type AuthenticatedDetails struct { AccessToken string `json:"access_token"` TokenType string `json:"token_type"` ExpiresIn int `json:"expires_in"` RefreshToken string `json:"refresh_token"` User User `json:"user"` ProviderToken string `json:"provider_token"` ProviderRefreshToken string `json:"provider_refresh_token"` }
type BucketOption ¶ added in v0.4.0
type Client ¶
type EmailOtpType ¶ added in v0.5.0
type EmailOtpType string
EmailOtpType is the type of email OTP.
const ( EmailOtpTypeEmail EmailOtpType = "email" EmailOtpTypeReceovery EmailOtpType = "recovery" EmailOtpTypeInvite EmailOtpType = "invite" EmailOtpTypeEmailChange EmailOtpType = "email_change" )
type ErrorResponse ¶
func (*ErrorResponse) Error ¶
func (err *ErrorResponse) Error() string
type ExchangeCodeOpts ¶ added in v0.3.0
type Factor ¶ added in v0.4.0
type Factor struct { ID string `json:"id" db:"id"` CreatedAt time.Time `json:"created_at" db:"created_at"` UpdatedAt time.Time `json:"updated_at" db:"updated_at"` Status string `json:"status" db:"status"` FriendlyName string `json:"friendly_name,omitempty" db:"friendly_name"` FactorType string `json:"factor_type" db:"factor_type"` }
type FileErrorResponse ¶ added in v0.3.0
type FileErrorResponse struct { Status string `json:"statusCode"` ShortError string `json:"error"` Message string `json:"message"` }
func (*FileErrorResponse) Error ¶ added in v0.3.0
func (err *FileErrorResponse) Error() string
type FileObject ¶ added in v0.2.0
type FileObject struct { Name string `json:"name"` BucketId string `json:"bucket_id"` Owner string `json:"owner"` Id string `json:"id"` UpdatedAt string `json:"updated_at"` CreatedAt string `json:"created_at"` LastAccessedAt string `json:"last_accessed_at"` Metadata interface{} `json:"metadata"` Buckets bucket `json:"buckets"` }
type FileResponse ¶ added in v0.2.0
type FileSearchOptions ¶ added in v0.2.0
type FileUploadOptions ¶ added in v0.5.0
type GenerateLinkParams ¶ added in v0.4.0
type GenerateLinkResponse ¶ added in v0.4.0
type Identity ¶ added in v0.4.0
type Identity struct { ID string `json:"id" db:"id"` UserID string `json:"user_id" db:"user_id"` IdentityData JSONMap `json:"identity_data,omitempty" db:"identity_data"` Provider string `json:"provider" db:"provider"` LastSignInAt *time.Time `json:"last_sign_in_at,omitempty" db:"last_sign_in_at"` CreatedAt time.Time `json:"created_at" db:"created_at"` UpdatedAt time.Time `json:"updated_at" db:"updated_at"` }
type ListFileRequest ¶ added in v0.2.0
type PKCEParams ¶ added in v0.3.0
adapted from https://go-review.googlesource.com/c/oauth2/+/463979/9/pkce.go#64
type PhoneOtpType ¶ added in v0.5.0
type PhoneOtpType string
PhoneOtpType is the type of phone OTP.
const ( PhoneOtpTypeSMS PhoneOtpType = "sms" PhoneOtpTypePhoneChange PhoneOtpType = "phone_change" )
type ProviderSignInDetails ¶
type ProviderSignInOptions ¶
type SignedUrlResponse ¶ added in v0.2.0
type SignedUrlResponse struct {
SignedUrl string `json:"signedURL"`
}
type Storage ¶ added in v0.2.0
type Storage struct {
// contains filtered or unexported fields
}
func (*Storage) CreateBucket ¶ added in v0.2.0
func (s *Storage) CreateBucket(ctx context.Context, option BucketOption) (*bucket, error)
CreateBucket creates a new storage bucket @param: option: a bucketOption with the name and id of the bucket you want to create @returns: bucket: a response with the details of the bucket of the bucket created
func (*Storage) DeleteBucket ¶ added in v0.2.0
DeleteBucket deletes a bucket by its id, a bucket can't be deleted except emptied @param: id: the id of the bucket @returns bucketMessage: a successful response message or failed
func (*Storage) EmptyBucket ¶ added in v0.2.0
EmptyBucket empties the object of a bucket by id @param: id: the id of the bucket @returns bucketMessage: a successful response message or failed
func (*Storage) GetBucket ¶ added in v0.2.0
GetBucket retrieves a bucket by its id @param: id: the id of the bucket @returns: bucketResponse: a response with the details of the bucket
func (*Storage) ListBuckets ¶ added in v0.2.0
ListBucket retrieves all buckets ina supabase storage @returns: []bucketResponse: a response with the details of all the bucket
func (*Storage) UpdateBucket ¶ added in v0.2.0
func (s *Storage) UpdateBucket(ctx context.Context, id string, option BucketOption) (*bucketMessage, error)
UpdateBucket updates a bucket by its id @param: id: the id of the bucket @param: option: the options to be updated @returns bucketMessage: a successful response message or failed
type User ¶
type User struct { ID string `json:"id"` Aud string `json:"aud"` Role string `json:"role"` Email string `json:"email"` InvitedAt time.Time `json:"invited_at"` ConfirmedAt time.Time `json:"confirmed_at"` ConfirmationSentAt time.Time `json:"confirmation_sent_at"` AppMetadata struct { // contains filtered or unexported fields } `json:"app_metadata"` UserMetadata map[string]interface{} `json:"user_metadata"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }
type UserCredentials ¶
type VerifyEmailOtpCredentials ¶ added in v0.5.0
type VerifyEmailOtpCredentials struct { Email string `mapstructure:"email"` Token string `mapstructure:"token"` TokenHash string `mapstructure:"token_hash"` Type EmailOtpType `mapstructure:"type"` RedirectTo string `mapstructure:"redirect_to,omitempty"` }
VerifyEmailOtpCredentials is the struct for verifying OTPs sent to an email address.
func (VerifyEmailOtpCredentials) OtpType ¶ added in v0.5.0
func (c VerifyEmailOtpCredentials) OtpType() string
OtpType returns the type of OTP.
type VerifyOtpCredentials ¶ added in v0.5.0
type VerifyOtpCredentials interface {
OtpType() string
}
VerifyOtpCredentials is the interface for verifying OTPs.
type VerifyPhoneOtpCredentials ¶ added in v0.5.0
type VerifyPhoneOtpCredentials struct { Phone string `mapstructure:"phone"` Type PhoneOtpType `mapstructure:"type"` TokenHash string `mapstructure:"token_hash"` Token string `mapstructure:"token"` RedirectTo string `mapstructure:"redirect_to,omitempty"` }
VerifyPhoneOtpCredentials is the struct for verifying OTPs sent to a phone number.
func (VerifyPhoneOtpCredentials) OtpType ¶ added in v0.5.0
func (c VerifyPhoneOtpCredentials) OtpType() string
type VerifyTokenHashOtpCredentials ¶ added in v0.5.0
type VerifyTokenHashOtpCredentials struct { TokenHash string `mapstructure:"token_hash"` Type string `mapstructure:"type"` RedirectTo string `mapstructure:"redirect_to,omitempty"` }
VerifyTokenHashOtpCredentials is the struct for verifying OTPs sent other than email or phone.
func (VerifyTokenHashOtpCredentials) OtpType ¶ added in v0.5.0
func (c VerifyTokenHashOtpCredentials) OtpType() string
OtpType returns the type of OTP.