QuantumNous/new-api · error · Error

Unsupported verification method: {{method}}

Error message

Unsupported verification method: {{method}}

What it means

Thrown by verify() when the method argument does not match the '2fa' or 'passkey' case in the switch. The function only supports those two verification methods, and any other string falls through to the default branch. This is a programming/caller error or a data problem (an unvalidated method value from state), not a runtime environment issue.

Source

Thrown at web/src/features/auth/secure-verification/api.ts:89

    }
  }
}

/**
 * Execute a verification flow based on the method type.
 */
export async function verify(
  method: VerificationMethod,
  scope: SecurityProofScope,
  code?: string
): Promise<SecurityProof> {
  switch (method) {
    case '2fa':
      return verifyTwoFA(scope, code)
    case 'passkey':
      return verifyPasskey(scope)
    default:
      throw new Error(
        i18next.t('Unsupported verification method: {{method}}', { method })
      )
  }
}

/**
 * Perform 2FA verification flow.
 */
async function verifyTwoFA(
  scope: SecurityProofScope,
  code?: string | null
): Promise<SecurityProof> {
  const trimmed = code?.trim()
  if (!trimmed) {
    throw new Error(
      i18next.t('Please enter the verification code or backup code')
    )
  }

View on GitHub (pinned to e2c7aa7b10)

Solutions

  1. Log or inspect the actual method value at the call site — it will be anything other than '2fa' or 'passkey'.
  2. If you extended verification methods, add the new case to the switch in verify().
  3. Validate method against the supported set before invoking verify() (see type guard below).
  4. Clear persisted auth-verification state after schema changes so stale method values disappear.

Example fix

// before
verify(method, scope, code) // method = 'email' → default branch throws

// after
const isVerificationMethod = (m: unknown): m is VerificationMethod =>
  m === '2fa' || m === 'passkey'
if (!isVerificationMethod(method)) {
  throw new Error(`Unsupported verification method: ${String(method)}`)
}
await verify(method, scope, code)
Defensive patterns

Strategy: type-guard

Validate before calling

const SUPPORTED_METHODS = ['2fa', 'passkey'] as const
if (!SUPPORTED_METHODS.includes(method)) {
  toast.error(`Unsupported verification method: ${method}`)
  return
}

Type guard

const isVerificationMethod = (
  m: unknown
): m is '2fa' | 'passkey' => m === '2fa' || m === 'passkey'

Prevention

When it happens

Trigger: Calling verify(method, scope) with a string outside the VerificationMethod union (e.g. 'email', 'sms', empty string, undefined coerced to 'undefined'); passing state.method from a store that was never validated against the supported set.

Common situations: A new verification method is added to the backend and to persisted state but not to this switch; state restored from localStorage contains a legacy method value; typo in the method literal at a call site.

Related errors


AI-assisted analysis of QuantumNous/new-api@e2c7aa7b10 (2026-08-15). Data as JSON: /api/errors/f4fc5f3bc7652683. Report an issue: GitHub.