Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .changeset/nice-seas-vue-nuxt-oauth-consent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
"@clerk/nuxt": minor
"@clerk/vue": minor
---

Expose `OAuthConsent` as a public component export for Vue and Nuxt.

Example:

```vue
<script setup lang="ts">
import { OAuthConsent } from '@clerk/vue';
</script>
<template>
<OAuthConsent />
</template>
```
15 changes: 15 additions & 0 deletions .changeset/small-planets-astro-oauth-consent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
"@clerk/astro": minor
---

Expose `OAuthConsent` as a public component export for Astro.

Example:

```astro
---
import { OAuthConsent } from '@clerk/astro/components';
---
<OAuthConsent />
```
13 changes: 13 additions & 0 deletions .changeset/three-rabbits-react-oauth-consent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
"@clerk/clerk-js": minor
"@clerk/nextjs": minor
"@clerk/react": minor
"@clerk/react-router": minor
"@clerk/shared": minor
"@clerk/tanstack-react-start": minor
"@clerk/ui": minor
---

Expose `OAuthConsent` as a public component export across React-based SDKs.

Also expose `useOAuthConsent()` as a public hook where supported.
1 change: 1 addition & 0 deletions packages/astro/src/astro-components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ export { default as OrganizationList } from './interactive/OrganizationList.astr
export { default as CreateOrganization } from './interactive/CreateOrganization.astro';
export { default as GoogleOneTap } from './interactive/GoogleOneTap.astro';
export { default as Waitlist } from './interactive/Waitlist.astro';
export { default as OAuthConsent } from './interactive/OAuthConsent.astro';
export { default as PricingTable } from './interactive/PricingTable.astro';
export { default as APIKeys } from './interactive/APIKeys.astro';
11 changes: 11 additions & 0 deletions packages/astro/src/astro-components/interactive/OAuthConsent.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
import type { OAuthConsentProps } from '@clerk/shared/types';
type Props = OAuthConsentProps;
import InternalUIComponentRenderer from './InternalUIComponentRenderer.astro';
---

<InternalUIComponentRenderer
{...Astro.props}
component='oauth-consent'
/>
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const mountAllClerkAstroJSComponents = () => {
waitlist: 'mountWaitlist',
'pricing-table': 'mountPricingTable',
'api-keys': 'mountAPIKeys',
'oauth-consent': 'mountOAuthConsent',
} as const satisfies Record<InternalUIComponentId, keyof Clerk>;

Object.entries(mountFns).forEach(([category, mountFn]) => {
Expand Down
11 changes: 11 additions & 0 deletions packages/astro/src/react/uiComponents.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type {
GoogleOneTapProps,
OAuthConsentProps,
OrganizationListProps,
OrganizationProfileProps,
OrganizationSwitcherProps,
Expand Down Expand Up @@ -196,3 +197,13 @@ export const PricingTable = withClerk(({ clerk, ...props }: WithClerkProp<Pricin
/>
);
}, 'PricingTable');

export const OAuthConsent = withClerk(({ clerk, ...props }: WithClerkProp<OAuthConsentProps>) => {
return (
<Portal
mount={clerk?.mountOAuthConsent}
unmount={clerk?.unmountOAuthConsent}
props={props}
/>
);
}, 'OAuthConsent');
3 changes: 2 additions & 1 deletion packages/astro/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,5 @@ export type InternalUIComponentId =
| 'google-one-tap'
| 'waitlist'
| 'pricing-table'
| 'api-keys';
| 'api-keys'
| 'oauth-consent';
2 changes: 1 addition & 1 deletion packages/clerk-js/sandbox/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ void (async () => {
description: scope === 'offline_access' ? null : `Grants access to your ${scope}`,
requires_consent: true,
}));
Clerk.__internal_mountOAuthConsent(
Clerk.mountOAuthConsent(
app,
componentControls.oauthConsent.getProps() ?? {
scopes,
Expand Down
19 changes: 17 additions & 2 deletions packages/clerk-js/src/core/clerk.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { inBrowser as inClientSide, isValidBrowserOnline } from '@clerk/shared/browser';

Check failure on line 1 in packages/clerk-js/src/core/clerk.ts

View workflow job for this annotation

GitHub Actions / Static analysis

Run autofix to sort these imports!
import { clerkEvents, createClerkEventBus } from '@clerk/shared/clerkEventBus';
import {
ClerkOfflineError,
Expand Down Expand Up @@ -58,6 +58,7 @@
__internal_CheckoutProps,
__internal_EnableOrganizationsPromptProps,
__internal_OAuthConsentProps,
OAuthConsentProps,
__internal_PlanDetailsProps,
__internal_SubscriptionDetailsProps,
__internal_UserVerificationModalProps,
Expand Down Expand Up @@ -1348,7 +1349,7 @@
void this.#clerkUI?.then(ui => ui.ensureMounted()).then(controls => controls.unmountComponent({ node }));
};

public __internal_mountOAuthConsent = (node: HTMLDivElement, props?: __internal_OAuthConsentProps) => {
public mountOAuthConsent = (node: HTMLDivElement, props?: OAuthConsentProps) => {
if (noUserExists(this)) {
if (this.#instanceType === 'development') {
throw new ClerkRuntimeError(warnings.cannotRenderOAuthConsentComponentWhenUserDoesNotExist, {
Expand All @@ -1372,10 +1373,24 @@
);
};

public __internal_unmountOAuthConsent = (node: HTMLDivElement) => {
public unmountOAuthConsent = (node: HTMLDivElement) => {
void this.#clerkUI?.then(ui => ui.ensureMounted()).then(controls => controls.unmountComponent({ node }));
};

/**
* @deprecated Use mountOAuthConsent instead.
*/
public __internal_mountOAuthConsent = (node: HTMLDivElement, props?: __internal_OAuthConsentProps) => {
return this.mountOAuthConsent(node, props);
};

/**
* @deprecated Use unmountOAuthConsent instead.
*/
public __internal_unmountOAuthConsent = (node: HTMLDivElement) => {
return this.unmountOAuthConsent(node);
};

/**
* Mount an API keys component at the target element.
* @param targetNode Target to mount the APIKeys component.
Expand Down
1 change: 1 addition & 0 deletions packages/nextjs/src/client-boundary/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export {
useAuth,
useClerk,
useEmailLink,
useOAuthConsent,
useOrganization,
useOrganizationList,
useOrganizationCreationDefaults,
Expand Down
5 changes: 2 additions & 3 deletions packages/nextjs/src/client-boundary/uiComponents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export {
APIKeys,
CreateOrganization,
GoogleOneTap,
HandleSSOCallback,
OAuthConsent,
OrganizationList,
OrganizationSwitcher,
PricingTable,
Expand All @@ -28,11 +30,8 @@ export {
UserAvatar,
UserButton,
Waitlist,
HandleSSOCallback,
} from '@clerk/react';

export { OAuthConsent } from '@clerk/react/internal';

// The assignment of UserProfile with BaseUserProfile props is used
// to support the CustomPage functionality (eg UserProfile.Page)
// Also the `typeof BaseUserProfile` is used to resolve the following error:
Expand Down
2 changes: 2 additions & 0 deletions packages/nextjs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export {
APIKeys,
CreateOrganization,
GoogleOneTap,
OAuthConsent,
OrganizationList,
OrganizationProfile,
OrganizationSwitcher,
Expand Down Expand Up @@ -52,6 +53,7 @@ export {
useAuth,
useClerk,
useEmailLink,
useOAuthConsent,
useOrganization,
useOrganizationCreationDefaults,
useOrganizationList,
Expand Down
17 changes: 15 additions & 2 deletions packages/nextjs/src/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@
* These need to be explicitly listed. Do not use an * here.
* If you do, app router will break.
*/
import { OAuthConsent as OAuthConsentOriginal } from './client-boundary/uiComponents';
import { useOAuthConsent as useOAuthConsentOriginal } from '@clerk/shared/react';

export { MultisessionAppSupport } from './client-boundary/controlComponents';
export { OAuthConsent } from './client-boundary/uiComponents';
export { useOAuthConsent } from '@clerk/shared/react';

/**
* @deprecated Import `OAuthConsent` from `@clerk/nextjs` instead.
*/
const OAuthConsent = OAuthConsentOriginal;
export { OAuthConsent };

/**
* @deprecated Import `useOAuthConsent` from `@clerk/nextjs` instead.
*/
const useOAuthConsent = useOAuthConsentOriginal;
export { useOAuthConsent };
1 change: 1 addition & 0 deletions packages/nuxt/src/runtime/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export {
UserButton,
OrganizationSwitcher,
GoogleOneTap,
OAuthConsent,
Waitlist,
// Control components
ClerkLoaded,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ exports[`root public exports > should not change unexpectedly 1`] = `
"CreateOrganization",
"GoogleOneTap",
"HandleSSOCallback",
"OAuthConsent",
"OrganizationList",
"OrganizationProfile",
"OrganizationSwitcher",
Expand Down Expand Up @@ -61,6 +62,7 @@ exports[`root public exports > should not change unexpectedly 1`] = `
"useAuth",
"useClerk",
"useEmailLink",
"useOAuthConsent",
"useOrganization",
"useOrganizationCreationDefaults",
"useOrganizationList",
Expand Down
14 changes: 13 additions & 1 deletion packages/react-router/src/internal.ts
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
export { useOAuthConsent, OAuthConsent } from '@clerk/react/internal';
import { OAuthConsent as OAuthConsentOriginal, useOAuthConsent as useOAuthConsentOriginal } from '@clerk/react';

/**
* @deprecated Import `OAuthConsent` from `@clerk/react-router` instead.
*/
const OAuthConsent = OAuthConsentOriginal;
export { OAuthConsent };

/**
* @deprecated Import `useOAuthConsent` from `@clerk/react-router` instead.
*/
const useOAuthConsent = useOAuthConsentOriginal;
export { useOAuthConsent };
1 change: 1 addition & 0 deletions packages/react/src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export {
APIKeys,
CreateOrganization,
GoogleOneTap,
OAuthConsent,
OrganizationList,
OrganizationProfile,
OrganizationSwitcher,
Expand Down
1 change: 1 addition & 0 deletions packages/react/src/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export {
useSession,
useReverification,
useAPIKeys,
useOAuthConsent,
__experimental_useCheckout,
__experimental_CheckoutProvider,
__experimental_usePaymentElement,
Expand Down
17 changes: 15 additions & 2 deletions packages/react/src/internal.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
import { useOAuthConsent as useOAuthConsentOriginal } from '@clerk/shared/react';
import type { InternalClerkScriptProps } from '@clerk/shared/types';
import type { Ui } from '@clerk/ui/internal';
import type React from 'react';

import { OAuthConsent as OAuthConsentOriginal } from './components/uiComponents';
import { ClerkProvider } from './contexts/ClerkProvider';
import type { ClerkProviderProps } from './types';

export { publishableKeyFromHost } from '@clerk/shared/keys';
export { setErrorThrowerOptions } from './errors/errorThrower';
export { MultisessionAppSupport } from './components/controlComponents';
export { useOAuthConsent } from '@clerk/shared/react';
export { OAuthConsent } from './components/uiComponents';

/**
* @deprecated Import `useOAuthConsent` from `@clerk/react` instead.
*/
const useOAuthConsent = useOAuthConsentOriginal;
export { useOAuthConsent };

/**
* @deprecated Import `OAuthConsent` from `@clerk/react` instead.
*/
const OAuthConsent = OAuthConsentOriginal;
export { OAuthConsent };

export { useRoutingProps } from './hooks/useRoutingProps';
export { useDerivedAuth } from './hooks/useAuth';
export { IS_REACT_SHARED_VARIANT_COMPATIBLE } from './utils/versionCheck';
Expand Down
9 changes: 9 additions & 0 deletions packages/react/src/isomorphicClerk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type {
__internal_CheckoutProps,
__internal_EnableOrganizationsPromptProps,
__internal_OAuthConsentProps,
OAuthConsentProps,
__internal_PlanDetailsProps,
__internal_SubscriptionDetailsProps,
__internal_UserVerificationModalProps,
Expand Down Expand Up @@ -1298,6 +1299,14 @@ export class IsomorphicClerk implements IsomorphicLoadedClerk {
}
};

mountOAuthConsent = (node: HTMLDivElement, props?: OAuthConsentProps) => {
this.__internal_mountOAuthConsent(node, props);
};

unmountOAuthConsent = (node: HTMLDivElement) => {
this.__internal_unmountOAuthConsent(node);
};
Comment on lines +1302 to +1308
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE="packages/react/src/isomorphicClerk.ts"

# Verify newly added methods currently omit explicit return types
rg -n "mountOAuthConsent\\s*=\\s*\\(node: HTMLDivElement, props\\?: OAuthConsentProps\\)\\s*=>" "$FILE"
rg -n "unmountOAuthConsent\\s*=\\s*\\(node: HTMLDivElement\\)\\s*=>" "$FILE"

# Compare with existing explicit-void public mount/unmount methods in same file
rg -n "mountAPIKeys\\s*=\\s*\\(node: HTMLDivElement, props\\?: APIKeysProps\\): void" "$FILE"
rg -n "unmountAPIKeys\\s*=\\s*\\(node: HTMLDivElement\\): void" "$FILE"

Repository: clerk/javascript

Length of output: 403


Add explicit return type annotations to the new public OAuth consent methods.

Lines 1302 and 1306 introduce public API methods without explicit return type annotations. Declare : void to match existing methods in the same file (mountAPIKeys, unmountAPIKeys) and comply with the guideline requiring explicit return types for public APIs.

Proposed fix
-  mountOAuthConsent = (node: HTMLDivElement, props?: OAuthConsentProps) => {
+  mountOAuthConsent = (node: HTMLDivElement, props?: OAuthConsentProps): void => {
     this.__internal_mountOAuthConsent(node, props);
   };

-  unmountOAuthConsent = (node: HTMLDivElement) => {
+  unmountOAuthConsent = (node: HTMLDivElement): void => {
     this.__internal_unmountOAuthConsent(node);
   };
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
mountOAuthConsent = (node: HTMLDivElement, props?: OAuthConsentProps) => {
this.__internal_mountOAuthConsent(node, props);
};
unmountOAuthConsent = (node: HTMLDivElement) => {
this.__internal_unmountOAuthConsent(node);
};
mountOAuthConsent = (node: HTMLDivElement, props?: OAuthConsentProps): void => {
this.__internal_mountOAuthConsent(node, props);
};
unmountOAuthConsent = (node: HTMLDivElement): void => {
this.__internal_unmountOAuthConsent(node);
};
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/react/src/isomorphicClerk.ts` around lines 1302 - 1308, The new
public methods mountOAuthConsent and unmountOAuthConsent lack explicit return
types; update their signatures to include ": void" (e.g., change
mountOAuthConsent = (node: HTMLDivElement, props?: OAuthConsentProps) => { ... }
to declare a void return and similarly for unmountOAuthConsent) to match
existing public methods like mountAPIKeys and unmountAPIKeys and satisfy the
public API return-type guideline.


mountTaskChooseOrganization = (node: HTMLDivElement, props?: TaskChooseOrganizationProps): void => {
if (this.clerkjs && this.loaded) {
this.clerkjs.mountTaskChooseOrganization(node, props);
Expand Down
20 changes: 19 additions & 1 deletion packages/shared/src/types/clerk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,21 @@ export interface Clerk {
*/
__internal_unmountOAuthConsent: (targetNode: HTMLDivElement) => void;

/**
* Mounts a OAuth consent component at the target element.
*
* @param targetNode - Target node to mount the OAuth consent component.
* @param oauthConsentProps - OAuth consent configuration parameters.
*/
mountOAuthConsent: (targetNode: HTMLDivElement, oauthConsentProps?: OAuthConsentProps) => void;

/**
* Unmounts a OAuth consent component from the target element.
*
* @param targetNode - Target node to unmount the OAuth consent component from.
*/
unmountOAuthConsent: (targetNode: HTMLDivElement) => void;

/**
* Mounts a TaskChooseOrganization component at the target element.
*
Expand Down Expand Up @@ -2265,7 +2280,7 @@ export type __experimental_SubscriptionDetailsButtonProps = {
};
};

export type __internal_OAuthConsentProps = {
export type OAuthConsentProps = {
/**
* Customize the appearance of the component.
*/
Expand Down Expand Up @@ -2328,6 +2343,9 @@ export type __internal_OAuthConsentProps = {
onDeny?: () => void;
};

/** @deprecated Use OAuthConsentProps instead. */
export type __internal_OAuthConsentProps = OAuthConsentProps;

export interface HandleEmailLinkVerificationParams {
/**
* Full URL or path to navigate to after successful magic link verification
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ exports[`root public exports > should not change unexpectedly 1`] = `
"CreateOrganization",
"GoogleOneTap",
"HandleSSOCallback",
"OAuthConsent",
"OrganizationList",
"OrganizationProfile",
"OrganizationSwitcher",
Expand Down Expand Up @@ -67,6 +68,7 @@ exports[`root public exports > should not change unexpectedly 1`] = `
"useAuth",
"useClerk",
"useEmailLink",
"useOAuthConsent",
"useOrganization",
"useOrganizationCreationDefaults",
"useOrganizationList",
Expand Down
Loading
Loading