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

70 lines (69 loc) • 3.06 kB
import { CredoError } from "../../../error/CredoError.mjs"; import "../../../error/index.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 { PublicJwk } from "../../kms/jwk/PublicJwk.mjs"; import { suites } from "./adapters/jsonld-signatures-adapter.mjs"; //#region src/modules/vc/linked-data-proofs/SignatureSuiteRegistry.ts suites.LinkedDataSignature; /** * @deprecated Registration token retained for backward compatibility. * Will be removed in 0.8. */ const SignatureSuiteToken = Symbol("SignatureSuiteToken"); let SignatureSuiteRegistry = class SignatureSuiteRegistry { constructor(suites = []) { this.suiteMapping = [...suites]; } /** * @deprecated Pass suites to the constructor instead. * Will be removed in 0.8. */ registerSuite(suiteInfo) { this.suiteMapping.push(suiteInfo); } /** * @deprecated Pass suites to the constructor instead. * Will be removed in 0.8. */ registerSuites(suites) { for (const suite of suites) this.registerSuite(suite); } get supportedProofTypes() { return this.suiteMapping.map((x) => x.proofType); } /** * @deprecated recommended to always search by key type instead as that will have broader support */ getByVerificationMethodType(verificationMethodType) { return this.suiteMapping.find((x) => x.verificationMethodTypes.includes(verificationMethodType)); } getAllByPublicJwkType(publicJwkType) { const publicJwkClass = publicJwkType instanceof PublicJwk ? publicJwkType.JwkClass : publicJwkType; return this.suiteMapping.filter((x) => x.supportedPublicJwkTypes.includes(publicJwkClass)); } getByProofType(proofType) { const suiteInfo = this.suiteMapping.find((x) => x.proofType === proofType); if (!suiteInfo) throw new CredoError(`No signature suite for proof type: ${proofType}`); return suiteInfo; } /** * Returns the `@context` url that the signature suite for the given proof type adds to documents * it signs (see `LinkedDataSignature.ensureSuiteContext`), or undefined if the proof type is not * registered or its suite does not declare a context url. */ findContextUrlByProofType(proofType) { const suiteClass = this.suiteMapping.find((x) => x.proofType === proofType)?.suiteClass; return typeof suiteClass?.CONTEXT_URL === "string" ? suiteClass.CONTEXT_URL : void 0; } getVerificationMethodTypesByProofType(proofType) { const suiteInfo = this.suiteMapping.find((suiteInfo) => suiteInfo.proofType === proofType); if (!suiteInfo) throw new CredoError(`No verification method type found for proof type: ${proofType}`); return suiteInfo.verificationMethodTypes; } }; SignatureSuiteRegistry = __decorate([injectable(), __decorateMetadata("design:paramtypes", [Array])], SignatureSuiteRegistry); //#endregion export { SignatureSuiteRegistry, SignatureSuiteToken }; //# sourceMappingURL=SignatureSuiteRegistry.mjs.map