pub fn profile_owner(target: &[u8]) -> Option<DidNostr>Expand description
Returns the owner of the profile document named by a request target,
or None when the target is anything but exactly
/pods/<64 lower-case hex>/profile/card.
The comparison is byte for byte on the target as received: nothing is
decoded or normalised. A query (even a bare ?), a fragment, any %,
an empty segment, a dot segment, a trailing slash, a suffix such as
.acl, a different case, or a key that is not a valid public key all
fail. The pod server serves the card under several equivalent spellings,
so this exact match is what confines the unsigned read to one resource
per pod.
ยงExamples
use stratum_node_core::{profile_card_path, profile_owner, DidNostr};
let owner = DidNostr::from_hex("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798")?;
let path = profile_card_path(&owner);
assert_eq!(profile_owner(path.as_str().as_bytes()), Some(owner));
let hex = owner.to_hex();
for refused in [
format!("/pods/{hex}/profile/card?"),
format!("/pods/{hex}/profile/./card"),
format!("/pods/{hex}/profile/%2e/card"),
format!("/pods/{hex}/profile/card.acl"),
format!("/pods/{}/profile/card", hex.to_uppercase()),
] {
assert_eq!(profile_owner(refused.as_bytes()), None, "{refused}");
}