From f030f6f152b7312d7e08a51e6d947edf769ec0ab Mon Sep 17 00:00:00 2001 From: Bryce Kalow Date: Fri, 8 Nov 2024 10:17:01 -0600 Subject: [PATCH] feat(elements): Support SignIn.Captcha and sso-callback step (#4523) --- .changeset/rich-badgers-pump.md | 5 ++ .../app/sign-in/[[...sign-in]]/page.tsx | 1 + .../third-party/third-party.actors.ts | 4 -- .../elements/src/react/sign-in/captcha.tsx | 70 +++++++++++++++++++ .../src/react/sign-in/sso-callback.tsx | 13 ++++ packages/elements/src/react/sign-in/step.tsx | 8 ++- 6 files changed, 96 insertions(+), 5 deletions(-) create mode 100644 .changeset/rich-badgers-pump.md create mode 100644 packages/elements/src/react/sign-in/captcha.tsx create mode 100644 packages/elements/src/react/sign-in/sso-callback.tsx diff --git a/.changeset/rich-badgers-pump.md b/.changeset/rich-badgers-pump.md new file mode 100644 index 0000000000..91a13ed520 --- /dev/null +++ b/.changeset/rich-badgers-pump.md @@ -0,0 +1,5 @@ +--- +'@clerk/elements': minor +--- + +Introduce support for `` and ``. This allows rendering of a CAPTCHA widget when a sign in attempt is transferred to a sign up attempt. diff --git a/packages/elements/examples/nextjs/app/sign-in/[[...sign-in]]/page.tsx b/packages/elements/examples/nextjs/app/sign-in/[[...sign-in]]/page.tsx index e99e7cfbc9..d428a07f6d 100644 --- a/packages/elements/examples/nextjs/app/sign-in/[[...sign-in]]/page.tsx +++ b/packages/elements/examples/nextjs/app/sign-in/[[...sign-in]]/page.tsx @@ -499,6 +499,7 @@ export default function SignInPage() { Update Password + ); diff --git a/packages/elements/src/internals/machines/third-party/third-party.actors.ts b/packages/elements/src/internals/machines/third-party/third-party.actors.ts index 592f273814..e80a48b2e9 100644 --- a/packages/elements/src/internals/machines/third-party/third-party.actors.ts +++ b/packages/elements/src/internals/machines/third-party/third-party.actors.ts @@ -78,10 +78,6 @@ export const handleRedirectCallback = fromCallback; + +type CaptchaElementProps = Omit< + React.DetailedHTMLProps, HTMLDivElement>, + 'id' | 'children' +>; + +export type SignInCaptchaProps = + | ({ + asChild: true; + /* Must only be a self-closing element/component */ + children: React.ReactElement; + } & CaptchaElementProps) + | ({ asChild?: false; children?: undefined } & CaptchaElementProps); + +/** + * The `` component is used to render the Cloudflare Turnstile widget. It must be used within the `` component. + * + * If utilizing the `asChild` prop, the component must be a self-closing element or component. Any children passed to the immediate child component of will be ignored. + * + * @param {boolean} [asChild] - If true, `` will render as its child element, passing along any necessary props. + * + * @example + * + * + * + * + * + * + * @example + * + * + * + *