Skip to content

Commit

Permalink
Merge pull request #596 from credebl/agent-token-encryption
Browse files Browse the repository at this point in the history
feat: agent token encryption
  • Loading branch information
KulkarniShashank authored Mar 21, 2024
2 parents 72dc53a + 613c860 commit 48fce00
Show file tree
Hide file tree
Showing 14 changed files with 881 additions and 954 deletions.
85 changes: 39 additions & 46 deletions apps/agent-service/src/agent-service.controller.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { Controller } from '@nestjs/common';
import { MessagePattern } from '@nestjs/microservices';
import { AgentServiceService } from './agent-service.service';
import { IAgentStatus, IConnectionDetails, IUserRequestInterface, ISendProofRequestPayload, IAgentSpinUpSatus, IGetCredDefAgentRedirection, IGetSchemaAgentRedirection, IAgentSpinupDto, IIssuanceCreateOffer, ITenantCredDef, ITenantDto, ITenantSchema, IOutOfBandCredentialOffer, IProofPresentation, IAgentProofRequest, IPresentation, IDidCreate, IWallet, ITenantRecord } from './interface/agent-service.interface';
import { IAgentStatus, IConnectionDetails, IUserRequestInterface, ISendProofRequestPayload, IAgentSpinUpSatus, IGetCredDefAgentRedirection, IGetSchemaAgentRedirection, IAgentSpinupDto, IIssuanceCreateOffer, ITenantCredDef, ITenantDto, ITenantSchema, IOutOfBandCredentialOffer, IAgentProofRequest, IDidCreate, IWallet, ITenantRecord } from './interface/agent-service.interface';
import { user } from '@prisma/client';
import { IConnectionDetailsById } from 'apps/api-gateway/src/interfaces/IConnectionSearch.interface';
import { IProofPresentationDetails } from '@credebl/common/interfaces/verification.interface';
import { InvitationMessage } from '@credebl/common/interfaces/agent-service.interface';

@Controller()
Expand Down Expand Up @@ -67,17 +65,17 @@ export class AgentServiceController {

//DONE
@MessagePattern({ cmd: 'agent-create-connection-legacy-invitation' })
async createLegacyConnectionInvitation(payload: { connectionPayload: IConnectionDetails, url: string, apiKey: string }): Promise<InvitationMessage> {
return this.agentServiceService.createLegacyConnectionInvitation(payload.connectionPayload, payload.url, payload.apiKey);
async createLegacyConnectionInvitation(payload: { connectionPayload: IConnectionDetails, url: string, orgId: string }): Promise<InvitationMessage> {
return this.agentServiceService.createLegacyConnectionInvitation(payload.connectionPayload, payload.url, payload.orgId);
}

@MessagePattern({ cmd: 'agent-send-credential-create-offer' })
async sendCredentialCreateOffer(payload: {
issueData: IIssuanceCreateOffer;
url: string;
apiKey: string;
orgId: string;
}): Promise<object> {
return this.agentServiceService.sendCredentialCreateOffer(payload.issueData, payload.url, payload.apiKey);
return this.agentServiceService.sendCredentialCreateOffer(payload.issueData, payload.url, payload.orgId);
}

//DONE
Expand All @@ -88,8 +86,8 @@ export class AgentServiceController {

//DONE
@MessagePattern({ cmd: 'agent-get-issued-credentials-by-credentialDefinitionId' })
async getIssueCredentialsbyCredentialRecordId(payload: { url: string; apiKey: string }): Promise<object> {
return this.agentServiceService.getIssueCredentialsbyCredentialRecordId(payload.url, payload.apiKey);
async getIssueCredentialsbyCredentialRecordId(payload: { url: string; orgId: string }): Promise<object> {
return this.agentServiceService.getIssueCredentialsbyCredentialRecordId(payload.url, payload.orgId);
}
//DONE
@MessagePattern({ cmd: 'agent-get-proof-presentations' })
Expand All @@ -99,34 +97,34 @@ export class AgentServiceController {

//DONE
@MessagePattern({ cmd: 'agent-get-proof-presentation-by-id' })
async getProofPresentationById(payload: { url: string; apiKey: string }): Promise<IProofPresentation> {
return this.agentServiceService.getProofPresentationById(payload.url, payload.apiKey);
async getProofPresentationById(payload: { url: string; orgId: string }): Promise<object> {
return this.agentServiceService.getProofPresentationById(payload.url, payload.orgId);
}

//DONE
@MessagePattern({ cmd: 'agent-send-proof-request' })
async sendProofRequest(payload: {
proofRequestPayload: ISendProofRequestPayload;
url: string;
apiKey: string;
orgId: string;
}): Promise<IAgentProofRequest> {
return this.agentServiceService.sendProofRequest(payload.proofRequestPayload, payload.url, payload.apiKey);
return this.agentServiceService.sendProofRequest(payload.proofRequestPayload, payload.url, payload.orgId);
}
//DONE
@MessagePattern({ cmd: 'agent-verify-presentation' })
async verifyPresentation(payload: { url: string; apiKey: string }): Promise<IPresentation> {
return this.agentServiceService.verifyPresentation(payload.url, payload.apiKey);
async verifyPresentation(payload: { url: string; orgId: string }): Promise<object> {
return this.agentServiceService.verifyPresentation(payload.url, payload.orgId);
}

//DONE
@MessagePattern({ cmd: 'agent-get-all-connections' })
async getConnections(payload: { url: string; apiKey: string }): Promise<object> {
return this.agentServiceService.getConnections(payload.url, payload.apiKey);
async getConnections(payload: { url: string; orgId: string }): Promise<object> {
return this.agentServiceService.getConnections(payload.url, payload.orgId);
}

@MessagePattern({ cmd: 'agent-get-connection-details-by-connectionId' })
async getConnectionsByconnectionId(payload: { url: string, apiKey: string }): Promise<IConnectionDetailsById> {
return this.agentServiceService.getConnectionsByconnectionId(payload.url, payload.apiKey);
async getConnectionsByconnectionId(payload: { url: string, orgId: string }): Promise<object> {
return this.agentServiceService.getConnectionsByconnectionId(payload.url, payload.orgId);
}

/**
Expand All @@ -149,97 +147,92 @@ export class AgentServiceController {
async sendOutOfBandProofRequest(payload: {
proofRequestPayload: ISendProofRequestPayload;
url: string;
apiKey: string;
orgId: string;
}): Promise<object> {
return this.agentServiceService.sendOutOfBandProofRequest(payload.proofRequestPayload, payload.url, payload.apiKey);
return this.agentServiceService.sendOutOfBandProofRequest(payload.proofRequestPayload, payload.url, payload.orgId);
}

//DONE
@MessagePattern({ cmd: 'get-agent-verified-proof-details' })
async getVerifiedProofDetails(payload: { url: string; apiKey: string }): Promise<IProofPresentationDetails[]> {
return this.agentServiceService.getVerifiedProofDetails(payload.url, payload.apiKey);
async getVerifiedProofDetails(payload: { url: string; orgId: string }): Promise<object> {
return this.agentServiceService.getVerifiedProofDetails(payload.url, payload.orgId);
}

@MessagePattern({ cmd: 'agent-schema-endorsement-request' })
async schemaEndorsementRequest(payload: {
url: string;
apiKey: string;
orgId: string;
requestSchemaPayload: object;
}): Promise<object> {
return this.agentServiceService.schemaEndorsementRequest(payload.url, payload.apiKey, payload.requestSchemaPayload);
return this.agentServiceService.schemaEndorsementRequest(payload.url, payload.orgId, payload.requestSchemaPayload);
}
@MessagePattern({ cmd: 'agent-credDef-endorsement-request' })
async credDefEndorsementRequest(payload: {
url: string;
apiKey: string;
orgId: string;
requestSchemaPayload: object;
}): Promise<object> {
return this.agentServiceService.credDefEndorsementRequest(
payload.url,
payload.apiKey,
payload.orgId,
payload.requestSchemaPayload
);
}

//DONE
@MessagePattern({ cmd: 'agent-sign-transaction' })
async signTransaction(payload: { url: string; apiKey: string; signEndorsementPayload: object }): Promise<object> {
return this.agentServiceService.signTransaction(payload.url, payload.apiKey, payload.signEndorsementPayload);
async signTransaction(payload: { url: string; orgId: string; signEndorsementPayload: object }): Promise<object> {
return this.agentServiceService.signTransaction(payload.url, payload.orgId, payload.signEndorsementPayload);
}

//DONE
@MessagePattern({ cmd: 'agent-submit-transaction' })
async submitTransaction(payload: { url: string; apiKey: string; submitEndorsementPayload: object }): Promise<object> {
return this.agentServiceService.sumbitTransaction(payload.url, payload.apiKey, payload.submitEndorsementPayload);
async submitTransaction(payload: { url: string; orgId: string; submitEndorsementPayload: object }): Promise<object> {
return this.agentServiceService.sumbitTransaction(payload.url, payload.orgId, payload.submitEndorsementPayload);
}

//DONE
@MessagePattern({ cmd: 'agent-out-of-band-credential-offer' })
async outOfBandCredentialOffer(payload: { outOfBandIssuancePayload: IOutOfBandCredentialOffer, url: string, apiKey: string }): Promise<object> {
return this.agentServiceService.outOfBandCredentialOffer(payload.outOfBandIssuancePayload, payload.url, payload.apiKey);
async outOfBandCredentialOffer(payload: { outOfBandIssuancePayload: IOutOfBandCredentialOffer, url: string, orgId: string }): Promise<object> {
return this.agentServiceService.outOfBandCredentialOffer(payload.outOfBandIssuancePayload, payload.url, payload.orgId);
}

@MessagePattern({ cmd: 'delete-wallet' })
async deleteWallet(payload: { url; apiKey }): Promise<object> {
return this.agentServiceService.deleteWallet(payload.url, payload.apiKey);
}

@MessagePattern({ cmd: 'get-org-agent-api-key' })
async getOrgAgentApiKey(payload: { orgId: string }): Promise<string> {
return this.agentServiceService.getOrgAgentApiKey(payload.orgId);
}

@MessagePattern({ cmd: 'agent-receive-invitation-url' })
async receiveInvitationUrl(payload: {
url,
apiKey,
orgId,
receiveInvitationUrl
}): Promise<string> {
return this.agentServiceService.receiveInvitationUrl(payload.receiveInvitationUrl, payload.url, payload.apiKey);
return this.agentServiceService.receiveInvitationUrl(payload.receiveInvitationUrl, payload.url, payload.orgId);
}

@MessagePattern({ cmd: 'agent-receive-invitation' })
async receiveInvitation(payload: {
url,
apiKey,
orgId,
receiveInvitation
}): Promise<string> {
return this.agentServiceService.receiveInvitation(payload.receiveInvitation, payload.url, payload.apiKey);
return this.agentServiceService.receiveInvitation(payload.receiveInvitation, payload.url, payload.orgId);
}

@MessagePattern({ cmd: 'agent-send-question' })
async sendQuestion(payload: {
url,
apiKey,
orgId,
questionPayload
}): Promise<object> {

return this.agentServiceService.sendQuestion(payload.questionPayload, payload.url, payload.apiKey);
return this.agentServiceService.sendQuestion(payload.questionPayload, payload.url, payload.orgId);
}

@MessagePattern({ cmd: 'agent-get-question-answer-record' })
async getQuestionAnswersRecord(payload: { url: string, apiKey: string }): Promise<object> {
return this.agentServiceService.getQuestionAnswersRecord(payload.url, payload.apiKey);
async getQuestionAnswersRecord(payload: { url: string, orgId: string }): Promise<object> {
return this.agentServiceService.getQuestionAnswersRecord(payload.url, payload.orgId);
}

@MessagePattern({ cmd: 'polygon-create-keys' })
Expand Down
Loading

0 comments on commit 48fce00

Please sign in to comment.