@velocitycareerlabs/vcl-react-native 1.12.3 → 1.12.5

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.
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Created by Michael Avoyan on 08/08/2023.
3
+ *
4
+ * Copyright 2022 Velocity Career Labs inc.
5
+ * SPDX-License-Identifier: Apache-2.0
6
+ */
7
+
8
+ package io.velocitycareerlabs.reactnative
9
+
10
+ import io.velocitycareerlabs.api.VCLEnvironment
11
+
12
+ internal object GlobalConfig {
13
+
14
+ var CurrentEnvironment = VCLEnvironment.PROD
15
+
16
+ var IsDebugOn = false //BuildConfig.DEBUG
17
+
18
+ const val LogTagPrefix = "VCL RN Android "
19
+ val IsLoggerOn get() = CurrentEnvironment != VCLEnvironment.PROD || IsDebugOn
20
+ }
@@ -35,10 +35,12 @@ import io.velocitycareerlabs.reactnative.utlis.Converter.mapToVerifiedProfileDes
35
35
  import io.velocitycareerlabs.reactnative.utlis.Converter.verifiedProfileToMap
36
36
  import io.velocitycareerlabs.api.VCLProvider
37
37
  import io.velocitycareerlabs.api.entities.VCLError
38
+ import io.velocitycareerlabs.api.entities.VCLInitializationDescriptor
38
39
  import io.velocitycareerlabs.reactnative.extensions.toThrowable
39
40
  import io.velocitycareerlabs.reactnative.utlis.Converter.didJwkToMap
40
41
  import io.velocitycareerlabs.reactnative.utlis.Converter.mapToInitializationDescriptor
41
42
  import io.velocitycareerlabs.reactnative.utlis.Converter.mapToJwtDescriptor
43
+ import io.velocitycareerlabs.reactnative.utlis.VCLLog
42
44
  import java.lang.Exception
43
45
 
44
46
  /**
@@ -46,6 +48,8 @@ import java.lang.Exception
46
48
  */
47
49
  class VclReactNativeModule(private val reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {
48
50
 
51
+ val TAG = "VclReactNativeModule"
52
+
49
53
  companion object {
50
54
  const val ModuleName = "VclReactNative"
51
55
  }
@@ -56,17 +60,26 @@ class VclReactNativeModule(private val reactContext: ReactApplicationContext) :
56
60
  return ModuleName
57
61
  }
58
62
 
63
+ private fun initGlobalConfigurations(
64
+ initializationDescriptor: VCLInitializationDescriptor
65
+ ) {
66
+ GlobalConfig.CurrentEnvironment = initializationDescriptor.environment
67
+ GlobalConfig.IsDebugOn = initializationDescriptor.isDebugOn
68
+ }
69
+
59
70
  @ReactMethod
60
71
  fun initialize(
61
- initializationDescriptor: ReadableMap,
72
+ initializationDescriptorMap: ReadableMap,
62
73
  promise: Promise
63
74
  ) {
64
75
  try {
76
+ val initializationDescriptor = mapToInitializationDescriptor(
77
+ reactContext,
78
+ initializationDescriptorMap
79
+ )
80
+ initGlobalConfigurations(initializationDescriptor)
65
81
  vcl.initialize(
66
- initializationDescriptor = mapToInitializationDescriptor(
67
- reactContext,
68
- initializationDescriptor
69
- ),
82
+ initializationDescriptor = initializationDescriptor,
70
83
  successHandler = {
71
84
  promise.resolve("VCL initialization succeed!")
72
85
  },
@@ -189,7 +202,9 @@ class VclReactNativeModule(private val reactContext: ReactApplicationContext) :
189
202
  promise: Promise
190
203
  ) {
191
204
  try {
205
+ VCLLog.d(TAG, "credentialManifestDescriptorMap map: $credentialManifestDescriptorMap")
192
206
  mapToCredentialManifestDescriptor(credentialManifestDescriptorMap)?.let { credentialManifestDescriptor ->
207
+ VCLLog.d(TAG, "credentialManifestDescriptor VCL entity: ${credentialManifestDescriptor.toPropsString()}")
193
208
  vcl.getCredentialManifest(credentialManifestDescriptor,
194
209
  {
195
210
  promise.resolve(credentialManifestToMap(it))
@@ -14,9 +14,6 @@ import io.velocitycareerlabs.reactnative.extensions.*
14
14
  import org.json.JSONObject
15
15
  import java.lang.Exception
16
16
 
17
- /**
18
- * Created by Michael Avoyan on 04/07/2021.
19
- */
20
17
  object Converter {
21
18
 
22
19
  fun mapToInitializationDescriptor(
@@ -431,9 +428,9 @@ object Converter {
431
428
  fun mapToServiceCredentialAgentIssuer(
432
429
  serviceMap: ReadableMap?
433
430
  ): VCLServiceCredentialAgentIssuer {
434
- var payload = JSONObject("{}")
431
+ var payload = JSONObject()
435
432
  try {
436
- payload = JSONObject(serviceMap?.getMapOpt("payload").toString()).getJSONObject("NativeMap")
433
+ payload = serviceMap?.getMapOpt("payload")?.toJsonObject() ?: JSONObject()
437
434
  } catch (ex: Exception) {
438
435
  ex.printStackTrace()
439
436
  }
@@ -0,0 +1,128 @@
1
+ /**
2
+ * Created by Michael Avoyan on 08/08/2023.
3
+ *
4
+ * Copyright 2022 Velocity Career Labs inc.
5
+ * SPDX-License-Identifier: Apache-2.0
6
+ */
7
+
8
+ package io.velocitycareerlabs.reactnative.utlis
9
+
10
+ import android.util.Log
11
+ import io.velocitycareerlabs.reactnative.GlobalConfig
12
+
13
+ internal object VCLLog {
14
+ /**
15
+ * Send a [.VERBOSE] log message.
16
+ * @param tag Used to identify the source of a log message. It usually identifies
17
+ * the class or activity where the log call occurs.
18
+ * @param msg The message you would like logged.
19
+ */
20
+ fun v(tag: String?, msg: String): Int {
21
+ return if (GlobalConfig.IsLoggerOn) Log.v(GlobalConfig.LogTagPrefix +tag, msg) else -1
22
+ }
23
+
24
+ /**
25
+ * Send a [.VERBOSE] log message and log the exception.
26
+ * @param tag Used to identify the source of a log message. It usually identifies
27
+ * the class or activity where the log call occurs.
28
+ * @param msg The message you would like logged.
29
+ * @param tr An exception to log
30
+ */
31
+ fun v(tag: String?, msg: String?, tr: Throwable?): Int {
32
+ return if (GlobalConfig.IsLoggerOn) Log.v(GlobalConfig.LogTagPrefix +tag, msg, tr) else -1
33
+ }
34
+
35
+ /**
36
+ * Send a [.DEBUG] log message.
37
+ * @param tag Used to identify the source of a log message. It usually identifies
38
+ * the class or activity where the log call occurs.
39
+ * @param msg The message you would like logged.
40
+ */
41
+ fun d(tag: String?, msg: String): Int {
42
+ return if (GlobalConfig.IsLoggerOn) Log.d(GlobalConfig.LogTagPrefix +tag, msg) else -1
43
+ }
44
+
45
+ /**
46
+ * Send a [.DEBUG] log message and log the exception.
47
+ * @param tag Used to identify the source of a log message. It usually identifies
48
+ * the class or activity where the log call occurs.
49
+ * @param msg The message you would like logged.
50
+ * @param tr An exception to log
51
+ */
52
+ fun d(tag: String?, msg: String?, tr: Throwable?): Int {
53
+ return if (GlobalConfig.IsLoggerOn) Log.d(GlobalConfig.LogTagPrefix +tag, msg, tr) else -1
54
+ }
55
+
56
+ /**
57
+ * Send an [.INFO] log message.
58
+ * @param tag Used to identify the source of a log message. It usually identifies
59
+ * the class or activity where the log call occurs.
60
+ * @param msg The message you would like logged.
61
+ */
62
+ fun i(tag: String?, msg: String): Int {
63
+ return if (GlobalConfig.IsLoggerOn) Log.i(GlobalConfig.LogTagPrefix +tag, msg) else -1
64
+ }
65
+
66
+ /**
67
+ * Send a [.INFO] log message and log the exception.
68
+ * @param tag Used to identify the source of a log message. It usually identifies
69
+ * the class or activity where the log call occurs.
70
+ * @param msg The message you would like logged.
71
+ * @param tr An exception to log
72
+ */
73
+ fun i(tag: String?, msg: String?, tr: Throwable?): Int {
74
+ return if (GlobalConfig.IsLoggerOn) Log.i(GlobalConfig.LogTagPrefix +tag, msg, tr) else -1
75
+ }
76
+
77
+ /**
78
+ * Send a [.WARN] log message.
79
+ * @param tag Used to identify the source of a log message. It usually identifies
80
+ * the class or activity where the log call occurs.
81
+ * @param msg The message you would like logged.
82
+ */
83
+ fun w(tag: String?, msg: String): Int {
84
+ return if (GlobalConfig.IsLoggerOn) Log.w(GlobalConfig.LogTagPrefix +tag, msg) else -1
85
+ }
86
+
87
+ /**
88
+ * Send a [.WARN] log message and log the exception.
89
+ * @param tag Used to identify the source of a log message. It usually identifies
90
+ * the class or activity where the log call occurs.
91
+ * @param msg The message you would like logged.
92
+ * @param tr An exception to log
93
+ */
94
+ fun w(tag: String?, msg: String?, tr: Throwable?): Int {
95
+ return if (GlobalConfig.IsLoggerOn) Log.w(GlobalConfig.LogTagPrefix +tag, msg, tr) else -1
96
+ }
97
+
98
+ /*
99
+ * Send a {@link #WARN} log message and log the exception.
100
+ * @param tag Used to identify the source of a log message. It usually identifies
101
+ * the class or activity where the log call occurs.
102
+ * @param tr An exception to log
103
+ */
104
+ fun w(tag: String?, tr: Throwable?): Int {
105
+ return if (GlobalConfig.IsLoggerOn) Log.w(GlobalConfig.LogTagPrefix +tag, tr) else -1
106
+ }
107
+
108
+ /**
109
+ * Send an [.ERROR] log message.
110
+ * @param tag Used to identify the source of a log message. It usually identifies
111
+ * the class or activity where the log call occurs.
112
+ * @param msg The message you would like logged.
113
+ */
114
+ fun e(tag: String?, msg: String): Int {
115
+ return if (GlobalConfig.IsLoggerOn) Log.e(GlobalConfig.LogTagPrefix +tag, msg) else -1
116
+ }
117
+
118
+ /**
119
+ * Send a [.ERROR] log message and log the exception.
120
+ * @param tag Used to identify the source of a log message. It usually identifies
121
+ * the class or activity where the log call occurs.
122
+ * @param msg The message you would like logged.
123
+ * @param tr An exception to log
124
+ */
125
+ fun e(tag: String?, msg: String?, tr: Throwable?): Int {
126
+ return if (GlobalConfig.IsLoggerOn) Log.e(GlobalConfig.LogTagPrefix +tag, msg, tr) else -1
127
+ }
128
+ }
@@ -0,0 +1,42 @@
1
+ //
2
+ // VCLLog.swift
3
+ // vcl-react-native
4
+ //
5
+ // Created by Michael Avoyan on 08/08/2023.
6
+ //
7
+ // Copyright 2022 Velocity Career Labs inc.
8
+ // SPDX-License-Identifier: Apache-2.0
9
+
10
+ import Foundation
11
+
12
+ struct VCLLog {
13
+
14
+ enum LogLevel: String {
15
+ case error = "⛔️"
16
+ case warning = "⚠️"
17
+ case debug = "💬"
18
+ }
19
+ static func d(_ info: String, level: LogLevel = .debug, file: String = #file, function: String = #function, line: Int = #line) {
20
+ if GlobalConfig.IsLoggerOn {
21
+ print("\(level.rawValue), \((file as NSString).lastPathComponent), \(line), \(function), \(GlobalConfig.LogTagPrefix + info)")
22
+ }
23
+ }
24
+
25
+ static func w(_ warning: String, level: LogLevel = .warning, file: String = #file, function: String = #function, line: Int = #line) {
26
+ if GlobalConfig.IsLoggerOn {
27
+ print("\(level.rawValue), \((file as NSString).lastPathComponent), \(line), \(function), \(GlobalConfig.LogTagPrefix + warning)")
28
+ }
29
+ }
30
+
31
+ static func e(_ error: Error, level: LogLevel = .error, file: String = #file, function: String = #function, line: Int = #line) {
32
+ if GlobalConfig.IsLoggerOn {
33
+ VCLLog.e("\(error)", level: level, file: file, function: function, line: line)
34
+ }
35
+ }
36
+
37
+ static func e(_ error: String, level: LogLevel = .error, file: String = #file, function: String = #function, line: Int = #line) {
38
+ if GlobalConfig.IsLoggerOn {
39
+ print("\(level.rawValue), \((file as NSString).lastPathComponent), \(line), \(function), \(GlobalConfig.LogTagPrefix + error)")
40
+ }
41
+ }
42
+ }
@@ -11,13 +11,22 @@ class VclReactNative: NSObject {
11
11
 
12
12
  private let vcl = VCLProvider.vclInstance()
13
13
 
14
+ private func initGlobalConfigurations(
15
+ _ initializationDescriptor: VCLInitializationDescriptor
16
+ ) {
17
+ GlobalConfig.CurrentEnvironment = initializationDescriptor.environment
18
+ GlobalConfig.IsDebugOn = initializationDescriptor.isDebugOn
19
+ }
20
+
14
21
  @objc(initialize:withResolver:withRejecter:)
15
22
  func initialize(
16
23
  initializationDescriptorDictionary: [String: Any],
17
24
  resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock
18
25
  ) {
26
+ let initializationDescriptor = dictionaryToInitializationDescriptor(initializationDescriptorDictionary)
27
+ initGlobalConfigurations(initializationDescriptor)
19
28
  vcl.initialize(
20
- initializationDescriptor: dictionaryToInitializationDescriptor(initializationDescriptorDictionary),
29
+ initializationDescriptor: initializationDescriptor,
21
30
  successHandler: {
22
31
  resolve("VCL initialization succeed!")
23
32
  },
@@ -128,15 +137,17 @@ class VclReactNative: NSObject {
128
137
  credentialManifestDescriptorDictionary: [String: Any],
129
138
  resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock
130
139
  ) {
140
+ VCLLog.d("credentialManifestDescriptorDictionary: \(credentialManifestDescriptorDictionary)")
131
141
  if let credentialManifestDescriptor = dictionaryToCredentialManifestDescriptor(credentialManifestDescriptorDictionary) {
132
- vcl.getCredentialManifest(
133
- credentialManifestDescriptor: credentialManifestDescriptor,
134
- successHandler: {
135
- resolve(credentialManifestToDictionary($0))
136
- },
137
- errorHandler: {
138
- reject(nil, $0.toDictionary().toJsonString(), $0)
139
- })
142
+ VCLLog.d("credentialManifestDescriptor: \(credentialManifestDescriptor.toPropsString())")
143
+ vcl.getCredentialManifest(
144
+ credentialManifestDescriptor: credentialManifestDescriptor,
145
+ successHandler: {
146
+ resolve(credentialManifestToDictionary($0))
147
+ },
148
+ errorHandler: {
149
+ reject(nil, $0.toDictionary().toJsonString(), $0)
150
+ })
140
151
  } else {
141
152
  reject(nil, "Unexpected Credential Credential Manifest Descriptor: \(credentialManifestDescriptorDictionary)", nil)
142
153
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@velocitycareerlabs/vcl-react-native",
3
- "version": "1.12.3",
3
+ "version": "1.12.5",
4
4
  "description": "Velocity Career Labs React Native SDK",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
package/android/.DS_Store DELETED
Binary file
package/ios/.DS_Store DELETED
Binary file
package/src/.DS_Store DELETED
Binary file
package/src/api/.DS_Store DELETED
Binary file
Binary file