Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added support for generating web did with multiple hosts #327

Merged
merged 2 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading