@account-kit/react-native-signer 4.1.8-alpha
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/.github/actions/setup/action.yml +27 -0
- package/.github/workflows/ci.yml +157 -0
- package/.npmrc +1 -0
- package/.turbo/turbo-prepare.log +21 -0
- package/.watchmanconfig +1 -0
- package/README.md +37 -0
- package/account-kit-react-native-signer.podspec +41 -0
- package/android/build.gradle +132 -0
- package/android/generated/java/com/accountkit/reactnativesigner/NativeTEKStamperSpec.java +55 -0
- package/android/generated/jni/CMakeLists.txt +36 -0
- package/android/generated/jni/NativeTEKStamperSpec-generated.cpp +56 -0
- package/android/generated/jni/NativeTEKStamperSpec.h +31 -0
- package/android/generated/jni/react/renderer/components/NativeTEKStamperSpec/ComponentDescriptors.cpp +22 -0
- package/android/generated/jni/react/renderer/components/NativeTEKStamperSpec/ComponentDescriptors.h +24 -0
- package/android/generated/jni/react/renderer/components/NativeTEKStamperSpec/EventEmitters.cpp +16 -0
- package/android/generated/jni/react/renderer/components/NativeTEKStamperSpec/EventEmitters.h +17 -0
- package/android/generated/jni/react/renderer/components/NativeTEKStamperSpec/NativeTEKStamperSpecJSI-generated.cpp +54 -0
- package/android/generated/jni/react/renderer/components/NativeTEKStamperSpec/NativeTEKStamperSpecJSI.h +150 -0
- package/android/generated/jni/react/renderer/components/NativeTEKStamperSpec/Props.cpp +19 -0
- package/android/generated/jni/react/renderer/components/NativeTEKStamperSpec/Props.h +18 -0
- package/android/generated/jni/react/renderer/components/NativeTEKStamperSpec/ShadowNodes.cpp +17 -0
- package/android/generated/jni/react/renderer/components/NativeTEKStamperSpec/ShadowNodes.h +23 -0
- package/android/generated/jni/react/renderer/components/NativeTEKStamperSpec/States.cpp +16 -0
- package/android/generated/jni/react/renderer/components/NativeTEKStamperSpec/States.h +19 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/java/com/accountkit/reactnativesigner/KeyExtensions.kt +77 -0
- package/android/src/main/java/com/accountkit/reactnativesigner/NativeTEKStamperModule.kt +234 -0
- package/android/src/main/java/com/accountkit/reactnativesigner/ReactNativeSignerPackage.kt +33 -0
- package/android/src/main/java/com/accountkit/reactnativesigner/TEKManager.kt +88 -0
- package/babel.config.js +5 -0
- package/example/.bundle/config +2 -0
- package/example/.watchmanconfig +1 -0
- package/example/Gemfile +9 -0
- package/example/README.md +79 -0
- package/example/android/app/build.gradle +133 -0
- package/example/android/app/debug.keystore +0 -0
- package/example/android/app/proguard-rules.pro +10 -0
- package/example/android/app/src/debug/AndroidManifest.xml +9 -0
- package/example/android/app/src/main/AndroidManifest.xml +17 -0
- package/example/android/app/src/main/java/accountkit/reactnativesigner/example/MainActivity.kt +27 -0
- package/example/android/app/src/main/java/accountkit/reactnativesigner/example/MainApplication.kt +48 -0
- package/example/android/app/src/main/res/drawable/rn_edit_text_material.xml +37 -0
- package/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
- package/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
- package/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
- package/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
- package/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
- package/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
- package/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
- package/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
- package/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
- package/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
- package/example/android/app/src/main/res/values/strings.xml +3 -0
- package/example/android/app/src/main/res/values/styles.xml +9 -0
- package/example/android/build.gradle +21 -0
- package/example/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/example/android/gradle/wrapper/gradle-wrapper.properties +7 -0
- package/example/android/gradle.properties +41 -0
- package/example/android/gradlew +252 -0
- package/example/android/gradlew.bat +94 -0
- package/example/android/settings.gradle +6 -0
- package/example/app.json +4 -0
- package/example/babel.config.js +12 -0
- package/example/index.js +6 -0
- package/example/ios/.xcode.env +11 -0
- package/example/ios/File.swift +6 -0
- package/example/ios/Podfile +47 -0
- package/example/ios/ReactNativeSignerExample/AppDelegate.h +6 -0
- package/example/ios/ReactNativeSignerExample/AppDelegate.mm +31 -0
- package/example/ios/ReactNativeSignerExample/Images.xcassets/AppIcon.appiconset/Contents.json +53 -0
- package/example/ios/ReactNativeSignerExample/Images.xcassets/Contents.json +6 -0
- package/example/ios/ReactNativeSignerExample/Info.plist +52 -0
- package/example/ios/ReactNativeSignerExample/LaunchScreen.storyboard +47 -0
- package/example/ios/ReactNativeSignerExample/PrivacyInfo.xcprivacy +37 -0
- package/example/ios/ReactNativeSignerExample/main.m +10 -0
- package/example/ios/ReactNativeSignerExample-Bridging-Header.h +3 -0
- package/example/ios/ReactNativeSignerExample.xcodeproj/project.pbxproj +690 -0
- package/example/ios/ReactNativeSignerExample.xcodeproj/xcshareddata/xcschemes/ReactNativeSignerExample.xcscheme +98 -0
- package/example/ios/ReactNativeSignerExampleTests/Info.plist +24 -0
- package/example/ios/ReactNativeSignerExampleTests/ReactNativeSignerExampleTests.m +66 -0
- package/example/jest.config.js +3 -0
- package/example/metro.config.js +22 -0
- package/example/package.json +56 -0
- package/example/react-native.config.js +15 -0
- package/example/redirect-server/index.ts +19 -0
- package/example/src/App.tsx +30 -0
- package/example/src/screens/Home.tsx +149 -0
- package/example/turbo.json +38 -0
- package/ios/ReactNativeSigner.h +12 -0
- package/ios/ReactNativeSigner.mm +21 -0
- package/ios/generated/NativeTEKStamperSpec/ComponentDescriptors.cpp +22 -0
- package/ios/generated/NativeTEKStamperSpec/ComponentDescriptors.h +24 -0
- package/ios/generated/NativeTEKStamperSpec/EventEmitters.cpp +16 -0
- package/ios/generated/NativeTEKStamperSpec/EventEmitters.h +17 -0
- package/ios/generated/NativeTEKStamperSpec/NativeTEKStamperSpec-generated.mm +67 -0
- package/ios/generated/NativeTEKStamperSpec/NativeTEKStamperSpec.h +68 -0
- package/ios/generated/NativeTEKStamperSpec/Props.cpp +19 -0
- package/ios/generated/NativeTEKStamperSpec/Props.h +18 -0
- package/ios/generated/NativeTEKStamperSpec/RCTComponentViewHelpers.h +18 -0
- package/ios/generated/NativeTEKStamperSpec/ShadowNodes.cpp +17 -0
- package/ios/generated/NativeTEKStamperSpec/ShadowNodes.h +23 -0
- package/ios/generated/NativeTEKStamperSpec/States.cpp +16 -0
- package/ios/generated/NativeTEKStamperSpec/States.h +19 -0
- package/ios/generated/NativeTEKStamperSpecJSI-generated.cpp +54 -0
- package/ios/generated/NativeTEKStamperSpecJSI.h +150 -0
- package/lib/commonjs/NativeTEKStamper.js +9 -0
- package/lib/commonjs/NativeTEKStamper.js.map +1 -0
- package/lib/commonjs/client.js +103 -0
- package/lib/commonjs/client.js.map +1 -0
- package/lib/commonjs/index.js +13 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/signer.js +39 -0
- package/lib/commonjs/signer.js.map +1 -0
- package/lib/commonjs/utils/mmkv-localstorage-polyfill.js +38 -0
- package/lib/commonjs/utils/mmkv-localstorage-polyfill.js.map +1 -0
- package/lib/module/NativeTEKStamper.js +5 -0
- package/lib/module/NativeTEKStamper.js.map +1 -0
- package/lib/module/client.js +96 -0
- package/lib/module/client.js.map +1 -0
- package/lib/module/index.js +5 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/signer.js +33 -0
- package/lib/module/signer.js.map +1 -0
- package/lib/module/utils/mmkv-localstorage-polyfill.js +38 -0
- package/lib/module/utils/mmkv-localstorage-polyfill.js.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/src/NativeTEKStamper.d.ts +34 -0
- package/lib/typescript/commonjs/src/NativeTEKStamper.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/client.d.ts +107 -0
- package/lib/typescript/commonjs/src/client.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +2 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/signer.d.ts +185 -0
- package/lib/typescript/commonjs/src/signer.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/utils/mmkv-localstorage-polyfill.d.ts +2 -0
- package/lib/typescript/commonjs/src/utils/mmkv-localstorage-polyfill.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/src/NativeTEKStamper.d.ts +34 -0
- package/lib/typescript/module/src/NativeTEKStamper.d.ts.map +1 -0
- package/lib/typescript/module/src/client.d.ts +107 -0
- package/lib/typescript/module/src/client.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +2 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -0
- package/lib/typescript/module/src/signer.d.ts +185 -0
- package/lib/typescript/module/src/signer.d.ts.map +1 -0
- package/lib/typescript/module/src/utils/mmkv-localstorage-polyfill.d.ts +2 -0
- package/lib/typescript/module/src/utils/mmkv-localstorage-polyfill.d.ts.map +1 -0
- package/package.json +153 -0
- package/react-native.config.js +11 -0
- package/src/NativeTEKStamper.ts +42 -0
- package/src/client.ts +128 -0
- package/src/index.tsx +2 -0
- package/src/signer.ts +39 -0
- package/src/utils/mmkv-localstorage-polyfill.ts +41 -0
- package/tsconfig.build.json +4 -0
- package/tsconfig.json +30 -0
- package/turbo.json +9 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
package com.accountkit.reactnativesigner
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.TurboReactPackage
|
|
4
|
+
import com.facebook.react.bridge.NativeModule
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
+
import com.facebook.react.module.model.ReactModuleInfo
|
|
7
|
+
import com.facebook.react.module.model.ReactModuleInfoProvider
|
|
8
|
+
import java.util.HashMap
|
|
9
|
+
|
|
10
|
+
class ReactNativeSignerPackage : TurboReactPackage() {
|
|
11
|
+
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
|
|
12
|
+
return if (name == NativeTEKStamperModule.NAME) {
|
|
13
|
+
NativeTEKStamperModule(reactContext)
|
|
14
|
+
} else {
|
|
15
|
+
null
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
|
|
20
|
+
return ReactModuleInfoProvider {
|
|
21
|
+
val moduleInfos: MutableMap<String, ReactModuleInfo> = HashMap()
|
|
22
|
+
moduleInfos[NativeTEKStamperModule.NAME] = ReactModuleInfo(
|
|
23
|
+
NativeTEKStamperModule.NAME,
|
|
24
|
+
NativeTEKStamperModule.NAME,
|
|
25
|
+
false, // canOverrideExistingModule
|
|
26
|
+
false, // needsEagerInit
|
|
27
|
+
false, // isCxxModule
|
|
28
|
+
true // isTurboModule
|
|
29
|
+
)
|
|
30
|
+
moduleInfos
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
package com.accountkit.reactnativesigner
|
|
2
|
+
|
|
3
|
+
import android.content.SharedPreferences
|
|
4
|
+
import com.google.crypto.tink.InsecureSecretKeyAccess
|
|
5
|
+
import com.google.crypto.tink.KeyTemplate
|
|
6
|
+
import com.google.crypto.tink.KeysetHandle
|
|
7
|
+
import com.google.crypto.tink.TinkJsonProtoKeysetFormat
|
|
8
|
+
import com.google.crypto.tink.hybrid.HpkeParameters
|
|
9
|
+
import com.google.crypto.tink.hybrid.HpkePublicKey
|
|
10
|
+
import com.google.crypto.tink.hybrid.internal.HpkeContext
|
|
11
|
+
import com.google.crypto.tink.hybrid.internal.HpkeKemKeyFactory
|
|
12
|
+
import com.google.crypto.tink.hybrid.internal.HpkePrimitiveFactory
|
|
13
|
+
|
|
14
|
+
private const val TEK_STORAGE_KEY = "TEK_STORAGE_KEY"
|
|
15
|
+
private val hpkeParams = HpkeParameters.builder()
|
|
16
|
+
.setKemId(HpkeParameters.KemId.DHKEM_P256_HKDF_SHA256)
|
|
17
|
+
.setKdfId(HpkeParameters.KdfId.HKDF_SHA256)
|
|
18
|
+
.setAeadId(HpkeParameters.AeadId.AES_256_GCM)
|
|
19
|
+
.setVariant(HpkeParameters.Variant.NO_PREFIX)
|
|
20
|
+
.build()
|
|
21
|
+
|
|
22
|
+
class HpkeTEKManager(private val sharedPreferences: SharedPreferences) {
|
|
23
|
+
fun hpkeDecrypt(
|
|
24
|
+
encapsulatePublicKey: ByteArray,
|
|
25
|
+
cipherText: ByteArray,
|
|
26
|
+
info: ByteArray,
|
|
27
|
+
aad: ByteArray
|
|
28
|
+
): ByteArray {
|
|
29
|
+
// Why do we hve to do all this rather than doing:
|
|
30
|
+
// val hybridDecrypt = tekHandle.getPrimitive(HybridDecrypt::class.java)
|
|
31
|
+
// val decryptedKey = hybridDecrypt.decrypt(ciphertext, "turnkey_hpke".toByteArray())
|
|
32
|
+
// the hybridDecrypt.decrypt that google exposes doesn't allow us to pass in
|
|
33
|
+
// the aad that's needed to complete decryption
|
|
34
|
+
val keyHandle = getKeysetHandle() ?: throw IllegalStateException("No TEK found!")
|
|
35
|
+
|
|
36
|
+
val recipient = HpkeContext.createRecipientContext(
|
|
37
|
+
encapsulatePublicKey,
|
|
38
|
+
HpkeKemKeyFactory.createPrivate(keyHandle.toHpkePrivateKey(hpkeParams)),
|
|
39
|
+
HpkePrimitiveFactory.createKem(hpkeParams.kemId),
|
|
40
|
+
HpkePrimitiveFactory.createKdf(hpkeParams.kdfId),
|
|
41
|
+
HpkePrimitiveFactory.createAead(hpkeParams.aeadId),
|
|
42
|
+
info
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
return recipient.open(cipherText, aad)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
fun createTEK(): HpkePublicKey {
|
|
49
|
+
val existingPublicKey = publicKey()
|
|
50
|
+
if (existingPublicKey != null) {
|
|
51
|
+
return existingPublicKey
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
val keysetHandle = KeysetHandle.generateNew(KeyTemplate.createFrom(hpkeParams))
|
|
55
|
+
|
|
56
|
+
sharedPreferences
|
|
57
|
+
.edit()
|
|
58
|
+
.putString(
|
|
59
|
+
TEK_STORAGE_KEY,
|
|
60
|
+
TinkJsonProtoKeysetFormat.serializeKeyset(
|
|
61
|
+
keysetHandle,
|
|
62
|
+
InsecureSecretKeyAccess.get()
|
|
63
|
+
)
|
|
64
|
+
)
|
|
65
|
+
.apply()
|
|
66
|
+
|
|
67
|
+
return keysetHandle.toHpkePublicKey(hpkeParams)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
fun publicKey(): HpkePublicKey? {
|
|
71
|
+
val ksHandle = getKeysetHandle() ?: return null
|
|
72
|
+
|
|
73
|
+
return ksHandle.toHpkePublicKey(hpkeParams)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
fun publicKeyHex(): String? {
|
|
77
|
+
return publicKey()?.toHex()
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
private fun getKeysetHandle(): KeysetHandle? {
|
|
81
|
+
val storageVal = sharedPreferences.getString(TEK_STORAGE_KEY, null) ?: return null
|
|
82
|
+
|
|
83
|
+
return TinkJsonProtoKeysetFormat.parseKeyset(
|
|
84
|
+
storageVal,
|
|
85
|
+
InsecureSecretKeyAccess.get()
|
|
86
|
+
)
|
|
87
|
+
}
|
|
88
|
+
}
|
package/babel.config.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
package/example/Gemfile
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
source 'https://rubygems.org'
|
|
2
|
+
|
|
3
|
+
# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
|
|
4
|
+
ruby ">= 2.6.10"
|
|
5
|
+
|
|
6
|
+
# Exclude problematic versions of cocoapods and activesupport that causes build failures.
|
|
7
|
+
gem 'cocoapods', '>= 1.13', '!= 1.15.0', '!= 1.15.1'
|
|
8
|
+
gem 'activesupport', '>= 6.1.7.5', '!= 7.1.0'
|
|
9
|
+
gem 'xcodeproj', '< 1.26.0'
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
This is a new [**React Native**](https://reactnative.dev) project, bootstrapped using [`@react-native-community/cli`](https://github.com/react-native-community/cli).
|
|
2
|
+
|
|
3
|
+
# Getting Started
|
|
4
|
+
|
|
5
|
+
> **Note**: Make sure you have completed the [React Native - Environment Setup](https://reactnative.dev/docs/environment-setup) instructions till "Creating a new application" step, before proceeding.
|
|
6
|
+
|
|
7
|
+
## Step 1: Start the Metro Server
|
|
8
|
+
|
|
9
|
+
First, you will need to start **Metro**, the JavaScript _bundler_ that ships _with_ React Native.
|
|
10
|
+
|
|
11
|
+
To start Metro, run the following command from the _root_ of your React Native project:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
# using npm
|
|
15
|
+
npm start
|
|
16
|
+
|
|
17
|
+
# OR using Yarn
|
|
18
|
+
yarn start
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Step 2: Start your Application
|
|
22
|
+
|
|
23
|
+
Let Metro Bundler run in its _own_ terminal. Open a _new_ terminal from the _root_ of your React Native project. Run the following command to start your _Android_ or _iOS_ app:
|
|
24
|
+
|
|
25
|
+
### For Android
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
# using npm
|
|
29
|
+
npm run android
|
|
30
|
+
|
|
31
|
+
# OR using Yarn
|
|
32
|
+
yarn android
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### For iOS
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
# using npm
|
|
39
|
+
npm run ios
|
|
40
|
+
|
|
41
|
+
# OR using Yarn
|
|
42
|
+
yarn ios
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
If everything is set up _correctly_, you should see your new app running in your _Android Emulator_ or _iOS Simulator_ shortly provided you have set up your emulator/simulator correctly.
|
|
46
|
+
|
|
47
|
+
This is one way to run your app — you can also run it directly from within Android Studio and Xcode respectively.
|
|
48
|
+
|
|
49
|
+
## Step 3: Modifying your App
|
|
50
|
+
|
|
51
|
+
Now that you have successfully run the app, let's modify it.
|
|
52
|
+
|
|
53
|
+
1. Open `App.tsx` in your text editor of choice and edit some lines.
|
|
54
|
+
2. For **Android**: Press the <kbd>R</kbd> key twice or select **"Reload"** from the **Developer Menu** (<kbd>Ctrl</kbd> + <kbd>M</kbd> (on Window and Linux) or <kbd>Cmd ⌘</kbd> + <kbd>M</kbd> (on macOS)) to see your changes!
|
|
55
|
+
|
|
56
|
+
For **iOS**: Hit <kbd>Cmd ⌘</kbd> + <kbd>R</kbd> in your iOS Simulator to reload the app and see your changes!
|
|
57
|
+
|
|
58
|
+
## Congratulations! :tada:
|
|
59
|
+
|
|
60
|
+
You've successfully run and modified your React Native App. :partying_face:
|
|
61
|
+
|
|
62
|
+
### Now what?
|
|
63
|
+
|
|
64
|
+
- If you want to add this new React Native code to an existing application, check out the [Integration guide](https://reactnative.dev/docs/integration-with-existing-apps).
|
|
65
|
+
- If you're curious to learn more about React Native, check out the [Introduction to React Native](https://reactnative.dev/docs/getting-started).
|
|
66
|
+
|
|
67
|
+
# Troubleshooting
|
|
68
|
+
|
|
69
|
+
If you can't get this to work, see the [Troubleshooting](https://reactnative.dev/docs/troubleshooting) page.
|
|
70
|
+
|
|
71
|
+
# Learn More
|
|
72
|
+
|
|
73
|
+
To learn more about React Native, take a look at the following resources:
|
|
74
|
+
|
|
75
|
+
- [React Native Website](https://reactnative.dev) - learn more about React Native.
|
|
76
|
+
- [Getting Started](https://reactnative.dev/docs/environment-setup) - an **overview** of React Native and how setup your environment.
|
|
77
|
+
- [Learn the Basics](https://reactnative.dev/docs/getting-started) - a **guided tour** of the React Native **basics**.
|
|
78
|
+
- [Blog](https://reactnative.dev/blog) - read the latest official React Native **Blog** posts.
|
|
79
|
+
- [`@facebook/react-native`](https://github.com/facebook/react-native) - the Open Source; GitHub **repository** for React Native.
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
apply plugin: "com.android.application"
|
|
2
|
+
apply plugin: "org.jetbrains.kotlin.android"
|
|
3
|
+
apply plugin: "com.facebook.react"
|
|
4
|
+
apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* This is the configuration block to customize your React Native Android app.
|
|
8
|
+
* By default you don't need to apply any configuration, just uncomment the lines you need.
|
|
9
|
+
*/
|
|
10
|
+
react {
|
|
11
|
+
/* Folders */
|
|
12
|
+
// The root of your project, i.e. where "package.json" lives. Default is '../..'
|
|
13
|
+
// root = file("../../")
|
|
14
|
+
// The folder where the react-native NPM package is. Default is ../../node_modules/react-native
|
|
15
|
+
// reactNativeDir = file("../../node_modules/react-native")
|
|
16
|
+
// The folder where the react-native Codegen package is. Default is ../../node_modules/@react-native/codegen
|
|
17
|
+
// codegenDir = file("../../node_modules/@react-native/codegen")
|
|
18
|
+
// The cli.js file which is the React Native CLI entrypoint. Default is ../../node_modules/react-native/cli.js
|
|
19
|
+
// cliFile = file("../../node_modules/react-native/cli.js")
|
|
20
|
+
|
|
21
|
+
/* Variants */
|
|
22
|
+
// The list of variants to that are debuggable. For those we're going to
|
|
23
|
+
// skip the bundling of the JS bundle and the assets. By default is just 'debug'.
|
|
24
|
+
// If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants.
|
|
25
|
+
// debuggableVariants = ["liteDebug", "prodDebug"]
|
|
26
|
+
|
|
27
|
+
/* Bundling */
|
|
28
|
+
// A list containing the node command and its flags. Default is just 'node'.
|
|
29
|
+
// nodeExecutableAndArgs = ["node"]
|
|
30
|
+
//
|
|
31
|
+
// The command to run when bundling. By default is 'bundle'
|
|
32
|
+
// bundleCommand = "ram-bundle"
|
|
33
|
+
//
|
|
34
|
+
// The path to the CLI configuration file. Default is empty.
|
|
35
|
+
// bundleConfig = file(../rn-cli.config.js)
|
|
36
|
+
//
|
|
37
|
+
// The name of the generated asset file containing your JS bundle
|
|
38
|
+
// bundleAssetName = "MyApplication.android.bundle"
|
|
39
|
+
//
|
|
40
|
+
// The entry file for bundle generation. Default is 'index.android.js' or 'index.js'
|
|
41
|
+
// entryFile = file("../js/MyApplication.android.js")
|
|
42
|
+
//
|
|
43
|
+
// A list of extra flags to pass to the 'bundle' commands.
|
|
44
|
+
// See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle
|
|
45
|
+
// extraPackagerArgs = []
|
|
46
|
+
|
|
47
|
+
/* Hermes Commands */
|
|
48
|
+
// The hermes compiler command to run. By default it is 'hermesc'
|
|
49
|
+
// hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc"
|
|
50
|
+
//
|
|
51
|
+
// The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
|
|
52
|
+
// hermesFlags = ["-O", "-output-source-map"]
|
|
53
|
+
|
|
54
|
+
/* Autolinking */
|
|
55
|
+
autolinkLibrariesWithApp()
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Set this to true to Run Proguard on Release builds to minify the Java bytecode.
|
|
60
|
+
*/
|
|
61
|
+
def enableProguardInReleaseBuilds = false
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* The preferred build flavor of JavaScriptCore (JSC)
|
|
65
|
+
*
|
|
66
|
+
* For example, to use the international variant, you can use:
|
|
67
|
+
* `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
|
|
68
|
+
*
|
|
69
|
+
* The international variant includes ICU i18n library and necessary data
|
|
70
|
+
* allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
|
|
71
|
+
* give correct results when using with locales other than en-US. Note that
|
|
72
|
+
* this variant is about 6MiB larger per architecture than default.
|
|
73
|
+
*/
|
|
74
|
+
def jscFlavor = 'org.webkit:android-jsc:+'
|
|
75
|
+
|
|
76
|
+
android {
|
|
77
|
+
ndkVersion rootProject.ext.ndkVersion
|
|
78
|
+
buildToolsVersion rootProject.ext.buildToolsVersion
|
|
79
|
+
compileSdk rootProject.ext.compileSdkVersion
|
|
80
|
+
|
|
81
|
+
namespace "accountkit.reactnativesigner.example"
|
|
82
|
+
defaultConfig {
|
|
83
|
+
applicationId "accountkit.reactnativesigner.example"
|
|
84
|
+
minSdkVersion rootProject.ext.minSdkVersion
|
|
85
|
+
targetSdkVersion rootProject.ext.targetSdkVersion
|
|
86
|
+
versionCode 1
|
|
87
|
+
versionName "1.0"
|
|
88
|
+
}
|
|
89
|
+
signingConfigs {
|
|
90
|
+
debug {
|
|
91
|
+
storeFile file('debug.keystore')
|
|
92
|
+
storePassword 'android'
|
|
93
|
+
keyAlias 'androiddebugkey'
|
|
94
|
+
keyPassword 'android'
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
buildTypes {
|
|
98
|
+
debug {
|
|
99
|
+
signingConfig signingConfigs.debug
|
|
100
|
+
}
|
|
101
|
+
release {
|
|
102
|
+
// Caution! In production, you need to generate your own keystore file.
|
|
103
|
+
// see https://reactnative.dev/docs/signed-apk-android.
|
|
104
|
+
signingConfig signingConfigs.debug
|
|
105
|
+
minifyEnabled enableProguardInReleaseBuilds
|
|
106
|
+
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
dependencies {
|
|
112
|
+
// The version of react-native is set by the React Native Gradle Plugin
|
|
113
|
+
implementation("com.facebook.react:react-android")
|
|
114
|
+
|
|
115
|
+
if (hermesEnabled.toBoolean()) {
|
|
116
|
+
implementation("com.facebook.react:hermes-android")
|
|
117
|
+
} else {
|
|
118
|
+
implementation jscFlavor
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
def isNewArchitectureEnabled() {
|
|
123
|
+
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (isNewArchitectureEnabled()) {
|
|
127
|
+
// Since our library doesn't invoke codegen automatically we need to do it here.
|
|
128
|
+
tasks.register('invokeLibraryCodegen', Exec) {
|
|
129
|
+
workingDir "$rootDir/../../"
|
|
130
|
+
commandLine "npx", "bob", "build", "--target", "codegen"
|
|
131
|
+
}
|
|
132
|
+
preBuild.dependsOn invokeLibraryCodegen
|
|
133
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Add project specific ProGuard rules here.
|
|
2
|
+
# By default, the flags in this file are appended to flags specified
|
|
3
|
+
# in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt
|
|
4
|
+
# You can edit the include path and order by changing the proguardFiles
|
|
5
|
+
# directive in build.gradle.
|
|
6
|
+
#
|
|
7
|
+
# For more details, see
|
|
8
|
+
# http://developer.android.com/guide/developing/tools/proguard.html
|
|
9
|
+
|
|
10
|
+
# Add any project specific keep options here:
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
3
|
+
xmlns:tools="http://schemas.android.com/tools">
|
|
4
|
+
|
|
5
|
+
<application
|
|
6
|
+
android:usesCleartextTraffic="true"
|
|
7
|
+
tools:targetApi="28"
|
|
8
|
+
tools:ignore="GoogleAppIndexingWarning"/>
|
|
9
|
+
</manifest>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
|
2
|
+
<uses-permission android:name="android.permission.INTERNET"/>
|
|
3
|
+
<application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="false" android:theme="@style/AppTheme" android:supportsRtl="true">
|
|
4
|
+
<activity android:name=".MainActivity" android:label="@string/app_name" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode" android:launchMode="singleTask" android:windowSoftInputMode="adjustResize" android:exported="true">
|
|
5
|
+
<intent-filter>
|
|
6
|
+
<action android:name="android.intent.action.MAIN"/>
|
|
7
|
+
<category android:name="android.intent.category.LAUNCHER"/>
|
|
8
|
+
</intent-filter>
|
|
9
|
+
<intent-filter>
|
|
10
|
+
<action android:name="android.intent.action.VIEW"/>
|
|
11
|
+
<category android:name="android.intent.category.DEFAULT"/>
|
|
12
|
+
<category android:name="android.intent.category.BROWSABLE"/>
|
|
13
|
+
<data android:scheme="rn-signer-demo"/>
|
|
14
|
+
</intent-filter>
|
|
15
|
+
</activity>
|
|
16
|
+
</application>
|
|
17
|
+
</manifest>
|
package/example/android/app/src/main/java/accountkit/reactnativesigner/example/MainActivity.kt
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
package accountkit.reactnativesigner.example
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.ReactActivity
|
|
4
|
+
import com.facebook.react.ReactActivityDelegate
|
|
5
|
+
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled
|
|
6
|
+
import com.facebook.react.defaults.DefaultReactActivityDelegate
|
|
7
|
+
import android.os.Bundle
|
|
8
|
+
|
|
9
|
+
class MainActivity : ReactActivity() {
|
|
10
|
+
|
|
11
|
+
// Necessary for react-native-screens
|
|
12
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
|
13
|
+
super.onCreate(null)
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Returns the name of the main component registered from JavaScript. This is used to schedule
|
|
17
|
+
* rendering of the component.
|
|
18
|
+
*/
|
|
19
|
+
override fun getMainComponentName(): String = "ReactNativeSignerExample"
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Returns the instance of the [ReactActivityDelegate]. We use [DefaultReactActivityDelegate]
|
|
23
|
+
* which allows you to enable New Architecture with a single boolean flags [fabricEnabled]
|
|
24
|
+
*/
|
|
25
|
+
override fun createReactActivityDelegate(): ReactActivityDelegate =
|
|
26
|
+
DefaultReactActivityDelegate(this, mainComponentName, fabricEnabled)
|
|
27
|
+
}
|
package/example/android/app/src/main/java/accountkit/reactnativesigner/example/MainApplication.kt
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
package accountkit.reactnativesigner.example
|
|
2
|
+
|
|
3
|
+
import android.app.Application
|
|
4
|
+
import com.accountkit.reactnativesigner.NativeTEKStamperModule
|
|
5
|
+
import com.accountkit.reactnativesigner.NativeTEKStamperSpec
|
|
6
|
+
import com.accountkit.reactnativesigner.ReactNativeSignerPackage
|
|
7
|
+
import com.facebook.react.PackageList
|
|
8
|
+
import com.facebook.react.ReactApplication
|
|
9
|
+
import com.facebook.react.ReactHost
|
|
10
|
+
import com.facebook.react.ReactNativeHost
|
|
11
|
+
import com.facebook.react.ReactPackage
|
|
12
|
+
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.load
|
|
13
|
+
import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost
|
|
14
|
+
import com.facebook.react.defaults.DefaultReactNativeHost
|
|
15
|
+
import com.facebook.react.soloader.OpenSourceMergedSoMapping
|
|
16
|
+
import com.facebook.soloader.SoLoader
|
|
17
|
+
|
|
18
|
+
class MainApplication : Application(), ReactApplication {
|
|
19
|
+
|
|
20
|
+
override val reactNativeHost: ReactNativeHost =
|
|
21
|
+
object : DefaultReactNativeHost(this) {
|
|
22
|
+
override fun getPackages(): List<ReactPackage> =
|
|
23
|
+
PackageList(this).packages.apply {
|
|
24
|
+
// Packages that cannot be autolinked yet can be added manually here, for
|
|
25
|
+
// example:
|
|
26
|
+
add(ReactNativeSignerPackage())
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
override fun getJSMainModuleName(): String = "index"
|
|
30
|
+
|
|
31
|
+
override fun getUseDeveloperSupport(): Boolean = BuildConfig.DEBUG
|
|
32
|
+
|
|
33
|
+
override val isNewArchEnabled: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
|
|
34
|
+
override val isHermesEnabled: Boolean = BuildConfig.IS_HERMES_ENABLED
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
override val reactHost: ReactHost
|
|
38
|
+
get() = getDefaultReactHost(applicationContext, reactNativeHost)
|
|
39
|
+
|
|
40
|
+
override fun onCreate() {
|
|
41
|
+
super.onCreate()
|
|
42
|
+
SoLoader.init(this, OpenSourceMergedSoMapping)
|
|
43
|
+
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
|
|
44
|
+
// If you opted-in for the New Architecture, we load the native entry point for this app.
|
|
45
|
+
load()
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<!-- Copyright (C) 2014 The Android Open Source Project
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
-->
|
|
16
|
+
<inset xmlns:android="http://schemas.android.com/apk/res/android"
|
|
17
|
+
android:insetLeft="@dimen/abc_edit_text_inset_horizontal_material"
|
|
18
|
+
android:insetRight="@dimen/abc_edit_text_inset_horizontal_material"
|
|
19
|
+
android:insetTop="@dimen/abc_edit_text_inset_top_material"
|
|
20
|
+
android:insetBottom="@dimen/abc_edit_text_inset_bottom_material"
|
|
21
|
+
>
|
|
22
|
+
|
|
23
|
+
<selector>
|
|
24
|
+
<!--
|
|
25
|
+
This file is a copy of abc_edit_text_material (https://bit.ly/3k8fX7I).
|
|
26
|
+
The item below with state_pressed="false" and state_focused="false" causes a NullPointerException.
|
|
27
|
+
NullPointerException:tempt to invoke virtual method 'android.graphics.drawable.Drawable android.graphics.drawable.Drawable$ConstantState.newDrawable(android.content.res.Resources)'
|
|
28
|
+
|
|
29
|
+
<item android:state_pressed="false" android:state_focused="false" android:drawable="@drawable/abc_textfield_default_mtrl_alpha"/>
|
|
30
|
+
|
|
31
|
+
For more info, see https://bit.ly/3CdLStv (react-native/pull/29452) and https://bit.ly/3nxOMoR.
|
|
32
|
+
-->
|
|
33
|
+
<item android:state_enabled="false" android:drawable="@drawable/abc_textfield_default_mtrl_alpha"/>
|
|
34
|
+
<item android:drawable="@drawable/abc_textfield_activated_mtrl_alpha"/>
|
|
35
|
+
</selector>
|
|
36
|
+
|
|
37
|
+
</inset>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<resources>
|
|
2
|
+
|
|
3
|
+
<!-- Base application theme. -->
|
|
4
|
+
<style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
|
|
5
|
+
<!-- Customize your theme here. -->
|
|
6
|
+
<item name="android:editTextBackground">@drawable/rn_edit_text_material</item>
|
|
7
|
+
</style>
|
|
8
|
+
|
|
9
|
+
</resources>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
buildscript {
|
|
2
|
+
ext {
|
|
3
|
+
buildToolsVersion = "35.0.0"
|
|
4
|
+
minSdkVersion = 24
|
|
5
|
+
compileSdkVersion = 35
|
|
6
|
+
targetSdkVersion = 34
|
|
7
|
+
ndkVersion = "26.1.10909125"
|
|
8
|
+
kotlinVersion = "1.9.24"
|
|
9
|
+
}
|
|
10
|
+
repositories {
|
|
11
|
+
google()
|
|
12
|
+
mavenCentral()
|
|
13
|
+
}
|
|
14
|
+
dependencies {
|
|
15
|
+
classpath("com.android.tools.build:gradle")
|
|
16
|
+
classpath("com.facebook.react:react-native-gradle-plugin")
|
|
17
|
+
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin")
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
apply plugin: "com.facebook.react.rootproject"
|
|
Binary file
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Project-wide Gradle settings.
|
|
2
|
+
|
|
3
|
+
# IDE (e.g. Android Studio) users:
|
|
4
|
+
# Gradle settings configured through the IDE *will override*
|
|
5
|
+
# any settings specified in this file.
|
|
6
|
+
|
|
7
|
+
# For more details on how to configure your build environment visit
|
|
8
|
+
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
|
9
|
+
|
|
10
|
+
# Specifies the JVM arguments used for the daemon process.
|
|
11
|
+
# The setting is particularly useful for tweaking memory settings.
|
|
12
|
+
# Default value: -Xmx512m -XX:MaxMetaspaceSize=256m
|
|
13
|
+
org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m
|
|
14
|
+
|
|
15
|
+
# When configured, Gradle will run in incubating parallel mode.
|
|
16
|
+
# This option should only be used with decoupled projects. More details, visit
|
|
17
|
+
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
|
18
|
+
# org.gradle.parallel=true
|
|
19
|
+
|
|
20
|
+
# AndroidX package structure to make it clearer which packages are bundled with the
|
|
21
|
+
# Android operating system, and which are packaged with your app's APK
|
|
22
|
+
# https://developer.android.com/topic/libraries/support-library/androidx-rn
|
|
23
|
+
android.useAndroidX=true
|
|
24
|
+
|
|
25
|
+
# Use this property to specify which architecture you want to build.
|
|
26
|
+
# You can also override it from the CLI using
|
|
27
|
+
# ./gradlew <task> -PreactNativeArchitectures=x86_64
|
|
28
|
+
reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64
|
|
29
|
+
|
|
30
|
+
# Use this property to enable support to the new architecture.
|
|
31
|
+
# This will allow you to use TurboModules and the Fabric render in
|
|
32
|
+
# your application. You should enable this flag either if you want
|
|
33
|
+
# to write custom TurboModules/Fabric components OR use libraries that
|
|
34
|
+
# are providing them.
|
|
35
|
+
newArchEnabled=true
|
|
36
|
+
|
|
37
|
+
# Use this property to enable or disable the Hermes JS engine.
|
|
38
|
+
# If set to false, you will be using JSC instead.
|
|
39
|
+
hermesEnabled=true
|
|
40
|
+
|
|
41
|
+
newArchEnabled=true
|