@dynamic-labs/legacy-react-native-extension 5.16.1 → 5.17.0
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/android/KeyStoreKeyManager.kt +6 -4
- package/android/KeychainModule.kt +24 -6
- package/android/dynamic/keychain/KeyStoreKeyManager.kt +6 -4
- package/android/dynamic/keychain/KeychainModule.kt +24 -6
- package/android/java/xyz/dynamic/keychain/KeyStoreKeyManager.kt +6 -4
- package/android/java/xyz/dynamic/keychain/KeychainModule.kt +24 -6
- package/android/keychain/KeyStoreKeyManager.kt +6 -4
- package/android/keychain/KeychainModule.kt +24 -6
- package/android/main/java/xyz/dynamic/keychain/KeyStoreKeyManager.kt +6 -4
- package/android/main/java/xyz/dynamic/keychain/KeychainModule.kt +24 -6
- package/android/src/main/java/xyz/dynamic/keychain/KeyStoreKeyManager.kt +6 -4
- package/android/src/main/java/xyz/dynamic/keychain/KeychainModule.kt +24 -6
- package/android/xyz/dynamic/keychain/KeyStoreKeyManager.kt +6 -4
- package/android/xyz/dynamic/keychain/KeychainModule.kt +24 -6
- package/index.cjs +21 -5
- package/index.js +21 -5
- package/ios/KeychainModule.swift +12 -0
- package/package.json +6 -6
- package/src/ReactNativeExtension/ReactNativeExtension.d.ts +22 -1
- package/src/ReactNativeExtension/setupKeychainHandler/setupKeychainHandler.d.ts +8 -1
- package/src/nativeModules/Keychain.d.ts +11 -2
- package/turboModules/NativeKeychain.ts +6 -0
|
@@ -40,8 +40,8 @@ class KeyStoreKeyManager {
|
|
|
40
40
|
return keyStore.containsAlias(alias)
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
fun generateKeyPair(alias: String): String {
|
|
44
|
-
|
|
43
|
+
fun generateKeyPair(alias: String, strongBox: Boolean = false): String {
|
|
44
|
+
|
|
45
45
|
// Replace any existing key so the alias holds exactly one key and
|
|
46
46
|
// callers never have to pre-delete. iOS does the same explicitly in
|
|
47
47
|
// `SecureEnclaveKeyManager.generateKeyPair` — there the keychain would
|
|
@@ -58,7 +58,9 @@ class KeyStoreKeyManager {
|
|
|
58
58
|
.setAlgorithmParameterSpec(ECGenParameterSpec("secp256r1"))
|
|
59
59
|
.setDigests(KeyProperties.DIGEST_SHA256)
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
// TEE is the default: StrongBox signing is roughly 10-20x slower, so it is
|
|
62
|
+
// only worth it for callers that explicitly opt in.
|
|
63
|
+
if (strongBox && Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
|
62
64
|
specBuilder.setIsStrongBoxBacked(true)
|
|
63
65
|
}
|
|
64
66
|
|
|
@@ -66,7 +68,7 @@ class KeyStoreKeyManager {
|
|
|
66
68
|
generateKeyPairWithSpec(specBuilder.build())
|
|
67
69
|
} catch (e: ProviderException) {
|
|
68
70
|
// Without StrongBox requested there is nothing to fall back from.
|
|
69
|
-
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) {
|
|
71
|
+
if (!strongBox || Build.VERSION.SDK_INT < Build.VERSION_CODES.P) {
|
|
70
72
|
throw e
|
|
71
73
|
}
|
|
72
74
|
|
|
@@ -3,10 +3,26 @@ package xyz.dynamic.keychain
|
|
|
3
3
|
import expo.modules.kotlin.modules.Module
|
|
4
4
|
import expo.modules.kotlin.modules.ModuleDefinition
|
|
5
5
|
import expo.modules.kotlin.Promise
|
|
6
|
+
import expo.modules.kotlin.records.Field
|
|
7
|
+
import expo.modules.kotlin.records.Record
|
|
8
|
+
|
|
9
|
+
class GenerateKeyPairOptions : Record {
|
|
10
|
+
@Field
|
|
11
|
+
val strongBox: Boolean = false
|
|
12
|
+
}
|
|
6
13
|
|
|
7
14
|
class KeychainModule : Module() {
|
|
8
15
|
private val keyManager = KeyStoreKeyManager()
|
|
9
16
|
|
|
17
|
+
private fun generateKeyPair(key: String, strongBox: Boolean, promise: Promise) {
|
|
18
|
+
try {
|
|
19
|
+
val publicKey = keyManager.generateKeyPair(key, strongBox)
|
|
20
|
+
promise.resolve(mapOf("publicKey" to publicKey))
|
|
21
|
+
} catch (e: Exception) {
|
|
22
|
+
promise.reject("ERR_KEYCHAIN", "Failed to generate key pair: ${e.message}", e)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
10
26
|
override fun definition() = ModuleDefinition { // NOSONAR (cognitive complexity — inherent to Expo module DSL pattern)
|
|
11
27
|
Name("Keychain")
|
|
12
28
|
|
|
@@ -27,13 +43,15 @@ class KeychainModule : Module() {
|
|
|
27
43
|
}
|
|
28
44
|
}
|
|
29
45
|
|
|
46
|
+
// Kept with its one-argument signature: Expo rejects a call whose argument
|
|
47
|
+
// count differs from the native one, so older JS bundles still call this.
|
|
48
|
+
// TODO(next-major): remove generateKeyPair in favor of generateKeyPairWithOptions.
|
|
30
49
|
AsyncFunction("generateKeyPair") { key: String, promise: Promise ->
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
50
|
+
generateKeyPair(key, false, promise)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
AsyncFunction("generateKeyPairWithOptions") { key: String, options: GenerateKeyPairOptions, promise: Promise ->
|
|
54
|
+
generateKeyPair(key, options.strongBox, promise)
|
|
37
55
|
}
|
|
38
56
|
|
|
39
57
|
AsyncFunction("getPublicKey") { key: String, promise: Promise ->
|
|
@@ -40,8 +40,8 @@ class KeyStoreKeyManager {
|
|
|
40
40
|
return keyStore.containsAlias(alias)
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
fun generateKeyPair(alias: String): String {
|
|
44
|
-
|
|
43
|
+
fun generateKeyPair(alias: String, strongBox: Boolean = false): String {
|
|
44
|
+
|
|
45
45
|
// Replace any existing key so the alias holds exactly one key and
|
|
46
46
|
// callers never have to pre-delete. iOS does the same explicitly in
|
|
47
47
|
// `SecureEnclaveKeyManager.generateKeyPair` — there the keychain would
|
|
@@ -58,7 +58,9 @@ class KeyStoreKeyManager {
|
|
|
58
58
|
.setAlgorithmParameterSpec(ECGenParameterSpec("secp256r1"))
|
|
59
59
|
.setDigests(KeyProperties.DIGEST_SHA256)
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
// TEE is the default: StrongBox signing is roughly 10-20x slower, so it is
|
|
62
|
+
// only worth it for callers that explicitly opt in.
|
|
63
|
+
if (strongBox && Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
|
62
64
|
specBuilder.setIsStrongBoxBacked(true)
|
|
63
65
|
}
|
|
64
66
|
|
|
@@ -66,7 +68,7 @@ class KeyStoreKeyManager {
|
|
|
66
68
|
generateKeyPairWithSpec(specBuilder.build())
|
|
67
69
|
} catch (e: ProviderException) {
|
|
68
70
|
// Without StrongBox requested there is nothing to fall back from.
|
|
69
|
-
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) {
|
|
71
|
+
if (!strongBox || Build.VERSION.SDK_INT < Build.VERSION_CODES.P) {
|
|
70
72
|
throw e
|
|
71
73
|
}
|
|
72
74
|
|
|
@@ -3,10 +3,26 @@ package xyz.dynamic.keychain
|
|
|
3
3
|
import expo.modules.kotlin.modules.Module
|
|
4
4
|
import expo.modules.kotlin.modules.ModuleDefinition
|
|
5
5
|
import expo.modules.kotlin.Promise
|
|
6
|
+
import expo.modules.kotlin.records.Field
|
|
7
|
+
import expo.modules.kotlin.records.Record
|
|
8
|
+
|
|
9
|
+
class GenerateKeyPairOptions : Record {
|
|
10
|
+
@Field
|
|
11
|
+
val strongBox: Boolean = false
|
|
12
|
+
}
|
|
6
13
|
|
|
7
14
|
class KeychainModule : Module() {
|
|
8
15
|
private val keyManager = KeyStoreKeyManager()
|
|
9
16
|
|
|
17
|
+
private fun generateKeyPair(key: String, strongBox: Boolean, promise: Promise) {
|
|
18
|
+
try {
|
|
19
|
+
val publicKey = keyManager.generateKeyPair(key, strongBox)
|
|
20
|
+
promise.resolve(mapOf("publicKey" to publicKey))
|
|
21
|
+
} catch (e: Exception) {
|
|
22
|
+
promise.reject("ERR_KEYCHAIN", "Failed to generate key pair: ${e.message}", e)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
10
26
|
override fun definition() = ModuleDefinition { // NOSONAR (cognitive complexity — inherent to Expo module DSL pattern)
|
|
11
27
|
Name("Keychain")
|
|
12
28
|
|
|
@@ -27,13 +43,15 @@ class KeychainModule : Module() {
|
|
|
27
43
|
}
|
|
28
44
|
}
|
|
29
45
|
|
|
46
|
+
// Kept with its one-argument signature: Expo rejects a call whose argument
|
|
47
|
+
// count differs from the native one, so older JS bundles still call this.
|
|
48
|
+
// TODO(next-major): remove generateKeyPair in favor of generateKeyPairWithOptions.
|
|
30
49
|
AsyncFunction("generateKeyPair") { key: String, promise: Promise ->
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
50
|
+
generateKeyPair(key, false, promise)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
AsyncFunction("generateKeyPairWithOptions") { key: String, options: GenerateKeyPairOptions, promise: Promise ->
|
|
54
|
+
generateKeyPair(key, options.strongBox, promise)
|
|
37
55
|
}
|
|
38
56
|
|
|
39
57
|
AsyncFunction("getPublicKey") { key: String, promise: Promise ->
|
|
@@ -40,8 +40,8 @@ class KeyStoreKeyManager {
|
|
|
40
40
|
return keyStore.containsAlias(alias)
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
fun generateKeyPair(alias: String): String {
|
|
44
|
-
|
|
43
|
+
fun generateKeyPair(alias: String, strongBox: Boolean = false): String {
|
|
44
|
+
|
|
45
45
|
// Replace any existing key so the alias holds exactly one key and
|
|
46
46
|
// callers never have to pre-delete. iOS does the same explicitly in
|
|
47
47
|
// `SecureEnclaveKeyManager.generateKeyPair` — there the keychain would
|
|
@@ -58,7 +58,9 @@ class KeyStoreKeyManager {
|
|
|
58
58
|
.setAlgorithmParameterSpec(ECGenParameterSpec("secp256r1"))
|
|
59
59
|
.setDigests(KeyProperties.DIGEST_SHA256)
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
// TEE is the default: StrongBox signing is roughly 10-20x slower, so it is
|
|
62
|
+
// only worth it for callers that explicitly opt in.
|
|
63
|
+
if (strongBox && Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
|
62
64
|
specBuilder.setIsStrongBoxBacked(true)
|
|
63
65
|
}
|
|
64
66
|
|
|
@@ -66,7 +68,7 @@ class KeyStoreKeyManager {
|
|
|
66
68
|
generateKeyPairWithSpec(specBuilder.build())
|
|
67
69
|
} catch (e: ProviderException) {
|
|
68
70
|
// Without StrongBox requested there is nothing to fall back from.
|
|
69
|
-
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) {
|
|
71
|
+
if (!strongBox || Build.VERSION.SDK_INT < Build.VERSION_CODES.P) {
|
|
70
72
|
throw e
|
|
71
73
|
}
|
|
72
74
|
|
|
@@ -3,10 +3,26 @@ package xyz.dynamic.keychain
|
|
|
3
3
|
import expo.modules.kotlin.modules.Module
|
|
4
4
|
import expo.modules.kotlin.modules.ModuleDefinition
|
|
5
5
|
import expo.modules.kotlin.Promise
|
|
6
|
+
import expo.modules.kotlin.records.Field
|
|
7
|
+
import expo.modules.kotlin.records.Record
|
|
8
|
+
|
|
9
|
+
class GenerateKeyPairOptions : Record {
|
|
10
|
+
@Field
|
|
11
|
+
val strongBox: Boolean = false
|
|
12
|
+
}
|
|
6
13
|
|
|
7
14
|
class KeychainModule : Module() {
|
|
8
15
|
private val keyManager = KeyStoreKeyManager()
|
|
9
16
|
|
|
17
|
+
private fun generateKeyPair(key: String, strongBox: Boolean, promise: Promise) {
|
|
18
|
+
try {
|
|
19
|
+
val publicKey = keyManager.generateKeyPair(key, strongBox)
|
|
20
|
+
promise.resolve(mapOf("publicKey" to publicKey))
|
|
21
|
+
} catch (e: Exception) {
|
|
22
|
+
promise.reject("ERR_KEYCHAIN", "Failed to generate key pair: ${e.message}", e)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
10
26
|
override fun definition() = ModuleDefinition { // NOSONAR (cognitive complexity — inherent to Expo module DSL pattern)
|
|
11
27
|
Name("Keychain")
|
|
12
28
|
|
|
@@ -27,13 +43,15 @@ class KeychainModule : Module() {
|
|
|
27
43
|
}
|
|
28
44
|
}
|
|
29
45
|
|
|
46
|
+
// Kept with its one-argument signature: Expo rejects a call whose argument
|
|
47
|
+
// count differs from the native one, so older JS bundles still call this.
|
|
48
|
+
// TODO(next-major): remove generateKeyPair in favor of generateKeyPairWithOptions.
|
|
30
49
|
AsyncFunction("generateKeyPair") { key: String, promise: Promise ->
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
50
|
+
generateKeyPair(key, false, promise)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
AsyncFunction("generateKeyPairWithOptions") { key: String, options: GenerateKeyPairOptions, promise: Promise ->
|
|
54
|
+
generateKeyPair(key, options.strongBox, promise)
|
|
37
55
|
}
|
|
38
56
|
|
|
39
57
|
AsyncFunction("getPublicKey") { key: String, promise: Promise ->
|
|
@@ -40,8 +40,8 @@ class KeyStoreKeyManager {
|
|
|
40
40
|
return keyStore.containsAlias(alias)
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
fun generateKeyPair(alias: String): String {
|
|
44
|
-
|
|
43
|
+
fun generateKeyPair(alias: String, strongBox: Boolean = false): String {
|
|
44
|
+
|
|
45
45
|
// Replace any existing key so the alias holds exactly one key and
|
|
46
46
|
// callers never have to pre-delete. iOS does the same explicitly in
|
|
47
47
|
// `SecureEnclaveKeyManager.generateKeyPair` — there the keychain would
|
|
@@ -58,7 +58,9 @@ class KeyStoreKeyManager {
|
|
|
58
58
|
.setAlgorithmParameterSpec(ECGenParameterSpec("secp256r1"))
|
|
59
59
|
.setDigests(KeyProperties.DIGEST_SHA256)
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
// TEE is the default: StrongBox signing is roughly 10-20x slower, so it is
|
|
62
|
+
// only worth it for callers that explicitly opt in.
|
|
63
|
+
if (strongBox && Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
|
62
64
|
specBuilder.setIsStrongBoxBacked(true)
|
|
63
65
|
}
|
|
64
66
|
|
|
@@ -66,7 +68,7 @@ class KeyStoreKeyManager {
|
|
|
66
68
|
generateKeyPairWithSpec(specBuilder.build())
|
|
67
69
|
} catch (e: ProviderException) {
|
|
68
70
|
// Without StrongBox requested there is nothing to fall back from.
|
|
69
|
-
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) {
|
|
71
|
+
if (!strongBox || Build.VERSION.SDK_INT < Build.VERSION_CODES.P) {
|
|
70
72
|
throw e
|
|
71
73
|
}
|
|
72
74
|
|
|
@@ -3,10 +3,26 @@ package xyz.dynamic.keychain
|
|
|
3
3
|
import expo.modules.kotlin.modules.Module
|
|
4
4
|
import expo.modules.kotlin.modules.ModuleDefinition
|
|
5
5
|
import expo.modules.kotlin.Promise
|
|
6
|
+
import expo.modules.kotlin.records.Field
|
|
7
|
+
import expo.modules.kotlin.records.Record
|
|
8
|
+
|
|
9
|
+
class GenerateKeyPairOptions : Record {
|
|
10
|
+
@Field
|
|
11
|
+
val strongBox: Boolean = false
|
|
12
|
+
}
|
|
6
13
|
|
|
7
14
|
class KeychainModule : Module() {
|
|
8
15
|
private val keyManager = KeyStoreKeyManager()
|
|
9
16
|
|
|
17
|
+
private fun generateKeyPair(key: String, strongBox: Boolean, promise: Promise) {
|
|
18
|
+
try {
|
|
19
|
+
val publicKey = keyManager.generateKeyPair(key, strongBox)
|
|
20
|
+
promise.resolve(mapOf("publicKey" to publicKey))
|
|
21
|
+
} catch (e: Exception) {
|
|
22
|
+
promise.reject("ERR_KEYCHAIN", "Failed to generate key pair: ${e.message}", e)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
10
26
|
override fun definition() = ModuleDefinition { // NOSONAR (cognitive complexity — inherent to Expo module DSL pattern)
|
|
11
27
|
Name("Keychain")
|
|
12
28
|
|
|
@@ -27,13 +43,15 @@ class KeychainModule : Module() {
|
|
|
27
43
|
}
|
|
28
44
|
}
|
|
29
45
|
|
|
46
|
+
// Kept with its one-argument signature: Expo rejects a call whose argument
|
|
47
|
+
// count differs from the native one, so older JS bundles still call this.
|
|
48
|
+
// TODO(next-major): remove generateKeyPair in favor of generateKeyPairWithOptions.
|
|
30
49
|
AsyncFunction("generateKeyPair") { key: String, promise: Promise ->
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
50
|
+
generateKeyPair(key, false, promise)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
AsyncFunction("generateKeyPairWithOptions") { key: String, options: GenerateKeyPairOptions, promise: Promise ->
|
|
54
|
+
generateKeyPair(key, options.strongBox, promise)
|
|
37
55
|
}
|
|
38
56
|
|
|
39
57
|
AsyncFunction("getPublicKey") { key: String, promise: Promise ->
|
|
@@ -40,8 +40,8 @@ class KeyStoreKeyManager {
|
|
|
40
40
|
return keyStore.containsAlias(alias)
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
fun generateKeyPair(alias: String): String {
|
|
44
|
-
|
|
43
|
+
fun generateKeyPair(alias: String, strongBox: Boolean = false): String {
|
|
44
|
+
|
|
45
45
|
// Replace any existing key so the alias holds exactly one key and
|
|
46
46
|
// callers never have to pre-delete. iOS does the same explicitly in
|
|
47
47
|
// `SecureEnclaveKeyManager.generateKeyPair` — there the keychain would
|
|
@@ -58,7 +58,9 @@ class KeyStoreKeyManager {
|
|
|
58
58
|
.setAlgorithmParameterSpec(ECGenParameterSpec("secp256r1"))
|
|
59
59
|
.setDigests(KeyProperties.DIGEST_SHA256)
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
// TEE is the default: StrongBox signing is roughly 10-20x slower, so it is
|
|
62
|
+
// only worth it for callers that explicitly opt in.
|
|
63
|
+
if (strongBox && Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
|
62
64
|
specBuilder.setIsStrongBoxBacked(true)
|
|
63
65
|
}
|
|
64
66
|
|
|
@@ -66,7 +68,7 @@ class KeyStoreKeyManager {
|
|
|
66
68
|
generateKeyPairWithSpec(specBuilder.build())
|
|
67
69
|
} catch (e: ProviderException) {
|
|
68
70
|
// Without StrongBox requested there is nothing to fall back from.
|
|
69
|
-
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) {
|
|
71
|
+
if (!strongBox || Build.VERSION.SDK_INT < Build.VERSION_CODES.P) {
|
|
70
72
|
throw e
|
|
71
73
|
}
|
|
72
74
|
|
|
@@ -3,10 +3,26 @@ package xyz.dynamic.keychain
|
|
|
3
3
|
import expo.modules.kotlin.modules.Module
|
|
4
4
|
import expo.modules.kotlin.modules.ModuleDefinition
|
|
5
5
|
import expo.modules.kotlin.Promise
|
|
6
|
+
import expo.modules.kotlin.records.Field
|
|
7
|
+
import expo.modules.kotlin.records.Record
|
|
8
|
+
|
|
9
|
+
class GenerateKeyPairOptions : Record {
|
|
10
|
+
@Field
|
|
11
|
+
val strongBox: Boolean = false
|
|
12
|
+
}
|
|
6
13
|
|
|
7
14
|
class KeychainModule : Module() {
|
|
8
15
|
private val keyManager = KeyStoreKeyManager()
|
|
9
16
|
|
|
17
|
+
private fun generateKeyPair(key: String, strongBox: Boolean, promise: Promise) {
|
|
18
|
+
try {
|
|
19
|
+
val publicKey = keyManager.generateKeyPair(key, strongBox)
|
|
20
|
+
promise.resolve(mapOf("publicKey" to publicKey))
|
|
21
|
+
} catch (e: Exception) {
|
|
22
|
+
promise.reject("ERR_KEYCHAIN", "Failed to generate key pair: ${e.message}", e)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
10
26
|
override fun definition() = ModuleDefinition { // NOSONAR (cognitive complexity — inherent to Expo module DSL pattern)
|
|
11
27
|
Name("Keychain")
|
|
12
28
|
|
|
@@ -27,13 +43,15 @@ class KeychainModule : Module() {
|
|
|
27
43
|
}
|
|
28
44
|
}
|
|
29
45
|
|
|
46
|
+
// Kept with its one-argument signature: Expo rejects a call whose argument
|
|
47
|
+
// count differs from the native one, so older JS bundles still call this.
|
|
48
|
+
// TODO(next-major): remove generateKeyPair in favor of generateKeyPairWithOptions.
|
|
30
49
|
AsyncFunction("generateKeyPair") { key: String, promise: Promise ->
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
50
|
+
generateKeyPair(key, false, promise)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
AsyncFunction("generateKeyPairWithOptions") { key: String, options: GenerateKeyPairOptions, promise: Promise ->
|
|
54
|
+
generateKeyPair(key, options.strongBox, promise)
|
|
37
55
|
}
|
|
38
56
|
|
|
39
57
|
AsyncFunction("getPublicKey") { key: String, promise: Promise ->
|
|
@@ -40,8 +40,8 @@ class KeyStoreKeyManager {
|
|
|
40
40
|
return keyStore.containsAlias(alias)
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
fun generateKeyPair(alias: String): String {
|
|
44
|
-
|
|
43
|
+
fun generateKeyPair(alias: String, strongBox: Boolean = false): String {
|
|
44
|
+
|
|
45
45
|
// Replace any existing key so the alias holds exactly one key and
|
|
46
46
|
// callers never have to pre-delete. iOS does the same explicitly in
|
|
47
47
|
// `SecureEnclaveKeyManager.generateKeyPair` — there the keychain would
|
|
@@ -58,7 +58,9 @@ class KeyStoreKeyManager {
|
|
|
58
58
|
.setAlgorithmParameterSpec(ECGenParameterSpec("secp256r1"))
|
|
59
59
|
.setDigests(KeyProperties.DIGEST_SHA256)
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
// TEE is the default: StrongBox signing is roughly 10-20x slower, so it is
|
|
62
|
+
// only worth it for callers that explicitly opt in.
|
|
63
|
+
if (strongBox && Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
|
62
64
|
specBuilder.setIsStrongBoxBacked(true)
|
|
63
65
|
}
|
|
64
66
|
|
|
@@ -66,7 +68,7 @@ class KeyStoreKeyManager {
|
|
|
66
68
|
generateKeyPairWithSpec(specBuilder.build())
|
|
67
69
|
} catch (e: ProviderException) {
|
|
68
70
|
// Without StrongBox requested there is nothing to fall back from.
|
|
69
|
-
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) {
|
|
71
|
+
if (!strongBox || Build.VERSION.SDK_INT < Build.VERSION_CODES.P) {
|
|
70
72
|
throw e
|
|
71
73
|
}
|
|
72
74
|
|
|
@@ -3,10 +3,26 @@ package xyz.dynamic.keychain
|
|
|
3
3
|
import expo.modules.kotlin.modules.Module
|
|
4
4
|
import expo.modules.kotlin.modules.ModuleDefinition
|
|
5
5
|
import expo.modules.kotlin.Promise
|
|
6
|
+
import expo.modules.kotlin.records.Field
|
|
7
|
+
import expo.modules.kotlin.records.Record
|
|
8
|
+
|
|
9
|
+
class GenerateKeyPairOptions : Record {
|
|
10
|
+
@Field
|
|
11
|
+
val strongBox: Boolean = false
|
|
12
|
+
}
|
|
6
13
|
|
|
7
14
|
class KeychainModule : Module() {
|
|
8
15
|
private val keyManager = KeyStoreKeyManager()
|
|
9
16
|
|
|
17
|
+
private fun generateKeyPair(key: String, strongBox: Boolean, promise: Promise) {
|
|
18
|
+
try {
|
|
19
|
+
val publicKey = keyManager.generateKeyPair(key, strongBox)
|
|
20
|
+
promise.resolve(mapOf("publicKey" to publicKey))
|
|
21
|
+
} catch (e: Exception) {
|
|
22
|
+
promise.reject("ERR_KEYCHAIN", "Failed to generate key pair: ${e.message}", e)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
10
26
|
override fun definition() = ModuleDefinition { // NOSONAR (cognitive complexity — inherent to Expo module DSL pattern)
|
|
11
27
|
Name("Keychain")
|
|
12
28
|
|
|
@@ -27,13 +43,15 @@ class KeychainModule : Module() {
|
|
|
27
43
|
}
|
|
28
44
|
}
|
|
29
45
|
|
|
46
|
+
// Kept with its one-argument signature: Expo rejects a call whose argument
|
|
47
|
+
// count differs from the native one, so older JS bundles still call this.
|
|
48
|
+
// TODO(next-major): remove generateKeyPair in favor of generateKeyPairWithOptions.
|
|
30
49
|
AsyncFunction("generateKeyPair") { key: String, promise: Promise ->
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
50
|
+
generateKeyPair(key, false, promise)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
AsyncFunction("generateKeyPairWithOptions") { key: String, options: GenerateKeyPairOptions, promise: Promise ->
|
|
54
|
+
generateKeyPair(key, options.strongBox, promise)
|
|
37
55
|
}
|
|
38
56
|
|
|
39
57
|
AsyncFunction("getPublicKey") { key: String, promise: Promise ->
|
|
@@ -40,8 +40,8 @@ class KeyStoreKeyManager {
|
|
|
40
40
|
return keyStore.containsAlias(alias)
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
fun generateKeyPair(alias: String): String {
|
|
44
|
-
|
|
43
|
+
fun generateKeyPair(alias: String, strongBox: Boolean = false): String {
|
|
44
|
+
|
|
45
45
|
// Replace any existing key so the alias holds exactly one key and
|
|
46
46
|
// callers never have to pre-delete. iOS does the same explicitly in
|
|
47
47
|
// `SecureEnclaveKeyManager.generateKeyPair` — there the keychain would
|
|
@@ -58,7 +58,9 @@ class KeyStoreKeyManager {
|
|
|
58
58
|
.setAlgorithmParameterSpec(ECGenParameterSpec("secp256r1"))
|
|
59
59
|
.setDigests(KeyProperties.DIGEST_SHA256)
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
// TEE is the default: StrongBox signing is roughly 10-20x slower, so it is
|
|
62
|
+
// only worth it for callers that explicitly opt in.
|
|
63
|
+
if (strongBox && Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
|
62
64
|
specBuilder.setIsStrongBoxBacked(true)
|
|
63
65
|
}
|
|
64
66
|
|
|
@@ -66,7 +68,7 @@ class KeyStoreKeyManager {
|
|
|
66
68
|
generateKeyPairWithSpec(specBuilder.build())
|
|
67
69
|
} catch (e: ProviderException) {
|
|
68
70
|
// Without StrongBox requested there is nothing to fall back from.
|
|
69
|
-
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) {
|
|
71
|
+
if (!strongBox || Build.VERSION.SDK_INT < Build.VERSION_CODES.P) {
|
|
70
72
|
throw e
|
|
71
73
|
}
|
|
72
74
|
|
|
@@ -3,10 +3,26 @@ package xyz.dynamic.keychain
|
|
|
3
3
|
import expo.modules.kotlin.modules.Module
|
|
4
4
|
import expo.modules.kotlin.modules.ModuleDefinition
|
|
5
5
|
import expo.modules.kotlin.Promise
|
|
6
|
+
import expo.modules.kotlin.records.Field
|
|
7
|
+
import expo.modules.kotlin.records.Record
|
|
8
|
+
|
|
9
|
+
class GenerateKeyPairOptions : Record {
|
|
10
|
+
@Field
|
|
11
|
+
val strongBox: Boolean = false
|
|
12
|
+
}
|
|
6
13
|
|
|
7
14
|
class KeychainModule : Module() {
|
|
8
15
|
private val keyManager = KeyStoreKeyManager()
|
|
9
16
|
|
|
17
|
+
private fun generateKeyPair(key: String, strongBox: Boolean, promise: Promise) {
|
|
18
|
+
try {
|
|
19
|
+
val publicKey = keyManager.generateKeyPair(key, strongBox)
|
|
20
|
+
promise.resolve(mapOf("publicKey" to publicKey))
|
|
21
|
+
} catch (e: Exception) {
|
|
22
|
+
promise.reject("ERR_KEYCHAIN", "Failed to generate key pair: ${e.message}", e)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
10
26
|
override fun definition() = ModuleDefinition { // NOSONAR (cognitive complexity — inherent to Expo module DSL pattern)
|
|
11
27
|
Name("Keychain")
|
|
12
28
|
|
|
@@ -27,13 +43,15 @@ class KeychainModule : Module() {
|
|
|
27
43
|
}
|
|
28
44
|
}
|
|
29
45
|
|
|
46
|
+
// Kept with its one-argument signature: Expo rejects a call whose argument
|
|
47
|
+
// count differs from the native one, so older JS bundles still call this.
|
|
48
|
+
// TODO(next-major): remove generateKeyPair in favor of generateKeyPairWithOptions.
|
|
30
49
|
AsyncFunction("generateKeyPair") { key: String, promise: Promise ->
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
50
|
+
generateKeyPair(key, false, promise)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
AsyncFunction("generateKeyPairWithOptions") { key: String, options: GenerateKeyPairOptions, promise: Promise ->
|
|
54
|
+
generateKeyPair(key, options.strongBox, promise)
|
|
37
55
|
}
|
|
38
56
|
|
|
39
57
|
AsyncFunction("getPublicKey") { key: String, promise: Promise ->
|
package/index.cjs
CHANGED
|
@@ -35,7 +35,7 @@ function _interopNamespace(e) {
|
|
|
35
35
|
return Object.freeze(n);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
var version = "5.
|
|
38
|
+
var version = "5.17.0";
|
|
39
39
|
|
|
40
40
|
function _extends() {
|
|
41
41
|
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
@@ -573,6 +573,7 @@ const getKeychain = () => {
|
|
|
573
573
|
const unavailableKeychain = {
|
|
574
574
|
deleteKey: () => Promise.reject(keychainUnavailableError),
|
|
575
575
|
generateKeyPair: () => Promise.reject(keychainUnavailableError),
|
|
576
|
+
generateKeyPairWithOptions: () => Promise.reject(keychainUnavailableError),
|
|
576
577
|
getPublicKey: () => Promise.reject(keychainUnavailableError),
|
|
577
578
|
hasKey: () => Promise.reject(keychainUnavailableError),
|
|
578
579
|
isAvailable: () => Promise.resolve(false),
|
|
@@ -1089,9 +1090,18 @@ const setupTurnkeyPasskeyHandler = core => {
|
|
|
1089
1090
|
}));
|
|
1090
1091
|
};
|
|
1091
1092
|
|
|
1092
|
-
const
|
|
1093
|
+
const STRONG_BOX_UNSUPPORTED_WARNING = "android.strongBox was set, but this app's native build predates it, so it has no effect. " + "Keys are generated with the native build's built-in behavior (StrongBox when the device supports it). " + 'Rebuild the native app with the latest @dynamic-labs/react-native-extension to apply the option.';
|
|
1094
|
+
// An over-the-air JS update can run on a native binary built before
|
|
1095
|
+
// generateKeyPairWithOptions existed, where the method is absent.
|
|
1096
|
+
const supportsKeyPairOptions = keychain => typeof keychain.generateKeyPairWithOptions === 'function';
|
|
1097
|
+
const setupKeychainHandler = (core, {
|
|
1098
|
+
androidStrongBox
|
|
1099
|
+
} = {}) => {
|
|
1093
1100
|
const keychainRequestChannel = messageTransport.createRequestChannel(core.messageTransport);
|
|
1094
1101
|
const keychain = getKeychain();
|
|
1102
|
+
if (androidStrongBox !== undefined && reactNative.Platform.OS === 'android' && !supportsKeyPairOptions(keychain)) {
|
|
1103
|
+
logger.warn(STRONG_BOX_UNSUPPORTED_WARNING);
|
|
1104
|
+
}
|
|
1095
1105
|
keychainRequestChannel.handle('keychain_isAvailable', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1096
1106
|
return keychain.isAvailable();
|
|
1097
1107
|
}));
|
|
@@ -1100,10 +1110,13 @@ const setupKeychainHandler = core => {
|
|
|
1100
1110
|
}) {
|
|
1101
1111
|
return keychain.hasKey(key);
|
|
1102
1112
|
}));
|
|
1113
|
+
// TODO(next-major): call generateKeyPairWithOptions unconditionally.
|
|
1103
1114
|
keychainRequestChannel.handle('keychain_generateKey', _b => __awaiter(void 0, [_b], void 0, function* ({
|
|
1104
1115
|
key
|
|
1105
1116
|
}) {
|
|
1106
|
-
return keychain.
|
|
1117
|
+
return supportsKeyPairOptions(keychain) ? keychain.generateKeyPairWithOptions(key, {
|
|
1118
|
+
strongBox: androidStrongBox === true
|
|
1119
|
+
}) : keychain.generateKeyPair(key);
|
|
1107
1120
|
}));
|
|
1108
1121
|
keychainRequestChannel.handle('keychain_getPublicKey', _c => __awaiter(void 0, [_c], void 0, function* ({
|
|
1109
1122
|
key
|
|
@@ -1149,7 +1162,8 @@ const ReactNativeExtension = ({
|
|
|
1149
1162
|
appOrigin,
|
|
1150
1163
|
embeddedWebView: _embeddedWebView = false,
|
|
1151
1164
|
webviewLoad,
|
|
1152
|
-
allowWebViewPopups
|
|
1165
|
+
allowWebViewPopups,
|
|
1166
|
+
android
|
|
1153
1167
|
} = {}) => (_, core) => {
|
|
1154
1168
|
const isPlatformSupportedByWebView = reactNative.Platform.OS === 'android' || reactNative.Platform.OS === 'ios';
|
|
1155
1169
|
/**
|
|
@@ -1181,7 +1195,9 @@ const ReactNativeExtension = ({
|
|
|
1181
1195
|
setupTurnkeyPasskeyHandler(core);
|
|
1182
1196
|
setupPlatformHandler(core);
|
|
1183
1197
|
setupStorageHandler(core);
|
|
1184
|
-
setupKeychainHandler(core
|
|
1198
|
+
setupKeychainHandler(core, {
|
|
1199
|
+
androidStrongBox: android === null || android === void 0 ? void 0 : android.strongBox
|
|
1200
|
+
});
|
|
1185
1201
|
// Native overlay-webview path (iOS WKWebView / Android android.webkit
|
|
1186
1202
|
// .WebView). When the native module isn't linked — e.g. an OTA JS update on
|
|
1187
1203
|
// an older binary that predates it — fall through to the
|
package/index.js
CHANGED
|
@@ -14,7 +14,7 @@ import { openAuthSessionAsync } from 'expo-web-browser';
|
|
|
14
14
|
import { resetGenericPassword, getGenericPassword, setGenericPassword } from 'react-native-keychain';
|
|
15
15
|
import { createPasskey, PasskeyStamper } from '@turnkey/react-native-passkey-stamper';
|
|
16
16
|
|
|
17
|
-
var version = "5.
|
|
17
|
+
var version = "5.17.0";
|
|
18
18
|
|
|
19
19
|
function _extends() {
|
|
20
20
|
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
@@ -552,6 +552,7 @@ const getKeychain = () => {
|
|
|
552
552
|
const unavailableKeychain = {
|
|
553
553
|
deleteKey: () => Promise.reject(keychainUnavailableError),
|
|
554
554
|
generateKeyPair: () => Promise.reject(keychainUnavailableError),
|
|
555
|
+
generateKeyPairWithOptions: () => Promise.reject(keychainUnavailableError),
|
|
555
556
|
getPublicKey: () => Promise.reject(keychainUnavailableError),
|
|
556
557
|
hasKey: () => Promise.reject(keychainUnavailableError),
|
|
557
558
|
isAvailable: () => Promise.resolve(false),
|
|
@@ -1068,9 +1069,18 @@ const setupTurnkeyPasskeyHandler = core => {
|
|
|
1068
1069
|
}));
|
|
1069
1070
|
};
|
|
1070
1071
|
|
|
1071
|
-
const
|
|
1072
|
+
const STRONG_BOX_UNSUPPORTED_WARNING = "android.strongBox was set, but this app's native build predates it, so it has no effect. " + "Keys are generated with the native build's built-in behavior (StrongBox when the device supports it). " + 'Rebuild the native app with the latest @dynamic-labs/react-native-extension to apply the option.';
|
|
1073
|
+
// An over-the-air JS update can run on a native binary built before
|
|
1074
|
+
// generateKeyPairWithOptions existed, where the method is absent.
|
|
1075
|
+
const supportsKeyPairOptions = keychain => typeof keychain.generateKeyPairWithOptions === 'function';
|
|
1076
|
+
const setupKeychainHandler = (core, {
|
|
1077
|
+
androidStrongBox
|
|
1078
|
+
} = {}) => {
|
|
1072
1079
|
const keychainRequestChannel = createRequestChannel(core.messageTransport);
|
|
1073
1080
|
const keychain = getKeychain();
|
|
1081
|
+
if (androidStrongBox !== undefined && Platform.OS === 'android' && !supportsKeyPairOptions(keychain)) {
|
|
1082
|
+
logger.warn(STRONG_BOX_UNSUPPORTED_WARNING);
|
|
1083
|
+
}
|
|
1074
1084
|
keychainRequestChannel.handle('keychain_isAvailable', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1075
1085
|
return keychain.isAvailable();
|
|
1076
1086
|
}));
|
|
@@ -1079,10 +1089,13 @@ const setupKeychainHandler = core => {
|
|
|
1079
1089
|
}) {
|
|
1080
1090
|
return keychain.hasKey(key);
|
|
1081
1091
|
}));
|
|
1092
|
+
// TODO(next-major): call generateKeyPairWithOptions unconditionally.
|
|
1082
1093
|
keychainRequestChannel.handle('keychain_generateKey', _b => __awaiter(void 0, [_b], void 0, function* ({
|
|
1083
1094
|
key
|
|
1084
1095
|
}) {
|
|
1085
|
-
return keychain.
|
|
1096
|
+
return supportsKeyPairOptions(keychain) ? keychain.generateKeyPairWithOptions(key, {
|
|
1097
|
+
strongBox: androidStrongBox === true
|
|
1098
|
+
}) : keychain.generateKeyPair(key);
|
|
1086
1099
|
}));
|
|
1087
1100
|
keychainRequestChannel.handle('keychain_getPublicKey', _c => __awaiter(void 0, [_c], void 0, function* ({
|
|
1088
1101
|
key
|
|
@@ -1128,7 +1141,8 @@ const ReactNativeExtension = ({
|
|
|
1128
1141
|
appOrigin,
|
|
1129
1142
|
embeddedWebView: _embeddedWebView = false,
|
|
1130
1143
|
webviewLoad,
|
|
1131
|
-
allowWebViewPopups
|
|
1144
|
+
allowWebViewPopups,
|
|
1145
|
+
android
|
|
1132
1146
|
} = {}) => (_, core) => {
|
|
1133
1147
|
const isPlatformSupportedByWebView = Platform.OS === 'android' || Platform.OS === 'ios';
|
|
1134
1148
|
/**
|
|
@@ -1160,7 +1174,9 @@ const ReactNativeExtension = ({
|
|
|
1160
1174
|
setupTurnkeyPasskeyHandler(core);
|
|
1161
1175
|
setupPlatformHandler(core);
|
|
1162
1176
|
setupStorageHandler(core);
|
|
1163
|
-
setupKeychainHandler(core
|
|
1177
|
+
setupKeychainHandler(core, {
|
|
1178
|
+
androidStrongBox: android === null || android === void 0 ? void 0 : android.strongBox
|
|
1179
|
+
});
|
|
1164
1180
|
// Native overlay-webview path (iOS WKWebView / Android android.webkit
|
|
1165
1181
|
// .WebView). When the native module isn't linked — e.g. an OTA JS update on
|
|
1166
1182
|
// an older binary that predates it — fall through to the
|
package/ios/KeychainModule.swift
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import ExpoModulesCore
|
|
2
2
|
|
|
3
|
+
struct GenerateKeyPairOptions: Record {
|
|
4
|
+
@Field var strongBox: Bool = false
|
|
5
|
+
}
|
|
6
|
+
|
|
3
7
|
public class KeychainModule: Module {
|
|
4
8
|
private let keyManager = SecureEnclaveKeyManager()
|
|
5
9
|
|
|
@@ -14,11 +18,19 @@ public class KeychainModule: Module {
|
|
|
14
18
|
self.keyManager.hasKey(tag: key)
|
|
15
19
|
}
|
|
16
20
|
|
|
21
|
+
// TODO(next-major): remove generateKeyPair in favor of generateKeyPairWithOptions.
|
|
17
22
|
AsyncFunction("generateKeyPair") { (key: String) -> [String: String] in
|
|
18
23
|
let publicKey = try self.keyManager.generateKeyPair(tag: key)
|
|
19
24
|
return ["publicKey": publicKey]
|
|
20
25
|
}
|
|
21
26
|
|
|
27
|
+
// `strongBox` is Android-only: iOS keys always live in the Secure Enclave,
|
|
28
|
+
// the only backing tier, so the option is accepted and ignored.
|
|
29
|
+
AsyncFunction("generateKeyPairWithOptions") { (key: String, _: GenerateKeyPairOptions) -> [String: String] in
|
|
30
|
+
let publicKey = try self.keyManager.generateKeyPair(tag: key)
|
|
31
|
+
return ["publicKey": publicKey]
|
|
32
|
+
}
|
|
33
|
+
|
|
22
34
|
AsyncFunction("getPublicKey") { (key: String) -> [String: String]? in
|
|
23
35
|
guard let publicKey = try self.keyManager.getPublicKey(tag: key) else {
|
|
24
36
|
return nil
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/legacy-react-native-extension",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.17.0",
|
|
4
4
|
"main": "./index.cjs",
|
|
5
5
|
"module": "./index.js",
|
|
6
6
|
"types": "./src/index.d.ts",
|
|
@@ -18,11 +18,11 @@
|
|
|
18
18
|
"@turnkey/react-native-passkey-stamper": "1.2.7",
|
|
19
19
|
"@react-native-documents/picker": "^11.0.0",
|
|
20
20
|
"react-native-fs": ">=2.20.0",
|
|
21
|
-
"@dynamic-labs/assert-package-version": "5.
|
|
22
|
-
"@dynamic-labs/legacy-client": "5.
|
|
23
|
-
"@dynamic-labs/logger": "5.
|
|
24
|
-
"@dynamic-labs/message-transport": "5.
|
|
25
|
-
"@dynamic-labs/webview-messages": "5.
|
|
21
|
+
"@dynamic-labs/assert-package-version": "5.17.0",
|
|
22
|
+
"@dynamic-labs/legacy-client": "5.17.0",
|
|
23
|
+
"@dynamic-labs/logger": "5.17.0",
|
|
24
|
+
"@dynamic-labs/message-transport": "5.17.0",
|
|
25
|
+
"@dynamic-labs/webview-messages": "5.17.0"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"react": ">=18.0.0 <20.0.0",
|
|
@@ -64,10 +64,31 @@ export type ReactNativeExtensionProps = {
|
|
|
64
64
|
* behavior for consumers who don't set this.
|
|
65
65
|
*/
|
|
66
66
|
allowWebViewPopups?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Android-only options. Ignored on iOS and on the web.
|
|
69
|
+
*/
|
|
70
|
+
android?: {
|
|
71
|
+
/**
|
|
72
|
+
* Whether the keys the SDK creates on the device are backed by the
|
|
73
|
+
* dedicated StrongBox secure element instead of the device's trusted
|
|
74
|
+
* execution environment (TEE). Devices without a StrongBox chip fall back
|
|
75
|
+
* to a TEE-backed key.
|
|
76
|
+
*
|
|
77
|
+
* StrongBox signing is roughly 10-20x slower than TEE signing, so enable
|
|
78
|
+
* it only when you want the extra layer of hardware isolation.
|
|
79
|
+
*
|
|
80
|
+
* Only takes effect with native builds released together with this
|
|
81
|
+
* option. Older native builds always request StrongBox when the device
|
|
82
|
+
* supports it, so `false` cannot be honored there.
|
|
83
|
+
*
|
|
84
|
+
* @defaultValue `false`
|
|
85
|
+
*/
|
|
86
|
+
strongBox?: boolean;
|
|
87
|
+
};
|
|
67
88
|
};
|
|
68
89
|
export type IReactNativeExtension = {
|
|
69
90
|
reactNative: {
|
|
70
91
|
WebView: FC<WebViewProps> | (() => null);
|
|
71
92
|
};
|
|
72
93
|
};
|
|
73
|
-
export declare const ReactNativeExtension: ({ webviewUrl, webviewDebuggingEnabled, appOrigin, embeddedWebView, webviewLoad, allowWebViewPopups, }?: ReactNativeExtensionProps) => Extension<IReactNativeExtension>;
|
|
94
|
+
export declare const ReactNativeExtension: ({ webviewUrl, webviewDebuggingEnabled, appOrigin, embeddedWebView, webviewLoad, allowWebViewPopups, android, }?: ReactNativeExtensionProps) => Extension<IReactNativeExtension>;
|
|
@@ -1,2 +1,9 @@
|
|
|
1
1
|
import { Core } from '@dynamic-labs/legacy-client';
|
|
2
|
-
export
|
|
2
|
+
export type SetupKeychainHandlerOptions = {
|
|
3
|
+
/**
|
|
4
|
+
* Android only: request StrongBox-backed keys instead of TEE-backed ones.
|
|
5
|
+
* `undefined` means the integrator did not configure it.
|
|
6
|
+
*/
|
|
7
|
+
androidStrongBox?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare const setupKeychainHandler: (core: Core, { androidStrongBox }?: SetupKeychainHandlerOptions) => void;
|
|
@@ -1,9 +1,19 @@
|
|
|
1
|
-
type
|
|
1
|
+
export type GenerateKeyPairOptions = {
|
|
2
|
+
strongBox: boolean;
|
|
3
|
+
};
|
|
4
|
+
export type KeychainNativeModule = {
|
|
2
5
|
isAvailable: () => Promise<boolean>;
|
|
3
6
|
hasKey: (key: string) => Promise<boolean>;
|
|
4
7
|
generateKeyPair: (key: string) => Promise<{
|
|
5
8
|
publicKey: string;
|
|
6
9
|
}>;
|
|
10
|
+
/**
|
|
11
|
+
* Optional: an over-the-air JS update can run on a native binary that
|
|
12
|
+
* predates this method, so callers must fall back to `generateKeyPair`.
|
|
13
|
+
*/
|
|
14
|
+
generateKeyPairWithOptions?: (key: string, options: GenerateKeyPairOptions) => Promise<{
|
|
15
|
+
publicKey: string;
|
|
16
|
+
}>;
|
|
7
17
|
getPublicKey: (key: string) => Promise<{
|
|
8
18
|
publicKey: string;
|
|
9
19
|
} | null>;
|
|
@@ -26,4 +36,3 @@ type KeychainNativeModule = {
|
|
|
26
36
|
*/
|
|
27
37
|
export declare const isKeychainAvailable: () => boolean;
|
|
28
38
|
export declare const getKeychain: () => KeychainNativeModule;
|
|
29
|
-
export {};
|
|
@@ -11,7 +11,13 @@ import { type TurboModule, TurboModuleRegistry } from 'react-native';
|
|
|
11
11
|
|
|
12
12
|
export interface Spec extends TurboModule {
|
|
13
13
|
deleteKey(key: string): Promise<void>;
|
|
14
|
+
// TODO(next-major): remove generateKeyPair; generateKeyPairWithOptions
|
|
15
|
+
// replaces it once binaries without the new method are no longer supported.
|
|
14
16
|
generateKeyPair(key: string): Promise<{ publicKey: string }>;
|
|
17
|
+
generateKeyPairWithOptions(
|
|
18
|
+
key: string,
|
|
19
|
+
options: { strongBox: boolean }
|
|
20
|
+
): Promise<{ publicKey: string }>;
|
|
15
21
|
getPublicKey(key: string): Promise<{ publicKey: string } | null>;
|
|
16
22
|
hasKey(key: string): Promise<boolean>;
|
|
17
23
|
isAvailable(): Promise<boolean>;
|