Inicializar Firebase(CDN)

<script src="<https://www.gstatic.com/firebasejs/7.18.0/firebase-app.js>"></script>

<script src="<https://www.gstatic.com/firebasejs/7.18.0/firebase-auth.js>"></script>
var firebaseConfig = {
            apiKey:
            authDomain:
            databaseURL
            projectId:
            storageBucket: 
            messagingSenderId
            appId:
};
      
firebase.initializeApp(firebaseConfig);

Cargar el reCaptcha en el DOM (Se usa la opción de Invisible Captcha)

firebase.auth().languageCode = 'es';

window.recaptchaVerifier = new firebase.auth.RecaptchaVerifier('BUTTON_ID_ENVIAR_SMS', {
            'size': 'invisible',
            'callback': function (response) {
                // reCAPTCHA solved, allow signInWithPhoneNumber.
                onSignInSubmit();
            }
});

Enviar SMS

var telefonoUser = document.getElementById('phone-number').value;
var appVerifier = window.recaptchaVerifier;

firebase.auth().signInWithPhoneNumber(telefonoUser, appVerifier)
         .then(function (confirmationResult) {
                alert('SMS enviado')
                // SMS sent. Prompt user to type the code from the message, then sign the
                // user in with confirmationResult.confirm(code).
                window.confirmationResult = confirmationResult;
          }).catch(function (error) {

                alert('Error enviar SMS')
                console.log(error)
			          
								// Reload Captcha         
                grecaptcha.reset(window.recaptchaWidgetId);
          });

});

Validar código SMS enviado al usuario

var codigo = document.getElementById('code-auth').value;

confirmationResult.confirm(codigo).then(function (result) {
        alert('El usuario ha iniciado sesion correctamente')
        // User signed in successfully.
        var user = result.user;
        console.log(user);
        window.firebaseUser = user;
 
	   }).catch(function (error) {
         console.log(error);
         alert('El usuario no se pudo registrar')
     });

Documentación Extra Firebase

https://firebase.google.com/docs/auth/admin?hl=es-419

https://firebase.google.com/docs/auth/admin/manage-sessions

https://firebase.google.com/docs/auth/admin/verify-id-tokens?hl=es-419#web