@@ -125,6 +125,7 @@ export class IssuanceService {
125125 }
126126
127127 async getW3CSchemaAttributes ( schemaUrl : string ) : Promise < ISchemaAttributes [ ] > {
128+ this . logger . debug ( 'Getting w3c schema attributes from schemaUrl' , schemaUrl ) ;
128129 const schemaRequest = await this . commonService . httpGet ( schemaUrl ) . then ( async ( response ) => response ) ;
129130 if ( ! schemaRequest ) {
130131 throw new NotFoundException ( ResponseMessages . schema . error . W3CSchemaNotFOund , {
@@ -140,6 +141,7 @@ export class IssuanceService {
140141 }
141142
142143 const schemaAttributes = JSON . parse ( getSchemaDetails ?. attributes ) ;
144+ this . logger . debug ( 'Schema attributes fetched successfully' , JSON . stringify ( schemaAttributes , null , 2 ) ) ;
143145
144146 return schemaAttributes ;
145147 }
@@ -246,7 +248,7 @@ export class IssuanceService {
246248 const schemaUrlAttributes = await this . getW3CSchemaAttributes ( schemaServerUrl ) ;
247249
248250 if ( isValidateSchema ) {
249- validateW3CSchemaAttributes ( filteredIssuanceAttributes , schemaUrlAttributes ) ;
251+ validateW3CSchemaAttributes ( filteredIssuanceAttributes , schemaUrlAttributes , this . logger ) ;
250252 }
251253 }
252254
@@ -447,7 +449,7 @@ export class IssuanceService {
447449 const schemaUrlAttributes = await this . getW3CSchemaAttributes ( schemaServerUrl ) ;
448450
449451 if ( isValidateSchema ) {
450- validateW3CSchemaAttributes ( filteredIssuanceAttributes , schemaUrlAttributes ) ;
452+ validateW3CSchemaAttributes ( filteredIssuanceAttributes , schemaUrlAttributes , this . logger ) ;
451453 }
452454 }
453455 const credentialCreateOfferDetails = await this . _outOfBandCredentialOffer ( issueData , url , orgId ) ;
@@ -762,21 +764,27 @@ export class IssuanceService {
762764 isValidateSchema
763765 } = outOfBandCredential ;
764766
767+ this . logger . debug ( 'Request reaced isuance microservice service' ) ;
765768 const agentDetails = await this . issuanceRepository . getAgentEndPoint ( orgId ) ;
766769
770+ this . logger . debug ( 'The credential to be issued is of type:' , credentialType ) ;
767771 if ( IssueCredentialType . JSONLD === credentialType ) {
768772 await validateAndUpdateIssuanceDates ( credentialOffer ) ;
769773
774+ this . logger . debug ( 'Validated/Updated Issuance dates credential offer' ) ;
770775 const schemaIds = credentialOffer ?. map ( ( item ) => {
771776 const context : string [ ] = item ?. credential ?. [ '@context' ] ;
772777 return Array . isArray ( context ) && 1 < context . length ? context [ 1 ] : undefined ;
773778 } ) ;
774779
780+ this . logger . debug ( 'Issuing credential with schemaIds' , schemaIds ) ;
775781 const schemaDetails = await this . _getSchemaDetails ( schemaIds ) ;
776782
777783 const ledgerIds = schemaDetails ?. map ( ( item ) => item ?. ledgerId ) ;
784+ this . logger . debug ( 'Issuance will be done with the following schemas: ' , JSON . stringify ( schemaDetails , null , 2 ) ) ;
778785
779786 for ( const ledgerId of ledgerIds ) {
787+ this . logger . debug ( 'Checking ledger compatibility of schemas and issuer agent' ) ;
780788 if ( agentDetails ?. ledgerId !== ledgerId ) {
781789 throw new BadRequestException ( ResponseMessages . issuance . error . ledgerMismatched ) ;
782790 }
@@ -787,6 +795,10 @@ export class IssuanceService {
787795 const schemaResponse : SchemaDetails =
788796 await this . issuanceRepository . getCredentialDefinitionDetails ( credentialDefinitionId ) ;
789797
798+ this . logger . debug (
799+ 'Schema details for indy based credential received:' ,
800+ JSON . stringify ( schemaResponse , null , 2 )
801+ ) ;
790802 let attributesArray : IAttributes [ ] = [ ] ;
791803 if ( schemaResponse ?. attributes ) {
792804 attributesArray = JSON . parse ( schemaResponse . attributes ) ;
@@ -803,6 +815,7 @@ export class IssuanceService {
803815 }
804816 } ) ;
805817 if ( 0 < attrError . length ) {
818+ this . logger . debug ( 'Error validating attributes. Number of errors:' , attrError . length ) ;
806819 throw new BadRequestException ( attrError ) ;
807820 }
808821 }
@@ -839,6 +852,7 @@ export class IssuanceService {
839852 throw new NotFoundException ( ResponseMessages . issuance . error . organizationNotFound ) ;
840853 }
841854 const errors = [ ] ;
855+ this . logger . debug ( 'Creating offer response for agent on url: ' , url ) ;
842856 let credentialOfferResponse ;
843857 const arraycredentialOfferResponse = [ ] ;
844858 const sendEmailCredentialOffer : {
@@ -890,12 +904,14 @@ export class IssuanceService {
890904 } ;
891905
892906 if ( credentialOffer ) {
907+ this . logger . debug ( 'Iterating over credentials offers: ' , credentialOffer . entries ( ) ) ;
893908 for ( const [ index , iterator ] of credentialOffer . entries ( ) ) {
894909 sendEmailCredentialOffer [ 'iterator' ] = iterator ;
895910 sendEmailCredentialOffer [ 'emailId' ] = iterator . emailId ;
896911 sendEmailCredentialOffer [ 'index' ] = index ;
897912
898913 await this . delay ( 500 ) ; // Wait for 0.5 seconds
914+ this . logger . debug ( `Sending offer number: index: ${ index } , iterator: ${ iterator } ` ) ;
899915 const sendOobOffer = await this . sendEmailForCredentialOffer ( sendEmailCredentialOffer ) ;
900916 arraycredentialOfferResponse . push ( sendOobOffer ) ;
901917 }
@@ -905,6 +921,7 @@ export class IssuanceService {
905921
906922 return arraycredentialOfferResponse . every ( ( result ) => true === result ) ;
907923 } else {
924+ this . logger . debug ( 'Sending a single OOB email offer' ) ;
908925 credentialOfferResponse = await this . sendEmailForCredentialOffer ( sendEmailCredentialOffer ) ;
909926 return credentialOfferResponse ;
910927 }
@@ -957,6 +974,7 @@ export class IssuanceService {
957974 try {
958975 let invitationDid : string | undefined ;
959976 if ( true === isReuseConnection ) {
977+ this . logger . debug ( 'This is a reuse connection, fetching invitation did' ) ;
960978 const data : agent_invitations [ ] = await this . issuanceRepository . getInvitationDidByOrgId ( orgId ) ;
961979 if ( data && 0 < data . length ) {
962980 const [ firstElement ] = data ;
@@ -965,6 +983,7 @@ export class IssuanceService {
965983 }
966984
967985 let outOfBandIssuancePayload ;
986+ this . logger . debug ( 'This is an email issuance of type' , credentialType ) ;
968987 if ( IssueCredentialType . INDY === credentialType ) {
969988 outOfBandIssuancePayload = {
970989 protocolVersion : protocolVersion || 'v1' ,
@@ -1016,20 +1035,24 @@ export class IssuanceService {
10161035 const schemaUrlAttributes = await this . getW3CSchemaAttributes ( schemaServerUrl ) ;
10171036
10181037 if ( isValidateSchema ) {
1019- validateW3CSchemaAttributes ( filteredIssuanceAttributes , schemaUrlAttributes ) ;
1038+ validateW3CSchemaAttributes ( filteredIssuanceAttributes , schemaUrlAttributes , this . logger ) ;
10201039 }
10211040 }
1041+ this . logger . debug ( 'Payload created for issuance' ) ;
10221042 const credentialCreateOfferDetails = await this . _outOfBandCredentialOffer ( outOfBandIssuancePayload , url , orgId ) ;
1043+ this . logger . debug ( 'Offer created successfully' ) ;
10231044
10241045 if ( ! credentialCreateOfferDetails ) {
10251046 errors . push ( new NotFoundException ( ResponseMessages . issuance . error . credentialOfferNotFound ) ) ;
10261047 return false ;
10271048 }
10281049
10291050 const invitationUrl : string = credentialCreateOfferDetails . response ?. invitationUrl ;
1051+ this . logger . debug ( 'Shortening invitation url' ) ;
10301052 const shortenUrl : string = await this . storeIssuanceObjectReturnUrl ( invitationUrl ) ;
10311053
10321054 const deepLinkURL = convertUrlToDeepLinkUrl ( shortenUrl ) ;
1055+ this . logger . debug ( 'Deeplink URL created successfully' ) ;
10331056
10341057 if ( ! invitationUrl ) {
10351058 errors . push ( new NotFoundException ( ResponseMessages . issuance . error . invitationNotFound ) ) ;
@@ -1061,6 +1084,7 @@ export class IssuanceService {
10611084 disposition : 'attachment'
10621085 }
10631086 ] ;
1087+ this . logger . debug ( 'Invitation url and deeplink created successfully. Sending email' ) ;
10641088
10651089 const isEmailSent = await sendEmail ( this . emailData ) ;
10661090
@@ -1084,6 +1108,10 @@ export class IssuanceService {
10841108 }
10851109 }
10861110 }
1111+ this . logger . debug (
1112+ 'Email sent successfully for credential threadId:' ,
1113+ credentialCreateOfferDetails . response . credentialRequestThId ?? ''
1114+ ) ;
10871115
10881116 return isEmailSent ;
10891117 } catch ( error ) {
@@ -1123,9 +1151,12 @@ export class IssuanceService {
11231151 response ;
11241152 } > {
11251153 try {
1154+ this . logger . debug ( 'Issuance service call to the agent controller for creating an OOB offer' ) ;
11261155 const pattern = { cmd : 'agent-out-of-band-credential-offer' } ;
11271156 const payload = { outOfBandIssuancePayload, url, orgId } ;
1128- return await this . natsCall ( pattern , payload ) ;
1157+ const result = await this . natsCall ( pattern , payload ) ;
1158+ this . logger . debug ( 'Success: Issuance service call to the agent controller for creating an OOB offer' ) ;
1159+ return result ;
11291160 } catch ( error ) {
11301161 this . logger . error ( `[_outOfBandCredentialOffer] [NATS call]- error in out of band : ${ JSON . stringify ( error ) } ` ) ;
11311162 throw error ;
0 commit comments