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

feat: add support for json-object based issuer #155

Merged
merged 1 commit into from
May 9, 2024

Conversation

enmand
Copy link
Contributor

@enmand enmand commented May 4, 2024

Add support for a JSON-like object for id/name for an Issuer, in addition to a string based on the VC spec.

Resolves #113

@KendallWeihe
Copy link
Contributor

KendallWeihe commented May 6, 2024

This is amazing work @enmand 💯

CI currently failing because of UniFFI bindings; all of the bindings stuff is in a heavy WIP state so let me see what I can come to in order to merge this PR, brb

@KendallWeihe
Copy link
Contributor

Alright so the issue is caused from UniFFI's lack of support for enums with non-named field. I created a ticket to explore the ideal solution #161

@enmand I would recommend one of two ways forward:

  1. You could go ahead and embrace Option A; I did that with the KeySelector already. This would cause quite a few syntactical changes to your code, but it would be a fine way forward IMO.
  2. You're welcome to just simply remove the UDL code which is causing the build error, because the UDL code we currently have is mostly there as a part of a prototype and is probably going to change in short order. We would still have to address this issue eventually, but it would kick the can down the road to when we go to actually bind the Verifiable Credentials code, and perhaps at which point we could come to some other option than what is outlined in UniFFI UDL incompatibility with non-named field enums #161.

If you choose to go route (2), here is a code diff of the removal of the code (I don't have push access to your repo so I can't open a PR, so this is good enough):

diff --git a/bindings/uniffi/src/lib.rs b/bindings/uniffi/src/lib.rs
index 0069364..8aca89c 100644
--- a/bindings/uniffi/src/lib.rs
+++ b/bindings/uniffi/src/lib.rs
@@ -1,4 +1,3 @@
-use ::credentials::vc::{verify_vcjwt, CredentialError, CredentialSubject, VerifiableCredential};
 use ::crypto::Curve;
 use ::dids::{
     bearer::{BearerDid, BearerDidError},
diff --git a/bindings/uniffi/src/web5.udl b/bindings/uniffi/src/web5.udl
index 3bba112..22d1da0 100644
--- a/bindings/uniffi/src/web5.udl
+++ b/bindings/uniffi/src/web5.udl
@@ -6,9 +6,6 @@ namespace web5 {
   string sign_jwt([ByRef] BearerDid bearer_did, [ByRef] KeySelector key_selector, [ByRef] string encoded_header, [ByRef] string encoded_payload);
   [Throws=JwtError, Async]
   void verify_jwt([ByRef] string jwt);
-
-  [Throws=CredentialError, Async]
-  VerifiableCredential verify_vcjwt([ByRef] string jwt);
 };
 
 [Error]
@@ -195,21 +192,4 @@ interface Claims {
   string encode();
   [Throws=JwtError]
   string sign([ByRef] BearerDid bearer_did, [ByRef] KeySelector key_selector);
-};
-
-dictionary CredentialSubject {
-  string id;
-  record<string, string>? params;
-};
-
-[Error]
-enum CredentialError {
-  "JwtError",
-  "JwsError",
-};
-
-interface VerifiableCredential {
-  constructor(sequence<string> context, string id, sequence<string> type, string issuer, i64 issuance_date, i64? expiration_date, CredentialSubject credential_subject);
-  [Throws=CredentialError]
-  string sign([ByRef] BearerDid bearer_did, [ByRef] KeySelector key_selector);
 };
\ No newline at end of file

@KendallWeihe
Copy link
Contributor

I didn't expect this to work, but I was able to checkout enmand:feat/issuer-obj, rebase onto the upstream main, fix conflicts and then force push. I've never worked with forked repos, but anyways, it worked! lol so I took the liberty to get this fixed and I'm ready to merge it!

For background, we blanked out in #181 so the above blocker has been removed

@KendallWeihe
Copy link
Contributor

Thanks again for this @enmand! This is awesome work!

@KendallWeihe KendallWeihe merged commit 008cc00 into decentralized-identity:main May 9, 2024
9 checks passed
enmand added a commit to enmand/web5-rs that referenced this pull request May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for VC issuer to be string or object
2 participants