@ -23,7 +23,7 @@ import QRCode from "qrcode"; 
			
		
	
		
		
			
				
					
 
			
		
	
		
		
			
				
					import  {  APP_SERVER ,  NotificationIface  }  from  "@/constants/app" ; import  {  APP_SERVER ,  NotificationIface  }  from  "@/constants/app" ;  
			
		
	
		
		
			
				
					import  {  db ,  retrieveSettingsForActiveAccount  }  from  "@/db/index" ; import  {  db ,  retrieveSettingsForActiveAccount  }  from  "@/db/index" ;  
			
		
	
		
		
			
				
					
					import  *  as  endor serSer verfrom  "@/libs/endorserServer" ; import  *  as  serverUtil   from  "@/libs/endorserServer" ;  
			
				
				
			
		
	
		
		
	
		
		
			
				
					
 
			
		
	
		
		
			
				
					@ Component @ Component  
			
		
	
		
		
			
				
					export  default  class  ClaimCertificateView  extends  Vue  { export  default  class  ClaimCertificateView  extends  Vue  {  
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
						
					 
					@ -35,7 +35,7 @@ export default class ClaimCertificateView extends Vue { 
			
		
	
		
		
			
				
					  claimId  =  "" ;   claimId  =  "" ;  
			
		
	
		
		
			
				
					  claimData  =  null ;   claimData  =  null ;  
			
		
	
		
		
			
				
					
 
			
		
	
		
		
			
				
					
					  endor serSer ver=  endor serSer ver;   serverUtil   =  serverUtil  ;  
			
				
				
			
		
	
		
		
	
		
		
			
				
					
 
			
		
	
		
		
			
				
					  async  created ( )  {   async  created ( )  {  
			
		
	
		
		
			
				
					    const  settings  =  await  retrieveSettingsForActiveAccount ( ) ;     const  settings  =  await  retrieveSettingsForActiveAccount ( ) ;  
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
						
					 
					@ -50,14 +50,27 @@ export default class ClaimCertificateView extends Vue { 
			
		
	
		
		
			
				
					
 
			
		
	
		
		
			
				
					  async  fetchClaim ( )  {   async  fetchClaim ( )  {  
			
		
	
		
		
			
				
					    try  {     try  {  
			
		
	
		
		
			
				
					
					      const  response  =  await  fetch (       const  headers  =  await  serverUtil . getHeaders ( this . activeDid ) ;  
			
				
				
			
		
	
		
		
	
		
		
			
				
					      const  response  =  await  this . axios . get (  
			
		
	
		
		
			
				
					        ` ${ this . apiServer } /api/claim/ ${ this . claimId } ` ,         ` ${ this . apiServer } /api/claim/ ${ this . claimId } ` ,  
			
		
	
		
		
			
				
					        {  headers  } ,  
			
		
	
		
		
			
				
					      ) ;       ) ;  
			
		
	
		
		
			
				
					
					      if  ( response . ok )  {       if  ( response . status  ===  200 )  {  
			
				
				
			
		
	
		
		
			
				
					
					        this . claimData  =  await  response . json ( ) ;         this . claimData  =  await  response . data ;  
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					        const  claimEntryIds  =  [ this . claimId ] ;  
			
		
	
		
		
			
				
					        const  headers  =  await  serverUtil . getHeaders ( this . activeDid ) ;  
			
		
	
		
		
			
				
					        const  confirmerResponse  =  await  this . axios . post (  
			
		
	
		
		
			
				
					          ` ${ this . apiServer } /api/v2/report/confirmers/?claimEntryIds= ${ this . claimId } ` ,  
			
		
	
		
		
			
				
					          {  claimEntryIds  } ,  
			
		
	
		
		
			
				
					          {  headers  } ,  
			
		
	
		
		
			
				
					        ) ;  
			
		
	
		
		
			
				
					        let  confirmerIds :  Array < string >  =  [ ] ;  
			
		
	
		
		
			
				
					        if  ( confirmerResponse . status  ===  200 )  {  
			
		
	
		
		
			
				
					          confirmerIds  =  await  confirmerResponse . data . data ;  
			
		
	
		
		
			
				
					        }  
			
		
	
		
		
			
				
					        await  nextTick ( ) ;  / /   W a i t   f o r   t h e   D O M   t o   u p d a t e         await  nextTick ( ) ;  / /   W a i t   f o r   t h e   D O M   t o   u p d a t e  
			
		
	
		
		
			
				
					        if  ( this . claimData )  {         if  ( this . claimData )  {  
			
		
	
		
		
			
				
					
					          this . drawCanvas ( this . claimData ) ;           this . drawCanvas ( this . claimData ,  confirmerIds ) ;  
			
				
				
			
		
	
		
		
	
		
		
			
				
					        }         }  
			
		
	
		
		
			
				
					      }  else  {       }  else  {  
			
		
	
		
		
			
				
					        throw  new  Error ( ` Error fetching claim:  ${ response . statusText } ` ) ;         throw  new  Error ( ` Error fetching claim:  ${ response . statusText } ` ) ;  
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
						
					 
					@ -74,7 +87,8 @@ export default class ClaimCertificateView extends Vue { 
			
		
	
		
		
			
				
					  }   }  
			
		
	
		
		
			
				
					
 
			
		
	
		
		
			
				
					  async  drawCanvas (   async  drawCanvas (  
			
		
	
		
		
			
				
					
					    claimData :  endorserServer . GenericCredWrapper < endorserServer .GenericVerifiableCredential > ,     claimData :  serverUtil . GenericCredWrapper < serverUtil .GenericVerifiableCredential > ,  
			
				
				
			
		
	
		
		
	
		
		
			
				
					    confirmerIds :  Array < string > ,  
			
		
	
		
		
			
				
					  )  {   )  {  
			
		
	
		
		
			
				
					    await  db . open ( ) ;     await  db . open ( ) ;  
			
		
	
		
		
			
				
					    const  allContacts  =  await  db . contacts . toArray ( ) ;     const  allContacts  =  await  db . contacts . toArray ( ) ;  
			
		
	
	
		
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
					@ -102,7 +116,7 @@ export default class ClaimCertificateView extends Vue { 
			
		
	
		
		
			
				
					          / /   D r a w   c l a i m   t y p e           / /   D r a w   c l a i m   t y p e  
			
		
	
		
		
			
				
					          ctx . font  =  "bold 20px Arial" ;           ctx . font  =  "bold 20px Arial" ;  
			
		
	
		
		
			
				
					          const  claimTypeText  =           const  claimTypeText  =  
			
		
	
		
		
			
				
					
					            this . endor serSer ver. capitalizeAndInsertSpacesBeforeCaps (             this . serverUtil  . capitalizeAndInsertSpacesBeforeCaps (  
			
				
				
			
		
	
		
		
	
		
		
			
				
					              claimData . claimType  ||  "" ,               claimData . claimType  ||  "" ,  
			
		
	
		
		
			
				
					            ) ;             ) ;  
			
		
	
		
		
			
				
					          const  claimTypeWidth  =  ctx . measureText ( claimTypeText ) . width ;           const  claimTypeWidth  =  ctx . measureText ( claimTypeText ) . width ;  
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
						
					 
					@ -121,8 +135,10 @@ export default class ClaimCertificateView extends Vue { 
			
		
	
		
		
			
				
					              ( CANVAS_WIDTH  -  presentedWidth )  /  2 ,  / /   C e n t e r   h o r i z o n t a l l y               ( CANVAS_WIDTH  -  presentedWidth )  /  2 ,  / /   C e n t e r   h o r i z o n t a l l y  
			
		
	
		
		
			
				
					              CANVAS_HEIGHT  *  0.37 ,               CANVAS_HEIGHT  *  0.37 ,  
			
		
	
		
		
			
				
					            ) ;             ) ;  
			
		
	
		
		
			
				
					
					            const  agentText  =  endorserServer . didInfoForCertificate (             const  agentDid  =  
			
				
				
			
		
	
		
		
			
				
					
					              claimData . claim . agent ,               claimData . claim . agent . identifier  ||  claimData . claim . agent ;  
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					            const  agentText  =  serverUtil . didInfoForCertificate (  
			
		
	
		
		
			
				
					              agentDid ,  
			
		
	
		
		
			
				
					              allContacts ,               allContacts ,  
			
		
	
		
		
			
				
					            ) ;             ) ;  
			
		
	
		
		
			
				
					            ctx . font  =  "bold 20px Arial" ;             ctx . font  =  "bold 20px Arial" ;  
			
		
	
	
		
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
					@ -155,12 +171,21 @@ export default class ClaimCertificateView extends Vue { 
			
		
	
		
		
			
				
					            ctx . font  =  "14px Arial" ;             ctx . font  =  "14px Arial" ;  
			
		
	
		
		
			
				
					            const  issuerText  =             const  issuerText  =  
			
		
	
		
		
			
				
					              "Issued by "  +               "Issued by "  +  
			
		
	
		
		
			
				
					
					              endorserServer . didInfoForCertificate (               serverUtil . didInfoForCertificate ( claimData . issuer ,  allContacts ) ;  
			
				
				
			
		
	
		
		
			
				
					                claimData . issuer ,  
			
		
	
		
		
			
				
					                allContacts ,  
			
		
	
		
		
			
				
					              ) ;  
			
		
	
		
		
	
		
		
			
				
					            ctx . fillText ( issuerText ,  CANVAS_WIDTH  *  0.3 ,  CANVAS_HEIGHT  *  0.6 ) ;             ctx . fillText ( issuerText ,  CANVAS_WIDTH  *  0.3 ,  CANVAS_HEIGHT  *  0.6 ) ;  
			
		
	
		
		
			
				
					          }           }  
			
		
	
		
		
			
				
					          if  ( confirmerIds . length  >  0 )  {  
			
		
	
		
		
			
				
					            const  confirmerText  =  
			
		
	
		
		
			
				
					              "Confirmed by "  +  
			
		
	
		
		
			
				
					              confirmerIds . length  +  
			
		
	
		
		
			
				
					              ( confirmerIds . length  ===  1  ?  " person"  :  " people" ) ;  
			
		
	
		
		
			
				
					            ctx . font  =  "14px Arial" ;  
			
		
	
		
		
			
				
					            ctx . fillText (  
			
		
	
		
		
			
				
					              confirmerText ,  
			
		
	
		
		
			
				
					              CANVAS_WIDTH  *  0.3 ,  
			
		
	
		
		
			
				
					              CANVAS_HEIGHT  *  0.63 ,  
			
		
	
		
		
			
				
					            ) ;  
			
		
	
		
		
			
				
					          }  
			
		
	
		
		
			
				
					
 
			
		
	
		
		
			
				
					          / /   D r a w   c l a i m   I D           / /   D r a w   c l a i m   I D  
			
		
	
		
		
			
				
					          ctx . font  =  "14px Arial" ;           ctx . font  =  "14px Arial" ;