@ -52,7 +52,17 @@
<!-- Identity Details -- >
<!-- Identity Details -- >
< div class = "bg-slate-100 rounded-md overflow-hidden px-4 py-3 mb-4" >
< 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-slate-500 text-sm font-bold" > ID < / div >
< div class = "text-sm text-slate-500 flex justify-start items-center mb-1" >
< div class = "text-sm text-slate-500 flex justify-start items-center mb-1" >
@ -67,53 +77,11 @@
< / button >
< / button >
< span v-show ="showDidCopy" > Copied ! < / span >
< span v-show ="showDidCopy" > Copied ! < / span >
< / div >
< / 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 >
< / div >
< router -link
< router -link
: to = "{ name: 'new-edit-account' }"
: 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
Edit Identity
< / r o u t e r - l i n k >
< / r o u t e r - l i n k >
@ -132,8 +100,10 @@
)
)
"
"
>
>
<!-- label -- >
< div > App Notifications < / div >
<!-- toggle -- >
<!-- toggle -- >
< div class = "relative" >
< div class = "relative ml-2 " >
<!-- input -- >
<!-- input -- >
< input type = "checkbox" name = "toggleNotifications" class = "sr-only" / >
< input type = "checkbox" name = "toggleNotifications" class = "sr-only" / >
<!-- line -- >
<!-- line -- >
@ -143,8 +113,6 @@
class = "dot absolute left-1 top-1 bg-slate-400 w-6 h-6 rounded-full transition"
class = "dot absolute left-1 top-1 bg-slate-400 w-6 h-6 rounded-full transition"
> < / div >
> < / div >
< / div >
< / div >
<!-- label -- >
< div class = "ml-2" > App Notifications < / div >
< / label >
< / label >
< label
< label
for = "toggleMuteNotifications"
for = "toggleMuteNotifications"
@ -159,8 +127,10 @@
)
)
"
"
>
>
<!-- label -- >
< div > Mute Notifications < / div >
<!-- toggle -- >
<!-- toggle -- >
< div class = "relative" >
< div class = "relative ml-2 " >
<!-- input -- >
<!-- input -- >
< input
< input
type = "checkbox"
type = "checkbox"
@ -174,8 +144,6 @@
class = "dot absolute left-1 top-1 bg-slate-400 w-6 h-6 rounded-full transition"
class = "dot absolute left-1 top-1 bg-slate-400 w-6 h-6 rounded-full transition"
> < / div >
> < / div >
< / div >
< / div >
<!-- label -- >
< div class = "ml-2" > Mute Notifications < / div >
< / label >
< / label >
< / div >
< / 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"
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()"
@ click = "exportDatabase()"
>
>
Download Settings & Contacts ( excluding Identifier Data )
Download Settings & Contacts
< br / >
( excluding Identifier Data )
< / a >
< / a >
< a ref = "downloadLink" / >
< a ref = "downloadLink" / >
<!-- QR code popup -- >
< div v-if ="activeDid" class="flex py-2" >
< 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" >
< button class = "text-center text-md text-blue-500" @click ="checkLimits()" >
< button class = "text-center text-md text-blue-500" @click ="checkLimits()" >
Check Limits
Check Limits
< / button >
< / button >
@ -252,14 +201,76 @@
>
>
Advanced
Advanced
< / h3 >
< / h3 >
< div v-if ="showAdvanced" >
< 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
< label
for = "toggleShowAmounts"
for = "toggleShowAmounts"
class = "flex items-center cursor-pointer mb-6"
class = "flex items-center cursor-pointer py-2 "
@ click = "handleChange"
@ click = "handleChange"
>
>
<!-- label -- >
< h2 class = "text-slate-500 text-sm font-bold mb-2" >
Show amounts given with contacts
< / h2 >
<!-- toggle -- >
<!-- toggle -- >
< div class = "relative" >
< div class = "relative ml-2 " >
<!-- input -- >
<!-- input -- >
< input
< input
type = "checkbox"
type = "checkbox"
@ -274,23 +285,31 @@
class = "dot absolute left-1 top-1 bg-slate-400 w-6 h-6 rounded-full transition"
class = "dot absolute left-1 top-1 bg-slate-400 w-6 h-6 rounded-full transition"
> < / div >
> < / div >
< / div >
< / div >
<!-- label -- >
< div class = "ml-2" > Show amounts given with contacts < / div >
< / label >
< / label >
< div class = "flex py-2" >
< div class = "flex py-2" >
<!-- id used by puppeteer test script -- >
< button class = "text-blue-500" >
< router -link
<!-- id used by puppeteer test script -- >
id = "switch-identity-link"
< router -link
: to = "{ name: 'identity-switcher' }"
id = "switch-identity-link"
class = "block text-center text-md uppercase bg-slate-500 text-white px-1.5 py-2 rounded-md mb-2"
: to = "{ name: 'identity-switcher' }"
>
class = "block text-center"
Switch Identity / No Identity
>
< / r o u t e r - l i n k >
Switch Identity / No Identity
< / r o u t e r - l i n k >
< / button >
< / div >
< / div >
< div class = "flex py-2" >
< 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
< input
type = "text"
type = "text"
class = "block w-full rounded border border-slate-400 px-3 py-2"
class = "block w-full rounded border border-slate-400 px-3 py-2"
@ -322,17 +341,6 @@
Use Local
Use Local
< / button >
< / button >
< / div >
< / 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 >
< / div >
< / section >
< / section >
< / template >
< / template >
@ -346,7 +354,7 @@ import { useClipboard } from "@vueuse/core";
import QuickNav from "@/components/QuickNav.vue" ;
import QuickNav from "@/components/QuickNav.vue" ;
import { AppString } from "@/constants/app" ;
import { AppString } from "@/constants/app" ;
import { db , accountsDB } from "@/db/index" ;
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 { accessToken } from "@/libs/crypto" ;
import { IIdentifier } from "@veramo/core" ;
import { IIdentifier } from "@veramo/core" ;
import { ErrorResponse , RateLimits } from "@/libs/endorserServer" ;
import { ErrorResponse , RateLimits } from "@/libs/endorserServer" ;
@ -368,14 +376,6 @@ interface IAccount {
derivationPath : string ;
derivationPath : string ;
}
}
interface SettingsType {
activeDid ? : string ;
apiServer ? : string ;
firstName ? : string ;
lastName ? : string ;
showContactGivesInline ? : boolean ;
}
@ Component ( { components : { QuickNav } } )
@ Component ( { components : { QuickNav } } )
export default class AccountViewView extends Vue {
export default class AccountViewView extends Vue {
$notify ! : ( notification : Notification , timeout ? : number ) => void ;
$notify ! : ( notification : Notification , timeout ? : number ) => void ;
@ -386,8 +386,8 @@ export default class AccountViewView extends Vue {
apiServer = "" ;
apiServer = "" ;
apiServerInput = "" ;
apiServerInput = "" ;
derivationPath = "" ;
derivationPath = "" ;
first Name = "" ;
given Name = "" ;
lastName = "" ;
isRegistered = false ;
numAccounts = 0 ;
numAccounts = 0 ;
publicHex = "" ;
publicHex = "" ;
publicBase64 = "" ;
publicBase64 = "" ;
@ -402,8 +402,6 @@ export default class AccountViewView extends Vue {
showPubCopy = false ;
showPubCopy = false ;
showAdvanced = false ;
showAdvanced = false ;
alertMessage = "" ;
alertTitle = "" ;
public async getIdentity ( activeDid : string ) : Promise < IIdentifier | null > {
public async getIdentity ( activeDid : string ) : Promise < IIdentifier | null > {
try {
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
/ / 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 .
* Initializes component state with values from the database or defaults .
* @ param { SettingsType } settings - Object containing settings from the database .
* @ param { SettingsType } settings - Object containing settings from the database .
* /
* /
initializeState ( settings : SettingsType | undefined ) {
initializeState ( settings : Settings | undefined ) {
this . activeDid = settings ? . activeDid || "" ;
this . activeDid = ( settings ? . activeDid as string ) || "" ;
this . apiServer = settings ? . apiServer || "" ;
this . apiServer = ( settings ? . apiServer as string ) || "" ;
this . apiServerInput = settings ? . apiServer || "" ;
this . apiServerInput = ( settings ? . apiServer as string ) || "" ;
this . firstName = settings ? . firstName || "" ;
this . givenName =
this . lastName = settings ? . lastName || "" ;
( settings ? . firstName || "" ) +
( settings ? . lastName ? ` ${ settings . lastName } ` : "" ) ; / / p r e v 0 . 1 . 3
this . isRegistered = ! ! settings ? . isRegistered ;
this . showContactGives = ! ! settings ? . showContactGivesInline ;
this . showContactGives = ! ! settings ? . showContactGivesInline ;
}
}
@ -531,7 +531,7 @@ export default class AccountViewView extends Vue {
) {
) {
this . publicHex = identity . keys [ 0 ] . publicKeyHex ;
this . publicHex = identity . keys [ 0 ] . publicKeyHex ;
this . publicBase64 = Buffer . from ( this . publicHex , "hex" ) . toString ( "base64" ) ;
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 , {
db . settings . update ( MASTER_SETTINGS_KEY , {
activeDid : identity . did ,
activeDid : identity . did ,
@ -701,6 +701,27 @@ export default class AccountViewView extends Vue {
const resp = await this . fetchRateLimits ( identity ) ;
const resp = await this . fetchRateLimits ( identity ) ;
if ( resp . status === 200 ) {
if ( resp . status === 200 ) {
this . limits = resp . data ;
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 ) {
} catch ( error ) {
this . handleRateLimitsError ( error ) ;
this . handleRateLimitsError ( error ) ;
@ -729,8 +750,13 @@ export default class AccountViewView extends Vue {
private handleRateLimitsError ( error : unknown ) {
private handleRateLimitsError ( error : unknown ) {
if ( error instanceof AxiosError ) {
if ( error instanceof AxiosError ) {
const data = error . response ? . data as ErrorResponse ;
const data = error . response ? . data as ErrorResponse ;
this . limitsMessage = data ? . error ? . message || "Bad server response." ;
this . limitsMessage =
console . error ( "Bad response retrieving limits:" , error ) ;
( 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 (
} else if (
error instanceof Error &&
error instanceof Error &&
error . message ===
error . message ===