@base44-preview/sdk 0.8.19-pr.135.721e301 → 0.8.19-pr.135.d9d067f

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
  },
@@ -185,8 +185,9 @@ export interface AuthModule {
185
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
186
  * - `'facebook'` - {@link https://developers.facebook.com/docs/facebook-login | Facebook Login}. Enable Facebook in your app's authentication settings before using.
187
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
+ * - `'sso'` - Enterprise SSO. Enable SSO in your app's authentication settings before using this provider.
188
189
  *
189
- * @param provider - The authentication provider to use: `'google'`, `'microsoft'`, `'facebook'`, or `'apple'`.
190
+ * @param provider - The authentication provider to use: `'google'`, `'microsoft'`, `'facebook'`, `'apple'`, or `'sso'`.
190
191
  * @param fromUrl - URL to redirect to after successful authentication. Defaults to `'/'`.
191
192
  *
192
193
  * @example
@@ -206,6 +207,12 @@ export interface AuthModule {
206
207
  * // Apple
207
208
  * base44.auth.loginWithProvider('apple', '/dashboard');
208
209
  * ```
210
+ *
211
+ * @example
212
+ * ```typescript
213
+ * // SSO
214
+ * base44.auth.loginWithProvider('sso', '/dashboard');
215
+ * ```
209
216
  */
210
217
  loginWithProvider(provider: string, fromUrl?: string): void;
211
218
  /**
@@ -8,9 +8,13 @@
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) {
17
+ console.warn("[Base44 SDK] connectors.getAccessToken() is deprecated. Use getConnection(integrationType) and use the returned accessToken instead.");
14
18
  if (!integrationType || typeof integrationType !== "string") {
15
19
  throw new Error("Integration type is required and must be a string");
16
20
  }
@@ -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;
@@ -47,12 +48,14 @@ export interface ConnectorConnectionResponse {
47
48
  *
48
49
  * ## Dynamic Types
49
50
  *
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.
51
+ * 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
52
  */
52
53
  export interface ConnectorsModule {
53
54
  /**
54
55
  * Retrieves an OAuth access token for a specific external integration type.
55
56
  *
57
+ * @deprecated Use {@link getConnection} and use the returned `accessToken` (and `connectionConfig` when needed) instead.
58
+ *
56
59
  * Returns the OAuth token string for an external service that an app builder
57
60
  * has connected to. This token represents the connected app builder's account
58
61
  * and can be used to make authenticated API calls to that external service on behalf of the app.
@@ -114,14 +117,20 @@ export interface ConnectorsModule {
114
117
  *
115
118
  * @example
116
119
  * ```typescript
117
- * // Using connection config for a service that requires extra parameters
120
+ * // Shopify: connectionConfig has subdomain (e.g. "my-store" for my-store.myshopify.com)
118
121
  * const connection = await base44.asServiceRole.connectors.getConnection('shopify');
119
122
  * const { accessToken, connectionConfig } = connection;
123
+ * const shop = connectionConfig?.subdomain
124
+ * ? `https://${connectionConfig.subdomain}.myshopify.com`
125
+ * : null;
120
126
  *
121
- * const response = await fetch(
122
- * `https://${connectionConfig?.shop}/admin/api/2024-01/products.json`,
123
- * { headers: { 'X-Shopify-Access-Token': accessToken } }
124
- * );
127
+ * if (shop) {
128
+ * const response = await fetch(
129
+ * `${shop}/admin/api/2024-01/products.json?limit=10`,
130
+ * { headers: { 'X-Shopify-Access-Token': accessToken } }
131
+ * );
132
+ * const { products } = await response.json();
133
+ * }
125
134
  * ```
126
135
  */
127
136
  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.19-pr.135.d9d067f",
4
4
  "description": "JavaScript SDK for Base44 API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",