dexto 1.14.4 → 2.0.0-beta.0
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/billing.d.ts +0 -6
- package/dist/cli/auth/billing.d.ts.map +1 -1
- package/dist/cli/auth/billing.js +0 -23
- package/dist/cli/auth/constants.d.ts +3 -31
- package/dist/cli/auth/constants.d.ts.map +1 -1
- package/dist/cli/auth/constants.js +9 -33
- package/dist/cli/auth/index.d.ts +2 -9
- package/dist/cli/auth/index.d.ts.map +1 -1
- package/dist/cli/auth/index.js +2 -7
- package/dist/cli/auth/sign-in-runtime.d.ts +12 -0
- package/dist/cli/auth/sign-in-runtime.d.ts.map +1 -0
- package/dist/cli/auth/sign-in-runtime.js +59 -0
- package/dist/cli/cloud/app-scopes.d.ts +4 -0
- package/dist/cli/cloud/app-scopes.d.ts.map +1 -0
- package/dist/cli/cloud/app-scopes.js +19 -0
- package/dist/cli/cloud/command.d.ts +143 -0
- package/dist/cli/cloud/command.d.ts.map +1 -0
- package/dist/cli/cloud/command.js +202 -0
- package/dist/cli/cloud/commands/account.d.ts +11 -0
- package/dist/cli/cloud/commands/account.d.ts.map +1 -0
- package/dist/cli/cloud/commands/account.js +128 -0
- package/dist/cli/cloud/commands/agents.d.ts +3 -0
- package/dist/cli/cloud/commands/agents.d.ts.map +1 -0
- package/dist/cli/cloud/commands/agents.js +524 -0
- package/dist/cli/cloud/commands/api.d.ts +3 -0
- package/dist/cli/cloud/commands/api.d.ts.map +1 -0
- package/dist/cli/cloud/commands/api.js +26 -0
- package/dist/cli/cloud/commands/app-files.d.ts +29 -0
- package/dist/cli/cloud/commands/app-files.d.ts.map +1 -0
- package/dist/cli/cloud/commands/app-files.js +72 -0
- package/dist/cli/cloud/commands/automations.d.ts +3 -0
- package/dist/cli/cloud/commands/automations.d.ts.map +1 -0
- package/dist/cli/cloud/commands/automations.js +232 -0
- package/dist/cli/cloud/commands/chats.d.ts +3 -0
- package/dist/cli/cloud/commands/chats.d.ts.map +1 -0
- package/dist/cli/cloud/commands/chats.js +189 -0
- package/dist/cli/cloud/commands/data-deletions.d.ts +3 -0
- package/dist/cli/cloud/commands/data-deletions.d.ts.map +1 -0
- package/dist/cli/cloud/commands/data-deletions.js +54 -0
- package/dist/cli/cloud/commands/deploys.d.ts +10 -0
- package/dist/cli/cloud/commands/deploys.d.ts.map +1 -0
- package/dist/cli/cloud/commands/deploys.js +223 -0
- package/dist/cli/cloud/commands/drive.d.ts +12 -0
- package/dist/cli/cloud/commands/drive.d.ts.map +1 -0
- package/dist/cli/cloud/commands/drive.js +320 -0
- package/dist/cli/cloud/commands/files.d.ts +24 -0
- package/dist/cli/cloud/commands/files.d.ts.map +1 -0
- package/dist/cli/cloud/commands/files.js +282 -0
- package/dist/cli/cloud/commands/find.d.ts +3 -0
- package/dist/cli/cloud/commands/find.d.ts.map +1 -0
- package/dist/cli/cloud/commands/find.js +63 -0
- package/dist/cli/cloud/commands/models.d.ts +3 -0
- package/dist/cli/cloud/commands/models.d.ts.map +1 -0
- package/dist/cli/cloud/commands/models.js +248 -0
- package/dist/cli/cloud/commands/profile.d.ts +3 -0
- package/dist/cli/cloud/commands/profile.d.ts.map +1 -0
- package/dist/cli/cloud/commands/profile.js +119 -0
- package/dist/cli/cloud/commands/projects.d.ts +5 -0
- package/dist/cli/cloud/commands/projects.d.ts.map +1 -0
- package/dist/cli/cloud/commands/projects.js +66 -0
- package/dist/cli/cloud/commands/publish.d.ts +3 -0
- package/dist/cli/cloud/commands/publish.d.ts.map +1 -0
- package/dist/cli/cloud/commands/publish.js +138 -0
- package/dist/cli/cloud/commands/sandboxes.d.ts +3 -0
- package/dist/cli/cloud/commands/sandboxes.d.ts.map +1 -0
- package/dist/cli/cloud/commands/sandboxes.js +265 -0
- package/dist/cli/cloud/commands/secrets.d.ts +3 -0
- package/dist/cli/cloud/commands/secrets.d.ts.map +1 -0
- package/dist/cli/cloud/commands/secrets.js +110 -0
- package/dist/cli/cloud/commands/skills.d.ts +3 -0
- package/dist/cli/cloud/commands/skills.d.ts.map +1 -0
- package/dist/cli/cloud/commands/skills.js +202 -0
- package/dist/cli/cloud/commands/web.d.ts +3 -0
- package/dist/cli/cloud/commands/web.d.ts.map +1 -0
- package/dist/cli/cloud/commands/web.js +53 -0
- package/dist/cli/cloud/commands/workspace-apps.d.ts +58 -0
- package/dist/cli/cloud/commands/workspace-apps.d.ts.map +1 -0
- package/dist/cli/cloud/commands/workspace-apps.js +656 -0
- package/dist/cli/cloud/commands/workspace.d.ts +36 -0
- package/dist/cli/cloud/commands/workspace.d.ts.map +1 -0
- package/dist/cli/cloud/commands/workspace.js +279 -0
- package/dist/cli/cloud/connection.d.ts +33 -0
- package/dist/cli/cloud/connection.d.ts.map +1 -0
- package/dist/cli/cloud/connection.js +38 -0
- package/dist/cli/cloud/events.d.ts +63 -0
- package/dist/cli/cloud/events.d.ts.map +1 -0
- package/dist/cli/cloud/events.js +72 -0
- package/dist/cli/cloud/host.d.ts +9 -0
- package/dist/cli/cloud/host.d.ts.map +1 -0
- package/dist/cli/cloud/host.js +105 -0
- package/dist/cli/cloud/local-chats.d.ts +73 -0
- package/dist/cli/cloud/local-chats.d.ts.map +1 -0
- package/dist/cli/cloud/local-chats.js +441 -0
- package/dist/cli/cloud/output.d.ts +34 -0
- package/dist/cli/cloud/output.d.ts.map +1 -0
- package/dist/cli/cloud/output.js +76 -0
- package/dist/cli/cloud/run.d.ts +26 -0
- package/dist/cli/cloud/run.d.ts.map +1 -0
- package/dist/cli/cloud/run.js +444 -0
- package/dist/cli/cloud/runtime.d.ts +33 -0
- package/dist/cli/cloud/runtime.d.ts.map +1 -0
- package/dist/cli/cloud/runtime.js +86 -0
- package/dist/cli/cloud/tar.d.ts +9 -0
- package/dist/cli/cloud/tar.d.ts.map +1 -0
- package/dist/cli/cloud/tar.js +69 -0
- package/dist/cli/cloud/transfer.d.ts +13 -0
- package/dist/cli/cloud/transfer.d.ts.map +1 -0
- package/dist/cli/cloud/transfer.js +35 -0
- package/dist/cli/cloud/v1.d.ts +19 -0
- package/dist/cli/cloud/v1.d.ts.map +1 -0
- package/dist/cli/cloud/v1.js +65 -0
- package/dist/cli/cloud/zip.d.ts +8 -0
- package/dist/cli/cloud/zip.d.ts.map +1 -0
- package/dist/cli/cloud/zip.js +66 -0
- package/dist/cli/commands/auth/sign-in-commands.d.ts +62 -0
- package/dist/cli/commands/auth/sign-in-commands.d.ts.map +1 -0
- package/dist/cli/commands/auth/sign-in-commands.js +247 -0
- package/dist/cli/commands/auth/sign-in-context.d.ts +16 -0
- package/dist/cli/commands/auth/sign-in-context.d.ts.map +1 -0
- package/dist/cli/commands/auth/sign-in-context.js +68 -0
- package/dist/cli/commands/cloud/register.d.ts +5 -0
- package/dist/cli/commands/cloud/register.d.ts.map +1 -1
- package/dist/cli/commands/cloud/register.js +42 -24
- package/dist/cli/commands/create-app.js +5 -6
- package/dist/cli/commands/create-image.d.ts.map +1 -1
- package/dist/cli/commands/create-image.js +9 -10
- package/dist/cli/commands/index.d.ts +0 -2
- package/dist/cli/commands/index.d.ts.map +1 -1
- package/dist/cli/commands/index.js +0 -2
- package/dist/cli/commands/init.d.ts +0 -2
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +5 -26
- package/dist/cli/commands/run/headless.js +2 -2
- package/dist/cli/commands/run/output.d.ts +29 -10
- package/dist/cli/commands/run/output.d.ts.map +1 -1
- package/dist/cli/commands/run/output.js +44 -22
- package/dist/cli/commands/run/register.d.ts.map +1 -1
- package/dist/cli/commands/run/register.js +21 -9
- package/dist/cli/commands/session/register.d.ts.map +1 -1
- package/dist/cli/commands/session/register.js +51 -21
- package/dist/cli/commands/session-commands.js +1 -1
- package/dist/cli/commands/setup.js +17 -14
- package/dist/cli/help-json.d.ts +22 -0
- package/dist/cli/help-json.d.ts.map +1 -0
- package/dist/cli/help-json.js +20 -0
- package/dist/cli/modes/cli.d.ts.map +1 -1
- package/dist/cli/modes/cli.js +42 -9
- package/dist/cli/modes/server.js +8 -8
- package/dist/cli/modes/web.js +3 -3
- package/dist/cli/utils/dexto-auth-check.d.ts +1 -1
- package/dist/cli/utils/dexto-auth-check.d.ts.map +1 -1
- package/dist/cli/utils/dexto-auth-check.js +4 -5
- package/dist/cli/utils/dexto-setup.d.ts +4 -5
- package/dist/cli/utils/dexto-setup.d.ts.map +1 -1
- package/dist/cli/utils/dexto-setup.js +17 -14
- package/dist/cli/utils/provider-setup.js +1 -1
- package/dist/cli/utils/scaffolding-utils.d.ts +9 -3
- package/dist/cli/utils/scaffolding-utils.d.ts.map +1 -1
- package/dist/cli/utils/scaffolding-utils.js +48 -40
- package/dist/cli/utils/version-check.d.ts.map +1 -1
- package/dist/cli/utils/version-check.js +2 -1
- package/dist/index-main.js +33 -65
- package/package.json +8 -7
- package/dist/cli/auth/api-client.d.ts +0 -125
- package/dist/cli/auth/api-client.d.ts.map +0 -1
- package/dist/cli/auth/api-client.js +0 -585
- package/dist/cli/auth/device.d.ts +0 -14
- package/dist/cli/auth/device.d.ts.map +0 -1
- package/dist/cli/auth/device.js +0 -84
- package/dist/cli/auth/dexto-api-key.d.ts +0 -34
- package/dist/cli/auth/dexto-api-key.d.ts.map +0 -1
- package/dist/cli/auth/dexto-api-key.js +0 -160
- package/dist/cli/auth/login-persistence.d.ts +0 -15
- package/dist/cli/auth/login-persistence.d.ts.map +0 -1
- package/dist/cli/auth/login-persistence.js +0 -72
- package/dist/cli/auth/oauth.d.ts +0 -39
- package/dist/cli/auth/oauth.d.ts.map +0 -1
- package/dist/cli/auth/oauth.js +0 -434
- package/dist/cli/auth/service.d.ts +0 -24
- package/dist/cli/auth/service.d.ts.map +0 -1
- package/dist/cli/auth/service.js +0 -161
- package/dist/cli/auth/types.d.ts +0 -11
- package/dist/cli/auth/types.d.ts.map +0 -1
- package/dist/cli/auth/types.js +0 -1
- package/dist/cli/cloud-chat.d.ts +0 -18
- package/dist/cli/cloud-chat.d.ts.map +0 -1
- package/dist/cli/cloud-chat.js +0 -734
- package/dist/cli/commands/auth/index.d.ts +0 -4
- package/dist/cli/commands/auth/index.d.ts.map +0 -1
- package/dist/cli/commands/auth/index.js +0 -4
- package/dist/cli/commands/auth/login.d.ts +0 -12
- package/dist/cli/commands/auth/login.d.ts.map +0 -1
- package/dist/cli/commands/auth/login.js +0 -153
- package/dist/cli/commands/auth/logout.d.ts +0 -5
- package/dist/cli/commands/auth/logout.d.ts.map +0 -1
- package/dist/cli/commands/auth/logout.js +0 -81
- package/dist/cli/commands/auth/register.d.ts +0 -3
- package/dist/cli/commands/auth/register.d.ts.map +0 -1
- package/dist/cli/commands/auth/register.js +0 -96
- package/dist/cli/commands/auth/status.d.ts +0 -2
- package/dist/cli/commands/auth/status.d.ts.map +0 -1
- package/dist/cli/commands/auth/status.js +0 -22
- package/dist/cli/commands/billing/index.d.ts +0 -2
- package/dist/cli/commands/billing/index.d.ts.map +0 -1
- package/dist/cli/commands/billing/index.js +0 -2
- package/dist/cli/commands/billing/register.d.ts +0 -3
- package/dist/cli/commands/billing/register.d.ts.map +0 -1
- package/dist/cli/commands/billing/register.js +0 -20
- package/dist/cli/commands/billing/status.d.ts +0 -8
- package/dist/cli/commands/billing/status.d.ts.map +0 -1
- package/dist/cli/commands/billing/status.js +0 -71
- package/dist/cli/commands/cloud/discovery.d.ts +0 -17
- package/dist/cli/commands/cloud/discovery.d.ts.map +0 -1
- package/dist/cli/commands/cloud/discovery.js +0 -88
- package/dist/cli/commands/deploy/client.d.ts +0 -113
- package/dist/cli/commands/deploy/client.d.ts.map +0 -1
- package/dist/cli/commands/deploy/client.js +0 -519
- package/dist/cli/commands/deploy/config.d.ts +0 -37
- package/dist/cli/commands/deploy/config.d.ts.map +0 -1
- package/dist/cli/commands/deploy/config.js +0 -144
- package/dist/cli/commands/deploy/entry-agent.d.ts +0 -3
- package/dist/cli/commands/deploy/entry-agent.d.ts.map +0 -1
- package/dist/cli/commands/deploy/entry-agent.js +0 -70
- package/dist/cli/commands/deploy/index.d.ts +0 -12
- package/dist/cli/commands/deploy/index.d.ts.map +0 -1
- package/dist/cli/commands/deploy/index.js +0 -370
- package/dist/cli/commands/deploy/links.d.ts +0 -3
- package/dist/cli/commands/deploy/links.d.ts.map +0 -1
- package/dist/cli/commands/deploy/links.js +0 -53
- package/dist/cli/commands/deploy/register.d.ts +0 -6
- package/dist/cli/commands/deploy/register.d.ts.map +0 -1
- package/dist/cli/commands/deploy/register.js +0 -128
- package/dist/cli/commands/deploy/snapshot.d.ts +0 -12
- package/dist/cli/commands/deploy/snapshot.d.ts.map +0 -1
- package/dist/cli/commands/deploy/snapshot.js +0 -76
- package/dist/cli/commands/deploy/state.d.ts +0 -13
- package/dist/cli/commands/deploy/state.d.ts.map +0 -1
- package/dist/cli/commands/deploy/state.js +0 -122
- package/dist/cli/commands/span/register.d.ts +0 -6
- package/dist/cli/commands/span/register.d.ts.map +0 -1
- package/dist/cli/commands/span/register.js +0 -25
- package/dist/cli/commands/trace/client.d.ts +0 -98
- package/dist/cli/commands/trace/client.d.ts.map +0 -1
- package/dist/cli/commands/trace/client.js +0 -150
- package/dist/cli/commands/trace/format.d.ts +0 -5
- package/dist/cli/commands/trace/format.d.ts.map +0 -1
- package/dist/cli/commands/trace/format.js +0 -58
- package/dist/cli/commands/trace/index.d.ts +0 -21
- package/dist/cli/commands/trace/index.d.ts.map +0 -1
- package/dist/cli/commands/trace/index.js +0 -49
- package/dist/cli/commands/trace/register.d.ts +0 -6
- package/dist/cli/commands/trace/register.d.ts.map +0 -1
- package/dist/cli/commands/trace/register.js +0 -71
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
export type DextoApiKeyProvisionStatusLevel = 'info' | 'success' | 'warning' | 'error';
|
|
2
|
-
export interface DextoApiKeyProvisionStatus {
|
|
3
|
-
level: DextoApiKeyProvisionStatusLevel;
|
|
4
|
-
message: string;
|
|
5
|
-
}
|
|
6
|
-
export interface EnsureDextoApiKeyOptions {
|
|
7
|
-
onStatus?: ((status: DextoApiKeyProvisionStatus) => void) | undefined;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Save DEXTO_API_KEY to the resolved dexto .env path and populate the current
|
|
11
|
-
* process environment immediately.
|
|
12
|
-
*/
|
|
13
|
-
export declare function saveDextoApiKeyToEnv(apiKey: string): Promise<void>;
|
|
14
|
-
export declare function removeDextoApiKeyFromEnv(options?: {
|
|
15
|
-
expectedValue?: string;
|
|
16
|
-
}): Promise<{
|
|
17
|
-
removed: boolean;
|
|
18
|
-
targetEnvPath: string;
|
|
19
|
-
}>;
|
|
20
|
-
/**
|
|
21
|
-
* Ensure a Dexto API key exists locally for the current auth session.
|
|
22
|
-
*
|
|
23
|
-
* - If a local key exists and validates, it is re-saved to .env (sync) and returned.
|
|
24
|
-
* - If a local key exists but is invalid, it is rotated (regenerated) and returned.
|
|
25
|
-
* - If no local key exists, a managed key is provisioned. If a same-name managed key
|
|
26
|
-
* already exists server-side, provisioning rotates it to obtain a fresh secret value.
|
|
27
|
-
*
|
|
28
|
-
* Returns `null` if provisioning fails (OAuth login can still succeed without it).
|
|
29
|
-
*/
|
|
30
|
-
export declare function ensureDextoApiKeyForAuthToken(authToken: string, options?: EnsureDextoApiKeyOptions): Promise<{
|
|
31
|
-
dextoApiKey: string;
|
|
32
|
-
keyId: string | null;
|
|
33
|
-
} | null>;
|
|
34
|
-
//# sourceMappingURL=dexto-api-key.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dexto-api-key.d.ts","sourceRoot":"","sources":["../../../src/cli/auth/dexto-api-key.ts"],"names":[],"mappings":"AAOA,MAAM,MAAM,+BAA+B,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;AAEvF,MAAM,WAAW,0BAA0B;IACvC,KAAK,EAAE,+BAA+B,CAAC;IACvC,OAAO,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,wBAAwB;IACrC,QAAQ,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,0BAA0B,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;CACzE;AAaD;;;GAGG;AACH,wBAAsB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA4BxE;AAED,wBAAsB,wBAAwB,CAAC,OAAO,GAAE;IAAE,aAAa,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,OAAO,CAAC;IAC9F,OAAO,EAAE,OAAO,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;CACzB,CAAC,CAsDD;AAED;;;;;;;;;GASG;AACH,wBAAsB,6BAA6B,CAC/C,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,wBAA6B,GACvC,OAAO,CAAC;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GAAG,IAAI,CAAC,CA+D/D"}
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs/promises';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { ensureDextoGlobalDirectory, getDextoEnvPath, logger } from '@dexto/core';
|
|
4
|
-
import { getDextoApiClient } from './api-client.js';
|
|
5
|
-
import { loadAuth, storeAuth } from './service.js';
|
|
6
|
-
import { DEXTO_PLATFORM_URL } from './constants.js';
|
|
7
|
-
async function ensureOwnerOnlyPermissions(filePath) {
|
|
8
|
-
try {
|
|
9
|
-
await fs.chmod(filePath, 0o600);
|
|
10
|
-
}
|
|
11
|
-
catch (error) {
|
|
12
|
-
logger.warn('Failed to set permissions on env file', {
|
|
13
|
-
filePath,
|
|
14
|
-
error: error instanceof Error ? error.message : String(error),
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Save DEXTO_API_KEY to the resolved dexto .env path and populate the current
|
|
20
|
-
* process environment immediately.
|
|
21
|
-
*/
|
|
22
|
-
export async function saveDextoApiKeyToEnv(apiKey) {
|
|
23
|
-
const envVar = 'DEXTO_API_KEY';
|
|
24
|
-
const targetEnvPath = getDextoEnvPath();
|
|
25
|
-
await ensureDextoGlobalDirectory();
|
|
26
|
-
await fs.mkdir(path.dirname(targetEnvPath), { recursive: true });
|
|
27
|
-
let envContent = '';
|
|
28
|
-
try {
|
|
29
|
-
envContent = await fs.readFile(targetEnvPath, 'utf-8');
|
|
30
|
-
}
|
|
31
|
-
catch {
|
|
32
|
-
// File doesn't exist, start fresh
|
|
33
|
-
}
|
|
34
|
-
const lines = envContent.split('\n');
|
|
35
|
-
const keyPattern = new RegExp(`^${envVar}=`);
|
|
36
|
-
const keyIndex = lines.findIndex((line) => keyPattern.test(line));
|
|
37
|
-
if (keyIndex >= 0) {
|
|
38
|
-
lines[keyIndex] = `${envVar}=${apiKey}`;
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
lines.push(`${envVar}=${apiKey}`);
|
|
42
|
-
}
|
|
43
|
-
const nextContent = lines.filter(Boolean).join('\n') + '\n';
|
|
44
|
-
await fs.writeFile(targetEnvPath, nextContent, { encoding: 'utf-8', mode: 0o600 });
|
|
45
|
-
await ensureOwnerOnlyPermissions(targetEnvPath);
|
|
46
|
-
process.env[envVar] = apiKey;
|
|
47
|
-
}
|
|
48
|
-
export async function removeDextoApiKeyFromEnv(options = {}) {
|
|
49
|
-
const envVar = 'DEXTO_API_KEY';
|
|
50
|
-
const targetEnvPath = getDextoEnvPath();
|
|
51
|
-
const clearProcessEnv = () => {
|
|
52
|
-
const currentValue = process.env[envVar];
|
|
53
|
-
if (!currentValue)
|
|
54
|
-
return;
|
|
55
|
-
if (!options.expectedValue || currentValue === options.expectedValue) {
|
|
56
|
-
delete process.env[envVar];
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
let envContent = '';
|
|
60
|
-
try {
|
|
61
|
-
envContent = await fs.readFile(targetEnvPath, 'utf-8');
|
|
62
|
-
}
|
|
63
|
-
catch {
|
|
64
|
-
clearProcessEnv();
|
|
65
|
-
return { removed: false, targetEnvPath };
|
|
66
|
-
}
|
|
67
|
-
const lines = envContent.split('\n');
|
|
68
|
-
const keyPattern = new RegExp(`^${envVar}=(.*)$`);
|
|
69
|
-
const keyLineIndex = lines.findIndex((line) => keyPattern.test(line));
|
|
70
|
-
if (keyLineIndex < 0) {
|
|
71
|
-
clearProcessEnv();
|
|
72
|
-
return { removed: false, targetEnvPath };
|
|
73
|
-
}
|
|
74
|
-
if (options.expectedValue) {
|
|
75
|
-
const match = lines[keyLineIndex]?.match(keyPattern);
|
|
76
|
-
const currentValue = match?.[1] ?? '';
|
|
77
|
-
if (currentValue !== options.expectedValue) {
|
|
78
|
-
clearProcessEnv();
|
|
79
|
-
return { removed: false, targetEnvPath };
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
lines.splice(keyLineIndex, 1);
|
|
83
|
-
const nextLines = lines.filter(Boolean);
|
|
84
|
-
const nextContent = nextLines.length ? nextLines.join('\n') + '\n' : '';
|
|
85
|
-
try {
|
|
86
|
-
await fs.writeFile(targetEnvPath, nextContent, { encoding: 'utf-8', mode: 0o600 });
|
|
87
|
-
await ensureOwnerOnlyPermissions(targetEnvPath);
|
|
88
|
-
}
|
|
89
|
-
catch (error) {
|
|
90
|
-
clearProcessEnv();
|
|
91
|
-
throw new Error(`Failed to remove ${envVar} from ${targetEnvPath}: ${error instanceof Error ? error.message : String(error)}`);
|
|
92
|
-
}
|
|
93
|
-
clearProcessEnv();
|
|
94
|
-
return { removed: true, targetEnvPath };
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Ensure a Dexto API key exists locally for the current auth session.
|
|
98
|
-
*
|
|
99
|
-
* - If a local key exists and validates, it is re-saved to .env (sync) and returned.
|
|
100
|
-
* - If a local key exists but is invalid, it is rotated (regenerated) and returned.
|
|
101
|
-
* - If no local key exists, a managed key is provisioned. If a same-name managed key
|
|
102
|
-
* already exists server-side, provisioning rotates it to obtain a fresh secret value.
|
|
103
|
-
*
|
|
104
|
-
* Returns `null` if provisioning fails (OAuth login can still succeed without it).
|
|
105
|
-
*/
|
|
106
|
-
export async function ensureDextoApiKeyForAuthToken(authToken, options = {}) {
|
|
107
|
-
const status = (level, message) => options.onStatus?.({ level, message });
|
|
108
|
-
try {
|
|
109
|
-
const apiClient = getDextoApiClient();
|
|
110
|
-
const auth = await loadAuth();
|
|
111
|
-
if (!auth) {
|
|
112
|
-
throw new Error('Authentication state not found');
|
|
113
|
-
}
|
|
114
|
-
if (auth.dextoApiKey) {
|
|
115
|
-
status('info', 'Validating existing API key...');
|
|
116
|
-
const isValid = await apiClient.validateDextoApiKey(auth.dextoApiKey);
|
|
117
|
-
if (isValid) {
|
|
118
|
-
status('success', 'Existing key is valid');
|
|
119
|
-
if (!auth.dextoApiKeySource && auth.dextoKeyId) {
|
|
120
|
-
await storeAuth({
|
|
121
|
-
...auth,
|
|
122
|
-
dextoApiKeySource: 'provisioned',
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
await saveDextoApiKeyToEnv(auth.dextoApiKey);
|
|
126
|
-
return { dextoApiKey: auth.dextoApiKey, keyId: auth.dextoKeyId ?? null };
|
|
127
|
-
}
|
|
128
|
-
status('warning', 'Existing key is invalid, rotating...');
|
|
129
|
-
const rotated = await apiClient.provisionDextoApiKey(authToken, 'Dexto CLI Key', true);
|
|
130
|
-
await storeAuth({
|
|
131
|
-
...auth,
|
|
132
|
-
dextoApiKey: rotated.dextoApiKey,
|
|
133
|
-
dextoKeyId: rotated.keyId,
|
|
134
|
-
dextoApiKeySource: 'provisioned',
|
|
135
|
-
dextoPlatformUrl: new URL(DEXTO_PLATFORM_URL).origin,
|
|
136
|
-
});
|
|
137
|
-
await saveDextoApiKeyToEnv(rotated.dextoApiKey);
|
|
138
|
-
status('success', 'New key provisioned');
|
|
139
|
-
return { dextoApiKey: rotated.dextoApiKey, keyId: rotated.keyId };
|
|
140
|
-
}
|
|
141
|
-
status('info', 'Provisioning Dexto API key...');
|
|
142
|
-
const provisioned = await apiClient.provisionDextoApiKey(authToken);
|
|
143
|
-
await storeAuth({
|
|
144
|
-
...auth,
|
|
145
|
-
dextoApiKey: provisioned.dextoApiKey,
|
|
146
|
-
dextoKeyId: provisioned.keyId,
|
|
147
|
-
dextoApiKeySource: 'provisioned',
|
|
148
|
-
dextoPlatformUrl: new URL(DEXTO_PLATFORM_URL).origin,
|
|
149
|
-
});
|
|
150
|
-
await saveDextoApiKeyToEnv(provisioned.dextoApiKey);
|
|
151
|
-
status('success', 'Dexto API key provisioned');
|
|
152
|
-
return { dextoApiKey: provisioned.dextoApiKey, keyId: provisioned.keyId };
|
|
153
|
-
}
|
|
154
|
-
catch (error) {
|
|
155
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
156
|
-
logger.warn('Failed to ensure DEXTO_API_KEY', { error: errorMessage });
|
|
157
|
-
status('error', `Failed to provision Dexto API key: ${errorMessage}`);
|
|
158
|
-
return null;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { type DextoApiKeyProvisionStatus } from './dexto-api-key.js';
|
|
2
|
-
import type { OAuthResult } from './oauth.js';
|
|
3
|
-
import type { DeviceApiKeyLoginResult } from './types.js';
|
|
4
|
-
export interface PersistOAuthLoginOptions {
|
|
5
|
-
onProvisionStatus?: ((status: DextoApiKeyProvisionStatus) => void) | undefined;
|
|
6
|
-
}
|
|
7
|
-
export interface PersistedLoginResult {
|
|
8
|
-
email?: string | undefined;
|
|
9
|
-
userId?: string | undefined;
|
|
10
|
-
keyId?: string | undefined;
|
|
11
|
-
hasDextoApiKey: boolean;
|
|
12
|
-
}
|
|
13
|
-
export declare function persistOAuthLoginResult(result: OAuthResult, options?: PersistOAuthLoginOptions): Promise<PersistedLoginResult>;
|
|
14
|
-
export declare function persistDeviceApiKeyLoginResult(result: DeviceApiKeyLoginResult, platformUrl?: string): Promise<PersistedLoginResult>;
|
|
15
|
-
//# sourceMappingURL=login-persistence.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"login-persistence.d.ts","sourceRoot":"","sources":["../../../src/cli/auth/login-persistence.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,0BAA0B,EAAiC,MAAM,oBAAoB,CAAC;AACpG,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAG1D,MAAM,WAAW,wBAAwB;IACrC,iBAAiB,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,0BAA0B,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;CAClF;AAED,MAAM,WAAW,oBAAoB;IACjC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,cAAc,EAAE,OAAO,CAAC;CAC3B;AAoDD,wBAAsB,uBAAuB,CACzC,MAAM,EAAE,WAAW,EACnB,OAAO,GAAE,wBAA6B,GACvC,OAAO,CAAC,oBAAoB,CAAC,CAyB/B;AAED,wBAAsB,8BAA8B,CAChD,MAAM,EAAE,uBAAuB,EAC/B,WAAW,GAAE,MAA2B,GACzC,OAAO,CAAC,oBAAoB,CAAC,CAa/B"}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { ensureDextoApiKeyForAuthToken } from './dexto-api-key.js';
|
|
2
|
-
import { loadAuth, storeAuth } from './service.js';
|
|
3
|
-
import { DEXTO_PLATFORM_URL } from './constants.js';
|
|
4
|
-
function isSameAuthenticatedUser(existingAuth, user) {
|
|
5
|
-
if (!existingAuth || !user) {
|
|
6
|
-
return false;
|
|
7
|
-
}
|
|
8
|
-
if (existingAuth.userId && user.id) {
|
|
9
|
-
return existingAuth.userId === user.id;
|
|
10
|
-
}
|
|
11
|
-
if (existingAuth.email && user.email) {
|
|
12
|
-
return existingAuth.email.toLowerCase() === user.email.toLowerCase();
|
|
13
|
-
}
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
function getPreservedDextoApiKey(existingAuth, user) {
|
|
17
|
-
if (!existingAuth?.dextoApiKey || !isSameAuthenticatedUser(existingAuth, user)) {
|
|
18
|
-
return null;
|
|
19
|
-
}
|
|
20
|
-
const keyOrigin = existingAuth.dextoPlatformUrl ?? 'https://app.dexto.ai';
|
|
21
|
-
if (new URL(keyOrigin).origin !== new URL(DEXTO_PLATFORM_URL).origin)
|
|
22
|
-
return null;
|
|
23
|
-
const isProvisionedKey = existingAuth.dextoApiKeySource === 'provisioned' ||
|
|
24
|
-
(existingAuth.dextoApiKeySource === undefined && Boolean(existingAuth.dextoKeyId));
|
|
25
|
-
if (!isProvisionedKey) {
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
return {
|
|
29
|
-
dextoApiKey: existingAuth.dextoApiKey,
|
|
30
|
-
...(existingAuth.dextoKeyId ? { dextoKeyId: existingAuth.dextoKeyId } : {}),
|
|
31
|
-
dextoApiKeySource: 'provisioned',
|
|
32
|
-
...(existingAuth.dextoPlatformUrl
|
|
33
|
-
? { dextoPlatformUrl: existingAuth.dextoPlatformUrl }
|
|
34
|
-
: {}),
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
export async function persistOAuthLoginResult(result, options = {}) {
|
|
38
|
-
const existingAuth = await loadAuth();
|
|
39
|
-
const expiresAt = result.expiresIn ? Date.now() + result.expiresIn * 1000 : undefined;
|
|
40
|
-
const preservedDextoApiKey = getPreservedDextoApiKey(existingAuth, result.user);
|
|
41
|
-
await storeAuth({
|
|
42
|
-
token: result.accessToken,
|
|
43
|
-
refreshToken: result.refreshToken,
|
|
44
|
-
userId: result.user?.id,
|
|
45
|
-
email: result.user?.email,
|
|
46
|
-
createdAt: Date.now(),
|
|
47
|
-
expiresAt,
|
|
48
|
-
...(preservedDextoApiKey ?? {}),
|
|
49
|
-
});
|
|
50
|
-
const ensured = await ensureDextoApiKeyForAuthToken(result.accessToken, {
|
|
51
|
-
onStatus: options.onProvisionStatus,
|
|
52
|
-
});
|
|
53
|
-
return {
|
|
54
|
-
email: result.user?.email,
|
|
55
|
-
userId: result.user?.id,
|
|
56
|
-
keyId: ensured?.keyId ?? preservedDextoApiKey?.dextoKeyId ?? undefined,
|
|
57
|
-
hasDextoApiKey: Boolean(ensured?.dextoApiKey ?? preservedDextoApiKey?.dextoApiKey),
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
export async function persistDeviceApiKeyLoginResult(result, platformUrl = DEXTO_PLATFORM_URL) {
|
|
61
|
-
await storeAuth({
|
|
62
|
-
dextoApiKey: result.dextoApiKey,
|
|
63
|
-
dextoKeyId: result.dextoKeyId,
|
|
64
|
-
dextoApiKeySource: 'provisioned',
|
|
65
|
-
dextoPlatformUrl: new URL(platformUrl).origin,
|
|
66
|
-
createdAt: Date.now(),
|
|
67
|
-
});
|
|
68
|
-
return {
|
|
69
|
-
keyId: result.dextoKeyId,
|
|
70
|
-
hasDextoApiKey: true,
|
|
71
|
-
};
|
|
72
|
-
}
|
package/dist/cli/auth/oauth.d.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
interface OAuthConfig {
|
|
2
|
-
authUrl: string;
|
|
3
|
-
clientId: string;
|
|
4
|
-
provider?: string;
|
|
5
|
-
scopes?: string[];
|
|
6
|
-
}
|
|
7
|
-
export interface OAuthResult {
|
|
8
|
-
accessToken: string;
|
|
9
|
-
refreshToken?: string | undefined;
|
|
10
|
-
expiresIn?: number | undefined;
|
|
11
|
-
user?: {
|
|
12
|
-
id: string;
|
|
13
|
-
email: string;
|
|
14
|
-
name?: string | undefined;
|
|
15
|
-
} | undefined;
|
|
16
|
-
}
|
|
17
|
-
interface CallbackServerOptionsInput {
|
|
18
|
-
timeoutMs?: number | undefined;
|
|
19
|
-
signal?: AbortSignal | undefined;
|
|
20
|
-
}
|
|
21
|
-
export interface OAuthLoginSession {
|
|
22
|
-
authUrl: string;
|
|
23
|
-
result: Promise<OAuthResult>;
|
|
24
|
-
cancel: () => void;
|
|
25
|
-
}
|
|
26
|
-
export interface PerformOAuthLoginOptions {
|
|
27
|
-
failOnBrowserOpenError?: boolean | undefined;
|
|
28
|
-
}
|
|
29
|
-
export declare function beginOAuthLogin(config: OAuthConfig, options?: CallbackServerOptionsInput): Promise<OAuthLoginSession>;
|
|
30
|
-
/**
|
|
31
|
-
* Perform OAuth login flow with Supabase
|
|
32
|
-
*/
|
|
33
|
-
export declare function performOAuthLogin(config: OAuthConfig, options?: PerformOAuthLoginOptions): Promise<OAuthResult>;
|
|
34
|
-
/**
|
|
35
|
-
* Default Supabase OAuth configuration for Dexto CLI
|
|
36
|
-
*/
|
|
37
|
-
export declare const DEFAULT_OAUTH_CONFIG: OAuthConfig;
|
|
38
|
-
export {};
|
|
39
|
-
//# sourceMappingURL=oauth.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../../../src/cli/auth/oauth.ts"],"names":[],"mappings":"AA8EA,UAAU,WAAW;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB;AAED,MAAM,WAAW,WAAW;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,IAAI,CAAC,EACC;QACI,EAAE,EAAE,MAAM,CAAC;QACX,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;KAC7B,GACD,SAAS,CAAC;CACnB;AA4BD,UAAU,0BAA0B;IAChC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,MAAM,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;CACpC;AAqSD,MAAM,WAAW,iBAAiB;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;IAC7B,MAAM,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,MAAM,WAAW,wBAAwB;IACrC,sBAAsB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CAChD;AAED,wBAAsB,eAAe,CACjC,MAAM,EAAE,WAAW,EACnB,OAAO,GAAE,0BAA+B,GACzC,OAAO,CAAC,iBAAiB,CAAC,CAyC5B;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CACnC,MAAM,EAAE,WAAW,EACnB,OAAO,GAAE,wBAA6B,GACvC,OAAO,CAAC,WAAW,CAAC,CAoCtB;AAED;;GAEG;AACH,eAAO,MAAM,oBAAoB,EAAE,WAKlC,CAAC"}
|