@circle-fin/w3s-pw-react-native-sdk 1.0.7 → 1.1.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/README.md +3 -3
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/circlefin/programmablewalletrnsdk/BridgeHelper.kt +8 -1
- package/android/src/main/java/com/circlefin/programmablewalletrnsdk/ProgrammablewalletRnSdkModule.kt +53 -21
- package/android/src/main/java/com/circlefin/programmablewalletrnsdk/PromiseCallback.kt +6 -7
- package/android/src/main/java/com/circlefin/programmablewalletrnsdk/PromiseCallback2.kt +65 -0
- package/android/src/main/java/com/circlefin/programmablewalletrnsdk/PromiseLogoutCallback.kt +47 -0
- package/android/src/main/java/com/circlefin/programmablewalletrnsdk/PromiseSocialCallback.kt +53 -0
- package/android/src/main/java/com/circlefin/programmablewalletrnsdk/annotation/ExcludeFromGeneratedCCReport.kt +33 -0
- package/android/src/main/java/com/circlefin/programmablewalletrnsdk/pwcustom/RnLayoutProvider.kt +3 -0
- package/android/src/oldarch/ProgrammablewalletRnSdkSpec.kt +16 -7
- package/circlefin-w3s-pw-react-native-sdk.podspec +1 -1
- package/ios/BridgeHelper.swift +1 -6
- package/ios/ProgrammablewalletRnSdk.mm +22 -7
- package/ios/RnWalletSdk+CustomizeAdapter.swift +176 -5
- package/ios/RnWalletSdk.swift +146 -81
- package/ios/TextKey.swift +137 -74
- package/ios/UIColor+Extension.swift +3 -3
- package/lib/commonjs/NativeProgrammablewalletRnSdk.js.map +1 -1
- package/lib/commonjs/WalletSdk.js +19 -7
- package/lib/commonjs/WalletSdk.js.map +1 -1
- package/lib/commonjs/types.js +61 -4
- package/lib/commonjs/types.js.map +1 -1
- package/lib/module/NativeProgrammablewalletRnSdk.js.map +1 -1
- package/lib/module/WalletSdk.js +19 -7
- package/lib/module/WalletSdk.js.map +1 -1
- package/lib/module/types.js +60 -3
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/src/NativeProgrammablewalletRnSdk.d.ts +3 -1
- package/lib/typescript/src/NativeProgrammablewalletRnSdk.d.ts.map +1 -1
- package/lib/typescript/src/WalletSdk.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +84 -8
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/NativeProgrammablewalletRnSdk.ts +16 -7
- package/src/WalletSdk.ts +36 -14
- package/src/types.ts +102 -13
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
|
|
|
15
15
|
Create a Personal Access Token in your [GitHub setting](https://github.com/settings/tokens). Use `Configure SSO` button next to your created token to authorize `circlefin` organization. More instruction can be found [here](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens). Then, log in to `npm` on your terminal.
|
|
16
16
|
|
|
17
17
|
```bash
|
|
18
|
-
npm login --scope=@OWNER --registry=https://
|
|
18
|
+
npm login --scope=@OWNER --registry=https://registry.npmjs.org
|
|
19
19
|
```
|
|
20
20
|
This will ask you to submit your GitHub personal access token as below.
|
|
21
21
|
Check below links for creating GitHub PAT:
|
|
@@ -23,7 +23,7 @@ Check below links for creating GitHub PAT:
|
|
|
23
23
|
- [Creating a personal access token (classic)](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-personal-access-token-classic)
|
|
24
24
|
|
|
25
25
|
```properties
|
|
26
|
-
npm notice Log in on https://
|
|
26
|
+
npm notice Log in on https://registry.npmjs.org/
|
|
27
27
|
Username: <insert your GitHub username here>
|
|
28
28
|
Password: <insert your GitHub personal access token here>
|
|
29
29
|
```
|
|
@@ -79,7 +79,7 @@ pwsdk.maven.password=<GITHUB_PAT>
|
|
|
79
79
|
Add below links at tne top of `ios/Podfile`:
|
|
80
80
|
```ruby
|
|
81
81
|
source 'https://github.com/circlefin/w3s-ios-sdk.git'
|
|
82
|
-
source 'https://
|
|
82
|
+
source 'https://github.com/CocoaPods/Specs.git'
|
|
83
83
|
|
|
84
84
|
platform :ios, '13.4'
|
|
85
85
|
```
|
package/android/build.gradle
CHANGED
|
@@ -126,7 +126,7 @@ dependencies {
|
|
|
126
126
|
//noinspection GradleDynamicVersion
|
|
127
127
|
implementation "com.facebook.react:react-native:+"
|
|
128
128
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
129
|
-
implementation "circle.programmablewallet:sdk:1.0.
|
|
129
|
+
implementation "circle.programmablewallet:sdk:1.0.1066"
|
|
130
130
|
implementation 'com.github.bumptech.glide:glide:4.14.2'
|
|
131
131
|
}
|
|
132
132
|
|
|
@@ -27,6 +27,7 @@ import circle.programmablewallet.sdk.presentation.Resource
|
|
|
27
27
|
import circle.programmablewallet.sdk.presentation.SecurityQuestion
|
|
28
28
|
import circle.programmablewallet.sdk.presentation.SettingsManagement
|
|
29
29
|
import circle.programmablewallet.sdk.presentation.TextConfig
|
|
30
|
+
import com.circlefin.programmablewalletrnsdk.annotation.ExcludeFromGeneratedCCReport
|
|
30
31
|
import com.circlefin.programmablewalletrnsdk.pwcustom.RnImageSetter
|
|
31
32
|
import com.facebook.react.bridge.Arguments
|
|
32
33
|
import com.facebook.react.bridge.ReadableArray
|
|
@@ -38,9 +39,12 @@ import java.lang.reflect.Modifier
|
|
|
38
39
|
object BridgeHelper {
|
|
39
40
|
private val TAG = BridgeHelper::class.java.simpleName
|
|
40
41
|
val typefaceMap: MutableMap<String?, Typeface?> = HashMap()
|
|
42
|
+
@ExcludeFromGeneratedCCReport
|
|
41
43
|
var questionsForTest: Array<SecurityQuestion?>? = null
|
|
44
|
+
@ExcludeFromGeneratedCCReport
|
|
42
45
|
var dismissOnCallbackForTest: MutableMap<Int, Boolean>? = null
|
|
43
46
|
|
|
47
|
+
@ExcludeFromGeneratedCCReport
|
|
44
48
|
fun objectToMap(obj: ExecuteWarning?): WritableMap {
|
|
45
49
|
val map = Arguments.createMap()
|
|
46
50
|
obj ?: return map
|
|
@@ -49,6 +53,7 @@ object BridgeHelper {
|
|
|
49
53
|
return map
|
|
50
54
|
}
|
|
51
55
|
|
|
56
|
+
@ExcludeFromGeneratedCCReport
|
|
52
57
|
fun objectToMap(obj: ApiError?): WritableMap {
|
|
53
58
|
val map = Arguments.createMap()
|
|
54
59
|
obj ?: return map
|
|
@@ -57,6 +62,7 @@ object BridgeHelper {
|
|
|
57
62
|
return map
|
|
58
63
|
}
|
|
59
64
|
|
|
65
|
+
@ExcludeFromGeneratedCCReport
|
|
60
66
|
@JvmStatic
|
|
61
67
|
fun objectToMap(obj: Any?): WritableMap {
|
|
62
68
|
val map = Arguments.createMap()
|
|
@@ -101,6 +107,7 @@ object BridgeHelper {
|
|
|
101
107
|
return map
|
|
102
108
|
}
|
|
103
109
|
|
|
110
|
+
@ExcludeFromGeneratedCCReport
|
|
104
111
|
private fun objectToArray(array: Any?): WritableArray {
|
|
105
112
|
val arr = Arguments.createArray()
|
|
106
113
|
array ?: return arr
|
|
@@ -204,7 +211,7 @@ object BridgeHelper {
|
|
|
204
211
|
fun getSettingsManagement(rnMap: ReadableMap?): SettingsManagement? {
|
|
205
212
|
rnMap ?: return null
|
|
206
213
|
val settingsMap = safeGetMap(rnMap, "settingsManagement") ?: return null
|
|
207
|
-
return SettingsManagement(safeGetBoolean(settingsMap, "enableBiometricsPin")
|
|
214
|
+
return SettingsManagement(safeGetBoolean(settingsMap, "enableBiometricsPin"))
|
|
208
215
|
}
|
|
209
216
|
|
|
210
217
|
private fun safeGetBoolean(map: ReadableMap, key: String): Boolean{
|
package/android/src/main/java/com/circlefin/programmablewalletrnsdk/ProgrammablewalletRnSdkModule.kt
CHANGED
|
@@ -19,13 +19,14 @@ import android.app.ActivityManager
|
|
|
19
19
|
import android.content.Context
|
|
20
20
|
import circle.programmablewallet.sdk.WalletSdk
|
|
21
21
|
import circle.programmablewallet.sdk.WalletSdk.execute
|
|
22
|
-
import circle.programmablewallet.sdk.WalletSdk.executeWithUserSecret
|
|
23
22
|
import circle.programmablewallet.sdk.WalletSdk.init
|
|
24
23
|
import circle.programmablewallet.sdk.WalletSdk.setLayoutProvider
|
|
25
24
|
import circle.programmablewallet.sdk.WalletSdk.setSecurityQuestions
|
|
26
25
|
import circle.programmablewallet.sdk.WalletSdk.setViewSetterProvider
|
|
27
26
|
import circle.programmablewallet.sdk.api.ExecuteEvent
|
|
27
|
+
import circle.programmablewallet.sdk.api.SocialProvider
|
|
28
28
|
import circle.programmablewallet.sdk.presentation.EventListener
|
|
29
|
+
import com.circlefin.programmablewalletrnsdk.annotation.ExcludeFromGeneratedCCReport
|
|
29
30
|
import com.circlefin.programmablewalletrnsdk.pwcustom.RnLayoutProvider
|
|
30
31
|
import com.circlefin.programmablewalletrnsdk.pwcustom.RnViewSetterProvider
|
|
31
32
|
import com.facebook.react.bridge.Arguments
|
|
@@ -51,6 +52,7 @@ class ProgrammablewalletRnSdkModule internal constructor(context: ReactApplicati
|
|
|
51
52
|
setViewSetterProvider(viewSetterProvider)
|
|
52
53
|
}
|
|
53
54
|
|
|
55
|
+
@ExcludeFromGeneratedCCReport
|
|
54
56
|
override fun getName(): String {
|
|
55
57
|
return NAME
|
|
56
58
|
}
|
|
@@ -103,9 +105,10 @@ class ProgrammablewalletRnSdkModule internal constructor(context: ReactApplicati
|
|
|
103
105
|
@ReactMethod
|
|
104
106
|
override fun setDismissOnCallbackMap(readableMap: ReadableMap) {
|
|
105
107
|
val map = BridgeHelper.getDismissOnCallbackMap(readableMap)
|
|
106
|
-
|
|
108
|
+
setDismissOnCallbackMap(map)
|
|
107
109
|
}
|
|
108
110
|
|
|
111
|
+
@ExcludeFromGeneratedCCReport
|
|
109
112
|
@ReactMethod
|
|
110
113
|
override fun moveRnTaskToFront() {
|
|
111
114
|
currentActivity?.let {
|
|
@@ -119,6 +122,7 @@ class ProgrammablewalletRnSdkModule internal constructor(context: ReactApplicati
|
|
|
119
122
|
}
|
|
120
123
|
}
|
|
121
124
|
|
|
125
|
+
@ExcludeFromGeneratedCCReport
|
|
122
126
|
@ReactMethod
|
|
123
127
|
override fun moveTaskToFront() {
|
|
124
128
|
WalletSdk.moveTaskToFront(reactContext)
|
|
@@ -177,50 +181,78 @@ class ProgrammablewalletRnSdkModule internal constructor(context: ReactApplicati
|
|
|
177
181
|
PromiseCallback(promise, reactContext)
|
|
178
182
|
)
|
|
179
183
|
}
|
|
180
|
-
|
|
184
|
+
@ExcludeFromGeneratedCCReport
|
|
181
185
|
@ReactMethod
|
|
182
|
-
override fun
|
|
186
|
+
override fun setBiometricsPin(
|
|
183
187
|
userToken: String?,
|
|
184
188
|
secretKey: String?,
|
|
185
|
-
userSecret: String?,
|
|
186
|
-
challengeIdArr: ReadableArray,
|
|
187
189
|
promise: Promise?
|
|
188
190
|
) {
|
|
189
|
-
|
|
190
|
-
for (i in challengeIds.indices) {
|
|
191
|
-
challengeIds[i] = challengeIdArr.getString(i)
|
|
192
|
-
}
|
|
193
|
-
executeWithUserSecret(
|
|
191
|
+
WalletSdk.setBiometricsPin(
|
|
194
192
|
currentActivity,
|
|
195
193
|
userToken,
|
|
196
194
|
secretKey,
|
|
197
|
-
userSecret,
|
|
198
|
-
challengeIds,
|
|
199
195
|
PromiseCallback(promise, reactContext)
|
|
200
196
|
)
|
|
201
197
|
}
|
|
202
198
|
|
|
203
199
|
@ReactMethod
|
|
204
|
-
override fun
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
200
|
+
override fun performLogin(
|
|
201
|
+
provider: String,
|
|
202
|
+
deviceToken: String,
|
|
203
|
+
deviceEncryptionKey: String,
|
|
204
|
+
promise: Promise
|
|
208
205
|
) {
|
|
209
|
-
WalletSdk.
|
|
206
|
+
WalletSdk.performLogin(
|
|
210
207
|
currentActivity,
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
208
|
+
SocialProvider.valueOf(provider),
|
|
209
|
+
deviceToken,
|
|
210
|
+
deviceEncryptionKey,
|
|
211
|
+
PromiseSocialCallback(promise)
|
|
212
|
+
)
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
@ReactMethod
|
|
216
|
+
override fun verifyOTP(
|
|
217
|
+
otpToken: String,
|
|
218
|
+
deviceToken: String,
|
|
219
|
+
deviceEncryptionKey: String,
|
|
220
|
+
promise: Promise
|
|
221
|
+
) {
|
|
222
|
+
WalletSdk.verifyOTP(
|
|
223
|
+
currentActivity,
|
|
224
|
+
otpToken,
|
|
225
|
+
deviceToken,
|
|
226
|
+
deviceEncryptionKey,
|
|
227
|
+
PromiseCallback2(promise, reactContext)
|
|
214
228
|
)
|
|
215
229
|
}
|
|
216
230
|
|
|
231
|
+
@ReactMethod
|
|
232
|
+
override fun performLogout(
|
|
233
|
+
provider: String,
|
|
234
|
+
promise: Promise
|
|
235
|
+
) {
|
|
236
|
+
|
|
237
|
+
WalletSdk.performLogout(
|
|
238
|
+
currentActivity,
|
|
239
|
+
SocialProvider.valueOf(provider),
|
|
240
|
+
PromiseLogoutCallback(promise)
|
|
241
|
+
)
|
|
242
|
+
}
|
|
217
243
|
companion object {
|
|
218
244
|
const val NAME = "ProgrammablewalletRnSdk"
|
|
219
245
|
const val EVENT_NAME_ON_EVENT = "CirclePwOnEvent"
|
|
220
246
|
const val EVENT_NAME_ON_SUCCESS = "CirclePwOnSuccess"
|
|
221
247
|
const val EVENT_NAME_ON_ERROR = "CirclePwOnError"
|
|
248
|
+
val dismissOnCallbackMap: MutableMap<Int, Boolean> = HashMap()
|
|
249
|
+
fun setDismissOnCallbackMap(map: Map<Int, Boolean>) {
|
|
250
|
+
dismissOnCallbackMap.clear()
|
|
251
|
+
dismissOnCallbackMap.putAll(map)
|
|
252
|
+
}
|
|
222
253
|
}
|
|
223
254
|
|
|
255
|
+
@ExcludeFromGeneratedCCReport
|
|
224
256
|
override fun onEvent(event: ExecuteEvent) {
|
|
225
257
|
reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
226
258
|
.emit(EVENT_NAME_ON_EVENT, event.name)
|
|
@@ -20,6 +20,7 @@ import circle.programmablewallet.sdk.api.ApiError
|
|
|
20
20
|
import circle.programmablewallet.sdk.api.Callback
|
|
21
21
|
import circle.programmablewallet.sdk.api.ExecuteWarning
|
|
22
22
|
import com.circlefin.programmablewalletrnsdk.BridgeHelper.objectToMap
|
|
23
|
+
import com.circlefin.programmablewalletrnsdk.annotation.ExcludeFromGeneratedCCReport
|
|
23
24
|
import com.facebook.react.bridge.Arguments
|
|
24
25
|
import com.facebook.react.bridge.Promise
|
|
25
26
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
@@ -30,10 +31,12 @@ class PromiseCallback<R> internal constructor(
|
|
|
30
31
|
private val context: ReactApplicationContext
|
|
31
32
|
) : Callback<R> {
|
|
32
33
|
private var result: R? = null
|
|
34
|
+
|
|
35
|
+
@ExcludeFromGeneratedCCReport
|
|
33
36
|
override fun onError(error: Throwable): Boolean {
|
|
34
37
|
Log.w(TAG, "onError: ", error)
|
|
35
38
|
if (error is ApiError) {
|
|
36
|
-
val isDismiss = java.lang.Boolean.TRUE == dismissOnCallbackMap[error.code.value]
|
|
39
|
+
val isDismiss = java.lang.Boolean.TRUE == ProgrammablewalletRnSdkModule.dismissOnCallbackMap[error.code.value]
|
|
37
40
|
if (isDismiss) {
|
|
38
41
|
promise?.reject(error.code.value.toString(), error.message, error)
|
|
39
42
|
} else {
|
|
@@ -57,8 +60,9 @@ class PromiseCallback<R> internal constructor(
|
|
|
57
60
|
promise.resolve(map)
|
|
58
61
|
}
|
|
59
62
|
|
|
63
|
+
@ExcludeFromGeneratedCCReport
|
|
60
64
|
override fun onWarning(warning: ExecuteWarning, result: R?): Boolean {
|
|
61
|
-
val isDismiss = java.lang.Boolean.TRUE == dismissOnCallbackMap[warning.warningType]
|
|
65
|
+
val isDismiss = java.lang.Boolean.TRUE == ProgrammablewalletRnSdkModule.dismissOnCallbackMap[warning.warningType]
|
|
62
66
|
val map = Arguments.createMap()
|
|
63
67
|
if (result == null) {
|
|
64
68
|
map.putMap("result", objectToMap(this.result))
|
|
@@ -80,10 +84,5 @@ class PromiseCallback<R> internal constructor(
|
|
|
80
84
|
|
|
81
85
|
companion object {
|
|
82
86
|
private val TAG = PromiseCallback::class.java.simpleName
|
|
83
|
-
val dismissOnCallbackMap: MutableMap<Int, Boolean> = HashMap()
|
|
84
|
-
fun setDismissOnCallbackMap(map: Map<Int, Boolean>) {
|
|
85
|
-
dismissOnCallbackMap.clear()
|
|
86
|
-
dismissOnCallbackMap.putAll(map)
|
|
87
|
-
}
|
|
88
87
|
}
|
|
89
88
|
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// Copyright (c) 2024, Circle Internet Financial, LTD. All rights reserved.
|
|
2
|
+
//
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
//
|
|
5
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
// you may not use this file except in compliance with the License.
|
|
7
|
+
// You may obtain a copy of the License at
|
|
8
|
+
//
|
|
9
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
//
|
|
11
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
// See the License for the specific language governing permissions and
|
|
15
|
+
// limitations under the License.
|
|
16
|
+
package com.circlefin.programmablewalletrnsdk
|
|
17
|
+
|
|
18
|
+
import android.util.Log
|
|
19
|
+
import circle.programmablewallet.sdk.api.ApiError
|
|
20
|
+
import circle.programmablewallet.sdk.api.Callback
|
|
21
|
+
import circle.programmablewallet.sdk.api.Callback2
|
|
22
|
+
import circle.programmablewallet.sdk.api.ExecuteWarning
|
|
23
|
+
import com.circlefin.programmablewalletrnsdk.BridgeHelper.objectToMap
|
|
24
|
+
import com.circlefin.programmablewalletrnsdk.annotation.ExcludeFromGeneratedCCReport
|
|
25
|
+
import com.facebook.react.bridge.Arguments
|
|
26
|
+
import com.facebook.react.bridge.Promise
|
|
27
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
28
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
29
|
+
|
|
30
|
+
class PromiseCallback2<R> internal constructor(
|
|
31
|
+
private val promise: Promise?,
|
|
32
|
+
private val context: ReactApplicationContext
|
|
33
|
+
) : Callback2<R> {
|
|
34
|
+
|
|
35
|
+
@ExcludeFromGeneratedCCReport
|
|
36
|
+
override fun onError(error: Throwable): Boolean {
|
|
37
|
+
Log.w(TAG, "onError: ", error)
|
|
38
|
+
if (error is ApiError) {
|
|
39
|
+
val isDismiss = java.lang.Boolean.TRUE == ProgrammablewalletRnSdkModule.dismissOnCallbackMap[error.code.value]
|
|
40
|
+
if (isDismiss) {
|
|
41
|
+
promise?.reject(error.code.value.toString(), error.message, error)
|
|
42
|
+
} else {
|
|
43
|
+
val map = objectToMap(error)
|
|
44
|
+
context.getJSModule(
|
|
45
|
+
DeviceEventManagerModule.RCTDeviceEventEmitter::class.java
|
|
46
|
+
)
|
|
47
|
+
.emit(ProgrammablewalletRnSdkModule.EVENT_NAME_ON_ERROR, map)
|
|
48
|
+
}
|
|
49
|
+
return !isDismiss
|
|
50
|
+
} else {
|
|
51
|
+
promise?.reject(RuntimeException(error.message))
|
|
52
|
+
}
|
|
53
|
+
return false
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
@ExcludeFromGeneratedCCReport
|
|
57
|
+
override fun onResult(result: R) {
|
|
58
|
+
promise ?: return
|
|
59
|
+
promise.resolve(objectToMap(result))
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
companion object {
|
|
63
|
+
private val TAG = PromiseCallback2::class.java.simpleName
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Copyright (c) 2024, Circle Internet Financial, LTD. All rights reserved.
|
|
2
|
+
//
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
//
|
|
5
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
// you may not use this file except in compliance with the License.
|
|
7
|
+
// You may obtain a copy of the License at
|
|
8
|
+
//
|
|
9
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
//
|
|
11
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
// See the License for the specific language governing permissions and
|
|
15
|
+
// limitations under the License.
|
|
16
|
+
package com.circlefin.programmablewalletrnsdk
|
|
17
|
+
|
|
18
|
+
import android.util.Log
|
|
19
|
+
import circle.programmablewallet.sdk.api.ApiError
|
|
20
|
+
import circle.programmablewallet.sdk.api.LogoutCallback
|
|
21
|
+
import com.circlefin.programmablewalletrnsdk.annotation.ExcludeFromGeneratedCCReport
|
|
22
|
+
import com.facebook.react.bridge.Promise
|
|
23
|
+
|
|
24
|
+
class PromiseLogoutCallback internal constructor(
|
|
25
|
+
private val promise: Promise?,
|
|
26
|
+
) : LogoutCallback {
|
|
27
|
+
|
|
28
|
+
@ExcludeFromGeneratedCCReport
|
|
29
|
+
override fun onError(error: Throwable) {
|
|
30
|
+
Log.w(TAG, "onError: ", error)
|
|
31
|
+
if (error is ApiError) {
|
|
32
|
+
promise?.reject(error.code.value.toString(), error.message, error)
|
|
33
|
+
} else {
|
|
34
|
+
promise?.reject(RuntimeException(error.message))
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
override fun onComplete() {
|
|
39
|
+
promise ?: return
|
|
40
|
+
promise.resolve(null)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
companion object {
|
|
45
|
+
private val TAG = PromiseLogoutCallback::class.java.simpleName
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// Copyright (c) 2024, Circle Internet Financial, LTD. All rights reserved.
|
|
2
|
+
//
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
//
|
|
5
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
// you may not use this file except in compliance with the License.
|
|
7
|
+
// You may obtain a copy of the License at
|
|
8
|
+
//
|
|
9
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
//
|
|
11
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
// See the License for the specific language governing permissions and
|
|
15
|
+
// limitations under the License.
|
|
16
|
+
package com.circlefin.programmablewalletrnsdk
|
|
17
|
+
|
|
18
|
+
import android.util.Log
|
|
19
|
+
import circle.programmablewallet.sdk.api.ApiError
|
|
20
|
+
import circle.programmablewallet.sdk.api.Callback
|
|
21
|
+
import circle.programmablewallet.sdk.api.ExecuteWarning
|
|
22
|
+
import circle.programmablewallet.sdk.api.SocialCallback
|
|
23
|
+
import com.circlefin.programmablewalletrnsdk.BridgeHelper.objectToMap
|
|
24
|
+
import com.circlefin.programmablewalletrnsdk.annotation.ExcludeFromGeneratedCCReport
|
|
25
|
+
import com.facebook.react.bridge.Arguments
|
|
26
|
+
import com.facebook.react.bridge.Promise
|
|
27
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
28
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
29
|
+
|
|
30
|
+
class PromiseSocialCallback<R> internal constructor(
|
|
31
|
+
private val promise: Promise?,
|
|
32
|
+
) : SocialCallback<R> {
|
|
33
|
+
|
|
34
|
+
@ExcludeFromGeneratedCCReport
|
|
35
|
+
override fun onError(error: Throwable) {
|
|
36
|
+
Log.w(TAG, "onError: ", error)
|
|
37
|
+
if (error is ApiError) {
|
|
38
|
+
promise?.reject(error.code.value.toString(), error.message, error)
|
|
39
|
+
} else {
|
|
40
|
+
promise?.reject(RuntimeException(error.message))
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
override fun onResult(result: R) {
|
|
45
|
+
promise ?: return
|
|
46
|
+
promise.resolve(objectToMap(result))
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
companion object {
|
|
51
|
+
private val TAG = PromiseSocialCallback::class.java.simpleName
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Copyright (c) 2024, Circle Internet Financial, LTD. All rights reserved.
|
|
2
|
+
//
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
//
|
|
5
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
// you may not use this file except in compliance with the License.
|
|
7
|
+
// You may obtain a copy of the License at
|
|
8
|
+
//
|
|
9
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
//
|
|
11
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
// See the License for the specific language governing permissions and
|
|
15
|
+
// limitations under the License.
|
|
16
|
+
package com.circlefin.programmablewalletrnsdk.annotation
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @suppress
|
|
20
|
+
*/
|
|
21
|
+
@MustBeDocumented
|
|
22
|
+
@Retention(AnnotationRetention.RUNTIME)
|
|
23
|
+
@Target(
|
|
24
|
+
AnnotationTarget.ANNOTATION_CLASS,
|
|
25
|
+
AnnotationTarget.CLASS,
|
|
26
|
+
AnnotationTarget.FIELD,
|
|
27
|
+
AnnotationTarget.FUNCTION,
|
|
28
|
+
AnnotationTarget.PROPERTY_GETTER,
|
|
29
|
+
AnnotationTarget.PROPERTY_SETTER,
|
|
30
|
+
AnnotationTarget.CONSTRUCTOR,
|
|
31
|
+
AnnotationTarget.LOCAL_VARIABLE, AnnotationTarget.PROPERTY
|
|
32
|
+
)
|
|
33
|
+
internal annotation class ExcludeFromGeneratedCCReport
|
package/android/src/main/java/com/circlefin/programmablewalletrnsdk/pwcustom/RnLayoutProvider.kt
CHANGED
|
@@ -20,6 +20,7 @@ import circle.programmablewallet.sdk.presentation.IconTextConfig
|
|
|
20
20
|
import circle.programmablewallet.sdk.presentation.LayoutProvider
|
|
21
21
|
import circle.programmablewallet.sdk.presentation.Resource
|
|
22
22
|
import circle.programmablewallet.sdk.presentation.TextConfig
|
|
23
|
+
import com.circlefin.programmablewalletrnsdk.annotation.ExcludeFromGeneratedCCReport
|
|
23
24
|
import java.util.Locale
|
|
24
25
|
|
|
25
26
|
object RnLayoutProvider : LayoutProvider() {
|
|
@@ -27,7 +28,9 @@ object RnLayoutProvider : LayoutProvider() {
|
|
|
27
28
|
val textConfigMap: MutableMap<String, TextConfig> = HashMap()
|
|
28
29
|
val iconTextsMap: MutableMap<Resource.IconTextsKey, Array<IconTextConfig?>> = HashMap()
|
|
29
30
|
val errorStringMap: MutableMap<Int, String> = HashMap()
|
|
31
|
+
@ExcludeFromGeneratedCCReport
|
|
30
32
|
var _dateFormat: String? = null
|
|
33
|
+
@ExcludeFromGeneratedCCReport
|
|
31
34
|
var _debugging = true
|
|
32
35
|
fun setTextConfigsMap(textConfigsMap: Map<String, Array<TextConfig?>>) {
|
|
33
36
|
this.textConfigsMap.clear()
|
|
@@ -34,18 +34,27 @@ abstract class ProgrammablewalletRnSdkSpec internal constructor(val context: Rea
|
|
|
34
34
|
challengeIdArr: ReadableArray,
|
|
35
35
|
promise: Promise?
|
|
36
36
|
)
|
|
37
|
-
abstract fun executeWithUserSecret(
|
|
38
|
-
userToken: String?,
|
|
39
|
-
secretKey: String?,
|
|
40
|
-
userSecret: String?,
|
|
41
|
-
challengeIdArr: ReadableArray,
|
|
42
|
-
promise: Promise?
|
|
43
|
-
)
|
|
44
37
|
abstract fun setBiometricsPin(
|
|
45
38
|
userToken: String?,
|
|
46
39
|
secretKey: String?,
|
|
47
40
|
promise: Promise?
|
|
48
41
|
)
|
|
42
|
+
abstract fun performLogin(
|
|
43
|
+
provider: String,
|
|
44
|
+
deviceToken: String,
|
|
45
|
+
deviceEncryptionKey: String,
|
|
46
|
+
promise: Promise
|
|
47
|
+
)
|
|
48
|
+
abstract fun verifyOTP(
|
|
49
|
+
otpToken: String,
|
|
50
|
+
deviceToken: String,
|
|
51
|
+
deviceEncryptionKey: String,
|
|
52
|
+
promise: Promise
|
|
53
|
+
)
|
|
54
|
+
abstract fun performLogout(
|
|
55
|
+
provider: String,
|
|
56
|
+
promise: Promise
|
|
57
|
+
)
|
|
49
58
|
|
|
50
59
|
abstract fun setDismissOnCallbackMap(readableMap: ReadableMap)
|
|
51
60
|
abstract fun moveTaskToFront()
|
|
@@ -15,7 +15,7 @@ Pod::Spec.new do |s|
|
|
|
15
15
|
s.source = { :git => package["repository"], :tag => "#{s.version}" }
|
|
16
16
|
|
|
17
17
|
s.source_files = "ios/**/*.{h,m,mm,swift}"
|
|
18
|
-
s.dependency '
|
|
18
|
+
s.dependency 'CircleProgrammableWalletSDK_static', '1.1.8'
|
|
19
19
|
|
|
20
20
|
# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
|
|
21
21
|
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
|
package/ios/BridgeHelper.swift
CHANGED
|
@@ -71,12 +71,7 @@ class BridgeHelper: NSObject {
|
|
|
71
71
|
} else {
|
|
72
72
|
var url = URL(string: image)
|
|
73
73
|
if let url = url {
|
|
74
|
-
|
|
75
|
-
items.append(SecurityConfirmItem(image: UIImage.init(contentsOfFile: url.path()), text: text))
|
|
76
|
-
} else {
|
|
77
|
-
// TODO
|
|
78
|
-
items.append(SecurityConfirmItem(text: text))
|
|
79
|
-
}
|
|
74
|
+
items.append(SecurityConfirmItem(image: UIImage(contentsOfFile: url.path), text: text))
|
|
80
75
|
}
|
|
81
76
|
}
|
|
82
77
|
} else{
|
|
@@ -41,22 +41,37 @@ RCT_EXPORT_METHOD(execute:(NSString *)userToken
|
|
|
41
41
|
[sdk execute:userToken encryptionKey:encryptionKey challengeIds:challengeIds resolve:resolve reject:reject];
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
RCT_EXPORT_METHOD(
|
|
44
|
+
RCT_EXPORT_METHOD(setBiometricsPin:(NSString *)userToken
|
|
45
45
|
encryptionKey:(NSString *)encryptionKey
|
|
46
|
-
userSecret:(NSString *)userSecret
|
|
47
|
-
challengeIds:(NSArray *)challengeIds
|
|
48
46
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
49
47
|
reject:(RCTPromiseRejectBlock)reject)
|
|
50
48
|
{
|
|
51
|
-
[sdk
|
|
49
|
+
[sdk setBiometricsPin:userToken encryptionKey:encryptionKey resolve:resolve reject:reject];
|
|
52
50
|
}
|
|
53
51
|
|
|
54
|
-
RCT_EXPORT_METHOD(
|
|
55
|
-
|
|
52
|
+
RCT_EXPORT_METHOD(performLogin:(NSString *)provider
|
|
53
|
+
deviceToken:(NSString *)deviceToken
|
|
54
|
+
deviceEncryptionKey:(NSString *)deviceEncryptionKey
|
|
56
55
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
57
56
|
reject:(RCTPromiseRejectBlock)reject)
|
|
58
57
|
{
|
|
59
|
-
[sdk
|
|
58
|
+
[sdk performLoginWithProvider:provider deviceToken:deviceToken encryptionKey:deviceEncryptionKey resolve:resolve reject:reject];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
RCT_EXPORT_METHOD(verifyOTP:(NSString *)otpToken
|
|
62
|
+
deviceToken:(NSString *)deviceToken
|
|
63
|
+
deviceEncryptionKey:(NSString *)deviceEncryptionKey
|
|
64
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
65
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
66
|
+
{
|
|
67
|
+
[sdk verifyOTPWithDeviceToken:deviceToken encryptionKey:deviceEncryptionKey otpToken:otpToken resolve:resolve reject:reject];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
RCT_EXPORT_METHOD(performLogout:(NSString *)provider
|
|
71
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
72
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
73
|
+
{
|
|
74
|
+
[sdk performLogoutWithProvider:provider resolve:resolve reject:reject];
|
|
60
75
|
}
|
|
61
76
|
|
|
62
77
|
RCT_EXPORT_METHOD(setDismissOnCallbackMap:(NSDictionary *)map)
|