From d3364c0e1337d1be9642f6fae752f46a30d192c9 Mon Sep 17 00:00:00 2001 From: johnny Date: Thu, 19 Feb 2026 16:39:35 +0200 Subject: [PATCH 01/10] expose underlying axios client --- src/client.ts | 2 ++ src/client.types.ts | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/src/client.ts b/src/client.ts index 5a8038b..f653231 100644 --- a/src/client.ts +++ b/src/client.ts @@ -144,6 +144,7 @@ export function createClient(config: CreateClientConfig): Base44Client { ); const userModules = { + axiosClient, entities: createEntitiesModule({ axios: axiosClient, appId, @@ -176,6 +177,7 @@ export function createClient(config: CreateClientConfig): Base44Client { }; const serviceRoleModules = { + axiosClient: serviceRoleAxiosClient, entities: createEntitiesModule({ axios: serviceRoleAxiosClient, appId, diff --git a/src/client.types.ts b/src/client.types.ts index d5a83df..f731a65 100644 --- a/src/client.types.ts +++ b/src/client.types.ts @@ -1,3 +1,4 @@ +import type { AxiosInstance } from "axios"; import type { EntitiesModule } from "./modules/entities.types.js"; import type { IntegrationsModule } from "./modules/integrations.types.js"; import type { AuthModule } from "./modules/auth.types.js"; @@ -85,6 +86,8 @@ export interface Base44Client { appLogs: AppLogsModule; /** {@link AuthModule | Auth module} for user authentication and management. */ auth: AuthModule; + /** The underlying Axios instance used for API requests. Useful for making custom API calls with the same authentication and configuration as the SDK. */ + axiosClient: AxiosInstance; /** {@link EntitiesModule | Entities module} for CRUD operations on your data models. */ entities: EntitiesModule; /** {@link FunctionsModule | Functions module} for invoking custom backend functions. */ @@ -119,6 +122,8 @@ export interface Base44Client { readonly asServiceRole: { /** {@link AgentsModule | Agents module} with elevated permissions. */ agents: AgentsModule; + /** The underlying Axios instance used for service role API requests. Useful for making custom API calls with service role authentication. */ + axiosClient: AxiosInstance; /** {@link AppLogsModule | App logs module} with elevated permissions. */ appLogs: AppLogsModule; /** {@link ConnectorsModule | Connectors module} for OAuth token retrieval. */ From 9ec192e5ac8e024aa315191cbedc4b71dfeac777 Mon Sep 17 00:00:00 2001 From: johnny Date: Mon, 23 Feb 2026 15:13:42 +0200 Subject: [PATCH 02/10] connectors initiate method --- src/modules/connectors.ts | 17 +++++++++++++++++ src/modules/connectors.types.ts | 27 +++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/src/modules/connectors.ts b/src/modules/connectors.ts index 5d99a3c..d55bb45 100644 --- a/src/modules/connectors.ts +++ b/src/modules/connectors.ts @@ -2,6 +2,7 @@ import { AxiosInstance } from "axios"; import { ConnectorIntegrationType, ConnectorAccessTokenResponse, + ConnectorInitiateResponse, ConnectorsModule, } from "./connectors.types.js"; @@ -34,5 +35,21 @@ export function createConnectorsModule( // @ts-expect-error return response.access_token; }, + + async initiate( + integrationType: ConnectorIntegrationType + ): Promise { + if (!integrationType || typeof integrationType !== "string") { + throw new Error("Integration type is required and must be a string"); + } + + const response = await axios.post( + `/apps/${appId}/end-user-auth/initiate`, + { integration_type: integrationType } + ); + + // @ts-expect-error + return response.redirect_url; + }, }; } diff --git a/src/modules/connectors.types.ts b/src/modules/connectors.types.ts index 46f9e92..dc60995 100644 --- a/src/modules/connectors.types.ts +++ b/src/modules/connectors.types.ts @@ -24,6 +24,13 @@ export interface ConnectorAccessTokenResponse { access_token: string; } +/** + * Response from the connectors initiate endpoint. + */ +export interface ConnectorInitiateResponse { + redirect_url: string; +} + /** * Connectors module for managing OAuth tokens for external services. * @@ -87,4 +94,24 @@ export interface ConnectorsModule { * ``` */ getAccessToken(integrationType: ConnectorIntegrationType): Promise; + + /** + * Initiates the end-user OAuth flow for a specific external integration type. + * + * Returns a redirect URL that the end user should be redirected to in order to + * authenticate with the external service. + * + * @param integrationType - The type of integration, such as `'googlecalendar'`, `'slack'`, or `'github'`. + * @returns Promise resolving to the redirect URL string. + * + * @example + * ```typescript + * // Initiate Google Calendar OAuth for the end user + * const redirectUrl = await base44.asServiceRole.connectors.initiate('googlecalendar'); + * + * // Redirect the user to the OAuth provider + * res.redirect(redirectUrl); + * ``` + */ + initiate(integrationType: ConnectorIntegrationType): Promise; } From 9bf78d5697663c0defc57dc534b08192c8b5f40f Mon Sep 17 00:00:00 2001 From: johnny Date: Mon, 23 Feb 2026 15:15:12 +0200 Subject: [PATCH 03/10] add the connectors module on the user module --- src/client.ts | 1 + src/client.types.ts | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/client.ts b/src/client.ts index f653231..1a7d83c 100644 --- a/src/client.ts +++ b/src/client.ts @@ -151,6 +151,7 @@ export function createClient(config: CreateClientConfig): Base44Client { getSocket, }), integrations: createIntegrationsModule(axiosClient, appId), + connectors: createConnectorsModule(axiosClient, appId), auth: userAuthModule, functions: createFunctionsModule(functionsAxiosClient, appId), agents: createAgentsModule({ diff --git a/src/client.types.ts b/src/client.types.ts index f731a65..d3da3ff 100644 --- a/src/client.types.ts +++ b/src/client.types.ts @@ -88,6 +88,8 @@ export interface Base44Client { auth: AuthModule; /** The underlying Axios instance used for API requests. Useful for making custom API calls with the same authentication and configuration as the SDK. */ axiosClient: AxiosInstance; + /** {@link ConnectorsModule | Connectors module} for OAuth token retrieval. */ + connectors: ConnectorsModule; /** {@link EntitiesModule | Entities module} for CRUD operations on your data models. */ entities: EntitiesModule; /** {@link FunctionsModule | Functions module} for invoking custom backend functions. */ From 5ef7bb4aa0038d33a0337ca3057cbc47a0cd7f77 Mon Sep 17 00:00:00 2001 From: johnny Date: Thu, 26 Feb 2026 10:41:17 +0200 Subject: [PATCH 04/10] uou connectors - disconnect --- src/modules/connectors.ts | 12 ++++++++++++ src/modules/connectors.types.ts | 17 +++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/src/modules/connectors.ts b/src/modules/connectors.ts index d55bb45..fc07115 100644 --- a/src/modules/connectors.ts +++ b/src/modules/connectors.ts @@ -51,5 +51,17 @@ export function createConnectorsModule( // @ts-expect-error return response.redirect_url; }, + + async disconnect( + integrationType: ConnectorIntegrationType + ): Promise { + if (!integrationType || typeof integrationType !== "string") { + throw new Error("Integration type is required and must be a string"); + } + + await axios.delete( + `/apps/${appId}/end-user-auth/${integrationType}` + ); + }, }; } diff --git a/src/modules/connectors.types.ts b/src/modules/connectors.types.ts index dc60995..3c64cf6 100644 --- a/src/modules/connectors.types.ts +++ b/src/modules/connectors.types.ts @@ -114,4 +114,21 @@ export interface ConnectorsModule { * ``` */ initiate(integrationType: ConnectorIntegrationType): Promise; + + /** + * Disconnects an end-user's OAuth connection for a specific external integration type. + * + * Removes the stored OAuth credentials for the end user's connection to the + * specified external service. + * + * @param integrationType - The type of integration to disconnect, such as `'googlecalendar'`, `'slack'`, or `'github'`. + * @returns Promise resolving when the connection has been removed. + * + * @example + * ```typescript + * // Disconnect Google Calendar for the end user + * await base44.asServiceRole.connectors.disconnect('googlecalendar'); + * ``` + */ + disconnect(integrationType: ConnectorIntegrationType): Promise; } From 5102fc2f9ada4c132754923a06c0df2002079dfc Mon Sep 17 00:00:00 2001 From: johnny Date: Thu, 26 Feb 2026 12:48:03 +0200 Subject: [PATCH 05/10] new public api --- src/client.ts | 7 +++- src/client.types.ts | 9 +++-- src/index.ts | 5 ++- src/modules/connectors.ts | 36 +++++++++++++++++- src/modules/connectors.types.ts | 66 +++++++++++++++++++++++++-------- 5 files changed, 100 insertions(+), 23 deletions(-) diff --git a/src/client.ts b/src/client.ts index 1a7d83c..c630a4e 100644 --- a/src/client.ts +++ b/src/client.ts @@ -3,7 +3,10 @@ import { createEntitiesModule } from "./modules/entities.js"; import { createIntegrationsModule } from "./modules/integrations.js"; import { createAuthModule } from "./modules/auth.js"; import { createSsoModule } from "./modules/sso.js"; -import { createConnectorsModule } from "./modules/connectors.js"; +import { + createConnectorsModule, + createUserConnectorsModule, +} from "./modules/connectors.js"; import { getAccessToken } from "./utils/auth-utils.js"; import { createFunctionsModule } from "./modules/functions.js"; import { createAgentsModule } from "./modules/agents.js"; @@ -151,7 +154,7 @@ export function createClient(config: CreateClientConfig): Base44Client { getSocket, }), integrations: createIntegrationsModule(axiosClient, appId), - connectors: createConnectorsModule(axiosClient, appId), + connectors: createUserConnectorsModule(axiosClient, appId), auth: userAuthModule, functions: createFunctionsModule(functionsAxiosClient, appId), agents: createAgentsModule({ diff --git a/src/client.types.ts b/src/client.types.ts index d3da3ff..2ed94ab 100644 --- a/src/client.types.ts +++ b/src/client.types.ts @@ -3,7 +3,10 @@ import type { EntitiesModule } from "./modules/entities.types.js"; import type { IntegrationsModule } from "./modules/integrations.types.js"; import type { AuthModule } from "./modules/auth.types.js"; import type { SsoModule } from "./modules/sso.types.js"; -import type { ConnectorsModule } from "./modules/connectors.types.js"; +import type { + ConnectorsModule, + UserConnectorsModule, +} from "./modules/connectors.types.js"; import type { FunctionsModule } from "./modules/functions.types.js"; import type { AgentsModule } from "./modules/agents.types.js"; import type { AppLogsModule } from "./modules/app-logs.types.js"; @@ -88,8 +91,8 @@ export interface Base44Client { auth: AuthModule; /** The underlying Axios instance used for API requests. Useful for making custom API calls with the same authentication and configuration as the SDK. */ axiosClient: AxiosInstance; - /** {@link ConnectorsModule | Connectors module} for OAuth token retrieval. */ - connectors: ConnectorsModule; + /** {@link UserConnectorsModule | Connectors module} for end-user OAuth flows. */ + connectors: UserConnectorsModule; /** {@link EntitiesModule | Entities module} for CRUD operations on your data models. */ entities: EntitiesModule; /** {@link FunctionsModule | Functions module} for invoking custom backend functions. */ diff --git a/src/index.ts b/src/index.ts index b95308b..2e2cd33 100644 --- a/src/index.ts +++ b/src/index.ts @@ -100,7 +100,10 @@ export type { AppLogsModule } from "./modules/app-logs.types.js"; export type { SsoModule, SsoAccessTokenResponse } from "./modules/sso.types.js"; -export type { ConnectorsModule } from "./modules/connectors.types.js"; +export type { + ConnectorsModule, + UserConnectorsModule, +} from "./modules/connectors.types.js"; export type { CustomIntegrationsModule, diff --git a/src/modules/connectors.ts b/src/modules/connectors.ts index fc07115..d31b114 100644 --- a/src/modules/connectors.ts +++ b/src/modules/connectors.ts @@ -4,6 +4,7 @@ import { ConnectorAccessTokenResponse, ConnectorInitiateResponse, ConnectorsModule, + UserConnectorsModule, } from "./connectors.types.js"; /** @@ -35,8 +36,39 @@ export function createConnectorsModule( // @ts-expect-error return response.access_token; }, + }; +} + +/** + * Creates the user-scoped Connectors module (end-user OAuth flows). + * + * @param axios - Axios instance (user-scoped client) + * @param appId - Application ID + * @returns User connectors module with end-user OAuth methods + * @internal + */ +export function createUserConnectorsModule( + axios: AxiosInstance, + appId: string +): UserConnectorsModule { + return { + // @ts-expect-error Return type mismatch - implementation returns object, interface expects string + async getEndUserAccessToken( + integrationType: ConnectorIntegrationType + ): Promise { + if (!integrationType || typeof integrationType !== "string") { + throw new Error("Integration type is required and must be a string"); + } + + const response = await axios.get( + `/apps/${appId}/end-user-auth/tokens/${integrationType}` + ); + + // @ts-expect-error + return response.access_token; + }, - async initiate( + async connectEndUser( integrationType: ConnectorIntegrationType ): Promise { if (!integrationType || typeof integrationType !== "string") { @@ -52,7 +84,7 @@ export function createConnectorsModule( return response.redirect_url; }, - async disconnect( + async disconnectEndUser( integrationType: ConnectorIntegrationType ): Promise { if (!integrationType || typeof integrationType !== "string") { diff --git a/src/modules/connectors.types.ts b/src/modules/connectors.types.ts index 3c64cf6..5ac4668 100644 --- a/src/modules/connectors.types.ts +++ b/src/modules/connectors.types.ts @@ -32,7 +32,7 @@ export interface ConnectorInitiateResponse { } /** - * Connectors module for managing OAuth tokens for external services. + * Connectors module for managing app-scoped OAuth tokens for external services. * * This module allows you to retrieve OAuth access tokens for external services that the app has connected to. Connectors are app-scoped. When an app builder connects an integration like Google Calendar or Slack, all users of the app share that same connection. * @@ -41,9 +41,7 @@ export interface ConnectorInitiateResponse { * the API calls you make. This is useful when you need custom API interactions that aren't * covered by Base44's pre-built integrations. * - * ## Authentication Modes - * - * This module is only available to use with a client in service role authentication mode, which means it can only be used in backend environments. + * This module is only available via `base44.asServiceRole.connectors`. * * ## Dynamic Types * @@ -94,11 +92,49 @@ export interface ConnectorsModule { * ``` */ getAccessToken(integrationType: ConnectorIntegrationType): Promise; +} + +/** + * User-scoped connectors module for managing end-user OAuth connections. + * + * This module provides methods for end-user OAuth flows: initiating an OAuth connection, + * retrieving the end user's access token, and disconnecting the end user's connection. + * + * Unlike {@link ConnectorsModule | ConnectorsModule} which manages app-scoped tokens, + * this module manages tokens scoped to individual end users. + * + * Available via `base44.connectors`. + * + * ## Dynamic Types + * + * If you're working in a TypeScript project, you can generate types from your app's connector configurations to get autocomplete on integration type names. See the [Dynamic Types](/developers/references/sdk/getting-started/dynamic-types) guide to get started. + */ +export interface UserConnectorsModule { + /** + * Retrieves an OAuth access token for an end user's connection to a specific external integration. + * + * Returns the OAuth token string that belongs to the currently authenticated end user + * for the specified external service. + * + * @param integrationType - The type of integration, such as `'googlecalendar'`, `'slack'`, or `'github'`. + * @returns Promise resolving to the access token string. + * + * @example + * ```typescript + * // Get the end user's Google Calendar token + * const token = await base44.connectors.getEndUserAccessToken('googlecalendar'); + * + * const response = await fetch('https://www.googleapis.com/calendar/v3/calendars/primary/events', { + * headers: { 'Authorization': `Bearer ${token}` } + * }); + * ``` + */ + getEndUserAccessToken(integrationType: ConnectorIntegrationType): Promise; /** * Initiates the end-user OAuth flow for a specific external integration type. * - * Returns a redirect URL that the end user should be redirected to in order to + * Returns a redirect URL that the end user should be navigated to in order to * authenticate with the external service. * * @param integrationType - The type of integration, such as `'googlecalendar'`, `'slack'`, or `'github'`. @@ -106,29 +142,29 @@ export interface ConnectorsModule { * * @example * ```typescript - * // Initiate Google Calendar OAuth for the end user - * const redirectUrl = await base44.asServiceRole.connectors.initiate('googlecalendar'); + * // Start Google Calendar OAuth for the end user + * const redirectUrl = await base44.connectors.connectEndUser('googlecalendar'); * * // Redirect the user to the OAuth provider - * res.redirect(redirectUrl); + * window.location.href = redirectUrl; * ``` */ - initiate(integrationType: ConnectorIntegrationType): Promise; + connectEndUser(integrationType: ConnectorIntegrationType): Promise; /** - * Disconnects an end-user's OAuth connection for a specific external integration type. + * Disconnects an end user's OAuth connection for a specific external integration type. * - * Removes the stored OAuth credentials for the end user's connection to the - * specified external service. + * Removes the stored OAuth credentials for the currently authenticated end user's + * connection to the specified external service. * * @param integrationType - The type of integration to disconnect, such as `'googlecalendar'`, `'slack'`, or `'github'`. * @returns Promise resolving when the connection has been removed. * * @example * ```typescript - * // Disconnect Google Calendar for the end user - * await base44.asServiceRole.connectors.disconnect('googlecalendar'); + * // Disconnect the end user's Google Calendar connection + * await base44.connectors.disconnectEndUser('googlecalendar'); * ``` */ - disconnect(integrationType: ConnectorIntegrationType): Promise; + disconnectEndUser(integrationType: ConnectorIntegrationType): Promise; } From 53225a6234012383743904104b50a3f985a4e17d Mon Sep 17 00:00:00 2001 From: johnny Date: Sun, 8 Mar 2026 22:10:28 +0200 Subject: [PATCH 06/10] support multiple uou connectors of the same type --- src/modules/connectors.ts | 31 ++++++++++------------- src/modules/connectors.types.ts | 44 ++++++++++++++++----------------- 2 files changed, 34 insertions(+), 41 deletions(-) diff --git a/src/modules/connectors.ts b/src/modules/connectors.ts index d31b114..b3fcb33 100644 --- a/src/modules/connectors.ts +++ b/src/modules/connectors.ts @@ -53,46 +53,41 @@ export function createUserConnectorsModule( ): UserConnectorsModule { return { // @ts-expect-error Return type mismatch - implementation returns object, interface expects string - async getEndUserAccessToken( - integrationType: ConnectorIntegrationType + async getAppUserAccessToken( + connectorId: string ): Promise { - if (!integrationType || typeof integrationType !== "string") { - throw new Error("Integration type is required and must be a string"); + if (!connectorId || typeof connectorId !== "string") { + throw new Error("Connector ID is required and must be a string"); } const response = await axios.get( - `/apps/${appId}/end-user-auth/tokens/${integrationType}` + `/apps/${appId}/end-user-auth/connectors/${connectorId}/token` ); // @ts-expect-error return response.access_token; }, - async connectEndUser( - integrationType: ConnectorIntegrationType - ): Promise { - if (!integrationType || typeof integrationType !== "string") { - throw new Error("Integration type is required and must be a string"); + async connectAppUser(connectorId: string): Promise { + if (!connectorId || typeof connectorId !== "string") { + throw new Error("Connector ID is required and must be a string"); } const response = await axios.post( - `/apps/${appId}/end-user-auth/initiate`, - { integration_type: integrationType } + `/apps/${appId}/end-user-auth/connectors/${connectorId}/initiate` ); // @ts-expect-error return response.redirect_url; }, - async disconnectEndUser( - integrationType: ConnectorIntegrationType - ): Promise { - if (!integrationType || typeof integrationType !== "string") { - throw new Error("Integration type is required and must be a string"); + async disconnectAppUser(connectorId: string): Promise { + if (!connectorId || typeof connectorId !== "string") { + throw new Error("Connector ID is required and must be a string"); } await axios.delete( - `/apps/${appId}/end-user-auth/${integrationType}` + `/apps/${appId}/end-user-auth/connectors/${connectorId}` ); }, }; diff --git a/src/modules/connectors.types.ts b/src/modules/connectors.types.ts index 5ac4668..821d2f3 100644 --- a/src/modules/connectors.types.ts +++ b/src/modules/connectors.types.ts @@ -101,70 +101,68 @@ export interface ConnectorsModule { * retrieving the end user's access token, and disconnecting the end user's connection. * * Unlike {@link ConnectorsModule | ConnectorsModule} which manages app-scoped tokens, - * this module manages tokens scoped to individual end users. + * this module manages tokens scoped to individual end users. Methods are keyed on + * the connector ID (the OrgConnector's database ID) rather than the integration type. * * Available via `base44.connectors`. - * - * ## Dynamic Types - * - * If you're working in a TypeScript project, you can generate types from your app's connector configurations to get autocomplete on integration type names. See the [Dynamic Types](/developers/references/sdk/getting-started/dynamic-types) guide to get started. */ export interface UserConnectorsModule { /** - * Retrieves an OAuth access token for an end user's connection to a specific external integration. + * Retrieves an OAuth access token for an end user's connection to a specific connector. * * Returns the OAuth token string that belongs to the currently authenticated end user - * for the specified external service. + * for the specified connector. * - * @param integrationType - The type of integration, such as `'googlecalendar'`, `'slack'`, or `'github'`. + * @param connectorId - The connector ID (OrgConnector database ID). * @returns Promise resolving to the access token string. * * @example * ```typescript - * // Get the end user's Google Calendar token - * const token = await base44.connectors.getEndUserAccessToken('googlecalendar'); + * // Get the end user's access token for a connector + * const token = await base44.connectors.getAppUserAccessToken('abc123def'); * * const response = await fetch('https://www.googleapis.com/calendar/v3/calendars/primary/events', { * headers: { 'Authorization': `Bearer ${token}` } * }); * ``` */ - getEndUserAccessToken(integrationType: ConnectorIntegrationType): Promise; + getAppUserAccessToken(connectorId: string): Promise; /** - * Initiates the end-user OAuth flow for a specific external integration type. + * Initiates the end-user OAuth flow for a specific connector. * * Returns a redirect URL that the end user should be navigated to in order to - * authenticate with the external service. + * authenticate with the external service. The scopes and integration type are + * derived from the connector configuration server-side. * - * @param integrationType - The type of integration, such as `'googlecalendar'`, `'slack'`, or `'github'`. + * @param connectorId - The connector ID (OrgConnector database ID). * @returns Promise resolving to the redirect URL string. * * @example * ```typescript - * // Start Google Calendar OAuth for the end user - * const redirectUrl = await base44.connectors.connectEndUser('googlecalendar'); + * // Start OAuth for the end user + * const redirectUrl = await base44.connectors.connectAppUser('abc123def'); * * // Redirect the user to the OAuth provider * window.location.href = redirectUrl; * ``` */ - connectEndUser(integrationType: ConnectorIntegrationType): Promise; + connectAppUser(connectorId: string): Promise; /** - * Disconnects an end user's OAuth connection for a specific external integration type. + * Disconnects an end user's OAuth connection for a specific connector. * * Removes the stored OAuth credentials for the currently authenticated end user's - * connection to the specified external service. + * connection to the specified connector. * - * @param integrationType - The type of integration to disconnect, such as `'googlecalendar'`, `'slack'`, or `'github'`. + * @param connectorId - The connector ID (OrgConnector database ID). * @returns Promise resolving when the connection has been removed. * * @example * ```typescript - * // Disconnect the end user's Google Calendar connection - * await base44.connectors.disconnectEndUser('googlecalendar'); + * // Disconnect the end user's connection + * await base44.connectors.disconnectAppUser('abc123def'); * ``` */ - disconnectEndUser(integrationType: ConnectorIntegrationType): Promise; + disconnectAppUser(connectorId: string): Promise; } From c190c305d132171035725977a668aa17f908b661 Mon Sep 17 00:00:00 2001 From: johnny Date: Wed, 11 Mar 2026 12:00:30 +0200 Subject: [PATCH 07/10] change routes to /app-user-auth --- src/client.types.ts | 2 +- src/modules/connectors.ts | 10 +++++----- src/modules/connectors.types.ts | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/client.types.ts b/src/client.types.ts index 2ed94ab..d76e4d4 100644 --- a/src/client.types.ts +++ b/src/client.types.ts @@ -91,7 +91,7 @@ export interface Base44Client { auth: AuthModule; /** The underlying Axios instance used for API requests. Useful for making custom API calls with the same authentication and configuration as the SDK. */ axiosClient: AxiosInstance; - /** {@link UserConnectorsModule | Connectors module} for end-user OAuth flows. */ + /** {@link UserConnectorsModule | Connectors module} for app-user OAuth flows. */ connectors: UserConnectorsModule; /** {@link EntitiesModule | Entities module} for CRUD operations on your data models. */ entities: EntitiesModule; diff --git a/src/modules/connectors.ts b/src/modules/connectors.ts index 8e572a5..c4af6de 100644 --- a/src/modules/connectors.ts +++ b/src/modules/connectors.ts @@ -62,11 +62,11 @@ export function createConnectorsModule( } /** - * Creates the user-scoped Connectors module (end-user OAuth flows). + * Creates the user-scoped Connectors module (app-user OAuth flows). * * @param axios - Axios instance (user-scoped client) * @param appId - Application ID - * @returns User connectors module with end-user OAuth methods + * @returns User connectors module with app-user OAuth methods * @internal */ export function createUserConnectorsModule( @@ -83,7 +83,7 @@ export function createUserConnectorsModule( } const response = await axios.get( - `/apps/${appId}/end-user-auth/connectors/${connectorId}/token` + `/apps/${appId}/app-user-auth/connectors/${connectorId}/token` ); // @ts-expect-error @@ -96,7 +96,7 @@ export function createUserConnectorsModule( } const response = await axios.post( - `/apps/${appId}/end-user-auth/connectors/${connectorId}/initiate` + `/apps/${appId}/app-user-auth/connectors/${connectorId}/initiate` ); // @ts-expect-error @@ -109,7 +109,7 @@ export function createUserConnectorsModule( } await axios.delete( - `/apps/${appId}/end-user-auth/connectors/${connectorId}` + `/apps/${appId}/app-user-auth/connectors/${connectorId}` ); }, }; diff --git a/src/modules/connectors.types.ts b/src/modules/connectors.types.ts index b9bf591..f6729c1 100644 --- a/src/modules/connectors.types.ts +++ b/src/modules/connectors.types.ts @@ -230,9 +230,9 @@ export interface ConnectorsModule { } /** - * User-scoped connectors module for managing end-user OAuth connections. + * User-scoped connectors module for managing app-user OAuth connections. * - * This module provides methods for end-user OAuth flows: initiating an OAuth connection, + * This module provides methods for app-user OAuth flows: initiating an OAuth connection, * retrieving the end user's access token, and disconnecting the end user's connection. * * Unlike {@link ConnectorsModule | ConnectorsModule} which manages app-scoped tokens, @@ -264,7 +264,7 @@ export interface UserConnectorsModule { getAppUserAccessToken(connectorId: string): Promise; /** - * Initiates the end-user OAuth flow for a specific connector. + * Initiates the app-user OAuth flow for a specific connector. * * Returns a redirect URL that the end user should be navigated to in order to * authenticate with the external service. The scopes and integration type are From 5c5523888102bba948ad025cf88a019671c5ac85 Mon Sep 17 00:00:00 2001 From: johnny Date: Mon, 16 Mar 2026 13:33:12 +0200 Subject: [PATCH 08/10] remove exposing of axiosClient --- src/client.ts | 2 -- src/client.types.ts | 5 ----- 2 files changed, 7 deletions(-) diff --git a/src/client.ts b/src/client.ts index c630a4e..500d70c 100644 --- a/src/client.ts +++ b/src/client.ts @@ -147,7 +147,6 @@ export function createClient(config: CreateClientConfig): Base44Client { ); const userModules = { - axiosClient, entities: createEntitiesModule({ axios: axiosClient, appId, @@ -181,7 +180,6 @@ export function createClient(config: CreateClientConfig): Base44Client { }; const serviceRoleModules = { - axiosClient: serviceRoleAxiosClient, entities: createEntitiesModule({ axios: serviceRoleAxiosClient, appId, diff --git a/src/client.types.ts b/src/client.types.ts index cbf5e38..6b4c9c5 100644 --- a/src/client.types.ts +++ b/src/client.types.ts @@ -1,4 +1,3 @@ -import type { AxiosInstance } from "axios"; import type { EntitiesModule } from "./modules/entities.types.js"; import type { IntegrationsModule } from "./modules/integrations.types.js"; import type { AuthModule } from "./modules/auth.types.js"; @@ -94,8 +93,6 @@ export interface Base44Client { appLogs: AppLogsModule; /** {@link AuthModule | Auth module} for user authentication and management. */ auth: AuthModule; - /** The underlying Axios instance used for API requests. Useful for making custom API calls with the same authentication and configuration as the SDK. */ - axiosClient: AxiosInstance; /** {@link UserConnectorsModule | Connectors module} for app-user OAuth flows. */ connectors: UserConnectorsModule; /** {@link EntitiesModule | Entities module} for CRUD operations on your data models. */ @@ -132,8 +129,6 @@ export interface Base44Client { readonly asServiceRole: { /** {@link AgentsModule | Agents module} with elevated permissions. */ agents: AgentsModule; - /** The underlying Axios instance used for service role API requests. Useful for making custom API calls with service role authentication. */ - axiosClient: AxiosInstance; /** {@link AppLogsModule | App logs module} with elevated permissions. */ appLogs: AppLogsModule; /** {@link ConnectorsModule | Connectors module} for OAuth token retrieval. */ From f81ac1d726d255440076e92f6dfaed2368227424 Mon Sep 17 00:00:00 2001 From: johnny Date: Mon, 16 Mar 2026 13:49:45 +0200 Subject: [PATCH 09/10] get rid of @ts-expect-error --- src/modules/connectors.ts | 16 +++++++--------- src/modules/connectors.types.ts | 7 ------- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/src/modules/connectors.ts b/src/modules/connectors.ts index c4af6de..033891c 100644 --- a/src/modules/connectors.ts +++ b/src/modules/connectors.ts @@ -2,7 +2,6 @@ import { AxiosInstance } from "axios"; import { ConnectorIntegrationType, ConnectorAccessTokenResponse, - ConnectorInitiateResponse, ConnectorConnectionResponse, ConnectorsModule, UserConnectorsModule, @@ -74,20 +73,19 @@ export function createUserConnectorsModule( appId: string ): UserConnectorsModule { return { - // @ts-expect-error Return type mismatch - implementation returns object, interface expects string async getAppUserAccessToken( connectorId: string - ): Promise { + ): Promise { if (!connectorId || typeof connectorId !== "string") { throw new Error("Connector ID is required and must be a string"); } - const response = await axios.get( + const response = await axios.get( `/apps/${appId}/app-user-auth/connectors/${connectorId}/token` ); - // @ts-expect-error - return response.access_token; + const data = response as unknown as { access_token: string }; + return data.access_token; }, async connectAppUser(connectorId: string): Promise { @@ -95,12 +93,12 @@ export function createUserConnectorsModule( throw new Error("Connector ID is required and must be a string"); } - const response = await axios.post( + const response = await axios.post( `/apps/${appId}/app-user-auth/connectors/${connectorId}/initiate` ); - // @ts-expect-error - return response.redirect_url; + const data = response as unknown as { redirect_url: string }; + return data.redirect_url; }, async disconnectAppUser(connectorId: string): Promise { diff --git a/src/modules/connectors.types.ts b/src/modules/connectors.types.ts index e684498..c49c544 100644 --- a/src/modules/connectors.types.ts +++ b/src/modules/connectors.types.ts @@ -38,13 +38,6 @@ export interface ConnectorConnectionResponse { connectionConfig: Record | null; } -/** - * Response from the connectors initiate endpoint. - */ -export interface ConnectorInitiateResponse { - redirect_url: string; -} - /** * Connectors module for managing app-scoped OAuth tokens for external services. * From 36b3b6ba505b9c73786361f1de7da92b57af2440 Mon Sep 17 00:00:00 2001 From: johnny Date: Mon, 16 Mar 2026 18:40:00 +0200 Subject: [PATCH 10/10] rename to getCurrentAppUserAccessToken --- src/modules/connectors.ts | 2 +- src/modules/connectors.types.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/modules/connectors.ts b/src/modules/connectors.ts index 033891c..6f518ac 100644 --- a/src/modules/connectors.ts +++ b/src/modules/connectors.ts @@ -73,7 +73,7 @@ export function createUserConnectorsModule( appId: string ): UserConnectorsModule { return { - async getAppUserAccessToken( + async getCurrentAppUserAccessToken( connectorId: string ): Promise { if (!connectorId || typeof connectorId !== "string") { diff --git a/src/modules/connectors.types.ts b/src/modules/connectors.types.ts index c49c544..0c5a2c1 100644 --- a/src/modules/connectors.types.ts +++ b/src/modules/connectors.types.ts @@ -259,14 +259,14 @@ export interface UserConnectorsModule { * @example * ```typescript * // Get the end user's access token for a connector - * const token = await base44.connectors.getAppUserAccessToken('abc123def'); + * const token = await base44.connectors.getCurrentAppUserAccessToken('abc123def'); * * const response = await fetch('https://www.googleapis.com/calendar/v3/calendars/primary/events', { * headers: { 'Authorization': `Bearer ${token}` } * }); * ``` */ - getAppUserAccessToken(connectorId: string): Promise; + getCurrentAppUserAccessToken(connectorId: string): Promise; /** * Initiates the app-user OAuth flow for a specific connector.