@base44-preview/sdk 0.8.19-pr.135.721e301 → 0.8.20-pr.136.1b3a14b

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -37,9 +37,18 @@ export function createAuthModule(axios, functionsAxiosClient, appId, options) {
37
37
  loginWithProvider(provider, fromUrl = "/") {
38
38
  // Build the full redirect URL
39
39
  const redirectUrl = new URL(fromUrl, window.location.origin).toString();
40
- // Build the provider login URL (google is the default, so no provider path needed)
41
- const providerPath = provider === "google" ? "" : `/${provider}`;
42
- const loginUrl = `${options.appBaseUrl}/api/apps/auth${providerPath}/login?app_id=${appId}&from_url=${encodeURIComponent(redirectUrl)}`;
40
+ const queryParams = `app_id=${appId}&from_url=${encodeURIComponent(redirectUrl)}`;
41
+ // SSO uses a different URL structure with appId in the path
42
+ let authPath;
43
+ if (provider === "sso") {
44
+ authPath = `/apps/${appId}/auth/sso/login`;
45
+ }
46
+ else {
47
+ // Google is the default provider, so no provider path segment needed
48
+ const providerPath = provider === "google" ? "" : `/${provider}`;
49
+ authPath = `/apps/auth${providerPath}/login`;
50
+ }
51
+ const loginUrl = `${options.appBaseUrl}/api${authPath}?${queryParams}`;
43
52
  // Redirect to the provider login page
44
53
  window.location.href = loginUrl;
45
54
  },
@@ -181,10 +181,10 @@ export interface AuthModule {
181
181
  * Initiates an OAuth login flow with one of the built-in providers. Requires a browser environment and can't be used in the backend.
182
182
  *
183
183
  * Supported providers:
184
- * - `'google'` - {@link https://developers.google.com/identity/protocols/oauth2 | Google OAuth}. Enabled by default.
185
- * - `'microsoft'` - {@link https://learn.microsoft.com/en-us/entra/identity-platform/v2-oauth2-auth-code-flow | Microsoft OAuth}. Enable Microsoft in your app's authentication settings before specifying this provider.
186
- * - `'facebook'` - {@link https://developers.facebook.com/docs/facebook-login | Facebook Login}. Enable Facebook in your app's authentication settings before using.
187
- * - `'apple'` - {@link https://developer.apple.com/sign-in-with-apple/ | Sign in with Apple}. Enable Apple in your app's authentication settings before using this provider.
184
+ * - `'google'`: {@link https://developers.google.com/identity/protocols/oauth2 | Google OAuth}. Enabled by default.
185
+ * - `'microsoft'`: {@link https://learn.microsoft.com/en-us/entra/identity-platform/v2-oauth2-auth-code-flow | Microsoft OAuth}. Enable Microsoft in your app's authentication settings before specifying this provider.
186
+ * - `'facebook'`: {@link https://developers.facebook.com/docs/facebook-login | Facebook Login}. Enable Facebook in your app's authentication settings before using.
187
+ * - `'apple'`: {@link https://developer.apple.com/sign-in-with-apple/ | Sign in with Apple}. Enable Apple in your app's authentication settings before using this provider.
188
188
  *
189
189
  * @param provider - The authentication provider to use: `'google'`, `'microsoft'`, `'facebook'`, or `'apple'`.
190
190
  * @param fromUrl - URL to redirect to after successful authentication. Defaults to `'/'`.
@@ -206,6 +206,7 @@ export interface AuthModule {
206
206
  * // Apple
207
207
  * base44.auth.loginWithProvider('apple', '/dashboard');
208
208
  * ```
209
+ *
209
210
  */
210
211
  loginWithProvider(provider: string, fromUrl?: string): void;
211
212
  /**
@@ -8,8 +8,11 @@
8
8
  */
9
9
  export function createConnectorsModule(axios, appId) {
10
10
  return {
11
- // Retrieve an OAuth access token for a specific external integration type
12
- // @ts-expect-error Return type mismatch with interface - implementation returns object, interface expects string
11
+ /**
12
+ * Retrieve an OAuth access token for a specific external integration type.
13
+ * @deprecated Use getConnection(integrationType) and use the returned accessToken (and connectionConfig when needed) instead.
14
+ */
15
+ // @ts-expect-error Return type mismatch with interface - implementation returns string, interface expects string but implementation is typed as ConnectorAccessTokenResponse
13
16
  async getAccessToken(integrationType) {
14
17
  if (!integrationType || typeof integrationType !== "string") {
15
18
  throw new Error("Integration type is required and must be a string");
@@ -10,7 +10,8 @@ export interface ConnectorIntegrationTypeRegistry {
10
10
  * ```typescript
11
11
  * // Using generated connector type names
12
12
  * // With generated types, you get autocomplete on integration types
13
- * const token = await base44.asServiceRole.connectors.getAccessToken('googlecalendar');
13
+ * const connection = await base44.asServiceRole.connectors.getConnection('googlecalendar');
14
+ * const token = connection.accessToken;
14
15
  * ```
15
16
  */
16
17
  export type ConnectorIntegrationType = keyof ConnectorIntegrationTypeRegistry extends never ? string : keyof ConnectorIntegrationTypeRegistry;
@@ -34,30 +35,62 @@ export interface ConnectorConnectionResponse {
34
35
  /**
35
36
  * Connectors module for managing OAuth tokens for external services.
36
37
  *
37
- * 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.
38
+ * 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, Slack, or GitHub, all users of the app share that same connection.
38
39
  *
39
40
  * Unlike the integrations module that provides pre-built functions, connectors give you
40
41
  * raw OAuth tokens so you can call external service APIs directly with full control over
41
42
  * the API calls you make. This is useful when you need custom API interactions that aren't
42
43
  * covered by Base44's pre-built integrations.
43
44
  *
45
+ * ## Available connectors
46
+ *
47
+ * All connectors work through [`getAccessToken()`](#getaccesstoken). Pass the integration type string and use the returned OAuth token to call the external service's API directly.
48
+ *
49
+ * | Service | Type identifier |
50
+ * |---|---|
51
+ * | Discord | `discord` |
52
+ * | GitHub | `github` |
53
+ * | Gmail | `gmail` |
54
+ * | Google BigQuery | `googlebigquery` |
55
+ * | Google Calendar | `googlecalendar` |
56
+ * | Google Docs | `googledocs` |
57
+ * | Google Drive | `googledrive` |
58
+ * | Google Sheets | `googlesheets` |
59
+ * | Google Slides | `googleslides` |
60
+ * | HubSpot | `hubspot` |
61
+ * | LinkedIn | `linkedin` |
62
+ * | Notion | `notion` |
63
+ * | Salesforce | `salesforce` |
64
+ * | Slack User | `slack` |
65
+ * | Slack Bot | `slackbot` |
66
+ * | TikTok | `tiktok` |
67
+ *
68
+ * ### Slack User vs Slack Bot
69
+ *
70
+ * Base44 provides two separate Slack connectors with different OAuth flows:
71
+ *
72
+ * - **`slack`** (Slack User): Uses a user token. API calls act as the connected Slack user. Requests user-level scopes such as reading conversations and searching message history. Some organizations restrict user-scope Slack apps.
73
+ * - **`slackbot`** (Slack Bot): Uses a bot token. API calls act as a bot with a customizable display name and icon. Requests bot-level scopes, which are more commonly allowed by organizations with stricter security policies. The bot can post to public channels without being invited and supports custom branding per message.
74
+ *
44
75
  * ## Authentication Modes
45
76
  *
46
77
  * 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.
47
78
  *
48
79
  * ## Dynamic Types
49
80
  *
50
- * 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 when calling `getAccessToken()`. See the [Dynamic Types](/developers/references/sdk/getting-started/dynamic-types) guide to get started.
81
+ * 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 when calling `getConnection()`. See the [Dynamic Types](/developers/references/sdk/getting-started/dynamic-types) guide to get started.
51
82
  */
52
83
  export interface ConnectorsModule {
53
84
  /**
54
- * Retrieves an OAuth access token for a specific external integration type.
85
+ * Retrieves an OAuth access token for a specific [external integration type](#available-connectors).
86
+ *
87
+ * @deprecated Use {@link getConnection} and use the returned `accessToken` (and `connectionConfig` when needed) instead.
55
88
  *
56
89
  * Returns the OAuth token string for an external service that an app builder
57
90
  * has connected to. This token represents the connected app builder's account
58
91
  * and can be used to make authenticated API calls to that external service on behalf of the app.
59
92
  *
60
- * @param integrationType - The type of integration, such as `'googlecalendar'`, `'slack'`, or `'github'`.
93
+ * @param integrationType - The type of integration, such as `'googlecalendar'`, `'slack'`, `'slackbot'`, `'github'`, or `'discord'`. See [Available connectors](#available-connectors) for the full list.
61
94
  * @returns Promise resolving to the access token string.
62
95
  *
63
96
  * @example
@@ -79,8 +112,8 @@ export interface ConnectorsModule {
79
112
  *
80
113
  * @example
81
114
  * ```typescript
82
- * // Slack connection
83
- * // Get Slack OAuth token and list channels
115
+ * // Slack User connection
116
+ * // Get Slack user token and list channels
84
117
  * const slackToken = await base44.asServiceRole.connectors.getAccessToken('slack');
85
118
  *
86
119
  * // List all public and private channels
@@ -92,6 +125,29 @@ export interface ConnectorsModule {
92
125
  *
93
126
  * const data = await slackResponse.json();
94
127
  * ```
128
+ *
129
+ * @example
130
+ * ```typescript
131
+ * // Slack Bot connection
132
+ * // Get Slack bot token and post a message with a custom bot identity
133
+ * const botToken = await base44.asServiceRole.connectors.getAccessToken('slackbot');
134
+ *
135
+ * const response = await fetch('https://slack.com/api/chat.postMessage', {
136
+ * method: 'POST',
137
+ * headers: {
138
+ * 'Authorization': `Bearer ${botToken}`,
139
+ * 'Content-Type': 'application/json'
140
+ * },
141
+ * body: JSON.stringify({
142
+ * channel: '#alerts',
143
+ * text: 'Deployment to production completed successfully.',
144
+ * username: 'Deploy Bot',
145
+ * icon_emoji: ':rocket:'
146
+ * })
147
+ * });
148
+ *
149
+ * const result = await response.json();
150
+ * ```
95
151
  */
96
152
  getAccessToken(integrationType: ConnectorIntegrationType): Promise<string>;
97
153
  /**
@@ -114,14 +170,20 @@ export interface ConnectorsModule {
114
170
  *
115
171
  * @example
116
172
  * ```typescript
117
- * // Using connection config for a service that requires extra parameters
173
+ * // Shopify: connectionConfig has subdomain (e.g. "my-store" for my-store.myshopify.com)
118
174
  * const connection = await base44.asServiceRole.connectors.getConnection('shopify');
119
175
  * const { accessToken, connectionConfig } = connection;
176
+ * const shop = connectionConfig?.subdomain
177
+ * ? `https://${connectionConfig.subdomain}.myshopify.com`
178
+ * : null;
120
179
  *
121
- * const response = await fetch(
122
- * `https://${connectionConfig?.shop}/admin/api/2024-01/products.json`,
123
- * { headers: { 'X-Shopify-Access-Token': accessToken } }
124
- * );
180
+ * if (shop) {
181
+ * const response = await fetch(
182
+ * `${shop}/admin/api/2024-01/products.json?limit=10`,
183
+ * { headers: { 'X-Shopify-Access-Token': accessToken } }
184
+ * );
185
+ * const { products } = await response.json();
186
+ * }
125
187
  * ```
126
188
  */
127
189
  getConnection(integrationType: ConnectorIntegrationType): Promise<ConnectorConnectionResponse>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@base44-preview/sdk",
3
- "version": "0.8.19-pr.135.721e301",
3
+ "version": "0.8.20-pr.136.1b3a14b",
4
4
  "description": "JavaScript SDK for Base44 API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",