Skip to content

Commit 0d3b7b7

Browse files
authored
Merge pull request #1072 from credebl/develop-dco-fixed
merge: DEV to QA
2 parents 3e2b522 + 43f4a93 commit 0d3b7b7

File tree

28 files changed

+128
-1128
lines changed

28 files changed

+128
-1128
lines changed

.env.demo

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,5 @@ AGENT_PROTOCOL=http
128128
OOB_BATCH_SIZE=10
129129
MAX_ORG_LIMIT=10
130130
FIDO_API_ENDPOINT=http://localhost:8000
131+
132+
IS_ECOSYSTEM_ENABLE=false

.env.sample

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,4 +153,6 @@ SCHEMA_FILE_SERVER_TOKEN=xxxxxxxx // Please provide schema file server token for
153153

154154
FILEUPLOAD_CACHE_TTL= //Provide file upload cache ttl
155155

156-
FIELD_UPLOAD_SIZE= //Provide field upload size
156+
FIELD_UPLOAD_SIZE= //Provide field upload size
157+
158+
IS_ECOSYSTEM_ENABLE= //Set this flag to `true` to enable the ecosystem, or `false` to disable it.

apps/agent-service/src/repositories/agent-service.repository.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ export class AgentServiceRepository {
121121
try {
122122

123123
const agentDetails =
124-
await this.prisma.org_agents.findFirstOrThrow({
124+
await this.prisma.org_agents.findFirst({
125125
where: {
126126
orgId
127127
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export class AuthzController {
106106
async login(@Body() loginUserDto: LoginUserDto, @Res() res: Response): Promise<Response> {
107107

108108
if (loginUserDto.email) {
109-
const userData = await this.authzService.login(loginUserDto.email, loginUserDto.password, loginUserDto.isPasskey);
109+
const userData = await this.authzService.login(loginUserDto.email, loginUserDto.password);
110110

111111
const finalResponse: IResponseType = {
112112
statusCode: HttpStatus.OK,
@@ -146,7 +146,6 @@ export class AuthzController {
146146
})
147147
@ApiResponse({ status: HttpStatus.OK, description: 'Success', type: ApiResponseDto })
148148
async forgotPassword(@Body() forgotPasswordDto: ForgotPasswordDto, @Res() res: Response): Promise<Response> {
149-
150149
const userData = await this.authzService.forgotPassword(forgotPasswordDto);
151150
const finalResponse: IResponseType = {
152151
statusCode: HttpStatus.OK,

apps/api-gateway/src/authz/dtos/forgot-password.dto.ts

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { IsEmail, IsNotEmpty, IsString } from 'class-validator';
1+
import { IsEmail, IsNotEmpty, IsOptional, IsString, IsUrl } from 'class-validator';
22

3-
import { ApiProperty } from '@nestjs/swagger';
3+
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
44
import { Transform } from 'class-transformer';
55
import { trim } from '@credebl/common/cast.helper';
66

@@ -11,4 +11,28 @@ export class ForgotPasswordDto {
1111
@IsString({ message: 'Email should be a string' })
1212
@Transform(({ value }) => trim(value))
1313
email: string;
14+
15+
@ApiPropertyOptional({ example: 'https://example.com/logo.png' })
16+
@Transform(({ value }) => trim(value))
17+
@IsOptional()
18+
@IsUrl({
19+
// eslint-disable-next-line camelcase
20+
require_protocol: true,
21+
// eslint-disable-next-line camelcase
22+
require_tld: true
23+
},
24+
{ message: 'brandLogoUrl should be a valid URL' })
25+
brandLogoUrl?: string;
26+
27+
@ApiPropertyOptional({ example: 'MyPlatform' })
28+
@Transform(({ value }) => trim(value))
29+
@IsOptional()
30+
@IsString({ message: 'platformName should be string' })
31+
platformName?: string;
32+
33+
@ApiPropertyOptional({ example: 'https://0.0.0.0:5000' })
34+
@Transform(({ value }) => trim(value))
35+
@IsOptional()
36+
@IsString({ message: 'endpoint should be string' })
37+
endpoint?: string;
1438
}
Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { IsBoolean, IsEmail, IsNotEmpty, IsOptional, IsString, ValidateIf } from 'class-validator';
1+
import { IsEmail, IsNotEmpty, IsString } from 'class-validator';
22

33
import { ApiProperty } from '@nestjs/swagger';
44
import { Transform } from 'class-transformer';
@@ -12,14 +12,9 @@ export class LoginUserDto {
1212
@Transform(({ value }) => trim(value))
1313
email: string;
1414

15-
@ValidateIf((obj) => false === obj.isPasskey)
1615
@ApiProperty()
1716
@Transform(({ value }) => trim(value))
1817
@IsNotEmpty({ message: 'Password is required.' })
19-
password?: string;
18+
password: string;
2019

21-
@ApiProperty({ example: 'false' })
22-
@IsOptional()
23-
@IsBoolean({ message: 'isPasskey should be boolean' })
24-
isPasskey: boolean;
2520
}

apps/api-gateway/src/user/dto/share-certificate.dto.ts

Lines changed: 0 additions & 35 deletions
This file was deleted.

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

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ import { OrgRolesGuard } from '../authz/guards/org-roles.guard';
4949
import { OrgRoles } from 'libs/org-roles/enums';
5050
import { AwsService } from '@credebl/aws/aws.service';
5151
import { PaginationDto } from '@credebl/common/dtos/pagination.dto';
52-
import { CreateCertificateDto } from './dto/share-certificate.dto';
5352
import { UserAccessGuard } from '../authz/guards/user-access-guard';
5453

5554
@UseFilters(CustomExceptionFilter)
@@ -266,23 +265,6 @@ export class UserController {
266265

267266
return res.status(HttpStatus.OK).json(finalResponse);
268267
}
269-
/**
270-
* @param credentialId
271-
* @returns User credentials
272-
*/
273-
@Get('/user-credentials/:credentialId')
274-
@ApiOperation({ summary: 'Get user credentials by Id', description: 'Get user credentials by Id' })
275-
@ApiResponse({ status: HttpStatus.OK, description: 'Success', type: ApiResponseDto })
276-
async getUserCredentialsById(@Param('credentialId') credentialId: string, @Res() res: Response): Promise<Response> {
277-
const getUserCrdentialsById = await this.userService.getUserCredentialsById(credentialId);
278-
279-
const finalResponse: IResponse = {
280-
statusCode: HttpStatus.OK,
281-
message: ResponseMessages.user.success.userCredentials,
282-
data: getUserCrdentialsById
283-
};
284-
return res.status(HttpStatus.OK).json(finalResponse);
285-
}
286268

287269
/**
288270
*
@@ -311,34 +293,7 @@ export class UserController {
311293
};
312294
return res.status(HttpStatus.CREATED).json(finalResponse);
313295
}
314-
/**
315-
* @Body shareUserCredentials
316-
* @returns User certificate URL
317-
*/
318-
@Post('/certificate')
319-
@ApiOperation({
320-
summary: 'Share user certificate',
321-
description: 'Share user certificate'
322-
})
323-
@ApiResponse({ status: HttpStatus.OK, description: 'Success', type: ApiResponseDto })
324-
async shareUserCertificate(
325-
@Body() shareUserCredentials: CreateCertificateDto,
326-
@Res() res: Response
327-
): Promise<Response> {
328-
const schemaIdParts = shareUserCredentials.schemaId.split(':');
329-
// eslint-disable-next-line prefer-destructuring
330-
const title = schemaIdParts[2];
331-
332-
const imageBuffer = await this.userService.shareUserCertificate(shareUserCredentials);
333-
const finalResponse: IResponse = {
334-
statusCode: HttpStatus.CREATED,
335-
message: ResponseMessages.user.success.shareUserCertificate || ResponseMessages.user.success.degreeCertificate,
336-
label: title,
337-
data: imageBuffer
338-
};
339-
return res.status(HttpStatus.CREATED).json(finalResponse);
340-
}
341-
296+
342297
/**
343298
* @Body updateUserProfileDto
344299
* @returns User details

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

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import { IUsersActivity } from 'libs/user-activity/interface';
1111
import { IUserInvitations } from '@credebl/common/interfaces/user.interface';
1212
import { user } from '@prisma/client';
1313
import { PaginationDto } from '@credebl/common/dtos/pagination.dto';
14-
import { CreateCertificateDto } from './dto/share-certificate.dto';
1514

1615
@Injectable()
1716
export class UserService extends BaseService {
@@ -29,12 +28,6 @@ export class UserService extends BaseService {
2928
return this.sendNatsMessage(this.serviceProxy, 'get-user-public-profile', payload);
3029
}
3130

32-
33-
async getUserCredentialsById(credentialId: string): Promise<object> {
34-
const payload = { credentialId };
35-
return this.sendNatsMessage(this.serviceProxy, 'get-user-credentials-by-id', payload);
36-
}
37-
3831
async updateUserProfile(updateUserProfileDto: UpdateUserProfileDto): Promise<user> {
3932
const payload = { updateUserProfileDto };
4033
return this.sendNatsMessage(this.serviceProxy, 'update-user-profile', payload);
@@ -64,12 +57,6 @@ export class UserService extends BaseService {
6457
return this.sendNatsMessage(this.serviceProxy, 'accept-reject-invitations', payload);
6558
}
6659

67-
async shareUserCertificate(
68-
shareUserCredentials: CreateCertificateDto
69-
): Promise<Buffer> {
70-
return this.sendNatsMessage(this.serviceProxy, 'share-user-certificate', shareUserCredentials);
71-
}
72-
7360
async get(
7461
paginationDto:PaginationDto
7562
): Promise<object> {

apps/organization/src/organization.service.ts

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ export class OrganizationService {
470470
try {
471471
const updatedOrglogo = orgLogo.split(',')[1];
472472
const imgData = Buffer.from(updatedOrglogo, 'base64');
473-
const logoUrl = await this.awsService.uploadUserCertificate(
473+
const logoUrl = await this.awsService.uploadFileToS3Bucket(
474474
imgData,
475475
'png',
476476
'orgLogo',
@@ -591,7 +591,7 @@ export class OrganizationService {
591591
/**
592592
* @returns Get created organizations details
593593
*/
594-
594+
595595
async getOrganizations(
596596
userId: string,
597597
pageNumber: number,
@@ -623,26 +623,38 @@ export class OrganizationService {
623623
userId
624624
);
625625

626-
let orgIds;
627-
if (0 > getOrgs?.organizations?.length) {
628-
orgIds = getOrgs?.organizations?.map(item => item.id);
626+
const { organizations } = getOrgs;
627+
628+
if (0 === organizations?.length) {
629+
throw new NotFoundException(ResponseMessages.organisation.error.organizationNotFound);
629630
}
630-
631-
const orgEcosystemDetails = await this._getOrgEcosystems(orgIds);
632-
if (!orgEcosystemDetails || !Array.isArray(orgEcosystemDetails) || 0 === orgEcosystemDetails.length) {
633-
throw new NotFoundException(ResponseMessages.ecosystem.error.ecosystemDetailsNotFound);
631+
632+
let orgIds;
633+
let updatedOrgs;
634+
635+
if ('true' === process.env.IS_ECOSYSTEM_ENABLE) {
636+
orgIds = organizations?.map(item => item.id);
637+
638+
const orgEcosystemDetails = await this._getOrgEcosystems(orgIds);
639+
if (!orgEcosystemDetails || !Array.isArray(orgEcosystemDetails) || 0 === orgEcosystemDetails.length) {
640+
throw new NotFoundException(ResponseMessages.ecosystem.error.ecosystemDetailsNotFound);
641+
}
642+
643+
updatedOrgs = getOrgs.organizations.map(org => {
644+
const matchingEcosystems = orgEcosystemDetails
645+
.filter(ecosystem => ecosystem.orgId === org.id)
646+
.map(ecosystem => ({ ecosystemId: ecosystem.ecosystemId }));
647+
return {
648+
...org,
649+
ecosystemOrgs: 0 < matchingEcosystems.length ? matchingEcosystems : []
650+
};
651+
});
652+
} else {
653+
updatedOrgs = getOrgs?.organizations?.map(org => ({
654+
...org
655+
}));
634656
}
635-
636-
const updatedOrgs = getOrgs.organizations.map(org => {
637-
const matchingEcosystems = orgEcosystemDetails
638-
.filter(ecosystem => ecosystem.orgId === org.id)
639-
.map(ecosystem => ({ ecosystemId: ecosystem.ecosystemId }));
640-
return {
641-
...org,
642-
ecosystemOrgs: 0 < matchingEcosystems.length ? matchingEcosystems : []
643-
};
644-
});
645-
657+
646658
return {
647659
totalCount: getOrgs.totalCount,
648660
totalPages: getOrgs.totalPages,

0 commit comments

Comments
 (0)