@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
CHANGED
|
@@ -1,396 +1,301 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
ClerkFailed,
|
|
5
|
-
ClerkLoaded,
|
|
6
|
-
ClerkLoading,
|
|
7
|
-
ClerkProvider,
|
|
8
|
-
RedirectToCreateOrganization,
|
|
9
|
-
RedirectToOrganizationProfile,
|
|
10
|
-
RedirectToSignIn,
|
|
11
|
-
RedirectToSignUp,
|
|
12
|
-
RedirectToTasks,
|
|
13
|
-
RedirectToUserProfile,
|
|
14
|
-
Show
|
|
15
|
-
} from "./chunk-GVGS7DUS.mjs";
|
|
16
|
-
import {
|
|
17
|
-
APIKeys,
|
|
18
|
-
CreateOrganization,
|
|
19
|
-
GoogleOneTap,
|
|
20
|
-
OAuthConsent,
|
|
21
|
-
OrganizationList,
|
|
22
|
-
OrganizationProfile,
|
|
23
|
-
OrganizationSwitcher,
|
|
24
|
-
PricingTable,
|
|
25
|
-
SignIn,
|
|
26
|
-
SignUp,
|
|
27
|
-
TaskChooseOrganization,
|
|
28
|
-
TaskResetPassword,
|
|
29
|
-
TaskSetupMFA,
|
|
30
|
-
UserAvatar,
|
|
31
|
-
UserButton,
|
|
32
|
-
UserProfile,
|
|
33
|
-
Waitlist,
|
|
34
|
-
__experimental_CheckoutProvider,
|
|
35
|
-
__experimental_PaymentElement,
|
|
36
|
-
__experimental_PaymentElementProvider,
|
|
37
|
-
__experimental_useCheckout,
|
|
38
|
-
__experimental_usePaymentElement,
|
|
39
|
-
assertSingleChild,
|
|
40
|
-
normalizeWithDefaultValue,
|
|
41
|
-
safeExecute,
|
|
42
|
-
useAPIKeys,
|
|
43
|
-
useAuth,
|
|
44
|
-
useClerk,
|
|
45
|
-
useEmailLink,
|
|
46
|
-
useOAuthConsent,
|
|
47
|
-
useOrganization,
|
|
48
|
-
useOrganizationCreationDefaults,
|
|
49
|
-
useOrganizationList,
|
|
50
|
-
useReverification,
|
|
51
|
-
useSession,
|
|
52
|
-
useSessionList,
|
|
53
|
-
useSignIn,
|
|
54
|
-
useSignUp,
|
|
55
|
-
useUser,
|
|
56
|
-
useWaitlist,
|
|
57
|
-
withClerk
|
|
58
|
-
} from "./chunk-FQVXBXXF.mjs";
|
|
59
|
-
import {
|
|
60
|
-
setErrorThrowerOptions
|
|
61
|
-
} from "./chunk-RQWALB2R.mjs";
|
|
62
|
-
import "./chunk-E5QRIS4Z.mjs";
|
|
63
|
-
|
|
64
|
-
// src/polyfills.ts
|
|
65
|
-
if (typeof window !== "undefined" && !window.global) {
|
|
66
|
-
window.global = typeof global === "undefined" ? window : global;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// ../ui/register/index.mjs
|
|
1
|
+
import { i as setErrorThrowerOptions } from "./useAssertWrappedByClerkProvider-GaNwZpWo.mjs";
|
|
2
|
+
import { A as SignIn, C as CreateOrganization, D as OrganizationProfile, E as OrganizationList, F as UserAvatar, G as safeExecute, I as UserButton, L as UserProfile, M as TaskChooseOrganization, N as TaskResetPassword, O as OrganizationSwitcher, P as TaskSetupMFA, R as Waitlist, S as APIKeys, T as OAuthConsent, U as assertSingleChild, W as normalizeWithDefaultValue, _ as useSignUp, a as __experimental_usePaymentElement, b as useAuth, c as useOAuthConsent, d as useOrganizationList, f as useReverification, g as useSignIn, h as useUser, i as __experimental_useCheckout, j as SignUp, k as PricingTable, l as useOrganization, m as useSessionList, n as __experimental_PaymentElement, o as useAPIKeys, p as useSession, r as __experimental_PaymentElementProvider, s as useClerk, t as __experimental_CheckoutProvider, u as useOrganizationCreationDefaults, v as useWaitlist, w as GoogleOneTap, y as useEmailLink, z as withClerk } from "./hooks-BiY5Zgpp.mjs";
|
|
3
|
+
import { a as ClerkFailed, d as RedirectToSignIn, f as RedirectToSignUp, h as Show, i as ClerkDegraded, l as RedirectToCreateOrganization, m as RedirectToUserProfile, o as ClerkLoaded, p as RedirectToTasks, r as AuthenticateWithRedirectCallback, s as ClerkLoading, t as ClerkProvider, u as RedirectToOrganizationProfile } from "./ClerkProvider-LQpPtmNL.mjs";
|
|
70
4
|
import * as react from "react";
|
|
5
|
+
import React, { useEffect, useRef } from "react";
|
|
71
6
|
import * as reactDom from "react-dom";
|
|
72
7
|
import * as reactDomClient from "react-dom/client";
|
|
73
8
|
import * as jsxRuntime from "react/jsx-runtime";
|
|
74
|
-
var _a;
|
|
75
|
-
if (globalThis.__clerkSharedModules) {
|
|
76
|
-
const existingVersion = (_a = globalThis.__clerkSharedModules.react) == null ? void 0 : _a.version;
|
|
77
|
-
if (existingVersion && existingVersion !== react.version) {
|
|
78
|
-
console.warn(
|
|
79
|
-
`[@clerk/ui/register] React version mismatch detected. Already registered: ${existingVersion}, current import: ${react.version}. This may cause issues with the shared @clerk/ui variant.`
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
} else {
|
|
83
|
-
globalThis.__clerkSharedModules = {
|
|
84
|
-
react,
|
|
85
|
-
"react-dom": reactDom,
|
|
86
|
-
"react-dom/client": reactDomClient,
|
|
87
|
-
"react/jsx-runtime": jsxRuntime
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// src/index.ts
|
|
92
9
|
import { setClerkJSLoadingErrorPackageName } from "@clerk/shared/loadClerkJsScript";
|
|
10
|
+
import { UNSAFE_PortalProvider } from "@clerk/shared/react";
|
|
11
|
+
import { deprecated } from "@clerk/shared/deprecated";
|
|
12
|
+
import { getToken } from "@clerk/shared/getToken";
|
|
93
13
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
component,
|
|
103
|
-
signUpFallbackRedirectUrl,
|
|
104
|
-
forceRedirectUrl,
|
|
105
|
-
fallbackRedirectUrl,
|
|
106
|
-
signUpForceRedirectUrl,
|
|
107
|
-
mode,
|
|
108
|
-
initialValues,
|
|
109
|
-
withSignUp,
|
|
110
|
-
oauthFlow,
|
|
111
|
-
...rest
|
|
112
|
-
} = props;
|
|
113
|
-
children = normalizeWithDefaultValue(children, "Sign in");
|
|
114
|
-
const child = assertSingleChild(children)("SignInButton");
|
|
115
|
-
const clickHandler = () => {
|
|
116
|
-
const opts = {
|
|
117
|
-
forceRedirectUrl,
|
|
118
|
-
fallbackRedirectUrl,
|
|
119
|
-
signUpFallbackRedirectUrl,
|
|
120
|
-
signUpForceRedirectUrl,
|
|
121
|
-
initialValues,
|
|
122
|
-
withSignUp,
|
|
123
|
-
oauthFlow
|
|
124
|
-
};
|
|
125
|
-
if (mode === "modal") {
|
|
126
|
-
return clerk.openSignIn({ ...opts, appearance, getContainer });
|
|
127
|
-
}
|
|
128
|
-
return clerk.redirectToSignIn({
|
|
129
|
-
...opts,
|
|
130
|
-
signInFallbackRedirectUrl: fallbackRedirectUrl,
|
|
131
|
-
signInForceRedirectUrl: forceRedirectUrl
|
|
132
|
-
});
|
|
133
|
-
};
|
|
134
|
-
const wrappedChildClickHandler = async (e) => {
|
|
135
|
-
if (child && typeof child === "object" && "props" in child) {
|
|
136
|
-
await safeExecute(child.props.onClick)(e);
|
|
137
|
-
}
|
|
138
|
-
return clickHandler();
|
|
139
|
-
};
|
|
140
|
-
const childProps = { ...rest, onClick: wrappedChildClickHandler };
|
|
141
|
-
return React.cloneElement(child, childProps);
|
|
142
|
-
},
|
|
143
|
-
{ component: "SignInButton", renderWhileLoading: true }
|
|
144
|
-
);
|
|
14
|
+
//#region src/polyfills.ts
|
|
15
|
+
/**
|
|
16
|
+
* Vite does not define `global` by default
|
|
17
|
+
* One workaround is to use the `define` config prop
|
|
18
|
+
* https://vitejs.dev/config/#define
|
|
19
|
+
* We are solving this in the SDK level to reduce setup steps.
|
|
20
|
+
*/
|
|
21
|
+
if (typeof window !== "undefined" && !window.global) window.global = typeof global === "undefined" ? window : global;
|
|
145
22
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region ../ui/register/index.mjs
|
|
25
|
+
/**
|
|
26
|
+
* Register React dependencies for sharing with @clerk/ui's shared variant.
|
|
27
|
+
*
|
|
28
|
+
* Import this module BEFORE loading the ui.shared.browser.js bundle:
|
|
29
|
+
*
|
|
30
|
+
* ```js
|
|
31
|
+
* import '@clerk/ui/register';
|
|
32
|
+
* // Now load clerk-js which will load ui.shared.browser.js
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* This enables @clerk/ui to use the host app's React instead of bundling its own,
|
|
36
|
+
* reducing the overall bundle size.
|
|
37
|
+
*/
|
|
38
|
+
if (globalThis.__clerkSharedModules) {
|
|
39
|
+
const existingVersion = globalThis.__clerkSharedModules.react?.version;
|
|
40
|
+
if (existingVersion && existingVersion !== react.version) console.warn(`[@clerk/ui/register] React version mismatch detected. Already registered: ${existingVersion}, current import: ${react.version}. This may cause issues with the shared @clerk/ui variant.`);
|
|
41
|
+
} else globalThis.__clerkSharedModules = {
|
|
42
|
+
react,
|
|
43
|
+
"react-dom": reactDom,
|
|
44
|
+
"react-dom/client": reactDomClient,
|
|
45
|
+
"react/jsx-runtime": jsxRuntime
|
|
46
|
+
};
|
|
168
47
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/components/SignInButton.tsx
|
|
50
|
+
const SignInButton = withClerk(({ clerk, children, ...props }) => {
|
|
51
|
+
const { appearance, getContainer, component, signUpFallbackRedirectUrl, forceRedirectUrl, fallbackRedirectUrl, signUpForceRedirectUrl, mode, initialValues, withSignUp, oauthFlow, ...rest } = props;
|
|
52
|
+
children = normalizeWithDefaultValue(children, "Sign in");
|
|
53
|
+
const child = assertSingleChild(children)("SignInButton");
|
|
54
|
+
const clickHandler = () => {
|
|
55
|
+
const opts = {
|
|
56
|
+
forceRedirectUrl,
|
|
57
|
+
fallbackRedirectUrl,
|
|
58
|
+
signUpFallbackRedirectUrl,
|
|
59
|
+
signUpForceRedirectUrl,
|
|
60
|
+
initialValues,
|
|
61
|
+
withSignUp,
|
|
62
|
+
oauthFlow
|
|
63
|
+
};
|
|
64
|
+
if (mode === "modal") return clerk.openSignIn({
|
|
65
|
+
...opts,
|
|
66
|
+
appearance,
|
|
67
|
+
getContainer
|
|
68
|
+
});
|
|
69
|
+
return clerk.redirectToSignIn({
|
|
70
|
+
...opts,
|
|
71
|
+
signInFallbackRedirectUrl: fallbackRedirectUrl,
|
|
72
|
+
signInForceRedirectUrl: forceRedirectUrl
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
const wrappedChildClickHandler = async (e) => {
|
|
76
|
+
if (child && typeof child === "object" && "props" in child) await safeExecute(child.props.onClick)(e);
|
|
77
|
+
return clickHandler();
|
|
78
|
+
};
|
|
79
|
+
const childProps = {
|
|
80
|
+
...rest,
|
|
81
|
+
onClick: wrappedChildClickHandler
|
|
82
|
+
};
|
|
83
|
+
return React.cloneElement(child, childProps);
|
|
84
|
+
}, {
|
|
85
|
+
component: "SignInButton",
|
|
86
|
+
renderWhileLoading: true
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
//#endregion
|
|
90
|
+
//#region src/components/SignInWithMetamaskButton.tsx
|
|
91
|
+
const SignInWithMetamaskButton = withClerk(({ clerk, children, ...props }) => {
|
|
92
|
+
const { redirectUrl, getContainer, component, ...rest } = props;
|
|
93
|
+
children = normalizeWithDefaultValue(children, "Sign in with Metamask");
|
|
94
|
+
const child = assertSingleChild(children)("SignInWithMetamaskButton");
|
|
95
|
+
const clickHandler = async () => {
|
|
96
|
+
async function authenticate() {
|
|
97
|
+
await clerk.authenticateWithMetamask({ redirectUrl: redirectUrl || void 0 });
|
|
98
|
+
}
|
|
99
|
+
authenticate();
|
|
100
|
+
};
|
|
101
|
+
const wrappedChildClickHandler = async (e) => {
|
|
102
|
+
await safeExecute(child.props.onClick)(e);
|
|
103
|
+
return clickHandler();
|
|
104
|
+
};
|
|
105
|
+
const childProps = {
|
|
106
|
+
...rest,
|
|
107
|
+
onClick: wrappedChildClickHandler
|
|
108
|
+
};
|
|
109
|
+
return React.cloneElement(child, childProps);
|
|
110
|
+
}, {
|
|
111
|
+
component: "SignInWithMetamask",
|
|
112
|
+
renderWhileLoading: true
|
|
113
|
+
});
|
|
194
114
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
forceRedirectUrl,
|
|
221
|
-
signInFallbackRedirectUrl,
|
|
222
|
-
signInForceRedirectUrl,
|
|
223
|
-
initialValues,
|
|
224
|
-
oauthFlow
|
|
225
|
-
};
|
|
226
|
-
if (mode === "modal") {
|
|
227
|
-
return clerk.openSignUp({
|
|
228
|
-
...opts,
|
|
229
|
-
appearance,
|
|
230
|
-
unsafeMetadata,
|
|
231
|
-
getContainer
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
return clerk.redirectToSignUp({
|
|
235
|
-
...opts,
|
|
236
|
-
signUpFallbackRedirectUrl: fallbackRedirectUrl,
|
|
237
|
-
signUpForceRedirectUrl: forceRedirectUrl
|
|
238
|
-
});
|
|
239
|
-
};
|
|
240
|
-
const wrappedChildClickHandler = async (e) => {
|
|
241
|
-
if (child && typeof child === "object" && "props" in child) {
|
|
242
|
-
await safeExecute(child.props.onClick)(e);
|
|
243
|
-
}
|
|
244
|
-
return clickHandler();
|
|
245
|
-
};
|
|
246
|
-
const childProps = { ...rest, onClick: wrappedChildClickHandler };
|
|
247
|
-
return React4.cloneElement(child, childProps);
|
|
248
|
-
},
|
|
249
|
-
{ component: "SignUpButton", renderWhileLoading: true }
|
|
250
|
-
);
|
|
115
|
+
//#endregion
|
|
116
|
+
//#region src/components/SignOutButton.tsx
|
|
117
|
+
const SignOutButton = withClerk(({ clerk, children, ...props }) => {
|
|
118
|
+
const { redirectUrl = "/", sessionId, signOutOptions, getContainer, component, ...rest } = props;
|
|
119
|
+
if (signOutOptions) deprecated("SignOutButton `signOutOptions`", "Use the `redirectUrl` and `sessionId` props directly instead.");
|
|
120
|
+
children = normalizeWithDefaultValue(children, "Sign out");
|
|
121
|
+
const child = assertSingleChild(children)("SignOutButton");
|
|
122
|
+
const clickHandler = () => clerk.signOut({
|
|
123
|
+
redirectUrl,
|
|
124
|
+
...sessionId !== void 0 && { sessionId },
|
|
125
|
+
...signOutOptions
|
|
126
|
+
});
|
|
127
|
+
const wrappedChildClickHandler = async (e) => {
|
|
128
|
+
await safeExecute(child.props.onClick)(e);
|
|
129
|
+
return clickHandler();
|
|
130
|
+
};
|
|
131
|
+
const childProps = {
|
|
132
|
+
...rest,
|
|
133
|
+
onClick: wrappedChildClickHandler
|
|
134
|
+
};
|
|
135
|
+
return React.cloneElement(child, childProps);
|
|
136
|
+
}, {
|
|
137
|
+
component: "SignOutButton",
|
|
138
|
+
renderWhileLoading: true
|
|
139
|
+
});
|
|
251
140
|
|
|
252
|
-
|
|
253
|
-
|
|
141
|
+
//#endregion
|
|
142
|
+
//#region src/components/SignUpButton.tsx
|
|
143
|
+
const SignUpButton = withClerk(({ clerk, children, ...props }) => {
|
|
144
|
+
const { appearance, unsafeMetadata, getContainer, component, fallbackRedirectUrl, forceRedirectUrl, signInFallbackRedirectUrl, signInForceRedirectUrl, mode, initialValues, oauthFlow, ...rest } = props;
|
|
145
|
+
children = normalizeWithDefaultValue(children, "Sign up");
|
|
146
|
+
const child = assertSingleChild(children)("SignUpButton");
|
|
147
|
+
const clickHandler = () => {
|
|
148
|
+
const opts = {
|
|
149
|
+
fallbackRedirectUrl,
|
|
150
|
+
forceRedirectUrl,
|
|
151
|
+
signInFallbackRedirectUrl,
|
|
152
|
+
signInForceRedirectUrl,
|
|
153
|
+
initialValues,
|
|
154
|
+
oauthFlow
|
|
155
|
+
};
|
|
156
|
+
if (mode === "modal") return clerk.openSignUp({
|
|
157
|
+
...opts,
|
|
158
|
+
appearance,
|
|
159
|
+
unsafeMetadata,
|
|
160
|
+
getContainer
|
|
161
|
+
});
|
|
162
|
+
return clerk.redirectToSignUp({
|
|
163
|
+
...opts,
|
|
164
|
+
signUpFallbackRedirectUrl: fallbackRedirectUrl,
|
|
165
|
+
signUpForceRedirectUrl: forceRedirectUrl
|
|
166
|
+
});
|
|
167
|
+
};
|
|
168
|
+
const wrappedChildClickHandler = async (e) => {
|
|
169
|
+
if (child && typeof child === "object" && "props" in child) await safeExecute(child.props.onClick)(e);
|
|
170
|
+
return clickHandler();
|
|
171
|
+
};
|
|
172
|
+
const childProps = {
|
|
173
|
+
...rest,
|
|
174
|
+
onClick: wrappedChildClickHandler
|
|
175
|
+
};
|
|
176
|
+
return React.cloneElement(child, childProps);
|
|
177
|
+
}, {
|
|
178
|
+
component: "SignUpButton",
|
|
179
|
+
renderWhileLoading: true
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
//#endregion
|
|
183
|
+
//#region src/components/HandleSSOCallback.tsx
|
|
184
|
+
/**
|
|
185
|
+
* Use this component when building custom UI to handle the SSO callback and navigate to the appropriate page based on
|
|
186
|
+
* the status of the sign-in or sign-up. By default, this component might render a captcha element to handle captchas
|
|
187
|
+
* when required by the Clerk API.
|
|
188
|
+
*
|
|
189
|
+
* @example
|
|
190
|
+
* ```tsx
|
|
191
|
+
* import { HandleSSOCallback } from '@clerk/react';
|
|
192
|
+
* import { useNavigate } from 'react-router';
|
|
193
|
+
*
|
|
194
|
+
* export default function Page() {
|
|
195
|
+
* const navigate = useNavigate();
|
|
196
|
+
*
|
|
197
|
+
* return (
|
|
198
|
+
* <HandleSSOCallback
|
|
199
|
+
* navigateToApp={({ session, decorateUrl }) => {
|
|
200
|
+
* if (session?.currentTask) {
|
|
201
|
+
* const destination = decorateUrl(`/onboarding/${session?.currentTask.key}`);
|
|
202
|
+
* if (destination.startsWith('http')) {
|
|
203
|
+
* window.location.href = destination;
|
|
204
|
+
* return;
|
|
205
|
+
* }
|
|
206
|
+
* navigate(destination);
|
|
207
|
+
* return;
|
|
208
|
+
* }
|
|
209
|
+
*
|
|
210
|
+
* const destination = decorateUrl('/dashboard');
|
|
211
|
+
* if (destination.startsWith('http')) {
|
|
212
|
+
* window.location.href = destination;
|
|
213
|
+
* return;
|
|
214
|
+
* }
|
|
215
|
+
* navigate(destination);
|
|
216
|
+
* }}
|
|
217
|
+
* navigateToSignIn={() => {
|
|
218
|
+
* navigate('/sign-in');
|
|
219
|
+
* }}
|
|
220
|
+
* navigateToSignUp={() => {
|
|
221
|
+
* navigate('/sign-up');
|
|
222
|
+
* }}
|
|
223
|
+
* />
|
|
224
|
+
* );
|
|
225
|
+
* }
|
|
226
|
+
* ```
|
|
227
|
+
*/
|
|
254
228
|
function HandleSSOCallback(props) {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
navigate: async (...params) => {
|
|
319
|
-
return navigateToApp(...params);
|
|
320
|
-
}
|
|
321
|
-
});
|
|
322
|
-
return;
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
})();
|
|
326
|
-
}, [clerk, clerk.loaded, signIn, signUp]);
|
|
327
|
-
return /* @__PURE__ */ React5.createElement("div", null, /* @__PURE__ */ React5.createElement("div", { id: "clerk-captcha" }));
|
|
229
|
+
const { navigateToApp, navigateToSignIn, navigateToSignUp } = props;
|
|
230
|
+
const clerk = useClerk();
|
|
231
|
+
const { signIn } = useSignIn();
|
|
232
|
+
const { signUp } = useSignUp();
|
|
233
|
+
const hasRun = useRef(false);
|
|
234
|
+
useEffect(() => {
|
|
235
|
+
(async () => {
|
|
236
|
+
if (!clerk.loaded || hasRun.current) return;
|
|
237
|
+
hasRun.current = true;
|
|
238
|
+
if (signIn.status === "complete") {
|
|
239
|
+
await signIn.finalize({ navigate: async (...params) => {
|
|
240
|
+
navigateToApp(...params);
|
|
241
|
+
} });
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
if (signUp.isTransferable) {
|
|
245
|
+
await signIn.create({ transfer: true });
|
|
246
|
+
if (signIn.status === "complete") {
|
|
247
|
+
await signIn.finalize({ navigate: async (...params) => {
|
|
248
|
+
navigateToApp(...params);
|
|
249
|
+
} });
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
return navigateToSignIn();
|
|
253
|
+
}
|
|
254
|
+
if (signIn.status === "needs_first_factor" && !signIn.supportedFirstFactors?.every((f) => f.strategy === "enterprise_sso")) return navigateToSignIn();
|
|
255
|
+
if (signIn.isTransferable) {
|
|
256
|
+
await signUp.create({ transfer: true });
|
|
257
|
+
if (signUp.status === "complete") {
|
|
258
|
+
await signUp.finalize({ navigate: async (...params) => {
|
|
259
|
+
navigateToApp(...params);
|
|
260
|
+
} });
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
return navigateToSignUp();
|
|
264
|
+
}
|
|
265
|
+
if (signUp.status === "complete") {
|
|
266
|
+
await signUp.finalize({ navigate: async (...params) => {
|
|
267
|
+
navigateToApp(...params);
|
|
268
|
+
} });
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
if (signIn.status === "needs_second_factor" || signIn.status === "needs_new_password") return navigateToSignIn();
|
|
272
|
+
if (signIn.existingSession || signUp.existingSession) {
|
|
273
|
+
const sessionId = signIn.existingSession?.sessionId || signUp.existingSession?.sessionId;
|
|
274
|
+
if (sessionId) {
|
|
275
|
+
await clerk.setActive({
|
|
276
|
+
session: sessionId,
|
|
277
|
+
navigate: async (...params) => {
|
|
278
|
+
return navigateToApp(...params);
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
})();
|
|
285
|
+
}, [
|
|
286
|
+
clerk,
|
|
287
|
+
clerk.loaded,
|
|
288
|
+
signIn,
|
|
289
|
+
signUp
|
|
290
|
+
]);
|
|
291
|
+
return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("div", { id: "clerk-captcha" }));
|
|
328
292
|
}
|
|
329
293
|
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
// src/index.ts
|
|
334
|
-
import { getToken } from "@clerk/shared/getToken";
|
|
294
|
+
//#endregion
|
|
295
|
+
//#region src/index.ts
|
|
335
296
|
setErrorThrowerOptions({ packageName: "@clerk/react" });
|
|
336
297
|
setClerkJSLoadingErrorPackageName("@clerk/react");
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
ClerkDegraded,
|
|
341
|
-
ClerkFailed,
|
|
342
|
-
ClerkLoaded,
|
|
343
|
-
ClerkLoading,
|
|
344
|
-
ClerkProvider,
|
|
345
|
-
CreateOrganization,
|
|
346
|
-
GoogleOneTap,
|
|
347
|
-
HandleSSOCallback,
|
|
348
|
-
OAuthConsent,
|
|
349
|
-
OrganizationList,
|
|
350
|
-
OrganizationProfile,
|
|
351
|
-
OrganizationSwitcher,
|
|
352
|
-
PricingTable,
|
|
353
|
-
RedirectToCreateOrganization,
|
|
354
|
-
RedirectToOrganizationProfile,
|
|
355
|
-
RedirectToSignIn,
|
|
356
|
-
RedirectToSignUp,
|
|
357
|
-
RedirectToTasks,
|
|
358
|
-
RedirectToUserProfile,
|
|
359
|
-
Show,
|
|
360
|
-
SignIn,
|
|
361
|
-
SignInButton,
|
|
362
|
-
SignInWithMetamaskButton,
|
|
363
|
-
SignOutButton,
|
|
364
|
-
SignUp,
|
|
365
|
-
SignUpButton,
|
|
366
|
-
TaskChooseOrganization,
|
|
367
|
-
TaskResetPassword,
|
|
368
|
-
TaskSetupMFA,
|
|
369
|
-
UNSAFE_PortalProvider,
|
|
370
|
-
UserAvatar,
|
|
371
|
-
UserButton,
|
|
372
|
-
UserProfile,
|
|
373
|
-
Waitlist,
|
|
374
|
-
__experimental_CheckoutProvider,
|
|
375
|
-
__experimental_PaymentElement,
|
|
376
|
-
__experimental_PaymentElementProvider,
|
|
377
|
-
__experimental_useCheckout,
|
|
378
|
-
__experimental_usePaymentElement,
|
|
379
|
-
getToken,
|
|
380
|
-
useAPIKeys,
|
|
381
|
-
useAuth,
|
|
382
|
-
useClerk,
|
|
383
|
-
useEmailLink,
|
|
384
|
-
useOAuthConsent,
|
|
385
|
-
useOrganization,
|
|
386
|
-
useOrganizationCreationDefaults,
|
|
387
|
-
useOrganizationList,
|
|
388
|
-
useReverification,
|
|
389
|
-
useSession,
|
|
390
|
-
useSessionList,
|
|
391
|
-
useSignIn,
|
|
392
|
-
useSignUp,
|
|
393
|
-
useUser,
|
|
394
|
-
useWaitlist
|
|
395
|
-
};
|
|
298
|
+
|
|
299
|
+
//#endregion
|
|
300
|
+
export { APIKeys, AuthenticateWithRedirectCallback, ClerkDegraded, ClerkFailed, ClerkLoaded, ClerkLoading, ClerkProvider, CreateOrganization, GoogleOneTap, HandleSSOCallback, OAuthConsent, OrganizationList, OrganizationProfile, OrganizationSwitcher, PricingTable, RedirectToCreateOrganization, RedirectToOrganizationProfile, RedirectToSignIn, RedirectToSignUp, RedirectToTasks, RedirectToUserProfile, Show, SignIn, SignInButton, SignInWithMetamaskButton, SignOutButton, SignUp, SignUpButton, TaskChooseOrganization, TaskResetPassword, TaskSetupMFA, UNSAFE_PortalProvider, UserAvatar, UserButton, UserProfile, Waitlist, __experimental_CheckoutProvider, __experimental_PaymentElement, __experimental_PaymentElementProvider, __experimental_useCheckout, __experimental_usePaymentElement, getToken, useAPIKeys, useAuth, useClerk, useEmailLink, useOAuthConsent, useOrganization, useOrganizationCreationDefaults, useOrganizationList, useReverification, useSession, useSessionList, useSignIn, useSignUp, useUser, useWaitlist };
|
|
396
301
|
//# sourceMappingURL=index.mjs.map
|