stacker.news/components
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
..
nav Encrypted device sync (#1373) 2024-10-01 14:55:01 -05:00
accordian-item.js Random CSS fixes (#1370) 2024-09-07 10:01:00 -05:00
account.js Account Switching (#644) 2024-09-12 13:05:11 -05:00
action-dropdown.js Use module path aliases (#938) 2024-03-19 19:37:31 -05:00
action-tooltip.js fix action tooltip container 2024-07-12 17:34:46 -05:00
adv-post-form.js ek boost hint suggestions 2024-09-19 15:27:09 -05:00
adv-post-form.module.css fix height of foward percent on validation err 2023-09-12 17:04:49 -05:00
autowithdraw-shared.js Account Switching (#644) 2024-09-12 13:05:11 -05:00
avatar.js Allow video uploads (#1399) 2024-09-13 09:26:08 -05:00
banners.js Account Switching (#644) 2024-09-12 13:05:11 -05:00
banners.module.css Add new visitor welcome banner (#418) 2023-09-11 16:29:45 -05:00
block-height.js add halving to price carousel 2024-04-16 17:58:26 -05:00
bolt11-info.js add lnc attached wallet (#1104) 2024-04-26 21:22:30 -05:00
bookmark.js Toast (#431) 2023-08-25 18:21:51 -05:00
boost-button.js boost icon refinement 2024-09-20 10:15:44 -05:00
bounty-form.js rethinking boost (#1408) 2024-09-19 13:13:14 -05:00
cancel-button.js Encrypted device sync (#1373) 2024-10-01 14:55:01 -05:00
carousel.js fixes #1395 (#1430) 2024-09-28 16:33:07 -05:00
carousel.module.css Image carousel (#1425) 2024-09-26 17:37:13 -05:00
chain-fee.js env vars for polling intervals (#1038) 2024-04-08 09:13:12 -05:00
charts-skeletons.js remove duplicative styles 2024-03-25 15:35:32 -04:00
charts.js Referral Rewards (#1262) 2024-07-10 19:23:05 -05:00
comment-edit.js backend payment optimism (#1195) 2024-07-01 12:02:29 -05:00
comment.js UX latency enhancements for paid actions (#1434) 2024-09-25 13:32:52 -05:00
comment.module.css refine comment padding 2024-07-12 15:18:13 -05:00
comments.js backend payment optimism (#1195) 2024-07-01 12:02:29 -05:00
countdown.js backend payment optimism (#1195) 2024-07-01 12:02:29 -05:00
dark-mode.js dark-mode needs to block block 2023-08-04 20:45:12 -05:00
delete.js backend payment optimism (#1195) 2024-07-01 12:02:29 -05:00
device-sync.js Encrypted device sync (#1373) 2024-10-01 14:55:01 -05:00
discussion-form.js rethinking boost (#1408) 2024-09-19 13:13:14 -05:00
dont-link-this.js rethinking boost (#1408) 2024-09-19 13:13:14 -05:00
embed.js dark mode for nostr embed 2024-09-28 20:02:33 -05:00
error-boundary.js Use module path aliases (#938) 2024-03-19 19:37:31 -05:00
fee-button.js remove debug log comment 2024-09-25 18:04:03 -05:00
fee-button.module.css small receipt styling 2023-11-10 09:22:14 -06:00
file-upload.js Catch s3 upload errors (#1400) 2024-09-13 10:41:07 -05:00
footer-rewards.js env vars for polling intervals (#1038) 2024-04-08 09:13:12 -05:00
footer.js remove defunct chats from footer 2024-08-26 12:59:39 -05:00
footer.module.css Bottom nav uses fixed position to fix firefox bug (#1011) 2024-04-04 18:50:52 -05:00
form.js Encrypted device sync (#1373) 2024-10-01 14:55:01 -05:00
form.module.css Encrypted device sync (#1373) 2024-10-01 14:55:01 -05:00
hat.js Fix hat contrast in profile in dark mode (#1406) 2024-09-13 19:05:16 -05:00
header.module.css refine hiding bottom navbar when virtual keyboard opens 2024-03-28 18:18:44 -05:00
hidden-wallet-summary.js Account Switching (#644) 2024-09-12 13:05:11 -05:00
hoverable-popover.js refine popover close timing 2024-09-02 18:25:02 -05:00
info.js Use module path aliases (#938) 2024-03-19 19:37:31 -05:00
invite.js add NEXT_PUBLIC_URL 2024-04-08 17:54:39 -05:00
invoice-status.js backend payment optimism (#1195) 2024-07-01 12:02:29 -05:00
invoice.js UX latency enhancements for paid actions (#1434) 2024-09-25 13:32:52 -05:00
invoice.module.css ready for invoices 2021-05-06 16:15:22 -05:00
item-act.js UX latency enhancements for paid actions (#1434) 2024-09-25 13:32:52 -05:00
item-full.js fix item full embed for the 3rd and final(?) time 2024-09-30 12:37:33 -05:00
item-info.js prevent shift on pending -> paid 2024-09-25 17:38:37 -05:00
item-job.js rethinking boost (#1408) 2024-09-19 13:13:14 -05:00
item-popover.js Item popover (#1162) 2024-05-15 12:05:50 -05:00
item.js UX latency enhancements for paid actions (#1434) 2024-09-25 13:32:52 -05:00
item.module.css rethinking boost (#1408) 2024-09-19 13:13:14 -05:00
items.js rethinking boost (#1408) 2024-09-19 13:13:14 -05:00
items.module.css working search 2022-01-27 13:18:48 -06:00
job-form.js rethinking boost (#1408) 2024-09-19 13:13:14 -05:00
layout.js navigation -> nav 2024-03-26 19:49:10 -05:00
layout.module.css more spacing consistency 2024-03-27 14:04:04 -05:00
lightning-auth.js Account Switching (#644) 2024-09-12 13:05:11 -05:00
lightning-auth.module.css Notifications with nostr info (#368) 2023-08-08 13:19:31 -05:00
lightning.js Use module path aliases (#938) 2024-03-19 19:37:31 -05:00
link-form.js rethinking boost (#1408) 2024-09-19 13:13:14 -05:00
link-to-context.js turn #1063 logic into a component for use in all comment lists 2024-04-15 16:23:26 -05:00
link-to-context.module.css fix image/video clicks in notifications 2024-09-04 13:36:56 -05:00
log-message.js Hide wallet name in logs for only a single wallet (#1305) 2024-08-16 09:02:09 -05:00
log-message.module.css Wallet Logs (#994) 2024-04-03 17:27:21 -05:00
logger.js Account Switching (#644) 2024-09-12 13:05:11 -05:00
login-button.js Account Switching (#644) 2024-09-12 13:05:11 -05:00
login.js Account Switching (#644) 2024-09-12 13:05:11 -05:00
login.module.css more invite work 2021-10-15 13:05:34 -05:00
long-pressable.js Fix first zap when modal closed (#771) (#1055) 2024-04-12 18:37:04 -05:00
me.js Account Switching (#644) 2024-09-12 13:05:11 -05:00
media-or-link.js fixes #1395 (#1430) 2024-09-28 16:33:07 -05:00
modal.js Encrypted device sync (#1373) 2024-10-01 14:55:01 -05:00
more-footer.js fix item spacing 2024-07-11 16:58:55 -05:00
mute.js honor mutes when sending push notifications (#1145) 2024-05-12 13:55:56 -05:00
nostr-auth.js Account Switching (#644) 2024-09-12 13:05:11 -05:00
notifications.js fix bounty paid action notification 2024-09-26 09:53:25 -05:00
notifications.module.css make sure all notifications have the same padding 2024-07-19 14:47:12 -05:00
page-loading.js Use module path aliases (#938) 2024-03-19 19:37:31 -05:00
past-bounties.js upgrade react-bootstrap 2023-07-24 13:53:53 -05:00
pay-bounty.js Account Switching (#644) 2024-09-12 13:05:11 -05:00
pay-bounty.module.css upgrade react-bootstrap 2023-07-24 13:53:53 -05:00
payer-data.js LUD-18 Service Support (#518) 2023-10-03 14:35:53 -05:00
payment.js Account Switching (#644) 2024-09-12 13:05:11 -05:00
poll-form.js rethinking boost (#1408) 2024-09-19 13:13:14 -05:00
poll.js Account Switching (#644) 2024-09-12 13:05:11 -05:00
poll.module.css increase poll choice length to 40 chars 2023-09-28 16:52:11 -05:00
post.js rethinking boost (#1408) 2024-09-19 13:13:14 -05:00
price.js Account Switching (#644) 2024-09-12 13:05:11 -05:00
qr.js add separators to all unabbreviated numbers 2024-07-31 19:02:33 -05:00
recent-header.js fix item spacing 2024-07-11 16:58:55 -05:00
related.js Use module path aliases (#938) 2024-03-19 19:37:31 -05:00
reply.js no optimistic item repetition for anon 2024-09-26 09:44:14 -05:00
reply.module.css refine comment padding 2024-07-12 15:18:13 -05:00
root.js improve comment performance 2023-05-06 16:51:17 -05:00
search.js Account Switching (#644) 2024-09-12 13:05:11 -05:00
search.module.css search all territories by default + more intuitive search filters 2024-03-26 18:37:40 -05:00
seo.js Use module path aliases (#938) 2024-03-19 19:37:31 -05:00
serviceworker.js Wallet Logs (#994) 2024-04-03 17:27:21 -05:00
share.js Account Switching (#644) 2024-09-12 13:05:11 -05:00
snl.js Use module path aliases (#938) 2024-03-19 19:37:31 -05:00
snow.js Use module path aliases (#938) 2024-03-19 19:37:31 -05:00
sub-select.js env vars for polling intervals (#1038) 2024-04-08 09:13:12 -05:00
sub-select.module.css enhance navigation 2024-03-26 18:36:31 -05:00
subscribe.js Toast (#431) 2023-08-25 18:21:51 -05:00
subscribeUser.js honor mutes when sending push notifications (#1145) 2024-05-12 13:55:56 -05:00
table-of-contents.js Fix different slugs generated in ToC vs text (#1405) 2024-09-13 15:54:30 -05:00
territory-form.js rethinking boost (#1408) 2024-09-19 13:13:14 -05:00
territory-header.js Account Switching (#644) 2024-09-12 13:05:11 -05:00
territory-list.js Use module path aliases (#938) 2024-03-19 19:37:31 -05:00
territory-payment-due.js Account Switching (#644) 2024-09-12 13:05:11 -05:00
territory-transfer.js Account Switching (#644) 2024-09-12 13:05:11 -05:00
text.js fix missing src on autolinks 2024-09-29 11:13:33 -05:00
text.module.css dark mode for nostr embed 2024-09-28 20:02:33 -05:00
toast.js hide overflow of toasts 2024-07-09 11:46:38 -05:00
toast.module.css CSS animation for toasts and offcanvas (#1432) 2024-09-24 13:43:15 -05:00
top-header.js fix item spacing 2024-07-11 16:58:55 -05:00
upvote.js unzapped bolt shouldn't glow 2024-09-20 10:41:46 -05:00
upvote.module.css boost icon refinement 2024-09-20 10:15:44 -05:00
usage-header.js fix: custom calendar dark theme (#1123) 2024-05-11 20:32:44 -05:00
use-client.js Reinitialize wallet form if initial values change + fix readOnly hydration error (#1354) 2024-09-03 09:15:04 -05:00
use-crossposter.js fix crossposting toast 2024-08-21 14:59:28 -05:00
use-data.js remove list jitter by initially preferring ssr 2023-08-06 13:04:25 -05:00
use-debounce-callback.js remove unused debounce callback deps 2023-10-06 16:34:16 -05:00
use-has-new-notes.js env vars for polling intervals (#1038) 2024-04-08 09:13:12 -05:00
use-item-submit.js allow comment updates when they have boost 2024-09-19 14:06:34 -05:00
use-local-state.js Fix WebLN checkbox unclickable (#1299) 2024-08-14 14:29:24 -05:00
use-no-initial-effect.js reuse debounce hook more places 2023-10-06 15:01:51 -05:00
use-paid-mutation.js UX latency enhancements for paid actions (#1434) 2024-09-25 13:32:52 -05:00
use-quote-reply.js Use module path aliases (#938) 2024-03-19 19:37:31 -05:00
use-vault.js Encrypted device sync (#1373) 2024-10-01 14:55:01 -05:00
user-header.js Account Switching (#644) 2024-09-12 13:05:11 -05:00
user-header.module.css Don't hide self in top even if hidden (#905) 2024-03-13 19:26:59 -05:00
user-list.js Account Switching (#644) 2024-09-12 13:05:11 -05:00
user-popover.js Item popover (#1162) 2024-05-15 12:05:50 -05:00
wallet-buttonbar.js Add WebLN for sending payments (#1274) 2024-07-23 13:23:48 -05:00
wallet-card.js Wallet definitions with uniform interface (#1243) 2024-07-20 17:51:46 -05:00
wallet-logger.js Fix recv wallet deleted on logout (#1398) 2024-09-12 13:06:13 -05:00