rownd

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CLAIM_USER_ID          = "https://auth.rownd.io/app_user_id"
	CLAIM_IS_VERIFIED_USER = "https://auth.rownd.io/is_verified_user"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type APIResponse

type APIResponse struct {
	Success bool        `json:"success"`
	Message string      `json:"message,omitempty"`
	Data    interface{} `json:"data,omitempty"`
	Error   string      `json:"error,omitempty"`
}

APIResponse represents a generic API response

type Client

type Client struct {
	AppKey     string
	AppSecret  string
	BaseURL    string
	HTTPClient *http.Client
	// contains filtered or unexported fields
}

func NewClient

func NewClient(config *ClientConfig) (*Client, error)

NewClient creates a new Rownd client instance

func (c *Client) CreateSmartLink(ctx context.Context, opts *SmartLinkOptions) (*SmartLink, error)

func (*Client) FetchWellKnownConfig

func (c *Client) FetchWellKnownConfig(ctx context.Context) (*WellKnownConfig, error)

func (*Client) GetUser

func (c *Client) GetUser(userID string) (*User, error)

func (*Client) UpdateUser

func (c *Client) UpdateUser(userID string, data map[string]interface{}) (*User, error)

func (*Client) ValidateToken

func (c *Client) ValidateToken(ctx context.Context, token string) (*TokenValidationResponse, error)

type ClientConfig

type ClientConfig struct {
	AppKey     string
	AppSecret  string
	BaseURL    string
	Timeout    time.Duration
	RetryCount int
}

ClientConfig represents the configuration for the Rownd client

type ErrType

type ErrType string

ErrType represents the type of error that occurred

const (
	ErrAuthentication ErrType = "authentication_error"
	ErrValidation     ErrType = "validation_error"
	ErrAPI            ErrType = "api_error"
	ErrNetwork        ErrType = "network_error"
	ErrNotFound       ErrType = "not_found_error"
)

type JWKS added in v0.1.8

type JWKS struct {
	Keys []json.RawMessage `json:"keys"`
}

type RowndError

type RowndError struct {
	Type    ErrType
	Message string
	Err     error
}

RowndError represents a custom error type for Rownd SDK

func NewError

func NewError(errType ErrType, message string, err error) *RowndError

NewError creates a new RowndError

func (*RowndError) Error

func (e *RowndError) Error() string
type SmartLink struct {
	Link      string `json:"link"`
	AppUserID string `json:"app_user_id"`
}

type SmartLinkOptions

type SmartLinkOptions struct {
	Email       string                 `json:"email,omitempty"`
	Phone       string                 `json:"phone,omitempty"`
	RedirectURL string                 `json:"redirect_url"`
	Data        map[string]interface{} `json:"data,omitempty"`
}

type TokenValidation

type TokenValidation struct {
	Valid    bool      `json:"valid"`
	UserID   string    `json:"user_id"`
	AppID    string    `json:"app_id"`
	IssuedAt time.Time `json:"iat"`
	ExpireAt time.Time `json:"exp"`
}

TokenValidation represents the response from token validation

type TokenValidationResponse

type TokenValidationResponse struct {
	DecodedToken jwt.MapClaims `json:"decoded_token"`
	UserID       string        `json:"user_id"`
	AccessToken  string        `json:"access_token"`
}

type User

type User struct {
	ID        string                 `json:"id"`
	Data      map[string]interface{} `json:"data"`
	CreatedAt time.Time              `json:"created_at"`
	UpdatedAt time.Time              `json:"updated_at"`
}

User represents a Rownd user

type UserUpdateRequest

type UserUpdateRequest struct {
	Data map[string]interface{} `json:"data"`
}

UserUpdateRequest represents the request body for updating a user

type ValidationError

type ValidationError struct {
	Field   string
	Message string
}

ValidationError represents a validation error

type Validator

type Validator struct{}

Validator provides validation methods for various inputs

func NewValidator

func NewValidator() *Validator

NewValidator creates a new validator instance

func (*Validator) ValidateClientConfig

func (v *Validator) ValidateClientConfig(config *ClientConfig) error

ValidateClientConfig validates the client configuration

func (*Validator) ValidateEmail

func (v *Validator) ValidateEmail(email string) error

ValidateEmail checks if the provided email is valid

func (*Validator) ValidateToken

func (v *Validator) ValidateToken(token string) error

ValidateToken checks if the provided token format is valid

func (*Validator) ValidateUserID

func (v *Validator) ValidateUserID(userID string) error

ValidateUserID checks if the provided user ID is valid

type WellKnownConfig

type WellKnownConfig struct {
	Issuer                 string   `json:"issuer"`
	AuthorizationEndpoint  string   `json:"authorization_endpoint"`
	TokenEndpoint          string   `json:"token_endpoint"`
	JwksUri                string   `json:"jwks_uri"`
	ResponseTypesSupported []string `json:"response_types_supported"`
	SubjectTypesSupported  []string `json:"subject_types_supported"`
	ScopesSupported        []string `json:"scopes_supported"`
}

WellKnownConfig represents the OAuth well-known configuration

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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