diff --git a/apps/api-gateway/src/issuance/issuance.controller.ts b/apps/api-gateway/src/issuance/issuance.controller.ts index 5c58c622b..02956f16a 100644 --- a/apps/api-gateway/src/issuance/issuance.controller.ts +++ b/apps/api-gateway/src/issuance/issuance.controller.ts @@ -603,7 +603,6 @@ export class IssuanceController { @Res() res: Response ): Promise { issueCredentialDto.type = 'Issuance'; - this.logger.debug(`issueCredentialDto ::: ${JSON.stringify(issueCredentialDto)}`); const getCredentialDetails = await this.issueCredentialService.getIssueCredentialWebhook(issueCredentialDto, id).catch(error => { this.logger.debug(`error in saving issuance webhook ::: ${JSON.stringify(error)}`); diff --git a/apps/api-gateway/src/verification/verification.controller.ts b/apps/api-gateway/src/verification/verification.controller.ts index efb8570a7..b396b8b31 100644 --- a/apps/api-gateway/src/verification/verification.controller.ts +++ b/apps/api-gateway/src/verification/verification.controller.ts @@ -286,7 +286,6 @@ export class VerificationController { @Res() res: Response ): Promise { proofPresentationPayload.type = 'Verification'; - this.logger.debug(`proofPresentationPayload ::: ${JSON.stringify(proofPresentationPayload)}`); const webhookProofPresentation = await this.verificationService.webhookProofPresentation(orgId, proofPresentationPayload).catch(error => { this.logger.debug(`error in saving verification webhook ::: ${JSON.stringify(error)}`); diff --git a/apps/ecosystem/src/ecosystem.repository.ts b/apps/ecosystem/src/ecosystem.repository.ts index 98be181dc..225598d0e 100644 --- a/apps/ecosystem/src/ecosystem.repository.ts +++ b/apps/ecosystem/src/ecosystem.repository.ts @@ -1035,6 +1035,26 @@ export class EcosystemRepository { } } + async schemaExist(schemaName: string, schemaVersion: string): Promise { + try { + return this.prisma.schema.findMany({ + where: { + name: { + contains: schemaName, + mode: 'insensitive' + }, + version: { + contains: schemaVersion, + mode: 'insensitive' + } + } + }); + } catch (error) { + this.logger.error(`Error in schemaExists: ${error}`); + throw error; + } + } + // eslint-disable-next-line camelcase async saveCredDef(credDefResult: saveCredDef): Promise { try { diff --git a/apps/ecosystem/src/ecosystem.service.ts b/apps/ecosystem/src/ecosystem.service.ts index be222c79c..eed9f4e52 100644 --- a/apps/ecosystem/src/ecosystem.service.ts +++ b/apps/ecosystem/src/ecosystem.service.ts @@ -684,7 +684,7 @@ export class EcosystemService { this.logger.log(`alreadySchemaExist ::: ${JSON.stringify(alreadySchemaExist.length)}`); if (0 !== alreadySchemaExist.length) { - throw new BadRequestException(ResponseMessages.ecosystem.error.schemaAlreadyExist); + throw new ConflictException(ResponseMessages.ecosystem.error.schemaAlreadyExist); } const getEcosystemLeadDetails = await this.ecosystemRepository.getEcosystemLeadDetails(ecosystemId); @@ -1321,11 +1321,13 @@ export class EcosystemService { async submitTransaction(transactionPayload: TransactionPayload): Promise { try { - const { endorsementId, ecosystemId, ecosystemLeadAgentEndPoint, orgId } = transactionPayload; + const { endorsementId, ecosystemId, ecosystemLeadAgentEndPoint, orgId } = transactionPayload; const endorsementTransactionPayload = await this.ecosystemRepository.getEndorsementTransactionById( endorsementId, endorsementTransactionStatus.SIGNED ); + + if (!endorsementTransactionPayload) { throw new InternalServerErrorException(ResponseMessages.ecosystem.error.invalidTransaction); } @@ -1353,6 +1355,19 @@ export class EcosystemService { ecosystemMemberDetails, ecosystemLeadAgentDetails ); + + const isSchemaExists = await this.ecosystemRepository.schemaExist( + payload.schema.name, + payload.schema.version + ); + + if (0 !== isSchemaExists.length) { + this.logger.error(ResponseMessages.ecosystem.error.schemaAlreadyExist); + throw new ConflictException( + ResponseMessages.ecosystem.error.schemaAlreadyExist, + { cause: new Error(), description: ResponseMessages.errorMessages.conflict } + ); + } let apiKey: string = await this.cacheService.get(CommonConstants.CACHE_APIKEY_KEY); if (!apiKey || null === apiKey || undefined === apiKey) { @@ -1407,7 +1422,7 @@ export class EcosystemService { throw new InternalServerErrorException(ResponseMessages.ecosystem.error.updateCredDefId); } return this.handleCredDefSubmission( - endorsementTransactionPayload, + endorsementTransactionPayload, ecosystemMemberDetails, submitTransactionRequest ); @@ -1442,11 +1457,12 @@ export class EcosystemService { const message = await this.ecosystemServiceProxy.send(pattern, payload).toPromise(); return { message }; } catch (error) { - this.logger.error(`catch: ${JSON.stringify(error)}`); + this.logger.error(` agent-submit-transaction catch: ${JSON.stringify(error)}`); throw new HttpException( { status: error.status, - error: error.message + message: error.message, + error: error.error }, error.status ); diff --git a/apps/ledger/src/credential-definition/credential-definition.service.ts b/apps/ledger/src/credential-definition/credential-definition.service.ts index c68bfed2d..23d6f33f2 100644 --- a/apps/ledger/src/credential-definition/credential-definition.service.ts +++ b/apps/ledger/src/credential-definition/credential-definition.service.ts @@ -38,7 +38,6 @@ export class CredentialDefinitionService extends BaseService { const getAgentDetails = await this.credentialDefinitionRepository.getAgentType(credDef.orgId); // const apiKey = await this._getOrgAgentApiKey(credDef.orgId); let apiKey:string = await this.cacheService.get(CommonConstants.CACHE_APIKEY_KEY); - this.logger.log(`cachedApiKey----${apiKey}`); if (!apiKey || null === apiKey || undefined === apiKey) { apiKey = await this._getOrgAgentApiKey(credDef.orgId); } @@ -184,7 +183,7 @@ export class CredentialDefinitionService extends BaseService { const orgAgentType = await this.credentialDefinitionRepository.getOrgAgentType(getAgentDetails.org_agents[0].orgAgentTypeId); // const apiKey = await this._getOrgAgentApiKey(String(orgId)); let apiKey:string = await this.cacheService.get(CommonConstants.CACHE_APIKEY_KEY); - this.logger.log(`cachedApiKey----${apiKey}`); + if (!apiKey || null === apiKey || undefined === apiKey) { apiKey = await this._getOrgAgentApiKey(String(orgId)); } diff --git a/apps/verification/src/verification.service.ts b/apps/verification/src/verification.service.ts index 9322b2acd..735c5f25e 100644 --- a/apps/verification/src/verification.service.ts +++ b/apps/verification/src/verification.service.ts @@ -222,7 +222,6 @@ export class VerificationService { const verificationMethodLabel = 'request-proof'; const url = await this.getAgentUrl(verificationMethodLabel, orgAgentType, getAgentDetails?.agentEndPoint, getAgentDetails?.tenantId); let apiKey: string = await this.cacheService.get(CommonConstants.CACHE_APIKEY_KEY); - this.logger.log(`cachedApiKey----${apiKey}`); if (!apiKey || null === apiKey || undefined === apiKey) { apiKey = await this._getOrgAgentApiKey(requestProof.orgId); } @@ -336,7 +335,6 @@ export class VerificationService { async sendOutOfBandPresentationRequest(outOfBandRequestProof: ISendProofRequestPayload, user: IUserRequest): Promise { try { - this.logger.log(`-------outOfBandRequestProof------${JSON.stringify(outOfBandRequestProof)}`); outOfBandRequestProof.protocolVersion = outOfBandRequestProof.protocolVersion || 'v1'; outOfBandRequestProof.autoAcceptProof = outOfBandRequestProof.autoAcceptProof || 'always'; @@ -357,7 +355,6 @@ export class VerificationService { let apiKey: string = await this.cacheService.get(CommonConstants.CACHE_APIKEY_KEY); const verificationMethodLabel = 'create-request-out-of-band'; const url = await this.getAgentUrl(verificationMethodLabel, orgAgentType, getAgentDetails?.agentEndPoint, getAgentDetails?.tenantId); - this.logger.log(`cachedApiKey----${apiKey}`); if (!apiKey || null === apiKey || undefined === apiKey) { apiKey = await this._getOrgAgentApiKey(user.orgId); } @@ -369,7 +366,6 @@ export class VerificationService { }; const getProofPresentation = await this._sendOutOfBandProofRequest(payload); - this.logger.log(`-----getProofPresentation---${JSON.stringify(getProofPresentation)}`); if (!getProofPresentation) { throw new Error(ResponseMessages.verification.error.proofPresentationNotFound); } @@ -393,14 +389,12 @@ export class VerificationService { private async generateOOBProofReq(payload: IProofRequestPayload, getAgentDetails: org_agents): Promise { let agentApiKey: string = await this.cacheService.get(CommonConstants.CACHE_APIKEY_KEY); - this.logger.log(`cachedApiKey----${agentApiKey}`); if (!agentApiKey || null === agentApiKey || undefined === agentApiKey) { agentApiKey = await this._getOrgAgentApiKey(getAgentDetails.orgId); } payload.apiKey = agentApiKey; const getProofPresentation = await this._sendOutOfBandProofRequest(payload); - this.logger.log(`-----getProofPresentation---${JSON.stringify(getProofPresentation)}`); if (!getProofPresentation) { throw new Error(ResponseMessages.verification.error.proofPresentationNotFound); @@ -439,7 +433,6 @@ export class VerificationService { async sendOutOfBandProofRequest(payload: IProofRequestPayload, email: string, getAgentDetails: org_agents, organizationDetails: organisation): Promise { let agentApiKey: string = await this.cacheService.get(CommonConstants.CACHE_APIKEY_KEY); - this.logger.log(`cachedApiKey----${agentApiKey}`); if (!agentApiKey || null === agentApiKey || undefined === agentApiKey) { agentApiKey = await this._getOrgAgentApiKey(getAgentDetails.orgId); } @@ -674,7 +667,7 @@ export class VerificationService { const orgAgentType = await this.verificationRepository.getOrgAgentType(getAgentDetails?.orgAgentTypeId); const url = await this.getAgentUrl(verificationMethodLabel, orgAgentType, getAgentDetails?.agentEndPoint, getAgentDetails?.tenantId, '', proofId); let apiKey: string = await this.cacheService.get(CommonConstants.CACHE_APIKEY_KEY); - this.logger.log(`cachedApiKey----${apiKey}`); + if (!apiKey || null === apiKey || undefined === apiKey) { apiKey = await this._getOrgAgentApiKey(orgId); } diff --git a/libs/client-registration/src/client-registration.service.ts b/libs/client-registration/src/client-registration.service.ts index b836b3422..d5fed0c93 100644 --- a/libs/client-registration/src/client-registration.service.ts +++ b/libs/client-registration/src/client-registration.service.ts @@ -164,7 +164,6 @@ export class ClientRegistrationService { `${process.env.KEYCLOAK_DOMAIN}admin/realms/${process.env.KEYCLOAK_REALM}/users/${payload['sub']}`, this.getAuthHeader(token) ); - this.logger.debug(`keycloak user ${JSON.stringify(userInfoResponse)}`); return userInfoResponse.data; } catch (error) { this.logger.error(`[getUserInfo]: ${JSON.stringify(error)}`); @@ -236,7 +235,6 @@ export class ClientRegistrationService { this.getAuthHeader(token) ); - this.logger.debug(`Existing apps response ${JSON.stringify(response)}`); return { clientId: client_id,