@@ -20,6 +20,8 @@ import type {
2020 __internal_OAuthConsentProps ,
2121 __internal_PlanDetailsProps ,
2222 __internal_UserVerificationModalProps ,
23+ APIKeysNamespace ,
24+ APIKeysProps ,
2325 AuthenticateWithCoinbaseWalletParams ,
2426 AuthenticateWithGoogleOneTapParams ,
2527 AuthenticateWithMetamaskParams ,
@@ -88,6 +90,7 @@ import {
8890 createAllowedRedirectOrigins ,
8991 createBeforeUnloadTracker ,
9092 createPageLifecycle ,
93+ disabledAPIKeysFeature ,
9194 disabledBillingFeature ,
9295 disabledOrganizationsFeature ,
9396 errorThrower ,
@@ -132,6 +135,7 @@ import { eventBus, events } from './events';
132135import type { FapiClient , FapiRequestCallback } from './fapiClient' ;
133136import { createFapiClient } from './fapiClient' ;
134137import { createClientFromJwt } from './jwt-client' ;
138+ import { APIKeys } from './modules/apiKeys' ;
135139import { CommerceBilling } from './modules/commerce' ;
136140import {
137141 BaseResource ,
@@ -163,6 +167,7 @@ const CANNOT_RENDER_USER_MISSING_ERROR_CODE = 'cannot_render_user_missing';
163167const CANNOT_RENDER_ORGANIZATIONS_DISABLED_ERROR_CODE = 'cannot_render_organizations_disabled' ;
164168const CANNOT_RENDER_ORGANIZATION_MISSING_ERROR_CODE = 'cannot_render_organization_missing' ;
165169const CANNOT_RENDER_SINGLE_SESSION_ENABLED_ERROR_CODE = 'cannot_render_single_session_enabled' ;
170+ const CANNOT_RENDER_API_KEYS_DISABLED_ERROR_CODE = 'cannot_render_api_keys_disabled' ;
166171const defaultOptions : ClerkOptions = {
167172 polling : true ,
168173 standardBrowser : true ,
@@ -189,6 +194,7 @@ export class Clerk implements ClerkInterface {
189194 environment : process . env . NODE_ENV || 'production' ,
190195 } ;
191196 private static _billing : CommerceBillingNamespace ;
197+ private static _apiKeys : APIKeysNamespace ;
192198
193199 public client : ClientResource | undefined ;
194200 public session : SignedInSessionResource | null | undefined ;
@@ -324,6 +330,13 @@ export class Clerk implements ClerkInterface {
324330 return Clerk . _billing ;
325331 }
326332
333+ get apiKeys ( ) : APIKeysNamespace {
334+ if ( ! Clerk . _apiKeys ) {
335+ Clerk . _apiKeys = new APIKeys ( ) ;
336+ }
337+ return Clerk . _apiKeys ;
338+ }
339+
327340 public __internal_getOption < K extends keyof ClerkOptions > ( key : K ) : ClerkOptions [ K ] {
328341 return this . #options[ key ] ;
329342 }
@@ -1055,6 +1068,53 @@ export class Clerk implements ClerkInterface {
10551068 void this . #componentControls. ensureMounted ( ) . then ( controls => controls . unmountComponent ( { node } ) ) ;
10561069 } ;
10571070
1071+ /**
1072+ * @experimental
1073+ * This API is in early access and may change in future releases.
1074+ *
1075+ * Mount a api keys component at the target element.
1076+ * @param targetNode Target to mount the APIKeys component.
1077+ * @param props Configuration parameters.
1078+ */
1079+ public mountApiKeys = ( node : HTMLDivElement , props ?: APIKeysProps ) => {
1080+ this . assertComponentsReady ( this . #componentControls) ;
1081+
1082+ logger . warnOnce ( 'Clerk: <APIKeys /> component is in early access and not yet recommended for production use.' ) ;
1083+
1084+ if ( disabledAPIKeysFeature ( this , this . environment ) ) {
1085+ if ( this . #instanceType === 'development' ) {
1086+ throw new ClerkRuntimeError ( warnings . cannotRenderAPIKeysComponent , {
1087+ code : CANNOT_RENDER_API_KEYS_DISABLED_ERROR_CODE ,
1088+ } ) ;
1089+ }
1090+ return ;
1091+ }
1092+ void this . #componentControls. ensureMounted ( { preloadHint : 'APIKeys' } ) . then ( controls =>
1093+ controls . mountComponent ( {
1094+ name : 'APIKeys' ,
1095+ appearanceKey : 'apiKeys' ,
1096+ node,
1097+ props,
1098+ } ) ,
1099+ ) ;
1100+
1101+ this . telemetry ?. record ( eventPrebuiltComponentMounted ( 'APIKeys' , props ) ) ;
1102+ } ;
1103+
1104+ /**
1105+ * @experimental
1106+ * This API is in early access and may change in future releases.
1107+ *
1108+ * Unmount a api keys component from the target element.
1109+ * If there is no component mounted at the target node, results in a noop.
1110+ *
1111+ * @param targetNode Target node to unmount the ApiKeys component from.
1112+ */
1113+ public unmountApiKeys = ( node : HTMLDivElement ) => {
1114+ this . assertComponentsReady ( this . #componentControls) ;
1115+ void this . #componentControls. ensureMounted ( ) . then ( controls => controls . unmountComponent ( { node } ) ) ;
1116+ } ;
1117+
10581118 /**
10591119 * `setActive` can be used to set the active session and/or organization.
10601120 */
0 commit comments