stacker.news/components
ekzyis b9461b7eb3
Allow zapping, posting and commenting without funds or an account (#336)
* Add anon zaps

* Add anon comments and posts (link, discussion, poll)

* Use payment hash instead of invoice id as proof of payment

Our invoice IDs can be enumerated.
So there is a - even though very rare - chance that an attacker could find a paid invoice which is not used yet and use it for himself.
Random payment hashes prevent this.

Also, since we delete invoices after use, using database IDs as proof of payments are not suitable.
If a user tells us an invoice ID after we deleted it, we can no longer tell if the invoice was paid or not since the LN node only knows about payment hashes but nothing about the database IDs.

* Allow pay per invoice for stackers

The modal which pops up if the stacker does not have enough sats now has two options: "fund wallet" and "pay invoice"

* Fix onSuccess called twice

For some reason, when calling `showModal`, `useMemo` in modal.js and the code for the modal component (here: <Invoice>) is called twice.

This leads to the `onSuccess` callback being called twice and one failing since the first one deletes the invoice.

* Keep invoice modal open if focus is lost

* Skip anon user during trust calculation

* Add error handling

* Skip 'invoice not found' errors

* Remove duplicate insufficient funds handling

* Fix insufficient funds error detection

* Fix invoice amount for comments

* Allow pay per invoice for bounty and job posts

* Also strike on payment after short press

* Fix unexpected token 'export'

* Fix eslint

* Remove unused id param

* Fix comment copy-paste error

* Rename to useInvoiceable

* Fix unexpected token 'export'

* Fix onConfirmation called at every render

* Add invoice HMAC

This prevents entities which know the invoice hash (like all LN nodes on the payment path) from using the invoice hash on SN.

Only the user which created the invoice knows the HMAC and thus can use the invoice hash.

* make anon posting less hidden, add anon info button explainer

* Fix anon users can't zap other anon users

* Always show repeat and contacts on action error

* Keep track of modal stack

* give anon an icon

* add generic date pivot helper

* make anon user's invoices expire in 5 minutes

* fix forgotten find and replace

* use datePivot more places

* add sat amounts to invoices

* reduce anon invoice expiration to 3 minutes

* don't abbreviate

* Fix [object Object] as error message

Any errors thrown here are already objects of shape { message: string }

* Fix empty invoice creation attempts

I stumbled across this while checking if anons can edit their items.

I monkey patched the code to make it possible (so they can see the 'edit' button) and tried to edit an item but I got this error:

  Variable "$amount" of required type "Int!" was not provided.

I fixed this even though this function should never be called without an amount anyway. It will return a sane error in that case now.

* anon func mods, e.g. inv limits

* anon tips should be denormalized

* remove redundant meTotalSats

* correct overlay zap text for anon

* exclude anon from trust graph before algo runs

* remove balance limit on anon

* give anon a bio and remove cowboy hat/top stackers;

* make anon hat appear on profile

* concat hash and hmac and call it a token

* Fix localStorage cleared because error were swallowed

* fix qr layout shift

* restyle fund error modal

* Catch invoice errors in fund error modal

* invoice check backoff

* anon info typo

* make invoice expiration times have saner defaults

* add comma to anon info

* use builtin copy input label

---------

Co-authored-by: ekzyis <ek@stacker.news>
Co-authored-by: keyan <keyan.kousha+huumn@gmail.com>
2023-08-11 18:50:57 -05:00
..
accordian-item.js upgrade react-bootstrap 2023-07-24 13:53:53 -05:00
action-tooltip.js upgrade react-bootstrap 2023-07-24 13:53:53 -05:00
adv-post-form.js Singular/Plural "Sats" labels (#380) 2023-08-08 16:04:06 -05:00
avatar.js upgrade react-bootstrap 2023-07-24 13:53:53 -05:00
bookmark.js upgrade react-bootstrap 2023-07-24 13:53:53 -05:00
bounty-form.js Allow zapping, posting and commenting without funds or an account (#336) 2023-08-11 18:50:57 -05:00
cancel-button.js upgrade react-bootstrap 2023-07-24 13:53:53 -05:00
charts.js fix dark mode 2023-08-04 19:21:51 -05:00
comment-edit.js upgrade react-bootstrap 2023-07-24 13:53:53 -05:00
comment.js render "reply" or "replies", "comment" or "comments" depending on the count (singular or plural) (#382) 2023-08-08 16:07:00 -05:00
comment.module.css enhance styling 2023-07-25 13:32:48 -05:00
comments.js Singular/Plural "Sats" labels (#380) 2023-08-08 16:04:06 -05:00
countdown.js Revert "Revert "shield your eyes; massive, squashed refactor; nextjs/react/react-dom/apollo upgrades"" 2023-07-23 10:08:43 -05:00
dark-mode.js dark-mode needs to block block 2023-08-04 20:45:12 -05:00
delete.js upgrade react-bootstrap 2023-07-24 13:53:53 -05:00
discussion-form.js Allow zapping, posting and commenting without funds or an account (#336) 2023-08-11 18:50:57 -05:00
dont-link-this.js upgrade react-bootstrap 2023-07-24 13:53:53 -05:00
error-boundary.js upgrade to next-auth 4 (bonus: improve error pages) 2023-07-29 14:38:20 -05:00
fee-button.js Allow zapping, posting and commenting without funds or an account (#336) 2023-08-11 18:50:57 -05:00
fee-button.module.css Allow zapping, posting and commenting without funds or an account (#336) 2023-08-11 18:50:57 -05:00
footer-rewards.js fix conditional nextFetchPolicy overriding cache-only on SSR and suppress time hydration warnings 2023-07-31 14:54:30 -05:00
footer.js fix issues with new linting 2023-07-25 09:14:45 -05:00
footer.module.css fix dark mode 2023-08-04 19:21:51 -05:00
form.js Allow zapping, posting and commenting without funds or an account (#336) 2023-08-11 18:50:57 -05:00
form.module.css upgrade react-bootstrap 2023-07-24 13:53:53 -05:00
fund-error.js Allow zapping, posting and commenting without funds or an account (#336) 2023-08-11 18:50:57 -05:00
hat.js Allow zapping, posting and commenting without funds or an account (#336) 2023-08-11 18:50:57 -05:00
header.js Allow zapping, posting and commenting without funds or an account (#336) 2023-08-11 18:50:57 -05:00
header.module.css Allow zapping, posting and commenting without funds or an account (#336) 2023-08-11 18:50:57 -05:00
info.js upgrade react-bootstrap 2023-07-24 13:53:53 -05:00
invite.js full powered editing 2022-08-18 13:15:24 -05:00
invoice-status.js Allow zapping, posting and commenting without funds or an account (#336) 2023-08-11 18:50:57 -05:00
invoice.js Allow zapping, posting and commenting without funds or an account (#336) 2023-08-11 18:50:57 -05:00
invoice.module.css ready for invoices 2021-05-06 16:15:22 -05:00
item-act.js Allow zapping, posting and commenting without funds or an account (#336) 2023-08-11 18:50:57 -05:00
item-full.js Singular/Plural "Sats" labels (#380) 2023-08-08 16:04:06 -05:00
item-info.js Allow zapping, posting and commenting without funds or an account (#336) 2023-08-11 18:50:57 -05:00
item-job.js Allow zapping, posting and commenting without funds or an account (#336) 2023-08-11 18:50:57 -05:00
item.js Singular/Plural "Sats" labels (#380) 2023-08-08 16:04:06 -05:00
item.module.css more noticable new comment indicator 2023-08-06 14:31:24 -05:00
items.js remove list jitter by initially preferring ssr 2023-08-06 13:04:25 -05:00
items.module.css working search 2022-01-27 13:18:48 -06:00
job-form.js Allow zapping, posting and commenting without funds or an account (#336) 2023-08-11 18:50:57 -05:00
layout.js Revert "Revert "shield your eyes; massive, squashed refactor; nextjs/react/react-dom/apollo upgrades"" 2023-07-23 10:08:43 -05:00
layout.module.css Revert "Revert "shield your eyes; massive, squashed refactor; nextjs/react/react-dom/apollo upgrades"" 2023-07-23 10:08:43 -05:00
lightning-auth.js fix conditional nextFetchPolicy overriding cache-only on SSR and suppress time hydration warnings 2023-07-31 14:54:30 -05:00
lightning-auth.module.css Notifications with nostr info (#368) 2023-08-08 13:19:31 -05:00
lightning.js fix issues with new linting 2023-07-25 09:14:45 -05:00
link-form.js Allow zapping, posting and commenting without funds or an account (#336) 2023-08-11 18:50:57 -05:00
login-button.js Add nostr login (#367) 2023-08-07 19:50:01 -05:00
login.js Add nostr login (#367) 2023-08-07 19:50:01 -05:00
login.module.css more invite work 2021-10-15 13:05:34 -05:00
me.js fix conditional nextFetchPolicy overriding cache-only on SSR and suppress time hydration warnings 2023-07-31 14:54:30 -05:00
modal.js Allow zapping, posting and commenting without funds or an account (#336) 2023-08-11 18:50:57 -05:00
more-footer.js upgrade react-bootstrap 2023-07-24 13:53:53 -05:00
nostr-auth.js Add nostr login (#367) 2023-08-07 19:50:01 -05:00
notifications.js handle all singular units appropriately 2023-08-08 16:47:27 -05:00
notifications.module.css remove list jitter by initially preferring ssr 2023-08-06 13:04:25 -05:00
page-loading.js Revert "Revert "shield your eyes; massive, squashed refactor; nextjs/react/react-dom/apollo upgrades"" 2023-07-23 10:08:43 -05:00
past-bounties.js upgrade react-bootstrap 2023-07-24 13:53:53 -05:00
pay-bounty.js Singular/Plural "Sats" labels (#380) 2023-08-08 16:04:06 -05:00
pay-bounty.module.css upgrade react-bootstrap 2023-07-24 13:53:53 -05:00
poll-form.js Allow zapping, posting and commenting without funds or an account (#336) 2023-08-11 18:50:57 -05:00
poll.js handle all singular units appropriately 2023-08-08 16:47:27 -05:00
poll.module.css upgrade react-bootstrap 2023-07-24 13:53:53 -05:00
post.js Allow zapping, posting and commenting without funds or an account (#336) 2023-08-11 18:50:57 -05:00
price.js fix conditional nextFetchPolicy overriding cache-only on SSR and suppress time hydration warnings 2023-07-31 14:54:30 -05:00
qr.js Allow zapping, posting and commenting without funds or an account (#336) 2023-08-11 18:50:57 -05:00
recent-header.js fix back button behavior on select navigation 2023-07-25 15:29:45 -05:00
related.js more package updates 2023-07-24 19:50:55 -05:00
reply.js Allow zapping, posting and commenting without funds or an account (#336) 2023-08-11 18:50:57 -05:00
reply.module.css upgrade react-bootstrap 2023-07-24 13:53:53 -05:00
root.js improve comment performance 2023-05-06 16:51:17 -05:00
search.js fix back button behavior on select navigation 2023-07-25 15:29:45 -05:00
search.module.css fix dark mode 2023-08-04 19:21:51 -05:00
seo.js handle all singular units appropriately 2023-08-08 16:47:27 -05:00
serviceworker.js handle when navigator controller isn't present 2023-08-08 16:55:53 -05:00
share.js upgrade react-bootstrap 2023-07-24 13:53:53 -05:00
snl.js Allow zapping, posting and commenting without funds or an account (#336) 2023-08-11 18:50:57 -05:00
sub-select-form.js fix undefined sub on post pre-form 2023-07-25 15:41:46 -05:00
subscribe.js upgrade react-bootstrap 2023-07-24 13:53:53 -05:00
table-of-contents.js upgrade react-bootstrap 2023-07-24 13:53:53 -05:00
text.js fix syntax highlighting warnings 2023-07-27 12:10:05 -05:00
text.module.css Revert "Revert "shield your eyes; massive, squashed refactor; nextjs/react/react-dom/apollo upgrades"" 2023-07-23 10:08:43 -05:00
top-header.js fix top header/stat order on back/forward nav 2023-08-06 13:13:32 -05:00
upload.js fix issues with new linting 2023-07-25 09:14:45 -05:00
upvote.js Allow zapping, posting and commenting without funds or an account (#336) 2023-08-11 18:50:57 -05:00
upvote.module.css fix dark mode 2023-08-04 19:21:51 -05:00
usage-header.js fix back button behavior on select navigation 2023-07-25 15:29:45 -05:00
use-data.js remove list jitter by initially preferring ssr 2023-08-06 13:04:25 -05:00
user-header.js Allow zapping, posting and commenting without funds or an account (#336) 2023-08-11 18:50:57 -05:00
user-header.module.css upgrade react-bootstrap 2023-07-24 13:53:53 -05:00
user-list.js Allow zapping, posting and commenting without funds or an account (#336) 2023-08-11 18:50:57 -05:00