@pnpm/network.web-auth 1101.0.0 → 1101.1.0

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/lib/index.d.ts CHANGED
@@ -2,4 +2,4 @@ export { generateQrCode } from './generateQrCode.js';
2
2
  export { pollForWebAuthToken, type PollForWebAuthTokenParams, type WebAuthContext, type WebAuthFetchOptions, type WebAuthFetchResponse, type WebAuthFetchResponseHeaders, } from './pollForWebAuthToken.js';
3
3
  export { promptBrowserOpen, type PromptBrowserOpenContext, type PromptBrowserOpenParams, type PromptBrowserOpenReadlineInterface, } from './promptBrowserOpen.js';
4
4
  export { WebAuthTimeoutError } from './WebAuthTimeoutError.js';
5
- export { isOtpError, type OtpContext, type OtpEnquirer, type OtpHandlingParams, OtpNonInteractiveError, type OtpProcess, type OtpPromptOptions, type OtpPromptResponse, OtpSecondChallengeError, SyntheticOtpError, withOtpHandling, } from './withOtpHandling.js';
5
+ export { isOtpError, type OtpContext, type OtpEnquirer, type OtpHandlingParams, OtpNonInteractiveError, type OtpProcess, OtpSecondChallengeError, SyntheticOtpError, withOtpHandling, } from './withOtpHandling.js';
@@ -2,15 +2,9 @@ import { PnpmError } from '@pnpm/error';
2
2
  import type { WebAuthFetchOptions, WebAuthFetchResponse } from './pollForWebAuthToken.js';
3
3
  import type { PromptBrowserOpenReadlineInterface } from './promptBrowserOpen.js';
4
4
  export interface OtpEnquirer {
5
- prompt: (options: OtpPromptOptions) => Promise<OtpPromptResponse | undefined>;
6
- }
7
- export interface OtpPromptOptions {
8
- message: string;
9
- name: 'otp';
10
- type: 'input';
11
- }
12
- export interface OtpPromptResponse {
13
- otp?: string;
5
+ input: (options: {
6
+ message: string;
7
+ }) => Promise<string | undefined>;
14
8
  }
15
9
  interface OtpDate {
16
10
  now: () => number;
@@ -48,13 +48,19 @@ export async function withOtpHandling({ context, fetchOptions, operation, }) {
48
48
  });
49
49
  }
50
50
  else {
51
- const enquirerResponse = await enquirer.prompt({
52
- message: 'This operation requires a one-time password.\nEnter OTP:',
53
- name: 'otp',
54
- type: 'input',
55
- });
56
- // Use || (not ??) so that empty-string input is treated as "no OTP provided"
57
- otp = enquirerResponse?.otp || undefined;
51
+ let otpValue;
52
+ try {
53
+ otpValue = await enquirer.input({
54
+ message: 'This operation requires a one-time password.\nEnter OTP:',
55
+ });
56
+ }
57
+ catch (err) {
58
+ if (err instanceof Error && err.name === 'ExitPromptError') {
59
+ throw error;
60
+ }
61
+ throw err;
62
+ }
63
+ otp = otpValue || undefined;
58
64
  }
59
65
  if (otp != null) {
60
66
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pnpm/network.web-auth",
3
- "version": "1101.0.0",
3
+ "version": "1101.1.0",
4
4
  "description": "Web-based authentication flow with QR code display and token polling",
5
5
  "keywords": [
6
6
  "pnpm",
@@ -32,7 +32,7 @@
32
32
  "devDependencies": {
33
33
  "@jest/globals": "30.3.0",
34
34
  "@types/qrcode-terminal": "^0.12.2",
35
- "@pnpm/network.web-auth": "1101.0.0"
35
+ "@pnpm/network.web-auth": "1101.1.0"
36
36
  },
37
37
  "engines": {
38
38
  "node": ">=22.13"