fix(cli-e2e): disable keychain only in e2e runs

This commit is contained in:
Tienson Qin
2026-04-22 15:31:13 +08:00
parent 80a99e0ad0
commit fd6bdff4cc
5 changed files with 132 additions and 63 deletions

View File

@@ -1,12 +1,8 @@
(ns frontend.handler.e2ee
"rtc E2EE related fns"
(:require [electron.ipc :as ipc]
[frontend.common.crypt :as crypt]
[frontend.common.thread-api :refer [def-thread-api]]
[frontend.mobile.secure-storage :as secure-storage]
[frontend.state :as state]
[frontend.util :as util]
[lambdaisland.glogi :as log]
[promesa.core :as p]))
(def ^:private save-op :keychain/save-e2ee-password)
@@ -70,35 +66,3 @@
(if (native-storage-supported?)
(<keychain-delete! key)
(p/resolved nil)))
(def-thread-api :thread-api/request-e2ee-password
[]
(p/let [password-promise (state/pub-event! [:rtc/request-e2ee-password])
password password-promise]
{:password password}))
(defn- <decrypt-user-e2ee-private-key
[encrypted-private-key]
(->
(p/let [private-key-promise (state/pub-event! [:rtc/decrypt-user-e2ee-private-key encrypted-private-key])
private-key private-key-promise]
(crypt/<export-private-key private-key))
(p/catch (fn [e]
(log/error :<decrypt-user-e2ee-private-key e)
e))))
(def-thread-api :thread-api/decrypt-user-e2ee-private-key
[encrypted-private-key]
(<decrypt-user-e2ee-private-key encrypted-private-key))
(def-thread-api :thread-api/native-save-e2ee-password
[encrypted-text]
(<native-save-secret! "logseq-encrypted-password" encrypted-text))
(def-thread-api :thread-api/native-get-e2ee-password
[]
(<native-get-secret "logseq-encrypted-password"))
(def-thread-api :thread-api/native-delete-e2ee-password
[]
(<native-delete-secret! "logseq-encrypted-password"))