-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dd9c1d0
commit cc192b4
Showing
25 changed files
with
119 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,11 @@ | ||
use crate::{Collection, Sign, SubjectSyntaxType, Verify}; | ||
use crate::{Sign, Verify}; | ||
use anyhow::Result; | ||
use std::{str::FromStr, sync::Arc}; | ||
use std::sync::Arc; | ||
|
||
pub type SigningSubject = Arc<dyn Subject>; | ||
|
||
// TODO: Use a URI of some sort. | ||
/// This [`Subject`] trait is used to sign and verify JWTs. | ||
pub trait Subject: Sign + Verify + Send + Sync { | ||
fn identifier(&self, did_method: &str) -> Result<String>; | ||
fn type_(&self) -> Result<SubjectSyntaxType> { | ||
SubjectSyntaxType::from_str(&self.identifier("FIX_THIS")?) | ||
} | ||
} | ||
|
||
pub type Subjects = Collection<dyn Subject>; | ||
|
||
impl<const N: usize> TryFrom<[Arc<dyn Subject>; N]> for Subjects { | ||
type Error = anyhow::Error; | ||
|
||
fn try_from(subjects: [Arc<dyn Subject>; N]) -> Result<Self> { | ||
Ok(Self::from( | ||
subjects | ||
.iter() | ||
.map(|subject| subject.type_().map(|subject_type| (subject_type, subject.clone()))) | ||
.collect::<Result<Vec<_>>>()?, | ||
)) | ||
} | ||
fn identifier(&self, subject_syntax_type: &str) -> Result<String>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.