-
Notifications
You must be signed in to change notification settings - Fork 22
Fix/sl-verification #332
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
Fix/sl-verification #332
Changes from 10 commits
72f315a
8805216
9e07274
4e9ca99
f2af854
a3e8abb
0d4c0c0
ad7dd20
960987b
3b63a50
437e75a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| export * from './status-list'; | ||
| export * from './status-list-jwt'; | ||
| export * from './types'; | ||
| export * from './status-list-exception'; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| /** | ||
| * SLException is a custom error class for Status List related exceptions. | ||
| */ | ||
| export class SLException extends Error { | ||
| public details?: unknown; | ||
|
|
||
| constructor(message: string, details?: unknown) { | ||
| super(message); | ||
| Object.setPrototypeOf(this, SLException.prototype); | ||
| this.name = 'SLException'; | ||
| this.details = details; | ||
| } | ||
|
|
||
| getFullMessage(): string { | ||
| return `${this.name}: ${this.message} ${ | ||
| this.details ? `- ${JSON.stringify(this.details)}` : '' | ||
| }`; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| import { Jwt, SDJwt, SDJwtInstance, type VerifierOptions } from '@sd-jwt/core'; | ||
| import { | ||
| getListFromStatusListJWT, | ||
| SLException, | ||
| type StatusListJWTHeaderParameters, | ||
| type StatusListJWTPayload, | ||
| } from '@sd-jwt/jwt-status-list'; | ||
|
|
@@ -306,18 +307,18 @@ export class SDJwtVcInstance extends SDJwtInstance<SdJwtVcPayload> { | |
| StatusListJWTPayload | ||
| >(statusListJWT); | ||
| // check if the status list has a valid signature. The presence of the verifier is checked in the parent class. | ||
| await slJWT.verify( | ||
| this.userConfig.statusVerifier ?? | ||
| (this.userConfig.verifier as Verifier), | ||
| options, | ||
| ); | ||
|
|
||
| const currentDate = | ||
| options?.currentDate ?? Math.floor(Date.now() / 1000); | ||
| //check if the status list is expired | ||
| if (slJWT.payload?.exp && (slJWT.payload.exp as number) < currentDate) { | ||
| throw new SDJWTException('Status list is expired'); | ||
| } | ||
| await slJWT | ||
| .verify( | ||
| this.userConfig.statusVerifier ?? | ||
| (this.userConfig.verifier as Verifier), | ||
| options, | ||
| ) | ||
| .catch((err: SLException) => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think casting this as an
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it should rather be implemented as
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I made a suggestion with a fix here @TimoGlastra can you please verify it if this was your intention? I agree that we should give the flexibility of throwing own exceptions. |
||
| throw new SLException( | ||
| `Status List JWT verification failed: ${err.message}`, | ||
| err.details, | ||
| ); | ||
| }); | ||
|
|
||
| // get the status list from the status list JWT | ||
| const statusList = getListFromStatusListJWT(statusListJWT); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.