From 600959d5f6929f6cb9ad077c6dead8db3f19b9c5 Mon Sep 17 00:00:00 2001 From: J the Code Monkey Date: Wed, 8 Jan 2025 13:04:23 -0500 Subject: [PATCH] Nip 55 (#1) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * delete events from cache * Add delete to eventcarddropdownmenu * URL normalization * Support blocked relays * format * Minor debugging changes * Emit from pool when connecting * Foramt * Debugging * Refactor OutboxTracker to handle tracking users in batches * Refactor follows function to use fetchEvent instead of fetchEvents * format * Fetch relay lists for users from 10002 and 3 in parallel * Make outbox calculation great again * move md files * use r tags because "lets index absolutely everything just in case" * correct import * add utxo's notepress reference * picture before image (#178) * Move event validation and signature verification in-house (#200) * Aggregate, cache, deduplicate NIP-05 queries and Zap settings queries -- Massive performance improvement! * improve markdown rendering * Cache NIP-05 and zap specs * format, fix tests, generate docs, version bump * fix bad release * NIP46: Fixed wrong parsing of rpc response when requesting decryption from bunker (#202) - The JSON.parse() call resulted in exception being thrown since 'response.result' is not a valid JSON string * Remove hexpubkey references everywhere (#199) * Remove hexpubkey references everywhere * Add one last one * Improve hashtag regex (#201) * Improve hashtag regex - Match all non space and punctuation characters - Require a space character before regex to avoid matching URL fragments, see https://github.com/verbiricha/habla.news/issues/163 * fix: match string start or space before hashtag * remove console.logs * Add LRU cache for zappers * unused import (#205) this unused import appears to be causing a problem in some weird edge case situation * add created_at to NDKUserProfile (#204) fix ts errors by type hints * fix url conversion issue * threading utility functions * increase LRU cache size of outbox tracker * improve LRU caches * Remove duplicate method calls (#212) * Remove duplicate method calls * force a new timestamp for replaceable events --------- Co-authored-by: Pablo Fernandez * Update package manager and add engines (#211) * Update nostr-tools on ndk-cache-dexie and fix types (#209) * Squashed commit of the following: commit cf6d33e6f488d2252ee939af5ca193cc0ffcfc35 Author: Jeff Gardner <202880+erskingardner@users.noreply.github.com> Date: Tue Apr 9 15:20:53 2024 +0200 Update nostr-tools on ndk-svelte-components - remove unused files * Squashed commit of the following: commit 09a56a0a6ab5aadc49fad39a40fd41d7662861bd Author: Pablo Fernandez Date: Wed Apr 10 10:29:00 2024 +0100 merge master commit 8054b64c8909bb1ba75857066ce7e47d57290295 Author: Jeff Gardner <202880+erskingardner@users.noreply.github.com> Date: Tue Apr 9 16:16:50 2024 +0200 Update nostr-tools and others for cache-redis * update pnpm-lock * avoid verifying signatures of cached events * allow offloading signature verification to an async web worker * fix bug where we are REQing events even if they were cached and the filter has completed * fix unfollow function * handle more reply cases * correct timestamp of bad events * better event content rendering and mentions * cache events on an LRU too * fix nip46 login with nip05 (#214) * fix nip46 login with nip05 * nip46: fix rpc to use nip05 user defined relays * nip46 fixes on create_account * fix event fetching from tag when there is no relay hint * Incease performance of signature verification * Adds a small LRU cache to prevent re-verifying the same event multiple times * Skips signature verification of duplicated events * Strips one unnecessary hashing that was still not being done on the web worker * fix incorrect tagging when quoting an event * allow clicking on mentions * keep event tags in LRU cache too * fix broken subscription unref * attempt to load 10002 from cache first * optimize serialization and avoid grouping subscriptions that will not close with those that do * allow forcing a tag (for q tagging) * truncate npub by default * lay groundwork for ratioed signature validation * prioritize already-connected relays * fix race condition when using synchronous cache * improve outbox tracking * bump * fix for when using a pubkey with a secret * get all profiles that match a filter function from a cache * support deprecated replies * bump * allow passing-in sanitizeHtml options * Track events per relay when already seen (#218) * allow scheduling more than one event * better support for empty d tag * small thread handling improvements * allow changing which component is used to render embedded components * naive changes to how events are interpreted for signature * fix build * readd createFeedback * improve logic to avoid avoid duplicated relays * format & bump * if reconnecting to a relay whose reconnection was delayed, don't reattempt immediately * lower case normalize * export normalize * Update nostr-tools on NDK & fix tests (#210) * Update nostr-tools on NDK & fix tests * Remove unused jest config * Make NDKPrivateKeySigner backwards compatible * Bind function call to relay object * Update svelte-time to fix warning about svelte export missing * Add more tests on connectivity * minor adjustments to make it work * fix some tests * add convenience method to update replaceable event id,sig,created_at when publishing * add optimistic updates * bump * render wiki entries as markdown * wip * Adds `devcontainer` (#170) * draft: added first version of devcontainer * customize devcontainer with bash --------- Co-authored-by: JeffG <202880+erskingardner@users.noreply.github.com> * feat: store profile event in NDKUserProfile (#229) * feat: store profile event in NDKUserProfile * refactor: make store profile event optional * correct unfollow method logic and event tagging (#230) - Fixed user removal logic to set the foundUser flag correctly - Updated event tagging to use newUserFollowList - Ensured consistent parameter typing for currentFollowList as Set * reduce debugging * fixes NIP-42 * allow passing in subscription options for root/reply fetchers * improve how EOSE is handled on NDK-svelte * control that we don't unnecessarily load more stuff into the LRU beyond it's max size * remove unused call * bump * fix bug that was causing groupable subscriptions not to be cleared properly * fix issue with failing to send over a closed connection * fix: only count missing EOSE from connected relays * add methods to access and manage unpublished events from the cache * extract code to set active user and make fetching theri data more efficient * formatting noop * fix: close subscription on EOSE at the relay level * be more efficient at fetching uses' relay lists * remove unused code * add tests to ndk-cache-dexie * move docs * move docs * change base * update tests * typedoc * typedoc * wip * improve typedoc * lint * api link * subscription management * optimize which relays are set on zap requests * chore: Add onEvent callback to NDKSvelte subscription options * chore: Add event ID to unpublished event in NDKCacheAdapterDexie * fix NIP-42 authentication * improve url normalization and be more careful on connection management * fix auth.md to renamed NDKAuthPolicies -> NDKRelayAuthPolicies (#243) Co-authored-by: jeremyd * NDK Nostr Cache Adapter * refactor outbox and be smarter abotu the relays we publish to (account for p-tags and relay hints) * add BUILD.md (closes: #244) * 30818 component powered by svelte-asciidoc. (#247) * filterForEventsTaggingId * index event kinds and add byKinds filter * pnpm-lock * ignoreDeadLinks * ignoreDeadLinks * apply limit filter * Squashed commit of the following: commit 3ab09895c5950fcd5f1f6b5245fd36f066663906 Author: Pablo Fernandez Date: Fri Aug 2 13:34:22 2024 +0100 handle events coming in with the same created_at and different IDs commit 08b3a2e07f9b5c16e36f9e4883406d0b8350dac7 Author: Pablo Fernandez Date: Fri Aug 2 13:33:24 2024 +0100 emit insufficient balance commit b85cbae245852cde72bb532c7dbfa28049213d36 Author: Pablo Fernandez Date: Fri Aug 2 11:57:40 2024 +0100 handle the same event being incorrectly being published multiple times before it finishes publishing commit ab187ba7dbe5dd5ba6267e455ded7b4c79683696 Author: Pablo Fernandez Date: Thu Aug 1 16:33:34 2024 +0100 wrap string in error commit 9fb7f50ac58abf1fe6f1584778275d0484351fcc Author: Pablo Fernandez Date: Thu Aug 1 15:57:10 2024 +0100 fix LN payments commit b47e829af529addccb37657dcd0feda26a56b9e3 Author: Pablo Fernandez Date: Thu Aug 1 15:56:22 2024 +0100 Accept from that return undefined commit 81784d538a5ef50ce0699d8f79382cc5b63864d8 Author: Pablo Fernandez Date: Thu Aug 1 14:07:14 2024 +0100 improve nutzaps commit a013d285ebefe4f8a6078697ecf3ce4a08de4a97 Author: Pablo Fernandez Date: Wed Jul 31 22:55:28 2024 +0100 rename meta-data because its bet-ter commit 942afe9982e8a78603b1de45f9f3afeda2ab20b2 Author: Pablo Fernandez Date: Wed Jul 31 22:54:09 2024 +0100 debug commit dbf0e79cbda4fd60c376d1c039f301b5a502759b Author: Pablo Fernandez Date: Wed Jul 31 22:50:42 2024 +0100 be explicit about the timeout commit c8d9fc8c08ea6db144d48c7e665d432d356c8540 Author: Pablo Fernandez Date: Wed Jul 31 22:50:31 2024 +0100 fix order of getting reference tags so we don't add markers to h tags commit d3cfdb08d2b1f276aad8bdaf9e8dde47080a8e4f Author: Pablo Fernandez Date: Wed Jul 31 22:47:36 2024 +0100 refactor NDKCashuWallet a bit to be more explicit on what tags are private or public commit 5217f01509ec39f0b334006af06cd93cb3b75976 Author: Pablo Fernandez Date: Wed Jul 31 22:47:11 2024 +0100 remove dead code commit f233ad8753c86ba0922ef7f2019b14f62e6e68d7 Author: Pablo Fernandez Date: Wed Jul 31 22:46:55 2024 +0100 fetch main user's relay lists in order to get a better clue of where the user's wallets are commit 341a6fda909fa225bccb0dad50f084fb903d61d9 Author: Pablo Fernandez Date: Wed Jul 31 22:46:26 2024 +0100 Read events' onRelays from the subscription manager, this will give a better idea of where events exists commit 701d5466fef10aed90556005468162d2bb883ebd Author: Pablo Fernandez Date: Wed Jul 31 20:28:00 2024 +0100 normalize relay urls to connect to explicit relays commit 68f4a602b564774541ded786fbb8a9db390dbc4d Author: Pablo Fernandez Date: Wed Jul 31 14:09:34 2024 +0100 delete unused file commit f1e5624d7a4f51f81787c2cd7fd580bf28e39034 Author: Pablo Fernandez Date: Wed Jul 31 11:12:26 2024 +0100 Add documentation on subscription lifecycle commit 79d2333cc77567f34e9e208e6b7667ac56a56f92 Author: Pablo Fernandez Date: Wed Jul 31 10:12:40 2024 +0100 lint commit 1a181a48c0af5a4822e3c2a3201f7dfb37e82c5d Author: Pablo Fernandez Date: Wed Jul 31 10:12:05 2024 +0100 format commit 7fe4ca2509073b6480b7f41ed82d2de788c70b78 Author: Pablo Fernandez Date: Wed Jul 31 10:05:29 2024 +0100 changeset commit 8aae14522c81b8e1df9487977ec87e1375bbb2ac Author: Pablo Fernandez Date: Wed Jul 31 10:03:23 2024 +0100 Massive refactor of how subscriptions are fingerprinted, grouped, ungrouped and their internal lifecycle commit 2dd41ecd63363e1b42a1d11545f765456623ea22 Author: Pablo Fernandez Date: Wed Jul 31 09:53:42 2024 +0100 correct NDKSubscriptionTier kind commit 2286630354c197834a56d1ec1e1e7132220d6f27 Author: Pablo Fernandez Date: Wed Jul 31 09:50:06 2024 +0100 inherit relay auth policy commit 21a4ac661b6dc79bc1f2a21e35e65bac67cc3244 Author: Pablo Fernandez Date: Wed Jul 31 09:45:08 2024 +0100 add ndk reference to relays commit 69cc6f9816dbb34e1263ae7df417a41793facc12 Author: Pablo Fernandez Date: Wed Jul 31 09:44:21 2024 +0100 k-tag deletions commit 26e2da921b14dbf082ca3fb3cdbdc553e9d0d463 Author: Pablo Fernandez Date: Thu Jul 25 10:08:18 2024 +0100 h-tag when getting reference tags commit 99d413ad5511f0e28e7629975c00a0aca4c7de2b Author: Pablo Fernandez Date: Mon Jul 22 21:30:34 2024 +0100 wip commit 158b65b6adc46a663d1470517ff66030b1ace92f Author: Pablo Fernandez Date: Mon Jul 22 20:16:00 2024 +0100 wip commit 8ad0be00e1d77f4fed1c8e4dd203d1eb47922848 Merge: f7eaec3 8185295 Author: Pablo Fernandez Date: Mon Jul 22 20:15:34 2024 +0100 merge with all-your-relays-are-mine commit f7eaec37b0187ee7fa2796b3d7aa94b45c3a37ff Author: Pablo Fernandez Date: Mon Jul 22 20:11:26 2024 +0100 abstract relay stuff commit 818529523b521b0bbb8a430503fec44cadf8672e Author: Jeff Gardner <202880+erskingardner@users.noreply.github.com> Date: Mon Jul 22 17:33:57 2024 +0200 Remove returns from methods in auth-policies commit 4c47449cd1c84e45a1e1f996c886b9454bdf2663 Author: Jeff Gardner <202880+erskingardner@users.noreply.github.com> Date: Mon Jul 22 17:25:51 2024 +0200 Remove dependency on Nostr Tools Relay commit 741035c7ffb9d4f5b5cbabf737a497faac32866a Author: Pablo Fernandez Date: Sat Jul 20 08:17:30 2024 +0100 pnpm commit 32495e97b743ef665945d5315676cc83aadc7624 Author: Pablo Fernandez Date: Sat Jul 20 08:17:18 2024 +0100 change the zapping interface commit 585fa4132e7f4994048b4732b0c8c43f24baa5ca Author: Pablo Fernandez Date: Sat Jul 20 08:13:51 2024 +0100 event wrappers commit 74c5b0893f7772957bf532f387c5fb5a3934e86e Author: Pablo Fernandez Date: Sat Jul 20 08:12:40 2024 +0100 prevent writing to closed websockets commit a64ad45e3796f18c4fc118e24429d313222ca580 Author: Pablo Fernandez Date: Sat Jul 20 08:10:43 2024 +0100 ensure we only eose once per subscription commit 337f8418d8035b410c678e60a288ba30920c58e9 Author: Pablo Fernandez Date: Fri Jul 19 00:24:38 2024 +0100 wip commit 848abdae26b98dd66fd04e4e80a37b63278d68d7 Author: Pablo Fernandez Date: Fri Jul 19 00:22:50 2024 +0100 inherir properties from ndkevent when using `from` commit 709f9d7091deeeb66cee4931f1bdff7c8ba08c46 Author: Pablo Fernandez Date: Thu Jul 18 11:46:25 2024 +0100 refactor ndk-wallet commit 415ac6792b651c3b464c8d7589223103d0efb60a Author: Pablo Fernandez Date: Wed Jul 17 12:32:18 2024 +0100 NIP-29 work commit 191d82a6a3433dd7af9e5fb64db63005379a575a Author: Pablo Fernandez Date: Wed Jul 17 12:07:12 2024 +0100 wip commit 85cf1da1e872e65e6ae827c109628d14510cfc82 Author: Pablo Fernandez Date: Wed Jul 17 12:07:07 2024 +0100 wip commit 0b9bf8e3cfe95693ccb906e0de19075b9be2b6d4 Author: Pablo Fernandez Date: Mon Jul 15 10:47:42 2024 +0100 wip * fix docs * 30818 component powered by svelte-asciidoc. (#257) * update svelte-asciidoc. (#267) this fixes an issue with tables. it also introduces a way to disable the markdown transitional syntax that makes the asciidoc parser understand some random markdown syntax directives like "#" (which should be "=" in asciidoc) and just confuses everybody. it should have been disabled since day one, but since I missed that this commit keeps it for all articles in the past and disables it only for events authored after 2024-09-14 (two weeks expected for this change to be deployed). * Update README.md (#261) Added 'import "websocket-polyfill";' to demo, could not connect to relay without it * Add DM receive relay list to NDKKinds (#259) * fix bad state store * pnpm-lock * refactor a bunch ndk-wallet stuff * remove a bunch of unneeded packages * cap the number of relay hints we add * add NIP-78 interface * track at which timestamp we cached events * properly handled abandoned subscriptions closing * use urlFactory to generate URLs on rendering engine * package dependencies * nip-44 support * generate NIP-60 quote events and wip refactor of ndk-wallet's service * upgrade cashu-ts * format * add wallet change events * bump version * provide a way to skip receiving an optimistic publish callback * provide a way to create nuts of specific denomincation(s) * add lib * Revert "add lib" This reverts commit 575a481f6d626019812a1e344ea23aa82c25bdcb. * add lib * * Change markdown parser for a more modular approach that enables svelte components * Remove Asciidoc (breaks sveltekit builds!) * release * version * add NDKWallet receiveToken * better history tagging * default bunker == user pubkey * avoid doubling the number of tokens * add a convenient way to gather network traffic * improve filter fingerprint -- allow grouping when time constraints have the same value and remove grouping on limit filters (since they change the meaning of the result * fix incorrect grouping of subscriptions with the same fingerprint * be more tolerant with incorrect nip04 encryption * if we run into duplicate proofs throughout the same or different tokens, clean up when we roll them into a new token event * apply orphan tokens to the default wallet * fix: authed relays weren't reported as connected on connectedRelays * concatenate subscriptions that use a limit -- this is better than treating subscriptions with a limit filter as non-groupable * add netDebug direction * nip46 fixes * document netDebug in the introduction * lol * fix: authed relays weren't reported as connected on connectedRelays * skip by default, PRE that have been tagged as "deleted" * document how to check for unpublished events from the cache * add kind:7373 * correct types * fix (NDKRelayConnectivity) reconnection Issues (#280) * early return when encountering an empty-filter bug * update closeOnEose example in readme (#264) * remove old directories * add Olas as a reference * commit initial version of ndk-mobile (#281) * add default export * remove lockfile * nasty way of fixing the dependency but turbo is getting in the way * format * fixes * handle both nip04 and nip44 encryption * add kind 20 and 22 * useNDKSessionEventKind * change build script so it works on windows (theres still people using that thing lol) * nip46 fixes * add useNDKSessionEvents * add sync profile fetching from cache * add useUserProfile hook * add LRU cache for profiles * add LRU cache for profiles * add useUserProfile * simplify client tag check * fix client tag * fix bug where user profile information could be returned out of order (mixing user profile data) this was happening because the call to retrieve user profile could complete after the props had already changed * include stringified reposted event when reposting, and k-tag non kind-1 events * allow users to explicitly include muted pubkeys * Squashed commit of the following: commit d9317a20921ae657195f92a2e6b569ee81acd094 Author: pablof7z Date: Fri Nov 29 17:26:37 2024 +0000 modify ndk-mobile to remove NDKWalletService commit 16c07fbf0977c1e0d2e87bdc3c9c5aeb62b0819a Author: pablof7z Date: Fri Nov 29 17:11:47 2024 +0000 wip commit dd7442a22dc64560b1526818aab2ba782e0b627a Author: pablof7z Date: Fri Nov 29 17:08:46 2024 +0000 wip commit 9799003e4d4d81297f5d635f5438512f5b595118 Author: pablof7z Date: Thu Nov 28 20:50:59 2024 +0000 try giving all mint proofs to cashu-ts commit acf0a7b7b60c73ba1b2ac08197c56ee68d6c041d Author: pablof7z Date: Thu Nov 28 15:43:15 2024 +0000 wip commit f239104e9b216e6fc9e1e7e61e7f538b43b2b9ad Author: pablof7z Date: Thu Nov 28 13:45:13 2024 +0000 minor corrections commit 78200ee8f6a9a8f3dc4488fb14d3efaf62cdc82f Author: pablof7z Date: Thu Nov 28 12:48:16 2024 +0000 remove dexie from docs? commit 162ed25a60ed241318fc9cc096d2e89fc0a393a2 Author: pablof7z Date: Thu Nov 28 12:44:14 2024 +0000 update docs commit 4971db7363adecb4b0a0df53b2a183bc6713014b Author: pablof7z Date: Thu Nov 28 12:22:55 2024 +0000 take ndk-mobile out from the default build commit 5bfd0b5165cc13d0c1e928743fba632920001153 Author: pablof7z Date: Thu Nov 28 12:21:03 2024 +0000 hopefully make github actions run commit eb48a7b480c7b1bcb6c367391a95b73c35ae91e4 Author: pablof7z Date: Thu Nov 28 12:17:33 2024 +0000 workflow commit d9da2d5fdbf2913052e5c36babe9410dc198f970 Author: pablof7z Date: Thu Nov 28 12:11:45 2024 +0000 update test commit c11da8d393a6e42f509f7295c3f1572af84297ea Author: pablof7z Date: Thu Nov 28 12:10:58 2024 +0000 fix bug where both a and e tags were going in zap requests commit 35cdde8c9b0b70c78ddd10a8152c58ef662edb98 Author: pablof7z Date: Thu Nov 28 12:10:41 2024 +0000 deprecate user.zap() and ndk.zap() -- use new NDKZapper instead commit d70feb323e2d7f2d3c0912d8da1462445f192840 Author: pablof7z Date: Wed Nov 27 13:19:53 2024 +0000 nwc support commit aee2abd285ea60c57a886849fc8e0820643637ec Author: pablof7z Date: Fri Nov 22 23:43:52 2024 +0000 wip commit ec7bb98b4405880e2a5a12013268f1453ec01464 Author: pablof7z Date: Thu Nov 14 00:09:55 2024 +0000 wip commit 74bf589e3aadcd8ab3bb7904d949f32992915255 Author: pablof7z Date: Wed Nov 13 22:07:56 2024 +0000 upgrade cashu-ts * change default encryption scheme to nip44 * add validation to check if nip07 extension supports nip44 * fix nip07 bad commit * be more thorough finding the wallet that can unlock a nutzap * track wallet stuff on the session * delete events from cache when we see a deletion * fix zap missing event tag * wallet docs * add pubkey hint to e tags * remove unused package * improve how event deletion is handled in the cache * add support for Svelte 5's runes * change github workflow * change github workflow * Fix github workflow * skip deleted events by default * add support in dexie cache to retrieve profile info synchronously * add NIP-22 support * Store NWC pairing code * allow users to automatically store wallet settings * wip * fix bad replaceable event write * refactor some wallet code * upgrade ndk-mobile packages * add protections to avoid double-counting proofs * cache warnings * add fee on wallet change * relay indicator component * Breaking apart NDKCashuWallet * WIP: begin nip-55 integration in ndk-mobile --------- Co-authored-by: Pablo Fernandez Co-authored-by: gzuuus <116975404+gzuuus@users.noreply.github.com> Co-authored-by: JeffG <202880+erskingardner@users.noreply.github.com> Co-authored-by: Five <126801697+Pleb5@users.noreply.github.com> Co-authored-by: Alejandro Co-authored-by: gsovereignty Co-authored-by: arkinox <99223753+arkin0x@users.noreply.github.com> Co-authored-by: Sepehr Safari Co-authored-by: Caleb Simpson Co-authored-by: anon-dev <148810564+anon-dev-gh@users.noreply.github.com> Co-authored-by: Vladimir Lazić Co-authored-by: Jeremy D <4072+jeremyd@users.noreply.github.com> Co-authored-by: fiatjaf_ Co-authored-by: JZ273 <102374100+JohnZolton@users.noreply.github.com> Co-authored-by: pablof7z Co-authored-by: Fer <82674220+cuervoshi@users.noreply.github.com> Co-authored-by: Adam Soltys --- .changeset/README.md | 8 + .changeset/cold-pianos-tickle.md | 5 + .changeset/config.json | 11 + .changeset/eighty-toes-refuse.md | 5 + .changeset/fifty-llamas-boil.md | 5 + .changeset/flat-garlics-taste.md | 5 + .changeset/fresh-oranges-guess.md | 5 + .changeset/great-keys-knock.md | 5 + .changeset/khaki-pets-smell.md | 5 + .changeset/pretty-berries-talk.md | 5 + .changeset/purple-fireants-invite.md | 5 + .changeset/silly-cows-boil.md | 5 + .changeset/strong-files-fly.md | 5 + .devcontainer/Dockerfile | 13 + .devcontainer/devcontainer.json | 29 + .eslintignore | 13 + .eslintrc.js | 3 + .github/workflows/deploy.yml | 66 ++ .prettierignore | 5 + .prettierrc | 16 + BUILD.md | 20 + LICENSE | 21 + REFERENCES.md | 45 + docs/.vitepress/config.mts | 78 ++ docs/.vitepress/theme/index.ts | 17 + docs/.vitepress/theme/style.css | 139 +++ docs/api-examples.md | 49 + docs/cache/dexie.md | 153 +++ docs/cache/nostr.md | 34 + docs/getting-started/introduction.md | 35 + docs/getting-started/signers.md | 38 + docs/getting-started/usage.md | 57 ++ docs/index.md | 18 + docs/internals/subscriptions.md | 205 ++++ docs/markdown-examples.md | 85 ++ docs/mobile/index.md | 53 ++ docs/mobile/profile-hook.md | 20 + docs/mobile/session.md | 36 + docs/mobile/subscriptions.md | 0 docs/mobile/wallet.md | 47 + docs/tutorial/auth.md | 29 + docs/tutorial/index.md | 1 + docs/tutorial/local-first.md | 63 ++ docs/tutorial/publishing.md | 38 + docs/tutorial/speed.md | 48 + docs/tutorial/subscription-management.md | 67 ++ docs/tutorial/zaps/index.md | 16 + docs/wallet/discover.md | 44 + docs/wallet/index.md | 23 + docs/wallet/nutsack.md | 95 ++ docs/wallet/nutzaps.md | 16 + docs/wrappers/svelte.md | 107 +++ ndk-cache-dexie/.gitignore | 5 + ndk-cache-dexie/.prettierignore | 1 + ndk-cache-dexie/CHANGELOG.md | 389 ++++++++ ndk-cache-dexie/README.md | 28 + ndk-cache-dexie/jest.config.ts | 16 + ndk-cache-dexie/package.json | 64 ++ ndk-cache-dexie/src/caches/event-tags.ts | 37 + ndk-cache-dexie/src/caches/events.ts | 35 + ndk-cache-dexie/src/caches/nip05.ts | 43 + ndk-cache-dexie/src/caches/profiles.ts | 42 + ndk-cache-dexie/src/caches/relay-info.ts | 49 + .../src/caches/unpublished-events.ts | 104 ++ ndk-cache-dexie/src/caches/zapper.ts | 47 + ndk-cache-dexie/src/db.ts | 81 ++ ndk-cache-dexie/src/index.test.ts | 79 ++ ndk-cache-dexie/src/index.ts | 607 ++++++++++++ ndk-cache-dexie/src/lru-cache.ts | 164 ++++ ndk-cache-dexie/tsconfig.json | 5 + ndk-cache-dexie/typedoc.json | 16 + ndk-cache-nostr/.gitignore | 3 + ndk-cache-nostr/.prettierignore | 1 + ndk-cache-nostr/CHANGELOG.md | 56 ++ ndk-cache-nostr/README.md | 34 + ndk-cache-nostr/jest.config.ts | 11 + ndk-cache-nostr/package.json | 56 ++ ndk-cache-nostr/src/index.ts | 272 ++++++ ndk-cache-nostr/src/queue.ts | 90 ++ ndk-cache-nostr/tsconfig.json | 5 + ndk-cache-redis/.gitignore | 3 + ndk-cache-redis/.prettierignore | 1 + ndk-cache-redis/CHANGELOG.md | 362 +++++++ ndk-cache-redis/README.md | 27 + ndk-cache-redis/jest.config.ts | 11 + ndk-cache-redis/package.json | 58 ++ ndk-cache-redis/src/index.test.ts | 83 ++ ndk-cache-redis/src/index.ts | 160 ++++ ndk-cache-redis/tsconfig.json | 5 + ndk-mobile/CHANGELOG.md | 21 + ndk-mobile/LICENSE | 21 + ndk-mobile/README.md | 35 + ndk-mobile/index.ts | 10 + ndk-mobile/package.json | 83 ++ ndk-mobile/src/cache-adapter/migrations.ts | 61 ++ ndk-mobile/src/cache-adapter/sqlite.ts | 314 +++++++ ndk-mobile/src/components/index.ts | 7 + ndk-mobile/src/components/relays/index.tsx | 3 + .../src/components/relays/indicator.tsx | 45 + ndk-mobile/src/context/index.ts | 2 + ndk-mobile/src/context/ndk.ts | 30 + ndk-mobile/src/context/session.ts | 27 + ndk-mobile/src/hooks/index.ts | 4 + ndk-mobile/src/hooks/ndk.ts | 12 + ndk-mobile/src/hooks/session.ts | 57 ++ ndk-mobile/src/hooks/subscribe.ts | 252 +++++ ndk-mobile/src/hooks/user-profile.ts | 85 ++ ndk-mobile/src/index.ts | 13 + ndk-mobile/src/providers/index.ts | 2 + ndk-mobile/src/providers/ndk/index.tsx | 118 +++ ndk-mobile/src/providers/ndk/signers/index.ts | 4 + ndk-mobile/src/providers/ndk/signers/nip07.ts | 14 + ndk-mobile/src/providers/ndk/signers/nip46.ts | 16 + ndk-mobile/src/providers/ndk/signers/nip55.ts | 324 +++++++ ndk-mobile/src/providers/ndk/signers/pk.ts | 12 + ndk-mobile/src/providers/session/index.tsx | 273 ++++++ ndk-mobile/src/stores/session.ts | 75 ++ ndk-mobile/src/stores/wallet.ts | 27 + ndk-mobile/tsconfig.json | 17 + ndk-svelte-components/.eslintrc.cjs | 32 + ndk-svelte-components/.gitignore | 14 + ndk-svelte-components/.npmrc | 5 + ndk-svelte-components/.prettierignore | 3 + ndk-svelte-components/.storybook/main.ts | 26 + ndk-svelte-components/.storybook/preview.ts | 16 + ndk-svelte-components/CHANGELOG.md | 380 ++++++++ ndk-svelte-components/LICENSE | 21 + ndk-svelte-components/README.md | 69 ++ ndk-svelte-components/images/relay-list.png | Bin 0 -> 200622 bytes ndk-svelte-components/package.json | 97 ++ ndk-svelte-components/postcss.config.cjs | 7 + ndk-svelte-components/src/app.html | 28 + .../src/lib/event/ElementConnector.svelte | 65 ++ .../src/lib/event/EventCard.svelte | 109 +++ .../lib/event/EventCardDropdownMenu.svelte | 87 ++ .../src/lib/event/EventThread.svelte | 217 +++++ .../src/lib/event/content/EventContent.svelte | 94 ++ .../src/lib/event/content/Kind1.svelte | 82 ++ .../src/lib/event/content/Kind1063.svelte | 81 ++ .../src/lib/event/content/Kind30000.svelte | 29 + .../src/lib/event/content/Kind30001.svelte | 27 + .../src/lib/event/content/Kind30023.svelte | 59 ++ .../src/lib/event/content/Kind9802.svelte | 26 + .../lib/event/content/NoteContentLink.svelte | 30 + .../event/content/NoteContentNewline.svelte | 8 + .../event/content/NoteContentPerson.svelte | 25 + .../lib/event/content/NoteContentTopic.svelte | 8 + .../src/lib/event/content/RenderHtml.svelte | 69 ++ .../lib/event/content/renderer/hashtag.svelte | 5 + .../src/lib/event/content/renderer/index.ts | 12 + .../lib/event/content/renderer/link.svelte | 29 + .../lib/event/content/renderer/mention.svelte | 15 + .../event/content/renderer/nostr-event.svelte | 19 + ndk-svelte-components/src/lib/index.ts | 32 + .../src/lib/relay/RelayList.svelte | 34 + .../src/lib/relay/RelayListItem.svelte | 208 ++++ .../src/lib/relay/RelayName.svelte | 8 + ndk-svelte-components/src/lib/stores/ndk.ts | 13 + .../src/lib/user/Avatar.svelte | 97 ++ .../src/lib/user/Name.svelte | 82 ++ .../src/lib/user/Nip05.svelte | 99 ++ .../src/lib/user/Npub.svelte | 86 ++ .../src/lib/user/UserCard.svelte | 110 +++ .../src/lib/utils/event/index.ts | 30 + .../src/lib/utils/extensions/event.svelte | 19 + .../src/lib/utils/extensions/hashtag.svelte | 5 + .../src/lib/utils/extensions/image.svelte | 10 + .../src/lib/utils/extensions/mention.svelte | 17 + ndk-svelte-components/src/lib/utils/index.ts | 14 + .../src/lib/utils/markdown.ts | 111 +++ ndk-svelte-components/src/lib/utils/notes.ts | 312 ++++++ .../src/lib/utils/relay/index.ts | 20 + .../src/lib/utils/user/index.ts | 8 + ndk-svelte-components/src/routes/+page.svelte | 6 + .../src/stories/Introduction.mdx | 21 + .../src/stories/events/EventCard.stories.ts | 63 ++ .../events/EventCardDropdownMenu.stories.ts | 46 + .../stories/events/EventContent.stories.ts | 60 ++ .../src/stories/events/EventThread.stories.ts | 67 ++ .../src/stories/events/kinds/1.stories.ts | 49 + .../src/stories/events/kinds/1063.stories.ts | 43 + .../src/stories/events/kinds/30023.stories.ts | 53 ++ .../src/stories/events/kinds/9802.stories.ts | 45 + .../events/kinds/lists/30000.stories.ts | 46 + .../events/kinds/lists/30001.stories.ts | 46 + .../src/stories/relay/RelayList.stories.ts | 57 ++ .../src/stories/user/Avatar.stories.ts | 87 ++ .../src/stories/user/Name.stories.ts | 89 ++ .../src/stories/user/Nip05.stories.ts | 96 ++ .../src/stories/user/Npub.stories.ts | 59 ++ .../src/stories/user/UserCard.stories.ts | 75 ++ ndk-svelte-components/src/styles/global.css | 21 + ndk-svelte-components/static/favicon.png | Bin 0 -> 1571 bytes ndk-svelte-components/svelte.config.js | 15 + ndk-svelte-components/tailwind.config.js | 4 + ndk-svelte-components/tsconfig.json | 13 + ndk-svelte-components/vite.config.ts | 6 + ndk-svelte/.gitignore | 13 + ndk-svelte/.prettierignore | 1 + ndk-svelte/CHANGELOG.md | 362 +++++++ ndk-svelte/LICENSE | 21 + ndk-svelte/README.md | 102 ++ ndk-svelte/package.json | 60 ++ ndk-svelte/src/index.svelte.ts | 119 +++ ndk-svelte/src/index.ts | 359 +++++++ ndk-svelte/tsconfig.json | 5 + ndk-wallet/CHANGELOG.md | 428 +++++++++ ndk-wallet/README.md | 24 + ndk-wallet/jest.config.ts | 11 + ndk-wallet/package.json | 67 ++ ndk-wallet/src/index.ts | 15 + ndk-wallet/src/light-bolt11-decoder.d.ts | 4 + ndk-wallet/src/nutzap-monitor/index.ts | 245 +++++ ndk-wallet/src/utils/ln.ts | 26 + ndk-wallet/src/wallets/cashu/decrypt.ts | 18 + .../src/wallets/cashu/deposit-monitor.ts | 40 + ndk-wallet/src/wallets/cashu/deposit.ts | 193 ++++ .../wallets/cashu/event-handlers/deletion.ts | 14 + .../src/wallets/cashu/event-handlers/index.ts | 22 + .../src/wallets/cashu/event-handlers/quote.ts | 14 + .../src/wallets/cashu/event-handlers/token.ts | 14 + ndk-wallet/src/wallets/cashu/history.ts | 182 ++++ ndk-wallet/src/wallets/cashu/mint.ts | 60 ++ ndk-wallet/src/wallets/cashu/mint/utils.ts | 64 ++ ndk-wallet/src/wallets/cashu/pay.ts | 14 + ndk-wallet/src/wallets/cashu/pay/ln.ts | 111 +++ ndk-wallet/src/wallets/cashu/pay/nut.test.ts | 42 + ndk-wallet/src/wallets/cashu/pay/nut.ts | 255 +++++ ndk-wallet/src/wallets/cashu/proofs.ts | 96 ++ ndk-wallet/src/wallets/cashu/quote.ts | 78 ++ ndk-wallet/src/wallets/cashu/token.ts | 126 +++ ndk-wallet/src/wallets/cashu/validate.ts | 116 +++ ndk-wallet/src/wallets/cashu/wallet/index.ts | 740 +++++++++++++++ .../src/wallets/cashu/wallet/payment.ts | 86 ++ ndk-wallet/src/wallets/cashu/wallet/state.ts | 305 ++++++ ndk-wallet/src/wallets/cashu/wallet/txs.ts | 95 ++ ndk-wallet/src/wallets/index.ts | 89 ++ ndk-wallet/src/wallets/nwc/index.ts | 173 ++++ ndk-wallet/src/wallets/nwc/req.ts | 100 ++ ndk-wallet/src/wallets/nwc/res.ts | 47 + ndk-wallet/src/wallets/nwc/types.ts | 122 +++ ndk-wallet/src/wallets/webln/index.ts | 76 ++ ndk-wallet/src/wallets/webln/pay.ts | 78 ++ ndk-wallet/tsconfig.json | 5 + ndk/.prettierignore | 7 + ndk/CHANGELOG | 23 + ndk/CHANGELOG.md | 336 +++++++ ndk/LICENSE | 21 + ndk/OUTBOX.md | 7 + ndk/docs-styles.css | 37 + ndk/jest.config.ts | 15 + ndk/package.json | 87 ++ ndk/src/app-settings/index.ts | 75 ++ ndk/src/blossom/index.ts | 0 ndk/src/cache/index.ts | 118 +++ ndk/src/dvm/schedule.ts | 135 +++ ndk/src/events/content-tagger.test.ts | 232 +++++ ndk/src/events/content-tagger.ts | 186 ++++ ndk/src/events/dedup.ts | 14 + ndk/src/events/encode.test.ts | 17 + ndk/src/events/fetch-tagged-event.ts | 44 + ndk/src/events/index.test.ts | 567 +++++++++++ ndk/src/events/index.ts | 886 ++++++++++++++++++ ndk/src/events/kind.ts | 20 + ndk/src/events/kinds/NDKRelayList.ts | 115 +++ ndk/src/events/kinds/article.ts | 152 +++ ndk/src/events/kinds/classified.ts | 181 ++++ ndk/src/events/kinds/drafts.ts | 116 +++ .../events/kinds/dvm/NDKTranscriptionDVM.ts | 69 ++ ndk/src/events/kinds/dvm/feedback.ts | 48 + ndk/src/events/kinds/dvm/index.ts | 6 + ndk/src/events/kinds/dvm/request.ts | 121 +++ ndk/src/events/kinds/dvm/result.ts | 83 ++ ndk/src/events/kinds/highlight.ts | 115 +++ ndk/src/events/kinds/index.ts | 185 ++++ ndk/src/events/kinds/lists/index.test.ts | 51 + ndk/src/events/kinds/lists/index.ts | 391 ++++++++ ndk/src/events/kinds/nip89/NDKAppHandler.ts | 57 ++ ndk/src/events/kinds/nutzap/index.ts | 182 ++++ ndk/src/events/kinds/nutzap/mint-list.ts | 76 ++ ndk/src/events/kinds/nutzap/proof.ts | 18 + ndk/src/events/kinds/repost.ts | 74 ++ ndk/src/events/kinds/simple-group/index.ts | 240 +++++ .../events/kinds/simple-group/member-list.ts | 43 + ndk/src/events/kinds/simple-group/metadata.ts | 62 ++ ndk/src/events/kinds/subscriptions/amount.ts | 61 ++ ndk/src/events/kinds/subscriptions/receipt.ts | 146 +++ .../kinds/subscriptions/subscription-start.ts | 147 +++ .../events/kinds/subscriptions/tier.test.ts | 76 ++ ndk/src/events/kinds/subscriptions/tier.ts | 122 +++ ndk/src/events/kinds/video.ts | 144 +++ ndk/src/events/kinds/wiki.ts | 7 + ndk/src/events/nip04.ts | 52 + ndk/src/events/nip19.test.ts | 58 ++ ndk/src/events/nip19.ts | 34 + ndk/src/events/nip73.ts | 13 + ndk/src/events/repost.ts | 47 + ndk/src/events/serializer.ts | 41 + ndk/src/events/signature.ts | 52 + ndk/src/events/validation.ts | 90 ++ ndk/src/index.ts | 61 ++ ndk/src/light-bolt11-decoder.d.ts | 4 + ndk/src/media/index.test.ts | 77 ++ ndk/src/media/index.ts | 199 ++++ ndk/src/ndk/active-user.ts | 112 +++ ndk/src/ndk/fetch-event-from-tag.test.ts | 22 + ndk/src/ndk/fetch-event-from-tag.ts | 162 ++++ ndk/src/ndk/index.ts | 737 +++++++++++++++ ndk/src/ndk/queue/index.ts | 90 ++ ndk/src/outbox/index.ts | 118 +++ ndk/src/outbox/read/with-authors.ts | 24 + ndk/src/outbox/relay-ranking.ts | 27 + ndk/src/outbox/tracker.test.ts | 20 + ndk/src/outbox/tracker.ts | 177 ++++ ndk/src/outbox/write.ts | 38 + ndk/src/relay/auth-policies.test.ts | 19 + ndk/src/relay/auth-policies.ts | 93 ++ ndk/src/relay/connectivity.test.ts | 122 +++ ndk/src/relay/connectivity.ts | 619 ++++++++++++ ndk/src/relay/index.test.ts | 168 ++++ ndk/src/relay/index.ts | 289 ++++++ ndk/src/relay/pool/index.test.ts | 26 + ndk/src/relay/pool/index.ts | 437 +++++++++ ndk/src/relay/publisher.ts | 112 +++ ndk/src/relay/score.ts | 2 + ndk/src/relay/sets/calculate.test.ts | 205 ++++ ndk/src/relay/sets/calculate.ts | 179 ++++ ndk/src/relay/sets/index.ts | 196 ++++ ndk/src/relay/sets/utils.ts | 29 + ndk/src/relay/sub-manager.ts | 84 ++ ndk/src/relay/subscription.test.ts | 165 ++++ ndk/src/relay/subscription.ts | 439 +++++++++ ndk/src/signers/index.ts | 73 ++ ndk/src/signers/nip07/index.ts | 261 ++++++ ndk/src/signers/nip46/backend/connect.ts | 42 + .../signers/nip46/backend/get-public-key.ts | 12 + ndk/src/signers/nip46/backend/index.ts | 214 +++++ .../signers/nip46/backend/nip04-decrypt.ts | 39 + .../signers/nip46/backend/nip04-encrypt.ts | 39 + .../signers/nip46/backend/nip44-decrypt.ts | 39 + .../signers/nip46/backend/nip44-encrypt.ts | 39 + ndk/src/signers/nip46/backend/ping.ts | 26 + ndk/src/signers/nip46/backend/sign-event.ts | 48 + ndk/src/signers/nip46/index.test.ts | 71 ++ ndk/src/signers/nip46/index.ts | 351 +++++++ ndk/src/signers/nip46/rpc.ts | 209 +++++ ndk/src/signers/private-key/index.test.ts | 63 ++ ndk/src/signers/private-key/index.ts | 139 +++ ndk/src/subscription/grouping.test.ts | 71 ++ ndk/src/subscription/grouping.ts | 80 ++ ndk/src/subscription/index.test.ts | 84 ++ ndk/src/subscription/index.ts | 587 ++++++++++++ ndk/src/subscription/manager.ts | 34 + ndk/src/subscription/utils.test.ts | 92 ++ ndk/src/subscription/utils.ts | 278 ++++++ ndk/src/thread/index.test.ts | 267 ++++++ ndk/src/thread/index.ts | 233 +++++ ndk/src/user/follows.test.ts | 52 + ndk/src/user/follows.ts | 42 + ndk/src/user/index.test.ts | 292 ++++++ ndk/src/user/index.ts | 547 +++++++++++ ndk/src/user/nip05.test.ts | 40 + ndk/src/user/nip05.ts | 111 +++ ndk/src/user/pin.ts | 45 + ndk/src/user/profile.ts | 109 +++ ndk/src/utils/get-users-relay-list.ts | 119 +++ ndk/src/utils/normalize-url.ts | 356 +++++++ ndk/src/utils/timeout.ts | 19 + ndk/src/workers/sig-verification.ts | 40 + ndk/src/zap/invoice.ts | 111 +++ ndk/src/zapper/index.test.ts | 124 +++ ndk/src/zapper/index.ts | 488 ++++++++++ ndk/src/zapper/ln.ts | 84 ++ ndk/src/zapper/nip57.ts | 58 ++ ndk/src/zapper/nip61.ts | 43 + ndk/tsconfig.json | 8 + ndk/typedoc.json | 23 + packages/eslint-config-custom/index.json | 25 + packages/eslint-config-custom/package.json | 17 + packages/tailwind-config/package.json | 11 + packages/tailwind-config/tailwind.config.js | 21 + packages/tsconfig/base.json | 24 + packages/tsconfig/ndk-cache-dexie.json | 5 + packages/tsconfig/ndk-cache-redis.json | 5 + packages/tsconfig/ndk-svelte.json | 5 + packages/tsconfig/ndk.json | 16 + packages/tsconfig/package.json | 16 + tsconfig.json | 4 + 388 files changed, 33948 insertions(+) create mode 100644 .changeset/README.md create mode 100644 .changeset/cold-pianos-tickle.md create mode 100644 .changeset/config.json create mode 100644 .changeset/eighty-toes-refuse.md create mode 100644 .changeset/fifty-llamas-boil.md create mode 100644 .changeset/flat-garlics-taste.md create mode 100644 .changeset/fresh-oranges-guess.md create mode 100644 .changeset/great-keys-knock.md create mode 100644 .changeset/khaki-pets-smell.md create mode 100644 .changeset/pretty-berries-talk.md create mode 100644 .changeset/purple-fireants-invite.md create mode 100644 .changeset/silly-cows-boil.md create mode 100644 .changeset/strong-files-fly.md create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json create mode 100644 .eslintignore create mode 100644 .eslintrc.js create mode 100644 .github/workflows/deploy.yml create mode 100644 .prettierignore create mode 100644 .prettierrc create mode 100644 BUILD.md create mode 100644 LICENSE create mode 100644 REFERENCES.md create mode 100644 docs/.vitepress/config.mts create mode 100644 docs/.vitepress/theme/index.ts create mode 100644 docs/.vitepress/theme/style.css create mode 100644 docs/api-examples.md create mode 100644 docs/cache/dexie.md create mode 100644 docs/cache/nostr.md create mode 100644 docs/getting-started/introduction.md create mode 100644 docs/getting-started/signers.md create mode 100644 docs/getting-started/usage.md create mode 100644 docs/index.md create mode 100644 docs/internals/subscriptions.md create mode 100644 docs/markdown-examples.md create mode 100644 docs/mobile/index.md create mode 100644 docs/mobile/profile-hook.md create mode 100644 docs/mobile/session.md create mode 100644 docs/mobile/subscriptions.md create mode 100644 docs/mobile/wallet.md create mode 100644 docs/tutorial/auth.md create mode 100644 docs/tutorial/index.md create mode 100644 docs/tutorial/local-first.md create mode 100644 docs/tutorial/publishing.md create mode 100644 docs/tutorial/speed.md create mode 100644 docs/tutorial/subscription-management.md create mode 100644 docs/tutorial/zaps/index.md create mode 100644 docs/wallet/discover.md create mode 100644 docs/wallet/index.md create mode 100644 docs/wallet/nutsack.md create mode 100644 docs/wallet/nutzaps.md create mode 100644 docs/wrappers/svelte.md create mode 100644 ndk-cache-dexie/.gitignore create mode 100644 ndk-cache-dexie/.prettierignore create mode 100644 ndk-cache-dexie/CHANGELOG.md create mode 100644 ndk-cache-dexie/README.md create mode 100644 ndk-cache-dexie/jest.config.ts create mode 100644 ndk-cache-dexie/package.json create mode 100644 ndk-cache-dexie/src/caches/event-tags.ts create mode 100644 ndk-cache-dexie/src/caches/events.ts create mode 100644 ndk-cache-dexie/src/caches/nip05.ts create mode 100644 ndk-cache-dexie/src/caches/profiles.ts create mode 100644 ndk-cache-dexie/src/caches/relay-info.ts create mode 100644 ndk-cache-dexie/src/caches/unpublished-events.ts create mode 100644 ndk-cache-dexie/src/caches/zapper.ts create mode 100644 ndk-cache-dexie/src/db.ts create mode 100644 ndk-cache-dexie/src/index.test.ts create mode 100644 ndk-cache-dexie/src/index.ts create mode 100644 ndk-cache-dexie/src/lru-cache.ts create mode 100644 ndk-cache-dexie/tsconfig.json create mode 100644 ndk-cache-dexie/typedoc.json create mode 100644 ndk-cache-nostr/.gitignore create mode 100644 ndk-cache-nostr/.prettierignore create mode 100644 ndk-cache-nostr/CHANGELOG.md create mode 100644 ndk-cache-nostr/README.md create mode 100644 ndk-cache-nostr/jest.config.ts create mode 100644 ndk-cache-nostr/package.json create mode 100644 ndk-cache-nostr/src/index.ts create mode 100644 ndk-cache-nostr/src/queue.ts create mode 100644 ndk-cache-nostr/tsconfig.json create mode 100644 ndk-cache-redis/.gitignore create mode 100644 ndk-cache-redis/.prettierignore create mode 100644 ndk-cache-redis/CHANGELOG.md create mode 100644 ndk-cache-redis/README.md create mode 100644 ndk-cache-redis/jest.config.ts create mode 100644 ndk-cache-redis/package.json create mode 100644 ndk-cache-redis/src/index.test.ts create mode 100644 ndk-cache-redis/src/index.ts create mode 100644 ndk-cache-redis/tsconfig.json create mode 100644 ndk-mobile/CHANGELOG.md create mode 100644 ndk-mobile/LICENSE create mode 100644 ndk-mobile/README.md create mode 100644 ndk-mobile/index.ts create mode 100644 ndk-mobile/package.json create mode 100644 ndk-mobile/src/cache-adapter/migrations.ts create mode 100644 ndk-mobile/src/cache-adapter/sqlite.ts create mode 100644 ndk-mobile/src/components/index.ts create mode 100644 ndk-mobile/src/components/relays/index.tsx create mode 100644 ndk-mobile/src/components/relays/indicator.tsx create mode 100644 ndk-mobile/src/context/index.ts create mode 100644 ndk-mobile/src/context/ndk.ts create mode 100644 ndk-mobile/src/context/session.ts create mode 100644 ndk-mobile/src/hooks/index.ts create mode 100644 ndk-mobile/src/hooks/ndk.ts create mode 100644 ndk-mobile/src/hooks/session.ts create mode 100644 ndk-mobile/src/hooks/subscribe.ts create mode 100644 ndk-mobile/src/hooks/user-profile.ts create mode 100644 ndk-mobile/src/index.ts create mode 100644 ndk-mobile/src/providers/index.ts create mode 100644 ndk-mobile/src/providers/ndk/index.tsx create mode 100644 ndk-mobile/src/providers/ndk/signers/index.ts create mode 100644 ndk-mobile/src/providers/ndk/signers/nip07.ts create mode 100644 ndk-mobile/src/providers/ndk/signers/nip46.ts create mode 100644 ndk-mobile/src/providers/ndk/signers/nip55.ts create mode 100644 ndk-mobile/src/providers/ndk/signers/pk.ts create mode 100644 ndk-mobile/src/providers/session/index.tsx create mode 100644 ndk-mobile/src/stores/session.ts create mode 100644 ndk-mobile/src/stores/wallet.ts create mode 100644 ndk-mobile/tsconfig.json create mode 100644 ndk-svelte-components/.eslintrc.cjs create mode 100644 ndk-svelte-components/.gitignore create mode 100644 ndk-svelte-components/.npmrc create mode 100644 ndk-svelte-components/.prettierignore create mode 100644 ndk-svelte-components/.storybook/main.ts create mode 100644 ndk-svelte-components/.storybook/preview.ts create mode 100644 ndk-svelte-components/CHANGELOG.md create mode 100644 ndk-svelte-components/LICENSE create mode 100644 ndk-svelte-components/README.md create mode 100644 ndk-svelte-components/images/relay-list.png create mode 100644 ndk-svelte-components/package.json create mode 100644 ndk-svelte-components/postcss.config.cjs create mode 100644 ndk-svelte-components/src/app.html create mode 100644 ndk-svelte-components/src/lib/event/ElementConnector.svelte create mode 100644 ndk-svelte-components/src/lib/event/EventCard.svelte create mode 100644 ndk-svelte-components/src/lib/event/EventCardDropdownMenu.svelte create mode 100644 ndk-svelte-components/src/lib/event/EventThread.svelte create mode 100644 ndk-svelte-components/src/lib/event/content/EventContent.svelte create mode 100644 ndk-svelte-components/src/lib/event/content/Kind1.svelte create mode 100644 ndk-svelte-components/src/lib/event/content/Kind1063.svelte create mode 100644 ndk-svelte-components/src/lib/event/content/Kind30000.svelte create mode 100644 ndk-svelte-components/src/lib/event/content/Kind30001.svelte create mode 100644 ndk-svelte-components/src/lib/event/content/Kind30023.svelte create mode 100644 ndk-svelte-components/src/lib/event/content/Kind9802.svelte create mode 100644 ndk-svelte-components/src/lib/event/content/NoteContentLink.svelte create mode 100644 ndk-svelte-components/src/lib/event/content/NoteContentNewline.svelte create mode 100644 ndk-svelte-components/src/lib/event/content/NoteContentPerson.svelte create mode 100644 ndk-svelte-components/src/lib/event/content/NoteContentTopic.svelte create mode 100644 ndk-svelte-components/src/lib/event/content/RenderHtml.svelte create mode 100644 ndk-svelte-components/src/lib/event/content/renderer/hashtag.svelte create mode 100644 ndk-svelte-components/src/lib/event/content/renderer/index.ts create mode 100644 ndk-svelte-components/src/lib/event/content/renderer/link.svelte create mode 100644 ndk-svelte-components/src/lib/event/content/renderer/mention.svelte create mode 100644 ndk-svelte-components/src/lib/event/content/renderer/nostr-event.svelte create mode 100644 ndk-svelte-components/src/lib/index.ts create mode 100644 ndk-svelte-components/src/lib/relay/RelayList.svelte create mode 100644 ndk-svelte-components/src/lib/relay/RelayListItem.svelte create mode 100644 ndk-svelte-components/src/lib/relay/RelayName.svelte create mode 100644 ndk-svelte-components/src/lib/stores/ndk.ts create mode 100644 ndk-svelte-components/src/lib/user/Avatar.svelte create mode 100644 ndk-svelte-components/src/lib/user/Name.svelte create mode 100644 ndk-svelte-components/src/lib/user/Nip05.svelte create mode 100644 ndk-svelte-components/src/lib/user/Npub.svelte create mode 100644 ndk-svelte-components/src/lib/user/UserCard.svelte create mode 100644 ndk-svelte-components/src/lib/utils/event/index.ts create mode 100644 ndk-svelte-components/src/lib/utils/extensions/event.svelte create mode 100644 ndk-svelte-components/src/lib/utils/extensions/hashtag.svelte create mode 100644 ndk-svelte-components/src/lib/utils/extensions/image.svelte create mode 100644 ndk-svelte-components/src/lib/utils/extensions/mention.svelte create mode 100644 ndk-svelte-components/src/lib/utils/index.ts create mode 100644 ndk-svelte-components/src/lib/utils/markdown.ts create mode 100644 ndk-svelte-components/src/lib/utils/notes.ts create mode 100644 ndk-svelte-components/src/lib/utils/relay/index.ts create mode 100644 ndk-svelte-components/src/lib/utils/user/index.ts create mode 100644 ndk-svelte-components/src/routes/+page.svelte create mode 100644 ndk-svelte-components/src/stories/Introduction.mdx create mode 100644 ndk-svelte-components/src/stories/events/EventCard.stories.ts create mode 100644 ndk-svelte-components/src/stories/events/EventCardDropdownMenu.stories.ts create mode 100644 ndk-svelte-components/src/stories/events/EventContent.stories.ts create mode 100644 ndk-svelte-components/src/stories/events/EventThread.stories.ts create mode 100644 ndk-svelte-components/src/stories/events/kinds/1.stories.ts create mode 100644 ndk-svelte-components/src/stories/events/kinds/1063.stories.ts create mode 100644 ndk-svelte-components/src/stories/events/kinds/30023.stories.ts create mode 100644 ndk-svelte-components/src/stories/events/kinds/9802.stories.ts create mode 100644 ndk-svelte-components/src/stories/events/kinds/lists/30000.stories.ts create mode 100644 ndk-svelte-components/src/stories/events/kinds/lists/30001.stories.ts create mode 100644 ndk-svelte-components/src/stories/relay/RelayList.stories.ts create mode 100644 ndk-svelte-components/src/stories/user/Avatar.stories.ts create mode 100644 ndk-svelte-components/src/stories/user/Name.stories.ts create mode 100644 ndk-svelte-components/src/stories/user/Nip05.stories.ts create mode 100644 ndk-svelte-components/src/stories/user/Npub.stories.ts create mode 100644 ndk-svelte-components/src/stories/user/UserCard.stories.ts create mode 100644 ndk-svelte-components/src/styles/global.css create mode 100644 ndk-svelte-components/static/favicon.png create mode 100644 ndk-svelte-components/svelte.config.js create mode 100644 ndk-svelte-components/tailwind.config.js create mode 100644 ndk-svelte-components/tsconfig.json create mode 100644 ndk-svelte-components/vite.config.ts create mode 100644 ndk-svelte/.gitignore create mode 100644 ndk-svelte/.prettierignore create mode 100644 ndk-svelte/CHANGELOG.md create mode 100644 ndk-svelte/LICENSE create mode 100644 ndk-svelte/README.md create mode 100644 ndk-svelte/package.json create mode 100644 ndk-svelte/src/index.svelte.ts create mode 100644 ndk-svelte/src/index.ts create mode 100644 ndk-svelte/tsconfig.json create mode 100644 ndk-wallet/CHANGELOG.md create mode 100644 ndk-wallet/README.md create mode 100644 ndk-wallet/jest.config.ts create mode 100644 ndk-wallet/package.json create mode 100644 ndk-wallet/src/index.ts create mode 100644 ndk-wallet/src/light-bolt11-decoder.d.ts create mode 100644 ndk-wallet/src/nutzap-monitor/index.ts create mode 100644 ndk-wallet/src/utils/ln.ts create mode 100644 ndk-wallet/src/wallets/cashu/decrypt.ts create mode 100644 ndk-wallet/src/wallets/cashu/deposit-monitor.ts create mode 100644 ndk-wallet/src/wallets/cashu/deposit.ts create mode 100644 ndk-wallet/src/wallets/cashu/event-handlers/deletion.ts create mode 100644 ndk-wallet/src/wallets/cashu/event-handlers/index.ts create mode 100644 ndk-wallet/src/wallets/cashu/event-handlers/quote.ts create mode 100644 ndk-wallet/src/wallets/cashu/event-handlers/token.ts create mode 100644 ndk-wallet/src/wallets/cashu/history.ts create mode 100644 ndk-wallet/src/wallets/cashu/mint.ts create mode 100644 ndk-wallet/src/wallets/cashu/mint/utils.ts create mode 100644 ndk-wallet/src/wallets/cashu/pay.ts create mode 100644 ndk-wallet/src/wallets/cashu/pay/ln.ts create mode 100644 ndk-wallet/src/wallets/cashu/pay/nut.test.ts create mode 100644 ndk-wallet/src/wallets/cashu/pay/nut.ts create mode 100644 ndk-wallet/src/wallets/cashu/proofs.ts create mode 100644 ndk-wallet/src/wallets/cashu/quote.ts create mode 100644 ndk-wallet/src/wallets/cashu/token.ts create mode 100644 ndk-wallet/src/wallets/cashu/validate.ts create mode 100644 ndk-wallet/src/wallets/cashu/wallet/index.ts create mode 100644 ndk-wallet/src/wallets/cashu/wallet/payment.ts create mode 100644 ndk-wallet/src/wallets/cashu/wallet/state.ts create mode 100644 ndk-wallet/src/wallets/cashu/wallet/txs.ts create mode 100644 ndk-wallet/src/wallets/index.ts create mode 100644 ndk-wallet/src/wallets/nwc/index.ts create mode 100644 ndk-wallet/src/wallets/nwc/req.ts create mode 100644 ndk-wallet/src/wallets/nwc/res.ts create mode 100644 ndk-wallet/src/wallets/nwc/types.ts create mode 100644 ndk-wallet/src/wallets/webln/index.ts create mode 100644 ndk-wallet/src/wallets/webln/pay.ts create mode 100644 ndk-wallet/tsconfig.json create mode 100644 ndk/.prettierignore create mode 100644 ndk/CHANGELOG create mode 100644 ndk/CHANGELOG.md create mode 100644 ndk/LICENSE create mode 100644 ndk/OUTBOX.md create mode 100644 ndk/docs-styles.css create mode 100644 ndk/jest.config.ts create mode 100644 ndk/package.json create mode 100644 ndk/src/app-settings/index.ts create mode 100644 ndk/src/blossom/index.ts create mode 100644 ndk/src/cache/index.ts create mode 100644 ndk/src/dvm/schedule.ts create mode 100644 ndk/src/events/content-tagger.test.ts create mode 100644 ndk/src/events/content-tagger.ts create mode 100644 ndk/src/events/dedup.ts create mode 100644 ndk/src/events/encode.test.ts create mode 100644 ndk/src/events/fetch-tagged-event.ts create mode 100644 ndk/src/events/index.test.ts create mode 100644 ndk/src/events/index.ts create mode 100644 ndk/src/events/kind.ts create mode 100644 ndk/src/events/kinds/NDKRelayList.ts create mode 100644 ndk/src/events/kinds/article.ts create mode 100644 ndk/src/events/kinds/classified.ts create mode 100644 ndk/src/events/kinds/drafts.ts create mode 100644 ndk/src/events/kinds/dvm/NDKTranscriptionDVM.ts create mode 100644 ndk/src/events/kinds/dvm/feedback.ts create mode 100644 ndk/src/events/kinds/dvm/index.ts create mode 100644 ndk/src/events/kinds/dvm/request.ts create mode 100644 ndk/src/events/kinds/dvm/result.ts create mode 100644 ndk/src/events/kinds/highlight.ts create mode 100644 ndk/src/events/kinds/index.ts create mode 100644 ndk/src/events/kinds/lists/index.test.ts create mode 100644 ndk/src/events/kinds/lists/index.ts create mode 100644 ndk/src/events/kinds/nip89/NDKAppHandler.ts create mode 100644 ndk/src/events/kinds/nutzap/index.ts create mode 100644 ndk/src/events/kinds/nutzap/mint-list.ts create mode 100644 ndk/src/events/kinds/nutzap/proof.ts create mode 100644 ndk/src/events/kinds/repost.ts create mode 100644 ndk/src/events/kinds/simple-group/index.ts create mode 100644 ndk/src/events/kinds/simple-group/member-list.ts create mode 100644 ndk/src/events/kinds/simple-group/metadata.ts create mode 100644 ndk/src/events/kinds/subscriptions/amount.ts create mode 100644 ndk/src/events/kinds/subscriptions/receipt.ts create mode 100644 ndk/src/events/kinds/subscriptions/subscription-start.ts create mode 100644 ndk/src/events/kinds/subscriptions/tier.test.ts create mode 100644 ndk/src/events/kinds/subscriptions/tier.ts create mode 100644 ndk/src/events/kinds/video.ts create mode 100644 ndk/src/events/kinds/wiki.ts create mode 100644 ndk/src/events/nip04.ts create mode 100644 ndk/src/events/nip19.test.ts create mode 100644 ndk/src/events/nip19.ts create mode 100644 ndk/src/events/nip73.ts create mode 100644 ndk/src/events/repost.ts create mode 100644 ndk/src/events/serializer.ts create mode 100644 ndk/src/events/signature.ts create mode 100644 ndk/src/events/validation.ts create mode 100644 ndk/src/index.ts create mode 100644 ndk/src/light-bolt11-decoder.d.ts create mode 100644 ndk/src/media/index.test.ts create mode 100644 ndk/src/media/index.ts create mode 100644 ndk/src/ndk/active-user.ts create mode 100644 ndk/src/ndk/fetch-event-from-tag.test.ts create mode 100644 ndk/src/ndk/fetch-event-from-tag.ts create mode 100644 ndk/src/ndk/index.ts create mode 100644 ndk/src/ndk/queue/index.ts create mode 100644 ndk/src/outbox/index.ts create mode 100644 ndk/src/outbox/read/with-authors.ts create mode 100644 ndk/src/outbox/relay-ranking.ts create mode 100644 ndk/src/outbox/tracker.test.ts create mode 100644 ndk/src/outbox/tracker.ts create mode 100644 ndk/src/outbox/write.ts create mode 100644 ndk/src/relay/auth-policies.test.ts create mode 100644 ndk/src/relay/auth-policies.ts create mode 100644 ndk/src/relay/connectivity.test.ts create mode 100644 ndk/src/relay/connectivity.ts create mode 100644 ndk/src/relay/index.test.ts create mode 100644 ndk/src/relay/index.ts create mode 100644 ndk/src/relay/pool/index.test.ts create mode 100644 ndk/src/relay/pool/index.ts create mode 100644 ndk/src/relay/publisher.ts create mode 100644 ndk/src/relay/score.ts create mode 100644 ndk/src/relay/sets/calculate.test.ts create mode 100644 ndk/src/relay/sets/calculate.ts create mode 100644 ndk/src/relay/sets/index.ts create mode 100644 ndk/src/relay/sets/utils.ts create mode 100644 ndk/src/relay/sub-manager.ts create mode 100644 ndk/src/relay/subscription.test.ts create mode 100644 ndk/src/relay/subscription.ts create mode 100644 ndk/src/signers/index.ts create mode 100644 ndk/src/signers/nip07/index.ts create mode 100644 ndk/src/signers/nip46/backend/connect.ts create mode 100644 ndk/src/signers/nip46/backend/get-public-key.ts create mode 100644 ndk/src/signers/nip46/backend/index.ts create mode 100644 ndk/src/signers/nip46/backend/nip04-decrypt.ts create mode 100644 ndk/src/signers/nip46/backend/nip04-encrypt.ts create mode 100644 ndk/src/signers/nip46/backend/nip44-decrypt.ts create mode 100644 ndk/src/signers/nip46/backend/nip44-encrypt.ts create mode 100644 ndk/src/signers/nip46/backend/ping.ts create mode 100644 ndk/src/signers/nip46/backend/sign-event.ts create mode 100644 ndk/src/signers/nip46/index.test.ts create mode 100644 ndk/src/signers/nip46/index.ts create mode 100644 ndk/src/signers/nip46/rpc.ts create mode 100644 ndk/src/signers/private-key/index.test.ts create mode 100644 ndk/src/signers/private-key/index.ts create mode 100644 ndk/src/subscription/grouping.test.ts create mode 100644 ndk/src/subscription/grouping.ts create mode 100644 ndk/src/subscription/index.test.ts create mode 100644 ndk/src/subscription/index.ts create mode 100644 ndk/src/subscription/manager.ts create mode 100644 ndk/src/subscription/utils.test.ts create mode 100644 ndk/src/subscription/utils.ts create mode 100644 ndk/src/thread/index.test.ts create mode 100644 ndk/src/thread/index.ts create mode 100644 ndk/src/user/follows.test.ts create mode 100644 ndk/src/user/follows.ts create mode 100644 ndk/src/user/index.test.ts create mode 100644 ndk/src/user/index.ts create mode 100644 ndk/src/user/nip05.test.ts create mode 100644 ndk/src/user/nip05.ts create mode 100644 ndk/src/user/pin.ts create mode 100644 ndk/src/user/profile.ts create mode 100644 ndk/src/utils/get-users-relay-list.ts create mode 100644 ndk/src/utils/normalize-url.ts create mode 100644 ndk/src/utils/timeout.ts create mode 100644 ndk/src/workers/sig-verification.ts create mode 100644 ndk/src/zap/invoice.ts create mode 100644 ndk/src/zapper/index.test.ts create mode 100644 ndk/src/zapper/index.ts create mode 100644 ndk/src/zapper/ln.ts create mode 100644 ndk/src/zapper/nip57.ts create mode 100644 ndk/src/zapper/nip61.ts create mode 100644 ndk/tsconfig.json create mode 100644 ndk/typedoc.json create mode 100644 packages/eslint-config-custom/index.json create mode 100644 packages/eslint-config-custom/package.json create mode 100644 packages/tailwind-config/package.json create mode 100644 packages/tailwind-config/tailwind.config.js create mode 100644 packages/tsconfig/base.json create mode 100644 packages/tsconfig/ndk-cache-dexie.json create mode 100644 packages/tsconfig/ndk-cache-redis.json create mode 100644 packages/tsconfig/ndk-svelte.json create mode 100644 packages/tsconfig/ndk.json create mode 100644 packages/tsconfig/package.json create mode 100644 tsconfig.json diff --git a/.changeset/README.md b/.changeset/README.md new file mode 100644 index 00000000..e5b6d8d6 --- /dev/null +++ b/.changeset/README.md @@ -0,0 +1,8 @@ +# Changesets + +Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works +with multi-package repos, or single-package repos to help you version and publish your code. You can +find the full documentation for it [in our repository](https://github.com/changesets/changesets) + +We have a quick list of common questions to get you started engaging with this project in +[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md) diff --git a/.changeset/cold-pianos-tickle.md b/.changeset/cold-pianos-tickle.md new file mode 100644 index 00000000..e7993579 --- /dev/null +++ b/.changeset/cold-pianos-tickle.md @@ -0,0 +1,5 @@ +--- +"@nostr-dev-kit/ndk": minor +--- + +deprecate user.zap/ndk.zap -- use new NDKZapper instead diff --git a/.changeset/config.json b/.changeset/config.json new file mode 100644 index 00000000..77b04199 --- /dev/null +++ b/.changeset/config.json @@ -0,0 +1,11 @@ +{ + "$schema": "https://unpkg.com/@changesets/config@2.3.1/schema.json", + "changelog": "@changesets/cli/changelog", + "commit": false, + "fixed": [], + "linked": [], + "access": "public", + "baseBranch": "master", + "updateInternalDependencies": "patch", + "ignore": [] +} diff --git a/.changeset/eighty-toes-refuse.md b/.changeset/eighty-toes-refuse.md new file mode 100644 index 00000000..21a099c7 --- /dev/null +++ b/.changeset/eighty-toes-refuse.md @@ -0,0 +1,5 @@ +--- +"@nostr-dev-kit/ndk": patch +--- + +move NWC to ndk-wallet diff --git a/.changeset/fifty-llamas-boil.md b/.changeset/fifty-llamas-boil.md new file mode 100644 index 00000000..657b902d --- /dev/null +++ b/.changeset/fifty-llamas-boil.md @@ -0,0 +1,5 @@ +--- +"@nostr-dev-kit/ndk": patch +--- + +add pubkey hint to e tags diff --git a/.changeset/flat-garlics-taste.md b/.changeset/flat-garlics-taste.md new file mode 100644 index 00000000..e59d34d0 --- /dev/null +++ b/.changeset/flat-garlics-taste.md @@ -0,0 +1,5 @@ +--- +"@nostr-dev-kit/ndk-mobile": patch +--- + +add useUserProfile hook diff --git a/.changeset/fresh-oranges-guess.md b/.changeset/fresh-oranges-guess.md new file mode 100644 index 00000000..a56d009c --- /dev/null +++ b/.changeset/fresh-oranges-guess.md @@ -0,0 +1,5 @@ +--- +"@nostr-dev-kit/ndk-svelte": minor +--- + +add support for Svelte 5's runes diff --git a/.changeset/great-keys-knock.md b/.changeset/great-keys-knock.md new file mode 100644 index 00000000..11cf8620 --- /dev/null +++ b/.changeset/great-keys-knock.md @@ -0,0 +1,5 @@ +--- +"@nostr-dev-kit/ndk-mobile": patch +--- + +add LRU cache for profiles diff --git a/.changeset/khaki-pets-smell.md b/.changeset/khaki-pets-smell.md new file mode 100644 index 00000000..4638c43b --- /dev/null +++ b/.changeset/khaki-pets-smell.md @@ -0,0 +1,5 @@ +--- +"@nostr-dev-kit/ndk": patch +--- + +fix bug where both a and e tags were going in zap requests diff --git a/.changeset/pretty-berries-talk.md b/.changeset/pretty-berries-talk.md new file mode 100644 index 00000000..76efd29c --- /dev/null +++ b/.changeset/pretty-berries-talk.md @@ -0,0 +1,5 @@ +--- +"@nostr-dev-kit/ndk-wallet": patch +--- + +NWC support diff --git a/.changeset/purple-fireants-invite.md b/.changeset/purple-fireants-invite.md new file mode 100644 index 00000000..5e7433de --- /dev/null +++ b/.changeset/purple-fireants-invite.md @@ -0,0 +1,5 @@ +--- +"@nostr-dev-kit/ndk-mobile": patch +--- + +add sync profile fetching from cache diff --git a/.changeset/silly-cows-boil.md b/.changeset/silly-cows-boil.md new file mode 100644 index 00000000..f809c2d9 --- /dev/null +++ b/.changeset/silly-cows-boil.md @@ -0,0 +1,5 @@ +--- +"@nostr-dev-kit/ndk-cache-dexie": patch +--- + +add support in dexie cache to retrieve profile info synchronously diff --git a/.changeset/strong-files-fly.md b/.changeset/strong-files-fly.md new file mode 100644 index 00000000..2fef01c2 --- /dev/null +++ b/.changeset/strong-files-fly.md @@ -0,0 +1,5 @@ +--- +"@nostr-dev-kit/ndk": patch +--- + +add NIP-22 support diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 00000000..0ccefc48 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,13 @@ +# FIXME: Hardcoded node version +# FIXME: Use prod and dev stages! +FROM node:20-slim + +RUN corepack enable + +# FIXME: We need to use a WORKDIR because of +# https://stackoverflow.com/a/65443098 but +# the choice of the actual dir is quite arbitrary. +COPY . /app +WORKDIR /app + +RUN pnpm install diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..709d82c2 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,29 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/javascript-node +{ + "name": "NDK devcontainer", + "build": { + // Path is relative to the devcontainer.json file. + "dockerfile": "Dockerfile", + "context": "../" + }, + "customizations": { + "vscode": { + "settings": { + "terminal.integrated.shell.linux": "/bin/bash" + } + } + }, + // Add pnpm bin to path, so we have turbo available + "postStartCommand": "echo 'export PATH=$(pnpm bin):$PATH' >> ~/.bashrc && . ~/.bashrc" + // Features to add to the dev container. More info: https://containers.dev/features. + // "features": {}, + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "yarn install", + // Configure tool-specific properties. + // "customizations": {}, + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "root" +} diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 00000000..e5dc490a --- /dev/null +++ b/.eslintignore @@ -0,0 +1,13 @@ +.DS_Store +node_modules +build +dist +package +.env +.env.* +!.env.example + +# Ignore files for PNPM, NPM and YARN +pnpm-lock.yaml +package-lock.json +yarn.lock diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 00000000..8b05a81c --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,3 @@ +module.exports = { + extends: ["@nostr-dev-kit/custom"], +}; diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 00000000..605f05db --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,66 @@ +# Sample workflow for building and deploying a VitePress site to GitHub Pages +# +name: Deploy VitePress site to Pages + +on: + # Runs on pushes targeting the `main` branch. Change this to `master` if you're + # using the `master` branch as the default branch. + push: + branches: + - '*' + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. +concurrency: + group: pages + cancel-in-progress: false + +jobs: + # Build job + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 # Not needed if lastUpdated is not enabled + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: '20' + - name: Setup PNPM + uses: pnpm/action-setup@v4 + - name: Setup Pages + uses: actions/configure-pages@v4 + - name: Install dependencies + run: pnpm install # or pnpm install / yarn install / bun install + - name: Build with VitePress + run: pnpm docs:build # or pnpm docs:build / yarn docs:build / bun run docs:build + - name: Build typedoc + run: cd ndk && pnpm typedoc --out ../docs/.vitepress/dist/api + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + path: docs/.vitepress/dist + + # Deployment job + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + needs: build + runs-on: ubuntu-latest + name: Deploy + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..f757754f --- /dev/null +++ b/.prettierignore @@ -0,0 +1,5 @@ +dist +docs +coverage +**/.changeset +**/.svelte-kit diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 00000000..4431ccbf --- /dev/null +++ b/.prettierrc @@ -0,0 +1,16 @@ +{ + "useTabs": false, + "tabWidth": 4, + "singleQuote": false, + "semi": true, + "trailingComma": "es5", + "printWidth": 100, + "overrides": [ + { + "files": "*.svelte", + "options": { + "parser": "svelte" + } + } + ] +} diff --git a/BUILD.md b/BUILD.md new file mode 100644 index 00000000..741a89e4 --- /dev/null +++ b/BUILD.md @@ -0,0 +1,20 @@ +# Build NDK + +NDK is structured as a monorepo using `pnpm` as the package manager. + +``` +git clone https://github.com/nostr-dev-kit/ndk +cd ndk +pnpm install +pnpm build +``` + +If you only care about building ndk core and not the family of packages you can just + +``` +git clone https://github.com/nostr-dev-kit/ndk +cd ndk +pnpm install +cd ndk +pnpm build +``` diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..2a6ea523 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 Pablo Fernandez + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/REFERENCES.md b/REFERENCES.md new file mode 100644 index 00000000..48274ac7 --- /dev/null +++ b/REFERENCES.md @@ -0,0 +1,45 @@ +# Open source Nostr apps using NDK + +This is a running list of applications using NDK that are open source. Use these codebases to understand +how others handle Nostr things using NDK. + +If you are the author of an application that uses NDK, send a pull-request to this repo adding your application +to this list. + +- [Highlighter](https://github.com/kind-0/highlighter) - By [@pablof7z](https://njump.me/npub1l2vyh47mk2p0qlsku7hg0vn29faehy9hy34ygaclpn66ukqp3afqutajft) + - Svelte, frontend +- [nsecBunker](https://github.com/kind-0/nsecbunkerd) - By [@pablof7z](https://njump.me/npub1l2vyh47mk2p0qlsku7hg0vn29faehy9hy34ygaclpn66ukqp3afqutajft) + - Typescript, backend +- [Highlighter Chrome Extension](https://github.com/pablof7z/highlighter-chrome-extension/) - By [@pablof7z](https://njump.me/npub1l2vyh47mk2p0qlsku7hg0vn29faehy9hy34ygaclpn66ukqp3afqutajft) + - Typescript, Chrome extension +- [Nostr Data Vending Machine](https://github.com/pablof7z/nostr-data-vending-machine) - By [@pablof7z](https://njump.me/npub1l2vyh47mk2p0qlsku7hg0vn29faehy9hy34ygaclpn66ukqp3afqutajft) + - Typescript, backend +- [Nostr Chat Widget](https://github.com/pablof7z/nostr-chat-widget) - By [@pablof7z](https://njump.me/npub1l2vyh47mk2p0qlsku7hg0vn29faehy9hy34ygaclpn66ukqp3afqutajft) + - Svelte, Rollup, embeddable widget +- [Zapstr](https://github.com/zapstr/zapstr) - By [@pablof7z](https://njump.me/npub1l2vyh47mk2p0qlsku7hg0vn29faehy9hy34ygaclpn66ukqp3afqutajft) + - Svelte, Frontend +- [Ostrich.work](https://github.com/erskingardner/ostrich.work) - By [@jeffg](https://njump.me/npub1zuuajd7u3sx8xu92yav9jwxpr839cs0kc3q6t56vd5u9q033xmhsk6c2uc) + - Svelte, frontend +- [Listr.lol](https://github.com/erskingardner/listr) - By [@jeffg](https://njump.me/npub1zuuajd7u3sx8xu92yav9jwxpr839cs0kc3q6t56vd5u9q033xmhsk6c2uc) + - Svelte, frontend +- [Lume](https://github.com/luminous-devs/lume) - By [@reya](https://njump.me/npub1zfss807aer0j26mwp2la0ume0jqde3823rmu97ra6sgyyg956e0s6xw445) + - Tauri, Desktop app +- [Nostr App Manager](https://github.com/nostrband/nostr-app-manager) - By [@nostrband](https://njump.me/npub1wc4rc9wxl2gfzxl384g0cw3f79nrms0sfdpe02y7aasy7c3we4sqd0qywr) + - React, Frontend +- [Stemstr](https://github.com/stemstr/Client) - By [@stemstr](https://njump.me/npub1stemstrls4f5plqeqkeq43gtjhtycuqd9w25v5r5z5ygaq2n2sjsd6mul5) +- [Audgit.ai](https://github.com/ArcadeLabsInc/audgit.ai) - By [@ArcadeLabsInc](https://njump.me/npub1tlv67m7xvlyplzexuynmfpguvyet0sjffce3y8vu0suuyuwgzauqjk7fdm) +- [Swarmstr](https://github.com/ptrio42/swarmstr.com) - By [@pitiunited](https://njump.me/npub178umpxtdflcm7a08nexvs4mu384kx0ngg9w8ltm5eut6q7lcp0vq05qrg4) +- [zapddit](https://github.com/vivganes/zapddit) - By [@vivganes](https://njump.me/npub1ltx67888tz7lqnxlrg06x234vjnq349tcfyp52r0lstclp548mcqnuz40t) +- [Nuxstr](https://github.com/Sebastix/nuxstr) - By [@Sebastix](https://njump.me/sebastian@sebastix.dev) + - Nuxt (Vue), frontend +- [Flockstr](https://github.com/zmeyer44/flockstr) - By [@zach](https://njump.me/npub1zach44xjpc4yyhx6pgse2cj2pf98838kja03dv2e8ly8lfr094vqvm5dy5) +- [Flare.pub](https://github.com/zmeyer44/flare) - By [@zach](https://njump.me/npub1zach44xjpc4yyhx6pgse2cj2pf98838kja03dv2e8ly8lfr094vqvm5dy5) +- [Pinstr.app](https://github.com/sepehr-safari/pinstr) - By [@sepehr](https://njump.me/nprofile1qqsru22d9lfnnwck54qr4phrvey50h2q33xc0gqxv5j03ftn4efu4rspr9mhxue69uhhyetvv9ujuumwdae8gtnnda3kjctv9uq3wamnwvaz7tmjwdekccte9ehx7um5wghx6mm99uq36amnwvaz7tmwdaehgu3wd46hg6tw09mkzmrvv46zucm0d5hsv6ffvh) + - React, Nostr Web Client +- [Nostr-Hooks](https://github.com/ostyjs/nostr-hooks) - By [@sepehr](https://njump.me/nprofile1qqsru22d9lfnnwck54qr4phrvey50h2q33xc0gqxv5j03ftn4efu4rspr9mhxue69uhhyetvv9ujuumwdae8gtnnda3kjctv9uq3wamnwvaz7tmjwdekccte9ehx7um5wghx6mm99uq36amnwvaz7tmwdaehgu3wd46hg6tw09mkzmrvv46zucm0d5hsv6ffvh) + - Stateful wrapper library of React hooks around NDK. +- [magicCity h=n](https://github.com/tezosmiami/hicetnunc) - By [@hicetnunc2000](https://github.com/hicetnunc2000/), [@tezosmiami](https://njump.me/npub190rqwj0nud4uhvmaeg7cgn0gypu0s09j87vqjluhfhju0req2khsskh9w7) +- [notepress](https://github.com/utxo-one/notepress) - By [@utxo](httsp://njump.me/_@utxo.one) + - No frameworks! A very simple long-form (NIP-23) reader +- [Olas 🌊](https://github.com/pablof7z/snapstr) - By [@pablof7z](https://njump.me/f7z.io) + - React Native, mobile-only app diff --git a/docs/.vitepress/config.mts b/docs/.vitepress/config.mts new file mode 100644 index 00000000..75669e0d --- /dev/null +++ b/docs/.vitepress/config.mts @@ -0,0 +1,78 @@ +import { defineConfig } from 'vitepress' +import { withMermaid } from "vitepress-plugin-mermaid"; + +// https://vitepress.dev/reference/site-config +export default withMermaid(defineConfig({ + title: "NDK", + description: "NDK Docs", + base: "/ndk/", + ignoreDeadLinks: true, + themeConfig: { + // https://vitepress.dev/reference/default-theme-config + nav: [ + { text: 'Home', link: '/' }, + { text: 'API Reference', link: '/api/', target: '_blank' }, + { text: 'Wiki', link: 'https://wikifreedia.xyz/?c=NDK', target: '_blank' }, + ], + + sidebar: [ + { + text: "Getting Started", + items: [ + { text: 'Introduction', link: '/getting-started/introduction' }, + { text: 'Usage', link: '/getting-started/usage' }, + { text: 'Signers', link: '/getting-started/signers' }, + ] + }, + { + text: 'Tutorial', + items: [ + { text: 'Local-first', link: '/tutorial/local-first' }, + { text: 'Publishing', link: '/tutorial/publishing' }, + { text: "Subscription Management", link: '/tutorial/subscription-management' }, + { text: "Speed", link: '/tutorial/speed' }, + { text: 'Zaps', link: '/tutorial/zaps' }, + ] + }, + { + text: "Cache Adapters", + items: [ + { text: 'In-memory + dexie', link: '/cache/dexie' }, + { text: 'Local Nostr Relay', link: '/cache/nostr' }, + ] + }, + { + text: "Wallet", + items: [ + { text: 'Introduction', link: '/wallet/index' }, + { text: 'Nutsack (NIP-60)', link: '/wallet/nutsack' }, + { text: 'Nutzaps', link: '/wallet/nutzaps' }, + ] + }, + { + text: "Wrappers", + items: [ + { text: 'NDK Svelte', link: '/wrappers/svelte' }, + ] + }, + { + text: "Mobile", + items: [ + { text: 'Introduction', link: '/mobile/index' }, + { text: 'Session', link: '/mobile/session' }, + { text: 'Wallet', link: '/mobile/wallet' }, + ] + }, + { + text: "Internals", + items: [ + { text: "Subscription Lifecycle", link: '/internals/subscriptions' }, + ] + } + ], + + socialLinks: [ + { icon: 'github', link: 'https://github.com/nostr-dev-kit/ndk' } + ] + } +})) \ No newline at end of file diff --git a/docs/.vitepress/theme/index.ts b/docs/.vitepress/theme/index.ts new file mode 100644 index 00000000..def4cfc8 --- /dev/null +++ b/docs/.vitepress/theme/index.ts @@ -0,0 +1,17 @@ +// https://vitepress.dev/guide/custom-theme +import { h } from 'vue' +import type { Theme } from 'vitepress' +import DefaultTheme from 'vitepress/theme' +import './style.css' + +export default { + extends: DefaultTheme, + Layout: () => { + return h(DefaultTheme.Layout, null, { + // https://vitepress.dev/guide/extending-default-theme#layout-slots + }) + }, + enhanceApp({ app, router, siteData }) { + // ... + } +} satisfies Theme diff --git a/docs/.vitepress/theme/style.css b/docs/.vitepress/theme/style.css new file mode 100644 index 00000000..d63aee82 --- /dev/null +++ b/docs/.vitepress/theme/style.css @@ -0,0 +1,139 @@ +/** + * Customize default theme styling by overriding CSS variables: + * https://github.com/vuejs/vitepress/blob/main/src/client/theme-default/styles/vars.css + */ + +/** + * Colors + * + * Each colors have exact same color scale system with 3 levels of solid + * colors with different brightness, and 1 soft color. + * + * - `XXX-1`: The most solid color used mainly for colored text. It must + * satisfy the contrast ratio against when used on top of `XXX-soft`. + * + * - `XXX-2`: The color used mainly for hover state of the button. + * + * - `XXX-3`: The color for solid background, such as bg color of the button. + * It must satisfy the contrast ratio with pure white (#ffffff) text on + * top of it. + * + * - `XXX-soft`: The color used for subtle background such as custom container + * or badges. It must satisfy the contrast ratio when putting `XXX-1` colors + * on top of it. + * + * The soft color must be semi transparent alpha channel. This is crucial + * because it allows adding multiple "soft" colors on top of each other + * to create a accent, such as when having inline code block inside + * custom containers. + * + * - `default`: The color used purely for subtle indication without any + * special meanings attched to it such as bg color for menu hover state. + * + * - `brand`: Used for primary brand colors, such as link text, button with + * brand theme, etc. + * + * - `tip`: Used to indicate useful information. The default theme uses the + * brand color for this by default. + * + * - `warning`: Used to indicate warning to the users. Used in custom + * container, badges, etc. + * + * - `danger`: Used to show error, or dangerous message to the users. Used + * in custom container, badges, etc. + * -------------------------------------------------------------------------- */ + + :root { + --vp-c-default-1: var(--vp-c-gray-1); + --vp-c-default-2: var(--vp-c-gray-2); + --vp-c-default-3: var(--vp-c-gray-3); + --vp-c-default-soft: var(--vp-c-gray-soft); + + --vp-c-brand-1: var(--vp-c-indigo-1); + --vp-c-brand-2: var(--vp-c-indigo-2); + --vp-c-brand-3: var(--vp-c-indigo-3); + --vp-c-brand-soft: var(--vp-c-indigo-soft); + + --vp-c-tip-1: var(--vp-c-brand-1); + --vp-c-tip-2: var(--vp-c-brand-2); + --vp-c-tip-3: var(--vp-c-brand-3); + --vp-c-tip-soft: var(--vp-c-brand-soft); + + --vp-c-warning-1: var(--vp-c-yellow-1); + --vp-c-warning-2: var(--vp-c-yellow-2); + --vp-c-warning-3: var(--vp-c-yellow-3); + --vp-c-warning-soft: var(--vp-c-yellow-soft); + + --vp-c-danger-1: var(--vp-c-red-1); + --vp-c-danger-2: var(--vp-c-red-2); + --vp-c-danger-3: var(--vp-c-red-3); + --vp-c-danger-soft: var(--vp-c-red-soft); +} + +/** + * Component: Button + * -------------------------------------------------------------------------- */ + +:root { + --vp-button-brand-border: transparent; + --vp-button-brand-text: var(--vp-c-white); + --vp-button-brand-bg: var(--vp-c-brand-3); + --vp-button-brand-hover-border: transparent; + --vp-button-brand-hover-text: var(--vp-c-white); + --vp-button-brand-hover-bg: var(--vp-c-brand-2); + --vp-button-brand-active-border: transparent; + --vp-button-brand-active-text: var(--vp-c-white); + --vp-button-brand-active-bg: var(--vp-c-brand-1); +} + +/** + * Component: Home + * -------------------------------------------------------------------------- */ + +:root { + --vp-home-hero-name-color: transparent; + --vp-home-hero-name-background: -webkit-linear-gradient( + 120deg, + #bd34fe 30%, + #41d1ff + ); + + --vp-home-hero-image-background-image: linear-gradient( + -45deg, + #bd34fe 50%, + #47caff 50% + ); + --vp-home-hero-image-filter: blur(44px); +} + +@media (min-width: 640px) { + :root { + --vp-home-hero-image-filter: blur(56px); + } +} + +@media (min-width: 960px) { + :root { + --vp-home-hero-image-filter: blur(68px); + } +} + +/** + * Component: Custom Block + * -------------------------------------------------------------------------- */ + +:root { + --vp-custom-block-tip-border: transparent; + --vp-custom-block-tip-text: var(--vp-c-text-1); + --vp-custom-block-tip-bg: var(--vp-c-brand-soft); + --vp-custom-block-tip-code-bg: var(--vp-c-brand-soft); +} + +/** + * Component: Algolia + * -------------------------------------------------------------------------- */ + +.DocSearch { + --docsearch-primary-color: var(--vp-c-brand-1) !important; +} + diff --git a/docs/api-examples.md b/docs/api-examples.md new file mode 100644 index 00000000..6bd8bb5c --- /dev/null +++ b/docs/api-examples.md @@ -0,0 +1,49 @@ +--- +outline: deep +--- + +# Runtime API Examples + +This page demonstrates usage of some of the runtime APIs provided by VitePress. + +The main `useData()` API can be used to access site, theme, and page data for the current page. It works in both `.md` and `.vue` files: + +```md + + +## Results + +### Theme Data +
{{ theme }}
+ +### Page Data +
{{ page }}
+ +### Page Frontmatter +
{{ frontmatter }}
+``` + + + +## Results + +### Theme Data +
{{ theme }}
+ +### Page Data +
{{ page }}
+ +### Page Frontmatter +
{{ frontmatter }}
+ +## More + +Check out the documentation for the [full list of runtime APIs](https://vitepress.dev/reference/runtime-api#usedata). diff --git a/docs/cache/dexie.md b/docs/cache/dexie.md new file mode 100644 index 00000000..114b53bd --- /dev/null +++ b/docs/cache/dexie.md @@ -0,0 +1,153 @@ +# Dexie Cache + +Meant to be used client-side within a browser context. This is a cache adapter for [Dexie](https://dexie.org/), a wrapper around IndexedDB. + +## Usage + +NDK will attempt to use the Dexie adapter to store users, events, and tags. The default behaviour is to always check the cache first and then hit relays, replacing older cached events as needed. + +## Support + +- [x] Events +- [x] User profiles +- [x] Event<>Tag indexes +- [x] NIP-05 lookups +- [x] Unpublished events + +### Install + +``` +pnpm add @nostr-dev-kit/ndk-cache-dexie +``` + +### Add as a cache adapter + +```ts +import NDKCacheAdapterDexie from "@nostr-dev-kit/ndk-cache-dexie"; + +const dexieAdapter = new NDKCacheAdapterDexie({ dbName: 'your-db-name' }); +const ndk = new NDK({cacheAdapter: dexieAdapter, ...other config options}); +``` + +🚨 Because Dexie only exists client-side, this cache adapter will not work in pure node.js environments. You'll need to make sure that you're using the right cache adapter in the right place (e.g. Redis on the backend, Dexie on the frontend). + +## Slowness + +Because IndexDB is painfully slow, this adapter will primarly act via an LRU cache that periodically flushes to the database. Individual read/writes don't directly hit the database. + +## Options + +[**NDK Dexie Cache Adapter**](../README.md) • **Docs** + +*** + +[NDK Dexie Cache Adapter](../globals.md) / NDKCacheAdapterDexieOptions + +# Interface: NDKCacheAdapterDexieOptions + +## Properties + +### dbName? + +> `optional` **dbName**: `string` + +The name of the database to use + +#### Defined in + +[ndk-cache-dexie/src/index.ts:34](https://github.com/nostr-dev-kit/ndk/blob/26ea669eeeadbc93b894cac1f29829e9a41694cb/ndk-cache-dexie/src/index.ts#L34) + +*** + +### debug? + +> `optional` **debug**: `Debugger` + +Debug instance to use for logging + +#### Defined in + +[ndk-cache-dexie/src/index.ts:39](https://github.com/nostr-dev-kit/ndk/blob/26ea669eeeadbc93b894cac1f29829e9a41694cb/ndk-cache-dexie/src/index.ts#L39) + +*** + +### eventCacheSize? + +> `optional` **eventCacheSize**: `number` + +#### Defined in + +[ndk-cache-dexie/src/index.ts:53](https://github.com/nostr-dev-kit/ndk/blob/26ea669eeeadbc93b894cac1f29829e9a41694cb/ndk-cache-dexie/src/index.ts#L53) + +*** + +### eventTagsCacheSize? + +> `optional` **eventTagsCacheSize**: `number` + +#### Defined in + +[ndk-cache-dexie/src/index.ts:54](https://github.com/nostr-dev-kit/ndk/blob/26ea669eeeadbc93b894cac1f29829e9a41694cb/ndk-cache-dexie/src/index.ts#L54) + +*** + +### expirationTime? + +> `optional` **expirationTime**: `number` + +The number of seconds to store events in Dexie (IndexedDB) before they expire +Defaults to 3600 seconds (1 hour) + +#### Defined in + +[ndk-cache-dexie/src/index.ts:45](https://github.com/nostr-dev-kit/ndk/blob/26ea669eeeadbc93b894cac1f29829e9a41694cb/ndk-cache-dexie/src/index.ts#L45) + +*** + +### indexableKinds? + +> `optional` **indexableKinds**: `number`[] \| `"all"` \| `"none"` + +The kinds of events that should be indexed + +#### Default + +```ts +"all" +``` + +#### Defined in + +[ndk-cache-dexie/src/index.ts:60](https://github.com/nostr-dev-kit/ndk/blob/26ea669eeeadbc93b894cac1f29829e9a41694cb/ndk-cache-dexie/src/index.ts#L60) + +*** + +### nip05CacheSize? + +> `optional` **nip05CacheSize**: `number` + +#### Defined in + +[ndk-cache-dexie/src/index.ts:52](https://github.com/nostr-dev-kit/ndk/blob/26ea669eeeadbc93b894cac1f29829e9a41694cb/ndk-cache-dexie/src/index.ts#L52) + +*** + +### profileCacheSize? + +> `optional` **profileCacheSize**: `number` + +Number of profiles to keep in an LRU cache + +#### Defined in + +[ndk-cache-dexie/src/index.ts:50](https://github.com/nostr-dev-kit/ndk/blob/26ea669eeeadbc93b894cac1f29829e9a41694cb/ndk-cache-dexie/src/index.ts#L50) + +*** + +### zapperCacheSize? + +> `optional` **zapperCacheSize**: `number` + +#### Defined in + +[ndk-cache-dexie/src/index.ts:51](https://github.com/nostr-dev-kit/ndk/blob/26ea669eeeadbc93b894cac1f29829e9a41694cb/ndk-cache-dexie/src/index.ts#L51) diff --git a/docs/cache/nostr.md b/docs/cache/nostr.md new file mode 100644 index 00000000..ec166e2a --- /dev/null +++ b/docs/cache/nostr.md @@ -0,0 +1,34 @@ +# Nostr Cache Adapter + +NDK cache adapter using a nostr relay as the database. + +This cache adapter is meant to be run against a local relay. This adapter will generate two NDK instances: + +`ndk` -- This talks exclusively to the local relay, with outbox model disabled. +`fallbackNdk` -- This is used to hydrate the cache and uses the outbox model -- each query the cache receives is placed in a queue in the background so that subsequent requests can be served from the cache. All events from other relays + +## Usage + +### Install + +``` +npm add @nostr-dev-kit/ndk-cache-nostr + +``` + +### Add as a cache adapter + +```ts +import NDKCacheAdapterNostr from "@nostr-dev-kit/ndk-cache-nostr"; + +const cacheAdapter = new NDKCacheAdapterNostr({ + relayUrl: 'ws://localhost:5577', +}); +const ndk = new NDK({ cacheAdapter }); +``` + +If running server-side in a NodeJS environment, you should make sure to polyfill `WebSocket`. + +# License + +MIT diff --git a/docs/getting-started/introduction.md b/docs/getting-started/introduction.md new file mode 100644 index 00000000..50c63b8f --- /dev/null +++ b/docs/getting-started/introduction.md @@ -0,0 +1,35 @@ +# Getting started + +## Installation + +```sh +npm add @nostr-dev-kit/ndk +``` + +## Debugging + +NDK uses the `debug` package to assist in understanding what's happening behind the hood. If you are building a package +that runs on the server define the `DEBUG` envionment variable like + +```sh +export DEBUG='ndk:*' +``` + +or in the browser enable it by writing in the DevTools console + +```sh +localStorage.debug = 'ndk:*' +``` + +## Network Debugging + +You can construct NDK passing a netDebug callback to receive network traffic events, particularly useful for debugging applications not running in a browser. + +```ts +const netDebug = (msg: string, relay: NDKRelay, direction?: "send" | "recv") = { + const hostname = new URL(relay.url).hostname; + netDebug(hostname, msg, direction); +} + +ndk = new NDK({ netDebug }); +``` diff --git a/docs/getting-started/signers.md b/docs/getting-started/signers.md new file mode 100644 index 00000000..47346bef --- /dev/null +++ b/docs/getting-started/signers.md @@ -0,0 +1,38 @@ +# Signers + +NDK uses signers _optionally_ passed in to sign events. Note that it is possible to use NDK without signing events (e.g. [to get someone's profile](https://github.com/nostr-dev-kit/ndk-cli/blob/master/src/commands/profile.ts)). + +Signing adapters can be passed in when NDK is instantiated or later during runtime. + +### Using a NIP-07 browser extension (e.g. Alby, nos2x) + +Instatiate NDK with a NIP-07 signer + +```ts +// Import the package, NIP-07 signer and NDK event +import NDK, { NDKEvent, NDKNip07Signer } from "@nostr-dev-kit/ndk"; + +const nip07signer = new NDKNip07Signer(); +const ndk = new NDK({ signer: nip07signer }); +``` + +NDK can now ask for permission, via their NIP-07 extension, to... + +**Read the user's public key** + +```ts +nip07signer.user().then(async (user) => { + if (!!user.npub) { + console.log("Permission granted to read their public key:", user.npub); + } +}); +``` + +**Sign & publish events** + +```ts +const ndkEvent = new NDKEvent(ndk); +ndkEvent.kind = 1; +ndkEvent.content = "Hello, world!"; +ndkEvent.publish(); // This will trigger the extension to ask the user to confirm signing. +``` \ No newline at end of file diff --git a/docs/getting-started/usage.md b/docs/getting-started/usage.md new file mode 100644 index 00000000..068f985c --- /dev/null +++ b/docs/getting-started/usage.md @@ -0,0 +1,57 @@ +# Usage + +## Instantiate an NDK instance + +You can pass an object with several options to a newly created instance of NDK. + +- `explicitRelayUrls` – an array of relay URLs. +- `signer` - an instance of a [signer](#signers). +- `cacheAdapter` - an instance of a [Cache Adapter](#caching) +- `debug` - Debug instance to use for logging. Defaults to `debug("ndk")`. + +```ts +// Import the package +import NDK from "@nostr-dev-kit/ndk"; + +// Create a new NDK instance with explicit relays +const ndk = new NDK({ + explicitRelayUrls: ["wss://a.relay", "wss://another.relay"], +}); +``` + +If the signer implements the `getRelays()` method, NDK will use the relays returned by that method as the explicit relays. + +```ts +// Import the package +import NDK, { NDKNip07Signer } from "@nostr-dev-kit/ndk"; + +// Create a new NDK instance with just a signer (provided the signer implements the getRelays() method) +const nip07signer = new NDKNip07Signer(); +const ndk = new NDK({ signer: nip07signer }); +``` + +Note: In normal client use, it's best practice to instantiate NDK as a singleton class. [See more below](#architecture-decisions--suggestions). + +## Connecting + +After you've instatiated NDK, you need to tell it to connect before you'll be able to interact with any relays. + +```ts +// Import the package +import NDK from "@nostr-dev-kit/ndk"; + +// Create a new NDK instance with explicit relays +const ndk = new NDK({ + explicitRelayUrls: ["wss://a.relay", "wss://another.relay"], +}); +// Now connect to specified relays +await ndk.connect(); +``` + +## Architecture decisions & suggestions + +- Users of NDK should instantiate a single NDK instance. +- That instance tracks state with all relays connected, explicit and otherwise. +- All relays are tracked in a single pool that handles connection errors/reconnection logic. +- RelaySets are assembled ad-hoc as needed depending on the queries set, although some RelaySets might be long-lasting, like the `explicitRelayUrls` specified by the user. +- RelaySets are always a subset of the pool of all available relays. diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 00000000..52fac990 --- /dev/null +++ b/docs/index.md @@ -0,0 +1,18 @@ +--- +# https://vitepress.dev/reference/default-theme-home-page +layout: home + +hero: + name: "NDK Documentation" + tagline: "Nostr Development Kit Docs" + actions: + - theme: brand + text: Getting Started + link: /getting-started/introduction.html + - theme: secondary + text: References + link: https://github.com/nostr-dev-kit/ndk/blob/master/REFERENCES.md + +--- + +NDK is a nostr development kit that makes the experience of building Nostr-related applications, whether they are relays, clients, or anything in between, better, more reliable and overall nicer to work with than existing solutions. \ No newline at end of file diff --git a/docs/internals/subscriptions.md b/docs/internals/subscriptions.md new file mode 100644 index 00000000..ab328ce8 --- /dev/null +++ b/docs/internals/subscriptions.md @@ -0,0 +1,205 @@ +# Subscriptions Lifecycle +When an application creates a subscription a lot of things happen under the hood. + +Say we want to see `kind:1` events from pubkeys `123`, `456`, and `678`. + +```ts +const subscription = ndk.subscribe({ kinds: [1], authors: [ "123", "456", "678" ]}) +``` + +Since the application level didn't explicitly provide a relay-set, which is the most common use case, NDK will calculate a relay set based on the outbox model plus a variety of some other factors. + +So the first thing we'll do before talking to relays is, decide to *which* relays we should talk to. + +The `calculateRelaySetsFromFilters` function will take care of this and provide us with a map of relay URLs and filters for each relay. + +This means that the query, as specified by the client might be broken into distinct queries specialized for the different relays. + +For example, if we have 3 relays, and the query is for `kind:1` events from pubkeys `a` and `b`, the `calculateRelaySetsFromFilters` function might return something like this: + +```ts +{ + "wss://relay1": { kinds: [1], authors: [ "a" ] }, + "wss://relay2": { kinds: [1], authors: [ "b" ] }, +} +``` + +```mermaid +flowchart TD + Client -->|"kinds: [1], authors: [a, b]"| Subscription1 + Subscription1 -->|"kinds: [1], authors: [a]"| wss://relay1 + Subscription1 -->|"kinds: [1], authors: [b]"| wss://relay2 +``` + +## Subscription bundling +Once the subscription has been split into the filters each relay should receive, the filters are sent to the individual `NDKRelay`'s `NDKRelaySubscriptionManager` instances. + +`NDKRelaySubscriptionManager` is responsible for keeping track of the active and scheduled subscriptions that are pending to be executed within an individual relay. + +This is an important aspect to consider: + +> `NDKSubscription` have a different lifecycle than `NDKRelaySubscription`. For example, a subscription that is set to close after EOSE might still be active within the `NDKSubscription` lifecycle, but it might have been already been closed within the `NDKRelaySubscription` lifecycle, since NDK attempts to keep the minimum amount of open subscriptions at any given time. + +## NDKRelaySubscription +Most NDK subscriptions (by default) are set to be executed with a grouping delay. Will cover what this looks like in practice later, but for now, let's understand than when the `NDKRelaySubscriptionManager` receives an order, it might not execute it right away. + +The different filters that can be grouped together (thus executed as a single `REQ` within a relay) are grouped within the same `NDKRelaySubscription` instance and the execution scheduler is computed respecting what each individual `NDKSubscription` has requested. + +(For example, if a subscription with a `groupingDelay` of `at-least` 500 millisecond has been grouped with another subscription with a `groupingDelay` of `at-least` 1000 milliseconds, the `NDKRelaySubscriptionManager` will wait 1000 ms before sending the `REQ` to this particular relay). + +### Execution +Once the filter is executed at the relay level, the `REQ` is submitted into that relay's `NDKRelayConnectivity` instance, which will take care of monitoring for responses for this particular REQ and communicate them back into the `NDKRelaySubscription` instance. + +Each `EVENT` that comes back as a response to our `REQ` within this `NDKRelaySubscription` instance is then compared with the filters of each `NDKSubscription` that has been grouped and if it matches, it is sent back to the `NDKSubscription` instance. + + +# Example + +If an application requests `kind:1` of pubkeys `123`, `456`, and `789`. It creates an `NDKSubscription`: + +```ts +ndk.subscribe({ kinds: [1], authors: [ "123", "456", "789" ]}, { groupableDelay: 500, groupableDelayType: 'at-least' }) +// results in NDKSubscription1 with filters { kinds: [1], authors: [ "123", "456", "789" ] } +``` + +Some other part of the application requests a kind:7 from pubkey `123` at the same time. + +```ts +ndk.subscribe({ kinds: [7], authors: [ "123" ]}, { groupableDelay: 500, groupableDelayType: 'at-most' }) +// results in NDKSubscription2 with filters { kinds: [7], authors: [ "123" ] } +``` + +```mermaid +flowchart TD + subgraph Subscriptions Lifecycle + A[Application] -->|"kinds: [1], authors: [123, 456, 678], groupingDelay: at-least 500ms"| B[NDKSubscription1] + + A2[Application] -->|"kinds: [7], authors: [123], groupingDelay: at-most 1000ms"| B2[NDKSubscription2] + end +``` + +Both subscriptions have their relayset calculated by NDK and, the resulting filters are sent into the `NDKRelaySubscriptionManager`, which will decide what, and how filters can be grouped. + +```mermaid +flowchart TD + subgraph Subscriptions Lifecycle + A[Application] -->|"kinds: [1], authors: [123, 456, 678], groupingDelay: at-least 500ms"| B[NDKSubscription1] + B --> C{Calculate Relay Sets} + + A2[Application] -->|"kinds: [7], authors: [123], groupingDelay: at-most 1000ms"| B2[NDKSubscription2] + B2 --> C2{Calculate Relay Sets} + end + + subgraph Subscription Bundling + C -->|"kinds: [1], authors: [123]"| E1[wss://relay1 NDKRelaySubscriptionManager] + C -->|"kinds: [1], authors: [456]"| E2[wss://relay2 NDKRelaySubscriptionManager] + C -->|"kinds: [1], authors: [678]"| E3[wss://relay3 NDKRelaySubscriptionManager] + + C2 -->|"kinds: [7], authors: [123]"| E1 + end +``` + +The `NDKRelaySubscriptionManager` will create `NDKRelaySubscription` instances, or add filters to them if `NDKRelaySubscription` with the same filter fingerprint exists. + +```mermaid +flowchart TD + subgraph Subscriptions Lifecycle + A[Application] -->|"kinds: [1], authors: [123, 456, 678], groupingDelay: at-least 500ms"| B[NDKSubscription1] + B --> C{Calculate Relay Sets} + + A2[Application] -->|"kinds: [7], authors: [123], groupingDelay: at-most 1000ms"| B2[NDKSubscription2] + B2 --> C2{Calculate Relay Sets} + end + + subgraph Subscription Bundling + C -->|"kinds: [1], authors: [123]"| E1[wss://relay1 NDKRelaySubscriptionManager] + C -->|"kinds: [1], authors: [456]"| E2[wss://relay2 NDKRelaySubscriptionManager] + C -->|"kinds: [1], authors: [678]"| E3[wss://relay3 NDKRelaySubscriptionManager] + + C2 -->|"kinds: [7], authors: [123]"| E1 + + E1 -->|"Grouping Delay: at-most 1000ms"| F1[NDKRelaySubscription] + E2 -->|"Grouping Delay: at-least 500ms"| F2[NDKRelaySubscription] + E3 -->|"Grouping Delay: at-least 500ms"| F3[NDKRelaySubscription] + end +``` + +Each individual `NDKRelaySubscription` computes the execution schedule of the filters it has received and sends them to the `NDKRelayConnectivity` instance, which in turns sends the `REQ` to the relay. + +```mermaid +flowchart TD + subgraph Subscriptions Lifecycle + A[Application] -->|"kinds: [1], authors: [123, 456, 678], groupingDelay: at-least 500ms"| B[NDKSubscription1] + B --> C{Calculate Relay Sets} + + A2[Application] -->|"kinds: [7], authors: [123], groupingDelay: at-most 1000ms"| B2[NDKSubscription2] + B2 --> C2{Calculate Relay Sets} + end + + subgraph Subscription Bundling + C -->|"kinds: [1], authors: [123]"| E1[wss://relay1 NDKRelaySubscriptionManager] + C -->|"kinds: [1], authors: [456]"| E2[wss://relay2 NDKRelaySubscriptionManager] + C -->|"kinds: [1], authors: [678]"| E3[wss://relay3 NDKRelaySubscriptionManager] + + C2 -->|"kinds: [7], authors: [123]"| E1 + + E1 -->|"Grouping Delay: at-most 1000ms"| F1[NDKRelaySubscription] + E2 -->|"Grouping Delay: at-least 500ms"| F2[NDKRelaySubscription] + E3 -->|"Grouping Delay: at-least 500ms"| F3[NDKRelaySubscription] + + F1 -->|"REQ: kinds: [1, 7], authors: [123]"| G1[NDKRelayConnectivity] + F2 -->|"REQ: kinds: [1], authors: [456]"| G2[NDKRelayConnectivity] + F3 -->|"REQ: kinds: [1], authors: [678]"| G3[NDKRelayConnectivity] + end + + subgraph Execution + G1 -->|"Send REQ to wss://relay1 after 1000ms"| R1[Relay1] + G2 -->|"Send REQ to wss://relay2 after 500ms"| R2[Relay2] + G3 -->|"Send REQ to wss://relay3 after 500ms"| R3[Relay3] + end +``` + +As the events come from the relays, `NDKRelayConnectivity` will send them back to the `NDKRelaySubscription` instance, which will compare the event with the filters of the `NDKSubscription` instances that have been grouped together and send the received event back to the correct `NDKSubscription` instance. + +```mermaid +flowchart TD + subgraph Subscriptions Lifecycle + A[Application] -->|"kinds: [1], authors: [123, 456, 678], groupingDelay: at-least 500ms"| B[NDKSubscription1] + B --> C{Calculate Relay Sets} + + A2[Application] -->|"kinds: [7], authors: [123], groupingDelay: at-most 1000ms"| B2[NDKSubscription2] + B2 --> C2{Calculate Relay Sets} + end + + subgraph Subscription Bundling + C -->|"kinds: [1], authors: [123]"| E1[wss://relay1 NDKRelaySubscriptionManager] + C -->|"kinds: [1], authors: [456]"| E2[wss://relay2 NDKRelaySubscriptionManager] + C -->|"kinds: [1], authors: [678]"| E3[wss://relay3 NDKRelaySubscriptionManager] + + C2 -->|"kinds: [7], authors: [123]"| E1 + + E1 -->|"Grouping Delay: at-most 1000ms"| F1[NDKRelaySubscription] + E2 -->|"Grouping Delay: at-least 500ms"| F2[NDKRelaySubscription] + E3 -->|"Grouping Delay: at-least 500ms"| F3[NDKRelaySubscription] + + F1 -->|"REQ: kinds: [1, 7], authors: [123]"| G1[NDKRelayConnectivity] + F2 -->|"REQ: kinds: [1], authors: [456]"| G2[NDKRelayConnectivity] + F3 -->|"REQ: kinds: [1], authors: [678]"| G3[NDKRelayConnectivity] + end + + subgraph Execution + G1 -->|"Send REQ to wss://relay1 after 1000ms"| R1[Relay1] + G2 -->|"Send REQ to wss://relay2 after 500ms"| R2[Relay2] + G3 -->|"Send REQ to wss://relay3 after 500ms"| R3[Relay3] + + R1 -->|"EVENT: kinds: [1]"| H1[NDKRelaySubscription] + R1 -->|"EVENT: kinds: [7]"| H2[NDKRelaySubscription] + R2 -->|"EVENT"| H3[NDKRelaySubscription] + R3 -->|"EVENT"| H4[NDKRelaySubscription] + + H1 -->|"Matched Filters: kinds: [1]"| I1[NDKSubscription1] + H2 -->|"Matched Filters: kinds: [7]"| I2[NDKSubscription2] + H3 -->|"Matched Filters: kinds: [1]"| I1 + H4 -->|"Matched Filters: kinds: [1]"| I1 + end +``` \ No newline at end of file diff --git a/docs/markdown-examples.md b/docs/markdown-examples.md new file mode 100644 index 00000000..f9258a55 --- /dev/null +++ b/docs/markdown-examples.md @@ -0,0 +1,85 @@ +# Markdown Extension Examples + +This page demonstrates some of the built-in markdown extensions provided by VitePress. + +## Syntax Highlighting + +VitePress provides Syntax Highlighting powered by [Shiki](https://github.com/shikijs/shiki), with additional features like line-highlighting: + +**Input** + +````md +```js{4} +export default { + data () { + return { + msg: 'Highlighted!' + } + } +} +``` +```` + +**Output** + +```js{4} +export default { + data () { + return { + msg: 'Highlighted!' + } + } +} +``` + +## Custom Containers + +**Input** + +```md +::: info +This is an info box. +::: + +::: tip +This is a tip. +::: + +::: warning +This is a warning. +::: + +::: danger +This is a dangerous warning. +::: + +::: details +This is a details block. +::: +``` + +**Output** + +::: info +This is an info box. +::: + +::: tip +This is a tip. +::: + +::: warning +This is a warning. +::: + +::: danger +This is a dangerous warning. +::: + +::: details +This is a details block. +::: + +## More + +Check out the documentation for the [full list of markdown extensions](https://vitepress.dev/guide/markdown). diff --git a/docs/mobile/index.md b/docs/mobile/index.md new file mode 100644 index 00000000..e78b9544 --- /dev/null +++ b/docs/mobile/index.md @@ -0,0 +1,53 @@ +# NDK Mobile + +A React Native/Expo implementation of [NDK (Nostr Development Kit)](https://github.com/nostr-dev-kit/ndk) that provides a complete toolkit for building Nostr applications on mobile platforms. + +## Features + +- 🔐 Multiple signer implementations (NIP-07, NIP-46, Private Key) +- 💾 SQLite-based caching for offline support +- 🔄 Subscription management with automatic reconnection +- 📱 React Native and Expo compatibility +- 🪝 React hooks for easy state management +- 👛 Integrated wallet support + +## Installation + +```sh +npm install @nostr-dev-kit/ndk-mobile +``` + +## Usage + +When using this library don't import `@nostr-dev-kit/ndk` directly, instead import `@nostr-dev-kit/ndk-mobile`. `ndk-mobile` exports the same classes as `ndk`, so you can just swap the import. + +Once you have imported the library, you can use the `NDKProvider` to wrap your application. Pass as props all the typical arguments you would pass to an `new NDK()` call. + +```tsx +function App() { + return {/* your app here */}; +} +``` + +## useNDK() + +`useNDK()` provides access to the `ndk` instance and some other useful information. + +```tsx +function LoginScreen() { + const { ndk, currentUser, login } = useNDK(); + + useEffect(() => { + if (currentUser) alert("you are now logged in as ", +currentUser.pubkey); + }, [currentUser]); + + return + + {#if open} +
    + +
  • + +
  • + +
  • + +
  • + +
  • + +
  • + + {#if enableDelete} +
  • + +
  • + {/if} +
+ {/if} + + + \ No newline at end of file diff --git a/ndk-svelte-components/src/lib/event/EventThread.svelte b/ndk-svelte-components/src/lib/event/EventThread.svelte new file mode 100644 index 00000000..fa9ec263 --- /dev/null +++ b/ndk-svelte-components/src/lib/event/EventThread.svelte @@ -0,0 +1,217 @@ + + +
+ {#if !skipEvent} +
+ {#each Array.from(threadIds.values()).sort(sortThread) as event (event.id)} + + {/each} +
+ {/if} + + {#if replyIds.size > 0 || $extraItems} +
+ {#each $extraItems??[] as item (item.props.key)} + + + + {/each} + + {#each Array.from(replyIds.values()).sort(sortReplies) as reply (reply.id)} + {#if !whitelistPubkeys || !useWhitelist || whitelistPubkeys.has(reply.pubkey)} + + + + {:else if whitelistPubkeys && useWhitelist && !whitelistPubkeys.has(reply.pubkey)} +
+
+ This reply was hidden + +
+
+ {/if} + {/each} +
+ {/if} +
+ + \ No newline at end of file diff --git a/ndk-svelte-components/src/lib/event/content/EventContent.svelte b/ndk-svelte-components/src/lib/event/content/EventContent.svelte new file mode 100644 index 00000000..e9411834 --- /dev/null +++ b/ndk-svelte-components/src/lib/event/content/EventContent.svelte @@ -0,0 +1,94 @@ + + +{#if event} + {#if event.kind === 1} + + {:else if event.kind === 40} + + {:else if event.kind === 1063} + + {:else if event.kind === 1985} + + {:else if event.kind === 9802} + + {:else if event.kind === 30000} + + {:else if event.kind === 30001} + + {:else if markdownKinds.includes(event.kind)} + + {:else} + + {/if} +{/if} diff --git a/ndk-svelte-components/src/lib/event/content/Kind1.svelte b/ndk-svelte-components/src/lib/event/content/Kind1.svelte new file mode 100644 index 00000000..e9a11e78 --- /dev/null +++ b/ndk-svelte-components/src/lib/event/content/Kind1.svelte @@ -0,0 +1,82 @@ + + +
+

+ {#each groupedContent as { type, value }, i} + {#if type === NEWLINE} + + {:else if type === TOPIC} + + {:else if type === LINK} + + {:else if type === LINKCOLLECTION} + {#if mediaCollectionComponent} + v.value.url)} /> + {:else} +

+ {#each value as {type: _type, value: _value}, j} + + {/each} +
+ {/if} + {:else if type.match(/^nostr:np(rofile|ub)$/)} + + {:else if type.startsWith('nostr:') && showMedia && isStartOrEnd(i) && value.id !== anchorId} + + {:else if type.startsWith('nostr:')} + + {:else} + {value} + {/if} + {' '} + {/each} +

+ +
diff --git a/ndk-svelte-components/src/lib/event/content/Kind1063.svelte b/ndk-svelte-components/src/lib/event/content/Kind1063.svelte new file mode 100644 index 00000000..4dfab226 --- /dev/null +++ b/ndk-svelte-components/src/lib/event/content/Kind1063.svelte @@ -0,0 +1,81 @@ + + +
+

File metadata

+
Description: {event.content}
+
+
MIME type: {mimeType}
+
File size: {size}
+
Dimensions: {dim}
+ {#if showMedia && SUPPORTED_IMAGE_TYPES.includes(mimeType)} +
File preview:
+
+ {event.content} +
+ {/if} + {#if showMedia && SUPPORTED_VIDEO_TYPES.includes(mimeType)} +
File preview:
+
+ + +
+ {/if} +
+ + diff --git a/ndk-svelte-components/src/lib/event/content/Kind30000.svelte b/ndk-svelte-components/src/lib/event/content/Kind30000.svelte new file mode 100644 index 00000000..8b11f1c5 --- /dev/null +++ b/ndk-svelte-components/src/lib/event/content/Kind30000.svelte @@ -0,0 +1,29 @@ + + +{#each list.items as tag (tag[1])} +
+ + +
+{/each} + + \ No newline at end of file diff --git a/ndk-svelte-components/src/lib/event/content/Kind30001.svelte b/ndk-svelte-components/src/lib/event/content/Kind30001.svelte new file mode 100644 index 00000000..997fd0a3 --- /dev/null +++ b/ndk-svelte-components/src/lib/event/content/Kind30001.svelte @@ -0,0 +1,27 @@ + + +{#each list.items as tag (tag[1])} +
+ +
+{/each} + + \ No newline at end of file diff --git a/ndk-svelte-components/src/lib/event/content/Kind30023.svelte b/ndk-svelte-components/src/lib/event/content/Kind30023.svelte new file mode 100644 index 00000000..86c33fc5 --- /dev/null +++ b/ndk-svelte-components/src/lib/event/content/Kind30023.svelte @@ -0,0 +1,59 @@ + + +
+ +
+ + diff --git a/ndk-svelte-components/src/lib/event/content/Kind9802.svelte b/ndk-svelte-components/src/lib/event/content/Kind9802.svelte new file mode 100644 index 00000000..ae9960b6 --- /dev/null +++ b/ndk-svelte-components/src/lib/event/content/Kind9802.svelte @@ -0,0 +1,26 @@ + + +
+
+ + {@html sanitizeHtml(context || event.content)} +
+
+ +{#if ref} +
+ +
+{/if} diff --git a/ndk-svelte-components/src/lib/event/content/NoteContentLink.svelte b/ndk-svelte-components/src/lib/event/content/NoteContentLink.svelte new file mode 100644 index 00000000..1160cc62 --- /dev/null +++ b/ndk-svelte-components/src/lib/event/content/NoteContentLink.svelte @@ -0,0 +1,30 @@ + + +{#if showMedia && value.isMedia} + {#if !!isImage(value.url)} + {""} + {:else if isVideo(value.url)} + +