-
Notifications
You must be signed in to change notification settings - Fork 153
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: improving loginAttempt storage #1067
Changes from all commits
ebc5e22
79d6fda
ef4047a
00fe7b4
b7b80da
255cf5a
3b1b901
77a48a3
80eb302
412cf48
1719a3b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,11 +4,12 @@ | |
|
||
import { walletId, KeychainServices } from '../constants' | ||
import { WalletSecret } from '../types/security' | ||
import { LoginAttempt } from '../types/state' | ||
import { hashPIN } from '../utils/crypto' | ||
|
||
const keyFauxUserName = 'WalletFauxPINUserName' | ||
const saltFauxUserName = 'WalletFauxSaltUserName' | ||
|
||
const loginAttemptFauxUserName = 'WalletFauxLoginAttemptUserName' | ||
export interface WalletSalt { | ||
id: string | ||
salt: string | ||
|
@@ -72,6 +73,13 @@ | |
return typeof result === 'boolean' ? false : true | ||
} | ||
|
||
export const storeLoginAttempt = async (loginAttempt: LoginAttempt): Promise<boolean> => { | ||
const opts = optionsForKeychainAccess(KeychainServices.LoginAttempt, false) | ||
const loginAttemptAsString = JSON.stringify(loginAttempt) | ||
const result = await Keychain.setGenericPassword(loginAttemptFauxUserName, loginAttemptAsString, opts) | ||
return typeof result !== 'boolean' | ||
} | ||
|
||
export const storeWalletSecret = async (secret: WalletSecret, useBiometrics = false): Promise<boolean> => { | ||
let keyResult = false | ||
if (secret.key) { | ||
|
@@ -95,6 +103,19 @@ | |
return JSON.parse(result.password) as WalletSalt | ||
} | ||
|
||
export const loadLoginAttempt = async (): Promise<LoginAttempt | undefined> => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you export this method from the bifold index? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @bryce-mcmath I didn't understand. We don't have this method in the index There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if you go into |
||
const opts: Keychain.Options = { | ||
service: KeychainServices.LoginAttempt, | ||
} | ||
|
||
const result = await Keychain.getGenericPassword(opts) | ||
if (!result) { | ||
return | ||
} | ||
|
||
return JSON.parse(result.password) as LoginAttempt | ||
} | ||
|
||
export const loadWalletKey = async (title?: string, description?: string): Promise<WalletKey | undefined> => { | ||
let opts: Keychain.Options = { | ||
service: KeychainServices.Key, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wadeking98 Is this okay?