pub const AUTHS_INIT_SUCCESS_TEMPLATE: &str = "\
\u{2713} Created device KEL: did:keri:E{prefix}
This identifies *this machine*, not your identity yet.
Next: run `auths pair` on another device to bind them as controllers of a shared identity.
";
pub const DUPLICITY_WARNING_TEMPLATE: &str = "\
\u{26A0} Your identity's key-event log has diverged.
Two controllers signed incompatible rotations at sequence {seq}.
To resolve, pick the device you trust and run:
auths device remove <other-controller-did>
This produces an authoritative rotation on that device's timeline.
";
pub fn format_init_success(prefix: &str) -> String {
AUTHS_INIT_SUCCESS_TEMPLATE.replace("{prefix}", prefix)
}
pub fn format_duplicity_warning(seq: u64) -> String {
DUPLICITY_WARNING_TEMPLATE.replace("{seq}", &seq.to_string())
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn init_success_substitutes_prefix() {
let out = format_init_success("abc");
assert!(out.contains("did:keri:Eabc"));
assert!(out.contains("This identifies *this machine*"));
}
#[test]
fn init_success_is_stable_across_calls() {
let a = format_init_success("xyz");
let b = format_init_success("xyz");
assert_eq!(a, b);
}
#[test]
fn duplicity_warning_substitutes_seq() {
let out = format_duplicity_warning(42);
assert!(out.contains("sequence 42"));
assert!(out.contains("auths device remove"));
}
#[test]
fn duplicity_warning_action_block_is_byte_stable() {
let out = format_duplicity_warning(7);
assert!(out.contains(
" To resolve, pick the device you trust and run:\n\
\x20 auths device remove <other-controller-did>"
));
}
}