dexto 1.6.10 → 1.6.11
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/cli/auth/api-client.d.ts +15 -6
- package/dist/cli/auth/api-client.d.ts.map +1 -1
- package/dist/cli/auth/api-client.js +143 -78
- package/dist/cli/auth/constants.d.ts +7 -2
- package/dist/cli/auth/constants.d.ts.map +1 -1
- package/dist/cli/auth/constants.js +7 -2
- package/dist/cli/auth/index.d.ts +1 -1
- package/dist/cli/auth/index.d.ts.map +1 -1
- package/dist/cli/auth/index.js +1 -1
- package/package.json +11 -11
|
@@ -53,17 +53,26 @@ interface RequestOptions {
|
|
|
53
53
|
* Dexto API client for key management
|
|
54
54
|
*/
|
|
55
55
|
export declare class DextoApiClient {
|
|
56
|
-
private readonly
|
|
56
|
+
private readonly gatewayBaseUrl;
|
|
57
|
+
private readonly platformBaseUrl;
|
|
57
58
|
private readonly timeoutMs;
|
|
58
|
-
constructor(baseUrl?: string
|
|
59
|
+
constructor(baseUrl?: string | {
|
|
60
|
+
gatewayBaseUrl?: string | undefined;
|
|
61
|
+
platformBaseUrl?: string | undefined;
|
|
62
|
+
});
|
|
59
63
|
private createRequestSignal;
|
|
64
|
+
private getGatewayUrl;
|
|
65
|
+
private getPlatformUrl;
|
|
66
|
+
private listPlatformApiKeys;
|
|
67
|
+
private createPlatformApiKey;
|
|
68
|
+
private deletePlatformApiKey;
|
|
60
69
|
/**
|
|
61
70
|
* Validate if a Dexto API key is valid
|
|
62
71
|
*/
|
|
63
72
|
validateDextoApiKey(apiKey: string): Promise<boolean>;
|
|
64
73
|
/**
|
|
65
|
-
* Provision Dexto API key
|
|
66
|
-
* @param regenerate - If true, delete existing key and create new one
|
|
74
|
+
* Provision Dexto API key and always return a usable secret key value.
|
|
75
|
+
* @param regenerate - If true, delete existing key(s) and create a new one
|
|
67
76
|
*/
|
|
68
77
|
provisionDextoApiKey(authToken: string, name?: string, regenerate?: boolean): Promise<{
|
|
69
78
|
dextoApiKey: string;
|
|
@@ -75,11 +84,11 @@ export declare class DextoApiClient {
|
|
|
75
84
|
*/
|
|
76
85
|
getUsageSummary(apiKey: string): Promise<UsageSummaryResponse>;
|
|
77
86
|
/**
|
|
78
|
-
* Start device code login at the
|
|
87
|
+
* Start device code login at the platform.
|
|
79
88
|
*/
|
|
80
89
|
startDeviceCodeLogin(client?: string, options?: RequestOptions): Promise<DeviceCodeStartResponse>;
|
|
81
90
|
/**
|
|
82
|
-
* Poll the
|
|
91
|
+
* Poll the platform for device-code login completion.
|
|
83
92
|
*/
|
|
84
93
|
pollDeviceCodeLogin(deviceCode: string, options?: RequestOptions): Promise<DeviceCodePollResponse>;
|
|
85
94
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-client.d.ts","sourceRoot":"","sources":["../../../src/cli/auth/api-client.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"api-client.d.ts","sourceRoot":"","sources":["../../../src/cli/auth/api-client.ts"],"names":[],"mappings":"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"}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
// 3. Use tRPC if we want full-stack type safety
|
|
8
8
|
// Currently using plain fetch() with runtime response validation.
|
|
9
9
|
import { logger } from '@dexto/core';
|
|
10
|
-
import { DEXTO_API_URL, SUPABASE_ANON_KEY, SUPABASE_URL } from './constants.js';
|
|
10
|
+
import { DEXTO_API_URL, DEXTO_PLATFORM_URL, SUPABASE_ANON_KEY, SUPABASE_URL } from './constants.js';
|
|
11
11
|
function parseString(value) {
|
|
12
12
|
return typeof value === 'string' && value.trim().length > 0 ? value : null;
|
|
13
13
|
}
|
|
@@ -26,35 +26,6 @@ function parseNumber(value) {
|
|
|
26
26
|
}
|
|
27
27
|
return null;
|
|
28
28
|
}
|
|
29
|
-
function parseProvisionResponse(payload) {
|
|
30
|
-
if (typeof payload !== 'object' || payload === null) {
|
|
31
|
-
throw new Error('Invalid response from API');
|
|
32
|
-
}
|
|
33
|
-
const success = parseBoolean(Reflect.get(payload, 'success'));
|
|
34
|
-
if (success === null) {
|
|
35
|
-
throw new Error('Invalid response from API');
|
|
36
|
-
}
|
|
37
|
-
const dextoApiKey = parseString(Reflect.get(payload, 'dextoApiKey')) ?? undefined;
|
|
38
|
-
const keyId = parseString(Reflect.get(payload, 'keyId')) ?? undefined;
|
|
39
|
-
const isNewKey = parseBoolean(Reflect.get(payload, 'isNewKey')) ?? undefined;
|
|
40
|
-
const error = parseString(Reflect.get(payload, 'error')) ?? undefined;
|
|
41
|
-
const result = {
|
|
42
|
-
success,
|
|
43
|
-
};
|
|
44
|
-
if (dextoApiKey) {
|
|
45
|
-
result.dextoApiKey = dextoApiKey;
|
|
46
|
-
}
|
|
47
|
-
if (keyId) {
|
|
48
|
-
result.keyId = keyId;
|
|
49
|
-
}
|
|
50
|
-
if (isNewKey !== undefined) {
|
|
51
|
-
result.isNewKey = isNewKey;
|
|
52
|
-
}
|
|
53
|
-
if (error) {
|
|
54
|
-
result.error = error;
|
|
55
|
-
}
|
|
56
|
-
return result;
|
|
57
|
-
}
|
|
58
29
|
function parseDeviceCodeStartResponse(payload) {
|
|
59
30
|
if (typeof payload !== 'object' || payload === null) {
|
|
60
31
|
throw new Error('Invalid device start response');
|
|
@@ -221,6 +192,58 @@ function parseValidateResponse(payload) {
|
|
|
221
192
|
const valid = parseBoolean(Reflect.get(payload, 'valid'));
|
|
222
193
|
return valid ?? false;
|
|
223
194
|
}
|
|
195
|
+
function parsePlatformKeyListResponse(payload) {
|
|
196
|
+
if (typeof payload !== 'object' || payload === null) {
|
|
197
|
+
throw new Error('Invalid response from API');
|
|
198
|
+
}
|
|
199
|
+
const success = parseBoolean(Reflect.get(payload, 'success'));
|
|
200
|
+
if (success !== true) {
|
|
201
|
+
const error = parseString(Reflect.get(payload, 'error'));
|
|
202
|
+
throw new Error(error || 'Failed to fetch API keys');
|
|
203
|
+
}
|
|
204
|
+
const data = Reflect.get(payload, 'data');
|
|
205
|
+
if (!Array.isArray(data)) {
|
|
206
|
+
throw new Error('Invalid response from API');
|
|
207
|
+
}
|
|
208
|
+
const keys = [];
|
|
209
|
+
for (const entry of data) {
|
|
210
|
+
if (typeof entry !== 'object' || entry === null) {
|
|
211
|
+
continue;
|
|
212
|
+
}
|
|
213
|
+
const id = parseString(Reflect.get(entry, 'id'));
|
|
214
|
+
const name = parseString(Reflect.get(entry, 'name'));
|
|
215
|
+
const status = parseString(Reflect.get(entry, 'status'));
|
|
216
|
+
const isActive = parseBoolean(Reflect.get(entry, 'isActive'));
|
|
217
|
+
if (!id || !status || isActive === null) {
|
|
218
|
+
continue;
|
|
219
|
+
}
|
|
220
|
+
keys.push({ id, name, status, isActive });
|
|
221
|
+
}
|
|
222
|
+
return { success: true, data: keys };
|
|
223
|
+
}
|
|
224
|
+
function parsePlatformCreateKeyResponse(payload) {
|
|
225
|
+
if (typeof payload !== 'object' || payload === null) {
|
|
226
|
+
throw new Error('Invalid response from API');
|
|
227
|
+
}
|
|
228
|
+
const success = parseBoolean(Reflect.get(payload, 'success'));
|
|
229
|
+
if (success !== true) {
|
|
230
|
+
const error = parseString(Reflect.get(payload, 'error'));
|
|
231
|
+
return { success: false, error: error || 'Failed to create API key' };
|
|
232
|
+
}
|
|
233
|
+
const data = Reflect.get(payload, 'data');
|
|
234
|
+
if (typeof data !== 'object' || data === null) {
|
|
235
|
+
throw new Error('Invalid response from API');
|
|
236
|
+
}
|
|
237
|
+
const id = parseString(Reflect.get(data, 'id'));
|
|
238
|
+
const fullKey = parseString(Reflect.get(data, 'fullKey'));
|
|
239
|
+
if (!id || !fullKey) {
|
|
240
|
+
throw new Error('Invalid response from API');
|
|
241
|
+
}
|
|
242
|
+
return {
|
|
243
|
+
success: true,
|
|
244
|
+
data: { id, fullKey },
|
|
245
|
+
};
|
|
246
|
+
}
|
|
224
247
|
function formatHttpFailure(status, payload, rawText) {
|
|
225
248
|
if (rawText.trim().length > 0) {
|
|
226
249
|
return `${status} ${rawText}`;
|
|
@@ -234,10 +257,18 @@ function formatHttpFailure(status, payload, rawText) {
|
|
|
234
257
|
* Dexto API client for key management
|
|
235
258
|
*/
|
|
236
259
|
export class DextoApiClient {
|
|
237
|
-
|
|
260
|
+
gatewayBaseUrl;
|
|
261
|
+
platformBaseUrl;
|
|
238
262
|
timeoutMs = 10_000;
|
|
239
|
-
constructor(baseUrl =
|
|
240
|
-
|
|
263
|
+
constructor(baseUrl = {}) {
|
|
264
|
+
if (typeof baseUrl === 'string') {
|
|
265
|
+
const normalized = baseUrl.replace(/\/+$/, '');
|
|
266
|
+
this.gatewayBaseUrl = normalized;
|
|
267
|
+
this.platformBaseUrl = DEXTO_PLATFORM_URL.replace(/\/+$/, '');
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
this.gatewayBaseUrl = (baseUrl.gatewayBaseUrl ?? DEXTO_API_URL).replace(/\/+$/, '');
|
|
271
|
+
this.platformBaseUrl = (baseUrl.platformBaseUrl ?? DEXTO_PLATFORM_URL).replace(/\/+$/, '');
|
|
241
272
|
}
|
|
242
273
|
createRequestSignal(signal) {
|
|
243
274
|
const timeoutSignal = AbortSignal.timeout(this.timeoutMs);
|
|
@@ -246,13 +277,71 @@ export class DextoApiClient {
|
|
|
246
277
|
}
|
|
247
278
|
return AbortSignal.any([signal, timeoutSignal]);
|
|
248
279
|
}
|
|
280
|
+
getGatewayUrl(path) {
|
|
281
|
+
return `${this.gatewayBaseUrl}${path}`;
|
|
282
|
+
}
|
|
283
|
+
getPlatformUrl(path) {
|
|
284
|
+
return `${this.platformBaseUrl}${path}`;
|
|
285
|
+
}
|
|
286
|
+
async listPlatformApiKeys(authToken) {
|
|
287
|
+
const response = await fetch(this.getPlatformUrl('/api/keys'), {
|
|
288
|
+
method: 'GET',
|
|
289
|
+
headers: {
|
|
290
|
+
Authorization: `Bearer ${authToken}`,
|
|
291
|
+
},
|
|
292
|
+
signal: this.createRequestSignal(undefined),
|
|
293
|
+
});
|
|
294
|
+
if (!response.ok) {
|
|
295
|
+
const rawText = await response.text();
|
|
296
|
+
throw new Error(`API request failed: ${formatHttpFailure(response.status, null, rawText)}`);
|
|
297
|
+
}
|
|
298
|
+
const payload = await response.json();
|
|
299
|
+
return parsePlatformKeyListResponse(payload).data;
|
|
300
|
+
}
|
|
301
|
+
async createPlatformApiKey(authToken, name) {
|
|
302
|
+
const response = await fetch(this.getPlatformUrl('/api/keys'), {
|
|
303
|
+
method: 'POST',
|
|
304
|
+
headers: {
|
|
305
|
+
Authorization: `Bearer ${authToken}`,
|
|
306
|
+
'Content-Type': 'application/json',
|
|
307
|
+
},
|
|
308
|
+
body: JSON.stringify({ name }),
|
|
309
|
+
signal: this.createRequestSignal(undefined),
|
|
310
|
+
});
|
|
311
|
+
if (!response.ok) {
|
|
312
|
+
const rawText = await response.text();
|
|
313
|
+
throw new Error(`API request failed: ${formatHttpFailure(response.status, null, rawText)}`);
|
|
314
|
+
}
|
|
315
|
+
const payload = await response.json();
|
|
316
|
+
const result = parsePlatformCreateKeyResponse(payload);
|
|
317
|
+
if (!result.success || !result.data) {
|
|
318
|
+
throw new Error(result.error || 'Failed to create Dexto API key');
|
|
319
|
+
}
|
|
320
|
+
return {
|
|
321
|
+
dextoApiKey: result.data.fullKey,
|
|
322
|
+
keyId: result.data.id,
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
async deletePlatformApiKey(authToken, keyId) {
|
|
326
|
+
const response = await fetch(this.getPlatformUrl(`/api/keys/${encodeURIComponent(keyId)}`), {
|
|
327
|
+
method: 'DELETE',
|
|
328
|
+
headers: {
|
|
329
|
+
Authorization: `Bearer ${authToken}`,
|
|
330
|
+
},
|
|
331
|
+
signal: this.createRequestSignal(undefined),
|
|
332
|
+
});
|
|
333
|
+
if (!response.ok) {
|
|
334
|
+
const rawText = await response.text();
|
|
335
|
+
throw new Error(`API request failed: ${formatHttpFailure(response.status, null, rawText)}`);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
249
338
|
/**
|
|
250
339
|
* Validate if a Dexto API key is valid
|
|
251
340
|
*/
|
|
252
341
|
async validateDextoApiKey(apiKey) {
|
|
253
342
|
try {
|
|
254
343
|
logger.debug('Validating DEXTO_API_KEY');
|
|
255
|
-
const response = await fetch(
|
|
344
|
+
const response = await fetch(this.getPlatformUrl('/api/keys/validate'), {
|
|
256
345
|
method: 'GET',
|
|
257
346
|
headers: {
|
|
258
347
|
Authorization: `Bearer ${apiKey}`,
|
|
@@ -271,51 +360,27 @@ export class DextoApiClient {
|
|
|
271
360
|
}
|
|
272
361
|
}
|
|
273
362
|
/**
|
|
274
|
-
* Provision Dexto API key
|
|
275
|
-
* @param regenerate - If true, delete existing key and create new one
|
|
363
|
+
* Provision Dexto API key and always return a usable secret key value.
|
|
364
|
+
* @param regenerate - If true, delete existing key(s) and create a new one
|
|
276
365
|
*/
|
|
277
366
|
async provisionDextoApiKey(authToken, name = 'Dexto CLI Key', regenerate = false) {
|
|
278
367
|
try {
|
|
279
368
|
logger.debug(`Provisioning DEXTO_API_KEY with name: ${name}, regenerate: ${regenerate}`);
|
|
280
|
-
const
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
});
|
|
289
|
-
if (!response.ok) {
|
|
290
|
-
const rawText = await response.text();
|
|
291
|
-
throw new Error(`API request failed: ${formatHttpFailure(response.status, null, rawText)}`);
|
|
292
|
-
}
|
|
293
|
-
const payload = await response.json();
|
|
294
|
-
const result = parseProvisionResponse(payload);
|
|
295
|
-
if (!result.success) {
|
|
296
|
-
throw new Error(result.error || 'Failed to provision Dexto API key');
|
|
297
|
-
}
|
|
298
|
-
if (!result.keyId) {
|
|
299
|
-
throw new Error('Invalid response from API');
|
|
300
|
-
}
|
|
301
|
-
// If isNewKey is false, the key already exists (we don't get the key value back)
|
|
302
|
-
// This is expected - the key was already provisioned
|
|
303
|
-
if (!result.isNewKey && !result.dextoApiKey) {
|
|
304
|
-
logger.debug(`DEXTO_API_KEY already exists: ${result.keyId}`);
|
|
305
|
-
return {
|
|
306
|
-
dextoApiKey: '', // Empty - key already exists, not returned for security
|
|
307
|
-
keyId: result.keyId,
|
|
308
|
-
isNewKey: false,
|
|
309
|
-
};
|
|
310
|
-
}
|
|
311
|
-
if (!result.dextoApiKey) {
|
|
312
|
-
throw new Error('Invalid response from API - missing key');
|
|
369
|
+
const matchingKeys = (await this.listPlatformApiKeys(authToken)).filter((key) => key.isActive && key.name === name);
|
|
370
|
+
if (matchingKeys.length > 0) {
|
|
371
|
+
if (!regenerate) {
|
|
372
|
+
logger.debug(`Active key exists (${matchingKeys[0]?.id ?? 'unknown'}); rotating to obtain key value`);
|
|
373
|
+
}
|
|
374
|
+
for (const key of matchingKeys) {
|
|
375
|
+
await this.deletePlatformApiKey(authToken, key.id);
|
|
376
|
+
}
|
|
313
377
|
}
|
|
314
|
-
|
|
378
|
+
const createdKey = await this.createPlatformApiKey(authToken, name);
|
|
379
|
+
logger.debug(`Successfully provisioned DEXTO_API_KEY: ${createdKey.keyId}`);
|
|
315
380
|
return {
|
|
316
|
-
dextoApiKey:
|
|
317
|
-
keyId:
|
|
318
|
-
isNewKey:
|
|
381
|
+
dextoApiKey: createdKey.dextoApiKey,
|
|
382
|
+
keyId: createdKey.keyId,
|
|
383
|
+
isNewKey: true,
|
|
319
384
|
};
|
|
320
385
|
}
|
|
321
386
|
catch (error) {
|
|
@@ -329,7 +394,7 @@ export class DextoApiClient {
|
|
|
329
394
|
async getUsageSummary(apiKey) {
|
|
330
395
|
try {
|
|
331
396
|
logger.debug('Fetching usage summary');
|
|
332
|
-
const response = await fetch(
|
|
397
|
+
const response = await fetch(this.getGatewayUrl('/me/usage'), {
|
|
333
398
|
method: 'GET',
|
|
334
399
|
headers: {
|
|
335
400
|
Authorization: `Bearer ${apiKey}`,
|
|
@@ -349,10 +414,10 @@ export class DextoApiClient {
|
|
|
349
414
|
}
|
|
350
415
|
}
|
|
351
416
|
/**
|
|
352
|
-
* Start device code login at the
|
|
417
|
+
* Start device code login at the platform.
|
|
353
418
|
*/
|
|
354
419
|
async startDeviceCodeLogin(client = 'dexto-cli', options = {}) {
|
|
355
|
-
const response = await fetch(
|
|
420
|
+
const response = await fetch(this.getPlatformUrl('/api/auth/device/start'), {
|
|
356
421
|
method: 'POST',
|
|
357
422
|
headers: {
|
|
358
423
|
'Content-Type': 'application/json',
|
|
@@ -371,12 +436,12 @@ export class DextoApiClient {
|
|
|
371
436
|
return parseDeviceCodeStartResponse(payload);
|
|
372
437
|
}
|
|
373
438
|
/**
|
|
374
|
-
* Poll the
|
|
439
|
+
* Poll the platform for device-code login completion.
|
|
375
440
|
*/
|
|
376
441
|
async pollDeviceCodeLogin(deviceCode, options = {}) {
|
|
377
442
|
let response;
|
|
378
443
|
try {
|
|
379
|
-
response = await fetch(
|
|
444
|
+
response = await fetch(this.getPlatformUrl('/api/auth/device/poll'), {
|
|
380
445
|
method: 'POST',
|
|
381
446
|
headers: {
|
|
382
447
|
'Content-Type': 'application/json',
|
|
@@ -12,14 +12,19 @@
|
|
|
12
12
|
* Environment variable overrides (for local development):
|
|
13
13
|
* - SUPABASE_URL: Override Supabase URL (e.g., http://localhost:54321)
|
|
14
14
|
* - SUPABASE_ANON_KEY: Override anon key (from `supabase start` output)
|
|
15
|
-
* - DEXTO_API_URL: Override Dexto
|
|
15
|
+
* - DEXTO_API_URL: Override Dexto gateway URL for data-plane/usage calls (e.g., http://localhost:3001)
|
|
16
|
+
* - DEXTO_PLATFORM_URL: Override Dexto platform URL for auth/key control-plane calls (e.g., http://localhost:3002)
|
|
16
17
|
*/
|
|
17
18
|
export declare const SUPABASE_URL: string;
|
|
18
19
|
export declare const SUPABASE_ANON_KEY: string;
|
|
19
20
|
/**
|
|
20
|
-
* Dexto
|
|
21
|
+
* Dexto gateway URL for usage-summary and other retained gateway endpoints.
|
|
21
22
|
*/
|
|
22
23
|
export declare const DEXTO_API_URL: string;
|
|
24
|
+
/**
|
|
25
|
+
* Dexto platform URL for auth/key control-plane endpoints.
|
|
26
|
+
*/
|
|
27
|
+
export declare const DEXTO_PLATFORM_URL: string;
|
|
23
28
|
/**
|
|
24
29
|
* Dexto Nova credits purchase URL
|
|
25
30
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/cli/auth/constants.ts"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/cli/auth/constants.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,YAAY,QAAyE,CAAC;AACnG,eAAO,MAAM,iBAAiB,QAEwL,CAAC;AAEvN;;GAEG;AACH,eAAO,MAAM,aAAa,QAAsD,CAAC;AAEjF;;GAEG;AACH,eAAO,MAAM,kBAAkB,QAA2D,CAAC;AAE3F;;GAEG;AACH,eAAO,MAAM,iBAAiB,QAC+C,CAAC"}
|
|
@@ -13,15 +13,20 @@
|
|
|
13
13
|
* Environment variable overrides (for local development):
|
|
14
14
|
* - SUPABASE_URL: Override Supabase URL (e.g., http://localhost:54321)
|
|
15
15
|
* - SUPABASE_ANON_KEY: Override anon key (from `supabase start` output)
|
|
16
|
-
* - DEXTO_API_URL: Override Dexto
|
|
16
|
+
* - DEXTO_API_URL: Override Dexto gateway URL for data-plane/usage calls (e.g., http://localhost:3001)
|
|
17
|
+
* - DEXTO_PLATFORM_URL: Override Dexto platform URL for auth/key control-plane calls (e.g., http://localhost:3002)
|
|
17
18
|
*/
|
|
18
19
|
export const SUPABASE_URL = process.env.SUPABASE_URL || 'https://gdfbxznhnnsamvsrtwjq.supabase.co';
|
|
19
20
|
export const SUPABASE_ANON_KEY = process.env.SUPABASE_ANON_KEY ||
|
|
20
21
|
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImdkZmJ4em5obm5zYW12c3J0d2pxIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjQwNjkzNjksImV4cCI6MjA3OTY0NTM2OX0.j2NWOJDOy8gTT84XeomalkGSPpLdPvTCBnQMrTgdlI4';
|
|
21
22
|
/**
|
|
22
|
-
* Dexto
|
|
23
|
+
* Dexto gateway URL for usage-summary and other retained gateway endpoints.
|
|
23
24
|
*/
|
|
24
25
|
export const DEXTO_API_URL = process.env.DEXTO_API_URL || 'https://api.dexto.ai';
|
|
26
|
+
/**
|
|
27
|
+
* Dexto platform URL for auth/key control-plane endpoints.
|
|
28
|
+
*/
|
|
29
|
+
export const DEXTO_PLATFORM_URL = process.env.DEXTO_PLATFORM_URL || 'https://app.dexto.ai';
|
|
25
30
|
/**
|
|
26
31
|
* Dexto Nova credits purchase URL
|
|
27
32
|
*/
|
package/dist/cli/auth/index.d.ts
CHANGED
|
@@ -3,6 +3,6 @@ export { type OAuthResult } from './oauth.js';
|
|
|
3
3
|
export { type DeviceLoginPrompt, performDeviceCodeLogin } from './device.js';
|
|
4
4
|
export { type PersistOAuthLoginOptions, type PersistedLoginResult, persistOAuthLoginResult, } from './login-persistence.js';
|
|
5
5
|
export { type UsageSummaryResponse, DextoApiClient, getDextoApiClient } from './api-client.js';
|
|
6
|
-
export { SUPABASE_URL, SUPABASE_ANON_KEY, DEXTO_API_URL } from './constants.js';
|
|
6
|
+
export { SUPABASE_URL, SUPABASE_ANON_KEY, DEXTO_API_URL, DEXTO_PLATFORM_URL } from './constants.js';
|
|
7
7
|
export { type DextoApiKeyProvisionStatus, type DextoApiKeyProvisionStatusLevel, type EnsureDextoApiKeyOptions, ensureDextoApiKeyForAuthToken, saveDextoApiKeyToEnv, removeDextoApiKeyFromEnv, } from './dexto-api-key.js';
|
|
8
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cli/auth/index.ts"],"names":[],"mappings":"AAGA,OAAO,EACH,KAAK,UAAU,EACf,SAAS,EACT,QAAQ,EACR,UAAU,EACV,eAAe,EACf,YAAY,EACZ,cAAc,EACd,eAAe,GAClB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,OAAO,EAAE,KAAK,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAE7E,OAAO,EACH,KAAK,wBAAwB,EAC7B,KAAK,oBAAoB,EACzB,uBAAuB,GAC1B,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,KAAK,oBAAoB,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAE/F,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cli/auth/index.ts"],"names":[],"mappings":"AAGA,OAAO,EACH,KAAK,UAAU,EACf,SAAS,EACT,QAAQ,EACR,UAAU,EACV,eAAe,EACf,YAAY,EACZ,cAAc,EACd,eAAe,GAClB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,OAAO,EAAE,KAAK,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAE7E,OAAO,EACH,KAAK,wBAAwB,EAC7B,KAAK,oBAAoB,EACzB,uBAAuB,GAC1B,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,KAAK,oBAAoB,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAE/F,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpG,OAAO,EACH,KAAK,0BAA0B,EAC/B,KAAK,+BAA+B,EACpC,KAAK,wBAAwB,EAC7B,6BAA6B,EAC7B,oBAAoB,EACpB,wBAAwB,GAC3B,MAAM,oBAAoB,CAAC"}
|
package/dist/cli/auth/index.js
CHANGED
|
@@ -4,5 +4,5 @@ export { storeAuth, loadAuth, removeAuth, isAuthenticated, getAuthToken, getDext
|
|
|
4
4
|
export { performDeviceCodeLogin } from './device.js';
|
|
5
5
|
export { persistOAuthLoginResult, } from './login-persistence.js';
|
|
6
6
|
export { DextoApiClient, getDextoApiClient } from './api-client.js';
|
|
7
|
-
export { SUPABASE_URL, SUPABASE_ANON_KEY, DEXTO_API_URL } from './constants.js';
|
|
7
|
+
export { SUPABASE_URL, SUPABASE_ANON_KEY, DEXTO_API_URL, DEXTO_PLATFORM_URL } from './constants.js';
|
|
8
8
|
export { ensureDextoApiKeyForAuthToken, saveDextoApiKeyToEnv, removeDextoApiKeyFromEnv, } from './dexto-api-key.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dexto",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.11",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"dexto": "./dist/index.js"
|
|
@@ -32,16 +32,16 @@
|
|
|
32
32
|
"ws": "^8.18.1",
|
|
33
33
|
"yaml": "^2.7.1",
|
|
34
34
|
"zod": "^3.25.0",
|
|
35
|
-
"@dexto/agent-config": "1.6.
|
|
36
|
-
"@dexto/agent-management": "1.6.
|
|
37
|
-
"@dexto/analytics": "1.6.
|
|
38
|
-
"@dexto/core": "1.6.
|
|
39
|
-
"@dexto/image-local": "1.6.
|
|
40
|
-
"@dexto/image-logger-agent": "1.6.
|
|
41
|
-
"@dexto/registry": "1.6.
|
|
42
|
-
"@dexto/server": "1.6.
|
|
43
|
-
"@dexto/storage": "1.6.
|
|
44
|
-
"@dexto/tui": "1.6.
|
|
35
|
+
"@dexto/agent-config": "1.6.11",
|
|
36
|
+
"@dexto/agent-management": "1.6.11",
|
|
37
|
+
"@dexto/analytics": "1.6.11",
|
|
38
|
+
"@dexto/core": "1.6.11",
|
|
39
|
+
"@dexto/image-local": "1.6.11",
|
|
40
|
+
"@dexto/image-logger-agent": "1.6.11",
|
|
41
|
+
"@dexto/registry": "1.6.11",
|
|
42
|
+
"@dexto/server": "1.6.11",
|
|
43
|
+
"@dexto/storage": "1.6.11",
|
|
44
|
+
"@dexto/tui": "1.6.11"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/ws": "^8.5.11",
|