@dotbots-boutique/auth-sdk 1.0.23 → 1.0.25
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 +3 -3
- package/dist/cjs/index.js +9 -47
- package/dist/esm/index.js +9 -47
- package/dist/types/DotBotsAuth.d.ts +1 -1
- package/dist/types/index.js +9 -47
- package/dist/types/types.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# @dotbots-boutique/auth-sdk
|
|
2
2
|
|
|
3
|
-
The official authentication and authorisation SDK for apps running on the [DotBots Boutique](https://dotbots.boutique) platform.
|
|
3
|
+
The official authentication and authorisation SDK for apps running on the [DotBots Boutique](https://marketplace.dotbots.boutique) platform.
|
|
4
4
|
|
|
5
5
|
## What is DotBots Boutique?
|
|
6
6
|
|
|
7
|
-
[DotBots Boutique](https://dotbots.boutique) is a marketplace platform where vibe coders build and publish apps. The platform handles user management, authentication, authorisation, payments, and infrastructure, and offers a growing set of additional services — so you can focus on building your app.
|
|
7
|
+
[DotBots Boutique](https://marketplace.dotbots.boutique) is a marketplace platform where vibe coders build and publish apps. The platform handles user management, authentication, authorisation, payments, and infrastructure, and offers a growing set of additional services — so you can focus on building your app.
|
|
8
8
|
|
|
9
9
|
---
|
|
10
10
|
|
|
@@ -351,7 +351,7 @@ try {
|
|
|
351
351
|
interface DotBotsConfig {
|
|
352
352
|
appId: string; // Required — app ID assigned by the platform
|
|
353
353
|
apiUrl: string; // Required — always 'https://api.dotbots.ai'
|
|
354
|
-
marketplaceOrigin?: string; // Default: 'https://dotbots.boutique'
|
|
354
|
+
marketplaceOrigin?: string; // Default: 'https://marketplace.dotbots.boutique'
|
|
355
355
|
tokenRefreshBuffer?: number; // Default: 60000 (ms before expiry to refresh)
|
|
356
356
|
iframeTimeout?: number; // Default: 5000 (ms to wait for auth code)
|
|
357
357
|
onTokenRefreshFailed?: () => void; // Called when token refresh fails
|
package/dist/cjs/index.js
CHANGED
|
@@ -267,7 +267,7 @@ class DotBotsAuth {
|
|
|
267
267
|
};
|
|
268
268
|
this.config = config;
|
|
269
269
|
this.environment = this.detectEnvironment();
|
|
270
|
-
this.marketplaceOrigin = config.marketplaceOrigin ?? 'https://dotbots.boutique';
|
|
270
|
+
this.marketplaceOrigin = config.marketplaceOrigin ?? 'https://marketplace.dotbots.boutique';
|
|
271
271
|
console.warn(`[DotBotsAuth] SDK v${DotBotsAuth.SDK_VERSION} — env: ${this.environment}, appId: ${config.appId}`);
|
|
272
272
|
this.tokenManager = new TokenManager(config, this.environment, () => this.emit('tokenRefreshed'), () => this.emit('sessionExpired'), () => this.proxyConfigManager.getBaseUrl());
|
|
273
273
|
this.postMessageHandler = new PostMessageHandler(this.marketplaceOrigin);
|
|
@@ -284,7 +284,7 @@ class DotBotsAuth {
|
|
|
284
284
|
// Redirect to marketplace if opened directly (not in iframe)
|
|
285
285
|
if (!this.postMessageHandler.isInIframe()) {
|
|
286
286
|
const mode = this.environment === 'test' ? '?mode=test' : '';
|
|
287
|
-
window.location.href = `https://dotbots.boutique/boutique/${this.config.appId}/open${mode}`;
|
|
287
|
+
window.location.href = `https://marketplace.dotbots.boutique/boutique/${this.config.appId}/open${mode}`;
|
|
288
288
|
return;
|
|
289
289
|
}
|
|
290
290
|
// Step 1 — Fetch proxy config
|
|
@@ -396,41 +396,9 @@ class DotBotsAuth {
|
|
|
396
396
|
}
|
|
397
397
|
async ai(feature, request, onDelta) {
|
|
398
398
|
this.assertInitialized();
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
return new Promise((resolve, reject) => {
|
|
402
|
-
this.aiStream(feature, request, onDelta, resolve).catch(reject);
|
|
403
|
-
});
|
|
404
|
-
}
|
|
405
|
-
const baseUrl = this.proxyConfigManager.getBaseUrl();
|
|
406
|
-
console.warn(`[DotBotsAuth] ai() — feature: ${feature}, messages: ${request.messages.length}`);
|
|
407
|
-
const response = await this.buildRequest(`${baseUrl}/ai/call`, {
|
|
408
|
-
method: 'POST',
|
|
409
|
-
headers: { 'Content-Type': 'application/json' },
|
|
410
|
-
body: JSON.stringify({
|
|
411
|
-
feature,
|
|
412
|
-
messages: request.messages,
|
|
413
|
-
tools: request.tools,
|
|
414
|
-
stream: false,
|
|
415
|
-
maxTokens: request.maxTokens,
|
|
416
|
-
}),
|
|
399
|
+
return new Promise((resolve, reject) => {
|
|
400
|
+
this.aiStream(feature, request, onDelta ?? (() => { }), resolve).catch(reject);
|
|
417
401
|
});
|
|
418
|
-
if (response.status === 402) {
|
|
419
|
-
console.error('[DotBotsAuth] ai() failed — 402: insufficient balance');
|
|
420
|
-
throw new DotBotsAuthError('AI_INSUFFICIENT_BALANCE', 'Insufficient balance for AI call');
|
|
421
|
-
}
|
|
422
|
-
if (response.status === 400) {
|
|
423
|
-
const body = await response.json();
|
|
424
|
-
console.error(`[DotBotsAuth] ai() failed — 400: ${body.error}`);
|
|
425
|
-
throw new DotBotsAuthError(body.error || 'AI_FEATURE_NOT_FOUND', body.message ?? 'AI request failed');
|
|
426
|
-
}
|
|
427
|
-
if (!response.ok) {
|
|
428
|
-
console.error(`[DotBotsAuth] ai() failed — HTTP ${response.status}`);
|
|
429
|
-
throw new DotBotsAuthError('AI_CALL_FAILED', `AI call failed: ${response.status}`);
|
|
430
|
-
}
|
|
431
|
-
const data = await response.json();
|
|
432
|
-
console.warn(`[DotBotsAuth] ai() success — model: ${data.model}, tokens: ${data.usage.totalTokens}, transactionId: ${data.transactionId}`);
|
|
433
|
-
return data;
|
|
434
402
|
}
|
|
435
403
|
async aiStream(feature, request, onDelta, onDone) {
|
|
436
404
|
this.assertInitialized();
|
|
@@ -474,17 +442,11 @@ class DotBotsAuth {
|
|
|
474
442
|
onDelta(data.delta);
|
|
475
443
|
}
|
|
476
444
|
else if (data.type === 'done') {
|
|
477
|
-
const finalResponse = {
|
|
478
|
-
content: '',
|
|
479
|
-
model: data.model,
|
|
480
|
-
provider: data.provider,
|
|
481
|
-
usage: data.usage,
|
|
482
|
-
cost: data.cost,
|
|
483
|
-
transactionId: data.transactionId,
|
|
484
|
-
toolCalls: data.toolCalls,
|
|
485
|
-
};
|
|
486
445
|
console.warn(`[DotBotsAuth] aiStream() done — model: ${data.model}, tokens: ${data.usage.totalTokens}, transactionId: ${data.transactionId}`);
|
|
487
|
-
onDone?.(
|
|
446
|
+
onDone?.(data);
|
|
447
|
+
}
|
|
448
|
+
else if (data.type === 'error') {
|
|
449
|
+
throw new DotBotsAuthError(data.error ?? 'AI_CALL_FAILED', data.message ?? 'AI call failed');
|
|
488
450
|
}
|
|
489
451
|
}
|
|
490
452
|
}
|
|
@@ -618,7 +580,7 @@ class DotBotsAuth {
|
|
|
618
580
|
}
|
|
619
581
|
}
|
|
620
582
|
}
|
|
621
|
-
DotBotsAuth.SDK_VERSION = '1.0.
|
|
583
|
+
DotBotsAuth.SDK_VERSION = '1.0.25';
|
|
622
584
|
|
|
623
585
|
exports.DotBotsAuth = DotBotsAuth;
|
|
624
586
|
exports.DotBotsAuthError = DotBotsAuthError;
|
package/dist/esm/index.js
CHANGED
|
@@ -265,7 +265,7 @@ class DotBotsAuth {
|
|
|
265
265
|
};
|
|
266
266
|
this.config = config;
|
|
267
267
|
this.environment = this.detectEnvironment();
|
|
268
|
-
this.marketplaceOrigin = config.marketplaceOrigin ?? 'https://dotbots.boutique';
|
|
268
|
+
this.marketplaceOrigin = config.marketplaceOrigin ?? 'https://marketplace.dotbots.boutique';
|
|
269
269
|
console.warn(`[DotBotsAuth] SDK v${DotBotsAuth.SDK_VERSION} — env: ${this.environment}, appId: ${config.appId}`);
|
|
270
270
|
this.tokenManager = new TokenManager(config, this.environment, () => this.emit('tokenRefreshed'), () => this.emit('sessionExpired'), () => this.proxyConfigManager.getBaseUrl());
|
|
271
271
|
this.postMessageHandler = new PostMessageHandler(this.marketplaceOrigin);
|
|
@@ -282,7 +282,7 @@ class DotBotsAuth {
|
|
|
282
282
|
// Redirect to marketplace if opened directly (not in iframe)
|
|
283
283
|
if (!this.postMessageHandler.isInIframe()) {
|
|
284
284
|
const mode = this.environment === 'test' ? '?mode=test' : '';
|
|
285
|
-
window.location.href = `https://dotbots.boutique/boutique/${this.config.appId}/open${mode}`;
|
|
285
|
+
window.location.href = `https://marketplace.dotbots.boutique/boutique/${this.config.appId}/open${mode}`;
|
|
286
286
|
return;
|
|
287
287
|
}
|
|
288
288
|
// Step 1 — Fetch proxy config
|
|
@@ -394,41 +394,9 @@ class DotBotsAuth {
|
|
|
394
394
|
}
|
|
395
395
|
async ai(feature, request, onDelta) {
|
|
396
396
|
this.assertInitialized();
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
return new Promise((resolve, reject) => {
|
|
400
|
-
this.aiStream(feature, request, onDelta, resolve).catch(reject);
|
|
401
|
-
});
|
|
402
|
-
}
|
|
403
|
-
const baseUrl = this.proxyConfigManager.getBaseUrl();
|
|
404
|
-
console.warn(`[DotBotsAuth] ai() — feature: ${feature}, messages: ${request.messages.length}`);
|
|
405
|
-
const response = await this.buildRequest(`${baseUrl}/ai/call`, {
|
|
406
|
-
method: 'POST',
|
|
407
|
-
headers: { 'Content-Type': 'application/json' },
|
|
408
|
-
body: JSON.stringify({
|
|
409
|
-
feature,
|
|
410
|
-
messages: request.messages,
|
|
411
|
-
tools: request.tools,
|
|
412
|
-
stream: false,
|
|
413
|
-
maxTokens: request.maxTokens,
|
|
414
|
-
}),
|
|
397
|
+
return new Promise((resolve, reject) => {
|
|
398
|
+
this.aiStream(feature, request, onDelta ?? (() => { }), resolve).catch(reject);
|
|
415
399
|
});
|
|
416
|
-
if (response.status === 402) {
|
|
417
|
-
console.error('[DotBotsAuth] ai() failed — 402: insufficient balance');
|
|
418
|
-
throw new DotBotsAuthError('AI_INSUFFICIENT_BALANCE', 'Insufficient balance for AI call');
|
|
419
|
-
}
|
|
420
|
-
if (response.status === 400) {
|
|
421
|
-
const body = await response.json();
|
|
422
|
-
console.error(`[DotBotsAuth] ai() failed — 400: ${body.error}`);
|
|
423
|
-
throw new DotBotsAuthError(body.error || 'AI_FEATURE_NOT_FOUND', body.message ?? 'AI request failed');
|
|
424
|
-
}
|
|
425
|
-
if (!response.ok) {
|
|
426
|
-
console.error(`[DotBotsAuth] ai() failed — HTTP ${response.status}`);
|
|
427
|
-
throw new DotBotsAuthError('AI_CALL_FAILED', `AI call failed: ${response.status}`);
|
|
428
|
-
}
|
|
429
|
-
const data = await response.json();
|
|
430
|
-
console.warn(`[DotBotsAuth] ai() success — model: ${data.model}, tokens: ${data.usage.totalTokens}, transactionId: ${data.transactionId}`);
|
|
431
|
-
return data;
|
|
432
400
|
}
|
|
433
401
|
async aiStream(feature, request, onDelta, onDone) {
|
|
434
402
|
this.assertInitialized();
|
|
@@ -472,17 +440,11 @@ class DotBotsAuth {
|
|
|
472
440
|
onDelta(data.delta);
|
|
473
441
|
}
|
|
474
442
|
else if (data.type === 'done') {
|
|
475
|
-
const finalResponse = {
|
|
476
|
-
content: '',
|
|
477
|
-
model: data.model,
|
|
478
|
-
provider: data.provider,
|
|
479
|
-
usage: data.usage,
|
|
480
|
-
cost: data.cost,
|
|
481
|
-
transactionId: data.transactionId,
|
|
482
|
-
toolCalls: data.toolCalls,
|
|
483
|
-
};
|
|
484
443
|
console.warn(`[DotBotsAuth] aiStream() done — model: ${data.model}, tokens: ${data.usage.totalTokens}, transactionId: ${data.transactionId}`);
|
|
485
|
-
onDone?.(
|
|
444
|
+
onDone?.(data);
|
|
445
|
+
}
|
|
446
|
+
else if (data.type === 'error') {
|
|
447
|
+
throw new DotBotsAuthError(data.error ?? 'AI_CALL_FAILED', data.message ?? 'AI call failed');
|
|
486
448
|
}
|
|
487
449
|
}
|
|
488
450
|
}
|
|
@@ -616,6 +578,6 @@ class DotBotsAuth {
|
|
|
616
578
|
}
|
|
617
579
|
}
|
|
618
580
|
}
|
|
619
|
-
DotBotsAuth.SDK_VERSION = '1.0.
|
|
581
|
+
DotBotsAuth.SDK_VERSION = '1.0.25';
|
|
620
582
|
|
|
621
583
|
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.
|
|
14
|
+
static readonly SDK_VERSION = "1.0.25";
|
|
15
15
|
constructor(config: DotBotsConfig);
|
|
16
16
|
initialize(): Promise<void>;
|
|
17
17
|
private _doInitialize;
|
package/dist/types/index.js
CHANGED
|
@@ -265,7 +265,7 @@ class DotBotsAuth {
|
|
|
265
265
|
};
|
|
266
266
|
this.config = config;
|
|
267
267
|
this.environment = this.detectEnvironment();
|
|
268
|
-
this.marketplaceOrigin = config.marketplaceOrigin ?? 'https://dotbots.boutique';
|
|
268
|
+
this.marketplaceOrigin = config.marketplaceOrigin ?? 'https://marketplace.dotbots.boutique';
|
|
269
269
|
console.warn(`[DotBotsAuth] SDK v${DotBotsAuth.SDK_VERSION} — env: ${this.environment}, appId: ${config.appId}`);
|
|
270
270
|
this.tokenManager = new TokenManager(config, this.environment, () => this.emit('tokenRefreshed'), () => this.emit('sessionExpired'), () => this.proxyConfigManager.getBaseUrl());
|
|
271
271
|
this.postMessageHandler = new PostMessageHandler(this.marketplaceOrigin);
|
|
@@ -282,7 +282,7 @@ class DotBotsAuth {
|
|
|
282
282
|
// Redirect to marketplace if opened directly (not in iframe)
|
|
283
283
|
if (!this.postMessageHandler.isInIframe()) {
|
|
284
284
|
const mode = this.environment === 'test' ? '?mode=test' : '';
|
|
285
|
-
window.location.href = `https://dotbots.boutique/boutique/${this.config.appId}/open${mode}`;
|
|
285
|
+
window.location.href = `https://marketplace.dotbots.boutique/boutique/${this.config.appId}/open${mode}`;
|
|
286
286
|
return;
|
|
287
287
|
}
|
|
288
288
|
// Step 1 — Fetch proxy config
|
|
@@ -394,41 +394,9 @@ class DotBotsAuth {
|
|
|
394
394
|
}
|
|
395
395
|
async ai(feature, request, onDelta) {
|
|
396
396
|
this.assertInitialized();
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
return new Promise((resolve, reject) => {
|
|
400
|
-
this.aiStream(feature, request, onDelta, resolve).catch(reject);
|
|
401
|
-
});
|
|
402
|
-
}
|
|
403
|
-
const baseUrl = this.proxyConfigManager.getBaseUrl();
|
|
404
|
-
console.warn(`[DotBotsAuth] ai() — feature: ${feature}, messages: ${request.messages.length}`);
|
|
405
|
-
const response = await this.buildRequest(`${baseUrl}/ai/call`, {
|
|
406
|
-
method: 'POST',
|
|
407
|
-
headers: { 'Content-Type': 'application/json' },
|
|
408
|
-
body: JSON.stringify({
|
|
409
|
-
feature,
|
|
410
|
-
messages: request.messages,
|
|
411
|
-
tools: request.tools,
|
|
412
|
-
stream: false,
|
|
413
|
-
maxTokens: request.maxTokens,
|
|
414
|
-
}),
|
|
397
|
+
return new Promise((resolve, reject) => {
|
|
398
|
+
this.aiStream(feature, request, onDelta ?? (() => { }), resolve).catch(reject);
|
|
415
399
|
});
|
|
416
|
-
if (response.status === 402) {
|
|
417
|
-
console.error('[DotBotsAuth] ai() failed — 402: insufficient balance');
|
|
418
|
-
throw new DotBotsAuthError('AI_INSUFFICIENT_BALANCE', 'Insufficient balance for AI call');
|
|
419
|
-
}
|
|
420
|
-
if (response.status === 400) {
|
|
421
|
-
const body = await response.json();
|
|
422
|
-
console.error(`[DotBotsAuth] ai() failed — 400: ${body.error}`);
|
|
423
|
-
throw new DotBotsAuthError(body.error || 'AI_FEATURE_NOT_FOUND', body.message ?? 'AI request failed');
|
|
424
|
-
}
|
|
425
|
-
if (!response.ok) {
|
|
426
|
-
console.error(`[DotBotsAuth] ai() failed — HTTP ${response.status}`);
|
|
427
|
-
throw new DotBotsAuthError('AI_CALL_FAILED', `AI call failed: ${response.status}`);
|
|
428
|
-
}
|
|
429
|
-
const data = await response.json();
|
|
430
|
-
console.warn(`[DotBotsAuth] ai() success — model: ${data.model}, tokens: ${data.usage.totalTokens}, transactionId: ${data.transactionId}`);
|
|
431
|
-
return data;
|
|
432
400
|
}
|
|
433
401
|
async aiStream(feature, request, onDelta, onDone) {
|
|
434
402
|
this.assertInitialized();
|
|
@@ -472,17 +440,11 @@ class DotBotsAuth {
|
|
|
472
440
|
onDelta(data.delta);
|
|
473
441
|
}
|
|
474
442
|
else if (data.type === 'done') {
|
|
475
|
-
const finalResponse = {
|
|
476
|
-
content: '',
|
|
477
|
-
model: data.model,
|
|
478
|
-
provider: data.provider,
|
|
479
|
-
usage: data.usage,
|
|
480
|
-
cost: data.cost,
|
|
481
|
-
transactionId: data.transactionId,
|
|
482
|
-
toolCalls: data.toolCalls,
|
|
483
|
-
};
|
|
484
443
|
console.warn(`[DotBotsAuth] aiStream() done — model: ${data.model}, tokens: ${data.usage.totalTokens}, transactionId: ${data.transactionId}`);
|
|
485
|
-
onDone?.(
|
|
444
|
+
onDone?.(data);
|
|
445
|
+
}
|
|
446
|
+
else if (data.type === 'error') {
|
|
447
|
+
throw new DotBotsAuthError(data.error ?? 'AI_CALL_FAILED', data.message ?? 'AI call failed');
|
|
486
448
|
}
|
|
487
449
|
}
|
|
488
450
|
}
|
|
@@ -616,6 +578,6 @@ class DotBotsAuth {
|
|
|
616
578
|
}
|
|
617
579
|
}
|
|
618
580
|
}
|
|
619
|
-
DotBotsAuth.SDK_VERSION = '1.0.
|
|
581
|
+
DotBotsAuth.SDK_VERSION = '1.0.25';
|
|
620
582
|
|
|
621
583
|
export { DotBotsAuth, DotBotsAuthError };
|
package/dist/types/types.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export interface DotBotsConfig {
|
|
|
8
8
|
appId: string;
|
|
9
9
|
/** Base URL of the DotBots API */
|
|
10
10
|
apiUrl: string;
|
|
11
|
-
/** Origin of the marketplace (default: 'https://dotbots.boutique') */
|
|
11
|
+
/** Origin of the marketplace (default: 'https://marketplace.dotbots.boutique') */
|
|
12
12
|
marketplaceOrigin?: string;
|
|
13
13
|
/** Milliseconds before token expiry to trigger refresh (default: 60000) */
|
|
14
14
|
tokenRefreshBuffer?: number;
|