Every stored certificate, as `(base32 id, document)` pairs. Unreadable files are skipped rather than failing the whole listing: one corrupt certificate should not make `atomic identity agent list` unusable.
(&self)
| 871 | /// corrupt certificate should not make `atomic identity agent list` |
| 872 | /// unusable. |
| 873 | pub fn list_delegations(&self) -> Result<Vec<(String, String)>, IdentityError> { |
| 874 | let dir = self.delegations_dir(); |
| 875 | if !dir.exists() { |
| 876 | return Ok(Vec::new()); |
| 877 | } |
| 878 | |
| 879 | let mut out = Vec::new(); |
| 880 | for entry in fs::read_dir(&dir)? { |
| 881 | let entry = entry?; |
| 882 | let name = entry.file_name(); |
| 883 | let Some(name) = name.to_str() else { continue }; |
| 884 | // Revocations sit beside certificates and share the id prefix. |
| 885 | if !name.ends_with(".json") || name.ends_with(".revocation.json") { |
| 886 | continue; |
| 887 | } |
| 888 | let id = name.trim_end_matches(".json").to_string(); |
| 889 | if let Ok(document) = fs::read_to_string(entry.path()) { |
| 890 | out.push((id, document)); |
| 891 | } |
| 892 | } |
| 893 | out.sort_by(|a, b| a.0.cmp(&b.0)); |
| 894 | Ok(out) |
| 895 | } |
| 896 | |
| 897 | /// Delete a certificate and any revocation stored alongside it. |
| 898 | pub fn delete_delegation(&self, id: &str) -> Result<(), IdentityError> { |