Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/credebl/platform into fix/r…
Browse files Browse the repository at this point in the history
…esolve-DCO

Signed-off-by: KulkarniShashank <[email protected]>
  • Loading branch information
KulkarniShashank committed Sep 6, 2024
2 parents 33810a1 + 435f68a commit 038b12d
Show file tree
Hide file tree
Showing 19 changed files with 521 additions and 455 deletions.
4 changes: 0 additions & 4 deletions Dockerfiles/Dockerfile.agent-service
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,3 @@ COPY --from=build /app/node_modules ./node_modules

# Set the command to run the microservice
CMD ["sh", "-c", "cd libs/prisma-service && npx prisma migrate deploy && cd ../.. && node dist/apps/agent-service/main.js"]

# docker build -t agent-service -f Dockerfiles/Dockerfile.agent-service .
# docker run -d --env-file .env --name agent-service docker.io/library/agent-service
# docker logs -f agent-service
4 changes: 0 additions & 4 deletions Dockerfiles/Dockerfile.connection
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,3 @@ COPY --from=build /app/node_modules ./node_modules

# Set the command to run the microservice
CMD ["sh", "-c", "cd libs/prisma-service && npx prisma migrate deploy && cd ../.. && node dist/apps/connection/main.js"]

# docker build -t connection -f Dockerfiles/Dockerfile.connection .
# docker run -d --env-file .env --name connection docker.io/library/connection
# docker logs -f connection
4 changes: 0 additions & 4 deletions Dockerfiles/Dockerfile.ecosystem
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,3 @@ COPY --from=build /app/node_modules ./node_modules

# Set the command to run the microservice
CMD ["sh", "-c", "cd libs/prisma-service && npx prisma migrate deploy && cd ../.. && node dist/apps/ecosystem/main.js"]

# docker build -t ecosystem -f Dockerfiles/Dockerfile.ecosystem .
# docker run -d --env-file .env --name ecosystem docker.io/library/ecosystem
# docker logs -f ecosystem
4 changes: 0 additions & 4 deletions Dockerfiles/Dockerfile.issuance
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,3 @@ COPY --from=build /app/node_modules ./node_modules

# Set the command to run the microservice
CMD ["sh", "-c", "cd libs/prisma-service && npx prisma migrate deploy && cd ../.. && node dist/apps/issuance/main.js"]

# docker build -t issuance -f Dockerfiles/Dockerfile.issuance .
# docker run -d --env-file .env --name issuance docker.io/library/issuance
# docker logs -f issuance
4 changes: 0 additions & 4 deletions Dockerfiles/Dockerfile.ledger
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,3 @@ COPY --from=build /app/node_modules ./node_modules

# Set the command to run the microservice
CMD ["sh", "-c", "cd libs/prisma-service && npx prisma migrate deploy && cd ../.. && node dist/apps/ledger/main.js"]

# docker build -t ledger -f Dockerfiles/Dockerfile.ledger .
# docker run -d --env-file .env --name ledger docker.io/library/ledger
# docker logs -f ledger
4 changes: 0 additions & 4 deletions Dockerfiles/Dockerfile.notification
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,3 @@ COPY --from=build /app/node_modules ./node_modules

# Set the command to run the microservice
CMD ["sh", "-c", "cd libs/prisma-service && npx prisma migrate deploy && cd ../.. && node dist/apps/notification/main.js"]

# docker build -t notification -f Dockerfiles/Dockerfile.notification .
# docker run -d --env-file .env --name notification docker.io/library/notification
# docker logs -f notification
4 changes: 0 additions & 4 deletions Dockerfiles/Dockerfile.organization
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,3 @@ COPY --from=build /app/node_modules ./node_modules

# Set the command to run the microservice
CMD ["sh", "-c", "cd libs/prisma-service && npx prisma migrate deploy && cd ../.. && node dist/apps/organization/main.js"]

# docker build -t organization -f Dockerfiles/Dockerfile.organization .
# docker run -d --env-file .env --name issuance docker.io/library/organization
# docker logs -f organization
4 changes: 0 additions & 4 deletions Dockerfiles/Dockerfile.user
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,3 @@ COPY --from=build /app/node_modules ./node_modules

# Set the command to run the microservice
CMD ["sh", "-c", "cd libs/prisma-service && npx prisma migrate deploy && cd ../.. && node dist/apps/user/main.js"]

# docker build -t user -f Dockerfiles/Dockerfile.user .
# docker run -d --env-file .env --name user docker.io/library/user
# docker logs -f user
4 changes: 0 additions & 4 deletions Dockerfiles/Dockerfile.verification
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,3 @@ COPY --from=build /app/node_modules ./node_modules

# Set the command to run the microservice
CMD ["sh", "-c", "cd libs/prisma-service && npx prisma migrate deploy && cd ../.. && node dist/apps/verification/main.js"]

# docker build -t verification -f Dockerfiles/Dockerfile.verification .
# docker run -d --env-file .env --name verification docker.io/library/verification
# docker logs -f verification
4 changes: 0 additions & 4 deletions Dockerfiles/Dockerfile.webhook
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,3 @@ COPY --from=build /app/node_modules ./node_modules

# Set the command to run the microservice
CMD ["sh", "-c", "cd libs/prisma-service && npx prisma migrate deploy && cd ../.. && node dist/apps/webhook/main.js"]

# docker build -t webhook -f Dockerfiles/Dockerfile.webhook .
# docker run -d --env-file .env --name webhook docker.io/library/webhook
# docker logs -f webhook
25 changes: 1 addition & 24 deletions apps/agent-service/src/agent-service.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -965,31 +965,8 @@ export class AgentServiceService {
const didDetails = await this.getDidDetails(url, payload, getApiKey);
const getDidByOrg = await this.agentServiceRepository.getOrgDid(orgId);


const didDetails = await this.commonService.httpPost(url, payload, {
headers: { authorization: getApiKey }
});

const didDetails = await this.commonService.httpPost(url, createDidPayload, {
headers: { authorization: getApiKey }
});
await this.checkDidExistence(getDidByOrg, didDetails);

if (!didDetails || Object.keys(didDetails).length === 0) {
throw new InternalServerErrorException(ResponseMessages.agent.error.createDid, {
cause: new Error(),
description: ResponseMessages.errorMessages.serverError
});
}


const didExist = getDidByOrg.some((orgDidExist) => orgDidExist.did === didDetails.did);
if (didExist) {
throw new ConflictException(ResponseMessages.agent.error.didAlreadyExist, {
cause: new Error(),
description: ResponseMessages.errorMessages.serverError
});
}

if (isPrimaryDid) {
await this.updateAllDidsToNonPrimary(orgId, getDidByOrg);
}
Expand Down
24 changes: 0 additions & 24 deletions apps/agent-service/src/repositories/agent-service.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,30 +221,6 @@ export class AgentServiceRepository {
}


/**
* Set primary DID
* @param did
* @returns did details
*/
// eslint-disable-next-line camelcase
async setPrimaryDid(isPrimaryDid:string, orgId:string): Promise<org_agents> {
try {
return await this.prisma.org_agents.update({
where: {
orgId
},
data: {
orgDid: isPrimaryDid
}
});

} catch (error) {
this.logger.error(`[setprimaryDid] - Update DID details: ${JSON.stringify(error)}`);
throw error;
}
}


/**
* Get agent details
* @param orgId
Expand Down
2 changes: 2 additions & 0 deletions apps/api-gateway/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import { WebhookModule } from './webhook/webhook.module';
import { UtilitiesModule } from './utilities/utilities.module';
import { NotificationModule } from './notification/notification.module';
import { GeoLocationModule } from './geo-location/geo-location.module';
import { CommonConstants } from '@credebl/common/common.constant';
import { CloudWalletModule } from './cloud-wallet/cloud-wallet.module';

@Module({
imports: [
Expand Down
6 changes: 3 additions & 3 deletions apps/api-gateway/src/authz/jwt.strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ export class JwtStrategy extends PassportStrategy(Strategy) {
throw new NotFoundException(ResponseMessages.user.error.notFound);
}
//TODO patch to QA
// if (userInfo && userInfo?.['attributes'] && userInfo?.['attributes']?.userRole) {
// userDetails['userRole'] = userInfo?.['attributes']?.userRole;
// }
if (userInfo && userInfo?.['attributes'] && userInfo?.['attributes']?.userRole) {
userDetails['userRole'] = userInfo?.['attributes']?.userRole;
}

return {
...userDetails,
Expand Down
23 changes: 2 additions & 21 deletions apps/api-gateway/src/issuance/dtos/issuance.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,26 +56,6 @@ class PrettyVc {
@IsString({ message: 'orientation must be in string format.' })
orientation: string;
}

class PrettyVc {
@ApiPropertyOptional()
@IsOptional()
@Transform(({ value }) => trim(value))
@IsString({ message: 'Certificate must be in string format.' })
certificate: string;

@ApiPropertyOptional({example: 'a4'})
@IsOptional()
@Transform(({ value }) => trim(value))
@IsString({ message: 'Size must be in string format.' })
size: string;

@ApiPropertyOptional({example: 'landscape'})
@IsOptional()
@Transform(({ value }) => trim(value))
@IsString({ message: 'orientation must be in string format.' })
orientation: string;
}
export class Credential {
@ApiProperty()
@IsNotEmpty({ message: 'context is required' })
Expand Down Expand Up @@ -562,7 +542,8 @@ export class ClientDetails {

userId?: string;

@ApiProperty({ required: false, example: 'issue-data.csv' })
@ApiPropertyOptional({ example: 'https://example.com/logo.png' })
@Transform(({ value }) => trim(value))
@IsOptional()
@IsUrl(
{
Expand Down
17 changes: 17 additions & 0 deletions apps/connection/src/connection.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,23 @@ export class ConnectionService {
if (!agentDetails) {
throw new NotFoundException(ResponseMessages.connection.error.agentEndPointNotFound);
}

let legacyinvitationDid;
if (IsReuseConnection) {
const data: agent_invitations[] = await this.connectionRepository.getInvitationDidByOrgId(orgId);
if (data && 0 < data.length) {
const [firstElement] = data;
legacyinvitationDid = firstElement?.invitationDid ?? undefined;

this.logger.log('legacyinvitationDid:', legacyinvitationDid);
}
}
const connectionInvitationDid = invitationDid ? invitationDid : legacyinvitationDid;

this.logger.log('connectionInvitationDid:', connectionInvitationDid);


this.logger.log(`logoUrl:::, ${organisation.logoUrl}`);
const connectionPayload = {
multiUseInvitation: multiUseInvitation ?? true,
autoAcceptConnection: autoAcceptConnection ?? true,
Expand Down
126 changes: 125 additions & 1 deletion libs/common/src/cast.helper.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { BadRequestException } from '@nestjs/common';
import { DidMethod, JSONSchemaType, ledgerLessDIDType, ProofType, schemaRequestType, TemplateIdentifier } from '@credebl/enum/enum';
import { ISchemaFields } from './interfaces/schema.interface';
import { BadRequestException, PipeTransform } from '@nestjs/common';
import { plainToClass } from 'class-transformer';
import {
ValidationArguments,
ValidationOptions,
Expand Down Expand Up @@ -147,6 +150,127 @@ export class ImageBase64Validator implements ValidatorConstraintInterface {
}
}

export class TrimStringParamPipe implements PipeTransform {
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/explicit-function-return-type
transform(value: string) {
return plainToClass(String, value.trim());
}
}

// export const IsNotUUID = (validationOptions?: ValidationOptions): PropertyDecorator => (object: object, propertyName: string) => {
// registerDecorator({
// name: 'isNotUUID',
// target: object.constructor,
// propertyName,
// options: validationOptions,
// validator: {
// validate(value) {
// return !isUUID(value);
// }
// }
// });
// };


export function validateSchemaPayload(schemaPayload: ISchemaFields, schemaType: string): void {
const errors: string[] = [];

switch (true) {
case schemaRequestType.INDY === schemaType:
switch (true) {
case !schemaPayload?.name:
errors.push('name is required for indy schema type');
break;
case 'string' !== typeof schemaPayload?.name:
errors.push('name must be string');
break;
case !schemaPayload?.version:
errors.push('version is required for indy schema type');
break;
default:
break;
}
if (!Array.isArray(schemaPayload?.attributes) || 0 === schemaPayload?.attributes.length) {
errors.push('attributes array must not be empty for indy schema type');
} else {
schemaPayload?.attributes.forEach((attribute, index) => {
if (!attribute) {
errors.push(`attributes are required at position ${index + 1} in indy schema type`);
} else {
switch (true) {
case !attribute?.displayName:
errors.push(`displayName is required at position ${index + 1} in indy schema type`);
break;
case !attribute?.attributeName:
errors.push(`attributeName is required at position ${index + 1} in indy schema type`);
break;
case !attribute?.schemaDataType:
errors.push(`schemaDataType is required at position ${index + 1} in indy schema type`);
break;
default:
break;
}
}
});
}
break;

case schemaRequestType.W3C === schemaType:
switch (true) {
case !schemaPayload?.schemaName:
errors.push('schemaName is required for w3c schema type');
break;
case 'string' !== typeof schemaPayload?.schemaName:
errors.push('schemaName must be string');
break;

case !schemaPayload?.did:
errors.push('did is required for w3c schema type');
break;
case 'string' !== typeof schemaPayload?.did:
errors.push('did must be string');
break;

case !schemaPayload?.description:
errors.push('description is required for w3c schema type');
break;
case 'string' !== typeof schemaPayload?.description:
errors.push('description must be string');
break;
default:
break;
}
if (!Array.isArray(schemaPayload.schemaAttributes) || 0 === schemaPayload.schemaAttributes.length) {
errors.push('schemaAttributes array must not be empty for w3c schema type');
} else {
schemaPayload.schemaAttributes.forEach((attribute, index) => {
if (!attribute) {
errors.push(`schemaAttributes are required at position ${index + 1} in w3c schema type`);
} else {
switch (true) {
case !attribute.title:
errors.push(`title is required at position ${index + 1} in w3c schema type`);
break;
case !attribute.type:
errors.push(`type is required at position ${index + 1} in w3c schema type`);
break;
default:
break;
}
}
});
}
break;

default:
break;
}

if (0 < errors.length) {
throw new BadRequestException(errors);
}
}

export class AgentSpinupValidator {
private static validateField(value: string, errorMessage: string): void {
if (!value) {
Expand Down
Loading

0 comments on commit 038b12d

Please sign in to comment.