@credo-ts/core
Version:
<p align="center"> <br /> <img alt="Credo Logo" src="https://github.com/openwallet-foundation/credo-ts/blob/c7886cb8377ceb8ee4efe8d264211e561a75072d/images/credo-logo.png" height="250px" /> </p> <h1 align="center"><b>Credo - Core</b></h1
1 lines • 3.98 kB
Source Map (JSON)
{"version":3,"file":"DidRecord.mjs","names":[],"sources":["../../../../src/modules/dids/repository/DidRecord.ts"],"sourcesContent":["import { Type } from 'class-transformer'\nimport { IsEnum, ValidateNested } from 'class-validator'\nimport type { TagsBase } from '../../../storage/BaseRecord'\nimport { BaseRecord } from '../../../storage/BaseRecord'\nimport { uuid } from '../../../utils/uuid'\nimport type { DidDocumentKey } from '../DidsApiOptions'\nimport { DidDocument } from '../domain'\nimport { DidDocumentRole } from '../domain/DidDocumentRole'\nimport { parseDid } from '../domain/parse'\nimport type { DidRecordMetadata } from './didRecordMetadataTypes'\nimport { DidRecordMetadataKeys } from './didRecordMetadataTypes'\n\nexport interface DidRecordProps {\n id?: string\n did: string\n role: DidDocumentRole\n didDocument?: DidDocument\n createdAt?: Date\n tags?: CustomDidTags\n\n /**\n * The kms key ids associated with the did record. Should only be used\n * when role is {@link DidDocumentRole.Created}\n */\n keys?: DidDocumentKey[]\n}\n\nexport interface CustomDidTags extends TagsBase {\n recipientKeyFingerprints?: string[]\n\n // Alternative forms of the did, allowed to be queried by them.\n // Relationship must be verified both ways before setting this tag.\n alternativeDids?: string[]\n}\n\ntype DefaultDidTags = {\n // We set the recipientKeyFingeprints as a default tag, if the did record has a did document\n // If the did record does not have a did document, we can't calculate it, and it needs to be\n // handled by the creator of the did record\n recipientKeyFingerprints?: string[]\n\n role: DidDocumentRole\n method: string\n legacyUnqualifiedDid?: string\n methodSpecificIdentifier: string\n did: string\n}\n\nexport class DidRecord extends BaseRecord<DefaultDidTags, CustomDidTags, DidRecordMetadata> implements DidRecordProps {\n @Type(() => DidDocument)\n @ValidateNested()\n public didDocument?: DidDocument\n\n public did!: string\n\n @IsEnum(DidDocumentRole)\n public role!: DidDocumentRole\n\n public static readonly type = 'DidRecord'\n public readonly type = DidRecord.type\n\n /**\n * The kms key ids associated with the DidRecord. Should only be used\n * when role is {@link DidDocumentRole.Created}.\n */\n keys?: DidDocumentKey[]\n\n public constructor(props: DidRecordProps) {\n super()\n\n if (props) {\n this.id = props.id ?? uuid()\n this.did = props.did\n this.role = props.role\n this.didDocument = props.didDocument\n this.createdAt = props.createdAt ?? new Date()\n this._tags = props.tags ?? {}\n this.keys = props.keys\n }\n }\n\n public getTags() {\n const did = parseDid(this.did)\n\n const legacyDid = this.metadata.get(DidRecordMetadataKeys.LegacyDid)\n\n return {\n ...this._tags,\n role: this.role,\n method: did.method,\n legacyUnqualifiedDid: legacyDid?.unqualifiedDid,\n did: this.did,\n methodSpecificIdentifier: did.id,\n\n // Calculate if we have a did document, otherwise use the already present recipient keys\n recipientKeyFingerprints: this.didDocument\n ? this.didDocument.recipientKeys.map((recipientKey) => recipientKey.fingerprint)\n : this._tags.recipientKeyFingerprints,\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAgDA,IAAa,YAAb,MAAa,kBAAkB,WAAuF;CAmBpH,AAAO,YAAY,OAAuB;AACxC,SAAO;OATO,OAAO,UAAU;AAW/B,MAAI,OAAO;AACT,QAAK,KAAK,MAAM,MAAM,MAAM;AAC5B,QAAK,MAAM,MAAM;AACjB,QAAK,OAAO,MAAM;AAClB,QAAK,cAAc,MAAM;AACzB,QAAK,YAAY,MAAM,6BAAa,IAAI,MAAM;AAC9C,QAAK,QAAQ,MAAM,QAAQ,EAAE;AAC7B,QAAK,OAAO,MAAM;;;CAItB,AAAO,UAAU;EACf,MAAM,MAAM,SAAS,KAAK,IAAI;EAE9B,MAAM,YAAY,KAAK,SAAS,IAAI,sBAAsB,UAAU;AAEpE,SAAO;GACL,GAAG,KAAK;GACR,MAAM,KAAK;GACX,QAAQ,IAAI;GACZ,sBAAsB,WAAW;GACjC,KAAK,KAAK;GACV,0BAA0B,IAAI;GAG9B,0BAA0B,KAAK,cAC3B,KAAK,YAAY,cAAc,KAAK,iBAAiB,aAAa,YAAY,GAC9E,KAAK,MAAM;GAChB;;;UAxCoB,OAAO;;CAT7B,WAAW,YAAY;CACvB,gBAAgB;;;YAKhB,OAAO,gBAAgB"}