| 
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -361,7 +361,12 @@ import GiftedDialog from "../components/GiftedDialog.vue"; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import OfferDialog from "../components/OfferDialog.vue"; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import ContactNameDialog from "../components/ContactNameDialog.vue"; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import TopMessage from "../components/TopMessage.vue"; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import { APP_SERVER, AppString, NotificationIface } from "../constants/app"; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  APP_SERVER, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  AppString, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  NotificationIface, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  USE_DEXIE_DB, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					} from "../constants/app"; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  db, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  logConsoleAndDb, | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -370,6 +375,7 @@ import { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  updateDefaultSettings, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					} from "../db/index"; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import { Contact } from "../db/tables/contacts"; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import * as databaseUtil from "../db/databaseUtil"; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import { getContactJwtFromJwtUrl } from "../libs/crypto"; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import { decodeEndorserJwt } from "../libs/crypto/vc"; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import { | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -390,6 +396,7 @@ import { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import * as libsUtil from "../libs/util"; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import { generateSaveAndActivateIdentity } from "../libs/util"; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import { logger } from "../utils/logger"; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import { PlatformServiceFactory } from "@/services/PlatformServiceFactory"; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					@Component({ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  components: { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    GiftedDialog, | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -438,8 +445,11 @@ export default class ContactsView extends Vue { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  libsUtil = libsUtil; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  public async created() { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    await db.open(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    const settings = await retrieveSettingsForActiveAccount(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    let settings = await databaseUtil.retrieveSettingsForActiveAccount(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    if (USE_DEXIE_DB) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      await db.open(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      settings = await retrieveSettingsForActiveAccount(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    this.activeDid = settings.activeDid || ""; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    this.apiServer = settings.apiServer || ""; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    this.isRegistered = !!settings.isRegistered; | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -457,12 +467,22 @@ export default class ContactsView extends Vue { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      this.loadGives(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    // .orderBy("name") wouldn't retrieve any entries with a blank name | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    // .toCollection.sortBy("name") didn't sort in an order I understood | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    const baseContacts = await db.contacts.toArray(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    this.contacts = baseContacts.sort((a, b) => | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      (a.name || "").localeCompare(b.name || ""), | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    const platformService = PlatformServiceFactory.getInstance(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    const dbAllContacts = await platformService.dbQuery( | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      "SELECT * FROM contacts ORDER BY name", | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    ); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    this.contacts = databaseUtil.mapQueryResultToValues( | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      dbAllContacts, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    ) as unknown as Contact[]; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    if (USE_DEXIE_DB) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      await db.open(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      // .orderBy("name") wouldn't retrieve any entries with a blank name | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      // .toCollection.sortBy("name") didn't sort in an order I understood | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      const baseContacts = await db.contacts.toArray(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      this.contacts = baseContacts.sort((a, b) => | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        (a.name || "").localeCompare(b.name || ""), | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      ); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  private async processContactJwt() { | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -820,12 +840,22 @@ export default class ContactsView extends Vue { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        this.danger("An error occurred. Some contacts may have been added."); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      // .orderBy("name") wouldn't retrieve any entries with a blank name | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      // .toCollection.sortBy("name") didn't sort in an order I understood | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      const baseContacts = await db.contacts.toArray(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      this.contacts = baseContacts.sort((a, b) => | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        (a.name || "").localeCompare(b.name || ""), | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      const platformService = PlatformServiceFactory.getInstance(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      const dbAllContacts = await platformService.dbQuery( | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        "SELECT * FROM contacts ORDER BY name", | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      ); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      this.contacts = databaseUtil.mapQueryResultToValues( | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        dbAllContacts, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      ) as unknown as Contact[]; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      if (USE_DEXIE_DB) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        await db.open(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        // .orderBy("name") wouldn't retrieve any entries with a blank name | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        // .toCollection.sortBy("name") didn't sort in an order I understood | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        const baseContacts = await db.contacts.toArray(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        this.contacts = baseContacts.sort((a, b) => | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					          (a.name || "").localeCompare(b.name || ""), | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        ); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      return; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -934,7 +964,15 @@ export default class ContactsView extends Vue { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      seesMe, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      registered, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    }; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    return db.contacts.add(newContact); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    const platformService = PlatformServiceFactory.getInstance(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    const { sql, params } = databaseUtil.generateInsertStatement( | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      newContact as unknown as Record<string, unknown>, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      "contacts", | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    ); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    await platformService.dbExec(sql, params); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    if (USE_DEXIE_DB) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      await db.contacts.add(newContact); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					  private async addContact(newContact: Contact) { | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -946,8 +984,18 @@ export default class ContactsView extends Vue { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      this.danger("The DID must begin with 'did:'", "Invalid DID"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      return; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    return db.contacts | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      .add(newContact) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    const platformService = PlatformServiceFactory.getInstance(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    const { sql, params } = databaseUtil.generateInsertStatement( | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      newContact as unknown as Record<string, unknown>, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      "contacts", | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    ); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    let contactPromise = platformService.dbExec(sql, params); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    if (USE_DEXIE_DB) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      // @ts-expect-error since the result of this promise won't be used, and this will go away soon | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      contactPromise = db.contacts.add(newContact); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    return contactPromise | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      .then(() => { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        const allContacts = this.contacts.concat([newContact]); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        this.contacts = R.sort( | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -1063,7 +1111,14 @@ export default class ContactsView extends Vue { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      ); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					      if (regResult.success) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        contact.registered = true; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        await db.contacts.update(contact.did, { registered: true }); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        const platformService = PlatformServiceFactory.getInstance(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        await platformService.dbExec( | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					          "UPDATE contacts SET registered = ? WHERE did = ?", | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					          [true, contact.did], | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        ); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        if (USE_DEXIE_DB) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					          await db.contacts.update(contact.did, { registered: true }); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        this.$notify( | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					          { | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
				 | 
				
					
  |