import type { ProofProtocol } from './ProofProtocol' import type { AgentMessage } from '../../../agent/AgentMessage' import type { ConnectionRecord } from '../../connections' import type { ExtractProofFormats, ProofFormat, ProofFormatCredentialForRequestPayload, ProofFormatPayload, ProofFormatService, } from '../formats' import type { AutoAcceptProof } from '../models' import type { ProofExchangeRecord } from '../repository' /** * Get the format data payload for a specific message from a list of ProofFormat interfaces and a message * * For an indy offer, this resolves to the proof request format as defined here: * https://github.com/hyperledger/aries-rfcs/tree/b3a3942ef052039e73cd23d847f42947f8287da2/features/0592-indy-attachments#proof-request-format * * @example * ``` * * type RequestFormatData = ProofFormatDataMessagePayload<[IndyProofFormat, PresentationExchangeProofFormat], 'createRequest'> * * // equal to * type RequestFormatData = { * indy: { * // ... payload for indy proof request attachment as defined in RFC 0592 ... * }, * presentationExchange: { * // ... payload for presentation exchange request attachment as defined in RFC 0510 ... * } * } * ``` */ export type ProofFormatDataMessagePayload< CFs extends ProofFormat[] = ProofFormat[], M extends keyof ProofFormat['formatData'] = keyof ProofFormat['formatData'] > = { [ProofFormat in CFs[number] as ProofFormat['formatKey']]?: ProofFormat['formatData'][M] } /** * Infer the {@link ProofFormat} types based on an array of {@link ProofProtocol} types. * * It does this by extracting the `ProofFormatServices` generic from the `ProofProtocol`, and * then extracting the `ProofFormat` generic from each of the `ProofFormatService` types. * * @example * ``` * // TheProofFormatServices is now equal to [IndyProofFormatService] * type TheProofFormatServices = ProofFormatsFromProtocols<[V1ProofProtocol]> * ``` * * Because the `V1ProofProtocol` is defined as follows: * ``` * class V1ProofProtocol implements ProofProtocol<[IndyProofFormatService]> { * } * ``` */ export type ProofFormatsFromProtocols = Type[number] extends ProofProtocol< infer ProofFormatServices > ? ProofFormatServices extends ProofFormatService[] ? ExtractProofFormats : never : never export type GetProofFormatDataReturn = { proposal?: ProofFormatDataMessagePayload request?: ProofFormatDataMessagePayload presentation?: ProofFormatDataMessagePayload } interface BaseOptions { goalCode?: string comment?: string autoAcceptProof?: AutoAcceptProof } export interface CreateProofProposalOptions extends BaseOptions { connectionRecord: ConnectionRecord proofFormats: ProofFormatPayload, 'createProposal'> parentThreadId?: string } export interface AcceptProofProposalOptions extends BaseOptions { proofRecord: ProofExchangeRecord proofFormats?: ProofFormatPayload, 'acceptProposal'> /** @default true */ willConfirm?: boolean } export interface NegotiateProofProposalOptions extends BaseOptions { proofRecord: ProofExchangeRecord proofFormats: ProofFormatPayload, 'createRequest'> /** @default true */ willConfirm?: boolean } export interface CreateProofRequestOptions extends BaseOptions { // Create request can also be used for connection-less, so connection is optional connectionRecord?: ConnectionRecord proofFormats: ProofFormatPayload, 'createRequest'> parentThreadId?: string /** @default true */ willConfirm?: boolean } export interface AcceptProofRequestOptions extends BaseOptions { proofRecord: ProofExchangeRecord proofFormats?: ProofFormatPayload, 'acceptRequest'> } export interface NegotiateProofRequestOptions extends BaseOptions { proofRecord: ProofExchangeRecord proofFormats: ProofFormatPayload, 'createProposal'> } export interface GetCredentialsForRequestOptions { proofRecord: ProofExchangeRecord proofFormats?: ProofFormatCredentialForRequestPayload, 'getCredentialsForRequest', 'input'> } export interface GetCredentialsForRequestReturn { proofFormats: ProofFormatCredentialForRequestPayload, 'getCredentialsForRequest', 'output'> } export interface SelectCredentialsForRequestOptions { proofRecord: ProofExchangeRecord proofFormats?: ProofFormatCredentialForRequestPayload< ExtractProofFormats, 'selectCredentialsForRequest', 'input' > } export interface SelectCredentialsForRequestReturn { proofFormats: ProofFormatCredentialForRequestPayload< ExtractProofFormats, 'selectCredentialsForRequest', 'output' > } export interface AcceptPresentationOptions { proofRecord: ProofExchangeRecord } export interface CreateProofProblemReportOptions { proofRecord: ProofExchangeRecord description: string } export interface ProofProtocolMsgReturnType { message: MessageType proofRecord: ProofExchangeRecord } export interface DeleteProofOptions { deleteAssociatedDidCommMessages?: boolean }