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

changing LAPolicyDeviceOwnerAuthenticationWithBiometrics to LAPolicyDeviceOwnerAuthentication #139

Open
wants to merge 124 commits into
base: fix/81-90
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
124 commits
Select commit Hold shift + click to select a range
7874e8b
Add poddspec file
rodan-lewarx Jan 23, 2018
c0f7af3
Update version based on package.json version
rodan-lewarx Jan 24, 2018
2ca794a
Update readme file
rodan-lewarx Jan 24, 2018
f7d3fb5
Add fallbackLabel option on iOS
mironiasty Feb 1, 2018
b0b538b
Update readme to describe new `fallbackLabel` option
mironiasty Feb 1, 2018
ad08695
Fix TouchID.m formatting and little update in readme
mironiasty Feb 1, 2018
34880a0
Update README to make `authenticate` params better described.
mironiasty Feb 5, 2018
61cde45
Fix typo in README
mironiasty Feb 7, 2018
db179d7
Check isHardwareDetected to prevent crashes on Samsung devices
mchudy Feb 22, 2018
b812455
Merge pull request #92 from naoufal/fix/81-90
zibs Feb 26, 2018
9c0ae27
Merge pull request #72 from rodan-lewarx/add-podspec
zibs Feb 26, 2018
0cf8458
Merge pull request #91 from mchudy/master
zibs Feb 26, 2018
a9c25c4
Allow customization of strings in Android dialog
mchudy Mar 8, 2018
fc09182
Make FingerprintDialog layout more responsive
mchudy Mar 8, 2018
5fea485
Replace spread operator with Object.assign
mchudy Mar 8, 2018
914aa00
Merge default config into supplied config
Aidurber Mar 10, 2018
c6adbd5
Merge pull request #100 from Aidurber/master
zibs Mar 10, 2018
c44d045
docs(CHANGELOG): Update changelog
naoufal Mar 11, 2018
454d0cf
chore(release): release 4.0.1
naoufal Mar 11, 2018
2764876
Merge branch 'master' into master
mchudy Mar 11, 2018
682be5f
Switch auth to allow passcode fallback
Mar 12, 2018
4cfbaaf
Ensure we check for functionality without biometrics as well
Mar 12, 2018
0248532
Adds readme section on permissions.
markrickert Mar 22, 2018
899ce15
Fix spelling error
ehellman Mar 23, 2018
fbd8756
Fix another spelling error
ehellman Mar 27, 2018
e4eb4a1
Add RCTNilIfNull for nil checking
mironiasty Apr 9, 2018
fb494f4
Merge pull request #103 from markrickert/readme-permissions
zibs Apr 26, 2018
15ffac5
Merge pull request #104 from ehellman/fix/spelling-error
zibs Apr 26, 2018
038dd48
Merge pull request #80 from 1debit/add-fallback-label-option-on-ios
zibs Apr 27, 2018
19191a8
🎨 Remove unused code, fixing lint issues.
nikDemyankov May 24, 2018
db94708
🐛 Cancel authentication when back button is pressed.
nikDemyankov May 24, 2018
bae528e
♻️🐛 Refactor module to fix crashes when app goes to background before…
nikDemyankov May 24, 2018
eca0f2f
🎨 Update comments, remove unused imports
nikDemyankov May 25, 2018
2fb9cd0
♻️ Cleanup fingerprint cipher
nikDemyankov May 25, 2018
2765f19
♻️ Refactor fingerprint handler a little bit.
nikDemyankov May 25, 2018
c65bbaf
♻️ Start auth when dialog is visible to the user. Cancel it when view…
nikDemyankov May 25, 2018
7ecde1f
♻️ Cleanup auth module.
nikDemyankov May 25, 2018
01acbc0
Merge pull request #122 from nikDemyankov/bugfix/issue-106
zibs May 26, 2018
d02143f
typo
zibs May 26, 2018
48950ce
4.0.2
zibs May 27, 2018
ebf2e1a
Merge remote-tracking branch 'upstream/master'
mchudy May 27, 2018
5cb609a
🐛 Fix android crashes on Android API < 23.
nikDemyankov May 28, 2018
db331b0
🎨 Remove unused import.
nikDemyankov May 29, 2018
e1687be
🐛 Protect from crashes when auth config is null.
nikDemyankov May 29, 2018
e591a2d
Strict mode fix: explicitly declare variable DEFAULT_CONFIG
Jun 11, 2018
2194449
Merge pull request #129 from fretman92/master
zibs Jun 12, 2018
fee8a23
Respect the Android lifecycle and stop listening for finger print act…
mcuelenaere Jun 22, 2018
a8c8caa
Merge pull request #123 from nikDemyankov/bugfix/old-android-crash
zibs Jun 30, 2018
d7e7ad6
4.0.3
zibs Jun 30, 2018
c52648a
Merge branch 'master' into properly-handle-lifecycle-when-reading-fin…
zibs Jun 30, 2018
c4e7269
Merge pull request #133 from mcuelenaere/properly-handle-lifecycle-wh…
zibs Jun 30, 2018
b89775a
Merge branch 'master' of github.com:naoufal/react-native-touch-id
zibs Jun 30, 2018
a53a6bf
4.0.4
zibs Jun 30, 2018
900b05b
Use SDK Version variables from root project
taranda Jul 10, 2018
9788eee
Merge remote-tracking branch 'upstream/master'
mchudy Aug 23, 2018
f1ab492
Restore original gradlew files
mchudy Aug 23, 2018
37de7e2
Add android error codes, unified errors
jspaine Aug 28, 2018
8363ec7
Merge pull request #140 from Aranda-Cyber-Solutions-LLC/master
zibs Sep 13, 2018
8df7c90
Merge branch 'master' of github.com:naoufal/react-native-touch-id
zibs Sep 13, 2018
a3ec26c
4.0.5
zibs Sep 13, 2018
b4f1fe6
Update README.md
zibs Sep 13, 2018
945878e
Merge pull request #153 from jspaine/unified_errors
zibs Sep 21, 2018
5e758da
small fixes
zibs Sep 21, 2018
5409ec2
Merge branch 'master' into master
zibs Sep 21, 2018
019d5b2
Merge pull request #99 from mchudy/master
zibs Sep 21, 2018
4f5a63f
add default unifiedErrors to android
zibs Sep 21, 2018
797801d
update readme
zibs Sep 21, 2018
8c95b6d
update readme
zibs Sep 21, 2018
f11f862
4.1.0
zibs Sep 21, 2018
ee72295
Update CHANGELOG.md
zibs Sep 21, 2018
d234022
Fix formatting
jspaine Sep 24, 2018
8b24d22
Merge pull request #159 from jspaine/fix-readme-formatting
zibs Sep 24, 2018
2410ebd
Merge remote-tracking branch 'upstream/master'
Oct 2, 2018
51ede1d
Update handler to clearly prefer biometrics, but fallback to PIN
Oct 2, 2018
cf1a56e
Merge pull request #1 from KomodoHQ/feature/merge-upstream
ianoshorty Oct 2, 2018
53096ec
Adding an optional config for iOS to allow passcode fallback
Oct 10, 2018
17f1ab6
Add config option for passcode fallback, default set to false to mimi…
Oct 10, 2018
00ed78b
Fix comma dangle failing travis build
Oct 10, 2018
778bde4
Adding more to README
Oct 10, 2018
578f3af
Android: handle failed attempts with error message
srulfi Oct 12, 2018
ce3e4f5
Android: replace color config option with imageColor. Add imageErrorC…
srulfi Oct 12, 2018
b84c3d5
Change repository order -- fix not find intellij
vanden1985 Oct 23, 2018
af54271
Merge pull request #166 from van1985/hotfix/build-gradle-config
zibs Oct 24, 2018
a6e1278
bump to 4.1.1
zibs Oct 27, 2018
520a603
Merge pull request #101 from KomodoHQ/master
zibs Oct 27, 2018
ae3c8a2
bump to 4.2.0
zibs Oct 27, 2018
ad0eeb8
Merge pull request #163 from srulfi/master
zibs Oct 27, 2018
c5615fc
update changelog
zibs Oct 27, 2018
c217659
merge
zibs Oct 27, 2018
b91aed7
bump 4.3.0
zibs Oct 27, 2018
eff5fd1
Update README.md
zibs Oct 27, 2018
9f5e95a
Update CHANGELOG.md
Oct 28, 2018
1ce40bc
Merge pull request #170 from ronilitman/patch-1
zibs Oct 28, 2018
91b6e35
Update README.md
zibs Oct 29, 2018
01bc745
Add typescript definition file
Aidurber Nov 9, 2018
4441568
Rename Config to IsSupportedConfig
Aidurber Nov 11, 2018
d2ff356
Merge pull request #178 from Aidurber/master
zibs Nov 11, 2018
24a84a0
fix(config): Allow optional fallback to passcode config on isSupporte…
pilsy Nov 27, 2018
a9821bf
fix(config): Optional passcodeFallback config in isSupported
pilsy Nov 27, 2018
0582fcc
fixed declaration variable DEFAULT_CONFIG for android
AleksandrZhukov Dec 22, 2018
cc666ac
Update build.gradle
Jan 22, 2019
1ff95b7
Add return type for authenticate
Manduro Jan 31, 2019
9e4f3fe
Update build.gradle
SaeedZhiany Feb 13, 2019
e1d3ab9
Merge pull request #182 from pilsy/fix/optional-is-supported-config
zibs Feb 15, 2019
18efcf5
update readme
zibs Feb 15, 2019
737c4ef
publish 4.4.0
zibs Feb 15, 2019
eba61d3
Merge pull request #189 from martinglova/patch-1
zibs Feb 15, 2019
6d70730
Merge pull request #186 from GettUK/master
zibs Feb 15, 2019
aa117ae
Merge pull request #195 from SaeedZhiany/patch-1
zibs Feb 15, 2019
a3e8f40
update changelog
zibs Feb 15, 2019
db10816
Merge branch 'master' of github.com:naoufal/react-native-touch-id
zibs Feb 15, 2019
e697d9c
updates;
zibs Feb 15, 2019
e2a2f36
4.4.1
zibs Feb 15, 2019
3f7bc3c
update: add LAErrorTouchIDLockout for iOS error codes
Feb 17, 2019
7137183
update codes indentation
Feb 17, 2019
2e7c4bc
Merge pull request #197 from Amos729/master
zibs Feb 19, 2019
3147822
Add types to package.json
maddijoyce Mar 19, 2019
83d18af
Revise android module to return the biometry type supported (instead …
Apr 13, 2019
ccd2148
Update build.gradle
SaeedZhiany May 1, 2019
3d7a3bc
Merge pull request #217 from adamshurson/android-return-string-type
zibs May 31, 2019
bb57633
Merge pull request #207 from maddijoyce/patch-1
zibs May 31, 2019
d7b69c6
Merge pull request #219 from SaeedZhiany/patch-1
zibs May 31, 2019
f865166
Merge pull request #192 from Manduro/types
zibs May 31, 2019
5e16c8e
Update README.md
zibs Jul 13, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion TouchID.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const { getError, TouchIDError, TouchIDUnifiedError } = require('./errors');
export default {
isSupported(config) {
return new Promise((resolve, reject) => {
NativeTouchID.isSupported((error, biometryType) => {
NativeTouchID.isSupported(config, (error, biometryType) => {
if (error) {
return reject(createError(config, error.message));
}
Expand Down
116 changes: 74 additions & 42 deletions TouchID.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,37 @@ @implementation TouchID

RCT_EXPORT_MODULE();

RCT_EXPORT_METHOD(isSupported: (RCTResponseSenderBlock)callback)
RCT_EXPORT_METHOD(isSupported: (NSDictionary *)options
callback: (RCTResponseSenderBlock)callback)
{
LAContext *context = [[LAContext alloc] init];
NSError *error;


// Check to see if we have a passcode fallback
NSNumber *passcodeFallback = [NSNumber numberWithBool:true];
if (RCTNilIfNull([options objectForKey:@"passcodeFallback"]) != nil) {
passcodeFallback = [RCTConvert NSNumber:options[@"passcodeFallback"]];
}

if ([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error]) {

// No error found, proceed
callback(@[[NSNull null], [self getBiometryType:context]]);
} else if ([passcodeFallback boolValue] && [context canEvaluatePolicy:LAPolicyDeviceOwnerAuthentication error:&error]) {

} else if ([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthentication error:&error]) {
// No error
callback(@[[NSNull null], [self getBiometryType:context]]);
}
// Device does not support FaceID / TouchID / Pin
// Device does not support FaceID / TouchID / Pin OR there was an error!
else {
if (error) {
NSString *errorReason = [self getErrorReason:error];
NSLog(@"Authentication failed: %@", errorReason);

callback(@[RCTMakeError(errorReason, nil, nil), [self getBiometryType:context]]);
return;
}

callback(@[RCTMakeError(@"RCTTouchIDNotSupported", nil, nil)]);
return;
}
Expand All @@ -33,7 +51,7 @@ @implementation TouchID
NSError *error;

if (RCTNilIfNull([options objectForKey:@"fallbackLabel"]) != nil) {
NSString *fallbackLabel = [RCTConvert NSString:options[@"fallbackLabel"]];
NSString *fallbackLabel = [RCTConvert NSString:options[@"fallbackLabel"]];
context.localizedFallbackTitle = fallbackLabel;
}

Expand All @@ -52,7 +70,7 @@ @implementation TouchID
}];

// Device does not support TouchID but user wishes to use passcode fallback
} else if ([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthentication error:&error] && [passcodeFallback boolValue]) {
} else if ([passcodeFallback boolValue] && [context canEvaluatePolicy:LAPolicyDeviceOwnerAuthentication error:&error]) {
// Attempt Authentification
[context evaluatePolicy:LAPolicyDeviceOwnerAuthentication
localizedReason:reason
Expand All @@ -62,6 +80,14 @@ @implementation TouchID
}];
}
else {
if (error) {
NSString *errorReason = [self getErrorReason:error];
NSLog(@"Authentication failed: %@", errorReason);

callback(@[RCTMakeError(errorReason, nil, nil), [self getBiometryType:context]]);
return;
}

callback(@[RCTMakeError(@"RCTTouchIDNotSupported", nil, nil)]);
return;
}
Expand All @@ -71,49 +97,55 @@ - (void)handleAttemptToUseDeviceIDWithSuccess:(BOOL)success error:(NSError *)err
if (success) { // Authentication Successful
callback(@[[NSNull null], @"Authenticated with Touch ID."]);
} else if (error) { // Authentication Error
NSString *errorReason;

switch (error.code) {
case LAErrorAuthenticationFailed:
errorReason = @"LAErrorAuthenticationFailed";
break;

case LAErrorUserCancel:
errorReason = @"LAErrorUserCancel";
break;

case LAErrorUserFallback:
errorReason = @"LAErrorUserFallback";
break;

case LAErrorSystemCancel:
errorReason = @"LAErrorSystemCancel";
break;

case LAErrorPasscodeNotSet:
errorReason = @"LAErrorPasscodeNotSet";
break;

case LAErrorTouchIDNotAvailable:
errorReason = @"LAErrorTouchIDNotAvailable";
break;

case LAErrorTouchIDNotEnrolled:
errorReason = @"LAErrorTouchIDNotEnrolled";
break;

default:
errorReason = @"RCTTouchIDUnknownError";
break;
}

NSString *errorReason = [self getErrorReason:error];
NSLog(@"Authentication failed: %@", errorReason);
callback(@[RCTMakeError(errorReason, nil, nil)]);
} else { // Authentication Failure
callback(@[RCTMakeError(@"LAErrorAuthenticationFailed", nil, nil)]);
}
}

- (NSString *)getErrorReason:(NSError *)error
{
NSString *errorReason;

switch (error.code) {
case LAErrorAuthenticationFailed:
errorReason = @"LAErrorAuthenticationFailed";
break;

case LAErrorUserCancel:
errorReason = @"LAErrorUserCancel";
break;

case LAErrorUserFallback:
errorReason = @"LAErrorUserFallback";
break;

case LAErrorSystemCancel:
errorReason = @"LAErrorSystemCancel";
break;

case LAErrorPasscodeNotSet:
errorReason = @"LAErrorPasscodeNotSet";
break;

case LAErrorTouchIDNotAvailable:
errorReason = @"LAErrorTouchIDNotAvailable";
break;

case LAErrorTouchIDNotEnrolled:
errorReason = @"LAErrorTouchIDNotEnrolled";
break;

default:
errorReason = @"RCTTouchIDUnknownError";
break;
}

return errorReason;
}

- (NSString *)getBiometryType:(LAContext *)context
{
if (@available(iOS 11, *)) {
Expand Down