smashspace 0.1.5 → 0.1.6
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/smash.mjs +22 -0
- package/package.json +1 -1
package/dist/smash.mjs
CHANGED
|
@@ -4531,8 +4531,30 @@ program2.command("login").description(
|
|
|
4531
4531
|
).option(
|
|
4532
4532
|
"--token <token>",
|
|
4533
4533
|
"Skip the browser flow and save the provided token directly"
|
|
4534
|
+
).option(
|
|
4535
|
+
"-f, --force",
|
|
4536
|
+
"Re-issue a token even if a valid one is already saved"
|
|
4534
4537
|
).action(async (opts) => {
|
|
4535
4538
|
const baseUrl = resolveBaseUrl();
|
|
4539
|
+
if (!opts.token && !opts.force) {
|
|
4540
|
+
const existing = await resolveToken(baseUrl);
|
|
4541
|
+
if (existing) {
|
|
4542
|
+
const check = await fetch(new URL("/api/usage/me", baseUrl), {
|
|
4543
|
+
headers: { Authorization: `Bearer ${existing}` }
|
|
4544
|
+
}).catch(() => null);
|
|
4545
|
+
if (check?.ok) {
|
|
4546
|
+
const me2 = await check.json();
|
|
4547
|
+
show(
|
|
4548
|
+
{ baseUrl, userId: me2.userId, alreadySignedIn: true },
|
|
4549
|
+
[
|
|
4550
|
+
`\u2713 already signed in as ${me2.userId} on ${baseUrl} \u2014 saved token is valid, nothing to do.`,
|
|
4551
|
+
` (use 'smash login --force' to re-issue)`
|
|
4552
|
+
]
|
|
4553
|
+
);
|
|
4554
|
+
return;
|
|
4555
|
+
}
|
|
4556
|
+
}
|
|
4557
|
+
}
|
|
4536
4558
|
let token = opts.token?.trim();
|
|
4537
4559
|
if (!token) {
|
|
4538
4560
|
try {
|