diff --git a/apps/proof-manager/src/app.module.spec.ts b/apps/proof-manager/src/app.module.spec.ts index 0bc3690cabeeee28112a26db03e48e2bd6fdd920..e5e685cb147cd6c916d4e4e80feb77c92880f436 100644 --- a/apps/proof-manager/src/app.module.spec.ts +++ b/apps/proof-manager/src/app.module.spec.ts @@ -1,5 +1,8 @@ -import { INestApplication } from '@nestjs/common'; -import { Test, TestingModule } from '@nestjs/testing'; +import type { INestApplication } from '@nestjs/common'; +import type { TestingModule } from '@nestjs/testing'; + +import { Test } from '@nestjs/testing'; + import AppModule from './app.module.js'; describe('App Module', () => { diff --git a/apps/proof-manager/src/app.module.ts b/apps/proof-manager/src/app.module.ts index ca775837ea0a829af11ca9d3431c272515ef0a74..100d223cdf6018077037000efcf36211bd2781e7 100644 --- a/apps/proof-manager/src/app.module.ts +++ b/apps/proof-manager/src/app.module.ts @@ -1,12 +1,10 @@ -import { - MiddlewareConsumer, - Module, - NestModule, - RequestMethod, -} from '@nestjs/common'; +import type { MiddlewareConsumer, NestModule } from '@nestjs/common'; + +import { Module, RequestMethod } from '@nestjs/common'; import { ConfigModule } from '@nestjs/config'; import { APP_FILTER } from '@nestjs/core'; import { TerminusModule } from '@nestjs/terminus'; + import ExceptionHandler from './common/exception.handler.js'; import config from './config/config.js'; import validationSchema from './config/validation.js'; @@ -33,8 +31,7 @@ import PresentationProofsModule from './presentationProof/module.js'; ], }) export default class AppModule implements NestModule { - // eslint-disable-next-line class-methods-use-this - configure(consumer: MiddlewareConsumer) { + public configure(consumer: MiddlewareConsumer) { // eslint-disable-line consumer .apply(AuthMiddleware) diff --git a/apps/proof-manager/src/client/nats.client.ts b/apps/proof-manager/src/client/nats.client.ts index 7b1dc5a517f7b4596c58756e602c813a44b5a4c8..223860ddc3ea654e823d122d8e313d655c37cb5c 100644 --- a/apps/proof-manager/src/client/nats.client.ts +++ b/apps/proof-manager/src/client/nats.client.ts @@ -1,14 +1,18 @@ +import type PresentationSubscriptionEndpointDto from '../presentationProof/entities/presentationSubscribeEndPoint.entity.js'; + import { Inject, Injectable } from '@nestjs/common'; import { ClientProxy } from '@nestjs/microservices'; import { lastValueFrom } from 'rxjs'; + import { ATTESTATION, Connection, NATSServices } from '../common/constants.js'; -import PresentationSubscriptionEndpointDto from '../presentationProof/entities/presentationSubscribeEndPoint.entity.js'; @Injectable() export default class NatsClientService { - constructor(@Inject(NATSServices.SERVICE_NAME) private client: ClientProxy) {} + public constructor( + @Inject(NATSServices.SERVICE_NAME) private client: ClientProxy, + ) {} - getConnectionById(connectionId: string) { + public getConnectionById(connectionId: string) { const pattern = { endpoint: `${Connection.NATS_ENDPOINT}/${Connection.GET_CONNECTION_By_ID}`, }; @@ -16,14 +20,14 @@ export default class NatsClientService { return lastValueFrom(this.client.send(pattern, payload)); } - publishPresentation(data: PresentationSubscriptionEndpointDto) { + public publishPresentation(data: PresentationSubscriptionEndpointDto) { this.client.emit( `${NATSServices.SERVICE_NAME}/${NATSServices.PRESENTATION_SUBSCRIBER_ENDPOINT}`, data, ); } - getCredentialsTypeDetails(type: string) { + public getCredentialsTypeDetails(type: string) { const pattern = { endpoint: `${ATTESTATION.ATTESTATION_MANAGER_SERVICE}/${ATTESTATION.GET_MEMBERSHIP_CREDENTIALS_DETAILS}`, }; @@ -31,7 +35,7 @@ export default class NatsClientService { return lastValueFrom(this.client.send(pattern, payload)); } - makeConnectionTrusted(connectionId: string) { + public makeConnectionTrusted(connectionId: string) { const pattern = { endpoint: `${Connection.NATS_ENDPOINT}/${Connection.MAKE_CONNECTION_TRUSTED}`, }; diff --git a/apps/proof-manager/src/client/rest.client.ts b/apps/proof-manager/src/client/rest.client.ts index 51ee54a65b7a27f4c80b5a422ee3e37fb51a0cda..42d0fca0e2e5d415537e09991b12a80832e3f6c0 100644 --- a/apps/proof-manager/src/client/rest.client.ts +++ b/apps/proof-manager/src/client/rest.client.ts @@ -4,9 +4,9 @@ import { lastValueFrom, map } from 'rxjs'; @Injectable() export default class RestClientService { - constructor(private readonly httpService: HttpService) {} + public constructor(private readonly httpService: HttpService) {} - async post(url: string, payload: object) { + public async post(url: string, payload: object) { return lastValueFrom( this.httpService .post(url, payload) @@ -14,7 +14,7 @@ export default class RestClientService { ); } - async get(url: string) { + public async get(url: string) { return lastValueFrom( this.httpService.get(url).pipe(map((response) => response.data)), ); diff --git a/apps/proof-manager/src/common/constants.ts b/apps/proof-manager/src/common/constants.ts index c970284655d6e1b36dd463499573bae0cb011675..60254b10ceeeab44889b095acdc3367511684d5f 100644 --- a/apps/proof-manager/src/common/constants.ts +++ b/apps/proof-manager/src/common/constants.ts @@ -1,6 +1,6 @@ export enum LoggerConfig { FILE_PATH = 'logs/log.json', - lOG_DIR = './logs', + LOG_DIR = './logs', } export enum NATSServices { diff --git a/apps/proof-manager/src/common/exception.handler.ts b/apps/proof-manager/src/common/exception.handler.ts index d5960e37fdcd35a923efd999dffdda940c49e530..aab81f9f9089a2285c5195b16d2686fcdbe9b941 100644 --- a/apps/proof-manager/src/common/exception.handler.ts +++ b/apps/proof-manager/src/common/exception.handler.ts @@ -1,18 +1,15 @@ -import { - ArgumentsHost, - Catch, - ExceptionFilter, - HttpException, - HttpStatus, -} from '@nestjs/common'; -import { HttpAdapterHost } from '@nestjs/core'; import type ResponseType from './response.js'; +import type { ArgumentsHost, ExceptionFilter } from '@nestjs/common'; + +import { Catch, HttpException, HttpStatus } from '@nestjs/common'; +import { HttpAdapterHost } from '@nestjs/core'; @Catch() export default class ExceptionHandler implements ExceptionFilter { - constructor(private readonly httpAdapterHost: HttpAdapterHost) {} + public constructor(private readonly httpAdapterHost: HttpAdapterHost) {} - catch(exception: unknown, host: ArgumentsHost): void { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + public catch(exception: any, host: ArgumentsHost): void { // In certain situations `httpAdapter` might not be available in the // constructor method, thus we should resolve it here. const { httpAdapter } = this.httpAdapterHost; @@ -28,7 +25,10 @@ export default class ExceptionHandler implements ExceptionFilter { const errorResponse: string | object = exception.getResponse(); statusCode = exception.getStatus(); - message = errorResponse.error || message; + message = + (typeof errorResponse === 'object' && + Reflect.get(errorResponse, 'error')) || + message; } const responseBody: ResponseType = { diff --git a/apps/proof-manager/src/health/health.controller.ts b/apps/proof-manager/src/health/health.controller.ts index 94f00b17c4e64f380c89082bf9a85a8aab17b85c..d1ec52d5d37f97a243a1cbd4e623e1e264206faf 100644 --- a/apps/proof-manager/src/health/health.controller.ts +++ b/apps/proof-manager/src/health/health.controller.ts @@ -1,10 +1,11 @@ +import type ResponseType from '../common/response.js'; + import { Controller, Get, HttpStatus, Version } from '@nestjs/common'; import { ApiOperation, ApiResponse } from '@nestjs/swagger'; -import type ResponseType from '../common/response.js'; @Controller('health') export default class HealthController { - res: ResponseType; + public res: ResponseType; @Version(['1']) @Get() @@ -31,7 +32,7 @@ export default class HealthController { }, }, }) - getHealth() { + public getHealth() { this.res = { statusCode: HttpStatus.OK, message: `${new Date()}`, diff --git a/apps/proof-manager/src/health/health.spec.ts b/apps/proof-manager/src/health/health.spec.ts index a7ecda97f48681fcbca95cb4086ed1a048c10176..4babe4b160388001e1777d6fe6bd67f1c0c67a51 100644 --- a/apps/proof-manager/src/health/health.spec.ts +++ b/apps/proof-manager/src/health/health.spec.ts @@ -1,6 +1,9 @@ +import type { TestingModule } from '@nestjs/testing'; + import { HttpStatus } from '@nestjs/common'; -import { Test, TestingModule } from '@nestjs/testing'; -import HealthController from './health.controller'; +import { Test } from '@nestjs/testing'; + +import HealthController from './health.controller.js'; describe('Health', () => { let healthController: HealthController; diff --git a/apps/proof-manager/src/main.ts b/apps/proof-manager/src/main.ts index ef92466274d1bbe44a6b3ca3ba4a4a90b54bb1cb..0df020968a342e2686dea44fb436d29685de4ae3 100644 --- a/apps/proof-manager/src/main.ts +++ b/apps/proof-manager/src/main.ts @@ -1,45 +1,45 @@ -import { HttpAdapterHost, NestFactory } from '@nestjs/core'; -import { ConfigService } from '@nestjs/config'; +import type { MicroserviceOptions } from '@nestjs/microservices'; + import { VersioningType } from '@nestjs/common'; +import { ConfigService } from '@nestjs/config'; +import { HttpAdapterHost, NestFactory } from '@nestjs/core'; +import { Transport } from '@nestjs/microservices'; import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger'; -import { Transport, MicroserviceOptions } from '@nestjs/microservices'; + import AppModule from './app.module.js'; import AllExceptionsFilter from './utils/exceptionsFilter.js'; import logger from './utils/logger.js'; -async function bootstrap() { - const app = await NestFactory.create(AppModule); - const configService = app.get(ConfigService); - app.enableCors(); - app.connectMicroservice<MicroserviceOptions>({ - transport: Transport.NATS, - options: { - servers: [configService.get('nats')?.url], - }, - }); - - app.enableVersioning({ - defaultVersion: ['1'], - type: VersioningType.URI, - }); - - const swaggerConfig = new DocumentBuilder() - .setTitle('Gaia-x Proof Manager API') - .setDescription('API documentation for GAIA-X Proof Manager') - .setVersion('1.0') - .addServer(`localhost:${configService.get('PORT')}`) - .build(); - - const document = SwaggerModule.createDocument(app, swaggerConfig); - - SwaggerModule.setup('/swagger', app, document); - await app.startAllMicroservices(); - - const httpAdapter = app.get(HttpAdapterHost); - app.useGlobalFilters(new AllExceptionsFilter(httpAdapter)); - - await app.listen(configService.get('PORT') || 3000, () => { - logger.info(`Listening on Port:${configService.get('PORT')}` || 3000); - }); -} -bootstrap(); +const app = await NestFactory.create(AppModule); +const configService = app.get(ConfigService); +app.enableCors(); +app.connectMicroservice<MicroserviceOptions>({ + transport: Transport.NATS, + options: { + servers: [configService.get('nats')?.url], + }, +}); + +app.enableVersioning({ + defaultVersion: ['1'], + type: VersioningType.URI, +}); + +const swaggerConfig = new DocumentBuilder() + .setTitle('Gaia-x Proof Manager API') + .setDescription('API documentation for GAIA-X Proof Manager') + .setVersion('1.0') + .addServer(`localhost:${configService.get('PORT')}`) + .build(); + +const document = SwaggerModule.createDocument(app, swaggerConfig); + +SwaggerModule.setup('/swagger', app, document); +await app.startAllMicroservices(); + +const httpAdapter = app.get(HttpAdapterHost); +app.useGlobalFilters(new AllExceptionsFilter(httpAdapter)); + +await app.listen(configService.get('PORT') || 3000, () => { + logger.info(`Listening on Port:${configService.get('PORT')}` || 3000); +}); diff --git a/apps/proof-manager/src/middleware/auth.middleware.ts b/apps/proof-manager/src/middleware/auth.middleware.ts index 01f2b7df60889544371a6b6129d539d2c1c0ac72..26d29bb546be867b2bfef7e43d39b673bb414d60 100644 --- a/apps/proof-manager/src/middleware/auth.middleware.ts +++ b/apps/proof-manager/src/middleware/auth.middleware.ts @@ -1,13 +1,16 @@ -import { HttpStatus, Injectable, NestMiddleware } from '@nestjs/common'; -import { ConfigService } from '@nestjs/config'; +import type { NestMiddleware } from '@nestjs/common'; import type { NextFunction, Request, Response } from 'express'; + +import { HttpStatus, Injectable } from '@nestjs/common'; +import { ConfigService } from '@nestjs/config'; import jwt from 'jsonwebtoken'; import jwksClient from 'jwks-rsa'; + import logger from '../utils/logger.js'; @Injectable() export class AuthMiddleware implements NestMiddleware { - constructor(private readonly configService: ConfigService) {} + public constructor(private readonly configService: ConfigService) {} /* eslint-disable */ async use(req: Request, res: Response, next: NextFunction) { diff --git a/apps/proof-manager/src/presentationProof/controller/controller.spec.ts b/apps/proof-manager/src/presentationProof/controller/controller.spec.ts index d46522d19dc7f278f489b59ac699ff5189e851e2..8391bb180da4b222dd9d9e0868ca2d0da9446441 100644 --- a/apps/proof-manager/src/presentationProof/controller/controller.spec.ts +++ b/apps/proof-manager/src/presentationProof/controller/controller.spec.ts @@ -1,16 +1,21 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +import type FindProofPresentationDto from '../entities/find-proof-presentation.dto.js'; +import type SendProofRequest from '../entities/send-proof-request.dto.js'; +import type { TestingModule } from '@nestjs/testing'; + import { HttpModule } from '@nestjs/axios'; import { HttpStatus } from '@nestjs/common'; import { ConfigModule } from '@nestjs/config'; import { ClientsModule, Transport } from '@nestjs/microservices'; -import { Test, TestingModule } from '@nestjs/testing'; -import httpMocks from 'node-mocks-http'; +import { Test } from '@nestjs/testing'; +import { createResponse } from 'node-mocks-http'; + import NatsClientService from '../../client/nats.client.js'; import RestClientService from '../../client/rest.client.js'; import { NATSServices } from '../../common/constants.js'; import PrismaService from '../../prisma/prisma.service.js'; -import FindProofPresentationDto from '../entities/find-proof-presentation.dto.js'; -import SendProofRequest from '../entities/send-proof-request.dto.js'; import PresentationProofsService from '../services/service.js'; + import PresentationProofsController from './controller.js'; describe.skip('Proof Presentation Controller', () => { @@ -89,7 +94,7 @@ describe.skip('Proof Presentation Controller', () => { }, }; - const response = httpMocks.createResponse(); + const response = createResponse(); jest .spyOn(service, 'findProofPresentation') @@ -109,7 +114,7 @@ describe.skip('Proof Presentation Controller', () => { const serviceResult: any = [0, []]; const result: any = { statusCode: 404, message: 'No Data found' }; - const response = httpMocks.createResponse(); + const response = createResponse(); jest .spyOn(service, 'findProofPresentation') .mockResolvedValueOnce(serviceResult); @@ -187,7 +192,7 @@ describe.skip('Proof Presentation Controller', () => { isVerified: true, }; - const response = httpMocks.createResponse(); + const response = createResponse(); jest .spyOn(service, 'findProofByProofRecordId') @@ -208,7 +213,7 @@ describe.skip('Proof Presentation Controller', () => { participant_id: '', }; const serviceResult: any = []; - const response = httpMocks.createResponse(); + const response = createResponse(); response.status(HttpStatus.BAD_REQUEST); const result = { statusCode: HttpStatus.BAD_REQUEST, @@ -236,7 +241,7 @@ describe.skip('Proof Presentation Controller', () => { }; const serviceResult: any = ''; const result: any = { statusCode: 404, message: 'No Data found' }; - const response = httpMocks.createResponse(); + const response = createResponse(); jest .spyOn(service, 'findProofByProofRecordId') .mockResolvedValueOnce(serviceResult); @@ -267,7 +272,7 @@ describe.skip('Proof Presentation Controller', () => { proofRecordId: '', }; const serviceResult: any = []; - const response = httpMocks.createResponse(); + const response = createResponse(); response.status(HttpStatus.BAD_REQUEST); const result = { statusCode: HttpStatus.BAD_REQUEST, @@ -321,7 +326,7 @@ describe.skip('Proof Presentation Controller', () => { theirDid: 'CePQGVFWkpWBN2trZuZSx4', }; - const response = httpMocks.createResponse(); + const response = createResponse(); const result: any = { id: 'aa74842c-6bf5-4647-864c-4c45012cfef3', @@ -377,7 +382,7 @@ describe.skip('Proof Presentation Controller', () => { theirDid: 'CePQGVFWkpWBN2trZuZSx4', }; - const response = httpMocks.createResponse(); + const response = createResponse(); const result: any = { statusCode: HttpStatus.BAD_REQUEST, @@ -415,7 +420,7 @@ describe.skip('Proof Presentation Controller', () => { proofRecordId: '', }; const serviceResult: any = []; - const response = httpMocks.createResponse(); + const response = createResponse(); response.status(HttpStatus.BAD_REQUEST); const result = { statusCode: HttpStatus.BAD_REQUEST, @@ -474,7 +479,7 @@ describe.skip('Proof Presentation Controller', () => { participantId: '662dc769-a4de-4c95-934c-f6dab8cf432c', }; - const response = httpMocks.createResponse(); + const response = createResponse(); const result: any = { id: '4cb19a07-0a3c-4a73-bbd6-006b73b26eeb', @@ -532,7 +537,7 @@ describe.skip('Proof Presentation Controller', () => { theirDid: 'CePQGVFWkpWBN2trZuZSx4', }; - const response = httpMocks.createResponse(); + const response = createResponse(); const result: any = { statusCode: HttpStatus.BAD_REQUEST, diff --git a/apps/proof-manager/src/presentationProof/controller/controller.ts b/apps/proof-manager/src/presentationProof/controller/controller.ts index d06d1bc6e84b387e1525f914f23ebc2d479e9ed2..882b935a7dca44dacac581b2f50b42ed44713d4b 100644 --- a/apps/proof-manager/src/presentationProof/controller/controller.ts +++ b/apps/proof-manager/src/presentationProof/controller/controller.ts @@ -1,3 +1,10 @@ +import type ResponseType from '../../common/response.js'; +import type GetProofRequest from '../entities/get-proof-request.dto.js'; +import type MembershipCredentialDto from '../entities/membership-credential.dto.js'; +import type PresentationSubscriptionEndpointDto from '../entities/presentationSubscribeEndPoint.entity.js'; +// eslint-disable-next-line @typescript-eslint/consistent-type-imports +import type { Response } from 'express'; + import { Body, Controller, @@ -18,23 +25,19 @@ import { ApiResponse, ApiTags, } from '@nestjs/swagger'; -import type { Response } from 'express'; import { Base64 } from 'js-base64'; + import { ATTESTATION, Abstraction, NATSServices, States, } from '../../common/constants.js'; -import ResponseType from '../../common/response.js'; import logger from '../../utils/logger.js'; import AcceptPresentationDto from '../entities/accept-presentation.dto.js'; import AcceptProofRequestDto from '../entities/accept-proof-request.dto.js'; import FindProofPresentationDto from '../entities/find-proof-presentation.dto.js'; import GetPresentProofsDto from '../entities/get-present-proofs.dto.js'; -import GetProofRequest from '../entities/get-proof-request.dto.js'; -import MembershipCredentialDto from '../entities/membership-credential.dto.js'; -import PresentationSubscriptionEndpointDto from '../entities/presentationSubscribeEndPoint.entity.js'; import SendProofRequestBody from '../entities/send-proof-request-body.dto.js'; import SendProofRequest from '../entities/send-proof-request.dto.js'; import PresentationProofsService from '../services/service.js'; @@ -42,7 +45,7 @@ import PresentationProofsService from '../services/service.js'; @ApiTags('Proofs') @Controller() export default class PresentationProofsController { - constructor( + public constructor( private readonly presentationProofsService: PresentationProofsService, private configService: ConfigService, ) {} @@ -116,7 +119,7 @@ export default class PresentationProofsController { }, }, }) - async findProofPresentation( + public async findProofPresentation( @Query() query: FindProofPresentationDto, @Res() response: Response, ) { @@ -230,7 +233,7 @@ export default class PresentationProofsController { }, }, }) - async findProofByProofRecordId( + public async findProofByProofRecordId( @Query() query: AcceptPresentationDto, @Res() response: Response, ) { @@ -347,7 +350,7 @@ export default class PresentationProofsController { @MessagePattern({ endpoint: `${NATSServices.SERVICE_NAME}/sendMembershipProofRequest`, }) - async sendPrincipalCredentialPresentationRequest(data: { + public async sendPrincipalCredentialPresentationRequest(data: { connectionId: string; }) { let res: ResponseType; @@ -412,7 +415,9 @@ export default class PresentationProofsController { @EventPattern({ endpoint: `${Abstraction.NATS_ENDPOINT}/${Abstraction.PROOF_STATE_CHANGED}`, }) - async webhookGetProofPresentation(body: { proofRecord: GetProofRequest }) { + public async webhookGetProofPresentation(body: { + proofRecord: GetProofRequest; + }) { const getProofRequest = body.proofRecord; let res: ResponseType; let getProofRequestDTO: GetProofRequest; @@ -546,7 +551,7 @@ export default class PresentationProofsController { }, }, }) - async sendPresentationRequest( + public async sendPresentationRequest( @Body() sendProofRequest: SendProofRequest, @Res() response: Response, ) { @@ -684,7 +689,7 @@ export default class PresentationProofsController { }, }, }) - async sendOutOfBandPresentationRequest( + public async sendOutOfBandPresentationRequest( @Body() sendProofRequestBody: SendProofRequestBody, @Res() response: Response, ) { @@ -840,7 +845,7 @@ export default class PresentationProofsController { }, }, }) - async outOfBandProof( + public async outOfBandProof( @Query() query: { type: string }, @Res() response: Response, ) { @@ -977,7 +982,7 @@ export default class PresentationProofsController { }, }, }) - async acceptPresentation( + public async acceptPresentation( @Param() params: AcceptPresentationDto, @Res() response: Response, ) { @@ -1108,7 +1113,7 @@ export default class PresentationProofsController { }, }, }) - async acceptProofRequest( + public async acceptProofRequest( @Param() params: AcceptProofRequestDto, @Res() response: Response, ) { @@ -1195,7 +1200,7 @@ export default class PresentationProofsController { }, }, }) - async deleteProofRequest( + public async deleteProofRequest( @Param() params: AcceptProofRequestDto, @Res() response: Response, ) { @@ -1326,7 +1331,7 @@ export default class PresentationProofsController { }, }, }) - async declineProofRequest( + public async declineProofRequest( @Param() params: AcceptProofRequestDto, @Res() response: Response, ) { @@ -1447,7 +1452,7 @@ export default class PresentationProofsController { }, }, }) - async getAllProofRequest( + public async getAllProofRequest( @Query() query: { threadId: string }, @Res() response: Response, ) { @@ -1464,7 +1469,7 @@ export default class PresentationProofsController { @MessagePattern({ endpoint: `${NATSServices.SERVICE_NAME}/getPresentProofs`, }) - async getPresentProofs(data: GetPresentProofsDto) { + public async getPresentProofs(data: GetPresentProofsDto) { return this.presentationProofsService.getPresentProofs(data); } @@ -1474,7 +1479,7 @@ export default class PresentationProofsController { summary: 'Get full url from short url id', description: 'Get full url from short url id', }) - async redirectToOriginalUrl( + public async redirectToOriginalUrl( @Param('id') id: string, @Res() response: Response, ) { diff --git a/apps/proof-manager/src/presentationProof/entities/accept-presentation.dto.ts b/apps/proof-manager/src/presentationProof/entities/accept-presentation.dto.ts index 8b26dd14dcb885500df6fb121de87f2afa123a3a..d4c498c404e9caa391c99640cc941825070aaef5 100644 --- a/apps/proof-manager/src/presentationProof/entities/accept-presentation.dto.ts +++ b/apps/proof-manager/src/presentationProof/entities/accept-presentation.dto.ts @@ -4,5 +4,5 @@ import { IsString } from 'class-validator'; export default class AcceptPresentationDto { @IsString() @ApiProperty() - proofRecordId: string; + public proofRecordId: string; } diff --git a/apps/proof-manager/src/presentationProof/entities/accept-proof-request.dto.ts b/apps/proof-manager/src/presentationProof/entities/accept-proof-request.dto.ts index c9035dca960434aee902160e0033c1207833a7ab..b232485ee5995972173d9dbbbdc1e956a10e83d9 100644 --- a/apps/proof-manager/src/presentationProof/entities/accept-proof-request.dto.ts +++ b/apps/proof-manager/src/presentationProof/entities/accept-proof-request.dto.ts @@ -2,5 +2,5 @@ import { IsString } from 'class-validator'; export default class AcceptProofRequestDto { @IsString() - proofRecordId: string; + public proofRecordId: string; } diff --git a/apps/proof-manager/src/presentationProof/entities/find-proof-presentation.dto.ts b/apps/proof-manager/src/presentationProof/entities/find-proof-presentation.dto.ts index 8dc31ea58bbaab1d9a82d94dc56202f68798d449..7b8dead682e6a678e6d2a91a5cca7b886ed28fd7 100644 --- a/apps/proof-manager/src/presentationProof/entities/find-proof-presentation.dto.ts +++ b/apps/proof-manager/src/presentationProof/entities/find-proof-presentation.dto.ts @@ -1,39 +1,39 @@ -import { IsNumber, IsString, IsDateString } from 'class-validator'; +import { IsDateString, IsNumber, IsString } from 'class-validator'; export default class FindProofPresentationDto { @IsNumber() - page: string; + public page: string; @IsNumber() - pageSize: string; + public pageSize: string; @IsString() - proofRecordId: string; + public proofRecordId: string; @IsString() - connectionId: string; + public connectionId: string; @IsString() - credentialDefId: string; + public credentialDefId: string; @IsString() - schemaId: string; + public schemaId: string; @IsString() - theirDid: string; + public theirDid: string; @IsString() - status: string; + public status: string; @IsDateString() - createdDateStart: string; + public createdDateStart: string; @IsDateString() - createdDateEnd: string; + public createdDateEnd: string; @IsDateString() - updatedDateStart: string; + public updatedDateStart: string; @IsDateString() - updatedDateEnd: string; + public updatedDateEnd: string; } diff --git a/apps/proof-manager/src/presentationProof/entities/get-present-proofs.dto.ts b/apps/proof-manager/src/presentationProof/entities/get-present-proofs.dto.ts index b02a94d0770e81769782437039d20e42e99d0958..faa8f59a201dc6fb55d586b30ffc8d8f7fad50b6 100644 --- a/apps/proof-manager/src/presentationProof/entities/get-present-proofs.dto.ts +++ b/apps/proof-manager/src/presentationProof/entities/get-present-proofs.dto.ts @@ -2,5 +2,5 @@ import { IsString } from 'class-validator'; export default class GetPresentProofsDto { @IsString() - connectionId: string; + public connectionId: string; } diff --git a/apps/proof-manager/src/presentationProof/entities/get-proof-request.dto.ts b/apps/proof-manager/src/presentationProof/entities/get-proof-request.dto.ts index b5677433d0f499793e5087328f7e530e1e322350..b7d4f099ed6a2e7533b81f0c63b610c8cd357187 100644 --- a/apps/proof-manager/src/presentationProof/entities/get-proof-request.dto.ts +++ b/apps/proof-manager/src/presentationProof/entities/get-proof-request.dto.ts @@ -2,13 +2,13 @@ import { IsString } from 'class-validator'; export default class GetProofRequest { @IsString() - state: string; + public state: string; @IsString() - id: string; + public id: string; @IsString() - connectionId: string; + public connectionId: string; - isVerified?: boolean; + public isVerified?: boolean; } diff --git a/apps/proof-manager/src/presentationProof/entities/membership-credential.dto.ts b/apps/proof-manager/src/presentationProof/entities/membership-credential.dto.ts index bbc2793ee420771e18b96f8ac4388ac7b37940e7..48e352111ad5e646e264d8137edfbdb121c4eb9b 100644 --- a/apps/proof-manager/src/presentationProof/entities/membership-credential.dto.ts +++ b/apps/proof-manager/src/presentationProof/entities/membership-credential.dto.ts @@ -2,9 +2,9 @@ import { IsString } from 'class-validator'; export default class MembershipCredentialDto { @IsString() - connectionId: string; + public connectionId: string; - attributes: { + public attributes: { attributeName: string; schemaId?: string; credentialDefId?: string; diff --git a/apps/proof-manager/src/presentationProof/entities/presentationSubscribeEndPoint.entity.ts b/apps/proof-manager/src/presentationProof/entities/presentationSubscribeEndPoint.entity.ts index 3dc7e1dffb73531f39fd8d15e31a3b5d5d7f7f6c..c6dabeb1b2cbfe43c1da895a4984f569f050aa91 100644 --- a/apps/proof-manager/src/presentationProof/entities/presentationSubscribeEndPoint.entity.ts +++ b/apps/proof-manager/src/presentationProof/entities/presentationSubscribeEndPoint.entity.ts @@ -3,9 +3,9 @@ import { IsString, IsNotEmpty } from 'class-validator'; export default class PresentationSubscriptionEndpointDto { @IsString() @IsNotEmpty() - proofRecordId: string; + public proofRecordId: string; @IsString() @IsNotEmpty() - status: string; + public status: string; } diff --git a/apps/proof-manager/src/presentationProof/entities/send-proof-request-body.dto.ts b/apps/proof-manager/src/presentationProof/entities/send-proof-request-body.dto.ts index 9917f25118d51a915f843311ddc42322c3441ef3..a952a47c42462fb874381d9c41787fe23372a0a1 100644 --- a/apps/proof-manager/src/presentationProof/entities/send-proof-request-body.dto.ts +++ b/apps/proof-manager/src/presentationProof/entities/send-proof-request-body.dto.ts @@ -1,23 +1,24 @@ import { ApiProperty } from '@nestjs/swagger'; import { IsString } from 'class-validator'; + import GetProofRequest from './get-proof-request.dto.js'; export default class SendProofRequestBody { @ApiProperty({ example: 'comments' }) - comment?: string; + public comment?: string; @IsString() - status?: string; + public status?: string; @ApiProperty({ example: 'WgWxqztrNooG92RXvxSTWv:3:CL:20:tag' }) @IsString() - schemaId: string; + public schemaId: string; @IsString() - theirDID?: string; + public theirDID?: string; @IsString() - presentationMessage?: string; + public presentationMessage?: string; @ApiProperty({ example: { @@ -25,16 +26,16 @@ export default class SendProofRequestBody { credentialDefinitionId: 'credentialDefinitionId', }, }) - options?: { + public options?: { type: string; credentialDefinitionId: string; }; @IsString() - invitation?: GetProofRequest; + public invitation?: GetProofRequest; @ApiProperty({ example: ['attributeName'] }) - attributes: [ + public attributes: [ { attributeName: string; schemaId: string; diff --git a/apps/proof-manager/src/presentationProof/entities/send-proof-request.dto.ts b/apps/proof-manager/src/presentationProof/entities/send-proof-request.dto.ts index e5545ff416877b453823055d5bbd40aebf76cd89..5f14fd970ddcb27cf81ea7c97b05e67885ee2cf1 100644 --- a/apps/proof-manager/src/presentationProof/entities/send-proof-request.dto.ts +++ b/apps/proof-manager/src/presentationProof/entities/send-proof-request.dto.ts @@ -1,28 +1,29 @@ import { ApiProperty } from '@nestjs/swagger'; import { IsString } from 'class-validator'; + import GetProofRequest from './get-proof-request.dto.js'; export default class SendProofRequest { @ApiProperty({ example: 'comments' }) - comment?: string; + public comment?: string; @ApiProperty({ example: '3fa85f64-5717-4562-b3fc-2c963f66afa6' }) - connectionId?: string; + public connectionId?: string; @IsString() - proofRecordId?: string; + public proofRecordId?: string; @IsString() - status?: string; + public status?: string; @IsString() - theirDID?: string; + public theirDID?: string; @IsString() - presentationMessage?: string; + public presentationMessage?: string; @IsString() - invitation?: GetProofRequest; + public invitation?: GetProofRequest; @ApiProperty({ example: [ @@ -33,7 +34,7 @@ export default class SendProofRequest { }, ], }) - attributes: { + public attributes: { attributeName: string; schemaId?: string; credentialDefId?: string; diff --git a/apps/proof-manager/src/presentationProof/module.ts b/apps/proof-manager/src/presentationProof/module.ts index ae1f0534d5d034e14f0f9c63b27cb1459037a448..33e0f417bed52467985800a58b2711ca83c938d1 100644 --- a/apps/proof-manager/src/presentationProof/module.ts +++ b/apps/proof-manager/src/presentationProof/module.ts @@ -1,11 +1,13 @@ import { HttpModule } from '@nestjs/axios'; import { Module } from '@nestjs/common'; import { ClientsModule, Transport } from '@nestjs/microservices'; + import NatsClientService from '../client/nats.client.js'; import RestClientService from '../client/rest.client.js'; import { NATSServices } from '../common/constants.js'; import config from '../config/config.js'; import PrismaService from '../prisma/prisma.service.js'; + import PresentationProofsController from './controller/controller.js'; import PresentationProofsService from './services/service.js'; diff --git a/apps/proof-manager/src/presentationProof/repository/presentationProof.respository.ts b/apps/proof-manager/src/presentationProof/repository/presentationProof.respository.ts index b20d5987cdf7948d4c75e944b2619d3090e12682..8fd00b5608c807813611c9ea9ac85adb7fe71c7c 100644 --- a/apps/proof-manager/src/presentationProof/repository/presentationProof.respository.ts +++ b/apps/proof-manager/src/presentationProof/repository/presentationProof.respository.ts @@ -1,18 +1,20 @@ +import type { Prisma } from '@prisma/client'; + import { Injectable } from '@nestjs/common'; -import { Prisma } from '@prisma/client'; + import PrismaService from '../../prisma/prisma.service.js'; @Injectable() export default class PresentationProofRepository { - constructor(private readonly prismaService: PrismaService) {} + public constructor(private readonly prismaService: PrismaService) {} - async createPresentationProof(data: Prisma.ProofCreateInput) { + public async createPresentationProof(data: Prisma.ProofCreateInput) { return this.prismaService.proof.create({ data, }); } - async updatePresentationStatus(params: { + public async updatePresentationStatus(params: { where: Prisma.ProofWhereUniqueInput; data: Prisma.ProofUpdateInput; }) { @@ -23,7 +25,7 @@ export default class PresentationProofRepository { }); } - async findProofPresentation(params: { + public async findProofPresentation(params: { skip?: number; take?: number; cursor?: Prisma.ProofWhereUniqueInput; @@ -45,13 +47,13 @@ export default class PresentationProofRepository { ]); } - async deleteProofRequest(proofRecordId: string) { + public async deleteProofRequest(proofRecordId: string) { return this.prismaService.proof.delete({ where: { proofRecordId }, }); } - async createShortUrl(originalUrl: string) { + public async createShortUrl(originalUrl: string) { return this.prismaService.shortUrl.create({ data: { originalUrl, @@ -59,7 +61,7 @@ export default class PresentationProofRepository { }); } - async getShortUrl(id: string) { + public async getShortUrl(id: string) { return this.prismaService.shortUrl.findUnique({ where: { id, diff --git a/apps/proof-manager/src/presentationProof/services/service.spec.ts b/apps/proof-manager/src/presentationProof/services/service.spec.ts index 2d0cfd7734e3e008f3212184cb33098b08f3111e..d82d22e3e0e054dcdbeb4806ed9f98bb05af05ce 100644 --- a/apps/proof-manager/src/presentationProof/services/service.spec.ts +++ b/apps/proof-manager/src/presentationProof/services/service.spec.ts @@ -1,13 +1,18 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +import type MembershipCredentialDto from '../entities/membership-credential.dto.js'; +import type SendProofRequest from '../entities/send-proof-request.dto.js'; +import type { TestingModule } from '@nestjs/testing'; + import { HttpModule } from '@nestjs/axios'; import { ConfigModule } from '@nestjs/config'; import { ClientsModule, Transport } from '@nestjs/microservices'; -import { Test, TestingModule } from '@nestjs/testing'; +import { Test } from '@nestjs/testing'; + import NatsClientService from '../../client/nats.client.js'; import RestClientService from '../../client/rest.client.js'; import { NATSServices } from '../../common/constants.js'; import PrismaService from '../../prisma/prisma.service.js'; -import MembershipCredentialDto from '../entities/membership-credential.dto.js'; -import SendProofRequest from '../entities/send-proof-request.dto.js'; + import PresentationProofsService from './service.js'; describe.skip('ConnectionsService', () => { diff --git a/apps/proof-manager/src/presentationProof/services/service.ts b/apps/proof-manager/src/presentationProof/services/service.ts index c1912567754f18dee52b0c2e608dfd6df18e206f..f8ac9731c7fc985a7cda04f4a4a6bb07b0b6d5f3 100644 --- a/apps/proof-manager/src/presentationProof/services/service.ts +++ b/apps/proof-manager/src/presentationProof/services/service.ts @@ -1,18 +1,20 @@ +import type GetPresentProofsDto from '../entities/get-present-proofs.dto.js'; +import type GetProofRequest from '../entities/get-proof-request.dto.js'; +import type MembershipCredentialDto from '../entities/membership-credential.dto.js'; +import type PresentationSubscriptionEndpointDto from '../entities/presentationSubscribeEndPoint.entity.js'; +import type SendProofRequest from '../entities/send-proof-request.dto.js'; +import type { Prisma } from '@prisma/client'; + import { HttpService } from '@nestjs/axios'; import { Injectable } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; -import { Prisma } from '@prisma/client'; import { lastValueFrom, map } from 'rxjs'; + import NatsClientService from '../../client/nats.client.js'; import RestClientService from '../../client/rest.client.js'; import PrismaService from '../../prisma/prisma.service.js'; import logger from '../../utils/logger.js'; import pagination from '../../utils/pagination.js'; -import GetPresentProofsDto from '../entities/get-present-proofs.dto.js'; -import GetProofRequest from '../entities/get-proof-request.dto.js'; -import MembershipCredentialDto from '../entities/membership-credential.dto.js'; -import PresentationSubscriptionEndpointDto from '../entities/presentationSubscribeEndPoint.entity.js'; -import SendProofRequest from '../entities/send-proof-request.dto.js'; import PresentationProofRepository from '../repository/presentationProof.respository.js'; @Injectable() @@ -23,7 +25,7 @@ export default class PresentationProofsService { private didcommUrl; - constructor( + public constructor( private readonly natsClient: NatsClientService, private readonly prismaService: PrismaService, private readonly httpService: HttpService, @@ -38,19 +40,19 @@ export default class PresentationProofsService { this.didcommUrl = this.configService.get('agent').didcommUrl; } - getAppUrl() { + public getAppUrl() { return this.configService.get('APP_URL'); } - static readonly connectionStatus = { + public static readonly connectionStatus = { TRUSTED: 'trusted', }; - async findProofByProofRecordId(proof_record_id: string) { + public async findProofByProofRecordId(proof_record_id: string) { return this.restClient.get(`${this.agentURL}/proofs/${proof_record_id}`); } - async findProofPresentation( + public async findProofPresentation( pageSize: number, page: number, proofRecordId?: string | false, @@ -116,7 +118,7 @@ export default class PresentationProofsService { return this.presentationProofRepository.findProofPresentation(query); } - async createPresentationRequest(sendProofRequest: SendProofRequest) { + public async createPresentationRequest(sendProofRequest: SendProofRequest) { const query: Prisma.ProofCreateInput = { proofRecordId: sendProofRequest.proofRecordId || '', connectionId: sendProofRequest.connectionId, @@ -125,13 +127,13 @@ export default class PresentationProofsService { return this.presentationProofRepository.createPresentationProof(query); } - async getConnectionByID(connectionID: string) { + public async getConnectionByID(connectionID: string) { const connection = await this.natsClient.getConnectionById(connectionID); return connection; } - async sendPresentationRequest(sendProofRequest: SendProofRequest) { + public async sendPresentationRequest(sendProofRequest: SendProofRequest) { const getPayloadRes = PresentationProofsService.createCommonPresentationRequestPaylod( sendProofRequest, @@ -183,7 +185,7 @@ export default class PresentationProofsService { return responseData; } - static createCommonPresentationRequestPaylod( + public static createCommonPresentationRequestPaylod( sendProofRequest: SendProofRequest, ) { const requestedAttributes: { @@ -241,7 +243,9 @@ export default class PresentationProofsService { return payload; } - async sendOutOfBandPresentationRequest(sendProofRequest: SendProofRequest) { + public async sendOutOfBandPresentationRequest( + sendProofRequest: SendProofRequest, + ) { const getPayloadRes = PresentationProofsService.createCommonPresentationRequestPaylod( sendProofRequest, @@ -275,7 +279,7 @@ export default class PresentationProofsService { return responseData; } - async sendPrincipalCredentialPresentationRequest( + public async sendPrincipalCredentialPresentationRequest( sendProofRequest: MembershipCredentialDto, ) { const requestedAttributes: { @@ -286,41 +290,45 @@ export default class PresentationProofsService { } = {}; const generateNonce: number = Math.floor(Math.random() * 10000000000000); const comment = ''; + for ( let index = 0; index < sendProofRequest.attributes.length; index += 1 ) { - const attributeElement = sendProofRequest.attributes[index].attributeName; + const attributeElement = sendProofRequest.attributes[index]; const attributeReferent = `additionalProp${index + 1}`; const keys = Object.keys(requestedAttributes); if (keys.length > 0) { keys.forEach((attr, i) => { if ( + attributeElement.schemaId && requestedAttributes[attr].restrictions[i].schema_id === - sendProofRequest.attributes[index].schemaId + attributeElement.schemaId ) { - requestedAttributes[attr].names.push(attributeElement); + requestedAttributes[attr].names.push({ + schema_id: attributeElement.schemaId, + }); } else if (keys.length === i + 1) { requestedAttributes[attributeReferent] = { - names: [attributeElement], + names: [attributeElement.attributeName], restrictions: [ { - schema_id: sendProofRequest.attributes[index].schemaId || '', + schema_id: attributeElement.schemaId || '', }, ], - }; + } as any; // eslint-disable-line @typescript-eslint/no-explicit-any } }); } else { requestedAttributes[attributeReferent] = { - names: [attributeElement], + names: [attributeElement.attributeName], restrictions: [ { - schema_id: sendProofRequest.attributes[index].schemaId || '', + schema_id: attributeElement.schemaId || '', }, ], - }; + } as any; // eslint-disable-line @typescript-eslint/no-explicit-any } } @@ -347,7 +355,7 @@ export default class PresentationProofsService { return responseData; } - async updatePresentationStatus(getProofRequest: GetProofRequest) { + public async updatePresentationStatus(getProofRequest: GetProofRequest) { const getRes = await this.presentationProofRepository.updatePresentationStatus({ where: { proofRecordId: getProofRequest.id }, @@ -359,7 +367,7 @@ export default class PresentationProofsService { return getRes; } - async acceptPresentation(proof_record_id: string) { + public async acceptPresentation(proof_record_id: string) { return lastValueFrom( this.httpService .post(`${this.agentURL}/proofs/${proof_record_id}/accept-presentation`) @@ -367,7 +375,7 @@ export default class PresentationProofsService { ); } - async acceptProofRequest(proofRecordId: string) { + public async acceptProofRequest(proofRecordId: string) { return lastValueFrom( this.httpService .post(`${this.agentURL}/proofs/${proofRecordId}/accept-request`) @@ -375,7 +383,7 @@ export default class PresentationProofsService { ); } - async deleteProofRequest(proofRecordId: string) { + public async deleteProofRequest(proofRecordId: string) { const response = lastValueFrom( this.httpService .delete(`${this.agentURL}/proofs/${proofRecordId}`) @@ -387,7 +395,7 @@ export default class PresentationProofsService { return response; } - async declineProofRequest(proofRecordId: string) { + public async declineProofRequest(proofRecordId: string) { return lastValueFrom( this.httpService .post(`${this.didcommUrl}/v1/agent/proofs/declineRequest`, { @@ -397,7 +405,7 @@ export default class PresentationProofsService { ); } - async getAllProofRequest(threadId: string) { + public async getAllProofRequest(threadId: string) { const url = threadId ? `${this.agentURL}/proofs/?threadId=${threadId}` : `${this.agentURL}/proofs/`; @@ -406,35 +414,35 @@ export default class PresentationProofsService { ); } - async getSchemaById(schemaId: string) { + public async getSchemaById(schemaId: string) { const url = `${this.agentURL}/schemas/${schemaId}`; return lastValueFrom( this.httpService.get(url).pipe(map((response) => response.data)), ); } - async getCredentialDefinitionsById(credentialDefinitionsId: string) { + public async getCredentialDefinitionsById(credentialDefinitionsId: string) { const url = `${this.agentURL}/credential-definitions/${credentialDefinitionsId}`; return lastValueFrom( this.httpService.get(url).pipe(map((response) => response.data)), ); } - publishPresentationSubscriberEndpoint( + public publishPresentationSubscriberEndpoint( data: PresentationSubscriptionEndpointDto, ) { this.natsClient.publishPresentation(data); } - getCredentialsTypeDetails(type: string) { + public getCredentialsTypeDetails(type: string) { return this.natsClient.getCredentialsTypeDetails(type); } - makeConnectionTrusted(connectionId: string) { + public makeConnectionTrusted(connectionId: string) { return this.natsClient.makeConnectionTrusted(connectionId); } - async getPresentProofs(data: GetPresentProofsDto) { + public async getPresentProofs(data: GetPresentProofsDto) { return this.presentationProofRepository.findProofPresentation({ where: { connectionId: data.connectionId, @@ -442,7 +450,7 @@ export default class PresentationProofsService { }); } - async findUrlByShortUrlId(id: string) { + public async findUrlByShortUrlId(id: string) { return this.presentationProofRepository.getShortUrl(id); } } diff --git a/apps/proof-manager/src/prisma/prisma.module.ts b/apps/proof-manager/src/prisma/prisma.module.ts index 8245fa14cc0a3f1f2669de75e6a92a3007aa232f..c0d718cbaa670c814fbd4cb308450928e6146563 100644 --- a/apps/proof-manager/src/prisma/prisma.module.ts +++ b/apps/proof-manager/src/prisma/prisma.module.ts @@ -1,4 +1,5 @@ import { Module } from '@nestjs/common'; + import PrismaService from './prisma.service.js'; @Module({ diff --git a/apps/proof-manager/src/prisma/prisma.service.ts b/apps/proof-manager/src/prisma/prisma.service.ts index ed2ac64eccb97dae609fd5cecee44d74a3892e7e..b0f25f5c5d9bf25fe78f1113d3410f2318e2bc2a 100644 --- a/apps/proof-manager/src/prisma/prisma.service.ts +++ b/apps/proof-manager/src/prisma/prisma.service.ts @@ -1,4 +1,6 @@ -import { Injectable, OnModuleDestroy, OnModuleInit } from '@nestjs/common'; +import type { OnModuleDestroy, OnModuleInit } from '@nestjs/common'; + +import { Injectable } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; import { PrismaClient } from '@prisma/client'; @@ -7,7 +9,7 @@ export default class PrismaService extends PrismaClient implements OnModuleInit, OnModuleDestroy { - constructor(configService: ConfigService) { + public constructor(configService: ConfigService) { super({ datasources: { db: { @@ -17,11 +19,11 @@ export default class PrismaService }); } - async onModuleInit() { + public async onModuleInit() { await this.$connect(); } - async onModuleDestroy() { + public async onModuleDestroy() { await this.$disconnect(); } } diff --git a/apps/proof-manager/src/prisma/schema.prisma b/apps/proof-manager/src/prisma/schema.prisma index 2e5855f9e389c7efad0f93f5e54f7966af565aab..ceb5bb55a149a7227c96f0eef49b2d5a0bf7b54b 100644 --- a/apps/proof-manager/src/prisma/schema.prisma +++ b/apps/proof-manager/src/prisma/schema.prisma @@ -1,4 +1,3 @@ - generator client { provider = "prisma-client-js" } @@ -9,18 +8,18 @@ datasource db { } model Proof { - id String @id @default(uuid()) - proofRecordId String @unique @map("proof_record_id") - connectionId String @default("") @map("connection_id") - credentialDefId String @default("") @map("credential_def_id") - schemaId String @default("") @map("schema_id") - theirDid String @default("") @map("their_did") - status String @default("") - createdDate DateTime @default(now()) @map("created_date") - updatedDate DateTime @default(now()) @map("updated_date") + id String @id @default(uuid()) + proofRecordId String @unique @map("proof_record_id") + connectionId String @default("") @map("connection_id") + credentialDefId String @default("") @map("credential_def_id") + schemaId String @default("") @map("schema_id") + theirDid String @default("") @map("their_did") + status String @default("") + createdDate DateTime @default(now()) @map("created_date") + updatedDate DateTime @default(now()) @map("updated_date") } model ShortUrl { - id String @id @default(uuid()) - originalUrl String + id String @id @default(uuid()) + originalUrl String } diff --git a/apps/proof-manager/src/utils/exceptionsFilter.ts b/apps/proof-manager/src/utils/exceptionsFilter.ts index 1556f3f1204cd69797834d0dfa6b8ebb0cb3e3ab..7ce5599676efb868af1ecc25a46daa35f82a1c95 100644 --- a/apps/proof-manager/src/utils/exceptionsFilter.ts +++ b/apps/proof-manager/src/utils/exceptionsFilter.ts @@ -1,20 +1,15 @@ -import { - ArgumentsHost, - Catch, - ExceptionFilter, - HttpException, - HttpStatus, - Logger, -} from '@nestjs/common'; +import type { ArgumentsHost, ExceptionFilter } from '@nestjs/common'; +import type { Request } from 'express'; + +import { Catch, HttpException, HttpStatus, Logger } from '@nestjs/common'; import { HttpAdapterHost } from '@nestjs/core'; import { Prisma } from '@prisma/client'; -import { Request } from 'express'; @Catch() export default class AllExceptionsFilter implements ExceptionFilter { - constructor(private readonly httpAdapterHost: HttpAdapterHost) {} + public constructor(private readonly httpAdapterHost: HttpAdapterHost) {} - catch( + public catch( exception: | HttpException | Prisma.PrismaClientKnownRequestError diff --git a/apps/proof-manager/src/utils/logger.ts b/apps/proof-manager/src/utils/logger.ts index b9de07b40de47d4cb4f5c44faab9d864cfb5ff89..b1958d564a6e6657405384d03400e8485b2bcc43 100644 --- a/apps/proof-manager/src/utils/logger.ts +++ b/apps/proof-manager/src/utils/logger.ts @@ -1,19 +1,16 @@ -import { ecsFormat } from '@elastic/ecs-winston-format'; -import { existsSync, mkdirSync } from 'fs'; -import winston, { Logger } from 'winston'; -import { LoggerConfig } from '../common/constants.js'; +import type { Logger } from 'winston'; -if (!existsSync(LoggerConfig.lOG_DIR)) { - mkdirSync(LoggerConfig.lOG_DIR); -} +import { ecsFormat } from '@elastic/ecs-winston-format'; +import { createLogger, transports } from 'winston'; -const logger: Logger = winston.createLogger({ +const logger: Logger = createLogger({ format: ecsFormat({ convertReqRes: true }), - transports: [new winston.transports.Console()], + transports: [new transports.Console()], }); logger.on('error', (error) => { + // eslint-disable-next-line no-console console.error('Error in logger caught', error); }); diff --git a/apps/proof-manager/test/app.e2e-spec.ts b/apps/proof-manager/test/app.e2e-spec.ts index 45dd541ce95aad7fdb2a9011a7d7296b9670d5f9..bbcc2f610fd61c6a9ba0f5f7a09f9087ebd25b20 100644 --- a/apps/proof-manager/test/app.e2e-spec.ts +++ b/apps/proof-manager/test/app.e2e-spec.ts @@ -1,7 +1,10 @@ +import type { INestApplication } from '@nestjs/common'; +import type { TestingModule } from '@nestjs/testing'; + import { afterEach, beforeEach, describe, it } from '@jest/globals'; -import { INestApplication } from '@nestjs/common'; -import { Test, TestingModule } from '@nestjs/testing'; +import { Test } from '@nestjs/testing'; import request from 'supertest'; + import AppModule from '../src/app.module.js'; describe('AppController (e2e)', () => { @@ -18,7 +21,6 @@ describe('AppController (e2e)', () => { afterEach(() => app.close()); - // eslint-disable-next-line jest/expect-expect it('/health (GET)', () => request(app.getHttpServer()).get('/health').expect(200)); });