@voxli/cli 0.3.0 → 0.3.1
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/commands/auth.js
CHANGED
|
@@ -18,7 +18,7 @@ async function promptForKey() {
|
|
|
18
18
|
rl.close();
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
async function validateAndSave(key) {
|
|
21
|
+
async function validateAndSave(key, userId) {
|
|
22
22
|
console.log("Validating...");
|
|
23
23
|
try {
|
|
24
24
|
const hostname = getStableHostname();
|
|
@@ -36,14 +36,14 @@ async function validateAndSave(key) {
|
|
|
36
36
|
// Network error or other — warn but still save
|
|
37
37
|
console.warn("Warning: could not validate key (network error). Saving anyway.");
|
|
38
38
|
}
|
|
39
|
-
await writeConfig({ apiKey: key });
|
|
39
|
+
await writeConfig({ apiKey: key, userId });
|
|
40
40
|
console.log("API key saved to ~/.voxli/config.json");
|
|
41
41
|
}
|
|
42
42
|
export async function authCommand(opts) {
|
|
43
43
|
if (!opts.manual) {
|
|
44
44
|
try {
|
|
45
|
-
const
|
|
46
|
-
await validateAndSave(
|
|
45
|
+
const result = await browserAuth();
|
|
46
|
+
await validateAndSave(result.apiKey, result.userId);
|
|
47
47
|
return;
|
|
48
48
|
}
|
|
49
49
|
catch (err) {
|
package/dist/lib/browser-auth.js
CHANGED
|
@@ -57,6 +57,7 @@ export async function browserAuth() {
|
|
|
57
57
|
}
|
|
58
58
|
const returnedKey = url.searchParams.get("key");
|
|
59
59
|
const returnedState = url.searchParams.get("state");
|
|
60
|
+
const returnedUserId = url.searchParams.get("user_id");
|
|
60
61
|
if (returnedState !== state) {
|
|
61
62
|
res.writeHead(403, { "Content-Type": "text/html" });
|
|
62
63
|
res.end(ERROR_HTML);
|
|
@@ -70,7 +71,7 @@ export async function browserAuth() {
|
|
|
70
71
|
res.writeHead(200, { "Content-Type": "text/html" });
|
|
71
72
|
res.end(SUCCESS_HTML);
|
|
72
73
|
cleanup();
|
|
73
|
-
resolve(returnedKey);
|
|
74
|
+
resolve({ apiKey: returnedKey, userId: returnedUserId || undefined });
|
|
74
75
|
});
|
|
75
76
|
const timeout = setTimeout(() => {
|
|
76
77
|
cleanup();
|
package/dist/types.d.ts
CHANGED