Skip to content

Commit

Permalink
feat: add role and method to did record tags (#692)
Browse files Browse the repository at this point in the history
Signed-off-by: Timo Glastra <timo@animo.id>
  • Loading branch information
TimoGlastra committed Apr 4, 2022
1 parent 5cd1598 commit 3b6504b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/core/src/modules/dids/repository/DidRecord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { IsEnum, ValidateNested } from 'class-validator'
import { BaseRecord } from '../../../storage/BaseRecord'
import { DidDocument } from '../domain'
import { DidDocumentRole } from '../domain/DidDocumentRole'
import { parseDid } from '../domain/parse'

export interface DidRecordProps {
id: string
Expand All @@ -19,7 +20,10 @@ interface CustomDidTags extends TagsBase {
recipientKeys?: string[]
}

export type DefaultDidTags = TagsBase
type DefaultDidTags = {
role: DidDocumentRole
method: string
}

export class DidRecord extends BaseRecord<DefaultDidTags, CustomDidTags> implements DidRecordProps {
@Type(() => DidDocument)
Expand All @@ -40,12 +44,17 @@ export class DidRecord extends BaseRecord<DefaultDidTags, CustomDidTags> impleme
this.role = props.role
this.didDocument = props.didDocument
this.createdAt = props.createdAt ?? new Date()
this._tags = props.tags ?? {}
}
}

public getTags() {
const did = parseDid(this.id)

return {
...this._tags,
role: this.role,
method: did.method,
}
}
}

0 comments on commit 3b6504b

Please sign in to comment.