dexto 1.6.10 → 1.6.12
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 +13 -6
- package/dist/cli/auth/api-client.d.ts.map +1 -1
- package/dist/cli/auth/api-client.js +140 -79
- 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,24 @@ interface RequestOptions {
|
|
|
53
53
|
* Dexto API client for key management
|
|
54
54
|
*/
|
|
55
55
|
export declare class DextoApiClient {
|
|
56
|
-
private readonly
|
|
56
|
+
private readonly platformBaseUrl;
|
|
57
57
|
private readonly timeoutMs;
|
|
58
|
-
constructor(baseUrl?: string
|
|
58
|
+
constructor(baseUrl?: string | {
|
|
59
|
+
gatewayBaseUrl?: string | undefined;
|
|
60
|
+
platformBaseUrl?: string | undefined;
|
|
61
|
+
});
|
|
59
62
|
private createRequestSignal;
|
|
63
|
+
private getPlatformUrl;
|
|
64
|
+
private listPlatformApiKeys;
|
|
65
|
+
private createPlatformApiKey;
|
|
66
|
+
private deletePlatformApiKey;
|
|
60
67
|
/**
|
|
61
68
|
* Validate if a Dexto API key is valid
|
|
62
69
|
*/
|
|
63
70
|
validateDextoApiKey(apiKey: string): Promise<boolean>;
|
|
64
71
|
/**
|
|
65
|
-
* Provision Dexto API key
|
|
66
|
-
* @param regenerate - If true, delete existing key and create new one
|
|
72
|
+
* Provision Dexto API key and always return a usable secret key value.
|
|
73
|
+
* @param regenerate - If true, delete existing key(s) and create a new one
|
|
67
74
|
*/
|
|
68
75
|
provisionDextoApiKey(authToken: string, name?: string, regenerate?: boolean): Promise<{
|
|
69
76
|
dextoApiKey: string;
|
|
@@ -75,11 +82,11 @@ export declare class DextoApiClient {
|
|
|
75
82
|
*/
|
|
76
83
|
getUsageSummary(apiKey: string): Promise<UsageSummaryResponse>;
|
|
77
84
|
/**
|
|
78
|
-
* Start device code login at the
|
|
85
|
+
* Start device code login at the platform.
|
|
79
86
|
*/
|
|
80
87
|
startDeviceCodeLogin(client?: string, options?: RequestOptions): Promise<DeviceCodeStartResponse>;
|
|
81
88
|
/**
|
|
82
|
-
* Poll the
|
|
89
|
+
* Poll the platform for device-code login completion.
|
|
83
90
|
*/
|
|
84
91
|
pollDeviceCodeLogin(deviceCode: string, options?: RequestOptions): Promise<DeviceCodePollResponse>;
|
|
85
92
|
/**
|
|
@@ -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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"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// packages/cli/src/cli/auth/api-client.ts
|
|
2
|
-
// Dexto API client for key
|
|
2
|
+
// Dexto API client for auth/key/account APIs
|
|
3
3
|
// TODO: Migrate to typed client for type safety and better DX
|
|
4
4
|
// Options:
|
|
5
5
|
// 1. Migrate dexto-web APIs to Hono and use @hono/client (like packages/server)
|
|
@@ -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 {
|
|
10
|
+
import { 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,17 @@ function formatHttpFailure(status, payload, rawText) {
|
|
|
234
257
|
* Dexto API client for key management
|
|
235
258
|
*/
|
|
236
259
|
export class DextoApiClient {
|
|
237
|
-
|
|
260
|
+
platformBaseUrl;
|
|
238
261
|
timeoutMs = 10_000;
|
|
239
|
-
constructor(baseUrl =
|
|
240
|
-
|
|
262
|
+
constructor(baseUrl = {}) {
|
|
263
|
+
if (typeof baseUrl === 'string') {
|
|
264
|
+
const normalized = baseUrl.replace(/\/+$/, '');
|
|
265
|
+
this.platformBaseUrl = normalized;
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
this.platformBaseUrl = (baseUrl.platformBaseUrl ??
|
|
269
|
+
baseUrl.gatewayBaseUrl ??
|
|
270
|
+
DEXTO_PLATFORM_URL).replace(/\/+$/, '');
|
|
241
271
|
}
|
|
242
272
|
createRequestSignal(signal) {
|
|
243
273
|
const timeoutSignal = AbortSignal.timeout(this.timeoutMs);
|
|
@@ -246,13 +276,68 @@ export class DextoApiClient {
|
|
|
246
276
|
}
|
|
247
277
|
return AbortSignal.any([signal, timeoutSignal]);
|
|
248
278
|
}
|
|
279
|
+
getPlatformUrl(path) {
|
|
280
|
+
return `${this.platformBaseUrl}${path}`;
|
|
281
|
+
}
|
|
282
|
+
async listPlatformApiKeys(authToken) {
|
|
283
|
+
const response = await fetch(this.getPlatformUrl('/api/keys'), {
|
|
284
|
+
method: 'GET',
|
|
285
|
+
headers: {
|
|
286
|
+
Authorization: `Bearer ${authToken}`,
|
|
287
|
+
},
|
|
288
|
+
signal: this.createRequestSignal(undefined),
|
|
289
|
+
});
|
|
290
|
+
if (!response.ok) {
|
|
291
|
+
const rawText = await response.text();
|
|
292
|
+
throw new Error(`API request failed: ${formatHttpFailure(response.status, null, rawText)}`);
|
|
293
|
+
}
|
|
294
|
+
const payload = await response.json();
|
|
295
|
+
return parsePlatformKeyListResponse(payload).data;
|
|
296
|
+
}
|
|
297
|
+
async createPlatformApiKey(authToken, name) {
|
|
298
|
+
const response = await fetch(this.getPlatformUrl('/api/keys'), {
|
|
299
|
+
method: 'POST',
|
|
300
|
+
headers: {
|
|
301
|
+
Authorization: `Bearer ${authToken}`,
|
|
302
|
+
'Content-Type': 'application/json',
|
|
303
|
+
},
|
|
304
|
+
body: JSON.stringify({ name }),
|
|
305
|
+
signal: this.createRequestSignal(undefined),
|
|
306
|
+
});
|
|
307
|
+
if (!response.ok) {
|
|
308
|
+
const rawText = await response.text();
|
|
309
|
+
throw new Error(`API request failed: ${formatHttpFailure(response.status, null, rawText)}`);
|
|
310
|
+
}
|
|
311
|
+
const payload = await response.json();
|
|
312
|
+
const result = parsePlatformCreateKeyResponse(payload);
|
|
313
|
+
if (!result.success || !result.data) {
|
|
314
|
+
throw new Error(result.error || 'Failed to create Dexto API key');
|
|
315
|
+
}
|
|
316
|
+
return {
|
|
317
|
+
dextoApiKey: result.data.fullKey,
|
|
318
|
+
keyId: result.data.id,
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
async deletePlatformApiKey(authToken, keyId) {
|
|
322
|
+
const response = await fetch(this.getPlatformUrl(`/api/keys/${encodeURIComponent(keyId)}`), {
|
|
323
|
+
method: 'DELETE',
|
|
324
|
+
headers: {
|
|
325
|
+
Authorization: `Bearer ${authToken}`,
|
|
326
|
+
},
|
|
327
|
+
signal: this.createRequestSignal(undefined),
|
|
328
|
+
});
|
|
329
|
+
if (!response.ok) {
|
|
330
|
+
const rawText = await response.text();
|
|
331
|
+
throw new Error(`API request failed: ${formatHttpFailure(response.status, null, rawText)}`);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
249
334
|
/**
|
|
250
335
|
* Validate if a Dexto API key is valid
|
|
251
336
|
*/
|
|
252
337
|
async validateDextoApiKey(apiKey) {
|
|
253
338
|
try {
|
|
254
339
|
logger.debug('Validating DEXTO_API_KEY');
|
|
255
|
-
const response = await fetch(
|
|
340
|
+
const response = await fetch(this.getPlatformUrl('/api/keys/validate'), {
|
|
256
341
|
method: 'GET',
|
|
257
342
|
headers: {
|
|
258
343
|
Authorization: `Bearer ${apiKey}`,
|
|
@@ -271,51 +356,27 @@ export class DextoApiClient {
|
|
|
271
356
|
}
|
|
272
357
|
}
|
|
273
358
|
/**
|
|
274
|
-
* Provision Dexto API key
|
|
275
|
-
* @param regenerate - If true, delete existing key and create new one
|
|
359
|
+
* Provision Dexto API key and always return a usable secret key value.
|
|
360
|
+
* @param regenerate - If true, delete existing key(s) and create a new one
|
|
276
361
|
*/
|
|
277
362
|
async provisionDextoApiKey(authToken, name = 'Dexto CLI Key', regenerate = false) {
|
|
278
363
|
try {
|
|
279
364
|
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');
|
|
365
|
+
const matchingKeys = (await this.listPlatformApiKeys(authToken)).filter((key) => key.isActive && key.name === name);
|
|
366
|
+
if (matchingKeys.length > 0) {
|
|
367
|
+
if (!regenerate) {
|
|
368
|
+
logger.debug(`Active key exists (${matchingKeys[0]?.id ?? 'unknown'}); rotating to obtain key value`);
|
|
369
|
+
}
|
|
370
|
+
for (const key of matchingKeys) {
|
|
371
|
+
await this.deletePlatformApiKey(authToken, key.id);
|
|
372
|
+
}
|
|
313
373
|
}
|
|
314
|
-
|
|
374
|
+
const createdKey = await this.createPlatformApiKey(authToken, name);
|
|
375
|
+
logger.debug(`Successfully provisioned DEXTO_API_KEY: ${createdKey.keyId}`);
|
|
315
376
|
return {
|
|
316
|
-
dextoApiKey:
|
|
317
|
-
keyId:
|
|
318
|
-
isNewKey:
|
|
377
|
+
dextoApiKey: createdKey.dextoApiKey,
|
|
378
|
+
keyId: createdKey.keyId,
|
|
379
|
+
isNewKey: true,
|
|
319
380
|
};
|
|
320
381
|
}
|
|
321
382
|
catch (error) {
|
|
@@ -329,7 +390,7 @@ export class DextoApiClient {
|
|
|
329
390
|
async getUsageSummary(apiKey) {
|
|
330
391
|
try {
|
|
331
392
|
logger.debug('Fetching usage summary');
|
|
332
|
-
const response = await fetch(
|
|
393
|
+
const response = await fetch(this.getPlatformUrl('/api/account/usage'), {
|
|
333
394
|
method: 'GET',
|
|
334
395
|
headers: {
|
|
335
396
|
Authorization: `Bearer ${apiKey}`,
|
|
@@ -349,10 +410,10 @@ export class DextoApiClient {
|
|
|
349
410
|
}
|
|
350
411
|
}
|
|
351
412
|
/**
|
|
352
|
-
* Start device code login at the
|
|
413
|
+
* Start device code login at the platform.
|
|
353
414
|
*/
|
|
354
415
|
async startDeviceCodeLogin(client = 'dexto-cli', options = {}) {
|
|
355
|
-
const response = await fetch(
|
|
416
|
+
const response = await fetch(this.getPlatformUrl('/api/auth/device/start'), {
|
|
356
417
|
method: 'POST',
|
|
357
418
|
headers: {
|
|
358
419
|
'Content-Type': 'application/json',
|
|
@@ -371,12 +432,12 @@ export class DextoApiClient {
|
|
|
371
432
|
return parseDeviceCodeStartResponse(payload);
|
|
372
433
|
}
|
|
373
434
|
/**
|
|
374
|
-
* Poll the
|
|
435
|
+
* Poll the platform for device-code login completion.
|
|
375
436
|
*/
|
|
376
437
|
async pollDeviceCodeLogin(deviceCode, options = {}) {
|
|
377
438
|
let response;
|
|
378
439
|
try {
|
|
379
|
-
response = await fetch(
|
|
440
|
+
response = await fetch(this.getPlatformUrl('/api/auth/device/poll'), {
|
|
380
441
|
method: 'POST',
|
|
381
442
|
headers: {
|
|
382
443
|
'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 calls (e.g., http://localhost:3001)
|
|
16
|
+
* - DEXTO_PLATFORM_URL: Override Dexto platform URL for auth/key/account 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 retained data-plane endpoints.
|
|
21
22
|
*/
|
|
22
23
|
export declare const DEXTO_API_URL: string;
|
|
24
|
+
/**
|
|
25
|
+
* Dexto platform URL for auth/key/account 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 calls (e.g., http://localhost:3001)
|
|
17
|
+
* - DEXTO_PLATFORM_URL: Override Dexto platform URL for auth/key/account 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 retained data-plane 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/account 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.12",
|
|
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.12",
|
|
36
|
+
"@dexto/agent-management": "1.6.12",
|
|
37
|
+
"@dexto/analytics": "1.6.12",
|
|
38
|
+
"@dexto/core": "1.6.12",
|
|
39
|
+
"@dexto/image-local": "1.6.12",
|
|
40
|
+
"@dexto/image-logger-agent": "1.6.12",
|
|
41
|
+
"@dexto/registry": "1.6.12",
|
|
42
|
+
"@dexto/server": "1.6.12",
|
|
43
|
+
"@dexto/storage": "1.6.12",
|
|
44
|
+
"@dexto/tui": "1.6.12"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/ws": "^8.5.11",
|