react-native-mfa-trustbuilder 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +202 -0
  3. package/Trustbuilder.podspec +29 -0
  4. package/android/build.gradle +74 -0
  5. package/android/libs/iwlib-mac-0.2.17.jar +0 -0
  6. package/android/proguard-rules.pro +2 -0
  7. package/android/src/main/AndroidManifest.xml +2 -0
  8. package/android/src/main/java/com/trustbuilder/SimpleWebServiceCall.kt +40 -0
  9. package/android/src/main/java/com/trustbuilder/TrustbuilderModule.kt +590 -0
  10. package/android/src/main/java/com/trustbuilder/TrustbuilderPackage.kt +32 -0
  11. package/ios/RNTrustbuilder.h +5 -0
  12. package/ios/RNTrustbuilder.mm +433 -0
  13. package/ios/iw.h +785 -0
  14. package/ios/libs/libmaccess-0.2.19-ios-arm64_armv7.a +0 -0
  15. package/ios/libs/libmaccess-0.2.19-ios-arm64_i386_x86_64-simulator.a +0 -0
  16. package/lib/module/NativeRNTrustbuilder.js +5 -0
  17. package/lib/module/NativeRNTrustbuilder.js.map +1 -0
  18. package/lib/module/errors.js +64 -0
  19. package/lib/module/errors.js.map +1 -0
  20. package/lib/module/index.js +309 -0
  21. package/lib/module/index.js.map +1 -0
  22. package/lib/module/package.json +1 -0
  23. package/lib/module/types.js +2 -0
  24. package/lib/module/types.js.map +1 -0
  25. package/lib/typescript/package.json +1 -0
  26. package/lib/typescript/src/NativeRNTrustbuilder.d.ts +89 -0
  27. package/lib/typescript/src/NativeRNTrustbuilder.d.ts.map +1 -0
  28. package/lib/typescript/src/errors.d.ts +29 -0
  29. package/lib/typescript/src/errors.d.ts.map +1 -0
  30. package/lib/typescript/src/index.d.ts +68 -0
  31. package/lib/typescript/src/index.d.ts.map +1 -0
  32. package/lib/typescript/src/types.d.ts +45 -0
  33. package/lib/typescript/src/types.d.ts.map +1 -0
  34. package/package.json +184 -0
  35. package/src/NativeRNTrustbuilder.ts +117 -0
  36. package/src/errors.ts +72 -0
  37. package/src/index.ts +461 -0
  38. package/src/types.ts +54 -0
package/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 skanderhk
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,202 @@
1
+ # react-native-mfa-trustbuilder
2
+
3
+ Trustbuilder MFA SDK for React Native. Provides multi-factor authentication capabilities including activation, OTP generation, biometric authentication, push notifications, and transaction sealing.
4
+
5
+ ## Installation
6
+
7
+ ```sh
8
+ npm install react-native-mfa-trustbuilder
9
+ ```
10
+
11
+ ### iOS
12
+
13
+ ```sh
14
+ cd ios && pod install
15
+ ```
16
+
17
+ ### Android
18
+
19
+ No additional steps required.
20
+
21
+ ## Usage
22
+
23
+ ```ts
24
+ import { trustbuilder, TrustbuilderError } from 'react-native-mfa-trustbuilder';
25
+
26
+ // Initialize (call once at app startup)
27
+ const result = trustbuilder.initialize({
28
+ macId: 'your_maccess_id',
29
+ server: 'https://www.myinwebo.com',
30
+ hostVersion: 'my-app-1.0.0',
31
+ });
32
+
33
+ // Restore saved state
34
+ const storedData = trustbuilder.getStorageData();
35
+ if (storedData) {
36
+ trustbuilder.setStorageData(storedData);
37
+ }
38
+
39
+ // Check activation status
40
+ if (trustbuilder.isActivated()) {
41
+ // Generate online OTP
42
+ const { otp, remainingTime } = await trustbuilder.generateOnlineOtp('1234');
43
+ }
44
+ ```
45
+
46
+ ## API Reference
47
+
48
+ ### Initialization
49
+
50
+ #### `initialize(config: InitConfig): InitResult`
51
+
52
+ Initialize the Trustbuilder SDK.
53
+
54
+ ```ts
55
+ trustbuilder.initialize({
56
+ macId: 'your_maccess_id', // Required
57
+ server: 'https://www.myinwebo.com', // Default
58
+ hostVersion: 'my-app-1.0.0', // Default: 'react-native-mfa-trustbuilder-0.1.0'
59
+ timeout: 60000, // Default: 60000ms
60
+ lang: 'en', // 'en' | 'fr', Default: 'en'
61
+ });
62
+ ```
63
+
64
+ ### Activation
65
+
66
+ #### `activationStart(code: string): Promise<void>`
67
+
68
+ Start the device activation process.
69
+
70
+ #### `activationFinalize(code: string, pin: string, name: string): Promise<void>`
71
+
72
+ Finalize device activation.
73
+
74
+ #### `activate(code: string, pin: string, name: string): Promise<void>`
75
+
76
+ Convenience method that calls both start and finalize.
77
+
78
+ ### Unlock / Reset
79
+
80
+ #### `reset(code: string, pin: string): Promise<void>`
81
+
82
+ Unlock a blocked device with an unlock code.
83
+
84
+ ### Synchronization
85
+
86
+ #### `synchronize(pin: string): Promise<void>`
87
+
88
+ Synchronize device state with Trustbuilder servers.
89
+
90
+ ### PIN Management
91
+
92
+ #### `updatePin(newPin: string, currentPin: string): Promise<void>`
93
+
94
+ Update the user's PIN code.
95
+
96
+ ### Biometrics
97
+
98
+ #### `registerBiokey(biokey: string, pin: string): Promise<void>`
99
+
100
+ Register a biometric key.
101
+
102
+ #### `resetBiokeys(pin: string): Promise<void>`
103
+
104
+ Reset all registered biometric keys.
105
+
106
+ ### OTP Generation
107
+
108
+ #### `generateOnlineOtp(pin: string, serviceIndex?: number, keyType?: KeyType): Promise<OtpResult>`
109
+
110
+ Generate an OTP via server call.
111
+
112
+ #### `generateOfflineOtp(pin: string, serviceId?: number): Promise<OtpResult>`
113
+
114
+ Generate an OTP locally without network.
115
+
116
+ ### Push Notifications
117
+
118
+ #### `registerForPush(pushId: string): Promise<void>`
119
+
120
+ Register device for push notifications.
121
+
122
+ #### `getPushInfo(): PushInfo | null`
123
+
124
+ Check for pending push notification.
125
+
126
+ #### `onPushReceived(listener: (pushInfo: PushInfo) => void): () => void`
127
+
128
+ Subscribe to push notification events.
129
+
130
+ ### Sealing
131
+
132
+ #### `generateOnlineSeal(pin: string, sealData: string, serviceIndex?: number, keyType?: KeyType): Promise<SealResult>`
133
+
134
+ Generate an online seal.
135
+
136
+ #### `generateOfflineSeal(pin: string, sealData: string, serviceId?: number): Promise<SealResult>`
137
+
138
+ Generate an offline seal.
139
+
140
+ ### Utility
141
+
142
+ #### `isActivated(): boolean`
143
+
144
+ Check if device is activated.
145
+
146
+ #### `isBlocked(): boolean`
147
+
148
+ Check if device is blocked.
149
+
150
+ #### `getServiceInfo(index?: number): ServiceInfo`
151
+
152
+ Get service information.
153
+
154
+ #### `getVersionInfo(): VersionInfo`
155
+
156
+ Get SDK version information.
157
+
158
+ #### `saveStorageIfNeeded(): void`
159
+
160
+ Save internal state if it has changed. Call after each operation.
161
+
162
+ ## Error Handling
163
+
164
+ All methods throw `TrustbuilderError` on failure:
165
+
166
+ ```ts
167
+ try {
168
+ await trustbuilder.generateOnlineOtp('1234');
169
+ } catch (error) {
170
+ if (error instanceof TrustbuilderError) {
171
+ console.log(error.code); // Numeric error code
172
+ console.log(error.codeName); // e.g., 'NETWORK', 'CODE', 'ACCESS'
173
+ console.log(error.message); // Human-readable message
174
+ }
175
+ }
176
+ ```
177
+
178
+ ### Error Codes
179
+
180
+ | Code | Name | Description |
181
+ | ---- | -------------- | ---------------------------------- |
182
+ | 0 | OK | No error |
183
+ | 1 | NETWORK | Network or server unreachable |
184
+ | 2 | CODE | Activation code is incorrect |
185
+ | 3 | SN | Syntax error |
186
+ | 4 | ACCESS | Access refused |
187
+ | 5 | VERSION | Version error |
188
+ | 7 | BLOCKED | Account is blocked |
189
+ | 14 | FORBIDDEN | Forbidden operation |
190
+ | 15 | PINREFUSED | Bad PIN format |
191
+ | 16 | TIMEOUT | Timeout expired |
192
+ | 26 | BIOKEY | Device locked due to biokey errors |
193
+ | 27 | DESYNCHRONIZED | Device desynchronized |
194
+ | 999 | OTHER | Unknown error |
195
+
196
+ ## Contributing
197
+
198
+ See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
199
+
200
+ ## License
201
+
202
+ MIT
@@ -0,0 +1,29 @@
1
+ require "json"
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = "Trustbuilder"
7
+ s.version = package["version"]
8
+ s.summary = package["description"]
9
+ s.homepage = package["homepage"]
10
+ s.license = package["license"]
11
+ s.authors = package["author"]
12
+
13
+ s.platforms = { :ios => "13.4" }
14
+ s.source = { :git => "https://github.com/skanderhk/react-native-mfa-trustbuilder.git", :tag => "#{s.version}" }
15
+
16
+ s.source_files = "ios/**/*.{h,m,mm,swift,cpp}"
17
+ s.private_header_files = "ios/**/*.h"
18
+
19
+ s.vendored_libraries = "ios/libs/*.a"
20
+
21
+ s.preserve_paths = "ios/iw.h"
22
+
23
+ s.pod_target_xcconfig = {
24
+ "HEADER_SEARCH_PATHS" => '"$(PODS_TARGET_SRCROOT)/ios"',
25
+ "OTHER_LDFLAGS" => "-lsqlite3 -lz",
26
+ }
27
+
28
+ install_modules_dependencies(s)
29
+ end
@@ -0,0 +1,74 @@
1
+ buildscript {
2
+ ext.Trustbuilder = [
3
+ kotlinVersion: "2.0.21",
4
+ minSdkVersion: 24,
5
+ compileSdkVersion: 36,
6
+ targetSdkVersion: 36
7
+ ]
8
+
9
+ ext.getExtOrDefault = { prop ->
10
+ if (rootProject.ext.has(prop)) {
11
+ return rootProject.ext.get(prop)
12
+ }
13
+
14
+ return Trustbuilder[prop]
15
+ }
16
+
17
+ repositories {
18
+ google()
19
+ mavenCentral()
20
+ }
21
+
22
+ dependencies {
23
+ classpath "com.android.tools.build:gradle:8.7.2"
24
+ // noinspection DifferentKotlinGradleVersion
25
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}"
26
+ }
27
+ }
28
+
29
+
30
+ apply plugin: "com.android.library"
31
+ apply plugin: "kotlin-android"
32
+
33
+ apply plugin: "com.facebook.react"
34
+
35
+ android {
36
+ namespace "com.trustbuilder"
37
+
38
+ compileSdkVersion getExtOrDefault("compileSdkVersion")
39
+
40
+ defaultConfig {
41
+ minSdkVersion getExtOrDefault("minSdkVersion")
42
+ targetSdkVersion getExtOrDefault("targetSdkVersion")
43
+ }
44
+
45
+ buildFeatures {
46
+ buildConfig true
47
+ }
48
+
49
+ buildTypes {
50
+ release {
51
+ minifyEnabled false
52
+ }
53
+ debug {
54
+ minifyEnabled false
55
+ }
56
+ }
57
+
58
+ lint {
59
+ disable "GradleCompatible"
60
+ }
61
+
62
+ compileOptions {
63
+ sourceCompatibility JavaVersion.VERSION_1_8
64
+ targetCompatibility JavaVersion.VERSION_1_8
65
+ }
66
+ }
67
+
68
+ dependencies {
69
+ implementation "com.facebook.react:react-android"
70
+ implementation files('libs/iwlib-mac-0.2.17.jar')
71
+
72
+ implementation "androidx.security:security-crypto:1.1.0-alpha06"
73
+ implementation "androidx.preference:preference-ktx:1.2.1"
74
+ }
@@ -0,0 +1,2 @@
1
+ -keep class com.inwebo.iwlib.** { *; }
2
+ -dontwarn com.inwebo.iwlib.**
@@ -0,0 +1,2 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+ </manifest>
@@ -0,0 +1,40 @@
1
+ package com.trustbuilder
2
+
3
+ import android.util.Log
4
+ import com.inwebo.iwlib.WebServiceCall
5
+ import java.io.BufferedReader
6
+ import java.io.InputStreamReader
7
+ import java.net.HttpURLConnection
8
+ import java.net.URL
9
+
10
+ class SimpleWebServiceCall : WebServiceCall {
11
+ companion object {
12
+ private const val TAG = "SimpleWebServiceCall"
13
+ }
14
+
15
+ override fun WebServiceCall(url: String?, timeout: Long): String? {
16
+ Log.d(TAG, "WebServiceCall: $url, timeout=$timeout")
17
+ return try {
18
+ val connection = URL(url).openConnection() as HttpURLConnection
19
+ connection.requestMethod = "GET"
20
+ connection.connectTimeout = timeout.toInt()
21
+ connection.readTimeout = timeout.toInt()
22
+
23
+ val responseCode = connection.responseCode
24
+ Log.d(TAG, "Response code: $responseCode")
25
+
26
+ if (responseCode == HttpURLConnection.HTTP_OK) {
27
+ val reader = BufferedReader(InputStreamReader(connection.inputStream))
28
+ val response = reader.use { it.readText() }
29
+ Log.d(TAG, "Response length: ${response.length}")
30
+ response
31
+ } else {
32
+ Log.e(TAG, "HTTP error: $responseCode")
33
+ ""
34
+ }
35
+ } catch (e: Exception) {
36
+ Log.e(TAG, "Network error: ${e.message}", e)
37
+ ""
38
+ }
39
+ }
40
+ }