Compare commits

..

No commits in common. "2cdcfd7ca782b2b887d3fb11d84f2dd36a9d03ee" and "352500970ea83cb4932f4c3ada9380c3551fc9df" have entirely different histories.

2 changed files with 9 additions and 45 deletions

View File

@ -20,7 +20,6 @@ import { LoginMethods } from '../../store/auth/types'
import { Dispatch } from '../../store/store'
import { npubToHex, queryNip05 } from '../../utils'
import styles from './style.module.scss'
import { hexToBytes } from '@noble/hashes/utils'
export const Login = () => {
const [searchParams] = useSearchParams()
@ -93,24 +92,9 @@ export const Login = () => {
})
}
/**
* Login with NSEC or HEX private key
* @param privateKey in HEX format
*/
const loginWithNsec = async (privateKey?: Uint8Array) => {
let nsec = ''
if (privateKey) {
nsec = nip19.nsecEncode(privateKey)
} else {
nsec = inputValue
try {
privateKey = nip19.decode(nsec).data as Uint8Array
} catch (err) {
toast.error(`Error decoding the nsec. ${err}`)
}
}
const loginWithNsec = async () => {
const nsec = inputValue
const privateKey = nip19.decode(nsec).data as Uint8Array
if (!privateKey) {
toast.error(
@ -323,19 +307,7 @@ export const Login = () => {
return loginWithNsecBunker()
}
// Check if maybe hex nsec
try {
const privateKey = hexToBytes(inputValue)
const publickey = getPublicKey(privateKey)
if (publickey) return loginWithNsec(privateKey)
} catch (err) {
console.warn('err', err)
}
toast.error(
'Invalid format, please use: private key (hex), nsec..., bunker:// or nip05 format.'
)
toast.error('Invalid Input!')
return
}
@ -357,7 +329,7 @@ export const Login = () => {
<Typography variant="h4">Welcome to Sigit</Typography>
<TextField
onKeyDown={handleInputKeyDown}
label="nip05 login / nip46 bunker string"
label="nip05 login / nip46 bunker string / nsec"
value={inputValue}
onChange={(e) => setInputValue(e.target.value)}
sx={{ width: '100%', mt: 2 }}

View File

@ -240,19 +240,11 @@ export const ProfilePage = () => {
</Box>
<Box>
{profileMetadata?.nip05 &&
textElementWithCopyIcon(
profileMetadata.nip05,
undefined,
15
)}
textElementWithCopyIcon(profileMetadata.nip05, undefined, 15)}
</Box>
<Box>
{profileMetadata?.lud16 &&
textElementWithCopyIcon(
profileMetadata.lud16,
undefined,
15
)}
textElementWithCopyIcon(profileMetadata.lud16, undefined, 15)}
</Box>
</Box>