diff options
author | 2024-03-20 23:59:37 +0100 | |
---|---|---|
committer | 2024-03-20 17:36:01 -0700 | |
commit | beb8c80787beadbfdb8b970368a3200f7d59f58e (patch) | |
tree | 1096a698ef89494cc58a5d81be15bc9ca56422d7 /internal/ui/static/js/webauthn_handler.js | |
parent | fc4bdf3ab0088c8110905148951a26412bdef3ec (diff) | |
download | v2-beb8c80787beadbfdb8b970368a3200f7d59f58e.tar.gz v2-beb8c80787beadbfdb8b970368a3200f7d59f58e.tar.zst v2-beb8c80787beadbfdb8b970368a3200f7d59f58e.zip |
Replace a bunch of `let` with `const`
According to https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/const
> Many style guides (including MDN's) recommend using const over let whenever a
variable is not reassigned in its scope. This makes the intent clear that a
variable's type (or value, in the case of a primitive) can never change.
Diffstat (limited to 'internal/ui/static/js/webauthn_handler.js')
-rw-r--r-- | internal/ui/static/js/webauthn_handler.js | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/internal/ui/static/js/webauthn_handler.js b/internal/ui/static/js/webauthn_handler.js index 0835ae0d..32752d54 100644 --- a/internal/ui/static/js/webauthn_handler.js +++ b/internal/ui/static/js/webauthn_handler.js @@ -5,7 +5,7 @@ class WebAuthnHandler { static showErrorMessage(errorMessage) { console.log("webauthn error: " + errorMessage); - let alertElement = document.getElementById("webauthn-error"); + const alertElement = document.getElementById("webauthn-error"); if (alertElement) { alertElement.textContent += " (" + errorMessage + ")"; alertElement.classList.remove("hidden"); @@ -79,14 +79,14 @@ class WebAuthnHandler { return; } - let credentialCreationOptions = await registerBeginResponse.json(); + const credentialCreationOptions = await registerBeginResponse.json(); credentialCreationOptions.publicKey.challenge = this.decodeBuffer(credentialCreationOptions.publicKey.challenge); credentialCreationOptions.publicKey.user.id = this.decodeBuffer(credentialCreationOptions.publicKey.user.id); if (Object.hasOwn(credentialCreationOptions.publicKey, 'excludeCredentials')) { credentialCreationOptions.publicKey.excludeCredentials.forEach((credential) => credential.id = this.decodeBuffer(credential.id)); } - let attestation = await navigator.credentials.create(credentialCreationOptions); + const attestation = await navigator.credentials.create(credentialCreationOptions); let registrationFinishResponse; try { @@ -108,7 +108,7 @@ class WebAuthnHandler { throw new Error("Login failed with HTTP status code " + response.status); } - let jsonData = await registrationFinishResponse.json(); + const jsonData = await registrationFinishResponse.json(); window.location.href = jsonData.redirect; } @@ -121,7 +121,7 @@ class WebAuthnHandler { return; } - let credentialRequestOptions = await loginBeginResponse.json(); + const credentialRequestOptions = await loginBeginResponse.json(); credentialRequestOptions.publicKey.challenge = this.decodeBuffer(credentialRequestOptions.publicKey.challenge); if (Object.hasOwn(credentialRequestOptions.publicKey, 'allowCredentials')) { |