Commit Graph

759 Commits

Author SHA1 Message Date
k00b 651053fd71 remove deprecated canonizeResults 2024-10-08 14:25:23 -05:00
Keyan fec7c92fd9
run noncritical side effects outside critical path of paid action (#1464)
* run noncritical side effects outside critical path of paid action

* fix item fetching of zap side effect

* fix vapid pubkey env var name in readme
2024-10-08 11:48:19 -05:00
k00b 4532e00085 Revert "Include extension in S3 key (#1426)"
This reverts commit b82641d1bd.
2024-10-07 13:22:01 -05:00
k00b 154c0e0a4a fix cache key bloat 2024-10-06 18:56:48 -05:00
k00b 153455983e Revert "Encrypted device sync (#1373)"
This reverts commit a9a566a79f.
2024-10-04 15:00:13 -05:00
Keyan 5543a0755a
paginating wallet logs (#1459)
* paginating wallet logs

* refine
2024-10-04 06:59:32 -05:00
Keyan f4382ad73e
better boost hints (#1441)
* better boost hints

* refine
2024-10-02 19:24:01 -05:00
k00b 65a7ef10d0 make bio work as paid action 2024-10-02 18:39:56 -05:00
k00b 5fab3abb82 fix bio quirks 2024-10-02 18:12:49 -05:00
Keyan 4ce395889d
Be kind to lnd (#1448)
* cache or remove unecessary calls to lnd

* avoid redundant grpc calls in state machine

* store preimage whenever available

* enhancements post self-code review

* small refinements

* fixes

* fix lnurl-verify

* prevent wallet logger throwing on idb close

* fix promise in race while waiting for payment
2024-10-02 15:03:30 -05:00
Riccardo Balbo a9a566a79f
Encrypted device sync (#1373)
* user vault

* code cleanup and fixes

* improve ui

* prevent name collisions between users on the same device

* some improvements

* implement storage migration

* comments and cleanup

* make connect button primary instead of warning

* move show passphrase in new line (improvement for small screen devices)

* make show passphrase field readOnly

* fixes

* fix vault key unsync

* implicit migration

* move device sync under  general tab

* fix locally disabled wallets and default wallet selection

* improve text

* remove useless SSR check

* add auth checks

* Rename variables

* Fix missing await

* Refactor local<>vault storage interface

I've changed quite some things here. Attempt of a summary:

* storageKey is now only controlled by useVaultStorageState

I've noticed that dealing with how storage keys are generated (to apply user scope) was handled in two places: the existing wallet code and in the new vault code.

This was confusing and error-prone. I've fixed that by completely relying on the new vault code to generate correct storage keys.

* refactored migration

Migration now simply encrypts any existing local wallets and sends them to the server. On success, the local unencrypted version is deleted.

The previous code seemed to unnecessarily generate new local entries prefixed by 'vault:'.

However, since we either use unencrypted local state OR use the encrypted vault on the server for the data, I didn't see any need for these.

Migration seems to work just as well as before.

* removed unnecessary state

In the <DeviceSync> component, enabled & connected were using a unnecessary combo of useState+useEffect.

They were only using variables that are always available during render so simple assignments were enough.

* other minor changes include:

  * early returns
  * remove unnecessary SSR checks in useEffect or useCallback
  * formatting, comments
  * remove unnecessary me? to expose possible bugs

* Fix missing dependency for useZap

This didn't cause any bugs because useWallet returns everything we need on first render.

This caused a bug with E2EE device sync branch though since there the wallet is loaded async.

This meant that during payment, the wallet config was undefined.

* Assume JSON during encryption and decryption

* Fix stale value from cache served on next fetches

* Add wallet.perDevice field

This adds 'perDevice' as a new wallet field to force local storage. For example, WebLN should not be synced across devices.

* Remove debug buttons

* Rename userVault -> vault

* Update console.log's

* revert some of the migration and key handling changes. restore debug buttons for testing

* Fix existing wallets not loaded

* Pass in localOnly and generate localStorageKey once

* Small refactor of migration

* Fix wallet drag and drop

* Add passphrase copy button

* Fix priorityOnly -> skipTests

* Disable autocompletion for reset confirmation prompt

* Show wrong passphrase as input error

* Move code into components/device-sync.js

* Import/export passphrase via QR code

* Fix modal back button invisible in light mode

* Fix modal closed even on connect error

* Use me-2 for cancel/close button

* Some rephrasing

* Fix wallet detach

* Remove debug buttons

* Fix QR code scan in dark mode

* Don't allow custom passphrases

* More rephrasing

* Only use schema if not enabled

* Fix typo in comment

* Replace 'generate passphrase' button with reload icon

* Add comment about IV reuse in GCM

* Use 600k iterations as recommended by OWASP

* Set extractable to false where not needed

* use-vault fallbacks to local storage only for anonymous users

* fix localStorage reset on logout

* add copy button

* move reset out of modals

* hide server side errors

* hardened passphrase storage

* do not show passphrase even if hardened storage is disabled (ie. indexeddb not supported)

* show qr code button on passphrase creation

* use toast for serverside error

* Move key (de)serialization burden to get/setLocalKey functions

* password textarea and remove qr

* don't print plaintext vault values into console

---------

Co-authored-by: ekzyis <ek@stacker.news>
Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
Co-authored-by: k00b <k00b@stacker.news>
2024-10-01 14:55:01 -05:00
Keyan 9f06fd65ee
UX latency enhancements for paid actions (#1434)
* prevent multiple retries & pulse retry button

* fix lint

* don't wait for settlement on pessimistic zaps

* optimistic act modal
2024-09-25 13:32:52 -05:00
Keyan 450c969dfc
allow edit of pending items (#1431) 2024-09-24 15:42:32 -05:00
ekzyis b82641d1bd
Include extension in S3 key (#1426) 2024-09-24 08:10:43 -05:00
k00b 894d02a196 allow top sorting by boost 2024-09-21 14:58:25 -05:00
k00b 8c9d4aa59b fix auction based ranking 2024-09-19 17:07:36 -05:00
k00b 731df5fc67 better err message ek suggestion 2024-09-19 15:32:18 -05:00
k00b 2f191e04f9 ek boost hint suggestions 2024-09-19 15:27:09 -05:00
k00b 09be42844e boosted items aren't freebies 2024-09-19 15:18:07 -05:00
Keyan 3310925155
increase founders fee to 70% and zap sybil fee to 30% (#1388)
* increase founders fee to 70% and zap sybil fee to 30%

* more sybil fee changes
2024-09-19 15:15:56 -05:00
k00b 020b4c5eea allow comment updates when they have boost 2024-09-19 14:06:34 -05:00
Keyan 5f0494de30
rethinking boost (#1408)
* reuse boost for jobs

* wip

* allow job stopping

* restore upvote.js

* expire boost

* boost beyond edit window

* fix boost bolt styling

* rank comments with boost

* no random sort for jobs

* top boost for month at top of territory

* boost hints

* more boost help

* squash migrations

* for same boost, prioritize older

* show ad only if active

* fix itemCreate/Update boost expiration jobs

* fix fee button precedence
2024-09-19 13:13:14 -05:00
k00b ae579cbec3 remove mod outlaws from hot 2024-09-16 13:30:40 -05:00
k00b e63609a7c1 don't show deleted items in main sorts 2024-09-16 11:57:16 -05:00
ekzyis c8975038bd
Never update author of item on edit (#1401)
* Never update author of item on edit

* Only show option to edit via hmac if anonymous

* Only send hash+hmac if anonymous
2024-09-13 11:19:54 -05:00
ekzyis 30d5eb9801
Catch s3 upload errors (#1400)
* Catch s3 upload errors

* Include file name in error message

* More renaming from image to file
2024-09-13 10:41:07 -05:00
k00b e09e1398fd increase upload max and update error messages 2024-09-13 10:13:34 -05:00
ekzyis 8a4e67e9f0
Anon edits (#1393)
* Rename vars around edit permission

* Allow anon edits with hash+hmac

* Fix missing time zone for invoice.confirmedAt of comments

* Fix missing invoice update on item update

---------

Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
2024-09-13 10:11:19 -05:00
ekzyis 4340a82a62
Allow video uploads (#1399)
* Allow video uploads

* fix video preview

---------

Co-authored-by: k00b <k00b@stacker.news>
2024-09-13 09:26:08 -05:00
ekzyis a6713f9793
Account Switching (#644)
* WIP: Account switching

* Fix empty USER query

ANON_USER_ID was undefined and thus the query for @anon had no variables.

* Apply multiAuthMiddleware in /api/graphql

* Fix 'you must be logged in' query error on switch to anon

* Add smart 'switch account' button

"smart" means that it only shows if there are accounts to which one can switch

* Fix multiAuth not set in backend

* Comment fixes, minor changes

* Use fw-bold instead of 'selected'

* Close dropdown and offcanvas

Inside a dropdown, we can rely on autoClose but need to wrap the buttons with <Dropdown.Item> for that to work.

For the offcanvas, we need to pass down handleClose.

* Use button to add account

* Some pages require hard reload on account switch

* Reinit settings form on account switch

* Also don't refetch WalletHistory

* Formatting

* Use width: fit-content for standalone SignUpButton

* Remove unused className

* Use fw-bold and text-underline on selected

* Fix inconsistent padding of login buttons

* Fix duplicate redirect from /settings on anon switch

* Never throw during refetch

* Throw errors which extend GraphQLError

* Only use meAnonSats if logged out

* Use reactive variable for meAnonSats

The previous commit broke the UI update after anon zaps because we actually updated item.meSats in the cache and not item.meAnonSats.

Updating item.meAnonSats was not possible because it's a local field. For that, one needs to use reactive variables.

We do this now and thus also don't need the useEffect hack in item-info.js anymore.

* Switch to new user

* Fix missing cleanup during logout

If we logged in but never switched to any other account, the 'multi_auth.user-id' cookie was not set.

This meant that during logout, the other 'multi_auth.*' cookies were not deleted.

This broke the account switch modal.

This is fixed by setting the 'multi_auth.user-id' cookie on login.

Additionally, we now cleanup if cookie pointer OR session is set (instead of only if both are set).

* Fix comments in middleware

* Remove unnecessary effect dependencies

setState is stable and thus only noise in effect dependencies

* Show but disable unavailable auth methods

* make signup button consistent with others

* Always reload page on switch

* refine account switch styling

* logout barrier

---------

Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
Co-authored-by: k00b <k00b@stacker.news>
2024-09-12 13:05:11 -05:00
ekzyis 0e0fe1af69
Fix duplicate push notification as reply and subscription (#1392) 2024-09-11 16:28:55 -05:00
ekzyis 821ac60de5
Throw errors which extend GraphQLError (#1386) 2024-09-10 11:35:25 -05:00
Keyan 07b98c3253
Optout of display of images and video (show them as links) (#1358)
* optout of display of images/video

* fix disableFreebies warning in settings

* preview trusted images

Co-authored-by: ekzyis <ek@stacker.news>

---------

Co-authored-by: ekzyis <ek@stacker.news>
2024-09-04 09:23:06 -05:00
Keyan adcf048f4e
improve dupes (#1356) 2024-09-03 14:29:45 -05:00
Keyan 266e9a892d
Improve freebies (#1333)
* remove free posts

* deleted and freebie comments are always last
2024-08-26 19:23:07 -05:00
ekzyis 66cf97e832
Skip wallet tests on priority update (#1327)
* Skip wallet connection tests if only priority is changed

* Fix server priority overrides client priority

* Also add priorityOnly as last argument in generateMutation
2024-08-22 20:08:02 -05:00
ekzyis 382f16643d
Ignore no rows found in disableFreebies (#1326) 2024-08-22 18:09:22 -05:00
ekzyis 82788b35bf
Show item details via context menu (#1325)
* Show item details via context

* Use zappers instead of upvotes

Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>

---------

Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
2024-08-21 20:35:13 -05:00
Keyan df62cfb28c
paid action limits (#1323) 2024-08-21 14:45:51 -05:00
ekzyis 789d7626f7
Support receiving with NWC (#1310)
* Add NWC receives

* Refactor sendPayment+createInvoice with nwcCall function

* Update badge

* Add method support checks

* Add timeout to NWC test invoice

* Fix NWC isConfigured state

All NWC fields are marked as optional but NWC should only be considered configured if one of them is set.

* Fix relay.fetch() throws 'crypto is not defined' in node

nip04.encrypt() was failing in worker because 'crypto is not defined'. Updating to nostr-tools v2.7.2 fixed that.

However, now crypto.randomUUID() in relay.fetch() was throwing 'crypto is not defined'. Importing crypto from 'crypto' fixed that.

However, with the import, randomUUID() does not work so I switched to randomBytes().

Running relay.fetch() now works in browser and node.

* recv must not support pay_invoice

* Fix Relay connection check

* this.url was undefined
* error was an object

* Fix additional isConfigured check runs always

It was meant to only catch false positives, not turn negatives into false positives.

* Rename testConnectServer to testCreateInvoice

* Rename testConnectClient to testSendPayment

* Only run testSendPayment if send is configured

The return value of testSendPayment was used before but it only returned something for LNC.

And for LNC, we only wanted to save the transformation during validation, so it was not needed.

* Always use withTimeout in NWC test functions

* Fix fragment name

* Use get_info command exclusively

* Check permissions more efficiently

* Log NWC request-response flow

* Fix variable name

* Call ws.send after listener is added

* Fix websocket not closed after timeout

* Also check that pay_keysend etc. are not supported

* fix lnc session key save

---------

Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
Co-authored-by: k00b <k00b@stacker.news>
2024-08-21 10:13:27 -05:00
Keyan bc94ec7d28
disable freebies setting (#1320)
* disable freebies setting

* await in disableFreebie resolver + better info modal
2024-08-21 09:37:25 -05:00
k00b 555601c7de no bios in random 2024-08-20 21:12:39 -05:00
k00b 85e91ede47 show only active items with comments on random 2024-08-20 21:09:52 -05:00
k00b accf5212b2 fix ~jobs 2024-08-20 20:50:04 -05:00
Tom 4fd23a3694
Add Random link and basic query (#1306)
* Add Random link and basic query

* Use random

* refine random sort query

* make vote threshold higher

---------

Co-authored-by: k00b <k00b@stacker.news>
2024-08-20 16:50:55 -05:00
ekzyis 6801b775c1
Fix inconsistency between walletTypeToResolveType and generateTypeDefName (#1318) 2024-08-19 17:36:07 -05:00
k00b 2ff839f3a5 check invoice after transitioning to cancel 2024-08-18 18:03:01 -05:00
k00b df7baf4d7c don't filter freebies/outlaws on profiles + fix ~sub/recent/all 2024-08-18 16:43:19 -05:00
ekzyis 3d8ae4a7a3
Generate more server wallet code (#1309)
* Generate more code from wallet defs

* generate "type WalletLND { ... }"
* generate "union WalletDetails = WalletLND | ..."
* hardcode function for __resolveType
* add comments where updates are needed if another server wallet is added

* Fix type for LN addresses

* Generate __resolveType from wallet.type column
2024-08-18 11:32:25 -05:00
Keyan ffc156df2b
Msats to sats floor (#1307)
* make wallet invoice creation tests make full sat invoice

* handle rounded/floored msats for receiving wallets

* msats flooring to sats function
2024-08-16 19:33:17 -05:00