stacker.news/svgs
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
..
add-fill.svg add polls 2022-07-30 08:51:04 -05:00
advertisement-fill.svg add simple badge to ad 2023-08-16 14:39:01 -05:00
advertisement-line.svg restyle ad to be clearer 2023-08-16 17:53:51 -05:00
amboss.svg add amboss link in footer 2023-05-05 16:22:22 -05:00
arrow-down-line.svg sub related enchancements 2023-05-02 11:55:10 -05:00
arrow-down-s-fill.svg WIP tips 2021-09-10 13:55:36 -05:00
arrow-left-fill.svg lightning login copy 2023-01-10 12:55:17 -06:00
arrow-left-line.svg lightning login copy 2023-01-10 12:55:17 -06:00
arrow-right-line.svg Image carousel (#1425) 2024-09-26 17:37:13 -05:00
arrow-right-s-fill.svg WIP tips 2021-09-10 13:55:36 -05:00
arrow-up-double-line.svg boost icon refinement 2024-09-20 10:15:44 -05:00
arrow-up-s-fill.svg tables 2021-04-13 19:57:32 -05:00
bald.svg streaks 2023-02-01 17:40:49 -06:00
bar-chart-horizontal-fill.svg add polls 2022-07-30 08:51:04 -05:00
bimi.svg add mempool link 2024-01-02 16:35:01 -06:00
bit-coin-fill.svg ready for invoices 2021-05-06 16:15:22 -05:00
bitcoin.svg new bolt 2021-12-05 11:37:55 -06:00
bold.svg lexical beta test url 2023-01-05 13:24:09 -06:00
bolt.svg new bolt 2021-12-05 11:37:55 -06:00
bookmark.svg Implement bookmarking of posts and comments (#235) 2023-02-16 16:23:59 -06:00
bounty-bag.svg stackernews bounties (#227) 2023-01-26 10:11:55 -06:00
briefcase-4-fill.svg jobs w/o payments yet 2022-02-24 13:05:57 -06:00
camera-line.svg Add QR code scanner for withdrawal invoices (#600) 2023-11-08 18:55:06 -06:00
chat-3-fill.svg refine reply-only notifications 2022-04-21 12:48:27 -05:00
check-double-line.svg invoiced ... WIP transactions 2021-05-11 10:52:50 -05:00
check-line.svg lexical beta test url 2023-01-05 13:24:09 -06:00
checkbox-circle-fill.svg add polls 2022-07-30 08:51:04 -05:00
clipboard-line.svg Encrypted device sync (#1373) 2024-10-01 14:55:01 -05:00
close-line.svg invoiced ... WIP transactions 2021-05-11 10:52:50 -05:00
cloud-fill.svg wild west mode 2022-09-21 14:57:36 -05:00
code-box-line.svg lexical beta test url 2023-01-05 13:24:09 -06:00
code-line.svg lexical beta test url 2023-01-05 13:24:09 -06:00
coin-fill.svg ready for invoices 2021-05-06 16:15:22 -05:00
cowboy.svg streaks 2023-02-01 17:40:49 -06:00
death-skull.svg pwa prompt on iOS 2023-12-27 19:06:12 -06:00
delete-bin-line.svg API Keys (#915) 2024-03-14 15:32:34 -05:00
double-quotes-r.svg lexical beta test url 2023-01-05 13:24:09 -06:00
error-warning-fill.svg wild west mode 2022-09-21 14:57:36 -05:00
eye-close-fill.svg collapse 'em 2021-04-30 16:42:51 -05:00
eye-close-line.svg collapse 'em 2021-04-30 16:42:51 -05:00
eye-fill.svg collapse 'em 2021-04-30 16:42:51 -05:00
eye-line.svg collapse 'em 2021-04-30 16:42:51 -05:00
file-upload-line.svg Allow video uploads (#1399) 2024-09-13 09:26:08 -05:00
file-warning-line.svg Revert "Revert "shield your eyes; massive, squashed refactor; nextjs/react/react-dom/apollo upgrades"" 2023-07-23 10:08:43 -05:00
flag-2-fill.svg wild west mode 2022-09-21 14:57:36 -05:00
flag-fill.svg wild west mode 2022-09-21 14:57:36 -05:00
font-size-2.svg lexical beta test url 2023-01-05 13:24:09 -06:00
github-fill.svg custom auth page 2021-04-24 16:05:07 -05:00
hand-coin-fill.svg ready for invoices 2021-05-06 16:15:22 -05:00
image-add-fill.svg image uploading backend 2022-05-12 13:44:21 -05:00
image-add-line.svg lexical beta test url 2023-01-05 13:24:09 -06:00
image-edit-fill.svg profile photos 2022-05-16 15:51:22 -05:00
image-fill.svg enhance image detection and proxy 2023-07-13 15:18:04 -05:00
image-line.svg lexical beta test url 2023-01-05 13:24:09 -06:00
indent-decrease.svg lexical beta test url 2023-01-05 13:24:09 -06:00
indent-increase.svg lexical beta test url 2023-01-05 13:24:09 -06:00
information-fill.svg jobs w/o payments yet 2022-02-24 13:05:57 -06:00
italic.svg lexical beta test url 2023-01-05 13:24:09 -06:00
lightning-arrow.svg tables 2021-04-13 19:57:32 -05:00
lightning-plus.svg different icon for tipping 2021-11-17 16:54:00 -06:00
lightning-pplus.svg change tip upvote icon 2021-11-26 13:24:51 -06:00
lightning-warning.svg tables 2021-04-13 19:57:32 -05:00
lightning.svg add forgetten lnurl-auth files 2021-06-26 22:18:32 -05:00
link.svg linkable headers 2022-07-17 10:35:50 -05:00
list-ordered.svg lexical beta test url 2023-01-05 13:24:09 -06:00
list-unordered.svg add table of contents 2022-07-18 16:24:28 -05:00
login-box-line.svg a bunch of increments 2021-04-12 13:05:09 -05:00
logout-box-line.svg a bunch of increments 2021-04-12 13:05:09 -05:00
logout-box-r-line.svg a bunch of increments 2021-04-12 13:05:09 -05:00
mail-open-fill.svg job board enhancements 2022-07-21 17:55:05 -05:00
mail-open-line.svg job board enhancements 2022-07-21 17:55:05 -05:00
markdown-fill.svg markdown previews 2021-07-01 18:51:58 -05:00
markdown-line.svg markdown previews 2021-07-01 18:51:58 -05:00
moon-fill.svg ready for invoices 2021-05-06 16:15:22 -05:00
more-fill.svg wild west mode 2022-09-21 14:57:36 -05:00
more-line.svg wild west mode 2022-09-21 14:57:36 -05:00
no.svg allow lightning animation to be disabled 2022-10-04 17:34:28 -05:00
nostr.svg Add nostr login (#367) 2023-08-07 19:50:01 -05:00
notification-4-fill.svg Update notification-4-fill.svg 2022-06-07 16:49:57 -04:00
pin.svg support pinned posts + recurring pins 2022-01-07 10:32:31 -06:00
plug.svg autowithdraw to lightning address 2024-01-11 13:10:07 -06:00
prism.svg add prism logo 2023-09-26 16:44:57 -05:00
pushpin-fill.svg Update pushpin-fill.svg 2022-06-07 15:23:01 -04:00
pushpin-line.svg better pin icon 2022-01-08 09:30:59 -06:00
pyramid.svg tables 2021-04-13 19:57:32 -05:00
qr-code-line.svg Encrypted device sync (#1373) 2024-10-01 14:55:01 -05:00
qr-scan-line.svg Encrypted device sync (#1373) 2024-10-01 14:55:01 -05:00
refresh-line.svg Encrypted device sync (#1373) 2024-10-01 14:55:01 -05:00
search-fill.svg search bar ui 2022-01-26 15:43:18 -06:00
search-line.svg search bar ui 2022-01-26 15:43:18 -06:00
service-fill.svg Referral Rewards (#1262) 2024-07-10 19:23:05 -05:00
settings-5-fill.svg territories 2023-12-04 21:34:06 -06:00
share-fill.svg referrals 2022-12-19 16:27:52 -06:00
share-forward-fill.svg referrals 2022-12-19 16:27:52 -06:00
slashtags.svg slashtags auth 2023-01-18 12:49:20 -06:00
sn.svg enhance navigation 2024-03-26 18:36:31 -05:00
spy-fill.svg Allow zapping, posting and commenting without funds or an account (#336) 2023-08-11 18:50:57 -05:00
strikethrough.svg lexical beta test url 2023-01-05 13:24:09 -06:00
subtract-line.svg collapse 'em 2021-04-30 16:42:51 -05:00
sun-fill.svg dark mode without ability to switch 2021-11-04 14:22:03 -04:00
terminal-box-fill.svg use code icon for contibutors 2023-09-18 14:17:22 -05:00
texas.svg foss and twitter link in footer 2021-06-30 18:01:28 -05:00
thumb-down-fill.svg make withdrawls mostly work 2021-05-13 16:19:51 -05:00
thumb-up-fill.svg ready for invoices 2021-05-06 16:15:22 -05:00
tip.svg tip button 2021-11-19 13:13:59 -06:00
triangle.svg tables 2021-04-13 19:57:32 -05:00
trophy-fill.svg show sources and history of rewards 2023-08-15 12:41:51 -05:00
twitter-fill.svg custom auth page 2021-04-24 16:05:07 -05:00
underline.svg lexical beta test url 2023-01-05 13:24:09 -06:00
upbolt.svg new bolt 2021-12-05 11:37:55 -06:00
user-add-fill.svg Referral Rewards (#1262) 2024-07-10 19:23:05 -05:00
video-on-fill.svg refactor embeds to be reused (#1368) 2024-09-07 12:07:10 -05:00
window-2-fill.svg complete tips 2021-09-10 16:13:52 -05:00
youtube-line.svg snl live banner 2023-06-20 09:57:06 -05:00