Skip to content

Commit 35b2aa9

Browse files
authored
Merge branch 'main' into jacek/fix-core3-oauth-retry
2 parents d2d1a49 + 7a5892f commit 35b2aa9

7 files changed

Lines changed: 59 additions & 24 deletions

File tree

.changeset/dry-mice-begin.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@clerk/backend": patch
3+
"@clerk/shared": patch
4+
---
5+
6+
Fix OAuth consent component and hook related types.

.typedoc/custom-plugin.mjs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ const FILES_WITHOUT_HEADINGS = [
3636
'payment-element-props.mdx',
3737
'use-organization-creation-defaults-return.mdx',
3838
'use-organization-creation-defaults-params.mdx',
39+
'use-o-auth-consent-params.mdx',
40+
'use-o-auth-consent-return.mdx',
3941
];
4042

4143
/**
@@ -66,6 +68,8 @@ const LINK_REPLACEMENTS = [
6668
['organization-domain-resource', '/docs/reference/types/organization-domain-resource'],
6769
['organization-invitation-resource', '/docs/reference/types/organization-invitation'],
6870
['organization-membership-request-resource', '/docs/reference/types/organization-membership-request'],
71+
['o-auth-consent-info', '/docs/reference/types/oauth-consent-info'],
72+
['o-auth-consent-scope', '/docs/reference/types/oauth-consent-scope'],
6973
['session', '/docs/reference/backend/types/backend-session'],
7074
['session-activity', '/docs/reference/backend/types/backend-session-activity'],
7175
['organization', '/docs/reference/backend/types/backend-organization'],
@@ -76,6 +80,9 @@ const LINK_REPLACEMENTS = [
7680
['email-address', '/docs/reference/backend/types/backend-email-address'],
7781
['enterprise-account', '/docs/reference/backend/types/backend-enterprise-account'],
7882
['enterprise-account-connection', '/docs/reference/backend/types/backend-enterprise-account-connection'],
83+
['enterprise-connection', '/docs/reference/backend/types/backend-enterprise-connection'],
84+
['enterprise-connection-oauth-config', '/docs/reference/backend/types/backend-enterprise-connection-oauth-config'],
85+
['enterprise-connection-saml-connection', '/docs/reference/backend/types/backend-enterprise-connection-saml-connection'],
7986
['external-account', '/docs/reference/backend/types/backend-external-account'],
8087
['phone-number', '/docs/reference/backend/types/backend-phone-number'],
8188
['saml-account', '/docs/reference/backend/types/backend-saml-account'],
@@ -101,6 +108,7 @@ const LINK_REPLACEMENTS = [
101108
['billing-statement-resource', '/docs/reference/types/billing-statement-resource'],
102109
['billing-subscription-resource', '/docs/reference/types/billing-subscription-resource'],
103110
['clerk-api-response-error', '/docs/reference/types/clerk-api-response-error'],
111+
['clerk-api-error', '/docs/reference/types/clerk-api-error'],
104112
['billing-statement-totals', '/docs/reference/types/billing-statement-totals'],
105113
['billing-payment-resource', '/docs/reference/types/billing-payment-resource'],
106114
['deleted-object-resource', '/docs/reference/types/deleted-object-resource'],
@@ -134,6 +142,10 @@ function getRelativeLinkReplacements() {
134142

135143
function getCatchAllReplacements() {
136144
return [
145+
{
146+
pattern: /(?<![`[\]])\bClerkAPIResponseError\b(?![\]\(])/g,
147+
replace: '[ClerkAPIResponseError](/docs/reference/types/clerk-api-response-error)',
148+
},
137149
{
138150
pattern: /(?<![\[\w`])`Appearance`\\<`Theme`\\>/g,
139151
replace: '[`Appearance<Theme>`](/docs/guides/customizing-clerk/appearance-prop/overview)',

packages/backend/src/api/resources/EnterpriseAccount.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { EnterpriseAccountConnectionJSON, EnterpriseAccountJSON } from './J
22
import { Verification } from './Verification';
33

44
/**
5-
* Represents an enterprise SSO connection associated with an enterprise account.
5+
* The Backend `EnterpriseAccountConnection` object represents an enterprise SSO connection associated with an enterprise account.
66
*/
77
export class EnterpriseAccountConnection {
88
constructor(

packages/backend/src/api/resources/EnterpriseConnection.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import type {
44
EnterpriseConnectionSamlConnectionJSON,
55
} from './JSON';
66

7+
/**
8+
* The Backend `EnterpriseConnectionSamlConnection` object holds information about a SAML enterprise connection for an instance or organization.
9+
*/
710
export class EnterpriseConnectionSamlConnection {
811
constructor(
912
/**

packages/shared/src/react/hooks/useOAuthConsent.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ const HOOK_NAME = 'useOAuthConsent';
1414
* (`GET /me/oauth/consent/{oauthClientId}`). Ensure the user is authenticated before relying on this hook
1515
* (for example, redirect to sign-in on your custom consent route).
1616
*
17-
* The hook is a pure data fetcher: it takes an explicit `oauthClientId` and optional `scope` and
18-
* issues the fetch when both the user is signed in and `oauthClientId` is non-empty. The query is
19-
* disabled when `oauthClientId` is empty or omitted.
20-
*
21-
* @internal
22-
*
2317
* @example
2418
* ```tsx
2519
* import { useOAuthConsent } from '@clerk/react/internal'
@@ -30,7 +24,7 @@ const HOOK_NAME = 'useOAuthConsent';
3024
* })
3125
* ```
3226
*/
33-
export function useOAuthConsent(params: UseOAuthConsentParams = {}): UseOAuthConsentReturn {
27+
export function useOAuthConsent(params: UseOAuthConsentParams): UseOAuthConsentReturn {
3428
useAssertWrappedByClerkProvider(HOOK_NAME);
3529

3630
const { oauthClientId: oauthClientIdParam, scope, keepPreviousData = true, enabled = true } = params;

packages/shared/src/react/hooks/useOAuthConsent.types.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,9 @@ import type { ClerkAPIResponseError } from '../../errors/clerkApiResponseError';
22
import type { GetOAuthConsentInfoParams, OAuthConsentInfo } from '../../types';
33

44
/**
5-
* Options for {@link useOAuthConsent}.
6-
*
7-
* Pass `oauthClientId` and `scope` explicitly. The hook does not read from `window.location` or
8-
* any other ambient source. The hook is disabled when `oauthClientId` is empty or omitted.
9-
*
10-
* @internal
11-
*
125
* @interface
136
*/
14-
export type UseOAuthConsentParams = Partial<Pick<GetOAuthConsentInfoParams, 'oauthClientId' | 'scope'>> & {
7+
export type UseOAuthConsentParams = Pick<GetOAuthConsentInfoParams, 'oauthClientId' | 'scope'> & {
158
/**
169
* If `true`, the previous data will be kept in the cache until new data is fetched.
1710
*
@@ -27,14 +20,11 @@ export type UseOAuthConsentParams = Partial<Pick<GetOAuthConsentInfoParams, 'oau
2720
};
2821

2922
/**
30-
* @internal
31-
*
3223
* @interface
3324
*/
3425
export type UseOAuthConsentReturn = {
3526
/**
36-
* OAuth consent screen metadata from Clerk, or `undefined` before the first successful fetch.
37-
* Additional fields (e.g. submission helpers) may be added in the future without renaming this hook.
27+
* The OAuth consent screen metadata returned by Clerk, or `undefined` before the first successful fetch.
3828
*/
3929
data: OAuthConsentInfo | undefined;
4030
/**

packages/shared/src/types/oauthApplication.ts

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,30 +24,60 @@ export interface OAuthConsentInfoJSON extends ClerkResourceJSON {
2424

2525
/**
2626
* A single OAuth scope with its description and whether it requires consent.
27+
*
28+
* @interface
2729
*/
2830
export type OAuthConsentScope = {
31+
/**
32+
* The name of the scope, as defined by the OAuth application.
33+
*/
2934
scope: string;
35+
/**
36+
* The description of the scope, which can be shown to users on the consent screen. This may be `null` if no description is available.
37+
*/
3038
description: string | null;
39+
/**
40+
* Whether or not this scope requires explicit user consent. If `false`, the scope is considered "safe" and can be granted without showing the consent screen to the user.
41+
*/
3142
requiresConsent: boolean;
3243
};
3344

3445
/**
35-
* OAuth consent screen metadata from `GET /v1/me/oauth/consent/{oauthClientId}`.
36-
* Includes information needed to populate the consent dialog.
46+
* An interface representing OAuth consent information, including application details and requested scopes.
47+
*
48+
* @interface
3749
*/
3850
export type OAuthConsentInfo = {
51+
/**
52+
* The display name of the OAuth application requesting access.
53+
*/
3954
oauthApplicationName: string;
55+
/**
56+
* The URL of the OAuth application's logo image.
57+
*/
4058
oauthApplicationLogoUrl: string;
59+
/**
60+
* The homepage URL of the OAuth application.
61+
*/
4162
oauthApplicationUrl: string;
63+
/**
64+
* The OAuth `client_id` identifying the application.
65+
*/
4266
clientId: string;
67+
/**
68+
* The `state` parameter from the original authorize request.
69+
*/
4370
state: string;
71+
/**
72+
* A list of scopes the application is requesting, with descriptions and consent requirements.
73+
*/
4474
scopes: OAuthConsentScope[];
4575
};
4676

4777
export type GetOAuthConsentInfoParams = {
48-
/** OAuth `client_id` from the authorize request. */
78+
/** The OAuth `client_id` from the authorize request. The hook is disabled when this value is empty or omitted. */
4979
oauthClientId: string;
50-
/** Optional space-delimited scope string from the authorize request. */
80+
/** A space-delimited scope string from the authorize request. */
5181
scope?: string;
5282
};
5383

0 commit comments

Comments
 (0)