async handleInitValidationError()

in src/auth/auth-core.ts [473:500]


  async handleInitValidationError(error: Error | TokenValidationError): Promise<undefined> {
    if ('cause' in error && error.cause instanceof Error && error.cause?.message === 'invalid_client') {
      // eslint-disable-next-line no-console
      console.error('RingUI Auth: invalid client detected. Logging out', error);
      await this.logout();
      return undefined;
    }
    // Redirect flow
    if ('authRedirect' in error && error.authRedirect && this.config.redirect) {
      return this.sendRedirect(error);
    }

    // Background flow
    if ('authRedirect' in error && error.authRedirect && !this.config.redirect) {
      try {
        await this._backgroundFlow?.authorize();
        await this._tokenValidator?.validateToken();
        this._initDeferred?.resolve?.();
        return undefined;
      } catch (validationError) {
        // Fallback to redirect flow
        return validationError instanceof Error ? this.sendRedirect(validationError) : undefined;
      }
    }

    this._initDeferred?.reject?.(error);
    throw error;
  }