diff --git a/.github/dependabot.yml b/.github/dependabot.yml
deleted file mode 100644
index 3269b62..0000000
--- a/.github/dependabot.yml
+++ /dev/null
@@ -1,11 +0,0 @@
-# To get started with Dependabot version updates, you'll need to specify which
-# package ecosystems to update and where the package manifests are located.
-# Please see the documentation for all configuration options:
-# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
-
-version: 2
-updates:
- - package-ecosystem: 'npm' # See documentation for possible values
- directory: '/' # Location of package manifests
- schedule:
- interval: 'monthly'
diff --git a/.release-it.json b/.release-it.json
index bce7147..ffc889b 100644
--- a/.release-it.json
+++ b/.release-it.json
@@ -37,43 +37,43 @@
"types": [
{
"type": "feat",
- "section": "Features"
+ "section": "๐ Features"
},
{
"type": "fix",
- "section": "Bug Fixes"
+ "section": "๐ Bug Fixes"
},
{
"type": "perf",
- "section": "Performance Improvements"
+ "section": "โก๏ธ Performance Improvements"
},
{
"type": "revert",
- "section": "Reverts"
+ "section": "โช๏ธ Reverts"
},
{
"type": "docs",
- "section": "Documentation"
+ "section": "๐ Documentation"
},
{
"type": "style",
- "section": "Styles"
+ "section": "๐จ Styles"
},
{
"type": "refactor",
- "section": "Code Refactoring"
+ "section": "๐ Code Refactoring"
},
{
"type": "test",
- "section": "Tests"
+ "section": "๐งช Tests"
},
{
"type": "build",
- "section": "Build System"
+ "section": "โ๏ธ Build System"
},
{
"type": "ci",
- "section": "Continuous Integration"
+ "section": "๐ Continuous Integration"
}
]
},
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8715aad..fff3876 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,23 +1,40 @@
-## [1.0.1](https://github.com/evva-sfw/abrevva-react-native/compare/1.0.0...1.0.1) (2024-08-28)
+## [2.0.0](https://github.com/evva-sfw/abrevva-react-native/compare/1.0.1...2.0.0) (2024-10-22)
+
+
+### โ BREAKING CHANGES
+
+* rename package name
+
+### chore
+
+* rename package name ([5cb649d](https://github.com/evva-sfw/abrevva-react-native/commit/5cb649d521859fbfec62ec006cb8b99da4d47a53))
+
+
+### Features
+
+* replaced manual disengage logic with AbrevvaSDK disengage function ([#46](https://github.com/evva-sfw/abrevva-react-native/issues/46)) ([b16cf3b](https://github.com/evva-sfw/abrevva-react-native/commit/b16cf3baa897c098d8cf6b431e7c03aa91054395))
### Bug Fixes
-* corrected output Path for decryptFileFromURL (android) ([#44](https://github.com/evva-sfw/abrevva-react-native/issues/44)) ([308c8f2](https://github.com/evva-sfw/abrevva-react-native/commit/308c8f29c059dae8e0ed55b63d15f8b7775736bf))
+* removed cryptoswift from podfile and formating ([0b6d2c5](https://github.com/evva-sfw/abrevva-react-native/commit/0b6d2c512ec5411b5f2c3cc39eb76844c8849a39))
+* removed nfc ([9384a65](https://github.com/evva-sfw/abrevva-react-native/commit/9384a65b4f6d0532964c2690c73cfdbd2dd985d4))
+* removed nfc traces ([bbb4042](https://github.com/evva-sfw/abrevva-react-native/commit/bbb404217a60bf514bbdb7c21072bd110f23c41d))
+* removed whitespace in string, since toInt throws otherwise ([82e3d6d](https://github.com/evva-sfw/abrevva-react-native/commit/82e3d6d21dd8351610762d382e5ba420e9f34327))
### Documentation
-* format readme and add shields.io ([#41](https://github.com/evva-sfw/abrevva-react-native/issues/41)) ([a4efc62](https://github.com/evva-sfw/abrevva-react-native/commit/a4efc6297e72901b61b61ea410ec09b16df15d10))
+* change deprecation alert to important ([1ee4c06](https://github.com/evva-sfw/abrevva-react-native/commit/1ee4c06ebb01a546e77c1cc027fff147b4b414c6))
-### Build System
+### Continuous Integration
-* add npm-compatibility-check test ([#43](https://github.com/evva-sfw/abrevva-react-native/issues/43)) ([5b18750](https://github.com/evva-sfw/abrevva-react-native/commit/5b187502a987ca58d0ee1d1061a9e92796797be6))
-* add yarn cache to github workflow caching ([#42](https://github.com/evva-sfw/abrevva-react-native/issues/42)) ([b952769](https://github.com/evva-sfw/abrevva-react-native/commit/b9527693868e6a3153c4e036195301a30708cbec))
-* fix workflow cache names ([#40](https://github.com/evva-sfw/abrevva-react-native/issues/40)) ([e72bde1](https://github.com/evva-sfw/abrevva-react-native/commit/e72bde1640ae5cfac07aaa8c7752cb364bc0ac08))
+* fix test-android gradle target ([cb28d88](https://github.com/evva-sfw/abrevva-react-native/commit/cb28d883cdf3b882e4e8c0b065ec9f9527afc9bf))
+* fix version in filename for release ([#45](https://github.com/evva-sfw/abrevva-react-native/issues/45)) ([9e6dbaf](https://github.com/evva-sfw/abrevva-react-native/commit/9e6dbafee8f7f7b748104354213f1d050ddcd6a7))
+* reconfigure auto-changelog to only track merge commits ([#52](https://github.com/evva-sfw/abrevva-react-native/issues/52)) ([089cd1a](https://github.com/evva-sfw/abrevva-react-native/commit/089cd1a9d25300fd831157997271bcf585e18c3a))
### Changelog
@@ -25,8 +42,22 @@ All notable changes to this project will be documented in this file. Dates are d
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
+#### [2.0.0](https://github.com/evva-sfw/abrevva-react-native/compare/1.0.1...2.0.0)
+
+- chore!: rename package to @evva/ instead of @evva-sfw/ [`#60`](https://github.com/evva-sfw/abrevva-react-native/pull/60)
+- fix!: removed broken nfc code [`#61`](https://github.com/evva-sfw/abrevva-react-native/pull/61)
+- chore(deps-dev): bump @release-it/conventional-changelog from 8.0.1 to 8.0.2 [`#56`](https://github.com/evva-sfw/abrevva-react-native/pull/56)
+- ci: reconfigure auto-changelog to only track merge commits [`#52`](https://github.com/evva-sfw/abrevva-react-native/pull/52)
+- chore(deps-dev): bump commitlint from 19.4.0 to 19.4.1 [`#48`](https://github.com/evva-sfw/abrevva-react-native/pull/48)
+- chore(deps-dev): bump @commitlint/config-conventional from 19.2.2 to 19.4.1 [`#50`](https://github.com/evva-sfw/abrevva-react-native/pull/50)
+- chore(deps-dev): bump react-native-builder-bob from 0.29.1 to 0.30.0 [`#49`](https://github.com/evva-sfw/abrevva-react-native/pull/49)
+- feat: replaced manual disengage logic with AbrevvaSDK disengage function [`#46`](https://github.com/evva-sfw/abrevva-react-native/pull/46)
+- ci: fix version in filename for release [`#45`](https://github.com/evva-sfw/abrevva-react-native/pull/45)
+
#### [1.0.1](https://github.com/evva-sfw/abrevva-react-native/compare/1.0.0...1.0.1)
+> 28 August 2024
+
- fix: corrected output Path for decryptFileFromURL (android) [`#44`](https://github.com/evva-sfw/abrevva-react-native/pull/44)
- build: add npm-compatibility-check test [`#43`](https://github.com/evva-sfw/abrevva-react-native/pull/43)
- build: add yarn cache to github workflow caching [`#42`](https://github.com/evva-sfw/abrevva-react-native/pull/42)
@@ -47,16 +78,11 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- build: add attest provenance with lint and release workflow [`#29`](https://github.com/evva-sfw/abrevva-react-native/pull/29)
- fix: minor adjustments to scan timeout [`#28`](https://github.com/evva-sfw/abrevva-react-native/pull/28)
- feat: tests for android & ios [`#23`](https://github.com/evva-sfw/abrevva-react-native/pull/23)
-- chore: release 1.0.0 [`4ecb13c`](https://github.com/evva-sfw/abrevva-react-native/commit/4ecb13c555bf899f3ad45900c4c9e62f9ed0aa80)
#### [0.1.5](https://github.com/evva-sfw/abrevva-react-native/compare/0.1.4...0.1.5)
> 22 August 2024
-- chore: add CHANGELOG.md [`b337c52`](https://github.com/evva-sfw/abrevva-react-native/commit/b337c5234d389eb3a538de817639afe6b4005616)
-- chore: release 0.1.5 [`3a77838`](https://github.com/evva-sfw/abrevva-react-native/commit/3a778385e035379153759d0c368872c4c3f09309)
-- ci: enable npm upload on release [`56973c1`](https://github.com/evva-sfw/abrevva-react-native/commit/56973c101119399c3df4b567396efe8e403d56c7)
-
#### [0.1.4](https://github.com/evva-sfw/abrevva-react-native/compare/0.1.0...0.1.4)
> 22 August 2024
@@ -66,9 +92,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- chore: moved eslint config to package.json [`#25`](https://github.com/evva-sfw/abrevva-react-native/pull/25)
- chore: minor UI improvements [`#24`](https://github.com/evva-sfw/abrevva-react-native/pull/24)
- chore(deps): bump rexml from 3.2.9 to 3.3.3 in /example [`#22`](https://github.com/evva-sfw/abrevva-react-native/pull/22)
-- ci(release-it): checkout via ssh [`fd05e9a`](https://github.com/evva-sfw/abrevva-react-native/commit/fd05e9a0b3da6412acd1f3bdc508ea51e2541fb4)
-- ci(release-it): fix release github token for workflow [`425ad0a`](https://github.com/evva-sfw/abrevva-react-native/commit/425ad0ae88de58f74c6efcd8ee449a1121e10477)
-- ci: disable npm publish for debugging release-it workflow [`7fdd9d3`](https://github.com/evva-sfw/abrevva-react-native/commit/7fdd9d338e993bbdcb257dfad5ea5c6d68072505)
#### 0.1.0
@@ -90,6 +113,3 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- fix: added missing yarn files [`#6`](https://github.com/evva-sfw/abrevva-react-native/pull/6)
- chore: fix internal links [`#3`](https://github.com/evva-sfw/abrevva-react-native/pull/3)
- Update LICENSE [`#4`](https://github.com/evva-sfw/abrevva-react-native/pull/4)
-- Initital Project upload [`3524503`](https://github.com/evva-sfw/abrevva-react-native/commit/352450306f13773405be10d5f50c53d14d9dea6f)
-- chore(deps-dev): bump @release-it/conventional-changelog [`335c87f`](https://github.com/evva-sfw/abrevva-react-native/commit/335c87f2fed18199e73679b47a699e9cdba2e0a6)
-- refactor: added interfaces and restructured app accordingly [`436c12b`](https://github.com/evva-sfw/abrevva-react-native/commit/436c12bf624efcbccd694bf577c3d0e2c4591d32)
diff --git a/Makefile b/Makefile
index 713f6ec..fc760e9 100644
--- a/Makefile
+++ b/Makefile
@@ -11,4 +11,4 @@ test-ios:
test || exit 1
test-android:
- cd example/android && ./gradlew :evva-sfw_abrevva-react-native:testDebugUnitTest || exit 1
+ cd example/android && ./gradlew :evva_abrevva-react-native:testDebugUnitTest || exit 1
diff --git a/README.md b/README.md
index 15c01de..19afe4d 100644
--- a/README.md
+++ b/README.md
@@ -1,19 +1,15 @@
-
-
EVVA React-Native Module
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+# Abrevva React-Native Module
+
+[](https://www.npmjs.com/package/@evva/abrevva-react-native)
+[](https://www.npmjs.com/package/@evva/abrevva-react-native)
+
+
+
+[]([URL](https://github.com/evva-sfw/abrevva-react-native/actions))
+[](LICENSE)
+
+> [!IMPORTANT]
+> This package was renamed please use the new package name! __@evva/abrevva-react-native__
The EVVA React-Native Module is a collection of tools to work with electronical EVVA access components. It allows for scanning and connecting via BLE.
@@ -41,7 +37,7 @@ The EVVA React-Native Module is a collection of tools to work with electronical
## Installation
```
-yarn add @evva-sfw/abrevva-react-native
+yarn add @evva/abrevva-react-native
```
### iOS
@@ -59,7 +55,7 @@ Perform a gradle sync.
To start off first import `AbrevvaBle` from this module
```typescript
-import { AbrevvaBle } from '@evva-sfw/abrevva-react-native';
+import { AbrevvaBle } from '@evva/abrevva-react-native';
async function scanForBleDevices(androidNeverForLocation: Boolean = true, timeout: Number) {
await AbrevvaBle.initialize(androidNeverForLocation);
diff --git a/abrevva-react-native.podspec b/abrevva-react-native.podspec
index 7f2fe3e..f14d184 100644
--- a/abrevva-react-native.podspec
+++ b/abrevva-react-native.podspec
@@ -18,7 +18,7 @@ Pod::Spec.new do |s|
s.dependency "CocoaMQTT"
s.dependency "CryptoSwift"
- s.dependency "AbrevvaSDK", '~> 1.0.23'
+ s.dependency "AbrevvaSDK", '1.0.31'
# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
diff --git a/android/build.gradle b/android/build.gradle
index 71e50ed..9c8964e 100644
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -91,7 +91,7 @@ repositories {
def kotlin_version = getExtOrDefault("kotlinVersion")
dependencies {
- implementation group: "com.evva.xesar", name: "abrevva-sdk-android", version: "1.0.19"
+ implementation group: "com.evva.xesar", name: "abrevva-sdk-android", version: "1.0.21"
implementation "com.facebook.react:react-native:0.20.1"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml
index be24cc6..1a1fca2 100644
--- a/android/src/main/AndroidManifest.xml
+++ b/android/src/main/AndroidManifest.xml
@@ -1,7 +1,6 @@
-
diff --git a/android/src/main/java/com/evva/xesar/abrevva/reactnative/AbrevvaBleModule.kt b/android/src/main/java/com/evva/xesar/abrevva/reactnative/AbrevvaBleModule.kt
index 30f0087..b11276d 100644
--- a/android/src/main/java/com/evva/xesar/abrevva/reactnative/AbrevvaBleModule.kt
+++ b/android/src/main/java/com/evva/xesar/abrevva/reactnative/AbrevvaBleModule.kt
@@ -10,7 +10,6 @@ import androidx.annotation.RequiresPermission
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import com.evva.xesar.abrevva.ble.BleManager
-import com.evva.xesar.abrevva.nfc.toHexString
import com.evva.xesar.abrevva.util.bytesToString
import com.evva.xesar.abrevva.util.stringToBytes
import com.facebook.react.bridge.Arguments
@@ -448,12 +447,10 @@ class AbrevvaBleModule(reactContext: ReactApplicationContext) :
if (scanRecordBytes != null) {
try {
// Extract EVVA manufacturer-id
- val arr = byteArrayOf(0x01)
- arr.toHexString()
- val keyHex = byteArrayOf(scanRecordBytes.getByte(6)!!).toHexString() + byteArrayOf(
+ val keyHex = byteArrayOf(scanRecordBytes.getByte(6)!!) + byteArrayOf(
scanRecordBytes.getByte(5)!!
- ).toHexString()
- val keyDec = keyHex.toInt(16)
+ )
+ val keyDec = bytesToString(keyHex).replace(" ", "").toInt(16)
// Slice out manufacturer data
val bytes = scanRecordBytes.copyOfRange(7, scanRecordBytes.size)
diff --git a/android/src/main/java/com/evva/xesar/abrevva/reactnative/AbrevvaNfcModule.kt b/android/src/main/java/com/evva/xesar/abrevva/reactnative/AbrevvaNfcModule.kt
deleted file mode 100644
index 52641b5..0000000
--- a/android/src/main/java/com/evva/xesar/abrevva/reactnative/AbrevvaNfcModule.kt
+++ /dev/null
@@ -1,163 +0,0 @@
-package com.evva.xesar.abrevva.reactnative
-
-import android.content.Intent
-import android.nfc.NfcAdapter
-import com.evva.xesar.abrevva.nfc.KeyStoreHandler
-import com.evva.xesar.abrevva.nfc.Message
-import com.evva.xesar.abrevva.nfc.Mqtt5Client
-import com.evva.xesar.abrevva.nfc.NfcDelegate
-import com.evva.xesar.abrevva.nfc.asByteArray
-import com.evva.xesar.abrevva.nfc.toHexString
-import com.facebook.react.bridge.BaseActivityEventListener
-import com.facebook.react.bridge.LifecycleEventListener
-import com.facebook.react.bridge.Promise
-import com.facebook.react.bridge.ReactApplicationContext
-import com.facebook.react.bridge.ReactContextBaseJavaModule
-import com.facebook.react.bridge.ReactMethod
-import com.hivemq.client.mqtt.mqtt5.message.publish.Mqtt5Publish
-import java.util.Timer
-import java.util.TimerTask
-
-class AbrevvaNfcModule(reactContext: ReactApplicationContext) :
- ReactContextBaseJavaModule(reactContext) {
-
- private val host = "172.16.2.91"
- private val port = 1883
- private val clientID = "96380897-0eee-479e-80c3-84c0dde286cd"
-
- private val STATUS_NFC_OK = "enabled"
-
- private val kyOffTimer = Timer()
- private val hbTimer = Timer()
-
- private var mqtt5Client: Mqtt5Client? = null
- private var nfcDelegate = NfcDelegate()
-
- private var clientId: String? = null
-
- private val adapterStatus: String
- get() = nfcDelegate.setAdapterStatus()
-
- private val activityEventListener = object : BaseActivityEventListener() {
- override fun onNewIntent(intent: Intent?) {
- super.onNewIntent(intent)
- if (intent != null) {
- currentActivity!!.intent = intent
- nfcDelegate.processTag(intent) {
- mqtt5Client?.subscribe("readers/1/$clientId/t", ::messageReceivedCallback)
- mqtt5Client?.publish(
- "readers/1/$clientId",
- Message(
- "ky",
- "on",
- nfcDelegate.getIdentifier(),
- nfcDelegate.getHistoricalBytesAsHexString(),
- "BAKA"
- ).asByteArray()
- )
- setDisconnectTimer()
- setHbTimer()
- }
- }
- }
- }
-
- private val lifecycleEventListener = object : LifecycleEventListener {
- override fun onHostResume() {
- nfcDelegate.restartForegroundDispatch(reactContext, currentActivity)
- }
-
- override fun onHostPause() {
- nfcDelegate.disableForegroundDispatch(reactContext, currentActivity)
- }
-
- override fun onHostDestroy() {
- }
- }
-
- init {
- reactContext.addActivityEventListener(activityEventListener)
- reactContext.addLifecycleEventListener(lifecycleEventListener)
- nfcDelegate.setAdapter(NfcAdapter.getDefaultAdapter(reactContext))
- }
-
- private fun messageReceivedCallback(response: Mqtt5Publish) {
- try {
- val resp = nfcDelegate.transceive(response.payloadAsBytes)
- mqtt5Client?.publish("readers/1/$clientId/f", resp)
- } catch (e: Exception) {
- println(e)
- }
- }
-
- private fun setDisconnectTimer() {
- kyOffTimer.scheduleAtFixedRate(object : TimerTask() {
- override fun run() {
- try {
- // .isConnected throws SecurityException when Tag is outdated
- nfcDelegate.isConnected()
- } catch (ex: java.lang.Exception) {
- mqtt5Client?.publish(
- "readers/1",
- Message("ky", "off", oid = clientId).asByteArray()
- )
- this.cancel()
- }
- }
- }, 250, 250)
- }
-
- private fun setHbTimer() {
- hbTimer.scheduleAtFixedRate(object : TimerTask() {
- override fun run() {
- mqtt5Client?.publish("readers/1", Message("cr", "hb", oid = clientId).asByteArray())
- }
- }, 30000, 30000)
- }
-
- @ReactMethod
- fun read(promise: Promise) {
- if (adapterStatus != STATUS_NFC_OK) {
- // No NFC hardware or NFC is disabled by the user
- promise.reject(adapterStatus)
- return
- }
- nfcDelegate.restartForegroundDispatch(reactApplicationContext, currentActivity)
- }
-
- @OptIn(ExperimentalStdlibApi::class)
- @ReactMethod
- fun connect() {
- val ksh = KeyStoreHandler()
- try {
- val cacheDir = reactApplicationContext.cacheDir
- ksh.parseP12File("$cacheDir/client-android.p12", "123")
- ksh.initKeyManagerFactory()
- ksh.initTrustManagerFactory()
- } catch (ex: Exception) {
- println(ex)
- return
- }
-
- this.clientId = clientID
- this.mqtt5Client = Mqtt5Client(clientID, port, host, ksh)
- mqtt5Client?.connect()
- print(Message("ky", "off", oid = "oidValue").asByteArray().toHexString())
- }
-
- @ReactMethod
- fun disconnect() {
- hbTimer.cancel()
- kyOffTimer.cancel()
- mqtt5Client?.publish("readers/1", Message("cr", "off", oid = clientID).asByteArray())
- mqtt5Client?.disconnect()
- }
-
- override fun getName(): String {
- return NAME
- }
-
- companion object {
- const val NAME = "AbrevvaNfc"
- }
-}
diff --git a/android/src/main/java/com/evva/xesar/abrevva/reactnative/ExampleAppPackage.kt b/android/src/main/java/com/evva/xesar/abrevva/reactnative/ExampleAppPackage.kt
index 8670457..c8b1596 100644
--- a/android/src/main/java/com/evva/xesar/abrevva/reactnative/ExampleAppPackage.kt
+++ b/android/src/main/java/com/evva/xesar/abrevva/reactnative/ExampleAppPackage.kt
@@ -7,7 +7,7 @@ import com.facebook.react.uimanager.ViewManager
class ExampleAppPackage : ReactPackage {
override fun createNativeModules(reactContext: ReactApplicationContext): List {
- return listOf(AbrevvaCryptoModule(reactContext)) + listOf(AbrevvaNfcModule(reactContext)) + listOf(
+ return listOf(AbrevvaCryptoModule(reactContext)) + listOf(
AbrevvaBleModule(reactContext)
)
}
diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml
index 2499a4f..4122f36 100644
--- a/example/android/app/src/main/AndroidManifest.xml
+++ b/example/android/app/src/main/AndroidManifest.xml
@@ -1,6 +1,5 @@
-
/dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
- 59D3BAD406D244112EDD8B5C /* [CP] Check Pods Manifest.lock */ = {
+ 19905B8CF9CAE6AA1D1D84D6 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
+ "${PODS_ROOT}/Target Support Files/Pods-ExampleAppExample-ExampleAppExampleTests/Pods-ExampleAppExample-ExampleAppExampleTests-frameworks-${CONFIGURATION}-input-files.xcfilelist",
);
- inputPaths = (
- "${PODS_PODFILE_DIR_PATH}/Podfile.lock",
- "${PODS_ROOT}/Manifest.lock",
- );
- name = "[CP] Check Pods Manifest.lock";
+ name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
- );
- outputPaths = (
- "$(DERIVED_FILE_DIR)/Pods-ExampleAppExample-ExampleAppExampleTests-checkManifestLockResult.txt",
+ "${PODS_ROOT}/Target Support Files/Pods-ExampleAppExample-ExampleAppExampleTests/Pods-ExampleAppExample-ExampleAppExampleTests-frameworks-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
- shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
+ shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-ExampleAppExample-ExampleAppExampleTests/Pods-ExampleAppExample-ExampleAppExampleTests-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
- 88569654A39B7F4943A4ECB5 /* [CP] Check Pods Manifest.lock */ = {
+ 20635155BD5ADF3EF1109A16 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
+ "${PODS_ROOT}/Target Support Files/Pods-ExampleAppExample/Pods-ExampleAppExample-frameworks-${CONFIGURATION}-input-files.xcfilelist",
);
- inputPaths = (
- "${PODS_PODFILE_DIR_PATH}/Podfile.lock",
- "${PODS_ROOT}/Manifest.lock",
- );
- name = "[CP] Check Pods Manifest.lock";
+ name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
- );
- outputPaths = (
- "$(DERIVED_FILE_DIR)/Pods-ExampleAppExample-checkManifestLockResult.txt",
+ "${PODS_ROOT}/Target Support Files/Pods-ExampleAppExample/Pods-ExampleAppExample-frameworks-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
- shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
+ shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-ExampleAppExample/Pods-ExampleAppExample-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
- 92BE6BC0CFAA17A0C2386446 /* [CP] Embed Pods Frameworks */ = {
+ AA1E527239C7DC8BC535B9F1 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
- "${PODS_ROOT}/Target Support Files/Pods-ExampleAppExample-ExampleAppExampleTests/Pods-ExampleAppExample-ExampleAppExampleTests-frameworks-${CONFIGURATION}-input-files.xcfilelist",
);
- name = "[CP] Embed Pods Frameworks";
+ inputPaths = (
+ "${PODS_PODFILE_DIR_PATH}/Podfile.lock",
+ "${PODS_ROOT}/Manifest.lock",
+ );
+ name = "[CP] Check Pods Manifest.lock";
outputFileListPaths = (
- "${PODS_ROOT}/Target Support Files/Pods-ExampleAppExample-ExampleAppExampleTests/Pods-ExampleAppExample-ExampleAppExampleTests-frameworks-${CONFIGURATION}-output-files.xcfilelist",
+ );
+ outputPaths = (
+ "$(DERIVED_FILE_DIR)/Pods-ExampleAppExample-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
- shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-ExampleAppExample-ExampleAppExampleTests/Pods-ExampleAppExample-ExampleAppExampleTests-frameworks.sh\"\n";
+ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
@@ -374,7 +374,7 @@
/* Begin XCBuildConfiguration section */
13B07F941A680F5B00A75B9A /* Debug */ = {
isa = XCBuildConfiguration;
- baseConfigurationReference = 88BFDD102C005583A3DDE543 /* Pods-ExampleAppExample.debug.xcconfig */;
+ baseConfigurationReference = 6CDCDB6EBD657F5AB82D4529 /* Pods-ExampleAppExample.debug.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
@@ -407,7 +407,7 @@
};
13B07F951A680F5B00A75B9A /* Release */ = {
isa = XCBuildConfiguration;
- baseConfigurationReference = 68BC1AF6EDA113C27D65AC10 /* Pods-ExampleAppExample.release.xcconfig */;
+ baseConfigurationReference = 8A4DF353A54EAC9B7D836744 /* Pods-ExampleAppExample.release.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
@@ -438,7 +438,7 @@
};
39FBC3E42C64DE9800BEE979 /* Debug */ = {
isa = XCBuildConfiguration;
- baseConfigurationReference = 20389187CDDBF5F10F171A64 /* Pods-ExampleAppExample-ExampleAppExampleTests.debug.xcconfig */;
+ baseConfigurationReference = 95A96E601730AC9031B18B92 /* Pods-ExampleAppExample-ExampleAppExampleTests.debug.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
CLANG_ANALYZER_NONNULL = YES;
@@ -475,7 +475,7 @@
};
39FBC3E52C64DE9800BEE979 /* Release */ = {
isa = XCBuildConfiguration;
- baseConfigurationReference = 9A974A4BFAF3C7FA0946ABAC /* Pods-ExampleAppExample-ExampleAppExampleTests.release.xcconfig */;
+ baseConfigurationReference = 791740A1319B42B285B9B9D9 /* Pods-ExampleAppExample-ExampleAppExampleTests.release.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
CLANG_ANALYZER_NONNULL = YES;
diff --git a/example/ios/ExampleAppExample/Info.plist b/example/ios/ExampleAppExample/Info.plist
index e17ceff..12ab5c2 100644
--- a/example/ios/ExampleAppExample/Info.plist
+++ b/example/ios/ExampleAppExample/Info.plist
@@ -31,6 +31,8 @@
NSAllowsLocalNetworking
+ NSBluetoothAlwaysUsageDescription
+ Our app does not request this permission or utilize this functionality but it is included in our info.plist since our app utilizes the react-native-permissions library, which references this permission in its code.
NSLocationWhenInUseUsageDescription
UILaunchStoryboardName
@@ -47,15 +49,5 @@
UIViewControllerBasedStatusBarAppearance
- com.apple.developer.nfc.readersession.felica.systemcodes
-
- 12FC
-
- NFCReaderUsageDescription
- NFC tag to read NDEF messages into the application
-NSBluetoothAlwaysUsageDescription
-Our app does not request this permission or utilize this functionality but it is included in our info.plist since our app utilizes the react-native-permissions library, which references this permission in its code.
-
-
diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock
index eb28ed5..bc7ad65 100644
--- a/example/ios/Podfile.lock
+++ b/example/ios/Podfile.lock
@@ -1,5 +1,5 @@
PODS:
- - abrevva-react-native (0.1.5):
+ - abrevva-react-native (1.0.1):
- AbrevvaSDK (~> 1.0.23)
- CocoaMQTT
- CryptoSwift
@@ -23,7 +23,7 @@ PODS:
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- Yoga
- - AbrevvaSDK (1.0.23):
+ - AbrevvaSDK (1.0.31):
- CocoaMQTT
- CryptoSwift
- boost (1.83.0)
@@ -32,15 +32,15 @@ PODS:
- CocoaMQTT/Core (2.1.6):
- MqttCocoaAsyncSocket (~> 1.0.8)
- CryptoSwift (1.8.3)
- - CwlCatchException (2.2.0):
- - CwlCatchExceptionSupport (~> 2.2.0)
- - CwlCatchExceptionSupport (2.2.0)
- - CwlMachBadInstructionHandler (2.2.0)
- - CwlPosixPreconditionTesting (2.2.0)
- - CwlPreconditionTesting (2.2.1):
- - CwlCatchException (~> 2.2.0)
- - CwlMachBadInstructionHandler (~> 2.2.0)
- - CwlPosixPreconditionTesting (~> 2.2.0)
+ - CwlCatchException (2.2.1):
+ - CwlCatchExceptionSupport (~> 2.2.1)
+ - CwlCatchExceptionSupport (2.2.1)
+ - CwlMachBadInstructionHandler (2.2.2)
+ - CwlPosixPreconditionTesting (2.2.2)
+ - CwlPreconditionTesting (2.2.2):
+ - CwlCatchException (~> 2.2.1)
+ - CwlMachBadInstructionHandler (~> 2.2.2)
+ - CwlPosixPreconditionTesting (~> 2.2.2)
- DoubleConversion (1.1.6)
- FBLazyVector (0.74.3)
- fmt (9.1.0)
@@ -50,7 +50,7 @@ PODS:
- hermes-engine/Pre-built (0.74.3)
- MockingbirdFramework (0.20.0)
- MqttCocoaAsyncSocket (1.0.8)
- - Nimble (13.4.0):
+ - Nimble (13.5.0):
- CwlPreconditionTesting (~> 2.2.0)
- Quick (7.6.2)
- RCT-Folly (2024.01.01.00):
@@ -1440,16 +1440,16 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/ReactCommon/yoga"
SPEC CHECKSUMS:
- abrevva-react-native: 6980035371bf192213003a60418276baced5d569
- AbrevvaSDK: 4edd60273dd1b2d171e8adb5a84756aa5084347c
+ abrevva-react-native: bad5d64a489a5cc76813d5ac9ef5747081fc7f6c
+ AbrevvaSDK: 87be0b144be7212470f79d2cbc5d3b3c72df4da4
boost: d3f49c53809116a5d38da093a8aa78bf551aed09
CocoaMQTT: 1f206228b29318eabdacad0c2e4e88575922c27a
CryptoSwift: 967f37cea5a3294d9cce358f78861652155be483
- CwlCatchException: 51bf8319009a31104ea6f0568730d1ecc25b6454
- CwlCatchExceptionSupport: 1345d6adb01a505933f2bc972dab60dcb9ce3e50
- CwlMachBadInstructionHandler: ea1030428925d9bf340882522af30712fb4bf356
- CwlPosixPreconditionTesting: a125dee731883f2582715f548c6b6c92c7fde145
- CwlPreconditionTesting: ccfd08aca58d14e04062b2a3dd2fd52e09857453
+ CwlCatchException: 7acc161b299a6de7f0a46a6ed741eae2c8b4d75a
+ CwlCatchExceptionSupport: 54ccab8d8c78907b57f99717fb19d4cc3bce02dc
+ CwlMachBadInstructionHandler: dae4fdd124d45c9910ac240287cc7b898f4502a1
+ CwlPosixPreconditionTesting: ecd095aa2129e740b44301c34571e8d85906fb88
+ CwlPreconditionTesting: 67a0047dd4de4382b93442c0e3f25207f984f35a
DoubleConversion: 76ab83afb40bddeeee456813d9c04f67f78771b5
FBLazyVector: 7e977dd099937dc5458851233141583abba49ff2
fmt: 4c2741a687cc09f0634a2e2c72a838b99f1ff120
@@ -1457,7 +1457,7 @@ SPEC CHECKSUMS:
hermes-engine: 1f547997900dd0752dc0cc0ae6dd16173c49e09b
MockingbirdFramework: 54e35fbbb47b806c1a1fae2cf3ef99f6eceb55e5
MqttCocoaAsyncSocket: 77d3b74f76228dd5a05d1f9526eab101d415b30c
- Nimble: c3d7c9848a0adae88a665ca52f8da23dd4d2cd94
+ Nimble: cc0469644d253140c6bab7e88d4ee3bbed59a25c
Quick: b8bec97cd4b9f21da0472d45580f763b801fc353
RCT-Folly: 02617c592a293bd6d418e0a88ff4ee1f88329b47
RCTDeprecation: 4c7eeb42be0b2e95195563c49be08d0b839d22b4
@@ -1514,4 +1514,4 @@ SPEC CHECKSUMS:
PODFILE CHECKSUM: c2b657d91fc21203dd436e57c3a2a27527cbae3b
-COCOAPODS: 1.14.3
+COCOAPODS: 1.15.2
diff --git a/example/src/App.tsx b/example/src/App.tsx
index 42e6dba..5285df6 100644
--- a/example/src/App.tsx
+++ b/example/src/App.tsx
@@ -1,18 +1,8 @@
-import { AbrevvaCrypto, AbrevvaNfc } from '@evva-sfw/abrevva-react-native';
+import { AbrevvaCrypto } from '@evva/abrevva-react-native';
import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
-import { useEffect } from 'react';
import { useState } from 'react';
-import {
- Dimensions,
- Platform,
- ScrollView,
- StyleSheet,
- Text,
- TouchableOpacity,
- View,
-} from 'react-native';
-import RNFS from 'react-native-fs';
+import { Dimensions, ScrollView, StyleSheet, Text, TouchableOpacity, View } from 'react-native';
import { BleScreen } from './BleScreenComponents';
@@ -23,7 +13,6 @@ const App = () => {
-
@@ -34,9 +23,6 @@ const App = () => {
const HomeScreen = ({ navigation }) => {
return (
- navigation.navigate('nfc')}>
- NFC Test
-
navigation.navigate('crypto')}>
Crpto Test
@@ -47,28 +33,6 @@ const HomeScreen = ({ navigation }) => {
);
};
-const NfcScreen = () => {
- useEffect(() => {
- if (Platform.OS === 'ios' || Platform.OS === 'android') {
- RNFS.exists(`${RNFS.DocumentDirectoryPath}/client-${Platform.OS}.p12`).then((exists) => {
- if (!exists) {
- void RNFS.copyFile(
- RNFS.MainBundlePath + `/client-${Platform.OS}.p12`,
- `${RNFS.DocumentDirectoryPath}/client-${Platform.OS}.p12`,
- );
- }
- });
- }
- }, []);
- return (
-
-
- );
-};
-
const CryptoScreen = () => {
const [result, setResult] = useState('');
return (
diff --git a/example/src/BleScreenComponents.tsx b/example/src/BleScreenComponents.tsx
index 21538f5..7da1159 100644
--- a/example/src/BleScreenComponents.tsx
+++ b/example/src/BleScreenComponents.tsx
@@ -1,4 +1,4 @@
-import { AbrevvaBle, type ScanResult } from '@evva-sfw/abrevva-react-native';
+import { AbrevvaBle, type ScanResult } from '@evva/abrevva-react-native';
import { useEffect } from 'react';
import { useState } from 'react';
import {
diff --git a/ios/crypto/AbrevvaCrypto.swift b/ios/crypto/AbrevvaCrypto.swift
index 1672038..9a9c4ab 100644
--- a/ios/crypto/AbrevvaCrypto.swift
+++ b/ios/crypto/AbrevvaCrypto.swift
@@ -1,200 +1,242 @@
-import Foundation
-import CryptoKit
import AbrevvaSDK
+import CryptoKit
+import CryptoSwift
+import Foundation
@objc(AbrevvaCrypto)
public class AbrevvaCrypto: NSObject {
- private let X25519Impl = X25519()
- private let AesGcmImpl = AesGcm()
- private let AesCcmImpl = AesCcm()
- private let SimpleSecureRandomImpl = SimpleSecureRandom()
- private let HKDFImpl = HKDFWrapper()
-
- @objc func encrypt(_ options: NSDictionary , resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock ) {
- guard let optionsSwift = options as? [String: Any] else {
- reject("Failed to convert NSDictionary to Swift dictionary", nil, nil)
- return
- }
-
- let key = Array(hex: "0x" + (optionsSwift["key"] as? String ?? ""))
- let iv = Array(hex: "0x" + (optionsSwift["iv"] as? String ?? ""))
- let adata = Array(hex: "0x" + (optionsSwift["adata"] as? String ?? ""))
- let pt = Array(hex: "0x" + (optionsSwift["pt"] as? String ?? ""))
- let tagLength = optionsSwift["tagLength"] as? Int ?? 0
- let ct = AesCcmImpl.encrypt(key: key, iv: iv, adata: adata, pt: pt, tagLength: tagLength)
- if (ct.isEmpty) {
- reject("encrypt failed", nil, nil)
- } else {
- resolve([
- "cipherText": Array(ct[..(ct[pt.count...]).toHexString(),
- ]);
- }
- }
-
-
- @objc func decrypt(_ options: NSDictionary , resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock ) {
- guard let optionsSwift = options as? [String: Any] else {
- reject("Failed to convert NSDictionary to Swift dictionary", nil, nil)
- return
- }
-
- let key = Array(hex: "0x" + (optionsSwift["key"] as? String ?? ""))
- let iv = Array(hex: "0x" + (optionsSwift["iv"] as? String ?? ""))
- let adata = Array(hex: "0x" + (optionsSwift["adata"] as? String ?? ""))
- let ct = Array(hex: "0x" + (optionsSwift["ct"] as? String ?? ""))
- let tagLength = optionsSwift["tagLength"] as? Int ?? 0
-
- let pt = AesCcmImpl.decrypt(key: key, iv: iv, adata: adata, ct: ct, tagLength: tagLength).toHexString()
- if (pt.isEmpty) {
- reject("decrypt failed", nil, nil)
- } else {
- resolve([
- "plainText": pt,
- "authOk": true
- ]);
- }
- }
-
- @objc func generateKeyPair(_ resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock ) {
- let keyPair = X25519Impl.generateKeyPair()
-
- resolve([
- "privateKey": keyPair[0].toHexString(),
- "publicKey": keyPair[1].toHexString()
- ])
- }
-
- @objc func computeSharedSecret(_ options: NSDictionary , resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock ) {
- guard let optionsSwift = options as? [String: Any] else {
- reject("Failed to convert NSDictionary to Swift dictionary", nil, nil)
- return
- }
-
- let privateKeyData = Data(hex: "0x" + (optionsSwift["key"] as? String ?? ""))
- let publicKeyData = Data(hex: "0x" + (optionsSwift["peerPublicKey"] as? String ?? ""))
- let sharedSecret = X25519Impl.computeSharedSecret(privateKeyData: privateKeyData, publicKeyData: publicKeyData)
-
- resolve([
- "sharedSecret": sharedSecret?.toHexString()
- ])
- }
-
- @objc func encryptFile(_ options: NSDictionary , resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock ) {
- guard let optionsSwift = options as? [String: Any] else {
- reject("Failed to convert NSDictionary to Swift dictionary", nil, nil)
- return
- }
-
- let sharedSecret = Array(hex: "0x" + (optionsSwift["sharedSecret"] as? String ?? ""))
- let ptPath = optionsSwift["ptPath"] as? String ?? ""
- let ctPath = optionsSwift["ctPath"] as? String ?? ""
-
- let operationResult = AesGcmImpl.encryptFile(key: sharedSecret, pathPt: ptPath, pathCt: ctPath)
- if (operationResult == false) {
- reject("encryption failed", nil, nil)
- } else {
- resolve([
- "opOk": operationResult
- ]);
- }
- }
-
- @objc func decryptFile(_ options: NSDictionary , resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock ) {
- guard let optionsSwift = options as? [String: Any] else {
- reject("Failed to convert NSDictionary to Swift dictionary", nil, nil)
- return
- }
-
- let sharedSecret = Array(hex: "0x" + (optionsSwift["sharedSecret"] as? String ?? ""))
- let ctPath = optionsSwift["ctPath"] as? String ?? ""
- let ptPath = optionsSwift["ptPath"] as? String ?? ""
-
- let url = URL(fileURLWithPath: ctPath)
-
- let data: Data
- do {
- data = try Data(contentsOf: url, options: .mappedIfSafe)
- } catch {
- debugPrint("\(AbrevvaCrypto.description()): Failed to load data from file")
- return reject("Failed to load data", nil, nil)
- }
-
- let operationResult = AesGcmImpl.decryptFile(key: sharedSecret, data: data, pathPt: ptPath)
- if (operationResult == false) {
- reject("Encryption has failed", nil, nil)
- } else {
- resolve([
- "opOk": operationResult
- ]);
- }
- }
-
- @objc func decryptFileFromURL(_ options: NSDictionary , resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock ) {
- guard let optionsSwift = options as? [String: Any] else {
- reject("Failed to convert NSDictionary to Swift dictionary", nil, nil)
- return
- }
-
- let sharedSecret = Array(hex: "0x" + (optionsSwift["sharedSecret"] as? String ?? ""))
- let ptPath = optionsSwift["ptPath"] as? String ?? ""
-
- let url = URL(string: optionsSwift["url"] as? String ?? "")
-
- let data: Data
- do {
- data = try Data(contentsOf: url!)
- } catch {
- debugPrint("\(AbrevvaCrypto.description()): Failed to load data from url")
- return reject("Failed to load data", nil, nil)
- }
-
- let operationResult = AesGcmImpl.decryptFile(key: sharedSecret, data: data, pathPt: ptPath)
- if (operationResult == false) {
- reject("Decryption has failed", nil, nil)
- } else {
- resolve([
- "opOk": operationResult
- ]);
- }
- }
-
- @objc func random(_ options: NSDictionary , resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock ) {
- guard let optionsSwift = options as? [String: Any] else {
- reject("Failed to convert NSDictionary to Swift dictionary", nil, nil)
- return
- }
-
- let numBytes = optionsSwift["numBytes"] as? Int ?? 0
-
- let rnd = SimpleSecureRandomImpl.random(numBytes).toHexString();
- if (rnd.isEmpty) {
- reject("random generation failed", nil, nil)
- } else {
- resolve([
- "value": rnd
- ]);
- }
- }
-
- @objc func derive(_ options: NSDictionary , resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock ) {
- guard let optionsSwift = options as? [String: Any] else {
- reject("Failed to convert NSDictionary to Swift dictionary", nil, nil)
- return
- }
-
- let key = Array(hex: "0x" + (optionsSwift["key"] as? String ?? ""))
- let salt = Array(hex: "0x" + (optionsSwift["salt"] as? String ?? ""))
- let info = Array(hex: "0x" + (optionsSwift["info"] as? String ?? ""))
- let length = optionsSwift["length"] as? Int ?? 0
-
- let derived = HKDFImpl.derive(key: key, salt: salt, info: info, length: length).toHexString();
- if (derived.isEmpty) {
- reject("derivation failed", nil, nil)
- } else {
- resolve([
- "value": derived
- ]);
- }
+ private let X25519Impl = X25519()
+ private let AesGcmImpl = AesGcm()
+ private let AesCcmImpl = AesCcm()
+ private let SimpleSecureRandomImpl = SimpleSecureRandom()
+ private let HKDFImpl = HKDFWrapper()
+
+ @objc func encrypt(
+ _ options: NSDictionary, resolver resolve: @escaping RCTPromiseResolveBlock,
+ rejecter reject: @escaping RCTPromiseRejectBlock
+ ) {
+ guard let optionsSwift = options as? [String: Any] else {
+ reject("Failed to convert NSDictionary to Swift dictionary", nil, nil)
+ return
+ }
+
+ let key = [UInt8](hex: "0x" + (optionsSwift["key"] as? String ?? ""))
+ let iv = [UInt8](hex: "0x" + (optionsSwift["iv"] as? String ?? ""))
+ let adata = [UInt8](hex: "0x" + (optionsSwift["adata"] as? String ?? ""))
+ let pt = [UInt8](hex: "0x" + (optionsSwift["pt"] as? String ?? ""))
+ let tagLength = optionsSwift["tagLength"] as? Int ?? 0
+ let ct = AesCcmImpl.encrypt(
+ key: key, iv: iv, adata: adata, pt: pt, tagLength: tagLength)
+ if ct.isEmpty {
+ reject("encrypt failed", nil, nil)
+ } else {
+ resolve([
+ "cipherText": [UInt8](ct[..
-
-@interface RCT_EXTERN_MODULE(AbrevvaNfc, NSObject)
-RCT_EXTERN_METHOD(connect)
-RCT_EXTERN_METHOD(disconnect)
-RCT_EXTERN_METHOD(read)
-
-+ (BOOL)requiresMainQueueSetup
-{
- return NO;
-}
-@end
\ No newline at end of file
diff --git a/ios/nfc/AbrevvaNfc.swift b/ios/nfc/AbrevvaNfc.swift
deleted file mode 100644
index 628219d..0000000
--- a/ios/nfc/AbrevvaNfc.swift
+++ /dev/null
@@ -1,122 +0,0 @@
-import Foundation
-import UIKit
-import os
-import Dispatch
-import CocoaMQTT
-import CoreNFC
-import AbrevvaSDK
-
-@objc(AbrevvaNfc)
-class AbrevvaNfc: NSObject, NFCSessionDelegate {
-
- let HOST = "172.16.2.91" //"172.16.158.30" //
- let PORT: UInt16 = 1883
- let CLIENTID: String = "96380897-0eee-479e-80c3-84c0dde286cd" // "9c97fe36-d0f7-4e6c-b1e2-1b045587eed3" //
-
- var clientID: String = ""
- private var mqtt5Client: MQTT5Client?
- private var nfcSession = NFCSession()
-
- override init() {
- super.init()
- nfcSession.delegate = self
- }
-
- @objc func connect() {
- let clientCertArray = getClientCertFromP12File(certName: "client-ios.p12", certPassword: "123")
-
- self.clientID = CLIENTID
-
- mqtt5Client = MQTT5Client(clientID: clientID, host: HOST, port: PORT, clientCertArray:clientCertArray)
- mqtt5Client?.setOnMessageRecieveHandler(handler: onMessageRecieveHandler)
- mqtt5Client?.setDidStateChangeToHandler(handler: didStateChangeToHandler)
- mqtt5Client?.connect()
- }
-
- @objc func disconnect() {
- mqtt5Client?.disconnect()
- }
-
- @objc func read() {
- nfcSession.beginSession()
- }
-
- func getClientCertFromP12File(certName: String, certPassword: String) -> CFArray? {
- let DOCUMENT_DIR = try! FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: true).path
- let resourcePath: String? = "\(DOCUMENT_DIR)/\(certName)"
-
- guard let filePath = resourcePath, let p12Data = NSData(contentsOfFile: filePath) else {
- print("Failed to open the certificate file: \(certName)")
- return nil
- }
-
- // create key dictionary for reading p12 file
- let key = kSecImportExportPassphrase as String
- let options : NSDictionary = [key: certPassword]
-
- var items : CFArray?
- let securityError = SecPKCS12Import(p12Data, options, &items)
- guard securityError == errSecSuccess else {
- if securityError == errSecAuthFailed {
- print("ERROR: SecPKCS12Import returned errSecAuthFailed. Incorrect password?")
- } else {
- print("ERROR SecPKCS12Import \(securityError)")
- }
- return nil
- }
-
- guard let theArray = items, CFArrayGetCount(theArray) > 0 else {
- return nil
- }
-
- let dictionary = (theArray as NSArray).object(at: 0)
- guard let identity = (dictionary as AnyObject).value(forKey: kSecImportItemIdentity as String) else {
- return nil
- }
- let certArray = [identity] as CFArray
- return certArray
- }
-
- public func onMessageRecieveHandler(message: CocoaMQTT5Message) {
- Task {
- if let resp = await self.nfcSession.send(apdu: NFCISO7816APDU(data: Data(message.payload))!) {
- var apduArr:[UInt8] = [UInt8](resp.0)
- apduArr.append(resp.1)
- apduArr.append(resp.2)
- print(apduArr)
- self.mqtt5Client?.publishMessage(topic: "readers/1/\(clientID)/f", payload: apduArr)
- }
- }
- }
-
- public func didStateChangeToHandler(state: CocoaMQTTConnState) {
- if state == .connected {
- self.mqtt5Client?.publishMessage(topic: "readers/1", message: Message(t: "cr", e: "on", oid: self.clientID, atr: nil))
- self.mqtt5Client?.subscribe(topics: [MqttSubscription.init(topic: "readers/1/\(clientID)/t")])
-
- }
- else if state == .disconnected {
- self.nfcSession.invalidateSession(message: "Connection to broker lost.")
- }
- }
-
- public func disconnectMqttClient() {
- self.mqtt5Client?.publishMessage(topic: "readers/1", message: Message(t: "cr", e: "off", oid: self.clientID, atr: nil))
- self.mqtt5Client?.disconnect()
- self.nfcSession.invalidateSession()
- }
-
- func sessionDidStart(_ withSuccess: Bool) {
- }
-
- func sessionDidClose(_ withError: (any Error)?) {
- }
-
- func sessionDidReceiveKeyOnEvent(_ tagID: Data, _ historicalBytes: Data) {
- mqtt5Client?.publishKyOn(identifier: tagID.toHexString(), historicalBytes: historicalBytes.toHexString())
- }
-
- func sessionDidReceiveKeyOffEvent(_ tagID: Data, _ historicalBytes: Data) {
- mqtt5Client?.publishKyOff(identifier: tagID.toHexString(), historicalBytes: historicalBytes.toHexString())
- }
-}
diff --git a/package.json b/package.json
index e587993..b06204c 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
- "name": "@evva-sfw/abrevva-react-native",
- "version": "1.0.1",
+ "name": "@evva/abrevva-react-native",
+ "version": "2.0.0",
"author": "EVVA Sicherheitstechnologie GmbH",
"description": "The EVVA React-Native Module is a collection of tools to work with electronical EVVA access components. It allows for scanning and connecting via BLE.",
"source": "./src/index.tsx",
diff --git a/src/index.test.tsx b/src/index.test.tsx
index aa7f6d7..3529a30 100644
--- a/src/index.test.tsx
+++ b/src/index.test.tsx
@@ -1,11 +1,6 @@
import { NativeEventEmitter, NativeModules, Platform } from 'react-native';
-import {
- type AbrevvaBLEInterface,
- AbrevvaCrypto,
- AbrevvaNfc,
- createAbrevvaBleInstance,
-} from './index';
+import { type AbrevvaBLEInterface, AbrevvaCrypto, createAbrevvaBleInstance } from './index';
describe('AbrevvaBleModule', () => {
let AbrevvaBleMock = NativeModules.AbrevvaBle;
@@ -172,27 +167,6 @@ describe('AbrevvaBleModule', () => {
});
});
-describe('AbrevvaNfcModule', () => {
- const AbrevvaNfcMock = NativeModules.AbrevvaNfc;
-
- beforeEach(() => {
- jest.clearAllMocks();
- });
-
- it('should run connect()', async () => {
- await AbrevvaNfc.connect();
- expect(AbrevvaNfcMock.connect).toHaveBeenCalledTimes(1);
- });
- it('should run disconnect()', async () => {
- await AbrevvaNfc.disconnect();
- expect(AbrevvaNfcMock.disconnect).toHaveBeenCalledTimes(1);
- });
- it('should run read()', async () => {
- await AbrevvaNfc.read();
- expect(AbrevvaNfcMock.read).toHaveBeenCalledTimes(1);
- });
-});
-
describe('AbrevvaCryptoModule', () => {
const AbrevvaCryptoMock = NativeModules.AbrevvaCrypto;
diff --git a/src/index.tsx b/src/index.tsx
index 73b5617..bd84540 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -14,24 +14,12 @@ import { convertObject, convertValue } from './conversion';
import type {
AbrevvaBLEInterface,
AbrevvaCryptoInterface,
- AbrevvaNfcInterface,
ScanMode,
ScanResult,
ScanResultInternal,
StringResult,
} from './interfaces';
-const NativeModuleNfc = NativeModules.AbrevvaNfc
- ? NativeModules.AbrevvaNfc
- : new Proxy(
- {},
- {
- get() {
- throw new Error('Linking Error AbrevvaNfc');
- },
- },
- );
-
const NativeModuleCrypto = NativeModules.AbrevvaCrypto
? NativeModules.AbrevvaCrypto
: new Proxy(
@@ -307,18 +295,6 @@ export class AbrevvaBleModule implements AbrevvaBLEInterface {
}
}
-class AbrevvaNfcModule implements AbrevvaNfcInterface {
- connect() {
- return NativeModuleNfc.connect();
- }
- disconnect() {
- return NativeModuleNfc.disconnect();
- }
- read() {
- return NativeModuleNfc.read();
- }
-}
-
class AbrevvaCryptoModule implements AbrevvaCryptoInterface {
encrypt(key: string, iv: string, adata: string, pt: string, tagLength?: number) {
return NativeModuleCrypto.encrypt({
@@ -381,7 +357,6 @@ class AbrevvaCryptoModule implements AbrevvaCryptoInterface {
export const AbrevvaBle = new AbrevvaBleModule();
export const AbrevvaCrypto = new AbrevvaCryptoModule();
-export const AbrevvaNfc = new AbrevvaNfcModule();
export function createAbrevvaBleInstance() {
return new AbrevvaBleModule();
diff --git a/src/interfaces.tsx b/src/interfaces.tsx
index 80552f5..7ec0dfa 100644
--- a/src/interfaces.tsx
+++ b/src/interfaces.tsx
@@ -45,12 +45,6 @@ export interface ScanResultInternal {
export interface StringResult {
value?: string;
}
-
-export interface AbrevvaNfcInterface {
- connect: () => Promise;
- disconnect: () => Promise;
- read: () => Promise;
-}
export interface AbrevvaCryptoInterface {
encrypt: (
key: string,
diff --git a/src/setup.tsx b/src/setup.tsx
index 0a9702c..b7317fd 100644
--- a/src/setup.tsx
+++ b/src/setup.tsx
@@ -14,11 +14,6 @@ jest.mock('react-native/Libraries/Utilities/Platform', () => ({
jest.mock('react-native', () => {
const originalModule = jest.requireActual('react-native');
- originalModule.NativeModules.AbrevvaNfc = {
- connect: jest.fn(),
- disconnect: jest.fn(),
- read: jest.fn(),
- };
originalModule.NativeModules.AbrevvaBle = {
setSupportedEvents: jest.fn(),
initialize: jest.fn(),
diff --git a/tsconfig.json b/tsconfig.json
index 8271f5c..d5d43e2 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -3,7 +3,7 @@
"compilerOptions": {
"rootDir": ".",
"paths": {
- "@evva-sfw/abrevva-react-native": ["./src/index"]
+ "@evva/abrevva-react-native": ["./src/index"]
},
"allowUnreachableCode": false,
"allowUnusedLabels": false,
diff --git a/yarn.lock b/yarn.lock
index 2e9881f..afc4305 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1651,11 +1651,11 @@ __metadata:
linkType: hard
"@babel/runtime@npm:^7.0.0, @babel/runtime@npm:^7.20.0, @babel/runtime@npm:^7.8.4":
- version: 7.25.4
- resolution: "@babel/runtime@npm:7.25.4"
+ version: 7.26.0
+ resolution: "@babel/runtime@npm:7.26.0"
dependencies:
regenerator-runtime: ^0.14.0
- checksum: 5c2aab03788e77f1f959d7e6ce714c299adfc9b14fb6295c2a17eb7cad0dd9c2ebfb2d25265f507f68c43d5055c5cd6f71df02feb6502cea44b68432d78bcbbe
+ checksum: c8e2c0504ab271b3467a261a8f119bf2603eb857a0d71e37791f4e3fae00f681365073cc79f141ddaa90c6077c60ba56448004ad5429d07ac73532be9f7cf28a
languageName: node
linkType: hard
@@ -1956,18 +1956,18 @@ __metadata:
linkType: hard
"@evilmartians/lefthook@npm:^1.7.11":
- version: 1.7.14
- resolution: "@evilmartians/lefthook@npm:1.7.14"
+ version: 1.8.2
+ resolution: "@evilmartians/lefthook@npm:1.8.2"
bin:
lefthook: bin/index.js
- checksum: ddd1b6eda95d0d4f8728900d65a597075499ebec2d3181dab87fd3de2897d68ff47a111da6672e226c54952a477807dde7d1300f5622822701864846166887e2
+ checksum: 1b9e5ab70355ad1a71c201d0cbbc7e5791503cb66e1509d95dadbb4b4f2413a171ec755ee85d997b0df904c0f0421d2b7819468511462a19b14bd382955bc6fd
conditions: (os=darwin | os=linux | os=win32) & (cpu=x64 | cpu=arm64 | cpu=ia32)
languageName: node
linkType: hard
-"@evva-sfw/abrevva-react-native@workspace:.":
+"@evva/abrevva-react-native@workspace:.":
version: 0.0.0-use.local
- resolution: "@evva-sfw/abrevva-react-native@workspace:."
+ resolution: "@evva/abrevva-react-native@workspace:."
dependencies:
"@commitlint/config-conventional": ^19.2.2
"@evilmartians/lefthook": ^1.7.11
@@ -3142,10 +3142,17 @@ __metadata:
languageName: node
linkType: hard
+"@rtsao/scc@npm:^1.1.0":
+ version: 1.1.0
+ resolution: "@rtsao/scc@npm:1.1.0"
+ checksum: 17d04adf404e04c1e61391ed97bca5117d4c2767a76ae3e879390d6dec7b317fcae68afbf9e98badee075d0b64fa60f287729c4942021b4d19cd01db77385c01
+ languageName: node
+ linkType: hard
+
"@scure/base@npm:^1.1.7":
- version: 1.1.7
- resolution: "@scure/base@npm:1.1.7"
- checksum: d9084be9a2f27971df1684af9e40bb750e86f549345e1bb3227fb61673c0c83569c92c1cb0a4ddccb32650b39d3cd3c145603b926ba751c9bc60c27317549b20
+ version: 1.1.9
+ resolution: "@scure/base@npm:1.1.9"
+ checksum: 120820a37dfe9dfe4cab2b7b7460552d08e67dee8057ed5354eb68d8e3440890ae983ce3bee957d2b45684950b454a2b6d71d5ee77c1fd3fddc022e2a510337f
languageName: node
linkType: hard
@@ -3905,7 +3912,7 @@ __metadata:
languageName: node
linkType: hard
-"array-includes@npm:^3.1.6, array-includes@npm:^3.1.7, array-includes@npm:^3.1.8":
+"array-includes@npm:^3.1.6, array-includes@npm:^3.1.8":
version: 3.1.8
resolution: "array-includes@npm:3.1.8"
dependencies:
@@ -3940,7 +3947,7 @@ __metadata:
languageName: node
linkType: hard
-"array.prototype.findlastindex@npm:^1.2.3":
+"array.prototype.findlastindex@npm:^1.2.5":
version: 1.2.5
resolution: "array.prototype.findlastindex@npm:1.2.5"
dependencies:
@@ -5880,15 +5887,15 @@ __metadata:
languageName: node
linkType: hard
-"eslint-module-utils@npm:^2.8.0":
- version: 2.8.2
- resolution: "eslint-module-utils@npm:2.8.2"
+"eslint-module-utils@npm:^2.12.0":
+ version: 2.12.0
+ resolution: "eslint-module-utils@npm:2.12.0"
dependencies:
debug: ^3.2.7
peerDependenciesMeta:
eslint:
optional: true
- checksum: f21109dd06eff6eb99c60738f8092e05b498e8438232a3112612e2f124e278d541eda4cd58dd8ec139ee443cf7fcd8be0212804be477284ee8013c6d319a1e5a
+ checksum: be3ac52e0971c6f46daeb1a7e760e45c7c45f820c8cc211799f85f10f04ccbf7afc17039165d56cb2da7f7ca9cec2b3a777013cddf0b976784b37eb9efa24180
languageName: node
linkType: hard
@@ -5918,29 +5925,31 @@ __metadata:
linkType: hard
"eslint-plugin-import@npm:^2.28.1":
- version: 2.29.1
- resolution: "eslint-plugin-import@npm:2.29.1"
+ version: 2.31.0
+ resolution: "eslint-plugin-import@npm:2.31.0"
dependencies:
- array-includes: ^3.1.7
- array.prototype.findlastindex: ^1.2.3
+ "@rtsao/scc": ^1.1.0
+ array-includes: ^3.1.8
+ array.prototype.findlastindex: ^1.2.5
array.prototype.flat: ^1.3.2
array.prototype.flatmap: ^1.3.2
debug: ^3.2.7
doctrine: ^2.1.0
eslint-import-resolver-node: ^0.3.9
- eslint-module-utils: ^2.8.0
- hasown: ^2.0.0
- is-core-module: ^2.13.1
+ eslint-module-utils: ^2.12.0
+ hasown: ^2.0.2
+ is-core-module: ^2.15.1
is-glob: ^4.0.3
minimatch: ^3.1.2
- object.fromentries: ^2.0.7
- object.groupby: ^1.0.1
- object.values: ^1.1.7
+ object.fromentries: ^2.0.8
+ object.groupby: ^1.0.3
+ object.values: ^1.2.0
semver: ^6.3.1
+ string.prototype.trimend: ^1.0.8
tsconfig-paths: ^3.15.0
peerDependencies:
- eslint: ^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8
- checksum: e65159aef808136d26d029b71c8c6e4cb5c628e65e5de77f1eb4c13a379315ae55c9c3afa847f43f4ff9df7e54515c77ffc6489c6a6f81f7dd7359267577468c
+ eslint: ^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8 || ^9
+ checksum: b1d2ac268b3582ff1af2a72a2c476eae4d250c100f2e335b6e102036e4a35efa530b80ec578dfc36761fabb34a635b9bf5ab071abe9d4404a4bb054fdf22d415
languageName: node
linkType: hard
@@ -7549,7 +7558,7 @@ __metadata:
languageName: node
linkType: hard
-"is-core-module@npm:^2.13.0, is-core-module@npm:^2.13.1, is-core-module@npm:^2.5.0":
+"is-core-module@npm:^2.13.0, is-core-module@npm:^2.15.1, is-core-module@npm:^2.5.0":
version: 2.15.1
resolution: "is-core-module@npm:2.15.1"
dependencies:
@@ -10061,7 +10070,7 @@ __metadata:
languageName: node
linkType: hard
-"object.fromentries@npm:^2.0.7, object.fromentries@npm:^2.0.8":
+"object.fromentries@npm:^2.0.8":
version: 2.0.8
resolution: "object.fromentries@npm:2.0.8"
dependencies:
@@ -10073,7 +10082,7 @@ __metadata:
languageName: node
linkType: hard
-"object.groupby@npm:^1.0.1":
+"object.groupby@npm:^1.0.3":
version: 1.0.3
resolution: "object.groupby@npm:1.0.3"
dependencies:
@@ -10084,7 +10093,7 @@ __metadata:
languageName: node
linkType: hard
-"object.values@npm:^1.1.6, object.values@npm:^1.1.7, object.values@npm:^1.2.0":
+"object.values@npm:^1.1.6, object.values@npm:^1.2.0":
version: 1.2.0
resolution: "object.values@npm:1.2.0"
dependencies:
@@ -10872,8 +10881,8 @@ __metadata:
linkType: hard
"react-native-builder-bob@npm:^0.30.0":
- version: 0.30.0
- resolution: "react-native-builder-bob@npm:0.30.0"
+ version: 0.30.3
+ resolution: "react-native-builder-bob@npm:0.30.3"
dependencies:
"@babel/core": ^7.25.2
"@babel/plugin-transform-strict-mode": ^7.24.7
@@ -10899,7 +10908,7 @@ __metadata:
yargs: ^17.5.1
bin:
bob: bin/bob
- checksum: fe4092547308d946756f0c41b1cde970781d00e22d8f3ae235a3d0e3ab8e7c8dfcb2e3b313af593986d07c672058b071f9f7397284b548139d4b9dc81f1b7a7e
+ checksum: 32b2159559a08310656b6b2f5f591a6aeeb9595f0f2d0e8dff7602af6aa62f59ae7206b023789de0a08f231d747c9bcab19e3efc874fad124b38e40c61f1ec90
languageName: node
linkType: hard
@@ -10920,12 +10929,12 @@ __metadata:
linkType: hard
"react-native-safe-area-context@npm:^4.10.8":
- version: 4.10.9
- resolution: "react-native-safe-area-context@npm:4.10.9"
+ version: 4.12.0
+ resolution: "react-native-safe-area-context@npm:4.12.0"
peerDependencies:
react: "*"
react-native: "*"
- checksum: 150bf4fa7607e8de565cce0c45d321048a3c982f4c82cc2a49eb342def968559f538d4554c30c20fa8b2e6dc716c24846745b129dc25396e083d98c2a29962a2
+ checksum: 04a751afed448b31dc401f0e8ecf9cf3edc4fe77b5c16cb7bc2a70381c3a2ffa54f42a313a46ad7deec0aff74a3f5650cf49db0264ba4a6c4f6a1d69ecf489fd
languageName: node
linkType: hard