commit e19f32986522e47e742a259b4c194c5ede77d803
parent 843d84556553ab2600c2a620e31f4a3b252574fe
Author: srfsh <dev@srf.sh>
Date: Tue, 26 Jul 2022 17:24:02 +0300
Zenflows.Restroom: support keypairoomServer
Diffstat:
1 file changed, 23 insertions(+), 0 deletions(-)
diff --git a/src/zenflows/restroom.ex b/src/zenflows/restroom.ex
@@ -49,6 +49,22 @@ def verify_graphql?(body, signature, pubkey) do
end
end
+@doc """
+See https://github.com/dyne/keypairoom for details.
+"""
+@spec keypairoom_server(String.t()) :: String.t()
+def keypairoom_server(data) do
+ data = %{
+ "userData" => data,
+ "theBackendPassword" => pass(),
+ }
+ case exec("keypairoomServer", data) do
+ {:ok, %{"key_derivation" => derived}} -> {:ok, derived}
+ {:error, reason} -> {:error, reason}
+ end
+end
+
+
# Execute a Zencode specified by `name` with JSON data `data`.
@spec exec(String.t(), map()) :: {:ok, map()} | {:error, any()}
defp exec(name, data) do
@@ -85,6 +101,13 @@ defp host() do
"#{conf[:room_host]}:#{conf[:room_port]}"
end
+# Return the passphrase from the configs.
+@spec pass() :: String.t()
+defp pass() do
+ conf = conf()
+ conf[:room_pass]
+end
+
# Return the application configurations of this module.
@spec conf() :: Keyword.t()
defp conf() do