-
Notifications
You must be signed in to change notification settings - Fork 84
Feat/jwt vc jsonld #1646
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/jwt vc jsonld #1646
Changes from all commits
f268d48
4011757
03152e4
e931936
05b4fbb
70f9446
4afb9e1
40c0412
26d7b5c
0d1652e
6211dd0
2e05268
ae7e8ea
3a70c87
f73b179
f584dc1
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 |
|---|---|---|
|
|
@@ -196,6 +196,14 @@ export class SdJwtTemplateDto { | |
| @IsString() | ||
| vct: string; | ||
|
|
||
| @ApiPropertyOptional({ | ||
| example: 'https://dev-schema.sovio.id/schemas/a99d55b6-c663-4af8-bcd3-4fe6699df91a', | ||
| description: 'JSON-LD schema URL for the credential' | ||
| }) | ||
| @IsString() | ||
| @IsOptional() | ||
| schemaUrl?: string; | ||
|
|
||
| @ApiProperty({ | ||
| type: 'array', | ||
| items: { $ref: getSchemaPath(CredentialAttributeDto) }, | ||
|
|
@@ -229,8 +237,13 @@ export class CreateCredentialTemplateDto { | |
| @IsEnum(CredentialFormat) | ||
| format: CredentialFormat; | ||
|
|
||
| @ValidateIf((o: CreateCredentialTemplateDto) => CredentialFormat.SdJwtVc === o.format) | ||
| @IsEmpty({ message: 'doctype must not be provided when format is "dc+sd-jwt"' }) | ||
| @ValidateIf( | ||
| (o: CreateCredentialTemplateDto) => | ||
| CredentialFormat.SdJwtVc === o.format || | ||
| CredentialFormat.JwtVcJsonLd === o.format || | ||
| CredentialFormat.LdpVc === o.format | ||
| ) | ||
|
Comment on lines
+240
to
+245
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. Fix the lint-blocking The current multiline arrow predicate triggers the ESLint Proposed fix- `@ValidateIf`(
- (o: CreateCredentialTemplateDto) =>
- CredentialFormat.SdJwtVc === o.format || CredentialFormat.JwtVcJsonLd === o.format
- )
+ `@ValidateIf`(
+ (o: CreateCredentialTemplateDto) =>
+ CredentialFormat.SdJwtVc === o.format || CredentialFormat.JwtVcJsonLd === o.format
+ )🧰 Tools🪛 ESLint[error] 234-234: Expected no linebreak before this expression. (implicit-arrow-linebreak) 🤖 Prompt for AI Agents |
||
| @IsEmpty({ message: 'doctype must not be provided when format is "dc+sd-jwt", "jwt_vc_json-ld" or "ldp_vc"' }) | ||
| readonly _doctypeAbsentGuard?: unknown; | ||
|
|
||
| @ValidateIf((o: CreateCredentialTemplateDto) => CredentialFormat.Mdoc === o.format) | ||
|
|
@@ -246,7 +259,11 @@ export class CreateCredentialTemplateDto { | |
| @Type(({ object }) => { | ||
| if (object.format === CredentialFormat.Mdoc) { | ||
| return MdocTemplateDto; | ||
| } else if (object.format === CredentialFormat.SdJwtVc) { | ||
| } else if ( | ||
| object.format === CredentialFormat.SdJwtVc || | ||
| object.format === CredentialFormat.JwtVcJsonLd || | ||
| object.format === CredentialFormat.LdpVc | ||
| ) { | ||
| return SdJwtTemplateDto; | ||
| } | ||
| }) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
Add element-level string validation for
contextarray.The
@IsArraydecorator validates the field is an array, but doesn't validate that each element is a string. A malformed payload with non-string elements (e.g.,context: [123, {}]) would pass validation.Proposed fix
`@ApiPropertyOptional`({ example: ['https://www.w3.org/2018/credentials/v1', 'https://json-ld.org/contexts/person.jsonld'], description: 'JSON-LD context for the credential (optional, defaults to person schema for JSON-LD format)' }) `@IsArray`() + `@IsString`({ each: true }) `@IsOptional`() context?: string[];📝 Committable suggestion
🤖 Prompt for AI Agents
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.
We do not expose or accept the context array directly from the user in the DTO. Instead, the backend automatically constructs it internally from the schemaUrl (which is strictly validated as a string via @IsString()) and a default constant. Therefore, this issue is already mitigated.
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.