@aui.io/aui-client 1.2.19 → 1.2.25

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/README.md CHANGED
@@ -14,15 +14,23 @@ npm install @aui.io/aui-client
14
14
  ## ⚡ Quick Start
15
15
 
16
16
  ```typescript
17
- import { ApolloClient } from '@aui.io/aui-client';
17
+ import { ApolloClient, ApolloEnvironment } from '@aui.io/aui-client';
18
18
 
19
+ // Default: Uses Gcp environment
19
20
  const client = new ApolloClient({
20
21
  networkApiKey: 'API_KEY_YOUR_KEY_HERE'
21
22
  });
22
23
 
23
- // This connects to production:
24
- // - REST API: https://azure.aui.io/api/ia-controller
25
- // - WebSocket: wss://api.aui.io/ia-controller/api/v1/external/session
24
+ // Or explicitly choose an environment:
25
+ const gcpClient = new ApolloClient({
26
+ environment: ApolloEnvironment.Gcp,
27
+ networkApiKey: 'API_KEY_YOUR_KEY_HERE'
28
+ });
29
+
30
+ const azureClient = new ApolloClient({
31
+ environment: ApolloEnvironment.Azure,
32
+ networkApiKey: 'API_KEY_YOUR_KEY_HERE'
33
+ });
26
34
  ```
27
35
 
28
36
 
@@ -64,8 +72,14 @@ console.log('Total tasks:', userTasks.total);
64
72
  ### WebSocket - Real-time Agent Communication
65
73
 
66
74
  ```typescript
67
- // Connect to WebSocket
68
- const socket = await client.apolloWsSession.connect();
75
+ // Connect to WebSocket with authentication headers
76
+ const socket = await client.apolloWsSession.connect({
77
+ debug: false,
78
+ reconnectAttempts: 3,
79
+ headers: {
80
+ 'x-network-api-key': 'API_KEY_YOUR_KEY_HERE'
81
+ }
82
+ });
69
83
 
70
84
  // Listen for connection open
71
85
  socket.on('open', () => {
@@ -145,15 +159,52 @@ interface ApolloClient.Options {
145
159
  }
146
160
  ```
147
161
 
148
- **Production Environment (Default):**
162
+ ### Available Environments
163
+
164
+ The SDK supports multiple environments for both REST API and WebSocket connections:
165
+
149
166
  ```typescript
150
- {
151
- base: "https://azure.aui.io/api/ia-controller", // REST API
152
- production: "wss://api.aui.io" // WebSocket
167
+ import { ApolloEnvironment } from '@aui.io/aui-client';
168
+
169
+ // Gcp Environment (Default)
170
+ ApolloEnvironment.Gcp = {
171
+ base: "https://api.aui.io/ia-controller", // REST API
172
+ wsUrl: "wss://api.aui.io" // WebSocket
173
+ }
174
+
175
+ // Azure Environment
176
+ ApolloEnvironment.Azure = {
177
+ base: "https://azure-v2.aui.io/ia-controller", // REST API
178
+ wsUrl: "wss://azure-v2.aui.io" // WebSocket
179
+ }
180
+
181
+ // Default (same as Gcp)
182
+ ApolloEnvironment.Default = {
183
+ base: "https://api.aui.io/ia-controller",
184
+ wsUrl: "wss://api.aui.io"
153
185
  }
154
186
  ```
155
187
 
156
- The SDK is configured for production use. All REST and WebSocket connections use production servers.
188
+ **Usage Example:**
189
+ ```typescript
190
+ import { ApolloClient, ApolloEnvironment } from '@aui.io/aui-client';
191
+
192
+ // Use Azure environment
193
+ const client = new ApolloClient({
194
+ environment: ApolloEnvironment.Azure,
195
+ networkApiKey: 'API_KEY_YOUR_KEY_HERE'
196
+ });
197
+
198
+ // Both REST and WebSocket will use Azure endpoints
199
+ const task = await client.controllerApi.createTask({...});
200
+ const socket = await client.apolloWsSession.connect({
201
+ debug: false,
202
+ reconnectAttempts: 3,
203
+ headers: {
204
+ 'x-network-api-key': 'API_KEY_YOUR_KEY_HERE'
205
+ }
206
+ });
207
+ ```
157
208
 
158
209
  ---
159
210
 
@@ -307,8 +358,14 @@ async function searchProducts(userId: string, query: string) {
307
358
  const taskId = taskResponse.id;
308
359
  console.log('Created task:', taskId);
309
360
 
310
- // Step 2: Connect to WebSocket
311
- const socket = await client.apolloWsSession.connect();
361
+ // Step 2: Connect to WebSocket with authentication
362
+ const socket = await client.apolloWsSession.connect({
363
+ debug: false,
364
+ reconnectAttempts: 3,
365
+ headers: {
366
+ 'x-network-api-key': 'API_KEY_YOUR_KEY_HERE'
367
+ }
368
+ });
312
369
 
313
370
  // Step 3: Set up event handlers
314
371
  socket.on('open', () => {
@@ -450,8 +507,11 @@ const taskResponse = await client.controllerApi.createTask(
450
507
 
451
508
  ```typescript
452
509
  const socket = await client.apolloWsSession.connect({
453
- reconnectAttempts: 50, // Try to reconnect up to 50 times
454
- debug: true // Enable debug logging
510
+ debug: true, // Enable debug logging
511
+ reconnectAttempts: 50, // Try to reconnect up to 50 times
512
+ headers: {
513
+ 'x-network-api-key': 'API_KEY_YOUR_KEY_HERE'
514
+ }
455
515
  });
456
516
 
457
517
  // The WebSocket will automatically attempt to reconnect on failure
@@ -45,8 +45,8 @@ class ApolloClient {
45
45
  "x-network-api-key": _options === null || _options === void 0 ? void 0 : _options.networkApiKey,
46
46
  "X-Fern-Language": "JavaScript",
47
47
  "X-Fern-SDK-Name": "@aui.io/aui-client",
48
- "X-Fern-SDK-Version": "1.2.19",
49
- "User-Agent": "@aui.io/aui-client/1.2.19",
48
+ "X-Fern-SDK-Version": "1.2.25",
49
+ "User-Agent": "@aui.io/aui-client/1.2.25",
50
50
  "X-Fern-Runtime": core.RUNTIME.type,
51
51
  "X-Fern-Runtime-Version": core.RUNTIME.version,
52
52
  }, _options === null || _options === void 0 ? void 0 : _options.headers) });
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  // This file was auto-generated by Fern from our API Definition.
3
+ // MANUALLY FIXED: Use .wsUrl instead of .gcp for WebSocket URL (see .fernignore)
3
4
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
5
  if (k2 === undefined) k2 = k;
5
6
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -58,7 +59,7 @@ class ApolloWsSession {
58
59
  const _headers = Object.assign({}, headers);
59
60
  const socket = new core.ReconnectingWebSocket({
60
61
  url: core.url.join((_a = (yield core.Supplier.get(this._options.baseUrl))) !== null && _a !== void 0 ? _a : ((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.ApolloEnvironment.Default)
61
- .gcp, "/ia-controller/api/v1/external/session"),
62
+ .wsUrl, "/ia-controller/api/v1/external/session"),
62
63
  protocols: [],
63
64
  queryParameters: {},
64
65
  headers: _headers,
@@ -96,8 +96,7 @@ class ControllerApi {
96
96
  "x-network-api-key": (_b = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.networkApiKey) !== null && _b !== void 0 ? _b : (_c = this._options) === null || _c === void 0 ? void 0 : _c.networkApiKey,
97
97
  }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
98
98
  const _response = yield core.fetcher({
99
- url: core.url.join((_d = (yield core.Supplier.get(this._options.baseUrl))) !== null && _d !== void 0 ? _d : ((_e = (yield core.Supplier.get(this._options.environment))) !== null && _e !== void 0 ? _e : environments.ApolloEnvironment.Default)
100
- .base, "api/v1/external/tasks"),
99
+ url: core.url.join((_d = (yield core.Supplier.get(this._options.baseUrl))) !== null && _d !== void 0 ? _d : ((_e = (yield core.Supplier.get(this._options.environment))) !== null && _e !== void 0 ? _e : environments.ApolloEnvironment.Gcp).base, "api/v1/external/tasks"),
101
100
  method: "GET",
102
101
  headers: _headers,
103
102
  queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
@@ -161,8 +160,7 @@ class ControllerApi {
161
160
  "x-network-api-key": (_b = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.networkApiKey) !== null && _b !== void 0 ? _b : (_c = this._options) === null || _c === void 0 ? void 0 : _c.networkApiKey,
162
161
  }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
163
162
  const _response = yield core.fetcher({
164
- url: core.url.join((_d = (yield core.Supplier.get(this._options.baseUrl))) !== null && _d !== void 0 ? _d : ((_e = (yield core.Supplier.get(this._options.environment))) !== null && _e !== void 0 ? _e : environments.ApolloEnvironment.Default)
165
- .base, "api/v1/external/tasks"),
163
+ url: core.url.join((_d = (yield core.Supplier.get(this._options.baseUrl))) !== null && _d !== void 0 ? _d : ((_e = (yield core.Supplier.get(this._options.environment))) !== null && _e !== void 0 ? _e : environments.ApolloEnvironment.Gcp).base, "api/v1/external/tasks"),
166
164
  method: "POST",
167
165
  headers: _headers,
168
166
  contentType: "application/json",
@@ -226,8 +224,7 @@ class ControllerApi {
226
224
  "x-network-api-key": (_b = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.networkApiKey) !== null && _b !== void 0 ? _b : (_c = this._options) === null || _c === void 0 ? void 0 : _c.networkApiKey,
227
225
  }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
228
226
  const _response = yield core.fetcher({
229
- url: core.url.join((_d = (yield core.Supplier.get(this._options.baseUrl))) !== null && _d !== void 0 ? _d : ((_e = (yield core.Supplier.get(this._options.environment))) !== null && _e !== void 0 ? _e : environments.ApolloEnvironment.Default)
230
- .base, `api/v1/external/tasks/${core.url.encodePathParam(taskId)}/messages`),
227
+ url: core.url.join((_d = (yield core.Supplier.get(this._options.baseUrl))) !== null && _d !== void 0 ? _d : ((_e = (yield core.Supplier.get(this._options.environment))) !== null && _e !== void 0 ? _e : environments.ApolloEnvironment.Gcp).base, `api/v1/external/tasks/${core.url.encodePathParam(taskId)}/messages`),
231
228
  method: "GET",
232
229
  headers: _headers,
233
230
  queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
@@ -297,8 +294,7 @@ class ControllerApi {
297
294
  "x-network-api-key": (_b = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.networkApiKey) !== null && _b !== void 0 ? _b : (_c = this._options) === null || _c === void 0 ? void 0 : _c.networkApiKey,
298
295
  }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
299
296
  const _response = yield core.fetcher({
300
- url: core.url.join((_d = (yield core.Supplier.get(this._options.baseUrl))) !== null && _d !== void 0 ? _d : ((_e = (yield core.Supplier.get(this._options.environment))) !== null && _e !== void 0 ? _e : environments.ApolloEnvironment.Default)
301
- .base, "api/v1/external/message"),
297
+ url: core.url.join((_d = (yield core.Supplier.get(this._options.baseUrl))) !== null && _d !== void 0 ? _d : ((_e = (yield core.Supplier.get(this._options.environment))) !== null && _e !== void 0 ? _e : environments.ApolloEnvironment.Gcp).base, "api/v1/external/message"),
302
298
  method: "POST",
303
299
  headers: _headers,
304
300
  contentType: "application/json",
@@ -367,8 +363,7 @@ class ControllerApi {
367
363
  "x-network-api-key": (_b = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.networkApiKey) !== null && _b !== void 0 ? _b : (_c = this._options) === null || _c === void 0 ? void 0 : _c.networkApiKey,
368
364
  }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
369
365
  const _response = yield core.fetcher({
370
- url: core.url.join((_d = (yield core.Supplier.get(this._options.baseUrl))) !== null && _d !== void 0 ? _d : ((_e = (yield core.Supplier.get(this._options.environment))) !== null && _e !== void 0 ? _e : environments.ApolloEnvironment.Default)
371
- .base, "api/v1/external/product-metadata"),
366
+ url: core.url.join((_d = (yield core.Supplier.get(this._options.baseUrl))) !== null && _d !== void 0 ? _d : ((_e = (yield core.Supplier.get(this._options.environment))) !== null && _e !== void 0 ? _e : environments.ApolloEnvironment.Gcp).base, "api/v1/external/product-metadata"),
372
367
  method: "GET",
373
368
  headers: _headers,
374
369
  queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
@@ -371,13 +371,34 @@ class ReconnectingWebSocket {
371
371
  url = `${url}?${queryString}`;
372
372
  }
373
373
  }
374
- // FIX: Don't pass empty protocols array - it breaks header authentication in Node.js v21+
375
- // Only pass protocols parameter if it has actual values
376
- if (this._protocols && this._protocols.length > 0) {
377
- this._ws = new WebSocket(url, this._protocols, options);
374
+ // FIX: Browser WebSocket doesn't support options parameter (causes "[object Object]" error)
375
+ // Detect if we're in a browser environment
376
+ const isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
377
+ if (isBrowser) {
378
+ // Browser: Can only pass URL and optionally protocols (string/array)
379
+ // Add API key to URL as query parameter for browser authentication
380
+ // NOTE: Backend must also accept x-network-api-key from query params for this to work
381
+ if (this._headers && this._headers["x-network-api-key"]) {
382
+ const separator = url.includes("?") ? "&" : "?";
383
+ url = `${url}${separator}x-network-api-key=${encodeURIComponent(this._headers["x-network-api-key"])}`;
384
+ }
385
+ // FIX: Don't pass empty protocols array
386
+ if (this._protocols && this._protocols.length > 0) {
387
+ this._ws = new WebSocket(url, this._protocols);
388
+ }
389
+ else {
390
+ this._ws = new WebSocket(url);
391
+ }
378
392
  }
379
393
  else {
380
- this._ws = new WebSocket(url, options);
394
+ // Node.js: Can pass options with headers
395
+ // FIX: Don't pass empty protocols array - it breaks header authentication in Node.js v21+
396
+ if (this._protocols && this._protocols.length > 0) {
397
+ this._ws = new WebSocket(url, this._protocols, options);
398
+ }
399
+ else {
400
+ this._ws = new WebSocket(url, options);
401
+ }
381
402
  }
382
403
  this._ws.binaryType = this._binaryType;
383
404
  this._connectLock = false;
@@ -1,13 +1,19 @@
1
1
  export interface ApolloEnvironmentUrls {
2
2
  base: string;
3
- gcp: string;
4
- azure: string;
3
+ wsUrl: string;
5
4
  }
6
5
  export declare const ApolloEnvironment: {
6
+ readonly Gcp: {
7
+ readonly base: "https://api.aui.io/ia-controller";
8
+ readonly wsUrl: "wss://api.aui.io";
9
+ };
10
+ readonly Azure: {
11
+ readonly base: "https://azure-v2.aui.io/ia-controller";
12
+ readonly wsUrl: "wss://azure-v2.aui.io";
13
+ };
7
14
  readonly Default: {
8
- readonly base: "https://azure.aui.io/api/ia-controller";
9
- readonly gcp: "wss://api.aui.io";
10
- readonly azure: "wss://azure-v2.aui.io";
15
+ readonly base: "https://api.aui.io/ia-controller";
16
+ readonly wsUrl: "wss://api.aui.io";
11
17
  };
12
18
  };
13
- export type ApolloEnvironment = typeof ApolloEnvironment.Default;
19
+ export type ApolloEnvironment = typeof ApolloEnvironment.Default | typeof ApolloEnvironment.Gcp | typeof ApolloEnvironment.Azure;
@@ -1,11 +1,20 @@
1
1
  "use strict";
2
2
  // This file was auto-generated by Fern from our API Definition.
3
+ // MANUALLY FIXED: Added wsUrl property for WebSocket URL resolution (see .fernignore)
3
4
  Object.defineProperty(exports, "__esModule", { value: true });
4
5
  exports.ApolloEnvironment = void 0;
5
6
  exports.ApolloEnvironment = {
7
+ Gcp: {
8
+ base: "https://api.aui.io/ia-controller",
9
+ wsUrl: "wss://api.aui.io",
10
+ },
11
+ Azure: {
12
+ base: "https://azure-v2.aui.io/ia-controller",
13
+ wsUrl: "wss://azure-v2.aui.io",
14
+ },
15
+ // Default points to Gcp for backwards compatibility
6
16
  Default: {
7
- base: "https://azure.aui.io/api/ia-controller",
8
- gcp: "wss://api.aui.io",
9
- azure: "wss://azure-v2.aui.io",
17
+ base: "https://api.aui.io/ia-controller",
18
+ wsUrl: "wss://api.aui.io",
10
19
  },
11
20
  };
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "1.2.19";
1
+ export declare const SDK_VERSION = "1.2.25";
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SDK_VERSION = void 0;
4
- exports.SDK_VERSION = "1.2.19";
4
+ exports.SDK_VERSION = "1.2.25";
@@ -9,8 +9,8 @@ export class ApolloClient {
9
9
  "x-network-api-key": _options === null || _options === void 0 ? void 0 : _options.networkApiKey,
10
10
  "X-Fern-Language": "JavaScript",
11
11
  "X-Fern-SDK-Name": "@aui.io/aui-client",
12
- "X-Fern-SDK-Version": "1.2.19",
13
- "User-Agent": "@aui.io/aui-client/1.2.19",
12
+ "X-Fern-SDK-Version": "1.2.25",
13
+ "User-Agent": "@aui.io/aui-client/1.2.25",
14
14
  "X-Fern-Runtime": core.RUNTIME.type,
15
15
  "X-Fern-Runtime-Version": core.RUNTIME.version,
16
16
  }, _options === null || _options === void 0 ? void 0 : _options.headers) });
@@ -1,4 +1,5 @@
1
1
  // This file was auto-generated by Fern from our API Definition.
2
+ // MANUALLY FIXED: Use .wsUrl instead of .gcp for WebSocket URL (see .fernignore)
2
3
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
4
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
5
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -22,7 +23,7 @@ export class ApolloWsSession {
22
23
  const _headers = Object.assign({}, headers);
23
24
  const socket = new core.ReconnectingWebSocket({
24
25
  url: core.url.join((_a = (yield core.Supplier.get(this._options.baseUrl))) !== null && _a !== void 0 ? _a : ((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.ApolloEnvironment.Default)
25
- .gcp, "/ia-controller/api/v1/external/session"),
26
+ .wsUrl, "/ia-controller/api/v1/external/session"),
26
27
  protocols: [],
27
28
  queryParameters: {},
28
29
  headers: _headers,
@@ -60,8 +60,7 @@ export class ControllerApi {
60
60
  "x-network-api-key": (_b = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.networkApiKey) !== null && _b !== void 0 ? _b : (_c = this._options) === null || _c === void 0 ? void 0 : _c.networkApiKey,
61
61
  }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
62
62
  const _response = yield core.fetcher({
63
- url: core.url.join((_d = (yield core.Supplier.get(this._options.baseUrl))) !== null && _d !== void 0 ? _d : ((_e = (yield core.Supplier.get(this._options.environment))) !== null && _e !== void 0 ? _e : environments.ApolloEnvironment.Default)
64
- .base, "api/v1/external/tasks"),
63
+ url: core.url.join((_d = (yield core.Supplier.get(this._options.baseUrl))) !== null && _d !== void 0 ? _d : ((_e = (yield core.Supplier.get(this._options.environment))) !== null && _e !== void 0 ? _e : environments.ApolloEnvironment.Gcp).base, "api/v1/external/tasks"),
65
64
  method: "GET",
66
65
  headers: _headers,
67
66
  queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
@@ -125,8 +124,7 @@ export class ControllerApi {
125
124
  "x-network-api-key": (_b = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.networkApiKey) !== null && _b !== void 0 ? _b : (_c = this._options) === null || _c === void 0 ? void 0 : _c.networkApiKey,
126
125
  }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
127
126
  const _response = yield core.fetcher({
128
- url: core.url.join((_d = (yield core.Supplier.get(this._options.baseUrl))) !== null && _d !== void 0 ? _d : ((_e = (yield core.Supplier.get(this._options.environment))) !== null && _e !== void 0 ? _e : environments.ApolloEnvironment.Default)
129
- .base, "api/v1/external/tasks"),
127
+ url: core.url.join((_d = (yield core.Supplier.get(this._options.baseUrl))) !== null && _d !== void 0 ? _d : ((_e = (yield core.Supplier.get(this._options.environment))) !== null && _e !== void 0 ? _e : environments.ApolloEnvironment.Gcp).base, "api/v1/external/tasks"),
130
128
  method: "POST",
131
129
  headers: _headers,
132
130
  contentType: "application/json",
@@ -190,8 +188,7 @@ export class ControllerApi {
190
188
  "x-network-api-key": (_b = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.networkApiKey) !== null && _b !== void 0 ? _b : (_c = this._options) === null || _c === void 0 ? void 0 : _c.networkApiKey,
191
189
  }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
192
190
  const _response = yield core.fetcher({
193
- url: core.url.join((_d = (yield core.Supplier.get(this._options.baseUrl))) !== null && _d !== void 0 ? _d : ((_e = (yield core.Supplier.get(this._options.environment))) !== null && _e !== void 0 ? _e : environments.ApolloEnvironment.Default)
194
- .base, `api/v1/external/tasks/${core.url.encodePathParam(taskId)}/messages`),
191
+ url: core.url.join((_d = (yield core.Supplier.get(this._options.baseUrl))) !== null && _d !== void 0 ? _d : ((_e = (yield core.Supplier.get(this._options.environment))) !== null && _e !== void 0 ? _e : environments.ApolloEnvironment.Gcp).base, `api/v1/external/tasks/${core.url.encodePathParam(taskId)}/messages`),
195
192
  method: "GET",
196
193
  headers: _headers,
197
194
  queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
@@ -261,8 +258,7 @@ export class ControllerApi {
261
258
  "x-network-api-key": (_b = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.networkApiKey) !== null && _b !== void 0 ? _b : (_c = this._options) === null || _c === void 0 ? void 0 : _c.networkApiKey,
262
259
  }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
263
260
  const _response = yield core.fetcher({
264
- url: core.url.join((_d = (yield core.Supplier.get(this._options.baseUrl))) !== null && _d !== void 0 ? _d : ((_e = (yield core.Supplier.get(this._options.environment))) !== null && _e !== void 0 ? _e : environments.ApolloEnvironment.Default)
265
- .base, "api/v1/external/message"),
261
+ url: core.url.join((_d = (yield core.Supplier.get(this._options.baseUrl))) !== null && _d !== void 0 ? _d : ((_e = (yield core.Supplier.get(this._options.environment))) !== null && _e !== void 0 ? _e : environments.ApolloEnvironment.Gcp).base, "api/v1/external/message"),
266
262
  method: "POST",
267
263
  headers: _headers,
268
264
  contentType: "application/json",
@@ -331,8 +327,7 @@ export class ControllerApi {
331
327
  "x-network-api-key": (_b = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.networkApiKey) !== null && _b !== void 0 ? _b : (_c = this._options) === null || _c === void 0 ? void 0 : _c.networkApiKey,
332
328
  }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
333
329
  const _response = yield core.fetcher({
334
- url: core.url.join((_d = (yield core.Supplier.get(this._options.baseUrl))) !== null && _d !== void 0 ? _d : ((_e = (yield core.Supplier.get(this._options.environment))) !== null && _e !== void 0 ? _e : environments.ApolloEnvironment.Default)
335
- .base, "api/v1/external/product-metadata"),
330
+ url: core.url.join((_d = (yield core.Supplier.get(this._options.baseUrl))) !== null && _d !== void 0 ? _d : ((_e = (yield core.Supplier.get(this._options.environment))) !== null && _e !== void 0 ? _e : environments.ApolloEnvironment.Gcp).base, "api/v1/external/product-metadata"),
336
331
  method: "GET",
337
332
  headers: _headers,
338
333
  queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
@@ -335,13 +335,34 @@ export class ReconnectingWebSocket {
335
335
  url = `${url}?${queryString}`;
336
336
  }
337
337
  }
338
- // FIX: Don't pass empty protocols array - it breaks header authentication in Node.js v21+
339
- // Only pass protocols parameter if it has actual values
340
- if (this._protocols && this._protocols.length > 0) {
341
- this._ws = new WebSocket(url, this._protocols, options);
338
+ // FIX: Browser WebSocket doesn't support options parameter (causes "[object Object]" error)
339
+ // Detect if we're in a browser environment
340
+ const isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
341
+ if (isBrowser) {
342
+ // Browser: Can only pass URL and optionally protocols (string/array)
343
+ // Add API key to URL as query parameter for browser authentication
344
+ // NOTE: Backend must also accept x-network-api-key from query params for this to work
345
+ if (this._headers && this._headers["x-network-api-key"]) {
346
+ const separator = url.includes("?") ? "&" : "?";
347
+ url = `${url}${separator}x-network-api-key=${encodeURIComponent(this._headers["x-network-api-key"])}`;
348
+ }
349
+ // FIX: Don't pass empty protocols array
350
+ if (this._protocols && this._protocols.length > 0) {
351
+ this._ws = new WebSocket(url, this._protocols);
352
+ }
353
+ else {
354
+ this._ws = new WebSocket(url);
355
+ }
342
356
  }
343
357
  else {
344
- this._ws = new WebSocket(url, options);
358
+ // Node.js: Can pass options with headers
359
+ // FIX: Don't pass empty protocols array - it breaks header authentication in Node.js v21+
360
+ if (this._protocols && this._protocols.length > 0) {
361
+ this._ws = new WebSocket(url, this._protocols, options);
362
+ }
363
+ else {
364
+ this._ws = new WebSocket(url, options);
365
+ }
345
366
  }
346
367
  this._ws.binaryType = this._binaryType;
347
368
  this._connectLock = false;
@@ -1,13 +1,19 @@
1
1
  export interface ApolloEnvironmentUrls {
2
2
  base: string;
3
- gcp: string;
4
- azure: string;
3
+ wsUrl: string;
5
4
  }
6
5
  export declare const ApolloEnvironment: {
6
+ readonly Gcp: {
7
+ readonly base: "https://api.aui.io/ia-controller";
8
+ readonly wsUrl: "wss://api.aui.io";
9
+ };
10
+ readonly Azure: {
11
+ readonly base: "https://azure-v2.aui.io/ia-controller";
12
+ readonly wsUrl: "wss://azure-v2.aui.io";
13
+ };
7
14
  readonly Default: {
8
- readonly base: "https://azure.aui.io/api/ia-controller";
9
- readonly gcp: "wss://api.aui.io";
10
- readonly azure: "wss://azure-v2.aui.io";
15
+ readonly base: "https://api.aui.io/ia-controller";
16
+ readonly wsUrl: "wss://api.aui.io";
11
17
  };
12
18
  };
13
- export type ApolloEnvironment = typeof ApolloEnvironment.Default;
19
+ export type ApolloEnvironment = typeof ApolloEnvironment.Default | typeof ApolloEnvironment.Gcp | typeof ApolloEnvironment.Azure;
@@ -1,8 +1,17 @@
1
1
  // This file was auto-generated by Fern from our API Definition.
2
+ // MANUALLY FIXED: Added wsUrl property for WebSocket URL resolution (see .fernignore)
2
3
  export const ApolloEnvironment = {
4
+ Gcp: {
5
+ base: "https://api.aui.io/ia-controller",
6
+ wsUrl: "wss://api.aui.io",
7
+ },
8
+ Azure: {
9
+ base: "https://azure-v2.aui.io/ia-controller",
10
+ wsUrl: "wss://azure-v2.aui.io",
11
+ },
12
+ // Default points to Gcp for backwards compatibility
3
13
  Default: {
4
- base: "https://azure.aui.io/api/ia-controller",
5
- gcp: "wss://api.aui.io",
6
- azure: "wss://azure-v2.aui.io",
14
+ base: "https://api.aui.io/ia-controller",
15
+ wsUrl: "wss://api.aui.io",
7
16
  },
8
17
  };
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "1.2.19";
1
+ export declare const SDK_VERSION = "1.2.25";
@@ -1 +1 @@
1
- export const SDK_VERSION = "1.2.19";
1
+ export const SDK_VERSION = "1.2.25";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aui.io/aui-client",
3
- "version": "1.2.19",
3
+ "version": "1.2.25",
4
4
  "private": false,
5
5
  "repository": "github:aui-io/aui-client-typescript",
6
6
  "type": "commonjs",