Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add witnessed_by_cid-equivalent helper to UcanBuilder API #32

Open
cdata opened this issue Oct 17, 2022 · 1 comment
Open

Add witnessed_by_cid-equivalent helper to UcanBuilder API #32

cdata opened this issue Oct 17, 2022 · 1 comment
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@cdata
Copy link
Member

cdata commented Oct 17, 2022

As of #28 , we only recognize CIDs in the prf field of UCANs. However, the UcanBuilder API only accepts a Ucan as the value for the witnessed_by method that adds elements to the prf field. This is convenient because the builder automatically encodes the Ucan and adds its CID on your behalf. However, there are cases where you will have the CID handy but perhaps not the UCAN it points to. For this case, it can be convenient to add a witness by CID. We should enhance UcanBuilder to support this.

@cdata cdata added enhancement New feature or request good first issue Good for newcomers labels Oct 17, 2022
@cdata
Copy link
Member Author

cdata commented Oct 20, 2022

Maybe instead, it should be...

pub trait Authorization {
  async fn resolve_ucan<S: UcanJwtStore>(&self, &S) -> Result<Ucan>;
}

// Or...

pub enum Authorization {
  Ucan(Ucan),
  Cid(Cid),
  Jwt(String),
  UcanIpld(UcanIpld)
}

And then the builder signature is changed to something like...

pub struct UcanBuilder {
  // ...
 
  pub fn witnessed_by(mut self, authorization: &Authorization) -> Self { /* ... */ }

  // ...
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants