Fix yarn.lock (#448)

This commit is contained in:
KoalaSat 2023-03-19 18:51:19 +00:00 committed by GitHub
commit f983b5caa0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 8413 additions and 12270 deletions

View File

@ -3,10 +3,9 @@ import SInfo from 'react-native-sensitive-info'
import { RelayPoolContext } from './RelayPoolContext' import { RelayPoolContext } from './RelayPoolContext'
import { AppContext } from './AppContext' import { AppContext } from './AppContext'
import { getUser } from '../Functions/DatabaseFunctions/Users' import { getUser } from '../Functions/DatabaseFunctions/Users'
import { getPublicKey } from 'nostr-tools' import { getPublicKey, nip19 } from 'nostr-tools'
import { dropTables } from '../Functions/DatabaseFunctions' import { dropTables } from '../Functions/DatabaseFunctions'
import { navigate } from '../lib/Navigation' import { navigate } from '../lib/Navigation'
import { nsecEncode } from 'nostr-tools/nip19'
import { getNpub } from '../lib/nostr/Nip19' import { getNpub } from '../lib/nostr/Nip19'
import { getGroups } from '../Functions/DatabaseFunctions/Groups' import { getGroups } from '../Functions/DatabaseFunctions/Groups'
import { getList } from '../Functions/DatabaseFunctions/Lists' import { getList } from '../Functions/DatabaseFunctions/Lists'
@ -174,7 +173,7 @@ export const UserContextProvider = ({ children }: UserContextProviderProps): JSX
useEffect(() => { useEffect(() => {
if (privateKey && privateKey !== '') { if (privateKey && privateKey !== '') {
SInfo.setItem('privateKey', privateKey, {}) SInfo.setItem('privateKey', privateKey, {})
setNsec(nsecEncode(privateKey)) setNsec(nip19.nsecEncode(privateKey))
setPublicKey(getPublicKey(privateKey)) setPublicKey(getPublicKey(privateKey))
} }
}, [privateKey]) }, [privateKey])

View File

@ -2,7 +2,7 @@ import React, { useContext, useEffect, useState } from 'react'
import { type NativeScrollEvent, type NativeSyntheticEvent, StyleSheet, View } from 'react-native' import { type NativeScrollEvent, type NativeSyntheticEvent, StyleSheet, View } from 'react-native'
import Clipboard from '@react-native-clipboard/clipboard' import Clipboard from '@react-native-clipboard/clipboard'
import { AppContext } from '../../Contexts/AppContext' import { AppContext } from '../../Contexts/AppContext'
import { Kind } from 'nostr-tools' import { Kind, nip05 } from 'nostr-tools'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import { FlashList, type ListRenderItem } from '@shopify/flash-list' import { FlashList, type ListRenderItem } from '@shopify/flash-list'
import { import {
@ -30,7 +30,6 @@ import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityI
import { useFocusEffect } from '@react-navigation/native' import { useFocusEffect } from '@react-navigation/native'
import ProfileData from '../../Components/ProfileData' import ProfileData from '../../Components/ProfileData'
import { handleInfinityScroll } from '../../Functions/NativeFunctions' import { handleInfinityScroll } from '../../Functions/NativeFunctions'
import { queryProfile } from 'nostr-tools/nip05'
import DatabaseModule from '../../lib/Native/DatabaseModule' import DatabaseModule from '../../lib/Native/DatabaseModule'
import { removeMutedUsersList } from '../../Functions/RelayFunctions/Lists' import { removeMutedUsersList } from '../../Functions/RelayFunctions/Lists'
@ -149,7 +148,7 @@ export const ContactsPage: React.FC = () => {
let hexKey = contactInput let hexKey = contactInput
if (contactInput.includes('@')) { if (contactInput.includes('@')) {
const profile = await queryProfile(contactInput) const profile = await nip05.queryProfile(contactInput)
hexKey = profile?.pubkey ?? hexKey hexKey = profile?.pubkey ?? hexKey
} else { } else {
hexKey = getNip19Key(contactInput) ?? hexKey hexKey = getNip19Key(contactInput) ?? hexKey

View File

@ -35,7 +35,7 @@ import { UserContext } from '../../Contexts/UserContext'
import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons' import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons'
import { useFocusEffect } from '@react-navigation/native' import { useFocusEffect } from '@react-navigation/native'
import { Kind } from 'nostr-tools' import { Kind } from 'nostr-tools'
import { handleInfinityScroll } from '../../Functions/NativeFunctions' import { formatHour, handleInfinityScroll } from '../../Functions/NativeFunctions'
import NostrosAvatar from '../../Components/NostrosAvatar' import NostrosAvatar from '../../Components/NostrosAvatar'
import UploadImage from '../../Components/UploadImage' import UploadImage from '../../Components/UploadImage'
import { Swipeable } from 'react-native-gesture-handler' import { Swipeable } from 'react-native-gesture-handler'

View File

@ -7,14 +7,13 @@ import { createBottomTabNavigator } from '@react-navigation/bottom-tabs'
import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons' import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons'
import { UserContext } from '../../Contexts/UserContext' import { UserContext } from '../../Contexts/UserContext'
import { RelayPoolContext } from '../../Contexts/RelayPoolContext' import { RelayPoolContext } from '../../Contexts/RelayPoolContext'
import { Kind } from 'nostr-tools' import { Kind, nip19 } from 'nostr-tools'
import { getMentionNotes, getNotificationsIds } from '../../Functions/DatabaseFunctions/Notes' import { getMentionNotes, getNotificationsIds } from '../../Functions/DatabaseFunctions/Notes'
import { AppContext } from '../../Contexts/AppContext' import { AppContext } from '../../Contexts/AppContext'
import { StyleSheet } from 'react-native' import { StyleSheet } from 'react-native'
import RBSheet from 'react-native-raw-bottom-sheet' import RBSheet from 'react-native-raw-bottom-sheet'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import { navigate } from '../../lib/Navigation' import { navigate } from '../../lib/Navigation'
import { decode } from 'nostr-tools/nip19'
import { import {
getDirectMessagesCount, getDirectMessagesCount,
getGroupedDirectMessages, getGroupedDirectMessages,
@ -94,7 +93,7 @@ export const HomePage: React.FC = () => {
const goToEvent: () => void = () => { const goToEvent: () => void = () => {
if (clipboardNip21) { if (clipboardNip21) {
const key = decode(clipboardNip21.replace('nostr:', '')) const key = nip19.decode(clipboardNip21.replace('nostr:', ''))
if (key?.data) { if (key?.data) {
if (key.type === 'nevent') { if (key.type === 'nevent') {
navigate('Note', { noteId: key.data.id }) navigate('Note', { noteId: key.data.id })

View File

@ -9,7 +9,7 @@ import Logo from '../../Components/Logo'
import { navigate } from '../../lib/Navigation' import { navigate } from '../../lib/Navigation'
import { useFocusEffect } from '@react-navigation/native' import { useFocusEffect } from '@react-navigation/native'
import RBSheet from 'react-native-raw-bottom-sheet' import RBSheet from 'react-native-raw-bottom-sheet'
import { privateKeyFromSeedWords } from 'nostr-tools/nip06' import { nip06 } from 'nostr-tools'
import { AppContext } from '../../Contexts/AppContext' import { AppContext } from '../../Contexts/AppContext'
interface ProfileConnectPageProps { interface ProfileConnectPageProps {
@ -77,7 +77,7 @@ export const ProfileConnectPage: React.FC<ProfileConnectPageProps> = ({ route })
for (let index = 1; index <= 12; index++) { for (let index = 1; index <= 12; index++) {
words.push(mnemonicWords[index].trim()) words.push(mnemonicWords[index].trim())
} }
setPrivateKey(privateKeyFromSeedWords(words.join(' '))) setPrivateKey(nip06.privateKeyFromSeedWords(words.join(' ')))
setMnemonicWords({}) setMnemonicWords({})
navigate('ProfileLoad') navigate('ProfileLoad')
} }

View File

@ -6,8 +6,7 @@ import { Button, Checkbox, Snackbar, Text, TextInput } from 'react-native-paper'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import { type DrawerNavigationHelpers } from '@react-navigation/drawer/lib/typescript/src/types' import { type DrawerNavigationHelpers } from '@react-navigation/drawer/lib/typescript/src/types'
import { UserContext } from '../../Contexts/UserContext' import { UserContext } from '../../Contexts/UserContext'
import { privateKeyFromSeedWords } from 'nostr-tools/nip06' import { nip06, nip19 } from 'nostr-tools'
import { nsecEncode } from 'nostr-tools/nip19'
import { RelayPoolContext } from '../../Contexts/RelayPoolContext' import { RelayPoolContext } from '../../Contexts/RelayPoolContext'
import { getUnixTime } from 'date-fns' import { getUnixTime } from 'date-fns'
import { type Event } from '../../lib/nostr/Events' import { type Event } from '../../lib/nostr/Events'
@ -35,9 +34,9 @@ export const ProfileCreatePage: React.FC<ProfileCreatePageProps> = ({ navigation
Keyboard.addListener('keyboardDidHide', () => setKeyboardShow(false)) Keyboard.addListener('keyboardDidHide', () => setKeyboardShow(false))
generateRandomMnemonic().then((words) => { generateRandomMnemonic().then((words) => {
setMnemonicWords(words) setMnemonicWords(words)
const privateKey = privateKeyFromSeedWords(Object.values(words).join(' ')) const privateKey = nip06.privateKeyFromSeedWords(Object.values(words).join(' '))
setKey(privateKey) setKey(privateKey)
const nsec = nsecEncode(privateKey) const nsec = nip19.nsecEncode(privateKey)
setInputValue(nsec) setInputValue(nsec)
}) })
createRandomRelays() createRandomRelays()

View File

@ -2,8 +2,7 @@ import { useFocusEffect } from '@react-navigation/native'
import { FlashList, type ListRenderItem } from '@shopify/flash-list' import { FlashList, type ListRenderItem } from '@shopify/flash-list'
import { t } from 'i18next' import { t } from 'i18next'
import debounce from 'lodash.debounce' import debounce from 'lodash.debounce'
import { Kind } from 'nostr-tools' import { Kind, nip19 } from 'nostr-tools'
import { decode } from 'nostr-tools/nip19'
import * as React from 'react' import * as React from 'react'
import { StyleSheet, View } from 'react-native' import { StyleSheet, View } from 'react-native'
import { ActivityIndicator, Text, TextInput, TouchableRipple, useTheme } from 'react-native-paper' import { ActivityIndicator, Text, TextInput, TouchableRipple, useTheme } from 'react-native-paper'
@ -118,7 +117,7 @@ export const SearchPage: React.FC<SearchPageProps> = ({ route }) => {
React.useEffect(() => { React.useEffect(() => {
if (searchInput !== '' && validNip21(searchInput)) { if (searchInput !== '' && validNip21(searchInput)) {
try { try {
const key = decode(searchInput.replace('nostr:', '')) const key = nip19.decode(searchInput.replace('nostr:', ''))
if (key?.data) { if (key?.data) {
if (key.type === 'nevent') { if (key.type === 'nevent') {
setSearchInput('') setSearchInput('')

View File

@ -1,18 +1,11 @@
import { import { nip19 } from 'nostr-tools'
decode,
type EventPointer,
neventEncode,
nprofileEncode,
npubEncode,
type ProfilePointer,
} from 'nostr-tools/nip19'
export function getNpub(key: string | undefined): string { export function getNpub(key: string | undefined): string {
if (!key) return '' if (!key) return ''
if (isPublicKey(key)) return key if (isPublicKey(key)) return key
try { try {
return npubEncode(key) return nip19.npubEncode(key)
} catch { } catch {
console.log('Error encoding') console.log('Error encoding')
} }
@ -24,7 +17,7 @@ export function getNprofile(key: string, relays: string[]): string {
if (!key) return '' if (!key) return ''
try { try {
return nprofileEncode({ return nip19.nprofileEncode({
pubkey: key, pubkey: key,
relays, relays,
}) })
@ -40,7 +33,7 @@ export function getNevent(key: string | undefined, relays: string[]): string {
if (isPublicKey(key)) return key if (isPublicKey(key)) return key
try { try {
return neventEncode({ id: key, relays }) return nip19.neventEncode({ id: key, relays })
} catch { } catch {
console.log('Error encoding') console.log('Error encoding')
} }
@ -48,16 +41,16 @@ export function getNevent(key: string | undefined, relays: string[]): string {
return key return key
} }
export function getNip19Key(nip19: string): string | null { export function getNip19Key(key: string): string | null {
let result = null let result = null
try { try {
const decoded = decode(nip19) const decoded = nip19.decode(key)
if (decoded.type === 'nprofile') { if (decoded.type === 'nprofile') {
const data = decoded.data as ProfilePointer const data = decoded.data as nip19.ProfilePointer
result = data.pubkey result = data.pubkey
} else if (decoded.type === 'nevent') { } else if (decoded.type === 'nevent') {
const data = decoded.data as EventPointer const data = decoded.data as nip19.EventPointer
result = data.id result = data.id
} else { } else {
result = decoded.data as string result = decoded.data as string

View File

@ -32,7 +32,7 @@
"i18next": "^22.4.10", "i18next": "^22.4.10",
"lnurl-pay": "^2.2.0", "lnurl-pay": "^2.2.0",
"lodash.debounce": "^4.0.8", "lodash.debounce": "^4.0.8",
"nostr-tools": "^1.2.1", "nostr-tools": "^1.7.5",
"react": "18.2.0", "react": "18.2.0",
"react-content-loader": "^6.2.0", "react-content-loader": "^6.2.0",
"react-i18next": "^12.2.0", "react-i18next": "^12.2.0",

20625
yarn.lock

File diff suppressed because it is too large Load Diff