From 0efd9085f717ca58e4acd94a255dbe3287b9bbed Mon Sep 17 00:00:00 2001 From: KoalaSat Date: Sun, 8 Jan 2023 20:41:13 +0100 Subject: [PATCH 1/3] Bench32 compatible --- App.tsx | 1 + .../main/java/com/nostros/classes/Event.java | 25 +- .../java/com/nostros/classes/Websocket.java | 31 +-- .../com/nostros/modules/DatabaseModule.java | 17 ++ frontend/Components/LnPayment/index.tsx | 10 +- frontend/Components/NoteCard/index.tsx | 6 +- frontend/Pages/ConversationPage/index.tsx | 20 +- frontend/Pages/DirectMessagesPage/index.tsx | 6 +- frontend/Pages/HomePage/index.tsx | 6 +- frontend/Pages/LandingPage/Loader/index.tsx | 13 +- frontend/Pages/LandingPage/Logger/index.tsx | 14 +- frontend/Pages/ProfilePage/index.tsx | 37 +-- frontend/lib/nostr/Crypto/index.ts | 20 -- frontend/lib/nostr/Nip04/index.ts | 37 +++ frontend/lib/nostr/Nip19/index.ts | 30 +++ package.json | 4 +- yarn.lock | 215 +++++------------- 17 files changed, 229 insertions(+), 263 deletions(-) delete mode 100644 frontend/lib/nostr/Crypto/index.ts create mode 100644 frontend/lib/nostr/Nip04/index.ts create mode 100644 frontend/lib/nostr/Nip19/index.ts diff --git a/App.tsx b/App.tsx index fe12dae..7383f8b 100644 --- a/App.tsx +++ b/App.tsx @@ -1,5 +1,6 @@ import App from './frontend' import { Buffer as SafeBuffer } from 'safe-buffer' +import 'text-encoding-polyfill' global.Buffer = SafeBuffer diff --git a/android/app/src/main/java/com/nostros/classes/Event.java b/android/app/src/main/java/com/nostros/classes/Event.java index 44fde85..2a15a4d 100644 --- a/android/app/src/main/java/com/nostros/classes/Event.java +++ b/android/app/src/main/java/com/nostros/classes/Event.java @@ -84,7 +84,9 @@ public class Event { JSONArray eTags = filterTags("e"); String replyEventId = null; try { - replyEventId = eTags.getJSONArray(eTags.length() - 1).getString(1); + if (eTags.length() > 0) { + replyEventId = eTags.getJSONArray(eTags.length() - 1).getString(1); + } } catch (JSONException e) { e.printStackTrace(); } @@ -171,6 +173,15 @@ public class Event { JSONArray pTags = filterTags("p"); JSONArray eTags = filterTags("e"); + String reacted_event_id = ""; + String reacted_user_id = ""; + if (eTags.length() > 0) { + reacted_event_id = eTags.getJSONArray(eTags.length() - 1).getString(1); + } + if (pTags.length() > 0) { + reacted_user_id = pTags.getJSONArray(pTags.length() - 1).getString(1); + } + ContentValues values = new ContentValues(); values.put("id", id); values.put("content", content.replace("'", "''")); @@ -180,8 +191,8 @@ public class Event { values.put("sig", sig); values.put("tags", tags.toString()); values.put("positive", !content.equals("-")); - values.put("reacted_event_id", eTags.getJSONArray(eTags.length() - 1).getString(1)); - values.put("reacted_user_id", pTags.getJSONArray(pTags.length() - 1).getString(1)); + values.put("reacted_event_id", reacted_event_id); + values.put("reacted_user_id", reacted_user_id); String query = "SELECT id FROM nostros_reactions WHERE id = ?"; @SuppressLint("Recycle") Cursor cursor = database.rawQuery(query, new String[] {id}); @@ -218,13 +229,17 @@ public class Event { for (int i = 0; i < tags.length(); ++i) { JSONArray tag = tags.getJSONArray(i); String petId = tag.getString(1); + String name = ""; + if (tag.length() >= 4) { + name = tag.getString(3); + } String query = "SELECT * FROM nostros_users WHERE id = ?"; Cursor cursor = database.rawQuery(query, new String[] {petId}); if (cursor.getCount() == 0) { ContentValues values = new ContentValues(); values.put("id", petId); - values.put("name", tag.getString(3)); - values.put("contact", true); + values.put("name", name); + values.put("contact", true); database.insert("nostros_users", null, values); } } diff --git a/android/app/src/main/java/com/nostros/classes/Websocket.java b/android/app/src/main/java/com/nostros/classes/Websocket.java index 02666ad..fe8c5a5 100644 --- a/android/app/src/main/java/com/nostros/classes/Websocket.java +++ b/android/app/src/main/java/com/nostros/classes/Websocket.java @@ -1,21 +1,18 @@ package com.nostros.classes; -import android.os.Bundle; import android.util.Log; import com.facebook.react.bridge.Arguments; -import com.facebook.react.bridge.Callback; import com.facebook.react.bridge.ReactApplicationContext; -import com.facebook.react.bridge.ReactContext; import com.facebook.react.bridge.WritableMap; import com.facebook.react.modules.core.DeviceEventManagerModule; -import com.facebook.react.uimanager.events.RCTEventEmitter; import com.neovisionaries.ws.client.HostnameUnverifiedException; import com.neovisionaries.ws.client.OpeningHandshakeException; import com.neovisionaries.ws.client.WebSocket; import com.neovisionaries.ws.client.WebSocketAdapter; import com.neovisionaries.ws.client.WebSocketException; import com.neovisionaries.ws.client.WebSocketFactory; +import com.neovisionaries.ws.client.WebSocketFrame; import com.nostros.modules.DatabaseModule; import org.json.JSONArray; @@ -48,6 +45,9 @@ public class Websocket { public void connect(String userPubKey) throws IOException { WebSocketFactory factory = new WebSocketFactory(); webSocket = factory.createSocket(url); + webSocket.setMissingCloseFrameAllowed(true); + webSocket.setPingInterval(25 * 1000); + webSocket.addListener(new WebSocketAdapter() { @Override public void onTextMessage(WebSocket websocket, String message) throws Exception { @@ -59,24 +59,13 @@ public class Websocket { reactNativeEvent(data.getString("id")); } } + @Override + public void onDisconnected(WebSocket ws, WebSocketFrame serverCloseFrame, + WebSocketFrame clientCloseFrame, boolean closedByServer) { + ws.connectAsynchronously(); + } }); - try { - webSocket.connect(); - }catch (OpeningHandshakeException e) - { - // A violation against the WebSocket protocol was detected - // during the opening handshake. - Log.d("WebSocket", "A violation against the WebSocket protocol was detected."); - } - catch (HostnameUnverifiedException e) - { - // The certificate of the peer does not match the expected hostname. - Log.d("WebSocket", "The certificate of the peer does not match the expected hostname."); - } - catch (WebSocketException e) - { - Log.d("WebSocket", "Failed to establish a WebSocket connection."); - } + webSocket.connectAsynchronously(); } public void reactNativeEvent(String eventId) { diff --git a/android/app/src/main/java/com/nostros/modules/DatabaseModule.java b/android/app/src/main/java/com/nostros/modules/DatabaseModule.java index ef5e678..666fe7b 100644 --- a/android/app/src/main/java/com/nostros/modules/DatabaseModule.java +++ b/android/app/src/main/java/com/nostros/modules/DatabaseModule.java @@ -80,6 +80,23 @@ public class DatabaseModule { " reacted_event_id TEXT,\n" + " reacted_user_id TEXT\n" + " );"); + try { + database.execSQL("CREATE INDEX nostros_notes_pubkey_index ON nostros_notes(pubkey); "); + database.execSQL("CREATE INDEX nostros_notes_main_event_id_index ON nostros_notes(main_event_id); "); + database.execSQL("CREATE INDEX nostros_notes_reply_event_id_index ON nostros_notes(reply_event_id); "); + database.execSQL("CREATE INDEX nostros_notes_kind_index ON nostros_notes(kind); "); + + database.execSQL("CREATE INDEX nostros_direct_messages_pubkey_index ON nostros_direct_messages(pubkey); "); + database.execSQL("CREATE INDEX nostros_direct_messages_conversation_id_index ON nostros_direct_messages(conversation_id); "); + + database.execSQL("CREATE INDEX nostros_reactions_pubkey_index ON nostros_reactions(pubkey); "); + database.execSQL("CREATE INDEX nostros_reactions_reacted_event_id_index ON nostros_reactions(reacted_event_id); "); + + database.execSQL("CREATE INDEX nostros_users_contact_index ON nostros_users(contact); "); + } catch (SQLException e) { } + try { + database.execSQL("ALTER TABLE nostros_users ADD COLUMN nip05 TEXT;"); + } catch (SQLException e) { } } public void saveEvent(JSONObject data, String userPubKey) throws JSONException { diff --git a/frontend/Components/LnPayment/index.tsx b/frontend/Components/LnPayment/index.tsx index 72a9008..bfb40f2 100644 --- a/frontend/Components/LnPayment/index.tsx +++ b/frontend/Components/LnPayment/index.tsx @@ -17,19 +17,17 @@ interface TextContentProps { export const LnPayment: React.FC = ({ open, setOpen, event, user }) => { const { t } = useTranslation('common') const [monto, setMonto] = useState('') - const [comment, setComment] = useState('') + const defaultComment = event?.id ? `Tip for Nostr event ${event?.id}` : '' + const [comment, setComment] = useState(defaultComment) const [loading, setLoading] = useState(false) useEffect(() => { setMonto('') - setComment('') }, [open]) useEffect(() => { - if (event?.id) { - setComment(`Tip for Nostr event ${event?.id}`) - } - }, [event, user]) + setComment(defaultComment) + }, [event, open]) const styles = StyleSheet.create({ modal: { diff --git a/frontend/Components/NoteCard/index.tsx b/frontend/Components/NoteCard/index.tsx index f10a3d0..7839661 100644 --- a/frontend/Components/NoteCard/index.tsx +++ b/frontend/Components/NoteCard/index.tsx @@ -35,7 +35,7 @@ export const NoteCard: React.FC = ({ onlyContactsReplies = false, }) => { const theme = useTheme() - const { relayPool, publicKey, lastEventId } = useContext(RelayPoolContext) + const { relayPool, publicKey, privateKey, lastEventId } = useContext(RelayPoolContext) const { database, goToPage } = useContext(AppContext) const [relayAdded, setRelayAdded] = useState(false) const [replies, setReplies] = useState([]) @@ -141,7 +141,7 @@ export const NoteCard: React.FC = ({ appearance='ghost' status={userUpvoted ? 'success' : 'primary'} onPress={() => { - if (!userUpvoted) { + if (!userUpvoted && privateKey) { setUserUpvoted(true) setPositiveReactions((prev) => prev + 1) publishReaction(true) @@ -165,7 +165,7 @@ export const NoteCard: React.FC = ({ appearance='ghost' status={userDownvoted ? 'danger' : 'primary'} onPress={() => { - if (!userDownvoted) { + if (!userDownvoted && privateKey) { setUserDownvoted(true) setNegativeReactions((prev) => prev + 1) publishReaction(false) diff --git a/frontend/Pages/ConversationPage/index.tsx b/frontend/Pages/ConversationPage/index.tsx index 5592c9c..5ac861a 100644 --- a/frontend/Pages/ConversationPage/index.tsx +++ b/frontend/Pages/ConversationPage/index.tsx @@ -11,12 +11,11 @@ import { } from '../../Functions/DatabaseFunctions/DirectMessages' import { getUser, User } from '../../Functions/DatabaseFunctions/Users' import Avatar from '../../Components/Avatar' -import { decrypt } from 'nostr-tools/nip04' import Icon from 'react-native-vector-icons/FontAwesome5' import { username, usersToTags } from '../../Functions/RelayFunctions/Users' import moment from 'moment' -import { encrypt } from '../../lib/nostr/Crypto' import TextContent from '../../Components/TextContent' +import { encrypt, decrypt } from '../../lib/nostr/Nip04' export const ConversationPage: React.FC = () => { const theme = useTheme() @@ -96,20 +95,19 @@ export const ConversationPage: React.FC = () => { } setSendingMessages((prev) => [...prev, event as DirectMessage]) setInput('') - encrypt(privateKey, otherPubKey, input).then((content) => { - relayPool?.sendEvent({ - ...event, - content, - }) + const encryptedcontent = encrypt(privateKey, otherPubKey, input) + relayPool?.sendEvent({ + ...event, + content: encryptedcontent, }) } } - const userCard: (message: DirectMessage) => JSX.Element = (message) => { + const userCard: (message: DirectMessage, index: number) => JSX.Element = (message, index) => { if (!publicKey || !privateKey || !otherUser || !user) return <> return message.pubkey === otherPubKey ? ( - + @@ -128,7 +126,7 @@ export const ConversationPage: React.FC = () => { ) : ( - + @@ -236,7 +234,7 @@ export const ConversationPage: React.FC = () => { onContentSizeChange={() => scrollViewRef.current?.scrollToEnd({ animated: true })} horizontal={false} > - {[...directMessages, ...sendingMessages].map((msg) => userCard(msg))} + {[...directMessages, ...sendingMessages].map((msg, index) => userCard(msg, index))} diff --git a/frontend/Pages/DirectMessagesPage/index.tsx b/frontend/Pages/DirectMessagesPage/index.tsx index 81c8e03..7be77c6 100644 --- a/frontend/Pages/DirectMessagesPage/index.tsx +++ b/frontend/Pages/DirectMessagesPage/index.tsx @@ -27,6 +27,7 @@ import Avatar from '../../Components/Avatar' import Icon from 'react-native-vector-icons/FontAwesome5' import { useTranslation } from 'react-i18next' import { username } from '../../Functions/RelayFunctions/Users' +import { getPublicKey } from '../../lib/nostr/Nip19' export const DirectMessagesPage: React.FC = () => { const theme = useTheme() @@ -81,8 +82,9 @@ export const DirectMessagesPage: React.FC = () => { const onPressOpenConversation: (sendPubKey: string) => void = (sendPubKey) => { if (sendPubKey !== '' && publicKey) { - const conversationId = generateConversationId(publicKey, sendPubKey) - const conversationPath = getConversationPath(conversationId, sendPubKey) + const contactPubKey = getPublicKey(sendPubKey) + const conversationId = generateConversationId(publicKey, contactPubKey) + const conversationPath = getConversationPath(conversationId, contactPubKey) goToPage(conversationPath) } } diff --git a/frontend/Pages/HomePage/index.tsx b/frontend/Pages/HomePage/index.tsx index ff3eae4..b622989 100644 --- a/frontend/Pages/HomePage/index.tsx +++ b/frontend/Pages/HomePage/index.tsx @@ -29,6 +29,7 @@ export const HomePage: React.FC = () => { const [notes, setNotes] = useState([]) const [authors, setAuthors] = useState([]) const [refreshing, setRefreshing] = useState(true) + const [firstLoad, setFirstLoad] = useState(true) const calculateInitialNotes: () => Promise = async () => { if (database && publicKey) { @@ -78,12 +79,15 @@ export const HomePage: React.FC = () => { useEffect(() => { relayPool?.unsubscribeAll() if (relayPool && publicKey) { + setFirstLoad(false) calculateInitialNotes().then(() => loadNotes()) } }, [publicKey, relayPool]) useEffect(() => { - loadNotes() + if (!firstLoad) { + loadNotes() + } }, [lastEventId]) useEffect(() => { diff --git a/frontend/Pages/LandingPage/Loader/index.tsx b/frontend/Pages/LandingPage/Loader/index.tsx index 4975154..5889faa 100644 --- a/frontend/Pages/LandingPage/Loader/index.tsx +++ b/frontend/Pages/LandingPage/Loader/index.tsx @@ -7,6 +7,7 @@ import { AppContext } from '../../../Contexts/AppContext' import { getUser, getUsers, User } from '../../../Functions/DatabaseFunctions/Users' import Icon from 'react-native-vector-icons/FontAwesome5' import { useTranslation } from 'react-i18next' +import moment from 'moment' export const Loader: React.FC = () => { const { goToPage, loadingDb, database } = useContext(AppContext) @@ -19,7 +20,7 @@ export const Loader: React.FC = () => { useEffect(() => { if (!loadingRelayPool && !loadingDb && publicKey) { relayPool?.subscribe('main-channel', { - kinds: [EventKind.petNames, EventKind.meta, EventKind.directMessage], + kinds: [EventKind.petNames, EventKind.meta], authors: [publicKey], }) } @@ -34,16 +35,12 @@ export const Loader: React.FC = () => { if (database) { getUsers(database, { contacts: true }).then((results) => { setContactsCount(results.length) - if (publicKey && results && results.length > 0) { + if (publicKey && results && results.length > 1) { const authors = [...results.map((user: User) => user.id), publicKey] relayPool?.subscribe('main-channel', { - kinds: [EventKind.meta], + kinds: [EventKind.meta, EventKind.textNote], authors, - }) - relayPool?.subscribe('main-channel', { - kinds: [EventKind.textNote], - authors, - limit: 50, + since: moment().unix() - 86400, }) } }) diff --git a/frontend/Pages/LandingPage/Logger/index.tsx b/frontend/Pages/LandingPage/Logger/index.tsx index e0dadd2..cc07a7d 100644 --- a/frontend/Pages/LandingPage/Logger/index.tsx +++ b/frontend/Pages/LandingPage/Logger/index.tsx @@ -6,6 +6,7 @@ import { useTranslation } from 'react-i18next' import Icon from 'react-native-vector-icons/FontAwesome5' import { generateRandomKey } from '../../../lib/nostr/Bip' import { showMessage } from 'react-native-flash-message' +import { getNip19Key, isPrivateKey, isPublicKey } from '../../../lib/nostr/Nip19' export const Logger: React.FC = () => { const { publicKey, setPrivateKey, setPublicKey } = useContext(RelayPoolContext) @@ -16,10 +17,17 @@ export const Logger: React.FC = () => { const onPress: () => void = () => { if (inputValue && inputValue !== '') { - if (isPrivate) { - setPrivateKey(inputValue) + const isBenchPrivate = isPrivateKey(inputValue) + const isBenchPublic = isPublicKey(inputValue) + if (isBenchPrivate) setIsPrivate(true) + if (isBenchPublic) setIsPrivate(false) + + const key = getNip19Key(inputValue) + + if ((isPrivate && !isBenchPublic) || isBenchPrivate) { + setPrivateKey(key) } else { - setPublicKey(inputValue) + setPublicKey(key) } } } diff --git a/frontend/Pages/ProfilePage/index.tsx b/frontend/Pages/ProfilePage/index.tsx index 3b79ca6..eccb4aa 100644 --- a/frontend/Pages/ProfilePage/index.tsx +++ b/frontend/Pages/ProfilePage/index.tsx @@ -28,7 +28,7 @@ import LnPayment from '../../Components/LnPayment' export const ProfilePage: React.FC = () => { const { database, page, goToPage, goBack } = useContext(AppContext) - const { publicKey, privateKey, lastEventId, relayPool } = useContext(RelayPoolContext) + const { publicKey, lastEventId, relayPool } = useContext(RelayPoolContext) const theme = useTheme() const initialPageSize = 10 const [notes, setNotes] = useState() @@ -37,13 +37,13 @@ export const ProfilePage: React.FC = () => { const [isContact, setIsContact] = useState() const [refreshing, setRefreshing] = useState(false) const [openPayment, setOpenPayment] = useState(false) + const [firstLoad, setFirstLoad] = useState(true) const breadcrump = page.split('%') const userId = breadcrump[breadcrump.length - 1].split('#')[1] ?? publicKey const username = user?.name === '' ? formatPubKey(user.id) : user?.name useEffect(() => { setRefreshing(true) - relayPool?.unsubscribeAll() setNotes(undefined) setUser(undefined) @@ -51,8 +51,24 @@ export const ProfilePage: React.FC = () => { loadNotes() subscribeProfile() subscribeNotes() + setFirstLoad(false) }, [page]) + useEffect(() => { + if (notes && !firstLoad) { + loadUser() + loadNotes() + } + }, [lastEventId]) + + useEffect(() => { + if (pageSize > initialPageSize && !firstLoad) { + loadUser() + loadNotes() + subscribeNotes(true) + } + }, [pageSize]) + const loadUser: () => void = () => { if (database) { getUser(userId, database).then((result) => { @@ -95,21 +111,6 @@ export const ProfilePage: React.FC = () => { }) } - useEffect(() => { - if (notes) { - loadUser() - loadNotes() - } - }, [lastEventId]) - - useEffect(() => { - if (pageSize > initialPageSize && notes) { - loadUser() - loadNotes() - subscribeNotes(true) - } - }, [pageSize]) - const onRefresh = useCallback(() => { setRefreshing(true) relayPool?.unsubscribeAll() @@ -359,7 +360,7 @@ export const ProfilePage: React.FC = () => { )} - {privateKey && publicKey === userId && ( + {publicKey === userId && ( Promise = async ( - privkey, - pubkey, - text, -) => { - const key = secp256k1.getSharedSecret(privkey, '02' + pubkey) - const normalizedKey = Buffer.from(key.slice(1, 33)).toString('hex') - - const iv = await generateSecureRandom(16) - const cipher = aes.createCipheriv('aes-256-cbc', Buffer.from(normalizedKey, 'hex'), iv) - let encryptedMessage = cipher.update(text, 'utf8', 'base64') - encryptedMessage += cipher.final('base64') - - return `${encryptedMessage}?iv=${Buffer.from(iv.buffer).toString('base64')}` -} diff --git a/frontend/lib/nostr/Nip04/index.ts b/frontend/lib/nostr/Nip04/index.ts new file mode 100644 index 0000000..2a5f860 --- /dev/null +++ b/frontend/lib/nostr/Nip04/index.ts @@ -0,0 +1,37 @@ +import { Buffer } from 'buffer' +import { randomBytes } from '@noble/hashes/utils' +import * as secp256k1 from '@noble/secp256k1' +// @ts-expect-error +import aes from 'browserify-cipher' + +export function encrypt(privkey: string, pubkey: string, text: string): string { + const key = secp256k1.getSharedSecret(privkey, '02' + pubkey) + const normalizedKey = getNormalizedX(key) + + const iv = Uint8Array.from(randomBytes(16)) + const cipher = aes.createCipheriv('aes-256-cbc', Buffer.from(normalizedKey, 'hex'), iv) + let encryptedMessage = cipher.update(text, 'utf8', 'base64') + encryptedMessage += cipher.final('base64') + + return `${encryptedMessage}?iv=${Buffer.from(iv.buffer).toString('base64')}` +} + +export function decrypt(privkey: string, pubkey: string, ciphertext: string): string { + const [cip, iv] = ciphertext.split('?iv=') + const key = secp256k1.getSharedSecret(privkey, '02' + pubkey) + const normalizedKey = getNormalizedX(key) + + const decipher = aes.createDecipheriv( + 'aes-256-cbc', + Buffer.from(normalizedKey, 'hex'), + Buffer.from(iv, 'base64'), + ) + let decryptedMessage = decipher.update(cip, 'base64', 'utf8') + decryptedMessage += decipher.final('utf8') + + return decryptedMessage +} + +function getNormalizedX(key: Uint8Array): string { + return Buffer.from(key.slice(1, 33)).toString('hex') +} diff --git a/frontend/lib/nostr/Nip19/index.ts b/frontend/lib/nostr/Nip19/index.ts new file mode 100644 index 0000000..85b4339 --- /dev/null +++ b/frontend/lib/nostr/Nip19/index.ts @@ -0,0 +1,30 @@ +import { decode, EventPointer, ProfilePointer } from 'nostr-tools/nip19' + +export function getNip19Key(nip19: string): string { + let result = nip19 + + try { + const decoded = decode(result) + if (decoded.type === 'nprofile') { + const data = decoded.data as ProfilePointer + result = data.pubkey + } else if (decoded.type === 'nevent') { + const data = decoded.data as EventPointer + result = data.id + } else { + result = decoded.data as string + } + } catch (e) { + console.log('Error decoding getPublicKey', e) + } + + return result +} + +export function isPrivateKey(nip19: string): boolean { + return /^(nsec1).*/.test(nip19) +} + +export function isPublicKey(nip19: string): boolean { + return /^(npub1|nprofile1).*/.test(nip19) +} diff --git a/package.json b/package.json index 4cb68f0..7b9412d 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "dependencies": { "@eva-design/eva": "^2.1.0", "@flyerhq/react-native-link-preview": "^1.6.0", + "@scure/base": "^1.1.1", "@ui-kitten/components": "5.1.2", "@ui-kitten/eva-icons": "5.1.2", "@ui-kitten/metro-config": "5.1.2", @@ -28,7 +29,7 @@ "lnurl-pay": "^2.1.0", "lodash.debounce": "^4.0.8", "moment": "^2.29.4", - "nostr-tools": "^0.24.1", + "nostr-tools": "^1.1.1", "react": "18.1.0", "react-i18next": "^12.0.0", "react-native": "0.70.6", @@ -48,6 +49,7 @@ "safe-buffer": "^5.2.1", "sqlstring": "^2.3.3", "stream": "^0.0.2", + "text-encoding-polyfill": "^0.6.7", "uuid": "^9.0.0" }, "devDependencies": { diff --git a/yarn.lock b/yarn.lock index dedd207..2691d6b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1381,12 +1381,17 @@ dependencies: eslint-scope "5.1.1" -"@noble/hashes@^0.5.5", "@noble/hashes@^0.5.7": +"@noble/hashes@^0.5.7": version "0.5.9" resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-0.5.9.tgz#9f3051a4cc6f7c168022b3b7fbbe9fe2a35cccf0" integrity sha512-7lN1Qh6d8DUGmfN36XRsbN/WcGIPNtTGhkw26vWId/DlCIGsYJJootTtPGghTLcn/AaXPx2Q0b3cacrwXa7OVw== -"@noble/secp256k1@^1.3.4", "@noble/secp256k1@^1.5.2": +"@noble/hashes@~1.1.1", "@noble/hashes@~1.1.3": + version "1.1.5" + resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.1.5.tgz#1a0377f3b9020efe2fae03290bd2a12140c95c11" + integrity sha512-LTMZiiLc+V4v1Yi16TD6aX2gmtKszNye0pQgbaLqkvhIqP7nVsSaJsWloGQjJfJ8offaoP5GtX3yY5swbcJxxQ== + +"@noble/secp256k1@^1.7.0", "@noble/secp256k1@~1.7.0": version "1.7.0" resolved "https://registry.yarnpkg.com/@noble/secp256k1/-/secp256k1-1.7.0.tgz#d15357f7c227e751d90aa06b05a0e5cf993ba8c1" integrity sha512-kbacwGSsH/CTout0ZnZWxnW1B+jH/7r/WAAKLBtrRJ/+CUH7lgmQzl3GTrQua3SGKWNSDsS6lmjnDpIJ5Dxyaw== @@ -1624,6 +1629,28 @@ resolved "https://registry.yarnpkg.com/@react-native/polyfills/-/polyfills-2.0.0.tgz#4c40b74655c83982c8cf47530ee7dc13d957b6aa" integrity sha512-K0aGNn1TjalKj+65D7ycc1//H9roAQ51GJVk5ZJQFb2teECGmzd86bYDC0aYdbRf7gtovescq4Zt6FR0tgXiHQ== +"@scure/base@^1.1.1", "@scure/base@~1.1.0": + version "1.1.1" + resolved "https://registry.yarnpkg.com/@scure/base/-/base-1.1.1.tgz#ebb651ee52ff84f420097055f4bf46cfba403938" + integrity sha512-ZxOhsSyxYwLJj3pLZCefNitxsj093tb2vq90mp2txoYeBqbcjDjqFhyM8eUjq/uFm6zJ+mUuqxlS2FkuSY1MTA== + +"@scure/bip32@^1.1.1": + version "1.1.1" + resolved "https://registry.yarnpkg.com/@scure/bip32/-/bip32-1.1.1.tgz#f62e4a2f13cc3e5e720ad81b7582b8631ae6835a" + integrity sha512-UmI+liY7np2XakaW+6lMB6HZnpczWk1yXZTxvg8TM8MdOcKHCGL1YkraGj8eAjPfMwFNiAyek2hXmS/XFbab8g== + dependencies: + "@noble/hashes" "~1.1.3" + "@noble/secp256k1" "~1.7.0" + "@scure/base" "~1.1.0" + +"@scure/bip39@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@scure/bip39/-/bip39-1.1.0.tgz#92f11d095bae025f166bef3defcc5bf4945d419a" + integrity sha512-pwrPOS16VeTKg98dYXQyIjJEcWfz7/1YJIwxUEPFfQPtc86Ym/1sVgQ2RLoD43AazMk2l/unK4ITySSpW2+82w== + dependencies: + "@noble/hashes" "~1.1.1" + "@scure/base" "~1.1.0" + "@sideway/address@^4.1.3": version "4.1.4" resolved "https://registry.yarnpkg.com/@sideway/address/-/address-4.1.4.tgz#03dccebc6ea47fdc226f7d3d1ad512955d4783f0" @@ -2670,7 +2697,7 @@ browserify-aes@^1.0.0, browserify-aes@^1.0.4: inherits "^2.0.1" safe-buffer "^5.0.1" -browserify-cipher@>=1, browserify-cipher@^1.0.0: +browserify-cipher@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/browserify-cipher/-/browserify-cipher-1.0.1.tgz#8d6474c1b870bfdabcd3bcfcc1934a10e94f15f0" integrity sha512-sPhkz0ARKbf4rRQt2hTpAHqn47X3llLkUGn+xEJzLjwY8LRs2p0v7ljvI5EyoRO/mexrNunNECisZs+gw2zz1w== @@ -2762,14 +2789,6 @@ buffer-xor@^1.0.3: resolved "https://registry.yarnpkg.com/buffer-xor/-/buffer-xor-1.0.3.tgz#26e61ed1422fb70dd42e6e36729ed51d855fe8d9" integrity sha512-571s0T7nZWK6vB67HI5dyUF7wXiNcfaPPPTl6zYCNApANjIvYJTg7hlud/+cJpdAhS7dVzqMLmfhfHR3rAcOjQ== -buffer@>=5, buffer@^6.0.3: - version "6.0.3" - resolved "https://registry.yarnpkg.com/buffer/-/buffer-6.0.3.tgz#2ace578459cc8fbe2a70aaa8f52ee63b6a74c6c6" - integrity sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA== - dependencies: - base64-js "^1.3.1" - ieee754 "^1.2.1" - buffer@^5.5.0: version "5.7.1" resolved "https://registry.yarnpkg.com/buffer/-/buffer-5.7.1.tgz#ba62e7c13133053582197160851a8f648e99eed0" @@ -2778,12 +2797,13 @@ buffer@^5.5.0: base64-js "^1.3.1" ieee754 "^1.1.13" -bufferutil@^4.0.1: - version "4.0.7" - resolved "https://registry.yarnpkg.com/bufferutil/-/bufferutil-4.0.7.tgz#60c0d19ba2c992dd8273d3f73772ffc894c153ad" - integrity sha512-kukuqc39WOHtdxtw4UScxF/WVnMFVSQVKhtx3AjZJzhd0RGZZldcrfSEbVsWWe6KNH253574cq5F+wpv0G9pJw== +buffer@^6.0.3: + version "6.0.3" + resolved "https://registry.yarnpkg.com/buffer/-/buffer-6.0.3.tgz#2ace578459cc8fbe2a70aaa8f52ee63b6a74c6c6" + integrity sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA== dependencies: - node-gyp-build "^4.3.0" + base64-js "^1.3.1" + ieee754 "^1.2.1" builtin-status-codes@^3.0.0: version "3.0.0" @@ -3153,13 +3173,6 @@ create-hmac@^1.1.0, create-hmac@^1.1.4, create-hmac@^1.1.7: safe-buffer "^5.0.1" sha.js "^2.4.8" -cross-fetch@^3.1.4: - version "3.1.5" - resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-3.1.5.tgz#e1389f44d9e7ba767907f7af8454787952ab534f" - integrity sha512-lvb1SBsI0Z7GDwmuid+mU3kWVBwTVUbe7S0H52yaaAdQOXq2YktTCZdlAcNKFzE6QtRz0snpw9bNiPeOIkkQvw== - dependencies: - node-fetch "2.6.7" - cross-spawn@^6.0.0: version "6.0.5" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4" @@ -3231,14 +3244,6 @@ csstype@^3.0.2: resolved "https://registry.yarnpkg.com/csstype/-/csstype-3.1.1.tgz#841b532c45c758ee546a11d5bd7b7b473c8c30b9" integrity sha512-DJR/VvkAvSZW9bTouZue2sSxDwdTN92uHjqeKVm+0dAqdfNykRzQ95tay8aXMBAAPpUiq4Qcug2L7neoRh2Egw== -d@1, d@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/d/-/d-1.0.1.tgz#8698095372d58dbee346ffd0c7093f99f8f9eb5a" - integrity sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA== - dependencies: - es5-ext "^0.10.50" - type "^1.0.1" - dayjs@^1.8.15: version "1.11.6" resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.11.6.tgz#2e79a226314ec3ec904e3ee1dd5a4f5e5b1c7afb" @@ -3615,37 +3620,11 @@ es-to-primitive@^1.2.1: is-date-object "^1.0.1" is-symbol "^1.0.2" -es5-ext@^0.10.35, es5-ext@^0.10.50: - version "0.10.62" - resolved "https://registry.yarnpkg.com/es5-ext/-/es5-ext-0.10.62.tgz#5e6adc19a6da524bf3d1e02bbc8960e5eb49a9a5" - integrity sha512-BHLqn0klhEpnOKSrzn/Xsz2UIW8j+cGmo9JLzr8BiUapV8hPL9+FliFqjwr9ngW7jWdnxv6eO+/LqyhJVqgrjA== - dependencies: - es6-iterator "^2.0.3" - es6-symbol "^3.1.3" - next-tick "^1.1.0" - -es6-iterator@^2.0.3: - version "2.0.3" - resolved "https://registry.yarnpkg.com/es6-iterator/-/es6-iterator-2.0.3.tgz#a7de889141a05a94b0854403b2d0a0fbfa98f3b7" - integrity sha512-zw4SRzoUkd+cl+ZoE15A9o1oQd920Bb0iOJMQkQhl3jNc03YqVjAhG7scf9C5KWRU/R13Orf588uCC6525o02g== - dependencies: - d "1" - es5-ext "^0.10.35" - es6-symbol "^3.1.1" - es6-object-assign@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/es6-object-assign/-/es6-object-assign-1.1.0.tgz#c2c3582656247c39ea107cb1e6652b6f9f24523c" integrity sha512-MEl9uirslVwqQU369iHNWZXsI8yaZYGg/D65aOgZkeyFJwHYSxilf7rQzXKI7DdDuBPrBXbfk3sl9hJhmd5AUw== -es6-symbol@^3.1.1, es6-symbol@^3.1.3: - version "3.1.3" - resolved "https://registry.yarnpkg.com/es6-symbol/-/es6-symbol-3.1.3.tgz#bad5d3c1bcdac28269f4cb331e431c78ac705d18" - integrity sha512-NJ6Yn3FuDinBaBRWl/q5X/s4koRHBrgKAu+yGI6JCBeiu3qrcbJhwT2GeR/EXVfylRk8dpQVJoLEFhK+Mu31NA== - dependencies: - d "^1.0.1" - ext "^1.1.2" - escalade@^3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40" @@ -4084,13 +4063,6 @@ expect@^29.3.1: jest-message-util "^29.3.1" jest-util "^29.3.1" -ext@^1.1.2: - version "1.7.0" - resolved "https://registry.yarnpkg.com/ext/-/ext-1.7.0.tgz#0ea4383c0103d60e70be99e9a7f11027a33c4f5f" - integrity sha512-6hxeJYaL110a9b5TEJSj0gojyHQAmA2ch5Os+ySCiA1QGdS697XWY1pzsrSjqA9LDEEgdB/KypIlR59RcLuHYw== - dependencies: - type "^2.7.2" - extend-shallow@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/extend-shallow/-/extend-shallow-2.0.1.tgz#51af7d614ad9a9f610ea1bafbb989d6b1c56890f" @@ -4990,11 +4962,6 @@ is-typed-array@^1.1.3, is-typed-array@^1.1.9: for-each "^0.3.3" has-tostringtag "^1.0.0" -is-typedarray@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" - integrity sha512-cyA56iCMHAh5CdzjJIa4aohJyeO1YbwLi3Jc35MmRU6poroFjIGZzUzupGiRPOjgHg9TLu43xbpwXk523fMxKA== - is-unicode-supported@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz#3f26c76a809593b52bfa2ecb5710ed2779b522a7" @@ -6224,28 +6191,6 @@ metro@0.72.3: ws "^7.5.1" yargs "^15.3.1" -micro-base@^0.10.1: - version "0.10.2" - resolved "https://registry.yarnpkg.com/micro-base/-/micro-base-0.10.2.tgz#f6f9f0bd949ce511883e5a99f9147d80ddc32f5a" - integrity sha512-lqqJrT7lfJtDmmiQ4zRLZuIJBk96t0RAc5pCrrWpL9zDeH5i/SUL85mku9HqzTI/OCZ8EQ3aicbMW+eK5Nyu5w== - -micro-bip32@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/micro-bip32/-/micro-bip32-0.1.0.tgz#ca51b80eddf9e5afee5da41a2c93ba679297e84b" - integrity sha512-HxwYJzokbObqPHUqQuzRpCEqZ3EE4uHKrGlLX5ylt0ktD6m9LeS3RkWuQ1HApXEgrGMs3XgykN5Bic2YHE0f6Q== - dependencies: - "@noble/hashes" "^0.5.7" - "@noble/secp256k1" "^1.3.4" - micro-base "^0.10.1" - -micro-bip39@^0.1.3: - version "0.1.3" - resolved "https://registry.yarnpkg.com/micro-bip39/-/micro-bip39-0.1.3.tgz#f0866912da588fc97e27b7315cdd484c0b43186c" - integrity sha512-lEaRG/MKxFQvG19lfJfPkLIG0rgT28nWud3otN+VgAbrozGqXn2PLaZuYPsy9guQjIZWBTvoLw/HDJQxmMXjMA== - dependencies: - "@noble/hashes" "^0.5.5" - micro-base "^0.10.1" - micromatch@^3.1.10: version "3.1.10" resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-3.1.10.tgz#70859bc95c9840952f359a068a3fc49f9ecfac23" @@ -6402,11 +6347,6 @@ neo-async@^2.5.0: resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.6.2.tgz#b4aafb93e3aeb2d8174ca53cf163ab7d7308305f" integrity sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw== -next-tick@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/next-tick/-/next-tick-1.1.0.tgz#1836ee30ad56d67ef281b22bd199f709449b35eb" - integrity sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ== - nice-try@^1.0.4: version "1.0.5" resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366" @@ -6429,14 +6369,14 @@ node-dir@^0.1.17: dependencies: minimatch "^3.0.2" -node-fetch@2.6.7, node-fetch@^2.2.0, node-fetch@^2.6.0: +node-fetch@^2.2.0, node-fetch@^2.6.0: version "2.6.7" resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad" integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ== dependencies: whatwg-url "^5.0.0" -node-gyp-build@^4.2.0, node-gyp-build@^4.3.0: +node-gyp-build@^4.2.0: version "4.5.0" resolved "https://registry.yarnpkg.com/node-gyp-build/-/node-gyp-build-4.5.0.tgz#7a64eefa0b21112f89f58379da128ac177f20e40" integrity sha512-2iGbaQBV+ITgCz76ZEjmhUKAKVf7xfY1sRl4UiKQspfZMH2h06SyhNsnSVy50cwkFQDGLyif6m/6uFXHkOZ6rg== @@ -6461,20 +6401,16 @@ normalize-path@^3.0.0: resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== -nostr-tools@^0.24.1: - version "0.24.1" - resolved "https://registry.yarnpkg.com/nostr-tools/-/nostr-tools-0.24.1.tgz#99f73c2ea58bb3a0e964485120f497180522fa9a" - integrity sha512-+aUWblwNTYra8ZsjmfzxStr4XSKAb0gPsehNP3oBiSouLevqD3FWngc++kh8l+zfMYEPPGS6kS0i9iaq/5ZF6A== +nostr-tools@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/nostr-tools/-/nostr-tools-1.1.1.tgz#2be4cd650bc0a4d20650b6cf46fee451c9f565b8" + integrity sha512-mxgjbHR6nx2ACBNa2tBpeM/glsPWqxHPT1Kszx/XfzL+kUdi1Gm3Xz1UcaODQ2F84IFtCKNLO+aF31ZfTAhSYQ== dependencies: "@noble/hashes" "^0.5.7" - "@noble/secp256k1" "^1.5.2" - browserify-cipher ">=1" - buffer ">=5" - create-hash "^1.2.0" - cross-fetch "^3.1.4" - micro-bip32 "^0.1.0" - micro-bip39 "^0.1.3" - websocket-polyfill "^0.0.3" + "@noble/secp256k1" "^1.7.0" + "@scure/base" "^1.1.1" + "@scure/bip32" "^1.1.1" + "@scure/bip39" "^1.1.0" npm-run-path@^2.0.0: version "2.0.2" @@ -8067,6 +8003,11 @@ test-exclude@^6.0.0: glob "^7.1.4" minimatch "^3.0.4" +text-encoding-polyfill@^0.6.7: + version "0.6.7" + resolved "https://registry.yarnpkg.com/text-encoding-polyfill/-/text-encoding-polyfill-0.6.7.tgz#4d27de0153e4c86eb2631ffd74c2f3f57969a9ec" + integrity sha512-/DZ1XJqhbqRkCop6s9ZFu8JrFRwmVuHg4quIRm+ziFkR3N3ec6ck6yBvJ1GYeEQZhLVwRW0rZE+C3SSJpy0RTg== + text-table@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" @@ -8170,11 +8111,6 @@ tslib@^2.3.1, tslib@^2.4.1: resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.4.1.tgz#0d0bfbaac2880b91e22df0768e55be9753a5b17e" integrity sha512-tGyy4dAjRIEwI7BzsB0lynWgOpfqjUdq91XXAlIWD2OwKBH7oCl/GZG/HT4BOHrTlPMOASlMQ7veyTqpmRcrNA== -tstl@^2.0.7: - version "2.5.13" - resolved "https://registry.yarnpkg.com/tstl/-/tstl-2.5.13.tgz#a5a5d27b79a12767e46a08525b3e045c5cdb1180" - integrity sha512-h9wayHHFI5+yqt8iau0vqH96cTNhezhZ/Fk/hrIdpfkiMu3lg9nzyvMfs5bIdX51IVzZO6DudLqhkL/rVXpT6g== - tsutils@^3.21.0: version "3.21.0" resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.21.0.tgz#b48717d394cea6c1e096983eed58e9d61715b623" @@ -8209,23 +8145,6 @@ type-fest@^0.7.1: resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.7.1.tgz#8dda65feaf03ed78f0a3f9678f1869147f7c5c48" integrity sha512-Ne2YiiGN8bmrmJJEuTWTLJR32nh/JdL1+PSicowtNb0WFpn59GK8/lfD61bVtzguz7b3PBt74nxpv/Pw5po5Rg== -type@^1.0.1: - version "1.2.0" - resolved "https://registry.yarnpkg.com/type/-/type-1.2.0.tgz#848dd7698dafa3e54a6c479e759c4bc3f18847a0" - integrity sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg== - -type@^2.7.2: - version "2.7.2" - resolved "https://registry.yarnpkg.com/type/-/type-2.7.2.tgz#2376a15a3a28b1efa0f5350dcf72d24df6ef98d0" - integrity sha512-dzlvlNlt6AXU7EBSfpAscydQ7gXB+pPGsPnfJnZpiNJBDj7IaJzQlBZYGdEi4R9HmPdBv2XmWJ6YUtoTa7lmCw== - -typedarray-to-buffer@^3.1.5: - version "3.1.5" - resolved "https://registry.yarnpkg.com/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz#a97ee7a9ff42691b9f783ff1bc5112fe3fca9080" - integrity sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q== - dependencies: - is-typedarray "^1.0.0" - typeforce@^1.11.3: version "1.18.0" resolved "https://registry.yarnpkg.com/typeforce/-/typeforce-1.18.0.tgz#d7416a2c5845e085034d70fcc5b6cc4a90edbfdc" @@ -8343,13 +8262,6 @@ use@^3.1.0: resolved "https://registry.yarnpkg.com/use/-/use-3.1.1.tgz#d50c8cac79a19fbc20f2911f56eb973f4e10070f" integrity sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ== -utf-8-validate@^5.0.2: - version "5.0.10" - resolved "https://registry.yarnpkg.com/utf-8-validate/-/utf-8-validate-5.0.10.tgz#d7d10ea39318171ca982718b6b96a8d2442571a2" - integrity sha512-Z6czzLq4u8fPOyx7TU6X3dvUZVvoJmxSQ+IcrlmagKhilxlhZgxPK6C5Jqbkw1IDUmFTM+cz9QDnnLTwDz/2gQ== - dependencies: - node-gyp-build "^4.3.0" - util-deprecate@^1.0.1, util-deprecate@~1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" @@ -8426,26 +8338,6 @@ webidl-conversions@^3.0.0: resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871" integrity sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ== -websocket-polyfill@^0.0.3: - version "0.0.3" - resolved "https://registry.yarnpkg.com/websocket-polyfill/-/websocket-polyfill-0.0.3.tgz#7321ada0f5f17516290ba1cb587ac111b74ce6a5" - integrity sha512-pF3kR8Uaoau78MpUmFfzbIRxXj9PeQrCuPepGE6JIsfsJ/o/iXr07Q2iQNzKSSblQJ0FiGWlS64N4pVSm+O3Dg== - dependencies: - tstl "^2.0.7" - websocket "^1.0.28" - -websocket@^1.0.28: - version "1.0.34" - resolved "https://registry.yarnpkg.com/websocket/-/websocket-1.0.34.tgz#2bdc2602c08bf2c82253b730655c0ef7dcab3111" - integrity sha512-PRDso2sGwF6kM75QykIesBijKSVceR6jL2G8NGYyq2XrItNC2P5/qL5XeR056GhA+Ly7JMFvJb9I312mJfmqnQ== - dependencies: - bufferutil "^4.0.1" - debug "^2.2.0" - es5-ext "^0.10.50" - typedarray-to-buffer "^3.1.5" - utf-8-validate "^5.0.2" - yaeti "^0.0.6" - whatwg-fetch@^3.0.0: version "3.6.2" resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-3.6.2.tgz#dced24f37f2624ed0281725d51d0e2e3fe677f8c" @@ -8580,11 +8472,6 @@ y18n@^5.0.5: resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55" integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA== -yaeti@^0.0.6: - version "0.0.6" - resolved "https://registry.yarnpkg.com/yaeti/-/yaeti-0.0.6.tgz#f26f484d72684cf42bedfb76970aa1608fbf9577" - integrity sha512-MvQa//+KcZCUkBTIC9blM+CU9J2GzuTytsOUwf2lidtvkx/6gnEp1QvJv34t9vdjhFmha/mUiNDbN0D0mJWdug== - yallist@^3.0.2: version "3.1.1" resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.1.1.tgz#dbb7daf9bfd8bac9ab45ebf602b8cbad0d5d08fd" From ee80142a177064f886763037cf36e27c5c700820 Mon Sep 17 00:00:00 2001 From: KoalaSat Date: Sun, 8 Jan 2023 20:42:52 +0100 Subject: [PATCH 2/3] Change logic --- frontend/Pages/LandingPage/Loader/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/Pages/LandingPage/Loader/index.tsx b/frontend/Pages/LandingPage/Loader/index.tsx index 5889faa..4e7ee78 100644 --- a/frontend/Pages/LandingPage/Loader/index.tsx +++ b/frontend/Pages/LandingPage/Loader/index.tsx @@ -35,7 +35,7 @@ export const Loader: React.FC = () => { if (database) { getUsers(database, { contacts: true }).then((results) => { setContactsCount(results.length) - if (publicKey && results && results.length > 1) { + if (publicKey && results && results.length > 0) { const authors = [...results.map((user: User) => user.id), publicKey] relayPool?.subscribe('main-channel', { kinds: [EventKind.meta, EventKind.textNote], From 2813dff4e2132d9d6255e4f3af557622bf7aac2f Mon Sep 17 00:00:00 2001 From: KoalaSat Date: Sun, 8 Jan 2023 20:59:58 +0100 Subject: [PATCH 3/3] NIP in profile --- .../app/src/main/java/com/nostros/classes/Event.java | 1 + frontend/Functions/DatabaseFunctions/Users/index.ts | 1 + frontend/Locales/en.json | 1 + frontend/Locales/es.json | 1 + frontend/Locales/ru.json | 1 + frontend/Pages/ConfigPage/index.tsx | 11 +++++++++++ frontend/Pages/HomePage/index.tsx | 4 ++++ 7 files changed, 20 insertions(+) diff --git a/android/app/src/main/java/com/nostros/classes/Event.java b/android/app/src/main/java/com/nostros/classes/Event.java index 2a15a4d..db33924 100644 --- a/android/app/src/main/java/com/nostros/classes/Event.java +++ b/android/app/src/main/java/com/nostros/classes/Event.java @@ -211,6 +211,7 @@ public class Event { values.put("picture", userContent.optString("picture")); values.put("about", userContent.optString("about")); values.put("lnurl", userContent.optString("lud06")); + values.put("nip05", userContent.optString("nip05")); values.put("main_relay", userContent.optString("main_relay")); values.put("created_at", created_at); if (cursor.getCount() == 0) { diff --git a/frontend/Functions/DatabaseFunctions/Users/index.ts b/frontend/Functions/DatabaseFunctions/Users/index.ts index d3de4ce..055dea0 100644 --- a/frontend/Functions/DatabaseFunctions/Users/index.ts +++ b/frontend/Functions/DatabaseFunctions/Users/index.ts @@ -10,6 +10,7 @@ export interface User { contact?: boolean follower?: boolean lnurl?: string + nip05?: string } const databaseToEntity: (object: object) => User = (object) => { diff --git a/frontend/Locales/en.json b/frontend/Locales/en.json index 3594c88..6cbef0b 100644 --- a/frontend/Locales/en.json +++ b/frontend/Locales/en.json @@ -66,6 +66,7 @@ "username": "Username", "picture": "Picture URL", "lnurl": "LNURL / Lightning address", + "nip05": "NIP05", "about": "About", "publish": "Publish" }, diff --git a/frontend/Locales/es.json b/frontend/Locales/es.json index 88fa647..3c8832b 100644 --- a/frontend/Locales/es.json +++ b/frontend/Locales/es.json @@ -66,6 +66,7 @@ "username": "Nombre", "picture": "URL de imagen", "lnurl": "LNURL / Lightning address", + "nip05": "NIP05", "about": "Descripción", "publish": "Publicar" }, diff --git a/frontend/Locales/ru.json b/frontend/Locales/ru.json index aae3a37..1294aee 100644 --- a/frontend/Locales/ru.json +++ b/frontend/Locales/ru.json @@ -66,6 +66,7 @@ "username": "Имя", "picture": "URL изображения", "lnurl": "LNURL / Lightning address", + "nip05": "NIP05", "about": "Описание", "publish": "Опубликовать" }, diff --git a/frontend/Pages/ConfigPage/index.tsx b/frontend/Pages/ConfigPage/index.tsx index 437bb2d..18be913 100644 --- a/frontend/Pages/ConfigPage/index.tsx +++ b/frontend/Pages/ConfigPage/index.tsx @@ -21,6 +21,7 @@ export const ConfigPage: React.FC = () => { const [picture, setPicture] = useState() const [about, setAbout] = useState() const [lnurl, setLnurl] = useState() + const [nip05, setNip05] = useState() const { t } = useTranslation('common') useEffect(() => { @@ -32,6 +33,7 @@ export const ConfigPage: React.FC = () => { setPicture(user.picture) setAbout(user.about) setLnurl(user.lnurl) + setNip05(user.nip05) } }) } @@ -67,6 +69,7 @@ export const ConfigPage: React.FC = () => { about, picture, lud06: lnurl, + nip05, }), created_at: moment().unix(), kind: EventKind.meta, @@ -161,6 +164,14 @@ export const ConfigPage: React.FC = () => { label={t('configPage.lnurl')} /> + + + { const calculateInitialNotes: () => Promise = async () => { if (database && publicKey) { + relayPool?.subscribe('main-channel', { + kinds: [EventKind.petNames], + authors: [publicKey], + }) const users = await getUsers(database, { contacts: true, includeIds: [publicKey] }) subscribeNotes(users) setAuthors(users)