Skip to content

Commit 65f0878

Browse files
authored
feat(types,clerk-js): Add oidcPrompt prop to SignIn/SignUp components (#5925)
1 parent 5491491 commit 65f0878

File tree

13 files changed

+49
-6
lines changed

13 files changed

+49
-6
lines changed

.changeset/dirty-keys-heal.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
'@clerk/clerk-js': patch
3+
'@clerk/types': patch
4+
---
5+
6+
Add `oidcPrompt` prop to `SignIn` and `SignUp` components and `authenticateWithRedirect` method to control the OIDC authentication prompt behavior during Enterprise SSO flows
7+
8+
```tsx
9+
<SignUp oidcPrompt='select_account' />
10+
<SignIn oidcPrompt='select_account' />
11+
```
12+
13+
```ts
14+
signUp.authenticateWithRedirect({ redirectUrl: '/sso-callback', oidcPrompt: 'select_account' })
15+
```

packages/clerk-js/bundlewatch.config.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"files": [
3-
{ "path": "./dist/clerk.js", "maxSize": "595.7kB" },
3+
{ "path": "./dist/clerk.js", "maxSize": "598KB" },
44
{ "path": "./dist/clerk.browser.js", "maxSize": "68.5KB" },
5-
{ "path": "./dist/clerk.legacy.browser.js", "maxSize": "110KB" },
5+
{ "path": "./dist/clerk.legacy.browser.js", "maxSize": "113KB" },
66
{ "path": "./dist/clerk.headless*.js", "maxSize": "52KB" },
77
{ "path": "./dist/ui-common*.js", "maxSize": "105.1KB" },
88
{ "path": "./dist/vendors*.js", "maxSize": "39.5KB" },
@@ -13,7 +13,7 @@
1313
{ "path": "./dist/organizationswitcher*.js", "maxSize": "5KB" },
1414
{ "path": "./dist/organizationlist*.js", "maxSize": "5.5KB" },
1515
{ "path": "./dist/signin*.js", "maxSize": "14KB" },
16-
{ "path": "./dist/signup*.js", "maxSize": "7.4KB" },
16+
{ "path": "./dist/signup*.js", "maxSize": "7.7KB" },
1717
{ "path": "./dist/userbutton*.js", "maxSize": "5KB" },
1818
{ "path": "./dist/userprofile*.js", "maxSize": "16.5KB" },
1919
{ "path": "./dist/userverification*.js", "maxSize": "5KB" },

packages/clerk-js/src/core/resources/SignIn.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ export class SignIn extends BaseResource implements SignInResource {
148148
config = {
149149
redirectUrl: factor.redirectUrl,
150150
actionCompleteRedirectUrl: factor.actionCompleteRedirectUrl,
151+
oidcPrompt: factor.oidcPrompt,
151152
} as EnterpriseSSOConfig;
152153
break;
153154
default:
@@ -231,20 +232,22 @@ export class SignIn extends BaseResource implements SignInResource {
231232
params: AuthenticateWithRedirectParams,
232233
navigateCallback: (url: URL | string) => void,
233234
): Promise<void> => {
234-
const { strategy, redirectUrl, redirectUrlComplete, identifier } = params || {};
235+
const { strategy, redirectUrl, redirectUrlComplete, identifier, oidcPrompt } = params || {};
235236

236237
const { firstFactorVerification } =
237238
(strategy === 'saml' || strategy === 'enterprise_sso') && this.id
238239
? await this.prepareFirstFactor({
239240
strategy,
240241
redirectUrl: SignIn.clerk.buildUrlWithAuth(redirectUrl),
241242
actionCompleteRedirectUrl: redirectUrlComplete,
243+
oidcPrompt,
242244
})
243245
: await this.create({
244246
strategy,
245247
identifier,
246248
redirectUrl: SignIn.clerk.buildUrlWithAuth(redirectUrl),
247249
actionCompleteRedirectUrl: redirectUrlComplete,
250+
oidcPrompt,
248251
});
249252

250253
const { status, externalVerificationRedirectURL } = firstFactorVerification;

packages/clerk-js/src/core/resources/SignUp.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ export class SignUp extends BaseResource implements SignUpResource {
306306
unsafeMetadata,
307307
emailAddress,
308308
legalAccepted,
309+
oidcPrompt,
309310
} = params;
310311

311312
const authenticateFn = () => {
@@ -316,6 +317,7 @@ export class SignUp extends BaseResource implements SignUpResource {
316317
unsafeMetadata,
317318
emailAddress,
318319
legalAccepted,
320+
oidcPrompt,
319321
};
320322
return continueSignUp && this.id ? this.update(authParams) : this.create(authParams);
321323
};

packages/clerk-js/src/ui/components/SignIn/SignInSocialButtons.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ export const SignInSocialButtons = React.memo((props: SignInSocialButtonsProps)
4545
}, 500);
4646

4747
return signIn
48-
.authenticateWithPopup({ strategy, redirectUrl, redirectUrlComplete, popup })
48+
.authenticateWithPopup({ strategy, redirectUrl, redirectUrlComplete, popup, oidcPrompt: ctx.oidcPrompt })
4949
.catch(err => handleError(err, [], card.setError));
5050
}
5151

5252
return signIn
53-
.authenticateWithRedirect({ strategy, redirectUrl, redirectUrlComplete })
53+
.authenticateWithRedirect({ strategy, redirectUrl, redirectUrlComplete, oidcPrompt: ctx.oidcPrompt })
5454
.catch(err => handleError(err, [], card.setError));
5555
}}
5656
web3Callback={strategy => {

packages/clerk-js/src/ui/components/SignIn/SignInStart.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,7 @@ function SignInStartInternal(): JSX.Element {
387387
strategy: 'enterprise_sso',
388388
redirectUrl,
389389
redirectUrlComplete,
390+
oidcPrompt: ctx.oidcPrompt,
390391
});
391392
};
392393

packages/clerk-js/src/ui/components/SignUp/SignUpContinue.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ function SignUpContinueInternal() {
4646
const [activeCommIdentifierType, setActiveCommIdentifierType] = React.useState<ActiveIdentifier>(
4747
getInitialActiveIdentifier(attributes, userSettings.signUp.progressive),
4848
);
49+
const ctx = useSignUpContext();
4950

5051
// TODO: This form should be shared between SignUpStart and SignUpContinue
5152
const formState = {
@@ -179,6 +180,7 @@ function SignUpContinueInternal() {
179180
verifyPhonePath: './verify-phone-number',
180181
handleComplete: () => clerk.setActive({ session: res.createdSessionId, redirectUrl: afterSignUpUrl }),
181182
navigate,
183+
oidcPrompt: ctx.oidcPrompt,
182184
}),
183185
)
184186
.catch(err => handleError(err, fieldsToSubmit, card.setError))

packages/clerk-js/src/ui/components/SignUp/SignUpSocialButtons.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export const SignUpSocialButtons = React.memo((props: SignUpSocialButtonsProps)
5252
continueSignUp,
5353
unsafeMetadata: ctx.unsafeMetadata,
5454
legalAccepted: props.legalAccepted,
55+
oidcPrompt: ctx.oidcPrompt,
5556
})
5657
.catch(err => handleError(err, [], card.setError));
5758
}
@@ -64,6 +65,7 @@ export const SignUpSocialButtons = React.memo((props: SignUpSocialButtonsProps)
6465
strategy,
6566
unsafeMetadata: ctx.unsafeMetadata,
6667
legalAccepted: props.legalAccepted,
68+
oidcPrompt: ctx.oidcPrompt,
6769
})
6870
.catch(err => handleError(err, [], card.setError));
6971
}}

packages/clerk-js/src/ui/components/SignUp/SignUpStart.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ function SignUpStartInternal(): JSX.Element {
273273
navigate,
274274
redirectUrl,
275275
redirectUrlComplete,
276+
oidcPrompt: ctx.oidcPrompt,
276277
}),
277278
)
278279
.catch(err => handleError(err, fieldsToSubmit, card.setError))

packages/clerk-js/src/utils/completeSignUpFlow.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ type CompleteSignUpFlowProps = {
99
handleComplete?: () => Promise<void>;
1010
redirectUrl?: string;
1111
redirectUrlComplete?: string;
12+
oidcPrompt?: string;
1213
};
1314

1415
export const completeSignUpFlow = ({
@@ -20,6 +21,7 @@ export const completeSignUpFlow = ({
2021
handleComplete,
2122
redirectUrl = '',
2223
redirectUrlComplete = '',
24+
oidcPrompt,
2325
}: CompleteSignUpFlowProps): Promise<unknown> | undefined => {
2426
if (signUp.status === 'complete') {
2527
return handleComplete && handleComplete();
@@ -30,6 +32,7 @@ export const completeSignUpFlow = ({
3032
redirectUrl,
3133
redirectUrlComplete,
3234
continueSignUp: true,
35+
oidcPrompt,
3336
});
3437
}
3538

0 commit comments

Comments
 (0)