Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions apps/agent-service/src/agent-service.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,4 +323,61 @@ export class AgentServiceController {
async agentdetailsByOrgId(payload: { orgId: string }): Promise<IStoreAgent> {
return this.agentServiceService.getAgentDetails(payload.orgId);
}

@MessagePattern({ cmd: 'agent-create-oid4vc-issuer' })
// eslint-disable-next-line @typescript-eslint/no-explicit-any
async oidcIssuerCreate(payload: { issuerCreation; url: string; orgId: string }): Promise<any> {
return this.agentServiceService.oidcIssuerCreate(payload.issuerCreation, payload.url, payload.orgId);
}
@MessagePattern({ cmd: 'delete-oid4vc-issuer' })
async oidcDeleteIssuer(payload: { url: string; orgId: string }): Promise<object | string> {
return this.agentServiceService.deleteOidcIssuer(payload.url, payload.orgId);
}
@MessagePattern({ cmd: 'agent-create-oid4vc-template' })
// eslint-disable-next-line @typescript-eslint/no-explicit-any
async oidcIssuerTemplate(payload: { templatePayload; url: string; orgId: string }): Promise<any> {
return this.agentServiceService.oidcIssuerTemplate(payload.templatePayload, payload.url, payload.orgId);
}
//TODO: change message for oid4vc
@MessagePattern({ cmd: 'oid4vc-get-issuer-by-id' })
// eslint-disable-next-line @typescript-eslint/no-explicit-any
async oidcGetIssuerById(payload: { url: string; orgId: string }): Promise<any> {
return this.agentServiceService.oidcGetIssuerById(payload.url, payload.orgId);
}

@MessagePattern({ cmd: 'oid4vc-get-issuers-agent-service' })
// eslint-disable-next-line @typescript-eslint/no-explicit-any
async oidcGetIssuers(payload: { url: string; orgId: string }): Promise<any> {
return this.agentServiceService.oidcGetIssuers(payload.url, payload.orgId);
}

@MessagePattern({ cmd: 'agent-service-oid4vc-create-credential-offer' })
// eslint-disable-next-line @typescript-eslint/no-explicit-any
async oidcCreateCredentialOffer(payload: { credentialPayload; url: string; orgId: string }): Promise<any> {
return this.agentServiceService.oidcCreateCredentialOffer(payload.credentialPayload, payload.url, payload.orgId);
}

@MessagePattern({ cmd: 'agent-service-oid4vc-update-credential-offer' })
// eslint-disable-next-line @typescript-eslint/no-explicit-any
async oidcUpdateCredentialOffer(payload: { issuanceMetadata; url: string; orgId: string }): Promise<any> {
return this.agentServiceService.oidcUpdateCredentialOffer(payload.issuanceMetadata, payload.url, payload.orgId);
}

@MessagePattern({ cmd: 'agent-service-oid4vc-get-credential-offer-by-id' })
// eslint-disable-next-line @typescript-eslint/no-explicit-any
async oidcGetCredentialOfferById(payload: { url: string; orgId: string; offerId: string }): Promise<any> {
return this.agentServiceService.oidcGetCredentialOfferById(payload.url, payload.orgId);
}

@MessagePattern({ cmd: 'agent-service-oid4vc-get-all-credential-offers' })
// eslint-disable-next-line @typescript-eslint/no-explicit-any
async oidcGetAllCredentialOffers(payload: { url: string; orgId: string }): Promise<any> {
return this.agentServiceService.oidcGetAllCredentialOffers(payload.url, payload.orgId);
}

@MessagePattern({ cmd: 'agent-service-oid4vc-delete-credential-offer' })
// eslint-disable-next-line @typescript-eslint/no-explicit-any
async oidcDeleteCredentialOffer(payload: { url: string; orgId: string }): Promise<any> {
return this.agentServiceService.oidcDeleteCredentialOffer(payload.url, payload.orgId);
}
}
132 changes: 132 additions & 0 deletions apps/agent-service/src/agent-service.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1410,6 +1410,138 @@ export class AgentServiceService {
}
}

async oidcIssuerCreate(issueData, url: string, orgId: string): Promise<object> {
try {
const getApiKey = await this.getOrgAgentApiKey(orgId);
const data = await this.commonService
.httpPost(url, issueData, { headers: { authorization: getApiKey } })
.then(async (response) => response);
return data;
} catch (error) {
this.logger.error(`Error in oidcIssuerCreate in agent service : ${JSON.stringify(error)}`);
throw error;
}
}

async deleteOidcIssuer(url: string, orgId: string): Promise<object | string> {
try {
const getApiKey = await this.getOrgAgentApiKey(orgId);
const response = await this.commonService.httpDelete(url, {
headers: { authorization: getApiKey }
});
if (response?.status === 204) {
return 'Data deleted successfully';
}
} catch (error) {
this.logger.error(`Error in deleteOidcIssuer in agent service : ${JSON.stringify(error)}`);
throw error;
}
}

async oidcGetIssuerById(url: string, orgId: string): Promise<object> {
try {
const getApiKey = await this.getOrgAgentApiKey(orgId);
const data = await this.commonService
.httpGet(url, { headers: { authorization: getApiKey } })
.then(async (response) => response);
return data;
} catch (error) {
this.logger.error(`Error in oidcGetIssuerById in agent service : ${JSON.stringify(error)}`);
throw error;
}
}

async oidcGetIssuers(url: string, orgId: string): Promise<object> {
try {
const getApiKey = await this.getOrgAgentApiKey(orgId);
const data = await this.commonService
.httpGet(url, { headers: { authorization: getApiKey } })
.then(async (response) => response);
return data;
} catch (error) {
this.logger.error(`Error in oidcGetIssuers in agent service : ${JSON.stringify(error)}`);
throw error;
}
}

async oidcCreateCredentialOffer(credentialPayload, url: string, orgId: string): Promise<object> {
try {
const getApiKey = await this.getOrgAgentApiKey(orgId);
const data = await this.commonService
.httpPost(url, credentialPayload, { headers: { authorization: getApiKey } })
.then(async (response) => response);
return data;
} catch (error) {
this.logger.error(`Error in oidcCreateCredentialOffer in agent service : ${JSON.stringify(error)}`);
throw error;
}
}

async oidcUpdateCredentialOffer(issuanceMetadata, url: string, orgId: string): Promise<object> {
try {
const getApiKey = await this.getOrgAgentApiKey(orgId);
const data = await this.commonService
.httpPut(url, issuanceMetadata, { headers: { authorization: getApiKey } })
.then(async (response) => response);
return data;
} catch (error) {
this.logger.error(`Error in _oidcUpdateCredentialOffer in agent service : ${JSON.stringify(error)}`);
throw error;
}
}

async oidcGetCredentialOfferById(url: string, orgId: string): Promise<object> {
try {
const getApiKey = await this.getOrgAgentApiKey(orgId);
const data = await this.commonService
.httpGet(url, { headers: { authorization: getApiKey } })
.then(async (response) => response);
return data;
} catch (error) {
this.logger.error(`Error in _oidcGetCredentialOfferById in agent service : ${JSON.stringify(error)}`);
throw error;
}
}

async oidcGetAllCredentialOffers(url: string, orgId: string): Promise<object> {
try {
const getApiKey = await this.getOrgAgentApiKey(orgId);
const data = await this.commonService
.httpGet(url, { headers: { authorization: getApiKey } })
.then(async (response) => response);
return data;
} catch (error) {
this.logger.error(`Error in _oidcGetAllCredentialOffers in agent service : ${JSON.stringify(error)}`);
throw error;
}
}

async oidcDeleteCredentialOffer(url: string, orgId: string): Promise<object> {
try {
const getApiKey = await this.getOrgAgentApiKey(orgId);
const data = await this.commonService
.httpDelete(`${url}`, { headers: { authorization: getApiKey } })
.then(async (response) => response);
return data;
} catch (error) {
this.logger.error(`Error in _oidcDeleteCredentialOffer in agent service : ${JSON.stringify(error)}`);
throw error;
}
}

async oidcIssuerTemplate(templatePayload, url: string, orgId: string): Promise<object> {
try {
const getApiKey = await this.getOrgAgentApiKey(orgId);
const data = await this.commonService
.httpPut(url, templatePayload, { headers: { authorization: getApiKey } })
.then(async (response) => response);
return data;
} catch (error) {
this.logger.error(`Error in oidcIssuerTemplate in agent service : ${JSON.stringify(error)}`);
throw error;
}
}

async getIssueCredentials(url: string, apiKey: string): Promise<object> {
try {
const data = await this.commonService
Expand Down
43 changes: 23 additions & 20 deletions apps/api-gateway/src/agent-service/dto/create-schema.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,29 @@ import { ApiProperty } from '@nestjs/swagger';
import { IsString, IsNotEmpty, IsArray } from 'class-validator';

export class CreateTenantSchemaDto {
@ApiProperty()
@IsString({ message: 'tenantId must be a string' }) @IsNotEmpty({ message: 'please provide valid tenantId' })
tenantId: string;

@ApiProperty()
@IsString({ message: 'schema version must be a string' }) @IsNotEmpty({ message: 'please provide valid schema version' })
schemaVersion: string;
@ApiProperty()
@IsString({ message: 'tenantId must be a string' })
@IsNotEmpty({ message: 'please provide valid tenantId' })
tenantId: string;

@ApiProperty()
@IsString({ message: 'schema name must be a string' }) @IsNotEmpty({ message: 'please provide valid schema name' })
schemaName: string;
@ApiProperty()
@IsString({ message: 'schema version must be a string' })
@IsNotEmpty({ message: 'please provide valid schema version' })
schemaVersion: string;

@ApiProperty()
@IsArray({ message: 'attributes must be an array' })
@IsString({ each: true })
@IsNotEmpty({ message: 'please provide valid attributes' })
attributes: string[];
@ApiProperty()
@IsString({ message: 'schema name must be a string' })
@IsNotEmpty({ message: 'please provide valid schema name' })
schemaName: string;

@ApiProperty()

@IsNotEmpty({ message: 'please provide orgId' })
orgId: string;
}
@ApiProperty()
@IsArray({ message: 'attributes must be an array' })
@IsString({ each: true })
// TODO: IsNotEmpty won't work for array. Must use @ArrayNotEmpty() instead
@IsNotEmpty({ message: 'please provide valid attributes' })
attributes: string[];

@ApiProperty()
@IsNotEmpty({ message: 'please provide orgId' })
orgId: string;
}
4 changes: 3 additions & 1 deletion apps/api-gateway/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { ContextModule } from '@credebl/context/contextModule';
import { LoggerModule } from '@credebl/logger/logger.module';
import { GlobalConfigModule } from '@credebl/config/global-config.module';
import { ConfigModule as PlatformConfig } from '@credebl/config/config.module';
import { Oid4vcIssuanceModule } from './oid4vc-issuance/oid4vc-issuance.module';

@Module({
imports: [
Expand Down Expand Up @@ -64,7 +65,8 @@ import { ConfigModule as PlatformConfig } from '@credebl/config/config.module';
GlobalConfigModule,
CacheModule.register({ store: redisStore, host: process.env.REDIS_HOST, port: process.env.REDIS_PORT }),
GeoLocationModule,
CloudWalletModule
CloudWalletModule,
Oid4vcIssuanceModule
],
controllers: [AppController],
providers: [
Expand Down
1 change: 0 additions & 1 deletion apps/api-gateway/src/issuance/issuance.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,6 @@ export class IssuanceController {
@Res() res: Response
): Promise<Response> {
issueCredentialDto.type = 'Issuance';

if (id && 'default' === issueCredentialDto.contextCorrelationId) {
issueCredentialDto.orgId = id;
}
Expand Down
4 changes: 3 additions & 1 deletion apps/api-gateway/src/issuance/issuance.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/* eslint-disable camelcase */
/* eslint-disable @typescript-eslint/explicit-function-return-type */
// TODO: Remove this
import { Injectable, Inject } from '@nestjs/common';
import { ClientProxy } from '@nestjs/microservices';
import { BaseService } from 'libs/service/base.service';
Expand Down Expand Up @@ -26,8 +28,8 @@ import {
IIssuedCredential
} from '@credebl/common/interfaces/issuance.interface';
import { IssueCredentialDto } from './dtos/multi-connection.dto';
import { user } from '@prisma/client';
import { NATSClient } from '@credebl/common/NATSClient';
import { user } from '@prisma/client';
@Injectable()
export class IssuanceService extends BaseService {
constructor(
Expand Down
Loading