Skip to content

Commit 4561bbf

Browse files
committed
fix: handle authFailure + default openUrls to false
1 parent 67ab8cc commit 4561bbf

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

app/components/Org/OperationsQueue.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,10 @@ async function handleRetryWithOtp() {
104104
otpError.value = ''
105105
otpInput.value = ''
106106
107-
// First, re-approve all OTP-failed operations
107+
// First, re-approve all OTP/auth-failed operations
108108
const otpFailedOps = activeOperations.value.filter(
109-
(op: PendingOperation) => op.status === 'failed' && op.result?.requiresOtp,
109+
(op: PendingOperation) =>
110+
op.status === 'failed' && (op.result?.requiresOtp || op.result?.authFailure),
110111
)
111112
for (const op of otpFailedOps) {
112113
await retryOperation(op.id)

app/composables/useConnector.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -377,20 +377,22 @@ export const useConnector = createSharedComposable(function useConnector() {
377377
const approvedOperations = computed(() =>
378378
state.value.operations.filter(op => op.status === 'approved'),
379379
)
380-
/** Operations that are done (completed, or failed without needing OTP retry) */
380+
/** Operations that are done (completed, or failed without needing OTP/auth retry) */
381381
const completedOperations = computed(() =>
382382
state.value.operations.filter(
383-
op => op.status === 'completed' || (op.status === 'failed' && !op.result?.requiresOtp),
383+
op =>
384+
op.status === 'completed' ||
385+
(op.status === 'failed' && !op.result?.requiresOtp && !op.result?.authFailure),
384386
),
385387
)
386-
/** Operations that are still active (pending, approved, running, or failed needing OTP retry) */
388+
/** Operations that are still active (pending, approved, running, or failed needing OTP/auth retry) */
387389
const activeOperations = computed(() =>
388390
state.value.operations.filter(
389391
op =>
390392
op.status === 'pending' ||
391393
op.status === 'approved' ||
392394
op.status === 'running' ||
393-
(op.status === 'failed' && op.result?.requiresOtp),
395+
(op.status === 'failed' && (op.result?.requiresOtp || op.result?.authFailure)),
394396
),
395397
)
396398
const hasOperations = computed(() => state.value.operations.length > 0)

cli/src/npm-client.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,15 +160,15 @@ export interface ExecNpmOptions {
160160
/**
161161
* PTY-based npm execution for interactive commands (uses node-pty).
162162
*
163-
* - Web OTP - either opend URL in browser if openUrls is true or passes the URL to frontend. If no auth happend within AUTH_URL_TIMEOUT_MS kills the process to unlock the connector.
163+
* - Web OTP - either open URL in browser if openUrls is true or passes the URL to frontend. If no auth happend within AUTH_URL_TIMEOUT_MS kills the process to unlock the connector.
164164
*
165-
* - Cli OTP - if we get a classic OTP prompt will either return OTP request to the frontend or will pass sent OTP if its provided
165+
* - CLI OTP - if we get a classic OTP prompt will either return OTP request to the frontend or will pass sent OTP if its provided
166166
*/
167167
async function execNpmInteractive(
168168
args: string[],
169169
options: ExecNpmOptions = {},
170170
): Promise<NpmExecResult> {
171-
const openUrls = options.openUrls !== false
171+
const openUrls = options.openUrls === true
172172

173173
// Lazy-load node-pty so the native addon is only required when interactive mode is actually used.
174174
const pty = await import('@lydell/node-pty')
@@ -187,6 +187,7 @@ async function execNpmInteractive(
187187
let resolved = false
188188
let otpPromptSeen = false
189189
let authUrlSeen = false
190+
let enterSent = false
190191
let authUrlTimeout: ReturnType<typeof setTimeout> | null = null
191192
let authUrlTimedOut = false
192193

@@ -242,7 +243,8 @@ async function execNpmInteractive(
242243
}
243244
}
244245

245-
if (authUrlSeen && openUrls && AUTH_URL_PROMPT_RE.test(cleanAll)) {
246+
if (authUrlSeen && openUrls && !enterSent && AUTH_URL_PROMPT_RE.test(cleanAll)) {
247+
enterSent = true
246248
logDebug('Web auth prompt detected, pressing ENTER')
247249
child.write('\r')
248250
}

0 commit comments

Comments
 (0)