import type { AgentMessage } from '../../../../agent/AgentMessage'; import type { HandlerInboundMessage } from '../../../../agent/Handler'; import type { InboundMessageContext } from '../../../../agent/models/InboundMessageContext'; import type { ProblemReportMessage } from '../../../problem-reports'; import type { CreateProposalOptions, CredentialProtocolMsgReturnType, AcceptProposalOptions, NegotiateProposalOptions, CreateOfferOptions, AcceptOfferOptions, NegotiateOfferOptions, CreateRequestOptions, AcceptRequestOptions, AcceptCredentialOptions, GetFormatDataReturn, CreateProblemReportOptions } from '../../CredentialServiceOptions'; import type { CredentialFormat, CredentialFormatService } from '../../formats'; import { AgentConfig } from '../../../../agent/AgentConfig'; import { Dispatcher } from '../../../../agent/Dispatcher'; import { EventEmitter } from '../../../../agent/EventEmitter'; import { DidCommMessageRepository } from '../../../../storage'; import { ConnectionService } from '../../../connections'; import { RoutingService } from '../../../routing/services/RoutingService'; import { IndyCredentialFormatService } from '../../formats/indy/IndyCredentialFormatService'; import { CredentialRepository, CredentialExchangeRecord } from '../../repository'; import { CredentialService } from '../../services/CredentialService'; import { V2OfferCredentialHandler } from './handlers'; import { V2CredentialAckMessage, V2IssueCredentialMessage, V2OfferCredentialMessage, V2ProposeCredentialMessage, V2RequestCredentialMessage } from './messages'; export declare class V2CredentialService extends CredentialService { private connectionService; private credentialFormatCoordinator; protected didCommMessageRepository: DidCommMessageRepository; private routingService; private formatServiceMap; constructor(connectionService: ConnectionService, didCommMessageRepository: DidCommMessageRepository, agentConfig: AgentConfig, routingService: RoutingService, dispatcher: Dispatcher, eventEmitter: EventEmitter, credentialRepository: CredentialRepository, indyCredentialFormatService: IndyCredentialFormatService); /** * The version of the issue credential protocol this service supports */ readonly version: "v2"; getFormatServiceForRecordType(credentialRecordType: CFs[number]['credentialRecordType']): CredentialFormatService; /** * Create a {@link V2ProposeCredentialMessage} not bound to an existing credential exchange. * * @param proposal The ProposeCredentialOptions object containing the important fields for the credential message * @returns Object containing proposal message and associated credential record * */ createProposal({ connection, credentialFormats, comment, autoAcceptCredential, }: CreateProposalOptions): Promise>; /** * Method called by {@link V2ProposeCredentialHandler} on reception of a propose credential message * We do the necessary processing here to accept the proposal and do the state change, emit event etc. * @param messageContext the inbound propose credential message * @returns credential record appropriate for this incoming message (once accepted) */ processProposal(messageContext: InboundMessageContext): Promise; acceptProposal({ credentialRecord, credentialFormats, autoAcceptCredential, comment, }: AcceptProposalOptions): Promise>; /** * Negotiate a credential proposal as issuer (by sending a credential offer message) to the connection * associated with the credential record. * * @param options configuration for the offer see {@link NegotiateProposalOptions} * @returns Credential exchange record associated with the credential offer * */ negotiateProposal({ credentialRecord, credentialFormats, autoAcceptCredential, comment, }: NegotiateProposalOptions): Promise>; /** * Create a {@link V2OfferCredentialMessage} as beginning of protocol process. If no connectionId is provided, the * exchange will be created without a connection for usage in oob and connection-less issuance. * * @param formatService {@link CredentialFormatService} the format service object containing format-specific logic * @param options attributes of the original offer * @returns Object containing offer message and associated credential record * */ createOffer({ credentialFormats, autoAcceptCredential, comment, connection, }: CreateOfferOptions): Promise>; /** * Method called by {@link V2OfferCredentialHandler} on reception of a offer credential message * We do the necessary processing here to accept the offer and do the state change, emit event etc. * @param messageContext the inbound offer credential message * @returns credential record appropriate for this incoming message (once accepted) */ processOffer(messageContext: HandlerInboundMessage): Promise; acceptOffer({ credentialRecord, autoAcceptCredential, comment, credentialFormats, }: AcceptOfferOptions): Promise<{ credentialRecord: CredentialExchangeRecord; message: V2RequestCredentialMessage; }>; /** * Create a {@link ProposePresentationMessage} as response to a received credential offer. * To create a proposal not bound to an existing credential exchange, use {@link createProposal}. * * @param options configuration to use for the proposal * @returns Object containing proposal message and associated credential record * */ negotiateOffer({ credentialRecord, credentialFormats, autoAcceptCredential, comment, }: NegotiateOfferOptions): Promise>; /** * Create a {@link V2RequestCredentialMessage} as beginning of protocol process. * @returns Object containing offer message and associated credential record * */ createRequest({ credentialFormats, autoAcceptCredential, comment, connection, }: CreateRequestOptions): Promise>; /** * Process a received {@link RequestCredentialMessage}. This will not accept the credential request * or send a credential. It will only update the existing credential record with * the information from the credential request message. Use {@link createCredential} * after calling this method to create a credential. * * @param messageContext The message context containing a v2 credential request message * @returns credential record associated with the credential request message * */ processRequest(messageContext: InboundMessageContext): Promise; acceptRequest({ credentialRecord, autoAcceptCredential, comment, credentialFormats, }: AcceptRequestOptions): Promise<{ credentialRecord: CredentialExchangeRecord; message: V2IssueCredentialMessage; }>; /** * Process a received {@link IssueCredentialMessage}. This will not accept the credential * or send a credential acknowledgement. It will only update the existing credential record with * the information from the issue credential message. Use {@link createAck} * after calling this method to create a credential acknowledgement. * * @param messageContext The message context containing an issue credential message * * @returns credential record associated with the issue credential message * */ processCredential(messageContext: InboundMessageContext): Promise; /** * Create a {@link V2CredentialAckMessage} as response to a received credential. * * @param credentialRecord The credential record for which to create the credential acknowledgement * @returns Object containing credential acknowledgement message and associated credential record * */ acceptCredential({ credentialRecord, }: AcceptCredentialOptions): Promise>; /** * Process a received {@link CredentialAckMessage}. * * @param messageContext The message context containing a credential acknowledgement message * @returns credential record associated with the credential acknowledgement message * */ processAck(messageContext: InboundMessageContext): Promise; /** * Create a {@link V2CredentialProblemReportMessage} to be sent. * * @param message message to send * @returns a {@link V2CredentialProblemReportMessage} * */ createProblemReport(options: CreateProblemReportOptions): ProblemReportMessage; shouldAutoRespondToProposal(options: { credentialRecord: CredentialExchangeRecord; proposalMessage: V2ProposeCredentialMessage; }): Promise; shouldAutoRespondToOffer(options: { credentialRecord: CredentialExchangeRecord; offerMessage: V2OfferCredentialMessage; }): Promise; shouldAutoRespondToRequest(options: { credentialRecord: CredentialExchangeRecord; requestMessage: V2RequestCredentialMessage; }): Promise; shouldAutoRespondToCredential(options: { credentialRecord: CredentialExchangeRecord; credentialMessage: V2IssueCredentialMessage; }): Promise; findProposalMessage(credentialExchangeId: string): Promise; findOfferMessage(credentialExchangeId: string): Promise; findRequestMessage(credentialExchangeId: string): Promise; findCredentialMessage(credentialExchangeId: string): Promise; getFormatData(credentialExchangeId: string): Promise; protected registerHandlers(): void; /** * Get all the format service objects for a given credential format from an incoming message * @param messageFormats the format objects containing the format name (eg indy) * @return the credential format service objects in an array - derived from format object keys */ private getFormatServicesFromMessage; /** * Get all the format service objects for a given credential format * @param credentialFormats the format object containing various optional parameters * @return the credential format service objects in an array - derived from format object keys */ private getFormatServices; private getFormatServiceForFormatKey; private getFormatServiceForFormat; }