react-native-onekyc 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -0
- package/README.md +40 -0
- package/android/build.gradle +116 -0
- package/android/gradle.properties +8 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/java/com/onekyc/OnekycModule.kt +126 -0
- package/android/src/main/java/com/onekyc/OnekycPackage.kt +17 -0
- package/ios/Onekyc-Bridging-Header.h +2 -0
- package/ios/Onekyc.mm +14 -0
- package/ios/Onekyc.swift +8 -0
- package/lib/commonjs/index.js +28 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/module/index.js +23 -0
- package/lib/module/index.js.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +5 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/src/index.d.ts +5 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -0
- package/package.json +187 -0
- package/react-native-onekyc.podspec +41 -0
- package/src/index.tsx +33 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 wasifkhanzada
|
|
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,40 @@
|
|
|
1
|
+
# react-native-onekyc
|
|
2
|
+
|
|
3
|
+
One Stop Solution
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install react-native-onekyc
|
|
9
|
+
```
|
|
10
|
+
OR
|
|
11
|
+
```sh
|
|
12
|
+
yarn add react-native-onekyc
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
```js
|
|
19
|
+
import { OneKycSDK } from 'react-native-onekyc';
|
|
20
|
+
|
|
21
|
+
// ...
|
|
22
|
+
|
|
23
|
+
const init = await OneKycSDK.init();
|
|
24
|
+
|
|
25
|
+
const enroll = await OneKycSDK.enroll();
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
## Contributing
|
|
31
|
+
|
|
32
|
+
See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
|
|
33
|
+
|
|
34
|
+
## License
|
|
35
|
+
|
|
36
|
+
MIT
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
buildscript {
|
|
2
|
+
// Buildscript is evaluated before everything else so we can't use getExtOrDefault
|
|
3
|
+
def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["Onekyc_kotlinVersion"]
|
|
4
|
+
|
|
5
|
+
repositories {
|
|
6
|
+
google()
|
|
7
|
+
mavenCentral()
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
dependencies {
|
|
11
|
+
classpath "com.android.tools.build:gradle:7.2.1"
|
|
12
|
+
// noinspection DifferentKotlinGradleVersion
|
|
13
|
+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
def reactNativeArchitectures() {
|
|
18
|
+
def value = rootProject.getProperties().get("reactNativeArchitectures")
|
|
19
|
+
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
def isNewArchitectureEnabled() {
|
|
23
|
+
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
apply plugin: "com.android.library"
|
|
27
|
+
apply plugin: "kotlin-android"
|
|
28
|
+
|
|
29
|
+
if (isNewArchitectureEnabled()) {
|
|
30
|
+
apply plugin: "com.facebook.react"
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
def getExtOrDefault(name) {
|
|
34
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["Onekyc_" + name]
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
def getExtOrIntegerDefault(name) {
|
|
38
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["Onekyc_" + name]).toInteger()
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
def supportsNamespace() {
|
|
42
|
+
def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
|
|
43
|
+
def major = parsed[0].toInteger()
|
|
44
|
+
def minor = parsed[1].toInteger()
|
|
45
|
+
|
|
46
|
+
// Namespace support was added in 7.3.0
|
|
47
|
+
return (major == 7 && minor >= 3) || major >= 8
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
android {
|
|
51
|
+
if (supportsNamespace()) {
|
|
52
|
+
namespace "com.onekyc"
|
|
53
|
+
|
|
54
|
+
sourceSets {
|
|
55
|
+
main {
|
|
56
|
+
manifest.srcFile "src/main/AndroidManifestNew.xml"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
|
|
62
|
+
|
|
63
|
+
defaultConfig {
|
|
64
|
+
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
|
|
65
|
+
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
66
|
+
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
buildTypes {
|
|
70
|
+
release {
|
|
71
|
+
minifyEnabled false
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
lintOptions {
|
|
76
|
+
disable "GradleCompatible"
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
compileOptions {
|
|
80
|
+
sourceCompatibility JavaVersion.VERSION_1_8
|
|
81
|
+
targetCompatibility JavaVersion.VERSION_1_8
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
viewBinding {
|
|
85
|
+
enabled = true
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
repositories {
|
|
90
|
+
mavenCentral()
|
|
91
|
+
google()
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
rootProject.allprojects {
|
|
95
|
+
repositories {
|
|
96
|
+
maven {
|
|
97
|
+
url 'https://onekyc-369640065143.d.codeartifact.ap-southeast-1.amazonaws.com/maven/com.onekyc/'
|
|
98
|
+
credentials {
|
|
99
|
+
username = getExtOrDefault("artifactUser")
|
|
100
|
+
password = getExtOrDefault("artifactToken")
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
def kotlin_version = getExtOrDefault("kotlinVersion")
|
|
107
|
+
|
|
108
|
+
dependencies {
|
|
109
|
+
// For < 0.71, this will be from the local maven repo
|
|
110
|
+
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
|
|
111
|
+
//noinspection GradleDynamicVersion
|
|
112
|
+
implementation "com.facebook.react:react-native:+"
|
|
113
|
+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
114
|
+
implementation 'com.onekyc:sdk:0.0.9'
|
|
115
|
+
}
|
|
116
|
+
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
Onekyc_kotlinVersion=1.7.0
|
|
2
|
+
Onekyc_minSdkVersion=21
|
|
3
|
+
Onekyc_targetSdkVersion=31
|
|
4
|
+
Onekyc_compileSdkVersion=31
|
|
5
|
+
Onekyc_ndkversion=21.4.7075529
|
|
6
|
+
|
|
7
|
+
Onekyc_artifactUser=aws
|
|
8
|
+
Onekyc_artifactToken=eyJ2ZXIiOjEsImlzdSI6MTczMDM3NjMyMywiZW5jIjoiQTEyOEdDTSIsInRhZyI6Il9ZUEFBNG1rdGZlODVHb1BKM0JIOHciLCJleHAiOjE3MzA0MTk1MjMsImFsZyI6IkExMjhHQ01LVyIsIml2IjoiTlpCenZOSkthR0t4QnRFMCJ9.w2l7J-Wn23ivediKXtLawQ.FvMGAsaIMMgJ9v_n.vCcPCcvDc0pEUhIiAHx8PcT7oOo09xiHzo388yLeP0VfTXO2o9yw3kaLt-iNRp2qCzZjihm_lMzlxGxyKO64qwnXsSWv3qrZ6NwFNuEBF5lP1-gUlceoM6hlU5-72A-AwmyWRJ8d7ORAVYtXkKrdbElGzv_eXJBczaEBtywLL3f-KpccMwVqdkxv64Rlg8POlihddzHiZRHyor2w7-CiYsQDsVdVpXdphoHIC36glZl4JzGfiNuVhfeNsXDD7orN9VPZKOTVIHdUR8taIrBCr8mEk0iNi-TpyIc6vakCd3ApjDK_JrZ5KpI7uSRanTHprXrUxUDQVG7q02h6VvSmprzVgo4-L-EwcyiNVGebFPNdumSlRkksvyez0K7jXmP8BhL944hWWJvuJTFnEuSxdkh9w1YVPzLDSWxNL-78xH4NiC_2paMUBWAvXYAg4kd1HdDLMPDrW5RECO6Rpwv9d4Lvhnf3FlF6f3frFmmwCv9RrGXVhSbx7PMc16d-iNMAaRKYGTBwfzBEOBGXD8QdLSUCuxKB6iVSvOKCAKg6VWjAasc0lsYeFRR06CSRuYf21GHZ6XlSdPUEHYkCAGs583wNbERBiGQMg7XPNTtXE3KpM3V47FtQjbFjnlxTlAQotE-l5aFZAxKOFVHd2ERMLO_C35gRkn1BNtUQgzcSZnE4YF-KsQGgWweyPXRCH1h3F428TxqvsfPSlHsTvYIbpfkbkvavGX5XrIuz17jTiFZxF_FakuvYYg6e2U5Aek0t4IqW2PyNutZtPm0bifCodUJ2L5zjmRjW7nI7kC8RS2D2uz35sgITrJMsTURZziK7fb32XO9Sy4MLaK6bGX1Jt0Vgn55mn_TWjMrH2EuPk-ouOsRB8G0WMGmZamkidEBKW0R0fXzr6ErxLDGqBiSignKAvNHIVVCxVSZe-_Fdn5zkTBtArREkcmsx0Ch83uPXDVmPyGsRk_krMHjOSqixDBc005-lWIzeuQ.kL7c7Mip6ni6exebjSeB6Q
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
package com.onekyc
|
|
2
|
+
|
|
3
|
+
import android.app.Activity
|
|
4
|
+
import android.content.Intent
|
|
5
|
+
import android.util.Log
|
|
6
|
+
import com.facebook.react.bridge.ActivityEventListener
|
|
7
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
8
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
9
|
+
import com.facebook.react.bridge.ReactMethod
|
|
10
|
+
import com.facebook.react.bridge.Promise
|
|
11
|
+
import org.json.JSONObject
|
|
12
|
+
|
|
13
|
+
class OnekycModule(reactContext: ReactApplicationContext) :
|
|
14
|
+
ReactContextBaseJavaModule(reactContext), ActivityEventListener {
|
|
15
|
+
|
|
16
|
+
private var enrollmentPromise: Promise? = null
|
|
17
|
+
|
|
18
|
+
init {
|
|
19
|
+
reactContext.addActivityEventListener(this)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
override fun getName(): String {
|
|
23
|
+
return NAME
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@ReactMethod
|
|
27
|
+
fun init(promise: Promise) {
|
|
28
|
+
val activity: Activity? = currentActivity
|
|
29
|
+
if (activity != null) {
|
|
30
|
+
try {
|
|
31
|
+
// Initialize the OneKycSdk
|
|
32
|
+
OneKycSdk.initialize(activity)
|
|
33
|
+
promise.resolve("SDK initialized successfully")
|
|
34
|
+
} catch (e: Exception) {
|
|
35
|
+
sendError(promise, "INITIALIZATION_ERROR", "${e.message}", "")
|
|
36
|
+
}
|
|
37
|
+
} else {
|
|
38
|
+
sendError(promise, "INITIALIZATION_ERROR", "Activity is null, cannot initialize SDK.", "")
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@ReactMethod
|
|
43
|
+
fun enroll(enrollmentConfig: String, promise: Promise) {
|
|
44
|
+
val activity: Activity? = currentActivity
|
|
45
|
+
if (activity != null && enrollmentConfig.isNotEmpty()) {
|
|
46
|
+
try {
|
|
47
|
+
OneKycSdk.startEnrollment(activity, enrollmentConfig)
|
|
48
|
+
this.enrollmentPromise = promise
|
|
49
|
+
} catch (e: Exception) {
|
|
50
|
+
sendError(promise, "Error", "Failed to start enrollment: ${e.message}", "")
|
|
51
|
+
}
|
|
52
|
+
} else {
|
|
53
|
+
sendError(promise, "Error", "Activity or Config is null, cannot start enrollment", "")
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
private fun sendError(promise: Promise, code: String, message: String, task: String) {
|
|
58
|
+
sendError(promise, code, message, task, null.toString())
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
private fun sendError(
|
|
62
|
+
promise: Promise,
|
|
63
|
+
code: String,
|
|
64
|
+
message: String,
|
|
65
|
+
task: String,
|
|
66
|
+
data: String
|
|
67
|
+
) {
|
|
68
|
+
val error = JSONObject()
|
|
69
|
+
try {
|
|
70
|
+
error.put("code", code)
|
|
71
|
+
error.put("message", message)
|
|
72
|
+
error.put("task", task)
|
|
73
|
+
error.put("data", data)
|
|
74
|
+
} catch (e: Exception) {
|
|
75
|
+
e.printStackTrace()
|
|
76
|
+
}
|
|
77
|
+
promise.reject(error.toString())
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Handle activity result here
|
|
81
|
+
override fun onActivityResult(activity: Activity?, requestCode: Int, resultCode: Int, data: Intent?) {
|
|
82
|
+
Log.d("onActivityResult requestCode", requestCode.toString())
|
|
83
|
+
Log.d("onActivityResult resultCode", resultCode.toString())
|
|
84
|
+
Log.d("onActivityResult data RESULT_DATA_KEY", data?.getStringExtra("RESULT_DATA_KEY").toString())
|
|
85
|
+
if (requestCode == OneKycSdk.ENROLL_REQUEST_CODE) {
|
|
86
|
+
if (resultCode == Activity.RESULT_OK) {
|
|
87
|
+
val resultData = data?.getStringExtra(OneKycSdk.ENROLLMENT_RESULT) ?: "No Data Received"
|
|
88
|
+
enrollmentPromise?.resolve(resultData) // Resolve the promise with the result data
|
|
89
|
+
} else {
|
|
90
|
+
val resultData: String
|
|
91
|
+
val intent = data ?: return // Safely handle the case where data is null
|
|
92
|
+
|
|
93
|
+
when {
|
|
94
|
+
intent.hasExtra(OneKycSdk.ENROLLMENT_ERROR) -> {
|
|
95
|
+
resultData = intent.getStringExtra(OneKycSdk.ENROLLMENT_ERROR) ?: "No Error Data Received"
|
|
96
|
+
enrollmentPromise?.let { sendError(it, "Error", resultData, "") }
|
|
97
|
+
}
|
|
98
|
+
intent.hasExtra(OneKycSdk.ENROLLMENT_CANCELED) -> {
|
|
99
|
+
resultData = intent.getStringExtra(OneKycSdk.ENROLLMENT_CANCELED) ?: "No Cancel Data Received"
|
|
100
|
+
enrollmentPromise?.let { sendError(it, "Canceled", resultData, "") }
|
|
101
|
+
}
|
|
102
|
+
else -> {
|
|
103
|
+
resultData = "Unknown Error or Action"
|
|
104
|
+
enrollmentPromise?.let { sendError(it, "Unknown Error", resultData, "") }
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
enrollmentPromise = null // Clear the promise after handling
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Handle new intent if necessary
|
|
113
|
+
override fun onNewIntent(intent: Intent?) {
|
|
114
|
+
// Handle new intent if your module needs to
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
private fun parseConfig(configuration: String): String {
|
|
118
|
+
// Example of parsing the configuration from JSON, modify as per your requirement
|
|
119
|
+
return configuration
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
companion object {
|
|
124
|
+
const val NAME = "Onekyc"
|
|
125
|
+
}
|
|
126
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
package com.onekyc
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.ReactPackage
|
|
4
|
+
import com.facebook.react.bridge.NativeModule
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
+
import com.facebook.react.uimanager.ViewManager
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class OnekycPackage : ReactPackage {
|
|
10
|
+
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
|
|
11
|
+
return listOf(OnekycModule(reactContext))
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
|
|
15
|
+
return emptyList()
|
|
16
|
+
}
|
|
17
|
+
}
|
package/ios/Onekyc.mm
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#import <React/RCTBridgeModule.h>
|
|
2
|
+
|
|
3
|
+
@interface RCT_EXTERN_MODULE(Onekyc, NSObject)
|
|
4
|
+
|
|
5
|
+
RCT_EXTERN_METHOD(multiply:(float)a withB:(float)b
|
|
6
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
7
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
8
|
+
|
|
9
|
+
+ (BOOL)requiresMainQueueSetup
|
|
10
|
+
{
|
|
11
|
+
return NO;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
@end
|
package/ios/Onekyc.swift
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.OneKycSDK = void 0;
|
|
7
|
+
var _reactNative = require("react-native");
|
|
8
|
+
const LINKING_ERROR = `The package 'react-native-onekyc' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
|
|
9
|
+
ios: "- You have run 'pod install'\n",
|
|
10
|
+
default: ''
|
|
11
|
+
}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
|
|
12
|
+
const Onekyc = _reactNative.NativeModules.Onekyc ? _reactNative.NativeModules.Onekyc : new Proxy({}, {
|
|
13
|
+
get() {
|
|
14
|
+
throw new Error(LINKING_ERROR);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
class OneKycSDK {
|
|
18
|
+
async init() {
|
|
19
|
+
const result = await Onekyc.init();
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
22
|
+
async enroll(enrollmentConfiguration) {
|
|
23
|
+
const result = await Onekyc.enroll(JSON.stringify(enrollmentConfiguration));
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.OneKycSDK = OneKycSDK;
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNative","require","LINKING_ERROR","Platform","select","ios","default","Onekyc","NativeModules","Proxy","get","Error","OneKycSDK","init","result","enroll","enrollmentConfiguration","JSON","stringify","exports"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEA,MAAMC,aAAa,GACjB,8EAA8E,GAC9EC,qBAAQ,CAACC,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMC,MAAM,GAAGC,0BAAa,CAACD,MAAM,GAC/BC,0BAAa,CAACD,MAAM,GACpB,IAAIE,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACT,aAAa,CAAC;EAChC;AACF,CACF,CAAC;AAGE,MAAMU,SAAS,CAAC;EAErB,MAAMC,IAAIA,CAAA,EAAG;IACX,MAAMC,MAAM,GAAG,MAAMP,MAAM,CAACM,IAAI,CAAC,CAAC;IAClC,OAAOC,MAAM;EACf;EAEA,MAAMC,MAAMA,CAACC,uBAA4B,EAAE;IACvC,MAAMF,MAAM,GAAG,MAAMP,MAAM,CAACQ,MAAM,CAACE,IAAI,CAACC,SAAS,CAACF,uBAAuB,CAAC,CAAC;IAC3E,OAAOF,MAAM;EACjB;AAEF;AAACK,OAAA,CAAAP,SAAA,GAAAA,SAAA","ignoreList":[]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { NativeModules, Platform } from 'react-native';
|
|
4
|
+
const LINKING_ERROR = `The package 'react-native-onekyc' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
|
|
5
|
+
ios: "- You have run 'pod install'\n",
|
|
6
|
+
default: ''
|
|
7
|
+
}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
|
|
8
|
+
const Onekyc = NativeModules.Onekyc ? NativeModules.Onekyc : new Proxy({}, {
|
|
9
|
+
get() {
|
|
10
|
+
throw new Error(LINKING_ERROR);
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
export class OneKycSDK {
|
|
14
|
+
async init() {
|
|
15
|
+
const result = await Onekyc.init();
|
|
16
|
+
return result;
|
|
17
|
+
}
|
|
18
|
+
async enroll(enrollmentConfiguration) {
|
|
19
|
+
const result = await Onekyc.enroll(JSON.stringify(enrollmentConfiguration));
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["NativeModules","Platform","LINKING_ERROR","select","ios","default","Onekyc","Proxy","get","Error","OneKycSDK","init","result","enroll","enrollmentConfiguration","JSON","stringify"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AAEtD,MAAMC,aAAa,GACjB,8EAA8E,GAC9ED,QAAQ,CAACE,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMC,MAAM,GAAGN,aAAa,CAACM,MAAM,GAC/BN,aAAa,CAACM,MAAM,GACpB,IAAIC,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACP,aAAa,CAAC;EAChC;AACF,CACF,CAAC;AAGL,OAAO,MAAMQ,SAAS,CAAC;EAErB,MAAMC,IAAIA,CAAA,EAAG;IACX,MAAMC,MAAM,GAAG,MAAMN,MAAM,CAACK,IAAI,CAAC,CAAC;IAClC,OAAOC,MAAM;EACf;EAEA,MAAMC,MAAMA,CAACC,uBAA4B,EAAE;IACvC,MAAMF,MAAM,GAAG,MAAMN,MAAM,CAACO,MAAM,CAACE,IAAI,CAACC,SAAS,CAACF,uBAAuB,CAAC,CAAC;IAC3E,OAAOF,MAAM;EACjB;AAEF","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AAoBA,qBAAa,SAAS;IAEd,IAAI;IAKJ,MAAM,CAAC,uBAAuB,EAAE,GAAG;CAK1C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AAoBA,qBAAa,SAAS;IAEd,IAAI;IAKJ,MAAM,CAAC,uBAAuB,EAAE,GAAG;CAK1C"}
|
package/package.json
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "react-native-onekyc",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "One Stop Solution",
|
|
5
|
+
"source": "./src/index.tsx",
|
|
6
|
+
"main": "./lib/commonjs/index.js",
|
|
7
|
+
"module": "./lib/module/index.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": {
|
|
11
|
+
"types": "./lib/typescript/module/src/index.d.ts",
|
|
12
|
+
"default": "./lib/module/index.js"
|
|
13
|
+
},
|
|
14
|
+
"require": {
|
|
15
|
+
"types": "./lib/typescript/commonjs/src/index.d.ts",
|
|
16
|
+
"default": "./lib/commonjs/index.js"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"src",
|
|
22
|
+
"lib",
|
|
23
|
+
"android",
|
|
24
|
+
"ios",
|
|
25
|
+
"cpp",
|
|
26
|
+
"*.podspec",
|
|
27
|
+
"!ios/build",
|
|
28
|
+
"!android/build",
|
|
29
|
+
"!android/gradle",
|
|
30
|
+
"!android/gradlew",
|
|
31
|
+
"!android/gradlew.bat",
|
|
32
|
+
"!android/local.properties",
|
|
33
|
+
"!**/__tests__",
|
|
34
|
+
"!**/__fixtures__",
|
|
35
|
+
"!**/__mocks__",
|
|
36
|
+
"!**/.*"
|
|
37
|
+
],
|
|
38
|
+
"scripts": {
|
|
39
|
+
"example": "yarn workspace react-native-onekyc-example",
|
|
40
|
+
"test": "jest",
|
|
41
|
+
"typecheck": "tsc",
|
|
42
|
+
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
43
|
+
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
|
|
44
|
+
"prepare": "bob build",
|
|
45
|
+
"release": "release-it"
|
|
46
|
+
},
|
|
47
|
+
"keywords": [
|
|
48
|
+
"react-native",
|
|
49
|
+
"ios",
|
|
50
|
+
"android"
|
|
51
|
+
],
|
|
52
|
+
"repository": {
|
|
53
|
+
"type": "git",
|
|
54
|
+
"url": "git+https://github.com/wasifkhanzada/react-native-onekyc.git"
|
|
55
|
+
},
|
|
56
|
+
"author": "wasifkhanzada <wasifkhanzada309.wk@gmail.com> (https://github.com/wasifkhanzada)",
|
|
57
|
+
"license": "MIT",
|
|
58
|
+
"bugs": {
|
|
59
|
+
"url": "https://github.com/wasifkhanzada/react-native-onekyc/issues"
|
|
60
|
+
},
|
|
61
|
+
"homepage": "https://github.com/wasifkhanzada/react-native-onekyc#readme",
|
|
62
|
+
"publishConfig": {
|
|
63
|
+
"registry": "https://registry.npmjs.org/"
|
|
64
|
+
},
|
|
65
|
+
"devDependencies": {
|
|
66
|
+
"@commitlint/config-conventional": "^17.0.2",
|
|
67
|
+
"@evilmartians/lefthook": "^1.5.0",
|
|
68
|
+
"@react-native/eslint-config": "^0.73.1",
|
|
69
|
+
"@release-it/conventional-changelog": "^5.0.0",
|
|
70
|
+
"@types/jest": "^29.5.5",
|
|
71
|
+
"@types/react": "^18.2.44",
|
|
72
|
+
"commitlint": "^17.0.2",
|
|
73
|
+
"del-cli": "^5.1.0",
|
|
74
|
+
"eslint": "^8.51.0",
|
|
75
|
+
"eslint-config-prettier": "^9.0.0",
|
|
76
|
+
"eslint-plugin-prettier": "^5.0.1",
|
|
77
|
+
"jest": "^29.7.0",
|
|
78
|
+
"prettier": "^3.0.3",
|
|
79
|
+
"react": "18.3.1",
|
|
80
|
+
"react-native": "0.75.2",
|
|
81
|
+
"react-native-builder-bob": "^0.30.0",
|
|
82
|
+
"release-it": "^15.0.0",
|
|
83
|
+
"turbo": "^1.10.7",
|
|
84
|
+
"typescript": "^5.2.2"
|
|
85
|
+
},
|
|
86
|
+
"resolutions": {
|
|
87
|
+
"@types/react": "^18.2.44"
|
|
88
|
+
},
|
|
89
|
+
"peerDependencies": {
|
|
90
|
+
"react": "*",
|
|
91
|
+
"react-native": "*"
|
|
92
|
+
},
|
|
93
|
+
"workspaces": [
|
|
94
|
+
"example"
|
|
95
|
+
],
|
|
96
|
+
"packageManager": "yarn@3.6.1",
|
|
97
|
+
"jest": {
|
|
98
|
+
"preset": "react-native",
|
|
99
|
+
"modulePathIgnorePatterns": [
|
|
100
|
+
"<rootDir>/example/node_modules",
|
|
101
|
+
"<rootDir>/lib/"
|
|
102
|
+
]
|
|
103
|
+
},
|
|
104
|
+
"commitlint": {
|
|
105
|
+
"extends": [
|
|
106
|
+
"@commitlint/config-conventional"
|
|
107
|
+
]
|
|
108
|
+
},
|
|
109
|
+
"release-it": {
|
|
110
|
+
"git": {
|
|
111
|
+
"commitMessage": "chore: release ${version}",
|
|
112
|
+
"tagName": "v${version}"
|
|
113
|
+
},
|
|
114
|
+
"npm": {
|
|
115
|
+
"publish": true
|
|
116
|
+
},
|
|
117
|
+
"github": {
|
|
118
|
+
"release": true
|
|
119
|
+
},
|
|
120
|
+
"plugins": {
|
|
121
|
+
"@release-it/conventional-changelog": {
|
|
122
|
+
"preset": "angular"
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
"eslintConfig": {
|
|
127
|
+
"root": true,
|
|
128
|
+
"extends": [
|
|
129
|
+
"@react-native",
|
|
130
|
+
"prettier"
|
|
131
|
+
],
|
|
132
|
+
"rules": {
|
|
133
|
+
"react/react-in-jsx-scope": "off",
|
|
134
|
+
"prettier/prettier": [
|
|
135
|
+
"error",
|
|
136
|
+
{
|
|
137
|
+
"quoteProps": "consistent",
|
|
138
|
+
"singleQuote": true,
|
|
139
|
+
"tabWidth": 2,
|
|
140
|
+
"trailingComma": "es5",
|
|
141
|
+
"useTabs": false
|
|
142
|
+
}
|
|
143
|
+
]
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
"eslintIgnore": [
|
|
147
|
+
"node_modules/",
|
|
148
|
+
"lib/"
|
|
149
|
+
],
|
|
150
|
+
"prettier": {
|
|
151
|
+
"quoteProps": "consistent",
|
|
152
|
+
"singleQuote": true,
|
|
153
|
+
"tabWidth": 2,
|
|
154
|
+
"trailingComma": "es5",
|
|
155
|
+
"useTabs": false
|
|
156
|
+
},
|
|
157
|
+
"react-native-builder-bob": {
|
|
158
|
+
"source": "src",
|
|
159
|
+
"output": "lib",
|
|
160
|
+
"targets": [
|
|
161
|
+
[
|
|
162
|
+
"commonjs",
|
|
163
|
+
{
|
|
164
|
+
"esm": true
|
|
165
|
+
}
|
|
166
|
+
],
|
|
167
|
+
[
|
|
168
|
+
"module",
|
|
169
|
+
{
|
|
170
|
+
"esm": true
|
|
171
|
+
}
|
|
172
|
+
],
|
|
173
|
+
[
|
|
174
|
+
"typescript",
|
|
175
|
+
{
|
|
176
|
+
"project": "tsconfig.build.json",
|
|
177
|
+
"esm": true
|
|
178
|
+
}
|
|
179
|
+
]
|
|
180
|
+
]
|
|
181
|
+
},
|
|
182
|
+
"create-react-native-library": {
|
|
183
|
+
"type": "module-legacy",
|
|
184
|
+
"languages": "kotlin-swift",
|
|
185
|
+
"version": "0.41.0"
|
|
186
|
+
}
|
|
187
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
|
+
folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
|
|
5
|
+
|
|
6
|
+
Pod::Spec.new do |s|
|
|
7
|
+
s.name = "react-native-onekyc"
|
|
8
|
+
s.version = package["version"]
|
|
9
|
+
s.summary = package["description"]
|
|
10
|
+
s.homepage = package["homepage"]
|
|
11
|
+
s.license = package["license"]
|
|
12
|
+
s.authors = package["author"]
|
|
13
|
+
|
|
14
|
+
s.platforms = { :ios => min_ios_version_supported }
|
|
15
|
+
s.source = { :git => "https://github.com/wasifkhanzada/react-native-onekyc.git", :tag => "#{s.version}" }
|
|
16
|
+
|
|
17
|
+
s.source_files = "ios/**/*.{h,m,mm,swift}"
|
|
18
|
+
|
|
19
|
+
# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
|
|
20
|
+
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
|
|
21
|
+
if respond_to?(:install_modules_dependencies, true)
|
|
22
|
+
install_modules_dependencies(s)
|
|
23
|
+
else
|
|
24
|
+
s.dependency "React-Core"
|
|
25
|
+
|
|
26
|
+
# Don't install the dependencies when we run `pod install` in the old architecture.
|
|
27
|
+
if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
|
|
28
|
+
s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
|
|
29
|
+
s.pod_target_xcconfig = {
|
|
30
|
+
"HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
|
|
31
|
+
"OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
|
|
32
|
+
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
|
|
33
|
+
}
|
|
34
|
+
s.dependency "React-Codegen"
|
|
35
|
+
s.dependency "RCT-Folly"
|
|
36
|
+
s.dependency "RCTRequired"
|
|
37
|
+
s.dependency "RCTTypeSafety"
|
|
38
|
+
s.dependency "ReactCommon/turbomodule/core"
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { NativeModules, Platform } from 'react-native';
|
|
2
|
+
|
|
3
|
+
const LINKING_ERROR =
|
|
4
|
+
`The package 'react-native-onekyc' doesn't seem to be linked. Make sure: \n\n` +
|
|
5
|
+
Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
|
|
6
|
+
'- You rebuilt the app after installing the package\n' +
|
|
7
|
+
'- You are not using Expo Go\n';
|
|
8
|
+
|
|
9
|
+
const Onekyc = NativeModules.Onekyc
|
|
10
|
+
? NativeModules.Onekyc
|
|
11
|
+
: new Proxy(
|
|
12
|
+
{},
|
|
13
|
+
{
|
|
14
|
+
get() {
|
|
15
|
+
throw new Error(LINKING_ERROR);
|
|
16
|
+
},
|
|
17
|
+
}
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
export class OneKycSDK {
|
|
22
|
+
|
|
23
|
+
async init() {
|
|
24
|
+
const result = await Onekyc.init();
|
|
25
|
+
return result
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async enroll(enrollmentConfiguration: any) {
|
|
29
|
+
const result = await Onekyc.enroll(JSON.stringify(enrollmentConfiguration));
|
|
30
|
+
return result;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
}
|