emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/base32 34d9df6232 006/103: Split out the standard label ge


From: ELPA Syncer
Subject: [nongnu] elpa/base32 34d9df6232 006/103: Split out the standard label generation code
Date: Sat, 10 Feb 2024 12:59:50 -0500 (EST)

branch: elpa/base32
commit 34d9df6232e3f048fbcaf3ffa8a6c72a434f3bef
Author: Vivek Das Mohapatra <vivek@collabora.co.uk>
Commit: Vivek Das Mohapatra <vivek@collabora.co.uk>

    Split out the standard label generation code
    
    Allow the standard label generator to be used separately
    from the otpauth wrapper generator.
---
 totp.el | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/totp.el b/totp.el
index 5831797b6a..9015606b6c 100644
--- a/totp.el
+++ b/totp.el
@@ -231,18 +231,21 @@ same, ie probably intended for the same target."
           (setq target vault)))
     (or target default)))
 
+(defun totp-secret-make-label (secret)
+  "Take a `totp-unwrap-otp-blob' structure SECRET and generate a label
+from it (based on its user and service fields)."
+  (let (user srv-host)
+    (setq user     (cdr (assq :user secret))
+          srv-host (cdr (or (assq :service secret)
+                            (assq :host    secret))))
+    (if (and user srv-host)
+        (concat user "@" srv-host)
+      (or user srv-host "nobody@unknown"))))
+
 (defun totp-secret-make-label-and-wrapper (secret &optional label)
-  (let (wrapped)
+  (let ((wrapped (totp-wrap-otpauth-url secret)))
     (if (not label)
-        (let (user srv-host)
-          (setq user     (cdr (assq :user secret))
-                srv-host (cdr (or (assq :service secret)
-                                  (assq :host    secret))))
-          (setq label
-                (if (and user srv-host)
-                    (concat user "@" srv-host)
-                  (or user srv-host "nobody@unknown"))) ))
-    (setq wrapped (totp-wrap-otpauth-url secret))
+        (setq label (totp-secret-make-label secret)))
     (cons label wrapped)))
 
 (defun totp-save-secret-to-secrets-source (source secret &optional label)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]