Compare commits
No commits in common. "9caba52f7d0157d435c360e3204b602612714564" and "7808bcde44016a4d43dd9db5edfa976f024064ba" have entirely different histories.
9caba52f7d
...
7808bcde44
@ -20,7 +20,6 @@ import { LoginMethods } from '../../store/auth/types'
|
|||||||
import { Dispatch } from '../../store/store'
|
import { Dispatch } from '../../store/store'
|
||||||
import { npubToHex, queryNip05 } from '../../utils'
|
import { npubToHex, queryNip05 } from '../../utils'
|
||||||
import styles from './style.module.scss'
|
import styles from './style.module.scss'
|
||||||
import { hexToBytes } from '@noble/hashes/utils'
|
|
||||||
|
|
||||||
export const Login = () => {
|
export const Login = () => {
|
||||||
const [searchParams] = useSearchParams()
|
const [searchParams] = useSearchParams()
|
||||||
@ -93,24 +92,9 @@ export const Login = () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
const loginWithNsec = async () => {
|
||||||
* Login with NSEC or HEX private key
|
const nsec = inputValue
|
||||||
* @param privateKey in HEX format
|
const privateKey = nip19.decode(nsec).data as Uint8Array
|
||||||
*/
|
|
||||||
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}`)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!privateKey) {
|
if (!privateKey) {
|
||||||
toast.error(
|
toast.error(
|
||||||
@ -323,19 +307,7 @@ export const Login = () => {
|
|||||||
return loginWithNsecBunker()
|
return loginWithNsecBunker()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if maybe hex nsec
|
toast.error('Invalid Input!')
|
||||||
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.'
|
|
||||||
)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -357,7 +329,7 @@ export const Login = () => {
|
|||||||
<Typography variant="h4">Welcome to Sigit</Typography>
|
<Typography variant="h4">Welcome to Sigit</Typography>
|
||||||
<TextField
|
<TextField
|
||||||
onKeyDown={handleInputKeyDown}
|
onKeyDown={handleInputKeyDown}
|
||||||
label="nip05 login / nip46 bunker string"
|
label="nip05 login / nip46 bunker string / nsec"
|
||||||
value={inputValue}
|
value={inputValue}
|
||||||
onChange={(e) => setInputValue(e.target.value)}
|
onChange={(e) => setInputValue(e.target.value)}
|
||||||
sx={{ width: '100%', mt: 2 }}
|
sx={{ width: '100%', mt: 2 }}
|
||||||
|
@ -208,7 +208,7 @@ export const ProfilePage = () => {
|
|||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
<Box className={styles.head}>
|
<Box className={styles.head}>
|
||||||
<Box sx={{ lineHeight: 1 }} className={styles.npubNip}>
|
<Box sx={{lineHeight: 1}} className={styles.npubNip}>
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
display: 'flex'
|
display: 'flex'
|
||||||
@ -216,7 +216,7 @@ export const ProfilePage = () => {
|
|||||||
>
|
>
|
||||||
{profileMetadata && (
|
{profileMetadata && (
|
||||||
<Typography
|
<Typography
|
||||||
sx={{ margin: '5px 0 5px 0' }}
|
sx={{ margin: '5px 0 5px 0'}}
|
||||||
variant="h6"
|
variant="h6"
|
||||||
className={styles.bold}
|
className={styles.bold}
|
||||||
>
|
>
|
||||||
@ -240,19 +240,11 @@ export const ProfilePage = () => {
|
|||||||
</Box>
|
</Box>
|
||||||
<Box>
|
<Box>
|
||||||
{profileMetadata?.nip05 &&
|
{profileMetadata?.nip05 &&
|
||||||
textElementWithCopyIcon(
|
textElementWithCopyIcon(profileMetadata.nip05, undefined, 15)}
|
||||||
profileMetadata.nip05,
|
|
||||||
undefined,
|
|
||||||
15
|
|
||||||
)}
|
|
||||||
</Box>
|
</Box>
|
||||||
<Box>
|
<Box>
|
||||||
{profileMetadata?.lud16 &&
|
{profileMetadata?.lud16 &&
|
||||||
textElementWithCopyIcon(
|
textElementWithCopyIcon(profileMetadata.lud16, undefined, 15)}
|
||||||
profileMetadata.lud16,
|
|
||||||
undefined,
|
|
||||||
15
|
|
||||||
)}
|
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user