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

109 lines (108 loc) • 4.33 kB
import { AgentContext } from "../../agent/context/AgentContext.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 "../../agent/index.mjs"; import { Mdoc } from "./Mdoc.mjs"; import { MdocDcApiService } from "./MdocDcApiService.mjs"; import { MdocService } from "./MdocService.mjs"; //#region src/modules/mdoc/MdocApi.ts let MdocApi = class MdocApi { constructor(agentContext, mdocService, mdocDcApiService) { this.agentContext = agentContext; this.mdocService = mdocService; this.mdocDcApiService = mdocDcApiService; } /** * Create a new Mdoc, with a spcific doctype, namespace, and validity info. */ async sign(options) { return await this.mdocService.signMdoc(this.agentContext, options); } /** * * Verify an incoming mdoc. It will check whether everything is valid, but also returns parts of the validation. * * For example, you might still want to continue with a flow if not all the claims are included, but the signature is valid. * */ async verify(mdoc, options) { return await this.mdocService.verifyMdoc(this.agentContext, mdoc, options); } /** * Create a Mdoc class from a base64url encoded Mdoc Issuer-Signed structure */ fromBase64Url(base64Url) { return Mdoc.fromBase64Url(base64Url); } async store(options) { return await this.mdocService.store(this.agentContext, options); } async getById(id) { return await this.mdocService.getById(this.agentContext, id); } async getAll() { return await this.mdocService.getAll(this.agentContext); } async findAllByQuery(query, queryOptions) { return await this.mdocService.findByQuery(this.agentContext, query, queryOptions); } async deleteById(id) { return await this.mdocService.deleteById(this.agentContext, id); } async update(mdocRecord) { return await this.mdocService.update(this.agentContext, mdocRecord); } /** * Get an mdoc verification session by id, for any of the mdoc presentation protocols. */ async getVerificationSessionById(verificationSessionId) { return await this.mdocService.getVerificationSessionById(this.agentContext, verificationSessionId); } async findVerificationSessionsByQuery(query, queryOptions) { return await this.mdocService.findVerificationSessionsByQuery(this.agentContext, query, queryOptions); } /** * Delete an mdoc verification session. By default the ephemeral session key created for the * session is deleted along with it; it is not deleted at any other point in the session * lifecycle. */ async deleteVerificationSessionById(verificationSessionId, options) { return await this.mdocService.deleteVerificationSessionById(this.agentContext, verificationSessionId, options); } /** * Create an ISO 18013-7 Annex C (`org-iso-mdoc`) DC API request and the verification session * tracking it. The returned request can be passed to `navigator.credentials.get()` as the * `data` of a `org-iso-mdoc` protocol request. */ async createDcApiVerificationSession(options) { return await this.mdocDcApiService.createVerificationSession(this.agentContext, options); } /** * Decrypt and verify an `org-iso-mdoc` DC API response for a verification session. */ async verifyDcApiResponse(options) { return await this.mdocDcApiService.verifyResponse(this.agentContext, options); } /** * Parse an incoming `org-iso-mdoc` DC API request, verify reader authentication where present, * and match the requested documents against the stored mdocs. */ async resolveDcApiRequest(options) { return await this.mdocDcApiService.resolveRequest(this.agentContext, options); } /** * Create the encrypted `org-iso-mdoc` DC API response for a resolved request. */ async createDcApiResponse(options) { return await this.mdocDcApiService.createResponse(this.agentContext, options); } }; MdocApi = __decorate([injectable(), __decorateMetadata("design:paramtypes", [ typeof AgentContext === "undefined" ? Object : AgentContext, typeof MdocService === "undefined" ? Object : MdocService, typeof MdocDcApiService === "undefined" ? Object : MdocDcApiService ])], MdocApi); //#endregion export { MdocApi }; //# sourceMappingURL=MdocApi.mjs.map