|
@ -79,7 +79,7 @@ |
|
|
class="text-sm text-slate-500 flex justify-between items-center mb-1" |
|
|
class="text-sm text-slate-500 flex justify-between items-center mb-1" |
|
|
> |
|
|
> |
|
|
<span |
|
|
<span |
|
|
><code>did:peer:kl45kj41lk451kl3</code> |
|
|
><code>{{ address }}</code> |
|
|
<fa icon="copy" class="text-slate-400 fa-fw ml-1"></fa> |
|
|
<fa icon="copy" class="text-slate-400 fa-fw ml-1"></fa> |
|
|
</span> |
|
|
</span> |
|
|
<span> |
|
|
<span> |
|
@ -99,7 +99,7 @@ |
|
|
<div class="text-slate-500 text-sm font-bold">Public Key</div> |
|
|
<div class="text-slate-500 text-sm font-bold">Public Key</div> |
|
|
<div class="text-sm text-slate-500 mb-1"> |
|
|
<div class="text-sm text-slate-500 mb-1"> |
|
|
<span |
|
|
<span |
|
|
><code>dyIgKepL19trfrFu5jzkoNhI</code> |
|
|
><code>{{ publicHex }}</code> |
|
|
<fa icon="copy" class="text-slate-400 fa-fw ml-1"></fa> |
|
|
<fa icon="copy" class="text-slate-400 fa-fw ml-1"></fa> |
|
|
</span> |
|
|
</span> |
|
|
</div> |
|
|
</div> |
|
@ -107,7 +107,7 @@ |
|
|
<div class="text-slate-500 text-sm font-bold">Derivation Path</div> |
|
|
<div class="text-slate-500 text-sm font-bold">Derivation Path</div> |
|
|
<div class="text-sm text-slate-500 mb-1"> |
|
|
<div class="text-sm text-slate-500 mb-1"> |
|
|
<span |
|
|
<span |
|
|
><code>m/44'/0'/0'/0/0</code> |
|
|
><code>{{ UPORT_ROOT_DERIVATION_PATH }}</code> |
|
|
<fa icon="copy" class="text-slate-400 fa-fw ml-1"></fa> |
|
|
<fa icon="copy" class="text-slate-400 fa-fw ml-1"></fa> |
|
|
</span> |
|
|
</span> |
|
|
</div> |
|
|
</div> |
|
@ -167,8 +167,6 @@ |
|
|
|
|
|
|
|
|
<script lang="ts"> |
|
|
<script lang="ts"> |
|
|
import { Options, Vue } from "vue-class-component"; |
|
|
import { Options, Vue } from "vue-class-component"; |
|
|
import { useAppStore } from "../store/app"; |
|
|
|
|
|
import { useAccountStore } from "../store/account"; |
|
|
|
|
|
import { createIdentifier, deriveAddress, newIdentifier } from "../libs/crypto"; |
|
|
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"; |
|
@ -178,76 +176,76 @@ import { db } from "../db"; |
|
|
components: {}, |
|
|
components: {}, |
|
|
}) |
|
|
}) |
|
|
export default class AccountViewView extends Vue { |
|
|
export default class AccountViewView extends Vue { |
|
|
created() { |
|
|
mnemonic = ""; |
|
|
|
|
|
address = ""; |
|
|
|
|
|
privateHex = ""; |
|
|
|
|
|
publicHex = ""; |
|
|
|
|
|
UPORT_ROOT_DERIVATION_PATH = ""; |
|
|
|
|
|
async created() { |
|
|
const previousIdentifiers: Array<IIdentifier> = []; |
|
|
const previousIdentifiers: Array<IIdentifier> = []; |
|
|
const toLowercase = true; |
|
|
const toLowercase = true; |
|
|
const appStore = useAppStore(); |
|
|
|
|
|
const accountStore = useAccountStore(); |
|
|
this.mnemonic = createIdentifier(); |
|
|
|
|
|
[ |
|
|
if (appStore._condition == "uninitialized") { |
|
|
this.address, |
|
|
const mnemonic = createIdentifier(); |
|
|
this.privateHex, |
|
|
|
|
|
this.publicHex, |
|
|
const [address, privateHex, publicHex, UPORT_ROOT_DERIVATION_PATH] = |
|
|
this.UPORT_ROOT_DERIVATION_PATH, |
|
|
deriveAddress(mnemonic); |
|
|
] = deriveAddress(this.mnemonic); |
|
|
//appStore.dispatch(appSlice.actions.addLog({log: false, msg: "... derived keys and address..."})) |
|
|
//appStore.dispatch(appSlice.actions.addLog({log: false, msg: "... derived keys and address..."})) |
|
|
const prevIds = previousIdentifiers || []; |
|
|
const prevIds = previousIdentifiers || []; |
|
|
let addr = address; |
|
|
if (toLowercase) { |
|
|
if (toLowercase) { |
|
|
const foundEqual = R.find( |
|
|
const foundEqual = R.find( |
|
|
(id: IIdentifier) => id.did.split(":")[2] === this.address, |
|
|
(id: IIdentifier) => id.did.split(":")[2] === address, |
|
|
prevIds |
|
|
prevIds |
|
|
); |
|
|
); |
|
|
if (foundEqual) { |
|
|
if (foundEqual) { |
|
|
// appStore.dispatch(appSlice.actions.addLog({log: true, msg: "Will create a normal-case version of the DID since a regular version exists."})) |
|
|
// appStore.dispatch(appSlice.actions.addLog({log: true, msg: "Will create a normal-case version of the DID since a regular version exists."})) |
|
|
|
|
|
} else { |
|
|
|
|
|
addr = address.toLowerCase(); |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
} else { |
|
|
// They're not trying to convert to lowercase. |
|
|
this.address = this.address.toLowerCase(); |
|
|
const foundLower = R.find( |
|
|
|
|
|
(id: IIdentifier) => id.did.split(":")[2] === 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."})) |
|
|
|
|
|
addr = address.toLowerCase(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
} else { |
|
|
const newId = newIdentifier( |
|
|
// They're not trying to convert to lowercase. |
|
|
addr, |
|
|
const foundLower = R.find( |
|
|
publicHex, |
|
|
(id: IIdentifier) => |
|
|
privateHex, |
|
|
id.did.split(":")[2] === this.address.toLowerCase(), |
|
|
UPORT_ROOT_DERIVATION_PATH |
|
|
prevIds |
|
|
); |
|
|
); |
|
|
db.open() |
|
|
if (foundLower) { |
|
|
.then(function (odexie) { |
|
|
// appStore.dispatch(appSlice.actions.addLog({log: true, msg: "Will create a lowercase version of the DID since a lowercase version exists."})) |
|
|
odexie._allTables.accounts.count(function (result) { |
|
|
this.address = this.address.toLowerCase(); |
|
|
if (result === 0) { |
|
|
} |
|
|
console.log("No accounts"); |
|
|
} |
|
|
odexie._allTables.accounts |
|
|
|
|
|
.add({ |
|
|
const newId = newIdentifier( |
|
|
publicKey: newId.keys[0].publicKeyHex, |
|
|
this.address, |
|
|
mnemonic: mnemonic, |
|
|
this.publicHex, |
|
|
identity: JSON.stringify(newId), |
|
|
this.privateHex, |
|
|
dateCreated: new Date().getTime(), |
|
|
this.UPORT_ROOT_DERIVATION_PATH |
|
|
}) |
|
|
); |
|
|
.then(function () { |
|
|
try { |
|
|
odexie._allTables.accounts.each(function (account) { |
|
|
await db.open(); |
|
|
console.log("Found close friend: " + account.publicKey); |
|
|
const num_accounts = await db._allTables.accounts.count(); |
|
|
}); |
|
|
if (num_accounts === 0) { |
|
|
}); |
|
|
console.log("..."); |
|
|
} else { |
|
|
await db._allTables.accounts.add({ |
|
|
console.log("Skipping initial create on empty db."); |
|
|
publicKey: newId.keys[0].publicKeyHex, |
|
|
} |
|
|
mnemonic: this.mnemonic, |
|
|
}); |
|
|
identity: JSON.stringify(newId), |
|
|
}) |
|
|
dateCreated: new Date().getTime(), |
|
|
.catch(function (err) { |
|
|
|
|
|
console.error("Failed to open db: " + (err.stack || err)); |
|
|
|
|
|
}); |
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
const accounts = await db._allTables.accounts.toArray(); |
|
|
|
|
|
console.log(accounts[0]); |
|
|
|
|
|
const identity = JSON.parse(accounts[0].identity); |
|
|
|
|
|
|
|
|
|
|
|
this.address = identity.did; |
|
|
|
|
|
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: "... created new ID..."})) |
|
|
accountStore.account = JSON.stringify(newId); |
|
|
|
|
|
//appStore.dispatch(appSlice.actions.addLog({log: false, msg: "... stored new ID..."})) |
|
|
//appStore.dispatch(appSlice.actions.addLog({log: false, msg: "... stored new ID..."})) |
|
|
|
|
|
} catch { |
|
|
|
|
|
console.log("Error!"); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|