pubz 0.2.8 → 0.2.9

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.
Files changed (2) hide show
  1. package/dist/cli.js +13 -11
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -346,10 +346,9 @@ async function npmLogin(registry) {
346
346
  });
347
347
  });
348
348
  }
349
- async function promptForOtp() {
350
- console.log("");
351
- const code = await prompt(`${cyan("?")} Enter OTP code from your authenticator: `);
352
- return code.trim();
349
+ async function reauthenticate(registry) {
350
+ const loginResult = await npmLogin(registry);
351
+ return loginResult.success;
353
352
  }
354
353
 
355
354
  // src/publish.ts
@@ -439,11 +438,14 @@ async function publishPackage(pkg, registry, context, dryRun) {
439
438
  args.push("--otp", context.otp);
440
439
  }
441
440
  let result = await run("npm", args, pkg.path);
442
- if (result.code !== 0 && isOtpError(result.output) && context.onOtpRequired) {
443
- const otpCode = await context.onOtpRequired();
444
- if (otpCode) {
445
- context.otp = otpCode;
446
- const retryArgs = ["publish", "--registry", registry, "--access", "public", "--otp", otpCode];
441
+ if (result.code !== 0 && isOtpError(result.output) && context.onAuthRequired) {
442
+ console.log("");
443
+ console.log("2FA verification required. Opening browser for authentication...");
444
+ const authSuccess = await context.onAuthRequired(registry);
445
+ if (authSuccess) {
446
+ console.log("");
447
+ console.log(`Retrying publish...`);
448
+ const retryArgs = ["publish", "--registry", registry, "--access", "public"];
447
449
  result = await run("npm", retryArgs, pkg.path);
448
450
  }
449
451
  }
@@ -451,7 +453,7 @@ async function publishPackage(pkg, registry, context, dryRun) {
451
453
  if (isOtpError(result.output)) {
452
454
  return {
453
455
  success: false,
454
- error: `2FA OTP required. Use --otp flag or run interactively.`
456
+ error: `2FA required. Use --otp flag for TOTP, or run interactively for security key auth.`
455
457
  };
456
458
  }
457
459
  return { success: false, error: `Failed to publish ${pkg.name}` };
@@ -937,7 +939,7 @@ async function main() {
937
939
  console.log("");
938
940
  const publishContext = {
939
941
  otp: options.otp,
940
- onOtpRequired: options.ci ? undefined : promptForOtp
942
+ onAuthRequired: options.ci ? undefined : reauthenticate
941
943
  };
942
944
  for (const pkg of packages) {
943
945
  const result = await publishPackage(pkg, registry, publishContext, options.dryRun);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pubz",
3
- "version": "0.2.8",
3
+ "version": "0.2.9",
4
4
  "description": "Interactive CLI for publishing npm packages (single or monorepo)",
5
5
  "type": "module",
6
6
  "bin": {