|
@ -168,6 +168,17 @@ |
|
|
</button> |
|
|
</button> |
|
|
</form> |
|
|
</form> |
|
|
</dialog> |
|
|
</dialog> |
|
|
|
|
|
|
|
|
|
|
|
<div v-bind:class="computedAlertClassNames()"> |
|
|
|
|
|
<button |
|
|
|
|
|
class="close-button bg-slate-200 w-8 leading-loose rounded-full absolute top-2 right-2" |
|
|
|
|
|
@click="onClickClose()" |
|
|
|
|
|
> |
|
|
|
|
|
<fa icon="xmark"></fa> |
|
|
|
|
|
</button> |
|
|
|
|
|
<h4 class="font-bold pr-5">{{ alertTitle }}</h4> |
|
|
|
|
|
<p>{{ alertMessage }}</p> |
|
|
|
|
|
</div> |
|
|
</section> |
|
|
</section> |
|
|
</template> |
|
|
</template> |
|
|
|
|
|
|
|
@ -176,7 +187,6 @@ import { Options, Vue } from "vue-class-component"; |
|
|
import { useClipboard } from "@vueuse/core"; |
|
|
import { useClipboard } from "@vueuse/core"; |
|
|
import { deriveAddress, generateSeed, newIdentifier } from "../libs/crypto"; |
|
|
import { deriveAddress, generateSeed, newIdentifier } from "../libs/crypto"; |
|
|
import { db } from "../db"; |
|
|
import { db } from "../db"; |
|
|
import { useAppStore } from "@/store/app"; |
|
|
|
|
|
//import { testServerRegisterUser } from "../test"; |
|
|
//import { testServerRegisterUser } from "../test"; |
|
|
|
|
|
|
|
|
@Options({ |
|
|
@Options({ |
|
@ -203,46 +213,68 @@ export default class AccountViewView extends Vue { |
|
|
|
|
|
|
|
|
// 'created' hook runs when the Vue instance is first created |
|
|
// 'created' hook runs when the Vue instance is first created |
|
|
async created() { |
|
|
async created() { |
|
|
const appCondition = useAppStore().condition; |
|
|
await db.open(); |
|
|
if (appCondition == "uninitialized") { |
|
|
const num_accounts = await db.accounts.count(); |
|
|
this.mnemonic = generateSeed(); |
|
|
if (num_accounts === 0) { |
|
|
[this.address, this.privateHex, this.publicHex, this.derivationPath] = |
|
|
|
|
|
deriveAddress(this.mnemonic); |
|
|
|
|
|
|
|
|
|
|
|
const newId = newIdentifier( |
|
|
|
|
|
this.address, |
|
|
|
|
|
this.publicHex, |
|
|
|
|
|
this.privateHex, |
|
|
|
|
|
this.derivationPath |
|
|
|
|
|
); |
|
|
|
|
|
try { |
|
|
try { |
|
|
await db.open(); |
|
|
this.mnemonic = generateSeed(); |
|
|
const num_accounts = await db.accounts.count(); |
|
|
[this.address, this.privateHex, this.publicHex, this.derivationPath] = |
|
|
if (num_accounts === 0) { |
|
|
deriveAddress(this.mnemonic); |
|
|
await db.accounts.add({ |
|
|
|
|
|
dateCreated: new Date(), |
|
|
const newId = newIdentifier( |
|
|
derivationPath: this.derivationPath, |
|
|
this.address, |
|
|
identity: JSON.stringify(newId), |
|
|
this.publicHex, |
|
|
mnemonic: this.mnemonic, |
|
|
this.privateHex, |
|
|
publicKeyHex: newId.keys[0].publicKeyHex, |
|
|
this.derivationPath |
|
|
}); |
|
|
); |
|
|
} |
|
|
await db.accounts.add({ |
|
|
useAppStore().setCondition("registered"); |
|
|
dateCreated: new Date(), |
|
|
|
|
|
derivationPath: this.derivationPath, |
|
|
|
|
|
identity: JSON.stringify(newId), |
|
|
|
|
|
mnemonic: this.mnemonic, |
|
|
|
|
|
publicKeyHex: newId.keys[0].publicKeyHex, |
|
|
|
|
|
}); |
|
|
} catch (err) { |
|
|
} catch (err) { |
|
|
|
|
|
this.alertMessage = |
|
|
|
|
|
"Clear your cache and start over. Root Cause: " + err; |
|
|
|
|
|
this.alertTitle = "Error Creating Account"; |
|
|
|
|
|
this.isAlertVisible = true; |
|
|
console.log(err); |
|
|
console.log(err); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
await db.open(); |
|
|
|
|
|
const num_accounts = await db.accounts.count(); |
|
|
const accounts = await db.accounts.toArray(); |
|
|
if (num_accounts === 0) { |
|
|
const identity = JSON.parse(accounts[0].identity); |
|
|
console.log("Problem! Should have a profile!"); |
|
|
this.address = identity.did; |
|
|
} else { |
|
|
this.publicHex = identity.keys[0].publicKeyHex; |
|
|
const accounts = await db.accounts.toArray(); |
|
|
this.derivationPath = identity.keys[0].meta.derivationPath; |
|
|
const identity = JSON.parse(accounts[0].identity); |
|
|
} |
|
|
this.address = identity.did; |
|
|
|
|
|
this.publicHex = identity.keys[0].publicKeyHex; |
|
|
alertMessage = ""; |
|
|
this.derivationPath = identity.keys[0].meta.derivationPath; |
|
|
alertTitle = ""; |
|
|
} |
|
|
isAlertVisible = false; |
|
|
|
|
|
|
|
|
|
|
|
public onClickClose() { |
|
|
|
|
|
this.isAlertVisible = false; |
|
|
|
|
|
this.alertTitle = ""; |
|
|
|
|
|
this.alertMessage = ""; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public computedAlertClassNames() { |
|
|
|
|
|
return { |
|
|
|
|
|
hidden: !this.isAlertVisible, |
|
|
|
|
|
"dismissable-alert": true, |
|
|
|
|
|
"bg-slate-100": true, |
|
|
|
|
|
"p-5": true, |
|
|
|
|
|
rounded: true, |
|
|
|
|
|
"drop-shadow-lg": true, |
|
|
|
|
|
absolute: true, |
|
|
|
|
|
"top-3": true, |
|
|
|
|
|
"inset-x-3": true, |
|
|
|
|
|
"transition-transform": true, |
|
|
|
|
|
"ease-in": true, |
|
|
|
|
|
"duration-300": true, |
|
|
|
|
|
}; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
</script> |
|
|
</script> |
|
|