clerk

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2022 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProdUrl = "https://api.clerk.dev/v1/"

	ActorTokensUrl    = "actor_tokens"
	AllowlistsUrl     = "allowlist_identifiers"
	BlocklistsUrl     = "blocklist_identifiers"
	ClientsUrl        = "clients"
	ClientsVerifyUrl  = ClientsUrl + "/verify"
	EmailAddressesURL = "email_addresses"
	EmailsUrl         = "emails"
	InvitationsURL    = "invitations"
	OrganizationsUrl  = "organizations"
	PhoneNumbersURL   = "phone_numbers"
	RedirectURLsUrl   = "redirect_urls"
	SessionsUrl       = "sessions"
	SMSUrl            = "sms_messages"
	TemplatesUrl      = "templates"
	UsersUrl          = "users"
	UsersCountUrl     = UsersUrl + "/count"
	WebhooksUrl       = "webhooks"
	JWTTemplatesUrl   = "jwt_templates"
)
View Source
const (
	ActiveSession = iota
	ActiveSessionClaims
)
View Source
const (
	CookieSession       = "__session"
	QueryParamSessionId = "_clerk_session_id"
)

Variables

This section is empty.

Functions

func RequireSessionV2

func RequireSessionV2(client Client, verifyTokenOptions ...VerifyTokenOption) func(handler http.Handler) http.Handler

RequireSessionV2 will hijack the request and return an HTTP status 403 if the session is not authenticated.

func WithSession

func WithSession(client Client) func(handler http.Handler) http.Handler

func WithSessionV2

func WithSessionV2(client Client, verifyTokenOptions ...VerifyTokenOption) func(handler http.Handler) http.Handler

WithSessionV2 is the new middleware that supports Auth v2. If the session is authenticated, it adds the corresponding session claims found in the JWT to request's context.

Types

type ActorTokenResponse

type ActorTokenResponse struct {
	Object    string          `json:"object"`
	ID        string          `json:"id"`
	UserID    string          `json:"user_id"`
	Actor     json.RawMessage `json:"actor"`
	Token     string          `json:"token,omitempty"`
	Status    string          `json:"status"`
	CreatedAt int64           `json:"created_at"`
	UpdatedAt int64           `json:"updated_at"`
}

type ActorTokenService

type ActorTokenService service

func (*ActorTokenService) Create

func (*ActorTokenService) Revoke

func (s *ActorTokenService) Revoke(actorTokenID string) (*ActorTokenResponse, error)

type AllowlistIdentifierResponse

type AllowlistIdentifierResponse struct {
	Object         string `json:"object"`
	ID             string `json:"id"`
	InvitationID   string `json:"invitation_id,omitempty"`
	Identifier     string `json:"identifier"`
	IdentifierType string `json:"identifier_type"`
	CreatedAt      int64  `json:"created_at"`
	UpdatedAt      int64  `json:"updated_at"`
}

type AllowlistIdentifiersResponse

type AllowlistIdentifiersResponse struct {
	Data       []*AllowlistIdentifierResponse `json:"data"`
	TotalCount int64                          `json:"total_count"`
}

type AllowlistsService

type AllowlistsService service

func (*AllowlistsService) CreateIdentifier

func (*AllowlistsService) DeleteIdentifier

func (s *AllowlistsService) DeleteIdentifier(identifierID string) (*DeleteResponse, error)

func (*AllowlistsService) ListAllIdentifiers

func (s *AllowlistsService) ListAllIdentifiers() (*AllowlistIdentifiersResponse, error)

type BlocklistIdentifierResponse

type BlocklistIdentifierResponse struct {
	Object         string `json:"object"`
	ID             string `json:"id"`
	Identifier     string `json:"identifier"`
	IdentifierType string `json:"identifier_type"`
	CreatedAt      int64  `json:"created_at"`
	UpdatedAt      int64  `json:"updated_at"`
}

type BlocklistIdentifiersResponse

type BlocklistIdentifiersResponse struct {
	Data       []*BlocklistIdentifierResponse `json:"data"`
	TotalCount int64                          `json:"total_count"`
}

type BlocklistsService

type BlocklistsService service

func (*BlocklistsService) CreateIdentifier

func (*BlocklistsService) DeleteIdentifier

func (s *BlocklistsService) DeleteIdentifier(identifierID string) (*DeleteResponse, error)

func (*BlocklistsService) ListAllIdentifiers

func (s *BlocklistsService) ListAllIdentifiers() (*BlocklistIdentifiersResponse, error)

type ClerkOption

type ClerkOption func(*client) error

ClerkOption describes a functional parameter for the clerk client constructor

func WithBaseURL

func WithBaseURL(rawURL string) ClerkOption

WithBaseURL allows the overriding of the base URL

func WithHTTPClient

func WithHTTPClient(httpClient *http.Client) ClerkOption

WithHTTPClient allows the overriding of the http client

type Client

type Client interface {
	NewRequest(method, url string, body ...interface{}) (*http.Request, error)
	Do(req *http.Request, v interface{}) (*http.Response, error)

	DecodeToken(token string) (*TokenClaims, error)
	VerifyToken(token string, opts ...VerifyTokenOption) (*SessionClaims, error)

	Allowlists() *AllowlistsService
	Blocklists() *BlocklistsService
	Clients() *ClientsService
	EmailAddresses() *EmailAddressesService
	Emails() *EmailService
	ActorTokens() *ActorTokenService
	Instances() *InstanceService
	JWKS() *JWKSService
	JWTTemplates() *JWTTemplatesService
	Organizations() *OrganizationsService
	PhoneNumbers() *PhoneNumbersService
	RedirectURLs() *RedirectURLsService
	Sessions() *SessionsService
	SMS() *SMSService
	Templates() *TemplatesService
	Users() *UsersService
	Webhooks() *WebhooksService
	Verification() *VerificationService
	Interstitial() ([]byte, error)

	APIKey() string
}

func NewClient

func NewClient(token string, options ...ClerkOption) (Client, error)

NewClient creates a new Clerk client. Because the token supplied will be used for all authenticated requests, the created client should not be used across different users

func NewClientWithBaseUrl deprecated

func NewClientWithBaseUrl(token, baseUrl string) (Client, error)

Deprecated: NewClientWithBaseUrl is deprecated. Use the NewClient instead e.g. NewClient(token, WithBaseURL(baseUrl))

func NewClientWithCustomHTTP deprecated

func NewClientWithCustomHTTP(token, urlStr string, httpClient *http.Client) (Client, error)

Deprecated: NewClientWithCustomHTTP is deprecated. Use the NewClient instead e.g. NewClient(token, WithBaseURL(urlStr), WithHTTPClient(httpClient))

type ClientResponse

type ClientResponse struct {
	Object              string     `json:"object"`
	ID                  string     `json:"id"`
	LastActiveSessionID *string    `json:"last_active_session_id"`
	SessionIDs          []string   `json:"session_ids"`
	Sessions            []*Session `json:"sessions"`
	SignInAttemptID     *string    `json:"sign_in_attempt_id"`
	SignUpAttemptID     *string    `json:"sign_up_attempt_id"`
	Ended               bool       `json:"ended"`
}

type ClientsService

type ClientsService service

func (*ClientsService) ListAll

func (s *ClientsService) ListAll() ([]ClientResponse, error)

func (*ClientsService) Read

func (s *ClientsService) Read(clientId string) (*ClientResponse, error)

func (*ClientsService) Verify

func (s *ClientsService) Verify(token string) (*ClientResponse, error)

type CreateActorTokenParams

type CreateActorTokenParams struct {
	UserID                      string          `json:"user_id"`
	Actor                       json.RawMessage `json:"actor"`
	ExpiresInSeconds            *int            `json:"expires_in_seconds"`
	SessionMaxDurationInSeconds *int            `json:"session_max_duration_in_seconds"`
}

type CreateAllowlistIdentifierParams

type CreateAllowlistIdentifierParams struct {
	Identifier string `json:"identifier"`
	Notify     bool   `json:"notify"`
}

type CreateBlocklistIdentifierParams

type CreateBlocklistIdentifierParams struct {
	Identifier string `json:"identifier"`
}

type CreateEmailAddressParams

type CreateEmailAddressParams struct {
	UserID       string `json:"user_id"`
	EmailAddress string `json:"email_address"`
	Verified     *bool  `json:"verified"`
	Primary      *bool  `json:"primary"`
}

type CreateOrganizationInvitationParams

type CreateOrganizationInvitationParams struct {
	EmailAddress   string          `json:"email_address"`
	InviterUserID  string          `json:"inviter_user_id"`
	OrganizationID string          `json:"organization_id"`
	PublicMetadata json.RawMessage `json:"public_metadata,omitempty"`
	RedirectURL    string          `json:"redirect_url,omitempty"`
	Role           string          `json:"role"`
}

type CreateOrganizationParams

type CreateOrganizationParams struct {
	Name                  string          `json:"name"`
	Slug                  *string         `json:"slug,omitempty"`
	CreatedBy             string          `json:"created_by"`
	MaxAllowedMemberships *int            `json:"max_allowed_memberships,omitempty"`
	PublicMetadata        json.RawMessage `json:"public_metadata,omitempty"`
	PrivateMetadata       json.RawMessage `json:"private_metadata,omitempty"`
}

type CreatePhoneNumberParams

type CreatePhoneNumberParams struct {
	UserID      string `json:"user_id"`
	PhoneNumber string `json:"phone_number"`
	Verified    *bool  `json:"verified"`
	Primary     *bool  `json:"primary"`
}

type CreateRedirectURLParams

type CreateRedirectURLParams struct {
	URL string `json:"url"`
}

type CreateUpdateJWTTemplate

type CreateUpdateJWTTemplate struct {
	Name             string                 `json:"name"`
	Claims           map[string]interface{} `json:"claims"`
	Lifetime         *int                   `json:"lifetime"`
	AllowedClockSkew *int                   `json:"allowed_clock_skew"`

	CustomSigningKey bool    `json:"custom_signing_key"`
	SigningAlgorithm *string `json:"signing_algorithm"`
	SigningKey       *string `json:"signing_key"`
}

type CreateUserParams

type CreateUserParams struct {
	EmailAddresses  []string         `json:"email_address,omitempty"`
	PhoneNumbers    []string         `json:"phone_number,omitempty"`
	Web3Wallets     []string         `json:"web3_wallet,omitempty"`
	Username        *string          `json:"username,omitempty"`
	Password        *string          `json:"password,omitempty"`
	FirstName       *string          `json:"first_name,omitempty"`
	LastName        *string          `json:"last_name,omitempty"`
	UnsafeMetadata  *json.RawMessage `json:"unsafe_metadata,omitempty"`
	PublicMetadata  *json.RawMessage `json:"public_metadata,omitempty"`
	PrivateMetadata *json.RawMessage `json:"private_metadata,omitempty"`
	PasswordDigest  *string          `json:"password_digest,omitempty"`
	PasswordHasher  *string          `json:"password_hasher,omitempty"`
	TOTPSecret      *string          `json:"totp_secret,omitempty"`
	BackupCodes     []string         `json:"backup_codes,omitempty"`
}

type DeleteResponse

type DeleteResponse struct {
	ID      string `json:"id,omitempty"`
	Slug    string `json:"slug,omitempty"`
	Object  string `json:"object"`
	Deleted bool   `json:"deleted"`
}

type Email

type Email struct {
	FromEmailName  string `json:"from_email_name"`
	Subject        string `json:"subject"`
	Body           string `json:"body"`
	EmailAddressID string `json:"email_address_id"`
}

type EmailAddress

type EmailAddress struct {
	ID           string               `json:"id"`
	Object       string               `json:"object"`
	EmailAddress string               `json:"email_address"`
	Reserved     bool                 `json:"reserved"`
	Verification *Verification        `json:"verification"`
	LinkedTo     []IdentificationLink `json:"linked_to"`
}

type EmailAddressesService

type EmailAddressesService service

func (*EmailAddressesService) Create

func (*EmailAddressesService) Delete

func (s *EmailAddressesService) Delete(emailAddressID string) (*DeleteResponse, error)

func (*EmailAddressesService) Read

func (s *EmailAddressesService) Read(emailAddressID string) (*EmailAddress, error)

func (*EmailAddressesService) Update

func (s *EmailAddressesService) Update(emailAddressID string, params UpdateEmailAddressParams) (*EmailAddress, error)

type EmailResponse

type EmailResponse struct {
	ID               string          `json:"id"`
	Object           string          `json:"object"`
	Status           string          `json:"status,omitempty"`
	ToEmailAddress   *string         `json:"to_email_address,omitempty"`
	DeliveredByClerk bool            `json:"delivered_by_clerk"`
	Data             json.RawMessage `json:"data"`
	Email
}

type EmailService

type EmailService service

func (*EmailService) Create

func (s *EmailService) Create(email Email) (*EmailResponse, error)

type Error

type Error struct {
	Message     string      `json:"message"`
	LongMessage string      `json:"long_message"`
	Code        string      `json:"code"`
	Meta        interface{} `json:"meta,omitempty"`
}

type ErrorResponse

type ErrorResponse struct {
	Response *http.Response
	Errors   []Error `json:"errors"`
}

func (*ErrorResponse) Error

func (e *ErrorResponse) Error() string
type IdentificationLink struct {
	IdentType string `json:"type"`
	IdentID   string `json:"id"`
}

type InstanceRestrictionsResponse

type InstanceRestrictionsResponse struct {
	Object    string `json:"object"`
	Allowlist bool   `json:"allowlist"`
	Blocklist bool   `json:"blocklist"`
}

type InstanceService

type InstanceService service

func (*InstanceService) Update

func (s *InstanceService) Update(params UpdateInstanceParams) error

func (*InstanceService) UpdateOrganizationSettings

func (s *InstanceService) UpdateOrganizationSettings(params UpdateOrganizationSettingsParams) (*OrganizationSettingsResponse, error)

func (*InstanceService) UpdateRestrictions

type JWKS

type JWKS jose.JSONWebKeySet

type JWKSService

type JWKSService service

func (*JWKSService) ListAll

func (s *JWKSService) ListAll() (*JWKS, error)

type JWTTemplate

type JWTTemplate struct {
	ID               string          `json:"id"`
	Object           string          `json:"object"`
	Name             string          `json:"name"`
	Claims           json.RawMessage `json:"claims"`
	Lifetime         int             `json:"lifetime"`
	AllowedClockSkew int             `json:"allowed_clock_skew"`
	CustomSigningKey bool            `json:"custom_signing_key"`
	SigningAlgorithm string          `json:"signing_algorithm"`
	CreatedAt        int64           `json:"created_at"`
	UpdatedAt        int64           `json:"updated_at"`
}

type JWTTemplatesService

type JWTTemplatesService service

func (JWTTemplatesService) Create

func (JWTTemplatesService) Delete

func (JWTTemplatesService) ListAll

func (s JWTTemplatesService) ListAll() ([]JWTTemplate, error)

func (JWTTemplatesService) Read

func (JWTTemplatesService) Update

type ListAllOrganizationsParams

type ListAllOrganizationsParams struct {
	Limit               *int
	Offset              *int
	IncludeMembersCount bool
}

type ListAllUsersParams

type ListAllUsersParams struct {
	Limit          *int
	Offset         *int
	EmailAddresses []string
	PhoneNumbers   []string
	Web3Wallets    []string
	Usernames      []string
	UserIDs        []string
	Query          *string
	OrderBy        *string
}

type Organization

type Organization struct {
	Object                string          `json:"object"`
	ID                    string          `json:"id"`
	Name                  string          `json:"name"`
	Slug                  *string         `json:"slug"`
	LogoURL               *string         `json:"logo_url"`
	MembersCount          *int            `json:"members_count,omitempty"`
	MaxAllowedMemberships int             `json:"max_allowed_memberships"`
	PublicMetadata        json.RawMessage `json:"public_metadata"`
	PrivateMetadata       json.RawMessage `json:"private_metadata,omitempty"`
	CreatedAt             int64           `json:"created_at"`
	UpdatedAt             int64           `json:"updated_at"`
}

type OrganizationInvitation

type OrganizationInvitation struct {
	Object         string          `json:"object"`
	ID             string          `json:"id"`
	EmailAddress   string          `json:"email_address"`
	OrganizationID string          `json:"organization_id"`
	PublicMetadata json.RawMessage `json:"public_metadata"`
	Role           string          `json:"role"`
	Status         string          `json:"status"`
	CreatedAt      int64           `json:"created_at"`
	UpdatedAt      int64           `json:"updated_at"`
}

type OrganizationSettingsResponse

type OrganizationSettingsResponse struct {
	Object                string `json:"object"`
	Enabled               bool   `json:"enabled"`
	MaxAllowedMemberships int    `json:"max_allowed_memberships"`
}

type OrganizationsResponse

type OrganizationsResponse struct {
	Data       []Organization `json:"data"`
	TotalCount int64          `json:"total_count"`
}

type OrganizationsService

type OrganizationsService service

func (*OrganizationsService) Create

func (*OrganizationsService) CreateInvitation

func (*OrganizationsService) Delete

func (s *OrganizationsService) Delete(organizationID string) (*DeleteResponse, error)

func (*OrganizationsService) ListAll

func (*OrganizationsService) Update

func (s *OrganizationsService) Update(organizationID string, params UpdateOrganizationParams) (*Organization, error)

type PhoneNumber

type PhoneNumber struct {
	ID                      string               `json:"id"`
	Object                  string               `json:"object"`
	PhoneNumber             string               `json:"phone_number"`
	ReservedForSecondFactor bool                 `json:"reserved_for_second_factor"`
	DefaultSecondFactor     bool                 `json:"default_second_factor"`
	Reserved                bool                 `json:"reserved"`
	Verification            *Verification        `json:"verification"`
	LinkedTo                []IdentificationLink `json:"linked_to"`
	BackupCodes             []string             `json:"backup_codes"`
}

type PhoneNumbersService

type PhoneNumbersService service

func (*PhoneNumbersService) Create

func (*PhoneNumbersService) Delete

func (s *PhoneNumbersService) Delete(phoneNumberID string) (*DeleteResponse, error)

func (*PhoneNumbersService) Read

func (s *PhoneNumbersService) Read(phoneNumberID string) (*PhoneNumber, error)

func (*PhoneNumbersService) Update

func (s *PhoneNumbersService) Update(phoneNumberID string, params UpdatePhoneNumberParams) (*PhoneNumber, error)

type PreviewTemplateRequest

type PreviewTemplateRequest struct {
	Subject       string  `json:"subject,omitempty"`
	Body          string  `json:"body"`
	FromEmailName *string `json:"from_email_name"`
}

type RedirectURLResponse

type RedirectURLResponse struct {
	Object    string `json:"object"`
	ID        string `json:"id"`
	URL       string `json:"url"`
	CreatedAt int64  `json:"created_at"`
	UpdatedAt int64  `json:"updated_at"`
}

type RedirectURLsService

type RedirectURLsService service

func (*RedirectURLsService) Create

func (*RedirectURLsService) Delete

func (s *RedirectURLsService) Delete(redirectURLID string) (*DeleteResponse, error)

func (*RedirectURLsService) ListAll

func (s *RedirectURLsService) ListAll() ([]*RedirectURLResponse, error)

type SMSMessage

type SMSMessage struct {
	Message       string `json:"message"`
	PhoneNumberID string `json:"phone_number_id"`
}

type SMSMessageResponse

type SMSMessageResponse struct {
	Object           string          `json:"object"`
	ID               string          `json:"id"`
	FromPhoneNumber  string          `json:"from_phone_number"`
	ToPhoneNumber    *string         `json:"to_phone_number,omitempty"`
	Status           string          `json:"status"`
	DeliveredByClerk bool            `json:"delivered_by_clerk"`
	Data             json.RawMessage `json:"data"`
	SMSMessage
}

type SMSService

type SMSService service

func (*SMSService) Create

func (s *SMSService) Create(message SMSMessage) (*SMSMessageResponse, error)

type Session

type Session struct {
	Object       string `json:"object"`
	ID           string `json:"id"`
	ClientID     string `json:"client_id"`
	UserID       string `json:"user_id"`
	Status       string `json:"status"`
	LastActiveAt int64  `json:"last_active_at"`
	ExpireAt     int64  `json:"expire_at"`
	AbandonAt    int64  `json:"abandon_at"`
}

type SessionClaims

type SessionClaims struct {
	jwt.Claims
	SessionID              string `json:"sid"`
	AuthorizedParty        string `json:"azp"`
	ActiveOrganizationID   string `json:"org_id"`
	ActiveOrganizationSlug string `json:"org_slug"`
	ActiveOrganizationRole string `json:"org_role"`
}

func SessionFromContext

func SessionFromContext(ctx context.Context) (*SessionClaims, bool)

SessionFromContext returns the session's (if any) claims, as parsed from the token.

type SessionsService

type SessionsService service

func (*SessionsService) ListAll

func (s *SessionsService) ListAll() ([]Session, error)

func (*SessionsService) Read

func (s *SessionsService) Read(sessionId string) (*Session, error)

func (*SessionsService) Revoke

func (s *SessionsService) Revoke(sessionId string) (*Session, error)

func (*SessionsService) Verify

func (s *SessionsService) Verify(sessionId, token string) (*Session, error)

type SvixResponse

type SvixResponse struct {
	SvixURL string `json:"svix_url"`
}

type Template

type Template struct {
	Object           string  `json:"object"`
	Slug             string  `json:"slug"`
	ResourceType     string  `json:"resource_type"`
	TemplateType     string  `json:"template_type"`
	Name             string  `json:"name"`
	Position         int     `json:"position"`
	CanRevert        bool    `json:"can_revert"`
	CanDelete        bool    `json:"can_delete"`
	FromEmailName    *string `json:"from_email_name"`
	DeliveredByClerk bool    `json:"delivered_by_clerk"`
	CreatedAt        int64   `json:"created_at"`
	UpdatedAt        int64   `json:"updated_at"`
}

type TemplateExtended

type TemplateExtended struct {
	*Template
	Subject            string   `json:"subject"`
	Markup             string   `json:"markup"`
	Body               string   `json:"body"`
	AvailableVariables []string `json:"available_variables"`
	RequiredVariables  []string `json:"required_variables"`
}

type TemplatePreview

type TemplatePreview struct {
	Subject          string  `json:"subject,omitempty"`
	Body             string  `json:"body"`
	FromEmailAddress *string `json:"from_email_address,omitempty"`
}

type TemplatesService

type TemplatesService service

func (*TemplatesService) Delete

func (s *TemplatesService) Delete(templateType, slug string) (*DeleteResponse, error)

Delete deletes a custom user template

func (*TemplatesService) ListAll

func (s *TemplatesService) ListAll(templateType string) ([]Template, error)

func (*TemplatesService) Preview

func (s *TemplatesService) Preview(templateType, slug string, previewTemplateRequest *PreviewTemplateRequest) (*TemplatePreview, error)

Preview returns a rendering of a template with sample data for preview purposes

func (*TemplatesService) Read

func (s *TemplatesService) Read(templateType, slug string) (*TemplateExtended, error)

func (*TemplatesService) Revert

func (s *TemplatesService) Revert(templateType, slug string) (*TemplateExtended, error)

Revert reverts a user template to the corresponding system template

func (*TemplatesService) Upsert

func (s *TemplatesService) Upsert(templateType, slug string, upsertTemplateRequest *UpsertTemplateRequest) (*TemplateExtended, error)

type TokenClaims

type TokenClaims struct {
	jwt.Claims
	Extra map[string]interface{}
}

type UpdateEmailAddressParams

type UpdateEmailAddressParams struct {
	Verified *bool `json:"verified"`
	Primary  *bool `json:"primary"`
}

type UpdateInstanceParams

type UpdateInstanceParams struct {
	// TestMode can be used to toggle test mode for this instance.
	// Defaults to true for development instances.
	TestMode *bool `json:"test_mode,omitempty"`

	// HIBP is used to configure whether Clerk should use the
	// "Have I Been Pawned" service to check passwords against
	// known security breaches.
	// By default, this is enabled in all instances.
	HIBP *bool `json:"hibp,omitempty"`

	// EnhancedEmailDeliverability controls how Clerk delivers emails.
	// Specifically, when set to true, if the instance is a production
	// instance, OTP verification emails are sent by the Clerk's shared
	// domain via Postmark.
	EnhancedEmailDeliverability *bool `json:"enhanced_email_deliverability,omitempty"`

	// SupportEmail is the contact email address that will be displayed
	// on the frontend, in case your instance users need support.
	// If the empty string is provided, the support email that is currently
	// configured in the instance will be removed.
	SupportEmail *string `json:"support_email,omitempty"`

	// ClerkJSVersion allows you to request a specific Clerk JS version on the Clerk Hosted Account pages.
	// If an empty string is provided, the stored version will be removed.
	// If an explicit version is not set, the Clerk JS version will be automatically be resolved.
	ClerkJSVersion *string `json:"clerk_js_version,omitempty"`
}

type UpdateOrganizationParams

type UpdateOrganizationParams struct {
	Name                  *string `json:"name,omitempty"`
	MaxAllowedMemberships *int    `json:"max_allowed_memberships,omitempty"`
}

type UpdateOrganizationSettingsParams

type UpdateOrganizationSettingsParams struct {
	Enabled               *bool `json:"enabled,omitempty"`
	MaxAllowedMemberships *int  `json:"max_allowed_memberships,omitempty"`
}

type UpdatePhoneNumberParams

type UpdatePhoneNumberParams struct {
	Verified *bool `json:"verified"`
	Primary  *bool `json:"primary"`
}

type UpdateRestrictionsParams

type UpdateRestrictionsParams struct {
	Allowlist *bool `json:"allowlist,omitempty"`
	Blocklist *bool `json:"blocklist,omitempty"`
}

type UpdateUser

type UpdateUser struct {
	FirstName             *string     `json:"first_name,omitempty"`
	LastName              *string     `json:"last_name,omitempty"`
	PrimaryEmailAddressID *string     `json:"primary_email_address_id,omitempty"`
	PrimaryPhoneNumberID  *string     `json:"primary_phone_number_id,omitempty"`
	ProfileImage          *string     `json:"profile_image,omitempty"`
	Password              *string     `json:"password,omitempty"`
	PublicMetadata        interface{} `json:"public_metadata,omitempty"`
	PrivateMetadata       interface{} `json:"private_metadata,omitempty"`
	UnsafeMetadata        interface{} `json:"unsafe_metadata,omitempty"`
	TOTPSecret            *string     `json:"totp_secret,omitempty"`
	BackupCodes           []string    `json:"backup_codes,omitempty"`
}

type UpdateUserMetadata

type UpdateUserMetadata struct {
	PublicMetadata  interface{} `json:"public_metadata"`
	PrivateMetadata interface{} `json:"private_metadata"`
	UnsafeMetadata  interface{} `json:"unsafe_metadata"`
}

type UpsertTemplateRequest

type UpsertTemplateRequest struct {
	Name             string  `json:"name"`
	Subject          string  `json:"subject,omitempty"`
	Markup           string  `json:"markup,omitempty"`
	Body             string  `json:"body"`
	FromEmailName    *string `json:"from_email_name"`
	DeliveredByClerk *bool   `json:"delivered_by_clerk"`
}

type User

type User struct {
	ID                    string         `json:"id"`
	Object                string         `json:"object"`
	Username              *string        `json:"username"`
	FirstName             *string        `json:"first_name"`
	LastName              *string        `json:"last_name"`
	Gender                *string        `json:"gender"`
	Birthday              *string        `json:"birthday"`
	ProfileImageURL       string         `json:"profile_image_url"`
	PrimaryEmailAddressID *string        `json:"primary_email_address_id"`
	PrimaryPhoneNumberID  *string        `json:"primary_phone_number_id"`
	PasswordEnabled       bool           `json:"password_enabled"`
	TwoFactorEnabled      bool           `json:"two_factor_enabled"`
	TOTPEnabled           bool           `json:"totp_enabled"`
	BackupCodeEnabled     bool           `json:"backup_code_enabled"`
	EmailAddresses        []EmailAddress `json:"email_addresses"`
	PhoneNumbers          []PhoneNumber  `json:"phone_numbers"`
	ExternalAccounts      []interface{}  `json:"external_accounts"`
	PublicMetadata        interface{}    `json:"public_metadata"`
	PrivateMetadata       interface{}    `json:"private_metadata"`
	UnsafeMetadata        interface{}    `json:"unsafe_metadata"`
	LastSignInAt          *int64         `json:"last_sign_in_at"`
	Banned                bool           `json:"banned"`
	CreatedAt             int64          `json:"created_at"`
	UpdatedAt             int64          `json:"updated_at"`
}

type UserCount

type UserCount struct {
	Object     string `json:"object"`
	TotalCount int    `json:"total_count"`
}

type UserDisableMFAResponse

type UserDisableMFAResponse struct {
	UserID string `json:"user_id"`
}

type UsersService

type UsersService service

func (*UsersService) Ban

func (s *UsersService) Ban(userID string) (*User, error)

func (*UsersService) Count

func (s *UsersService) Count(params ListAllUsersParams) (*UserCount, error)

func (*UsersService) Create

func (s *UsersService) Create(params CreateUserParams) (*User, error)

func (*UsersService) Delete

func (s *UsersService) Delete(userId string) (*DeleteResponse, error)

func (*UsersService) DisableMFA

func (s *UsersService) DisableMFA(userID string) (*UserDisableMFAResponse, error)

func (*UsersService) ListAll

func (s *UsersService) ListAll(params ListAllUsersParams) ([]User, error)

func (*UsersService) Read

func (s *UsersService) Read(userId string) (*User, error)

func (*UsersService) Unban

func (s *UsersService) Unban(userID string) (*User, error)

func (*UsersService) Update

func (s *UsersService) Update(userId string, updateRequest *UpdateUser) (*User, error)

func (*UsersService) UpdateMetadata

func (s *UsersService) UpdateMetadata(userId string, updateMetadataRequest *UpdateUserMetadata) (*User, error)

type Verification

type Verification struct {
	Status           string `json:"status"`
	Strategy         string `json:"strategy"`
	Attempts         *int   `json:"attempts"`
	ExpireAt         *int64 `json:"expire_at"`
	VerifiedAtClient string `json:"verified_at_client,omitempty"`

	// needed for Web3
	Nonce *string `json:"nonce,omitempty"`

	// needed for OAuth
	ExternalVerificationRedirectURL *string `json:"external_verification_redirect_url,omitempty"`
	Error                           []byte  `json:"error,omitempty"`
}

type VerificationService

type VerificationService service

func (*VerificationService) Verify

func (s *VerificationService) Verify(req *http.Request) (*Session, error)

type VerifyTokenOption

type VerifyTokenOption func(*verifyTokenOptions) error

VerifyTokenOption describes a functional parameter for the VerifyToken method

func WithAuthorizedParty

func WithAuthorizedParty(parties ...string) VerifyTokenOption

WithAuthorizedParty allows to set the authorized parties to check against the azp claim of the session token

func WithCustomClaims

func WithCustomClaims(customClaims interface{}) VerifyTokenOption

WithCustomClaims allows to pass a type (e.g. struct), which will be populated with the token claims based on json tags. For this option to work you must pass a pointer.

func WithJWTVerificationKey

func WithJWTVerificationKey(key string) VerifyTokenOption

WithJWTVerificationKey allows to set the JWK to use for verifying tokens without the need to download or cache any JWKs at runtime

func WithLeeway

func WithLeeway(leeway time.Duration) VerifyTokenOption

WithLeeway allows to set a custom leeway that gives some extra time to the token to accomodate for clock skew, etc.

type WebhooksService

type WebhooksService service

func (*WebhooksService) CreateSvix

func (s *WebhooksService) CreateSvix() (*SvixResponse, error)

func (*WebhooksService) DeleteSvix

func (s *WebhooksService) DeleteSvix() error

func (*WebhooksService) RefreshSvixURL

func (s *WebhooksService) RefreshSvixURL() (*SvixResponse, error)

Jump to

Keyboard shortcuts

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