@todoforai/cli 0.1.1 → 0.1.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/todoai.js +11 -8
- package/package.json +1 -1
package/dist/todoai.js
CHANGED
|
@@ -44871,9 +44871,9 @@ Cancelled by user (Ctrl+C)
|
|
|
44871
44871
|
return;
|
|
44872
44872
|
}
|
|
44873
44873
|
const apiUrl = normalizeApiUrl(args["api-url"] || cfg.data.default_api_url || getEnv("API_URL") || DEFAULT_API_URL);
|
|
44874
|
-
|
|
44875
|
-
const
|
|
44876
|
-
const { code, url, expiresIn } = await
|
|
44874
|
+
async function deviceLogin() {
|
|
44875
|
+
const loginApi = new ApiClient(apiUrl, "");
|
|
44876
|
+
const { code, url, expiresIn } = await loginApi.initDeviceLogin("cli");
|
|
44877
44877
|
const userCode = new URL(url).searchParams.get("user_code") || code.slice(-8).toUpperCase();
|
|
44878
44878
|
process.stderr.write(`
|
|
44879
44879
|
\uD83D\uDD11 Open this URL to authorize:
|
|
@@ -44899,13 +44899,13 @@ Cancelled by user (Ctrl+C)
|
|
|
44899
44899
|
while (Date.now() < deadline) {
|
|
44900
44900
|
await new Promise((r) => setTimeout(r, 3000));
|
|
44901
44901
|
try {
|
|
44902
|
-
const poll = await
|
|
44902
|
+
const poll = await loginApi.pollDeviceLogin(code);
|
|
44903
44903
|
failures = 0;
|
|
44904
44904
|
if (poll.status === "complete" && poll.apiKey) {
|
|
44905
44905
|
cfg.setDefaultApiKey(poll.apiKey);
|
|
44906
44906
|
process.stderr.write(`${GREEN}\u2705 Login successful! API key saved.${RESET}
|
|
44907
44907
|
`);
|
|
44908
|
-
return;
|
|
44908
|
+
return poll.apiKey;
|
|
44909
44909
|
}
|
|
44910
44910
|
if (poll.status === "expired")
|
|
44911
44911
|
break;
|
|
@@ -44921,10 +44921,13 @@ Cancelled by user (Ctrl+C)
|
|
|
44921
44921
|
`);
|
|
44922
44922
|
process.exit(1);
|
|
44923
44923
|
}
|
|
44924
|
-
|
|
44924
|
+
if (positionals[0] === "login" && positionals.length === 1) {
|
|
44925
|
+
await deviceLogin();
|
|
44926
|
+
return;
|
|
44927
|
+
}
|
|
44928
|
+
let apiKey = args["api-key"] || cfg.data.default_api_key || getEnv("API_KEY") || "";
|
|
44925
44929
|
if (!apiKey) {
|
|
44926
|
-
|
|
44927
|
-
process.exit(1);
|
|
44930
|
+
apiKey = await deviceLogin();
|
|
44928
44931
|
}
|
|
44929
44932
|
const api = new ApiClient(apiUrl, apiKey);
|
|
44930
44933
|
if (args.inspect) {
|