@dotbots-boutique/auth-sdk 1.0.21 → 1.0.23

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/cjs/index.js CHANGED
@@ -281,15 +281,16 @@ class DotBotsAuth {
281
281
  return this.initializePromise;
282
282
  }
283
283
  async _doInitialize() {
284
+ // Redirect to marketplace if opened directly (not in iframe)
285
+ if (!this.postMessageHandler.isInIframe()) {
286
+ const mode = this.environment === 'test' ? '?mode=test' : '';
287
+ window.location.href = `https://dotbots.boutique/boutique/${this.config.appId}/open${mode}`;
288
+ return;
289
+ }
284
290
  // Step 1 — Fetch proxy config
285
291
  await this.proxyConfigManager.fetchConfig();
286
292
  // Step 2 — Authenticate
287
- if (this.postMessageHandler.isInIframe()) {
288
- await this.initializeIframe();
289
- }
290
- else {
291
- await this.initializeStandalone();
292
- }
293
+ await this.initializeIframe();
293
294
  this.initialized = true;
294
295
  // Step 3 — Forward console output to marketplace when in iframe
295
296
  if (this.postMessageHandler.isInIframe()) {
@@ -498,13 +499,7 @@ class DotBotsAuth {
498
499
  await this.tokenManager.revoke();
499
500
  this.cachedUser = null;
500
501
  this.emit('loggedOut');
501
- if (this.postMessageHandler.isInIframe()) {
502
- this.postMessageHandler.sendLogout();
503
- }
504
- else {
505
- const redirectUri = encodeURIComponent(window.location.origin);
506
- window.location.href = `${this.config.apiUrl}/api/auth/logout?redirectUri=${redirectUri}`;
507
- }
502
+ this.postMessageHandler.sendLogout();
508
503
  }
509
504
  destroy() {
510
505
  console.log = this._console.log;
@@ -544,22 +539,6 @@ class DotBotsAuth {
544
539
  console.warn(`[DotBotsAuth] Received auth code from iframe: ${code.substring(0, 2)}**`);
545
540
  await this.tokenManager.exchangeCode(code);
546
541
  }
547
- async initializeStandalone() {
548
- const url = new URL(window.location.href);
549
- const code = url.searchParams.get('code');
550
- if (code) {
551
- console.warn(`[DotBotsAuth] Received auth code from URL: ${code.substring(0, 2)}**`);
552
- // Remove code from URL immediately
553
- url.searchParams.delete('code');
554
- window.history.replaceState({}, '', url.toString());
555
- await this.tokenManager.exchangeCode(code);
556
- }
557
- else if (!this.tokenManager.isAuthenticated()) {
558
- // Redirect to auth
559
- const redirectUri = encodeURIComponent(window.location.href);
560
- window.location.href = `${this.config.apiUrl}/api/auth/authorize?appId=${this.config.appId}&redirectUri=${redirectUri}`;
561
- }
562
- }
563
542
  interceptConsole() {
564
543
  const appId = this.config.appId;
565
544
  const forward = (level, original) => {
@@ -639,7 +618,7 @@ class DotBotsAuth {
639
618
  }
640
619
  }
641
620
  }
642
- DotBotsAuth.SDK_VERSION = '1.0.21';
621
+ DotBotsAuth.SDK_VERSION = '1.0.23';
643
622
 
644
623
  exports.DotBotsAuth = DotBotsAuth;
645
624
  exports.DotBotsAuthError = DotBotsAuthError;
package/dist/esm/index.js CHANGED
@@ -279,15 +279,16 @@ class DotBotsAuth {
279
279
  return this.initializePromise;
280
280
  }
281
281
  async _doInitialize() {
282
+ // Redirect to marketplace if opened directly (not in iframe)
283
+ if (!this.postMessageHandler.isInIframe()) {
284
+ const mode = this.environment === 'test' ? '?mode=test' : '';
285
+ window.location.href = `https://dotbots.boutique/boutique/${this.config.appId}/open${mode}`;
286
+ return;
287
+ }
282
288
  // Step 1 — Fetch proxy config
283
289
  await this.proxyConfigManager.fetchConfig();
284
290
  // Step 2 — Authenticate
285
- if (this.postMessageHandler.isInIframe()) {
286
- await this.initializeIframe();
287
- }
288
- else {
289
- await this.initializeStandalone();
290
- }
291
+ await this.initializeIframe();
291
292
  this.initialized = true;
292
293
  // Step 3 — Forward console output to marketplace when in iframe
293
294
  if (this.postMessageHandler.isInIframe()) {
@@ -496,13 +497,7 @@ class DotBotsAuth {
496
497
  await this.tokenManager.revoke();
497
498
  this.cachedUser = null;
498
499
  this.emit('loggedOut');
499
- if (this.postMessageHandler.isInIframe()) {
500
- this.postMessageHandler.sendLogout();
501
- }
502
- else {
503
- const redirectUri = encodeURIComponent(window.location.origin);
504
- window.location.href = `${this.config.apiUrl}/api/auth/logout?redirectUri=${redirectUri}`;
505
- }
500
+ this.postMessageHandler.sendLogout();
506
501
  }
507
502
  destroy() {
508
503
  console.log = this._console.log;
@@ -542,22 +537,6 @@ class DotBotsAuth {
542
537
  console.warn(`[DotBotsAuth] Received auth code from iframe: ${code.substring(0, 2)}**`);
543
538
  await this.tokenManager.exchangeCode(code);
544
539
  }
545
- async initializeStandalone() {
546
- const url = new URL(window.location.href);
547
- const code = url.searchParams.get('code');
548
- if (code) {
549
- console.warn(`[DotBotsAuth] Received auth code from URL: ${code.substring(0, 2)}**`);
550
- // Remove code from URL immediately
551
- url.searchParams.delete('code');
552
- window.history.replaceState({}, '', url.toString());
553
- await this.tokenManager.exchangeCode(code);
554
- }
555
- else if (!this.tokenManager.isAuthenticated()) {
556
- // Redirect to auth
557
- const redirectUri = encodeURIComponent(window.location.href);
558
- window.location.href = `${this.config.apiUrl}/api/auth/authorize?appId=${this.config.appId}&redirectUri=${redirectUri}`;
559
- }
560
- }
561
540
  interceptConsole() {
562
541
  const appId = this.config.appId;
563
542
  const forward = (level, original) => {
@@ -637,6 +616,6 @@ class DotBotsAuth {
637
616
  }
638
617
  }
639
618
  }
640
- DotBotsAuth.SDK_VERSION = '1.0.21';
619
+ DotBotsAuth.SDK_VERSION = '1.0.23';
641
620
 
642
621
  export { DotBotsAuth, DotBotsAuthError };
@@ -11,7 +11,7 @@ export declare class DotBotsAuth {
11
11
  private initialized;
12
12
  private initializePromise;
13
13
  private readonly _console;
14
- static readonly SDK_VERSION = "1.0.21";
14
+ static readonly SDK_VERSION = "1.0.23";
15
15
  constructor(config: DotBotsConfig);
16
16
  initialize(): Promise<void>;
17
17
  private _doInitialize;
@@ -36,7 +36,6 @@ export declare class DotBotsAuth {
36
36
  getProxyConfig(): DotBotsProxyConfig | null;
37
37
  private detectEnvironment;
38
38
  private initializeIframe;
39
- private initializeStandalone;
40
39
  private interceptConsole;
41
40
  private buildRequest;
42
41
  private assertInitialized;
@@ -1,3 +1,3 @@
1
1
  export { DotBotsAuth } from './DotBotsAuth.js';
2
2
  export { DotBotsAuthError } from './DotBotsAuthError.js';
3
- export type { DotBotsConfig, DotBotsUser, DotBotsAuthEvent, DotBotsAuthErrorCode, DotBotsProxyConfig, ProxyFeature, DotBotsEnvironment, AiMessage, AiContentBlock, AiTool, AiRequest, AiResponse, AiToolCall, } from './types.js';
3
+ export type { DotBotsConfig, DotBotsUser, DotBotsAuthEvent, DotBotsAuthErrorCode, DotBotsProxyConfig, ProxyFeature, DotBotsEnvironment, AiMessage, AiContentBlock, AiTool, AiRequest, AiResponse, AiImage, AiToolCall, } from './types.js';
@@ -279,15 +279,16 @@ class DotBotsAuth {
279
279
  return this.initializePromise;
280
280
  }
281
281
  async _doInitialize() {
282
+ // Redirect to marketplace if opened directly (not in iframe)
283
+ if (!this.postMessageHandler.isInIframe()) {
284
+ const mode = this.environment === 'test' ? '?mode=test' : '';
285
+ window.location.href = `https://dotbots.boutique/boutique/${this.config.appId}/open${mode}`;
286
+ return;
287
+ }
282
288
  // Step 1 — Fetch proxy config
283
289
  await this.proxyConfigManager.fetchConfig();
284
290
  // Step 2 — Authenticate
285
- if (this.postMessageHandler.isInIframe()) {
286
- await this.initializeIframe();
287
- }
288
- else {
289
- await this.initializeStandalone();
290
- }
291
+ await this.initializeIframe();
291
292
  this.initialized = true;
292
293
  // Step 3 — Forward console output to marketplace when in iframe
293
294
  if (this.postMessageHandler.isInIframe()) {
@@ -496,13 +497,7 @@ class DotBotsAuth {
496
497
  await this.tokenManager.revoke();
497
498
  this.cachedUser = null;
498
499
  this.emit('loggedOut');
499
- if (this.postMessageHandler.isInIframe()) {
500
- this.postMessageHandler.sendLogout();
501
- }
502
- else {
503
- const redirectUri = encodeURIComponent(window.location.origin);
504
- window.location.href = `${this.config.apiUrl}/api/auth/logout?redirectUri=${redirectUri}`;
505
- }
500
+ this.postMessageHandler.sendLogout();
506
501
  }
507
502
  destroy() {
508
503
  console.log = this._console.log;
@@ -542,22 +537,6 @@ class DotBotsAuth {
542
537
  console.warn(`[DotBotsAuth] Received auth code from iframe: ${code.substring(0, 2)}**`);
543
538
  await this.tokenManager.exchangeCode(code);
544
539
  }
545
- async initializeStandalone() {
546
- const url = new URL(window.location.href);
547
- const code = url.searchParams.get('code');
548
- if (code) {
549
- console.warn(`[DotBotsAuth] Received auth code from URL: ${code.substring(0, 2)}**`);
550
- // Remove code from URL immediately
551
- url.searchParams.delete('code');
552
- window.history.replaceState({}, '', url.toString());
553
- await this.tokenManager.exchangeCode(code);
554
- }
555
- else if (!this.tokenManager.isAuthenticated()) {
556
- // Redirect to auth
557
- const redirectUri = encodeURIComponent(window.location.href);
558
- window.location.href = `${this.config.apiUrl}/api/auth/authorize?appId=${this.config.appId}&redirectUri=${redirectUri}`;
559
- }
560
- }
561
540
  interceptConsole() {
562
541
  const appId = this.config.appId;
563
542
  const forward = (level, original) => {
@@ -637,6 +616,6 @@ class DotBotsAuth {
637
616
  }
638
617
  }
639
618
  }
640
- DotBotsAuth.SDK_VERSION = '1.0.21';
619
+ DotBotsAuth.SDK_VERSION = '1.0.23';
641
620
 
642
621
  export { DotBotsAuth, DotBotsAuthError };
@@ -69,8 +69,17 @@ export interface AiRequest {
69
69
  tools?: AiTool[];
70
70
  maxTokens?: number;
71
71
  }
72
+ export interface AiImage {
73
+ mimeType: string;
74
+ data: string;
75
+ url: string;
76
+ }
72
77
  export interface AiResponse {
73
78
  content: string;
79
+ images?: AiImage[];
80
+ imageUrl?: string;
81
+ image_url?: string;
82
+ image?: AiImage;
74
83
  model: string;
75
84
  provider: string;
76
85
  usage: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dotbots-boutique/auth-sdk",
3
- "version": "1.0.21",
3
+ "version": "1.0.23",
4
4
  "description": "Authentication SDK for DotBots marketplace apps",
5
5
  "license": "MIT",
6
6
  "type": "module",