bitwarden.el 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612
  1. ;;; bitwarden.el --- Bitwarden command wrapper -*- lexical-binding: t -*-
  2. ;; Copyright (C) 2018 Sean Farley
  3. ;; Author: Sean Farley
  4. ;; URL: https://github.com/seanfarley/emacs-bitwarden
  5. ;; Version: 0.1.3
  6. ;; Created: 2018-09-04
  7. ;; Package-Requires: ((emacs "24.4"))
  8. ;; Keywords: extensions processes bw bitwarden
  9. ;;; License
  10. ;; This program is free software: you can redistribute it and/or modify
  11. ;; it under the terms of the GNU General Public License as published by
  12. ;; the Free Software Foundation, either version 3 of the License, or
  13. ;; (at your option) any later version.
  14. ;; This program is distributed in the hope that it will be useful,
  15. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. ;; GNU General Public License for more details.
  18. ;; You should have received a copy of the GNU General Public License
  19. ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. ;;; Commentary:
  21. ;; This package wraps the bitwarden command-line program.
  22. ;;; Code:
  23. (require 'auth-source)
  24. (require 'json)
  25. (require 'seq)
  26. (require 'subr-x)
  27. (require 'tree-widget)
  28. ;=============================== custom variables ==============================
  29. (defgroup bitwarden nil
  30. "Bitwarden functions and settings."
  31. :group 'external
  32. :tag "bitwarden"
  33. :prefix "bitwarden-")
  34. (defcustom bitwarden-bw-executable (executable-find "bw")
  35. "The bw cli executable used by Bitwarden."
  36. :group 'bitwarden
  37. :type 'string)
  38. (defcustom bitwarden-data-file
  39. (expand-file-name (cond
  40. ((eq system-type 'darwin)
  41. "~/Library/Application Support/Bitwarden CLI/data.json")
  42. ((eq system-type 'windows-nt)
  43. "~/AppData/Bitwarden CLI/data.json")
  44. (t
  45. "~/.config/Bitwarden CLI/data.json")))
  46. "The bw data file used by Bitwarden."
  47. :group 'bitwarden
  48. :type 'string)
  49. (defcustom bitwarden-user nil
  50. "Bitwarden user e-mail."
  51. :group 'bitwarden
  52. :type 'string)
  53. (defcustom bitwarden-automatic-unlock nil
  54. "Optional function to be called to attempt to unlock the vault.
  55. Set this to a lamdba that will evaluate to a password. For
  56. example, this can be the :secret plist from
  57. `auth-source-search'."
  58. :group 'bitwarden
  59. :type 'function)
  60. (defconst bitwarden--err-logged-in "you are not logged in")
  61. (defconst bitwarden--err-multiple "more than one result found")
  62. (defconst bitwarden--err-locked "vault is locked")
  63. ;===================================== util ====================================
  64. (defun bitwarden-logged-in-p ()
  65. "Check if `bitwarden-user' is logged in.
  66. Returns nil if not logged in."
  67. (let* ((json-object-type 'hash-table)
  68. (json-key-type 'string)
  69. (json (json-read-file bitwarden-data-file)))
  70. (gethash "__PROTECTED__key" json)))
  71. (defun bitwarden-unlocked-p ()
  72. "Check if we have already set the 'BW_SESSION' environment variable."
  73. (and (bitwarden-logged-in-p) (getenv "BW_SESSION")))
  74. (defun bitwarden--raw-runcmd (cmd &rest args)
  75. "Run bw command CMD with ARGS.
  76. Returns a list with the first element being the exit code and the
  77. second element being the output."
  78. (with-temp-buffer
  79. (list (apply 'call-process
  80. bitwarden-bw-executable
  81. nil (current-buffer) nil
  82. (cons cmd args))
  83. (replace-regexp-in-string "\n$" ""
  84. (buffer-string)))))
  85. (defun bitwarden-runcmd (cmd &rest args)
  86. "Run bw command CMD with ARGS.
  87. This is a wrapper for `bitwarden--raw-runcmd' that also checks
  88. for common errors."
  89. (if (bitwarden-logged-in-p)
  90. (if (bitwarden-unlocked-p)
  91. (let* ((ret (apply #'bitwarden--raw-runcmd cmd args))
  92. (exit-code (nth 0 ret))
  93. (output (nth 1 ret)))
  94. (if (eq exit-code 0)
  95. output
  96. (cond ((string-match "^More than one result was found." output)
  97. bitwarden--err-multiple)
  98. (t nil))))
  99. bitwarden--err-locked)
  100. bitwarden--err-logged-in))
  101. (defun bitwarden--login-proc-filter (proc string print-message)
  102. "Interacts with PROC by sending line-by-line STRING.
  103. If PRINT-MESSAGE is set then messages are printed to minibuffer."
  104. ;; read username if not defined
  105. (when (string-match "^? Email address:" string)
  106. (let ((user (read-string "Bitwarden email: ")))
  107. ;; if we are here then the user forgot to fill in this field so let's do
  108. ;; that now
  109. (setq bitwarden-user user)
  110. (process-send-string proc (concat bitwarden-user "\n"))))
  111. ;; read master password
  112. (when (string-match "^? Master password:" string)
  113. (process-send-string
  114. proc (concat (read-passwd "Bitwarden master password: ") "\n")))
  115. ;; check for bad password
  116. (when (string-match "^Username or password is incorrect" string)
  117. (bitwarden--message "incorrect master password" nil print-message))
  118. ;; if trying to unlock, check if logged in
  119. (when (string-match "^You are not logged in" string)
  120. (bitwarden--message "cannot unlock: not logged in" nil print-message))
  121. ;; read the 2fa code
  122. (when (string-match "^? Two-step login code:" string)
  123. (process-send-string
  124. proc (concat (read-passwd "Bitwarden two-step login code: ") "\n")))
  125. ;; check for bad code
  126. (when (string-match "^Login failed" string)
  127. (bitwarden--message "incorrect two-step code" nil print-message))
  128. ;; check for already logged in
  129. (when (string-match "^You are already logged in" string)
  130. (string-match "You are already logged in as \\(.*\\)\\." string)
  131. (bitwarden--message
  132. "already logged in as %s" (match-string 1 string) print-message))
  133. ;; success! now save the BW_SESSION into the environment so spawned processes
  134. ;; inherit it
  135. (when (string-match "^\\(You are logged in\\|Your vault is now unlocked\\)"
  136. string)
  137. ;; set the session env variable so spawned processes inherit
  138. (string-match "export BW_SESSION=\"\\(.*\\)\"" string)
  139. (setenv "BW_SESSION" (match-string 1 string))
  140. (bitwarden--message
  141. "successfully logged in as %s" bitwarden-user print-message)))
  142. (defun bitwarden--raw-unlock (cmd print-message)
  143. "Raw CMD to either unlock a vault or login.
  144. The only difference between unlock and login is just the name of
  145. the command and whether to pass the user.
  146. If PRINT-MESSAGE is set then messages are printed to minibuffer."
  147. (when (get-process "bitwarden")
  148. (delete-process "bitwarden"))
  149. (make-process :name "bitwarden"
  150. :buffer nil
  151. :connection-type 'pipe
  152. :command (append (list bitwarden-bw-executable)
  153. cmd)
  154. :filter (lambda (proc string)
  155. (bitwarden--login-proc-filter
  156. proc string print-message)))
  157. ;; suppress output to the minibuffer when running this programatically
  158. nil)
  159. ;================================= interactive =================================
  160. (defun bitwarden-unlock (&optional print-message)
  161. "Unlock bitwarden vault.
  162. It is not sufficient to check the env variable for BW_SESSION
  163. since that could be set yet could be expired or incorrect.
  164. If run interactively PRINT-MESSAGE gets set and messages are
  165. printed to minibuffer."
  166. (interactive "p")
  167. (let ((pass (if bitwarden-automatic-unlock
  168. (funcall bitwarden-automatic-unlock)
  169. "")))
  170. (bitwarden--raw-unlock (list "unlock" pass) print-message)))
  171. ;;;###autoload
  172. (defun bitwarden-login (&optional print-message)
  173. "Prompts user for password if not logged in.
  174. If run interactively PRINT-MESSAGE gets set and messages are
  175. printed to minibuffer."
  176. (interactive "p")
  177. (unless bitwarden-user
  178. (setq bitwarden-user (read-string "Bitwarden email: ")))
  179. (let ((pass (when bitwarden-automatic-unlock
  180. (funcall bitwarden-automatic-unlock))))
  181. (bitwarden--raw-unlock (list "login" bitwarden-user pass) print-message)))
  182. (defun bitwarden-lock ()
  183. "Lock the bw vault. Does not ask for confirmation."
  184. (interactive)
  185. (when (bitwarden-unlocked-p)
  186. (setenv "BW_SESSION" nil)))
  187. (defun bitwarden-logout ()
  188. "Log out bw. Does not ask for confirmation."
  189. (interactive)
  190. (when (bitwarden-logged-in-p)
  191. (bitwarden-runcmd "logout")
  192. (bitwarden-lock)))
  193. (defun bitwarden--message (msg args &optional print-message)
  194. "Print MSG using `message' and `format' with ARGS if non-nil.
  195. PRINT-MESSAGE is an optional parameter to control whether this
  196. method should print at all. If nil then nothing will be printed
  197. at all.
  198. This method will prepend 'Bitwarden: ' before each MSG as a
  199. convenience. Also, return a value of nil so that no strings
  200. are mistaken as a password (e.g. accidentally interpreting
  201. 'Bitwarden: error' as the password when in fact, it was an error
  202. message but happens to be last on the method stack)."
  203. (when print-message
  204. (let ((msg (if args (format msg args) msg)))
  205. (message (concat "Bitwarden: " msg))))
  206. nil)
  207. (defun bitwarden--handle-message (msg &optional print-message)
  208. "Handle return MSG of `bitwarden--auto-cmd'.
  209. Since `bitwarden--auto-cmd' returns a list of (err-code message),
  210. this function exists to handle that. Printing the error message
  211. is entirely dependent on PRINT-MESSAGE (see below for more info
  212. on PRINT-MESSAGE).
  213. If the error code is 0, then print the password based on
  214. PRINT-MESSAGE or just return it.
  215. If the error code is non-zero, then print the message based on
  216. PRINT-MESSAGE and return nil.
  217. PRINT-MESSAGE is an optional parameter to control whether this
  218. method should print at all. If nil then nothing will be printed
  219. at all but password will be returned (e.g. when run
  220. non-interactively)."
  221. (let* ((err (nth 0 msg))
  222. (pass (nth 1 msg)))
  223. (cond
  224. ((eq err 0)
  225. (if print-message
  226. (message "%s" pass)
  227. pass))
  228. (t
  229. (bitwarden--message "%s" pass print-message)
  230. nil))))
  231. (defun bitwarden--auto-cmd (cmd &optional recursive-pass)
  232. "Run Bitwarden CMD and attempt to auto unlock.
  233. If RECURSIVE-PASS is set, then treat this call as a second
  234. attempt after trying to auto-unlock.
  235. Returns a tuple of the error code and the error message or
  236. password if successful."
  237. (let* ((res (or recursive-pass (apply 'bitwarden-runcmd cmd))))
  238. (cond
  239. ((string-match bitwarden--err-locked res)
  240. ;; try to unlock automatically, if possible
  241. (if (not bitwarden-automatic-unlock)
  242. (list 1 (format "error: %s" res))
  243. ;; only attempt a retry once; to prevent infinite recursion
  244. (when (not recursive-pass)
  245. ;; because I don't understand how emacs is asyncronous here nor
  246. ;; how to tell it to wait until the process is done, we do so here
  247. ;; manually
  248. (bitwarden-unlock)
  249. (while (get-process "bitwarden")
  250. (sleep-for 0.1))
  251. (bitwarden--auto-cmd cmd (apply 'bitwarden-runcmd cmd)))))
  252. ((or (string-match bitwarden--err-logged-in res)
  253. (string-match bitwarden--err-multiple res))
  254. (list 2 (format "error: %s" res)))
  255. (t (list 0 res)))))
  256. ;;;###autoload
  257. (defun bitwarden-getpass (account &optional print-message)
  258. "Get password associated with ACCOUNT.
  259. If run interactively PRINT-MESSAGE gets set and password is
  260. printed to minibuffer."
  261. (interactive "MBitwarden account name: \np")
  262. (bitwarden--handle-message
  263. (bitwarden--auto-cmd (list "get" "password" account))
  264. print-message))
  265. ;;;###autoload
  266. (defun bitwarden-search (&optional search-str)
  267. "Search for vault for items containing SEARCH-STR.
  268. Returns a vector of hashtables of the results."
  269. (let* ((args (and search-str (list "--search" search-str)))
  270. (ret (bitwarden--auto-cmd (append (list "list" "items") args)))
  271. (result (bitwarden--handle-message ret)))
  272. (when result
  273. (let* ((json-object-type 'hash-table)
  274. (json-key-type 'string)
  275. (json (json-read-from-string result)))
  276. json))))
  277. (defun bitwarden-search-filter-username (accounts &optional username)
  278. "Filter results of `bitwarden-search' ACCOUNTS by USERNAME.
  279. ACCOUNTS can be the results of `bitwarden-search' or a string to
  280. search which will call `bitwarden-search' as a convenience."
  281. (let* ((accounts (if (vectorp accounts)
  282. accounts (bitwarden-search accounts)))
  283. ;; filter out matches that are not logins
  284. (accounts (seq-filter (lambda (elt) (gethash "login" elt)) accounts)))
  285. (if (and (stringp username) (not (string= username "")))
  286. (seq-filter (lambda (elt)
  287. (when-let* ((login (gethash "login" elt)))
  288. (string= (gethash "username" login) username)))
  289. accounts)
  290. accounts)))
  291. (defun bitwarden-folders ()
  292. "List bitwarden folders."
  293. (let* ((ret (bitwarden--auto-cmd (list "list" "folders")))
  294. (result (bitwarden--handle-message ret)))
  295. (when result
  296. (let* ((json-object-type 'hash-table)
  297. (json-key-type 'string)
  298. (json (json-read-from-string result)))
  299. json))))
  300. (defun bitwarden-sync ()
  301. "Sync local store with server."
  302. (interactive)
  303. (let ((res (bitwarden--auto-cmd (list "sync"))))
  304. (message (nth 1 res))))
  305. ;================================= auth-source =================================
  306. (defun bitwarden-auth-source-search (&rest spec)
  307. "Search Bitwarden according to SPEC.
  308. See `auth-source-search' for a description of the plist SPEC."
  309. (let* ((host (plist-get spec :host))
  310. (max (plist-get spec :max))
  311. (user (plist-get spec :user))
  312. (res (mapcar #'bitwarden-auth-source--build-result
  313. (bitwarden-search-filter-username host user))))
  314. (seq-take res max)))
  315. (defun bitwarden-auth-source--build-result (elt)
  316. "Build a auth-source result for ELT.
  317. This is meant to be used by `mapcar' for the results from
  318. `bitwarden-search-filter-username'."
  319. (let* ((host (gethash "name" elt))
  320. (login (gethash "login" elt)) ;; always present since
  321. ;; `bitwarden-search-filter-username'
  322. ;; tests for it
  323. (user (gethash "username" login))
  324. (pass (gethash "password" login)))
  325. `(:host ,host
  326. :user ,user
  327. :secret (lambda () ,pass))))
  328. (defvar bitwarden-auth-source-backend
  329. (auth-source-backend :type 'bitwarden
  330. :source "." ;; not used
  331. :search-function #'bitwarden-auth-source-search)
  332. "Auth-source backend variable for Bitwarden.")
  333. (defun bitwarden-auth-source-backend-parse (entry)
  334. "Create auth-source backend from ENTRY."
  335. (when (eq entry 'bitwarden)
  336. (auth-source-backend-parse-parameters entry bitwarden-auth-source-backend)))
  337. ;; advice to add custom auth-source function
  338. (if (boundp 'auth-source-backend-parser-functions)
  339. (add-hook 'auth-source-backend-parser-functions
  340. #'bitwarden-auth-source-backend-parse)
  341. (advice-add 'auth-source-backend-parse
  342. :before-until #'bitwarden-auth-source-backend-parse))
  343. ;;;###autoload
  344. (defun bitwarden-auth-source-enable ()
  345. "Enable Bitwarden auth-source by adding it to `auth-sources'."
  346. (interactive)
  347. (add-to-list 'auth-sources 'bitwarden)
  348. (auth-source-forget-all-cached)
  349. (message "Bitwarden: auth-source enabled"))
  350. ;================================= widget utils ================================
  351. (defun bitwarden-list-next ()
  352. "Move to the next item."
  353. (interactive)
  354. (forward-line)
  355. (beginning-of-line)
  356. (widget-forward 1))
  357. (defun bitwarden-list-prev ()
  358. "Move to the previous item."
  359. (interactive)
  360. (widget-backward 2)
  361. (beginning-of-line)
  362. (widget-forward 1))
  363. ;; bitwarden-list-dialog-mode
  364. (defvar bitwarden-list-dialog-mode-map
  365. (let ((map (make-sparse-keymap)))
  366. (set-keymap-parent map widget-keymap)
  367. (define-key map "n" 'bitwarden-list-next)
  368. (define-key map "p" 'bitwarden-list-prev)
  369. (define-key map "q" 'bitwarden-list-cancel-dialog)
  370. map)
  371. "Keymap used in recentf dialogs.")
  372. (define-derived-mode bitwarden-list-dialog-mode nil "bitwarden-list-dialog"
  373. "Major mode of recentf dialogs.
  374. \\{bitwarden-list-dialog-mode-map}"
  375. :syntax-table nil
  376. :abbrev-table nil
  377. (setq truncate-lines t))
  378. (defsubst bitwarden-list-all-get-item-at-pos ()
  379. "Get hashtable from widget at current pos in dialog widget."
  380. (let ((widget (get-char-property (point) 'button)))
  381. (widget-value widget)))
  382. (defsubst bitwarden-list-all-make-spaces (spaces)
  383. "Create a string with SPACES number of whitespaces."
  384. (mapconcat 'identity (make-list spaces " ") ""))
  385. (defsubst bitwarden-pad-to-width (item width)
  386. "Create a string with ITEM padded to WIDTH."
  387. (if (= (length item) width)
  388. item
  389. (if (>= (length item) width)
  390. (concat (substring item 0 (- width 1)) "…")
  391. (concat item (bitwarden-list-all-make-spaces (- width (length item)))))))
  392. ;================================ widget actions ===============================
  393. ;; Dialog settings and actions
  394. (defun bitwarden-list-cancel-dialog (&rest _ignore)
  395. "Cancel the current dialog.
  396. IGNORE arguments."
  397. (interactive)
  398. (kill-buffer (current-buffer))
  399. (bitwarden--message "dialog canceled" nil t))
  400. (defun bitwarden-list-all-kill-ring-save (&optional widget-item)
  401. "Bitwarden `kill-ring-save', insert password to kill ring.
  402. If WIDGET-ITEM is not supplied then look for the widget at the
  403. current point."
  404. (interactive)
  405. (let* ((item (or widget-item
  406. (bitwarden-list-all-get-item-at-pos)))
  407. (type (gethash "type" item))
  408. (login (gethash "login" item)))
  409. (if (not (eq type 1))
  410. (bitwarden--message "error: not a login item" nil t)
  411. (kill-new (gethash "password" login))
  412. (message "Password added to kill ring"))))
  413. (defun bitwarden-list-all-item-action (widget &rest _ignore)
  414. "Do action to element associated with WIDGET's value.
  415. IGNORE other arguments."
  416. (bitwarden-list-all-kill-ring-save (widget-value widget))
  417. (kill-buffer (current-buffer)))
  418. ;=================================== widgets ===================================
  419. (defmacro bitwarden-list-dialog (name &rest forms)
  420. "Show a dialog buffer with NAME, setup with FORMS."
  421. (declare (indent 1) (debug t))
  422. `(with-current-buffer (get-buffer-create ,name)
  423. ;; Cleanup buffer
  424. (let ((inhibit-read-only t)
  425. (ol (overlay-lists)))
  426. (mapc 'delete-overlay (car ol))
  427. (mapc 'delete-overlay (cdr ol))
  428. (erase-buffer))
  429. (bitwarden-list-dialog-mode)
  430. ,@forms
  431. (widget-setup)
  432. (switch-to-buffer (current-buffer))))
  433. (defsubst bitwarden-list-all-make-element (item)
  434. "Create a new cons list from ITEM."
  435. (let* ((folder-id (gethash "folderId" item))
  436. (login-item (gethash "login" item)))
  437. (cons folder-id
  438. (list (cons (concat
  439. (bitwarden-pad-to-width (gethash "name" item) 40)
  440. (bitwarden-pad-to-width
  441. (if login-item (gethash "username" login-item) "")
  442. 32)
  443. (format-time-string
  444. "%Y-%m-%d %T"
  445. (date-to-time (bitwarden-pad-to-width
  446. (gethash "revisionDate" item) 24))))
  447. item)))))
  448. (defun bitwarden-list-all-tree (key val)
  449. "Return a `tree-widget' of folders.
  450. Creates a widget with text KEY and items VAL."
  451. ;; Represent a sub-menu with a tree widget
  452. `(tree-widget
  453. :open t
  454. :match ignore
  455. :node (item :tag ,key
  456. :sample-face bold
  457. :format "%{%t%}\n")
  458. ,@(mapcar 'bitwarden-list-all-item val)))
  459. (defun bitwarden-list-all-item (pass-element)
  460. "Return a widget to display PASS-ELEMENT in a dialog buffer."
  461. ;; Represent a single file with a link widget
  462. `(link :tag ,(car pass-element)
  463. :button-prefix ""
  464. :button-suffix ""
  465. :button-face default
  466. :format "%[%t\n%]"
  467. :help-echo ,(concat "Viewing item " (gethash "id" (cdr pass-element)))
  468. :action bitwarden-list-all-item-action
  469. ,(cdr pass-element)))
  470. (defun bitwarden-list-all-items (items)
  471. "Return a list of widgets to display ITEMS in a dialog buffer."
  472. (let* ((folders (mapcar (lambda (e)
  473. (cons
  474. (gethash "id" e)
  475. (gethash "name" e)))
  476. (bitwarden-folders)))
  477. (hash (make-hash-table :test 'equal)))
  478. ;; create hash table where the keys are the folders and each value is a list
  479. ;; of the password items
  480. (dolist (x (mapcar 'bitwarden-list-all-make-element items))
  481. (let* ((folder-id (car x))
  482. (key (cdr (assoc folder-id folders)))
  483. (val (cdr x))
  484. (klist (gethash key hash)))
  485. (puthash key (append klist val) hash)))
  486. (mapcar (lambda (key)
  487. (bitwarden-list-all-tree key (gethash key hash)))
  488. (sort (hash-table-keys hash) #'string<))))
  489. ;;;###autoload
  490. (defun bitwarden-list-all ()
  491. "Show a dialog, listing all entries associated with `bitwarden-user'.
  492. If optional argument GROUP is given, only entries in GROUP will be listed."
  493. (interactive)
  494. (bitwarden-list-dialog "*bitwarden-list*"
  495. ;; Use a L&F that looks like the recentf menu.
  496. (tree-widget-set-theme "folder")
  497. (apply 'widget-create
  498. `(group
  499. :indent 0
  500. :format "%v\n"
  501. ,@(bitwarden-list-all-items
  502. (bitwarden-search))))
  503. (widget-create
  504. 'push-button
  505. :notify 'bitwarden-list-cancel-dialog
  506. "Cancel")
  507. (goto-char (point-min))))
  508. (provide 'bitwarden)
  509. ;;; bitwarden.el ends here