@base44-preview/sdk 0.8.59-pr.373.e530673 → 0.8.60-pr.376.c2b0448

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.
package/dist/client.js CHANGED
@@ -4,8 +4,9 @@ import { createIntegrationsModule } from "./modules/integrations.js";
4
4
  import { createAuthModule } from "./modules/auth.js";
5
5
  import { createSsoModule } from "./modules/sso.js";
6
6
  import { createBrowserModule } from "./modules/browser.js";
7
+ import { createVoiceModule } from "./modules/voice.js";
7
8
  import { createConnectorsModule, createUserConnectorsModule, } from "./modules/connectors.js";
8
- import { getAccessToken } from "./utils/auth-utils.js";
9
+ import { getAccessToken, sanitizeAppBaseUrl } from "./utils/auth-utils.js";
9
10
  import { createFetchWithAuth } from "./utils/fetch-with-auth.js";
10
11
  import { createFunctionsModule } from "./modules/functions.js";
11
12
  import { createAgentsModule } from "./modules/agents.js";
@@ -57,8 +58,8 @@ import { createActorsModule, resolveActorsHost, } from "./modules/actors.js";
57
58
  export function createClient(config) {
58
59
  var _a, _b, _c, _d;
59
60
  const { serverUrl = "https://base44.app", appId, analytics, token, serviceToken, requiresAuth = false, appBaseUrl, options, functionsVersion, headers: optionalHeaders, } = config;
60
- // Normalize appBaseUrl to always be a string (empty if not provided or invalid)
61
- const normalizedAppBaseUrl = typeof appBaseUrl === "string" ? appBaseUrl : "";
61
+ // Always a string: empty if not provided or not http(s)
62
+ const normalizedAppBaseUrl = sanitizeAppBaseUrl(appBaseUrl);
62
63
  const socketConfig = {
63
64
  serverUrl,
64
65
  mountPath: "/ws-user-apps/socket.io/",
@@ -230,6 +231,7 @@ export function createClient(config) {
230
231
  integrations: createIntegrationsModule(serviceRoleAxiosClient, appId),
231
232
  sso: createSsoModule(serviceRoleAxiosClient, appId),
232
233
  browser: createBrowserModule(serviceRoleAxiosClient),
234
+ voice: createVoiceModule(serviceRoleAxiosClient, { functionsVersion }),
233
235
  connectors: createConnectorsModule(serviceRoleAxiosClient, appId),
234
236
  functions: createFunctionsModule(serviceRoleFunctionsAxiosClient, appId, {
235
237
  getAuthHeaders: () => {
@@ -3,6 +3,7 @@ import type { IntegrationsModule } from "./modules/integrations.types.js";
3
3
  import type { AuthModule } from "./modules/auth.types.js";
4
4
  import type { SsoModule } from "./modules/sso.types.js";
5
5
  import type { BrowserModule } from "./modules/browser.types.js";
6
+ import type { VoiceModule } from "./modules/voice.types.js";
6
7
  import type { PaymentsModule, ServiceRolePaymentsModule } from "./modules/payments.types.js";
7
8
  import type { ConnectorsModule, UserConnectorsModule } from "./modules/connectors.types.js";
8
9
  import type { FunctionsModule } from "./modules/functions.types.js";
@@ -245,6 +246,8 @@ export interface Base44Client {
245
246
  payments: ServiceRolePaymentsModule;
246
247
  /** {@link SsoModule | SSO module} for generating SSO tokens. */
247
248
  sso: SsoModule;
249
+ /** {@link VoiceModule | Voice module} for live voice sessions. */
250
+ voice: VoiceModule;
248
251
  /** Cleanup function to disconnect WebSocket connections. */
249
252
  cleanup: () => void;
250
253
  };
package/dist/index.d.ts CHANGED
@@ -6,7 +6,7 @@ export type { Base44Client, CreateClientAnalyticsConfig, CreateClientConfig, Cre
6
6
  export * from "./types.js";
7
7
  export type { DeleteManyResult, DeleteResult, EntitiesModule, EntityAggregateResult, EntityAggregateSpec, EntityDateBucket, EntityDistinctOptions, EntityFilterOperators, EntityFilterQuery, EntityFilterValue, EntityHandler, EntityListOptions, EntityPage, EntityRecord, EntityTypeRegistry, EntityUpsertOptions, EntityUpsertResult, ImportResult, RealtimeEventType, RealtimeEvent, RealtimeCallback, SortField, UpdateManyResult, } from "./modules/entities.types.js";
8
8
  export type { AuthModule, LoginResponse, RegisterParams, VerifyOtpParams, ChangePasswordParams, ResetPasswordParams, User, } from "./modules/auth.types.js";
9
- export type { IntegrationsModule, IntegrationEndpointFunction, CoreIntegrations, InvokeLLMParams, GenerateImageParams, GenerateImageResult, UploadFileParams, UploadFileResult, SendEmailParams, SendEmailResult, ExtractDataFromUploadedFileParams, ExtractDataFromUploadedFileResult, UploadPrivateFileParams, UploadPrivateFileResult, CreateFileSignedUrlParams, CreateFileSignedUrlResult, } from "./modules/integrations.types.js";
9
+ export type { IntegrationsModule, IntegrationEndpointFunction, CoreIntegrations, InvokeLLMParams, GenerateImageParams, GenerateImageResult, UploadFileParams, UploadFileResult, EmailAttachment, SendEmailParams, SendEmailResult, ExtractDataFromUploadedFileParams, ExtractDataFromUploadedFileResult, UploadPrivateFileParams, UploadPrivateFileResult, CreateFileSignedUrlParams, CreateFileSignedUrlResult, } from "./modules/integrations.types.js";
10
10
  export type { FunctionsModule, FunctionName, FunctionNameRegistry, } from "./modules/functions.types.js";
11
11
  export type { AgentsModule, AgentName, AgentNameRegistry, AgentConversation, AgentMessage, AgentMessageReasoning, AgentMessageToolCall, AgentMessageUsage, AgentMessageCustomContext, AgentMessageMetadata, CreateConversationParams, } from "./modules/agents.types.js";
12
12
  export type { AiGatewayModule, AiGatewayConnection, AiGatewayConnectionOptions, } from "./modules/ai-gateway.types.js";
@@ -16,6 +16,7 @@ export type { ActorsModule, ActorClient, ActorRef, Connection, ActorSubscription
16
16
  export type { SsoModule, SsoAccessTokenResponse } from "./modules/sso.types.js";
17
17
  export type { PaymentsModule, ServiceRolePaymentsModule, PaymentsErrorCode, PaymentsRecurringFrequency, CheckoutBuyer, CheckoutFreeTrial, CheckoutItem, CheckoutItemRecurring, CheckoutPresentation, CheckoutShipping, CheckoutElement, CheckoutMount, MountableCheckout, CreateCheckoutParams, CreateCheckoutResult, CompleteCheckoutResult, EmbeddedCheckout, PayPalCheckoutOnClick, PayPalEmbeddedCheckout, StripeEmbeddedCheckout, MountCheckoutOptions, ListPurchasesParams, ServiceRoleListPurchasesParams, ListPurchasesResult, Purchase, PurchaseItem, PurchaseStatus, RefundParams, ShippingAddress, RefundResult, CancelSubscriptionOptions, SubscriptionResult, } from "./modules/payments.types.js";
18
18
  export type { BrowserModule, BrowserSession, BrowserSessionOptions, } from "./modules/browser.types.js";
19
+ export type { VoiceModule, VoiceSession, VoiceSessionMessage, VoiceSessionOptions, } from "./modules/voice.types.js";
19
20
  export { Actor, type Conn } from "./actor.js";
20
21
  export type { ConnectorsModule, UserConnectorsModule, ConnectorApiRequest, ConnectorApiResponse, ConnectorApiResponsePhase, } from "./modules/connectors.types.js";
21
22
  export type { CustomIntegrationsModule, CustomIntegrationCallParams, CustomIntegrationCallResponse, } from "./modules/custom-integrations.types.js";
@@ -86,6 +86,21 @@ export interface UploadFileResult {
86
86
  /** URL of the uploaded file. */
87
87
  file_url: string;
88
88
  }
89
+ /**
90
+ * A file to attach to an email.
91
+ */
92
+ export interface EmailAttachment {
93
+ /**
94
+ * File name the recipient sees, including the extension. The supported extensions are `csv`, `docx`, `gif`, `ics`, `jpeg`, `jpg`, `md`, `pdf`, `png`, `txt`, `webp`, and `xlsx`.
95
+ */
96
+ filename: string;
97
+ /**
98
+ * A file your app already uploaded, such as the `file_url` returned by [`UploadFile()`](#uploadfile) or the `file_uri` returned by [`UploadPrivateFile()`](#uploadprivatefile). Files uploaded by other apps are rejected.
99
+ */
100
+ file_url?: string;
101
+ /** Base64-encoded file contents, for a file your code generated. */
102
+ content?: string;
103
+ }
89
104
  /**
90
105
  * Parameters for the SendEmail function.
91
106
  */
@@ -94,10 +109,18 @@ export interface SendEmailParams {
94
109
  to: string;
95
110
  /** Email subject line. */
96
111
  subject: string;
97
- /** Plain text email body content. */
98
- body: string;
99
- /** The name of the sender. If omitted, the app's name will be used. */
112
+ /** HTML email body. The same as `html`, so set one or the other, not both. */
113
+ body?: string;
114
+ /** HTML email body. The same as `body`, so set one or the other, not both. */
115
+ html?: string;
116
+ /**
117
+ * Plain-text email body. On its own, it sends a plain-text email. Set it together with `body` or `html` to send both versions in one email, and the recipient's mail client shows whichever it prefers. Make sure both versions say the same thing.
118
+ */
119
+ text?: string;
120
+ /** The name of the sender. If omitted, the app's name is used. */
100
121
  from_name?: string;
122
+ /** Files to attach. You can attach up to 5 files, up to 5 MB each and 10 MB in total. Set `filename` and exactly one of `file_url` or `content` on each file. */
123
+ attachments?: EmailAttachment[];
101
124
  }
102
125
  export type SendEmailResult = any;
103
126
  /**
@@ -236,10 +259,35 @@ export interface CoreIntegrations {
236
259
  */
237
260
  UploadFile(params: UploadFileParams): Promise<UploadFileResult>;
238
261
  /**
239
- * Send emails to registered users of your app.
262
+ * Send an email from your app.
263
+ *
264
+ * You can always email registered users of your app. To email anyone else, the app needs a paid plan and a connected custom domain.
240
265
  *
241
- * @param params - Parameters for sending email
266
+ * @param params - Parameters for sending email. Set at least one of `body`, `html`, or `text`.
242
267
  * @returns Promise resolving when the email is sent.
268
+ *
269
+ * @example
270
+ * ```typescript
271
+ * // Send an HTML email with a plain-text version
272
+ * await base44.integrations.Core.SendEmail({
273
+ * to: "user@example.com",
274
+ * subject: "Your order has shipped",
275
+ * html: "<p>Your order <strong>#1234</strong> is on its way.</p>",
276
+ * text: "Your order #1234 is on its way.",
277
+ * });
278
+ * ```
279
+ *
280
+ * @example
281
+ * ```typescript
282
+ * // Attach a file your app uploaded
283
+ * const { file_url } = await base44.integrations.Core.UploadFile({ file });
284
+ * await base44.integrations.Core.SendEmail({
285
+ * to: "user@example.com",
286
+ * subject: "Your invoice",
287
+ * html: "<p>Your invoice is attached.</p>",
288
+ * attachments: [{ filename: "invoice.pdf", file_url }],
289
+ * });
290
+ * ```
243
291
  */
244
292
  SendEmail(params: SendEmailParams): Promise<SendEmailResult>;
245
293
  /**
@@ -0,0 +1,23 @@
1
+ import { AxiosInstance } from "axios";
2
+ import { VoiceModule } from "./voice.types.js";
3
+ /**
4
+ * Options for {@linkcode createVoiceModule}.
5
+ *
6
+ * @internal
7
+ */
8
+ export interface VoiceModuleConfig {
9
+ /** Sent as `Base44-Functions-Version` so the backend can pick the draft MCP profile. */
10
+ functionsVersion?: string;
11
+ }
12
+ /**
13
+ * Creates the Voice module for the Base44 SDK.
14
+ *
15
+ * The module passes every value through unchanged. Base44 validates them, so
16
+ * a backend rule change never needs an SDK release.
17
+ *
18
+ * @param axios - Axios instance (should be service role client)
19
+ * @param config - Module configuration
20
+ * @returns Voice module with methods to create and end live voice sessions
21
+ * @internal
22
+ */
23
+ export declare function createVoiceModule(axios: AxiosInstance, { functionsVersion }?: VoiceModuleConfig): VoiceModule;
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Creates the Voice module for the Base44 SDK.
3
+ *
4
+ * The module passes every value through unchanged. Base44 validates them, so
5
+ * a backend rule change never needs an SDK release.
6
+ *
7
+ * @param axios - Axios instance (should be service role client)
8
+ * @param config - Module configuration
9
+ * @returns Voice module with methods to create and end live voice sessions
10
+ * @internal
11
+ */
12
+ export function createVoiceModule(axios, { functionsVersion } = {}) {
13
+ const endSession = async (sessionId) => {
14
+ if (!sessionId || typeof sessionId !== "string") {
15
+ throw new Error("Session ID is required and must be a string");
16
+ }
17
+ await axios.delete(`/v1/voice-sessions/${encodeURIComponent(sessionId)}`);
18
+ };
19
+ return {
20
+ async createSession(options) {
21
+ // The app is derived from the service token, so the route isn't app-scoped.
22
+ const response = await axios.post("/v1/voice-sessions", {
23
+ sdp: options.sdp,
24
+ mcp_profile_id: options.mcpProfileId,
25
+ voice_instructions: options.voiceInstructions,
26
+ agent_instructions: options.agentInstructions,
27
+ // Send optional keys only when set, so the backend applies its defaults.
28
+ ...(options.voiceModel !== undefined && {
29
+ voice_model: options.voiceModel,
30
+ }),
31
+ ...(options.agentModel !== undefined && {
32
+ agent_model: options.agentModel,
33
+ }),
34
+ ...(options.voice !== undefined && { voice: options.voice }),
35
+ ...(options.initialMessages !== undefined && {
36
+ initial_messages: options.initialMessages,
37
+ }),
38
+ }, {
39
+ // The backend picks the draft or published MCP profile from this
40
+ // header. The service-role client doesn't send it by default.
41
+ headers: functionsVersion
42
+ ? { "Base44-Functions-Version": functionsVersion }
43
+ : undefined,
44
+ });
45
+ const data = response;
46
+ return {
47
+ sessionId: data.session_id,
48
+ sdp: data.sdp,
49
+ expiresAt: data.expires_at,
50
+ environment: data.environment,
51
+ };
52
+ },
53
+ endSession,
54
+ };
55
+ }
@@ -0,0 +1,187 @@
1
+ /**
2
+ * A text message placed in the conversation before the call starts.
3
+ */
4
+ export interface VoiceSessionMessage {
5
+ /**
6
+ * Who wrote the message, such as:
7
+ *
8
+ * - `'developer'`: Context for the voice agent, such as what the current user is looking at.
9
+ * - `'user'`: An earlier turn by the current user.
10
+ * - `'assistant'`: An earlier turn by the voice agent.
11
+ */
12
+ role: string;
13
+ /** The message text. */
14
+ text: string;
15
+ }
16
+ /**
17
+ * Options for {@linkcode VoiceModule.createSession | createSession()}.
18
+ */
19
+ export interface VoiceSessionOptions {
20
+ /**
21
+ * The browser's WebRTC SDP offer.
22
+ *
23
+ * Create it in the browser with [`RTCPeerConnection.createOffer()`](https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/createOffer) and send it to your backend function. A new offer is needed for every session.
24
+ */
25
+ sdp: string;
26
+ /**
27
+ * ID of the app's MCP profile whose tools the voice agent can use.
28
+ *
29
+ * The AI inserts this ID into your backend function when it sets up voice for the app.
30
+ */
31
+ mcpProfileId: string;
32
+ /**
33
+ * Model that talks with the current user, as an AI Gateway model ID. Defaults to Base44's default voice model.
34
+ */
35
+ voiceModel?: string;
36
+ /**
37
+ * Model behind the voice that calls the app's tools, as an AI Gateway model ID, such as `'gpt_6_luna'`. Defaults to Base44's default agent model.
38
+ */
39
+ agentModel?: string;
40
+ /**
41
+ * How the voice model speaks with the current user, such as its persona, tone, and turn-taking.
42
+ */
43
+ voiceInstructions: string;
44
+ /**
45
+ * How the agent behind the voice uses the app's tools to answer and act.
46
+ */
47
+ agentInstructions: string;
48
+ /**
49
+ * Built-in voice to speak with, such as `'cedar'`. The voice is fixed for the whole session. Defaults to the provider's default voice.
50
+ */
51
+ voice?: string;
52
+ /**
53
+ * Text conversation placed before the call starts, oldest first.
54
+ *
55
+ * Use it to give the voice agent context, or to continue a conversation the current user started in text.
56
+ */
57
+ initialMessages?: VoiceSessionMessage[];
58
+ }
59
+ /**
60
+ * A live voice session returned by {@linkcode VoiceModule.createSession | createSession()}.
61
+ */
62
+ export interface VoiceSession {
63
+ /**
64
+ * Opaque session identifier issued to your app.
65
+ *
66
+ * Pass it unchanged to [`endSession()`](#endsession) to end the session.
67
+ */
68
+ sessionId: string;
69
+ /**
70
+ * The SDP answer.
71
+ *
72
+ * Return it to the browser and apply it with [`RTCPeerConnection.setRemoteDescription()`](https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/setRemoteDescription). Audio then flows directly between the browser and the voice model.
73
+ */
74
+ sdp: string;
75
+ /** ISO 8601 timestamp when the session ends at the latest. */
76
+ expiresAt: string;
77
+ /**
78
+ * Where the voice agent's tools come from.
79
+ *
80
+ * - `'live'`: The published MCP profile.
81
+ * - `'draft'`: The current draft of the MCP profile. Served when the app's owner or an editor starts the session from the app editor preview, so voice works before the app is published.
82
+ */
83
+ environment: "live" | "draft";
84
+ }
85
+ /**
86
+ * Voice module for live voice conversations between your app's users and an AI agent.
87
+ *
88
+ * This module creates and ends live voice sessions. The voice agent can use your app's tools through one of the app's MCP profiles, acting as the current user. Audio flows directly between the browser and the voice model over [WebRTC](https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API), so your backend only creates and ends the session.
89
+ *
90
+ * A session takes three steps:
91
+ * - The browser creates a WebRTC SDP offer and sends it to one of your backend functions.
92
+ * - The backend function calls {@linkcode createSession | createSession()} with the offer and your voice settings, and returns the SDP answer to the browser.
93
+ * - The browser applies the answer, and the conversation starts.
94
+ *
95
+ * Keep the instructions, models, and MCP profile ID in the backend function. Only the SDP offer should come from the browser.
96
+ *
97
+ * This module is in beta and may change.
98
+ *
99
+ * ## Authentication modes
100
+ *
101
+ * This module is only available to use with a client in [service role authentication mode](/developers/references/sdk/getting-started/client#service-role) (`base44.asServiceRole.voice`), which means it can only be used in backend environments. The app's tools run as the current user of the request that created the client. Without a current user, they run as a guest, which only works in apps that allow anonymous access.
102
+ */
103
+ export interface VoiceModule {
104
+ /**
105
+ * Creates a live voice session and returns the SDP answer for the browser.
106
+ *
107
+ * Each call creates a new session, which uses credits from the workspace that owns the app. The session ends on its own when it's idle or reaches its maximum duration. To end it sooner, such as when the current user hangs up, call {@linkcode endSession | endSession()} from a later request.
108
+ *
109
+ * @param options - The browser's SDP offer and the voice settings.
110
+ * @returns Promise resolving to the new voice session. Rejects with a [`Base44Error`](/developers/references/sdk/getting-started/work-with-sdk#error-handling) whose `code` is one of the values under [Throws](#throws).
111
+ * @throws `insufficient_credits`: The workspace is out of credits.
112
+ * @throws `authentication_required`: The app requires a current user, and the request had none.
113
+ * @throws `unsupported_voice_model`: The voice model isn't supported.
114
+ * @throws `unsupported_agent_model`: The agent model isn't supported.
115
+ * @throws `voice_settings_rejected`: The voice provider rejected the settings, for example because the instructions are too long.
116
+ * @throws `invalid_request`: A value in the options is invalid.
117
+ * @throws `rate_limited`: You created too many sessions in a short time.
118
+ * @throws `voice_capacity_exceeded`: Voice capacity is temporarily unavailable.
119
+ * @throws `voice_connection_failed`: The voice provider couldn't be reached or rejected the request.
120
+ *
121
+ * @example
122
+ * ```typescript
123
+ * // Backend function that creates a voice session for the current user
124
+ * import { createClientFromRequest } from 'npm:@base44/sdk';
125
+ *
126
+ * const VOICE_PROFILE_ID = '6a1f0c2b9d8e7f6a5b4c3d2e';
127
+ *
128
+ * Deno.serve(async (req) => {
129
+ * const base44 = createClientFromRequest(req);
130
+ * // Only the SDP offer comes from the browser.
131
+ * const { sdp } = await req.json();
132
+ *
133
+ * const session = await base44.asServiceRole.voice.createSession({
134
+ * sdp,
135
+ * mcpProfileId: VOICE_PROFILE_ID,
136
+ * voiceInstructions: 'You are the shop assistant. Speak briefly and let the person interrupt.',
137
+ * agentInstructions: 'Use the app tools to look up orders. Report only what the tools return.',
138
+ * });
139
+ *
140
+ * return Response.json({ sessionId: session.sessionId, sdp: session.sdp });
141
+ * });
142
+ * ```
143
+ *
144
+ * @example
145
+ * ```typescript
146
+ * // Pick the models and voice, and give the agent context about the current page
147
+ * const session = await base44.asServiceRole.voice.createSession({
148
+ * sdp,
149
+ * mcpProfileId: VOICE_PROFILE_ID,
150
+ * voiceModel: 'gpt_live_1',
151
+ * agentModel: 'gpt_6_luna',
152
+ * voiceInstructions: 'You are the shop assistant.',
153
+ * agentInstructions: 'Use the app tools to look up orders.',
154
+ * voice: 'cedar',
155
+ * initialMessages: [
156
+ * { role: 'developer', text: 'The person is viewing order 1042 on the checkout page.' },
157
+ * ],
158
+ * });
159
+ * ```
160
+ */
161
+ createSession(options: VoiceSessionOptions): Promise<VoiceSession>;
162
+ /**
163
+ * Ends a voice session created by your app.
164
+ *
165
+ * Call it from a later request, such as when the browser reports that the current user hung up. Ending a session that has already ended succeeds, so it's safe to call more than once.
166
+ *
167
+ * @param sessionId - The `sessionId` returned by {@linkcode createSession | createSession()}.
168
+ * @returns Promise that resolves when Base44 accepts the request. The session closes in the background. Rejects with a [`Base44Error`](/developers/references/sdk/getting-started/work-with-sdk#error-handling) whose `code` is one of the values under [Throws](#throws-2).
169
+ * @throws `voice_session_not_found`: The session ID wasn't issued to your app.
170
+ * @throws `voice_connection_failed`: Base44 couldn't reach its background processing. It closes the session directly where possible, and retrying is safe.
171
+ *
172
+ * @example
173
+ * ```typescript
174
+ * // End a session from a later request, using the ID sent in the request body
175
+ * import { createClientFromRequest } from 'npm:@base44/sdk';
176
+ *
177
+ * Deno.serve(async (req) => {
178
+ * const base44 = createClientFromRequest(req);
179
+ * const { sessionId } = await req.json();
180
+ * await base44.asServiceRole.voice.endSession(sessionId);
181
+ *
182
+ * return new Response(null, { status: 204 });
183
+ * });
184
+ * ```
185
+ */
186
+ endSession(sessionId: string): Promise<void>;
187
+ }
@@ -0,0 +1,4 @@
1
+ // This file deliberately states no backend limits, value lists, durations, or
2
+ // prices. Base44 validates every value, so changing a backend rule must never
3
+ // need an SDK release. Those details belong in the live voice guide.
4
+ export {};
@@ -115,3 +115,4 @@ export declare function removeAccessToken(options: RemoveAccessTokenOptions): bo
115
115
  * ```
116
116
  */
117
117
  export declare function getLoginUrl(nextUrl: string, options: GetLoginUrlOptions): string;
118
+ export declare function sanitizeAppBaseUrl(value: unknown): string;
@@ -187,3 +187,19 @@ export function getLoginUrl(nextUrl, options) {
187
187
  const encodedRedirectUrl = encodeURIComponent(nextUrl || (typeof window !== "undefined" ? window.location.href : ""));
188
188
  return `${serverUrl}${loginPath}?from_url=${encodedRedirectUrl}&app_id=${appId}`;
189
189
  }
190
+ // appBaseUrl becomes a navigation target, so only http(s) values may pass.
191
+ export function sanitizeAppBaseUrl(value) {
192
+ var _a;
193
+ if (typeof value !== "string")
194
+ return "";
195
+ try {
196
+ const base = typeof window !== "undefined" && ((_a = window.location) === null || _a === void 0 ? void 0 : _a.origin)
197
+ ? window.location.origin
198
+ : "http://localhost";
199
+ const { protocol } = new URL(value, base);
200
+ return protocol === "http:" || protocol === "https:" ? value : "";
201
+ }
202
+ catch (_b) {
203
+ return "";
204
+ }
205
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@base44-preview/sdk",
3
- "version": "0.8.59-pr.373.e530673",
3
+ "version": "0.8.60-pr.376.c2b0448",
4
4
  "description": "JavaScript SDK for Base44 API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",