Created
January 25, 2025 04:37
-
-
Save chuckwagoncomputing/b945c079e18c59b1fe101a18af204333 to your computer and use it in GitHub Desktop.
Dumb JS function for importing OTP token URIs to Bangle.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function importToken(uri) { | |
var url = unescape(uri) | |
var groups = url.match(/totp\/([^:]+):?(.*)\?secret=([a-zA-Z0-9]+)&algorithm=([A-Z0-9]+)&digits=([0-9]+)&period=([0-9]+)/); | |
document.querySelector("[name='label']").value = groups[1]; | |
document.querySelector("[name='secret']").value = groups[3]; | |
document.querySelector("[name='account']").value = groups[2]; | |
document.querySelector("[name='issuer']").value = groups[1]; | |
document.querySelector("[name='period']").value = groups[6]; | |
document.querySelector("[name='digits']").value = groups[5]; | |
document.querySelector("[name='algorithm']").value = groups[4]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment