File tree Expand file tree Collapse file tree 4 files changed +28
-8
lines changed
clerk-js/src/core/resources Expand file tree Collapse file tree 4 files changed +28
-8
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @clerk/clerk-js " : patch
3+ " @clerk/types " : patch
4+ ---
5+
6+ Bypass captcha for providers dynamically provided in environment
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import type {
55 DisplayConfigJSON ,
66 DisplayConfigResource ,
77 DisplayThemeJSON ,
8+ OAuthStrategy ,
89 PreferredSignInStrategy ,
910} from '@clerk/types' ;
1011
@@ -25,6 +26,7 @@ export class DisplayConfig extends BaseResource implements DisplayConfigResource
2526 captchaWidgetType : CaptchaWidgetType = null ;
2627 captchaProvider : CaptchaProvider = 'turnstile' ;
2728 captchaPublicKeyInvisible : string | null = null ;
29+ captchaOauthBypass : OAuthStrategy [ ] = [ ] ;
2830 homeUrl ! : string ;
2931 instanceEnvironmentType ! : string ;
3032 faviconImageUrl ! : string ;
@@ -84,6 +86,9 @@ export class DisplayConfig extends BaseResource implements DisplayConfigResource
8486 this . captchaWidgetType = data . captcha_widget_type ;
8587 this . captchaProvider = data . captcha_provider ;
8688 this . captchaPublicKeyInvisible = data . captcha_public_key_invisible ;
89+ // These are the OAuth strategies we used to bypass the captcha for by default
90+ // before the introduction of the captcha_oauth_bypass field
91+ this . captchaOauthBypass = data . captcha_oauth_bypass || [ 'oauth_google' , 'oauth_microsoft' , 'oauth_apple' ] ;
8792 this . supportEmail = data . support_email || '' ;
8893 this . clerkJSVersion = data . clerk_js_version ;
8994 this . organizationProfileUrl = data . organization_profile_url ;
Original file line number Diff line number Diff line change @@ -339,18 +339,19 @@ export class SignUp extends BaseResource implements SignUpResource {
339339 * We delegate bot detection to the following providers, instead of relying on turnstile exclusively
340340 */
341341 protected shouldBypassCaptchaForAttempt ( params : SignUpCreateParams ) {
342- if (
343- params . strategy === 'oauth_google' ||
344- params . strategy === 'oauth_microsoft' ||
345- params . strategy === 'oauth_apple'
346- ) {
342+ if ( ! params . strategy ) {
343+ return false ;
344+ }
345+
346+ const captchaOauthBypass = SignUp . clerk . __unstable__environment ! . displayConfig . captchaOauthBypass ;
347+
348+ if ( captchaOauthBypass . some ( strategy => strategy === params . strategy ) ) {
347349 return true ;
348350 }
351+
349352 if (
350353 params . transfer &&
351- ( SignUp . clerk . client ?. signIn . firstFactorVerification . strategy === 'oauth_google' ||
352- SignUp . clerk . client ?. signIn . firstFactorVerification . strategy === 'oauth_microsoft' ||
353- SignUp . clerk . client ?. signIn . firstFactorVerification . strategy === 'oauth_apple' )
354+ captchaOauthBypass . some ( strategy => strategy === SignUp . clerk . client ! . signIn . firstFactorVerification . strategy )
354355 ) {
355356 return true ;
356357 }
Original file line number Diff line number Diff line change 11import type { DisplayThemeJSON } from './json' ;
22import type { ClerkResource } from './resource' ;
3+ import type { OAuthStrategy } from './strategies' ;
34
45export type PreferredSignInStrategy = 'password' | 'otp' ;
56export type CaptchaWidgetType = 'smart' | 'invisible' | null ;
@@ -19,6 +20,7 @@ export interface DisplayConfigJSON {
1920 captcha_widget_type : CaptchaWidgetType ;
2021 captcha_public_key_invisible : string | null ;
2122 captcha_provider : CaptchaProvider ;
23+ captcha_oauth_bypass : OAuthStrategy [ ] | null ;
2224 home_url : string ;
2325 instance_environment_type : string ;
2426 /* @deprecated */
@@ -55,6 +57,12 @@ export interface DisplayConfigResource extends ClerkResource {
5557 captchaWidgetType : CaptchaWidgetType ;
5658 captchaProvider : CaptchaProvider ;
5759 captchaPublicKeyInvisible : string | null ;
60+ /**
61+ * An array of OAuth strategies for which we will bypass the captcha.
62+ * We trust that the provider will verify that the user is not a bot on their end.
63+ * This can also be used to bypass the captcha for a specific OAuth provider on a per-instance basis.
64+ */
65+ captchaOauthBypass : OAuthStrategy [ ] ;
5866 homeUrl : string ;
5967 instanceEnvironmentType : string ;
6068 logoImageUrl : string ;
You can’t perform that action at this time.
0 commit comments