Skip to content

Instantly share code, notes, and snippets.

@chuckwagoncomputing
Created January 25, 2025 04:37
Show Gist options
  • Save chuckwagoncomputing/b945c079e18c59b1fe101a18af204333 to your computer and use it in GitHub Desktop.
Save chuckwagoncomputing/b945c079e18c59b1fe101a18af204333 to your computer and use it in GitHub Desktop.
Dumb JS function for importing OTP token URIs to Bangle.js
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