@dotbots-boutique/auth-sdk 1.0.19 → 1.0.21

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
@@ -258,10 +258,17 @@ class DotBotsAuth {
258
258
  this.cachedUser = null;
259
259
  this.initialized = false;
260
260
  this.initializePromise = null;
261
+ // Original console methods stored for restore
262
+ this._console = {
263
+ log: console.log.bind(console),
264
+ info: console.info.bind(console),
265
+ warn: console.warn.bind(console),
266
+ error: console.error.bind(console),
267
+ };
261
268
  this.config = config;
262
269
  this.environment = this.detectEnvironment();
263
- console.warn(`[DotBotsAuth] SDK v${DotBotsAuth.SDK_VERSION} — env: ${this.environment}, appId: ${config.appId}`);
264
270
  this.marketplaceOrigin = config.marketplaceOrigin ?? 'https://dotbots.boutique';
271
+ console.warn(`[DotBotsAuth] SDK v${DotBotsAuth.SDK_VERSION} — env: ${this.environment}, appId: ${config.appId}`);
265
272
  this.tokenManager = new TokenManager(config, this.environment, () => this.emit('tokenRefreshed'), () => this.emit('sessionExpired'), () => this.proxyConfigManager.getBaseUrl());
266
273
  this.postMessageHandler = new PostMessageHandler(this.marketplaceOrigin);
267
274
  this.proxyConfigManager = new ProxyConfigManager(config.apiUrl, config.appId, this.environment);
@@ -284,6 +291,10 @@ class DotBotsAuth {
284
291
  await this.initializeStandalone();
285
292
  }
286
293
  this.initialized = true;
294
+ // Step 3 — Forward console output to marketplace when in iframe
295
+ if (this.postMessageHandler.isInIframe()) {
296
+ this.interceptConsole();
297
+ }
287
298
  // Listen for user switch (new auth code from marketplace after init)
288
299
  window.addEventListener('message', async (event) => {
289
300
  if (event.origin !== this.marketplaceOrigin)
@@ -495,6 +506,12 @@ class DotBotsAuth {
495
506
  window.location.href = `${this.config.apiUrl}/api/auth/logout?redirectUri=${redirectUri}`;
496
507
  }
497
508
  }
509
+ destroy() {
510
+ console.log = this._console.log;
511
+ console.info = this._console.info;
512
+ console.warn = this._console.warn;
513
+ console.error = this._console.error;
514
+ }
498
515
  on(event, handler) {
499
516
  if (!this.listeners.has(event)) {
500
517
  this.listeners.set(event, new Set());
@@ -543,6 +560,56 @@ class DotBotsAuth {
543
560
  window.location.href = `${this.config.apiUrl}/api/auth/authorize?appId=${this.config.appId}&redirectUri=${redirectUri}`;
544
561
  }
545
562
  }
563
+ interceptConsole() {
564
+ const appId = this.config.appId;
565
+ const forward = (level, original) => {
566
+ return (...args) => {
567
+ original(...args);
568
+ window.parent.postMessage({
569
+ type: 'DOTBOTS_LOG',
570
+ level,
571
+ message: args.map(a => {
572
+ if (typeof a === 'object' && a !== null) {
573
+ try {
574
+ return JSON.stringify(a);
575
+ }
576
+ catch {
577
+ return String(a);
578
+ }
579
+ }
580
+ return String(a);
581
+ }).join(' '),
582
+ timestamp: new Date().toISOString(),
583
+ appId,
584
+ }, '*');
585
+ };
586
+ };
587
+ console.log = forward('info', this._console.log);
588
+ console.info = forward('info', this._console.info);
589
+ console.warn = forward('warn', this._console.warn);
590
+ console.error = forward('error', this._console.error);
591
+ window.addEventListener('error', (event) => {
592
+ window.parent.postMessage({
593
+ type: 'DOTBOTS_LOG',
594
+ level: 'error',
595
+ message: `Uncaught error: ${event.message} (${event.filename}:${event.lineno}:${event.colno})`,
596
+ timestamp: new Date().toISOString(),
597
+ appId,
598
+ }, '*');
599
+ });
600
+ window.addEventListener('unhandledrejection', (event) => {
601
+ const reason = event.reason instanceof Error
602
+ ? `${event.reason.message}\n${event.reason.stack ?? ''}`
603
+ : String(event.reason);
604
+ window.parent.postMessage({
605
+ type: 'DOTBOTS_LOG',
606
+ level: 'error',
607
+ message: `Unhandled promise rejection: ${reason}`,
608
+ timestamp: new Date().toISOString(),
609
+ appId,
610
+ }, '*');
611
+ });
612
+ }
546
613
  async buildRequest(url, options) {
547
614
  const headers = new Headers(options?.headers);
548
615
  const accessToken = this.tokenManager.getAccessToken();
@@ -572,7 +639,7 @@ class DotBotsAuth {
572
639
  }
573
640
  }
574
641
  }
575
- DotBotsAuth.SDK_VERSION = '1.0.19';
642
+ DotBotsAuth.SDK_VERSION = '1.0.21';
576
643
 
577
644
  exports.DotBotsAuth = DotBotsAuth;
578
645
  exports.DotBotsAuthError = DotBotsAuthError;
package/dist/esm/index.js CHANGED
@@ -256,10 +256,17 @@ class DotBotsAuth {
256
256
  this.cachedUser = null;
257
257
  this.initialized = false;
258
258
  this.initializePromise = null;
259
+ // Original console methods stored for restore
260
+ this._console = {
261
+ log: console.log.bind(console),
262
+ info: console.info.bind(console),
263
+ warn: console.warn.bind(console),
264
+ error: console.error.bind(console),
265
+ };
259
266
  this.config = config;
260
267
  this.environment = this.detectEnvironment();
261
- console.warn(`[DotBotsAuth] SDK v${DotBotsAuth.SDK_VERSION} — env: ${this.environment}, appId: ${config.appId}`);
262
268
  this.marketplaceOrigin = config.marketplaceOrigin ?? 'https://dotbots.boutique';
269
+ console.warn(`[DotBotsAuth] SDK v${DotBotsAuth.SDK_VERSION} — env: ${this.environment}, appId: ${config.appId}`);
263
270
  this.tokenManager = new TokenManager(config, this.environment, () => this.emit('tokenRefreshed'), () => this.emit('sessionExpired'), () => this.proxyConfigManager.getBaseUrl());
264
271
  this.postMessageHandler = new PostMessageHandler(this.marketplaceOrigin);
265
272
  this.proxyConfigManager = new ProxyConfigManager(config.apiUrl, config.appId, this.environment);
@@ -282,6 +289,10 @@ class DotBotsAuth {
282
289
  await this.initializeStandalone();
283
290
  }
284
291
  this.initialized = true;
292
+ // Step 3 — Forward console output to marketplace when in iframe
293
+ if (this.postMessageHandler.isInIframe()) {
294
+ this.interceptConsole();
295
+ }
285
296
  // Listen for user switch (new auth code from marketplace after init)
286
297
  window.addEventListener('message', async (event) => {
287
298
  if (event.origin !== this.marketplaceOrigin)
@@ -493,6 +504,12 @@ class DotBotsAuth {
493
504
  window.location.href = `${this.config.apiUrl}/api/auth/logout?redirectUri=${redirectUri}`;
494
505
  }
495
506
  }
507
+ destroy() {
508
+ console.log = this._console.log;
509
+ console.info = this._console.info;
510
+ console.warn = this._console.warn;
511
+ console.error = this._console.error;
512
+ }
496
513
  on(event, handler) {
497
514
  if (!this.listeners.has(event)) {
498
515
  this.listeners.set(event, new Set());
@@ -541,6 +558,56 @@ class DotBotsAuth {
541
558
  window.location.href = `${this.config.apiUrl}/api/auth/authorize?appId=${this.config.appId}&redirectUri=${redirectUri}`;
542
559
  }
543
560
  }
561
+ interceptConsole() {
562
+ const appId = this.config.appId;
563
+ const forward = (level, original) => {
564
+ return (...args) => {
565
+ original(...args);
566
+ window.parent.postMessage({
567
+ type: 'DOTBOTS_LOG',
568
+ level,
569
+ message: args.map(a => {
570
+ if (typeof a === 'object' && a !== null) {
571
+ try {
572
+ return JSON.stringify(a);
573
+ }
574
+ catch {
575
+ return String(a);
576
+ }
577
+ }
578
+ return String(a);
579
+ }).join(' '),
580
+ timestamp: new Date().toISOString(),
581
+ appId,
582
+ }, '*');
583
+ };
584
+ };
585
+ console.log = forward('info', this._console.log);
586
+ console.info = forward('info', this._console.info);
587
+ console.warn = forward('warn', this._console.warn);
588
+ console.error = forward('error', this._console.error);
589
+ window.addEventListener('error', (event) => {
590
+ window.parent.postMessage({
591
+ type: 'DOTBOTS_LOG',
592
+ level: 'error',
593
+ message: `Uncaught error: ${event.message} (${event.filename}:${event.lineno}:${event.colno})`,
594
+ timestamp: new Date().toISOString(),
595
+ appId,
596
+ }, '*');
597
+ });
598
+ window.addEventListener('unhandledrejection', (event) => {
599
+ const reason = event.reason instanceof Error
600
+ ? `${event.reason.message}\n${event.reason.stack ?? ''}`
601
+ : String(event.reason);
602
+ window.parent.postMessage({
603
+ type: 'DOTBOTS_LOG',
604
+ level: 'error',
605
+ message: `Unhandled promise rejection: ${reason}`,
606
+ timestamp: new Date().toISOString(),
607
+ appId,
608
+ }, '*');
609
+ });
610
+ }
544
611
  async buildRequest(url, options) {
545
612
  const headers = new Headers(options?.headers);
546
613
  const accessToken = this.tokenManager.getAccessToken();
@@ -570,6 +637,6 @@ class DotBotsAuth {
570
637
  }
571
638
  }
572
639
  }
573
- DotBotsAuth.SDK_VERSION = '1.0.19';
640
+ DotBotsAuth.SDK_VERSION = '1.0.21';
574
641
 
575
642
  export { DotBotsAuth, DotBotsAuthError };
@@ -10,7 +10,8 @@ export declare class DotBotsAuth {
10
10
  private cachedUser;
11
11
  private initialized;
12
12
  private initializePromise;
13
- static readonly SDK_VERSION = "1.0.19";
13
+ private readonly _console;
14
+ static readonly SDK_VERSION = "1.0.21";
14
15
  constructor(config: DotBotsConfig);
15
16
  initialize(): Promise<void>;
16
17
  private _doInitialize;
@@ -26,6 +27,7 @@ export declare class DotBotsAuth {
26
27
  ai(feature: string, request: AiRequest, onDelta?: (delta: string) => void): Promise<AiResponse>;
27
28
  aiStream(feature: string, request: AiRequest, onDelta: (delta: string) => void, onDone?: (response: AiResponse) => void): Promise<void>;
28
29
  logout(): Promise<void>;
30
+ destroy(): void;
29
31
  on(event: DotBotsAuthEvent, handler: Function): void;
30
32
  off(event: DotBotsAuthEvent, handler: Function): void;
31
33
  /**
@@ -35,6 +37,7 @@ export declare class DotBotsAuth {
35
37
  private detectEnvironment;
36
38
  private initializeIframe;
37
39
  private initializeStandalone;
40
+ private interceptConsole;
38
41
  private buildRequest;
39
42
  private assertInitialized;
40
43
  private emit;
@@ -256,10 +256,17 @@ class DotBotsAuth {
256
256
  this.cachedUser = null;
257
257
  this.initialized = false;
258
258
  this.initializePromise = null;
259
+ // Original console methods stored for restore
260
+ this._console = {
261
+ log: console.log.bind(console),
262
+ info: console.info.bind(console),
263
+ warn: console.warn.bind(console),
264
+ error: console.error.bind(console),
265
+ };
259
266
  this.config = config;
260
267
  this.environment = this.detectEnvironment();
261
- console.warn(`[DotBotsAuth] SDK v${DotBotsAuth.SDK_VERSION} — env: ${this.environment}, appId: ${config.appId}`);
262
268
  this.marketplaceOrigin = config.marketplaceOrigin ?? 'https://dotbots.boutique';
269
+ console.warn(`[DotBotsAuth] SDK v${DotBotsAuth.SDK_VERSION} — env: ${this.environment}, appId: ${config.appId}`);
263
270
  this.tokenManager = new TokenManager(config, this.environment, () => this.emit('tokenRefreshed'), () => this.emit('sessionExpired'), () => this.proxyConfigManager.getBaseUrl());
264
271
  this.postMessageHandler = new PostMessageHandler(this.marketplaceOrigin);
265
272
  this.proxyConfigManager = new ProxyConfigManager(config.apiUrl, config.appId, this.environment);
@@ -282,6 +289,10 @@ class DotBotsAuth {
282
289
  await this.initializeStandalone();
283
290
  }
284
291
  this.initialized = true;
292
+ // Step 3 — Forward console output to marketplace when in iframe
293
+ if (this.postMessageHandler.isInIframe()) {
294
+ this.interceptConsole();
295
+ }
285
296
  // Listen for user switch (new auth code from marketplace after init)
286
297
  window.addEventListener('message', async (event) => {
287
298
  if (event.origin !== this.marketplaceOrigin)
@@ -493,6 +504,12 @@ class DotBotsAuth {
493
504
  window.location.href = `${this.config.apiUrl}/api/auth/logout?redirectUri=${redirectUri}`;
494
505
  }
495
506
  }
507
+ destroy() {
508
+ console.log = this._console.log;
509
+ console.info = this._console.info;
510
+ console.warn = this._console.warn;
511
+ console.error = this._console.error;
512
+ }
496
513
  on(event, handler) {
497
514
  if (!this.listeners.has(event)) {
498
515
  this.listeners.set(event, new Set());
@@ -541,6 +558,56 @@ class DotBotsAuth {
541
558
  window.location.href = `${this.config.apiUrl}/api/auth/authorize?appId=${this.config.appId}&redirectUri=${redirectUri}`;
542
559
  }
543
560
  }
561
+ interceptConsole() {
562
+ const appId = this.config.appId;
563
+ const forward = (level, original) => {
564
+ return (...args) => {
565
+ original(...args);
566
+ window.parent.postMessage({
567
+ type: 'DOTBOTS_LOG',
568
+ level,
569
+ message: args.map(a => {
570
+ if (typeof a === 'object' && a !== null) {
571
+ try {
572
+ return JSON.stringify(a);
573
+ }
574
+ catch {
575
+ return String(a);
576
+ }
577
+ }
578
+ return String(a);
579
+ }).join(' '),
580
+ timestamp: new Date().toISOString(),
581
+ appId,
582
+ }, '*');
583
+ };
584
+ };
585
+ console.log = forward('info', this._console.log);
586
+ console.info = forward('info', this._console.info);
587
+ console.warn = forward('warn', this._console.warn);
588
+ console.error = forward('error', this._console.error);
589
+ window.addEventListener('error', (event) => {
590
+ window.parent.postMessage({
591
+ type: 'DOTBOTS_LOG',
592
+ level: 'error',
593
+ message: `Uncaught error: ${event.message} (${event.filename}:${event.lineno}:${event.colno})`,
594
+ timestamp: new Date().toISOString(),
595
+ appId,
596
+ }, '*');
597
+ });
598
+ window.addEventListener('unhandledrejection', (event) => {
599
+ const reason = event.reason instanceof Error
600
+ ? `${event.reason.message}\n${event.reason.stack ?? ''}`
601
+ : String(event.reason);
602
+ window.parent.postMessage({
603
+ type: 'DOTBOTS_LOG',
604
+ level: 'error',
605
+ message: `Unhandled promise rejection: ${reason}`,
606
+ timestamp: new Date().toISOString(),
607
+ appId,
608
+ }, '*');
609
+ });
610
+ }
544
611
  async buildRequest(url, options) {
545
612
  const headers = new Headers(options?.headers);
546
613
  const accessToken = this.tokenManager.getAccessToken();
@@ -570,6 +637,6 @@ class DotBotsAuth {
570
637
  }
571
638
  }
572
639
  }
573
- DotBotsAuth.SDK_VERSION = '1.0.19';
640
+ DotBotsAuth.SDK_VERSION = '1.0.21';
574
641
 
575
642
  export { DotBotsAuth, DotBotsAuthError };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dotbots-boutique/auth-sdk",
3
- "version": "1.0.19",
3
+ "version": "1.0.21",
4
4
  "description": "Authentication SDK for DotBots marketplace apps",
5
5
  "license": "MIT",
6
6
  "type": "module",