@scryme/chat 2.34.2 → 2.53.1

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.
@@ -35,7 +35,11 @@ var getBaseURL = function () {
35
35
  (typeof window !== 'undefined' && window.location.hostname !== 'localhost' && window.location.hostname !== '127.0.0.1');
36
36
  url = getEnv('API_URL') || getEnv('NEXT_PUBLIC_API_URL') || (isProd ? 'https://api.chat.scryme.tech' : 'http://localhost:3000');
37
37
  }
38
- return url.replace(/\/$/, '') + '/api';
38
+ url = url.replace(/\/$/, '');
39
+ if (url.endsWith('/api')) {
40
+ url = url.slice(0, -4);
41
+ }
42
+ return url;
39
43
  };
40
44
  var globalToken = null;
41
45
  export var setGlobalToken = function (token) {
package/dist/sdk.js CHANGED
@@ -96,7 +96,11 @@ var ScrymeSDK = /** @class */ (function () {
96
96
  env.VITE_API_URL ||
97
97
  (isProd ? 'https://api.chat.scryme.tech' : 'http://localhost:3000');
98
98
  }
99
- this.baseURL = url.replace(/\/$/, '');
99
+ url = url.replace(/\/$/, '');
100
+ if (url.endsWith('/api')) {
101
+ url = url.slice(0, -4);
102
+ }
103
+ this.baseURL = url;
100
104
  }
101
105
  /**
102
106
  * Synchronizes the authentication token to local storage and the global configuration.
@@ -188,7 +192,7 @@ var ScrymeSDK = /** @class */ (function () {
188
192
  case 1:
189
193
  token = _a.sent();
190
194
  return [2 /*return*/, {
191
- baseURL: "".concat(this.baseURL, "/api"),
195
+ baseURL: this.baseURL,
192
196
  headers: __assign({}, (token ? { Authorization: "Bearer ".concat(token) } : {})),
193
197
  }];
194
198
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scryme/chat",
3
- "version": "2.34.2",
3
+ "version": "2.53.1",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -164,16 +164,22 @@ describe('ScrymeSDK', () => {
164
164
  });
165
165
 
166
166
  describe('Initialization', () => {
167
- it('should initialize with default baseURL', () => {
167
+ it('should initialize with default baseURL without /api suffix', () => {
168
168
  const sdk = new ScrymeSDK();
169
169
  expect(sdk.baseURL).toContain('http://localhost:3000');
170
+ expect(sdk.baseURL).not.toContain('/api');
170
171
  });
171
172
 
172
- it('should initialize with custom baseURL', () => {
173
+ it('should initialize with custom baseURL stripping trailing slash', () => {
173
174
  const sdk = new ScrymeSDK({ baseURL: 'https://custom-api.com/' });
174
175
  expect(sdk.baseURL).toBe('https://custom-api.com');
175
176
  });
176
177
 
178
+ it('should strip /api suffix from custom baseURL if provided', () => {
179
+ const sdk = new ScrymeSDK({ baseURL: 'https://custom-api.com/api' });
180
+ expect(sdk.baseURL).toBe('https://custom-api.com');
181
+ });
182
+
177
183
  it('should accept clientId and clientSecret options', () => {
178
184
  const sdk = new ScrymeSDK({
179
185
  clientId: 'test-client-id',
@@ -273,7 +279,7 @@ describe('ScrymeSDK', () => {
273
279
  const result = await sdk.raw.v3WorkspacesControllerGetWorkspaces() as any;
274
280
  expect(result).toBeDefined();
275
281
  expect(result.options).toBeDefined();
276
- expect(result.options.baseURL).toBe('https://api.test.com/api');
282
+ expect(result.options.baseURL).toBe('https://api.test.com');
277
283
  expect(result.options.headers.Authorization).toBe('Bearer active-token');
278
284
  });
279
285
 
@@ -34,7 +34,11 @@ const getBaseURL = () => {
34
34
  (typeof window !== 'undefined' && window.location.hostname !== 'localhost' && window.location.hostname !== '127.0.0.1');
35
35
  url = getEnv('API_URL') || getEnv('NEXT_PUBLIC_API_URL') || (isProd ? 'https://api.chat.scryme.tech' : 'http://localhost:3000');
36
36
  }
37
- return url.replace(/\/$/, '') + '/api';
37
+ url = url.replace(/\/$/, '');
38
+ if (url.endsWith('/api')) {
39
+ url = url.slice(0, -4);
40
+ }
41
+ return url;
38
42
  };
39
43
 
40
44
  let globalToken: string | null = null;
package/src/sdk.ts CHANGED
@@ -520,7 +520,11 @@ export class ScrymeSDK {
520
520
  env.VITE_API_URL ||
521
521
  (isProd ? 'https://api.chat.scryme.tech' : 'http://localhost:3000');
522
522
  }
523
- this.baseURL = url.replace(/\/$/, '');
523
+ url = url.replace(/\/$/, '');
524
+ if (url.endsWith('/api')) {
525
+ url = url.slice(0, -4);
526
+ }
527
+ this.baseURL = url;
524
528
  }
525
529
 
526
530
  /**
@@ -585,7 +589,7 @@ export class ScrymeSDK {
585
589
  private async getRequestConfig(): Promise<AxiosRequestConfig> {
586
590
  const token = await this.getOrFetchToken();
587
591
  return {
588
- baseURL: `${this.baseURL}/api`,
592
+ baseURL: this.baseURL,
589
593
  headers: {
590
594
  ...(token ? { Authorization: `Bearer ${token}` } : {}),
591
595
  },