import type { CredentialFormat, CredentialFormatPayload } from './CredentialFormat' import type { CredentialFormatService } from './CredentialFormatService' import type { Attachment } from '../../../decorators/attachment/Attachment' import type { CredentialFormatSpec } from '../models/CredentialFormatSpec' import type { CredentialPreviewAttributeOptions } from '../models/CredentialPreviewAttribute' import type { CredentialExchangeRecord } from '../repository/CredentialExchangeRecord' /** * Infer the {@link CredentialFormat} based on a {@link CredentialFormatService}. * * It does this by extracting the `CredentialFormat` generic from the `CredentialFormatService`. * * @example * ``` * // TheCredentialFormat is now equal to IndyCredentialFormat * type TheCredentialFormat = ExtractCredentialFormat * ``` * * Because the `IndyCredentialFormatService` is defined as follows: * ``` * class IndyCredentialFormatService implements CredentialFormatService { * } * ``` */ export type ExtractCredentialFormat = Type extends CredentialFormatService ? CredentialFormat : never /** * Infer an array of {@link CredentialFormat} types based on an array of {@link CredentialFormatService} types. * * This is based on {@link ExtractCredentialFormat}, but allows to handle arrays. */ export type ExtractCredentialFormats = { [CF in keyof CFs]: ExtractCredentialFormat } /** * Base return type for all methods that create an attachment format. * * It requires an attachment and a format to be returned. */ export interface CredentialFormatCreateReturn { format: CredentialFormatSpec attachment: Attachment } /** * Base return type for all credential process methods. */ export interface CredentialFormatProcessOptions { attachment: Attachment credentialRecord: CredentialExchangeRecord } export interface CredentialFormatProcessCredentialOptions extends CredentialFormatProcessOptions { requestAttachment: Attachment } export interface CredentialFormatCreateProposalOptions { credentialRecord: CredentialExchangeRecord credentialFormats: CredentialFormatPayload<[CF], 'createProposal'> attachmentId?: string } export interface CredentialFormatAcceptProposalOptions { credentialRecord: CredentialExchangeRecord credentialFormats?: CredentialFormatPayload<[CF], 'acceptProposal'> attachmentId?: string proposalAttachment: Attachment } export interface CredentialFormatCreateProposalReturn extends CredentialFormatCreateReturn { previewAttributes?: CredentialPreviewAttributeOptions[] } export interface CredentialFormatCreateOfferOptions { credentialRecord: CredentialExchangeRecord credentialFormats: CredentialFormatPayload<[CF], 'createOffer'> attachmentId?: string } export interface CredentialFormatAcceptOfferOptions { credentialRecord: CredentialExchangeRecord credentialFormats?: CredentialFormatPayload<[CF], 'acceptOffer'> attachmentId?: string offerAttachment: Attachment } export interface CredentialFormatCreateOfferReturn extends CredentialFormatCreateReturn { previewAttributes?: CredentialPreviewAttributeOptions[] } export interface CredentialFormatCreateRequestOptions { credentialRecord: CredentialExchangeRecord credentialFormats: CredentialFormatPayload<[CF], 'createRequest'> } export interface CredentialFormatAcceptRequestOptions { credentialRecord: CredentialExchangeRecord credentialFormats?: CredentialFormatPayload<[CF], 'acceptRequest'> attachmentId?: string requestAttachment: Attachment offerAttachment?: Attachment } // Auto accept method interfaces export interface CredentialFormatAutoRespondProposalOptions { credentialRecord: CredentialExchangeRecord proposalAttachment: Attachment offerAttachment: Attachment } export interface CredentialFormatAutoRespondOfferOptions { credentialRecord: CredentialExchangeRecord proposalAttachment: Attachment offerAttachment: Attachment } export interface CredentialFormatAutoRespondRequestOptions { credentialRecord: CredentialExchangeRecord proposalAttachment?: Attachment offerAttachment: Attachment requestAttachment: Attachment } export interface CredentialFormatAutoRespondCredentialOptions { credentialRecord: CredentialExchangeRecord proposalAttachment?: Attachment offerAttachment?: Attachment requestAttachment: Attachment credentialAttachment: Attachment }