@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 • 6.39 kB
Source Map (JSON)
{"version":3,"file":"W3cDataIntegrityApi.mjs","names":[],"sources":["../../../src/modules/w3c-di/W3cDataIntegrityApi.ts"],"sourcesContent":["import { AgentContext } from '../../agent'\nimport { injectable } from '../../plugins'\nimport type { PublicJwk, SupportedPublicJwkClass } from '../kms/jwk/PublicJwk'\nimport { W3cDataIntegrityCryptosuiteRegistry } from './W3cDataIntegrityCryptosuiteRegistry'\nimport { assertCreated, assertVerified } from './W3cDataIntegrityError'\nimport type {\n W3cDataIntegrityProofSetSecuredDocument,\n W3cDataIntegritySecuredDocument,\n W3cDataIntegritySingleProofSecuredDocument,\n} from './W3cDataIntegrityProof'\nimport { assertMultiProofDocument, assertSingleProofDocument } from './W3cDataIntegrityProof'\nimport type {\n W3cDataIntegrityCreateProofOptions,\n W3cDataIntegrityVerifyProofDocumentOptions,\n W3cDataIntegrityVerifyProofOptions,\n} from './W3cDataIntegrityProofService'\nimport { W3cDataIntegrityProofService } from './W3cDataIntegrityProofService'\n\n@injectable()\nexport class W3cDataIntegrityApi {\n private agentContext: AgentContext\n private dataIntegrityProofService: W3cDataIntegrityProofService\n private dataIntegrityCryptosuiteRegistry: W3cDataIntegrityCryptosuiteRegistry\n\n public constructor(\n agentContext: AgentContext,\n dataIntegrityProofService: W3cDataIntegrityProofService,\n dataIntegrityCryptosuiteRegistry: W3cDataIntegrityCryptosuiteRegistry\n ) {\n this.agentContext = agentContext\n this.dataIntegrityProofService = dataIntegrityProofService\n this.dataIntegrityCryptosuiteRegistry = dataIntegrityCryptosuiteRegistry\n }\n\n // ─── Create (Result-Based) ────────────────────────────────────────────────\n\n public async createProof(options: W3cDataIntegrityCreateProofOptions) {\n return await this.dataIntegrityProofService.createProof(this.agentContext, options)\n }\n\n // ─── Create (Fail-Fast) ───────────────────────────────────────────────────\n\n public async createProofOrThrow(options: W3cDataIntegrityCreateProofOptions) {\n const result = await this.createProof(options)\n assertCreated(result)\n return result\n }\n\n // ─── Verify (Explicit Paths) ──────────────────────────────────────────────\n\n public async verifyProof(\n securedDocument: W3cDataIntegritySingleProofSecuredDocument,\n options?: W3cDataIntegrityVerifyProofOptions\n ) {\n return await this.dataIntegrityProofService.verifyProof(this.agentContext, securedDocument, options)\n }\n\n public async verifyProofSetAndChain(\n securedDocument: W3cDataIntegrityProofSetSecuredDocument,\n options?: W3cDataIntegrityVerifyProofOptions\n ) {\n return await this.dataIntegrityProofService.verifyProofSetAndChain(this.agentContext, securedDocument, options)\n }\n\n // ─── Verify (Convenience Dispatcher) ──────────────────────────────────────\n\n public async verifySecuredDocument(\n securedDocument: W3cDataIntegritySecuredDocument,\n options?: W3cDataIntegrityVerifyProofOptions\n ) {\n if (Array.isArray(securedDocument.proof)) {\n assertMultiProofDocument(securedDocument)\n return await this.verifyProofSetAndChain(securedDocument, options)\n }\n\n assertSingleProofDocument(securedDocument)\n return await this.verifyProof(securedDocument, options)\n }\n\n // ─── Verify (Fail-Fast) ───────────────────────────────────────────────────\n\n public async verifySecuredDocumentOrThrow(\n securedDocument: W3cDataIntegritySecuredDocument,\n options?: W3cDataIntegrityVerifyProofOptions\n ) {\n const result = await this.verifySecuredDocument(securedDocument, options)\n assertVerified(result)\n return result\n }\n\n // ─── Verify (Document Parsing + Verification) ─────────────────────────────\n\n public async verifyProofDocument(options: W3cDataIntegrityVerifyProofDocumentOptions) {\n return await this.dataIntegrityProofService.verifyProofDocument(this.agentContext, options)\n }\n\n // ─── Metadata ─────────────────────────────────────────────────────────────\n\n /**\n * The identifiers of the registered Data Integrity cryptosuites, in registration order.\n *\n * @param publicJwkType when provided, only the cryptosuites that can create and verify proofs\n * with this key type are returned.\n */\n public getSupportedCryptosuites(publicJwkType?: SupportedPublicJwkClass | PublicJwk): string[] {\n if (!publicJwkType) return this.dataIntegrityCryptosuiteRegistry.supportedCryptosuites\n\n return this.dataIntegrityCryptosuiteRegistry\n .getAllByPublicJwkType(publicJwkType)\n .map((cryptosuiteInfo) => cryptosuiteInfo.cryptosuite)\n }\n}\n"],"mappings":";;;;;;;;;;AAmBO,IAAM,sBAAN,MAAM,oBAAoB;CAK/B,YACE,cACA,2BACA,kCACA;EACA,KAAK,eAAe;EACpB,KAAK,4BAA4B;EACjC,KAAK,mCAAmC;CAC1C;CAIA,MAAa,YAAY,SAA6C;EACpE,OAAO,MAAM,KAAK,0BAA0B,YAAY,KAAK,cAAc,OAAO;CACpF;CAIA,MAAa,mBAAmB,SAA6C;EAC3E,MAAM,SAAS,MAAM,KAAK,YAAY,OAAO;EAC7C,cAAc,MAAM;EACpB,OAAO;CACT;CAIA,MAAa,YACX,iBACA,SACA;EACA,OAAO,MAAM,KAAK,0BAA0B,YAAY,KAAK,cAAc,iBAAiB,OAAO;CACrG;CAEA,MAAa,uBACX,iBACA,SACA;EACA,OAAO,MAAM,KAAK,0BAA0B,uBAAuB,KAAK,cAAc,iBAAiB,OAAO;CAChH;CAIA,MAAa,sBACX,iBACA,SACA;EACA,IAAI,MAAM,QAAQ,gBAAgB,KAAK,GAAG;GACxC,yBAAyB,eAAe;GACxC,OAAO,MAAM,KAAK,uBAAuB,iBAAiB,OAAO;EACnE;EAEA,0BAA0B,eAAe;EACzC,OAAO,MAAM,KAAK,YAAY,iBAAiB,OAAO;CACxD;CAIA,MAAa,6BACX,iBACA,SACA;EACA,MAAM,SAAS,MAAM,KAAK,sBAAsB,iBAAiB,OAAO;EACxE,eAAe,MAAM;EACrB,OAAO;CACT;CAIA,MAAa,oBAAoB,SAAqD;EACpF,OAAO,MAAM,KAAK,0BAA0B,oBAAoB,KAAK,cAAc,OAAO;CAC5F;;;;;;;CAUA,yBAAgC,eAA+D;EAC7F,IAAI,CAAC,eAAe,OAAO,KAAK,iCAAiC;EAEjE,OAAO,KAAK,iCACT,sBAAsB,aAAa,CAAC,CACpC,KAAK,oBAAoB,gBAAgB,WAAW;CACzD;AACF;AA7FC,sBAAA,WAAA,CAAA,WAAW,GAAA,mBAAA,qBAAA"}