Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: settings security #462

Merged
merged 1 commit into from
Sep 24, 2024
Merged

feat: settings security #462

merged 1 commit into from
Sep 24, 2024

Conversation

fbwoolf
Copy link
Contributor

@fbwoolf fbwoolf commented Sep 19, 2024

This PR wires up the security settings flows, and:

  • Separates settings read/write api to be exposed thru useSettings in settings.ts
  • Creates a UI library component for Switch (note, I didn't replace the one in Cell bc it will be removed)


cc @mica000 We will need final text for Description here on both sheets. Also, is App authorization the right naming here? I'm not sure I even understood what it meant and the toast says metrics?

Copy link
Contributor

@pete-watters pete-watters left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work 🚀

Copy link
Collaborator

@kyranjamie kyranjamie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work @fbwoolf

Lots of comments, pretty much all naming related


export const defaultNetworks = ['mainnet', 'testnet', 'signet'] as const;

export const defaultThemes = ['light', 'dark', 'system'] as const;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Been thinking on this naming, because system isn't really a theme, it's a setting that points to a theme.

Maybe we have ThemeSetting/ThemePreference and Theme?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, been struggling a bit with some of the naming so thx for the feedback on all comments. I'll refactor them here.

walletSecurityLevel: 'undefined',
};

export function useSettings() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the refactor. Think this is a really nice pattern where we expose all store read/writes via a uniform hook, abstracting any store-specific implementation details.

Will follow up with a depcruiser rule to prevent components reading .{read,write}.ts files

apps/mobile/src/store/settings/settings.ts Outdated Show resolved Hide resolved
onToggleValue?(): void;
value: boolean;
}
export function Switch({ onToggleValue, value, ...props }: SwitchProps) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, think Pete made an issue for this we can close

export const initialState: SettingsState = {
accountDisplayPreference: 'ns',
analyticsEnabled: false,
appAuthEnabled: false,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't this be inferred from walletSecurityLevel?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need clarification on what this setting is for the from design team. I am unclear what it is, the toast says Metrics updated. 🤔 cc @mica000 Can someone clarify for me what walletSecurityLevel is for?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does appear this is used with biometrics true/false, so I'll remove appAuthEnabled bc it seems the same.

Copy link

@mica000 mica000 Sep 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just registering that the copy should be App authentication updated.

apps/mobile/src/store/settings/settings.ts Outdated Show resolved Hide resolved
apps/mobile/src/store/settings/settings.ts Outdated Show resolved Hide resolved
Comment on lines 19 to 27
<TouchableOpacity onPress={onCreateSheetRef}>
<Flag img={<Avatar>{icon}</Avatar>}>
<ItemLayout
actionIcon={<ChevronRightIcon variant="small" />}
captionLeft={caption}
titleLeft={title}
/>
</Flag>
</TouchableOpacity>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like many would look at this, see the repetition between this and the other Cells, and have to fight the urge not to try refactor into a more terse JSX component.

But this would be a mistake IMO. This is just the right composition where we make no assumptions about the content and can change any cell to any layout requirement 👍🏼

apps/mobile/src/store/settings/settings.ts Outdated Show resolved Hide resolved
@fbwoolf fbwoolf force-pushed the feat/settings-security branch 2 times, most recently from 0936192 to df67bca Compare September 20, 2024 20:41
Copy link

codecov bot commented Sep 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 22.38%. Comparing base (e8691eb) to head (f90d96c).
Report is 1 commits behind head on dev.

Additional details and impacted files
@@           Coverage Diff           @@
##              dev     #462   +/-   ##
=======================================
  Coverage   22.38%   22.38%           
=======================================
  Files         132      132           
  Lines        5521     5521           
  Branches      241      241           
=======================================
  Hits         1236     1236           
  Misses       4285     4285           
Components Coverage Δ
bitcoin 53.77% <ø> (ø)
query 12.05% <ø> (ø)
utils 52.45% <ø> (ø)
crypto 69.40% <ø> (ø)
stacks 53.27% <ø> (ø)

@edgarkhanzadian edgarkhanzadian added the needs:demo-build Create EAS simulator build based on label label Sep 23, 2024
@fbwoolf fbwoolf force-pushed the feat/settings-security branch 2 times, most recently from bbfbb97 to 1e04613 Compare September 23, 2024 15:30
@fbwoolf
Copy link
Contributor Author

fbwoolf commented Sep 23, 2024

@kyranjamie thoughts on renaming here, I went in a direction where I coordinated all settings to be ...Preference so when encountered we know it is associated to a preferred setting chosen by the user.

@leather-bot
Copy link
Contributor

@fbwoolf
Copy link
Contributor Author

fbwoolf commented Sep 23, 2024

@markmhendrickson can you confirm, is the app authentication turning on/off using biometrics? I am still a little unclear if I am interpreting this correctly?

@markmhendrickson
Copy link

Indeed, app authentication == whether the user needs to use device-level authentication (e.g. biometrics like Face ID or PIN as backup) to perform certain actions. If they do, they'll see the unlock view each time: https://github.com/leather-io/issues/issues/160

These are the intended triggers / actions that require unlock if enabled.

@fbwoolf
Copy link
Contributor Author

fbwoolf commented Sep 23, 2024

Indeed, app authentication == whether the user needs to use device-level authentication (e.g. biometrics like Face ID or PIN as backup) to perform certain actions. If they do, they'll see the unlock view each time: leather-io/issues#160

These are the intended triggers / actions that require unlock if enabled.

Got it, thanks for clarifying. 👍

@fbwoolf
Copy link
Contributor Author

fbwoolf commented Sep 23, 2024

@edgarkhanzadian where is the code that triggers the face id to popup? I see biometrics being passed around, but I'm not understanding what I can use to trigger it if the user toggles app auth on/off?

@leather-bot
Copy link
Contributor

@leather-bot
Copy link
Contributor

Comment on lines 18 to 21
useEffect(() => {
if (settings.securityLevelPreference === 'undefined')
settings.changeSecurityLevelPreference('insecure');
});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mmm, this seems weird? Why wouldn't we just set the preference as insecure in the store if it it changed automatically when landing on this page?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'll remove. Prob not needed but was asking for clarification on this setting from Edgar. I'm not sure why undefined is even needed in the type?

@leather-bot
Copy link
Contributor

@fbwoolf fbwoolf added this pull request to the merge queue Sep 24, 2024
Merged via the queue into dev with commit 936fa26 Sep 24, 2024
12 checks passed
@fbwoolf fbwoolf deleted the feat/settings-security branch September 24, 2024 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs:demo-build Create EAS simulator build based on label
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants