Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
9bce7f4
fix: update nest version and add them to catalog in pnpm
GHkrishna Sep 23, 2025
4138137
fix: nest version update changes for services
GHkrishna Sep 23, 2025
2448baa
fix: add remaining packages in catalog
GHkrishna Sep 23, 2025
130e252
fix: logging and unnecessary await
GHkrishna Sep 24, 2025
ca72d30
fix: inconsistent return type
GHkrishna Sep 24, 2025
62e850e
fix: remove toPromise in favour of firstValueFrom
GHkrishna Sep 24, 2025
b88926e
fix: toPromise to lastValuFrom
GHkrishna Sep 24, 2025
52f2d15
fix: update error message
GHkrishna Sep 24, 2025
cea5806
fix: update duplicate credDefData interface
GHkrishna Sep 24, 2025
5ddd324
fix: get all ledgers
GHkrishna Sep 24, 2025
26b5920
fix: throw error
GHkrishna Sep 24, 2025
32f5e3e
fix: proper use of params
GHkrishna Sep 24, 2025
8b5c3ce
fix: path excluded properly
GHkrishna Sep 24, 2025
378b562
fix: api-response code
GHkrishna Sep 25, 2025
aa5a0ce
fix: remove unwanted controllers, with no matching nats call available
GHkrishna Sep 25, 2025
45a68e6
fix: header setting for nats
GHkrishna Sep 25, 2025
546e746
fix: add missing roleguard
GHkrishna Sep 25, 2025
5290a2b
fix: return type is actually an object(including referenceId and the …
GHkrishna Sep 25, 2025
5c5b873
fix: update correct enum
GHkrishna Sep 25, 2025
2e48e6a
fix: min value for transformation
GHkrishna Sep 25, 2025
fae3f49
fix: parsing string as a boolean to handle boolean values correctly
GHkrishna Sep 25, 2025
a9a4902
fix: add required typing
GHkrishna Sep 25, 2025
17c9214
fix: error handling
GHkrishna Sep 25, 2025
e4215dc
fix: add dependency for loggerModule
GHkrishna Sep 25, 2025
f026820
fix: add typing and todo for the nested response issue
GHkrishna Sep 25, 2025
4be4bdb
fix: add roleguards where role level access is expected
GHkrishna Sep 25, 2025
645a0af
fix: interface type
GHkrishna Sep 25, 2025
eb9d7b7
fix: adding a todo for unsure changes regarding authguards in fido co…
GHkrishna Sep 25, 2025
f72cb89
fix: use params directly instead of through req object
GHkrishna Sep 25, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/agent-service/src/agent-service.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export class AgentServiceService {
private readonly prisma: PrismaService,
private readonly commonService: CommonService,
private readonly connectionService: ConnectionService,
@Inject('NATS_CLIENT') private readonly agentServiceProxy: ClientProxy,
@Inject('NATS_CLIENT') private readonly agentServiceProxy,
@Inject(CACHE_MANAGER) private cacheService: Cache,
private readonly userActivityRepository: UserActivityRepository,
private readonly natsClient: NATSClient
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ const seedLength = 32;
@Controller()
@ApiTags('agents')
@ApiBearerAuth()
@ApiUnauthorizedResponse({ status: HttpStatus.UNAUTHORIZED, description: 'Unauthorized', type: UnauthorizedErrorDto })
@ApiForbiddenResponse({ status: HttpStatus.FORBIDDEN, description: 'Forbidden', type: ForbiddenErrorDto })
@ApiUnauthorizedResponse({ description: 'Unauthorized', type: UnauthorizedErrorDto })
@ApiForbiddenResponse({ description: 'Forbidden', type: ForbiddenErrorDto })
export class AgentController {
constructor(private readonly agentService: AgentService) {}
private readonly logger = new Logger();
Expand Down
3 changes: 1 addition & 2 deletions apps/api-gateway/src/agent-service/agent-service.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Injectable, Inject } from '@nestjs/common';
import { ClientProxy } from '@nestjs/microservices';
import { user } from '@prisma/client';
import { BaseService } from 'libs/service/base.service';
import { AgentSpinupDto } from './dto/agent-service.dto';
Expand All @@ -14,7 +13,7 @@ import { NATSClient } from '@credebl/common/NATSClient';
@Injectable()
export class AgentService extends BaseService {
constructor(
@Inject('NATS_CLIENT') private readonly agentServiceProxy: ClientProxy,
@Inject('NATS_CLIENT') private readonly agentServiceProxy,
private readonly natsClient: NATSClient
) {
super('AgentService');
Expand Down
118 changes: 59 additions & 59 deletions apps/api-gateway/src/agent/agent.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,17 @@ import {
HttpStatus
} from '@nestjs/common';
import { AgentService } from './agent.service';
import { ApiTags, ApiResponse, ApiOperation, ApiQuery, ApiBearerAuth, ApiParam, ApiUnauthorizedResponse, ApiForbiddenResponse, ApiExcludeEndpoint } from '@nestjs/swagger';
import {
ApiTags,
ApiResponse,
ApiOperation,
ApiQuery,
ApiBearerAuth,
ApiParam,
ApiUnauthorizedResponse,
ApiForbiddenResponse,
ApiExcludeEndpoint
} from '@nestjs/swagger';
import { AuthGuard } from '@nestjs/passport';
import { WalletDetailsDto } from '../dtos/wallet-details.dto';
import { UnauthorizedErrorDto } from '../dtos/unauthorized-error.dto';
Expand All @@ -33,17 +43,19 @@ import { User } from '../authz/decorators/user.decorator';
@ApiBearerAuth()
@Controller('agent')
export class AgentController {
constructor(private readonly agentService: AgentService,
private readonly commonService: CommonService) { }
constructor(
private readonly agentService: AgentService,
private readonly commonService: CommonService
) {}

private readonly logger = new Logger();

/**
*
* @param user
* @param _public
* @param verkey
* @param did
*
* @param user
* @param _public
* @param verkey
* @param did
* @returns List of all the DID created for the current Cloud Agent.
*/
@Get('/wallet/did')
Expand All @@ -55,8 +67,8 @@ export class AgentController {
@ApiQuery({ name: 'did', required: false })
@ApiOperation({ summary: 'List of all DID', description: 'List of all the DID created for the current Cloud Agent.' })
@ApiResponse({ status: HttpStatus.OK, description: 'Success', type: ApiResponseDto })
@ApiUnauthorizedResponse({ status: HttpStatus.UNAUTHORIZED, description: 'Unauthorized', type: UnauthorizedErrorDto })
@ApiForbiddenResponse({ status: HttpStatus.FORBIDDEN, description: 'Forbidden', type: ForbiddenErrorDto })
@ApiUnauthorizedResponse({ description: 'Unauthorized', type: UnauthorizedErrorDto })
@ApiForbiddenResponse({ description: 'Forbidden', type: ForbiddenErrorDto })
getAllDid(
@User() user: any,
@Query('_public') _public: boolean,
Expand All @@ -68,8 +80,8 @@ export class AgentController {
}

/**
*
* @param user
*
* @param user
* @returns Created DID
*/
@Post('/wallet/did/create')
Expand All @@ -78,20 +90,18 @@ export class AgentController {
@SetMetadata('permissions', [CommonConstants.PERMISSION_ORG_MGMT])
@ApiOperation({ summary: 'Create a new DID', description: 'Create a new did for the current Cloud Agent wallet.' })
@ApiResponse({ status: HttpStatus.CREATED, description: 'Success', type: ApiResponseDto })
@ApiUnauthorizedResponse({ status: HttpStatus.UNAUTHORIZED, description: 'Unauthorized', type: UnauthorizedErrorDto })
@ApiForbiddenResponse({ status: HttpStatus.FORBIDDEN, description: 'Forbidden', type: ForbiddenErrorDto })
createLocalDid(
@User() user: any
): Promise<object> {
@ApiUnauthorizedResponse({ description: 'Unauthorized', type: UnauthorizedErrorDto })
@ApiForbiddenResponse({ description: 'Forbidden', type: ForbiddenErrorDto })
createLocalDid(@User() user: any): Promise<object> {
this.logger.log(`**** Create Local Did...`);
return this.agentService.createLocalDid(user);
}

/**
*
* @param walletUserDetails
* @param user
* @returns
*
* @param walletUserDetails
* @param user
* @returns
*/
@Post('/wallet/provision')
@ApiTags('agent')
Expand All @@ -102,20 +112,17 @@ export class AgentController {
description: 'Create a new wallet and spin up your Aries Cloud Agent Python by selecting your desired network.'
})
@ApiResponse({ status: HttpStatus.CREATED, description: 'Success', type: ApiResponseDto })
@ApiUnauthorizedResponse({ status: HttpStatus.UNAUTHORIZED, description: 'Unauthorized', type: UnauthorizedErrorDto })
@ApiForbiddenResponse({ status: HttpStatus.FORBIDDEN, description: 'Forbidden', type: ForbiddenErrorDto })
walletProvision(
@Body() walletUserDetails: WalletDetailsDto,
@User() user: object
): Promise<object> {
@ApiUnauthorizedResponse({ description: 'Unauthorized', type: UnauthorizedErrorDto })
@ApiForbiddenResponse({ description: 'Forbidden', type: ForbiddenErrorDto })
walletProvision(@Body() walletUserDetails: WalletDetailsDto, @User() user: object): Promise<object> {
this.logger.log(`**** Spin up the agent...${JSON.stringify(walletUserDetails)}`);

const regex = new RegExp('^[a-zA-Z0-9]+$');
if (!regex.test(walletUserDetails.walletName)) {
this.logger.error(`Wallet name in wrong format.`);
throw new BadRequestException(`Please enter valid wallet name, It allows only alphanumeric values`);
}
const decryptedPassword = this.commonService.decryptPassword(walletUserDetails.walletPassword);
const decryptedPassword = this.commonService.decryptPassword(walletUserDetails.walletPassword);
walletUserDetails.walletPassword = decryptedPassword;
return this.agentService.walletProvision(walletUserDetails, user);
}
Expand All @@ -129,31 +136,26 @@ export class AgentController {
@SetMetadata('permissions', [CommonConstants.PERMISSION_ORG_MGMT])
@ApiOperation({ summary: 'Fetch the current public DID', description: 'Fetch the current public DID.' })
@ApiResponse({ status: HttpStatus.OK, description: 'Success', type: ApiResponseDto })
@ApiUnauthorizedResponse({ status: HttpStatus.UNAUTHORIZED, description: 'Unauthorized', type: UnauthorizedErrorDto })
@ApiForbiddenResponse({ status: HttpStatus.FORBIDDEN, description: 'Forbidden', type: ForbiddenErrorDto })
getPublicDid(
@User() user: any
): Promise<object> {
@ApiUnauthorizedResponse({ description: 'Unauthorized', type: UnauthorizedErrorDto })
@ApiForbiddenResponse({ description: 'Forbidden', type: ForbiddenErrorDto })
getPublicDid(@User() user: any): Promise<object> {
this.logger.log(`**** Fetch public Did...`);
return this.agentService.getPublicDid(user);
}

/**
* Description: Route for assign public DID
* @param did
* @param did
*/
@Get('/wallet/did/public/:id')
@ApiTags('agent')
@UseGuards(AuthGuard('jwt'), RolesGuard)
@SetMetadata('permissions', [CommonConstants.PERMISSION_USER_MANAGEMENT])
@ApiOperation({ summary: 'Assign public DID', description: 'Assign public DID for the current use.' })
@ApiResponse({ status: HttpStatus.OK, description: 'Success', type: ApiResponseDto })
@ApiUnauthorizedResponse({ status: HttpStatus.UNAUTHORIZED, description: 'Unauthorized', type: UnauthorizedErrorDto })
@ApiForbiddenResponse({ status: HttpStatus.FORBIDDEN, description: 'Forbidden', type: ForbiddenErrorDto })
assignPublicDid(
@Param('id') id: number,
@User() user: any
): Promise<object> {
@ApiUnauthorizedResponse({ description: 'Unauthorized', type: UnauthorizedErrorDto })
@ApiForbiddenResponse({ description: 'Forbidden', type: ForbiddenErrorDto })
assignPublicDid(@Param('id') id: number, @User() user: any): Promise<object> {
this.logger.log(`**** Assign public DID...`);
this.logger.log(`user: ${user.orgId} == id: ${Number(id)}`);

Expand All @@ -165,26 +167,25 @@ export class AgentController {
}
}


/**
* Description: Route for onboarding register role on ledger
* @param role
* @param alias
* @param verkey
* @param did
* @param role
* @param alias
* @param verkey
* @param did
*/
@Get('/ledger/register-nym/:id')
@ApiTags('agent')
@UseGuards(AuthGuard('jwt'), RolesGuard)
@SetMetadata('permissions', [CommonConstants.PERMISSION_ORG_MGMT])
@ApiOperation({ summary: 'Send a NYM registration to the ledger', description: 'Write the DID to the ledger to make that DID public.' })
@ApiOperation({
summary: 'Send a NYM registration to the ledger',
description: 'Write the DID to the ledger to make that DID public.'
})
@ApiResponse({ status: HttpStatus.OK, description: 'Success', type: ApiResponseDto })
@ApiUnauthorizedResponse({ status: HttpStatus.UNAUTHORIZED, description: 'Unauthorized', type: UnauthorizedErrorDto })
@ApiForbiddenResponse({ status: HttpStatus.FORBIDDEN, description: 'Forbidden', type: ForbiddenErrorDto })
registerNym(
@Param('id') id: string,
@User() user: IUserRequestInterface
): Promise<object> {
@ApiUnauthorizedResponse({ description: 'Unauthorized', type: UnauthorizedErrorDto })
@ApiForbiddenResponse({ description: 'Forbidden', type: ForbiddenErrorDto })
registerNym(@Param('id') id: string, @User() user: IUserRequestInterface): Promise<object> {
this.logger.log(`user: ${typeof user.orgId} == id: ${typeof Number(id)}`);

if (user.orgId !== id) {
Expand All @@ -204,8 +205,8 @@ export class AgentController {
description: 'Platform Admin can restart or stop the running Aries Agent. (Platform Admin)'
})
@ApiResponse({ status: HttpStatus.OK, description: 'Success', type: ApiResponseDto })
@ApiUnauthorizedResponse({ status: HttpStatus.UNAUTHORIZED, description: 'Unauthorized', type: UnauthorizedErrorDto })
@ApiForbiddenResponse({ status: HttpStatus.FORBIDDEN, description: 'Forbidden', type: ForbiddenErrorDto })
@ApiUnauthorizedResponse({ description: 'Unauthorized', type: UnauthorizedErrorDto })
@ApiForbiddenResponse({ description: 'Forbidden', type: ForbiddenErrorDto })
@ApiParam({ name: 'action', enum: AgentActions })
restartStopAgent(@Param('orgId') orgId: string, @Param('action') action: string): Promise<object> {
return this.agentService.restartStopAgent(action, orgId);
Expand All @@ -220,8 +221,8 @@ export class AgentController {
description: 'Fetch the status of the Aries Cloud Agent.'
})
@ApiResponse({ status: HttpStatus.OK, description: 'Success', type: ApiResponseDto })
@ApiUnauthorizedResponse({ status: HttpStatus.UNAUTHORIZED, description: 'Unauthorized', type: UnauthorizedErrorDto })
@ApiForbiddenResponse({ status: HttpStatus.FORBIDDEN, description: 'Forbidden', type: ForbiddenErrorDto })
@ApiUnauthorizedResponse({ description: 'Unauthorized', type: UnauthorizedErrorDto })
@ApiForbiddenResponse({ description: 'Forbidden', type: ForbiddenErrorDto })
getAgentServerStatus(@User() user: any): Promise<object> {
this.logger.log(`**** getPlatformConfig called...`);
return this.agentService.getAgentServerStatus(user);
Expand Down Expand Up @@ -249,8 +250,8 @@ export class AgentController {
description: 'List of all created Aries Cloud Agent status.'
})
@ApiResponse({ status: HttpStatus.OK, description: 'Success', type: ApiResponseDto })
@ApiUnauthorizedResponse({ status: HttpStatus.UNAUTHORIZED, description: 'Unauthorized', type: UnauthorizedErrorDto })
@ApiForbiddenResponse({ status: HttpStatus.FORBIDDEN, description: 'Forbidden', type: ForbiddenErrorDto })
@ApiUnauthorizedResponse({ description: 'Unauthorized', type: UnauthorizedErrorDto })
@ApiForbiddenResponse({ description: 'Forbidden', type: ForbiddenErrorDto })
@ApiQuery({ name: 'items_per_page', required: false })
@ApiQuery({ name: 'page', required: false })
@ApiQuery({ name: 'search_text', required: false })
Expand All @@ -265,7 +266,6 @@ export class AgentController {
@Query('status') status: any,
@User() user: any
): Promise<object> {

this.logger.log(`status: ${typeof status} ${status}`);

items_per_page = items_per_page || 10;
Expand Down
Loading