@digiotech/react-native 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 +114 -0
- package/android/build.gradle +106 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/java/com/digioreactnative/ArrayUtil.java +162 -0
- package/android/src/main/java/com/digioreactnative/DigioReactNativeModule.java +210 -0
- package/android/src/main/java/com/digioreactnative/DigioReactNativePackage.java +28 -0
- package/android/src/main/java/com/digioreactnative/JsonUtils.java +61 -0
- package/android/src/main/java/com/digioreactnative/MapUtil.java +179 -0
- package/digio-react-native.podspec +43 -0
- package/ios/DigioKycResponse.swift +18 -0
- package/ios/DigioReactNative-Bridging-Header.h +3 -0
- package/ios/DigioReactNative.mm +20 -0
- package/ios/DigioReactNative.swift +114 -0
- package/lib/commonjs/index.js +59 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/types/enums/environment.js +12 -0
- package/lib/commonjs/types/enums/environment.js.map +1 -0
- package/lib/commonjs/types/interfaces/digio_config.js +6 -0
- package/lib/commonjs/types/interfaces/digio_config.js.map +1 -0
- package/lib/commonjs/types/interfaces/digio_response.js +2 -0
- package/lib/commonjs/types/interfaces/digio_response.js.map +1 -0
- package/lib/commonjs/types/interfaces/error.js +2 -0
- package/lib/commonjs/types/interfaces/error.js.map +1 -0
- package/lib/commonjs/types/interfaces/gateway_event.js +6 -0
- package/lib/commonjs/types/interfaces/gateway_event.js.map +1 -0
- package/lib/commonjs/types/interfaces/theme.js +2 -0
- package/lib/commonjs/types/interfaces/theme.js.map +1 -0
- package/lib/module/index.js +46 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/types/enums/environment.js +6 -0
- package/lib/module/types/enums/environment.js.map +1 -0
- package/lib/module/types/interfaces/digio_config.js +2 -0
- package/lib/module/types/interfaces/digio_config.js.map +1 -0
- package/lib/module/types/interfaces/digio_response.js +2 -0
- package/lib/module/types/interfaces/digio_response.js.map +1 -0
- package/lib/module/types/interfaces/error.js +2 -0
- package/lib/module/types/interfaces/error.js.map +1 -0
- package/lib/module/types/interfaces/gateway_event.js +2 -0
- package/lib/module/types/interfaces/gateway_event.js.map +1 -0
- package/lib/module/types/interfaces/theme.js +2 -0
- package/lib/module/types/interfaces/theme.js.map +1 -0
- package/lib/typescript/src/index.d.ts +17 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/types/enums/environment.d.ts +5 -0
- package/lib/typescript/src/types/enums/environment.d.ts.map +1 -0
- package/lib/typescript/src/types/interfaces/digio_config.d.ts +8 -0
- package/lib/typescript/src/types/interfaces/digio_config.d.ts.map +1 -0
- package/lib/typescript/src/types/interfaces/digio_response.d.ts +7 -0
- package/lib/typescript/src/types/interfaces/digio_response.d.ts.map +1 -0
- package/lib/typescript/src/types/interfaces/error.d.ts +5 -0
- package/lib/typescript/src/types/interfaces/error.d.ts.map +1 -0
- package/lib/typescript/src/types/interfaces/gateway_event.d.ts +17 -0
- package/lib/typescript/src/types/interfaces/gateway_event.d.ts.map +1 -0
- package/lib/typescript/src/types/interfaces/theme.d.ts +8 -0
- package/lib/typescript/src/types/interfaces/theme.d.ts.map +1 -0
- package/package.json +162 -0
- package/src/index.ts +91 -0
- package/src/types/enums/environment.ts +4 -0
- package/src/types/interfaces/digio_config.ts +8 -0
- package/src/types/interfaces/digio_response.ts +6 -0
- package/src/types/interfaces/error.ts +4 -0
- package/src/types/interfaces/gateway_event.ts +16 -0
- package/src/types/interfaces/theme.ts +7 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
package com.digioreactnative;
|
|
2
|
+
|
|
3
|
+
import org.json.JSONArray;
|
|
4
|
+
import org.json.JSONException;
|
|
5
|
+
import org.json.JSONObject;
|
|
6
|
+
|
|
7
|
+
import java.util.ArrayList;
|
|
8
|
+
import java.util.HashMap;
|
|
9
|
+
import java.util.Iterator;
|
|
10
|
+
import java.util.List;
|
|
11
|
+
import java.util.Map;
|
|
12
|
+
|
|
13
|
+
public class JsonUtils {
|
|
14
|
+
public static Map<String, Object> jsonToMap(JSONObject json) {
|
|
15
|
+
Map<String, Object> retMap = new HashMap();
|
|
16
|
+
if (json != JSONObject.NULL) {
|
|
17
|
+
retMap = toMap(json);
|
|
18
|
+
}
|
|
19
|
+
return retMap;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
public static Map<String, Object> toMap(JSONObject jsonObject) {
|
|
23
|
+
Map<String, Object> map = new HashMap();
|
|
24
|
+
Iterator<String> keys = jsonObject.keys();
|
|
25
|
+
while (keys.hasNext()) {
|
|
26
|
+
String key = keys.next();
|
|
27
|
+
Object value = null;
|
|
28
|
+
try {
|
|
29
|
+
value = jsonObject.get(key);
|
|
30
|
+
} catch (JSONException e) {
|
|
31
|
+
e.printStackTrace();
|
|
32
|
+
}
|
|
33
|
+
if (value instanceof JSONArray) {
|
|
34
|
+
value = toList((JSONArray) value);
|
|
35
|
+
} else if (value instanceof JSONObject) {
|
|
36
|
+
value = toMap((JSONObject) value);
|
|
37
|
+
}
|
|
38
|
+
map.put(key, value);
|
|
39
|
+
}
|
|
40
|
+
return map;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
public static List<Object> toList(JSONArray array) {
|
|
44
|
+
List<Object> list = new ArrayList();
|
|
45
|
+
for (int i = 0; i < array.length(); i++) {
|
|
46
|
+
Object value = null;
|
|
47
|
+
try {
|
|
48
|
+
value = array.get(i);
|
|
49
|
+
} catch (JSONException e) {
|
|
50
|
+
e.printStackTrace();
|
|
51
|
+
}
|
|
52
|
+
if (value instanceof JSONArray) {
|
|
53
|
+
value = toList((JSONArray) value);
|
|
54
|
+
} else if (value instanceof JSONObject) {
|
|
55
|
+
value = toMap((JSONObject) value);
|
|
56
|
+
}
|
|
57
|
+
list.add(value);
|
|
58
|
+
}
|
|
59
|
+
return list;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
package com.digioreactnative;
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.Arguments;
|
|
4
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
5
|
+
import com.facebook.react.bridge.ReadableMapKeySetIterator;
|
|
6
|
+
import com.facebook.react.bridge.ReadableType;
|
|
7
|
+
import com.facebook.react.bridge.WritableMap;
|
|
8
|
+
import com.facebook.react.bridge.WritableNativeMap;
|
|
9
|
+
|
|
10
|
+
import org.json.JSONArray;
|
|
11
|
+
import org.json.JSONException;
|
|
12
|
+
import org.json.JSONObject;
|
|
13
|
+
|
|
14
|
+
import java.net.URL;
|
|
15
|
+
import java.util.HashMap;
|
|
16
|
+
import java.util.Iterator;
|
|
17
|
+
import java.util.Map;
|
|
18
|
+
|
|
19
|
+
public class MapUtil {
|
|
20
|
+
|
|
21
|
+
public static void mapPutNullable(WritableMap map, String key, Object value) {
|
|
22
|
+
if (value == null) {
|
|
23
|
+
map.putNull(key);
|
|
24
|
+
} else if (value instanceof String) {
|
|
25
|
+
map.putString(key, (String) value);
|
|
26
|
+
} else if (value instanceof URL) {
|
|
27
|
+
map.putString(key, value.toString());
|
|
28
|
+
} else if (value instanceof Boolean) {
|
|
29
|
+
map.putBoolean(key, (Boolean) value);
|
|
30
|
+
} else if (value instanceof Integer) {
|
|
31
|
+
map.putInt(key, (Integer) value);
|
|
32
|
+
} else if (value instanceof Long) {
|
|
33
|
+
map.putDouble(key, ((Long) value).doubleValue());
|
|
34
|
+
} else if (value instanceof Double) {
|
|
35
|
+
map.putDouble(key, (Double) value);
|
|
36
|
+
} else if (value instanceof Float) {
|
|
37
|
+
map.putDouble(key, Double.valueOf(value.toString()));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public static JSONObject toJSONObject(ReadableMap readableMap) throws JSONException {
|
|
42
|
+
JSONObject jsonObject = new JSONObject();
|
|
43
|
+
|
|
44
|
+
ReadableMapKeySetIterator iterator = readableMap.keySetIterator();
|
|
45
|
+
|
|
46
|
+
while (iterator.hasNextKey()) {
|
|
47
|
+
String key = iterator.nextKey();
|
|
48
|
+
ReadableType type = readableMap.getType(key);
|
|
49
|
+
|
|
50
|
+
switch (type) {
|
|
51
|
+
case Null:
|
|
52
|
+
jsonObject.put(key, null);
|
|
53
|
+
break;
|
|
54
|
+
case Boolean:
|
|
55
|
+
jsonObject.put(key, readableMap.getBoolean(key));
|
|
56
|
+
break;
|
|
57
|
+
case Number:
|
|
58
|
+
jsonObject.put(key, readableMap.getDouble(key));
|
|
59
|
+
break;
|
|
60
|
+
case String:
|
|
61
|
+
jsonObject.put(key, readableMap.getString(key));
|
|
62
|
+
break;
|
|
63
|
+
case Map:
|
|
64
|
+
jsonObject.put(key, MapUtil.toJSONObject(readableMap.getMap(key)));
|
|
65
|
+
break;
|
|
66
|
+
case Array:
|
|
67
|
+
jsonObject.put(key, ArrayUtil.toJSONArray(readableMap.getArray(key)));
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return jsonObject;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
public static Map<String, Object> toMap(JSONObject jsonObject) throws JSONException {
|
|
76
|
+
Map<String, Object> map = new HashMap<>();
|
|
77
|
+
Iterator<String> iterator = jsonObject.keys();
|
|
78
|
+
|
|
79
|
+
while (iterator.hasNext()) {
|
|
80
|
+
String key = iterator.next();
|
|
81
|
+
Object value = jsonObject.get(key);
|
|
82
|
+
|
|
83
|
+
if (value instanceof JSONObject) {
|
|
84
|
+
value = MapUtil.toMap((JSONObject) value);
|
|
85
|
+
}
|
|
86
|
+
if (value instanceof JSONArray) {
|
|
87
|
+
value = ArrayUtil.toArray((JSONArray) value);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
map.put(key, value);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return map;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
public static Map<String, String> toMap(ReadableMap readableMap) {
|
|
97
|
+
Map<String, String> map = new HashMap<>();
|
|
98
|
+
ReadableMapKeySetIterator iterator = readableMap.keySetIterator();
|
|
99
|
+
|
|
100
|
+
while (iterator.hasNextKey()) {
|
|
101
|
+
String key = iterator.nextKey();
|
|
102
|
+
map.put(key, readableMap.getString(key));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return map;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
public static WritableMap toWritableMap(Map<String, Object> map) {
|
|
109
|
+
WritableMap writableMap = Arguments.createMap();
|
|
110
|
+
Iterator iterator = map.entrySet().iterator();
|
|
111
|
+
|
|
112
|
+
while (iterator.hasNext()) {
|
|
113
|
+
Map.Entry pair = (Map.Entry)iterator.next();
|
|
114
|
+
Object value = pair.getValue();
|
|
115
|
+
|
|
116
|
+
if (value == null) {
|
|
117
|
+
writableMap.putNull((String) pair.getKey());
|
|
118
|
+
} else if (value instanceof Boolean) {
|
|
119
|
+
writableMap.putBoolean((String) pair.getKey(), (Boolean) value);
|
|
120
|
+
} else if (value instanceof Double) {
|
|
121
|
+
writableMap.putDouble((String) pair.getKey(), (Double) value);
|
|
122
|
+
} else if (value instanceof Integer) {
|
|
123
|
+
writableMap.putInt((String) pair.getKey(), (Integer) value);
|
|
124
|
+
} else if (value instanceof String) {
|
|
125
|
+
writableMap.putString((String) pair.getKey(), (String) value);
|
|
126
|
+
} else if (value instanceof Map) {
|
|
127
|
+
writableMap.putMap((String) pair.getKey(), MapUtil.toWritableMap((Map<String, Object>) value));
|
|
128
|
+
} else if (value.getClass() != null && value.getClass().isArray()) {
|
|
129
|
+
writableMap.putArray((String) pair.getKey(), ArrayUtil.toWritableArray((Object[]) value));
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
iterator.remove();
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return writableMap;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
public static WritableMap jsonToWritableMap(JSONObject jsonObject) {
|
|
139
|
+
WritableMap writableMap = new WritableNativeMap();
|
|
140
|
+
|
|
141
|
+
if (jsonObject == null) {
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
Iterator<String> iterator = jsonObject.keys();
|
|
146
|
+
|
|
147
|
+
if (!iterator.hasNext()) {
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
while (iterator.hasNext()) {
|
|
152
|
+
try {
|
|
153
|
+
String key = iterator.next();
|
|
154
|
+
Object value = jsonObject.get(key);
|
|
155
|
+
|
|
156
|
+
if (value == null) {
|
|
157
|
+
writableMap.putNull(key);
|
|
158
|
+
} else if (value instanceof Boolean) {
|
|
159
|
+
writableMap.putBoolean(key, (Boolean) value);
|
|
160
|
+
} else if (value instanceof Integer) {
|
|
161
|
+
writableMap.putInt(key, (Integer) value);
|
|
162
|
+
} else if (value instanceof Double) {
|
|
163
|
+
writableMap.putDouble(key, (Double) value);
|
|
164
|
+
} else if (value instanceof String) {
|
|
165
|
+
writableMap.putString(key, (String) value);
|
|
166
|
+
} else if (value instanceof JSONObject) {
|
|
167
|
+
writableMap.putMap(key, jsonToWritableMap((JSONObject) value));
|
|
168
|
+
} else if (value instanceof JSONArray) {
|
|
169
|
+
writableMap.putArray(key, ArrayUtil.jsonArrayToWritableArray((JSONArray) value));
|
|
170
|
+
}
|
|
171
|
+
} catch (JSONException e) {
|
|
172
|
+
e.printStackTrace();
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
return writableMap;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
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 = "digio-react-native"
|
|
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 => "11.0" }
|
|
15
|
+
s.source = { :git => "https://github.com/digio-tech/reactnative-sdk.git", :tag => "#{s.version}" }
|
|
16
|
+
|
|
17
|
+
s.source_files = "ios/**/*.{h,m,mm,swift}"
|
|
18
|
+
|
|
19
|
+
s.dependency 'DigiokycSDK', '~> 1.1.0'
|
|
20
|
+
|
|
21
|
+
# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
|
|
22
|
+
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
|
|
23
|
+
if respond_to?(:install_modules_dependencies, true)
|
|
24
|
+
install_modules_dependencies(s)
|
|
25
|
+
else
|
|
26
|
+
s.dependency "React-Core"
|
|
27
|
+
|
|
28
|
+
# Don't install the dependencies when we run `pod install` in the old architecture.
|
|
29
|
+
if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
|
|
30
|
+
s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
|
|
31
|
+
s.pod_target_xcconfig = {
|
|
32
|
+
"HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
|
|
33
|
+
"OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
|
|
34
|
+
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
|
|
35
|
+
}
|
|
36
|
+
s.dependency "React-Codegen"
|
|
37
|
+
s.dependency "RCT-Folly"
|
|
38
|
+
s.dependency "RCTRequired"
|
|
39
|
+
s.dependency "RCTTypeSafety"
|
|
40
|
+
s.dependency "ReactCommon/turbomodule/core"
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//
|
|
2
|
+
// DigioKycResponse.swift
|
|
3
|
+
// digio-react-native
|
|
4
|
+
//
|
|
5
|
+
// Created by Ramanand Sirvi on 26/10/23.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
|
|
10
|
+
struct DigioKycResponse: Codable{
|
|
11
|
+
let status: String?
|
|
12
|
+
let message: String?
|
|
13
|
+
let id: String?
|
|
14
|
+
let code: Int?
|
|
15
|
+
let errorCode: Int?
|
|
16
|
+
let type: String?
|
|
17
|
+
let screen: String?
|
|
18
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#import <React/RCTBridgeModule.h>
|
|
2
|
+
|
|
3
|
+
@interface RCT_EXTERN_MODULE(DigioReactNative, NSObject)
|
|
4
|
+
|
|
5
|
+
RCT_EXTERN_METHOD(
|
|
6
|
+
start:(NSString *)documentId
|
|
7
|
+
withIdentifier:(NSString *)identifier
|
|
8
|
+
withTokenId:(NSString *)tokenId
|
|
9
|
+
withAdditionalData:(NSDictionary * _Nullable)additionalData
|
|
10
|
+
withConfig:(NSDictionary * _Nullable)config
|
|
11
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
12
|
+
withRejecter:(RCTPromiseRejectBlock)reject
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
+ (BOOL)requiresMainQueueSetup
|
|
16
|
+
{
|
|
17
|
+
return NO;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@end
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import DigiokycSDK
|
|
2
|
+
import React
|
|
3
|
+
import UIKit
|
|
4
|
+
import Foundation
|
|
5
|
+
|
|
6
|
+
@objc(DigioReactNative)
|
|
7
|
+
class DigioReactNative: RCTEventEmitter, DigioKycResponseDelegate {
|
|
8
|
+
var result: RCTPromiseResolveBlock!
|
|
9
|
+
|
|
10
|
+
override func supportedEvents() -> [String]! {
|
|
11
|
+
return ["gatewayEvent"]
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
@objc(start:withIdentifier:withTokenId:withAdditionalData:withConfig:withResolver:withRejecter:)
|
|
15
|
+
func start(documentId: String, identifier: String, tokenId: String?, additionalData: NSDictionary?, config: NSDictionary?, resolve:@escaping RCTPromiseResolveBlock,reject:@escaping RCTPromiseRejectBlock) -> Void {
|
|
16
|
+
self.result = resolve;
|
|
17
|
+
DispatchQueue.main.async {
|
|
18
|
+
let rootViewController = UIApplication.shared.windows.filter({ (w) -> Bool in
|
|
19
|
+
return w.isHidden == false
|
|
20
|
+
}).first?.rootViewController
|
|
21
|
+
|
|
22
|
+
if rootViewController != nil {
|
|
23
|
+
do {
|
|
24
|
+
var additionalParams: [String: String]?
|
|
25
|
+
var primaryColor: String?
|
|
26
|
+
var logo: String?
|
|
27
|
+
var fontFormat: String?
|
|
28
|
+
var fontFamily: String?
|
|
29
|
+
var fontUrl: String?
|
|
30
|
+
var environment: String = "production"
|
|
31
|
+
|
|
32
|
+
additionalParams = additionalData as? [String : String];
|
|
33
|
+
|
|
34
|
+
environment = config?["environment"] as? String ?? "production";
|
|
35
|
+
primaryColor = config?["primaryColor"] as? String;
|
|
36
|
+
logo = config?["logo"] as? String;
|
|
37
|
+
fontFormat = config?["fontFormat"] as? String;
|
|
38
|
+
fontFamily = config?["fontFamily"] as? String;
|
|
39
|
+
fontUrl = config?["fontUrl"] as? String;
|
|
40
|
+
|
|
41
|
+
// Your existing code here...
|
|
42
|
+
try DigioKycBuilder()
|
|
43
|
+
.withController(viewController: rootViewController!)
|
|
44
|
+
.setDocumentId(documentId: documentId)
|
|
45
|
+
.setKycResponseDelegate(delegate: self)
|
|
46
|
+
.setIdentifier(identifier: identifier)
|
|
47
|
+
.setEnvironment(environment: environment.elementsEqual("sandbox") ? DigioEnvironment.SANDBOX : DigioEnvironment.PRODUCTION)
|
|
48
|
+
.setPrimaryColor(hexColor: primaryColor ?? "")
|
|
49
|
+
.setTokenId(tokenId: tokenId ?? "")
|
|
50
|
+
.setFontFormat(fontFormat: fontFormat ?? "")
|
|
51
|
+
.setFontFamily(fontFamily: fontFamily ?? "")
|
|
52
|
+
.setFontUrl(fontUrl: fontUrl ?? "")
|
|
53
|
+
.setLogo(logo: logo ?? "")
|
|
54
|
+
.setAdditionalParams(additionalParams: additionalParams ?? [:])
|
|
55
|
+
.build()
|
|
56
|
+
} catch let error {
|
|
57
|
+
print("Exception --> \(error.localizedDescription)")
|
|
58
|
+
}
|
|
59
|
+
} else {
|
|
60
|
+
reject("Error", "Root view controller not found", nil)
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
//
|
|
65
|
+
private func formatJson(response: String)->[String: Any]{
|
|
66
|
+
let kycResponse = try! JSONDecoder().decode(DigioKycResponse.self, from: response.data(using: .utf8)!)
|
|
67
|
+
var resultMap: [String: Any] = [:]
|
|
68
|
+
resultMap["message"] = kycResponse.message
|
|
69
|
+
resultMap["documentId"] = kycResponse.id
|
|
70
|
+
if let code = kycResponse.code {
|
|
71
|
+
resultMap["code"] = code
|
|
72
|
+
}
|
|
73
|
+
if let errorCode = kycResponse.errorCode{
|
|
74
|
+
resultMap["errorCode"] = errorCode
|
|
75
|
+
}
|
|
76
|
+
if let screen = kycResponse.screen{
|
|
77
|
+
resultMap["screen"] = screen
|
|
78
|
+
}
|
|
79
|
+
if let type = kycResponse.type {
|
|
80
|
+
resultMap["type"] = type
|
|
81
|
+
}
|
|
82
|
+
return resultMap
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
func onDigioKycResponseSuccess(successResponse: String) {
|
|
86
|
+
print("Success \(successResponse)")
|
|
87
|
+
if self.result != nil {
|
|
88
|
+
self.result(formatJson(response: successResponse))
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
func onDigioKycResponseFailure(failureResponse: String) {
|
|
93
|
+
print("Failure \(failureResponse)")
|
|
94
|
+
if self.result != nil {
|
|
95
|
+
self.result(formatJson(response: failureResponse))
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
func onGateWayEvent(event: String) {
|
|
100
|
+
print("Gateway event \(event)")
|
|
101
|
+
self.sendEvent(withName: "gatewayEvent", body: convertToDictionary(text: event))
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
func convertToDictionary(text: String) -> [String: Any]? {
|
|
105
|
+
if let data = text.data(using: .utf8) {
|
|
106
|
+
do {
|
|
107
|
+
return try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any]
|
|
108
|
+
} catch {
|
|
109
|
+
print(error.localizedDescription)
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return nil
|
|
113
|
+
}
|
|
114
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Digio = void 0;
|
|
7
|
+
Object.defineProperty(exports, "Environment", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return _environment.Environment;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
var _reactNative = require("react-native");
|
|
14
|
+
var _environment = require("./types/enums/environment");
|
|
15
|
+
const LINKING_ERROR = `The package 'digio-react-native' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
|
|
16
|
+
ios: "- You have run 'pod install'\n",
|
|
17
|
+
default: ''
|
|
18
|
+
}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
|
|
19
|
+
const DigioReactNative = _reactNative.NativeModules.DigioReactNative ? _reactNative.NativeModules.DigioReactNative : new Proxy({}, {
|
|
20
|
+
get() {
|
|
21
|
+
throw new Error(LINKING_ERROR);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
class Digio {
|
|
25
|
+
constructor(config) {
|
|
26
|
+
this.config = config;
|
|
27
|
+
}
|
|
28
|
+
addGatewayEventListener(callback) {
|
|
29
|
+
if (_reactNative.Platform.OS === 'android') {
|
|
30
|
+
return _reactNative.DeviceEventEmitter.addListener('gatewayEvent', data => {
|
|
31
|
+
if (callback) {
|
|
32
|
+
callback(data);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
if (_reactNative.Platform.OS === 'ios') {
|
|
37
|
+
const digioReactNativeEmitter = new _reactNative.NativeEventEmitter(DigioReactNative);
|
|
38
|
+
return digioReactNativeEmitter.addListener('gatewayEvent', data => {
|
|
39
|
+
if (callback) {
|
|
40
|
+
callback(data);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
throw Error(`Platform ${_reactNative.Platform.OS} not supported`);
|
|
45
|
+
}
|
|
46
|
+
async start(documentId, identifier, tokenId, additionalData) {
|
|
47
|
+
return DigioReactNative.start(documentId, identifier, tokenId ?? null, additionalData ?? null, this.buildConfigParams() ?? null);
|
|
48
|
+
}
|
|
49
|
+
buildConfigParams() {
|
|
50
|
+
if (!this.config) return;
|
|
51
|
+
return {
|
|
52
|
+
environment: this.config.environment,
|
|
53
|
+
logo: this.config.logo,
|
|
54
|
+
...this.config.theme
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.Digio = Digio;
|
|
59
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_environment","LINKING_ERROR","Platform","select","ios","default","DigioReactNative","NativeModules","Proxy","get","Error","Digio","constructor","config","addGatewayEventListener","callback","OS","DeviceEventEmitter","addListener","data","digioReactNativeEmitter","NativeEventEmitter","start","documentId","identifier","tokenId","additionalData","buildConfigParams","environment","logo","theme","exports"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAWA,IAAAC,YAAA,GAAAD,OAAA;AAEA,MAAME,aAAa,GAChB,6EAA4E,GAC7EC,qBAAQ,CAACC,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMC,gBAAgB,GAAGC,0BAAa,CAACD,gBAAgB,GACnDC,0BAAa,CAACD,gBAAgB,GAC9B,IAAIE,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACT,aAAa,CAAC;EAChC;AACF,CACF,CAAC;AAWE,MAAMU,KAAK,CAAC;EAGjBC,WAAWA,CAACC,MAAmB,EAAE;IAC/B,IAAI,CAACA,MAAM,GAAGA,MAAM;EACtB;EAEAC,uBAAuBA,CACrBC,QAAgC,EACX;IACrB,IAAIb,qBAAQ,CAACc,EAAE,KAAK,SAAS,EAAE;MAC7B,OAAOC,+BAAkB,CAACC,WAAW,CAAC,cAAc,EAAGC,IAAI,IAAK;QAC9D,IAAIJ,QAAQ,EAAE;UACZA,QAAQ,CAACI,IAAI,CAAC;QAChB;MACF,CAAC,CAAC;IACJ;IACA,IAAIjB,qBAAQ,CAACc,EAAE,KAAK,KAAK,EAAE;MACzB,MAAMI,uBAAuB,GAAG,IAAIC,+BAAkB,CAACf,gBAAgB,CAAC;MACxE,OAAOc,uBAAuB,CAACF,WAAW,CAAC,cAAc,EAAGC,IAAI,IAAK;QACnE,IAAIJ,QAAQ,EAAE;UACZA,QAAQ,CAACI,IAAI,CAAC;QAChB;MACF,CAAC,CAAC;IACJ;IACA,MAAMT,KAAK,CAAE,YAAWR,qBAAQ,CAACc,EAAG,gBAAe,CAAC;EACtD;EAEA,MAAMM,KAAKA,CACTC,UAAkB,EAClBC,UAAkB,EAClBC,OAAgB,EAChBC,cAA0C,EAClB;IACxB,OAAOpB,gBAAgB,CAACgB,KAAK,CAC3BC,UAAU,EACVC,UAAU,EACVC,OAAO,IAAI,IAAI,EACfC,cAAc,IAAI,IAAI,EACtB,IAAI,CAACC,iBAAiB,CAAC,CAAC,IAAI,IAC9B,CAAC;EACH;EAEQA,iBAAiBA,CAAA,EAAG;IAC1B,IAAI,CAAC,IAAI,CAACd,MAAM,EAAE;IAClB,OAAO;MACLe,WAAW,EAAE,IAAI,CAACf,MAAM,CAACe,WAAW;MACpCC,IAAI,EAAE,IAAI,CAAChB,MAAM,CAACgB,IAAI;MACtB,GAAG,IAAI,CAAChB,MAAM,CAACiB;IACjB,CAAC;EACH;AACF;AAACC,OAAA,CAAApB,KAAA,GAAAA,KAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Environment = void 0;
|
|
7
|
+
let Environment = exports.Environment = /*#__PURE__*/function (Environment) {
|
|
8
|
+
Environment["SANDBOX"] = "sandbox";
|
|
9
|
+
Environment["PRODUCTION"] = "production";
|
|
10
|
+
return Environment;
|
|
11
|
+
}({});
|
|
12
|
+
//# sourceMappingURL=environment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Environment","exports"],"sourceRoot":"../../../../src","sources":["types/enums/environment.ts"],"mappings":";;;;;;IAAYA,WAAW,GAAAC,OAAA,CAAAD,WAAA,0BAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAA,OAAXA,WAAW;AAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["types/interfaces/digio_config.ts"],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["types/interfaces/digio_response.ts"],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["types/interfaces/error.ts"],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["types/interfaces/gateway_event.ts"],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["types/interfaces/theme.ts"],"mappings":""}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { DeviceEventEmitter, NativeEventEmitter, NativeModules, Platform } from 'react-native';
|
|
2
|
+
export { Environment } from './types/enums/environment';
|
|
3
|
+
const LINKING_ERROR = `The package 'digio-react-native' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
|
|
4
|
+
ios: "- You have run 'pod install'\n",
|
|
5
|
+
default: ''
|
|
6
|
+
}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
|
|
7
|
+
const DigioReactNative = NativeModules.DigioReactNative ? NativeModules.DigioReactNative : new Proxy({}, {
|
|
8
|
+
get() {
|
|
9
|
+
throw new Error(LINKING_ERROR);
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
export class Digio {
|
|
13
|
+
constructor(config) {
|
|
14
|
+
this.config = config;
|
|
15
|
+
}
|
|
16
|
+
addGatewayEventListener(callback) {
|
|
17
|
+
if (Platform.OS === 'android') {
|
|
18
|
+
return DeviceEventEmitter.addListener('gatewayEvent', data => {
|
|
19
|
+
if (callback) {
|
|
20
|
+
callback(data);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
if (Platform.OS === 'ios') {
|
|
25
|
+
const digioReactNativeEmitter = new NativeEventEmitter(DigioReactNative);
|
|
26
|
+
return digioReactNativeEmitter.addListener('gatewayEvent', data => {
|
|
27
|
+
if (callback) {
|
|
28
|
+
callback(data);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
throw Error(`Platform ${Platform.OS} not supported`);
|
|
33
|
+
}
|
|
34
|
+
async start(documentId, identifier, tokenId, additionalData) {
|
|
35
|
+
return DigioReactNative.start(documentId, identifier, tokenId ?? null, additionalData ?? null, this.buildConfigParams() ?? null);
|
|
36
|
+
}
|
|
37
|
+
buildConfigParams() {
|
|
38
|
+
if (!this.config) return;
|
|
39
|
+
return {
|
|
40
|
+
environment: this.config.environment,
|
|
41
|
+
logo: this.config.logo,
|
|
42
|
+
...this.config.theme
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["DeviceEventEmitter","NativeEventEmitter","NativeModules","Platform","Environment","LINKING_ERROR","select","ios","default","DigioReactNative","Proxy","get","Error","Digio","constructor","config","addGatewayEventListener","callback","OS","addListener","data","digioReactNativeEmitter","start","documentId","identifier","tokenId","additionalData","buildConfigParams","environment","logo","theme"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA,SACEA,kBAAkB,EAClBC,kBAAkB,EAClBC,aAAa,EACbC,QAAQ,QACH,cAAc;AAMrB,SAASC,WAAW,QAAQ,2BAA2B;AAEvD,MAAMC,aAAa,GAChB,6EAA4E,GAC7EF,QAAQ,CAACG,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMC,gBAAgB,GAAGP,aAAa,CAACO,gBAAgB,GACnDP,aAAa,CAACO,gBAAgB,GAC9B,IAAIC,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACP,aAAa,CAAC;EAChC;AACF,CACF,CAAC;AAWL,OAAO,MAAMQ,KAAK,CAAC;EAGjBC,WAAWA,CAACC,MAAmB,EAAE;IAC/B,IAAI,CAACA,MAAM,GAAGA,MAAM;EACtB;EAEAC,uBAAuBA,CACrBC,QAAgC,EACX;IACrB,IAAId,QAAQ,CAACe,EAAE,KAAK,SAAS,EAAE;MAC7B,OAAOlB,kBAAkB,CAACmB,WAAW,CAAC,cAAc,EAAGC,IAAI,IAAK;QAC9D,IAAIH,QAAQ,EAAE;UACZA,QAAQ,CAACG,IAAI,CAAC;QAChB;MACF,CAAC,CAAC;IACJ;IACA,IAAIjB,QAAQ,CAACe,EAAE,KAAK,KAAK,EAAE;MACzB,MAAMG,uBAAuB,GAAG,IAAIpB,kBAAkB,CAACQ,gBAAgB,CAAC;MACxE,OAAOY,uBAAuB,CAACF,WAAW,CAAC,cAAc,EAAGC,IAAI,IAAK;QACnE,IAAIH,QAAQ,EAAE;UACZA,QAAQ,CAACG,IAAI,CAAC;QAChB;MACF,CAAC,CAAC;IACJ;IACA,MAAMR,KAAK,CAAE,YAAWT,QAAQ,CAACe,EAAG,gBAAe,CAAC;EACtD;EAEA,MAAMI,KAAKA,CACTC,UAAkB,EAClBC,UAAkB,EAClBC,OAAgB,EAChBC,cAA0C,EAClB;IACxB,OAAOjB,gBAAgB,CAACa,KAAK,CAC3BC,UAAU,EACVC,UAAU,EACVC,OAAO,IAAI,IAAI,EACfC,cAAc,IAAI,IAAI,EACtB,IAAI,CAACC,iBAAiB,CAAC,CAAC,IAAI,IAC9B,CAAC;EACH;EAEQA,iBAAiBA,CAAA,EAAG;IAC1B,IAAI,CAAC,IAAI,CAACZ,MAAM,EAAE;IAClB,OAAO;MACLa,WAAW,EAAE,IAAI,CAACb,MAAM,CAACa,WAAW;MACpCC,IAAI,EAAE,IAAI,CAACd,MAAM,CAACc,IAAI;MACtB,GAAG,IAAI,CAACd,MAAM,CAACe;IACjB,CAAC;EACH;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Environment"],"sourceRoot":"../../../../src","sources":["types/enums/environment.ts"],"mappings":"AAAA,WAAYA,WAAW,0BAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAA,OAAXA,WAAW;AAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["types/interfaces/digio_config.ts"],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["types/interfaces/digio_response.ts"],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["types/interfaces/error.ts"],"mappings":""}
|