Skip to content

Commit 6c40087

Browse files
TS conversion
1 parent 43cb4f4 commit 6c40087

File tree

102 files changed

+1786
-467
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+1786
-467
lines changed

.gitignore

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,19 @@
11
.idea
2-
.vscode
2+
.vscode
3+
.DS_Store
4+
*.js
5+
*.log
6+
*.map
7+
*.tgz
8+
!src/angular/*.js
9+
!demo/karma.conf.js
10+
!demo/app/tests/*.js
11+
demo/*.d.ts
12+
src/*.d.ts
13+
!src/index.d.ts
14+
!src/references.d.ts
15+
demo/lib
16+
demo/platforms
17+
node_modules
18+
demo/hooks/
19+
publish/package/

.npmignore

Lines changed: 0 additions & 3 deletions
This file was deleted.

.travis.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
language: android
2+
3+
jdk: oraclejdk8
4+
5+
android:
6+
components:
7+
- tools
8+
- platform-tools
9+
- build-tools-25.0.2
10+
- android-25
11+
- extra-android-m2repository
12+
- sys-img-armeabi-v7a-android-21
13+
14+
before_cache:
15+
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
16+
17+
cache:
18+
directories:
19+
- .nvm
20+
- $HOME/.gradle/caches/
21+
- $HOME/.gradle/wrapper/
22+
23+
install:
24+
- nvm install node
25+
- npm install -g nativescript
26+
- tns usage-reporting disable
27+
- tns error-reporting disable
28+
- npm install
29+
30+
before_script:
31+
- echo no | android create avd --force -n test -t android-21 -b armeabi-v7a
32+
- emulator -avd test -no-audio -no-window &
33+
- android-wait-for-emulator
34+
35+
script:
36+
- cd src
37+
- npm run setup
38+
- npm run demo.android
39+
- npm run test.android

README.md

Lines changed: 83 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,109 @@
1-
# NativeScript Fingerprint authentication Plugin
2-
Formerly known as [`nativescript-touchid`](https://github.com/EddyVerbruggen/nativescript-fingerprint-auth/tree/nativescript-touchid)
1+
# NativeScript Fingerprint Authentication
32

4-
<img src="images/fingerprint.png" />
3+
[![Build Status][build-status]][build-url]
4+
[![NPM version][npm-image]][npm-url]
5+
[![Downloads][downloads-image]][npm-url]
6+
[![Twitter Follow][twitter-image]][twitter-url]
57

6-
### Use when
7-
* You want to know if the device runing your app has enrolled for [Touch ID](https://support.apple.com/en-us/HT201371),
8-
* You want to leverage a fingerprint scanner in your {N} app.
8+
[build-status]:https://travis-ci.org/EddyVerbruggen/nativescript-fingerprint-auth.svg?branch=master
9+
[build-url]:https://travis-ci.org/EddyVerbruggen/nativescript-fingerprint-auth
10+
[npm-image]:http://img.shields.io/npm/v/nativescript-fingerprint-auth.svg
11+
[npm-url]:https://npmjs.org/package/nativescript-fingerprint-auth
12+
[downloads-image]:http://img.shields.io/npm/dm/nativescript-fingerprint-auth.svg
13+
[twitter-image]:https://img.shields.io/twitter/follow/eddyverbruggen.svg?style=social&label=Follow%20me
14+
[twitter-url]:https://twitter.com/eddyverbruggen
15+
16+
<img src="https://github.com/EddyVerbruggen/nativescript-fingerprint-auth/tree/master/media/fingerprint.png" />
917

1018
## Installation
1119
From the command prompt go to your app's root folder and execute:
1220
```
1321
tns plugin add nativescript-fingerprint-auth
1422
```
1523

16-
## Usage
24+
## Demo
25+
If you want a quickstart, [check out the demo app](https://github.com/EddyVerbruggen/nativescript-fingerprint-auth/tree/master/demo).
1726

18-
If you want a quickstart, [clone our demo app](https://github.com/EddyVerbruggen/nativescript-fingerprint-auth-demo).
27+
<img src="https://github.com/EddyVerbruggen/nativescript-fingerprint-auth/tree/master/media/ios-demo-01.png" width="200px" />
28+
<img src="https://github.com/EddyVerbruggen/nativescript-fingerprint-auth/tree/master/media/ios-demo-02.png" width="200px" />
29+
<img src="https://github.com/EddyVerbruggen/nativescript-fingerprint-auth/tree/master/media/ios-demo-03.png" width="200px" />
30+
<img src="https://github.com/EddyVerbruggen/nativescript-fingerprint-auth/tree/master/media/ios-demo-04.png" width="200px" />
31+
<img src="https://github.com/EddyVerbruggen/nativescript-fingerprint-auth/tree/master/media/ios-demo-05.png" width="200px" />
1932

33+
## API
2034
Want a nicer guide than these raw code samples? Read [Nic Raboy's blog post about this plugin](https://www.thepolyglotdeveloper.com/2016/03/add-touch-id-authentication-support-to-your-nativescript-app/).
2135

22-
### function: available
36+
### `available`
37+
38+
#### JavaScript
2339
```js
24-
var fingerprintAuth = require("nativescript-fingerprint-auth");
40+
var fingerprintAuthPlugin = require("nativescript-fingerprint-auth");
41+
var fingerprintAuth = new fingerprintAuthPlugin.FingerprintAuth();
2542

26-
fingerprintAuth.available().then(
27-
function(avail) {
28-
console.log("Available? " + avail);
29-
}
30-
)
43+
fingerprintAuth.available().then(
44+
function(avail) {
45+
console.log("Available? " + avail);
46+
}
47+
)
3148
```
3249

33-
### function: verifyFingerprint
34-
50+
#### TypeScript
3551
```js
36-
fingerprintAuth.verifyFingerprint({
37-
title: 'Android title', // optional title (used only on Android)
38-
message: 'Scan yer finger', // optional (used on both platforms)
39-
authenticationValidityDuration: 10 // optional (used on Android, default 0)
40-
}).then(
41-
function() {
42-
console.log("Fingerprint was OK");
43-
},
44-
function(error) {
45-
console.log("Fingerprint NOT OK" + (error.code ? ". Code: " + error.code : ""));
46-
}
47-
)
52+
import { FingerprintAuth } from "nativescript-fingerprint-auth";
53+
54+
class MyClass {
55+
private fingerprintAuth: FingerprintAuth;
56+
57+
constructor() {
58+
this.fingerprintAuth = new FingerprintAuth();
59+
}
60+
61+
this.fingerprintAuth.available().then(
62+
(avail: boolean) => {
63+
console.log(`Available? ${avail}`);
64+
});
65+
);
66+
}
4867
```
4968

50-
### function: verifyFingerprintWithCustomFallback
69+
### `verifyFingerprint`
70+
Note that on the iOS simulator this will just `resolve()`.
71+
72+
```js
73+
fingerprintAuth.verifyFingerprint({
74+
title: 'Android title', // optional title (used only on Android)
75+
message: 'Scan yer finger', // optional (used on both platforms)
76+
authenticationValidityDuration: 10 // optional (used on Android, default 0)
77+
}).then(
78+
function() {
79+
console.log("Fingerprint was OK");
80+
},
81+
function() {
82+
console.log("Fingerprint NOT OK");
83+
}
84+
)
85+
```
5186

52-
#### Note: not implemented in android yet
87+
### `verifyFingerprintWithCustomFallback` (iOS only, falls back to `verifyFingerprint` on Android)
88+
Instead of falling back to the default Passcode UI of iOS you can roll your own.
89+
Just show that when the error callback is invoked.
5390

5491
```js
55-
fingerprintAuth.verifyFingerprintWithCustomFallback({
56-
message: 'Scan yer finger', // optional, shown in the fingerprint dialog (default: 'Scan your finger').
57-
fallbackMessage: 'Enter PIN' // optional, the button label when scanning fails (default: 'Enter password').
58-
}).then(
59-
function() {
60-
console.log("Fingerprint was OK");
61-
},
62-
function(error) {
63-
console.log("Fingerprint NOT OK" + (error.code ? ". Code: " + error.code : ""));
64-
}
65-
)
92+
fingerprintAuth.verifyFingerprintWithCustomFallback({
93+
message: 'Scan yer finger', // optional, shown in the fingerprint dialog (default: 'Scan your finger').
94+
fallbackMessage: 'Enter PIN' // optional, the button label when scanning fails (default: 'Enter password').
95+
}).then(
96+
function() {
97+
console.log("Fingerprint was OK");
98+
},
99+
function(error) {
100+
// when error.code === -3, the user pressed the button labeled with your fallbackMessage
101+
console.log("Fingerprint NOT OK. Error code: " + error.code + ". Error message: " + error.message);
102+
}
103+
)
66104
```
67105

68-
## Security++
106+
## Security++ (iOS)
69107
Since iOS9 it's possible to check whether or not the list of enrolled fingerprints changed since
70108
the last time you checked it. It's recommended you add this check so you can counter hacker attacks
71109
to your app. See [this article](https://godpraksis.no/2016/03/fingerprint-trojan/) for more details.
@@ -74,8 +112,6 @@ So instead of checking the fingerprint after `available` add another check.
74112
In case `didFingerprintDatabaseChange` returns `true` you probably want to re-authenticate your user
75113
before accepting valid fingerprints again.
76114

77-
#### Note: not implemented in android yet
78-
79115
```js
80116
fingerprintAuth.available().then(
81117
function(avail) {
@@ -95,7 +131,8 @@ fingerprintAuth.available().then(
95131
```
96132

97133
## Changelog
98-
- 3.0.0 Android support added. Renamed `nativescript-touchid` to `nativescript-fingerprint-auth` (sorry for any inconvenience!)
134+
- 4.0.0 Converted to TypeScript. Changed the error response type of `verifyFingerprintWithCustomFallback`.
135+
- 3.0.0 Android support added. Renamed `nativescript-touchid` to `nativescript-fingerprint-auth` (sorry for any inconvenience!).
99136
- 2.1.1 Xcode 8 compatibility - requires NativeScript 2.3.0+.
100137
- 2.1.0 Added `didFingerprintDatabaseChange` for enhanced security.
101138
- 2.0.0 Added `verifyFingerprintWithCustomFallback`, `verifyFingerprint` now falls back to the passcode.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="__PACKAGE__"
4+
android:versionCode="1"
5+
android:versionName="1.0">
6+
7+
<supports-screens
8+
android:smallScreens="true"
9+
android:normalScreens="true"
10+
android:largeScreens="true"
11+
android:xlargeScreens="true"/>
12+
13+
<uses-sdk
14+
android:minSdkVersion="17"
15+
android:targetSdkVersion="__APILEVEL__"/>
16+
17+
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
18+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
19+
<uses-permission android:name="android.permission.INTERNET"/>
20+
21+
<application
22+
android:name="com.tns.NativeScriptApplication"
23+
android:allowBackup="true"
24+
android:icon="@drawable/icon"
25+
android:label="@string/app_name"
26+
android:theme="@style/AppTheme">
27+
28+
<activity
29+
android:name="com.tns.NativeScriptActivity"
30+
android:label="@string/title_activity_kimera"
31+
android:configChanges="keyboardHidden|orientation|screenSize"
32+
android:theme="@style/LaunchScreenTheme">
33+
34+
<meta-data android:name="SET_THEME_ON_LAUNCH" android:resource="@style/AppTheme" />
35+
36+
<intent-filter>
37+
<action android:name="android.intent.action.MAIN" />
38+
<category android:name="android.intent.category.LAUNCHER" />
39+
</intent-filter>
40+
</activity>
41+
<activity android:name="com.tns.ErrorReportActivity"/>
42+
</application>
43+
</manifest>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Add your native dependencies here:
2+
3+
// Uncomment to add recyclerview-v7 dependency
4+
//dependencies {
5+
// compile 'com.android.support:recyclerview-v7:+'
6+
//}
7+
8+
android {
9+
defaultConfig {
10+
generatedDensities = []
11+
applicationId = "org.nativescript.FingerprintAuth"
12+
}
13+
aaptOptions {
14+
additionalParameters "--no-version-vectors"
15+
}
16+
}
3.42 KB
Loading
10.7 KB
Loading
32.4 KB
Loading
1.31 KB
Loading

0 commit comments

Comments
 (0)