store/io.bend relies on unsafe/foreign
raw source on the hub · import cswap-bend-cli@0.1.0.0/store/io.bend as Io
9 imports
import Base import ../json.bend as Json import ../b64.bend as B64 import ../fs.bend as Fs import ../act.bend as Act import ../clock.bend as Clock import ../fs/write.bend as FsW import ./base.bend as SBase import ./seq.bend as SSeq
Definitions
def ActM source · line 12 · raw
@-A:Type -> Type
do ActM<A>: needs the monad defined in the file that uses it.
def ActM.pure source · line 15 · raw
@-A:Type -> @x:A -> 0x0717344745a30ebad1f19045228e8f18/act.of(A)
def ActM.bind source · line 18 · raw
@-A:Type -> @-B:Type -> @m:0x0717344745a30ebad1f19045228e8f18/act.of(A) -> @f:(@_:A -> 0x0717344745a30ebad1f19045228e8f18/act.of(B)) -> 0x0717344745a30ebad1f19045228e8f18/act.of(B)
def now_iso source · line 23 · raw
0x0717344745a30ebad1f19045228e8f18/act.of(String)
def swallow source · line 28 · raw
@r:0x0717344745a30ebad1f19045228e8f18/fs.Res(Unit) -> 0x0717344745a30ebad1f19045228e8f18/act.of(Unit)
def log_write source · line 31 · raw
@+root:String -> @+ts:String -> @+level:String -> @+msg:String -> 0x0717344745a30ebad1f19045228e8f18/act.of(Unit)
def log source · line 36 · raw
@+root:String -> @+level:String -> @+msg:String -> 0x0717344745a30ebad1f19045228e8f18/act.of(Unit)
One line in claude-swap.log, in the reference's format. A log that cannot be written never fails the operation.
def secure_dir source · line 41 · raw
@+path:String -> 0x0717344745a30ebad1f19045228e8f18/act.of(Unit)
def setup_dirs source · line 47 · raw
@+root:String -> 0x0717344745a30ebad1f19045228e8f18/act.of(Unit)
The backup root, credentials/ and configs/, all 0700.
def write_secret source · line 53 · raw
@+path:String -> @+text:String -> 0x0717344745a30ebad1f19045228e8f18/act.of(Unit)
def write_seq source · line 56 · raw
@+root:String -> @+j:0x0717344745a30ebad1f19045228e8f18/json.Json -> 0x0717344745a30ebad1f19045228e8f18/act.of(Unit)
def parse_seq source · line 59 · raw
@+path:String -> @r:Result<&2, &2, String, 0x0717344745a30ebad1f19045228e8f18/json.Json> -> 0x0717344745a30ebad1f19045228e8f18/act.of(Maybe<&2, 0x0717344745a30ebad1f19045228e8f18/json.Json>)
def read_seq2 source · line 66 · raw
@+ex:Bool -> @+path:String -> 0x0717344745a30ebad1f19045228e8f18/act.of(Maybe<&2, 0x0717344745a30ebad1f19045228e8f18/json.Json>)
def read_seq source · line 77 · raw
@+root:String -> 0x0717344745a30ebad1f19045228e8f18/act.of(Maybe<&2, 0x0717344745a30ebad1f19045228e8f18/json.Json>)
sequence.json, or None when there is none yet. A torn file is an error and is never replaced.
def ensure_seq2 source · line 82 · raw
@+m:Maybe<&2, 0x0717344745a30ebad1f19045228e8f18/json.Json> -> @+root:String -> @+ts:String -> 0x0717344745a30ebad1f19045228e8f18/act.of(0x0717344745a30ebad1f19045228e8f18/json.Json)
def ensure_seq source · line 92 · raw
@+root:String -> @+ts:String -> 0x0717344745a30ebad1f19045228e8f18/act.of(0x0717344745a30ebad1f19045228e8f18/json.Json)
sequence.json, written fresh first when it does not exist.
def decoded source · line 97 · raw
@+m:Maybe<&2, String> -> String
def read_cred2 source · line 100 · raw
@+ex:Bool -> @+path:String -> 0x0717344745a30ebad1f19045228e8f18/act.of(String)
def read_cred source · line 110 · raw
@+root:String -> @+slot:String -> @+email:String -> 0x0717344745a30ebad1f19045228e8f18/act.of(String)
A slot's stored credential: the decoded text, "" when absent or undecodable.
def keep_prev source · line 115 · raw
@+keep:Bool -> @+root:String -> @+slot:String -> @+email:String -> @+cur:String -> 0x0717344745a30ebad1f19045228e8f18/act.of(Unit)
def write_cred source · line 120 · raw
@+root:String -> @+slot:String -> @+email:String -> @+creds:String -> 0x0717344745a30ebad1f19045228e8f18/act.of(Unit)
Store a slot's credential (0600). The generation it replaces is kept as
.enc.prev when it was readable and different.
def write_config source · line 126 · raw
@+root:String -> @+slot:String -> @+email:String -> @+text:String -> 0x0717344745a30ebad1f19045228e8f18/act.of(Unit)
def read_config source · line 129 · raw
@+root:String -> @+slot:String -> @+email:String -> 0x0717344745a30ebad1f19045228e8f18/act.of(String)
def mv_keep2 source · line 134 · raw
@+ex:Bool -> @+src:String -> @+dst:String -> 0x0717344745a30ebad1f19045228e8f18/act.of(Unit)
def mv_keep source · line 143 · raw
@+src:String -> @+dst:String -> 0x0717344745a30ebad1f19045228e8f18/act.of(Unit)
def archive_dirs source · line 151 · raw
@+root:String -> 0x0717344745a30ebad1f19045228e8f18/act.of(Unit)
Move the slot's .enc (and .prev, legacy copy, config) under .removed/ with a
UTC time stamp. This is where remove and every slot displacement send a
credential: the reference deletes them, which lost the only full login once.
def archive_mv source · line 156 · raw
@+root:String -> @+slot:String -> @+email:String -> @+ts:String -> 0x0717344745a30ebad1f19045228e8f18/act.of(Unit)
def archive_slot source · line 163 · raw
@+root:String -> @+slot:String -> @+email:String -> @+ts:String -> 0x0717344745a30ebad1f19045228e8f18/act.of(Unit)
def slot_email2 source · line 169 · raw
@+m:Maybe<&2, 0x0717344745a30ebad1f19045228e8f18/json.Json> -> String
def slot_email source · line 176 · raw
@+seq:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+num:String -> String
def drop_slot source · line 180 · raw
@+root:String -> @+seq:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+num:String -> @+ts:String -> 0x0717344745a30ebad1f19045228e8f18/act.of(0x0717344745a30ebad1f19045228e8f18/json.Json)
Archive a slot's files and forget its record; sequence.json is rewritten.
def drop_opt source · line 187 · raw
@+root:String -> @+seq:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+m:Maybe<&2, String> -> @+ts:String -> 0x0717344745a30ebad1f19045228e8f18/act.of(0x0717344745a30ebad1f19045228e8f18/json.Json)
def drop_pair source · line 195 · raw
@+root:String -> @+seq:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+displace:Maybe<&2, String> -> @+migrate:Maybe<&2, String> -> @+ts:String -> 0x0717344745a30ebad1f19045228e8f18/act.of(0x0717344745a30ebad1f19045228e8f18/json.Json)
Archive what a displaced and a migrated slot held, in that order.