Skip to content
Draft
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
7 changes: 7 additions & 0 deletions .changeset/mosaic-oauth-consent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@clerk/shared': patch
'@clerk/ui': patch
'@clerk/mosaic': patch
---

Move the OAuth consent redirect domain helper into `@clerk/shared` so it can be shared across UI packages. No behavior change.
9 changes: 9 additions & 0 deletions packages/mosaic/src/__tests__/feature/fake-fapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type {
ClientJSON,
EmailAddressJSON,
EnterpriseConnectionJSON,
OAuthConsentInfoJSON,
OAuthProvider,
OrganizationInvitationJSON,
OrganizationJSON,
Expand Down Expand Up @@ -82,6 +83,8 @@ export interface FakeFapiState {
mfa: FakeMfaState;
activeDevices?: ActiveDeviceRecord[];
deviceTrackingEnabled: boolean;
oauthConsent?: OAuthConsentInfoJSON;
oauthConsentRequests: URL[];
}

export interface ActiveDeviceRecord extends SessionWithActivitiesJSON {
Expand Down Expand Up @@ -318,6 +321,7 @@ export function serveFapi(seed: FakeFapiSeed = {}): FakeFapiState {
passwordUpdates: [],
enterpriseConnections: [],
deviceTrackingEnabled: true,
oauthConsentRequests: [],
mfa: createMfaState(),
...rest,
verification: createVerificationState(verification),
Expand Down Expand Up @@ -843,6 +847,11 @@ export function serveFapi(seed: FakeFapiSeed = {}): FakeFapiState {
state.apiKeys = state.apiKeys.map(k => (k.id === revoked.id ? revoked : k));
return HttpResponse.json(revoked);
}),
http.get(fapiUrl('/v1/me/oauth/consent/:clientId'), ({ request, params }) => {
state.oauthConsentRequests.push(new URL(request.url));
const consent = state.oauthConsent;
return consent?.client_id === params.clientId ? envelope(consent, null) : missing();
}),
);

return state;
Expand Down
17 changes: 17 additions & 0 deletions packages/mosaic/src/__tests__/feature/fapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import type {
EnterpriseConnectionJSON,
EnvironmentJSON,
ExternalAccountJSON,
OAuthConsentInfoJSON,
OAuthProviders,
OrganizationJSON,
OrganizationMembershipJSON,
Expand Down Expand Up @@ -592,6 +593,22 @@ export function fapiApiKey(overrides: Partial<ApiKeyJSON> & Pick<ApiKeyJSON, 'id
};
}

export function fapiOAuthConsentInfo(
overrides: Partial<OAuthConsentInfoJSON> & Pick<OAuthConsentInfoJSON, 'client_id'>,
): OAuthConsentInfoJSON {
return {
object: 'oauth_consent_info',
id: overrides.client_id,
oauth_application_name: 'Linear',
oauth_application_logo_url: '',
oauth_application_url: 'https://linear.app',
state: '',
redirect_domain: null,
scopes: [],
...overrides,
};
}

export function fapiPage<T>(data: T[], totalCount = data.length): FapiPage<T> {
return { data, total_count: totalCount };
}
Expand Down
Loading
Loading