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
7 changes: 7 additions & 0 deletions .changeset/brown-bags-fold.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@clerk/clerk-js": minor
"@clerk/clerk-react": minor
"@clerk/shared": minor
---

Standardized API keys naming convention
2 changes: 1 addition & 1 deletion packages/clerk-js/sandbox/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ void (async () => {
Clerk.mountPricingTable(app, componentControls.pricingTable.getProps() ?? {});
},
'/api-keys': () => {
Clerk.mountApiKeys(app, componentControls.apiKeys.getProps() ?? {});
Clerk.mountAPIKeys(app, componentControls.apiKeys.getProps() ?? {});
},
'/oauth-consent': () => {
const searchParams = new URLSearchParams(window.location.search);
Expand Down
4 changes: 2 additions & 2 deletions packages/clerk-js/src/core/clerk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1230,7 +1230,7 @@ export class Clerk implements ClerkInterface {
* @param targetNode Target to mount the APIKeys component.
* @param props Configuration parameters.
*/
public mountApiKeys = (node: HTMLDivElement, props?: APIKeysProps) => {
public mountAPIKeys = (node: HTMLDivElement, props?: APIKeysProps) => {
this.assertComponentsReady(this.#componentControls);

logger.warnOnce('Clerk: <APIKeys /> component is in early access and not yet recommended for production use.');
Expand Down Expand Up @@ -1282,7 +1282,7 @@ export class Clerk implements ClerkInterface {
*
* @param targetNode Target node to unmount the ApiKeys component from.
*/
public unmountApiKeys = (node: HTMLDivElement) => {
public unmountAPIKeys = (node: HTMLDivElement) => {
this.assertComponentsReady(this.#componentControls);
void this.#componentControls.ensureMounted().then(controls => controls.unmountComponent({ node }));
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ export const APIKeysPage = ({ subject, perPage, revokeModalRoot }: APIKeysPagePr
} = useSWRMutation('api-keys-create', (_key, { arg }: { arg: CreateAPIKeyParams }) => clerk.apiKeys.create(arg));
const { t } = useLocalizations();
const [isRevokeModalOpen, setIsRevokeModalOpen] = useState(false);
const [selectedApiKeyId, setSelectedApiKeyId] = useState('');
const [selectedApiKeyName, setSelectedApiKeyName] = useState('');
const [selectedAPIKeyID, setSelectedAPIKeyID] = useState('');
const [selectedAPIKeyName, setSelectedAPIKeyName] = useState('');
const [isCopyModalOpen, setIsCopyModalOpen] = useState(false);

const handleCreateAPIKey = async (params: OnCreateParams) => {
Expand All @@ -123,9 +123,9 @@ export const APIKeysPage = ({ subject, perPage, revokeModalRoot }: APIKeysPagePr
}
};

const handleRevoke = (apiKeyId: string, apiKeyName: string) => {
setSelectedApiKeyId(apiKeyId);
setSelectedApiKeyName(apiKeyName);
const handleRevoke = (apiKeyID: string, apiKeyName: string) => {
setSelectedAPIKeyID(apiKeyID);
setSelectedAPIKeyName(apiKeyName);
setIsRevokeModalOpen(true);
};

Expand Down Expand Up @@ -220,12 +220,12 @@ export const APIKeysPage = ({ subject, perPage, revokeModalRoot }: APIKeysPagePr
isOpen={isRevokeModalOpen}
onOpen={() => setIsRevokeModalOpen(true)}
onClose={() => {
setSelectedApiKeyId('');
setSelectedApiKeyName('');
setSelectedAPIKeyID('');
setSelectedAPIKeyName('');
setIsRevokeModalOpen(false);
}}
apiKeyId={selectedApiKeyId}
apiKeyName={selectedApiKeyName}
apiKeyID={selectedAPIKeyID}
apiKeyName={selectedAPIKeyName}
onRevokeSuccess={invalidateAll}
modalRoot={revokeModalRoot}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type RevokeAPIKeyConfirmationModalProps = {
isOpen: boolean;
onOpen: () => void;
onClose: () => void;
apiKeyId?: string;
apiKeyID?: string;
apiKeyName: string;
onRevokeSuccess?: () => void;
modalRoot?: React.MutableRefObject<HTMLElement | null>;
Expand All @@ -24,7 +24,7 @@ export const RevokeAPIKeyConfirmationModal = ({
isOpen,
onOpen,
onClose,
apiKeyId,
apiKeyID,
apiKeyName,
onRevokeSuccess,
modalRoot,
Expand All @@ -48,11 +48,11 @@ export const RevokeAPIKeyConfirmationModal = ({

const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
if (!apiKeyId || !canSubmit) {
if (!apiKeyID || !canSubmit) {
return;
}

await clerk.apiKeys.revoke({ apiKeyID: apiKeyId });
await clerk.apiKeys.revoke({ apiKeyID: apiKeyID });
onRevokeSuccess?.();
handleClose();
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { describe, expect, it, vi } from 'vitest';
import { bindCreateFixtures } from '@/test/create-fixtures';
import { render, waitFor } from '@/test/utils';

import { APIKeys } from '../ApiKeys';
import { APIKeys } from '../APIKeys';

const { createFixtures } = bindCreateFixtures('APIKeys');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Col, localizationKeys } from '@/ui/customizables';
import { Header } from '@/ui/elements/Header';
import { useUnsafeNavbarContext } from '@/ui/elements/Navbar';

import { APIKeysPage } from '../ApiKeys/ApiKeys';
import { APIKeysPage } from '../APIKeys/APIKeys';

export const OrganizationAPIKeysPage = () => {
const { organization } = useOrganization();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const OrganizationBillingPage = lazy(() =>
);

const OrganizationAPIKeysPage = lazy(() =>
import(/* webpackChunkName: "op-api-keys-page"*/ './OrganizationApiKeysPage').then(module => ({
import(/* webpackChunkName: "op-api-keys-page"*/ './OrganizationAPIKeysPage').then(module => ({
default: module.OrganizationAPIKeysPage,
})),
);
Expand Down Expand Up @@ -43,10 +43,11 @@ export const OrganizationProfileRoutes = () => {
isMembersPageRoot,
isGeneralPageRoot,
isBillingPageRoot,
isApiKeysPageRoot,
isAPIKeysPageRoot,
shouldShowBilling,
apiKeysProps,
} = useOrganizationProfileContext();

const { apiKeysSettings, commerceSettings } = useEnvironment();

const customPageRoutesWithContents = pages.contents?.map((customPage, index) => {
Expand Down Expand Up @@ -130,7 +131,7 @@ export const OrganizationProfileRoutes = () => {
has({ permission: 'org:sys_api_keys:read' }) || has({ permission: 'org:sys_api_keys:manage' })
}
>
<Route path={isApiKeysPageRoot ? undefined : 'organization-api-keys'}>
<Route path={isAPIKeysPageRoot ? undefined : 'organization-api-keys'}>
<Switch>
<Route index>
<Suspense fallback={''}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Col, descriptors, localizationKeys } from '@/ui/customizables';
import { Header } from '@/ui/elements/Header';
import { useUnsafeNavbarContext } from '@/ui/elements/Navbar';

import { APIKeysPage as APIKeysPageInternal } from '../ApiKeys/ApiKeys';
import { APIKeysPage as APIKeysPageInternal } from '../APIKeys/APIKeys';

export const APIKeysPage = () => {
const { user } = useUser();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const BillingPage = lazy(() =>
);

const APIKeysPage = lazy(() =>
import(/* webpackChunkName: "up-api-keys-page"*/ './ApiKeysPage').then(module => ({
import(/* webpackChunkName: "up-api-keys-page"*/ './APIKeysPage').then(module => ({
default: module.APIKeysPage,
})),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export type OrganizationProfileContextType = OrganizationProfileCtx & {
isMembersPageRoot: boolean;
isGeneralPageRoot: boolean;
isBillingPageRoot: boolean;
isApiKeysPageRoot: boolean;
isAPIKeysPageRoot: boolean;
shouldShowBilling: boolean;
};

Expand Down Expand Up @@ -67,7 +67,7 @@ export const useOrganizationProfileContext = (): OrganizationProfileContextType
const isMembersPageRoot = pages.routes[0].id === ORGANIZATION_PROFILE_NAVBAR_ROUTE_ID.MEMBERS;
const isGeneralPageRoot = pages.routes[0].id === ORGANIZATION_PROFILE_NAVBAR_ROUTE_ID.GENERAL;
const isBillingPageRoot = pages.routes[0].id === ORGANIZATION_PROFILE_NAVBAR_ROUTE_ID.BILLING;
const isApiKeysPageRoot = pages.routes[0].id === ORGANIZATION_PROFILE_NAVBAR_ROUTE_ID.API_KEYS;
const isAPIKeysPageRoot = pages.routes[0].id === ORGANIZATION_PROFILE_NAVBAR_ROUTE_ID.API_KEYS;
const navigateToGeneralPageRoot = () =>
navigate(isGeneralPageRoot ? '../' : isMembersPageRoot ? './organization-general' : '../organization-general');

Expand All @@ -80,7 +80,7 @@ export const useOrganizationProfileContext = (): OrganizationProfileContextType
isMembersPageRoot,
isGeneralPageRoot,
isBillingPageRoot,
isApiKeysPageRoot,
isAPIKeysPageRoot,
shouldShowBilling,
};
};
2 changes: 1 addition & 1 deletion packages/clerk-js/src/ui/contexts/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export * from './ApiKeys';
export * from './APIKeys';
export * from './Checkout';
export * from './CreateOrganization';
export * from './GoogleOneTap';
Expand Down
2 changes: 1 addition & 1 deletion packages/clerk-js/src/ui/lazyModules/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const componentImportPaths = {
import(/* webpackChunkName: "taskChooseOrganization" */ '../components/SessionTasks/tasks/TaskChooseOrganization'),
PlanDetails: () => import(/* webpackChunkName: "planDetails" */ '../components/Plans/PlanDetails'),
SubscriptionDetails: () => import(/* webpackChunkName: "subscriptionDetails" */ '../components/SubscriptionDetails'),
APIKeys: () => import(/* webpackChunkName: "apiKeys" */ '../components/ApiKeys/ApiKeys'),
APIKeys: () => import(/* webpackChunkName: "apiKeys" */ '../components/APIKeys/APIKeys'),
OAuthConsent: () => import(/* webpackChunkName: "oauthConsent" */ '../components/OAuthConsent/OAuthConsent'),
} as const;

Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/components/uiComponents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -628,8 +628,8 @@ export const APIKeys = withClerk(
{clerk.loaded && (
<ClerkHostRenderer
component={component}
mount={clerk.mountApiKeys}
unmount={clerk.unmountApiKeys}
mount={clerk.mountAPIKeys}
unmount={clerk.unmountAPIKeys}
updateProps={(clerk as any).__unstable__updateProps}
props={props}
rootProps={rendererRootProps}
Expand Down
18 changes: 9 additions & 9 deletions packages/react/src/isomorphicClerk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export class IsomorphicClerk implements IsomorphicLoadedClerk {
private premountMethodCalls = new Map<MethodName<BrowserClerk>, MethodCallback>();
private premountWaitlistNodes = new Map<HTMLDivElement, WaitlistProps | undefined>();
private premountPricingTableNodes = new Map<HTMLDivElement, PricingTableProps | undefined>();
private premountApiKeysNodes = new Map<HTMLDivElement, APIKeysProps | undefined>();
private premountAPIKeysNodes = new Map<HTMLDivElement, APIKeysProps | undefined>();
private premountOAuthConsentNodes = new Map<HTMLDivElement, __internal_OAuthConsentProps | undefined>();
private premountTaskChooseOrganizationNodes = new Map<HTMLDivElement, TaskChooseOrganizationProps | undefined>();

Expand Down Expand Up @@ -656,8 +656,8 @@ export class IsomorphicClerk implements IsomorphicLoadedClerk {
clerkjs.mountPricingTable(node, props);
});

this.premountApiKeysNodes.forEach((props, node) => {
clerkjs.mountApiKeys(node, props);
this.premountAPIKeysNodes.forEach((props, node) => {
clerkjs.mountAPIKeys(node, props);
});

this.premountOAuthConsentNodes.forEach((props, node) => {
Expand Down Expand Up @@ -1146,19 +1146,19 @@ export class IsomorphicClerk implements IsomorphicLoadedClerk {
}
};

mountApiKeys = (node: HTMLDivElement, props?: APIKeysProps): void => {
mountAPIKeys = (node: HTMLDivElement, props?: APIKeysProps): void => {
if (this.clerkjs && this.loaded) {
this.clerkjs.mountApiKeys(node, props);
this.clerkjs.mountAPIKeys(node, props);
} else {
this.premountApiKeysNodes.set(node, props);
this.premountAPIKeysNodes.set(node, props);
}
};

unmountApiKeys = (node: HTMLDivElement): void => {
unmountAPIKeys = (node: HTMLDivElement): void => {
if (this.clerkjs && this.loaded) {
this.clerkjs.unmountApiKeys(node);
this.clerkjs.unmountAPIKeys(node);
} else {
this.premountApiKeysNodes.delete(node);
this.premountAPIKeysNodes.delete(node);
}
};

Expand Down
2 changes: 1 addition & 1 deletion packages/shared/src/react/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export { assertContextExists, createContextAndHook } from './createContextAndHook';
export { useApiKeys as __experimental_useAPIKeys } from './useAPIKeys';
export { useAPIKeys as __experimental_useAPIKeys } from './useAPIKeys';
export { useOrganization } from './useOrganization';
export { useOrganizationList } from './useOrganizationList';
export { useSafeLayoutEffect } from './useSafeLayoutEffect';
Expand Down
22 changes: 11 additions & 11 deletions packages/shared/src/react/hooks/useAPIKeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { usePagesOrInfinite, useWithSafeValues } from './usePagesOrInfinite';
/**
* @interface
*/
export type UseApiKeysParams = PaginatedHookConfig<
export type UseAPIKeysParams = PaginatedHookConfig<
GetAPIKeysParams & {
/**
* If `true`, a request will be triggered when the hook is mounted.
Expand All @@ -23,19 +23,19 @@ export type UseApiKeysParams = PaginatedHookConfig<
/**
* @interface
*/
export type UseApiKeysReturn<T extends UseApiKeysParams> = PaginatedResources<
export type UseAPIKeysReturn<T extends UseAPIKeysParams> = PaginatedResources<
APIKeyResource,
T extends { infinite: true } ? true : false
>;

/**
* The `useApiKeys()` hook provides access to paginated API keys for the current user or organization.
* The `useAPIKeys()` hook provides access to paginated API keys for the current user or organization.
*
* @example
* ### Basic usage with default pagination
*
* ```tsx
* const { data, isLoading, page, pageCount, fetchNext, fetchPrevious } = useApiKeys({
* const { data, isLoading, page, pageCount, fetchNext, fetchPrevious } = useAPIKeys({
* subject: 'user_123',
* pageSize: 10,
* initialPage: 1,
Expand All @@ -49,7 +49,7 @@ export type UseApiKeysReturn<T extends UseApiKeysParams> = PaginatedResources<
* const [searchValue, setSearchValue] = useState('');
* const debouncedSearch = useDebounce(searchValue, 500);
*
* const { data, isLoading } = useApiKeys({
* const { data, isLoading } = useAPIKeys({
* subject: 'user_123',
* query: debouncedSearch.trim(),
* pageSize: 10,
Expand All @@ -60,14 +60,14 @@ export type UseApiKeysReturn<T extends UseApiKeysParams> = PaginatedResources<
* ### Infinite scroll
*
* ```tsx
* const { data, isLoading, fetchNext, hasNextPage } = useApiKeys({
* const { data, isLoading, fetchNext, hasNextPage } = useAPIKeys({
* subject: 'user_123',
* infinite: true,
* });
* ```
*/
export function useApiKeys<T extends UseApiKeysParams>(params?: T): UseApiKeysReturn<T> {
useAssertWrappedByClerkProvider('useApiKeys');
export function useAPIKeys<T extends UseAPIKeysParams>(params?: T): UseAPIKeysReturn<T> {
useAssertWrappedByClerkProvider('useAPIKeys');

const safeValues = useWithSafeValues(params, {
initialPage: 1,
Expand All @@ -77,11 +77,11 @@ export function useApiKeys<T extends UseApiKeysParams>(params?: T): UseApiKeysRe
subject: '',
query: '',
enabled: true,
} as UseApiKeysParams);
} as UseAPIKeysParams);

const clerk = useClerkInstanceContext();

clerk.telemetry?.record(eventMethodCalled('useApiKeys'));
clerk.telemetry?.record(eventMethodCalled('useAPIKeys'));

const hookParams: GetAPIKeysParams = {
initialPage: safeValues.initialPage,
Expand All @@ -104,5 +104,5 @@ export function useApiKeys<T extends UseApiKeysParams>(params?: T): UseApiKeysRe
type: 'apiKeys',
subject: safeValues.subject || '',
},
) as UseApiKeysReturn<T>;
) as UseAPIKeysReturn<T>;
}
4 changes: 2 additions & 2 deletions packages/shared/src/types/clerk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ export interface Clerk {
* @param targetNode - Target to mount the APIKeys component.
* @param props - Configuration parameters.
*/
mountApiKeys: (targetNode: HTMLDivElement, props?: APIKeysProps) => void;
mountAPIKeys: (targetNode: HTMLDivElement, props?: APIKeysProps) => void;

/**
* This API is in early access and may change in future releases.
Expand All @@ -595,7 +595,7 @@ export interface Clerk {
*
* @param targetNode - Target node to unmount the ApiKeys component from.
*/
unmountApiKeys: (targetNode: HTMLDivElement) => void;
unmountAPIKeys: (targetNode: HTMLDivElement) => void;

/**
* Mounts a OAuth consent component at the target element.
Expand Down
Loading