@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.5 kB
Source Map (JSON)
{"version":3,"file":"W3cPresentation.mjs","names":[],"sources":["../../../../../src/modules/vc/models/presentation/W3cPresentation.ts"],"sourcesContent":["import { Expose } from 'class-transformer'\nimport { IsOptional, ValidateNested } from 'class-validator'\nimport type { JsonObject, SingleOrArray } from '../../../../types'\nimport { JsonTransformer } from '../../../../utils'\nimport { IsInstanceOrArrayOfInstances, IsUri } from '../../../../utils/validators'\nimport { CREDENTIALS_CONTEXT_V1_URL, VERIFIABLE_PRESENTATION_TYPE } from '../../constants'\nimport { W3cJwtVerifiableCredential } from '../../jwt-vc/W3cJwtVerifiableCredential'\nimport { W3cJsonLdVerifiableCredential } from '../../linked-data-proofs/models/W3cJsonLdVerifiableCredential'\nimport { IsCredentialJsonLdContext, IsVerifiablePresentationType } from '../../validators'\nimport { type W3cVerifiableCredential, W3cVerifiableCredentialTransformer } from '../credential/W3cVerifiableCredential'\nimport type { W3cHolderOptions } from './W3cHolder'\nimport { IsW3cHolder, W3cHolder, W3cHolderTransformer } from './W3cHolder'\nimport type { W3cJsonPresentation } from './W3cJsonPresentation'\n\nexport interface W3cPresentationOptions {\n id?: string\n context?: Array<string | JsonObject>\n type?: Array<string>\n verifiableCredential: SingleOrArray<W3cVerifiableCredential>\n holder?: string | W3cHolderOptions\n}\n\nexport class W3cPresentation {\n public constructor(options: W3cPresentationOptions) {\n if (options) {\n this.id = options.id\n this.context = options.context ?? [CREDENTIALS_CONTEXT_V1_URL]\n this.type = options.type ?? [VERIFIABLE_PRESENTATION_TYPE]\n this.verifiableCredential = options.verifiableCredential\n\n if (options.holder) {\n this.holder = typeof options.holder === 'string' ? options.holder : new W3cHolder(options.holder)\n }\n }\n }\n\n @Expose({ name: '@context' })\n @IsCredentialJsonLdContext()\n public context!: Array<string | JsonObject>\n\n @IsOptional()\n @IsUri()\n public id?: string\n\n @IsVerifiablePresentationType()\n public type!: Array<string>\n\n @W3cHolderTransformer()\n @IsW3cHolder()\n @IsOptional()\n public holder?: string | W3cHolder\n\n @W3cVerifiableCredentialTransformer()\n @IsInstanceOrArrayOfInstances({ classType: [W3cJsonLdVerifiableCredential, W3cJwtVerifiableCredential] })\n @ValidateNested({ each: true })\n public verifiableCredential!: SingleOrArray<W3cVerifiableCredential>\n\n public get holderId(): string | null {\n if (!this.holder) return null\n\n return this.holder instanceof W3cHolder ? this.holder.id : this.holder\n }\n\n public toJSON() {\n return JsonTransformer.toJSON(this) as W3cJsonPresentation\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAsBA,IAAa,kBAAb,MAA6B;CAC3B,YAAmB,SAAiC;EAClD,IAAI,SAAS;GACX,KAAK,KAAK,QAAQ;GAClB,KAAK,UAAU,QAAQ,WAAW,CAAA,wCAA2B;GAC7D,KAAK,OAAO,QAAQ,QAAQ,CAAA,wBAA6B;GACzD,KAAK,uBAAuB,QAAQ;GAEpC,IAAI,QAAQ,QACV,KAAK,SAAS,OAAO,QAAQ,WAAW,WAAW,QAAQ,SAAS,IAAI,UAAU,QAAQ,MAAM;EAEpG;CACF;CAuBA,IAAW,WAA0B;EACnC,IAAI,CAAC,KAAK,QAAQ,OAAO;EAEzB,OAAO,KAAK,kBAAkB,YAAY,KAAK,OAAO,KAAK,KAAK;CAClE;CAEA,SAAgB;EACd,OAAO,gBAAgB,OAAO,IAAI;CACpC;AACF;;CA9BG,OAAO,EAAE,MAAM,WAAW,CAAC;CAC3B,0BAA0B;;;;CAG1B,WAAW;CACX,MAAM;;;AAGN,WAAA,CAAA,6BAA6B,GAAA,mBAAA,eAAA,OAAA,UAAA,cAAA,SAAA,KAAA,CAAA,GAAA,gBAAA,WAAA,QAAA,KAAA,CAAA;;CAG7B,qBAAqB;CACrB,YAAY;CACZ,WAAW;;;;CAGX,mCAAmC;CACnC,6BAA6B,EAAE,WAAW,CAAC,+BAA+B,0BAA0B,EAAE,CAAC;CACvG,eAAe,EAAE,MAAM,KAAK,CAAC"}