11import { PROTOCOL_MESSAGE_TYPE , MediaType } from '../constants' ;
22import {
3+ Attachment ,
34 BasicMessage ,
45 CredentialOffer ,
56 CredentialsOfferMessage ,
@@ -13,9 +14,9 @@ import * as uuid from 'uuid';
1314import { proving } from '@iden3/js-jwz' ;
1415import {
1516 Proposal ,
16- ProposalRequestCredential ,
1717 ProposalRequestMessage ,
18- ProposalMessage
18+ ProposalMessage ,
19+ ProposalRequestCredential
1920} from '../types/protocol/proposal-request' ;
2021import { IIdentityWallet } from '../../identity' ;
2122import { byteEncoder } from '../../utils' ;
@@ -32,6 +33,7 @@ export type ProposalRequestCreationOptions = {
3233 credentials : ProposalRequestCredential [ ] ;
3334 did_doc ?: DIDDocument ;
3435 expires_time ?: Date ;
36+ attachments ?: Attachment [ ] ;
3537} ;
3638
3739/** @beta ProposalCreationOptions represents proposal creation options */
@@ -62,7 +64,8 @@ export function createProposalRequest(
6264 type : PROTOCOL_MESSAGE_TYPE . PROPOSAL_REQUEST_MESSAGE_TYPE ,
6365 body : opts ,
6466 created_time : getUnixTimestamp ( new Date ( ) ) ,
65- expires_time : opts ?. expires_time ? getUnixTimestamp ( opts . expires_time ) : undefined
67+ expires_time : opts ?. expires_time ? getUnixTimestamp ( opts . expires_time ) : undefined ,
68+ attachments : opts . attachments
6669 } ;
6770 return request ;
6871}
@@ -153,7 +156,11 @@ export type ProposalHandlerOptions = BasicHandlerOptions & {
153156/** @beta CredentialProposalHandlerParams represents credential proposal handler params */
154157export type CredentialProposalHandlerParams = {
155158 agentUrl : string ;
156- proposalResolverFn : ( context : string , type : string ) => Promise < Proposal > ;
159+ proposalResolverFn : (
160+ context : string ,
161+ type : string ,
162+ opts ?: { msg ?: BasicMessage }
163+ ) => Promise < Proposal > ;
157164 packerParams : PackerParams ;
158165} ;
159166
@@ -281,7 +288,9 @@ export class CredentialProposalHandler
281288 }
282289
283290 // credential not found in the wallet, prepare proposal protocol message
284- const proposal = await this . _params . proposalResolverFn ( cred . context , cred . type ) ;
291+ const proposal = await this . _params . proposalResolverFn ( cred . context , cred . type , {
292+ msg : proposalRequest
293+ } ) ;
285294 if ( ! proposal ) {
286295 throw new Error ( `can't resolve Proposal for type: ${ cred . type } , context: ${ cred . context } ` ) ;
287296 }
0 commit comments