Skip to content

Commit dbf594f

Browse files
authored
feat: add sign and verify api (#1277)
* feat: add sign and verify api Signed-off-by: Krishna Waske <[email protected]> * fix: feature ids Signed-off-by: Krishna Waske <[email protected]> * fix: add validations on sign and also add validations globally to allow validations to be overriden for specific DTOs Signed-off-by: Krishna Waske <[email protected]> * fix: remove declarative type from enum to make it validatable Signed-off-by: Krishna Waske <[email protected]> --------- Signed-off-by: Krishna Waske <[email protected]>
1 parent e0b640c commit dbf594f

File tree

9 files changed

+866
-319
lines changed

9 files changed

+866
-319
lines changed

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

Lines changed: 67 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import {
2626
import { user } from '@prisma/client';
2727
import { InvitationMessage } from '@credebl/common/interfaces/agent-service.interface';
2828
import { AgentSpinUpStatus } from '@credebl/enum/enum';
29+
import { SignDataDto } from '../../api-gateway/src/agent-service/dto/agent-service.dto';
2930

3031
@Controller()
3132
export class AgentServiceController {
@@ -37,7 +38,7 @@ export class AgentServiceController {
3738
* @returns Get agent status
3839
*/
3940
@MessagePattern({ cmd: 'agent-spinup' })
40-
async walletProvision(payload: { agentSpinupDto: IAgentSpinupDto, user: IUserRequestInterface }): Promise<{
41+
async walletProvision(payload: { agentSpinupDto: IAgentSpinupDto; user: IUserRequestInterface }): Promise<{
4142
agentSpinupStatus: AgentSpinUpStatus;
4243
}> {
4344
return this.agentServiceService.walletProvision(payload.agentSpinupDto, payload.user);
@@ -46,8 +47,8 @@ export class AgentServiceController {
4647
//DONE
4748
@MessagePattern({ cmd: 'create-tenant' })
4849
async createTenant(payload: {
49-
createTenantDto: ITenantDto,
50-
user: IUserRequestInterface,
50+
createTenantDto: ITenantDto;
51+
user: IUserRequestInterface;
5152
}): Promise<IAgentSpinUpSatus> {
5253
return this.agentServiceService.createTenant(payload.createTenantDto, payload.user);
5354
}
@@ -56,12 +57,12 @@ export class AgentServiceController {
5657
* @returns did
5758
*/
5859
@MessagePattern({ cmd: 'create-did' })
59-
async createDid(payload: { createDidDto: IDidCreate, orgId: string, user: IUserRequestInterface }): Promise<object> {
60+
async createDid(payload: { createDidDto: IDidCreate; orgId: string; user: IUserRequestInterface }): Promise<object> {
6061
return this.agentServiceService.createDid(payload.createDidDto, payload.orgId, payload.user);
6162
}
6263

6364
@MessagePattern({ cmd: 'create-wallet' })
64-
async createWallet(payload: { createWalletDto: IWallet, user: IUserRequestInterface }): Promise<ITenantRecord> {
65+
async createWallet(payload: { createWalletDto: IWallet; user: IUserRequestInterface }): Promise<ITenantRecord> {
6566
return this.agentServiceService.createWallet(payload.createWalletDto);
6667
}
6768

@@ -73,7 +74,7 @@ export class AgentServiceController {
7374

7475
//DONE
7576
@MessagePattern({ cmd: 'agent-create-w3c-schema' })
76-
async createW3CSchema(payload: { url, orgId, schemaRequestPayload }): Promise<object> {
77+
async createW3CSchema(payload: { url; orgId; schemaRequestPayload }): Promise<object> {
7778
return this.agentServiceService.createW3CSchema(payload.url, payload.orgId, payload.schemaRequestPayload);
7879
}
7980

@@ -99,8 +100,8 @@ export class AgentServiceController {
99100
@MessagePattern({ cmd: 'agent-create-connection-legacy-invitation' })
100101
async createLegacyConnectionInvitation(payload: {
101102
connectionPayload: IConnectionDetails;
102-
url: string,
103-
orgId: string,
103+
url: string;
104+
orgId: string;
104105
}): Promise<InvitationMessage> {
105106
return this.agentServiceService.createLegacyConnectionInvitation(
106107
payload.connectionPayload,
@@ -112,58 +113,58 @@ export class AgentServiceController {
112113
@MessagePattern({ cmd: 'agent-send-credential-create-offer' })
113114
async sendCredentialCreateOffer(payload: {
114115
issueData: IIssuanceCreateOffer;
115-
url: string,
116-
orgId: string,
116+
url: string;
117+
orgId: string;
117118
}): Promise<object> {
118119
return this.agentServiceService.sendCredentialCreateOffer(payload.issueData, payload.url, payload.orgId);
119120
}
120121

121122
//DONE
122123
@MessagePattern({ cmd: 'agent-get-all-issued-credentials' })
123-
async getIssueCredentials(payload: { url: string, apiKey: string }): Promise<object> {
124+
async getIssueCredentials(payload: { url: string; apiKey: string }): Promise<object> {
124125
return this.agentServiceService.getIssueCredentials(payload.url, payload.apiKey);
125126
}
126127

127128
//DONE
128129
@MessagePattern({ cmd: 'agent-get-issued-credentials-by-credentialDefinitionId' })
129-
async getIssueCredentialsbyCredentialRecordId(payload: { url: string, orgId: string }): Promise<object> {
130+
async getIssueCredentialsbyCredentialRecordId(payload: { url: string; orgId: string }): Promise<object> {
130131
return this.agentServiceService.getIssueCredentialsbyCredentialRecordId(payload.url, payload.orgId);
131132
}
132133
//DONE
133134
@MessagePattern({ cmd: 'agent-get-proof-presentations' })
134-
async getProofPresentations(payload: { url: string, apiKey: string }): Promise<object> {
135+
async getProofPresentations(payload: { url: string; apiKey: string }): Promise<object> {
135136
return this.agentServiceService.getProofPresentations(payload.url, payload.apiKey);
136137
}
137138

138139
//DONE
139140
@MessagePattern({ cmd: 'agent-get-proof-presentation-by-id' })
140-
async getProofPresentationById(payload: { url: string, orgId: string }): Promise<object> {
141+
async getProofPresentationById(payload: { url: string; orgId: string }): Promise<object> {
141142
return this.agentServiceService.getProofPresentationById(payload.url, payload.orgId);
142143
}
143144

144145
//DONE
145146
@MessagePattern({ cmd: 'agent-send-proof-request' })
146147
async sendProofRequest(payload: {
147-
proofRequestPayload: ISendProofRequestPayload,
148-
url: string,
149-
orgId: string,
148+
proofRequestPayload: ISendProofRequestPayload;
149+
url: string;
150+
orgId: string;
150151
}): Promise<IAgentProofRequest> {
151152
return this.agentServiceService.sendProofRequest(payload.proofRequestPayload, payload.url, payload.orgId);
152153
}
153154
//DONE
154155
@MessagePattern({ cmd: 'agent-verify-presentation' })
155-
async verifyPresentation(payload: { url: string, orgId: string }): Promise<object> {
156+
async verifyPresentation(payload: { url: string; orgId: string }): Promise<object> {
156157
return this.agentServiceService.verifyPresentation(payload.url, payload.orgId);
157158
}
158159

159160
//DONE
160161
@MessagePattern({ cmd: 'agent-get-all-connections' })
161-
async getConnections(payload: { url: string, orgId: string }): Promise<object> {
162+
async getConnections(payload: { url: string; orgId: string }): Promise<object> {
162163
return this.agentServiceService.getConnections(payload.url, payload.orgId);
163164
}
164165

165166
@MessagePattern({ cmd: 'agent-get-connection-details-by-connectionId' })
166-
async getConnectionsByconnectionId(payload: { url: string, orgId: string }): Promise<object> {
167+
async getConnectionsByconnectionId(payload: { url: string; orgId: string }): Promise<object> {
167168
return this.agentServiceService.getConnectionsByconnectionId(payload.url, payload.orgId);
168169
}
169170

@@ -173,10 +174,30 @@ export class AgentServiceController {
173174
* @returns Get agent health
174175
*/
175176
@MessagePattern({ cmd: 'agent-health' })
176-
async getAgentHealth(payload: { user: user, orgId: string }): Promise<IAgentStatus> {
177+
async getAgentHealth(payload: { user: user; orgId: string }): Promise<IAgentStatus> {
177178
return this.agentServiceService.getAgentHealthDetails(payload.orgId);
178179
}
179180

181+
/**
182+
* Sign data from agent
183+
* @param payload
184+
* @returns Signed data by agent
185+
*/
186+
@MessagePattern({ cmd: 'sign-data-from-agent' })
187+
async signData(payload: { data: SignDataDto; orgId: string }): Promise<unknown> {
188+
return this.agentServiceService.signDataFromAgent(payload.data, payload.orgId);
189+
}
190+
191+
/**
192+
* Get agent health
193+
* @param payload
194+
* @returns Get agent health
195+
*/
196+
@MessagePattern({ cmd: 'verify-signature-from-agent' })
197+
async verifysignature(payload: { data: unknown; orgId: string }): Promise<unknown> {
198+
return this.agentServiceService.verifysignature(payload.data, payload.orgId);
199+
}
200+
180201
@MessagePattern({ cmd: 'get-ledger-config' })
181202
async getLedgerConfig(payload: { user: IUserRequestInterface }): Promise<object> {
182203
return this.agentServiceService.getLedgerConfigDetails(payload.user);
@@ -185,24 +206,24 @@ export class AgentServiceController {
185206
//DONE
186207
@MessagePattern({ cmd: 'agent-send-out-of-band-proof-request' })
187208
async sendOutOfBandProofRequest(payload: {
188-
proofRequestPayload: ISendProofRequestPayload,
189-
url: string,
190-
orgId: string,
209+
proofRequestPayload: ISendProofRequestPayload;
210+
url: string;
211+
orgId: string;
191212
}): Promise<object> {
192213
return this.agentServiceService.sendOutOfBandProofRequest(payload.proofRequestPayload, payload.url, payload.orgId);
193214
}
194215

195216
//DONE
196217
@MessagePattern({ cmd: 'get-agent-verified-proof-details' })
197-
async getVerifiedProofDetails(payload: { url: string, orgId: string }): Promise<object> {
218+
async getVerifiedProofDetails(payload: { url: string; orgId: string }): Promise<object> {
198219
return this.agentServiceService.getVerifiedProofDetails(payload.url, payload.orgId);
199220
}
200221

201222
@MessagePattern({ cmd: 'agent-schema-endorsement-request' })
202223
async schemaEndorsementRequest(payload: {
203-
url: string,
204-
orgId: string,
205-
requestSchemaPayload: object,
224+
url: string;
225+
orgId: string;
226+
requestSchemaPayload: object;
206227
}): Promise<object> {
207228
return this.agentServiceService.schemaEndorsementRequest(payload.url, payload.orgId, payload.requestSchemaPayload);
208229
}
@@ -217,22 +238,22 @@ export class AgentServiceController {
217238

218239
//DONE
219240
@MessagePattern({ cmd: 'agent-sign-transaction' })
220-
async signTransaction(payload: { url: string, orgId: string, signEndorsementPayload: object }): Promise<object> {
241+
async signTransaction(payload: { url: string; orgId: string; signEndorsementPayload: object }): Promise<object> {
221242
return this.agentServiceService.signTransaction(payload.url, payload.orgId, payload.signEndorsementPayload);
222243
}
223244

224245
//DONE
225246
@MessagePattern({ cmd: 'agent-submit-transaction' })
226-
async submitTransaction(payload: { url: string; orgId: string, submitEndorsementPayload: object }): Promise<object> {
247+
async submitTransaction(payload: { url: string; orgId: string; submitEndorsementPayload: object }): Promise<object> {
227248
return this.agentServiceService.sumbitTransaction(payload.url, payload.orgId, payload.submitEndorsementPayload);
228249
}
229250

230251
//DONE
231252
@MessagePattern({ cmd: 'agent-out-of-band-credential-offer' })
232253
async outOfBandCredentialOffer(payload: {
233-
outOfBandIssuancePayload: IOutOfBandCredentialOffer,
234-
url: string,
235-
orgId: string,
254+
outOfBandIssuancePayload: IOutOfBandCredentialOffer;
255+
url: string;
256+
orgId: string;
236257
}): Promise<object> {
237258
return this.agentServiceService.outOfBandCredentialOffer(
238259
payload.outOfBandIssuancePayload,
@@ -242,32 +263,32 @@ export class AgentServiceController {
242263
}
243264

244265
@MessagePattern({ cmd: 'delete-wallet' })
245-
async deleteWallet(payload: { orgId, user }): Promise<object> {
266+
async deleteWallet(payload: { orgId; user }): Promise<object> {
246267
return this.agentServiceService.deleteWallet(payload.orgId, payload.user);
247268
}
248269

249270
@MessagePattern({ cmd: 'agent-receive-invitation-url' })
250-
async receiveInvitationUrl(payload: { url, orgId, receiveInvitationUrl }): Promise<string> {
271+
async receiveInvitationUrl(payload: { url; orgId; receiveInvitationUrl }): Promise<string> {
251272
return this.agentServiceService.receiveInvitationUrl(payload.receiveInvitationUrl, payload.url, payload.orgId);
252273
}
253274

254275
@MessagePattern({ cmd: 'agent-receive-invitation' })
255-
async receiveInvitation(payload: { url, orgId, receiveInvitation }): Promise<string> {
276+
async receiveInvitation(payload: { url; orgId; receiveInvitation }): Promise<string> {
256277
return this.agentServiceService.receiveInvitation(payload.receiveInvitation, payload.url, payload.orgId);
257278
}
258279

259280
@MessagePattern({ cmd: 'agent-send-question' })
260-
async sendQuestion(payload: { url, orgId, questionPayload }): Promise<object> {
281+
async sendQuestion(payload: { url; orgId; questionPayload }): Promise<object> {
261282
return this.agentServiceService.sendQuestion(payload.questionPayload, payload.url, payload.orgId);
262283
}
263284

264285
@MessagePattern({ cmd: 'agent-send-basic-message' })
265-
async sendBasicMessage(payload: { url, orgId, content }): Promise<object> {
286+
async sendBasicMessage(payload: { url; orgId; content }): Promise<object> {
266287
return this.agentServiceService.sendBasicMessage(payload.content, payload.url, payload.orgId);
267288
}
268289

269290
@MessagePattern({ cmd: 'agent-get-question-answer-record' })
270-
async getQuestionAnswersRecord(payload: { url: string, orgId: string }): Promise<object> {
291+
async getQuestionAnswersRecord(payload: { url: string; orgId: string }): Promise<object> {
271292
return this.agentServiceService.getQuestionAnswersRecord(payload.url, payload.orgId);
272293
}
273294

@@ -278,9 +299,9 @@ export class AgentServiceController {
278299

279300
@MessagePattern({ cmd: 'agent-create-connection-invitation' })
280301
async createConnectionInvitation(payload: {
281-
url: string,
282-
orgId: string,
283-
connectionPayload: ICreateConnectionInvitation,
302+
url: string;
303+
orgId: string;
304+
connectionPayload: ICreateConnectionInvitation;
284305
}): Promise<object> {
285306
return this.agentServiceService.createConnectionInvitation(payload.url, payload.orgId, payload.connectionPayload);
286307
}
@@ -292,16 +313,14 @@ export class AgentServiceController {
292313
*/
293314
@MessagePattern({ cmd: 'agent-configure' })
294315
async agentConfigure(payload: {
295-
agentConfigureDto: IAgentConfigure,
296-
user: IUserRequestInterface,
316+
agentConfigureDto: IAgentConfigure;
317+
user: IUserRequestInterface;
297318
}): Promise<IStoreAgent> {
298319
return this.agentServiceService.agentConfigure(payload.agentConfigureDto, payload.user);
299320
}
300321

301322
@MessagePattern({ cmd: 'get-agent-details-by-org-id' })
302-
async agentdetailsByOrgId(payload: {
303-
orgId: string,
304-
}): Promise<IStoreAgent> {
323+
async agentdetailsByOrgId(payload: { orgId: string }): Promise<IStoreAgent> {
305324
return this.agentServiceService.getAgentDetails(payload.orgId);
306325
}
307-
}
326+
}

0 commit comments

Comments
 (0)