@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 • 5.1 kB
Source Map (JSON)
{"version":3,"file":"SdJwtVcApi.mjs","names":[],"sources":["../../../src/modules/sd-jwt-vc/SdJwtVcApi.ts"],"sourcesContent":["import type { ResolvedTypeMetadata } from '@sd-jwt/sd-jwt-vc'\nimport { AgentContext } from '../../agent'\nimport { injectable } from '../../plugins'\nimport type { Query, QueryOptions } from '../../storage/StorageService'\nimport type { SdJwtVcRecord } from './repository'\nimport type {\n SdJwtVcHeader,\n SdJwtVcPayload,\n SdJwtVcPresentOptions,\n SdJwtVcSignOptions,\n SdJwtVcStoreOptions,\n SdJwtVcVerifyOptions,\n} from './SdJwtVcOptions'\n\nimport { type SdJwtVc, SdJwtVcService } from './SdJwtVcService'\n\n/**\n * @public\n */\n@injectable()\nexport class SdJwtVcApi {\n private agentContext: AgentContext\n private sdJwtVcService: SdJwtVcService\n\n public constructor(agentContext: AgentContext, sdJwtVcService: SdJwtVcService) {\n this.agentContext = agentContext\n this.sdJwtVcService = sdJwtVcService\n }\n\n public async sign<Payload extends SdJwtVcPayload>(options: SdJwtVcSignOptions<Payload>) {\n return await this.sdJwtVcService.sign<Payload>(this.agentContext, options)\n }\n\n /**\n *\n * Create a compact presentation of the sd-jwt.\n * This presentation can be send in- or out-of-band to the verifier.\n *\n * Also, whether to include the holder key binding.\n */\n public async present<Payload extends SdJwtVcPayload = SdJwtVcPayload>(\n options: SdJwtVcPresentOptions<Payload>\n ): Promise<string> {\n return await this.sdJwtVcService.present(this.agentContext, options)\n }\n\n /**\n *\n * Verify an incoming sd-jwt. It will check whether everything is valid, but also returns parts of the validation.\n *\n * For example, you might still want to continue with a flow if not all the claims are included, but the signature is valid.\n *\n */\n public async verify<Header extends SdJwtVcHeader, Payload extends SdJwtVcPayload>(options: SdJwtVcVerifyOptions) {\n return await this.sdJwtVcService.verify<Header, Payload>(this.agentContext, options)\n }\n\n /**\n * Fetches the type metadata for the `vct`. The default resolver only supports HTTPs,\n * but you can register a custom resolver on the SdJwtVcModule config.\n *\n * If the default resolver is used and fetching the VCT directly fails, it will fallback to the legacy vct path.\n * If both fail, an error will be thrown, unless `throwErrorOnFetchError` is set to `false`.\n *\n * The integrity will always be verified if the metadata was resolved. The `extends` keyword is\n * not resolved yet.\n */\n public async fetchTypeMetadata(\n sdJwtVc: SdJwtVc,\n options?: { throwErrorOnFetchError?: boolean; throwErrorOnUnsupportedVctValue?: boolean }\n ): Promise<ResolvedTypeMetadata | undefined> {\n return this.sdJwtVcService.fetchTypeMetadata(this.agentContext, sdJwtVc, options)\n }\n\n /**\n * Get and validate a sd-jwt-vc from a serialized JWT.\n */\n public fromCompact<Header extends SdJwtVcHeader, Payload extends SdJwtVcPayload>(sdJwtVcCompact: string) {\n return this.sdJwtVcService.fromCompact<Header, Payload>(sdJwtVcCompact)\n }\n\n public async store(options: SdJwtVcStoreOptions) {\n return await this.sdJwtVcService.store(this.agentContext, options)\n }\n\n public async getById(id: string): Promise<SdJwtVcRecord> {\n return await this.sdJwtVcService.getById(this.agentContext, id)\n }\n\n public async getAll(): Promise<Array<SdJwtVcRecord>> {\n return await this.sdJwtVcService.getAll(this.agentContext)\n }\n\n public async findAllByQuery(query: Query<SdJwtVcRecord>, queryOptions?: QueryOptions): Promise<Array<SdJwtVcRecord>> {\n return await this.sdJwtVcService.findByQuery(this.agentContext, query, queryOptions)\n }\n\n public async deleteById(id: string) {\n return await this.sdJwtVcService.deleteById(this.agentContext, id)\n }\n\n public async update(sdJwtVcRecord: SdJwtVcRecord) {\n return await this.sdJwtVcService.update(this.agentContext, sdJwtVcRecord)\n }\n}\n"],"mappings":";;;;;;;AAoBO,IAAM,aAAN,MAAM,WAAW;CAItB,YAAmB,cAA4B,gBAAgC;EAC7E,KAAK,eAAe;EACpB,KAAK,iB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