nixamp 0.7.40 → 0.7.41
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/session.js +19 -8
- package/package.json +1 -1
- package/src/session.ts +16 -7
- package/web/dist/sw.js +1 -1
package/dist/session.js
CHANGED
|
@@ -357,20 +357,31 @@ export async function chooseWay(ways, options) {
|
|
|
357
357
|
if (options.device)
|
|
358
358
|
return ways.device ? "device" : null;
|
|
359
359
|
// Naming an address is asking for the password flow by implication.
|
|
360
|
-
if (!ways.device || options.email
|
|
361
|
-
return "password";
|
|
362
|
-
if (ways.providers.length === 0)
|
|
360
|
+
if (!ways.device || options.email)
|
|
363
361
|
return "password";
|
|
362
|
+
// A site with no providers configured still has a browser to approve in,
|
|
363
|
+
// and that is the way in from a terminal: a code, a page, a click. This
|
|
364
|
+
// used to fall through to a password prompt the moment the provider list
|
|
365
|
+
// was empty, which is what nixamp.com answers, so nobody ever saw the
|
|
366
|
+
// browser flow that was built for exactly this. With no terminal to draw
|
|
367
|
+
// a menu on, the browser page offers the providers instead.
|
|
368
|
+
if (ways.providers.length === 0 || !process.stdin.isTTY)
|
|
369
|
+
return "device";
|
|
364
370
|
console.log("How would you like to sign in?");
|
|
365
371
|
ways.providers.forEach((provider, index) => console.log(` ${index + 1}) ${provider.name}`));
|
|
366
|
-
console.log(` ${ways.providers.length + 1})
|
|
372
|
+
console.log(` ${ways.providers.length + 1}) In a browser you are already signed in to`);
|
|
373
|
+
console.log(` ${ways.providers.length + 2}) Email and password`);
|
|
367
374
|
const typed = await ask(`Choose [1]: `);
|
|
368
375
|
const picked = typed === "" ? 1 : Number(typed);
|
|
369
|
-
if (!Number.isInteger(picked) || picked < 1 || picked > ways.providers.length +
|
|
370
|
-
console.log("Not one of those, so:
|
|
371
|
-
return "
|
|
376
|
+
if (!Number.isInteger(picked) || picked < 1 || picked > ways.providers.length + 2) {
|
|
377
|
+
console.log("Not one of those, so: in a browser.");
|
|
378
|
+
return "device";
|
|
372
379
|
}
|
|
373
|
-
|
|
380
|
+
if (picked === ways.providers.length + 1)
|
|
381
|
+
return "device";
|
|
382
|
+
if (picked === ways.providers.length + 2)
|
|
383
|
+
return "password";
|
|
384
|
+
return ways.providers[picked - 1]?.id ?? "device";
|
|
374
385
|
}
|
|
375
386
|
const day = (at) => (at ? new Date(at).toISOString().slice(0, 10) : "never");
|
|
376
387
|
/**
|
package/package.json
CHANGED
package/src/session.ts
CHANGED
|
@@ -417,19 +417,28 @@ export async function chooseWay(ways: SiteWays, options: LoginOptions): Promise<
|
|
|
417
417
|
// them, and a browser that is already signed in can approve on the spot.
|
|
418
418
|
if (options.device) return ways.device ? "device" : null;
|
|
419
419
|
// Naming an address is asking for the password flow by implication.
|
|
420
|
-
if (!ways.device || options.email
|
|
421
|
-
|
|
420
|
+
if (!ways.device || options.email) return "password";
|
|
421
|
+
// A site with no providers configured still has a browser to approve in,
|
|
422
|
+
// and that is the way in from a terminal: a code, a page, a click. This
|
|
423
|
+
// used to fall through to a password prompt the moment the provider list
|
|
424
|
+
// was empty, which is what nixamp.com answers, so nobody ever saw the
|
|
425
|
+
// browser flow that was built for exactly this. With no terminal to draw
|
|
426
|
+
// a menu on, the browser page offers the providers instead.
|
|
427
|
+
if (ways.providers.length === 0 || !process.stdin.isTTY) return "device";
|
|
422
428
|
|
|
423
429
|
console.log("How would you like to sign in?");
|
|
424
430
|
ways.providers.forEach((provider, index) => console.log(` ${index + 1}) ${provider.name}`));
|
|
425
|
-
console.log(` ${ways.providers.length + 1})
|
|
431
|
+
console.log(` ${ways.providers.length + 1}) In a browser you are already signed in to`);
|
|
432
|
+
console.log(` ${ways.providers.length + 2}) Email and password`);
|
|
426
433
|
const typed = await ask(`Choose [1]: `);
|
|
427
434
|
const picked = typed === "" ? 1 : Number(typed);
|
|
428
|
-
if (!Number.isInteger(picked) || picked < 1 || picked > ways.providers.length +
|
|
429
|
-
console.log("Not one of those, so:
|
|
430
|
-
return "
|
|
435
|
+
if (!Number.isInteger(picked) || picked < 1 || picked > ways.providers.length + 2) {
|
|
436
|
+
console.log("Not one of those, so: in a browser.");
|
|
437
|
+
return "device";
|
|
431
438
|
}
|
|
432
|
-
|
|
439
|
+
if (picked === ways.providers.length + 1) return "device";
|
|
440
|
+
if (picked === ways.providers.length + 2) return "password";
|
|
441
|
+
return ways.providers[picked - 1]?.id ?? "device";
|
|
433
442
|
}
|
|
434
443
|
|
|
435
444
|
const day = (at: number | null): string => (at ? new Date(at).toISOString().slice(0, 10) : "never");
|
package/web/dist/sw.js
CHANGED