@base44-preview/sdk 0.8.32-pr.206.d8fc10d → 0.8.34-pr.203.e66bb40

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.
@@ -194,7 +194,7 @@ export interface AgentsModuleConfig {
194
194
  * This module is available to use with a client in all authentication modes:
195
195
  *
196
196
  * - **Anonymous or User authentication** (`base44.agents`): Access is scoped to the current user's permissions. Users must be authenticated to create and access conversations.
197
- * - **Service role authentication** (`base44.asServiceRole.agents`): Operations run with elevated permissions for backend code that isn't tied to a specific user session.
197
+ * - **Service role authentication** (`base44.asServiceRole.agents`): Operations are invoked with the service role for backend code that needs elevated permissions.
198
198
  *
199
199
  * ## Generated Types
200
200
  *
@@ -40,7 +40,7 @@ export interface FunctionsModuleConfig {
40
40
  * This module is available to use with a client in all authentication modes:
41
41
  *
42
42
  * - **Anonymous or User authentication** (`base44.functions`): Functions are invoked with the current user's permissions. Anonymous users invoke functions without authentication, while authenticated users invoke functions with their authentication context.
43
- * - **Service role authentication** (`base44.asServiceRole.functions`): Functions are invoked with elevated permissions and no authenticated user. The function code receives a request with no user context.
43
+ * - **Service role authentication** (`base44.asServiceRole.functions`): Functions are invoked with the service role for backend code that needs elevated permissions.
44
44
  *
45
45
  * ## Generated Types
46
46
  *
@@ -362,7 +362,7 @@ export interface CoreIntegrations {
362
362
  * This module is available to use with a client in all authentication modes:
363
363
  *
364
364
  * - **Anonymous or User authentication** (`base44.integrations`): Integration methods are invoked with the current user's permissions. Anonymous users invoke methods without authentication, while authenticated users invoke methods with their authentication context.
365
- * - **Service role authentication** (`base44.asServiceRole.integrations`): Integration methods are invoked with elevated permissions for backend code that isn't tied to a specific user session.
365
+ * - **Service role authentication** (`base44.asServiceRole.integrations`): Integration methods are invoked with the service role for backend code that needs elevated permissions.
366
366
  */
367
367
  export type IntegrationsModule = {
368
368
  /**
@@ -1,6 +1,7 @@
1
1
  import axios from "axios";
2
2
  import { isInIFrame } from "./common.js";
3
3
  import { v4 as uuidv4 } from "uuid";
4
+ import { getAnalyticsSessionId } from "../modules/analytics.js";
4
5
  /**
5
6
  * Custom error class for Base44 SDK errors.
6
7
  *
@@ -131,6 +132,12 @@ export function createAxiosClient({ baseURL, headers = {}, token, interceptRespo
131
132
  client.interceptors.request.use((config) => {
132
133
  if (typeof window !== "undefined") {
133
134
  config.headers.set("X-Origin-URL", window.location.href);
135
+ // On unauthenticated requests, attach a stable anonymous visitor id so the
136
+ // backend can support anonymous agent access (conversation grouping + ownership).
137
+ // Authenticated requests are identified by their Authorization header instead.
138
+ if (!config.headers.get("Authorization")) {
139
+ config.headers.set("X-Base44-Anonymous-Id", getAnalyticsSessionId());
140
+ }
134
141
  }
135
142
  const requestId = uuidv4();
136
143
  config.requestId = requestId;
@@ -1,15 +1,25 @@
1
1
  import { io } from "socket.io-client";
2
2
  import { getAccessToken } from "./auth-utils.js";
3
+ import { getAnalyticsSessionId } from "../modules/analytics.js";
3
4
  const ROOM_LEAVE_GRACE_MS = 250;
4
5
  function initializeSocket(config, handlers) {
5
6
  var _a;
7
+ // On unauthenticated clients, send a stable anonymous visitor id on the
8
+ // handshake so the backend can verify room access for anonymous agent
9
+ // conversations (mirrors the X-Base44-Anonymous-Id HTTP header). Authenticated
10
+ // clients are identified by their token instead.
11
+ const resolvedToken = (_a = config.token) !== null && _a !== void 0 ? _a : getAccessToken();
12
+ const query = {
13
+ app_id: config.appId,
14
+ token: resolvedToken,
15
+ };
16
+ if (!resolvedToken) {
17
+ query.anonymous_id = getAnalyticsSessionId();
18
+ }
6
19
  const socket = io(config.serverUrl, {
7
20
  path: config.mountPath,
8
21
  transports: config.transports,
9
- query: {
10
- app_id: config.appId,
11
- token: (_a = config.token) !== null && _a !== void 0 ? _a : getAccessToken(),
12
- },
22
+ query,
13
23
  });
14
24
  socket.on("connect", async () => {
15
25
  var _a;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@base44-preview/sdk",
3
- "version": "0.8.32-pr.206.d8fc10d",
3
+ "version": "0.8.34-pr.203.e66bb40",
4
4
  "description": "JavaScript SDK for Base44 API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",