From 65e06883c379b62945c298f05f5b0cbd351397fe Mon Sep 17 00:00:00 2001 From: Bryce Kalow Date: Thu, 7 Nov 2024 22:00:46 -0600 Subject: [PATCH 1/2] support SignIn.Captcha within sso-callback step --- .../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 ++- 5 files changed, 91 insertions(+), 5 deletions(-) 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/packages/elements/examples/nextjs/app/sign-in/[[...sign-in]]/page.tsx b/packages/elements/examples/nextjs/app/sign-in/[[...sign-in]]/page.tsx index e99e7cfbc93..d428a07f6de 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 592f273814f..e80a48b2e9c 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 + * + * + * + *