@ -2,7 +2,6 @@ import { Axios, AxiosRequestConfig, AxiosResponse } from "axios"; 
			
		
	
		
		
			
				
					import  *  as  didJwt  from  "did-jwt" ; import  *  as  didJwt  from  "did-jwt" ;  
			
		
	
		
		
			
				
					import  {  LRUCache  }  from  "lru-cache" ; import  {  LRUCache  }  from  "lru-cache" ;  
			
		
	
		
		
			
				
					import  *  as  R  from  "ramda" ; import  *  as  R  from  "ramda" ;  
			
		
	
		
		
			
				
					import  {  IIdentifier  }  from  "@veramo/core" ;  
			
		
	
		
		
			
				
					
 
			
		
	
		
		
			
				
					import  {  DEFAULT_IMAGE_API_SERVER  }  from  "@/constants/app" ; import  {  DEFAULT_IMAGE_API_SERVER  }  from  "@/constants/app" ;  
			
		
	
		
		
			
				
					import  {  Contact  }  from  "@/db/tables/contacts" ; import  {  Contact  }  from  "@/db/tables/contacts" ;  
			
		
	
	
		
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
					@ -516,6 +515,9 @@ export async function setPlanInCache( 
			
		
	
		
		
			
				
					  planCache . set ( handleId ,  planSummary ) ;   planCache . set ( handleId ,  planSummary ) ;  
			
		
	
		
		
			
				
					} }  
			
		
	
		
		
			
				
					
 
			
		
	
		
		
			
				
					/ * *  
			
		
	
		
		
			
				
					 *  Construct  GiveAction  VC  for  submission  to  server  
			
		
	
		
		
			
				
					 * /  
			
		
	
		
		
			
				
					export  function  constructGive ( export  function  constructGive (  
			
		
	
		
		
			
				
					  fromDid? : string  |  null ,   fromDid? : string  |  null ,  
			
		
	
		
		
			
				
					  toDid? : string ,   toDid? : string ,  
			
		
	
	
		
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
					@ -570,7 +572,7 @@ export function constructGive( 
			
		
	
		
		
			
				
					export  async  function  createAndSubmitGive ( export  async  function  createAndSubmitGive (  
			
		
	
		
		
			
				
					  axios : Axios ,   axios : Axios ,  
			
		
	
		
		
			
				
					  apiServer : string ,   apiServer : string ,  
			
		
	
		
		
			
				
					
					  identity : IIdentifier  ,   issuerDid : string  ,  
			
				
				
			
		
	
		
		
	
		
		
			
				
					  fromDid? : string  |  null ,   fromDid? : string  |  null ,  
			
		
	
		
		
			
				
					  toDid? : string ,   toDid? : string ,  
			
		
	
		
		
			
				
					  description? : string ,   description? : string ,  
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
						
					 
					@ -594,7 +596,7 @@ export async function createAndSubmitGive( 
			
		
	
		
		
			
				
					  ) ;   ) ;  
			
		
	
		
		
			
				
					  return  createAndSubmitClaim (   return  createAndSubmitClaim (  
			
		
	
		
		
			
				
					    vcClaim  as  GenericCredWrapper ,     vcClaim  as  GenericCredWrapper ,  
			
		
	
		
		
			
				
					
					    identity  ,     issuerDid  ,  
			
				
				
			
		
	
		
		
	
		
		
			
				
					    apiServer ,     apiServer ,  
			
		
	
		
		
			
				
					    axios ,     axios ,  
			
		
	
		
		
			
				
					  ) ;   ) ;  
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
						
					 
					@ -612,7 +614,7 @@ export async function createAndSubmitGive( 
			
		
	
		
		
			
				
					export  async  function  createAndSubmitOffer ( export  async  function  createAndSubmitOffer (  
			
		
	
		
		
			
				
					  axios : Axios ,   axios : Axios ,  
			
		
	
		
		
			
				
					  apiServer : string ,   apiServer : string ,  
			
		
	
		
		
			
				
					
					  identity : IIdentifier  ,   issuerDid : string  ,  
			
				
				
			
		
	
		
		
	
		
		
			
				
					  description? : string ,   description? : string ,  
			
		
	
		
		
			
				
					  amount? : number ,   amount? : number ,  
			
		
	
		
		
			
				
					  unitCode? : string ,   unitCode? : string ,  
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
						
					 
					@ -623,7 +625,7 @@ export async function createAndSubmitOffer( 
			
		
	
		
		
			
				
					  const  vcClaim : OfferVerifiableCredential  =  {   const  vcClaim : OfferVerifiableCredential  =  {  
			
		
	
		
		
			
				
					    "@context" :  SCHEMA_ORG_CONTEXT ,     "@context" :  SCHEMA_ORG_CONTEXT ,  
			
		
	
		
		
			
				
					    "@type" :  "Offer" ,     "@type" :  "Offer" ,  
			
		
	
		
		
			
				
					
					    offeredBy :  {  identifier : identity.d id  } ,     offeredBy :  {  identifier : issuerD id  } ,  
			
				
				
			
		
	
		
		
	
		
		
			
				
					    validThrough : expirationDate  ||  undefined ,     validThrough : expirationDate  ||  undefined ,  
			
		
	
		
		
			
				
					  } ;   } ;  
			
		
	
		
		
			
				
					  if  ( amount )  {   if  ( amount )  {  
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
						
					 
					@ -647,7 +649,7 @@ export async function createAndSubmitOffer( 
			
		
	
		
		
			
				
					  }   }  
			
		
	
		
		
			
				
					  return  createAndSubmitClaim (   return  createAndSubmitClaim (  
			
		
	
		
		
			
				
					    vcClaim  as  GenericCredWrapper ,     vcClaim  as  GenericCredWrapper ,  
			
		
	
		
		
			
				
					
					    identity  ,     issuerDid  ,  
			
				
				
			
		
	
		
		
	
		
		
			
				
					    apiServer ,     apiServer ,  
			
		
	
		
		
			
				
					    axios ,     axios ,  
			
		
	
		
		
			
				
					  ) ;   ) ;  
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
						
					 
					@ -655,7 +657,7 @@ export async function createAndSubmitOffer( 
			
		
	
		
		
			
				
					
 
			
		
	
		
		
			
				
					// similar logic is found in endorser-mobile
 // similar logic is found in endorser-mobile
  
			
		
	
		
		
			
				
					export  const  createAndSubmitConfirmation  =  async  ( export  const  createAndSubmitConfirmation  =  async  (  
			
		
	
		
		
			
				
					
					  identifier : IIdentifier  ,   issuerDid : string  ,  
			
				
				
			
		
	
		
		
	
		
		
			
				
					  claim : GenericVerifiableCredential ,   claim : GenericVerifiableCredential ,  
			
		
	
		
		
			
				
					  lastClaimId : string ,  // used to set the lastClaimId
   lastClaimId : string ,  // used to set the lastClaimId
  
			
		
	
		
		
			
				
					  handleId : string  |  undefined ,   handleId : string  |  undefined ,  
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
						
					 
					@ -672,12 +674,12 @@ export const createAndSubmitConfirmation = async ( 
			
		
	
		
		
			
				
					    "@type" :  "AgreeAction" ,     "@type" :  "AgreeAction" ,  
			
		
	
		
		
			
				
					    object :  goodClaim ,     object :  goodClaim ,  
			
		
	
		
		
			
				
					  } ;   } ;  
			
		
	
		
		
			
				
					
					  return  createAndSubmitClaim ( confirmationClaim ,  identifier  ,  apiServer ,  axios ) ;   return  createAndSubmitClaim ( confirmationClaim ,  issuerDid  ,  apiServer ,  axios ) ;  
			
				
				
			
		
	
		
		
	
		
		
			
				
					} ; } ;  
			
		
	
		
		
			
				
					
 
			
		
	
		
		
			
				
					export  async  function  createAndSubmitClaim ( export  async  function  createAndSubmitClaim (  
			
		
	
		
		
			
				
					  vcClaim : GenericVerifiableCredential ,   vcClaim : GenericVerifiableCredential ,  
			
		
	
		
		
			
				
					
					  identity : IIdentifier  ,   issuerDid : string  ,  
			
				
				
			
		
	
		
		
	
		
		
			
				
					  apiServer : string ,   apiServer : string ,  
			
		
	
		
		
			
				
					  axios : Axios ,   axios : Axios ,  
			
		
	
		
		
			
				
					) :  Promise < CreateAndSubmitClaimResult >  { ) :  Promise < CreateAndSubmitClaimResult >  {  
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
						
					 
					@ -690,34 +692,15 @@ export async function createAndSubmitClaim( 
			
		
	
		
		
			
				
					      } ,       } ,  
			
		
	
		
		
			
				
					    } ;     } ;  
			
		
	
		
		
			
				
					
 
			
		
	
		
		
			
				
					
					    // Create a signature using private key of identity
     const  vcJwt : string  =  await  createEndorserJwt ( issuerDid ,  vcPayload ) ;  
			
				
				
			
		
	
		
		
			
				
					    const  firstKey  =  identity . keys [ 0 ] ;  
			
		
	
		
		
			
				
					    const  privateKeyHex  =  firstKey ? . privateKeyHex ;  
			
		
	
		
		
			
				
					
 
			
		
	
		
		
			
				
					    if  ( ! privateKeyHex )  {  
			
		
	
		
		
			
				
					      throw  {  
			
		
	
		
		
			
				
					        error :  "No private key" ,  
			
		
	
		
		
			
				
					        message :  ` Your identifier  ${ identity . did }  is not configured correctly. Use a different identifier. ` ,  
			
		
	
		
		
			
				
					      } ;  
			
		
	
		
		
			
				
					    }  
			
		
	
		
		
			
				
					
 
			
		
	
		
		
			
				
					    const  signer  =  await  SimpleSigner ( privateKeyHex ) ;  
			
		
	
		
		
			
				
					
 
			
		
	
		
		
			
				
					    // Create a JWT for the request
  
			
		
	
		
		
			
				
					    const  vcJwt : string  =  await  didJwt . createJWT ( vcPayload ,  {  
			
		
	
		
		
			
				
					      issuer : identity.did ,  
			
		
	
		
		
			
				
					      signer ,  
			
		
	
		
		
			
				
					    } ) ;  
			
		
	
		
		
	
		
		
			
				
					
 
			
		
	
		
		
			
				
					    // Make the xhr request payload
     // Make the xhr request payload
  
			
		
	
		
		
			
				
					    const  payload  =  JSON . stringify ( {  jwtEncoded : vcJwt  } ) ;     const  payload  =  JSON . stringify ( {  jwtEncoded : vcJwt  } ) ;  
			
		
	
		
		
			
				
					    const  url  =  ` ${ apiServer } /api/v2/claim ` ;     const  url  =  ` ${ apiServer } /api/v2/claim ` ;  
			
		
	
		
		
			
				
					    const  token  =  await  accessToken ( identity . did ) ;  
			
		
	
		
		
			
				
					
 
			
		
	
		
		
			
				
					    const  response  =  await  axios . post ( url ,  payload ,  {     const  response  =  await  axios . post ( url ,  payload ,  {  
			
		
	
		
		
			
				
					      headers :  {       headers :  {  
			
		
	
		
		
			
				
					        "Content-Type" :  "application/json" ,         "Content-Type" :  "application/json" ,  
			
		
	
		
		
			
				
					        Authorization :  ` Bearer  ${ token } ` ,  
			
		
	
		
		
			
				
					      } ,       } ,  
			
		
	
		
		
			
				
					    } ) ;     } ) ;  
			
		
	
		
		
			
				
					
 
			
		
	
	
		
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
					@ -942,21 +925,36 @@ export const bvcMeetingJoinClaim = (did: string, startTime: string) => { 
			
		
	
		
		
			
				
					  } ;   } ;  
			
		
	
		
		
			
				
					} ; } ;  
			
		
	
		
		
			
				
					
 
			
		
	
		
		
			
				
					
					export  async  function  createEndorserJwt ( did : string ,  payload : object )  { export  async  function  createEndorserJwtVcFromClaim (  
			
				
				
			
		
	
		
		
			
				
					
					  const  account  =  await  getAccount ( did ) ;   issuerDid : string ,  
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					  claim : object ,  
			
		
	
		
		
			
				
					)  {  
			
		
	
		
		
			
				
					  // Make a payload for the claim
  
			
		
	
		
		
			
				
					  const  vcPayload  =  {  
			
		
	
		
		
			
				
					    vc :  {  
			
		
	
		
		
			
				
					      "@context" :  [ "https://www.w3.org/2018/credentials/v1" ] ,  
			
		
	
		
		
			
				
					      type :  [ "VerifiableCredential" ] ,  
			
		
	
		
		
			
				
					      credentialSubject : claim ,  
			
		
	
		
		
			
				
					    } ,  
			
		
	
		
		
			
				
					  } ;  
			
		
	
		
		
			
				
					  return  createEndorserJwt ( issuerDid ,  vcPayload ) ;  
			
		
	
		
		
			
				
					}  
			
		
	
		
		
			
				
					
 
			
		
	
		
		
			
				
					export  async  function  createEndorserJwt ( issuerDid : string ,  payload : object )  {  
			
		
	
		
		
			
				
					  const  account  =  await  getAccount ( issuerDid ) ;  
			
		
	
		
		
			
				
					  if  ( account ? . identity )  {   if  ( account ? . identity )  {  
			
		
	
		
		
			
				
					    // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
     // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
  
			
		
	
		
		
			
				
					    const  identity  =  JSON . parse ( account . identity ! ) ;     const  identity  =  JSON . parse ( account . identity ! ) ;  
			
		
	
		
		
			
				
					    const  privateKeyHex  =  identity . keys [ 0 ] . privateKeyHex ;     const  privateKeyHex  =  identity . keys [ 0 ] . privateKeyHex ;  
			
		
	
		
		
			
				
					    const  signer  =  await  SimpleSigner ( privateKeyHex ) ;     const  signer  =  await  SimpleSigner ( privateKeyHex ) ;  
			
		
	
		
		
			
				
					    return  didJwt . createJWT ( payload ,  {     return  didJwt . createJWT ( payload ,  {  
			
		
	
		
		
			
				
					
					      issuer : did ,       issuer : issuerD id,  
			
				
				
			
		
	
		
		
	
		
		
			
				
					      signer : signer ,       signer : signer ,  
			
		
	
		
		
			
				
					    } ) ;     } ) ;  
			
		
	
		
		
			
				
					  }  else  if  ( account ? . passkeyCredIdHex )  {   }  else  if  ( account ? . passkeyCredIdHex )  {  
			
		
	
		
		
			
				
					
					    return  createDidPeerJwt ( did ,  account . passkeyCredIdHex ,  payload ) ;     return  createDidPeerJwt ( issuerD id,  account . passkeyCredIdHex ,  payload ) ;  
			
				
				
			
		
	
		
		
	
		
		
			
				
					  }  else  {   }  else  {  
			
		
	
		
		
			
				
					
					    throw  new  Error ( "No identity data found to sign for DID "  +  did ) ;     throw  new  Error ( "No identity data found to sign for DID "  +  issuerD id) ;  
			
				
				
			
		
	
		
		
	
		
		
			
				
					  }   }  
			
		
	
		
		
			
				
					} }  
			
		
	
		
		
			
				
					
 
			
		
	
	
		
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
					@ -1044,16 +1042,16 @@ export async function setVisibilityUtil( 
			
		
	
		
		
			
				
					 *  *  
			
		
	
		
		
			
				
					 *  @param  apiServer  endorser  server  URL  string  *  @param  apiServer  endorser  server  URL  string  
			
		
	
		
		
			
				
					 *  @param  axios  Axios  instance  *  @param  axios  Axios  instance  
			
		
	
		
		
			
				
					
					 *  @param  { IIdentifier }  identity  -  The  identity  object to  check  rate  limits  for  .  *  @param  { string }  issuerDid  -  The  DID  for  which to  check  rate  limits .  
			
				
				
			
		
	
		
		
	
		
		
			
				
					 *  @returns  { Promise < AxiosResponse > }  The  Axios  response  object .  *  @returns  { Promise < AxiosResponse > }  The  Axios  response  object .  
			
		
	
		
		
			
				
					 * /  * /  
			
		
	
		
		
			
				
					export  async  function  fetchEndorserRateLimits ( export  async  function  fetchEndorserRateLimits (  
			
		
	
		
		
			
				
					  apiServer : string ,   apiServer : string ,  
			
		
	
		
		
			
				
					  axios : Axios ,   axios : Axios ,  
			
		
	
		
		
			
				
					
					  d idstring ,   issuerD idstring ,  
			
				
				
			
		
	
		
		
	
		
		
			
				
					)  { )  {  
			
		
	
		
		
			
				
					  const  url  =  ` ${ apiServer } /api/report/rateLimits ` ;   const  url  =  ` ${ apiServer } /api/report/rateLimits ` ;  
			
		
	
		
		
			
				
					
					  const  headers  =  await  getHeaders ( d id) ;   const  headers  =  await  getHeaders ( issuerD id) ;  
			
				
				
			
		
	
		
		
	
		
		
			
				
					  return  await  axios . get ( url ,  {  headers  }  as  AxiosRequestConfig ) ;   return  await  axios . get ( url ,  {  headers  }  as  AxiosRequestConfig ) ;  
			
		
	
		
		
			
				
					} }  
			
		
	
		
		
			
				
					
 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
						
					 
					@ -1062,15 +1060,11 @@ export async function fetchEndorserRateLimits( 
			
		
	
		
		
			
				
					 *  *  
			
		
	
		
		
			
				
					 *  @param  apiServer  image  server  URL  string  *  @param  apiServer  image  server  URL  string  
			
		
	
		
		
			
				
					 *  @param  axios  Axios  instance  *  @param  axios  Axios  instance  
			
		
	
		
		
			
				
					
					 *  @param  { IIdentifier }  identity  -  The  identity  object to  check  rate  limits  for  .  *  @param  { string }  issuerDid  -  The  DID  for  which to  check  rate  limits .  
			
				
				
			
		
	
		
		
	
		
		
			
				
					 *  @returns  { Promise < AxiosResponse > }  The  Axios  response  object .  *  @returns  { Promise < AxiosResponse > }  The  Axios  response  object .  
			
		
	
		
		
			
				
					 * /  * /  
			
		
	
		
		
			
				
					
					export  async  function  fetchImageRateLimits ( export  async  function  fetchImageRateLimits ( axios : Axios ,  issuerDid : string )  {  
			
				
				
			
		
	
		
		
			
				
					  apiServer : string ,  
			
		
	
		
		
			
				
					  axios : Axios ,  
			
		
	
		
		
			
				
					  did : string ,  
			
		
	
		
		
			
				
					)  {  
			
		
	
		
		
	
		
		
			
				
					  const  url  =  DEFAULT_IMAGE_API_SERVER  +  "/image-limits" ;   const  url  =  DEFAULT_IMAGE_API_SERVER  +  "/image-limits" ;  
			
		
	
		
		
			
				
					
					  const  headers  =  await  getHeaders ( d id) ;   const  headers  =  await  getHeaders ( issuerDid ) ;  
			
				
				
			
		
	
		
		
	
		
		
			
				
					  return  await  axios . get ( url ,  {  headers  }  as  AxiosRequestConfig ) ;   return  await  axios . get ( url ,  {  headers  }  as  AxiosRequestConfig ) ;  
			
		
	
		
		
			
				
					} }