Skip to content

Commit b255849

Browse files
authored
feat: sign verify rawdata (#1280)
* 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]> * fix: add verification method from primary did of organization to sign credential payload Signed-off-by: Krishna Waske <[email protected]> --------- Signed-off-by: Krishna Waske <[email protected]>
1 parent dbf594f commit b255849

File tree

4 files changed

+448
-428
lines changed

4 files changed

+448
-428
lines changed

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ import { PrismaService } from '@credebl/prisma-service';
7777
import { from } from 'rxjs';
7878
import { NATSClient } from '@credebl/common/NATSClient';
7979
import { SignDataDto } from '../../api-gateway/src/agent-service/dto/agent-service.dto';
80-
80+
import { IVerificationMethod } from 'apps/organization/interfaces/organization.interface';
8181
@Injectable()
8282
@WebSocketGateway()
8383
export class AgentServiceService {
@@ -1595,6 +1595,15 @@ export class AgentServiceService {
15951595

15961596
const { dataTypeToSign, credentialPayload, rawPayload, storeCredential } = data;
15971597

1598+
if (dataTypeToSign === 'jsonLd' && credentialPayload) {
1599+
// Currently, get only primary did for issuance
1600+
const diddoc = await this.agentServiceRepository.getOrgDid(orgId, true);
1601+
const verificationMethod = diddoc[0].didDocument['verificationMethod'] as IVerificationMethod[];
1602+
// For now, we are strictly restricting dids and verification method associated with the primary did
1603+
// We can optionally modify it to be taken from the payload itself
1604+
credentialPayload.verificationMethod = verificationMethod[0].id;
1605+
}
1606+
15981607
const dataToSign = dataTypeToSign === 'jsonLd' ? credentialPayload : rawPayload;
15991608

16001609
// Invoke an API request from the agent to assess its current status

0 commit comments

Comments
 (0)