@clerk/react 6.9.0 → 6.9.1-canary.v20260610190754
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ClerkProvider-9lxHp9j5.cjs +1623 -0
- package/dist/ClerkProvider-9lxHp9j5.cjs.map +1 -0
- package/dist/ClerkProvider-LQpPtmNL.mjs +1533 -0
- package/dist/ClerkProvider-LQpPtmNL.mjs.map +1 -0
- package/dist/errors.cjs +69 -0
- package/dist/errors.d.cts +2 -0
- package/dist/errors.d.mts +2 -1
- package/dist/errors.mjs +2 -29
- package/dist/experimental.cjs +270 -0
- package/dist/experimental.cjs.map +1 -0
- package/dist/{experimental.d.ts → experimental.d.cts} +18 -18
- package/dist/experimental.d.mts +18 -18
- package/dist/experimental.mjs +201 -165
- package/dist/experimental.mjs.map +1 -1
- package/dist/hooks-BiY5Zgpp.mjs +1369 -0
- package/dist/hooks-BiY5Zgpp.mjs.map +1 -0
- package/dist/hooks-CBghYU21.cjs +1606 -0
- package/dist/hooks-CBghYU21.cjs.map +1 -0
- package/dist/index.cjs +447 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +345 -0
- package/dist/index.d.mts +183 -157
- package/dist/index.mjs +285 -380
- package/dist/index.mjs.map +1 -1
- package/dist/internal.cjs +107 -0
- package/dist/internal.cjs.map +1 -0
- package/dist/internal.d.cts +51 -0
- package/dist/internal.d.mts +24 -26
- package/dist/internal.mjs +39 -73
- package/dist/internal.mjs.map +1 -1
- package/dist/legacy.cjs +134 -0
- package/dist/legacy.cjs.map +1 -0
- package/dist/{legacy.d.ts → legacy.d.cts} +6 -3
- package/dist/legacy.d.mts +6 -3
- package/dist/legacy.mjs +126 -42
- package/dist/legacy.mjs.map +1 -1
- package/dist/types-Bwenmt7y.d.cts +10951 -0
- package/dist/types-CiIhevkA.d.mts +10951 -0
- package/dist/types.cjs +0 -0
- package/dist/types.d.cts +3 -0
- package/dist/types.d.mts +3 -109
- package/dist/types.mjs +1 -2
- package/dist/useAssertWrappedByClerkProvider-Cm0djUcB.cjs +52 -0
- package/dist/useAssertWrappedByClerkProvider-Cm0djUcB.cjs.map +1 -0
- package/dist/useAssertWrappedByClerkProvider-GaNwZpWo.mjs +29 -0
- package/dist/useAssertWrappedByClerkProvider-GaNwZpWo.mjs.map +1 -0
- package/dist/{useAuth-Dlg_G1_7.d.mts → useAuth-BK5Y4htK.d.mts} +58 -39
- package/dist/{useAuth-Cv6iRjL9.d.ts → useAuth-BMxaWktj.d.cts} +58 -39
- package/package.json +18 -18
- package/dist/chunk-E5QRIS4Z.mjs +0 -20
- package/dist/chunk-E5QRIS4Z.mjs.map +0 -1
- package/dist/chunk-FQVXBXXF.mjs +0 -1487
- package/dist/chunk-FQVXBXXF.mjs.map +0 -1
- package/dist/chunk-GVGS7DUS.mjs +0 -2097
- package/dist/chunk-GVGS7DUS.mjs.map +0 -1
- package/dist/chunk-RQWALB2R.mjs +0 -26
- package/dist/chunk-RQWALB2R.mjs.map +0 -1
- package/dist/errors.d.ts +0 -1
- package/dist/errors.js +0 -51
- package/dist/errors.js.map +0 -1
- package/dist/errors.mjs.map +0 -1
- package/dist/experimental.js +0 -1505
- package/dist/experimental.js.map +0 -1
- package/dist/index.d.ts +0 -319
- package/dist/index.js +0 -3919
- package/dist/index.js.map +0 -1
- package/dist/internal.d.ts +0 -53
- package/dist/internal.js +0 -3339
- package/dist/internal.js.map +0 -1
- package/dist/legacy.js +0 -90
- package/dist/legacy.js.map +0 -1
- package/dist/types.d.ts +0 -109
- package/dist/types.js +0 -19
- package/dist/types.js.map +0 -1
- package/dist/types.mjs.map +0 -1
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/polyfills.ts","../../ui/register/index.mjs","../src/index.ts","../src/components/SignInButton.tsx","../src/components/SignInWithMetamaskButton.tsx","../src/components/SignOutButton.tsx","../src/components/SignUpButton.tsx","../src/components/HandleSSOCallback.tsx","../src/contexts/index.ts"],"sourcesContent":["/**\n * Vite does not define `global` by default\n * One workaround is to use the `define` config prop\n * https://vitejs.dev/config/#define\n * We are solving this in the SDK level to reduce setup steps.\n */\nif (typeof window !== 'undefined' && !window.global) {\n window.global = typeof global === 'undefined' ? window : global;\n}\n\nexport {};\n","/**\n * Register React dependencies for sharing with @clerk/ui's shared variant.\n *\n * Import this module BEFORE loading the ui.shared.browser.js bundle:\n *\n * ```js\n * import '@clerk/ui/register';\n * // Now load clerk-js which will load ui.shared.browser.js\n * ```\n *\n * This enables @clerk/ui to use the host app's React instead of bundling its own,\n * reducing the overall bundle size.\n */\n\nimport * as react from 'react';\nimport * as reactDom from 'react-dom';\nimport * as reactDomClient from 'react-dom/client';\nimport * as jsxRuntime from 'react/jsx-runtime';\n\n// Only register if not already registered to avoid overwriting with potentially\n// different React versions in complex module resolution scenarios.\nif (globalThis.__clerkSharedModules) {\n // Warn if the already-registered React version differs from this import.\n // This could indicate multiple React versions in the bundle, which may cause issues.\n const existingVersion = globalThis.__clerkSharedModules.react?.version;\n if (existingVersion && existingVersion !== react.version) {\n console.warn(\n `[@clerk/ui/register] React version mismatch detected. ` +\n `Already registered: ${existingVersion}, current import: ${react.version}. ` +\n `This may cause issues with the shared @clerk/ui variant.`,\n );\n }\n} else {\n globalThis.__clerkSharedModules = {\n react,\n 'react-dom': reactDom,\n 'react-dom/client': reactDomClient,\n 'react/jsx-runtime': jsxRuntime,\n };\n}\n","import './polyfills';\nimport './types/appearance';\n// Register React on the global shared modules registry.\n// This enables @clerk/ui's shared variant to use the host app's React\n// instead of bundling its own copy, reducing overall bundle size.\nimport '@clerk/ui/register';\n\nimport { setClerkJSLoadingErrorPackageName } from '@clerk/shared/loadClerkJsScript';\n\nimport { setErrorThrowerOptions } from './errors/errorThrower';\n\nexport * from './components';\nexport * from './contexts';\n\nexport * from './hooks';\nexport { getToken } from '@clerk/shared/getToken';\nexport type {\n BrowserClerk,\n BrowserClerkConstructor,\n ClerkProp,\n HeadlessBrowserClerk,\n HeadlessBrowserClerkConstructor,\n IsomorphicClerkOptions,\n} from '@clerk/shared/types';\nexport type { ClerkProviderProps } from './types';\n\nsetErrorThrowerOptions({ packageName: PACKAGE_NAME });\nsetClerkJSLoadingErrorPackageName(PACKAGE_NAME);\n","import type { SignInButtonProps, SignInProps } from '@clerk/shared/types';\nimport React from 'react';\n\nimport type { WithClerkProp } from '../types';\nimport { assertSingleChild, normalizeWithDefaultValue, safeExecute } from '../utils';\nimport { withClerk } from './withClerk';\n\nexport const SignInButton = withClerk(\n ({ clerk, children, ...props }: WithClerkProp<React.PropsWithChildren<SignInButtonProps>>) => {\n const {\n // @ts-expect-error - appearance is a valid prop for SignInProps & SignInButtonPropsModal\n appearance,\n getContainer,\n component,\n signUpFallbackRedirectUrl,\n forceRedirectUrl,\n fallbackRedirectUrl,\n signUpForceRedirectUrl,\n mode,\n initialValues,\n withSignUp,\n oauthFlow,\n ...rest\n } = props;\n children = normalizeWithDefaultValue(children, 'Sign in');\n const child = assertSingleChild(children)('SignInButton');\n\n const clickHandler = () => {\n const opts: SignInProps = {\n forceRedirectUrl,\n fallbackRedirectUrl,\n signUpFallbackRedirectUrl,\n signUpForceRedirectUrl,\n initialValues,\n withSignUp,\n oauthFlow,\n };\n\n if (mode === 'modal') {\n return clerk.openSignIn({ ...opts, appearance, getContainer });\n }\n return clerk.redirectToSignIn({\n ...opts,\n signInFallbackRedirectUrl: fallbackRedirectUrl,\n signInForceRedirectUrl: forceRedirectUrl,\n });\n };\n\n const wrappedChildClickHandler: React.MouseEventHandler = async e => {\n if (child && typeof child === 'object' && 'props' in child) {\n await safeExecute(child.props.onClick)(e);\n }\n return clickHandler();\n };\n\n const childProps = { ...rest, onClick: wrappedChildClickHandler };\n return React.cloneElement(child as React.ReactElement<unknown>, childProps);\n },\n { component: 'SignInButton', renderWhileLoading: true },\n);\n","import React from 'react';\n\nimport type { SignInWithMetamaskButtonProps, WithClerkProp } from '../types';\nimport { assertSingleChild, normalizeWithDefaultValue, safeExecute } from '../utils';\nimport { withClerk } from './withClerk';\n\nexport const SignInWithMetamaskButton = withClerk(\n ({ clerk, children, ...props }: WithClerkProp<SignInWithMetamaskButtonProps>) => {\n const { redirectUrl, getContainer, component, ...rest } = props;\n\n children = normalizeWithDefaultValue(children, 'Sign in with Metamask');\n const child = assertSingleChild(children)('SignInWithMetamaskButton');\n\n // TODO: Properly fix this code\n // eslint-disable-next-line @typescript-eslint/require-await\n const clickHandler = async () => {\n async function authenticate() {\n await clerk.authenticateWithMetamask({ redirectUrl: redirectUrl || undefined });\n }\n void authenticate();\n };\n\n const wrappedChildClickHandler: React.MouseEventHandler = async e => {\n await safeExecute((child as any).props.onClick)(e);\n return clickHandler();\n };\n\n const childProps = { ...rest, onClick: wrappedChildClickHandler };\n return React.cloneElement(child as React.ReactElement<unknown>, childProps);\n },\n { component: 'SignInWithMetamask', renderWhileLoading: true },\n);\n","import { deprecated } from '@clerk/shared/deprecated';\nimport type { SignOutOptions } from '@clerk/shared/types';\nimport React from 'react';\n\nimport type { WithClerkProp } from '../types';\nimport { assertSingleChild, normalizeWithDefaultValue, safeExecute } from '../utils';\nimport { withClerk } from './withClerk';\n\nexport type SignOutButtonProps = {\n redirectUrl?: string;\n sessionId?: string;\n /**\n * @deprecated Use the `redirectUrl` and `sessionId` props directly instead.\n */\n signOutOptions?: SignOutOptions;\n children?: React.ReactNode;\n};\n\nexport const SignOutButton = withClerk(\n ({ clerk, children, ...props }: React.PropsWithChildren<WithClerkProp<SignOutButtonProps>>) => {\n const { redirectUrl = '/', sessionId, signOutOptions, getContainer, component, ...rest } = props;\n\n if (signOutOptions) {\n deprecated('SignOutButton `signOutOptions`', 'Use the `redirectUrl` and `sessionId` props directly instead.');\n }\n\n children = normalizeWithDefaultValue(children, 'Sign out');\n const child = assertSingleChild(children)('SignOutButton');\n\n const clickHandler = () =>\n clerk.signOut({\n redirectUrl,\n ...(sessionId !== undefined && { sessionId }),\n ...signOutOptions,\n });\n const wrappedChildClickHandler: React.MouseEventHandler = async e => {\n await safeExecute((child as any).props.onClick)(e);\n return clickHandler();\n };\n\n const childProps = { ...rest, onClick: wrappedChildClickHandler };\n return React.cloneElement(child as React.ReactElement<unknown>, childProps);\n },\n { component: 'SignOutButton', renderWhileLoading: true },\n);\n","import type { SignUpButtonProps, SignUpProps } from '@clerk/shared/types';\nimport React from 'react';\n\nimport type { WithClerkProp } from '../types';\nimport { assertSingleChild, normalizeWithDefaultValue, safeExecute } from '../utils';\nimport { withClerk } from './withClerk';\n\nexport const SignUpButton = withClerk(\n ({ clerk, children, ...props }: WithClerkProp<React.PropsWithChildren<SignUpButtonProps>>) => {\n const {\n // @ts-expect-error - appearance is a valid prop for SignUpProps & SignUpButtonPropsModal\n appearance,\n // @ts-expect-error - unsafeMetadata is a valid prop for SignUpProps & SignUpButtonPropsModal\n unsafeMetadata,\n getContainer,\n component,\n fallbackRedirectUrl,\n forceRedirectUrl,\n signInFallbackRedirectUrl,\n signInForceRedirectUrl,\n mode,\n initialValues,\n oauthFlow,\n ...rest\n } = props;\n\n children = normalizeWithDefaultValue(children, 'Sign up');\n const child = assertSingleChild(children)('SignUpButton');\n\n const clickHandler = () => {\n const opts: SignUpProps = {\n fallbackRedirectUrl,\n forceRedirectUrl,\n signInFallbackRedirectUrl,\n signInForceRedirectUrl,\n initialValues,\n oauthFlow,\n };\n\n if (mode === 'modal') {\n return clerk.openSignUp({\n ...opts,\n appearance,\n unsafeMetadata,\n getContainer,\n });\n }\n\n return clerk.redirectToSignUp({\n ...opts,\n signUpFallbackRedirectUrl: fallbackRedirectUrl,\n signUpForceRedirectUrl: forceRedirectUrl,\n });\n };\n\n const wrappedChildClickHandler: React.MouseEventHandler = async e => {\n if (child && typeof child === 'object' && 'props' in child) {\n await safeExecute(child.props.onClick)(e);\n }\n return clickHandler();\n };\n\n const childProps = { ...rest, onClick: wrappedChildClickHandler };\n return React.cloneElement(child as React.ReactElement<unknown>, childProps);\n },\n { component: 'SignUpButton', renderWhileLoading: true },\n);\n","import type { SetActiveNavigate } from '@clerk/shared/types';\nimport React, { type ReactNode, useEffect, useRef } from 'react';\n\nimport { useClerk, useSignIn, useSignUp } from '../hooks';\n\nexport interface HandleSSOCallbackProps {\n /**\n * Called when the SSO callback is complete and a session has been created.\n */\n navigateToApp: (...params: Parameters<SetActiveNavigate>) => void;\n /**\n * Called when a sign-in requires additional verification, or a sign-up is transfered to a sign-in that requires\n * additional verification.\n */\n navigateToSignIn: () => void;\n /**\n * Called when a sign-in is transfered to a sign-up that requires additional verification.\n */\n navigateToSignUp: () => void;\n}\n\n/**\n * Use this component when building custom UI to handle the SSO callback and navigate to the appropriate page based on\n * the status of the sign-in or sign-up. By default, this component might render a captcha element to handle captchas\n * when required by the Clerk API.\n *\n * @example\n * ```tsx\n * import { HandleSSOCallback } from '@clerk/react';\n * import { useNavigate } from 'react-router';\n *\n * export default function Page() {\n * const navigate = useNavigate();\n *\n * return (\n * <HandleSSOCallback\n * navigateToApp={({ session, decorateUrl }) => {\n * if (session?.currentTask) {\n * const destination = decorateUrl(`/onboarding/${session?.currentTask.key}`);\n * if (destination.startsWith('http')) {\n * window.location.href = destination;\n * return;\n * }\n * navigate(destination);\n * return;\n * }\n *\n * const destination = decorateUrl('/dashboard');\n * if (destination.startsWith('http')) {\n * window.location.href = destination;\n * return;\n * }\n * navigate(destination);\n * }}\n * navigateToSignIn={() => {\n * navigate('/sign-in');\n * }}\n * navigateToSignUp={() => {\n * navigate('/sign-up');\n * }}\n * />\n * );\n * }\n * ```\n */\nexport function HandleSSOCallback(props: HandleSSOCallbackProps): ReactNode {\n const { navigateToApp, navigateToSignIn, navigateToSignUp } = props;\n const clerk = useClerk();\n const { signIn } = useSignIn();\n const { signUp } = useSignUp();\n const hasRun = useRef(false);\n\n useEffect(() => {\n (async () => {\n if (!clerk.loaded || hasRun.current) {\n return;\n }\n // Prevent re-running this effect if the page is re-rendered during session activation (such as on Next.js).\n hasRun.current = true;\n\n // If this was a sign-in, and it's complete, there's nothing else to do.\n // Note: We perform a cast here to prevent TypeScript from narrowing the type of signIn.status. TypeScript\n // doesn't understand that the status can be mutated during the execution of this function.\n if ((signIn.status as string) === 'complete') {\n await signIn.finalize({\n navigate: async (...params) => {\n navigateToApp(...params);\n },\n });\n return;\n }\n\n // If the sign-up used an existing account, transfer it to a sign-in.\n if (signUp.isTransferable) {\n await signIn.create({ transfer: true });\n if (signIn.status === 'complete') {\n await signIn.finalize({\n navigate: async (...params) => {\n navigateToApp(...params);\n },\n });\n return;\n }\n // The sign-in requires additional verification, so we need to navigate to the sign-in page.\n return navigateToSignIn();\n }\n\n if (\n signIn.status === 'needs_first_factor' &&\n !signIn.supportedFirstFactors?.every(f => f.strategy === 'enterprise_sso')\n ) {\n // The sign-in requires the use of a configured first factor, so navigate to the sign-in page.\n return navigateToSignIn();\n }\n\n // If the sign-in used an external account not associated with an existing user, create a sign-up.\n if (signIn.isTransferable) {\n await signUp.create({ transfer: true });\n if (signUp.status === 'complete') {\n await signUp.finalize({\n navigate: async (...params) => {\n navigateToApp(...params);\n },\n });\n return;\n }\n return navigateToSignUp();\n }\n\n if (signUp.status === 'complete') {\n await signUp.finalize({\n navigate: async (...params) => {\n navigateToApp(...params);\n },\n });\n return;\n }\n\n if (signIn.status === 'needs_second_factor' || signIn.status === 'needs_new_password') {\n // The sign-in requires a MFA token or a new password, so navigate to the sign-in page.\n return navigateToSignIn();\n }\n\n // The external account used to sign-in or sign-up was already associated with an existing user and active\n // session on this client, so activate the session and navigate to the application.\n if (signIn.existingSession || signUp.existingSession) {\n const sessionId = signIn.existingSession?.sessionId || signUp.existingSession?.sessionId;\n if (sessionId) {\n // Because we're activating a session that's not the result of a sign-in or sign-up, we need to use the\n // Clerk `setActive` API instead of the `finalize` API.\n await clerk.setActive({\n session: sessionId,\n navigate: async (...params) => {\n return navigateToApp(...params);\n },\n });\n return;\n }\n }\n })();\n }, [clerk, clerk.loaded, signIn, signUp]);\n\n return (\n <div>\n {/* Because a sign-in transferred to a sign-up might require captcha verification, make sure to render the\n captcha element. */}\n <div id='clerk-captcha' />\n </div>\n );\n}\n","export { ClerkProvider } from './ClerkProvider';\nexport { UNSAFE_PortalProvider } from '@clerk/shared/react';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,IAAI,OAAO,WAAW,eAAe,CAAC,OAAO,QAAQ;AACnD,SAAO,SAAS,OAAO,WAAW,cAAc,SAAS;AAC3D;;;ACMA,YAAY,WAAW;AACvB,YAAY,cAAc;AAC1B,YAAY,oBAAoB;AAChC,YAAY,gBAAgB;AAjB5B;AAqBA,IAAI,WAAW,sBAAsB;AAGnC,QAAM,mBAAkB,gBAAW,qBAAqB,UAAhC,mBAAuC;AAC/D,MAAI,mBAAmB,oBAA0B,eAAS;AACxD,YAAQ;AAAA,MACN,6EACyB,eAAe,qBAA2B,aAAO;AAAA,IAE5E;AAAA,EACF;AACF,OAAO;AACL,aAAW,uBAAuB;AAAA,IAChC;AAAA,IACA,aAAa;AAAA,IACb,oBAAoB;AAAA,IACpB,qBAAqB;AAAA,EACvB;AACF;;;AChCA,SAAS,yCAAyC;;;ACNlD,OAAO,WAAW;AAMX,IAAM,eAAe;AAAA,EAC1B,CAAC,EAAE,OAAO,UAAU,GAAG,MAAM,MAAiE;AAC5F,UAAM;AAAA;AAAA,MAEJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,GAAG;AAAA,IACL,IAAI;AACJ,eAAW,0BAA0B,UAAU,SAAS;AACxD,UAAM,QAAQ,kBAAkB,QAAQ,EAAE,cAAc;AAExD,UAAM,eAAe,MAAM;AACzB,YAAM,OAAoB;AAAA,QACxB;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAEA,UAAI,SAAS,SAAS;AACpB,eA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;AACpD,kCAAkC,cAAY;","names":["React","React","React","React","React","React","React","_a","React"]}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/polyfills.ts","../../ui/register/index.mjs","../src/components/SignInButton.tsx","../src/components/SignInWithMetamaskButton.tsx","../src/components/SignOutButton.tsx","../src/components/SignUpButton.tsx","../src/components/HandleSSOCallback.tsx","../src/index.ts"],"sourcesContent":["/**\n * Vite does not define `global` by default\n * One workaround is to use the `define` config prop\n * https://vitejs.dev/config/#define\n * We are solving this in the SDK level to reduce setup steps.\n */\nif (typeof window !== 'undefined' && !window.global) {\n window.global = typeof global === 'undefined' ? window : global;\n}\n\nexport {};\n","/**\n * Register React dependencies for sharing with @clerk/ui's shared variant.\n *\n * Import this module BEFORE loading the ui.shared.browser.js bundle:\n *\n * ```js\n * import '@clerk/ui/register';\n * // Now load clerk-js which will load ui.shared.browser.js\n * ```\n *\n * This enables @clerk/ui to use the host app's React instead of bundling its own,\n * reducing the overall bundle size.\n */\n\nimport * as react from 'react';\nimport * as reactDom from 'react-dom';\nimport * as reactDomClient from 'react-dom/client';\nimport * as jsxRuntime from 'react/jsx-runtime';\n\n// Only register if not already registered to avoid overwriting with potentially\n// different React versions in complex module resolution scenarios.\nif (globalThis.__clerkSharedModules) {\n // Warn if the already-registered React version differs from this import.\n // This could indicate multiple React versions in the bundle, which may cause issues.\n const existingVersion = globalThis.__clerkSharedModules.react?.version;\n if (existingVersion && existingVersion !== react.version) {\n console.warn(\n `[@clerk/ui/register] React version mismatch detected. ` +\n `Already registered: ${existingVersion}, current import: ${react.version}. ` +\n `This may cause issues with the shared @clerk/ui variant.`,\n );\n }\n} else {\n globalThis.__clerkSharedModules = {\n react,\n 'react-dom': reactDom,\n 'react-dom/client': reactDomClient,\n 'react/jsx-runtime': jsxRuntime,\n };\n}\n","import type { SignInButtonProps, SignInProps } from '@clerk/shared/types';\nimport React from 'react';\n\nimport type { WithClerkProp } from '../types';\nimport { assertSingleChild, normalizeWithDefaultValue, safeExecute } from '../utils';\nimport { withClerk } from './withClerk';\n\nexport const SignInButton = withClerk(\n ({ clerk, children, ...props }: WithClerkProp<React.PropsWithChildren<SignInButtonProps>>) => {\n const {\n // @ts-expect-error - appearance is a valid prop for SignInProps & SignInButtonPropsModal\n appearance,\n getContainer,\n component,\n signUpFallbackRedirectUrl,\n forceRedirectUrl,\n fallbackRedirectUrl,\n signUpForceRedirectUrl,\n mode,\n initialValues,\n withSignUp,\n oauthFlow,\n ...rest\n } = props;\n children = normalizeWithDefaultValue(children, 'Sign in');\n const child = assertSingleChild(children)('SignInButton');\n\n const clickHandler = () => {\n const opts: SignInProps = {\n forceRedirectUrl,\n fallbackRedirectUrl,\n signUpFallbackRedirectUrl,\n signUpForceRedirectUrl,\n initialValues,\n withSignUp,\n oauthFlow,\n };\n\n if (mode === 'modal') {\n return clerk.openSignIn({ ...opts, appearance, getContainer });\n }\n return clerk.redirectToSignIn({\n ...opts,\n signInFallbackRedirectUrl: fallbackRedirectUrl,\n signInForceRedirectUrl: forceRedirectUrl,\n });\n };\n\n const wrappedChildClickHandler: React.MouseEventHandler = async e => {\n if (child && typeof child === 'object' && 'props' in child) {\n await safeExecute(child.props.onClick)(e);\n }\n return clickHandler();\n };\n\n const childProps = { ...rest, onClick: wrappedChildClickHandler };\n return React.cloneElement(child as React.ReactElement<unknown>, childProps);\n },\n { component: 'SignInButton', renderWhileLoading: true },\n);\n","import React from 'react';\n\nimport type { SignInWithMetamaskButtonProps, WithClerkProp } from '../types';\nimport { assertSingleChild, normalizeWithDefaultValue, safeExecute } from '../utils';\nimport { withClerk } from './withClerk';\n\nexport const SignInWithMetamaskButton = withClerk(\n ({ clerk, children, ...props }: WithClerkProp<SignInWithMetamaskButtonProps>) => {\n const { redirectUrl, getContainer, component, ...rest } = props;\n\n children = normalizeWithDefaultValue(children, 'Sign in with Metamask');\n const child = assertSingleChild(children)('SignInWithMetamaskButton');\n\n // TODO: Properly fix this code\n // eslint-disable-next-line @typescript-eslint/require-await\n const clickHandler = async () => {\n async function authenticate() {\n await clerk.authenticateWithMetamask({ redirectUrl: redirectUrl || undefined });\n }\n void authenticate();\n };\n\n const wrappedChildClickHandler: React.MouseEventHandler = async e => {\n await safeExecute((child as any).props.onClick)(e);\n return clickHandler();\n };\n\n const childProps = { ...rest, onClick: wrappedChildClickHandler };\n return React.cloneElement(child as React.ReactElement<unknown>, childProps);\n },\n { component: 'SignInWithMetamask', renderWhileLoading: true },\n);\n","import { deprecated } from '@clerk/shared/deprecated';\nimport type { SignOutOptions } from '@clerk/shared/types';\nimport React from 'react';\n\nimport type { WithClerkProp } from '../types';\nimport { assertSingleChild, normalizeWithDefaultValue, safeExecute } from '../utils';\nimport { withClerk } from './withClerk';\n\nexport type SignOutButtonProps = {\n redirectUrl?: string;\n sessionId?: string;\n /**\n * @deprecated Use the `redirectUrl` and `sessionId` props directly instead.\n */\n signOutOptions?: SignOutOptions;\n children?: React.ReactNode;\n};\n\nexport const SignOutButton = withClerk(\n ({ clerk, children, ...props }: React.PropsWithChildren<WithClerkProp<SignOutButtonProps>>) => {\n const { redirectUrl = '/', sessionId, signOutOptions, getContainer, component, ...rest } = props;\n\n if (signOutOptions) {\n deprecated('SignOutButton `signOutOptions`', 'Use the `redirectUrl` and `sessionId` props directly instead.');\n }\n\n children = normalizeWithDefaultValue(children, 'Sign out');\n const child = assertSingleChild(children)('SignOutButton');\n\n const clickHandler = () =>\n clerk.signOut({\n redirectUrl,\n ...(sessionId !== undefined && { sessionId }),\n ...signOutOptions,\n });\n const wrappedChildClickHandler: React.MouseEventHandler = async e => {\n await safeExecute((child as any).props.onClick)(e);\n return clickHandler();\n };\n\n const childProps = { ...rest, onClick: wrappedChildClickHandler };\n return React.cloneElement(child as React.ReactElement<unknown>, childProps);\n },\n { component: 'SignOutButton', renderWhileLoading: true },\n);\n","import type { SignUpButtonProps, SignUpProps } from '@clerk/shared/types';\nimport React from 'react';\n\nimport type { WithClerkProp } from '../types';\nimport { assertSingleChild, normalizeWithDefaultValue, safeExecute } from '../utils';\nimport { withClerk } from './withClerk';\n\nexport const SignUpButton = withClerk(\n ({ clerk, children, ...props }: WithClerkProp<React.PropsWithChildren<SignUpButtonProps>>) => {\n const {\n // @ts-expect-error - appearance is a valid prop for SignUpProps & SignUpButtonPropsModal\n appearance,\n // @ts-expect-error - unsafeMetadata is a valid prop for SignUpProps & SignUpButtonPropsModal\n unsafeMetadata,\n getContainer,\n component,\n fallbackRedirectUrl,\n forceRedirectUrl,\n signInFallbackRedirectUrl,\n signInForceRedirectUrl,\n mode,\n initialValues,\n oauthFlow,\n ...rest\n } = props;\n\n children = normalizeWithDefaultValue(children, 'Sign up');\n const child = assertSingleChild(children)('SignUpButton');\n\n const clickHandler = () => {\n const opts: SignUpProps = {\n fallbackRedirectUrl,\n forceRedirectUrl,\n signInFallbackRedirectUrl,\n signInForceRedirectUrl,\n initialValues,\n oauthFlow,\n };\n\n if (mode === 'modal') {\n return clerk.openSignUp({\n ...opts,\n appearance,\n unsafeMetadata,\n getContainer,\n });\n }\n\n return clerk.redirectToSignUp({\n ...opts,\n signUpFallbackRedirectUrl: fallbackRedirectUrl,\n signUpForceRedirectUrl: forceRedirectUrl,\n });\n };\n\n const wrappedChildClickHandler: React.MouseEventHandler = async e => {\n if (child && typeof child === 'object' && 'props' in child) {\n await safeExecute(child.props.onClick)(e);\n }\n return clickHandler();\n };\n\n const childProps = { ...rest, onClick: wrappedChildClickHandler };\n return React.cloneElement(child as React.ReactElement<unknown>, childProps);\n },\n { component: 'SignUpButton', renderWhileLoading: true },\n);\n","import type { SetActiveNavigate } from '@clerk/shared/types';\nimport React, { type ReactNode, useEffect, useRef } from 'react';\n\nimport { useClerk, useSignIn, useSignUp } from '../hooks';\n\nexport interface HandleSSOCallbackProps {\n /**\n * Called when the SSO callback is complete and a session has been created.\n */\n navigateToApp: (...params: Parameters<SetActiveNavigate>) => void;\n /**\n * Called when a sign-in requires additional verification, or a sign-up is transfered to a sign-in that requires\n * additional verification.\n */\n navigateToSignIn: () => void;\n /**\n * Called when a sign-in is transfered to a sign-up that requires additional verification.\n */\n navigateToSignUp: () => void;\n}\n\n/**\n * Use this component when building custom UI to handle the SSO callback and navigate to the appropriate page based on\n * the status of the sign-in or sign-up. By default, this component might render a captcha element to handle captchas\n * when required by the Clerk API.\n *\n * @example\n * ```tsx\n * import { HandleSSOCallback } from '@clerk/react';\n * import { useNavigate } from 'react-router';\n *\n * export default function Page() {\n * const navigate = useNavigate();\n *\n * return (\n * <HandleSSOCallback\n * navigateToApp={({ session, decorateUrl }) => {\n * if (session?.currentTask) {\n * const destination = decorateUrl(`/onboarding/${session?.currentTask.key}`);\n * if (destination.startsWith('http')) {\n * window.location.href = destination;\n * return;\n * }\n * navigate(destination);\n * return;\n * }\n *\n * const destination = decorateUrl('/dashboard');\n * if (destination.startsWith('http')) {\n * window.location.href = destination;\n * return;\n * }\n * navigate(destination);\n * }}\n * navigateToSignIn={() => {\n * navigate('/sign-in');\n * }}\n * navigateToSignUp={() => {\n * navigate('/sign-up');\n * }}\n * />\n * );\n * }\n * ```\n */\nexport function HandleSSOCallback(props: HandleSSOCallbackProps): ReactNode {\n const { navigateToApp, navigateToSignIn, navigateToSignUp } = props;\n const clerk = useClerk();\n const { signIn } = useSignIn();\n const { signUp } = useSignUp();\n const hasRun = useRef(false);\n\n useEffect(() => {\n (async () => {\n if (!clerk.loaded || hasRun.current) {\n return;\n }\n // Prevent re-running this effect if the page is re-rendered during session activation (such as on Next.js).\n hasRun.current = true;\n\n // If this was a sign-in, and it's complete, there's nothing else to do.\n // Note: We perform a cast here to prevent TypeScript from narrowing the type of signIn.status. TypeScript\n // doesn't understand that the status can be mutated during the execution of this function.\n if ((signIn.status as string) === 'complete') {\n await signIn.finalize({\n navigate: async (...params) => {\n navigateToApp(...params);\n },\n });\n return;\n }\n\n // If the sign-up used an existing account, transfer it to a sign-in.\n if (signUp.isTransferable) {\n await signIn.create({ transfer: true });\n if (signIn.status === 'complete') {\n await signIn.finalize({\n navigate: async (...params) => {\n navigateToApp(...params);\n },\n });\n return;\n }\n // The sign-in requires additional verification, so we need to navigate to the sign-in page.\n return navigateToSignIn();\n }\n\n if (\n signIn.status === 'needs_first_factor' &&\n !signIn.supportedFirstFactors?.every(f => f.strategy === 'enterprise_sso')\n ) {\n // The sign-in requires the use of a configured first factor, so navigate to the sign-in page.\n return navigateToSignIn();\n }\n\n // If the sign-in used an external account not associated with an existing user, create a sign-up.\n if (signIn.isTransferable) {\n await signUp.create({ transfer: true });\n if (signUp.status === 'complete') {\n await signUp.finalize({\n navigate: async (...params) => {\n navigateToApp(...params);\n },\n });\n return;\n }\n return navigateToSignUp();\n }\n\n if (signUp.status === 'complete') {\n await signUp.finalize({\n navigate: async (...params) => {\n navigateToApp(...params);\n },\n });\n return;\n }\n\n if (signIn.status === 'needs_second_factor' || signIn.status === 'needs_new_password') {\n // The sign-in requires a MFA token or a new password, so navigate to the sign-in page.\n return navigateToSignIn();\n }\n\n // The external account used to sign-in or sign-up was already associated with an existing user and active\n // session on this client, so activate the session and navigate to the application.\n if (signIn.existingSession || signUp.existingSession) {\n const sessionId = signIn.existingSession?.sessionId || signUp.existingSession?.sessionId;\n if (sessionId) {\n // Because we're activating a session that's not the result of a sign-in or sign-up, we need to use the\n // Clerk `setActive` API instead of the `finalize` API.\n await clerk.setActive({\n session: sessionId,\n navigate: async (...params) => {\n return navigateToApp(...params);\n },\n });\n return;\n }\n }\n })();\n }, [clerk, clerk.loaded, signIn, signUp]);\n\n return (\n <div>\n {/* Because a sign-in transferred to a sign-up might require captcha verification, make sure to render the\n captcha element. */}\n <div id='clerk-captcha' />\n </div>\n );\n}\n","import './polyfills';\nimport './types/appearance';\n// Register React on the global shared modules registry.\n// This enables @clerk/ui's shared variant to use the host app's React\n// instead of bundling its own copy, reducing overall bundle size.\nimport '@clerk/ui/register';\n\nimport { setClerkJSLoadingErrorPackageName } from '@clerk/shared/loadClerkJsScript';\n\nimport { setErrorThrowerOptions } from './errors/errorThrower';\n\nexport * from './components';\nexport * from './contexts';\n\nexport * from './hooks';\nexport { getToken } from '@clerk/shared/getToken';\nexport type {\n BrowserClerk,\n BrowserClerkConstructor,\n ClerkProp,\n HeadlessBrowserClerk,\n HeadlessBrowserClerkConstructor,\n IsomorphicClerkOptions,\n} from '@clerk/shared/types';\nexport type { ClerkProviderProps } from './types';\n\nsetErrorThrowerOptions({ packageName: PACKAGE_NAME });\nsetClerkJSLoadingErrorPackageName(PACKAGE_NAME);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAMA,IAAI,OAAO,WAAW,eAAe,CAAC,OAAO,QAC3C,OAAO,SAAS,OAAO,WAAW,cAAc,SAAS;;;;;;;;;;;;;;;;;ACc3D,IAAI,WAAW,sBAAsB;CAGnC,MAAM,kBAAkB,WAAW,qBAAqB,OAAO;CAC/D,IAAI,mBAAmB,oBAAoB,MAAM,SAC/C,QAAQ,KACN,6EACyB,gBAAgB,oBAAoB,MAAM,QAAQ,2DAE7E;AAEJ,OACE,WAAW,uBAAuB;CAChC;CACA,aAAa;CACb,oBAAoB;CACpB,qBAAqB;AACvB;;;;AC/BF,MAAa,eAAe,WACzB,EAAE,OAAO,UAAU,GAAG,YAAuE;CAC5F,MAAM,EAEJ,YACA,cACA,WACA,2BACA,kBACA,qBACA,wBACA,MACA,eACA,YACA,WACA,GAAG,SACD;CACJ,WAAW,0BAA0B,UAAU,SAAS;CACxD,MAAM,QAAQ,kBAAkB,QAAQ,CAAC,CAAC,cAAc;CAExD,MAAM,qBAAqB;EACzB,MAAM,OAAoB;GACxB;GACA;GACA;GACA;GACA;GACA;GACA;EACF;EAEA,IAAI,SAAS,SACX,OAAO,MAAM,WAAW;GAAE,GAAG;GAAM;GAAY;EAAa,CAAC;EAE/D,OAAO,MAAM,iBAAiB;GAC5B,GAAG;GACH,2BAA2B;GAC3B,wBAAwB;EAC1B,CAAC;CACH;CAEA,MAAM,2BAAoD,OAAM,MAAK;EACnE,IAAI,SAAS,OAAO,UAAU,YAAY,WAAW,OACnD,MAAM,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AAG;EAAC;EAAO,MAAM;EAAQ;EAAQ;CAAM,CAAC;CAExC,OACE,oCAAC,aAGC,oCAAC,OAAD,EAAK,IAAG,gBAAiB,EACtB;AAET;;;;AC/IA,uBAAuB,EAAE,4BAA0B,CAAC;AACpD,gDAA8C"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_hooks = require('./hooks-CBghYU21.cjs');
|
|
3
|
+
const require_useAssertWrappedByClerkProvider = require('./useAssertWrappedByClerkProvider-Cm0djUcB.cjs');
|
|
4
|
+
const require_ClerkProvider = require('./ClerkProvider-9lxHp9j5.cjs');
|
|
5
|
+
let _clerk_shared_loadClerkJsScript = require("@clerk/shared/loadClerkJsScript");
|
|
6
|
+
let _clerk_shared_react = require("@clerk/shared/react");
|
|
7
|
+
let _clerk_shared_keys = require("@clerk/shared/keys");
|
|
8
|
+
|
|
9
|
+
//#region src/hooks/useRoutingProps.ts
|
|
10
|
+
function useRoutingProps(componentName, props, routingOptions) {
|
|
11
|
+
const path = props.path || routingOptions?.path;
|
|
12
|
+
if ((props.routing || routingOptions?.routing || "path") === "path") {
|
|
13
|
+
if (!path) return require_useAssertWrappedByClerkProvider.errorThrower.throw(require_hooks.noPathProvidedError(componentName));
|
|
14
|
+
return {
|
|
15
|
+
...routingOptions,
|
|
16
|
+
...props,
|
|
17
|
+
routing: "path"
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
if (props.path) return require_useAssertWrappedByClerkProvider.errorThrower.throw(require_hooks.incompatibleRoutingWithPathProvidedError(componentName));
|
|
21
|
+
return {
|
|
22
|
+
...routingOptions,
|
|
23
|
+
...props,
|
|
24
|
+
path: void 0
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/internal.ts
|
|
30
|
+
/**
|
|
31
|
+
* @deprecated Import `useOAuthConsent` from `@clerk/react` instead.
|
|
32
|
+
*/
|
|
33
|
+
const useOAuthConsent = _clerk_shared_react.useOAuthConsent;
|
|
34
|
+
/**
|
|
35
|
+
* @deprecated Import `OAuthConsent` from `@clerk/react` instead.
|
|
36
|
+
*/
|
|
37
|
+
const OAuthConsent = require_hooks.OAuthConsent;
|
|
38
|
+
/**
|
|
39
|
+
* A wider-typed version of ClerkProvider that accepts internal script props.
|
|
40
|
+
* Framework SDKs should use this instead of the public ClerkProvider.
|
|
41
|
+
*/
|
|
42
|
+
const InternalClerkProvider = require_ClerkProvider.ClerkProvider;
|
|
43
|
+
|
|
44
|
+
//#endregion
|
|
45
|
+
exports.IS_REACT_SHARED_VARIANT_COMPATIBLE = require_ClerkProvider.IS_REACT_SHARED_VARIANT_COMPATIBLE;
|
|
46
|
+
exports.InternalClerkProvider = InternalClerkProvider;
|
|
47
|
+
exports.MultisessionAppSupport = require_ClerkProvider.MultisessionAppSupport;
|
|
48
|
+
exports.OAuthConsent = OAuthConsent;
|
|
49
|
+
Object.defineProperty(exports, 'buildClerkJSScriptAttributes', {
|
|
50
|
+
enumerable: true,
|
|
51
|
+
get: function () {
|
|
52
|
+
return _clerk_shared_loadClerkJsScript.buildClerkJSScriptAttributes;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
Object.defineProperty(exports, 'buildClerkJsScriptAttributes', {
|
|
56
|
+
enumerable: true,
|
|
57
|
+
get: function () {
|
|
58
|
+
return _clerk_shared_loadClerkJsScript.buildClerkJsScriptAttributes;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
Object.defineProperty(exports, 'buildClerkUIScriptAttributes', {
|
|
62
|
+
enumerable: true,
|
|
63
|
+
get: function () {
|
|
64
|
+
return _clerk_shared_loadClerkJsScript.buildClerkUIScriptAttributes;
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
Object.defineProperty(exports, 'clerkJSScriptUrl', {
|
|
68
|
+
enumerable: true,
|
|
69
|
+
get: function () {
|
|
70
|
+
return _clerk_shared_loadClerkJsScript.clerkJSScriptUrl;
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
Object.defineProperty(exports, 'clerkJsScriptUrl', {
|
|
74
|
+
enumerable: true,
|
|
75
|
+
get: function () {
|
|
76
|
+
return _clerk_shared_loadClerkJsScript.clerkJsScriptUrl;
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
Object.defineProperty(exports, 'clerkUIScriptUrl', {
|
|
80
|
+
enumerable: true,
|
|
81
|
+
get: function () {
|
|
82
|
+
return _clerk_shared_loadClerkJsScript.clerkUIScriptUrl;
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
Object.defineProperty(exports, 'publishableKeyFromHost', {
|
|
86
|
+
enumerable: true,
|
|
87
|
+
get: function () {
|
|
88
|
+
return _clerk_shared_keys.publishableKeyFromHost;
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
Object.defineProperty(exports, 'setClerkJSLoadingErrorPackageName', {
|
|
92
|
+
enumerable: true,
|
|
93
|
+
get: function () {
|
|
94
|
+
return _clerk_shared_loadClerkJsScript.setClerkJSLoadingErrorPackageName;
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
Object.defineProperty(exports, 'setClerkJsLoadingErrorPackageName', {
|
|
98
|
+
enumerable: true,
|
|
99
|
+
get: function () {
|
|
100
|
+
return _clerk_shared_loadClerkJsScript.setClerkJsLoadingErrorPackageName;
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
exports.setErrorThrowerOptions = require_useAssertWrappedByClerkProvider.setErrorThrowerOptions;
|
|
104
|
+
exports.useDerivedAuth = require_hooks.useDerivedAuth;
|
|
105
|
+
exports.useOAuthConsent = useOAuthConsent;
|
|
106
|
+
exports.useRoutingProps = useRoutingProps;
|
|
107
|
+
//# sourceMappingURL=internal.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal.cjs","names":["errorThrower","noPathProvidedError","incompatibleRoutingWithPathProvidedError","useOAuthConsentOriginal","OAuthConsentOriginal","ClerkProvider"],"sources":["../src/hooks/useRoutingProps.ts","../src/internal.ts"],"sourcesContent":["import type { RoutingOptions } from '@clerk/shared/types';\n\nimport { errorThrower } from '../errors/errorThrower';\nimport { incompatibleRoutingWithPathProvidedError, noPathProvidedError } from '../errors/messages';\n\nexport function useRoutingProps<T extends RoutingOptions>(\n componentName: string,\n props: T,\n routingOptions?: RoutingOptions,\n): T {\n const path = props.path || routingOptions?.path;\n const routing = props.routing || routingOptions?.routing || 'path';\n\n if (routing === 'path') {\n if (!path) {\n return errorThrower.throw(noPathProvidedError(componentName));\n }\n\n return {\n ...routingOptions,\n ...props,\n routing: 'path',\n };\n }\n\n if (props.path) {\n return errorThrower.throw(incompatibleRoutingWithPathProvidedError(componentName));\n }\n\n return {\n ...routingOptions,\n ...props,\n path: undefined,\n };\n}\n","import { useOAuthConsent as useOAuthConsentOriginal } from '@clerk/shared/react';\nimport type { InternalClerkScriptProps } from '@clerk/shared/types';\nimport type React from 'react';\n\nimport { OAuthConsent as OAuthConsentOriginal } from './components/uiComponents';\nimport { ClerkProvider } from './contexts/ClerkProvider';\nimport type { ClerkProviderProps, Ui } from './types';\n\nexport { publishableKeyFromHost } from '@clerk/shared/keys';\nexport { setErrorThrowerOptions } from './errors/errorThrower';\nexport { MultisessionAppSupport } from './components/controlComponents';\n\n/**\n * @deprecated Import `useOAuthConsent` from `@clerk/react` instead.\n */\nconst useOAuthConsent = useOAuthConsentOriginal;\nexport { useOAuthConsent };\n\n/**\n * @deprecated Import `OAuthConsent` from `@clerk/react` instead.\n */\nconst OAuthConsent = OAuthConsentOriginal;\nexport { OAuthConsent };\n\nexport { useRoutingProps } from './hooks/useRoutingProps';\nexport { useDerivedAuth } from './hooks/useAuth';\nexport { IS_REACT_SHARED_VARIANT_COMPATIBLE } from './utils/versionCheck';\n\nexport {\n clerkJSScriptUrl,\n buildClerkJSScriptAttributes,\n clerkUIScriptUrl,\n buildClerkUIScriptAttributes,\n setClerkJSLoadingErrorPackageName,\n // Deprecated aliases - will be removed in a future major version\n clerkJsScriptUrl,\n buildClerkJsScriptAttributes,\n setClerkJsLoadingErrorPackageName,\n} from '@clerk/shared/loadClerkJsScript';\n\nexport type { Ui } from './types';\n\nexport type { InternalClerkScriptProps } from '@clerk/shared/types';\n\n/**\n * A wider-typed version of ClerkProvider that accepts internal script props.\n * Framework SDKs should use this instead of the public ClerkProvider.\n */\nexport const InternalClerkProvider = ClerkProvider as unknown as (<TUi extends Ui = Ui>(\n props: ClerkProviderProps<TUi> & InternalClerkScriptProps,\n) => React.JSX.Element) & { displayName: string };\n"],"mappings":";;;;;;;;;AAKA,SAAgB,gBACd,eACA,OACA,gBACG;CACH,MAAM,OAAO,MAAM,QAAQ,gBAAgB;CAG3C,KAFgB,MAAM,WAAW,gBAAgB,WAAW,YAE5C,QAAQ;EACtB,IAAI,CAAC,MACH,OAAOA,qDAAa,MAAMC,kCAAoB,aAAa,CAAC;EAG9D,OAAO;GACL,GAAG;GACH,GAAG;GACH,SAAS;EACX;CACF;CAEA,IAAI,MAAM,MACR,OAAOD,qDAAa,MAAME,uDAAyC,aAAa,CAAC;CAGnF,OAAO;EACL,GAAG;EACH,GAAG;EACH,MAAM;CACR;AACF;;;;;;;ACnBA,MAAM,kBAAkBC;;;;AAMxB,MAAM,eAAeC;;;;;AA2BrB,MAAa,wBAAwBC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { d as Ui, g as WithClerkProp, t as ClerkProviderProps } from "./types-Bwenmt7y.cjs";
|
|
2
|
+
import { c as MultisessionAppSupport, n as useDerivedAuth } from "./useAuth-BMxaWktj.cjs";
|
|
3
|
+
import { ErrorThrowerOptions } from "@clerk/shared/error";
|
|
4
|
+
import { InternalClerkScriptProps, InternalClerkScriptProps as InternalClerkScriptProps$1, RoutingOptions } from "@clerk/shared/types";
|
|
5
|
+
import React from "react";
|
|
6
|
+
import { useOAuthConsent as useOAuthConsent$1 } from "@clerk/shared/react";
|
|
7
|
+
import { publishableKeyFromHost } from "@clerk/shared/keys";
|
|
8
|
+
import { buildClerkJSScriptAttributes, buildClerkJsScriptAttributes, buildClerkUIScriptAttributes, clerkJSScriptUrl, clerkJsScriptUrl, clerkUIScriptUrl, setClerkJSLoadingErrorPackageName, setClerkJsLoadingErrorPackageName } from "@clerk/shared/loadClerkJsScript";
|
|
9
|
+
|
|
10
|
+
//#region src/errors/errorThrower.d.ts
|
|
11
|
+
/**
|
|
12
|
+
* Overrides options of the internal errorThrower (eg setting packageName prefix).
|
|
13
|
+
*
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
declare function setErrorThrowerOptions(options: ErrorThrowerOptions): void;
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/hooks/useRoutingProps.d.ts
|
|
19
|
+
declare function useRoutingProps<T extends RoutingOptions>(componentName: string, props: T, routingOptions?: RoutingOptions): T;
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/utils/versionCheck.d.ts
|
|
22
|
+
/**
|
|
23
|
+
* Whether the host React version is compatible with the shared @clerk/ui variant.
|
|
24
|
+
* This is computed once at module load time for optimal performance.
|
|
25
|
+
*/
|
|
26
|
+
declare const IS_REACT_SHARED_VARIANT_COMPATIBLE: boolean;
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/internal.d.ts
|
|
29
|
+
/**
|
|
30
|
+
* @deprecated Import `useOAuthConsent` from `@clerk/react` instead.
|
|
31
|
+
*/
|
|
32
|
+
declare const useOAuthConsent: typeof useOAuthConsent$1;
|
|
33
|
+
/**
|
|
34
|
+
* @deprecated Import `OAuthConsent` from `@clerk/react` instead.
|
|
35
|
+
*/
|
|
36
|
+
declare const OAuthConsent: {
|
|
37
|
+
(props: import("@clerk/shared/types").Without<WithClerkProp<import("@clerk/shared/types").OAuthConsentProps & {
|
|
38
|
+
fallback?: React.ReactNode;
|
|
39
|
+
}>, "clerk">): React.JSX.Element | null;
|
|
40
|
+
displayName: string;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* A wider-typed version of ClerkProvider that accepts internal script props.
|
|
44
|
+
* Framework SDKs should use this instead of the public ClerkProvider.
|
|
45
|
+
*/
|
|
46
|
+
declare const InternalClerkProvider: (<TUi extends Ui = Ui>(props: ClerkProviderProps<TUi> & InternalClerkScriptProps$1) => React.JSX.Element) & {
|
|
47
|
+
displayName: string;
|
|
48
|
+
};
|
|
49
|
+
//#endregion
|
|
50
|
+
export { IS_REACT_SHARED_VARIANT_COMPATIBLE, InternalClerkProvider, type InternalClerkScriptProps, MultisessionAppSupport, OAuthConsent, type Ui, buildClerkJSScriptAttributes, buildClerkJsScriptAttributes, buildClerkUIScriptAttributes, clerkJSScriptUrl, clerkJsScriptUrl, clerkUIScriptUrl, publishableKeyFromHost, setClerkJSLoadingErrorPackageName, setClerkJsLoadingErrorPackageName, setErrorThrowerOptions, useDerivedAuth, useOAuthConsent, useRoutingProps };
|
|
51
|
+
//# sourceMappingURL=internal.d.cts.map
|
package/dist/internal.d.mts
CHANGED
|
@@ -1,53 +1,51 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
import
|
|
9
|
-
export { publishableKeyFromHost } from '@clerk/shared/keys';
|
|
10
|
-
import { ErrorThrowerOptions } from '@clerk/shared/error';
|
|
11
|
-
export { M as MultisessionAppSupport, u as useDerivedAuth } from './useAuth-Dlg_G1_7.mjs';
|
|
12
|
-
export { buildClerkJSScriptAttributes, buildClerkJsScriptAttributes, buildClerkUIScriptAttributes, clerkJSScriptUrl, clerkJsScriptUrl, clerkUIScriptUrl, setClerkJSLoadingErrorPackageName, setClerkJsLoadingErrorPackageName } from '@clerk/shared/loadClerkJsScript';
|
|
13
|
-
import '@clerk/shared/ui';
|
|
1
|
+
import { d as Ui, g as WithClerkProp, t as ClerkProviderProps } from "./types-CiIhevkA.mjs";
|
|
2
|
+
import { c as MultisessionAppSupport, n as useDerivedAuth } from "./useAuth-BK5Y4htK.mjs";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { buildClerkJSScriptAttributes, buildClerkJsScriptAttributes, buildClerkUIScriptAttributes, clerkJSScriptUrl, clerkJsScriptUrl, clerkUIScriptUrl, setClerkJSLoadingErrorPackageName, setClerkJsLoadingErrorPackageName } from "@clerk/shared/loadClerkJsScript";
|
|
5
|
+
import { ErrorThrowerOptions } from "@clerk/shared/error";
|
|
6
|
+
import { useOAuthConsent as useOAuthConsent$1 } from "@clerk/shared/react";
|
|
7
|
+
import { publishableKeyFromHost } from "@clerk/shared/keys";
|
|
8
|
+
import { InternalClerkScriptProps, InternalClerkScriptProps as InternalClerkScriptProps$1, RoutingOptions } from "@clerk/shared/types";
|
|
14
9
|
|
|
10
|
+
//#region src/errors/errorThrower.d.ts
|
|
15
11
|
/**
|
|
16
12
|
* Overrides options of the internal errorThrower (eg setting packageName prefix).
|
|
17
13
|
*
|
|
18
14
|
* @internal
|
|
19
15
|
*/
|
|
20
16
|
declare function setErrorThrowerOptions(options: ErrorThrowerOptions): void;
|
|
21
|
-
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/hooks/useRoutingProps.d.ts
|
|
22
19
|
declare function useRoutingProps<T extends RoutingOptions>(componentName: string, props: T, routingOptions?: RoutingOptions): T;
|
|
23
|
-
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/utils/versionCheck.d.ts
|
|
24
22
|
/**
|
|
25
23
|
* Whether the host React version is compatible with the shared @clerk/ui variant.
|
|
26
24
|
* This is computed once at module load time for optimal performance.
|
|
27
25
|
*/
|
|
28
26
|
declare const IS_REACT_SHARED_VARIANT_COMPATIBLE: boolean;
|
|
29
|
-
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/internal.d.ts
|
|
30
29
|
/**
|
|
31
30
|
* @deprecated Import `useOAuthConsent` from `@clerk/react` instead.
|
|
32
31
|
*/
|
|
33
32
|
declare const useOAuthConsent: typeof useOAuthConsent$1;
|
|
34
|
-
|
|
35
33
|
/**
|
|
36
34
|
* @deprecated Import `OAuthConsent` from `@clerk/react` instead.
|
|
37
35
|
*/
|
|
38
36
|
declare const OAuthConsent: {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
(props: import("@clerk/shared/types").Without<WithClerkProp<import("@clerk/shared/types").OAuthConsentProps & {
|
|
38
|
+
fallback?: React.ReactNode;
|
|
39
|
+
}>, "clerk">): React.JSX.Element | null;
|
|
40
|
+
displayName: string;
|
|
43
41
|
};
|
|
44
|
-
|
|
45
42
|
/**
|
|
46
43
|
* A wider-typed version of ClerkProvider that accepts internal script props.
|
|
47
44
|
* Framework SDKs should use this instead of the public ClerkProvider.
|
|
48
45
|
*/
|
|
49
|
-
declare const InternalClerkProvider: (<TUi extends Ui = Ui>(props: ClerkProviderProps<TUi> & InternalClerkScriptProps) => React.JSX.Element) & {
|
|
50
|
-
|
|
46
|
+
declare const InternalClerkProvider: (<TUi extends Ui = Ui>(props: ClerkProviderProps<TUi> & InternalClerkScriptProps$1) => React.JSX.Element) & {
|
|
47
|
+
displayName: string;
|
|
51
48
|
};
|
|
52
|
-
|
|
53
|
-
export { IS_REACT_SHARED_VARIANT_COMPATIBLE, InternalClerkProvider, OAuthConsent, setErrorThrowerOptions, useOAuthConsent, useRoutingProps };
|
|
49
|
+
//#endregion
|
|
50
|
+
export { IS_REACT_SHARED_VARIANT_COMPATIBLE, InternalClerkProvider, type InternalClerkScriptProps, MultisessionAppSupport, OAuthConsent, type Ui, buildClerkJSScriptAttributes, buildClerkJsScriptAttributes, buildClerkUIScriptAttributes, clerkJSScriptUrl, clerkJsScriptUrl, clerkUIScriptUrl, publishableKeyFromHost, setClerkJSLoadingErrorPackageName, setClerkJsLoadingErrorPackageName, setErrorThrowerOptions, useDerivedAuth, useOAuthConsent, useRoutingProps };
|
|
51
|
+
//# sourceMappingURL=internal.d.mts.map
|
package/dist/internal.mjs
CHANGED
|
@@ -1,79 +1,45 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
} from "
|
|
6
|
-
import {
|
|
7
|
-
OAuthConsent,
|
|
8
|
-
incompatibleRoutingWithPathProvidedError,
|
|
9
|
-
noPathProvidedError,
|
|
10
|
-
useDerivedAuth
|
|
11
|
-
} from "./chunk-FQVXBXXF.mjs";
|
|
12
|
-
import {
|
|
13
|
-
errorThrower,
|
|
14
|
-
setErrorThrowerOptions
|
|
15
|
-
} from "./chunk-RQWALB2R.mjs";
|
|
16
|
-
import "./chunk-E5QRIS4Z.mjs";
|
|
17
|
-
|
|
18
|
-
// src/internal.ts
|
|
19
|
-
import { useOAuthConsent as useOAuthConsentOriginal } from "@clerk/shared/react";
|
|
1
|
+
import { i as setErrorThrowerOptions, r as errorThrower } from "./useAssertWrappedByClerkProvider-GaNwZpWo.mjs";
|
|
2
|
+
import { J as noPathProvidedError, K as incompatibleRoutingWithPathProvidedError, T as OAuthConsent$1, x as useDerivedAuth } from "./hooks-BiY5Zgpp.mjs";
|
|
3
|
+
import { c as MultisessionAppSupport, n as IS_REACT_SHARED_VARIANT_COMPATIBLE, t as ClerkProvider } from "./ClerkProvider-LQpPtmNL.mjs";
|
|
4
|
+
import { buildClerkJSScriptAttributes, buildClerkJsScriptAttributes, buildClerkUIScriptAttributes, clerkJSScriptUrl, clerkJsScriptUrl, clerkUIScriptUrl, setClerkJSLoadingErrorPackageName, setClerkJsLoadingErrorPackageName } from "@clerk/shared/loadClerkJsScript";
|
|
5
|
+
import { useOAuthConsent as useOAuthConsent$1 } from "@clerk/shared/react";
|
|
20
6
|
import { publishableKeyFromHost } from "@clerk/shared/keys";
|
|
21
7
|
|
|
22
|
-
|
|
8
|
+
//#region src/hooks/useRoutingProps.ts
|
|
23
9
|
function useRoutingProps(componentName, props, routingOptions) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return {
|
|
40
|
-
...routingOptions,
|
|
41
|
-
...props,
|
|
42
|
-
path: void 0
|
|
43
|
-
};
|
|
10
|
+
const path = props.path || routingOptions?.path;
|
|
11
|
+
if ((props.routing || routingOptions?.routing || "path") === "path") {
|
|
12
|
+
if (!path) return errorThrower.throw(noPathProvidedError(componentName));
|
|
13
|
+
return {
|
|
14
|
+
...routingOptions,
|
|
15
|
+
...props,
|
|
16
|
+
routing: "path"
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
if (props.path) return errorThrower.throw(incompatibleRoutingWithPathProvidedError(componentName));
|
|
20
|
+
return {
|
|
21
|
+
...routingOptions,
|
|
22
|
+
...props,
|
|
23
|
+
path: void 0
|
|
24
|
+
};
|
|
44
25
|
}
|
|
45
26
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
OAuthConsent2 as OAuthConsent,
|
|
65
|
-
buildClerkJSScriptAttributes,
|
|
66
|
-
buildClerkJsScriptAttributes,
|
|
67
|
-
buildClerkUIScriptAttributes,
|
|
68
|
-
clerkJSScriptUrl,
|
|
69
|
-
clerkJsScriptUrl,
|
|
70
|
-
clerkUIScriptUrl,
|
|
71
|
-
publishableKeyFromHost,
|
|
72
|
-
setClerkJSLoadingErrorPackageName,
|
|
73
|
-
setClerkJsLoadingErrorPackageName,
|
|
74
|
-
setErrorThrowerOptions,
|
|
75
|
-
useDerivedAuth,
|
|
76
|
-
useOAuthConsent,
|
|
77
|
-
useRoutingProps
|
|
78
|
-
};
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/internal.ts
|
|
29
|
+
/**
|
|
30
|
+
* @deprecated Import `useOAuthConsent` from `@clerk/react` instead.
|
|
31
|
+
*/
|
|
32
|
+
const useOAuthConsent = useOAuthConsent$1;
|
|
33
|
+
/**
|
|
34
|
+
* @deprecated Import `OAuthConsent` from `@clerk/react` instead.
|
|
35
|
+
*/
|
|
36
|
+
const OAuthConsent = OAuthConsent$1;
|
|
37
|
+
/**
|
|
38
|
+
* A wider-typed version of ClerkProvider that accepts internal script props.
|
|
39
|
+
* Framework SDKs should use this instead of the public ClerkProvider.
|
|
40
|
+
*/
|
|
41
|
+
const InternalClerkProvider = ClerkProvider;
|
|
42
|
+
|
|
43
|
+
//#endregion
|
|
44
|
+
export { IS_REACT_SHARED_VARIANT_COMPATIBLE, InternalClerkProvider, MultisessionAppSupport, OAuthConsent, buildClerkJSScriptAttributes, buildClerkJsScriptAttributes, buildClerkUIScriptAttributes, clerkJSScriptUrl, clerkJsScriptUrl, clerkUIScriptUrl, publishableKeyFromHost, setClerkJSLoadingErrorPackageName, setClerkJsLoadingErrorPackageName, setErrorThrowerOptions, useDerivedAuth, useOAuthConsent, useRoutingProps };
|
|
79
45
|
//# sourceMappingURL=internal.mjs.map
|
package/dist/internal.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/
|
|
1
|
+
{"version":3,"file":"internal.mjs","names":["useOAuthConsentOriginal","OAuthConsentOriginal"],"sources":["../src/hooks/useRoutingProps.ts","../src/internal.ts"],"sourcesContent":["import type { RoutingOptions } from '@clerk/shared/types';\n\nimport { errorThrower } from '../errors/errorThrower';\nimport { incompatibleRoutingWithPathProvidedError, noPathProvidedError } from '../errors/messages';\n\nexport function useRoutingProps<T extends RoutingOptions>(\n componentName: string,\n props: T,\n routingOptions?: RoutingOptions,\n): T {\n const path = props.path || routingOptions?.path;\n const routing = props.routing || routingOptions?.routing || 'path';\n\n if (routing === 'path') {\n if (!path) {\n return errorThrower.throw(noPathProvidedError(componentName));\n }\n\n return {\n ...routingOptions,\n ...props,\n routing: 'path',\n };\n }\n\n if (props.path) {\n return errorThrower.throw(incompatibleRoutingWithPathProvidedError(componentName));\n }\n\n return {\n ...routingOptions,\n ...props,\n path: undefined,\n };\n}\n","import { useOAuthConsent as useOAuthConsentOriginal } from '@clerk/shared/react';\nimport type { InternalClerkScriptProps } from '@clerk/shared/types';\nimport type React from 'react';\n\nimport { OAuthConsent as OAuthConsentOriginal } from './components/uiComponents';\nimport { ClerkProvider } from './contexts/ClerkProvider';\nimport type { ClerkProviderProps, Ui } from './types';\n\nexport { publishableKeyFromHost } from '@clerk/shared/keys';\nexport { setErrorThrowerOptions } from './errors/errorThrower';\nexport { MultisessionAppSupport } from './components/controlComponents';\n\n/**\n * @deprecated Import `useOAuthConsent` from `@clerk/react` instead.\n */\nconst useOAuthConsent = useOAuthConsentOriginal;\nexport { useOAuthConsent };\n\n/**\n * @deprecated Import `OAuthConsent` from `@clerk/react` instead.\n */\nconst OAuthConsent = OAuthConsentOriginal;\nexport { OAuthConsent };\n\nexport { useRoutingProps } from './hooks/useRoutingProps';\nexport { useDerivedAuth } from './hooks/useAuth';\nexport { IS_REACT_SHARED_VARIANT_COMPATIBLE } from './utils/versionCheck';\n\nexport {\n clerkJSScriptUrl,\n buildClerkJSScriptAttributes,\n clerkUIScriptUrl,\n buildClerkUIScriptAttributes,\n setClerkJSLoadingErrorPackageName,\n // Deprecated aliases - will be removed in a future major version\n clerkJsScriptUrl,\n buildClerkJsScriptAttributes,\n setClerkJsLoadingErrorPackageName,\n} from '@clerk/shared/loadClerkJsScript';\n\nexport type { Ui } from './types';\n\nexport type { InternalClerkScriptProps } from '@clerk/shared/types';\n\n/**\n * A wider-typed version of ClerkProvider that accepts internal script props.\n * Framework SDKs should use this instead of the public ClerkProvider.\n */\nexport const InternalClerkProvider = ClerkProvider as unknown as (<TUi extends Ui = Ui>(\n props: ClerkProviderProps<TUi> & InternalClerkScriptProps,\n) => React.JSX.Element) & { displayName: string };\n"],"mappings":";;;;;;;;AAKA,SAAgB,gBACd,eACA,OACA,gBACG;CACH,MAAM,OAAO,MAAM,QAAQ,gBAAgB;CAG3C,KAFgB,MAAM,WAAW,gBAAgB,WAAW,YAE5C,QAAQ;EACtB,IAAI,CAAC,MACH,OAAO,aAAa,MAAM,oBAAoB,aAAa,CAAC;EAG9D,OAAO;GACL,GAAG;GACH,GAAG;GACH,SAAS;EACX;CACF;CAEA,IAAI,MAAM,MACR,OAAO,aAAa,MAAM,yCAAyC,aAAa,CAAC;CAGnF,OAAO;EACL,GAAG;EACH,GAAG;EACH,MAAM;CACR;AACF;;;;;;;ACnBA,MAAM,kBAAkBA;;;;AAMxB,MAAM,eAAeC;;;;;AA2BrB,MAAa,wBAAwB"}
|
package/dist/legacy.cjs
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_useAssertWrappedByClerkProvider = require('./useAssertWrappedByClerkProvider-Cm0djUcB.cjs');
|
|
3
|
+
let _clerk_shared_react = require("@clerk/shared/react");
|
|
4
|
+
let _clerk_shared_telemetry = require("@clerk/shared/telemetry");
|
|
5
|
+
|
|
6
|
+
//#region src/hooks/legacy/useSignIn.ts
|
|
7
|
+
/**
|
|
8
|
+
* The `useSignIn()` hook provides access to the [`SignIn`](https://clerk.com/docs/reference/objects/sign-in) object, which allows you to check the current state of a sign-in attempt and manage the sign-in flow. You can use this to create a [custom sign-in flow](https://clerk.com/docs/guides/development/custom-flows/overview).
|
|
9
|
+
*
|
|
10
|
+
* @unionReturnHeadings
|
|
11
|
+
* ["Initialization", "Loaded"]
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ### Check the current state of a sign-in
|
|
15
|
+
*
|
|
16
|
+
* The following example uses the `useSignIn()` hook to access the [`SignIn`](https://clerk.com/docs/reference/objects/sign-in) object, which contains the current sign-in attempt status and methods to create a new sign-in attempt. The `isLoaded` property is used to handle the loading state.
|
|
17
|
+
*
|
|
18
|
+
* <Tabs items='React,Next.js'>
|
|
19
|
+
* <Tab>
|
|
20
|
+
*
|
|
21
|
+
* ```tsx {{ filename: 'src/pages/SignInPage.tsx' }}
|
|
22
|
+
* import { useSignIn } from '@clerk/react'
|
|
23
|
+
*
|
|
24
|
+
* export default function SignInPage() {
|
|
25
|
+
* const { isLoaded, signIn } = useSignIn()
|
|
26
|
+
*
|
|
27
|
+
* if (!isLoaded) {
|
|
28
|
+
* // Handle loading state
|
|
29
|
+
* return null
|
|
30
|
+
* }
|
|
31
|
+
*
|
|
32
|
+
* return <div>The current sign-in attempt status is {signIn?.status}.</div>
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* </Tab>
|
|
37
|
+
* <Tab>
|
|
38
|
+
*
|
|
39
|
+
* {@include ../../../docs/legacy-use-sign-in.md#nextjs-01}
|
|
40
|
+
*
|
|
41
|
+
* </Tab>
|
|
42
|
+
* </Tabs>
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ### Create a custom sign-in flow with `useSignIn()`
|
|
46
|
+
*
|
|
47
|
+
* The `useSignIn()` hook can also be used to build fully custom sign-in flows, if Clerk's prebuilt components don't meet your specific needs or if you require more control over the authentication flow. Different sign-in flows include email and password, email and phone codes, email links, and multifactor (MFA). To learn more about using the `useSignIn()` hook to create custom flows, see the [custom flow guides](https://clerk.com/docs/guides/development/custom-flows/overview).
|
|
48
|
+
*
|
|
49
|
+
* ```empty```
|
|
50
|
+
*/
|
|
51
|
+
const useSignIn = () => {
|
|
52
|
+
require_useAssertWrappedByClerkProvider.useAssertWrappedByClerkProvider("useSignIn");
|
|
53
|
+
const isomorphicClerk = require_useAssertWrappedByClerkProvider.useIsomorphicClerkContext();
|
|
54
|
+
const client = (0, _clerk_shared_react.__internal_useClientBase)();
|
|
55
|
+
isomorphicClerk.telemetry?.record((0, _clerk_shared_telemetry.eventMethodCalled)("useSignIn"));
|
|
56
|
+
if (!client) return {
|
|
57
|
+
isLoaded: false,
|
|
58
|
+
signIn: void 0,
|
|
59
|
+
setActive: void 0
|
|
60
|
+
};
|
|
61
|
+
return {
|
|
62
|
+
isLoaded: true,
|
|
63
|
+
signIn: client.signIn,
|
|
64
|
+
setActive: isomorphicClerk.setActive
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region src/hooks/legacy/useSignUp.ts
|
|
70
|
+
/**
|
|
71
|
+
* The `useSignUp()` hook provides access to the [`SignUp`](https://clerk.com/docs/reference/objects/sign-up) object, which allows you to check the current state of a sign-up attempt and manage the sign-up flow. You can use this to create a [custom sign-up flow](https://clerk.com/docs/guides/development/custom-flows/overview).
|
|
72
|
+
*
|
|
73
|
+
* @unionReturnHeadings
|
|
74
|
+
* ["Initialization", "Loaded"]
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ### Check the current state of a sign-up
|
|
78
|
+
*
|
|
79
|
+
* The following example uses the `useSignUp()` hook to access the [`SignUp`](https://clerk.com/docs/reference/objects/sign-up) object, which contains the current sign-up attempt status and methods to create a new sign-up attempt. The `isLoaded` property is used to handle the loading state.
|
|
80
|
+
*
|
|
81
|
+
* <Tabs items='React,Next.js'>
|
|
82
|
+
* <Tab>
|
|
83
|
+
*
|
|
84
|
+
* ```tsx {{ filename: 'src/pages/SignUpPage.tsx' }}
|
|
85
|
+
* import { useSignUp } from '@clerk/react'
|
|
86
|
+
*
|
|
87
|
+
* export default function SignUpPage() {
|
|
88
|
+
* const { isLoaded, signUp } = useSignUp()
|
|
89
|
+
*
|
|
90
|
+
* if (!isLoaded) {
|
|
91
|
+
* // Handle loading state
|
|
92
|
+
* return null
|
|
93
|
+
* }
|
|
94
|
+
*
|
|
95
|
+
* return <div>The current sign-up attempt status is {signUp?.status}.</div>
|
|
96
|
+
* }
|
|
97
|
+
* ```
|
|
98
|
+
*
|
|
99
|
+
* </Tab>
|
|
100
|
+
* <Tab>
|
|
101
|
+
*
|
|
102
|
+
* {@include ../../../docs/legacy-use-sign-up.md#nextjs-01}
|
|
103
|
+
*
|
|
104
|
+
* </Tab>
|
|
105
|
+
* </Tabs>
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* ### Create a custom sign-up flow with `useSignUp()`
|
|
109
|
+
*
|
|
110
|
+
* The `useSignUp()` hook can also be used to build fully custom sign-up flows, if Clerk's prebuilt components don't meet your specific needs or if you require more control over the authentication flow. Different sign-up flows include email and password, email and phone codes, email links, and multifactor (MFA). To learn more about using the `useSignUp()` hook to create custom flows, see the [custom flow guides](https://clerk.com/docs/guides/development/custom-flows/overview).
|
|
111
|
+
*
|
|
112
|
+
* ```empty```
|
|
113
|
+
*/
|
|
114
|
+
const useSignUp = () => {
|
|
115
|
+
require_useAssertWrappedByClerkProvider.useAssertWrappedByClerkProvider("useSignUp");
|
|
116
|
+
const isomorphicClerk = require_useAssertWrappedByClerkProvider.useIsomorphicClerkContext();
|
|
117
|
+
const client = (0, _clerk_shared_react.__internal_useClientBase)();
|
|
118
|
+
isomorphicClerk.telemetry?.record((0, _clerk_shared_telemetry.eventMethodCalled)("useSignUp"));
|
|
119
|
+
if (!client) return {
|
|
120
|
+
isLoaded: false,
|
|
121
|
+
signUp: void 0,
|
|
122
|
+
setActive: void 0
|
|
123
|
+
};
|
|
124
|
+
return {
|
|
125
|
+
isLoaded: true,
|
|
126
|
+
signUp: client.signUp,
|
|
127
|
+
setActive: isomorphicClerk.setActive
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
//#endregion
|
|
132
|
+
exports.useSignIn = useSignIn;
|
|
133
|
+
exports.useSignUp = useSignUp;
|
|
134
|
+
//# sourceMappingURL=legacy.cjs.map
|