Browse Source

Add get-password-by-id for programmatic access

Sam Hedin 1 năm trước cách đây
mục cha
commit
9e649ef046
1 tập tin đã thay đổi với 11 bổ sung0 xóa
  1. 11 0
      bitwarden.el

+ 11 - 0
bitwarden.el

@@ -368,6 +368,17 @@ Returns a vector of hashtables of the results."
              (json (json-read-from-string result)))
            json))))
 
+;;;###autoload
+(defun bitwarden-get-info-by-id (id)
+  "The id can be found using the bitwarden CLI. For example: bw list items --pretty.
+To access the account password: `(gethash \"password\" (gethash \"login\" ))'"
+  (let* ((result (bitwarden--handle-message (bitwarden--auto-cmd (list "get" "item" id)))))
+        (when result
+      (let* ((json-object-type 'hash-table)
+             (json-key-type 'string)
+             (json (json-read-from-string result)))
+         (json-read-from-string result)))))
+
 (defun bitwarden-folders ()
   "List bitwarden folders."
   (let* ((ret (bitwarden--auto-cmd (list "list" "folders")))