Skip to content

Commit

Permalink
Merge pull request #327 from holashchand/issue-1018
Browse files Browse the repository at this point in the history
added support for generating web did with multiple hosts
  • Loading branch information
challabeehyv authored Jun 10, 2024
2 parents 7dd3095 + 97f6f91 commit e2944f4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 3 additions & 3 deletions services/identity-service/src/did/did.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ export class DidService {
return `did:web:${baseUrl}:`;
}

generateDidUri(method: string, id?: string): string {
generateDidUri(method: string, id?: string, webDidBaseUrl?: string): string {
if(id) return id;
if (method === 'web') {
return this.getWebDidIdForId(uuid());
return this.getWebDidIdForId(uuid(), webDidBaseUrl);
}
return `did:${(method && method.trim() !== '') ? method.trim() : 'rcw'}:${uuid()}`;
}
Expand All @@ -65,7 +65,7 @@ export class DidService {

async generateDID(doc: GenerateDidDTO): Promise<DIDDocument> {
// Create a UUID for the DID using uuidv4
const didUri: string = this.generateDidUri(doc?.method, doc?.id);
const didUri: string = this.generateDidUri(doc?.method, doc?.id, doc?.webDidBaseUrl);

// Create private/public key pair
let authnKeys;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ export class GenerateDidDTO {
description: 'Specific ID to generate DID document with.',
})
id?: string;
@ApiProperty({
required: false,
description: 'In case of method "web" the web url path to access the did document. It would be appended by generated uuid',
})
webDidBaseUrl?: string;
}

export class GenerateDidRequestDTO {
Expand Down

0 comments on commit e2944f4

Please sign in to comment.