Trent Larson
1 year ago
8 changed files with 179 additions and 48 deletions
@ -0,0 +1,112 @@ |
|||
<template> |
|||
<!-- QUICK NAV --> |
|||
<nav id="QuickNav" class="fixed bottom-0 left-0 right-0 bg-slate-200 z-50"> |
|||
<ul class="flex text-2xl p-2 gap-2"> |
|||
<!-- Home Feed --> |
|||
<li class="basis-1/5 rounded-md text-slate-500"> |
|||
<router-link :to="{ name: 'home' }" class="block text-center py-3 px-1"> |
|||
<fa icon="house-chimney" class="fa-fw"></fa> |
|||
</router-link> |
|||
</li> |
|||
<!-- Search --> |
|||
<li class="basis-1/5 rounded-md text-slate-500"> |
|||
<router-link |
|||
:to="{ name: 'discover' }" |
|||
class="block text-center py-3 px-1" |
|||
> |
|||
<fa icon="magnifying-glass" class="fa-fw"></fa> |
|||
</router-link> |
|||
</li> |
|||
<!-- Projects --> |
|||
<li class="basis-1/5 rounded-md text-slate-500"> |
|||
<router-link |
|||
:to="{ name: 'projects' }" |
|||
class="block text-center py-3 px-1" |
|||
> |
|||
<fa icon="folder-open" class="fa-fw"></fa> |
|||
</router-link> |
|||
</li> |
|||
<!-- Contacts --> |
|||
<li class="basis-1/5 rounded-md text-slate-500"> |
|||
<router-link |
|||
:to="{ name: 'contacts' }" |
|||
class="block text-center py-3 px-1" |
|||
> |
|||
<fa icon="users" class="fa-fw"></fa> |
|||
</router-link> |
|||
</li> |
|||
<!-- Profile --> |
|||
<li class="basis-1/5 rounded-md bg-slate-400 text-white"> |
|||
<router-link |
|||
:to="{ name: 'account' }" |
|||
class="block text-center py-3 px-1" |
|||
> |
|||
<fa icon="circle-user" class="fa-fw"></fa> |
|||
</router-link> |
|||
</li> |
|||
</ul> |
|||
</nav> |
|||
|
|||
<!-- CONTENT --> |
|||
<section id="Content" class="p-6 pb-24"> |
|||
<!-- Heading --> |
|||
<h1 id="ViewHeading" class="text-4xl text-center font-light pt-4 mb-8"> |
|||
Your Identity |
|||
</h1> |
|||
|
|||
<div class="flex justify-between py-2"> |
|||
<span /> |
|||
<span v-if="loading"> |
|||
Creating... <i class="fa-solid fa-loader fa-spin"></i> |
|||
</span> |
|||
<span v-else> |
|||
Created! |
|||
<i |
|||
class="fa-solid fa-burst fa-beat" |
|||
style="--fa-animation-duration: 3s" |
|||
></i> |
|||
</span> |
|||
</div> |
|||
</section> |
|||
</template> |
|||
|
|||
<script lang="ts"> |
|||
import "dexie-export-import"; |
|||
import { Component, Vue } from "vue-facing-decorator"; |
|||
import { accountsDB, db } from "@/db"; |
|||
import { deriveAddress, generateSeed, newIdentifier } from "@/libs/crypto"; |
|||
import { MASTER_SETTINGS_KEY } from "@/db/tables/settings"; |
|||
|
|||
@Component |
|||
export default class AccountViewView extends Vue { |
|||
loading = true; |
|||
|
|||
async mounted() { |
|||
await accountsDB.open(); |
|||
const mnemonic = generateSeed(); |
|||
// address is 0x... ETH address, without "did:eth:" |
|||
const [address, privateHex, publicHex, derivationPath] = |
|||
deriveAddress(mnemonic); |
|||
|
|||
const newId = newIdentifier(address, publicHex, privateHex, derivationPath); |
|||
const identity = JSON.stringify(newId); |
|||
await accountsDB.accounts.add({ |
|||
dateCreated: new Date().toISOString(), |
|||
derivationPath: derivationPath, |
|||
did: newId.did, |
|||
identity: identity, |
|||
mnemonic: mnemonic, |
|||
publicKeyHex: newId.keys[0].publicKeyHex, |
|||
}); |
|||
|
|||
await db.settings.update(MASTER_SETTINGS_KEY, { |
|||
activeDid: newId.did, |
|||
}); |
|||
|
|||
this.loading = false; |
|||
setTimeout(() => { |
|||
this.$router.push({ name: "account" }); |
|||
}, 3000); |
|||
} |
|||
} |
|||
</script> |
Loading…
Reference in new issue