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

1 lines • 23.6 kB
{"version":3,"file":"W3cDataIntegrityProofService.mjs","names":[],"sources":["../../../src/modules/w3c-di/W3cDataIntegrityProofService.ts"],"sourcesContent":["import type { AgentContext } from '../../agent/context'\nimport { injectable } from '../../plugins'\nimport { asArray, equalsIgnoreOrder } from '../../utils'\nimport type { W3cDataIntegrityCryptosuite, W3cDataIntegrityProofVerificationInput } from './cryptosuites/types'\nimport { omitUndefinedFields } from './proof-processing/normalization'\nimport { parseW3cDataIntegrityProofDocument } from './proof-processing/parsing'\nimport { validateProofPurposeVerificationRelationship } from './proof-processing/proofPurposeValidation'\nimport { validateProofChainStructure } from './proof-processing/proofSetValidation'\nimport {\n assertCreatedProofPostconditions,\n validateProofFieldFormats,\n validateProofRequiredMembers,\n} from './proof-processing/proofValidation'\n\nimport { W3cDataIntegrityCryptosuiteRegistry } from './W3cDataIntegrityCryptosuiteRegistry'\nimport type {\n W3cDataIntegrityCreateFailure,\n W3cDataIntegrityCreateSuccess,\n W3cDataIntegrityProcessingIssue,\n W3cDataIntegrityVerifyFailure,\n W3cDataIntegrityVerifySuccess,\n} from './W3cDataIntegrityError'\nimport {\n createInvalidResult,\n createIssue,\n W3cDataIntegrityProcessingError,\n W3cDataIntegrityProcessingErrorCode,\n} from './W3cDataIntegrityError'\nimport type {\n W3cDataIntegrityCryptosuiteProof,\n W3cDataIntegrityCryptosuiteProofOptions,\n W3cDataIntegrityDomain,\n W3cDataIntegrityPreviousProofReference,\n W3cDataIntegrityProofSetSecuredDocument,\n W3cDataIntegritySingleProofSecuredDocument,\n W3cDataIntegrityUnsecuredDocument,\n} from './W3cDataIntegrityProof'\nimport {\n assertMultiProofDocument,\n assertSingleProofDocument,\n createW3cDataIntegrityProofOptions,\n} from './W3cDataIntegrityProof'\n\nexport interface W3cDataIntegrityCreateProofOptions {\n unsecuredDocument: W3cDataIntegrityUnsecuredDocument\n verificationMethod: string\n proofPurpose: string\n cryptosuite: string\n created?: string\n expires?: string\n challenge?: string\n domain?: W3cDataIntegrityDomain\n nonce?: string\n previousProof?: W3cDataIntegrityPreviousProofReference\n}\n\nexport interface W3cDataIntegrityVerifyProofOptions {\n expectedProofPurpose?: string\n domain?: W3cDataIntegrityDomain\n challenge?: string\n}\n\nexport interface W3cDataIntegrityVerifyProofDocumentOptions extends W3cDataIntegrityVerifyProofOptions {\n mediaType: string\n documentBytes: Uint8Array\n}\n\n@injectable()\nexport class W3cDataIntegrityProofService {\n private dataIntegrityCryptosuiteRegistry: W3cDataIntegrityCryptosuiteRegistry\n private readonly supportedMediaTypes = ['application/json', 'application/ld+json', 'application/vc+ld+json']\n\n public constructor(dataIntegrityCryptosuiteRegistry: W3cDataIntegrityCryptosuiteRegistry) {\n this.dataIntegrityCryptosuiteRegistry = dataIntegrityCryptosuiteRegistry\n }\n\n // ─── Create (Result-Based) ────────────────────────────────────────────────\n\n /**\n * Implements VC Data Integrity v1.0 §4.2 \"Add Proof\" orchestration.\n * Delegates cryptographic suite proof creation and enforces postconditions.\n */\n public async createProof(\n agentContext: AgentContext,\n options: W3cDataIntegrityCreateProofOptions\n ): Promise<W3cDataIntegrityCreateSuccess | W3cDataIntegrityCreateFailure> {\n const normalizedUnsecuredDocument = omitUndefinedFields(options.unsecuredDocument)\n\n let cryptosuite: W3cDataIntegrityCryptosuite\n try {\n cryptosuite = this.dataIntegrityCryptosuiteRegistry.createByCryptosuite(agentContext, options.cryptosuite)\n } catch (error) {\n if (!(error instanceof Error)) {\n throw error\n }\n\n const issue =\n error instanceof W3cDataIntegrityProcessingError\n ? error.issue\n : createIssue(\n W3cDataIntegrityProcessingErrorCode.ProofGenerationError,\n 'Error creating Data Integrity proof',\n error.message\n )\n return {\n created: false,\n proof: null,\n errors: [issue],\n }\n }\n\n const proofOptions: W3cDataIntegrityCryptosuiteProofOptions = createW3cDataIntegrityProofOptions(\n omitUndefinedFields({\n cryptosuite: cryptosuite.cryptosuite,\n verificationMethod: options.verificationMethod,\n proofPurpose: options.proofPurpose,\n created: options.created,\n expires: options.expires,\n challenge: options.challenge,\n domain: options.domain,\n nonce: options.nonce,\n previousProof: options.previousProof,\n })\n )\n\n try {\n const proof = await cryptosuite.createProof(normalizedUnsecuredDocument, proofOptions)\n assertCreatedProofPostconditions(\n proof,\n { ...proofOptions, verificationMethod: options.verificationMethod },\n cryptosuite.cryptosuite\n )\n return {\n created: true,\n proof,\n }\n } catch (error) {\n if (!(error instanceof Error)) {\n throw error\n }\n\n const issue =\n error instanceof W3cDataIntegrityProcessingError\n ? error.issue\n : createIssue(\n W3cDataIntegrityProcessingErrorCode.ProofGenerationError,\n 'Error creating Data Integrity proof',\n error.message\n )\n return {\n created: false,\n proof: null,\n errors: [issue],\n }\n }\n }\n\n /**\n * Implements VC Data Integrity v1.0 §4.4 \"Verify Proof\" algorithm.\n * Steps 4-8 are enforced through required-member gate, policy checks,\n * field-format validation, and cryptosuite verification.\n */\n public async verifyProof(\n agentContext: AgentContext,\n securedDocument: W3cDataIntegritySingleProofSecuredDocument,\n options: W3cDataIntegrityVerifyProofOptions = {}\n ): Promise<W3cDataIntegrityVerifySuccess | W3cDataIntegrityVerifyFailure> {\n try {\n const normalizedSecuredDocument = omitUndefinedFields(securedDocument)\n assertSingleProofDocument(normalizedSecuredDocument)\n\n return await this.verifySingleProofCore(agentContext, normalizedSecuredDocument, options)\n } catch (error) {\n if (!(error instanceof Error)) {\n throw error\n }\n\n const issue =\n error instanceof W3cDataIntegrityProcessingError\n ? error.issue\n : createIssue(\n W3cDataIntegrityProcessingErrorCode.ProofVerificationError,\n 'Error verifying Data Integrity proof',\n error.message\n )\n return createInvalidResult(issue)\n }\n }\n\n // ─── Verify (Explicit Paths) ──────────────────────────────────────────────\n\n /**\n * Implements VC Data Integrity v1.0 §4.5 \"Verify Proof Sets and Chains\" algorithm.\n * Performs chain-structure validation, then verifies each proof against\n * reconstructed dependency-proof input.\n */\n public async verifyProofSetAndChain(\n agentContext: AgentContext,\n securedDocument: W3cDataIntegrityProofSetSecuredDocument,\n options: W3cDataIntegrityVerifyProofOptions = {}\n ): Promise<W3cDataIntegrityVerifySuccess | W3cDataIntegrityVerifyFailure> {\n try {\n const normalizedSecuredDocument = omitUndefinedFields(securedDocument)\n assertMultiProofDocument(normalizedSecuredDocument)\n\n const proofs = normalizedSecuredDocument.proof\n const requiredMemberIssues = proofs\n .map((proof, index) => {\n const requiredMemberValidationError = validateProofRequiredMembers(proof)\n if (!requiredMemberValidationError) return undefined\n\n return createIssue(\n W3cDataIntegrityProcessingErrorCode.ProofVerificationError,\n `Proof at index ${index} has invalid required members`,\n requiredMemberValidationError\n )\n })\n .filter((issue): issue is ReturnType<typeof createIssue> => issue !== undefined)\n\n if (requiredMemberIssues.length > 0) {\n return createInvalidResult(requiredMemberIssues[0], requiredMemberIssues.slice(1))\n }\n\n const proofChainIssues = validateProofChainStructure(proofs)\n if (proofChainIssues.length > 0) {\n return createInvalidResult(proofChainIssues[0], proofChainIssues.slice(1))\n }\n\n const proofPolicyIssues = proofs\n .map((proof, index) => {\n const proofPolicyIssue = this.validateProofPolicy(proof, options)\n if (!proofPolicyIssue) return undefined\n\n return createIssue(\n proofPolicyIssue.type,\n `Proof at index ${index} failed verification policy pre-check`,\n proofPolicyIssue.detail ?? proofPolicyIssue.title\n )\n })\n .filter((issue): issue is W3cDataIntegrityProcessingIssue => issue !== undefined)\n\n if (proofPolicyIssues.length > 0) {\n return createInvalidResult(proofPolicyIssues[0], proofPolicyIssues.slice(1))\n }\n\n const proofFieldFormatIssues = proofs\n .map((proof, index) => {\n const proofFieldFormatError = validateProofFieldFormats(proof)\n if (!proofFieldFormatError) return undefined\n\n return createIssue(\n W3cDataIntegrityProcessingErrorCode.ProofVerificationError,\n `Proof at index ${index} has invalid field formats`,\n proofFieldFormatError.errors[0]?.detail ?? proofFieldFormatError.errors[0]?.title\n )\n })\n .filter((issue): issue is W3cDataIntegrityProcessingIssue => issue !== undefined)\n\n if (proofFieldFormatIssues.length > 0) {\n return createInvalidResult(proofFieldFormatIssues[0], proofFieldFormatIssues.slice(1))\n }\n\n const proofIdToIndex = this.createProofIdToIndexMap(proofs)\n\n const { proof: _, ...unsecuredDocument } = normalizedSecuredDocument\n for (const [_index, proof] of proofs.entries()) {\n const matchingProofIndices = this.getMatchingProofIndices(proof, proofIdToIndex)\n const matchingProofs = matchingProofIndices.map((matchingProofIndex) => proofs[matchingProofIndex])\n const singleProofSecuredDocument: W3cDataIntegritySingleProofSecuredDocument = {\n ...unsecuredDocument,\n proof,\n }\n\n const chainInputDocument = this.reconstructProofInputDocument(unsecuredDocument, matchingProofs)\n\n const verificationResult = await this.verifySingleProofCore(\n agentContext,\n singleProofSecuredDocument,\n options,\n chainInputDocument\n )\n if (!verificationResult.verified) {\n return verificationResult\n }\n }\n\n return {\n verified: true,\n verifiedDocument: unsecuredDocument,\n mediaType: null,\n }\n } catch (error) {\n if (!(error instanceof Error)) {\n throw error\n }\n\n const issue =\n error instanceof W3cDataIntegrityProcessingError\n ? error.issue\n : createIssue(\n W3cDataIntegrityProcessingErrorCode.ProofVerificationError,\n 'Error verifying Data Integrity proof set/chain',\n error.message\n )\n return createInvalidResult(issue)\n }\n }\n\n // ─── Verify (Parsed Document Dispatcher) ──────────────────────────────────\n\n /**\n * Parses a secured document and dispatches to §4.4 or §4.5 verification paths.\n */\n public async verifyProofDocument(\n agentContext: AgentContext,\n options: W3cDataIntegrityVerifyProofDocumentOptions\n ): Promise<W3cDataIntegrityVerifySuccess | W3cDataIntegrityVerifyFailure> {\n const parseResult = parseW3cDataIntegrityProofDocument(options, this.supportedMediaTypes)\n if (!parseResult.ok) {\n return parseResult.result\n }\n\n const { normalizedMediaType, securedDocument, verifyOptions } = parseResult.value\n\n const verificationResult = Array.isArray(securedDocument.proof)\n ? await this.verifyProofSetAndChain(\n agentContext,\n securedDocument as W3cDataIntegrityProofSetSecuredDocument,\n verifyOptions\n )\n : await this.verifyProof(\n agentContext,\n securedDocument as W3cDataIntegritySingleProofSecuredDocument,\n verifyOptions\n )\n\n if (!verificationResult.verified) {\n return verificationResult\n }\n\n return {\n ...verificationResult,\n mediaType: normalizedMediaType,\n }\n }\n\n // ─── Verify (Single Proof Core) ───────────────────────────────────────────\n\n /**\n * Implements VC Data Integrity v1.0 §4.4 steps 5-8 for a single-proof input.\n * Runs proof checks, field-format checks, relationship validation, and cryptosuite verification.\n */\n private async verifySingleProofCore(\n agentContext: AgentContext,\n securedDocument: W3cDataIntegritySingleProofSecuredDocument,\n options: W3cDataIntegrityVerifyProofOptions,\n unsecuredDocument: W3cDataIntegrityUnsecuredDocument = (() => {\n const { proof: _, ...unsecuredDocument } = securedDocument\n return unsecuredDocument\n })()\n ): Promise<W3cDataIntegrityVerifySuccess | W3cDataIntegrityVerifyFailure> {\n const proof = securedDocument.proof\n\n const proofPolicyIssue = this.validateProofPolicy(proof, options)\n if (proofPolicyIssue) {\n return createInvalidResult(proofPolicyIssue)\n }\n\n const proofFieldFormatError = validateProofFieldFormats(proof)\n if (proofFieldFormatError) {\n return proofFieldFormatError\n }\n\n const proofPurposeValidationError = await validateProofPurposeVerificationRelationship(agentContext, proof)\n if (proofPurposeValidationError) {\n return proofPurposeValidationError\n }\n\n const cryptosuite = this.dataIntegrityCryptosuiteRegistry.createByCryptosuite(agentContext, proof.cryptosuite)\n const proofVerificationInput: W3cDataIntegrityProofVerificationInput = {\n unsecuredDocument,\n proof,\n }\n const verificationResult = await cryptosuite.verifyProof(proofVerificationInput)\n\n if (!verificationResult.verified || verificationResult.verifiedDocument === null) {\n return createInvalidResult(\n createIssue(W3cDataIntegrityProcessingErrorCode.ProofVerificationError, 'Cryptosuite proof verification failed')\n )\n }\n\n return {\n verified: true,\n verifiedDocument: verificationResult.verifiedDocument,\n mediaType: null,\n }\n }\n\n // ─── Verify (Policy Validation) ───────────────────────────────────────────\n\n /**\n * Implements VC Data Integrity v1.0 §4.4 steps 5-7 verification policy checks.\n * Validates expected proofPurpose, domain, and challenge when provided.\n */\n private validateProofPolicy(\n proof: W3cDataIntegrityCryptosuiteProof,\n options: W3cDataIntegrityVerifyProofOptions\n ): W3cDataIntegrityProcessingIssue | undefined {\n if (options.expectedProofPurpose && proof.proofPurpose !== options.expectedProofPurpose) {\n return createIssue(\n W3cDataIntegrityProcessingErrorCode.ProofVerificationError,\n 'Proof purpose does not match expected proof purpose',\n `Expected '${options.expectedProofPurpose}', received '${proof.proofPurpose}'`\n )\n }\n\n if (options.domain) {\n const expectedDomain = [...new Set(asArray(options.domain))]\n const proofDomain = [...new Set(asArray(proof.domain))]\n\n if (!equalsIgnoreOrder(expectedDomain, proofDomain)) {\n return createIssue(\n W3cDataIntegrityProcessingErrorCode.InvalidDomainError,\n 'Proof domain does not match expected domain'\n )\n }\n }\n\n if (options.challenge && proof.challenge !== options.challenge) {\n return createIssue(\n W3cDataIntegrityProcessingErrorCode.InvalidChallengeError,\n 'Proof challenge does not match expected challenge',\n `Expected '${options.challenge}', received '${proof.challenge ?? 'undefined'}'`\n )\n }\n\n return undefined\n }\n\n // ─── Verify (Proof Set Helpers) ───────────────────────────────────────────\n\n private createProofIdToIndexMap(proofs: W3cDataIntegrityCryptosuiteProof[]) {\n const proofIdToIndex = new Map<string, number>()\n\n for (const [index, proof] of proofs.entries()) {\n if (typeof proof.id !== 'string') continue\n proofIdToIndex.set(proof.id, index)\n }\n\n return proofIdToIndex\n }\n\n private getMatchingProofIndices(proof: W3cDataIntegrityCryptosuiteProof, proofIdToIndex: Map<string, number>) {\n const previousProofReferences = proof.previousProof\n ? Array.isArray(proof.previousProof)\n ? proof.previousProof\n : [proof.previousProof]\n : []\n\n const matchingProofIndices: number[] = []\n for (const previousProofReference of previousProofReferences) {\n const matchingProofIndex = proofIdToIndex.get(previousProofReference)\n if (matchingProofIndex !== undefined) {\n matchingProofIndices.push(matchingProofIndex)\n }\n }\n\n return matchingProofIndices\n }\n\n // ─── Verify (Proof Input Reconstruction) ──────────────────────────────────\n\n /**\n * Implements VC Data Integrity v1.0 §4.5 step 3.3 input reconstruction.\n * Adds matching dependency proofs into the unsecured document for per-proof verification.\n */\n private reconstructProofInputDocument(\n unsecuredDocument: W3cDataIntegrityUnsecuredDocument,\n matchingProofs: W3cDataIntegrityCryptosuiteProof[]\n ): W3cDataIntegrityUnsecuredDocument {\n if (matchingProofs.length === 0) {\n return unsecuredDocument\n }\n\n return {\n ...unsecuredDocument,\n proof: matchingProofs.length === 1 ? matchingProofs[0] : matchingProofs,\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAoEO,IAAM,+BAAN,MAAM,6BAA6B;CAIxC,YAAmB,kCAAuE;EAF1F,KAAiB,sBAAsB;GAAC;GAAoB;GAAuB;EAAwB;EAGzG,KAAK,mCAAmC;CAC1C;;;;;CAQA,MAAa,YACX,cACA,SACwE;EACxE,MAAM,8BAA8B,oBAAoB,QAAQ,iBAAiB;EAEjF,IAAI;EACJ,IAAI;GACF,cAAc,KAAK,iCAAiC,oBAAoB,cAAc,QAAQ,WAAW;EAC3G,SAAS,OAAO;GACd,IAAI,EAAE,iBAAiB,QACrB,MAAM;GAWR,OAAO;IACL,SAAS;IACT,OAAO;IACP,QAAQ,CAVR,iBAAiB,kCACb,MAAM,QACN,YAAA,oDAEE,uCACA,MAAM,OACR,CAIU;GAChB;EACF;EAEA,MAAM,eAAwD,mCAC5D,oBAAoB;GAClB,aAAa,YAAY;GACzB,oBAAoB,QAAQ;GAC5B,cAAc,QAAQ;GACtB,SAAS,QAAQ;GACjB,SAAS,QAAQ;GACjB,WAAW,QAAQ;GACnB,QAAQ,QAAQ;GAChB,OAAO,QAAQ;GACf,eAAe,QAAQ;EACzB,CAAC,CACH;EAEA,IAAI;GACF,MAAM,QAAQ,MAAM,YAAY,YAAY,6BAA6B,YAAY;GACrF,iCACE,OACA;IAAE,GAAG;IAAc,oBAAo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