@dotbots-boutique/auth-sdk 1.0.19 → 1.0.20
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 +48 -2
- package/dist/esm/index.js +48 -2
- package/dist/types/DotBotsAuth.d.ts +4 -1
- package/dist/types/index.js +48 -2
- package/package.json +1 -1
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,35 @@ 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
|
+
}
|
|
546
592
|
async buildRequest(url, options) {
|
|
547
593
|
const headers = new Headers(options?.headers);
|
|
548
594
|
const accessToken = this.tokenManager.getAccessToken();
|
|
@@ -572,7 +618,7 @@ class DotBotsAuth {
|
|
|
572
618
|
}
|
|
573
619
|
}
|
|
574
620
|
}
|
|
575
|
-
DotBotsAuth.SDK_VERSION = '1.0.
|
|
621
|
+
DotBotsAuth.SDK_VERSION = '1.0.20';
|
|
576
622
|
|
|
577
623
|
exports.DotBotsAuth = DotBotsAuth;
|
|
578
624
|
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,35 @@ 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
|
+
}
|
|
544
590
|
async buildRequest(url, options) {
|
|
545
591
|
const headers = new Headers(options?.headers);
|
|
546
592
|
const accessToken = this.tokenManager.getAccessToken();
|
|
@@ -570,6 +616,6 @@ class DotBotsAuth {
|
|
|
570
616
|
}
|
|
571
617
|
}
|
|
572
618
|
}
|
|
573
|
-
DotBotsAuth.SDK_VERSION = '1.0.
|
|
619
|
+
DotBotsAuth.SDK_VERSION = '1.0.20';
|
|
574
620
|
|
|
575
621
|
export { DotBotsAuth, DotBotsAuthError };
|
|
@@ -10,7 +10,8 @@ export declare class DotBotsAuth {
|
|
|
10
10
|
private cachedUser;
|
|
11
11
|
private initialized;
|
|
12
12
|
private initializePromise;
|
|
13
|
-
|
|
13
|
+
private readonly _console;
|
|
14
|
+
static readonly SDK_VERSION = "1.0.20";
|
|
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;
|
package/dist/types/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,35 @@ 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
|
+
}
|
|
544
590
|
async buildRequest(url, options) {
|
|
545
591
|
const headers = new Headers(options?.headers);
|
|
546
592
|
const accessToken = this.tokenManager.getAccessToken();
|
|
@@ -570,6 +616,6 @@ class DotBotsAuth {
|
|
|
570
616
|
}
|
|
571
617
|
}
|
|
572
618
|
}
|
|
573
|
-
DotBotsAuth.SDK_VERSION = '1.0.
|
|
619
|
+
DotBotsAuth.SDK_VERSION = '1.0.20';
|
|
574
620
|
|
|
575
621
|
export { DotBotsAuth, DotBotsAuthError };
|