@dotbots-boutique/auth-sdk 1.0.18 → 1.0.19
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 +8 -2
- package/dist/cjs/react/index.js +1 -1
- package/dist/esm/index.js +8 -2
- package/dist/esm/react/index.js +1 -1
- package/dist/types/DotBotsAuth.d.ts +2 -2
- package/dist/types/index.js +8 -2
- package/dist/types/react/DotBotsAuthProvider.d.ts +1 -1
- package/dist/types/react/index.js +1 -1
- package/dist/types/types.d.ts +1 -1
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -382,8 +382,14 @@ class DotBotsAuth {
|
|
|
382
382
|
this.emit('charged');
|
|
383
383
|
return data;
|
|
384
384
|
}
|
|
385
|
-
async ai(feature, request) {
|
|
385
|
+
async ai(feature, request, onDelta) {
|
|
386
386
|
this.assertInitialized();
|
|
387
|
+
const stream = onDelta !== undefined;
|
|
388
|
+
if (stream) {
|
|
389
|
+
return new Promise((resolve, reject) => {
|
|
390
|
+
this.aiStream(feature, request, onDelta, resolve).catch(reject);
|
|
391
|
+
});
|
|
392
|
+
}
|
|
387
393
|
const baseUrl = this.proxyConfigManager.getBaseUrl();
|
|
388
394
|
console.warn(`[DotBotsAuth] ai() — feature: ${feature}, messages: ${request.messages.length}`);
|
|
389
395
|
const response = await this.buildRequest(`${baseUrl}/ai/call`, {
|
|
@@ -566,7 +572,7 @@ class DotBotsAuth {
|
|
|
566
572
|
}
|
|
567
573
|
}
|
|
568
574
|
}
|
|
569
|
-
DotBotsAuth.SDK_VERSION = '1.0.
|
|
575
|
+
DotBotsAuth.SDK_VERSION = '1.0.19';
|
|
570
576
|
|
|
571
577
|
exports.DotBotsAuth = DotBotsAuth;
|
|
572
578
|
exports.DotBotsAuthError = DotBotsAuthError;
|
package/dist/cjs/react/index.js
CHANGED
|
@@ -59,7 +59,7 @@ function DotBotsAuthProvider({ auth, children, loadingComponent, errorComponent,
|
|
|
59
59
|
hasRole: (role) => auth.hasRole(role),
|
|
60
60
|
fetch: (url, options) => auth.fetch(url, options),
|
|
61
61
|
charge: (featureCode, paidBy, quantity) => auth.charge(featureCode, paidBy, quantity),
|
|
62
|
-
ai: (feature, request) => auth.ai(feature, request),
|
|
62
|
+
ai: (feature, request, onDelta) => auth.ai(feature, request, onDelta),
|
|
63
63
|
aiStream: (feature, request, onDelta, onDone) => auth.aiStream(feature, request, onDelta, onDone),
|
|
64
64
|
logout: () => auth.logout(),
|
|
65
65
|
};
|
package/dist/esm/index.js
CHANGED
|
@@ -380,8 +380,14 @@ class DotBotsAuth {
|
|
|
380
380
|
this.emit('charged');
|
|
381
381
|
return data;
|
|
382
382
|
}
|
|
383
|
-
async ai(feature, request) {
|
|
383
|
+
async ai(feature, request, onDelta) {
|
|
384
384
|
this.assertInitialized();
|
|
385
|
+
const stream = onDelta !== undefined;
|
|
386
|
+
if (stream) {
|
|
387
|
+
return new Promise((resolve, reject) => {
|
|
388
|
+
this.aiStream(feature, request, onDelta, resolve).catch(reject);
|
|
389
|
+
});
|
|
390
|
+
}
|
|
385
391
|
const baseUrl = this.proxyConfigManager.getBaseUrl();
|
|
386
392
|
console.warn(`[DotBotsAuth] ai() — feature: ${feature}, messages: ${request.messages.length}`);
|
|
387
393
|
const response = await this.buildRequest(`${baseUrl}/ai/call`, {
|
|
@@ -564,6 +570,6 @@ class DotBotsAuth {
|
|
|
564
570
|
}
|
|
565
571
|
}
|
|
566
572
|
}
|
|
567
|
-
DotBotsAuth.SDK_VERSION = '1.0.
|
|
573
|
+
DotBotsAuth.SDK_VERSION = '1.0.19';
|
|
568
574
|
|
|
569
575
|
export { DotBotsAuth, DotBotsAuthError };
|
package/dist/esm/react/index.js
CHANGED
|
@@ -57,7 +57,7 @@ function DotBotsAuthProvider({ auth, children, loadingComponent, errorComponent,
|
|
|
57
57
|
hasRole: (role) => auth.hasRole(role),
|
|
58
58
|
fetch: (url, options) => auth.fetch(url, options),
|
|
59
59
|
charge: (featureCode, paidBy, quantity) => auth.charge(featureCode, paidBy, quantity),
|
|
60
|
-
ai: (feature, request) => auth.ai(feature, request),
|
|
60
|
+
ai: (feature, request, onDelta) => auth.ai(feature, request, onDelta),
|
|
61
61
|
aiStream: (feature, request, onDelta, onDone) => auth.aiStream(feature, request, onDelta, onDone),
|
|
62
62
|
logout: () => auth.logout(),
|
|
63
63
|
};
|
|
@@ -10,7 +10,7 @@ export declare class DotBotsAuth {
|
|
|
10
10
|
private cachedUser;
|
|
11
11
|
private initialized;
|
|
12
12
|
private initializePromise;
|
|
13
|
-
static readonly SDK_VERSION = "1.0.
|
|
13
|
+
static readonly SDK_VERSION = "1.0.19";
|
|
14
14
|
constructor(config: DotBotsConfig);
|
|
15
15
|
initialize(): Promise<void>;
|
|
16
16
|
private _doInitialize;
|
|
@@ -23,7 +23,7 @@ export declare class DotBotsAuth {
|
|
|
23
23
|
charge(featureCode: string, paidBy: 'org' | 'app', quantity?: number): Promise<{
|
|
24
24
|
transactionId: string;
|
|
25
25
|
}>;
|
|
26
|
-
ai(feature: string, request: AiRequest): Promise<AiResponse>;
|
|
26
|
+
ai(feature: string, request: AiRequest, onDelta?: (delta: string) => void): Promise<AiResponse>;
|
|
27
27
|
aiStream(feature: string, request: AiRequest, onDelta: (delta: string) => void, onDone?: (response: AiResponse) => void): Promise<void>;
|
|
28
28
|
logout(): Promise<void>;
|
|
29
29
|
on(event: DotBotsAuthEvent, handler: Function): void;
|
package/dist/types/index.js
CHANGED
|
@@ -380,8 +380,14 @@ class DotBotsAuth {
|
|
|
380
380
|
this.emit('charged');
|
|
381
381
|
return data;
|
|
382
382
|
}
|
|
383
|
-
async ai(feature, request) {
|
|
383
|
+
async ai(feature, request, onDelta) {
|
|
384
384
|
this.assertInitialized();
|
|
385
|
+
const stream = onDelta !== undefined;
|
|
386
|
+
if (stream) {
|
|
387
|
+
return new Promise((resolve, reject) => {
|
|
388
|
+
this.aiStream(feature, request, onDelta, resolve).catch(reject);
|
|
389
|
+
});
|
|
390
|
+
}
|
|
385
391
|
const baseUrl = this.proxyConfigManager.getBaseUrl();
|
|
386
392
|
console.warn(`[DotBotsAuth] ai() — feature: ${feature}, messages: ${request.messages.length}`);
|
|
387
393
|
const response = await this.buildRequest(`${baseUrl}/ai/call`, {
|
|
@@ -564,6 +570,6 @@ class DotBotsAuth {
|
|
|
564
570
|
}
|
|
565
571
|
}
|
|
566
572
|
}
|
|
567
|
-
DotBotsAuth.SDK_VERSION = '1.0.
|
|
573
|
+
DotBotsAuth.SDK_VERSION = '1.0.19';
|
|
568
574
|
|
|
569
575
|
export { DotBotsAuth, DotBotsAuthError };
|
|
@@ -14,7 +14,7 @@ export interface DotBotsAuthContextValue {
|
|
|
14
14
|
charge: (featureCode: string, paidBy: 'org' | 'app', quantity?: number) => Promise<{
|
|
15
15
|
transactionId: string;
|
|
16
16
|
}>;
|
|
17
|
-
ai: (feature: string, request: AiRequest) => Promise<AiResponse>;
|
|
17
|
+
ai: (feature: string, request: AiRequest, onDelta?: (delta: string) => void) => Promise<AiResponse>;
|
|
18
18
|
aiStream: (feature: string, request: AiRequest, onDelta: (delta: string) => void, onDone?: (response: AiResponse) => void) => Promise<void>;
|
|
19
19
|
logout: () => Promise<void>;
|
|
20
20
|
}
|
|
@@ -57,7 +57,7 @@ function DotBotsAuthProvider({ auth, children, loadingComponent, errorComponent,
|
|
|
57
57
|
hasRole: (role) => auth.hasRole(role),
|
|
58
58
|
fetch: (url, options) => auth.fetch(url, options),
|
|
59
59
|
charge: (featureCode, paidBy, quantity) => auth.charge(featureCode, paidBy, quantity),
|
|
60
|
-
ai: (feature, request) => auth.ai(feature, request),
|
|
60
|
+
ai: (feature, request, onDelta) => auth.ai(feature, request, onDelta),
|
|
61
61
|
aiStream: (feature, request, onDelta, onDone) => auth.aiStream(feature, request, onDelta, onDone),
|
|
62
62
|
logout: () => auth.logout(),
|
|
63
63
|
};
|
package/dist/types/types.d.ts
CHANGED
|
@@ -41,7 +41,7 @@ export interface DotBotsProxyConfig {
|
|
|
41
41
|
}
|
|
42
42
|
export type ProxyFeature = 'cache' | 'localdb' | 'webhooks' | 'ratelimit';
|
|
43
43
|
export type DotBotsAuthEvent = 'tokenRefreshed' | 'loggedOut' | 'sessionExpired' | 'userLoaded' | 'charged' | 'userChanged';
|
|
44
|
-
export type DotBotsAuthErrorCode = 'IFRAME_TIMEOUT' | 'CODE_EXPIRED' | 'UNAUTHORIZED' | 'REFRESH_FAILED' | 'NETWORK_ERROR' | 'NOT_INITIALIZED' | 'PROXY_UNAVAILABLE' | 'PAYMENT_FAILED' | 'AI_FEATURE_NOT_FOUND' | 'AI_PROVIDER_NOT_CONFIGURED' | 'AI_INSUFFICIENT_BALANCE' | 'AI_CALL_FAILED' | 'AI_STREAM_ERROR';
|
|
44
|
+
export type DotBotsAuthErrorCode = 'IFRAME_TIMEOUT' | 'CODE_EXPIRED' | 'UNAUTHORIZED' | 'REFRESH_FAILED' | 'NETWORK_ERROR' | 'NOT_INITIALIZED' | 'PROXY_UNAVAILABLE' | 'PAYMENT_FAILED' | 'AI_FEATURE_NOT_FOUND' | 'AI_PROVIDER_NOT_CONFIGURED' | 'AI_INSUFFICIENT_BALANCE' | 'AI_CALL_FAILED' | 'AI_CALL_TIMEOUT' | 'AI_STREAM_ERROR';
|
|
45
45
|
export interface TokenPair {
|
|
46
46
|
accessToken: string;
|
|
47
47
|
refreshToken: string;
|