Skip to content

Commit 45d433c

Browse files
committed
fix: add examples (#1282)
Signed-off-by: Krishna Waske <[email protected]>
1 parent 33bd455 commit 45d433c

File tree

3 files changed

+110
-28
lines changed

3 files changed

+110
-28
lines changed

apps/api-gateway/src/agent-service/agent-service.controller.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import {
2222
ApiOperation,
2323
ApiForbiddenResponse,
2424
ApiBody,
25-
ApiParam,
2625
ApiBearerAuth,
2726
ApiUnauthorizedResponse
2827
} from '@nestjs/swagger';
@@ -32,7 +31,7 @@ import { ForbiddenErrorDto } from '../dtos/forbidden-error.dto';
3231
import { ResponseMessages } from '@credebl/common/response-messages';
3332
import { AgentService } from './agent-service.service';
3433
import IResponseType, { IResponse } from '@credebl/common/interfaces/response.interface';
35-
import { AgentSpinupDto, SignDataDto } from './dto/agent-service.dto';
34+
import { AgentSpinupDto, SignDataDto, VerifySignatureDto } from './dto/agent-service.dto';
3635
import { Response } from 'express';
3736
// eslint-disable-next-line @typescript-eslint/no-unused-vars
3837
import { user } from '@prisma/client';
@@ -48,6 +47,7 @@ import { CreateNewDidDto } from './dto/create-new-did.dto';
4847
import { AgentSpinupValidator, TrimStringParamPipe } from '@credebl/common/cast.helper';
4948
import { AgentConfigureDto } from './dto/agent-configure.dto';
5049
import { UnauthorizedErrorDto } from '../dtos/unauthorized-error.dto';
50+
import { IVerifySignature } from './interface/agent-service.interface';
5151

5252
const seedLength = 32;
5353

@@ -143,14 +143,8 @@ export class AgentController {
143143
*/
144144
@ApiBody({
145145
description:
146-
'Enter the data you would like to verify the signature for. It can be of type w3c jsonld credential or any type that needs to be verified'
147-
})
148-
@ApiParam({
149-
name: 'dataType',
150-
type: String,
151-
required: false,
152-
description:
153-
'dataType of the data you are sverifying the signature. It can be a credential or a random object of any data type. For credentials, currently only w3c-jsonld credentials are supported to be verified'
146+
'Enter the data you would like to verify the signature for. It can be of type w3c jsonld credential or any type that needs to be verified',
147+
type: VerifySignatureDto
154148
})
155149
@Post('/orgs/:orgId/agents/verify-signature')
156150
@ApiOperation({
@@ -169,8 +163,7 @@ export class AgentController {
169163
)
170164
async verifysignature(
171165
@Param('orgId') orgId: string,
172-
@Body() data: unknown,
173-
@Param('dataType') dataType: string,
166+
@Body() data: IVerifySignature,
174167
@Res() res: Response
175168
): Promise<Response> {
176169
const agentData = await this.agentService.verifysignature(data, orgId);

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

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,3 +213,87 @@ export class SignDataDto {
213213
@Type(() => SignRawDataDto)
214214
rawPayload?: SignRawDataDto;
215215
}
216+
217+
export class VerifySignatureDto {
218+
@ApiProperty({
219+
description: 'This is the signed w3c-jsonLd credential, which we want to verify',
220+
example: {
221+
id: 'http://example.com/credential/9290ae08-8959-4723-a26a-921aab97de6e',
222+
name: 'Teamwork v2',
223+
type: ['VerifiableCredential', 'OpenBadgeCredential'],
224+
image: {
225+
id: 'https://example.com/BadgeDesigns/a99a4121-e04e-477c-a890-15e9af789f73/1c61a4b2-dca4-4684-8f63-221333fd5c86-Teamwork%20v2.png',
226+
type: 'Image'
227+
},
228+
proof: {
229+
jws: 'eyJhbGciOiJFZERTQSIsImI2NCI6ZmFsc2UsImNyaXQiOlsiYjY0Il19..PN0gqrfiMhO_2AIT9i3Tv1Qt9Owlh5ZBPnplCrta49-6oyEpHg4aQwjGADe-B2RADb_cvdgVqTJe1G-ds9UYDg',
230+
type: 'Ed25519Signature2018',
231+
created: '2025-06-13T13:47:35Z',
232+
proofPurpose: 'assertionMethod',
233+
verificationMethod:
234+
'did:key:z6MkwSMgqptU9M5AiymSSXv3HLhEhXfE6RonJwMSG2dmURdE#z6MkwSMgqptU9M5AiymSSXv3HLhEhXfE6RonJwMSG2dmURdE'
235+
},
236+
issuer: {
237+
id: 'did:key:z6MkwSMgqptU9M5AiymSSXv3HLhEhXfE6RonJwMSG2dmURdE'
238+
},
239+
'@context': [
240+
'https://www.w3.org/2018/credentials/v1',
241+
'https://w3id.org/security/data-integrity/v2',
242+
'https://purl.imsglobal.org/spec/ob/v3p0/context-3.0.3.json'
243+
],
244+
validFrom: '2025-06-13T13:47:35.201Z',
245+
awardedDate: '2025-06-12T18:30:00.000Z',
246+
description:
247+
'EricTech is a cutting-edge product innovation company specialising in Web 3.0 development with extensive expertise in modern technologies. Our unique approach to product invention involves a comprehensive process, starting from the discovery phase and progressing through planning, research, development, marketing, and launch, all tailored to assist businesses in achieving their goals.',
248+
issuanceDate: '2025-06-13T13:47:35.201Z',
249+
expirationDate: '2026-12-30T18:30:00.000Z',
250+
credentialStatus: {
251+
id: 'http://example.com/revocation/addfc5a0-258f-4977-a138-f0d9f33d6dc6',
252+
type: '1EdTechRevocationList'
253+
},
254+
credentialSubject: {
255+
type: ['AchievementSubject'],
256+
identifier: [
257+
{
258+
type: 'IdentityObject',
259+
hashed: 'FALSE',
260+
identityHash: '[email protected]',
261+
identityType: 'emailAddress'
262+
}
263+
],
264+
achievement: {
265+
id: 'ds',
266+
Tag: ['fghfgh', 'fhfgh'],
267+
Type: ['Achievement'],
268+
name: 'sddgh',
269+
image: {
270+
id: 'sdsd',
271+
type: 'sdd'
272+
},
273+
version: '2',
274+
criteria: {
275+
narrative: 'sdd'
276+
},
277+
humanCode: 'sd',
278+
description: 'sdd',
279+
fieldOfStudy: 'sdsd',
280+
specialization: 'fghfg',
281+
achievementType: 'LearningProgram',
282+
otherIdentifier: [
283+
{
284+
type: 'fhgf',
285+
identifier: 'fghfgh',
286+
identifierType: 'fghfgh'
287+
}
288+
]
289+
}
290+
}
291+
}
292+
})
293+
credential: unknown;
294+
295+
@ApiPropertyOptional({ default: false })
296+
@IsOptional()
297+
@IsBoolean()
298+
verifyCredentialStatus?: boolean;
299+
}
Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,31 @@
11
export interface AgentSpinUpSatus {
2-
agentSpinupStatus: number;
2+
agentSpinupStatus: number;
33
}
44
export interface AgentStatus {
5-
label: string;
6-
endpoints: string[];
7-
isInitialized: boolean;
5+
label: string;
6+
endpoints: string[];
7+
isInitialized: boolean;
88
}
99
interface IWalletConfig {
10-
id: string;
11-
key: string;
12-
keyDerivationMethod: string;
10+
id: string;
11+
key: string;
12+
keyDerivationMethod: string;
1313
}
1414

1515
interface IConfig {
16-
label: string;
17-
walletConfig: IWalletConfig;
16+
label: string;
17+
walletConfig: IWalletConfig;
1818
}
1919
export interface IWalletRecord {
20-
_tags: string;
21-
metadata: string;
22-
id: string;
23-
createdAt: string;
24-
config: IConfig;
25-
updatedAt: string;
26-
}
20+
_tags: string;
21+
metadata: string;
22+
id: string;
23+
createdAt: string;
24+
config: IConfig;
25+
updatedAt: string;
26+
}
27+
28+
export interface IVerifySignature {
29+
credential: unknown;
30+
verifyCredentialStatus?: boolean;
31+
}

0 commit comments

Comments
 (0)