Update Context to accept External Identity Provider. (#127)

* rename .account_id() to .id()

* Create logos-traits crate

* Remove AccountId references

* external IdentityProvider for Context

* Fix compile errors from merge

* Update logos-traits to shared-traits

* format fixes

* warnings cleanup

* clippy fix

* Remove rebase artifact
This commit is contained in:
Jazz Turner-Baggs
2026-06-10 06:59:04 -07:00
committed by GitHub
parent 0e72fdf483
commit a610117e81
27 changed files with 297 additions and 222 deletions
+8
View File
@@ -0,0 +1,8 @@
[package]
name = "shared-traits"
description = "Shared traits for the Logos Ecosystem"
version = "0.1.0"
edition = "2024"
[dependencies]
crypto = { workspace = true }
+39
View File
@@ -0,0 +1,39 @@
use crypto::{Ed25519Signature, Ed25519VerifyingKey};
use std::fmt;
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct IdentId(String);
pub type IdentIdRef<'a> = &'a IdentId;
impl IdentId {
pub fn new(id: impl Into<String>) -> Self {
Self(id.into())
}
pub fn as_str(&self) -> &str {
&self.0
}
}
impl fmt::Display for IdentId {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
std::fmt::Display::fmt(&self.0, f)
}
}
impl AsRef<str> for IdentId {
fn as_ref(&self) -> &str {
&self.0
}
}
/// Represents an external Identity
/// Implement this to provide an Authentication model for users/installations
pub trait IdentityProvider {
fn id(&self) -> IdentIdRef<'_>;
// Display name is not garenteed to be consistent. It should only be used to
// provded a more readable identifier for the account.
fn display_name(&self) -> String;
fn sign(&self, payload: &[u8]) -> Ed25519Signature;
fn public_key(&self) -> &Ed25519VerifyingKey;
}