@dotbots-boutique/auth-sdk 1.0.6 → 1.0.8

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
@@ -115,7 +115,7 @@ App (frontend) → Local proxy (per server) → api.dotbots.ai
115
115
 
116
116
  During `initialize()`, the SDK fetches the proxy config from `GET {apiUrl}/api/proxy/config`. After that, all `auth.fetch()` calls are routed through the proxy automatically. If the proxy config cannot be fetched, the SDK falls back to direct communication with `apiUrl`.
117
117
 
118
- Auth endpoints (`/api/auth/*`) and the proxy config endpoint always go directly to `apiUrl` — never through the proxy.
118
+ Auth endpoints (`/auth/*`) and the proxy config endpoint always go directly to `apiUrl` — never through the proxy.
119
119
 
120
120
  ---
121
121
 
package/dist/cjs/index.js CHANGED
@@ -39,7 +39,7 @@ class TokenManager {
39
39
  throw new DotBotsAuthError('CODE_EXPIRED', 'No auth code provided');
40
40
  }
41
41
  console.warn(`[DotBotsAuth] Exchanging auth code: ${code.substring(0, 2)}**`);
42
- const response = await this.apiRequest('/api/auth/token', {
42
+ const response = await this.apiRequest('/auth/token', {
43
43
  method: 'POST',
44
44
  headers: { 'Content-Type': 'application/json' },
45
45
  body: JSON.stringify({ code, appId: this.config.appId }),
@@ -59,7 +59,7 @@ class TokenManager {
59
59
  }
60
60
  let response;
61
61
  try {
62
- response = await this.apiRequest('/api/auth/refresh', {
62
+ response = await this.apiRequest('/auth/refresh', {
63
63
  method: 'POST',
64
64
  headers: { 'Content-Type': 'application/json' },
65
65
  body: JSON.stringify({
@@ -80,7 +80,7 @@ class TokenManager {
80
80
  async revoke() {
81
81
  if (this.accessToken && this.refreshToken) {
82
82
  try {
83
- await this.apiRequest('/api/auth/revoke', {
83
+ await this.apiRequest('/auth/revoke', {
84
84
  method: 'POST',
85
85
  headers: {
86
86
  'Content-Type': 'application/json',
@@ -272,7 +272,7 @@ class DotBotsAuth {
272
272
  this.assertInitialized();
273
273
  if (this.cachedUser)
274
274
  return this.cachedUser;
275
- const response = await this.buildRequest(`${this.proxyConfigManager.getBaseUrl()}/api/auth/me`);
275
+ const response = await this.buildRequest(`${this.proxyConfigManager.getBaseUrl()}/auth/me`);
276
276
  if (!response.ok) {
277
277
  if (response.status === 401) {
278
278
  throw new DotBotsAuthError('UNAUTHORIZED', 'Not authorized to access this app');
@@ -303,8 +303,14 @@ class DotBotsAuth {
303
303
  }
304
304
  async fetch(url, options) {
305
305
  this.assertInitialized();
306
- const baseUrl = this.proxyConfigManager.getBaseUrl();
307
- const fullUrl = `${baseUrl}${url.startsWith('/') ? url : `/${url}`}`;
306
+ let fullUrl;
307
+ if (url.startsWith('https://') || url.startsWith('http://')) {
308
+ fullUrl = url;
309
+ }
310
+ else {
311
+ const baseUrl = this.proxyConfigManager.getBaseUrl();
312
+ fullUrl = `${baseUrl}${url.startsWith('/') ? url : `/${url}`}`;
313
+ }
308
314
  let response = await this.buildRequest(fullUrl, options);
309
315
  // On 401, try one refresh then retry
310
316
  if (response.status === 401) {
@@ -329,7 +335,7 @@ class DotBotsAuth {
329
335
  }
330
336
  else {
331
337
  const redirectUri = encodeURIComponent(window.location.origin);
332
- window.location.href = `${this.config.apiUrl}/api/auth/logout?redirectUri=${redirectUri}`;
338
+ window.location.href = `${this.config.apiUrl}/auth/logout?redirectUri=${redirectUri}`;
333
339
  }
334
340
  }
335
341
  on(event, handler) {
@@ -377,7 +383,7 @@ class DotBotsAuth {
377
383
  else if (!this.tokenManager.isAuthenticated()) {
378
384
  // Redirect to auth
379
385
  const redirectUri = encodeURIComponent(window.location.href);
380
- window.location.href = `${this.config.apiUrl}/api/auth/authorize?appId=${this.config.appId}&redirectUri=${redirectUri}`;
386
+ window.location.href = `${this.config.apiUrl}/auth/authorize?appId=${this.config.appId}&redirectUri=${redirectUri}`;
381
387
  }
382
388
  }
383
389
  async buildRequest(url, options) {
@@ -409,7 +415,7 @@ class DotBotsAuth {
409
415
  }
410
416
  }
411
417
  }
412
- DotBotsAuth.SDK_VERSION = '1.0.6';
418
+ DotBotsAuth.SDK_VERSION = '1.0.8';
413
419
 
414
420
  exports.DotBotsAuth = DotBotsAuth;
415
421
  exports.DotBotsAuthError = DotBotsAuthError;
package/dist/esm/index.js CHANGED
@@ -37,7 +37,7 @@ class TokenManager {
37
37
  throw new DotBotsAuthError('CODE_EXPIRED', 'No auth code provided');
38
38
  }
39
39
  console.warn(`[DotBotsAuth] Exchanging auth code: ${code.substring(0, 2)}**`);
40
- const response = await this.apiRequest('/api/auth/token', {
40
+ const response = await this.apiRequest('/auth/token', {
41
41
  method: 'POST',
42
42
  headers: { 'Content-Type': 'application/json' },
43
43
  body: JSON.stringify({ code, appId: this.config.appId }),
@@ -57,7 +57,7 @@ class TokenManager {
57
57
  }
58
58
  let response;
59
59
  try {
60
- response = await this.apiRequest('/api/auth/refresh', {
60
+ response = await this.apiRequest('/auth/refresh', {
61
61
  method: 'POST',
62
62
  headers: { 'Content-Type': 'application/json' },
63
63
  body: JSON.stringify({
@@ -78,7 +78,7 @@ class TokenManager {
78
78
  async revoke() {
79
79
  if (this.accessToken && this.refreshToken) {
80
80
  try {
81
- await this.apiRequest('/api/auth/revoke', {
81
+ await this.apiRequest('/auth/revoke', {
82
82
  method: 'POST',
83
83
  headers: {
84
84
  'Content-Type': 'application/json',
@@ -270,7 +270,7 @@ class DotBotsAuth {
270
270
  this.assertInitialized();
271
271
  if (this.cachedUser)
272
272
  return this.cachedUser;
273
- const response = await this.buildRequest(`${this.proxyConfigManager.getBaseUrl()}/api/auth/me`);
273
+ const response = await this.buildRequest(`${this.proxyConfigManager.getBaseUrl()}/auth/me`);
274
274
  if (!response.ok) {
275
275
  if (response.status === 401) {
276
276
  throw new DotBotsAuthError('UNAUTHORIZED', 'Not authorized to access this app');
@@ -301,8 +301,14 @@ class DotBotsAuth {
301
301
  }
302
302
  async fetch(url, options) {
303
303
  this.assertInitialized();
304
- const baseUrl = this.proxyConfigManager.getBaseUrl();
305
- const fullUrl = `${baseUrl}${url.startsWith('/') ? url : `/${url}`}`;
304
+ let fullUrl;
305
+ if (url.startsWith('https://') || url.startsWith('http://')) {
306
+ fullUrl = url;
307
+ }
308
+ else {
309
+ const baseUrl = this.proxyConfigManager.getBaseUrl();
310
+ fullUrl = `${baseUrl}${url.startsWith('/') ? url : `/${url}`}`;
311
+ }
306
312
  let response = await this.buildRequest(fullUrl, options);
307
313
  // On 401, try one refresh then retry
308
314
  if (response.status === 401) {
@@ -327,7 +333,7 @@ class DotBotsAuth {
327
333
  }
328
334
  else {
329
335
  const redirectUri = encodeURIComponent(window.location.origin);
330
- window.location.href = `${this.config.apiUrl}/api/auth/logout?redirectUri=${redirectUri}`;
336
+ window.location.href = `${this.config.apiUrl}/auth/logout?redirectUri=${redirectUri}`;
331
337
  }
332
338
  }
333
339
  on(event, handler) {
@@ -375,7 +381,7 @@ class DotBotsAuth {
375
381
  else if (!this.tokenManager.isAuthenticated()) {
376
382
  // Redirect to auth
377
383
  const redirectUri = encodeURIComponent(window.location.href);
378
- window.location.href = `${this.config.apiUrl}/api/auth/authorize?appId=${this.config.appId}&redirectUri=${redirectUri}`;
384
+ window.location.href = `${this.config.apiUrl}/auth/authorize?appId=${this.config.appId}&redirectUri=${redirectUri}`;
379
385
  }
380
386
  }
381
387
  async buildRequest(url, options) {
@@ -407,6 +413,6 @@ class DotBotsAuth {
407
413
  }
408
414
  }
409
415
  }
410
- DotBotsAuth.SDK_VERSION = '1.0.6';
416
+ DotBotsAuth.SDK_VERSION = '1.0.8';
411
417
 
412
418
  export { DotBotsAuth, DotBotsAuthError };
@@ -8,7 +8,7 @@ export declare class DotBotsAuth {
8
8
  private readonly listeners;
9
9
  private cachedUser;
10
10
  private initialized;
11
- static readonly SDK_VERSION = "1.0.6";
11
+ static readonly SDK_VERSION = "1.0.8";
12
12
  constructor(config: DotBotsConfig);
13
13
  initialize(): Promise<void>;
14
14
  getUser(): Promise<DotBotsUser>;
@@ -37,7 +37,7 @@ class TokenManager {
37
37
  throw new DotBotsAuthError('CODE_EXPIRED', 'No auth code provided');
38
38
  }
39
39
  console.warn(`[DotBotsAuth] Exchanging auth code: ${code.substring(0, 2)}**`);
40
- const response = await this.apiRequest('/api/auth/token', {
40
+ const response = await this.apiRequest('/auth/token', {
41
41
  method: 'POST',
42
42
  headers: { 'Content-Type': 'application/json' },
43
43
  body: JSON.stringify({ code, appId: this.config.appId }),
@@ -57,7 +57,7 @@ class TokenManager {
57
57
  }
58
58
  let response;
59
59
  try {
60
- response = await this.apiRequest('/api/auth/refresh', {
60
+ response = await this.apiRequest('/auth/refresh', {
61
61
  method: 'POST',
62
62
  headers: { 'Content-Type': 'application/json' },
63
63
  body: JSON.stringify({
@@ -78,7 +78,7 @@ class TokenManager {
78
78
  async revoke() {
79
79
  if (this.accessToken && this.refreshToken) {
80
80
  try {
81
- await this.apiRequest('/api/auth/revoke', {
81
+ await this.apiRequest('/auth/revoke', {
82
82
  method: 'POST',
83
83
  headers: {
84
84
  'Content-Type': 'application/json',
@@ -270,7 +270,7 @@ class DotBotsAuth {
270
270
  this.assertInitialized();
271
271
  if (this.cachedUser)
272
272
  return this.cachedUser;
273
- const response = await this.buildRequest(`${this.proxyConfigManager.getBaseUrl()}/api/auth/me`);
273
+ const response = await this.buildRequest(`${this.proxyConfigManager.getBaseUrl()}/auth/me`);
274
274
  if (!response.ok) {
275
275
  if (response.status === 401) {
276
276
  throw new DotBotsAuthError('UNAUTHORIZED', 'Not authorized to access this app');
@@ -301,8 +301,14 @@ class DotBotsAuth {
301
301
  }
302
302
  async fetch(url, options) {
303
303
  this.assertInitialized();
304
- const baseUrl = this.proxyConfigManager.getBaseUrl();
305
- const fullUrl = `${baseUrl}${url.startsWith('/') ? url : `/${url}`}`;
304
+ let fullUrl;
305
+ if (url.startsWith('https://') || url.startsWith('http://')) {
306
+ fullUrl = url;
307
+ }
308
+ else {
309
+ const baseUrl = this.proxyConfigManager.getBaseUrl();
310
+ fullUrl = `${baseUrl}${url.startsWith('/') ? url : `/${url}`}`;
311
+ }
306
312
  let response = await this.buildRequest(fullUrl, options);
307
313
  // On 401, try one refresh then retry
308
314
  if (response.status === 401) {
@@ -327,7 +333,7 @@ class DotBotsAuth {
327
333
  }
328
334
  else {
329
335
  const redirectUri = encodeURIComponent(window.location.origin);
330
- window.location.href = `${this.config.apiUrl}/api/auth/logout?redirectUri=${redirectUri}`;
336
+ window.location.href = `${this.config.apiUrl}/auth/logout?redirectUri=${redirectUri}`;
331
337
  }
332
338
  }
333
339
  on(event, handler) {
@@ -375,7 +381,7 @@ class DotBotsAuth {
375
381
  else if (!this.tokenManager.isAuthenticated()) {
376
382
  // Redirect to auth
377
383
  const redirectUri = encodeURIComponent(window.location.href);
378
- window.location.href = `${this.config.apiUrl}/api/auth/authorize?appId=${this.config.appId}&redirectUri=${redirectUri}`;
384
+ window.location.href = `${this.config.apiUrl}/auth/authorize?appId=${this.config.appId}&redirectUri=${redirectUri}`;
379
385
  }
380
386
  }
381
387
  async buildRequest(url, options) {
@@ -407,6 +413,6 @@ class DotBotsAuth {
407
413
  }
408
414
  }
409
415
  }
410
- DotBotsAuth.SDK_VERSION = '1.0.6';
416
+ DotBotsAuth.SDK_VERSION = '1.0.8';
411
417
 
412
418
  export { DotBotsAuth, DotBotsAuthError };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dotbots-boutique/auth-sdk",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "Authentication SDK for DotBots marketplace apps",
5
5
  "license": "MIT",
6
6
  "type": "module",