Skip to content

Commit

Permalink
Merge branch 'develop' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
simonmcl committed Jul 21, 2024
2 parents 9ca796b + e787c77 commit 5ff4b93
Show file tree
Hide file tree
Showing 8 changed files with 127 additions and 93 deletions.
6 changes: 3 additions & 3 deletions Kukai Mobile.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2430,7 +2430,7 @@
CODE_SIGN_ENTITLEMENTS = "Kukai Mobile/Kukai Mobile.entitlements";
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 317;
CURRENT_PROJECT_VERSION = 318;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = TK7KK2VPJP;
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = TK7KK2VPJP;
Expand Down Expand Up @@ -2470,7 +2470,7 @@
CODE_SIGN_IDENTITY = "iPhone Distribution";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 317;
CURRENT_PROJECT_VERSION = 318;
DEVELOPMENT_TEAM = TK7KK2VPJP;
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = TK7KK2VPJP;
ENABLE_BITCODE = NO;
Expand Down Expand Up @@ -2656,7 +2656,7 @@
CODE_SIGN_IDENTITY = "iPhone Distribution";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 317;
CURRENT_PROJECT_VERSION = 318;
DEVELOPMENT_TEAM = TK7KK2VPJP;
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = TK7KK2VPJP;
ENABLE_BITCODE = NO;
Expand Down
2 changes: 1 addition & 1 deletion Kukai Mobile/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>317</string>
<string>318</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSRequiresIPhoneOS</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ class CollectiblesCollectionsViewModel: ViewModel, UICollectionViewDiffableDataS
}

} else if let obj = dataSource?.itemIdentifier(for: forIndexPath) as? NFT {
urls = [MediaProxyService.smallURL(forNFT: obj)]
urls = [MediaProxyService.mediumURL(forNFT: obj)]
}

Logger.app.info("willDisplayImages: \(urls)")
Expand Down
154 changes: 77 additions & 77 deletions Kukai Mobile/Modules/Onboarding/Base.lproj/Onboarding.storyboard

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,16 @@ extension ConfirmPasscodeViewController: ValidatorTextFieldDelegate {
updateDigitViewsWithLength(length: text.count)

if validated {
if StorageService.validateTempPasscodeAndCommit(text) == true {
let storageResult = StorageService.validateTempPasscodeAndCommit(text)

if storageResult == .success {
navigate()

} else if storageResult == .biometricSetupError {
displayBiometricErrorAndReset()

} else {
displayErrorAndReset()
displayValidationErrorAndReset()
}
} else if text == "" {
errorLabel.isHidden = true
Expand All @@ -145,8 +151,19 @@ extension ConfirmPasscodeViewController: ValidatorTextFieldDelegate {

}

func displayErrorAndReset() {
func displayValidationErrorAndReset() {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { [weak self] in
self?.errorLabel.text = "Incorrect passcode try again"
self?.errorLabel.isHidden = false
self?.hiddenTextfield.text = ""
self?.updateDigitViewsWithLength(length: 0)
}
}

func displayBiometricErrorAndReset() {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { [weak self] in
let biometricTypeText = (CurrentDevice.biometricTypeSupported() == .touchID ? "Touch ID" : "Face ID")
self?.errorLabel.text = "Unknown error occured trying to use \(biometricTypeText). Please check your device settings and ensure its setup correctly"
self?.errorLabel.isHidden = false
self?.hiddenTextfield.text = ""
self?.updateDigitViewsWithLength(length: 0)
Expand Down
29 changes: 23 additions & 6 deletions Kukai Mobile/Services/StorageService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ public class StorageService {
public static let collectiblesGroupModeEnabled = "app.kukai.collectibles.group-mode"
}

public enum PasscodeStoreResult {
case success
case failure
case biometricSetupError
}



// MARK: - Cleanup
Expand Down Expand Up @@ -81,28 +87,39 @@ public class StorageService {
}

/// Compare temporary passcode with user supplied passcode. If valid, commit passcode to real storage (overwritting if necessary)
public static func validateTempPasscodeAndCommit(_ passcode: String) -> Bool {
public static func validateTempPasscodeAndCommit(_ passcode: String) -> PasscodeStoreResult {
guard let hash = KeychainSwift().get(StorageService.KeychainKeys.tempPasscode) else {
return false
return .failure
}

if Sodium.shared.pwHash.strVerify(hash: hash, passwd: passcode.bytes) {
return recordPasscode(passcode)
}

return false
return .failure
}

/// Delete previous record (if present) and create a new one with usePresence set
private static func recordPasscode(_ passcode: String) -> Bool {
private static func recordPasscode(_ passcode: String) -> PasscodeStoreResult {
guard let hash = Sodium.shared.pwHash.str(passwd: passcode.bytes, opsLimit: Sodium.shared.pwHash.OpsLimitInteractive, memLimit: Sodium.shared.pwHash.MemLimitInteractive) else {
return false
return .failure
}

// Recording the passcode only once with biometic flag, means when biometric enabled, users are unable to enter the passcode on its own (i.e. tapping cancel to biometric)
// Because retrieving the passcode to do the verification requires succesful biometrics
// Instead it needs to be stored twice, once where it can be accessed without biometrics and one with to enable both cases
return recordPasscodeHash(hash, withUserPresence: true) && recordPasscodeHash(hash, withUserPresence: false)
let res1 = recordPasscodeHash(hash, withUserPresence: true)
let res2 = recordPasscodeHash(hash, withUserPresence: false)

if res1 == false {
return .biometricSetupError

} else if res1 && res2 {
return .success

} else {
return .failure
}
}

private static func recordPasscodeHash(_ hash: String, withUserPresence: Bool) -> Bool {
Expand Down
2 changes: 1 addition & 1 deletion Kukai MobileTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>317</string>
<string>318</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion Kukai MobileUITests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>317</string>
<string>318</string>
</dict>
</plist>

0 comments on commit 5ff4b93

Please sign in to comment.