| 
						
						
							
								
							
						
						
					 | 
					@ -171,6 +171,7 @@ import { createIdentifier, deriveAddress, newIdentifier } from "../libs/crypto"; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import { IIdentifier } from "@veramo/core"; | 
					 | 
					 | 
					import { IIdentifier } from "@veramo/core"; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import * as R from "ramda"; | 
					 | 
					 | 
					import * as R from "ramda"; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import { db } from "../db"; | 
					 | 
					 | 
					import { db } from "../db"; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					import { useAppStore } from "@/store/app"; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					@Options({ | 
					 | 
					 | 
					@Options({ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					  components: {}, | 
					 | 
					 | 
					  components: {}, | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -185,68 +186,77 @@ export default class AccountViewView extends Vue { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    const previousIdentifiers: Array<IIdentifier> = []; | 
					 | 
					 | 
					    const previousIdentifiers: Array<IIdentifier> = []; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    const toLowercase = true; | 
					 | 
					 | 
					    const toLowercase = true; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					    this.mnemonic = createIdentifier(); | 
					 | 
					 | 
					    const appCondition = useAppStore().condition; | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					    [ | 
					 | 
					 | 
					    if (appCondition == "uninitialized") { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					      this.address, | 
					 | 
					 | 
					      this.mnemonic = createIdentifier(); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					      this.privateHex, | 
					 | 
					 | 
					      [ | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					      this.publicHex, | 
					 | 
					 | 
					        this.address, | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					      this.UPORT_ROOT_DERIVATION_PATH, | 
					 | 
					 | 
					        this.privateHex, | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					    ] = deriveAddress(this.mnemonic); | 
					 | 
					 | 
					        this.publicHex, | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					    //appStore.dispatch(appSlice.actions.addLog({log: false, msg: "... derived keys and address..."})) | 
					 | 
					 | 
					        this.UPORT_ROOT_DERIVATION_PATH, | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					    const prevIds = previousIdentifiers || []; | 
					 | 
					 | 
					      ] = deriveAddress(this.mnemonic); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					    if (toLowercase) { | 
					 | 
					 | 
					      //appStore.dispatch(appSlice.actions.addLog({log: false, msg: "... derived keys and address..."})) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					      const foundEqual = R.find( | 
					 | 
					 | 
					      const prevIds = previousIdentifiers || []; | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					        (id: IIdentifier) => id.did.split(":")[2] === this.address, | 
					 | 
					 | 
					      if (toLowercase) { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					        prevIds | 
					 | 
					 | 
					        const foundEqual = R.find( | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					      ); | 
					 | 
					 | 
					          (id: IIdentifier) => id.did.split(":")[2] === this.address, | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					      if (foundEqual) { | 
					 | 
					 | 
					          prevIds | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					        // appStore.dispatch(appSlice.actions.addLog({log: true, msg: "Will create a normal-case version of the DID since a regular version exists."})) | 
					 | 
					 | 
					        ); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (foundEqual) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					          // appStore.dispatch(appSlice.actions.addLog({log: true, msg: "Will create a normal-case version of the DID since a regular version exists."})) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        } else { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					          this.address = this.address.toLowerCase(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      } else { | 
					 | 
					 | 
					      } else { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					        this.address = this.address.toLowerCase(); | 
					 | 
					 | 
					        // They're not trying to convert to lowercase. | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        const foundLower = R.find( | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					          (id: IIdentifier) => | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            id.did.split(":")[2] === this.address.toLowerCase(), | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					          prevIds | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        ); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (foundLower) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					          // appStore.dispatch(appSlice.actions.addLog({log: true, msg: "Will create a lowercase version of the DID since a lowercase version exists."})) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					          this.address = this.address.toLowerCase(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      } | 
					 | 
					 | 
					      } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					    } else { | 
					 | 
					 | 
					
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					      // They're not trying to convert to lowercase. | 
					 | 
					 | 
					      const newId = newIdentifier( | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					      const foundLower = R.find( | 
					 | 
					 | 
					        this.address, | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					        (id: IIdentifier) => | 
					 | 
					 | 
					        this.publicHex, | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					          id.did.split(":")[2] === this.address.toLowerCase(), | 
					 | 
					 | 
					        this.privateHex, | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					        prevIds | 
					 | 
					 | 
					        this.UPORT_ROOT_DERIVATION_PATH | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					      ); | 
					 | 
					 | 
					      ); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					      if (foundLower) { | 
					 | 
					 | 
					      try { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					        // appStore.dispatch(appSlice.actions.addLog({log: true, msg: "Will create a lowercase version of the DID since a lowercase version exists."})) | 
					 | 
					 | 
					        await db.open(); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					        this.address = this.address.toLowerCase(); | 
					 | 
					 | 
					        const num_accounts = await db.accounts.count(); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					      } | 
					 | 
					 | 
					        if (num_accounts === 0) { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					    } | 
					 | 
					 | 
					          console.log("..."); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					          await db.accounts.add({ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            publicKey: newId.keys[0].publicKeyHex, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            mnemonic: this.mnemonic, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            identity: JSON.stringify(newId), | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            dateCreated: new Date().getTime(), | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					          }); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        useAppStore().setCondition("registered"); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					    const newId = newIdentifier( | 
					 | 
					 | 
					        //appStore.dispatch(appSlice.actions.addLog({log: false, msg: "... created new ID..."})) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					      this.address, | 
					 | 
					 | 
					        //appStore.dispatch(appSlice.actions.addLog({log: false, msg: "... stored new ID..."})) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					      this.publicHex, | 
					 | 
					 | 
					      } catch (err) { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					      this.privateHex, | 
					 | 
					 | 
					        console.log("Error!"); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					      this.UPORT_ROOT_DERIVATION_PATH | 
					 | 
					 | 
					        console.log(err); | 
				
			
			
				
				
			
		
	
		
		
			
				
					 | 
					 | 
					    ); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    try { | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      await db.open(); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      const num_accounts = await db.accounts.count(); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      if (num_accounts === 0) { | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        console.log("..."); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        await db.accounts.add({ | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					          publicKey: newId.keys[0].publicKeyHex, | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					          mnemonic: this.mnemonic, | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					          identity: JSON.stringify(newId), | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					          dateCreated: new Date().getTime(), | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        }); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					      } | 
					 | 
					 | 
					      } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    await db.open(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    const num_accounts = await db.accounts.count(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    if (num_accounts === 0) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      console.log("Problem!  Should have a profile!"); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    } else { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      const accounts = await db.accounts.toArray(); | 
					 | 
					 | 
					      const accounts = await db.accounts.toArray(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      console.log(accounts[0]); | 
					 | 
					 | 
					      console.log(accounts[0]); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      const identity = JSON.parse(accounts[0].identity); | 
					 | 
					 | 
					      const identity = JSON.parse(accounts[0].identity); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      this.address = identity.did; | 
					 | 
					 | 
					      this.address = identity.did; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      this.publicHex = identity.keys[0].publicKeyHex; | 
					 | 
					 | 
					      this.publicHex = identity.keys[0].publicKeyHex; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      //appStore.dispatch(appSlice.actions.addLog({log: false, msg: "... created new ID..."})) | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      //appStore.dispatch(appSlice.actions.addLog({log: false, msg: "... stored new ID..."})) | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    } catch (err) { | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      console.log("Error!"); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      console.log(err); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    } | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					  } | 
					 | 
					 | 
					  } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					} | 
					 | 
					 | 
					} | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					
  |