1 import { AUTH_FALLBACK_VERSION } from './constants';
2 import type { AuthVersion } from './interface';
3 import { cleanUsername } from './utils/username';
6 * Get the next auth version to use and if it's the last attempt.
9 { Version }: { Version: AuthVersion },
11 lastAuthVersion?: AuthVersion
12 ): { version: AuthVersion; done: boolean } => {
20 if (typeof lastAuthVersion === 'undefined') {
22 version: AUTH_FALLBACK_VERSION,
27 if (lastAuthVersion === 2 && cleanUsername(username) !== username.toLowerCase()) {
34 if (lastAuthVersion === 1 || lastAuthVersion === 2) {
41 throw new Error('Can not provide any other auth version');