dojah-kyc-sdk-react_native 0.0.1

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 ADDED
@@ -0,0 +1,20 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 shittu33
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,168 @@
1
+ # Dojah KYC SDK (React Native)
2
+
3
+
4
+ ## Installation
5
+
6
+ ```sh
7
+ npm install dojah-kyc-sdk-react_native
8
+ ```
9
+
10
+ ## Android Setup
11
+
12
+ ### Requirements
13
+ * Minimum Android SDK version - 21
14
+ * Supported targetSdkVersion - 35
15
+
16
+ In your android root/build.gradle file set maven path:
17
+ ```
18
+ ...
19
+ allprojects {
20
+ repositories {
21
+ ...
22
+ maven { url "https://jitpack.io" }
23
+ }
24
+ }
25
+ ```
26
+ Or Set maven path in your root/settings.gradle file:
27
+ ```
28
+ ...
29
+ dependencyResolutionManagement {
30
+ repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
31
+ repositories {
32
+ ...
33
+ maven { url "https://jitpack.io" }
34
+ }
35
+ }
36
+ ```
37
+
38
+ ### Permissions
39
+ For Android you don't need to declare permissions, its already included in the Package.
40
+
41
+ ## IOS Setup
42
+
43
+ ### Requirements
44
+ * Minimum iOS version - 14
45
+
46
+ ### Add the following POD dependencies in your Podfile app under your App target
47
+
48
+ ```
49
+ pod 'Realm', '~> 10.52.2', :modular_headers => true
50
+ pod 'DojahWidget', :git => 'https://github.com/dojah-inc/sdk-swift.git', :branch => 'pod-package'
51
+ ```
52
+
53
+ example
54
+ ```
55
+ target 'Example' do
56
+ ...
57
+ pod 'Realm', '~> 10.52.2', :modular_headers => true
58
+ pod 'DojahWidget', :git => 'https://github.com/dojah-inc/sdk-swift.git', :branch => 'pod-package'
59
+ ...
60
+ end
61
+ ```
62
+ and run pod install in your ios folder:
63
+ ```sh
64
+ cd ios
65
+ pod install
66
+ ```
67
+
68
+
69
+ ### Make some few changes in your AppDelegate.mm file
70
+
71
+ - Add the following imports:
72
+
73
+ ```objective-c
74
+ #import <React/RCTBridge.h>
75
+ #import <React/RCTRootView.h>
76
+ ```
77
+
78
+ - Then replace application function in your AppDelegate with the following:
79
+
80
+ `REMEMBER TO CHANGE THE Your App Name,to the actual name of your App`
81
+
82
+ ```objective-c
83
+ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
84
+
85
+ // Initialize the React Native bridge
86
+ RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
87
+
88
+ RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
89
+ moduleName:@"Your App Name"
90
+ initialProperties:nil];
91
+
92
+ UIViewController *rootViewController = [UIViewController new];
93
+ rootViewController.view = rootView;
94
+
95
+ // Wrap rootViewController in a UINavigationController
96
+ UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:rootViewController];
97
+
98
+ self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
99
+ self.window.rootViewController = navigationController;
100
+ [self.window makeKeyAndVisible];
101
+
102
+ return YES;
103
+ }
104
+
105
+ ```
106
+
107
+
108
+
109
+ ### Permissions
110
+ For IOS, Add the following keys to your Info.plist file:
111
+
112
+ NSCameraUsageDescription - describe why your app needs access to the camera. This is called Privacy - Camera Usage Description in the visual editor.
113
+
114
+ NSMicrophoneUsageDescription - describe why your app needs access to the microphone, if you intend to record videos. This is called Privacy - Microphone Usage Description in the visual editor.
115
+
116
+ NSLocationWhenInUseUsageDescription - describe why your app needs access to the location, if you intend to verify address/location. This is called Privacy - Location Usage Description in the visual editor.
117
+
118
+
119
+
120
+ ## Usage
121
+
122
+ To start KYC, import Dojah in your React Native code, and launch Dojah Screen
123
+
124
+ ```js
125
+ import {launchDojahKyc } from 'dojah-kyc-sdk-react_native';
126
+
127
+ launchDojahKyc(
128
+ "{Required: Your_WidgetID}",
129
+ "{Optional: Reference_ID}",
130
+ “{Optional: Email_Address}”
131
+ )
132
+
133
+ ```
134
+
135
+ ### SDK Parameters
136
+ - `WidgetID` - a `REQUIRED` parameter. You get this ID when you sign up on the Dojah platform, follow the next step to generate your WidgetId.
137
+ - `Reference ID` - an `OPTIONAL` parameter that allows you to initialize the SDK for an ongoing verification.
138
+ - `Email Address` - an `OPTIONAL` parameter that allows you to initialize the SDK for an ongoing verification.
139
+
140
+ ## How to Get a Widget ID
141
+ To use the SDK, you need a WidgetID, which is a required parameter for initializing the SDK. You can obtain this by creating a flow on the Dojah platform. Follow these steps to configure and get your Widget ID:
142
+
143
+ ```txt
144
+ 1. Log in to your Dojah Dashboard: If you don’t have an account, sign up on the Dojah platform.
145
+
146
+ 2. Navigate to the EasyOnboard Feature: Once logged in, find the EasyOnboard section on your dashboard.
147
+
148
+ 3. Create a Flow:
149
+
150
+ - Click on the 'Create a Flow' button.
151
+ - Name Your Flow: Choose a meaningful name for your flow, which will help you identify it later.
152
+
153
+ 4. Add an Application:
154
+
155
+ - Either create a new application or add an existing one.
156
+ - Customise your widget with your brand logo and color by selecting an application.
157
+
158
+ 5. Configure the Flow:
159
+
160
+ - Select a Country: Choose the country or countries relevant to your verification process.
161
+ - Select a Preview Process: Decide between automatic or manual verification.
162
+ - Notification Type: Choose how you’d like to receive notifications for updates (email, SMS, etc.).
163
+ - Add Verification Pages: Customize the verification steps in your flow (e.g., ID verification, address verification, etc.).
164
+
165
+ 6. Publish Your Widget: After configuring your flow, publish the widget. Once published, your flow is live.
166
+
167
+ 7. Copy Your Widget ID: After publishing, the platform will generate a Widget ID. Copy this Widget ID as you will need it to initialize the SDK as stated above.
168
+ ```
@@ -0,0 +1,116 @@
1
+
2
+ buildscript {
3
+ // Buildscript is evaluated before everything else so we can't use getExtOrDefault
4
+ def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["DojahKyc_kotlinVersion"]
5
+
6
+ repositories {
7
+ google()
8
+ mavenCentral()
9
+ maven { url "https://jitpack.io" }
10
+ }
11
+
12
+ dependencies {
13
+ classpath "com.android.tools.build:gradle:7.3.1"
14
+ // noinspection DifferentKotlinGradleVersion
15
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
16
+ }
17
+ }
18
+
19
+
20
+ def reactNativeArchitectures() {
21
+ def value = rootProject.getProperties().get("reactNativeArchitectures")
22
+ return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
23
+ }
24
+
25
+ def isNewArchitectureEnabled() {
26
+ return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
27
+ }
28
+
29
+ apply plugin: "com.android.library"
30
+ apply plugin: "kotlin-android"
31
+
32
+
33
+
34
+ if (isNewArchitectureEnabled()) {
35
+ apply plugin: "com.facebook.react"
36
+ }
37
+
38
+
39
+ def getExtOrDefault(name) {
40
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["DojahKyc_" + name]
41
+ }
42
+
43
+ def getExtOrIntegerDefault(name) {
44
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["DojahKyc_" + name]).toInteger()
45
+ }
46
+
47
+ def supportsNamespace() {
48
+ def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
49
+ def major = parsed[0].toInteger()
50
+ def minor = parsed[1].toInteger()
51
+
52
+ // Namespace support was added in 7.3.0
53
+ return (major == 7 && minor >= 3) || major >= 8
54
+ }
55
+
56
+ android {
57
+ if (supportsNamespace()) {
58
+ namespace "com.dojahkyc"
59
+
60
+ sourceSets {
61
+ main {
62
+ manifest.srcFile "src/main/AndroidManifestNew.xml"
63
+ }
64
+ }
65
+ }
66
+
67
+ compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
68
+
69
+ defaultConfig {
70
+ minSdkVersion getExtOrIntegerDefault("minSdkVersion")
71
+ targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
72
+
73
+ }
74
+
75
+ buildTypes {
76
+ release {
77
+ minifyEnabled true
78
+ }
79
+ }
80
+
81
+ lintOptions {
82
+ disable "GradleCompatible"
83
+ }
84
+
85
+ compileOptions {
86
+ sourceCompatibility JavaVersion.VERSION_1_8
87
+ targetCompatibility JavaVersion.VERSION_1_8
88
+ }
89
+ }
90
+
91
+ repositories {
92
+ google()
93
+ mavenCentral()
94
+ maven { url "https://jitpack.io" }
95
+ }
96
+
97
+
98
+
99
+
100
+ def kotlin_version = getExtOrDefault("kotlinVersion")
101
+
102
+
103
+ dependencies {
104
+
105
+ // For < 0.71, this will be from the local maven repo
106
+ // For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
107
+ //noinspection GradleDynamicVersion
108
+ implementation "com.facebook.react:react-native:+"
109
+ implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
110
+
111
+ implementation 'com.github.dojah-inc:sdk-kotlin:v0.0.2'
112
+
113
+
114
+ }
115
+
116
+
@@ -0,0 +1,7 @@
1
+ DojahKyc_kotlinVersion=1.7.0
2
+ DojahKyc_minSdkVersion=21
3
+ DojahKyc_targetSdkVersion=35
4
+ DojahKyc_compileSdkVersion=35
5
+ DojahKyc_ndkversion=21.4.7075529
6
+ android.useAndroidX=true
7
+ android.enableJetifier=true
File without changes
@@ -0,0 +1,3 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
+ package="com.dojahkyc">
3
+ </manifest>
@@ -0,0 +1,2 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+ </manifest>
@@ -0,0 +1,47 @@
1
+ package com.dojahkyc
2
+
3
+ import com.dojah.kyc_sdk_kotlin.DojahSdk
4
+ import com.facebook.react.bridge.LifecycleEventListener
5
+ import com.facebook.react.bridge.Promise
6
+ import com.facebook.react.bridge.ReactApplicationContext
7
+ import com.facebook.react.bridge.ReactContextBaseJavaModule
8
+ import com.facebook.react.bridge.ReactMethod
9
+ import com.facebook.react.bridge.WritableMap
10
+ import com.facebook.react.bridge.WritableNativeMap
11
+
12
+
13
+ class DojahKycModule(private val reactContext: ReactApplicationContext) :
14
+ ReactContextBaseJavaModule(reactContext) {
15
+
16
+ override fun getName(): String {
17
+ return NAME
18
+ }
19
+
20
+ // Example method
21
+ // See https://reactnative.dev/docs/native-modules-android
22
+ @ReactMethod
23
+ fun launch(
24
+ widgetId: String,
25
+ referenceId: String? = null,
26
+ email: String? = null,
27
+ promise: Promise
28
+ ) {
29
+ DojahSdk.with(reactContext).launch(widgetId, referenceId, email)
30
+ promise.resolve("Launched Dojah SDK")
31
+ }
32
+
33
+ @ReactMethod
34
+ fun getIdHistory(promise: Promise) {
35
+ val writeMap: WritableMap = WritableNativeMap()
36
+ DojahSdk.with(reactContext).getIdHistory().forEach {
37
+ writeMap.putString(it.first, it.second)
38
+ }
39
+
40
+ promise.resolve(writeMap)
41
+ }
42
+
43
+
44
+ companion object {
45
+ const val NAME = "DojahKyc"
46
+ }
47
+ }
@@ -0,0 +1,17 @@
1
+ package com.dojahkyc
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 DojahKycPackage : ReactPackage {
10
+ override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
11
+ return listOf(DojahKycModule(reactContext))
12
+ }
13
+
14
+ override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
15
+ return emptyList()
16
+ }
17
+ }
@@ -0,0 +1,4 @@
1
+ #import <React/RCTBridgeModule.h>
2
+ #import <React/RCTViewManager.h>
3
+ #import <React/RCTUtils.h>
4
+ #import "React/RCTEventEmitter.h"
@@ -0,0 +1,32 @@
1
+ // #import <React/RCTBridgeModule.h>
2
+
3
+ // @interface RCT_EXTERN_MODULE(DojahKyc, 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
15
+
16
+ #import <Foundation/Foundation.h>
17
+ #import <React/RCTBridgeModule.h>
18
+
19
+ @interface RCT_EXTERN_MODULE(DojahKyc, NSObject)
20
+
21
+ RCT_EXTERN_METHOD(initialize:(NSString)appName)
22
+
23
+
24
+ RCT_EXTERN_METHOD(launch:(NSString)widgetId withReferenceId:(NSString)referenceId withEmail:(NSString)email)
25
+
26
+ + (BOOL)requiresMainQueueSetup
27
+ {
28
+ return NO;
29
+ }
30
+
31
+ @end
32
+
@@ -0,0 +1,93 @@
1
+
2
+ import UIKit
3
+ import Foundation
4
+ import DojahWidget
5
+ import React
6
+
7
+ @objc(DojahKyc)
8
+ class DojahKyc: RCTEventEmitter, RCTBridgeDelegate {
9
+ func sourceURL(for bridge: RCTBridge) -> URL? {
10
+
11
+ #if DEBUG
12
+ return RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index", fallbackExtension: nil)
13
+ #else
14
+ return Bundle.main.url(forResource: "main", withExtension: "jsbundle")!
15
+ #endif
16
+
17
+ }
18
+
19
+
20
+ override var methodQueue: DispatchQueue {
21
+ return DispatchQueue.main;
22
+ }
23
+
24
+ override class func requiresMainQueueSetup() -> Bool {
25
+ return true;
26
+ }
27
+
28
+
29
+ @objc(initialize:)
30
+ func initialize(appName:String) -> Void {
31
+ // Initialize the React Native bridge
32
+ if let bridge = RCTBridge(delegate: self, launchOptions: nil) {
33
+ // Create a React Native root view with the provided module name
34
+ let rootView = RCTRootView(bridge: bridge, moduleName: appName, initialProperties: nil)
35
+
36
+ // Create the initial view controller with the React Native view
37
+ let rootViewController = UIViewController()
38
+ rootViewController.view = rootView
39
+
40
+ // Create a UINavigationController and set it as the window's rootViewController
41
+ let navigationController = UINavigationController(rootViewController: rootViewController)
42
+
43
+ // Set the window's rootViewController
44
+ if let window = UIApplication.shared.delegate?.window {
45
+ window?.rootViewController = navigationController
46
+ window?.makeKeyAndVisible()
47
+ }
48
+ }else{
49
+ print("bridge is null")
50
+ }
51
+
52
+
53
+ }
54
+
55
+
56
+ @objc(launch:withReferenceId:withEmail:)
57
+ func launch(widgetId:String, referenceId:String, email:String) -> Void {
58
+
59
+
60
+ guard let rootViewController = UIApplication.shared.keyWindow?.rootViewController else {
61
+ print("no root ctrl")
62
+ return
63
+ }
64
+ print("nav ctrl: $\(rootViewController as? UINavigationController)")
65
+
66
+ // print("Launched start")
67
+ // let nav: UIViewController? = RCTPresentedViewController()
68
+ // print("nav ctrl is \(nav?.navigationController)")
69
+
70
+ if(rootViewController as? UINavigationController != nil){
71
+ DojahWidgetSDK.initialize(widgetID: widgetId,referenceID: referenceId,emailAddress: email, navController: rootViewController as! UINavigationController)
72
+ // DojahWidgetSDK.initializeNormal(widgetID: widgetId,referenceID: referenceId,emailAddress: email, uiController: nav!)
73
+ print("Launched...")
74
+ // print("cached count is: \(DojahWidgetSDK.getCachedWidgetIDs().count)")
75
+ print("native details: Launch=> email:\(email), referenceId:\(referenceId), widgetId:\(widgetId)")
76
+ }else{
77
+ print("rootViewController is nil")
78
+ }
79
+
80
+ }
81
+
82
+ // @objc(launchTest:withB:withResolver:withRejecter:)
83
+ // func launchTest(a: Float, b: Float, resolve:RCTPromiseResolveBlock,reject:RCTPromiseRejectBlock) -> Void {
84
+ // print("Launched Test")
85
+ // // print("count is:\(DojahWidgetSDK.getCachedWidgetIDs().count;)")
86
+ // // if(DojahWidgetSDK.getCachedWidgetIDs().count > 0){
87
+ // // resolve("launched more")
88
+ // // }else{
89
+ // // resolve("launched 0")
90
+ // // }
91
+ // resolve("launched")
92
+ // }
93
+ }
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getIdHistory = getIdHistory;
7
+ exports.launchDojahKyc = launchDojahKyc;
8
+ var _reactNative = require("react-native");
9
+ const LINKING_ERROR = `The package 'dojah-kyc-sdk-react_native' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
10
+ ios: "- You have run 'pod install'\n",
11
+ default: ''
12
+ }) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
13
+ const DojahKyc = _reactNative.NativeModules.DojahKyc ? _reactNative.NativeModules.DojahKyc : new Proxy({}, {
14
+ get() {
15
+ throw new Error(LINKING_ERROR);
16
+ }
17
+ });
18
+
19
+ /// Initialize Dojah KYC for IOS,
20
+ /// call this before your app is registered
21
+ /// the Sdk won't work on IOS without this
22
+ /// @param appName: the name of your app
23
+ // export function initializeDojahIOS(appName: string) {
24
+ // if(Platform.OS === 'ios'){
25
+ // DojahKyc.initialize(appName);
26
+ // }
27
+ // }
28
+
29
+ function launchDojahKyc(widgetId, referenceId, email) {
30
+ if (_reactNative.Platform.OS === 'ios') {
31
+ DojahKyc.launch(widgetId, referenceId ?? '', email ?? '');
32
+ } else {
33
+ DojahKyc.launch(widgetId, referenceId, email);
34
+ }
35
+ }
36
+ function getIdHistory() {
37
+ return DojahKyc.getIdHistory();
38
+ }
39
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_reactNative","require","LINKING_ERROR","Platform","select","ios","default","DojahKyc","NativeModules","Proxy","get","Error","launchDojahKyc","widgetId","referenceId","email","OS","launch","getIdHistory"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEA,MAAMC,aAAa,GACjB,qFAAqF,GACrFC,qBAAQ,CAACC,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMC,QAAQ,GAAGC,0BAAa,CAACD,QAAQ,GACnCC,0BAAa,CAACD,QAAQ,GACtB,IAAIE,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACT,aAAa,CAAC;EAChC;AACF,CACF,CAAC;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEO,SAASU,cAAcA,CAC5BC,QAAgB,EAChBC,WAA2B,EAC3BC,KAAqB,EACrB;EACA,IAAIZ,qBAAQ,CAACa,EAAE,KAAK,KAAK,EAAE;IACzBT,QAAQ,CAACU,MAAM,CAACJ,QAAQ,EAAEC,WAAW,IAAI,EAAE,EAAEC,KAAK,IAAI,EAAE,CAAC;EAC3D,CAAC,MAAM;IACLR,QAAQ,CAACU,MAAM,CAACJ,QAAQ,EAAEC,WAAW,EAAEC,KAAK,CAAC;EAC/C;AACF;AAEO,SAASG,YAAYA,CAAA,EAAwC;EAClE,OAAOX,QAAQ,CAACW,YAAY,CAAC,CAAC;AAChC","ignoreList":[]}
@@ -0,0 +1,32 @@
1
+ import { NativeModules, Platform } from 'react-native';
2
+ const LINKING_ERROR = `The package 'dojah-kyc-sdk-react_native' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
3
+ ios: "- You have run 'pod install'\n",
4
+ default: ''
5
+ }) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
6
+ const DojahKyc = NativeModules.DojahKyc ? NativeModules.DojahKyc : new Proxy({}, {
7
+ get() {
8
+ throw new Error(LINKING_ERROR);
9
+ }
10
+ });
11
+
12
+ /// Initialize Dojah KYC for IOS,
13
+ /// call this before your app is registered
14
+ /// the Sdk won't work on IOS without this
15
+ /// @param appName: the name of your app
16
+ // export function initializeDojahIOS(appName: string) {
17
+ // if(Platform.OS === 'ios'){
18
+ // DojahKyc.initialize(appName);
19
+ // }
20
+ // }
21
+
22
+ export function launchDojahKyc(widgetId, referenceId, email) {
23
+ if (Platform.OS === 'ios') {
24
+ DojahKyc.launch(widgetId, referenceId ?? '', email ?? '');
25
+ } else {
26
+ DojahKyc.launch(widgetId, referenceId, email);
27
+ }
28
+ }
29
+ export function getIdHistory() {
30
+ return DojahKyc.getIdHistory();
31
+ }
32
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["NativeModules","Platform","LINKING_ERROR","select","ios","default","DojahKyc","Proxy","get","Error","launchDojahKyc","widgetId","referenceId","email","OS","launch","getIdHistory"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA,SAASA,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AAEtD,MAAMC,aAAa,GACjB,qFAAqF,GACrFD,QAAQ,CAACE,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMC,QAAQ,GAAGN,aAAa,CAACM,QAAQ,GACnCN,aAAa,CAACM,QAAQ,GACtB,IAAIC,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACP,aAAa,CAAC;EAChC;AACF,CACF,CAAC;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,SAASQ,cAAcA,CAC5BC,QAAgB,EAChBC,WAA2B,EAC3BC,KAAqB,EACrB;EACA,IAAIZ,QAAQ,CAACa,EAAE,KAAK,KAAK,EAAE;IACzBR,QAAQ,CAACS,MAAM,CAACJ,QAAQ,EAAEC,WAAW,IAAI,EAAE,EAAEC,KAAK,IAAI,EAAE,CAAC;EAC3D,CAAC,MAAM;IACLP,QAAQ,CAACS,MAAM,CAACJ,QAAQ,EAAEC,WAAW,EAAEC,KAAK,CAAC;EAC/C;AACF;AAEA,OAAO,SAASG,YAAYA,CAAA,EAAwC;EAClE,OAAOV,QAAQ,CAACU,YAAY,CAAC,CAAC;AAChC","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ export declare function launchDojahKyc(widgetId: string, referenceId?: string | null, email?: string | null): void;
2
+ export declare function getIdHistory(): Promise<Map<string, string> | null>;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AA6BA,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,MAAM,EAChB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,EAC3B,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,QAOtB;AAED,wBAAgB,YAAY,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC,CAElE"}
package/package.json ADDED
@@ -0,0 +1,160 @@
1
+ {
2
+ "name": "dojah-kyc-sdk-react_native",
3
+ "version": "0.0.1",
4
+ "description": "Dojah SDK",
5
+ "main": "lib/commonjs/index",
6
+ "module": "lib/module/index",
7
+ "types": "lib/typescript/src/index.d.ts",
8
+ "react-native": "src/index",
9
+ "source": "src/index",
10
+ "files": [
11
+ "src",
12
+ "lib",
13
+ "android",
14
+ "ios",
15
+ "cpp",
16
+ "*.podspec",
17
+ "!ios/build",
18
+ "!android/build",
19
+ "!android/gradle",
20
+ "!android/gradlew",
21
+ "!android/gradlew.bat",
22
+ "!android/local.properties",
23
+ "!**/__tests__",
24
+ "!**/__fixtures__",
25
+ "!**/__mocks__",
26
+ "!**/.*"
27
+ ],
28
+ "scripts": {
29
+ "example": "yarn workspace dojah-kyc-sdk-react_native-example",
30
+ "test": "jest",
31
+ "typecheck": "tsc --noEmit",
32
+ "lint": "eslint \"**/*.{js,ts,tsx}\"",
33
+ "clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
34
+ "prepare": "bob build",
35
+ "release": "release-it"
36
+ },
37
+ "keywords": [
38
+ "react-native",
39
+ "ios",
40
+ "android"
41
+ ],
42
+ "repository": {
43
+ "type": "git",
44
+ "url": "git+https://github.com/shittu33/dojah-kyc-sdk-react_native.git"
45
+ },
46
+ "author": "shittu33 <shittuabdulmujeeb@gmail.com> (https://github.com/shittu33)",
47
+ "license": "MIT",
48
+ "bugs": {
49
+ "url": "https://github.com/shittu33/dojah-kyc-sdk-react_native/issues"
50
+ },
51
+ "homepage": "https://github.com/shittu33/dojah-kyc-sdk-react_native#readme",
52
+ "publishConfig": {
53
+ "registry": "https://registry.npmjs.org/"
54
+ },
55
+ "devDependencies": {
56
+ "@commitlint/config-conventional": "^17.0.2",
57
+ "@evilmartians/lefthook": "^1.5.0",
58
+ "@react-native/eslint-config": "^0.73.1",
59
+ "@release-it/conventional-changelog": "^5.0.0",
60
+ "@types/jest": "^29.5.5",
61
+ "@types/react": "^18.2.44",
62
+ "commitlint": "^17.0.2",
63
+ "del-cli": "^5.1.0",
64
+ "eslint": "^8.51.0",
65
+ "eslint-config-prettier": "^9.0.0",
66
+ "eslint-plugin-prettier": "^5.0.1",
67
+ "jest": "^29.7.0",
68
+ "prettier": "^3.0.3",
69
+ "react": "18.2.0",
70
+ "react-native": "0.74.2",
71
+ "react-native-builder-bob": "^0.20.0",
72
+ "release-it": "^15.0.0",
73
+ "turbo": "^1.10.7",
74
+ "typescript": "^5.2.2"
75
+ },
76
+ "resolutions": {
77
+ "@types/react": "^18.2.44"
78
+ },
79
+ "peerDependencies": {
80
+ "react": "*",
81
+ "react-native": "*"
82
+ },
83
+ "workspaces": [
84
+ "example"
85
+ ],
86
+ "packageManager": "yarn@3.6.1",
87
+ "jest": {
88
+ "preset": "react-native",
89
+ "modulePathIgnorePatterns": [
90
+ "<rootDir>/example/node_modules",
91
+ "<rootDir>/lib/"
92
+ ]
93
+ },
94
+ "commitlint": {
95
+ "extends": [
96
+ "@commitlint/config-conventional"
97
+ ]
98
+ },
99
+ "release-it": {
100
+ "git": {
101
+ "commitMessage": "chore: release ${version}",
102
+ "tagName": "v${version}"
103
+ },
104
+ "npm": {
105
+ "publish": true
106
+ },
107
+ "github": {
108
+ "release": true
109
+ },
110
+ "plugins": {
111
+ "@release-it/conventional-changelog": {
112
+ "preset": "angular"
113
+ }
114
+ }
115
+ },
116
+ "eslintConfig": {
117
+ "root": true,
118
+ "extends": [
119
+ "@react-native",
120
+ "prettier"
121
+ ],
122
+ "rules": {
123
+ "prettier/prettier": [
124
+ "error",
125
+ {
126
+ "quoteProps": "consistent",
127
+ "singleQuote": true,
128
+ "tabWidth": 2,
129
+ "trailingComma": "es5",
130
+ "useTabs": false
131
+ }
132
+ ]
133
+ }
134
+ },
135
+ "eslintIgnore": [
136
+ "node_modules/",
137
+ "lib/"
138
+ ],
139
+ "prettier": {
140
+ "quoteProps": "consistent",
141
+ "singleQuote": true,
142
+ "tabWidth": 2,
143
+ "trailingComma": "es5",
144
+ "useTabs": false
145
+ },
146
+ "react-native-builder-bob": {
147
+ "source": "src",
148
+ "output": "lib",
149
+ "targets": [
150
+ "commonjs",
151
+ "module",
152
+ [
153
+ "typescript",
154
+ {
155
+ "project": "tsconfig.build.json"
156
+ }
157
+ ]
158
+ ]
159
+ }
160
+ }
@@ -0,0 +1,52 @@
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-dojah-kyc"
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
+
15
+ s.platforms = { :ios => '14.0' }
16
+ s.swift_version = '5.0'
17
+ s.source = { :git => "https://github.com/shittu33/dojah-kyc-sdk-react_native.git", :tag => "#{s.version}" }
18
+
19
+ s.source_files = "ios/**/*.{h,m,mm,swift}"
20
+ s.dependency 'DojahWidget'
21
+ # s.resources = ['ios/Fonts/**/*.{json,ttf,otf,pdf,dataset,imageset}']
22
+ # s.resources = ['sdk-swift-main/Sources/DojahWidget/Resources/**/*.{json,ttf,otf,dataset,imageset}']
23
+ # s.resource_bundles = {
24
+ # 'DojahWidgetResources' => ['DojahWidget/Resources/**/*']
25
+ # }
26
+ # s.vendored_frameworks = 'ios/DojahFramework.xcframework'
27
+
28
+ # Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
29
+ # See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
30
+
31
+ if respond_to?(:install_modules_dependencies, true)
32
+ install_modules_dependencies(s)
33
+ else
34
+ s.dependency "React-Core"
35
+
36
+ # Don't install the dependencies when we run `pod install` in the old architecture.
37
+ if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
38
+ s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
39
+ s.pod_target_xcconfig = {
40
+ "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
41
+ "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
42
+ "CLANG_CXX_LANGUAGE_STANDARD" => "c++17",
43
+ # 'SWIFT_INCLUDE_PATHS' => '$(inherited) ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)'
44
+ }
45
+ s.dependency "React-Codegen"
46
+ s.dependency "RCT-Folly"
47
+ s.dependency "RCTRequired"
48
+ s.dependency "RCTTypeSafety"
49
+ s.dependency "ReactCommon/turbomodule/core"
50
+ end
51
+ end
52
+ end
package/src/index.tsx ADDED
@@ -0,0 +1,44 @@
1
+ import { NativeModules, Platform } from 'react-native';
2
+
3
+ const LINKING_ERROR =
4
+ `The package 'dojah-kyc-sdk-react_native' 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 DojahKyc = NativeModules.DojahKyc
10
+ ? NativeModules.DojahKyc
11
+ : new Proxy(
12
+ {},
13
+ {
14
+ get() {
15
+ throw new Error(LINKING_ERROR);
16
+ },
17
+ }
18
+ );
19
+
20
+ /// Initialize Dojah KYC for IOS,
21
+ /// call this before your app is registered
22
+ /// the Sdk won't work on IOS without this
23
+ /// @param appName: the name of your app
24
+ // export function initializeDojahIOS(appName: string) {
25
+ // if(Platform.OS === 'ios'){
26
+ // DojahKyc.initialize(appName);
27
+ // }
28
+ // }
29
+
30
+ export function launchDojahKyc(
31
+ widgetId: string,
32
+ referenceId?: string | null,
33
+ email?: string | null
34
+ ) {
35
+ if (Platform.OS === 'ios') {
36
+ DojahKyc.launch(widgetId, referenceId ?? '', email ?? '');
37
+ } else {
38
+ DojahKyc.launch(widgetId, referenceId, email);
39
+ }
40
+ }
41
+
42
+ export function getIdHistory(): Promise<Map<string, string> | null> {
43
+ return DojahKyc.getIdHistory();
44
+ }