Skip to content

Commit 2900d93

Browse files
GHkrishnaankita-p17
authored andcommitted
fix: nestjs version update (#1459)
* fix: update nest version and add them to catalog in pnpm Signed-off-by: Krishna Waske <[email protected]> * fix: nest version update changes for services Signed-off-by: Krishna Waske <[email protected]> * fix: add remaining packages in catalog Signed-off-by: Krishna Waske <[email protected]> * fix: logging and unnecessary await Signed-off-by: Krishna Waske <[email protected]> * fix: inconsistent return type Signed-off-by: Krishna Waske <[email protected]> * fix: remove toPromise in favour of firstValueFrom Signed-off-by: Krishna Waske <[email protected]> * fix: toPromise to lastValuFrom Signed-off-by: Krishna Waske <[email protected]> * fix: update error message Signed-off-by: Krishna Waske <[email protected]> * fix: update duplicate credDefData interface Signed-off-by: Krishna Waske <[email protected]> * fix: get all ledgers Signed-off-by: Krishna Waske <[email protected]> * fix: throw error Signed-off-by: Krishna Waske <[email protected]> * fix: proper use of params Signed-off-by: Krishna Waske <[email protected]> * fix: path excluded properly Signed-off-by: Krishna Waske <[email protected]> * fix: api-response code Signed-off-by: Krishna Waske <[email protected]> * fix: remove unwanted controllers, with no matching nats call available Signed-off-by: Krishna Waske <[email protected]> * fix: header setting for nats Signed-off-by: Krishna Waske <[email protected]> * fix: add missing roleguard Signed-off-by: Krishna Waske <[email protected]> * fix: return type is actually an object(including referenceId and the url) instead of a string(url) Signed-off-by: Krishna Waske <[email protected]> * fix: update correct enum Signed-off-by: Krishna Waske <[email protected]> * fix: min value for transformation Signed-off-by: Krishna Waske <[email protected]> * fix: parsing string as a boolean to handle boolean values correctly Signed-off-by: Krishna Waske <[email protected]> * fix: add required typing Signed-off-by: Krishna Waske <[email protected]> * fix: error handling Signed-off-by: Krishna Waske <[email protected]> * fix: add dependency for loggerModule Signed-off-by: Krishna Waske <[email protected]> * fix: add typing and todo for the nested response issue Signed-off-by: Krishna Waske <[email protected]> * fix: add roleguards where role level access is expected Signed-off-by: Krishna Waske <[email protected]> * fix: interface type Signed-off-by: Krishna Waske <[email protected]> * fix: adding a todo for unsure changes regarding authguards in fido controller Signed-off-by: Krishna Waske <[email protected]> * fix: use params directly instead of through req object Signed-off-by: Krishna Waske <[email protected]> --------- Signed-off-by: Krishna Waske <[email protected]>
1 parent 6f0f282 commit 2900d93

File tree

55 files changed

+4441
-3515
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+4441
-3515
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ const seedLength = 32;
5555
@Controller()
5656
@ApiTags('agents')
5757
@ApiBearerAuth()
58-
@ApiUnauthorizedResponse({ status: HttpStatus.UNAUTHORIZED, description: 'Unauthorized', type: UnauthorizedErrorDto })
59-
@ApiForbiddenResponse({ status: HttpStatus.FORBIDDEN, description: 'Forbidden', type: ForbiddenErrorDto })
58+
@ApiUnauthorizedResponse({ description: 'Unauthorized', type: UnauthorizedErrorDto })
59+
@ApiForbiddenResponse({ description: 'Forbidden', type: ForbiddenErrorDto })
6060
export class AgentController {
6161
constructor(private readonly agentService: AgentService) {}
6262
private readonly logger = new Logger();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { Injectable, Inject } from '@nestjs/common';
2-
import { ClientProxy } from '@nestjs/microservices';
32
import { user } from '@prisma/client';
43
import { BaseService } from 'libs/service/base.service';
54
import { AgentSpinupDto } from './dto/agent-service.dto';
@@ -10,6 +9,7 @@ import { CreateDidDto } from './dto/create-did.dto';
109
import { CreateWalletDto } from './dto/create-wallet.dto';
1110
import { AgentConfigureDto } from './dto/agent-configure.dto';
1211
import { NATSClient } from '@credebl/common/NATSClient';
12+
import { ClientProxy } from '@nestjs/microservices';
1313

1414
@Injectable()
1515
export class AgentService extends BaseService {

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

Lines changed: 52 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,17 @@ import {
1616
HttpStatus
1717
} from '@nestjs/common';
1818
import { AgentService } from './agent.service';
19-
import { ApiTags, ApiResponse, ApiOperation, ApiQuery, ApiBearerAuth, ApiParam, ApiUnauthorizedResponse, ApiForbiddenResponse, ApiExcludeEndpoint } from '@nestjs/swagger';
19+
import {
20+
ApiTags,
21+
ApiResponse,
22+
ApiOperation,
23+
ApiQuery,
24+
ApiBearerAuth,
25+
ApiParam,
26+
ApiUnauthorizedResponse,
27+
ApiForbiddenResponse,
28+
ApiExcludeEndpoint
29+
} from '@nestjs/swagger';
2030
import { AuthGuard } from '@nestjs/passport';
2131
import { WalletDetailsDto } from '../dtos/wallet-details.dto';
2232
import { UnauthorizedErrorDto } from '../dtos/unauthorized-error.dto';
@@ -33,17 +43,19 @@ import { User } from '../authz/decorators/user.decorator';
3343
@ApiBearerAuth()
3444
@Controller('agent')
3545
export class AgentController {
36-
constructor(private readonly agentService: AgentService,
37-
private readonly commonService: CommonService) { }
46+
constructor(
47+
private readonly agentService: AgentService,
48+
private readonly commonService: CommonService
49+
) {}
3850

3951
private readonly logger = new Logger();
4052

4153
/**
42-
*
43-
* @param user
44-
* @param _public
45-
* @param verkey
46-
* @param did
54+
*
55+
* @param user
56+
* @param _public
57+
* @param verkey
58+
* @param did
4759
* @returns List of all the DID created for the current Cloud Agent.
4860
*/
4961
@Get('/wallet/did')
@@ -55,8 +67,8 @@ export class AgentController {
5567
@ApiQuery({ name: 'did', required: false })
5668
@ApiOperation({ summary: 'List of all DID', description: 'List of all the DID created for the current Cloud Agent.' })
5769
@ApiResponse({ status: HttpStatus.OK, description: 'Success', type: ApiResponseDto })
58-
@ApiUnauthorizedResponse({ status: HttpStatus.UNAUTHORIZED, description: 'Unauthorized', type: UnauthorizedErrorDto })
59-
@ApiForbiddenResponse({ status: HttpStatus.FORBIDDEN, description: 'Forbidden', type: ForbiddenErrorDto })
70+
@ApiUnauthorizedResponse({ description: 'Unauthorized', type: UnauthorizedErrorDto })
71+
@ApiForbiddenResponse({ description: 'Forbidden', type: ForbiddenErrorDto })
6072
getAllDid(
6173
@User() user: any,
6274
@Query('_public') _public: boolean,
@@ -68,8 +80,8 @@ export class AgentController {
6880
}
6981

7082
/**
71-
*
72-
* @param user
83+
*
84+
* @param user
7385
* @returns Created DID
7486
*/
7587
@Post('/wallet/did/create')
@@ -78,20 +90,18 @@ export class AgentController {
7890
@SetMetadata('permissions', [CommonConstants.PERMISSION_ORG_MGMT])
7991
@ApiOperation({ summary: 'Create a new DID', description: 'Create a new did for the current Cloud Agent wallet.' })
8092
@ApiResponse({ status: HttpStatus.CREATED, description: 'Success', type: ApiResponseDto })
81-
@ApiUnauthorizedResponse({ status: HttpStatus.UNAUTHORIZED, description: 'Unauthorized', type: UnauthorizedErrorDto })
82-
@ApiForbiddenResponse({ status: HttpStatus.FORBIDDEN, description: 'Forbidden', type: ForbiddenErrorDto })
83-
createLocalDid(
84-
@User() user: any
85-
): Promise<object> {
93+
@ApiUnauthorizedResponse({ description: 'Unauthorized', type: UnauthorizedErrorDto })
94+
@ApiForbiddenResponse({ description: 'Forbidden', type: ForbiddenErrorDto })
95+
createLocalDid(@User() user: any): Promise<object> {
8696
this.logger.log(`**** Create Local Did...`);
8797
return this.agentService.createLocalDid(user);
8898
}
8999

90100
/**
91-
*
92-
* @param walletUserDetails
93-
* @param user
94-
* @returns
101+
*
102+
* @param walletUserDetails
103+
* @param user
104+
* @returns
95105
*/
96106
@Post('/wallet/provision')
97107
@ApiTags('agent')
@@ -102,89 +112,40 @@ export class AgentController {
102112
description: 'Create a new wallet and spin up your Aries Cloud Agent Python by selecting your desired network.'
103113
})
104114
@ApiResponse({ status: HttpStatus.CREATED, description: 'Success', type: ApiResponseDto })
105-
@ApiUnauthorizedResponse({ status: HttpStatus.UNAUTHORIZED, description: 'Unauthorized', type: UnauthorizedErrorDto })
106-
@ApiForbiddenResponse({ status: HttpStatus.FORBIDDEN, description: 'Forbidden', type: ForbiddenErrorDto })
107-
walletProvision(
108-
@Body() walletUserDetails: WalletDetailsDto,
109-
@User() user: object
110-
): Promise<object> {
115+
@ApiUnauthorizedResponse({ description: 'Unauthorized', type: UnauthorizedErrorDto })
116+
@ApiForbiddenResponse({ description: 'Forbidden', type: ForbiddenErrorDto })
117+
walletProvision(@Body() walletUserDetails: WalletDetailsDto, @User() user: object): Promise<object> {
111118
this.logger.log(`**** Spin up the agent...${JSON.stringify(walletUserDetails)}`);
112119

113120
const regex = new RegExp('^[a-zA-Z0-9]+$');
114121
if (!regex.test(walletUserDetails.walletName)) {
115122
this.logger.error(`Wallet name in wrong format.`);
116123
throw new BadRequestException(`Please enter valid wallet name, It allows only alphanumeric values`);
117124
}
118-
const decryptedPassword = this.commonService.decryptPassword(walletUserDetails.walletPassword);
125+
const decryptedPassword = this.commonService.decryptPassword(walletUserDetails.walletPassword);
119126
walletUserDetails.walletPassword = decryptedPassword;
120127
return this.agentService.walletProvision(walletUserDetails, user);
121128
}
122129

123-
/**
124-
* Description: Route for fetch public DID
125-
*/
126-
@Get('/wallet/did/public')
127-
@ApiTags('agent')
128-
@UseGuards(AuthGuard('jwt'), RolesGuard)
129-
@SetMetadata('permissions', [CommonConstants.PERMISSION_ORG_MGMT])
130-
@ApiOperation({ summary: 'Fetch the current public DID', description: 'Fetch the current public DID.' })
131-
@ApiResponse({ status: HttpStatus.OK, description: 'Success', type: ApiResponseDto })
132-
@ApiUnauthorizedResponse({ status: HttpStatus.UNAUTHORIZED, description: 'Unauthorized', type: UnauthorizedErrorDto })
133-
@ApiForbiddenResponse({ status: HttpStatus.FORBIDDEN, description: 'Forbidden', type: ForbiddenErrorDto })
134-
getPublicDid(
135-
@User() user: any
136-
): Promise<object> {
137-
this.logger.log(`**** Fetch public Did...`);
138-
return this.agentService.getPublicDid(user);
139-
}
140-
141-
/**
142-
* Description: Route for assign public DID
143-
* @param did
144-
*/
145-
@Get('/wallet/did/public/:id')
146-
@ApiTags('agent')
147-
@UseGuards(AuthGuard('jwt'), RolesGuard)
148-
@SetMetadata('permissions', [CommonConstants.PERMISSION_USER_MANAGEMENT])
149-
@ApiOperation({ summary: 'Assign public DID', description: 'Assign public DID for the current use.' })
150-
@ApiResponse({ status: HttpStatus.OK, description: 'Success', type: ApiResponseDto })
151-
@ApiUnauthorizedResponse({ status: HttpStatus.UNAUTHORIZED, description: 'Unauthorized', type: UnauthorizedErrorDto })
152-
@ApiForbiddenResponse({ status: HttpStatus.FORBIDDEN, description: 'Forbidden', type: ForbiddenErrorDto })
153-
assignPublicDid(
154-
@Param('id') id: number,
155-
@User() user: any
156-
): Promise<object> {
157-
this.logger.log(`**** Assign public DID...`);
158-
this.logger.log(`user: ${user.orgId} == id: ${Number(id)}`);
159-
160-
if (user.orgId === Number(id)) {
161-
return this.agentService.assignPublicDid(id, user);
162-
} else {
163-
this.logger.error(`Cannot make DID public of requested organization.`);
164-
throw new BadRequestException(`Cannot make DID public requested organization.`);
165-
}
166-
}
167-
168-
169130
/**
170131
* Description: Route for onboarding register role on ledger
171-
* @param role
172-
* @param alias
173-
* @param verkey
174-
* @param did
132+
* @param role
133+
* @param alias
134+
* @param verkey
135+
* @param did
175136
*/
176137
@Get('/ledger/register-nym/:id')
177138
@ApiTags('agent')
178139
@UseGuards(AuthGuard('jwt'), RolesGuard)
179140
@SetMetadata('permissions', [CommonConstants.PERMISSION_ORG_MGMT])
180-
@ApiOperation({ summary: 'Send a NYM registration to the ledger', description: 'Write the DID to the ledger to make that DID public.' })
141+
@ApiOperation({
142+
summary: 'Send a NYM registration to the ledger',
143+
description: 'Write the DID to the ledger to make that DID public.'
144+
})
181145
@ApiResponse({ status: HttpStatus.OK, description: 'Success', type: ApiResponseDto })
182-
@ApiUnauthorizedResponse({ status: HttpStatus.UNAUTHORIZED, description: 'Unauthorized', type: UnauthorizedErrorDto })
183-
@ApiForbiddenResponse({ status: HttpStatus.FORBIDDEN, description: 'Forbidden', type: ForbiddenErrorDto })
184-
registerNym(
185-
@Param('id') id: string,
186-
@User() user: IUserRequestInterface
187-
): Promise<object> {
146+
@ApiUnauthorizedResponse({ description: 'Unauthorized', type: UnauthorizedErrorDto })
147+
@ApiForbiddenResponse({ description: 'Forbidden', type: ForbiddenErrorDto })
148+
registerNym(@Param('id') id: string, @User() user: IUserRequestInterface): Promise<object> {
188149
this.logger.log(`user: ${typeof user.orgId} == id: ${typeof Number(id)}`);
189150

190151
if (user.orgId !== id) {
@@ -204,8 +165,8 @@ export class AgentController {
204165
description: 'Platform Admin can restart or stop the running Aries Agent. (Platform Admin)'
205166
})
206167
@ApiResponse({ status: HttpStatus.OK, description: 'Success', type: ApiResponseDto })
207-
@ApiUnauthorizedResponse({ status: HttpStatus.UNAUTHORIZED, description: 'Unauthorized', type: UnauthorizedErrorDto })
208-
@ApiForbiddenResponse({ status: HttpStatus.FORBIDDEN, description: 'Forbidden', type: ForbiddenErrorDto })
168+
@ApiUnauthorizedResponse({ description: 'Unauthorized', type: UnauthorizedErrorDto })
169+
@ApiForbiddenResponse({ description: 'Forbidden', type: ForbiddenErrorDto })
209170
@ApiParam({ name: 'action', enum: AgentActions })
210171
restartStopAgent(@Param('orgId') orgId: string, @Param('action') action: string): Promise<object> {
211172
return this.agentService.restartStopAgent(action, orgId);
@@ -220,8 +181,8 @@ export class AgentController {
220181
description: 'Fetch the status of the Aries Cloud Agent.'
221182
})
222183
@ApiResponse({ status: HttpStatus.OK, description: 'Success', type: ApiResponseDto })
223-
@ApiUnauthorizedResponse({ status: HttpStatus.UNAUTHORIZED, description: 'Unauthorized', type: UnauthorizedErrorDto })
224-
@ApiForbiddenResponse({ status: HttpStatus.FORBIDDEN, description: 'Forbidden', type: ForbiddenErrorDto })
184+
@ApiUnauthorizedResponse({ description: 'Unauthorized', type: UnauthorizedErrorDto })
185+
@ApiForbiddenResponse({ description: 'Forbidden', type: ForbiddenErrorDto })
225186
getAgentServerStatus(@User() user: any): Promise<object> {
226187
this.logger.log(`**** getPlatformConfig called...`);
227188
return this.agentService.getAgentServerStatus(user);
@@ -249,8 +210,8 @@ export class AgentController {
249210
description: 'List of all created Aries Cloud Agent status.'
250211
})
251212
@ApiResponse({ status: HttpStatus.OK, description: 'Success', type: ApiResponseDto })
252-
@ApiUnauthorizedResponse({ status: HttpStatus.UNAUTHORIZED, description: 'Unauthorized', type: UnauthorizedErrorDto })
253-
@ApiForbiddenResponse({ status: HttpStatus.FORBIDDEN, description: 'Forbidden', type: ForbiddenErrorDto })
213+
@ApiUnauthorizedResponse({ description: 'Unauthorized', type: UnauthorizedErrorDto })
214+
@ApiForbiddenResponse({ description: 'Forbidden', type: ForbiddenErrorDto })
254215
@ApiQuery({ name: 'items_per_page', required: false })
255216
@ApiQuery({ name: 'page', required: false })
256217
@ApiQuery({ name: 'search_text', required: false })
@@ -265,7 +226,6 @@ export class AgentController {
265226
@Query('status') status: any,
266227
@User() user: any
267228
): Promise<object> {
268-
269229
this.logger.log(`status: ${typeof status} ${status}`);
270230

271231
items_per_page = items_per_page || 10;

0 commit comments

Comments
 (0)