UNPKG

@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

66 lines (65 loc) • 3.31 kB
import { AgentContext } from "../../agent/context/AgentContext.mjs"; import { injectable } from "../../plugins/index.mjs"; import __decorateMetadata from "../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorateMetadata.mjs"; import __decorate from "../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorate.mjs"; import "../../agent/index.mjs"; import { assertCreated, assertVerified } from "./W3cDataIntegrityError.mjs"; import { W3cDataIntegrityCryptosuiteRegistry } from "./W3cDataIntegrityCryptosuiteRegistry.mjs"; import { assertMultiProofDocument, assertSingleProofDocument } from "./W3cDataIntegrityProof.mjs"; import { W3cDataIntegrityProofService } from "./W3cDataIntegrityProofService.mjs"; //#region src/modules/w3c-di/W3cDataIntegrityApi.ts let W3cDataIntegrityApi = class W3cDataIntegrityApi { constructor(agentContext, dataIntegrityProofService, dataIntegrityCryptosuiteRegistry) { this.agentContext = agentContext; this.dataIntegrityProofService = dataIntegrityProofService; this.dataIntegrityCryptosuiteRegistry = dataIntegrityCryptosuiteRegistry; } async createProof(options) { return await this.dataIntegrityProofService.createProof(this.agentContext, options); } async createProofOrThrow(options) { const result = await this.createProof(options); assertCreated(result); return result; } async verifyProof(securedDocument, options) { return await this.dataIntegrityProofService.verifyProof(this.agentContext, securedDocument, options); } async verifyProofSetAndChain(securedDocument, options) { return await this.dataIntegrityProofService.verifyProofSetAndChain(this.agentContext, securedDocument, options); } async verifySecuredDocument(securedDocument, options) { if (Array.isArray(securedDocument.proof)) { assertMultiProofDocument(securedDocument); return await this.verifyProofSetAndChain(securedDocument, options); } assertSingleProofDocument(securedDocument); return await this.verifyProof(securedDocument, options); } async verifySecuredDocumentOrThrow(securedDocument, options) { const result = await this.verifySecuredDocument(securedDocument, options); assertVerified(result); return result; } async verifyProofDocument(options) { return await this.dataIntegrityProofService.verifyProofDocument(this.agentContext, options); } /** * The identifiers of the registered Data Integrity cryptosuites, in registration order. * * @param publicJwkType when provided, only the cryptosuites that can create and verify proofs * with this key type are returned. */ getSupportedCryptosuites(publicJwkType) { if (!publicJwkType) return this.dataIntegrityCryptosuiteRegistry.supportedCryptosuites; return this.dataIntegrityCryptosuiteRegistry.getAllByPublicJwkType(publicJwkType).map((cryptosuiteInfo) => cryptosuiteInfo.cryptosuite); } }; W3cDataIntegrityApi = __decorate([injectable(), __decorateMetadata("design:paramtypes", [ typeof AgentContext === "undefined" ? Object : AgentContext, typeof W3cDataIntegrityProofService === "undefined" ? Object : W3cDataIntegrityProofService, typeof W3cDataIntegrityCryptosuiteRegistry === "undefined" ? Object : W3cDataIntegrityCryptosuiteRegistry ])], W3cDataIntegrityApi); //#endregion export { W3cDataIntegrityApi }; //# sourceMappingURL=W3cDataIntegrityApi.mjs.map