@ -52,7 +52,17 @@
<!-- Identity Details -- >
< div class = "bg-slate-100 rounded-md overflow-hidden px-4 py-3 mb-4" >
< h2 class = "text-xl font-semibold mb-2" > { { firstName } } { { lastName } } < / h2 >
< h2 v-if ="givenName" class="text-xl font-semibold mb-2" >
{ { givenName } }
< / h2 >
< span v-else >
< router -link
: to = "{ name: 'new-edit-account' }"
class = "text-xs bg-blue-500 text-white px-1.5 py-1 rounded-md"
>
( set name )
< / r o u t e r - l i n k >
< / span >
< div class = "text-slate-500 text-sm font-bold" > ID < / div >
< div class = "text-sm text-slate-500 flex justify-start items-center mb-1" >
@ -67,53 +77,11 @@
< / button >
< span v-show ="showDidCopy" > Copied ! < / span >
< / div >
< div class = "text-slate-500 text-sm font-bold" > Public Key ( base 64 ) < / div >
< div class = "text-sm text-slate-500 flex justify-start items-center mb-1" >
< code class = "truncate" > { { publicBase64 } } < / code >
< button
@ click = "
doCopyTwoSecRedo ( publicBase64 , ( ) => ( showB64Copy = ! showB64Copy ) )
"
class = "ml-2"
>
< fa icon = "copy" class = "text-slate-400 fa-fw" > < / fa >
< / button >
< span v-show ="showB64Copy" > Copied ! < / span >
< / div >
< div class = "text-slate-500 text-sm font-bold" > Public Key ( hex ) < / div >
< div class = "text-sm text-slate-500 flex justify-start items-center mb-1" >
< code class = "truncate" > { { publicHex } } < / code >
< button
@ click = "
doCopyTwoSecRedo ( publicHex , ( ) => ( showPubCopy = ! showPubCopy ) )
"
class = "ml-2"
>
< fa icon = "copy" class = "text-slate-400 fa-fw" > < / fa >
< / button >
< span v-show ="showPubCopy" > Copied ! < / span >
< / div >
< div class = "text-slate-500 text-sm font-bold" > Derivation Path < / div >
< div class = "text-sm text-slate-500 flex justify-start items-center mb-1" >
< code class = "truncate" > { { derivationPath } } < / code >
< button
@ click = "
doCopyTwoSecRedo ( derivationPath , ( ) => ( showDerCopy = ! showDerCopy ) )
"
class = "ml-2"
>
< fa icon = "copy" class = "text-slate-400 fa-fw" > < / fa >
< / button >
< span v-show ="showDerCopy" > Copied ! < / span >
< / div >
< / div >
< router -link
: to = "{ name: 'new-edit-account' }"
class = "block text-center text-lg font-bold uppercase bg-blue-6 00 text-white px-2 py-3 rounded-md mb-2"
class = "block text-center text-lg font-bold uppercase bg-slate-500 text-white px-2 py-3 rounded-md mb-2"
>
Edit Identity
< / r o u t e r - l i n k >
@ -132,8 +100,10 @@
)
"
>
<!-- label -- >
< div > App Notifications < / div >
<!-- toggle -- >
< div class = "relative" >
< div class = "relative ml-2 " >
<!-- input -- >
< input type = "checkbox" name = "toggleNotifications" class = "sr-only" / >
<!-- line -- >
@ -143,8 +113,6 @@
class = "dot absolute left-1 top-1 bg-slate-400 w-6 h-6 rounded-full transition"
> < / div >
< / div >
<!-- label -- >
< div class = "ml-2" > App Notifications < / div >
< / label >
< label
for = "toggleMuteNotifications"
@ -159,8 +127,10 @@
)
"
>
<!-- label -- >
< div > Mute Notifications < / div >
<!-- toggle -- >
< div class = "relative" >
< div class = "relative ml-2 " >
<!-- input -- >
< input
type = "checkbox"
@ -174,8 +144,6 @@
class = "dot absolute left-1 top-1 bg-slate-400 w-6 h-6 rounded-full transition"
> < / div >
< / div >
<!-- label -- >
< div class = "ml-2" > Mute Notifications < / div >
< / label >
< / div >
@ -192,32 +160,13 @@
class = "block w-full text-center text-md uppercase bg-slate-500 text-white px-1.5 py-2 rounded-md mb-6"
@ click = "exportDatabase()"
>
Download Settings & Contacts ( excluding Identifier Data )
Download Settings & Contacts
< br / >
( excluding Identifier Data )
< / a >
< a ref = "downloadLink" / >
<!-- QR code popup -- >
< dialog id = "dlgQR" class = "backdrop:bg-black/75 rounded-md" >
< div class = "text-slate-500 text-center" >
< b > ID : < / b > < code > did : peer : kl45kj41lk451kl3 < / code >
< / div >
< img src = "/img/sample-qr-code.png" class = "w-full mb-3" / >
< button
value = "cancel"
class = "block w-full text-center text-md uppercase bg-slate-500 text-white px-1.5 py-2 rounded-md mb-2"
>
Copy to Clipboard
< / button >
< button
value = "cancel"
class = "block w-full text-center text-md uppercase bg-slate-500 text-white px-1.5 py-2 rounded-md"
>
Close
< / button >
< / dialog >
< div class = "flex py-2" >
< div v-if ="activeDid" class="flex py-2" >
< button class = "text-center text-md text-blue-500" @click ="checkLimits()" >
Check Limits
< / button >
@ -252,14 +201,76 @@
>
Advanced
< / h3 >
< div v-if ="showAdvanced" >
<!-- Deep Identity Details -- >
< h2 class = "text-slate-500 text-sm font-bold mb-2 py-2" >
Deep Identity Details
< / h2 >
< div class = "bg-slate-100 rounded-md overflow-hidden px-4 py-3 mb-4" >
< div class = "text-slate-500 text-sm font-bold" > Public Key ( base 64 ) < / div >
< div
class = "text-sm text-slate-500 flex justify-start items-center mb-1"
>
< code class = "truncate" > { { publicBase64 } } < / code >
< button
@ click = "
doCopyTwoSecRedo ( publicBase64 , ( ) => ( showB64Copy = ! showB64Copy ) )
"
class = "ml-2"
>
< fa icon = "copy" class = "text-slate-400 fa-fw" > < / fa >
< / button >
< span v-show ="showB64Copy" > Copied ! < / span >
< / div >
< div class = "text-slate-500 text-sm font-bold" > Public Key ( hex ) < / div >
< div
class = "text-sm text-slate-500 flex justify-start items-center mb-1"
>
< code class = "truncate" > { { publicHex } } < / code >
< button
@ click = "
doCopyTwoSecRedo ( publicHex , ( ) => ( showPubCopy = ! showPubCopy ) )
"
class = "ml-2"
>
< fa icon = "copy" class = "text-slate-400 fa-fw" > < / fa >
< / button >
< span v-show ="showPubCopy" > Copied ! < / span >
< / div >
< div class = "text-slate-500 text-sm font-bold" > Derivation Path < / div >
< div
class = "text-sm text-slate-500 flex justify-start items-center mb-1"
>
< code class = "truncate" > { { derivationPath } } < / code >
< button
@ click = "
doCopyTwoSecRedo (
derivationPath ,
( ) => ( showDerCopy = ! showDerCopy ) ,
)
"
class = "ml-2"
>
< fa icon = "copy" class = "text-slate-400 fa-fw" > < / fa >
< / button >
< span v-show ="showDerCopy" > Copied ! < / span >
< / div >
< / div >
< label
for = "toggleShowAmounts"
class = "flex items-center cursor-pointer mb-6"
class = "flex items-center cursor-pointer py-2 "
@ click = "handleChange"
>
<!-- label -- >
< h2 class = "text-slate-500 text-sm font-bold mb-2" >
Show amounts given with contacts
< / h2 >
<!-- toggle -- >
< div class = "relative" >
< div class = "relative ml-2 " >
<!-- input -- >
< input
type = "checkbox"
@ -274,23 +285,31 @@
class = "dot absolute left-1 top-1 bg-slate-400 w-6 h-6 rounded-full transition"
> < / div >
< / div >
<!-- label -- >
< div class = "ml-2" > Show amounts given with contacts < / div >
< / label >
< div class = "flex py-2" >
< button class = "text-blue-500" >
<!-- id used by puppeteer test script -- >
< router -link
id = "switch-identity-link"
: to = "{ name: 'identity-switcher' }"
class = "block text-center text-md uppercase bg-slate-500 text-white px-1.5 py-2 rounded-md mb-2 "
class = "block text-center"
>
Switch Identity / No Identity
< / r o u t e r - l i n k >
< / button >
< / div >
< div class = "flex py-2" >
Claim Server
< button class = "text-blue-500" >
< router -link : to = "{ name: 'statistics' }" class = "block text-center" >
See Achievements & Statistics
< / r o u t e r - l i n k >
< / button >
< / div >
< div class = "flex py-4" >
< h2 class = "text-slate-500 text-sm font-bold mb-2" > Claim Server < / h2 >
< input
type = "text"
class = "block w-full rounded border border-slate-400 px-3 py-2"
@ -322,17 +341,6 @@
Use Local
< / button >
< / div >
< div >
< button class = "text-blue-500" >
< router -link
: to = "{ name: 'statistics' }"
class = "block text-center py-3"
>
See Achievements & Statistics
< / r o u t e r - l i n k >
< / button >
< / div >
< / div >
< / section >
< / template >
@ -346,7 +354,7 @@ import { useClipboard } from "@vueuse/core";
import QuickNav from "@/components/QuickNav.vue" ;
import { AppString } from "@/constants/app" ;
import { db , accountsDB } from "@/db/index" ;
import { MASTER_SETTINGS_KEY } from "@/db/tables/settings" ;
import { MASTER_SETTINGS_KEY , Settings } from "@/db/tables/settings" ;
import { accessToken } from "@/libs/crypto" ;
import { IIdentifier } from "@veramo/core" ;
import { ErrorResponse , RateLimits } from "@/libs/endorserServer" ;
@ -368,14 +376,6 @@ interface IAccount {
derivationPath : string ;
}
interface SettingsType {
activeDid ? : string ;
apiServer ? : string ;
firstName ? : string ;
lastName ? : string ;
showContactGivesInline ? : boolean ;
}
@ Component ( { components : { QuickNav } } )
export default class AccountViewView extends Vue {
$notify ! : ( notification : Notification , timeout ? : number ) => void ;
@ -386,8 +386,8 @@ export default class AccountViewView extends Vue {
apiServer = "" ;
apiServerInput = "" ;
derivationPath = "" ;
first Name = "" ;
lastName = "" ;
given Name = "" ;
isRegistered = false ;
numAccounts = 0 ;
publicHex = "" ;
publicBase64 = "" ;
@ -402,8 +402,6 @@ export default class AccountViewView extends Vue {
showPubCopy = false ;
showAdvanced = false ;
alertMessage = "" ;
alertTitle = "" ;
public async getIdentity ( activeDid : string ) : Promise < IIdentifier | null > {
try {
@ -428,7 +426,7 @@ export default class AccountViewView extends Vue {
}
/ / R e t u r n p a r s e d i d e n t i t y o r n u l l i f n o t f o u n d
return JSON . parse ( account ? . identity || "null" ) ;
return JSON . parse ( ( account ? . identity as string ) || "null" ) ;
}
/ * *
@ -509,12 +507,14 @@ export default class AccountViewView extends Vue {
* Initializes component state with values from the database or defaults .
* @ param { SettingsType } settings - Object containing settings from the database .
* /
initializeState ( settings : SettingsType | undefined ) {
this . activeDid = settings ? . activeDid || "" ;
this . apiServer = settings ? . apiServer || "" ;
this . apiServerInput = settings ? . apiServer || "" ;
this . firstName = settings ? . firstName || "" ;
this . lastName = settings ? . lastName || "" ;
initializeState ( settings : Settings | undefined ) {
this . activeDid = ( settings ? . activeDid as string ) || "" ;
this . apiServer = ( settings ? . apiServer as string ) || "" ;
this . apiServerInput = ( settings ? . apiServer as string ) || "" ;
this . givenName =
( settings ? . firstName || "" ) +
( settings ? . lastName ? ` ${ settings . lastName } ` : "" ) ; / / p r e v 0 . 1 . 3
this . isRegistered = ! ! settings ? . isRegistered ;
this . showContactGives = ! ! settings ? . showContactGivesInline ;
}
@ -531,7 +531,7 @@ export default class AccountViewView extends Vue {
) {
this . publicHex = identity . keys [ 0 ] . publicKeyHex ;
this . publicBase64 = Buffer . from ( this . publicHex , "hex" ) . toString ( "base64" ) ;
this . derivationPath = identity . keys [ 0 ] . meta . derivationPath ;
this . derivationPath = identity . keys [ 0 ] . meta . derivationPath as string ;
db . settings . update ( MASTER_SETTINGS_KEY , {
activeDid : identity . did ,
@ -701,6 +701,27 @@ export default class AccountViewView extends Vue {
const resp = await this . fetchRateLimits ( identity ) ;
if ( resp . status === 200 ) {
this . limits = resp . data ;
if ( ! this . isRegistered ) {
/ / t h e u s e r i s n o t k n o w n t o b e r e g i s t e r e d , b u t t h e y a r e s o l e t ' s r e c o r d i t
try {
await db . open ( ) ;
db . settings . update ( MASTER_SETTINGS_KEY , {
isRegistered : true ,
} ) ;
this . isRegistered = true ;
} catch ( err ) {
console . log ( "Got an error updating settings:" , err ) ;
this . $notify (
{
group : "alert" ,
type : "warning" ,
title : "Update Error" ,
text : "Unable to update your settings. Check claim limits again." ,
} ,
- 1 ,
) ;
}
}
}
} catch ( error ) {
this . handleRateLimitsError ( error ) ;
@ -729,8 +750,13 @@ export default class AccountViewView extends Vue {
private handleRateLimitsError ( error : unknown ) {
if ( error instanceof AxiosError ) {
const data = error . response ? . data as ErrorResponse ;
this . limitsMessage = data ? . error ? . message || "Bad server response." ;
console . error ( "Bad response retrieving limits:" , error ) ;
this . limitsMessage =
( data ? . error ? . message as string ) || "Bad server response." ;
console . log (
"Got bad response retrieving limits, which usually means user isn't registered. Server says:" ,
this . limitsMessage ,
/ / e r r o r ,
) ;
} else if (
error instanceof Error &&
error . message ===