Skip to content

Commit 3af9804

Browse files
GHkrishnatipusinghaw
authored andcommitted
namespace changes
Signed-off-by: Krishna Waske <[email protected]>
1 parent fec51d0 commit 3af9804

File tree

5 files changed

+91
-83
lines changed

5 files changed

+91
-83
lines changed

apps/api-gateway/src/agent-service/dto/create-schema.dto.ts

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,29 @@ import { ApiProperty } from '@nestjs/swagger';
22
import { IsString, IsNotEmpty, IsArray } from 'class-validator';
33

44
export class CreateTenantSchemaDto {
5-
@ApiProperty()
6-
@IsString({ message: 'tenantId must be a string' }) @IsNotEmpty({ message: 'please provide valid tenantId' })
7-
tenantId: string;
8-
9-
@ApiProperty()
10-
@IsString({ message: 'schema version must be a string' }) @IsNotEmpty({ message: 'please provide valid schema version' })
11-
schemaVersion: string;
5+
@ApiProperty()
6+
@IsString({ message: 'tenantId must be a string' })
7+
@IsNotEmpty({ message: 'please provide valid tenantId' })
8+
tenantId: string;
129

13-
@ApiProperty()
14-
@IsString({ message: 'schema name must be a string' }) @IsNotEmpty({ message: 'please provide valid schema name' })
15-
schemaName: string;
10+
@ApiProperty()
11+
@IsString({ message: 'schema version must be a string' })
12+
@IsNotEmpty({ message: 'please provide valid schema version' })
13+
schemaVersion: string;
1614

17-
@ApiProperty()
18-
@IsArray({ message: 'attributes must be an array' })
19-
@IsString({ each: true })
20-
@IsNotEmpty({ message: 'please provide valid attributes' })
21-
attributes: string[];
15+
@ApiProperty()
16+
@IsString({ message: 'schema name must be a string' })
17+
@IsNotEmpty({ message: 'please provide valid schema name' })
18+
schemaName: string;
2219

23-
@ApiProperty()
24-
25-
@IsNotEmpty({ message: 'please provide orgId' })
26-
orgId: string;
27-
}
20+
@ApiProperty()
21+
@IsArray({ message: 'attributes must be an array' })
22+
@IsString({ each: true })
23+
// TODO: IsNotEmpty won't work for array. Must use @ArrayNotEmpty() instead
24+
@IsNotEmpty({ message: 'please provide valid attributes' })
25+
attributes: string[];
26+
27+
@ApiProperty()
28+
@IsNotEmpty({ message: 'please provide orgId' })
29+
orgId: string;
30+
}

apps/api-gateway/src/oid4vc-issuance/dtos/oid4vc-issuer-template.dto.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,20 @@ export class CredentialAttributeDto {
2222
@IsBoolean()
2323
mandatory?: boolean;
2424

25+
// TODO: Check how do we handle claims with only path rpoperty like email, etc.
2526
@ApiProperty({ description: 'Type of the attribute value (string, number, date, etc.)' })
2627
@IsString()
2728
value_type: string;
2829

30+
@ApiProperty({
31+
type: [String],
32+
description:
33+
'Claims path pointer as per the draft 15 - https://openid.net/specs/openid-4-verifiable-credential-issuance-1_0-ID2.html#name-claims-path-pointer'
34+
})
35+
@IsArray()
36+
@IsString({ each: true })
37+
path: string[];
38+
2939
@ApiProperty({ type: [DisplayDto], required: false, description: 'Localized display values' })
3040
@IsOptional()
3141
@ValidateNested({ each: true })
@@ -163,7 +173,7 @@ export class CreateCredentialTemplateDto {
163173
description: 'Attributes included in the credential template'
164174
})
165175
@IsObject()
166-
attributes: Record<string, CredentialAttributeDto>;
176+
attributes: CredentialAttributeDto[];
167177

168178
@ApiProperty({
169179
type: Object,

apps/api-gateway/src/oid4vc-issuance/dtos/oid4vc-issuer.dto.ts

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
/* eslint-disable camelcase */
2-
import { ApiExtraModels, ApiProperty, ApiPropertyOptional, getSchemaPath } from '@nestjs/swagger';
2+
import { ApiExtraModels, ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
33
import {
44
IsString,
55
IsOptional,
66
IsBoolean,
77
IsArray,
88
ValidateNested,
9-
IsObject,
109
IsUrl,
1110
IsNotEmpty,
1211
IsDefined,
1312
IsInt
1413
} from 'class-validator';
15-
import { plainToInstance, Transform, Type } from 'class-transformer';
14+
import { Type } from 'class-transformer';
1615

1716
export class ClaimDto {
1817
@ApiProperty({
19-
description: 'The unique key for the claim (e.g. email, name)',
20-
example: 'email'
18+
description: 'The path for nested claims',
19+
example: ['address', 'street_number'],
20+
type: [String]
2121
})
22-
@IsString()
23-
key: string;
22+
@Type(() => String)
23+
@IsArray()
24+
path: string[];
2425

2526
@ApiProperty({
2627
description: 'The display label for the claim',
@@ -85,6 +86,7 @@ export class DisplayDto {
8586
logo?: LogoDto;
8687
}
8788

89+
// TODO: Check where it is used, coz no reference found
8890
@ApiExtraModels(ClaimDto)
8991
export class CredentialConfigurationDto {
9092
@ApiProperty({
@@ -110,25 +112,25 @@ export class CredentialConfigurationDto {
110112
@IsString()
111113
scope: string;
112114

113-
// @ApiProperty({
114-
// description: 'List of claims supported in this credential',
115-
// type: [ClaimDto],
116-
// })
117-
// @IsArray()
118-
// @ValidateNested({ each: true })
119-
// @Type(() => ClaimDto)
120-
// claims: ClaimDto[]
121115
@ApiProperty({
122-
description: 'Claims supported by this credential',
123-
type: 'object',
124-
additionalProperties: { $ref: getSchemaPath(ClaimDto) }
116+
description: 'List of claims supported in this credential',
117+
type: [ClaimDto]
125118
})
126-
@IsObject()
119+
@IsArray()
127120
@ValidateNested({ each: true })
128-
@Transform(({ value }) =>
129-
Object.fromEntries(Object.entries(value || {}).map(([k, v]) => [k, plainToInstance(ClaimDto, v)]))
130-
)
131-
claims: Record<string, ClaimDto>;
121+
@Type(() => ClaimDto)
122+
claims: ClaimDto[];
123+
// @ApiProperty({
124+
// description: 'Claims supported by this credential',
125+
// type: 'object',
126+
// additionalProperties: { $ref: getSchemaPath(ClaimDto) }
127+
// })
128+
// @IsObject()
129+
// @ValidateNested({ each: true })
130+
// @Transform(({ value }) =>
131+
// Object.fromEntries(Object.entries(value || {}).map(([k, v]) => [k, plainToInstance(ClaimDto, v)]))
132+
// )
133+
// claims: Record<string, ClaimDto>;
132134

133135
@ApiProperty({ type: [String] })
134136
@IsArray()
@@ -217,7 +219,7 @@ export enum AccessTokenSignerKeyType {
217219
ED25519 = 'ed25519'
218220
}
219221

220-
@ApiExtraModels(CredentialConfigurationDto)
222+
// @ApiExtraModels(CredentialConfigurationDto)
221223
export class IssuerCreationDto {
222224
@ApiProperty({
223225
description: 'Name of the issuer',

apps/oid4vc-issuance/interfaces/oid4vc-issuance.interfaces.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ export interface OrgAgent {
1818
}
1919

2020
export interface Claim {
21-
key: string;
22-
label: string;
23-
required: boolean;
21+
path: string[];
22+
label?: string;
23+
required?: boolean;
2424
}
2525

2626
export interface Logo {
@@ -40,7 +40,7 @@ export interface CredentialConfiguration {
4040
vct?: string;
4141
doctype?: string;
4242
scope: string;
43-
claims: Record<string, Claim>;
43+
claims: Claim[];
4444
credential_signing_alg_values_supported: string[];
4545
cryptographic_binding_methods_supported: string[];
4646
display: Display[];
@@ -61,7 +61,7 @@ export interface IssuerCreation {
6161
accessTokenSignerKeyType?: AccessTokenSignerKeyType;
6262
display: Display[];
6363
dpopSigningAlgValuesSupported?: string[];
64-
credentialConfigurationsSupported?: Record<string, CredentialConfiguration>;
64+
// credentialConfigurationsSupported?: Record<string, CredentialConfiguration>; // Not used
6565
authorizationServerConfigs: AuthorizationServerConfig;
6666
batchCredentialIssuanceSize: number;
6767
}

apps/oid4vc-issuance/libs/helpers/issuer.metadata.ts

Lines changed: 26 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,25 @@ type Appearance = {
2222
display: CredentialDisplayItem[];
2323
};
2424

25+
type Claim = {
26+
mandatory?: boolean;
27+
// value_type: string;
28+
path: string[];
29+
display?: AttributeDisplay[];
30+
};
31+
2532
type CredentialConfig = {
2633
format: string;
2734
vct?: string;
2835
scope: string;
2936
doctype?: string;
30-
claims: Record<
31-
string,
32-
{
33-
mandatory?: boolean;
34-
value_type: string;
35-
display?: AttributeDisplay[];
36-
}
37-
>;
37+
claims: Claim[];
3838
credential_signing_alg_values_supported: string[];
3939
cryptographic_binding_methods_supported: string[];
4040
display: { name: string; description?: string; locale?: string }[];
4141
};
4242

43-
type CredentialConfigurationsSupported = {
44-
credentialConfigurationsSupported: Record<string, CredentialConfig>;
45-
};
43+
type CredentialConfigurationsSupported = CredentialConfig[];
4644

4745
// ---- Static Lists (as requested) ----
4846
const STATIC_CREDENTIAL_ALGS = ['ES256', 'EdDSA'] as const;
@@ -101,8 +99,7 @@ export function buildCredentialConfigurationsSupported(
10199
}
102100
): CredentialConfigurationsSupported {
103101
const defaultFormat = opts?.format ?? 'vc+sd-jwt';
104-
const credentialConfigurationsSupported: Record<string, CredentialConfig> = {};
105-
102+
const credentialConfigurationsSupported: CredentialConfigurationsSupported = [];
106103
for (const t of templates) {
107104
const attrs = coerceJsonObject<unknown>(t.attributes);
108105
const app = coerceJsonObject<unknown>(t.appearance);
@@ -120,8 +117,8 @@ export function buildCredentialConfigurationsSupported(
120117
const isMdoc = 'mso_mdoc' === rowFormat;
121118
const suffix = isMdoc ? 'mdoc' : 'sdjwt';
122119

123-
// key (allow override)
124-
const key = 'function' === typeof opts?.keyResolver ? opts.keyResolver(t) : `${t.name}-${suffix}`;
120+
// key: keep your keyResolver override; otherwise include suffix
121+
// const key = 'function' === typeof opts?.keyResolver ? opts.keyResolver(t) : `${t.name}-${suffix}`;
125122

126123
// Resolve doctype/vct:
127124
// - For mdoc: try opts.doctype -> t.doctype -> fallback to t.name (or throw if you prefer)
@@ -143,20 +140,15 @@ export function buildCredentialConfigurationsSupported(
143140
// Choose scope base: prefer opts.scopeVct, otherwise for mdoc use doctype, else vct
144141
const scopeBase = opts?.scopeVct ?? (isMdoc ? rowDoctype : rowVct);
145142
const scope = `openid4vc:credential:${scopeBase}-${suffix}`;
146-
147-
const claims = Object.fromEntries(
148-
Object.entries(attrs).map(([claimName, def]) => {
149-
const d = def as AttributeDef;
150-
return [
151-
claimName,
152-
{
153-
value_type: d.value_type,
154-
mandatory: d.mandatory ?? false,
155-
display: Array.isArray(d.display) ? d.display.map((x) => ({ name: x.name, locale: x.locale })) : undefined
156-
}
157-
];
158-
})
159-
);
143+
const claims = Object.entries(attrs).map(([claimName, def]) => {
144+
const d = def as AttributeDef;
145+
return {
146+
path: [claimName],
147+
// value_type: d.value_type, // Didn't find this in draft 15
148+
mandatory: d.mandatory ?? false, // always include, default to false
149+
display: Array.isArray(d.display) ? d.display.map((x) => ({ name: x.name, locale: x.locale })) : undefined
150+
};
151+
});
160152

161153
const display =
162154
app.display?.map((d) => ({
@@ -165,18 +157,19 @@ export function buildCredentialConfigurationsSupported(
165157
locale: d.locale
166158
})) ?? [];
167159

168-
credentialConfigurationsSupported[key] = {
160+
// assemble per-template config
161+
credentialConfigurationsSupported.push({
169162
format: rowFormat,
170163
scope,
171164
claims,
172165
credential_signing_alg_values_supported: [...STATIC_CREDENTIAL_ALGS],
173166
cryptographic_binding_methods_supported: [...STATIC_BINDING_METHODS],
174167
display,
175168
...(isMdoc ? { doctype: rowDoctype as string } : { vct: rowVct })
176-
};
169+
});
177170
}
178171

179-
return { credentialConfigurationsSupported };
172+
return credentialConfigurationsSupported;
180173
}
181174

182175
// Default DPoP list for issuer-level metadata (match your example)
@@ -241,7 +234,7 @@ export function buildIssuerPayload(
241234
return {
242235
display,
243236
dpopSigningAlgValuesSupported: opts?.dpopAlgs ?? [...ISSUER_DPOP_ALGS_DEFAULT],
244-
credentialConfigurationsSupported: credentialConfigurations.credentialConfigurationsSupported ?? {},
237+
credentialConfigurationsSupported: credentialConfigurations ?? [],
245238
batchCredentialIssuance: {
246239
batchSize: oidcIssuer?.batchCredentialIssuanceSize ?? batchCredentialIssuanceDefault
247240
}

0 commit comments

Comments
 (0)