@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 • 3.21 kB
Source Map (JSON)
{"version":3,"file":"SignatureSuiteRegistry.mjs","names":[],"sources":["../../../../src/modules/vc/data-integrity/SignatureSuiteRegistry.ts"],"sourcesContent":["import { CredoError } from '../../../error'\nimport { injectAll, injectable } from '../../../plugins'\nimport { PublicJwk, type SupportedPublicJwkClass } from '../../kms/jwk/PublicJwk'\n\nimport { suites } from './libraries/jsonld-signatures'\n\nconst LinkedDataSignature = suites.LinkedDataSignature\n\nexport const SignatureSuiteToken = Symbol('SignatureSuiteToken')\nexport interface SuiteInfo {\n suiteClass: typeof LinkedDataSignature\n proofType: string\n verificationMethodTypes: string[]\n supportedPublicJwkTypes: SupportedPublicJwkClass[]\n}\n\n@injectable()\nexport class SignatureSuiteRegistry {\n private suiteMapping: SuiteInfo[]\n\n // TODO: replace this signature suite token with just injecting and registering the suites\n // on the registry. It's a bit ugly/awkward approach.\n public constructor(@injectAll(SignatureSuiteToken) suites: Array<SuiteInfo | 'default'>) {\n this.suiteMapping = suites.filter((suite): suite is SuiteInfo => suite !== 'default')\n }\n\n public get supportedProofTypes(): string[] {\n return this.suiteMapping.map((x) => x.proofType)\n }\n\n /**\n * @deprecated recommended to always search by key type instead as that will have broader support\n */\n public getByVerificationMethodType(verificationMethodType: string) {\n return this.suiteMapping.find((x) => x.verificationMethodTypes.includes(verificationMethodType))\n }\n\n public getAllByPublicJwkType(publicJwkType: SupportedPublicJwkClass | PublicJwk) {\n const publicJwkClass = publicJwkType instanceof PublicJwk ? publicJwkType.JwkClass : publicJwkType\n return this.suiteMapping.filter((x) => x.supportedPublicJwkTypes.includes(publicJwkClass))\n }\n\n public getByProofType(proofType: string) {\n const suiteInfo = this.suiteMapping.find((x) => x.proofType === proofType)\n\n if (!suiteInfo) {\n throw new CredoError(`No signature suite for proof type: ${proofType}`)\n }\n\n return suiteInfo\n }\n\n public getVerificationMethodTypesByProofType(proofType: string): string[] {\n const suiteInfo = this.suiteMapping.find((suiteInfo) => suiteInfo.proofType === proofType)\n\n if (!suiteInfo) {\n throw new CredoError(`No verification method type found for proof type: ${proofType}`)\n }\n\n return suiteInfo.verificationMethodTypes\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAM4B,OAAO;AAEnC,MAAa,sBAAsB,OAAO,sBAAsB;AASzD,mCAAM,uBAAuB;CAKlC,AAAO,YAAY,AAAgC,QAAsC;AACvF,OAAK,eAAe,OAAO,QAAQ,UAA8B,UAAU,UAAU;;CAGvF,IAAW,sBAAgC;AACzC,SAAO,KAAK,aAAa,KAAK,MAAM,EAAE,UAAU;;;;;CAMlD,AAAO,4BAA4B,wBAAgC;AACjE,SAAO,KAAK,aAAa,MAAM,MAAM,EAAE,wBAAwB,SAAS,uBAAuB,CAAC;;CAGlG,AAAO,sBAAsB,eAAoD;EAC/E,MAAM,iBAAiB,yBAAyB,YAAY,cAAc,WAAW;AACrF,SAAO,KAAK,aAAa,QAAQ,MAAM,EAAE,wBAAwB,SAAS,eAAe,CAAC;;CAG5F,AAAO,eAAe,WAAmB;EACvC,MAAM,YAAY,KAAK,aAAa,MAAM,MAAM,EAAE,cAAc,UAAU;AAE1E,MAAI,CAAC,UACH,OAAM,IAAI,WAAW,sCAAsC,YAAY;AAGzE,SAAO;;CAGT,AAAO,sCAAsC,WAA6B;EACxE,MAAM,YAAY,KAAK,aAAa,MAAM,cAAc,UAAU,cAAc,UAAU;AAE1F,MAAI,CAAC,UACH,OAAM,IAAI,WAAW,qDAAqD,YAAY;AAGxF,SAAO,UAAU;;;;CA3CpB,YAAY;oBAMS,UAAU,oBAAoB"}