-
Notifications
You must be signed in to change notification settings - Fork 14
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
Use latest jws & jwt functionality, add VC verify and decode functions to match #150 #176
Use latest jws & jwt functionality, add VC verify and decode functions to match #150 #176
Conversation
@@ -85,45 +86,40 @@ impl VerifiableCredential { | |||
vc: self.clone(), | |||
}; | |||
|
|||
let encoded_header = header.encode()?; | |||
let encoded_claims = claims.encode()?; | |||
let jwt = Jwt::sign(bearer_did, key_selector, None, &claims)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eventually I think we will want a concept of a vcJwt as it is not exactly the same as a jwt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for reference :
public async sign(options: VerifiableCredentialSignOptions): Promise<string> {
const vcJwt: string = await Jwt.sign({
signerDid : options.did,
payload : {
vc : this.vcDataModel,
nbf : Math.floor(new Date(this.vcDataModel.issuanceDate).getTime() / 1000),
jti : this.vcDataModel.id,
iss : options.did.uri,
sub : this.subject,
iat : Math.floor(Date.now() / 1000),
...(this.vcDataModel.expirationDate && {
exp: Math.floor(new Date(this.vcDataModel.expirationDate).getTime() / 1000),
}),
}
});
return vcJwt;
}
} | ||
|
||
pub fn decode(jwt: &str) -> Result<Self, CredentialError> { | ||
let jwt_decoded = Jwt::decode::<VcJwtClaims>(jwt)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah perfect
Background
This is a part of a messy multi-step multi-PR campaign to revamp JWS (#143), JWT (#144) and the uses in VC (#150); this PR addresses #150. I will subsequently open a PR removing all the non-v2 code and update bindings accordingly.
Changes
jwt
crate (changes in Refactor jwt #144 #173) -- this includesRegisteredClaims
, and the newsign
/verify
/decode
functionsVerifiableCredential::verify()
andVerifiableCredential::decode()
functions, as to match the paradigm with the latest injws
andjwt
Forward looking
verify
anddecode
so we can iterate on the approach thereVcJwtClaims