Skip to content

Commit 63b95ad

Browse files
authored
feat(clerk-js): Display a prompt on Keyless mode (#4761)
1 parent e80166e commit 63b95ad

File tree

7 files changed

+30
-36
lines changed

7 files changed

+30
-36
lines changed

.changeset/quick-geckos-unite.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@clerk/clerk-js': minor
3+
---
4+
5+
Display a UI prompt while Clerk is running in Keyless mode.

packages/clerk-js/bundlewatch.config.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
{ "path": "./dist/userprofile*.js", "maxSize": "15KB" },
1818
{ "path": "./dist/userverification*.js", "maxSize": "5KB" },
1919
{ "path": "./dist/onetap*.js", "maxSize": "1KB" },
20-
{ "path": "./dist/waitlist*.js", "maxSize": "1.3KB" }
20+
{ "path": "./dist/waitlist*.js", "maxSize": "1.3KB" },
21+
{ "path": "./dist/keylessPrompt*.js", "maxSize": "4.5KB" }
2122
]
2223
}

packages/clerk-js/jest.setup.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ if (typeof window !== 'undefined') {
3535

3636
global.__PKG_NAME__ = '';
3737
global.__PKG_VERSION__ = '';
38-
global.__BUILD_FLAG_KEYLESS_UI__ = '';
3938
global.BUILD_ENABLE_NEW_COMPONENTS = '';
4039

4140
//@ts-expect-error

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

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1915,9 +1915,7 @@ export class Clerk implements ClerkInterface {
19151915
void this.#captchaHeartbeat.start();
19161916
this.#clearClerkQueryParams();
19171917
this.#handleImpersonationFab();
1918-
if (__BUILD_FLAG_KEYLESS_UI__) {
1919-
this.#handleKeylessPrompt();
1920-
}
1918+
this.#handleKeylessPrompt();
19211919
return true;
19221920
};
19231921

@@ -2048,18 +2046,16 @@ export class Clerk implements ClerkInterface {
20482046
};
20492047

20502048
#handleKeylessPrompt = () => {
2051-
if (__BUILD_FLAG_KEYLESS_UI__) {
2052-
void this.#componentControls?.ensureMounted().then(controls => {
2053-
if (this.#options.__internal_claimKeylessApplicationUrl) {
2054-
controls.updateProps({
2055-
options: {
2056-
__internal_claimKeylessApplicationUrl: this.#options.__internal_claimKeylessApplicationUrl,
2057-
__internal_copyInstanceKeysUrl: this.#options.__internal_copyInstanceKeysUrl,
2058-
},
2059-
});
2060-
}
2061-
});
2062-
}
2049+
void this.#componentControls?.ensureMounted().then(controls => {
2050+
if (this.#options.__internal_claimKeylessApplicationUrl) {
2051+
controls.updateProps({
2052+
options: {
2053+
__internal_claimKeylessApplicationUrl: this.#options.__internal_claimKeylessApplicationUrl,
2054+
__internal_copyInstanceKeysUrl: this.#options.__internal_copyInstanceKeysUrl,
2055+
},
2056+
});
2057+
}
2058+
});
20632059
};
20642060

20652061
#buildUrl = (

packages/clerk-js/src/globals.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ declare global {
55
/**
66
* Build time feature flags.
77
*/
8-
const __BUILD_FLAG_KEYLESS_UI__: boolean;
98
const __BUILD_DISABLE_RHC__: string;
109

1110
interface Window {

packages/clerk-js/src/ui/Components.tsx

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -517,17 +517,14 @@ const Components = (props: ComponentsProps) => {
517517
</LazyImpersonationFabProvider>
518518
)}
519519

520-
{__BUILD_FLAG_KEYLESS_UI__
521-
? state.options?.__internal_claimKeylessApplicationUrl &&
522-
state.options?.__internal_copyInstanceKeysUrl && (
523-
<LazyImpersonationFabProvider globalAppearance={state.appearance}>
524-
<KeylessPrompt
525-
claimUrl={state.options.__internal_claimKeylessApplicationUrl}
526-
copyKeysUrl={state.options.__internal_copyInstanceKeysUrl}
527-
/>
528-
</LazyImpersonationFabProvider>
529-
)
530-
: null}
520+
{state.options?.__internal_claimKeylessApplicationUrl && state.options?.__internal_copyInstanceKeysUrl && (
521+
<LazyImpersonationFabProvider globalAppearance={state.appearance}>
522+
<KeylessPrompt
523+
claimUrl={state.options.__internal_claimKeylessApplicationUrl}
524+
copyKeysUrl={state.options.__internal_copyInstanceKeysUrl}
525+
/>
526+
</LazyImpersonationFabProvider>
527+
)}
531528

532529
<Suspense>{state.organizationSwitcherPrefetch && <OrganizationSwitcherPrefetch />}</Suspense>
533530
</LazyProviders>

packages/clerk-js/src/ui/lazyModules/components.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ const componentImportPaths = {
1616
BlankCaptchaModal: () => import(/* webpackChunkName: "blankcaptcha" */ './../components/BlankCaptchaModal'),
1717
UserVerification: () => import(/* webpackChunkName: "userverification" */ './../components/UserVerification'),
1818
Waitlist: () => import(/* webpackChunkName: "waitlist" */ './../components/Waitlist'),
19-
KeylessPrompt: __BUILD_FLAG_KEYLESS_UI__
20-
? () => import(/* webpackChunkName: "keylessPrompt" */ '../components/KeylessPrompt')
21-
: () => null,
19+
KeylessPrompt: () => import(/* webpackChunkName: "keylessPrompt" */ '../components/KeylessPrompt'),
2220
} as const;
2321

2422
export const SignIn = lazy(() => componentImportPaths.SignIn().then(module => ({ default: module.SignIn })));
@@ -86,10 +84,9 @@ export const BlankCaptchaModal = lazy(() =>
8684
export const ImpersonationFab = lazy(() =>
8785
componentImportPaths.ImpersonationFab().then(module => ({ default: module.ImpersonationFab })),
8886
);
89-
export const KeylessPrompt = __BUILD_FLAG_KEYLESS_UI__
90-
? // @ts-expect-error Types are broken due to __BUILD_FLAG_KEYLESS_UI__
91-
lazy(() => componentImportPaths.KeylessPrompt().then(module => ({ default: module.KeylessPrompt })))
92-
: () => null;
87+
export const KeylessPrompt = lazy(() =>
88+
componentImportPaths.KeylessPrompt().then(module => ({ default: module.KeylessPrompt })),
89+
);
9390

9491
export const preloadComponent = async (component: unknown) => {
9592
return componentImportPaths[component as keyof typeof componentImportPaths]?.();

0 commit comments

Comments
 (0)