def archive_live
cswap-bend-cli@0.1.0.0 · swlive.bend:168
import cswap-bend-cli@0.1.0.0/swlive.bend as Swlive
import Base
import cswap-bend-cli@0.1.0.0/act.bend as Act
import cswap-bend-cli@0.1.0.0/b64.bend as B64
import cswap-bend-cli@0.1.0.0/store/base.bend as SBase
import cswap-bend-cli@0.1.0.0/store/io.bend as SIo
168def archive_live(+root: String, +email: String, +creds: String, +ts: String) -> Act.of(Unit):
169 do ActM<Unit>:
170 SIo.secure_dir(SBase.removed_dir(root))
171 SIo.write_secret(SBase.removed_dir(root) ++ "/" ++ ts ++ "-live-" ++ SBase.sel.s(String.is_empty(email), "unknown", email) ++ ".enc", B64.encode(creds))
172 SIo.log(root, "WARNING", "Archived the live login (" ++ SBase.sel.s(String.is_empty(email), "unknown", email) ++ ") to credentials/.removed/" ++ ts ++ "-live-...enc before replacing it; credentials are moved aside, never deleted")