@@ -5,7 +5,7 @@ import type {
55 ClerkPaginatedResponse ,
66 CreateEmailAddressParams ,
77 CreateExternalAccountParams ,
8- CreateMeEnterpriseConnectionParams ,
8+ CreateOrganizationEnterpriseConnectionParams ,
99 CreatePhoneNumberParams ,
1010 CreateWeb3WalletParams ,
1111 DeletedObjectJSON ,
@@ -34,7 +34,7 @@ import type {
3434 SetProfileImageParams ,
3535 TOTPJSON ,
3636 TOTPResource ,
37- UpdateMeEnterpriseConnectionParams ,
37+ UpdateOrganizationEnterpriseConnectionParams ,
3838 UpdateUserMetadataParams ,
3939 UpdateUserParams ,
4040 UpdateUserPasswordParams ,
@@ -47,6 +47,7 @@ import type {
4747
4848import { convertPageToOffsetSearchParams } from '../../utils/convertPageToOffsetSearchParams' ;
4949import { unixEpochToDate } from '../../utils/date' ;
50+ import { toEnterpriseConnectionBody } from '../../utils/enterpriseConnection' ;
5051import { normalizeUnsafeMetadata } from '../../utils/resourceParams' ;
5152import { eventBus , events } from '../events' ;
5253import { addPaymentMethod , getPaymentMethods , initializePaymentMethod } from '../modules/billing' ;
@@ -336,13 +337,13 @@ export class User extends BaseResource implements UserResource {
336337 } ;
337338
338339 createEnterpriseConnection = async (
339- params : CreateMeEnterpriseConnectionParams ,
340+ params : CreateOrganizationEnterpriseConnectionParams ,
340341 ) : Promise < EnterpriseConnectionResource > => {
341342 const json = (
342343 await BaseResource . _fetch < EnterpriseConnectionJSON > ( {
343344 path : `${ this . path ( ) } /enterprise_connections` ,
344345 method : 'POST' ,
345- body : toMeEnterpriseConnectionBody ( params ) as any ,
346+ body : toEnterpriseConnectionBody ( params ) as any ,
346347 } )
347348 ) ?. response as unknown as EnterpriseConnectionJSON ;
348349
@@ -351,13 +352,13 @@ export class User extends BaseResource implements UserResource {
351352
352353 updateEnterpriseConnection = async (
353354 enterpriseConnectionId : string ,
354- params : UpdateMeEnterpriseConnectionParams ,
355+ params : UpdateOrganizationEnterpriseConnectionParams ,
355356 ) : Promise < EnterpriseConnectionResource > => {
356357 const json = (
357358 await BaseResource . _fetch < EnterpriseConnectionJSON > ( {
358359 path : `${ this . path ( ) } /enterprise_connections/${ enterpriseConnectionId } ` ,
359360 method : 'PATCH' ,
360- body : toMeEnterpriseConnectionBody ( params ) as any ,
361+ body : toEnterpriseConnectionBody ( params ) as any ,
361362 } )
362363 ) ?. response as unknown as EnterpriseConnectionJSON ;
363364
@@ -553,69 +554,3 @@ export class User extends BaseResource implements UserResource {
553554 } ;
554555 }
555556}
556-
557- /**
558- * Serializes `CreateMeEnterpriseConnectionParams` / `UpdateMeEnterpriseConnectionParams`
559- * for the `/me/enterprise_connections` FAPI endpoints.
560- *
561- * The handler expects a flat form body where SAML and OIDC fields are
562- * prefixed (e.g. `saml_idp_metadata_url`, `oidc_client_id`) rather
563- * than nested under `saml`/`oidc` objects. `attribute_mapping` and
564- * `custom_attributes` stay as object values and are JSON-stringified
565- * by the form serializer downstream — their inner keys are
566- * user-supplied data and must not be camel→snake transformed.
567- */
568- function toMeEnterpriseConnectionBody (
569- params : CreateMeEnterpriseConnectionParams | UpdateMeEnterpriseConnectionParams ,
570- ) : Record < string , unknown > {
571- const body : Record < string , unknown > = { } ;
572-
573- // Top-level fields. `provider` is only on Create, the rest are shared
574- setIfDefined ( body , 'provider' , ( params as CreateMeEnterpriseConnectionParams ) . provider ) ;
575- setIfDefined ( body , 'name' , params . name ) ;
576- setIfDefined ( body , 'organization_id' , params . organizationId ) ;
577- setIfDefined ( body , 'active' , ( params as UpdateMeEnterpriseConnectionParams ) . active ) ;
578- setIfDefined ( body , 'sync_user_attributes' , ( params as UpdateMeEnterpriseConnectionParams ) . syncUserAttributes ) ;
579- setIfDefined (
580- body ,
581- 'disable_additional_identifications' ,
582- ( params as UpdateMeEnterpriseConnectionParams ) . disableAdditionalIdentifications ,
583- ) ;
584- setIfDefined ( body , 'custom_attributes' , ( params as UpdateMeEnterpriseConnectionParams ) . customAttributes ) ;
585-
586- if ( params . saml ) {
587- setIfDefined ( body , 'saml_idp_entity_id' , params . saml . idpEntityId ) ;
588- setIfDefined ( body , 'saml_idp_sso_url' , params . saml . idpSsoUrl ) ;
589- setIfDefined ( body , 'saml_idp_certificate' , params . saml . idpCertificate ) ;
590- setIfDefined ( body , 'saml_idp_metadata_url' , params . saml . idpMetadataUrl ) ;
591- setIfDefined ( body , 'saml_idp_metadata' , params . saml . idpMetadata ) ;
592- setIfDefined ( body , 'saml_attribute_mapping' , params . saml . attributeMapping ) ;
593- setIfDefined ( body , 'saml_allow_subdomains' , params . saml . allowSubdomains ) ;
594- setIfDefined ( body , 'saml_allow_idp_initiated' , params . saml . allowIdpInitiated ) ;
595- setIfDefined ( body , 'saml_force_authn' , params . saml . forceAuthn ) ;
596- }
597-
598- if ( params . oidc ) {
599- setIfDefined ( body , 'oidc_client_id' , params . oidc . clientId ) ;
600- setIfDefined ( body , 'oidc_client_secret' , params . oidc . clientSecret ) ;
601- setIfDefined ( body , 'oidc_discovery_url' , params . oidc . discoveryUrl ) ;
602- setIfDefined ( body , 'oidc_auth_url' , params . oidc . authUrl ) ;
603- setIfDefined ( body , 'oidc_token_url' , params . oidc . tokenUrl ) ;
604- setIfDefined ( body , 'oidc_user_info_url' , params . oidc . userInfoUrl ) ;
605- setIfDefined ( body , 'oidc_requires_pkce' , params . oidc . requiresPkce ) ;
606- }
607-
608- return body ;
609- }
610-
611- /**
612- * Adds `value` under `key` only when the caller actually provided it.
613- * Mirrors the SDK's existing semantics: `undefined` means "don't send
614- * this field"; `null` is forwarded so users can explicitly clear a
615- * value via the form-encoded body
616- */
617- function setIfDefined ( target : Record < string , unknown > , key : string , value : unknown ) : void {
618- if ( value !== undefined ) {
619- target [ key ] = value ;
620- }
621- }
0 commit comments