Skip to content

Commit

Permalink
feat: implementation of DID document for did web method (#601)
Browse files Browse the repository at this point in the history
* wip: did document

Signed-off-by: bhavanakarwade <[email protected]>

* remove unnecessary code

Signed-off-by: bhavanakarwade <[email protected]>

* wip: store did doc in org agents table

Signed-off-by: bhavanakarwade <[email protected]>

---------

Signed-off-by: bhavanakarwade <[email protected]>
Signed-off-by: KulkarniShashank <[email protected]>
  • Loading branch information
bhavanakarwade authored and KulkarniShashank committed Sep 11, 2024
1 parent acb2356 commit 2e66da0
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions apps/agent-service/src/agent-service.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,7 @@ export class AgentServiceService {

const storeOrgAgentData: IStoreOrgAgentDetails = {
did: tenantDetails.DIDCreationOption.did,
didDoc: tenantDetails.DIDCreationOption.didDocument || tenantDetails.DIDCreationOption.didDoc, //changed the didDoc into didDocument
isDidPublic: true,
agentSpinUpStatus: AgentSpinUpStatus.COMPLETED,
agentsTypeId: agentTypeId,
Expand Down Expand Up @@ -904,7 +905,7 @@ export class AgentServiceService {


const walletResponseDetails = await this._createTenantWallet(walletLabel, platformAdminSpinnedUp.org_agents[0].agentEndPoint, platformAdminSpinnedUp.org_agents[0].apiKey);
if (!walletResponseDetails && !walletResponseDetails.id) {
if (!walletResponseDetails && !walletResponseDetails.id) {
throw new InternalServerErrorException('Error while creating the wallet');
}
const didCreateOption = {
Expand Down Expand Up @@ -1260,7 +1261,6 @@ export class AgentServiceService {

// Get organization agent details
const orgAgentDetails: org_agents = await this.agentServiceRepository.getOrgAgentDetails(orgId);

let agentApiKey;
if (orgAgentDetails) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ export interface IStoreOrgAgentDetails {
network?: string;
role?: string;
did?: string;
didDoc?: string;
verkey?: string;
isDidPublic?: boolean;
agentSpinUpStatus?: number;
Expand Down
7 changes: 1 addition & 6 deletions apps/api-gateway/src/agent-service/dto/create-tenant.dto.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
import { trim } from '@credebl/common/cast.helper';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { Transform } from 'class-transformer';
import { MaxLength, IsString, MinLength, Matches, IsOptional } from 'class-validator';
import { MaxLength, IsString, MinLength, IsOptional } from 'class-validator';
import { CreateDidDto } from './create-did.dto';
const labelRegex = /^[a-zA-Z0-9 ]*$/;
export class CreateTenantDto extends CreateDidDto {
@ApiProperty()
@MaxLength(25, { message: 'Maximum length for label must be 25 characters.' })
@IsString({ message: 'label must be in string format.' })
@Transform(({ value }) => trim(value))
@MinLength(2, { message: 'Minimum length for label must be 2 characters.' })
@Matches(labelRegex, { message: 'Label must not contain special characters.' })
@Matches(/^\S*$/, {
message: 'Spaces are not allowed in label'
})
label: string;

@ApiProperty({ example: 'ojIckSD2jqNzOqIrAGzL' })
Expand Down
1 change: 1 addition & 0 deletions apps/organization/repositories/organization.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ export class OrganizationRepository {
select: {
id: true,
orgDid: true,
didDocument: true,
walletName: true,
agentEndPoint: true,
agentSpinUpStatus: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "org_agents" ADD COLUMN "didDocument" JSONB;
1 change: 1 addition & 0 deletions libs/prisma-service/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ model org_agents {
orgId String? @unique @db.Uuid
orgAgentTypeId String? @db.Uuid
ledgerId String? @db.Uuid
didDocument Json?
agent_invitations agent_invitations[]
agents agents? @relation(fields: [agentId], references: [id])
agents_type agents_type? @relation(fields: [agentsTypeId], references: [id])
Expand Down

0 comments on commit 2e66da0

Please sign in to comment.