mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2025-09-14 12:35:57 +03:00
Remove md5.js
dependency
Switch to the built-in WebCrypto APIs for computing identicon hashes.
This commit is contained in:
@@ -20,7 +20,6 @@
|
||||
width: auto;
|
||||
}
|
||||
</style>
|
||||
<script src="{{urlpath}}/bwrs_static/md5.js"></script>
|
||||
<script src="{{urlpath}}/bwrs_static/identicon.js"></script>
|
||||
<script>
|
||||
function reload() { window.location.reload(); }
|
||||
@@ -28,8 +27,17 @@
|
||||
text && alert(text);
|
||||
reload_page && reload();
|
||||
}
|
||||
function identicon(email) {
|
||||
const data = new Identicon(md5(email), { size: 48, format: 'svg' });
|
||||
async function sha256(message) {
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest
|
||||
const msgUint8 = new TextEncoder().encode(message);
|
||||
const hashBuffer = await crypto.subtle.digest('SHA-256', msgUint8);
|
||||
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
||||
const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
|
||||
return hashHex;
|
||||
}
|
||||
async function identicon(email) {
|
||||
const hash = await sha256(email);
|
||||
const data = new Identicon(hash, { size: 48, format: 'svg' });
|
||||
return "data:image/svg+xml;base64," + data.toString();
|
||||
}
|
||||
function toggleVis(input_id) {
|
||||
@@ -125,4 +133,4 @@
|
||||
<!-- This script needs to be at the bottom, else it will fail! -->
|
||||
<script src="{{urlpath}}/bwrs_static/bootstrap-native.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
@@ -73,9 +73,11 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
document.querySelectorAll("img.identicon").forEach(function (e, i) {
|
||||
e.src = identicon(e.dataset.src);
|
||||
});
|
||||
(async () => {
|
||||
for (let e of document.querySelectorAll("img.identicon")) {
|
||||
e.src = await identicon(e.dataset.src);
|
||||
}
|
||||
})();
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function(event) {
|
||||
$('#orgs-table').DataTable({
|
||||
@@ -87,4 +89,4 @@
|
||||
]
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</script>
|
||||
|
@@ -206,9 +206,11 @@
|
||||
"3": { "name": "Manager", "color": "green" },
|
||||
};
|
||||
|
||||
document.querySelectorAll("img.identicon").forEach(function (e, i) {
|
||||
e.src = identicon(e.dataset.src);
|
||||
});
|
||||
(async () => {
|
||||
for (let e of document.querySelectorAll("img.identicon")) {
|
||||
e.src = await identicon(e.dataset.src);
|
||||
}
|
||||
})();
|
||||
|
||||
document.querySelectorAll("[data-orgtype]").forEach(function (e, i) {
|
||||
let orgtype = OrgTypes[e.dataset.orgtype];
|
||||
@@ -288,4 +290,4 @@
|
||||
"Error updating organization type of the user", data);
|
||||
return false;
|
||||
}
|
||||
</script>
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user