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

39 lines (38 loc) • 1.72 kB
import { isObject } from "../../utils/object.mjs"; import { validateProofRequiredMembers } from "./proof-processing/proofValidation.mjs"; //#region src/modules/w3c-di/W3cDataIntegrityProof.ts function createW3cDataIntegrityProofOptions(options) { return { type: "DataIntegrityProof", ...options }; } /** * Enforces required member validation for Data Integrity proofs. * See VC Data Integrity v1.0 §4.4 step 4. */ function assertIsW3cDataIntegrityProof(proof) { const validationError = validateProofRequiredMembers(proof); if (validationError) throw new TypeError(validationError); } /** * Enforces single-proof secured document shape for VC Data Integrity v1.0 §4.4 flows. */ function assertSingleProofDocument(doc) { if (!isObject(doc)) throw new TypeError("Secured document must be a non-null object"); const securedDocument = doc; if (Array.isArray(securedDocument.proof)) throw new TypeError("Proof sets are not accepted by verifyProof; call verifyProofSetAndChain instead"); assertIsW3cDataIntegrityProof(securedDocument.proof); } /** * Enforces proof-set secured document shape for VC Data Integrity v1.0 §4.5 flows. */ function assertMultiProofDocument(doc) { if (!isObject(doc)) throw new TypeError("Secured document must be a non-null object"); const securedDocument = doc; if (!Array.isArray(securedDocument.proof)) throw new TypeError("Proof set expected for verifyProofSetAndChain"); if (securedDocument.proof.length === 0) throw new TypeError("Proof set expected for verifyProofSetAndChain"); } //#endregion export { assertIsW3cDataIntegrityProof, assertMultiProofDocument, assertSingleProofDocument, createW3cDataIntegrityProofOptions }; //# sourceMappingURL=W3cDataIntegrityProof.mjs.map