|
@ -25,12 +25,15 @@ |
|
|
<ul class="mb-4"> |
|
|
<ul class="mb-4"> |
|
|
<li |
|
|
<li |
|
|
class="block bg-slate-100 rounded-md flex items-center px-4 py-3 mb-2" |
|
|
class="block bg-slate-100 rounded-md flex items-center px-4 py-3 mb-2" |
|
|
|
|
|
v-for="ident in otherIdentities" |
|
|
|
|
|
:key="ident.did" |
|
|
|
|
|
@click="switchAccount(ident.did)" |
|
|
> |
|
|
> |
|
|
<fa icon="circle" class="fa-fw text-slate-400 text-xl mr-3"></fa> |
|
|
<fa icon="circle" class="fa-fw text-slate-400 text-xl mr-3"></fa> |
|
|
<span class="overflow-hidden"> |
|
|
<span class="overflow-hidden"> |
|
|
<h2 class="text-xl font-semibold mb-0">Givenname Surname</h2> |
|
|
<h2 class="text-xl font-semibold mb-0"></h2> |
|
|
<div class="text-sm text-slate-500 truncate"> |
|
|
<div class="text-sm text-slate-500 truncate"> |
|
|
<b>ID:</b> <code>did:peer:lk451kl3kl45kj41</code> |
|
|
<b>ID:</b> <code>{{ ident.did }}</code> |
|
|
</div> |
|
|
</div> |
|
|
</span> |
|
|
</span> |
|
|
</li> |
|
|
</li> |
|
@ -44,8 +47,9 @@ |
|
|
Add Another Identity… |
|
|
Add Another Identity… |
|
|
</router-link> |
|
|
</router-link> |
|
|
<a |
|
|
<a |
|
|
href="start.html" |
|
|
href="#" |
|
|
class="block w-full text-center text-md uppercase bg-slate-500 text-white px-1.5 py-2 rounded-md mb-8" |
|
|
class="block w-full text-center text-md uppercase bg-slate-500 text-white px-1.5 py-2 rounded-md mb-8" |
|
|
|
|
|
@click="switchAccount('0')" |
|
|
> |
|
|
> |
|
|
No Identity |
|
|
No Identity |
|
|
</a> |
|
|
</a> |
|
@ -68,10 +72,23 @@ import QuickNav from "@/components/QuickNav"; |
|
|
@Component({ components: { AlertMessage, QuickNav } }) |
|
|
@Component({ components: { AlertMessage, QuickNav } }) |
|
|
export default class IdentitySwitcherView extends Vue { |
|
|
export default class IdentitySwitcherView extends Vue { |
|
|
Constants = AppString; |
|
|
Constants = AppString; |
|
|
private accounts: AccountsSchema; |
|
|
public accounts: AccountsSchema; |
|
|
public activeDid; |
|
|
public activeDid; |
|
|
public firstName; |
|
|
public firstName; |
|
|
public lastName; |
|
|
public lastName; |
|
|
|
|
|
public alertTitle; |
|
|
|
|
|
public alertMessage; |
|
|
|
|
|
public otherIdentities = []; |
|
|
|
|
|
|
|
|
|
|
|
public async getIdentity(activeDid) { |
|
|
|
|
|
await accountsDB.open(); |
|
|
|
|
|
const account = await accountsDB.accounts |
|
|
|
|
|
.where("did") |
|
|
|
|
|
.equals(activeDid) |
|
|
|
|
|
.first(); |
|
|
|
|
|
const identity = JSON.parse(account?.identity || "null"); |
|
|
|
|
|
return identity; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
async created() { |
|
|
async created() { |
|
|
try { |
|
|
try { |
|
@ -86,14 +103,19 @@ export default class IdentitySwitcherView extends Vue { |
|
|
|
|
|
|
|
|
const identity = await this.getIdentity(this.activeDid); |
|
|
const identity = await this.getIdentity(this.activeDid); |
|
|
|
|
|
|
|
|
this.publicHex = identity.keys[0].publicKeyHex; |
|
|
if (identity) { |
|
|
this.publicBase64 = Buffer.from(this.publicHex, "hex").toString("base64"); |
|
|
|
|
|
this.derivationPath = identity.keys[0].meta.derivationPath; |
|
|
|
|
|
|
|
|
|
|
|
db.settings.update(MASTER_SETTINGS_KEY, { |
|
|
db.settings.update(MASTER_SETTINGS_KEY, { |
|
|
activeDid: identity.did, |
|
|
activeDid: identity.did, |
|
|
}); |
|
|
}); |
|
|
this.checkLimits(); |
|
|
} |
|
|
|
|
|
await accountsDB.open(); |
|
|
|
|
|
const accounts = await accountsDB.accounts.toArray(); |
|
|
|
|
|
for (let n = 0; n < accounts.length; n++) { |
|
|
|
|
|
const did = JSON.parse(accounts[n].identity)["did"]; |
|
|
|
|
|
if (did && this.activeDid !== did) { |
|
|
|
|
|
this.otherIdentities.push({ did: did }); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} catch (err) { |
|
|
} catch (err) { |
|
|
if ( |
|
|
if ( |
|
|
err.message === |
|
|
err.message === |
|
@ -113,31 +135,24 @@ export default class IdentitySwitcherView extends Vue { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
async switchAccount(accountNum: number) { |
|
|
async switchAccount(did: string) { |
|
|
// 0 means none |
|
|
// 0 means none |
|
|
if (accountNum === 0) { |
|
|
if (did === "0") { |
|
|
|
|
|
did = undefined; |
|
|
|
|
|
} |
|
|
await db.open(); |
|
|
await db.open(); |
|
|
db.settings.update(MASTER_SETTINGS_KEY, { |
|
|
db.settings.update(MASTER_SETTINGS_KEY, { |
|
|
activeDid: undefined, |
|
|
activeDid: did, |
|
|
}); |
|
|
}); |
|
|
this.activeDid = ""; |
|
|
this.activeDid = did; |
|
|
this.derivationPath = ""; |
|
|
this.otherIdentities = []; |
|
|
this.publicHex = ""; |
|
|
|
|
|
this.publicBase64 = ""; |
|
|
|
|
|
} else { |
|
|
|
|
|
await accountsDB.open(); |
|
|
await accountsDB.open(); |
|
|
const accounts = await accountsDB.accounts.toArray(); |
|
|
const accounts = await accountsDB.accounts.toArray(); |
|
|
const account = accounts[accountNum - 1]; |
|
|
for (let n = 0; n < accounts.length; n++) { |
|
|
|
|
|
const did = JSON.parse(accounts[n].identity)["did"]; |
|
|
await db.open(); |
|
|
if (did && this.activeDid !== did) { |
|
|
db.settings.update(MASTER_SETTINGS_KEY, { |
|
|
this.otherIdentities.push({ did: did }); |
|
|
activeDid: account.did, |
|
|
} |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
this.activeDid = account.did; |
|
|
|
|
|
this.derivationPath = account.derivationPath; |
|
|
|
|
|
this.publicHex = account.publicKeyHex; |
|
|
|
|
|
this.publicBase64 = Buffer.from(this.publicHex, "hex").toString("base64"); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|