Skip to content

Commit 244920d

Browse files
wobsorianoalexcarpenterjacekradko
authored
chore(clerk-js,ui): Make OAuthConsent component public (#8381)
Co-authored-by: Alex Carpenter <alex.carpenter@clerk.dev> Co-authored-by: Jacek Radko <jacek@clerk.dev>
1 parent 59400e3 commit 244920d

31 files changed

Lines changed: 194 additions & 32 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
"@clerk/nuxt": minor
3+
"@clerk/vue": minor
4+
---
5+
6+
Expose `OAuthConsent` as a public component export for Vue and Nuxt.
7+
8+
Example:
9+
10+
```vue
11+
<script setup lang="ts">
12+
import { OAuthConsent } from '@clerk/vue';
13+
</script>
14+
15+
<template>
16+
<OAuthConsent />
17+
</template>
18+
```
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
"@clerk/astro": minor
3+
---
4+
5+
Expose `OAuthConsent` as a public component export for Astro.
6+
7+
Example:
8+
9+
```astro
10+
---
11+
import { OAuthConsent } from '@clerk/astro/components';
12+
---
13+
14+
<OAuthConsent />
15+
```
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
"@clerk/clerk-js": minor
3+
"@clerk/nextjs": minor
4+
"@clerk/react": minor
5+
"@clerk/react-router": minor
6+
"@clerk/shared": minor
7+
"@clerk/tanstack-react-start": minor
8+
"@clerk/ui": minor
9+
---
10+
11+
Expose `OAuthConsent` as a public component export across React-based SDKs.
12+
13+
Example:
14+
15+
```tsx
16+
import { OAuthConsent } from '@clerk/react';
17+
18+
export default function Page() {
19+
return <OAuthConsent />;
20+
}
21+
```

packages/astro/src/astro-components/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,6 @@ export { default as OrganizationList } from './interactive/OrganizationList.astr
2828
export { default as CreateOrganization } from './interactive/CreateOrganization.astro';
2929
export { default as GoogleOneTap } from './interactive/GoogleOneTap.astro';
3030
export { default as Waitlist } from './interactive/Waitlist.astro';
31+
export { default as OAuthConsent } from './interactive/OAuthConsent.astro';
3132
export { default as PricingTable } from './interactive/PricingTable.astro';
3233
export { default as APIKeys } from './interactive/APIKeys.astro';
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
import type { OAuthConsentProps } from '@clerk/shared/types';
3+
type Props = OAuthConsentProps;
4+
5+
import InternalUIComponentRenderer from './InternalUIComponentRenderer.astro';
6+
---
7+
8+
<InternalUIComponentRenderer
9+
{...Astro.props}
10+
component='oauth-consent'
11+
/>

packages/astro/src/internal/mount-clerk-astro-js-components.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const mountAllClerkAstroJSComponents = () => {
2121
waitlist: 'mountWaitlist',
2222
'pricing-table': 'mountPricingTable',
2323
'api-keys': 'mountAPIKeys',
24+
'oauth-consent': 'mountOAuthConsent',
2425
} as const satisfies Record<InternalUIComponentId, keyof Clerk>;
2526

2627
Object.entries(mountFns).forEach(([category, mountFn]) => {

packages/astro/src/react/uiComponents.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type {
22
GoogleOneTapProps,
3+
OAuthConsentProps,
34
OrganizationListProps,
45
OrganizationProfileProps,
56
OrganizationSwitcherProps,
@@ -196,3 +197,13 @@ export const PricingTable = withClerk(({ clerk, ...props }: WithClerkProp<Pricin
196197
/>
197198
);
198199
}, 'PricingTable');
200+
201+
export const OAuthConsent = withClerk(({ clerk, ...props }: WithClerkProp<OAuthConsentProps>) => {
202+
return (
203+
<Portal
204+
mount={clerk?.mountOAuthConsent}
205+
unmount={clerk?.unmountOAuthConsent}
206+
props={props}
207+
/>
208+
);
209+
}, 'OAuthConsent');

packages/astro/src/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,4 +119,5 @@ export type InternalUIComponentId =
119119
| 'google-one-tap'
120120
| 'waitlist'
121121
| 'pricing-table'
122-
| 'api-keys';
122+
| 'api-keys'
123+
| 'oauth-consent';

packages/clerk-js/sandbox/app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ void (async () => {
475475
description: scope === 'offline_access' ? null : `Grants access to your ${scope}`,
476476
requires_consent: true,
477477
}));
478-
Clerk.__internal_mountOAuthConsent(
478+
Clerk.mountOAuthConsent(
479479
app,
480480
componentControls.oauthConsent.getProps() ?? {
481481
scopes,

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

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ import type {
9595
LoadedClerk,
9696
NavigateOptions,
9797
OAuthApplicationNamespace,
98+
OAuthConsentProps,
9899
OrganizationListProps,
99100
OrganizationProfileProps,
100101
OrganizationResource,
@@ -1348,7 +1349,7 @@ export class Clerk implements ClerkInterface {
13481349
void this.#clerkUI?.then(ui => ui.ensureMounted()).then(controls => controls.unmountComponent({ node }));
13491350
};
13501351

1351-
public __internal_mountOAuthConsent = (node: HTMLDivElement, props?: __internal_OAuthConsentProps) => {
1352+
public mountOAuthConsent = (node: HTMLDivElement, props?: OAuthConsentProps) => {
13521353
if (noUserExists(this)) {
13531354
if (this.#instanceType === 'development') {
13541355
throw new ClerkRuntimeError(warnings.cannotRenderOAuthConsentComponentWhenUserDoesNotExist, {
@@ -1372,10 +1373,24 @@ export class Clerk implements ClerkInterface {
13721373
);
13731374
};
13741375

1375-
public __internal_unmountOAuthConsent = (node: HTMLDivElement) => {
1376+
public unmountOAuthConsent = (node: HTMLDivElement) => {
13761377
void this.#clerkUI?.then(ui => ui.ensureMounted()).then(controls => controls.unmountComponent({ node }));
13771378
};
13781379

1380+
/**
1381+
* @deprecated Use mountOAuthConsent instead.
1382+
*/
1383+
public __internal_mountOAuthConsent = (node: HTMLDivElement, props?: __internal_OAuthConsentProps) => {
1384+
return this.mountOAuthConsent(node, props);
1385+
};
1386+
1387+
/**
1388+
* @deprecated Use unmountOAuthConsent instead.
1389+
*/
1390+
public __internal_unmountOAuthConsent = (node: HTMLDivElement) => {
1391+
return this.unmountOAuthConsent(node);
1392+
};
1393+
13791394
/**
13801395
* Mount an API keys component at the target element.
13811396
* @param targetNode Target to mount the APIKeys component.

0 commit comments

Comments
 (0)