remove jquery dependency, use vanilla js

This commit is contained in:
Constantin Wildförster 2022-11-18 11:54:04 +01:00
parent 2c5c3f0c7c
commit 60f8cbc89a
No known key found for this signature in database
GPG key ID: 5DDDBFF28CC85AFB

View file

@ -18,7 +18,6 @@
</div> </div>
</form> </form>
<script type="text/javascript" src="${url.resourcesCommonPath}/node_modules/jquery/dist/jquery.min.js"></script>
<script type="text/javascript" src="${url.resourcesPath}/js/base64url.js"></script> <script type="text/javascript" src="${url.resourcesPath}/js/base64url.js"></script>
<script type="text/javascript"> <script type="text/javascript">
@ -26,8 +25,8 @@
// Check if WebAuthn is supported by this browser // Check if WebAuthn is supported by this browser
if (!window.PublicKeyCredential) { if (!window.PublicKeyCredential) {
jQuery("#error").val("${msg("webauthn-unsupported-browser-text")?no_esc}"); document.querySelector("#error").value = "${msg("webauthn-unsupported-browser-text")?no_esc}";
jQuery("#register").submit(); document.querySelector("#register").submit();
return; return;
} }
@ -100,14 +99,14 @@
let attestationObject = result.response.attestationObject; let attestationObject = result.response.attestationObject;
let publicKeyCredentialId = result.rawId; let publicKeyCredentialId = result.rawId;
jQuery("#clientDataJSON").val(base64url.encode(new Uint8Array(clientDataJSON), {pad: false})); document.querySelector("#clientDataJSON").value = base64url.encode(new Uint8Array(clientDataJSON), {pad: false});
jQuery("#attestationObject").val(base64url.encode(new Uint8Array(attestationObject), {pad: false})); document.querySelector("#attestationObject").value = base64url.encode(new Uint8Array(attestationObject), {pad: false});
jQuery("#publicKeyCredentialId").val(base64url.encode(new Uint8Array(publicKeyCredentialId), {pad: false})); document.querySelector("#publicKeyCredentialId").value = base64url.encode(new Uint8Array(publicKeyCredentialId), {pad: false});
if (typeof result.response.getTransports === "function") { if (typeof result.response.getTransports === "function") {
let transports = result.response.getTransports(); let transports = result.response.getTransports();
if (transports) { if (transports) {
jQuery("#transports").val(getTransportsAsString(transports)); document.querySelector("#transports").value = getTransportsAsString(transports);
} }
} else { } else {
console.log("Your browser is not able to recognize supported transport media for the authenticator."); console.log("Your browser is not able to recognize supported transport media for the authenticator.");
@ -116,14 +115,14 @@
let initLabel = "WebAuthn Authenticator (Default Label)"; let initLabel = "WebAuthn Authenticator (Default Label)";
let labelResult = window.prompt("Please input your registered authenticator's label", initLabel); let labelResult = window.prompt("Please input your registered authenticator's label", initLabel);
if (labelResult === null) labelResult = initLabel; if (labelResult === null) labelResult = initLabel;
jQuery("#authenticatorLabel").val(labelResult); document.querySelector("#authenticatorLabel").value = labelResult;
jQuery("#register").submit(); document.querySelector("#register").submit();
}) })
.catch(function (err) { .catch(function (err) {
jQuery("#error").val(err); document.querySelector("#error").value = err;
jQuery("#register").submit(); document.querySelector("#register").submit();
}); });
} }