@dirgha/code 1.17.1 → 1.17.2
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/slash/login.d.ts +2 -2
- package/dist/cli/slash/login.js +8 -8
- package/dist/cli/slash/login.js.map +1 -1
- package/dist/cli/subcommands/login.d.ts +1 -1
- package/dist/cli/subcommands/login.js +42 -34
- package/dist/cli/subcommands/login.js.map +1 -1
- package/dist/integrations/device-auth.js +53 -42
- package/dist/integrations/device-auth.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* /login — device-code flow inside the REPL.
|
|
3
3
|
*
|
|
4
|
-
* Kicks off `/api/auth/device/
|
|
4
|
+
* Kicks off `/api/auth/device/request`, shows the user code + verification
|
|
5
5
|
* URL, then polls in the background so the REPL stays interactive. On
|
|
6
6
|
* success, saves the token and swaps it into `SlashContext` so
|
|
7
7
|
* subsequent billing / entitlement calls pick it up immediately.
|
|
8
8
|
*/
|
|
9
|
-
import type { SlashCommand } from
|
|
9
|
+
import type { SlashCommand } from "./types.js";
|
|
10
10
|
export declare const loginCommand: SlashCommand;
|
package/dist/cli/slash/login.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* /login — device-code flow inside the REPL.
|
|
3
3
|
*
|
|
4
|
-
* Kicks off `/api/auth/device/
|
|
4
|
+
* Kicks off `/api/auth/device/request`, shows the user code + verification
|
|
5
5
|
* URL, then polls in the background so the REPL stays interactive. On
|
|
6
6
|
* success, saves the token and swaps it into `SlashContext` so
|
|
7
7
|
* subsequent billing / entitlement calls pick it up immediately.
|
|
8
8
|
*/
|
|
9
|
-
import { loadToken, pollDeviceAuth, saveToken, startDeviceAuth, } from
|
|
9
|
+
import { loadToken, pollDeviceAuth, saveToken, startDeviceAuth, } from "../../integrations/device-auth.js";
|
|
10
10
|
export const loginCommand = {
|
|
11
|
-
name:
|
|
12
|
-
description:
|
|
11
|
+
name: "login",
|
|
12
|
+
description: "Sign in via device-code flow",
|
|
13
13
|
async execute(_args, ctx) {
|
|
14
14
|
let start;
|
|
15
15
|
try {
|
|
@@ -35,13 +35,13 @@ export const loginCommand = {
|
|
|
35
35
|
}
|
|
36
36
|
})();
|
|
37
37
|
return [
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
"Device-code login started.",
|
|
39
|
+
"",
|
|
40
40
|
` 1. Open: ${start.verifyUri}`,
|
|
41
41
|
` 2. Enter code: ${start.userCode}`,
|
|
42
|
-
|
|
42
|
+
"",
|
|
43
43
|
`Expires in ~${Math.round(start.expiresIn / 60_000)} minutes. The REPL stays usable; a status line will appear when authorization completes.`,
|
|
44
|
-
].join(
|
|
44
|
+
].join("\n");
|
|
45
45
|
},
|
|
46
46
|
};
|
|
47
47
|
//# sourceMappingURL=login.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../../src/cli/slash/login.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,SAAS,EACT,cAAc,EACd,SAAS,EACT,eAAe,GAEhB,MAAM,mCAAmC,CAAC;AAG3C,MAAM,CAAC,MAAM,YAAY,GAAiB;IACxC,IAAI,EAAE,OAAO;IACb,WAAW,EAAE,8BAA8B;IAC3C,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG;QACtB,IAAI,KAAsB,CAAC;QAC3B,IAAI,CAAC;YACH,KAAK,GAAG,MAAM,eAAe,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;QAC/C,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,0BAA0B,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;QACtF,CAAC;QAED,mEAAmE;QACnE,KAAK,CAAC,KAAK,IAAI,EAAE;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,CAAC;gBACH,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,KAAK,CAAC,UAAU,EAAE,GAAG,CAAC,OAAO,EAAE,EAAE;oBACnE,UAAU,EAAE,KAAK,CAAC,QAAQ;oBAC1B,SAAS,EAAE,KAAK,CAAC,SAAS;iBAC3B,CAAC,CAAC;gBACH,MAAM,SAAS,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;gBAC3D,MAAM,SAAS,GAAG,MAAM,SAAS,EAAE,CAAC;gBACpC,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;gBACxB,GAAG,CAAC,MAAM,CAAC,uBAAuB,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;YACpD,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,GAAG,CAAC,MAAM,CACR,wBAAwB,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAC3E,CAAC;YACJ,CAAC;QACH,CAAC,CAAC,EAAE,CAAC;QAEL,OAAO;YACL,4BAA4B;YAC5B,EAAE;YACF,cAAc,KAAK,CAAC,SAAS,EAAE;YAC/B,oBAAoB,KAAK,CAAC,QAAQ,EAAE;YACpC,EAAE;YACF,eAAe,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,GAAG,MAAM,CAAC,0FAA0F;SAC9I,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACf,CAAC;CACF,CAAC"}
|
|
@@ -10,6 +10,6 @@
|
|
|
10
10
|
*
|
|
11
11
|
* Non-REPL variant of the `/login` slash command. Returns POSIX exit codes.
|
|
12
12
|
*/
|
|
13
|
-
import type { Subcommand } from
|
|
13
|
+
import type { Subcommand } from "./index.js";
|
|
14
14
|
export declare function runLogin(argv: string[]): Promise<number>;
|
|
15
15
|
export declare const loginSubcommand: Subcommand;
|
|
@@ -10,20 +10,20 @@
|
|
|
10
10
|
*
|
|
11
11
|
* Non-REPL variant of the `/login` slash command. Returns POSIX exit codes.
|
|
12
12
|
*/
|
|
13
|
-
import { stdin, stdout } from
|
|
14
|
-
import { chmod, mkdir, readFile, writeFile } from
|
|
15
|
-
import { homedir } from
|
|
16
|
-
import { join } from
|
|
17
|
-
import { createInterface } from
|
|
18
|
-
import { pollDeviceAuth, saveToken, startDeviceAuth, } from
|
|
19
|
-
import { defaultTheme, style } from
|
|
13
|
+
import { stdin, stdout } from "node:process";
|
|
14
|
+
import { chmod, mkdir, readFile, writeFile } from "node:fs/promises";
|
|
15
|
+
import { homedir } from "node:os";
|
|
16
|
+
import { join } from "node:path";
|
|
17
|
+
import { createInterface } from "node:readline/promises";
|
|
18
|
+
import { pollDeviceAuth, saveToken, startDeviceAuth, } from "../../integrations/device-auth.js";
|
|
19
|
+
import { defaultTheme, style } from "../../tui/theme.js";
|
|
20
20
|
const PROVIDER_ENV = {
|
|
21
|
-
nvidia:
|
|
22
|
-
openrouter:
|
|
23
|
-
anthropic:
|
|
24
|
-
openai:
|
|
25
|
-
gemini:
|
|
26
|
-
fireworks:
|
|
21
|
+
nvidia: "NVIDIA_API_KEY",
|
|
22
|
+
openrouter: "OPENROUTER_API_KEY",
|
|
23
|
+
anthropic: "ANTHROPIC_API_KEY",
|
|
24
|
+
openai: "OPENAI_API_KEY",
|
|
25
|
+
gemini: "GEMINI_API_KEY",
|
|
26
|
+
fireworks: "FIREWORKS_API_KEY",
|
|
27
27
|
};
|
|
28
28
|
function print(line) {
|
|
29
29
|
stdout.write(`${line}\n`);
|
|
@@ -40,10 +40,10 @@ function parseFlag(argv, name) {
|
|
|
40
40
|
return undefined;
|
|
41
41
|
}
|
|
42
42
|
function keyStorePath() {
|
|
43
|
-
return join(homedir(),
|
|
43
|
+
return join(homedir(), ".dirgha", "keys.json");
|
|
44
44
|
}
|
|
45
45
|
async function readKeys() {
|
|
46
|
-
const text = await readFile(keyStorePath(),
|
|
46
|
+
const text = await readFile(keyStorePath(), "utf8").catch(() => "");
|
|
47
47
|
if (!text)
|
|
48
48
|
return {};
|
|
49
49
|
try {
|
|
@@ -54,19 +54,22 @@ async function readKeys() {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
async function writeKeys(store) {
|
|
57
|
-
await mkdir(join(homedir(),
|
|
58
|
-
await writeFile(keyStorePath(), JSON.stringify(store, null, 2) +
|
|
57
|
+
await mkdir(join(homedir(), ".dirgha"), { recursive: true });
|
|
58
|
+
await writeFile(keyStorePath(), JSON.stringify(store, null, 2) + "\n", "utf8");
|
|
59
59
|
try {
|
|
60
60
|
await chmod(keyStorePath(), 0o600);
|
|
61
61
|
}
|
|
62
|
-
catch {
|
|
62
|
+
catch {
|
|
63
|
+
/* non-POSIX */
|
|
64
|
+
}
|
|
63
65
|
}
|
|
64
66
|
async function promptHidden(prompt) {
|
|
65
67
|
const rl = createInterface({ input: stdin, output: stdout, terminal: true });
|
|
66
68
|
const wasRaw = stdin.isTTY ? stdin.isRaw : false;
|
|
67
69
|
// Simple hidden read: replace the readline echo with nothing.
|
|
68
70
|
// Works for typed input; pasted input is fine too.
|
|
69
|
-
const orig = rl
|
|
71
|
+
const orig = rl
|
|
72
|
+
._writeToOutput;
|
|
70
73
|
rl._writeToOutput = (s) => {
|
|
71
74
|
if (s.startsWith(prompt))
|
|
72
75
|
stdout.write(prompt);
|
|
@@ -77,7 +80,8 @@ async function promptHidden(prompt) {
|
|
|
77
80
|
return value.trim();
|
|
78
81
|
}
|
|
79
82
|
finally {
|
|
80
|
-
rl._writeToOutput =
|
|
83
|
+
rl._writeToOutput =
|
|
84
|
+
orig;
|
|
81
85
|
rl.close();
|
|
82
86
|
if (wasRaw && stdin.setRawMode)
|
|
83
87
|
stdin.setRawMode(true);
|
|
@@ -86,44 +90,46 @@ async function promptHidden(prompt) {
|
|
|
86
90
|
async function runProviderLogin(provider, argv) {
|
|
87
91
|
const env = PROVIDER_ENV[provider.toLowerCase()];
|
|
88
92
|
if (!env) {
|
|
89
|
-
print(style(defaultTheme.danger, `\n✗ Unknown provider "${provider}". Known: ${Object.keys(PROVIDER_ENV).join(
|
|
93
|
+
print(style(defaultTheme.danger, `\n✗ Unknown provider "${provider}". Known: ${Object.keys(PROVIDER_ENV).join(", ")}`));
|
|
90
94
|
return 1;
|
|
91
95
|
}
|
|
92
|
-
let key = parseFlag(argv,
|
|
96
|
+
let key = parseFlag(argv, "key");
|
|
93
97
|
if (!key) {
|
|
94
98
|
print(style(defaultTheme.accent, `\nBYOK login for ${provider}`));
|
|
95
99
|
print(style(defaultTheme.muted, ` paste your ${env} value (input hidden):`));
|
|
96
|
-
key = await promptHidden(
|
|
100
|
+
key = await promptHidden("> ");
|
|
97
101
|
}
|
|
98
102
|
if (!key || key.length < 6) {
|
|
99
|
-
print(style(defaultTheme.danger,
|
|
103
|
+
print(style(defaultTheme.danger, "\n✗ Empty or implausibly short key — aborted."));
|
|
100
104
|
return 1;
|
|
101
105
|
}
|
|
102
106
|
const store = await readKeys();
|
|
103
107
|
store[env] = key;
|
|
104
108
|
await writeKeys(store);
|
|
105
109
|
print(style(defaultTheme.success, `\n✓ Stored ${env} (${key.length} chars) at ~/.dirgha/keys.json (mode 0600).`));
|
|
106
|
-
print(style(defaultTheme.muted,
|
|
110
|
+
print(style(defaultTheme.muted, " Run `dirgha keys list` to verify, or `dirgha logout --provider=" +
|
|
111
|
+
provider +
|
|
112
|
+
"` to remove."));
|
|
107
113
|
return 0;
|
|
108
114
|
}
|
|
109
115
|
export async function runLogin(argv) {
|
|
110
|
-
const provider = parseFlag(argv,
|
|
116
|
+
const provider = parseFlag(argv, "provider");
|
|
111
117
|
if (provider)
|
|
112
118
|
return runProviderLogin(provider, argv);
|
|
113
|
-
const apiBase = parseFlag(argv,
|
|
114
|
-
print(style(defaultTheme.accent,
|
|
119
|
+
const apiBase = parseFlag(argv, "api-base") ?? process.env.DIRGHA_API_BASE;
|
|
120
|
+
print(style(defaultTheme.accent, "\ndirgha — device-code sign-in"));
|
|
115
121
|
let start;
|
|
116
122
|
try {
|
|
117
123
|
start = await startDeviceAuth(apiBase);
|
|
118
124
|
}
|
|
119
125
|
catch (err) {
|
|
120
|
-
print(style(defaultTheme.danger, `\n✗ device/
|
|
126
|
+
print(style(defaultTheme.danger, `\n✗ device/request failed: ${err instanceof Error ? err.message : String(err)}`));
|
|
121
127
|
return 2;
|
|
122
128
|
}
|
|
123
|
-
print(
|
|
129
|
+
print("");
|
|
124
130
|
print(` 1. Open: ${start.verifyUri}`);
|
|
125
131
|
print(` 2. Enter code: ${style(defaultTheme.accent, start.userCode)}`);
|
|
126
|
-
print(
|
|
132
|
+
print("");
|
|
127
133
|
print(`Waiting for authorization (expires in ~${Math.round(start.expiresIn / 60_000)} min)...`);
|
|
128
134
|
try {
|
|
129
135
|
const result = await pollDeviceAuth(start.deviceCode, apiBase, {
|
|
@@ -140,8 +146,10 @@ export async function runLogin(argv) {
|
|
|
140
146
|
}
|
|
141
147
|
}
|
|
142
148
|
export const loginSubcommand = {
|
|
143
|
-
name:
|
|
144
|
-
description:
|
|
145
|
-
async run(argv) {
|
|
149
|
+
name: "login",
|
|
150
|
+
description: "Sign in via device-code flow",
|
|
151
|
+
async run(argv) {
|
|
152
|
+
return runLogin(argv);
|
|
153
|
+
},
|
|
146
154
|
};
|
|
147
155
|
//# sourceMappingURL=login.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../../src/cli/subcommands/login.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;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AAC,OAAO,GAAG,EAAE,CAAC;QACb,KAAK,CACH,KAAK,CACH,YAAY,CAAC,MAAM,EACnB,qBAAqB,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CACxE,CACF,CAAC;QACF,OAAO,CAAC,CAAC;IACX,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,eAAe,GAAe;IACzC,IAAI,EAAE,OAAO;IACb,WAAW,EAAE,8BAA8B;IAC3C,KAAK,CAAC,GAAG,CAAC,IAAI;QACZ,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC;CACF,CAAC"}
|
|
@@ -12,46 +12,49 @@
|
|
|
12
12
|
* - CLI subcommands (`dirgha login`, `dirgha logout`).
|
|
13
13
|
* - Billing preflight (`preRequestCheck` reads the bearer).
|
|
14
14
|
*/
|
|
15
|
-
import { chmod, mkdir, readFile, rename, stat, unlink, writeFile, open } from
|
|
16
|
-
import { homedir } from
|
|
17
|
-
import { dirname, join } from
|
|
18
|
-
const DEFAULT_API_BASE =
|
|
15
|
+
import { chmod, mkdir, readFile, rename, stat, unlink, writeFile, open, } from "node:fs/promises";
|
|
16
|
+
import { homedir } from "node:os";
|
|
17
|
+
import { dirname, join } from "node:path";
|
|
18
|
+
const DEFAULT_API_BASE = "https://api.dirgha.ai";
|
|
19
19
|
const POLL_INTERVAL_MS = 2_000;
|
|
20
20
|
const POLL_TIMEOUT_MS = 15 * 60 * 1_000;
|
|
21
21
|
const TOKEN_TTL_MS = 30 * 24 * 60 * 60 * 1_000;
|
|
22
22
|
function resolveApiBase(apiBase) {
|
|
23
23
|
const raw = apiBase ?? process.env.DIRGHA_API_BASE ?? DEFAULT_API_BASE;
|
|
24
|
-
return raw.replace(/\/+$/,
|
|
24
|
+
return raw.replace(/\/+$/, "");
|
|
25
25
|
}
|
|
26
26
|
function credentialsPath() {
|
|
27
|
-
return join(homedir(),
|
|
27
|
+
return join(homedir(), ".dirgha", "credentials.json");
|
|
28
28
|
}
|
|
29
29
|
function redact(err) {
|
|
30
30
|
const message = err instanceof Error ? err.message : String(err);
|
|
31
|
-
return message.replace(/Bearer\s+[\w.-]+/gi,
|
|
31
|
+
return message.replace(/Bearer\s+[\w.-]+/gi, "Bearer [REDACTED]");
|
|
32
32
|
}
|
|
33
33
|
export async function startDeviceAuth(apiBase) {
|
|
34
34
|
const base = resolveApiBase(apiBase);
|
|
35
35
|
let response;
|
|
36
36
|
try {
|
|
37
|
-
response = await fetch(`${base}/api/auth/device/
|
|
38
|
-
method:
|
|
39
|
-
headers: {
|
|
40
|
-
|
|
37
|
+
response = await fetch(`${base}/api/auth/device/request`, {
|
|
38
|
+
method: "POST",
|
|
39
|
+
headers: {
|
|
40
|
+
"Content-Type": "application/json",
|
|
41
|
+
Accept: "application/json",
|
|
42
|
+
},
|
|
43
|
+
body: JSON.stringify({ client_id: "dirgha-cli" }),
|
|
41
44
|
});
|
|
42
45
|
}
|
|
43
46
|
catch (err) {
|
|
44
|
-
throw new Error(`device/
|
|
47
|
+
throw new Error(`device/request request failed: ${redact(err)}`);
|
|
45
48
|
}
|
|
46
49
|
if (!response.ok) {
|
|
47
|
-
throw new Error(`device/
|
|
50
|
+
throw new Error(`device/request failed: HTTP ${response.status}`);
|
|
48
51
|
}
|
|
49
52
|
const data = (await response.json());
|
|
50
53
|
const deviceCode = data.device_code;
|
|
51
54
|
const userCode = data.user_code;
|
|
52
55
|
const verifyUri = data.verification_uri ?? data.verification_url;
|
|
53
56
|
if (!deviceCode || !userCode || !verifyUri) {
|
|
54
|
-
throw new Error(
|
|
57
|
+
throw new Error("device/request returned malformed payload");
|
|
55
58
|
}
|
|
56
59
|
return {
|
|
57
60
|
deviceCode,
|
|
@@ -68,10 +71,12 @@ export async function pollDeviceAuth(deviceCode, apiBase, opts = {}) {
|
|
|
68
71
|
while (Date.now() < deadline) {
|
|
69
72
|
let response;
|
|
70
73
|
try {
|
|
71
|
-
response = await fetch(`${base}/api/auth/device/poll`, {
|
|
72
|
-
method:
|
|
73
|
-
headers: {
|
|
74
|
-
|
|
74
|
+
response = await fetch(`${base}/api/auth/device/poll?device_code=${encodeURIComponent(deviceCode)}`, {
|
|
75
|
+
method: "GET",
|
|
76
|
+
headers: {
|
|
77
|
+
Accept: "application/json",
|
|
78
|
+
"Content-Type": "application/json",
|
|
79
|
+
},
|
|
75
80
|
});
|
|
76
81
|
}
|
|
77
82
|
catch (err) {
|
|
@@ -82,29 +87,31 @@ export async function pollDeviceAuth(deviceCode, apiBase, opts = {}) {
|
|
|
82
87
|
continue;
|
|
83
88
|
}
|
|
84
89
|
if (response.status === 410)
|
|
85
|
-
throw new Error(
|
|
90
|
+
throw new Error("device code expired");
|
|
86
91
|
if (response.status === 403)
|
|
87
|
-
throw new Error(
|
|
92
|
+
throw new Error("device code denied");
|
|
88
93
|
if (response.ok) {
|
|
89
94
|
const data = (await response.json());
|
|
90
|
-
if (data.status ===
|
|
95
|
+
if (data.status === "authorized" && data.token) {
|
|
91
96
|
return {
|
|
92
97
|
token: data.token,
|
|
93
|
-
userId: data.user?.id ??
|
|
94
|
-
email: data.user?.email ??
|
|
98
|
+
userId: data.user?.id ?? "unknown",
|
|
99
|
+
email: data.user?.email ?? "unknown",
|
|
95
100
|
};
|
|
96
101
|
}
|
|
97
|
-
if (data.status ===
|
|
98
|
-
throw new Error(
|
|
99
|
-
if (data.status ===
|
|
100
|
-
throw new Error(
|
|
102
|
+
if (data.status === "denied")
|
|
103
|
+
throw new Error("device code denied");
|
|
104
|
+
if (data.status === "expired")
|
|
105
|
+
throw new Error("device code expired");
|
|
101
106
|
}
|
|
102
|
-
else if (response.status !== 202 &&
|
|
107
|
+
else if (response.status !== 202 &&
|
|
108
|
+
response.status !== 425 &&
|
|
109
|
+
response.status !== 428) {
|
|
103
110
|
throw new Error(`device/poll failed: HTTP ${response.status}`);
|
|
104
111
|
}
|
|
105
112
|
await sleep(intervalMs);
|
|
106
113
|
}
|
|
107
|
-
throw new Error(
|
|
114
|
+
throw new Error("device/poll timed out");
|
|
108
115
|
}
|
|
109
116
|
export async function saveToken(token, userId, email) {
|
|
110
117
|
const path = credentialsPath();
|
|
@@ -120,9 +127,9 @@ export async function saveToken(token, userId, email) {
|
|
|
120
127
|
// then rename into place — avoids a world-readable window where any local
|
|
121
128
|
// process could read the JWT between writeFile and chmod.
|
|
122
129
|
try {
|
|
123
|
-
const fh = await open(tmp,
|
|
130
|
+
const fh = await open(tmp, "w", 0o600);
|
|
124
131
|
try {
|
|
125
|
-
await fh.writeFile(JSON.stringify(payload, null, 2),
|
|
132
|
+
await fh.writeFile(JSON.stringify(payload, null, 2), "utf8");
|
|
126
133
|
}
|
|
127
134
|
finally {
|
|
128
135
|
await fh.close();
|
|
@@ -132,17 +139,19 @@ export async function saveToken(token, userId, email) {
|
|
|
132
139
|
catch {
|
|
133
140
|
// Fallback path for platforms where open+mode isn't supported (e.g. Windows):
|
|
134
141
|
// write first, then chmod. The window is unavoidable there.
|
|
135
|
-
await writeFile(path, JSON.stringify(payload, null, 2),
|
|
142
|
+
await writeFile(path, JSON.stringify(payload, null, 2), "utf8");
|
|
136
143
|
try {
|
|
137
144
|
await chmod(path, 0o600);
|
|
138
145
|
}
|
|
139
|
-
catch {
|
|
146
|
+
catch {
|
|
147
|
+
/* non-POSIX */
|
|
148
|
+
}
|
|
140
149
|
await unlink(tmp).catch(() => undefined);
|
|
141
150
|
}
|
|
142
151
|
}
|
|
143
152
|
export async function loadToken() {
|
|
144
153
|
const path = credentialsPath();
|
|
145
|
-
const text = await readFile(path,
|
|
154
|
+
const text = await readFile(path, "utf8").catch(() => undefined);
|
|
146
155
|
if (!text)
|
|
147
156
|
return null;
|
|
148
157
|
try {
|
|
@@ -169,7 +178,7 @@ export async function clearToken() {
|
|
|
169
178
|
* Logs a single line to stderr on a successful move. Silent on no-op.
|
|
170
179
|
*/
|
|
171
180
|
export async function migrateLegacyAuth() {
|
|
172
|
-
const legacyPath = join(homedir(),
|
|
181
|
+
const legacyPath = join(homedir(), ".dirgha", "auth.json");
|
|
173
182
|
const targetPath = credentialsPath();
|
|
174
183
|
const legacyInfo = await stat(legacyPath).catch(() => undefined);
|
|
175
184
|
if (!legacyInfo || !legacyInfo.isFile() || legacyInfo.size === 0)
|
|
@@ -177,7 +186,7 @@ export async function migrateLegacyAuth() {
|
|
|
177
186
|
const targetInfo = await stat(targetPath).catch(() => undefined);
|
|
178
187
|
if (targetInfo && targetInfo.size > 0)
|
|
179
188
|
return false;
|
|
180
|
-
const text = await readFile(legacyPath,
|
|
189
|
+
const text = await readFile(legacyPath, "utf8").catch(() => undefined);
|
|
181
190
|
if (!text)
|
|
182
191
|
return false;
|
|
183
192
|
let parsed;
|
|
@@ -192,20 +201,22 @@ export async function migrateLegacyAuth() {
|
|
|
192
201
|
await mkdir(dirname(targetPath), { recursive: true });
|
|
193
202
|
const payload = {
|
|
194
203
|
token: parsed.jwt,
|
|
195
|
-
userId: parsed.userId ??
|
|
196
|
-
email:
|
|
204
|
+
userId: parsed.userId ?? "unknown",
|
|
205
|
+
email: "unknown",
|
|
197
206
|
expiresAt: parsed.expiresAt ?? new Date(Date.now() + TOKEN_TTL_MS).toISOString(),
|
|
198
207
|
};
|
|
199
|
-
await writeFile(targetPath, JSON.stringify(payload, null, 2),
|
|
208
|
+
await writeFile(targetPath, JSON.stringify(payload, null, 2), "utf8");
|
|
200
209
|
try {
|
|
201
210
|
await chmod(targetPath, 0o600);
|
|
202
211
|
}
|
|
203
|
-
catch {
|
|
212
|
+
catch {
|
|
213
|
+
/* non-POSIX */
|
|
214
|
+
}
|
|
204
215
|
await rename(legacyPath, `${legacyPath}.migrated`).catch(() => undefined);
|
|
205
|
-
process.stderr.write(
|
|
216
|
+
process.stderr.write("[auth] migrated legacy credentials\n");
|
|
206
217
|
return true;
|
|
207
218
|
}
|
|
208
219
|
function sleep(ms) {
|
|
209
|
-
return new Promise(resolve => setTimeout(resolve, ms));
|
|
220
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
210
221
|
}
|
|
211
222
|
//# sourceMappingURL=device-auth.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"device-auth.js","sourceRoot":"","sources":["../../src/integrations/device-auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"device-auth.js","sourceRoot":"","sources":["../../src/integrations/device-auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EACL,KAAK,EACL,KAAK,EACL,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,MAAM,EACN,SAAS,EACT,IAAI,GACL,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAsC1C,MAAM,gBAAgB,GAAG,uBAAuB,CAAC;AACjD,MAAM,gBAAgB,GAAG,KAAK,CAAC;AAC/B,MAAM,eAAe,GAAG,EAAE,GAAG,EAAE,GAAG,KAAK,CAAC;AACxC,MAAM,YAAY,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,KAAK,CAAC;AAE/C,SAAS,cAAc,CAAC,OAAgB;IACtC,MAAM,GAAG,GAAG,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,gBAAgB,CAAC;IACvE,OAAO,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AACjC,CAAC;AAED,SAAS,eAAe;IACtB,OAAO,IAAI,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,kBAAkB,CAAC,CAAC;AACxD,CAAC;AAED,SAAS,MAAM,CAAC,GAAY;IAC1B,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAA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EAAE,EAAE,CAAC,CAAC,CAAC;AAC3D,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dirgha/code",
|
|
3
|
-
"version": "1.17.
|
|
3
|
+
"version": "1.17.2",
|
|
4
4
|
"description": "CLI coding agent for complex agentic workflows and long-horizon development. Local models (llama.cpp / Ollama), BYOK across 17 providers, parallel agents, persistent memory, scanned skills.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|