phewsh 0.5.1 → 0.5.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/commands/login.js +31 -0
- package/package.json +1 -1
package/commands/login.js
CHANGED
|
@@ -53,6 +53,37 @@ async function main() {
|
|
|
53
53
|
return;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
// --token: paste a JWT obtained from phewsh.com/intent settings
|
|
57
|
+
if (args.includes('--token')) {
|
|
58
|
+
const tokenIdx = args.indexOf('--token');
|
|
59
|
+
const jwt = args[tokenIdx + 1];
|
|
60
|
+
if (!jwt) {
|
|
61
|
+
console.log('\n Usage: phewsh login --token <jwt-from-web>\n');
|
|
62
|
+
console.log(' Get your token at phewsh.com/intent → Settings → CLI Access\n');
|
|
63
|
+
process.exit(1);
|
|
64
|
+
}
|
|
65
|
+
// Decode JWT payload (no verification needed — Supabase will validate on API calls)
|
|
66
|
+
try {
|
|
67
|
+
const payload = JSON.parse(Buffer.from(jwt.split('.')[1], 'base64url').toString());
|
|
68
|
+
const config = loadConfig() || {};
|
|
69
|
+
saveConfig({
|
|
70
|
+
...config,
|
|
71
|
+
userId: payload.sub,
|
|
72
|
+
email: payload.email || config.email || '',
|
|
73
|
+
supabaseUserId: payload.sub,
|
|
74
|
+
supabaseAccessToken: jwt,
|
|
75
|
+
supabaseRefreshToken: config.supabaseRefreshToken || null,
|
|
76
|
+
});
|
|
77
|
+
console.log(`\n ✓ Logged in as ${payload.email || payload.sub}`);
|
|
78
|
+
console.log(' ✓ Cloud sync enabled\n');
|
|
79
|
+
console.log(' Note: web tokens expire in ~1 hour. Run `phewsh login --refresh` if sync fails.\n');
|
|
80
|
+
} catch {
|
|
81
|
+
console.error('\n Invalid token. Copy it from phewsh.com/intent → Settings → CLI Access.\n');
|
|
82
|
+
process.exit(1);
|
|
83
|
+
}
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
|
|
56
87
|
if (args.includes('--set-key')) {
|
|
57
88
|
const config = loadConfig() || {};
|
|
58
89
|
const { ask, close } = createPrompter();
|