UNPKG

clerk-solidjs

Version:
356 lines (336 loc) 22.7 kB
import * as solid_js from 'solid-js'; import { ParentProps, JSX, Accessor } from 'solid-js'; import * as _clerk_types from '@clerk/types'; import { OrganizationCustomRoleKey, OrganizationCustomPermissionKey, CheckAuthorizationWithCustomPermissions, HandleOAuthCallbackParams, Without, SignInProps, SignUpProps, CreateOrganizationProps, OrganizationListProps, GoogleOneTapProps, UserProfileProps, OrganizationProfileProps, UserButtonProps, OrganizationSwitcherProps, SignOut, GetToken, SignInResource, SignUpResource, EmailAddressResource, OrganizationMembershipResource, OrganizationDomainResource, OrganizationMembershipRequestResource, OrganizationInvitationResource, GetDomainsParams, GetMembershipRequestParams, GetMembersParams, GetInvitationsParams, ClerkOptions, SDKMetadata, InstanceType, RedirectOptions, ClientResource, ActiveSessionResource, UserResource, OrganizationResource, SetActiveParams, __internal_UserVerificationModalProps, WaitlistProps, ListenerCallback, UnsubscribeCallback, SignInRedirectOptions, SignUpRedirectOptions, HandleEmailLinkVerificationParams, AuthenticateWithMetamaskParams, AuthenticateWithCoinbaseWalletParams, AuthenticateWithOKXWalletParams, ClerkAuthenticateWithWeb3Params, AuthenticateWithGoogleOneTapParams, CreateOrganizationParams, JoinWaitlistParams, WaitlistResource, LoadedClerk, UserOrganizationInvitationResource, OrganizationSuggestionResource, GetUserOrganizationMembershipParams, GetUserOrganizationInvitationsParams, GetUserOrganizationSuggestionsParams } from '@clerk/types'; import { W as WithClerkProp, S as SignInButtonProps, a as SignInWithMetamaskButtonProps, b as SignOutButtonProps, c as SignUpButtonProps, U as UserProfilePageProps, d as UserProfileLinkProps, O as OrganizationProfilePageProps, e as OrganizationProfileLinkProps, C as ClerkProviderProps, P as PaginatedResources, f as PaginatedHookConfig, I as IsomorphicClerkOptions, H as HeadlessBrowserClerk, B as BrowserClerk } from '../types-Dp7hHz1f.js'; export { g as ClerkProp } from '../types-Dp7hHz1f.js'; import * as _solid_primitives_destructure from '@solid-primitives/destructure'; import { TelemetryCollector } from '@clerk/shared/telemetry'; import '@clerk/shared/error'; declare const SignedIn: (props: ParentProps) => JSX.Element; declare const SignedOut: (props: ParentProps) => JSX.Element; declare const ClerkLoaded: (props: ParentProps) => JSX.Element; declare const ClerkLoading: (props: ParentProps) => JSX.Element; type ProtectProps = ParentProps<({ condition?: never; role: OrganizationCustomRoleKey; permission?: never; } | { condition?: never; role?: never; permission: OrganizationCustomPermissionKey; } | { condition: (has: CheckAuthorizationWithCustomPermissions) => boolean; role?: never; permission?: never; } | { condition?: never; role?: never; permission?: never; }) & { fallback?: JSX.Element; }>; /** * Use `<Protect/>` in order to prevent unauthenticated or unauthorized users from accessing the children passed to the component. * * Examples: * ``` * <Protect permission="a_permission_key" /> * <Protect role="a_role_key" /> * <Protect condition={(has) => has({permission:"a_permission_key"})} /> * <Protect condition={(has) => has({role:"a_role_key"})} /> * <Protect fallback={<p>Unauthorized</p>} /> * ``` */ declare const Protect: (props: ProtectProps) => JSX.Element; declare const RedirectToSignIn: (props: _clerk_types.Without<WithClerkProp<_clerk_types.SignInRedirectOptions>, "clerk">) => JSX.Element; declare const RedirectToSignUp: (props: _clerk_types.Without<WithClerkProp<_clerk_types.SignUpRedirectOptions>, "clerk">) => JSX.Element; declare const RedirectToUserProfile: (props: _clerk_types.Without<{ clerk: solid_js.Accessor<_clerk_types.LoadedClerk>; }, "clerk">) => JSX.Element; declare const RedirectToOrganizationProfile: (props: _clerk_types.Without<{ clerk: solid_js.Accessor<_clerk_types.LoadedClerk>; }, "clerk">) => JSX.Element; declare const RedirectToCreateOrganization: (props: _clerk_types.Without<{ clerk: solid_js.Accessor<_clerk_types.LoadedClerk>; }, "clerk">) => JSX.Element; declare const AuthenticateWithRedirectCallback: (props: _clerk_types.Without<WithClerkProp<HandleOAuthCallbackParams>, "clerk">) => JSX.Element; declare const SignInButton: (props: _clerk_types.Without<WithClerkProp<SignInButtonProps>, "clerk">) => solid_js.JSX.Element; declare const SignInWithMetamaskButton: (props: _clerk_types.Without<WithClerkProp<SignInWithMetamaskButtonProps>, "clerk">) => solid_js.JSX.Element; declare const SignOutButton: (props: _clerk_types.Without<WithClerkProp<SignOutButtonProps>, "clerk">) => solid_js.JSX.Element; declare const SignUpButton: (props: _clerk_types.Without<WithClerkProp<SignUpButtonProps>, "clerk">) => solid_js.JSX.Element; type UserProfileExportType = typeof _UserProfile & { Page: typeof UserProfilePage; Link: typeof UserProfileLink; }; type UserButtonExportType = typeof _UserButton & { UserProfilePage: typeof UserProfilePage; UserProfileLink: typeof UserProfileLink; }; type UserButtonPropsWithoutCustomPages = Without<UserButtonProps, 'userProfileProps'> & { userProfileProps?: Pick<UserProfileProps, 'additionalOAuthScopes' | 'appearance'>; }; type OrganizationProfileExportType = typeof _OrganizationProfile & { Page: typeof OrganizationProfilePage; Link: typeof OrganizationProfileLink; }; type OrganizationSwitcherExportType = typeof _OrganizationSwitcher & { OrganizationProfilePage: typeof OrganizationProfilePage; OrganizationProfileLink: typeof OrganizationProfileLink; }; type OrganizationSwitcherPropsWithoutCustomPages = Without<OrganizationSwitcherProps, 'organizationProfileProps'> & { organizationProfileProps?: Pick<OrganizationProfileProps, 'appearance'>; }; declare const SignIn: (props: Without<WithClerkProp<SignInProps>, "clerk">) => solid_js.JSX.Element; declare const SignUp: (props: Without<WithClerkProp<SignUpProps>, "clerk">) => solid_js.JSX.Element; declare function UserProfilePage(props: ParentProps<UserProfilePageProps>): solid_js.ChildrenReturn; declare function UserProfileLink(props: ParentProps<UserProfileLinkProps>): solid_js.ChildrenReturn; declare const _UserProfile: (props: Without<WithClerkProp<ParentProps<Without<UserProfileProps, "customPages">>>, "clerk">) => solid_js.JSX.Element; declare const UserProfile: UserProfileExportType; declare const _UserButton: (props: Without<WithClerkProp<ParentProps<UserButtonPropsWithoutCustomPages>>, "clerk">) => solid_js.JSX.Element; declare const UserButton: UserButtonExportType; declare function OrganizationProfilePage(props: ParentProps<OrganizationProfilePageProps>): solid_js.ChildrenReturn; declare function OrganizationProfileLink(props: ParentProps<OrganizationProfileLinkProps>): solid_js.ChildrenReturn; declare const _OrganizationProfile: (props: Without<WithClerkProp<ParentProps<Without<OrganizationProfileProps, "customPages">>>, "clerk">) => solid_js.JSX.Element; declare const OrganizationProfile: OrganizationProfileExportType; declare const CreateOrganization: (props: Without<WithClerkProp<CreateOrganizationProps>, "clerk">) => solid_js.JSX.Element; declare const _OrganizationSwitcher: (props: Without<WithClerkProp<ParentProps<OrganizationSwitcherPropsWithoutCustomPages>>, "clerk">) => solid_js.JSX.Element; declare const OrganizationSwitcher: OrganizationSwitcherExportType; declare const OrganizationList: (props: Without<WithClerkProp<OrganizationListProps>, "clerk">) => solid_js.JSX.Element; declare const GoogleOneTap: (props: Without<WithClerkProp<GoogleOneTapProps>, "clerk">) => solid_js.JSX.Element; declare const ClerkProvider: solid_js.Component<ClerkProviderProps>; declare const useAuth: () => { isLoaded: solid_js.Accessor<boolean>; isSignedIn: solid_js.Accessor<boolean | undefined>; sessionId: solid_js.Accessor<string | null | undefined>; userId: solid_js.Accessor<string | null | undefined>; actor: solid_js.Accessor<_clerk_types.ActJWTClaim | null | undefined>; orgId: solid_js.Accessor<string | null | undefined>; orgRole: solid_js.Accessor<string | null | undefined>; orgPermissions: solid_js.Accessor<string[] | null | undefined>; has: (params: Parameters<CheckAuthorizationWithCustomPermissions>[0]) => boolean; signOut: SignOut; getToken: GetToken; }; declare const useClerk: () => solid_js.Accessor<_clerk_types.LoadedClerk>; type EmailLinkable = SignUpResource | EmailAddressResource | SignInResource; declare function useEmailLink(resource: Accessor<EmailLinkable>): _solid_primitives_destructure.Spread<_clerk_types.CreateEmailLinkFlowReturn<_clerk_types.SignInStartEmailLinkFlowParams, SignInResource> | _clerk_types.CreateEmailLinkFlowReturn<_clerk_types.StartEmailLinkFlowParams, SignUpResource> | _clerk_types.CreateEmailLinkFlowReturn<_clerk_types.StartEmailLinkFlowParams, EmailAddressResource>>; type UseOrganizationParams = { domains?: true | PaginatedHookConfig<GetDomainsParams>; membershipRequests?: true | PaginatedHookConfig<GetMembershipRequestParams>; memberships?: true | PaginatedHookConfig<GetMembersParams>; invitations?: true | PaginatedHookConfig<GetInvitationsParams>; }; declare const useOrganization: (params?: Accessor<UseOrganizationParams>) => { isLoaded: Accessor<boolean>; organization: Accessor<_clerk_types.OrganizationResource | null | undefined>; membership: Accessor<OrganizationMembershipResource | null | undefined>; domains: Accessor<PaginatedResources<OrganizationDomainResource> | null | undefined>; membershipRequests: Accessor<PaginatedResources<OrganizationMembershipRequestResource> | null | undefined>; memberships: Accessor<PaginatedResources<OrganizationMembershipResource> | null | undefined>; invitations: Accessor<PaginatedResources<OrganizationInvitationResource> | null | undefined>; }; type IsomorphicLoadedClerk = Without<LoadedClerk, /** * Override ClerkJS methods in order to support premountMethodCalls */ 'buildSignInUrl' | 'buildSignUpUrl' | 'buildUserProfileUrl' | 'buildCreateOrganizationUrl' | 'buildOrganizationProfileUrl' | 'buildAfterSignUpUrl' | 'buildAfterSignInUrl' | 'buildAfterSignOutUrl' | 'buildAfterMultiSessionSingleSignOutUrl' | 'buildUrlWithAuth' | 'buildWaitlistUrl' | 'handleRedirectCallback' | 'handleGoogleOneTapCallback' | 'handleUnauthenticated' | 'authenticateWithMetamask' | 'authenticateWithCoinbaseWallet' | 'authenticateWithWeb3' | 'authenticateWithGoogleOneTap' | 'createOrganization' | 'getOrganization' | 'joinWaitlist' | 'mountUserButton' | 'mountOrganizationList' | 'mountOrganizationSwitcher' | 'mountOrganizationProfile' | 'mountCreateOrganization' | 'mountSignUp' | 'mountSignIn' | 'mountUserProfile' | 'mountWaitlist' | 'client' | '__internal_getCachedResources' | '__internal_reloadInitialResources'> & { handleRedirectCallback: (params: HandleOAuthCallbackParams) => void; handleGoogleOneTapCallback: (signInOrUp: SignInResource | SignUpResource, params: HandleOAuthCallbackParams) => void; handleUnauthenticated: () => void; authenticateWithMetamask: (params: AuthenticateWithMetamaskParams) => Promise<void>; authenticateWithCoinbaseWallet: (params: AuthenticateWithCoinbaseWalletParams) => Promise<void>; authenticateWithOKXWallet: (params: AuthenticateWithOKXWalletParams) => Promise<void>; authenticateWithWeb3: (params: ClerkAuthenticateWithWeb3Params) => Promise<void>; authenticateWithGoogleOneTap: (params: AuthenticateWithGoogleOneTapParams) => Promise<SignInResource | SignUpResource>; createOrganization: (params: CreateOrganizationParams) => Promise<OrganizationResource | void>; getOrganization: (organizationId: string) => Promise<OrganizationResource | void>; joinWaitlist: (params: JoinWaitlistParams) => Promise<WaitlistResource | void>; buildSignInUrl: (opts?: RedirectOptions) => string | void; buildSignUpUrl: (opts?: RedirectOptions) => string | void; buildUserProfileUrl: () => string | void; buildCreateOrganizationUrl: () => string | void; buildOrganizationProfileUrl: () => string | void; buildAfterSignInUrl: () => string | void; buildAfterSignUpUrl: () => string | void; buildAfterSignOutUrl: () => string | void; buildAfterMultiSessionSingleSignOutUrl: () => string | void; buildWaitlistUrl: () => string | void; mountUserButton: (node: HTMLDivElement, props: UserButtonProps) => void; mountOrganizationList: (node: HTMLDivElement, props: OrganizationListProps) => void; mountOrganizationSwitcher: (node: HTMLDivElement, props: OrganizationSwitcherProps) => void; mountOrganizationProfile: (node: HTMLDivElement, props: OrganizationProfileProps) => void; mountCreateOrganization: (node: HTMLDivElement, props: CreateOrganizationProps) => void; mountSignUp: (node: HTMLDivElement, props: SignUpProps) => void; mountSignIn: (node: HTMLDivElement, props: SignInProps) => void; mountUserProfile: (node: HTMLDivElement, props: UserProfileProps) => void; mountWaitlist: (node: HTMLDivElement, props: WaitlistProps) => void; client: ClientResource | undefined; }; declare class IsomorphicClerk implements IsomorphicLoadedClerk { #private; private readonly mode; private readonly options; private readonly Clerk; private clerkjs; private preopenOneTap?; private preopenUserVerification?; private preopenSignIn?; private preopenSignUp?; private preopenUserProfile?; private preopenOrganizationProfile?; private preopenCreateOrganization?; private preOpenWaitlist?; private premountSignInNodes; private premountSignUpNodes; private premountUserProfileNodes; private premountUserButtonNodes; private premountOrganizationProfileNodes; private premountCreateOrganizationNodes; private premountOrganizationSwitcherNodes; private premountOrganizationListNodes; private premountMethodCalls; private premountWaitlistNodes; private premountAddListenerCalls; private loadedListeners; get publishableKey(): string; get loaded(): boolean; static getOrCreateInstance(options: IsomorphicClerkOptions): IsomorphicClerk; static clearInstance(): void; get domain(): string; get proxyUrl(): string; __internal_getOption<K extends keyof ClerkOptions>(key: K): ClerkOptions[K] | undefined; constructor(options: IsomorphicClerkOptions); get sdkMetadata(): SDKMetadata | undefined; get instanceType(): InstanceType | undefined; get frontendApi(): string; get isStandardBrowser(): boolean; get isSatellite(): boolean; buildSignInUrl: (opts?: RedirectOptions) => string | void; buildSignUpUrl: (opts?: RedirectOptions) => string | void; buildAfterSignInUrl: () => string | void; buildAfterSignUpUrl: () => string | void; buildAfterSignOutUrl: () => string | void; buildAfterMultiSessionSingleSignOutUrl: () => string | void; buildUserProfileUrl: () => string | void; buildCreateOrganizationUrl: () => string | void; buildOrganizationProfileUrl: () => string | void; buildWaitlistUrl: () => string | void; buildUrlWithAuth: (to: string) => string | void; handleUnauthenticated: () => void; loadClerkJS(): Promise<HeadlessBrowserClerk | BrowserClerk | undefined>; addOnLoaded: (cb: () => void) => void; emitLoaded: () => void; private hydrateClerkJS; get version(): string | undefined; get client(): ClientResource | undefined; get session(): ActiveSessionResource | undefined | null; get user(): UserResource | undefined | null; get organization(): OrganizationResource | undefined | null; get telemetry(): TelemetryCollector | undefined; get __unstable__environment(): any; __unstable__setEnvironment(...args: any): void; __unstable__updateProps: (props: any) => Promise<void>; /** * `setActive` can be used to set the active session and/or organization. */ setActive: ({ session, organization, beforeEmit, redirectUrl }: SetActiveParams) => Promise<void>; openSignIn: (props?: SignInProps) => void; closeSignIn: () => void; __internal_openReverification: (props?: __internal_UserVerificationModalProps) => void; __internal_closeReverification: () => void; openGoogleOneTap: (props?: GoogleOneTapProps) => void; closeGoogleOneTap: () => void; openUserProfile: (props?: UserProfileProps) => void; closeUserProfile: () => void; openOrganizationProfile: (props?: OrganizationProfileProps) => void; closeOrganizationProfile: () => void; openCreateOrganization: (props?: CreateOrganizationProps) => void; closeCreateOrganization: () => void; openWaitlist: (props?: WaitlistProps) => void; closeWaitlist: () => void; openSignUp: (props?: SignUpProps) => void; closeSignUp: () => void; mountSignIn: (node: HTMLDivElement, props: SignInProps) => void; unmountSignIn: (node: HTMLDivElement) => void; mountSignUp: (node: HTMLDivElement, props: SignUpProps) => void; unmountSignUp: (node: HTMLDivElement) => void; mountUserProfile: (node: HTMLDivElement, props: UserProfileProps) => void; unmountUserProfile: (node: HTMLDivElement) => void; mountOrganizationProfile: (node: HTMLDivElement, props: OrganizationProfileProps) => void; unmountOrganizationProfile: (node: HTMLDivElement) => void; mountCreateOrganization: (node: HTMLDivElement, props: CreateOrganizationProps) => void; unmountCreateOrganization: (node: HTMLDivElement) => void; mountOrganizationSwitcher: (node: HTMLDivElement, props: OrganizationSwitcherProps) => void; unmountOrganizationSwitcher: (node: HTMLDivElement) => void; __experimental_prefetchOrganizationSwitcher: () => void; mountOrganizationList: (node: HTMLDivElement, props: OrganizationListProps) => void; unmountOrganizationList: (node: HTMLDivElement) => void; mountUserButton: (node: HTMLDivElement, userButtonProps: UserButtonProps) => void; unmountUserButton: (node: HTMLDivElement) => void; mountWaitlist: (node: HTMLDivElement, props: WaitlistProps) => void; unmountWaitlist: (node: HTMLDivElement) => void; addListener: (listener: ListenerCallback) => UnsubscribeCallback; navigate: (to: string) => void; redirectWithAuth: (to: string) => Promise<unknown>; redirectToSignIn: (opts: SignInRedirectOptions) => Promise<unknown>; redirectToSignUp: (opts: SignUpRedirectOptions) => Promise<unknown>; redirectToUserProfile: () => Promise<unknown>; redirectToAfterSignUp: () => void; redirectToAfterSignIn: () => void; redirectToAfterSignOut: () => void; redirectToOrganizationProfile: () => Promise<unknown>; redirectToCreateOrganization: () => Promise<unknown>; redirectToWaitlist: () => Promise<unknown>; handleRedirectCallback: (params: HandleOAuthCallbackParams) => void; handleGoogleOneTapCallback: (signInOrUp: SignInResource | SignUpResource, params: HandleOAuthCallbackParams) => void; handleEmailLinkVerification: (params: HandleEmailLinkVerificationParams) => Promise<void>; authenticateWithMetamask: (params: AuthenticateWithMetamaskParams) => Promise<void>; authenticateWithCoinbaseWallet: (params: AuthenticateWithCoinbaseWalletParams) => Promise<void>; authenticateWithOKXWallet: (params?: AuthenticateWithOKXWalletParams) => Promise<void>; authenticateWithWeb3: (params: ClerkAuthenticateWithWeb3Params) => Promise<void>; authenticateWithGoogleOneTap: (params: AuthenticateWithGoogleOneTapParams) => Promise<SignInResource | SignUpResource>; createOrganization: (params: CreateOrganizationParams) => Promise<OrganizationResource | void>; getOrganization: (organizationId: string) => Promise<OrganizationResource | void>; joinWaitlist: (params: JoinWaitlistParams) => Promise<WaitlistResource | void>; signOut: SignOut; } type UseOrganizationListParams = { userMemberships?: true | PaginatedHookConfig<GetUserOrganizationMembershipParams>; userInvitations?: true | PaginatedHookConfig<GetUserOrganizationInvitationsParams>; userSuggestions?: true | PaginatedHookConfig<GetUserOrganizationSuggestionsParams>; }; declare const useOrganizationList: (params?: Accessor<UseOrganizationListParams>) => { isLoaded: Accessor<boolean>; createOrganization: (params: Parameters<IsomorphicClerk["createOrganization"]>[0]) => Promise<_clerk_types.OrganizationResource>; setActive: (params: Parameters<IsomorphicClerk["setActive"]>[0]) => Promise<void>; userMemberships: Accessor<PaginatedResources<OrganizationMembershipResource> | undefined>; userInvitations: Accessor<PaginatedResources<UserOrganizationInvitationResource> | undefined>; userSuggestions: Accessor<PaginatedResources<OrganizationSuggestionResource> | undefined>; }; declare const useSession: () => { isLoaded: solid_js.Accessor<boolean>; isSignedIn: solid_js.Accessor<boolean>; session: solid_js.Accessor<_clerk_types.SessionResource | null | undefined>; }; declare const useSessionList: () => { isLoaded: solid_js.Accessor<boolean>; sessions: solid_js.Accessor<_clerk_types.SessionResource[] | undefined>; setActive: (params: Parameters<IsomorphicClerk["setActive"]>[0]) => Promise<void>; }; declare const useSignIn: () => { isLoaded: solid_js.Accessor<boolean>; signIn: solid_js.Accessor<_clerk_types.SignInResource | undefined>; setActive: (params: Parameters<IsomorphicClerk["setActive"]>[0]) => Promise<void>; }; declare const useSignUp: () => { isLoaded: solid_js.Accessor<boolean>; signUp: solid_js.Accessor<_clerk_types.SignUpResource | undefined>; setActive: (params: Parameters<IsomorphicClerk["setActive"]>[0]) => Promise<void>; }; declare function useUser(): { isLoaded: solid_js.Accessor<boolean>; isSignedIn: solid_js.Accessor<boolean>; user: solid_js.Accessor<_clerk_types.UserResource | null | undefined>; }; export { AuthenticateWithRedirectCallback, BrowserClerk, ClerkLoaded, ClerkLoading, ClerkProvider, ClerkProviderProps, CreateOrganization, GoogleOneTap, HeadlessBrowserClerk, OrganizationList, OrganizationProfile, OrganizationSwitcher, Protect, type ProtectProps, RedirectToCreateOrganization, RedirectToOrganizationProfile, RedirectToSignIn, RedirectToSignUp, RedirectToUserProfile, SignIn, SignInButton, SignInWithMetamaskButton, SignOutButton, SignUp, SignUpButton, SignedIn, SignedOut, UserButton, UserProfile, useAuth, useClerk, useEmailLink, useOrganization, useOrganizationList, useSession, useSessionList, useSignIn, useSignUp, useUser };