~martijnbraam/public-inbox

add contrib/andotp.py: import from andotp v1 APPLIED

Drew DeVault: 1
 add contrib/andotp.py: import from andotp

 1 files changed, 16 insertions(+), 0 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~martijnbraam/public-inbox/patches/27024/mbox | git am -3
Learn more about email & git

[PATCH] add contrib/andotp.py: import from andotp Export this patch

This script converts the andOTP JSON dump into a list of otpauth://
URLs.
---
 contrib/andotp.py | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
 create mode 100755 contrib/andotp.py

diff --git a/contrib/andotp.py b/contrib/andotp.py
new file mode 100755
index 0000000..a98e004
--- /dev/null
+++ b/contrib/andotp.py
@@ -0,0 +1,16 @@
#!/usr/bin/env python3
from urllib.parse import quote
import json
import sys

items = json.load(sys.stdin)
for item in items:
    if item["type"] != "TOTP":
        sys.stderr.write(f"Unknown code type {item['type']}\n")
    label = quote(item["label"])
    secret = item["secret"]
    url = f"otpauth://totp/{label}?secret={secret}"
    if item["issuer"]:
        issuer = quote(item["issuer"])
        url += f"&issuer={issuer}"
    print(url)
-- 
2.34.1
Thanks, applied to master

On 12/1/21 14:56, Drew DeVault wrote: