@tokamakdev/plugin-local-authentication 0.1.0-beta.82 → 0.1.0-beta.84
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -2
- package/apple/LocalAuthenticationPlugin.swift +13 -2
- package/package.json +3 -3
- package/src/index.ts +2 -2
package/README.md
CHANGED
|
@@ -27,8 +27,9 @@ falling back to the device passcode, PIN, pattern or password) or `biometrics`.
|
|
|
27
27
|
|
|
28
28
|
`authenticate` resolves when the device owner authenticates. It rejects with
|
|
29
29
|
`NotAllowedError` when the user cancels or fails, `InvalidStateError` when the
|
|
30
|
-
authentication is not set up,
|
|
31
|
-
perform it
|
|
30
|
+
authentication is not set up, `NotSupportedError` when the device cannot
|
|
31
|
+
perform it, and `NeedsUIError` while the app is off screen on iOS or Android,
|
|
32
|
+
where the system cannot show its prompt.
|
|
32
33
|
|
|
33
34
|
`authenticate` checks the device owner when the app asks; it does not protect
|
|
34
35
|
any data. To bind a stored value to authentication, use
|
|
@@ -4,7 +4,11 @@ import LocalAuthentication
|
|
|
4
4
|
final class TokamakLocalAuthenticationPlugin: TokamakPlugin {
|
|
5
5
|
let id = "local-authentication"
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
private let host: TokamakHost
|
|
8
|
+
|
|
9
|
+
init(host: TokamakHost) {
|
|
10
|
+
self.host = host
|
|
11
|
+
}
|
|
8
12
|
|
|
9
13
|
func call(
|
|
10
14
|
method: String,
|
|
@@ -39,12 +43,19 @@ final class TokamakLocalAuthenticationPlugin: TokamakPlugin {
|
|
|
39
43
|
}
|
|
40
44
|
}
|
|
41
45
|
|
|
46
|
+
/// Shows the system prompt, which needs the app able to show UI, unless the
|
|
47
|
+
/// authentication fails without one.
|
|
42
48
|
private func authenticate(
|
|
43
49
|
_ policy: LAPolicy,
|
|
44
50
|
prompt: String,
|
|
45
51
|
reply: @escaping TokamakPluginReply
|
|
46
|
-
) {
|
|
52
|
+
) throws(TokamakPluginError) {
|
|
47
53
|
let context = LAContext()
|
|
54
|
+
var error: NSError?
|
|
55
|
+
guard context.canEvaluatePolicy(policy, error: &error) else {
|
|
56
|
+
throw Self.failure(error)
|
|
57
|
+
}
|
|
58
|
+
try host.requireUI()
|
|
48
59
|
if policy == .deviceOwnerAuthenticationWithBiometrics {
|
|
49
60
|
// Hides the passcode fallback button, which this policy cannot use.
|
|
50
61
|
context.localizedFallbackTitle = ""
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tokamakdev/plugin-local-authentication",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.84",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/mantty/tokamak.git",
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
"exports": {
|
|
11
11
|
".": "./src/index.ts"
|
|
12
12
|
},
|
|
13
|
-
"
|
|
14
|
-
"@tokamakdev/plugin": "0.1.0-beta.
|
|
13
|
+
"peerDependencies": {
|
|
14
|
+
"@tokamakdev/plugin": "0.1.0-beta.84"
|
|
15
15
|
},
|
|
16
16
|
"files": [
|
|
17
17
|
"android",
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Plugin } from "@tokamakdev/plugin";
|
|
2
2
|
|
|
3
3
|
/** The authentication the device owner performs. */
|
|
4
4
|
export type Authentication = "biometricsOrPasscode" | "biometrics";
|
|
@@ -11,7 +11,7 @@ export interface AuthenticateOptions {
|
|
|
11
11
|
readonly prompt: string;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
class LocalAuthentication extends
|
|
14
|
+
class LocalAuthentication extends Plugin {
|
|
15
15
|
constructor() {
|
|
16
16
|
super("local-authentication");
|
|
17
17
|
}
|