Skip to content

Commit 18d1086

Browse files
authored
Merge pull request #1424 from credebl/develop
Sync Develop branch into QA
2 parents 2a446e6 + 230dc9a commit 18d1086

File tree

12 files changed

+78
-75
lines changed

12 files changed

+78
-75
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ export class AgentServiceService {
607607
/**
608608
* Organization storage data
609609
*/
610-
const storeOrgAgentData = await this._buildStoreOrgAgentData(payload, `${orgAgentTypeId}`);
610+
const storeOrgAgentData = this._buildStoreOrgAgentData(payload, `${orgAgentTypeId}`);
611611
/**
612612
* Store org agent details
613613
*/

apps/api-gateway/src/authz/guards/session.guard.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,15 @@ import { UserRepository } from 'apps/user/repositories/user.repository';
55

66
@Injectable()
77
export class SessionGuard implements CanActivate {
8-
constructor(private userRepository: UserRepository) {}
8+
constructor(private readonly userRepository: UserRepository) {}
99

1010
async canActivate(context: ExecutionContext): Promise<boolean> {
1111
const request = context.switchToHttp().getRequest<Request>();
1212
const sessionId = request.cookies['session_id'];
13-
14-
// if (!sessionId) {
15-
// throw new UnauthorizedException('Missing session cookie');
16-
// }
1713
if (sessionId) {
1814
const user = await this.userRepository.validateSession(sessionId);
1915
request.user = user;
2016
}
21-
22-
// if (!user) {
23-
// throw new UnauthorizedException('Invalid session');
24-
// }
2517
return true;
2618
}
2719
}

apps/api-gateway/src/tracer.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,22 @@
22
// @ts-nocheck TODO: Facing issues with types, need to fix later
33
// tracer.ts
44
import * as dotenv from 'dotenv';
5-
dotenv.config();
6-
7-
import { NodeSDK } from '@opentelemetry/sdk-node';
85
import * as process from 'process';
96

10-
import { HttpInstrumentation } from '@opentelemetry/instrumentation-http';
7+
import { BatchLogRecordProcessor, LoggerProvider } from '@opentelemetry/sdk-logs';
8+
import { DiagConsoleLogger, DiagLogLevel, diag } from '@opentelemetry/api';
9+
1110
import { ExpressInstrumentation } from '@opentelemetry/instrumentation-express';
11+
import { HttpInstrumentation } from '@opentelemetry/instrumentation-http';
12+
import type { Logger } from '@opentelemetry/api-logs';
1213
import { NestInstrumentation } from '@opentelemetry/instrumentation-nestjs-core';
13-
14-
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
14+
import { NodeSDK } from '@opentelemetry/sdk-node';
1515
import { OTLPLogExporter } from '@opentelemetry/exporter-logs-otlp-http';
16-
17-
import { resourceFromAttributes } from '@opentelemetry/resources';
16+
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
1817
import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions';
18+
import { resourceFromAttributes } from '@opentelemetry/resources';
1919

20-
import { LoggerProvider, BatchLogRecordProcessor } from '@opentelemetry/sdk-logs';
21-
import { DiagConsoleLogger, DiagLogLevel, diag } from '@opentelemetry/api';
22-
import type { Logger } from '@opentelemetry/api-logs';
20+
dotenv.config();
2321

2422
let otelSDK: NodeSDK | null = null;
2523
let otelLogger: Logger | null = null;

apps/api-gateway/src/user/utils/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export async function getCredentialsByAlias(alias: string): Promise<IClientDetai
3636
return defaultClient;
3737
}
3838

39-
const clientDetails = await getClientDetails(alias);
39+
const clientDetails = getClientDetails(alias);
4040

4141
if (!clientDetails.clientId || !clientDetails.clientSecret || !clientDetails.domain) {
4242
throw new Error(`Missing configuration for SSO client: ${alias}`);

apps/cloud-wallet/src/cloud-wallet.service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,8 @@ export class CloudWalletService {
175175

176176
const [baseWalletDetails, decryptedApiKey] = await this._commonCloudWalletInfo(userId);
177177
const { agentEndpoint } = baseWalletDetails;
178-
const url = `${agentEndpoint}${CommonConstants.CLOUD_WALLET_GET_PROOF_REQUEST}/${threadId ? `?threadId=${threadId}` : ''}`;
178+
const threadParam = threadId ? `?threadId=${threadId}` : '';
179+
const url = `${agentEndpoint}${CommonConstants.CLOUD_WALLET_GET_PROOF_REQUEST}/${threadParam}}`;
179180
const getProofById = await this.commonService.httpGet(url, { headers: { authorization: decryptedApiKey } });
180181
return getProofById;
181182
} catch (error) {

apps/issuance/src/issuance.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1077,7 +1077,7 @@ export class IssuanceService {
10771077

10781078
if (isEmailSent) {
10791079
const w3cSchemaId = outOfBandIssuancePayload?.credentialFormats?.jsonld?.credential?.['@context'] as string[];
1080-
if (w3cSchemaId && w3cSchemaId.includes(CommonConstants.W3C_SCHEMA_URL)) {
1080+
if (w3cSchemaId?.includes(CommonConstants.W3C_SCHEMA_URL)) {
10811081
const filterData = w3cSchemaId.filter((item) => CommonConstants.W3C_SCHEMA_URL !== item);
10821082
const [schemaId] = filterData;
10831083
if (credentialCreateOfferDetails.response.credentialRequestThId) {

apps/organization/src/organization.service.ts

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,25 @@ export class OrganizationService {
194194
}
195195
}
196196

197+
private async ensureOrganizationExists(orgId: string): Promise<void> {
198+
const organizationExist = await this.organizationRepository.getOrgProfile(orgId);
199+
if (!organizationExist) {
200+
throw new NotFoundException(ResponseMessages.organisation.error.notFound);
201+
}
202+
}
203+
private async ensureNotExistingPrimaryDid(orgId: string, did: string): Promise<void> {
204+
const orgAgentDetails = await this.organizationRepository.getAgentEndPoint(orgId);
205+
if (orgAgentDetails.orgDid === did) {
206+
throw new ConflictException(ResponseMessages.organisation.error.primaryDid);
207+
}
208+
}
209+
private async ensureDidBelongsToOrg(orgId: string, did: string): Promise<void> {
210+
const organizationDidList = await this.organizationRepository.getAllOrganizationDid(orgId);
211+
const isDidMatch = organizationDidList.some((item) => item.did === did);
212+
if (!isDidMatch) {
213+
throw new NotFoundException(ResponseMessages.organisation.error.didNotFound);
214+
}
215+
}
197216
/**
198217
*
199218
* @param registerOrgDto
@@ -203,22 +222,11 @@ export class OrganizationService {
203222
// eslint-disable-next-line camelcase
204223
async setPrimaryDid(orgId: string, did: string, id: string): Promise<string> {
205224
try {
206-
const organizationExist = await this.organizationRepository.getOrgProfile(orgId);
207-
if (!organizationExist) {
208-
throw new NotFoundException(ResponseMessages.organisation.error.notFound);
209-
}
210-
const orgAgentDetails = await this.organizationRepository.getAgentEndPoint(orgId);
211-
if (orgAgentDetails.orgDid === did) {
212-
throw new ConflictException(ResponseMessages.organisation.error.primaryDid);
213-
}
225+
await this.ensureOrganizationExists(orgId);
226+
await this.ensureNotExistingPrimaryDid(orgId, did);
214227

215228
//check user DID exist in the organization's did list
216-
const organizationDidList = await this.organizationRepository.getAllOrganizationDid(orgId);
217-
const isDidMatch = organizationDidList.some((item) => item.did === did);
218-
219-
if (!isDidMatch) {
220-
throw new NotFoundException(ResponseMessages.organisation.error.didNotFound);
221-
}
229+
await this.ensureDidBelongsToOrg(orgId, did);
222230
const didDetails = await this.organizationRepository.getDidDetailsByDid(did);
223231

224232
if (!didDetails) {
@@ -1735,7 +1743,7 @@ export class OrganizationService {
17351743
emailData.emailTo = email;
17361744
emailData.emailSubject = `Removal of participation of “${orgName}”`;
17371745

1738-
emailData.emailHtml = await urlEmailTemplate.sendDeleteOrgMemberEmailTemplate(email, orgName, orgRole);
1746+
emailData.emailHtml = urlEmailTemplate.sendDeleteOrgMemberEmailTemplate(email, orgName, orgRole);
17391747

17401748
//Email is sent to user for the verification through emailData
17411749
const isEmailSent = await sendEmail(emailData);

apps/user/repositories/user.repository.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ export class UserRepository {
153153
where: { id: sessionId },
154154
include: { user: true }
155155
});
156-
// if (!session || new Date() > session.expires) return null;
157156
return session;
158157
}
159158

apps/user/src/user.service.ts

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ import {
6060
IVerifyUserEmail,
6161
IUserInvitations,
6262
IResetPasswordResponse,
63-
ISignUpUserResponse
63+
ISignUpUserResponse,
64+
IVerificationEmail
6465
} from '@credebl/common/interfaces/user.interface';
6566
import { AddPasskeyDetailsDto } from 'apps/api-gateway/src/user/dto/add-user.dto';
6667
import { URLUserResetPasswordTemplate } from '../templates/reset-password-template';
@@ -149,16 +150,16 @@ export class UserService {
149150
throw new NotFoundException(ResponseMessages.user.error.redirectUrlNotFound);
150151
}
151152

152-
sendVerificationMail = await this.sendEmailForVerification(
153+
sendVerificationMail = await this.sendEmailForVerification({
153154
email,
154-
verifyCode,
155+
verificationCode: verifyCode,
155156
redirectUrl,
156-
clientDetails.clientId,
157+
clientId: clientDetails.clientId,
157158
brandLogoUrl,
158159
platformName,
159-
clientDetails.domain,
160+
redirectTo: clientDetails.domain,
160161
clientAlias
161-
);
162+
});
162163
} catch (error) {
163164
throw new InternalServerErrorException(ResponseMessages.user.error.emailSend);
164165
}
@@ -207,32 +208,22 @@ export class UserService {
207208
* @returns
208209
*/
209210

210-
async sendEmailForVerification(
211-
email: string,
212-
verificationCode: string,
213-
redirectUrl: string,
214-
clientId: string,
215-
brandLogoUrl: string,
216-
platformName: string,
217-
redirectTo?: string,
218-
clientAlias?: string
219-
): Promise<boolean> {
211+
async sendEmailForVerification(verificationEmailParameter: IVerificationEmail): Promise<boolean> {
220212
try {
213+
const { email, verificationCode, brandLogoUrl, platformName, redirectTo, clientAlias } =
214+
verificationEmailParameter;
221215
const platformConfigData = await this.prisma.platform_config.findMany();
222216

223-
const decryptedClientId = await this.commonService.decryptPassword(clientId);
224217
const urlEmailTemplate = new URLUserEmailTemplate();
225218
const emailData = new EmailDto();
226219
emailData.emailFrom = platformConfigData[0].emailFrom;
227220
emailData.emailTo = email;
228221
const platform = platformName || process.env.PLATFORM_NAME;
229222
emailData.emailSubject = `[${platform}] Verify your email to activate your account`;
230223

231-
emailData.emailHtml = await urlEmailTemplate.getUserURLTemplate(
224+
emailData.emailHtml = urlEmailTemplate.getUserURLTemplate(
232225
email,
233226
verificationCode,
234-
redirectUrl,
235-
decryptedClientId,
236227
brandLogoUrl,
237228
platformName,
238229
redirectTo,
@@ -662,7 +653,7 @@ export class UserService {
662653
const platform = platformName || process.env.PLATFORM_NAME;
663654
emailData.emailSubject = `[${platform}] Important: Password Reset Request`;
664655

665-
emailData.emailHtml = await urlEmailTemplate.getUserResetPasswordTemplate(
656+
emailData.emailHtml = urlEmailTemplate.getUserResetPasswordTemplate(
666657
email,
667658
platform,
668659
brandLogoUrl,

apps/user/templates/user-email-template.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ export class URLUserEmailTemplate {
22
public getUserURLTemplate(
33
email: string,
44
verificationCode: string,
5-
redirectUrl: string,
6-
clientId: string,
75
brandLogoUrl: string,
86
platformName: string,
97
redirectTo?: string,

0 commit comments

Comments
 (0)